Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Texturing in OpenGL

Is there any way to texture a bitmap or a jpeg onto say a cube in opengl. Could you provide an example? All the code I've seen on the net creates images within the code. I want to say paste a picture of real bricks onto a cube (made by glutSolidCube(int)).


Comments

  • : Is there any way to texture a bitmap or a jpeg onto say a cube in opengl. Could you provide an example? All the code I've seen on the net creates images within the code. I want to say paste a picture of real bricks onto a cube (made by glutSolidCube(int)).


    The OpenGL SUPERBIBLE is a good reference book for OpenGL.

    There are a number of options for texture mapping in OGL.

    Here is a quick & dirty intro to 2D OGL texture mapping functions


    - glEnable(GL_TEXTURE_2D) - enable state

    - glTexEnvi() - set tex parameters

    - glTexImage2d() - defines a 2D texture image

    - glTexCoord() - specifies the current tex coord


    - load your image (*.bmp)

    BITMAPINFO *bitmap_info;

    LoadBitmap('bitmap.bmp', &bitmap_info) - function to read bitmap info


    - enable 2D texture mapping

    glEnable(GL_TEXTURE_2D);


    - set Tex Parameters

    glTextParameter(... );

    ...


    - define 2d texture image

    glTexImage2D(... ); , use bitmap_info->bmiHeader.biWidth, bitmap_info->bmiHeader.biHeight


    - define tex coord

    glTexCoord(... );


    hope this helps

    DXSlacker




Sign In or Register to comment.