• Advertisement
Sign in to follow this  

Which Is Faster????

This topic is 3871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If i load a 128*128 square and use glDrawPixels to draw it? or if i use glBegin(GL_QUADS); glVertex3f(x,x,x)... to draw the same square?

Share this post


Link to post
Share on other sites
Advertisement
I dont think so because from the tests ive just been doing when i draw pixels my frame rate is around 58 but when drawing vertex i get a frame rate of about 30

Share this post


Link to post
Share on other sites
Well, without a doubt, storing an image as a texture, and then drawing a texture quad will be faster. If it's not faster, that means you're doing something wrong (or something is fishy with your drivers).

Let us see some code: How do you upload the texture to the graphics card? What's your drawing code look like?

~Chris

Share this post


Link to post
Share on other sites
never draw pixels. i once made a glow function using pixel operations, instead of using a pixel shader.. and the fps was at 640x480 about 8fps at really good optimizations, while comparing to a pixel shader, which nearly doesn't affect the frame rate at all..

Share this post


Link to post
Share on other sites
The texture loading function is LoadTGA really really long not gonna put it here but for drawing the image i use
 glDrawPixels(image->sizeX,image->sizeYGL_RGB,GL_UNSIGNED_BYTE,(GLvoid*)image->data);

for drawing the vertices:

glBegin(GL_QUADS);
glVertex2f(30,530);
glVertex2f(760,530);
glVertex2f(760,25);
glVertex2f(30,25);
glEnd();

Share this post


Link to post
Share on other sites
Sorry the graphics card is an nVidia fx 5200 128mb 384 ram XP Pro

Share this post


Link to post
Share on other sites
And you don't update the texture?
For sure, the texture way will be faster.

Share this post


Link to post
Share on other sites
Quote:
I dont think so because from the tests ive just been doing when i draw pixels my frame rate is around 58 but when drawing vertex i get a frame rate of about 30

Try doing that a 100 times. The quad should be much faster than glDrawPixels, then.

That said, how can you only get 30 fps with a simple, textured quad? The number should have been more like 300 (if not 3000) fps. Maybe you are rendering onto a non-accelerated opengl context (where glDrawPixels might be faster than rendering quads)?

Share this post


Link to post
Share on other sites
Okay, this might be dumb, but it is *always* worth a check. You aren't loading the texture _every frame_? It's the only explanation I can think of for getting 30 fps for one textured quad.

Share this post


Link to post
Share on other sites
Im not lloading the texture every time but when i tried on a different computer drawing the vertices was a lot faster!

How can i make sure im drawing to an accelerated opengl context?

Share this post


Link to post
Share on other sites
If i texture map a quad, its a lot faster than glDrawPixels...Ive got a question though. If i use glDrawPixels the color of the image is perfect. If i texture map a quad the color is wrong. I enable GL_COLOR_MATERIAL,disable lighting,enable depth test. Any ideas why the color is wrong?

Share this post


Link to post
Share on other sites
If it's not hardware accelerated, I'd expect you to get under 10 fps. But it's worth checking out. Just download the latest driver for your graphics card off of it's manufacturer's website. The default ones with windows have very poor OpenGL support (so it has to use software).

Share this post


Link to post
Share on other sites
texture loading function:

bool CreateTexture(UINT &texture, LPSTR strFileName)
{
if(!strFileName)
return false;
tImage *pImage = NULL;
if(strstr(strFileName, ".tga"))
{
pImage = LoadTGA(strFileName);
}
else
return false;
if(pImage == NULL)
return false;
glGenTextures(1, &texture);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, texture);
int textureType = GL_RGB;
if(pImage->channels == 4)
textureType = GL_RGBA;
gluBuild2DMipmaps(GL_TEXTURE_2D, pImage->channels, pImage->sizeX,
pImage->sizeY, textureType, GL_UNSIGNED_BYTE, pImage->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if (pImage) // If we loaded the image
{
if (pImage->data) // If there is texture data
{
free(pImage->data); // Free the texture data, we don't need it anymore
}
free(pImage); // Free the image structure
}
return true;
}


I use this to fraw the cube

glEnable(GL_TEXTURE_2D);
glEnable(GL_COLOR_MATERIAL);
glBindTexture(GL_TEXTURE_2D, texarray);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 1.0f);
glVertex2f(400,500); // Top Left
glTexCoord2f(0.0f, 1.0f);
glVertex2f(720,500); // Top Right
glTexCoord2f(0.0f, 0.0f);
glVertex2f(720,175); // Bottom Right
glTexCoord2f(1.0f, 0.0f);
glVertex2f(400,175); // Bottom Left
glEnd();
glDisable(GL_TEXTURE_2D);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement