Results 1 to 7 of 7

Thread: Draw Texture in Actual Size

  1. #1
    Member Contributor
    Join Date
    May 2001
    Location
    Malaysia
    Posts
    54

    Draw Texture in Actual Size

    Hai...I'm really bad in english.I hope this can be understanded.

    How can I draw texture in its actual size? I mean if I have 600x800 texture size,I want to draw it perfectly 600x800 in opengl app without distortion/blur/stratch. I want it perfectly like wallpaper.

    I've tried pasted it on 800x600 quad, switch to orthographic projection but it still stratched!

    How about glReadPixel and glDrawPixel? I've never use it but I know they read from the frame buffer to memory and draw from memory to frame buffer.But how to put the texture to the frame buffer without stretched it? Is the frame buffer reffer to the whole thing that appear on the screen?

    Please help.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,574

    Re: Draw Texture in Actual Size

    Stretch the texture to 1024x1024 and then texture it onto an 800x600 size quad. That should eliminate any distortions. If you want to make sure there are no distortions, don't use bilinear filtering when stretching the texture (in whatever art program you use to stretch it) and don't use filtering in OpenGL to draw it.

  3. #3
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,342

    Re: Draw Texture in Actual Size

    You don't even need to strech it. You could have it at 800x600 and let the rest of the texture up to 1024x1024 be black then use texturecoords (0,0) to (800/1024, 600/1024). With point sampling (GL_NEAREST) you should get a perfect copy, like blitting it in there.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Feb 2001
    Posts
    108

    Re: Draw Texture in Actual Size

    you might encounter a problem with very large textures:
    some older cards (voodoo2) canīt handle textures larger than 256x256, that means if you want to be on the safe side, you would need to split your 800x600 texture to several 256x256 (and 32*256 / 256*32 / 32*32) textures and polygonquads of corresponding size.

  5. #5
    Member Contributor
    Join Date
    May 2001
    Location
    Malaysia
    Posts
    54

    Re: Draw Texture in Actual Size

    Hai!

    I've try to use GL_NEAREST but it's still stretch! OK,here's what the actual problem.I want to put my logo with some text under it at the begining of my app.It's my intro like those game have(their company logo).

    Korval,
    I've stretch my texture to 1024x1024 and paste it on my 600x600 QUADS but it's still blur especially for text.

    Humus,
    I've add the rest of the texture up to 1024x1024 and paste on 1024x1024 QUADS,display it on the centre of the screen,but it still blur especially for text.But what do you mean by "use texturecoords (0,0) to (800/1024, 600/1024)"?

    What I do now to minimize this problem is to use bitmap font for the text and let the logo remain as texture.But I don't like this way much because the logo is still blur and I don't think the text will be resolution independent.May be the text will be smaller when I run my app in higher resolution.

    Can it be something wrong with my texture loader? I use 3D Exploration bmp loader.I also have several type of loader which I found at internet but all of them give the same result.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Dec 1969
    Location
    Munich,Germany
    Posts
    227

    Re: Draw Texture in Actual Size

    Code :
    GLint          viewport[4];		glGetIntegerv(GL_VIEWPORT, viewport);
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    gluOrtho2D(0.0, (GLfloat)(viewport[2] - viewport[0]),
    	   0.0, (GLfloat)(viewport[3] - viewport[1]));
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
     
    glTexCoord2d(0.0,0.0);
    glVertex2d(viewport[2]-400,viewport[3]-300);
    glTexCoord2d(0.0,(double)600/1034);
    glVertex2d(viewport[2]-400,viewport[3]+300);
    .
    .
    .
    .
    That should do the trick for u

    Chris
    yes

  7. #7
    Member Contributor
    Join Date
    May 2001
    Location
    Malaysia
    Posts
    54

    Re: Draw Texture in Actual Size

    Hai...

    I've try everything what you guys told. After many days, I still can't do what I want.

    But this morning, I found that maybe the problem occurs because of my 3D card or texture loader function. If I use 1024x1024 and 512x512 texture, both of them give the same quality!

    So, do you know what's in my mind? I think the big texture is shrinked to 512x512 before stored in memory! Thats why I can't have a perfect copy of texture for 800x600!

    So I split it into several 256x256 manualy using paint brush, tiled it and lastly, I have a perfect copy.

    So, I make a conclusion. My Vodoo3 2000 can't handle large texture(above 256x256) perfectly. If I want to use something larger than that, I've to split it.

    So, if anybody has any opinion, agree or disagree, or can load large texture perfectly using the same card as me, please let me know.

    P/S: Sorry for so many "so"

Similar Threads

  1. Mapping from rednerbuffer size to texture size for glow effect
    By 2Wheels in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-11-2013, 04:16 PM
  2. How to draw an image in it's real size in 3d space
    By pixelita in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 05-18-2011, 04:16 AM
  3. How draw a constant size object in all zoom?
    By ncn213 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-31-2009, 02:29 PM
  4. Best way to draw infinite size grid?
    By Jengu in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 07-03-2006, 05:02 PM
  5. Getting actual viewport size in pixels...
    By M/\dm/\n in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-29-2004, 10:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean