Knockr wrote:
> Dear All,
>
> I've created an OpenGL program to load and draw a texture.
> Texture is having 800x600 size. but the window has 1440x900
> pixels size.
>
> the projection is of type orthogonal - glOrtho(0, win_w, 0,
> win_h, -1.0, 1.0);
>
> the texture is loaded as follows
> glTexImage2D( GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB,
> TextureImage[i]-> sizeX, TextureImage[i]->sizeY,
> 0, GL_RGB, GL_UNSIGNED_BYTE,
> TextureImage[i]->data );
>
> the textures are mapped as follows
>
> glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S,
> GL_CLAMP_TO_BORDER);
> glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T,
> GL_CLAMP_TO_BORDER);
> glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER,
> GL_LINEAR);
> glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER,
> GL_LINEAR);
>
> glBegin(GL_QUADS);
> glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
> glTexCoord2f(1, 0.0); glVertex2f(win_w, 0.0);
> glTexCoord2f(1, 1); glVertex2f(win_w, win_h);
> glTexCoord2f(0.0, 1); glVertex2f(0.0, win_h);
> glEnd();
>
> How can make the texture fit to window?
Unh, your code already strechtes the texture to fit the window.
And thanks to the use of GL_TEXTURE_RECTANGLE (which has become
an ARB extension for years, so replace all occurences of
GL_TEXTURE_RECTANGLE_NV with GL_TEXTURE_RECTANGLE_ARB) you also
don't trip into the pitfall, that normal OpenGL textures are
addressed by the texel centers: Texture Rectangle textures are
addressed by texel indices.
So your code looks good so far. So the only thing that you might
have missed, you didn't write it in your post, is the size of
your View****t:
glView****t(0, 0, win_w, win_h);
Ideally put that right before setting the projection matrix.
Actually it would be sufficient if it came right before the
rendering calls, but some buggy OpenGL drivers apply the
view****t only, when the projection matrix is manipulated. I
don't know of any current driver that exposes that behaviour, a
few years ago it was a problem though.
Wolfgang Draxinger
--
E-Mail address works, Jabber: hexarith@[EMAIL PROTECTED]
ICQ: 134682867


|