當前位置:首頁 » 編程語言 » c語言工具

c語言工具

發布時間: 2022-02-04 10:10:57

c語言軟體

這段代碼,樓主可一試

#include <windows.h>
#include <time.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys/types.h>
#include <GL/glaux.h>

#define M_PI 3.14159265f

#define sinf(x) (float)sin((x))
#define cosf(x) (float)cos((x))
#define XSIZE 100
#define YSIZE 75

#define RINGS 5
#define BLUERING 0
#define BLACKRING 1
#define REDRING 2
#define YELLOWRING 3
#define GREENRING 4

#define BACKGROUND 8

enum {
BLACK = 0,
RED,
GREEN,
YELLOW,
BLUE,
MAGENTA,
CYAN,
WHITE
};

typedef short Point[2];

GLenum directRender;

unsigned char rgb_colors[RINGS][3];
int mapped_colors[RINGS];
float dests[RINGS][3];
float offsets[RINGS][3];
float angs[RINGS];
float rotAxis[RINGS][3];
int iters[RINGS];
GLuint theTorus;

void FillTorus(float rc, int numc, float rt, int numt)
{
int i, j, k;
float s, t;
float x, y, z;
float pi, twopi;

pi = M_PI;
twopi = 2 * pi;

for (i = 0; i < numc; i++) {
glBegin(GL_QUAD_STRIP);
for (j = 0; j <= numt; j++) {
for (k = 1; k >= 0; k--) {
s = (float)((i + k) % numc + 0.5f);
t = (float)(j % numt);

x = cosf(t * twopi / numt) * cosf(s * twopi / numc);
y = sinf(t * twopi / numt) * cosf(s * twopi / numc);
z = sinf(s * twopi / numc);
glNormal3f(x, y, z);

x = (rt + rc * cosf(s * twopi / numc)) * cosf(t * twopi / numt);
y = (rt + rc * cosf(s * twopi / numc)) * sinf(t * twopi / numt);
z = rc * sinf(s * twopi / numc);
glVertex3f(x, y, z);
}
}
glEnd();
}
}

float Clamp(int iters_left, float t)
{

if (iters_left < 3) {
return 0.0;
}
return (iters_left - 2) * t / iters_left;
}

void CALLBACK DrawScene(void)
{
int i;

glPushMatrix();

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);

for (i = 0; i < RINGS; i++) {
glColor3ubv(rgb_colors[i]);
glPushMatrix();
glTranslatef(dests[i][0] + offsets[i][0],
dests[i][1] + offsets[i][1],
dests[i][2] + offsets[i][2]);
glRotatef(angs[i], rotAxis[i][0], rotAxis[i][1], rotAxis[i][2]);
glCallList(theTorus);
glPopMatrix();
}
glPopMatrix();
auxSwapBuffers();
}

void CALLBACK Idle(void)
{
int i, j;
int more = GL_FALSE;
for (i = 0; i < RINGS; i++) {
if (iters[i]) {
for (j = 0; j < 3; j++) {
offsets[i][j] = Clamp(iters[i], offsets[i][j]);
}
angs[i] = Clamp(iters[i], angs[i]);
iters[i]--;
more = GL_TRUE;
}
}
if(more) {
DrawScene();
} else {
auxIdleFunc(NULL);
}
}

float MyRand(void)
{
return 10.0f * ( ((float) rand())/((float) RAND_MAX) - 0.5f);
}

void ReInit(void)
{
int i;
float deviation;

deviation = MyRand() / 2.0f;
deviation = deviation * deviation;
for (i = 0; i < RINGS; i++) {
offsets[i][0] = MyRand();
offsets[i][1] = MyRand();
offsets[i][2] = MyRand();
angs[i] = 260.0f * MyRand();
rotAxis[i][0] = MyRand();
rotAxis[i][1] = MyRand();
rotAxis[i][2] = MyRand();
iters[i] = (int)(deviation * MyRand() + 60);
}
}

void Init(void)
{
int i;
float top_y = 1.0f;
float bottom_y = 0.0f;
float top_z = 0.15f;
float bottom_z = 0.69f;
float spacing = 2.5f;
static float lmodel_ambient[] = {0.0f, 0.0f, 0.0f, 0.0f};
static float lmodel_twoside[] = {GL_FALSE};
static float lmodel_local[] = {GL_FALSE};
static float light0_ambient[] = {0.1f, 0.1f, 0.1f, 1.0f};
static float light0_diffuse[] = {1.0f, 1.0f, 1.0f, 0.0f};
static float light0_position[] = {0.8660254f, 0.5f, 1.0f, 0.0f};
static float light0_specular[] = {1.0f, 1.0f, 1.0f, 0.0f};
static float bevel_mat_ambient[] = {0.0f, 0.0f, 0.0f, 1.0f};
static float bevel_mat_shininess[] = {40.0f};
static float bevel_mat_specular[] = {1.0f, 1.0f, 1.0f, 0.0f};
static float bevel_mat_diffuse[] = {1.0f, 0.0f, 0.0f, 0.0f};

srand(time(NULL));
ReInit();
for (i = 0; i < RINGS; i++) {
rgb_colors[i][0] = rgb_colors[i][1] = rgb_colors[i][2] = 0;
}
rgb_colors[BLUERING][2] = 255;
rgb_colors[REDRING][0] = 255;
rgb_colors[GREENRING][1] = 255;
rgb_colors[YELLOWRING][0] = 255;
rgb_colors[YELLOWRING][1] = 255;
mapped_colors[BLUERING] = BLUE;
mapped_colors[REDRING] = RED;
mapped_colors[GREENRING] = GREEN;
mapped_colors[YELLOWRING] = YELLOW;
mapped_colors[BLACKRING] = BLACK;

dests[BLUERING][0] = -spacing;
dests[BLUERING][1] = top_y;
dests[BLUERING][2] = top_z;

dests[BLACKRING][0] = 0.0;
dests[BLACKRING][1] = top_y;
dests[BLACKRING][2] = top_z;

dests[REDRING][0] = spacing;
dests[REDRING][1] = top_y;
dests[REDRING][2] = top_z;

dests[YELLOWRING][0] = -spacing / 2.0f;
dests[YELLOWRING][1] = bottom_y;
dests[YELLOWRING][2] = bottom_z;

dests[GREENRING][0] = spacing / 2.0f;
dests[GREENRING][1] = bottom_y;
dests[GREENRING][2] = bottom_z;

theTorus = glGenLists(1);
glNewList(theTorus, GL_COMPILE);
FillTorus(0.1f, 8, 1.0f, 25);
glEndList();

glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glClearDepth(1.0);

glClearColor(0.5, 0.5, 0.5, 0.0);
glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
glEnable(GL_LIGHT0);

glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local);
glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
glEnable(GL_LIGHTING);

glMaterialfv(GL_FRONT, GL_AMBIENT, bevel_mat_ambient);
glMaterialfv(GL_FRONT, GL_SHININESS, bevel_mat_shininess);
glMaterialfv(GL_FRONT, GL_SPECULAR, bevel_mat_specular);
glMaterialfv(GL_FRONT, GL_DIFFUSE, bevel_mat_diffuse);

glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glShadeModel(GL_SMOOTH);

glMatrixMode(GL_PROJECTION);
gluPerspective(45, 1.33, 0.1, 100.0);
glMatrixMode(GL_MODELVIEW);
}

void CALLBACK Reshape(int width, int height)
{
glViewport(0, 0, width, height);
}

void main(int argc, char **argv)
{
auxInitPosition(0, 0, 400, 300);
auxInitDisplayMode(AUX_RGB|AUX_DOUBLE);
auxInitWindow("Olympic");
Init();
auxReshapeFunc(Reshape);
auxIdleFunc(Idle);
auxMainLoop(DrawScene);
}

㈡ 編寫c語言的工具用什麼

可以用C編寫也可以用別的語言編寫。我在解釋下吧,```看樣子我沒解釋的詳細。最原始的C語言編譯器估計是用匯編語言寫的,而匯編器估計是用機器碼強寫的,而機器碼的規則是設計CPU架構的人規定的。而所有的理論基礎,你就帶仔細查看50,60年代的大牛了,圖靈,馮諾依曼,knuth……之類的人給出理論上的證明和可行性,編譯器的設計在knuth給出了LR(K)演算法後才開始有了質的飛躍。而現在的編譯器實現的就簡單了,你可以用C語言在寫一個C編譯器,來編譯C程序,也可以寫C++編譯器來編譯C++,假如你是用C寫C編譯器,那麼這種貌似叫交叉編譯`~~,大概就這樣了。樓主真的想了解透徹自己去寫個編譯器就知道是怎麼回事了

㈢ C語言編寫程序一般用什麼工具

在DOS下可使用Turbo C 2.0即可。
下載地址:http://www.onlinedown.net/soft/5515.htm

㈣ c語言運行工具

你要下載運行C的軟體,turobo c++ 3.0 ,vc++等都可以。turbo c++入門比較容易。

㈤ c語言用什麼工具好

我們老師推薦Dev c++

㈥ c語言用什麼軟體編寫

可以編寫c語言的軟體有:Vim、C++編譯器、Dev-C++、Code::Blocks、Visual Studio等。

1、Vim

Vim是一個類似於Vi的著名的功能強大、高度可定製的文本編輯器,在Vi的基礎上改進和增加了很多特性。VIM是自由軟體。Vim普遍被推崇為類Vi編輯器中最好的一個,事實上真正的勁敵來自Emacs的不同變體。

1999 年Emacs被選為Linuxworld文本編輯分類的優勝者,Vim屈居第二。但在2000年2月Vim贏得了Slashdot Beanie的最佳開放源代碼文本編輯器大獎,又將Emacs推至二線, 總的來看, Vim和Emacs在文本編輯方面都是非常優秀的。

㈦ C語言軟體

給我你的郵箱我可以發給你。
如果你是初學者的話可以去玩一下CFree,在如鵬網的官網有,還可以使用以下VC++6.0/9.0或者是DEV C++這些軟體你去電驢網下載有破解版。www.verycd.com

㈧ 學習C語言需要什麼工具

一本參考書,然後加上msdn,參考書推薦譚浩強的C程序設計。

㈨ C語言用什麼編程工具好

VC++6.0的確很好.可以在WINDOWS下文本編輯,用起來順手很多.
但是,要注意一個問題,使用它的時候,要關掉卡巴,否則,會在鏈接的時候停下來,沒有響應.

熱點內容
易語言製作軟體源碼 發布:2025-01-09 15:03:27 瀏覽:259
scratch少兒編程是 發布:2025-01-09 15:01:34 瀏覽:711
javamd564加密 發布:2025-01-09 14:58:57 瀏覽:143
javaifint 發布:2025-01-09 14:57:32 瀏覽:487
怎麼配好電腦配置 發布:2025-01-09 14:46:31 瀏覽:835
土豆音頻上傳 發布:2025-01-09 14:45:49 瀏覽:991
貓追蝴蝶編程 發布:2025-01-09 14:30:05 瀏覽:355
花生視頻腳本 發布:2025-01-09 13:43:38 瀏覽:839
鎖相環c語言 發布:2025-01-09 13:43:37 瀏覽:969
e語言盜號源碼 發布:2025-01-09 13:35:25 瀏覽:830