why doesn't this work?
it dont rotate or change color!
[pascal]//OPEN-GL TEMPLATE///////
//DUCK ENTERPRISES 2005//
//COLIN DRAKE////////////
Program Tutor02;
Uses GL, GLUT;
////////////////////////////////////////////////////////////////////////////////declaration of constants and variables
var rtri:Extended;
var myvar1:Extended;
var new_t:integer;
var done:integer;
////////////////////////////////////////////////////////////////////////////////program initialization
////////////////////////////////////////////////////////////////////////////////misc
////////////////////////////////////////////////////////////////////////////////list creation
////////////////////////////////////////////////////////////////////////////////drawing
//
//
//callback
Procedure reshape(width, height : LongInt); stdcall;
Var aspect : glFloat;
Begin
aspect := width/height;
//setup new projection matrix which depends on window size
glMatrixMode(GL_PROJECTION); //switch to projection-matrix
glLoadIdentity; //setup standard matrix
glFrustum(-1.0*aspect,1.0*aspect,1.0,-1.0,1.0,20.0); //setup viewing matrix
glMatrixMode(GL_MODELVIEW); //switch back to the modelview-matrix
glLoadIdentity; //setup standard matrix
End;
////////////////////////////////////////////////////////////////////////////////CREATE EVERYTHING
Procedure draw; stdcall;
Begin
if new_t=0 then
begin
myvar1:=1.0;
new_t:=1;
end;
//Reminder: To Create Tris, glB Flag is: GL_TRIANGLES
//Reminder: To Create Quads, glB Flag is: GL_QUADS
//clear the color buffer
glClear(GL_COLOR_BUFFER_BIT); //clear the screen or window
myvar1:=myvar1-0.01;
rtri:=rtri+1;
glRotatef(rtri,1.0,1.0,1.0);
//do some drawing
glBegin(GL_TRIANGLES); //draw something with 4 vertexes
glColor3f(myvar1,0.0,0.0); //color
glVertex3f(-0.8, -0.5, -2.0); //first vertex
glColor3f(0.0,0.0,myvar1); //color
glVertex3f(-0.0, 0.5, -2.0); //second vertex
glColor3f(0.0,myvar1,0.0); //color
glVertex3f( 0.8, -0.5, -2.0); //third vertex
glEnd; //thats 3 vertexes, so it draws it!!
glFlush; //tell OpenGL to flush internal buffers
//glSwapBuffers; //we actually don't use the double-buffer
End;
////////////////////////////////////////////////////////////////////////////////START UP CODE
Begin
myvar1:=1.0;
//OpenGL and GLUT initialization
glutInit(@argc, argv);
glShadeModel(GL_SMOOTH);
glutCreateWindow('My First OpenGL Application');
//callback registration
glutDisplayFunc(@draw);
glutReshapeFunc(@reshape);
////////////////////////////////////////////////////////////////////////////////MAIN LOOP
while done=0 do
begin
glutMainLoop; //<<Render...
glutDisplayFunc(@draw);
glutReshapeFunc(@reshape);
end;
End.
[/pascal]
Bookmarks