Results 1 to 4 of 4

Thread: Textures

  1. #1
    Blay
    Guest

    Textures

    ops..
    hello there!!!
    i'm having some problems with textures. Can some good soul help with this code ????
    i'm waiting for your important reply

    What i'm doing is something like this:
    (Where FPrimitiveTexture[] is a vector 0..2 of TGLuint and my own Primitive Object Field )


    TextureImage : PTAUX_RGBImageRec;

    glGenTextures( 2, FPrimitiveTexture[0] );

    // Create Nearest Filtered Texture
    glGenTextures(3, FPrimitiveTexture[0]);
    glBindTexture(GL_TEXTURE_2D, FPrimitiveTexture[0]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage^.sizeX, TextureImage^.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage^.data);

    // Create Linear Filtered Texture
    glBindTexture(GL_TEXTURE_2D, FPrimitiveTexture[1]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage^.sizeX, TextureImage^.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage^.data);

    // Create MipMapped Texture
    glBindTexture(GL_TEXTURE_2D, FPrimitiveTexture[2]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR_MIPMAP_NEAREST);
    gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage^.sizeX, TextureImage^.sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage^.data);

    at the end of whole process above the vector FPrimitiveTexture still are ( 0, 0, 0 );
    what's happend ?

    thanks!!!
    _ _
    0 0
    .
    _

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: Textures

    You are wrong with your call to glGenTexture.

    The call declaration is :

    void glGenTextures(
    GLsizei n,
    GLuint * textures
    );

    When you do : glGenTextures(2,FPrim[0]), FPrim[0] is an int and not a pointer to an int.

    The correct call is :

    glGenTextures(2,FPrim);

    or

    glGenTextures(2,&FPrim[0]);

    This will give you the correct texture names.

    Best regards.

    Eric

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Textures

    Another thing to be said here is about the third parameter in glTexImage2D (same with second in gluBuild2DMipMaps): This does not specifies the number of components (as said in MSVC), but rather the format of the generated texture. This is in most cases the same as the seventh argument. However, if you send three as an argument, OpenGL assumes it is three components (and not the format defined as number three, because there is no), and uses a predefined format of three components as resulting textureformat, and this is different between drivers.

    This means that if you load a 24-bit RGB texture, and pass 3 as argument, the resulting texture might (depending on the driver) end up in a 16-bit texture.

    Just a tip then, always pass the same value as third and seventh (or sixth for mipmaps) argument.

  4. #4
    Blay
    Guest

    Re: Textures

    Thanks you guys for the help.

    But doesn't work..
    when i pass something like this: glGenTextures(2,FPrim) or
    glGenTextures(2,@FPrim[0]) i got a error like: 2nd parameter isn't the same as function declaration!!

    i meam, the glGenTexture isn't asking for array or a pointer.
    So let me explain what i'm doing:
    i created a class(object) that has a field array[0..2] of TGLuint and others fields.
    So one of these fields are a type of object, example: 1 => tri
    2 => quad
    .
    .
    .

    But the textures are fixed and individual to each object derived of TPrimitive.
    So when i called TPrimitive.PrimitiveDraw
    just check what kind of primitive are and draw it with glbindtexture applying the texture in protected field...
    i think is very simple, but i can't make it happens.

    It's possible, my idea ???

    still waiting for your important reply

    thanks !!!!

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