Slowdown with cylinder?

I don’t know if this is something anyone can answer or not, but here goes.

I have a simple scene. Only 4 cylinders (acting as columns) and a roof. The roof is just a sqished box made of quads. It’s all texture mapped. It runs horribly slow.

I ran an example from the OpenGl SuperBible with hindreds of columns/Spheres/pyramids in a 3d world and it runs fine.

I have a modern 3d graphics card with 32megs of ram. (Most games run perfectly for me)

Why could it have so much trouble drawing these 4 columns and a box? I took the textures away and it is still was way too slow.
I reduced the subdivisions for the cylinders and it was still too slow.

I have depth testing enabled and good perspective calculations. I know these have overhead, but it can’t be this much can it?

Any suggestions?

How many triangles do u have in you’r scene?
Whitch method do u use to render the scene ?

It may be that you have GL_POLYGON_SMOOTH enabled (which makes any card crawl down, especially GeForces coz’ when you enable this, they REALLY smooth the polygons !).

Try : glDisable(GL_POLYGON_SMOOTH);

This option should never be used…

If this is not the problem, can you tell the subdivisions you use for your cylinders ?

Regards.

Eric

I guess I’m too new to OpenGl to know which parts of this code are eating my frame rate…so I put it all here…Sorry…

Just stand beside one of the posts in my scene and try to rotate the world…It all breaks up and goes slow…

It only slows like this if I maximize my window…If the window is small…it runs fine…I need it to run fast in fullscreen

#include <gl\glut.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
#include <windows.h>
#include <math.h>

//Globals
//Position of camera
float x = 0;
float y = 0;
float z = 0;
float walkBob = 0;
float lookAround = 0;
float walkSpeed = 0.2;
//For rotation/movement
float angle = 0;
float rotate = 0;
float triRot = 0; //Triangle

GLuint texture[5]; //Hold five textures (unsigned int)
//Five image records for storing bitmap data
AUX_RGBImageRec *tex[5];

//Quadrics
GLUquadricObj *cylinder = gluNewQuadric();

//All input handled here
void Input() {
if(GetAsyncKeyState(VK_UP)) {
x += sin(angle * (3.14 / 180)) * walkSpeed;
z += cos(angle * (3.14 / 180)) * walkSpeed;
walkBob += 10;
//For bounce/Add later
y += sin(360 - walkBob * (3.14 /180)) / 50;
}
if(GetAsyncKeyState(VK_DOWN)) {
x -= sin(angle * (3.14 / 180)) * walkSpeed;
z -= cos(angle * (3.14 / 180)) * walkSpeed;
walkBob -= 10;
//For bounce/add later
y -= sin(360 - walkBob * (3.14 /180)) / 50;
}
//Increase angle of rotation
if(GetAsyncKeyState(VK_LEFT)) { angle += 0.5;}
//Decrease angle of rotation
if(GetAsyncKeyState(VK_RIGHT)) { angle -= 0.5;}
if(GetAsyncKeyState(VK_HOME)) { lookAround += 1;}
if(GetAsyncKeyState(VK_END)) { lookAround -= 1;}
}

//Hit escape to cancel program
void KeyboardHandler(unsigned char key, int x, int y) {
switch(key) {
case GLUT_KEY_F1:
break;
case GLUT_KEY_F2:

	break;
	case 27:
		exit(0);
	break;
	default:
		break;
}
glutPostRedisplay();

}

void createTexture(int index, char *path) {
tex[index] = auxDIBImageLoad(path);
glGenTextures(1, &texture[index]);
glBindTexture(GL_TEXTURE_2D, texture[index]);

//Specify the quality of the texture at different distances
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//Create the texture (WHERE TO GET IT)	
glTexImage2D(GL_TEXTURE_2D,
						0,						/*Image level (left 0)*/
						3,						/*Number of data components (R,G,B)*/
						tex[index]-&gt;sizeX,		/*Width of bitmap*/
						tex[index]-&gt;sizeY,		/*Height of bitmap*/
						0,						/*Border (left at 0)*/			
						GL_RGB,					/*Color mode*/
						GL_UNSIGNED_BYTE,		/*What data is made of*/
						tex[index]-&gt;data);		/*where the data is*/
//Free memory
if(tex[index]) {
	if(tex[index]-&gt;data) {
		free(tex[index]-&gt;data);
	}
	free(tex[index]);
}

}

void loadTextures() {
createTexture(1, “C:/pix/sand.bmp”);
createTexture(3, “C:/pix/grass1.bmp”);
}

//Draws the world in which to move
void draw(void) {
//Clear window with current color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

Input(); //Check for user input

/********************************************************************/
//Move the scene
glLoadIdentity();						//Reset the scene
rotate = 360 - angle;					//Determine wrap around angle
glRotatef(360 - lookAround, 1,0,0);		//Rotate up and down
glRotatef(rotate,0,1,0);				//Rotate side to side
glTranslatef(x,y,z);					//Move to correct position
//End Move
/********************************************************************/
//Enable texture mapping
glEnable(GL_TEXTURE_2D);
glColor3f(1,1,1);

//FLOOR
glBindTexture(GL_TEXTURE_2D, texture[1]);
glBegin(GL_QUADS);
	glTexCoord2f(20,0); glVertex3f(-150, -2, 150);
	glTexCoord2f(0,0); glVertex3f(150, -2, 150);
	glTexCoord2f(20,20); glVertex3f(150, -2, -150);
	glTexCoord2f(0,20); glVertex3f(-150, -2, -150);
glEnd();
//End Floor

//BUILDING
glBindTexture(GL_TEXTURE_2D, texture[3]);
//Post1
glPushMatrix();
glTranslatef(15,-2,0);
glRotatef(-90,1,0,0);
gluQuadricTexture(cylinder, GL_TRUE);
gluCylinder(cylinder, 0.5,0.5,7,5,1);
glPopMatrix();
//End Post1

//Post2
glPushMatrix();
glTranslatef(7.5,-2,0);
glRotatef(-90,1,0,0);
gluQuadricTexture(cylinder, GL_TRUE);
gluCylinder(cylinder, 0.5,0.5,7,5,1);
glPopMatrix();
//End Post2

//Post3
glPushMatrix();
glTranslatef(15,-2,10);
glRotatef(-90,1,0,0);
gluQuadricTexture(cylinder, GL_TRUE);
gluCylinder(cylinder, 0.5,0.5,7,5,1);
glPopMatrix();
//End Post3

//Post4
glPushMatrix();
glTranslatef(7.5,-2,10);
glRotatef(-90,1,0,0);
gluQuadricTexture(cylinder, GL_TRUE);
gluCylinder(cylinder, 0.5,0.5,7,5,1);
glPopMatrix();
//End Post4

//Roof bottom
glBegin(GL_QUADS);
	//Lower left
	glTexCoord2f(0.0,0.0); glVertex3f(6,5,-1);
	//Lower right
	glTexCoord2f(2.0,0.0); glVertex3f(16,5,-1);
	//Upper right
	glTexCoord2f(2.0,2.0); glVertex3f(16,5,11);
	//Upper left
	glTexCoord2f(0.0,2.0); glVertex3f(6,5,11);
glEnd();
//Roof top
glBegin(GL_QUADS);
	//Lower left
	glTexCoord2f(0.0,0.0); glVertex3f(6,5.5,-1);
	//Lower right
	glTexCoord2f(2.0,0.0); glVertex3f(16,5.5,-1);
	//Upper right
	glTexCoord2f(2.0,2.0); glVertex3f(16,5.5,11);
	//Upper left
	glTexCoord2f(0.0,2.0); glVertex3f(6,5.5,11);
glEnd();

//Left wall roof
glBegin(GL_QUADS);
	//Lower left
	glTexCoord2f(0.0,0.0); glVertex3f(6,5,-1);
	//Lower right
	glTexCoord2f(2.0,0.0); glVertex3f(6,5.5,-1);
	//Upper right
	glTexCoord2f(2.0,2.0); glVertex3f(6, 5.5,11);
	//Upper left
	glTexCoord2f(0.0,2.0); glVertex3f(6, 5, 11);
glEnd();

//right wall roof
glBegin(GL_QUADS);
	//Lower left
	glTexCoord2f(0.0,0.0); glVertex3f(16,5,-1);
	//Lower right
	glTexCoord2f(2.0,0.0); glVertex3f(16,5.5,-1);
	//Upper right
	glTexCoord2f(2.0,2.0); glVertex3f(16, 5.5,11);
	//Upper left
	glTexCoord2f(0.0,2.0); glVertex3f(16, 5, 11);
glEnd();

//back wall roof
glBegin(GL_QUADS);
	//Lower left
	glTexCoord2f(0.0,0.0); glVertex3f(6,5,-1);
	//Lower right
	glTexCoord2f(2.0,0.0); glVertex3f(16,5,-1);
	//Upper right
	glTexCoord2f(2.0,2.0); glVertex3f(16, 5.5,-1);
	//Upper left
	glTexCoord2f(0.0,2.0); glVertex3f(6, 5.5, -1);
glEnd();

//front wall roof
glBegin(GL_QUADS);
	//Lower left
	glTexCoord2f(0.0,0.0); glVertex3f(6,5, 11);
	//Lower right
	glTexCoord2f(2.0,0.0); glVertex3f(16,5, 11);
	//Upper right
	glTexCoord2f(2.0,2.0); glVertex3f(16, 5.5, 11);
	//Upper left
	glTexCoord2f(0.0,2.0); glVertex3f(6, 5.5, 11);
glEnd();
//Disable when not used
glDisable(GL_TEXTURE_2D);
//Empty buffer (double buffering)
glutSwapBuffers();
//Draw again
glutPostRedisplay();

}

//Change the window size
void ChangeSize(GLsizei w, GLsizei h) {
//Prevent divide by zero
if (h==0) { h = 1;}

//Affects camera
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

//Set viewport
glViewport(0,0,w,h);

//Feild of view, ratio, start distance, end distance
gluPerspective(45, w / h, 1, 1000);
//Affects models
glMatrixMode(GL_MODELVIEW);

}

//All setup code
void Setup(void) {
loadTextures();
//Great perspective calculations
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
//Enable Z-Buffering
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);

//Clear the screen to black
glClearColor(0,0,0,1);	

}

//Set up the window/Initialize/Define outines
void main(void) {
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(1024,768);
glutCreateWindow(“AceMan”);
glutDisplayFunc(draw);
glutReshapeFunc(ChangeSize);
glutKeyboardFunc(KeyboardHandler);
Setup();
glutMainLoop();
}

Thanks too all of you who’ve commented on this…