glLoadIdentity

Started by
4 comments, last by SpazBoy the Mitey 22 years, 2 months ago
I am working on a program where I rotate and translate about 30 small textured quads per frame and I was getting as little as 9 frames per second. Now I thought this may have been the fact that I have a second thread processing window messages that might have been hogging the cpu, but I commented out glLoadIdentity from my quad drawing thingy and I was getting 40 fps. Now each of these quads has to be translated and rotated independantly of all the others in the scene, so I have been calling glLoadIdentity() 30 times per loop and I was wondering if there was any way to get around it? I am going to go and make a single thread version and just check it isnt my being a multithread whore as well now :hat
I''m not interested, really.
Advertisement
Use glPushMatrix and glPopMatrix.

Push matrix saves the current modelviewmatirx on the matrix stack and pop will restore it again.

But maybe you should use another approach, instead of translating and rotating for every cube, do this :

for every frame :

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(360 - cam_x_angle,1.0,0,0);
glRotatef(360 - cam_y_angle,0,1.0,0);
glRotatef(360 - cam_z_angle,0,0,1.0);
glTranslatef(-cam_x_pos,-cam_y_pos,-cam_z_pos);

//draw cube's

You would off course need the positions of the cubes


Edited by - George2 on February 10, 2002 5:01:48 AM
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
i would, but this is a camera static 2d asteroids type clone
thing
I will try push/pop though
I''m not interested, really.
>>glLoadIdentity() 30 times per loop and I was wondering
if there was any way to get around it?<<

SpazBoy even calling loadidentity 30000x a frame is gonna make bugger all difference to your framerate.

A/ what card/os do u run?
B/ try char *s = glGetString( GL_VENDER ); what answer do u get

http://uk.geocities.com/sloppyturds/gotterdammerung.html
Hey, I comment out glLoadIdentity and the thing flys all of a sudden.

I''m temporarily running an i740 (HAHAHAHAHHA) on a win2000
machine and it is terribly gay
I''m not interested, really.
HAHAHA IT IS OKIES, SOMEWHERE IN TEH NETHER REGIONS OF TEH CODE
MY TEXTURE MANAGER TURNED ON LINEAR FILTERING OF TEXTURES WHICH
CAUSED MY POXY GRAPHICS CARD TO FALL OVER IN A HEAP!

IT IS WEIRD THAT TAKING OUT glLoadIdentity() IMPROVED THE SPEED
THOUGH I PUT IT DOWN TO WHAT I CALL "BUNG", LIKE WHEN I WROTE
A DUNGEON GAME FOR A SCHOOL PROJECT IN PASCAL AND MY GAME TIMER
WOULDN''T FUNCTION UNLESS I DID A WRITELN() TO PUT IT ON THE
SCREEN AND I COULDN''T FIGURE OUT WHY OH WELL AT LEAST IT''S
60 FPS NOW
I''m not interested, really.

This topic is closed to new replies.

Advertisement