Leath Muller | 3 Mar 01:08 2003
Picon

Re: overlays with wgl.

Thomas Kuriakose wrote:
> 
> 
> Thank you Mr.Muller, 
> 
>  I would have that looked into. In any case, could you tell me how I could go ahead using overlays or point me to
some place on the net. 
> 
>  and one another doubt. this might seem stupid. :D
> 
>  if i need to develop opengl apps for linux, i would need an opengl sdk for linux, right? I just cannot seem to
find one at Nvidia? What am I doing wrong?
> 
> thanking you in advance,
> tom.

Oops, did I ever get back to you on this? I apologise if I
didn't!!!

Leathal.

----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

--

-- 
Author: Leath Muller
  INET: leathm <at> gbrmpa.gov.au

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
(Continue reading)

Santeri Hernejärvi | 5 Mar 21:20 2003
Picon

Re: Non-square (but power of 2) textures

Pierre Terdiman wrote:
> Hi,
> 
> I have a newbie question about rectangular (but still power-of-2) 
> textures. Are they supported in OpenGL, yes or no ? 

Yes, they're supported.

> What I'm seeing is 
> very confusing. Here are the details :
> 
> - I haven't been using GL for years, but I once implemented a GL 
> renderer in some game company. By the time it was only naked GL 1.0 
> using square textures.
> 
> - Then I used D3D for some years, using non-square textures without 
> thinking about it.
> 
> - Now I'm trying to port the D3D engine back to GL, and I have troubles 
> with non-square textures.

AFAIK, what works in D3D, works in OpenGL.

> - At first it seemed like they were not supported, as written in some 
> Nehe tutorial. And indeed when I had one in a scene, it appeared as pure 
> white. But later I realized it was just because of mipmap. If I 
> turn mipmap off, it seems to work (only tested on a Radeon 9000).

Thats probably something else.  Do you check for opengl errors?

(Continue reading)

Gribb, Gil | 5 Mar 21:25 2003

RE: Non-square (but power of 2) textures [bcc][fake adr]

It has to do with the smallest mipmaps....OpenGL is slightly different and assuming I recall correctly the sizes go like this for example a 128x32
 
128x32
64x16
32x8
16x4
8x2
4x1
2x1
1x1
 
maybe you don't have the last two.
-Gil
-----Original Message-----
From: Pierre Terdiman [mailto:p.terdiman <at> wanadoo.fr]
Sent: Wednesday, March 05, 2003 1:35 PM
To: Multiple recipients of list OPENGL-GAMEDEV-L
Subject: Non-square (but power of 2) textures [bcc][fake adr]

Hi,

I have a newbie question about rectangular (but still power-of-2) textures. Are they supported in OpenGL, yes or no ? What I'm seeing is very confusing. Here are the details :

- I haven't been using GL for years, but I once implemented a GL renderer in some game company. By the time it was only naked GL 1.0 using square textures.

- Then I used D3D for some years, using non-square textures without thinking about it.

- Now I'm trying to port the D3D engine back to GL, and I have troubles with non-square textures.

- At first it seemed like they were not supported, as written in some Nehe tutorial. And indeed when I had one in a scene, it appeared as pure white. But later I realized it was just because of mipmap. If I turn mipmap off, it seems to work (only tested on a Radeon 9000).

- But now I see there's also an EXT_texture_rectangle extension. This is confusing me even more since it looks like it doesn't support mipmap either. So what's the benefit of using this, if it's the same as without the extension ? And where's TEXTURE_RECTANGLE_EXT defined ?

- Finally, in short, how do I get back mipmapping with non-square textures ? I assume the underlying hardware is ok with that since it works in D3D.

Thanks,

- Pierre
www.codercorner.com


Eero Pajarre | 5 Mar 21:48 2003
Picon

Re: Non-square (but power of 2) textures

Pierre Terdiman wrote:
> Hi,
> 
> I have a newbie question about rectangular (but still power-of-2) 
> textures. Are they supported in OpenGL, yes or no ? What I'm seeing is 
> very confusing. Here are the details :
> 

Non square power of two textures are ok in OpenGL, no extensions needed.
(I think the extension is for not-power-of-2 textures)

If you use mipmaps you just have to provide them all. gluBuild2DMipmaps
can do it for you, if you want to do it yourself, here is an example of
sequence of texture level sizes for different mipmap levels, starting
from level-0 texture 256x64.

256x64
128x32
64x16
32x8
16x4
8x2
4x1
2x1
1x1

from (old) Mesa sources here is the code for getting the texture
size from previous (larger) mipmap size:

       if (w == 1 && h == 1)
	 break;

       neww = (w < 2) ? 1 : w / 2;
       newh = (h < 2) ? 1 : h / 2;

		
		Eero

----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

--

-- 
Author: Eero Pajarre
  INET: epajarre <at> koti.soon.fi

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru <at> fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Pierre Terdiman | 5 Mar 21:55 2003
Picon

Re: Non-square (but power of 2) textures

>maybe you don't have the last two.

What do you mean ? I'm using gluBuildMipmaps most of the time so I guess it
should compute all required mipmaps, shouldn't it ?

> Yes, they're supported.

I'm very glad to hear that :)

> Thats probably something else.  Do you check for opengl errors?

I don't think so, but I'll do that.

> The texture rectangle extension allows non-power-of-two textures.

Certainly, what puzzles me is that it seems to work just as well *without*
the extension. Also, the documentation for this extension explicitely states
mipmaps are *not* supported. Whereas Gil seems to say mipmaps do work with
"native" non-square textures. So it's very confusing.

> If they're ^2, it should work as usual.  The easiest way it so use
> gluBuildMipmaps or the GENERATE_MIPMAP extension.

I'll try that extension I didn't know about.

Meanwhile, here's the code, in case you can spot an obvious bug :

bool GLTexture::Load(const Picture& pic)
{
 // 1) Call the base method
 if(!Texture::Load(pic)) return false;

 // 2) GL business
 glGenTextures(1, &mID);
 glBindTexture(GL_TEXTURE_2D, mID);
 GLboolean Status = glIsTexture(mID);

 sdword GLFormat;
 switch(mTF)
 {
  case TF_16_555:
   GLFormat = GL_RGB5;
   break;
  case TF_16_1555:
   GLFormat = GL_RGB5_A1;
   break;
  case TF_16_4444:
   GLFormat = GL_RGBA4;
   break;
  case TF_16_565:
   GLFormat = GL_RGB5; // No 565 in GL
   break;
  case TF_32_888:
   GLFormat = GL_RGB8;
   break;
  case TF_32_8888:
   GLFormat = GL_RGBA8;
   break;
  case TF_DXT1:
  case TF_DXT2:
  case TF_DXT3:
  case TF_DXT4:
  case TF_DXT5:
  case TF_CHOOSE_BEST:
   // "Some words of advice about internal texture formats: If you do not
request a specific internal resolution for your texture image
   // because you requested a GL_RGBA internal format instead of a
size-specific internal format such as GL_RGBA8 or GL_RGBA4, your OpenGL
   // implementation is free to pick the ``most appropriate'' format for the
particular implementation. If a smaller texture format has
   // better texturing performance, the implementation is free to choose the
smaller format. This means if you care about maintaining a
   // particular level of internal format resolution, selecting a
size-specific texture format is strongly recommended."
   GLFormat = GL_RGBA8; // We consider it's the best
   break;
 }

 if(1) // various code paths to try to make it work with non-square textures
 {
  if(mNbMipMap) gluBuild2DMipmaps(GL_TEXTURE_2D, GLFormat, mWidth, mHeight,
GL_RGBA, GL_UNSIGNED_BYTE, pic.GetPixels());
  else   glTexImage2D(GL_TEXTURE_2D, 0, GLFormat, mWidth, mHeight, 0,
GL_RGBA, GL_UNSIGNED_BYTE, pic.GetPixels());
 }
 else
 {
  glTexImage2D(GL_TEXTURE_2D, 0, GLFormat, mWidth, mHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, pic.GetPixels());
  if(mNbMipMap)
  {
   // Catch current mipmap generator
   MipmapGenerator Default;
   const MipmapGenerator* MG = mRenderer ? mRenderer->GetMipmapGenerator() :
&Default;

   // Loop through mipmaps
   for(udword i=1;i<mNbMipMap;i++)
   {
    // Compute current mipmap picture
    Picture MipMap;
    if(MG) MG->CreateMipmap(MipMap, pic, i);

//    udword Min = MIN(MipMap.GetWidth(), MipMap.GetHeight());
//    if(Min>=64)
    {
     glTexImage2D(GL_TEXTURE_2D, i, GLFormat, MipMap.GetWidth(),
MipMap.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, MipMap.GetPixels());
    }
   }
  }
 }

 // Make sure we only capture the texture pointer (is that useful? What
exactly does glBindTexture capture ?)
 glBindTexture(GL_TEXTURE_2D, mID);

 // Just checking
 GLboolean IsResident;
 glAreTexturesResident(1, &mID, &IsResident);

 return true;
}

----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

--

-- 
Author: Pierre Terdiman
  INET: p.terdiman <at> wanadoo.fr

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru <at> fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Eric Lengyel | 5 Mar 21:55 2003

Re: Non-square (but power of 2) textures

> I have a newbie question about rectangular (but still power-of-2) textures.
> Are they supported in OpenGL, yes or no ? What I'm seeing is very confusing.

> - At first it seemed like they were not supported, as written in some Nehe
> tutorial. And indeed when I had one in a scene, it appeared as pure white. But
> later I realized it was just because of mipmap. If I turn mipmap off, it seems
> to work (only tested on a Radeon 9000).

Hi --

Yes, non-square power-of-two textures are supported in OpenGL.  I suspect
that your mipmapping problem stems from the fact that OpenGL requires mipmap
levels to be defined all the way down to 1x1.  For non-square textures, this
means that more than one of the smallest mipmap levels will have a dimension
of only 1 pixel wide.  Once your smaller dimension reaches 1, keep dividing
your other dimension by 2 until it reaches 1 as well.

> - But now I see there's also an EXT_texture_rectangle extension. This is
> confusing me even more since it looks like it doesn't support mipmap either.
> So what's the benefit of using this, if it's the same as without the extension
> ? And where's TEXTURE_RECTANGLE_EXT defined ?

The GL_EXT_texture_rectangle (a.k.a. GL_NV_texture_rectangle) extension
provides support for NON-power-of-two texture images.  They can be whatever
size you want, but there are restrictions.  First, as you pointed out, no
mipmapping.  Second, only clamp wrap modes are supported (GL_CLAMP,
GL_CLAMP_TO_EDGE_EXT, and GL_CLAMP_TO_BORDER_ARB).  And third, you can't use
normalized [0,1] texture coordinates, but instead must use texture
coordinates that range from 0 to the actual width and height of the texture
image, in pixels.

-- Eric Lengyel

* Learn about the new book "The OpenGL Extensions Guide" coming this summer!
* Stop by the Charles River Media booth (#1039) at GDC.

----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

--

-- 
Author: Eric Lengyel
  INET: lengyel <at> C4Engine.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru <at> fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Arkadi Shishlov | 5 Mar 23:20 2003
Picon

Re: Non-square (but power of 2) textures

On Wed, Mar 05, 2003 at 01:19:32PM -0800, Pierre Terdiman wrote:
> So I guess it's actually "working", except the rectangular texture appears as pure white - probably
because of something else. Any idea what could be wrong ?

Did you set MIN/MAG_FILTER parameters with glTexParameter()?

arkadi.
----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

--

-- 
Author: Arkadi Shishlov
  INET: arkadi <at> it.lv

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru <at> fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Jon Watte | 6 Mar 00:53 2003

RE: Non-square (but power of 2) textures


I can't recommend the OpenGL specification (version 1.4 available as PDF
from www.opengl.org) enough. It's excellent. Get it and read it, especially
the part about MIP map completeness.

Basically, if you request MIP mapping, but haven't specified all MIP map
level images (down to the 1x1 image), then the texture isn't complete and
it'll behave as if texturing is turned off. This is the spec. You can say
that you only want to specify levels M through N to get around this, by
setting TexParameters for TEXTURE_BASE_LEVEL and TEXTURE_MAX_LEVEL (and/or
TEXTURE_MIN_LOD and TEXTURE_MAX_LOD).

OpenGL does support rectangular, power-of-two-on-each-side, textures, plus
the border size. The rectangular texture extension is for non-power-of-two
sizes.

Cheers,

                / h+

-----Original Message-----
Sent: Wednesday, March 05, 2003 11:35 AM
To: Multiple recipients of list OPENGL-GAMEDEV-L

Hi,

I have a newbie question about rectangular (but still power-of-2) textures.
Are they supported in OpenGL, yes or no ? What I'm seeing is very confusing.
Here are the details :

- I haven't been using GL for years, but I once implemented a GL renderer in
some game company. By the time it was only naked GL 1.0 using square
textures.

- Then I used D3D for some years, using non-square textures without thinking
about it.

- Now I'm trying to port the D3D engine back to GL, and I have troubles with
non-square textures.

- At first it seemed like they were not supported, as written in some Nehe
tutorial. And indeed when I had one in a scene, it appeared as pure white.
But later I realized it was just because of mipmap. If I turn mipmap off, it
seems to work (only tested on a Radeon 9000).

- But now I see there's also an EXT_texture_rectangle extension. This is
confusing me even more since it looks like it doesn't support mipmap either.
So what's the benefit of using this, if it's the same as without the
extension ? And where's TEXTURE_RECTANGLE_EXT defined ?

- Finally, in short, how do I get back mipmapping with non-square textures ?
I assume the underlying hardware is ok with that since it works in D3D.

Thanks,

- Pierre
www.codercorner.com

----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

--

-- 
Author: Jon Watte
  INET: hplus <at> mindcontrol.org

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru <at> fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Jon Watte | 6 Mar 00:53 2003

RE: Non-square (but power of 2) textures


>  // Just checking
>  GLboolean IsResident;
>  glAreTexturesResident(1, &mID, &IsResident);

A texture isn't resident just because it's bound. You need to 
draw some geometry using it, and Finish(), to "make sure" it's 
resident. Evenso, some implementations call all textures 
resident. Others call no textures resident.

Lesson: trust OpenGL to do the texture management. It won't 
forget about the image once you handed it to it.

Cheers,

				/ h+

----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

--

-- 
Author: Jon Watte
  INET: hplus <at> mindcontrol.org

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru <at> fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Arkadi Shishlov | 6 Mar 00:38 2003
Picon

Re: Non-square (but power of 2) textures

On Wed, Mar 05, 2003 at 02:54:40PM -0800, Sebastien Domine wrote:
> The clamp mode has to be GL_CLAMP or GL_CLAMP_TO_EDGE.
> No mipmap filtering - ie only Nearest.

Linear is allowed too and actually works by default, both for
minification and magnification.

arkadi.
----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

--

-- 
Author: Arkadi Shishlov
  INET: arkadi <at> it.lv

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru <at> fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).


Gmane