Texturing in OpenGL - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.