PDA

View Full Version : texture mapping - Image size



sarahippo
05-08-2003, 09:50 AM
Hi, everyone.
I am trying do some texture mapping.
I know that the image size should be in the form of 2^n. (ie. 2, 4, 8, 16, etc.)
The problem is the size of my image is 144(width) by 66(height). Is there any way to map this image on a surface without modifying it?
Thanks!!!

gator
05-08-2003, 10:18 AM
Put your 144x66 image on a 256x128 texture,
and only map to the 144x66 part.

Brian Jones
05-08-2003, 10:40 AM
There is also the GL_NV_texture_rectangle extension which allows you to use non-power of two texture dimensions. But there are several limitations, such as no border, or mipmapping, and you must specify the coordinates in image width and image height.
Also, it for nVidia hardware only. But there seems to be (GL_EXT_texture_rectangle) an undocumented extension (Not on SGI's page) for ATI cards. It uses the same constant values as the NV extension, but you should still check the documentation for it. It's only on Apple's site (why, I have no idea) It MIGHT be supported on other OS' but I have no idea. Here it is: http://developer.apple.com/opengl/extensions/ext_texture_rectangle.html

[This message has been edited by Brian Jones (edited 05-08-2003).]

sarahippo
05-13-2003, 12:32 PM
Thanks guys for the help!

well, now i am tryting to do 64(height) by 128(width) texture mapping.
However, for some reasons, it is only drawing the half of the image.

here are the settings for my texture mapping. can anyone tell me what is wrong with this code?

#define imageWidth 64
#define imageHeight 128

...other stuff.......

GLubyte image[3*imageWidth*imageHeight];
GLfloat textps[2][2][2] = {{{0.0,0.0}, {0.0, 1.0}},{{1.0,0.0}, {1.0,1.0}}};

...other stuff for drawing a surface...

void makeImage(void)
{

... the stuff....

}

void init(void)
{

glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, &texpts[0][0][0]);
glEnable(gl-map2_texture_coord);
makeImage();
glTexEnvf(gl_texture_env, gl_texture_env_mode, gl_blind);
glTexParameteri(gl_texture_2d, gl_texture_wrap_s, gl_repeat);
glTexParameteri(gl_texture_2d, gl_texture_wrap_t, Gl_repeat);
glTexParameteri(gl_texture_2d, gl_mag_filter, gl_nearest);
glTexParameteri(gl_texture_2d, gl_texture_min_filter, Gl_nearest);
glTexImage2D(GL_TEXTURE_2D, 0, 3, imageWidth, imageHeight, 0, GL_RGB, GL_UNSIGHED_BYTE, image);
glEnable(GL_TEXTURE_2D);
}

please let me know if there is anything missing or if I need to delete any.
Thanks!!

Gavin
05-13-2003, 11:49 PM
1. You can check you are loading your texture correctly using drawpixels just to draw it to the screen.
2. Show us how your bind it to your polygon