Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Graphics > OpenGL 3D API > Re: Texture Fit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 5 Topic 4881 of 5017
Post > Topic >>

Re: Texture Fit to Window

by Knockr <CSarath@[EMAIL PROTECTED] > Aug 22, 2008 at 05:25 AM

On Aug 22, 4:00=A0pm, Wolfgang Draxinger <wdraxin...@[EMAIL PROTECTED]
>
wrote:
> 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,
> > =A0 =A0 =A0 TextureImage[i]-> sizeX, TextureImage[i]->sizeY,
> > =A0 =A0 =A0 0, GL_RGB, GL_UNSIGNED_BYTE,
> > =A0 =A0 =A0 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); =A0 =A0 =A0 glVertex2f(0.0, 0.0);
> > glTexCoord2f(1, 0.0); glVertex2f(win_w, 0.0);
> > glTexCoord2f(1, 1); =A0 =A0 =A0 =A0 =A0 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: hexar...@[EMAIL PROTECTED]
 ICQ: 134682867

Thanks for your reply.

my code for the same would look as follows

void ChangeSize(int w, int h)
{
       // Set View****t to window dimensions
       glView****t(0, 0, w, h);

	win_h =3D w;
	win_w =3D h;

       // Reset coordinate system
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       glOrtho(0, win_w, 0, win_h, -1.0, 1.0);

       glMatrixMode(GL_MODELVIEW);
       glLoadIdentity();
       glutPostRedisplay();
}

the extra ****tion of the displaying window look as black when
CLAMP_TO_EDGE parameter. Otherwise the something like repeat effect.
but the texture never rendered full view****t
 




 5 Posts in Topic:
Texture Fit to Window
Knockr <CSarath@[EMAIL  2008-08-22 02:21:22 
Re: Texture Fit to Window
Wolfgang Draxinger <wd  2008-08-22 13:00:57 
Re: Texture Fit to Window
Knockr <CSarath@[EMAIL  2008-08-22 05:25:37 
Re: Texture Fit to Window
Wolfgang Draxinger <wd  2008-08-22 14:52:06 
Re: Texture Fit to Window
Knockr <CSarath@[EMAIL  2008-08-27 04:00:36 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 4:32:48 CST 2008.