GL_EXT_texture_rectangle

  • Permalink
  • submit to reddit
  • Email
  • Follow


Hi Folks,

Has anyone an example on how to use the GL_EXT_texture_rectangle extension
to set up a 2D texture? Currently I'm doing something like this:

void
guiGLCanvas::initializeTexture(GLuint &texture)
{
   glGenTextures(1, &texture);
   glBindTexture(GL_TEXTURE_2D, texture);
   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_REPLACE);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_TexWidth, m_TexHeight,
                0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
}

where the texture height/widths are big enough to cover the canvas,
however using GL_EXT_texture_rectangle would be better as the canvas
is not square of a power of 2.

thanks,

Keith
0
Reply false (23) 11/19/2006 4:35:07 PM

See related articles to this posting


Keith S. wrote:
> Hi Folks,
> 
> Has anyone an example on how to use the GL_EXT_texture_rectangle extension
> to set up a 2D texture?

I think you just need to replace "GL_TEXTURE_2D"
with "GL_TEXTURE_RECTANGLE_ARB"


> void
> guiGLCanvas::initializeTexture(GLuint &texture)
> {
>   glGenTextures(1, &texture);
>   glBindTexture(GL_TEXTURE_2D, texture);
>   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_REPLACE);
>   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_TexWidth, m_TexHeight,
>                0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
> }
> 

Rectangle textures can't do mipmapping so you
need to set filtering modes.


-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again.  They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful.  But it happens
every day.  I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address

0
Reply fungus 11/19/2006 4:56:10 PM

fungus wrote:
> Keith S. wrote:
>> Hi Folks,
>>
>> Has anyone an example on how to use the GL_EXT_texture_rectangle 
>> extension
>> to set up a 2D texture?
> 
> I think you just need to replace "GL_TEXTURE_2D"
> with "GL_TEXTURE_RECTANGLE_ARB"

thanks Fungus, however if I try that I get an error that GL_TEXTURE_RECTANGLE_ARB
is undefined... this in on win32 using VC++ 7.1

- Keith
0
Reply Keith 11/19/2006 6:43:34 PM

Keith S. wrote:

> thanks Fungus, however if I try that I get an error that 
> GL_TEXTURE_RECTANGLE_ARB
> is undefined... this in on win32 using VC++ 7.1

ok I defined it manually... the other needed change was
to set texture coords to be in the range 0-w, 0-h rather
than 0-1, 0-1.

- Keith
0
Reply Keith 11/19/2006 8:12:48 PM

Keith S. wrote:

> Keith S. wrote:
> 
>> thanks Fungus, however if I try that I get an error that
>> GL_TEXTURE_RECTANGLE_ARB
>> is undefined... this in on win32 using VC++ 7.1

You need to #include <glext.h>

> ok I defined it manually... the other needed change was
> to set texture coords to be in the range 0-w, 0-h rather
> than 0-1, 0-1.

Yes. Within glsl shaders, this is required, too.

0
Reply Rolf 11/19/2006 8:46:13 PM

Keith S. wrote:
> 
> thanks Fungus, however if I try that I get an error that 
> GL_TEXTURE_RECTANGLE_ARB
> is undefined... this in on win32 using VC++ 7.1
> 

Get glext.h from here:

http://www.opengl.org/registry/


-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again.  They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful.  But it happens
every day.  I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address

0
Reply fungus 11/19/2006 9:02:53 PM
comp.graphics.api.opengl 7099 articles. 24 followers. Post

5 Replies
370 Views

Similar Articles

[PageSpeed] 31


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces: