Object movement in OpenGl
-
Hi All I am loading multiple object On OpenGL.When i load Only one object ,the object movement is very smooth.After the increase the number object on screen at that time the movement is going slow. Please suggest the way how to increase the speed when multiple object on screen. Thanks
-
Hi All I am loading multiple object On OpenGL.When i load Only one object ,the object movement is very smooth.After the increase the number object on screen at that time the movement is going slow. Please suggest the way how to increase the speed when multiple object on screen. Thanks
Are you loading your objects (or textures, or anything) from a file ? If yes, are you loading the file once or for every frame ? If you are loading the files for every frame, you should load them once at the beginning of your program. File I/O is very slow. It's the only thing I can think that could slow down performance and that has a quick fix. If you already do that, then you will have to look for yourself how you can increase the performances of your program. Your question is so vague that there's no way to give you a correct answer.
Cédric Moonen Software developer
Charting control [v3.0] OpenGL game tutorial in C++ -
Are you loading your objects (or textures, or anything) from a file ? If yes, are you loading the file once or for every frame ? If you are loading the files for every frame, you should load them once at the beginning of your program. File I/O is very slow. It's the only thing I can think that could slow down performance and that has a quick fix. If you already do that, then you will have to look for yourself how you can increase the performances of your program. Your question is so vague that there's no way to give you a correct answer.
Cédric Moonen Software developer
Charting control [v3.0] OpenGL game tutorial in C++Ok,Here i am sending you my RenderScene function which is continuous call. I am loading image Once only.The other are text,Line,Point and 3D object.
Void RenderScene()
{
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT );float R = (float)GetRValue(m\_s3DDispManagerSetting.dwScreenBkColor)/255.0; float G = (float)GetGValue(m\_s3DDispManagerSetting.dwScreenBkColor)/255.0; float B = (float)GetBValue(m\_s3DDispManagerSetting.dwScreenBkColor)/255.0; ::glClearColor(R, G, B, 0.0f); glPushMatrix(); glLoadIdentity(); glShadeModel(GL\_FLAT) ; glEnable(GL\_NORMALIZE) ; multimap::iterator it; //Scalling as per user selection glScalef(m\_fScale, m\_fScale, m\_fScale); //3D rotation angle glRotated(m\_fRAngle\[0\],1.0, 0.0, 0.0); glRotated(m\_fRAngle\[1\],0.0,1.0, 0.0); glRotated(m\_fRAngle\[2\],0.0,0.0,1.0); glDepthMask(GL\_TRUE); for(it = m\_sMapObjectInfo.begin(); it != m\_sMapObjectInfo.end(); it++) { stObjectInfo sObjectInfo = (\*it).second; if(sObjectInfo.eObjectType == OBJECT\_LINE) glCallList((\*it).first); } for(it = m\_sMapObjectInfo.begin(); it != m\_sMapObjectInfo.end(); it++) { stObjectInfo sObjectInfo = (\*it).second; if(sObjectInfo.eObjectType == OBJECT\_POINT) glCallList((\*it).first); } for(it = m\_sMapObjectInfo.begin(); it != m\_sMapObjectInfo.end(); it++) { stObjectInfo sObjectInfo = (\*it).second; if(sObjectInfo.eObjectType == OBJECT\_TEXT) glCallList((\*it).first); } for(it = m\_sMapObjectInfo.begin(); it != m\_sMapObjectInfo.end(); it++) { stObjectInfo sObjectInfo = (\*it).second; if(sObjectInfo.eObjectType == OBJECT\_IMAGE) glCallList((\*it).first); } for(it = m\_sMapObjectInfo.begin(); it != m\_sMapObjectInfo.end(); it++) glEnable(GL\_CULL\_FACE); glCullFace(GL\_BACK); glFrontFace(GL\_CW); for(it = m\_sMapObjectInfo.begin(); it != m\_sMapObjectInfo.end(); it++) { stObjectInfo sObjectInfo = (\*it).second; if(sObjectInfo.eObjectType == OBJECT\_3D) { glMaterialfv(GL\_FRONT\_AND\_BACK , GL\_DIFFUSE, sObjectInfo.fIntensity); glCallList((\*it).first); } } glDisable(GL\_CULL\_FACE); glDisable(GL\_BLEND); glPopMatrix();
}