Slow framerate trying to draw quads

Started by
8 comments, last by hoLogramm 15 years, 9 months ago
I'm writing a tile based map system for a project, but when trying to draw 100x100 un-textured quads in wireframe i only get ~6 fps and displaylist doesn't help at all. I've been searching for a solution since midnight but nothing has come up. The routine looks like this:

glBegin( GL_QUADS);

for(int y = 0; y < 100; y++)
{
	for(int x = 0; x < 100; x++)
	{
		glVertex3f( 0	*x,		0	*y,		0);
		glVertex3f( 16	*x,		0	*y,		0);
		glVertex3f( 16	*x,		16	*y,		0);
		glVertex3f( 0	*x,		16	*y,		0);		
	}
}

glEnd();

Any suggestions?
Advertisement
you should definitely switch to vertex buffers. Now you're using the "immediate mode", but it is useful only for debug and other secondary things.

Take a look at this tutorial .

Hope this helps :)
First of all I dont think that code is doing what you intended.

the first quad is going to be at:

(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)

the second at

(0,0,0)
(16,0,0)
(16,0,0)
(0,0,0)

So your not drawing anything at all for them I assume.

Once Y goes to 1 youll start drawing quads which get progressively bigger and alway start at (0,0) which will mean youll have a massive amount of overdraw. for example at the end of the loop youll do:

(0,0,0)
(1584,0,0)
(1584,1584,0)
(0,1584,0)

I think this is why your getting such low fps.
Quote:Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!
Rendering primitives in wireframe mode always decreases performance by a lot.
How is rendering performance with GL_FILL?
If displaylists don't help improving performance, nothing will. I would say you have no hardware support (MESA drivers), running a profiler with an altered opengl32.dll in background or just a very crappy graphics card.


h.
Quote:Original post by hoLogramm
Rendering primitives in wireframe mode always decreases performance by a lot.
How is rendering performance with GL_FILL?
If displaylists don't help improving performance, nothing will. I would say you have no hardware support (MESA drivers), running a profiler with an altered opengl32.dll in background or just a very crappy graphics card.

h.


GL_FILL is way slower.

And since i can play World of Warcraft without any problems and VENDOR returns "Intel Inc" i assume that my card is sufficient and working.

I should at least be able to draw a map like those in Graal Online with a decent fps.
Quote:Original post by grekster
First of all I dont think that code is doing what you intended.

the first quad is going to be at:

(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)

the second at

(0,0,0)
(16,0,0)
(16,0,0)
(0,0,0)

So your not drawing anything at all for them I assume.

Once Y goes to 1 youll start drawing quads which get progressively bigger and alway start at (0,0) which will mean youll have a massive amount of overdraw. for example at the end of the loop youll do:

(0,0,0)
(1584,0,0)
(1584,1584,0)
(0,1584,0)

I think this is why your getting such low fps.



I've set up my projection so 16 actually represents 16 pixels. Everything draws as it's supposed too, just very slow.
you're still wrong

glVertex3f( 0 *x, 0 *y, 0);
glVertex3f( 16 *x, 0 *y, 0);
glVertex3f( 16 *x, 16 *y, 0);
glVertex3f( 0 *x, 16 *y, 0);


Line nr. 1 will allways be glVertex3f(0,0,0);

You are drawing quads but they all begin in (0,0,0) and only their size changes.

0*x will allways be 0 no matter what x is, or? (same goes for 0*y)
Quote:Original post by Softnux
Quote:Original post by hoLogramm
Rendering primitives in wireframe mode always decreases performance by a lot.
How is rendering performance with GL_FILL?
If displaylists don't help improving performance, nothing will. I would say you have no hardware support (MESA drivers), running a profiler with an altered opengl32.dll in background or just a very crappy graphics card.

h.


GL_FILL is way slower.

And since i can play World of Warcraft without any problems and VENDOR returns "Intel Inc" i assume that my card is sufficient and working.

I should at least be able to draw a map like those in Graal Online with a decent fps.


If GL_FILL is slower, than you have definitely a problem with overdraw and grekster is right. You are drawing every quad on top of each other. You would alter your code to something like this:
glBegin( GL_QUADS);for(int y = 0; y < 100; y++){	for(int x = 0; x < 100; x++)	{		glPushMatrix();		glTranslatef(x*16, y*16, 0);		glVertex3f( 0,	0,	0);		glVertex3f( 16,	0,	0);		glVertex3f( 16,	16,	0);		glVertex3f( 0,	16,	0);				glPopMatrix();	}}glEnd();
You're both right, sorry! haven't slept for some 24 hours now ^^

glVertex3f( 16 * x,		16 * y,		0);glVertex3f( 16 * x,		(16	*y) +16,		0);glVertex3f( (16	*x) + 16,		(16	*y) + 16,		0);glVertex3f( (16	*x) + 16,		16 * y,		0);


Fixed it up to ~300-400 fps in GL_FILLED.

Thanks alot! Surprisingly fast answers compared to other forums =)

Anyway, what framdrop should i expect if i use textures on all?
Quote:Original post by Softnux
You're both right, sorry! haven't slept for some 24 hours now ^^

glVertex3f( 16 * x,		16 * y,		0);glVertex3f( 16 * x,		(16	*y) +16,		0);glVertex3f( (16	*x) + 16,		(16	*y) + 16,		0);glVertex3f( (16	*x) + 16,		16 * y,		0);


Fixed it up to ~300-400 fps in GL_FILLED.

Thanks alot! Surprisingly fast answers compared to other forums =)

Anyway, what framdrop should i expect if i use textures on all?


Depends how many texture switches you have to introduce when rendering, but when you batch your quads with the same textures together, it would only make a very slight impact on it.

This topic is closed to new replies.

Advertisement