PDA

View Full Version : Binding 16Bit textures?


ChrisD
2003.04.10, 02:43 AM
Binding 16Bit tesxtures?

Basically how to do I load a texture in... 16 bits and or compressed formates etc to the video card using AGL.

Right now I have RGBA formate textures working just fine..

Mark Levin
2003.04.10, 02:49 AM
Change the internalFormat parameter of glTexImage2D to cause OpenGL to store the texture differently.

However, hardware texture compression is a whole other ball of wax and has to be enabled manually as an extension, AFAIK.

Frank C.
2003.04.10, 03:14 AM
Internal formats...

16bit = GL_RGB5 / GL_RGB5_A1 (or GL_RGBA4)
24/32bit = GL_RGB8 / GL_RGBA8
Compressed = GL_COMPRESSED_RGB / GL_COMPRESSED_RGBA

That's ARB compression - the hardware will use it's native compression, but this has nothing to do with the image format on disk, it's just compressed in memory, so load times may get longer. Texture swaps can be way faster with this simple compression enabled, but the image quality will suffer a bit.

ChrisD
2003.04.10, 03:23 AM
tes

ChrisD
2003.04.10, 03:26 AM
Originally posted by Frank C.
[B]Internal formats...

16bit = GL_RGB5 / GL_RGB5_A1 (or GL_RGBA4)
24/32bit = GL_RGB8 / GL_RGBA8
Compressed = GL_COMPRESSED_RGB / GL_COMPRESSED_RGBA


Second try to reply here... browsers keep giving me errors...

Ok there are what I am looking for...
Could not find directions on how to use them.

So now...

1. what is 24/32?

2. In RAVE I could do things like ... IIRC...

a. 16 bit RGB + 1 bit A
b. 16 bit RGB + 8 bit A

How can I do those formats if even possible?

Frank C.
2003.04.10, 05:36 AM
1. what is 24/32?
24bit (8bits per channel, no alpha) or 32bit (8bits per channel, plus 8bit alpha)

2. In RAVE I could do things like ... IIRC...

a. 16 bit RGB + 1 bit A
b. 16 bit RGB + 8 bit A

How can I do those formats if even possible?
GL_RGB5 will give you 16bit RGB with no alpha (R5G5B5A0 not sure where that extra bit goes), GL_RGB5_A1 gives you 16bit RGB with 1bit alpha (R5G5B5A1), and GL_RGBA4 gives you 16bit with 4bit alpha, but the colour channels take a hit (R4G4B4A4). GL_RGB5_A1 usually looks better than GL_RGBA4, but it depends on the texture.

I don't think 16 bit RGB + 8 bit A is possible though (?)

Could not find directions on how to use them.
Here's a glTexImage2D breakdown...

glTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
target: GL_TEXTURE_2D normally, 1D or 3D if ya get fancy.

level: mip map level (0 for full res mip)

internalformat: This is where the one of formats posted earlier would go.

width, height, border: texture dimensions and border size.

format: GL_RGB, or GL_RGBA - My GF3 seems to like GL_BGR(A)

type: usually GL_UNSIGNED_BYTE or one of apple's packed pixel types (eg. GL_UNSIGNED_INT_8_8_8_8_REV)

*pixels: pointer to your texture buffer

ChrisD
2003.04.11, 01:43 PM
First off Thanx...

Second when you say...

My GF3 seems to like GL_BGR(A)

How do you know?

Did you read this?
Or does FPS go up?
etc...

Frank C.
2003.04.11, 02:59 PM
The fastest settings on my GF3 seem to be GL_BGR(A) format with GL_COMPRESSED_RGB(A) internal format, and GL_UNSIGNED_BYTE type (packed pixels makes no difference). This is in a test project of mine swapping 3-5 big (1Kx1K) textures every frame. I haven't done any comparisons recently though...

Using the rectangle extension, with client storage and AGP hint is really fast on OSX, but there needs to be a separate path for other OS's or cards that don't support the rectangle extension - check Apple's developer site for the "OpenGLFastTexDemo"

ChrisD
2003.04.12, 03:48 AM
Originally posted by Frank C.
The fastest settings on my GF3 seem to be GL_BGR(A) format with GL_COMPRESSED_RGB(A) internal format, and GL_UNSIGNED_BYTE type (packed pixels makes no difference). This is in a test project of mine swapping 3-5 big (1Kx1K) textures every frame. I haven't done any comparisons recently though...

Using the rectangle extension, with client storage and AGP hint is really fast on OSX, but there needs to be a separate path for other OS's or cards that don't support the rectangle extension - check Apple's developer site for the "OpenGLFastTexDemo"

Ok so far so good.
Got the 16bot modes working :)
Got the client storage working.

Questions...

Hmm whats he AGP hint... not seeing in the apple ext docs etc.

And Oh yeah.. THANKs for all the help...
One day I promise this will ship... :)

OneSadCookie
2003.04.12, 04:55 AM
The 'AGP hint' is setting the texture's priority to zero. As of Mac OS X 10.1, and only on Mac OS X, the driver treats this as a hint that the texture should reside in AGP memory rather than in VRAM.

ChrisD
2003.04.12, 05:31 AM
Originally posted by OneSadCookie
The 'AGP hint' is setting the texture's priority to zero. As of Mac OS X 10.1, and only on Mac OS X, the driver treats this as a hint that the texture should reside in AGP memory rather than in VRAM.

Ok now someone needs to tell me.

Whats the differences between AGP mem and Vram
since I have never heard of AGP mem before...

OneSadCookie
2003.04.12, 06:17 AM
AGP memory is a section of the main memory of the computer which has been 'mapped' so that transfers from that memory to VRAM are particularly fast. This means it has all of the properties of main memory and many of the properties of VRAM :)

ChrisD
2003.04.12, 04:08 PM
Originally posted by OneSadCookie
AGP memory is a section of the main memory of the computer which has been 'mapped' so that transfers from that memory to VRAM are particularly fast. This means it has all of the properties of main memory and many of the properties of VRAM :)

Any idea HOW much of it there is on any machine?

OneSadCookie
2003.04.12, 08:43 PM
It's probably capped at the amount of the VRAM the card has, but I don't actually know.

NYGhost
2003.05.01, 01:23 PM
GL allows to specify lots of formats, but you will get better performance by sticking to a few formats.

I use RGB and RGBA in my project.
Also may help to look at:

http://developer.apple.com/samplecode/Sample_Code/Graphics_3D/OpenGLFastTexDemo.htm

Mars_999
2003.05.01, 11:58 PM
I don't know either how Apple has their MB setup but on a PC you set the amount of RAM you want to allocate to the AGP. If I remember right the allowable amount is a % of your total RAM. You will have to look into it, due to I am unsure for Macs.:sorry: