Board index » delphi » OpenGL: Textures are terribly slow!

OpenGL: Textures are terribly slow!

Hi everyone:

Is there a better (more FPS) way to draw a texture in OGL, other than
glTextImage2d??
I'm using it with textures as big as 1024x1024 and i get a really low FPS
rate.
Is there any extension i'm not aware of or something like that?
i really need better performance here...

This is what i'm doing to draw textures:

  glColor3ub(r,g,b);

  if aFilled then
    glPolygonMode(GL_FRONT,GL_FILL)
  else
    glPolygonMode(GL_FRONT,GL_LINE);

  glPixelStorei(GL_UNPACK_ALIGNMENT, 1) ;

  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

  glTexEnvF(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
     gltexImage2d(GL_TEXTURE_2D,cLevel,cTexel4,
  aGlImg.mWidth,aGlImg.mHeight,
  cBorder,GL_RGBA,GL_UNSIGNED_BYTE,@aGlImg.mData[0]);

  glEnable(GL_TEXTURE_2D);
  glBegin(GL_POLYGON);
    glTexCoord2f(0,0);glVertex3f(aDest.Left,aDest.bottom,Z);
    glTexCoord2f(1,0);glVertex3f(aDest.Right,aDest.bottom,Z);
    glTexCoord2f(1,1);glVertex3f(aDest.Right,aDest.top,Z);
    glTexCoord2f(0,1);glVertex3f(aDest.Left,aDest.top,Z);
  glend;
  glDisable(GL_TEXTURE_2D);

I've also thought of doing some mipmapping.... but the thing is that the my
users will see the texture very zoomed in... so, it would be almost the same
performance.

--
Emiliano Sosa
____
softw...@gosierra.com

 

Re:OpenGL: Textures are terribly slow!


Quote
"Software" <softw...@fibertel.com.ar> wrote in message

news:3ecbd31b@newsgroups.borland.com...

Quote
> I'm using it with textures as big as 1024x1024 and i get a really low FPS
> rate.

*cough* *sputter*

I hope you're not surprised by this. A 24-bit 1024x1024 image takes 3MB of
memory. If your video card doesn't handle the texture itself at this size it
will have to be done via software, and not many videocards handle this large
a texture.

My suggestion would be to limit yourself to 128x128 textures, and get a
nice, fast video card.

Hope That Helps,
  Ignacio

Re:OpenGL: Textures are terribly slow!


It would give me lot of performance for sure!!, but users would kill me!!

I figured out that i wasn't using the glBindTexture glGenTextures opengl
extensions...

Thanks anyway

Quote
"Ignacio Vazquez" <ivazquezATorioncommunications.com> wrote in message

news:3ecbd5d7@newsgroups.borland.com...
Quote
> "Software" <softw...@fibertel.com.ar> wrote in message
> news:3ecbd31b@newsgroups.borland.com...
> > I'm using it with textures as big as 1024x1024 and i get a really low
FPS
> > rate.

> *cough* *sputter*

> I hope you're not surprised by this. A 24-bit 1024x1024 image takes 3MB of
> memory. If your video card doesn't handle the texture itself at this size
it
> will have to be done via software, and not many videocards handle this
large
> a texture.

> My suggestion would be to limit yourself to 128x128 textures, and get a
> nice, fast video card.

> Hope That Helps,
>   Ignacio

Re:OpenGL: Textures are terribly slow!


Quote
"Software" <softw...@fibertel.com.ar> wrote in message

news:3ecbf66f$1@newsgroups.borland.com...

Quote
> It would give me lot of performance for sure!!, but users would kill me!!

Just out of curiosity, what are you doing that requires 1024x1024 textures?

Cheers,
  Ignacio

Re:OpenGL: Textures are terribly slow!


Judging by your code, you're uploading the texture to the video card
every frame, which is slow. You should upload once and just reuse
the texture.
1024x1024 is big, but not particularly huge for a geforce-class hardware.

Quote
> I've also thought of doing some mipmapping.... but the thing is that the my
> users will see the texture very zoomed in... so, it would be almost the same
> performance.

Mipmaps can't hurt performance, and can help improve image quality.
Btw, change your filters to at least GL_LINEAR unless you really
need a pixellated result.

Eric Grange
http://glscene.org

Re:OpenGL: Textures are terribly slow!


Hi Software,
    glBindTexture and glGenTextures are standard from OpenGL 1.2 onwards.
Also, the rate of drawing not only depends on the size of the texture, but
the amount of textured (and lit) pixels that a video card is capable of
drawing on the screen per second (this is called fill rate). While Geforce
class should be able to handle this easily, cards like the i810 or 845GL
might have a problem with the fillrates involved here.

Regards,
Ananth B.

Quote
"Software" <softw...@fibertel.com.ar> wrote in message

news:3ecbf66f$1@newsgroups.borland.com...
Quote
> It would give me lot of performance for sure!!, but users would [snip]

Re:OpenGL: Textures are terribly slow!


Yeah!  i810 and 845GL are the onboard cards that gave me so much trouble
with our customers!

In the un-accelerated mode (no HW accel), i had no troubles using these
textures... (besides that it's FPS consuming).
But, when i used the HW acceleration, when textures are bigger that 512x512
it draws garbage in the texture image... I'm verifiying the
GL_MAX_TEXTURE_SIZE flag, and it says 1024.... so, what's happening?

Other thing: OpenGL 1.2 is on winXP, and 98SE, right? How can i tell?

Emiliano Sosa

Quote
"Ananth B." <ana...@agnisoft.com> wrote in message

news:3ecc827a@newsgroups.borland.com...
Quote
> Hi Software,
>     glBindTexture and glGenTextures are standard from OpenGL 1.2 onwards.
> Also, the rate of drawing not only depends on the size of the texture, but
> the amount of textured (and lit) pixels that a video card is capable of
> drawing on the screen per second (this is called fill rate). While Geforce
> class should be able to handle this easily, cards like the i810 or 845GL
> might have a problem with the fillrates involved here.

> Regards,
> Ananth B.

> "Software" <softw...@fibertel.com.ar> wrote in message
> news:3ecbf66f$1@newsgroups.borland.com...
> > It would give me lot of performance for sure!!, but users would [snip]

Re:OpenGL: Textures are terribly slow!


Quote
> Just out of curiosity, what are you doing that requires 1024x1024

textures?
I am not entitled to publish that information.... but i can tell you that
the user needs to see scanned images, the best quality available...

Curiosity killed the cat...
i hope you are not a cat.

Re:OpenGL: Textures are terribly slow!


Hi Software,
    In generic mode you will get the proper results, but with depressing
framerates. You can check if its being hardware accelerated or noy be
checking the contents of the dwFlags field of the returned
PIXELFORMATDESCRIPTOR. If it contains PFD_GENERIC_ACCELERATED then you have
a software implementation (for the values you asked for).

The drivers you are talking about might support 1024x1024 textures (based on
GL_MAX_TEXTURE_SIZE), but it might depend on the memory consumption as well.
For example, try the same thing without mipmaps and try it without
filtering.

The OpenGL version has nothing to do with the OS installed. It simply
depends on the drivers that are installed. To find the current version of
OpenGL, use the glGetString(GL_VERSION) call. You can use Tom Nuyden's
OpenGL units to support later versions of OpenGL (if available) as well. You
can grab those here http://www.delphi3d.net/download/glunits.zip.

Hope this helps,

Regards,
Ananth B.

Quote
"Software" <softw...@fibertel.com.ar> wrote in message

news:3ecd403c@newsgroups.borland.com...
Quote
> Yeah!  i810 and 845GL are the onboard cards that gave [snip]

Re:OpenGL: Textures are terribly slow!


Quote
> In generic mode you will get the proper results, but with depressing
> framerates.

Yep, unfortunally i've realized that...
So, how else can i improve generic implemenation performance with textures?
anyone?(besides bindtexture and disabling filtering or mipmaps)

Quote
> For example, try the same thing without mipmaps and try it without
> filtering.

I'm not using any filtering nor any mip-mapping

thanks a bunch!

Re:OpenGL: Textures are terribly slow!


Hi Software,
    If 512x512 textures seem to work for you (in hardware accelerated mode),
you could draw 4 smaller quads with 4 different textures on it, instead of
one large quad with a 1024x1024 texture. Be sure to set the wrapmode of the
textures to GL_CLAMP or you will wind up with artifacts where the quads
meet.

Regards,
Ananth B.

Quote
"Software" <softw...@fibertel.com.ar> wrote in message

news:3ece231f$1@newsgroups.borland.com...
Quote
> > In generic mode you will get the proper results, but with depressing
> > framerates.
> Yep, unfortunally i've realized that [snip]

Other Threads