Archived

This topic is now archived and is closed to further replies.

nildo

Slow ?¿?¿?

Recommended Posts

First of all i want to know some thing: Witch is fastier and better: Create a list and call with glCallList, draw the vertex all the time or what ?? Second question: I did two glLists. One make a cube and other a sphere. If i only call the glCallList() of the cube or of the sphere it go fast. But if i call the Cube and the Sphere, it become mutch mutch mutch more slower. Why ? Heres my code: // --------------------------------------------------- procedure make_sphere; var slices, stacks: GLInt; quadObj:GLUquadricObj; begin quadObj := gluNewQuadric(); slices := 100; stacks := 100; glNewList(SPHERE, GL_COMPILE); glColor3f(1.0, 0.0, 1.0); gluSphere(quadObj, 0.5, slices, stacks); glEndList(); end; procedure make_cube; begin glNewList(CUBE, GL_COMPILE); glColor3f(0.2,0.3, 0.4); glBegin(GL_QUAD_STRIP); glNormal3d(0.0, 0.0, -1.0); glVertex3d(2.5, 2.5, -2.5); glVertex3d(2.5, -2.5, -2.5); glVertex3d(-2.5, 2.5, -2.5); glVertex3d(-2.5, -2.5, -2.5); glNormal3d(-1.0, 0.0, 0.0); glVertex3d(-2.5, 2.5, 2.5); glVertex3d(-2.5, -2.5, 2.5); glNormal3d(0.0, 0.0, 1.0); glVertex3d(2.5, 2.5, 2.5); glVertex3d(2.5, -2.5, 2.5); glNormal3d(1.0, 0.0, 0.0); glVertex3d(2.5, 2.5, -2.5); glVertex3d(2.5, -2.5, -2.5); glEnd(); glBegin(GL_QUADS); glNormal3d(0.0, 1.0, 0.0); glVertex3d(-2.5, -2.5, -2.5); glVertex3d(2.5, -2.5, -2.5); glVertex3d(2.5, -2.5, 2.5); glVertex3d(-2.5, -2.5, 2.5); glNormal3d(0.0, 1.0, 0.0); glVertex3d(-2.5, 2.5, -2.5); glVertex3d(2.5, 2.5, -2.5); glVertex3d(2.5, 2.5, 2.5); glVertex3d(-2.5, 2.5, 2.5); glEnd(); glEndList(); end; function InitGL:bool; // All Setup For OpenGL Goes Here begin make_sphere; make_cube; i := 0; glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading glClearColor(0.0, 0.0, 0.0, 0.5); // Black Background glClearDepth(1.0); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LESS); // The Type Of Depth Test To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);//Realy Nice perspective calculations end; function DrawGLScene():bool; // Here''s Where We Do All The Drawing const especular: array[0..3] of glFloat = (1, 1, 1, 1); difusa: array[0..3] of glFloat = (1, 1, 1, 1); ambiente: array[0..3] of glFloat = (1, 1, 1, 1); position: array[0..3] of glFloat = (0, 3, 1, 0); position2: array[0..3] of glFloat = (1, -2, 1, 0); begin glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_COLOR_MATERIAL); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, @especular); glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 120.0); glLightfv (GL_LIGHT0, GL_SPECULAR, @especular); glLightfv (GL_LIGHT0, GL_POSITION, @position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glTranslatef(0.0,0.0,-20.0); glRotatef(i, 1.0, 0.0, 0.0); glRotatef(i, 0.0, 1.0, 0.0); glRotatef(i, 0.0, 0.0, 1.0); glCallList(SPHERE); glTranslatef(-5.0,0.0,-20.0); glCallList(cube); i:= i + 0.25; DrawGLScene:=true; // Everything Went OK end; //-------------------------------------------

Share this post


Link to post
Share on other sites
Thank you !
But i dunno how to work with vertex array.
Can you change this my code to work with vertex array?

Then i can stud. Thanx

Share this post


Link to post
Share on other sites