Results 1 to 5 of 5

Thread: how do i draw 2d textures on screen

  1. #1
    Member Contributor
    Join Date
    Feb 2011
    Posts
    72

    how do i draw 2d textures on screen

    can some one help me here
    i just need to place textures on the screen that will stay in the same position and have no depth just screen size coordinates just like text

  2. #2
    Member Contributor
    Join Date
    Feb 2011
    Posts
    72

    Re: how do i draw 2d textures on screen

    i think its like this but there is no details
    do i have to make a polygon?

    The simplest way to do this is to draw your scene normally, then switch to an orthographic projection, turn off depth testing and place the texture with screen coordinates

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Karachi, Pakistan
    Posts
    810

    Re: how do i draw 2d textures on screen

    texture with screen coordinates
    True only if you are working with rectangle textures otherwise u would need to issue normalized uv coordinates (0-1)
    You will also have to draw a 2D quad on screen (two triangles will do).
    Regards,
    Mobeen

  4. #4
    Member Contributor
    Join Date
    Feb 2011
    Posts
    72

    Re: how do i draw 2d textures on screen

    but i dont want to then billboard the quads
    cant i just have a flat texture on the screen
    as if i was using photoshop

  5. #5
    Member Contributor
    Join Date
    Feb 2011
    Posts
    72

    Re: how do i draw 2d textures on screen

    ok i got it
    looked at how i was drawing text
    copied that and placed a quad in there and it werks
    plz let me know if i can take some code out from here, or optimize, modify something
    as to me this code looks a bit funky

    void DrawImage(void) {

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0.0, glutGet(GLUT_WINDOW_WIDTH), 0.0, glutGet(GLUT_WINDOW_HEIGHT), -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();


    glLoadIdentity();
    glDisable(GL_LIGHTING);


    glColor3f(1,1,1);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, mark_textures[0].id);


    // Draw a textured quad
    glBegin(GL_QUADS);
    glTexCoord2f(0, 0); glVertex3f(0, 0, 0);
    glTexCoord2f(0, 1); glVertex3f(0, 100, 0);
    glTexCoord2f(1, 1); glVertex3f(100, 100, 0);
    glTexCoord2f(1, 0); glVertex3f(100, 0, 0);
    glEnd();


    glDisable(GL_TEXTURE_2D);
    glPopMatrix();


    glMatrixMode(GL_PROJECTION);
    glPopMatrix();

    glMatrixMode(GL_MODELVIEW);

    }

Similar Threads

  1. How to draw text in the screen ?
    By Washiro in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-24-2012, 05:58 AM
  2. How to draw a screen aligned QUAD?
    By apapaxionga in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-16-2011, 05:46 AM
  3. How can I draw a quad that covers the whole screen
    By ei05tbe in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-14-2010, 10:19 AM
  4. How to draw 2 bezier curves on the same screen?
    By shidosh in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-06-2005, 03:20 AM
  5. How do I draw to the entire screen?
    By aktech in forum OpenGL: Windows
    Replies: 1
    Last Post: 05-05-2004, 07:21 PM

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