Results 1 to 6 of 6

Thread: textures?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    102

    textures?

    How do I import textures? Is there any easy way, does somebody have any kind of xtra libraries or something??? And as a subquestion, whats an arc fillet, and how do I use one???
    CyBBe

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

    Re: textures?

    Import textures, just load a bitmap ... it's no harder than that.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    102

    Re: textures?

    Exactly how do I import a bitmap, I asked for an easy way, can U give me some code examples???
    CyBBe

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2000
    Location
    ...
    Posts
    28

    Re: textures?

    hi,
    check this out...
    www.codeguru.com
    nehe.gamedev.net

  5. #5
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    102

    Re: textures?

    Someone else, som xtra libraries???
    CyBBe

  6. #6
    Member Contributor
    Join Date
    Feb 2000
    Location
    Brisbane,QLD, Australia
    Posts
    99

    Re: textures?

    Originally posted by CyBBe:
    Someone else, som xtra libraries???
    Here you go.. This should tide you over for awhile.
    ///////////////////////////////////////////////////////////////////////////////
    // This function loads a 24-bit color (RGB)Windows bitmap and sets it as the current
    // texture. The bitmap must be 24-bit color, and the dimensions must be powers
    // of 2 (no additional checks are performed).
    ///////////////////////////////////////////////////////////////////////////////

    loadBitmap(char* filename)
    {
    FILE* bmpfile;
    BITMAPFILEHEADER bmfileheader;
    BITMAPINFOHEADER bminfoheader;
    RGBTRIPLE rgb;

    int nTextureWidth;
    int nTextureHeight;
    int i,j,texpos = 0;
    BYTE *pBitmapData;

    bmpfile = fopen(filename, "rb");

    if (!bmpfile)
    exit(1);

    fread(&bmfileheader, sizeof(BITMAPFILEHEADER), 1, bmpfile);
    fread(&bminfoheader, sizeof(BITMAPINFOHEADER), 1, bmpfile);


    nTextureWidth = bminfoheader.biWidth;
    nTextureHeight = bminfoheader.biHeight;

    pBitmapData = (GLubyte*)malloc(nTextureWidth * nTextureHeight *3);

    // read color
    for (i = 0; i < nTextureWidth; i++)
    {
    for(j = nTextureHeight - 1; j>=0 ; j--) //start with the height because the first data you read in the color array of the bitmap
    { // is coord (1.0).
    fread(&rgb, sizeof(RGBTRIPLE),1,bmpfile);
    pBitmapData[texpos] = rgb.rgbtRed ;
    pBitmapData[texpos+1] = rgb.rgbtGreen;
    pBitmapData[texpos+2] = rgb.rgbtBlue;
    }
    }
    fclose(bmpfile);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
    glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, nTextureWidth, nTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pBitmapData);
    return TRUE;

    }


    [This message has been edited by dans (edited 03-27-2000).]

Similar Threads

  1. Applying textures to a sphere. I know nothing about textures.
    By ElFlautas in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-28-2018, 03:47 AM
  2. model textures being redirected to font textures
    By Tcll5850 in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 09-07-2014, 10:43 PM
  3. FBO Attached Textures Reused as Shader Source Textures
    By Rennie Johnson in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-22-2012, 09:43 PM
  4. Lots of small textures or fewer large textures?
    By jlamanna in forum OpenGL: Advanced Coding
    Replies: 30
    Last Post: 01-12-2004, 03:53 AM
  5. are GL_COLOR_INDEX textures converted to RGBA-Textures?
    By TB-Rex in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 12-18-2000, 06:34 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