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 4 of 5 Topic 4881 of 5017
Post > Topic >>

Re: Texture Fit to Window

by Wolfgang Draxinger <wdraxinger@[EMAIL PROTECTED] > Aug 22, 2008 at 02:52 PM

Knockr wrote:

> 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 = w;
>       win_w = h;
> 
>        // Reset coordinate system
>        glMatrixMode(GL_PROJECTION);
>        glLoadIdentity();
>        glOrtho(0, win_w, 0, win_h, -1.0, 1.0);
> 
>        glMatrixMode(GL_MODELVIEW);
>        glLoadIdentity();
>        glutPostRedisplay();
> }

Here's some advice: Don't do it that way. glView****t and setting
the matrices are very cheap calls. The best practice to do the
whole setup just right before the rendering. So your display()
function would look like

void display()
{
        glView****t(0, 0, win_w, win_h);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, win_w, 0, win_h, -1.0, 1.0);

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        
        /* render that stuff */
}

the reshape function would simplify to something like

void ChangeSize(int w, int h)
{
        win_w = w;
        win_h = h;
        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

Well, did you try GL_GLAMP (just CLAMP, nothing more)? Normally,
if there's no border supplied, GL_CLAMP_TO_BORDER should exhibit
the same behavior as GL_CLAMP, but some drivers might break
that.

Oh, and something I totally missed before: You actually _made_
some mistake: TEXTURE_RECTANGLE textures are addressed in
absolute pixels, not in relative [0, 1]^n coordinates, so you've
to write:

glEnable(GL_TEXTURE_RECTANGLE_ARB);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, TextureImage[i]->texID);

GLint tex_w = TextureImage[i]->sizeX;
GLint tex_w = TextureImage[i]->sizeY;

glBegin(GL_QUADS);
glTexCoord2i(0, 0);
glVertex2f(0.0, 0.0);

glTexCoord2i(tex_w, 0);
glVertex2f(win_w, 0.0);

glTexCoord2i(tex_w, tex_h);
glVertex2f(win_w, win_h);

glTexCoord2i(0, tex_h);
glVertex2f(0.0, win_h);
glEnd();


Wolfgang Draxinger
-- 
E-Mail address works, Jabber: hexarith@[EMAIL PROTECTED]
 ICQ: 134682867
 




 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:45:04 CST 2008.