PDA

View Full Version : I want to make a texture from a gray scale byte matrix ?



02-06-2001, 06:57 AM
hi,

I have an image as a matrix of gray scale tones.

Img = array[0..TEXSIZE, 0..TEXSIZE] of byte =
10 5 8 25 40 45 30 23 ......
40 45 28 35 70 43 55 54 ......
10 35 48 55 90 45 50 65 ......
60 55 58 28 38 42 60 34 ......
..............................
..............................
And I want to use this gray scale map as texture. I have tried this
glTexImage2D(GL_TEXTURE_2D, 0, 1, TEXSIZE, TEXSIZE, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, pointer(Img));

byte I get an Access violation error.
How can I make this texture.

Relic
02-06-2001, 07:16 AM
- TEXSIZE must be power of two.
- internalformat should be set to GL_LUMINANCE.
- Check glPixelStorei(GL_UNPACK_ALIGNMENT,..)
Default is 4 and could crash with 2x2 and 1x1 maps.