low framerate with my opengl code

Started by
3 comments, last by Ogre722 13 years, 9 months ago
I have created a small rendering system that is built around OpenGL. From the OpenGL gurus out there I'd like to know whether or not I should be expecting better frame rates than I have been getting based on scene complexity. I have two screen shots that were taken on my computer. one is of my code rendering a very reasonably sized scene and the other is of my computer running the source engine for comparison. I appreciate any comments or helpful suggestions offered.

http://i713.photobucket.com/albums/ww140/ogre722/scn.png?t=1278915361
The stats on this screen shot are:
210 frames per second
20194 total scene polygons (map + head)
rendered using a GLSL shader program

http://i713.photobucket.com/albums/ww140/ogre722/srcscn.png?t=1278915738

My System Specs are:
q6600 2.4ghz quad core cpu
9800gt gpu
4gb ram
5400rpm hard drive
Advertisement
It's impossible to say without seeing some code. There are many things that could slow down your rendering, and that kind of performance definitely seems quite low given the poly counts you have.

As a rough guess, given that you talk about discrete polygons, I am wondering if you're using glBegin/glEnd for each of those 20194 polys. But again, without seeing some code anything I might say is purely in the realms of speculation.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

both seem about the correct FPS.
the top is about twice the speed of the bottom.
if you make the windows about 320x240 + try again there should be a larger difference
One thing to note is that drop in framerate is not linear. IE if you draw nothing your FPS is theoretically huge (a million "theoretically"). As you draw a couple things it will drop down to something like 200-300, but as you draw a whole lot more your FPS will drop a lot less slower.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Quote:Original post by mhagain
It's impossible to say without seeing some code. There are many things that could slow down your rendering, and that kind of performance definitely seems quite low given the poly counts you have.

As a rough guess, given that you talk about discrete polygons, I am wondering if you're using glBegin/glEnd for each of those 20194 polys. But again, without seeing some code anything I might say is purely in the realms of speculation.


Here is the pertinent code:

The main draw method:
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);    glLoadIdentity();    cam.Render();    rs_AddLight(v3(0,5,0), v3(1,1,1), 0);    rs_AddLight(v3(0,-5,0), v3(1,0,0), 1);    shader.bind();    shader.passVar1i(1, "l[0]");    shader.passVar1i(1, "l[1]");    shader.passVar1i(1, "hasTex");    rs_DrawObj(&obj, &mat_obj);    shader.passVar1i(0, "hasTex");    glPushMatrix();    glScalef(.5,.5,.5);    rs_DrawObj(&light);    glPopMatrix();    shader.unbind();


Here are the two rsDrawObj methods
void rs_DrawObj(objModel* o){    SetDefMat();    glBindTexture(GL_TEXTURE_2D, 0);    glDisable(GL_TEXTURE_2D);    glCallList(o->object);    glEnable(GL_TEXTURE_2D);}void rs_DrawObj(objModel* o, Material* m){    GLfloat d[] = { m->d_Col.x, m->d_Col.y, m->d_Col.z, 1 };	GLfloat s[] = { m->s_Col.x, m->s_Col.y, m->s_Col.z, 1 };	GLfloat a [] = { m->a_Col.x,m->a_Col.y,m->a_Col.z,1 };	glMaterialfv(GL_FRONT, GL_DIFFUSE, d);	glMaterialfv(GL_FRONT, GL_SPECULAR, s);	glMaterialfv(GL_FRONT, GL_AMBIENT, a);	glMaterialf(GL_FRONT, GL_SHININESS, m->shine);    if (m->color.texID != 0)    {        glBindTexture(GL_TEXTURE_2D, 0);        glDisable(GL_TEXTURE_2D);        glCallList(o->object);    }    else    {        glBindTexture(GL_TEXTURE_2D, m->ColorTexID);        glCallList(o->object);        glEnable(GL_TEXTURE_2D);    }}

This topic is closed to new replies.

Advertisement