Results 1 to 10 of 10

Thread: Texture problem

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    108

    Texture problem

    I have a problem with texture not showing on the cube

    code:
    void LoadGLTextures()
    { AUX_RGBImageRec *text;
    if(!(text=auxDIBImageLoad("RedStar.bmp"))) printf("error");
    glGenTextures(1,&texturename[1]);
    glBindTexture(GL_TEXTURE_2D,texturename[0]);
    glTexImage2D(GL_TEXTURE_2D,0,3,text->sizeX,text->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,text->data);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
    }

    part of display code

    glBindTexture(GL_TEXTURE_2D,texturename[0]);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f,1.0f);
    //glColor3f(1.0f,0.0f,0.0f);
    glVertex3f(-0.5f,0.5f,0.5f);
    glTexCoord2f(0.0f,0.0f);
    glVertex3f(-0.5f,-0.5f,0.5f);
    glTexCoord2f(1.0f,0.0f);
    glVertex3f(0.5f,-0.5f,0.5f);
    glTexCoord2f(1.0f,1.0f);
    glVertex3f(0.5f,0.5f,0.5f);

    and GL_TEXTURE_2D is enabled

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2001
    Location
    Germany, Hannover
    Posts
    160

    Re: Texture problem

    glGenTextures(1,&texturename[1]);

    should be:
    glGenTextures(1,texturename);
    or:
    glGenTextures(1,&texturename[0]);
    because you use the [0]th element of the array, so get a valid textureobj for it, and not for the next element in the array ...

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    108

    Re: Texture problem

    i have fixed that but still the same - no texture on cube

  4. #4
    Senior Member Regular Contributor
    Join Date
    May 2001
    Location
    Germany, Hannover
    Posts
    160

    Re: Texture problem

    sorry, cant see any other errors, maybe the bmp is not loaded, or the dimensions of the texture are not n^2, or you call the binds between glBegin(); glEnd(); ...
    try to use a 1d texture, and use as data some array like:
    data[8]= { 0, 1, and so on
    when it work, your bmp isnt loaded correct or in the correct dimensions

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    108

    Re: Texture problem

    bitmap is 128*128 I created it .
    and there is testing for file load
    but i will try it your way

  6. #6
    Senior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Australia
    Posts
    431

    Re: Texture problem

    Send the app and texture to me (e-mail in profile, remove "nospam") if you like and I'll have a look on Sunday Australian time (day after tomorrow). It could be a number of things.

    Hope that helps.

  7. #7
    Guest

    Re: Texture problem

    you wouldnt be fred fish would you from the classic amiga collecion of PD discs?

  8. #8
    Senior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Australia
    Posts
    431

    Re: Texture problem

    No, sorry

  9. #9
    Senior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Australia
    Posts
    431

    Re: Texture problem

    Vlasko,

    I tried to e-mail the code to you but it didn't work so here are my changes:

    (i) You must put your init() function after all the GLUT initialisation code, in the line after glutCreateWindow. This is why the texture wasn't being bound properly.

    (ii) The depth testing you are doing is making other problems with the display. Comment out the two lines in your init() function that enable depth testing and the depth func to use.

    (iii) There are other problems with the program but making those two changes will get you started. If you have any other questions post them and someone will be glad to help.

    E-mail me if you need any more help with this program or you don't understand my explanations.

    Hope that helps.

  10. #10
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    108

    Re: Texture problem

    Thanks It works but I get now problem with rotating the yellow part of texture disappears when I rotate cube . It's a problem with graphics card or something else (like VC++ 6.0 ... )I'm using CL 5446 as primary graphics card( crapy but I'll try Voodoo 2 (crapy too - but still works) later

Similar Threads

  1. Render to texture problem or problem in approach
    By Taimoorak in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-07-2018, 06:04 AM
  2. Replies: 1
    Last Post: 01-10-2005, 09:50 AM
  3. Replies: 0
    Last Post: 01-09-2005, 06:01 PM
  4. Replies: 0
    Last Post: 01-09-2005, 05:53 PM
  5. Replies: 1
    Last Post: 01-09-2005, 05:50 PM

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