Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Object movement in OpenGl

Object movement in OpenGl

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsgame-devperformancetutorial
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GAJERA
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • G GAJERA

      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

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      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++

      G 1 Reply Last reply
      0
      • C Cedric Moonen

        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++

        G Offline
        G Offline
        GAJERA
        wrote on last edited by
        #3

        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();	
        

        }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups