[gameprogrammer] Re: Optimizing opengl rendering
- From: Scott Harper <lareon@xxxxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Mon, 4 Apr 2005 12:24:34 -0600
Real quick before we get into optimising OGL, just using 2D quads for a
game, do you even NEED to optimise it? How bad of a framerate hit are
you getting? What's your system like? How many quads do you have to
be rendering before you start slowing down?
I'm mostly just really curious what kind of system and how many
textured quads it takes before OpenGL starts to get slower. For
educational purposes. ^_^
Thanks, and I'll look into what you need.
--Scott
On 04 Apr, 2005, at 3:43 AM, jorgefm@xxxxxxxxx wrote:
> Hi,
>
> I'm developing an opengl/SDL 2D game. I'm trying to optimize
> the rendering process. I've read that the immediate mode is
> the slowest, but it's the easiest to implement and it's the
> mode i'm using.
>
> I'm renderering only GL_QUADS. My textures comes from bitmapped
> files with different size. For instance, my app window is
> 1024x768, then i have 12 256x256 textures. To render the app
> background i've to paint 12 textured quads for every frame.
> For the rendering code I only have:
>
>
> for( unsigned int i = 0; i < m_textures.size(); i++ )
> {
> // Bind texture.
> glBindTexture( GL_TEXTURE_2D, m_textures[i].id );
>
> // Paint polygon.
> glBegin( GL_QUADS );
>
> glTexCoord2f( 0.0f,
> m_textures[i].height );
> glVertex3f( m_textures[i].rect.x,
> m_textures[i].rect.y + m_textures[i].rect.h,
> 0.0f );
>
> glTexCoord2f( m_textures[i].width,
> m_textures[i].height );
> glVertex3f( m_textures[i].rect.x + m_textures[i].rect.w,
> m_textures[i].rect.y + m_textures[i].rect.h,
> 0.0f );
>
> glTexCoord2f( m_textures[i].width,
> 0.0f );
> glVertex3f( m_textures[i].rect.x + m_textures[i].rect.w,
> m_textures[i].rect.y,
> 0.0f );
>
> glTexCoord2f( 0.0f,
> 0.0f );
> glVertex3f( m_textures[i].rect.x,
> m_textures[i].rect.y,
> 0.0f );
> glEnd();
> }
>
> So, what's the best way to try to optimize this code? Using display
> lists, vertex arrays, vertex buffer objects, using GL_TRIANGLE instead
> of GL_QUADS, use STRIPS,... ??
>
> And, if I change the rendering code to dinamically multiply the
> vertex with a scale constant, like the next one, but method can i
> still use?
>
>
> for( unsigned int i = 0; i < m_textures.size(); i++ )
> {
> // Bind texture.
> glBindTexture( GL_TEXTURE_2D, m_textures[i].id );
>
> // Paint polygon.
> glBegin( GL_QUADS );
>
> glTexCoord2f( 0.0f,
> m_textures[i].height );
> glVertex3f( m_textures[i].rect.x * scale_x,
> (m_textures[i].rect.y + m_textures[i].rect.h) *
> scale_y,
> 0.0f );
>
> glTexCoord2f( m_textures[i].width,
> m_textures[i].height );
> glVertex3f( (m_textures[i].rect.x + m_textures[i].rect.w) *
> scale_x,
> (m_textures[i].rect.y + m_textures[i].rect.h) *
> scale_y,
> 0.0f );
>
> glTexCoord2f( m_textures[i].width,
> 0.0f );
> glVertex3f( (m_textures[i].rect.x + m_textures[i].rect.w) *
> scale_x,
> m_textures[i].rect.y * scale_y,
> 0.0f );
>
> glTexCoord2f( 0.0f,
> 0.0f );
> glVertex3f( m_textures[i].rect.x * scale_x,
> m_textures[i].rect.y * scale_y,
> 0.0f );
> glEnd();
> }
>
>
> Any suggestion is welcome, and sorry, for this lengthy mail!
> Thanks,
>
> Jorge
>
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: Optimizing opengl rendering
- From: David Olofson
- References:
- [gameprogrammer] Optimizing opengl rendering
- From: jorgefm
Other related posts:
- » [gameprogrammer] Optimizing opengl rendering
- » [gameprogrammer] Re: Optimizing opengl rendering
- » [gameprogrammer] Re: Optimizing opengl rendering
- » [gameprogrammer] Re: Optimizing opengl rendering
- » [gameprogrammer] Re: Optimizing opengl rendering
- » [gameprogrammer] Re: Optimizing opengl rendering
- » [gameprogrammer] Re: Optimizing opengl rendering
- » [gameprogrammer] Re: Optimizing opengl rendering
- » [gameprogrammer] Re: Optimizing opengl rendering
- [gameprogrammer] Re: Optimizing opengl rendering
- From: David Olofson
- [gameprogrammer] Optimizing opengl rendering
- From: jorgefm