Results 1 to 7 of 7

Thread: More texture problems: here we go....again!

  1. #1
    Member Contributor
    Join Date
    Jul 2008
    Posts
    52

    More texture problems: here we go....again!

    Hello again friends.

    I was just trying to map a texture to a glut solid sphere using automatic texture coordinates. After some hours studying, I realize this won't be so easy (holy sh*t!! there is no ease way with gfx!). The way to go right is using cube map, but I'm struggling to figure out how the hell this thing work!

    After loading a texture and building it with gluMipmap2D, I just set the following lines of code before drawing the sphere:

    Code :
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
    glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
     
    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);
     
    //Do I really need the R coordinate???
    glEnable(GL_TEXTURE_GEN_R);
     
    glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRAP_S,GL_REPEAT);
    glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRAP_T,GL_REPEAT);
    glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRAP_R,GL_REPEAT);
     
    glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
     
    glEnable(GL_TEXTURE_CUBE_MAP);
    glEnable(GL_TEXTURE_2D);
     
    glBindTexture(GL_TEXTURE_2D, TextEstrada);
     
    glutSolidSphere(10,32,16);

    The problem is as follows:



    this is Mars, lol. I can see the side of Mars, until...



    ...I turn the camera! The texture is always facing me!

    PS> I didn't set the 6 sides for the textures 'cause I tried this and I had a problem, the render got crazy and the problem above didn't go.

    Regards!

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: More texture problems: here we go....again!

    try with this instead :
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

  3. #3
    Member Contributor
    Join Date
    Jul 2008
    Posts
    52

    Re: More texture problems: here we go....again!

    Same thing.

  4. #4
    Member Contributor
    Join Date
    Jul 2008
    Posts
    52

    Re: More texture problems: here we go....again!

    I just want to texture a torus or a sphere. Is this the correct way to do using automatic texture generation?

  5. #5
    V-man
    Guest

    Re: More texture problems: here we go....again!

    Are you going to apply a cubemap or a 2D texture?
    You are calling
    Code :
    glEnable(GL_TEXTURE_CUBE_MAP);
    glEnable(GL_TEXTURE_2D);
     
    glBindTexture(GL_TEXTURE_2D, TextEstrada);

    If it is for cubemap, then you MUST bind a cubemap.

  6. #6
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: More texture problems: here we go....again!

    It's probably tricky to get a cubemap Mars image to apply. In addition things suggested like spheremap texgen happen in eyespace and you want an object space mapping so the texture moves with the planet. You could do this with a cubemap, but you'd be as well just drawing a sphere conventionally with polar coordinates mapping a lat/long image from NASA, unless you're concerned about extreme anisotropy at the poles.

    So I suggest you make your own sphere and map your own coordinate, read the following tutorial:

    http://www.swiftless.com/tutorials/opengl/sphere.html

  7. #7
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: More texture problems: here we go....again!

    P.S. I think a glut sphere may map polar coords anyway in which case you need only bind a lat/long texture image.

Similar Threads

  1. Problems Texture Mapping with Float Texture
    By CelticBlues in forum OpenGL: GLSL
    Replies: 21
    Last Post: 02-08-2009, 04:13 AM
  2. Texture problems
    By ThePatient in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-15-2003, 08:23 AM
  3. Texture Problems ...
    By Saintex in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 07-22-2002, 07:38 AM
  4. Texture Problems
    By spectrum in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 01-09-2002, 02:58 AM
  5. AVI texture problems
    By dmsy in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-12-2000, 01:09 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