Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Is it possible to render a texture on screen?

  1. #1
    Junior Member Regular Contributor
    Join Date
    Aug 2010
    Posts
    115

    Is it possible to render a texture on screen?

    Hi,

    I am learning openGL now. But I found that it is very complicated with the vertex value. I dont even know what values should I put in order to draw a simple cube. So, I plan to draw out a texture that I import from an image directly. Is it possible?

    There are a lots of array in openGL. I am totally lost here. What kind of array should I use for texture?

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Is it possible to render a texture on screen?


  3. #3
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: Is it possible to render a texture on screen?

    A cube? Make it -1.0 to 1.0.

    No, you can't draw a texture. You can only texturemap polygons.

    What kind of array to use for a texture?
    Assuming your image data is RGBA8, declare your array as
    GLubyte *myarray = new GLubyte[w*h*4];

    You might want to read the Red Book.
    This is the online version of the first Red Book.
    http://fly.cc.fer.hr/~unreal/theredbook/

    and click on
    Chapter 9: Texture Mapping
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •