Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Multitexturing does not works

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2008
    Location
    Russia - Samara - Togliatti
    Posts
    7

    Multitexturing does not works

    Hello.
    I use multitexturing as described in tutorials:
    At first, I declare function's pointers as globals:
    Code :
    PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
    PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2f;
    Then, I initialize them:
    Code :
    glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress ("glActiveTextureARB");
    glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2fARB");
    Loading texture as GL_TEXTURE0_ARB
    Code :
    glGenTextures(1, &unTexture[0]);
    glBindTexture(GL_TEXTURE_2D, unTexture[0]);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imageWidth, imageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, ilGetData());
     
    glActiveTextureARB(GL_TEXTURE0_ARB);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, unTexture[0]);
    And mapping texture to polygon:
    Code :
    glActiveTextureARB(GL_TEXTURE0_ARB);
    glBindTexture(GL_TEXTURE_2D, unTexture[0]);
    glEnable(GL_TEXTURE_2D);
    glBegin(GL_QUADS);
    glMultiTexCoord2f(GL_TEXTURE0_ARB, 1, 1);
    glTexCoord2f(1, 1);
    glVertex3d(1, 1, 1);
    glMultiTexCoord2f(GL_TEXTURE0_ARB, 1, 0);
    glTexCoord2f(1, 0);
    glVertex3d(1, 0, 1);
    glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 0);
    glTexCoord2f(0, 0);
    glVertex3d(-1, 0, 1);
    glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 1);
    glTexCoord2f(0, 1);
    glVertex3d(-1, 1, 1);
    glEnd();
    glDisable(GL_TEXTURE_2D);
    I checked up returned by wglGetProcAddress() - they are not NULL.
    But texture mapping does not works at all. But if replace "unTexture[0] by "0" (which is the default texture) it works, but, of course, only for one texture. It looks like my video card does not support multitexturing (but it does).
    Tell me, please, what can be wrong?

  2. #2
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Multitexturing does not works

    Maybe I am wrong, but I did think it is possible to use glMultiTexCoord* and glTexCoord* at the same time. If I wanted to map 2 textures with 2 texture units 0 and 1.
    Actually, what is the matter glTexCoord* calls in your code?

    You should:
    - active TU0
    -- bind texture
    -- enable 2D texturing
    - active TU1
    -- bind texture
    -- enable 2D texturing

    - set texture coordinates for TU0 (glMultiTexCoord)
    - set texture coordinates for TU1 (glMultiTexCoord)
    -- draw polygons

    - active TU0
    -- disable 2D texturing
    - active TU1
    -- disable 2D texturing

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2008
    Location
    Russia - Samara - Togliatti
    Posts
    7

    Re: Multitexturing does not works

    I do so:
    Code :
    void LoadTexture(char *imageName)
    {
    	ilLoadImage(imageName);
    	int imageWidth = ilGetInteger(IL_IMAGE_WIDTH);
    	int imageHeight = ilGetInteger(IL_IMAGE_HEIGHT);
    	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imageWidth, imageHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, ilGetData());
    	ilDeleteImage(0);
    }
    Loading texture:
    Code :
    LoadTexture("CatEye.bmp");
    glActiveTextureARB(GL_TEXTURE0_ARB);
    glBindTexture(GL_TEXTURE_2D, 0);
    glEnable(GL_TEXTURE_2D);
    And mapping texture:
    Code :
    glEnable(GL_TEXTURE_2D);
    glBegin(GL_QUADS);
    glMultiTexCoord2f(GL_TEXTURE0_ARB, 1, 1);
    glVertex3d(1, 1, 1);
    glMultiTexCoord2f(GL_TEXTURE0_ARB, 1, 0);
    glVertex3d(1, 0, 1);
    glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 0);
    glVertex3d(-1, 0, 1);
    glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 1);
    glVertex3d(-1, 1, 1);
    glEnd();
    glDisable(GL_TEXTURE_2D);
    It works only for GL_TEXTURE0_ARB. If replace it by some other value in loading and mapping, it will not work. And program always tries to use last loaded texture and it does not make a difference wich GL_TEXTUREX_ARB I use.
    What's wrong?
    And it would be perfect to look at a working example.

  4. #4
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Multitexturing does not works

    If I assume you want to apply 2 textures on a polygon, what do you do with these textures? Do you blend, add, ... them?
    You can configure this with:
    glTexEnv

    Or use a shader.

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2008
    Location
    Russia - Samara - Togliatti
    Posts
    7

    Re: Multitexturing does not works

    At least, I want to map textures to a difference polygons which must be rendered in the scene at the same moment. My scene requires 3 textures and without multitexturing I must to load them every 1/45 seconds - that's what I do now. But my video card supports 8 simultaneous 2048:2048 textures, what's would be more preferably to use multitexturing. But I can't!
    What's the problem? (Code is the same as above).

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,651

    Re: Multitexturing does not works

    Quote Originally Posted by Lator
    What's wrong?
    Post a small, compilable test program, and I bet someone will have time to take a look at it.

    And it would be perfect to look at a working example.
    The OpenGL red book probably has some. They're all over the net as well:

    * The ARB_multitexture extension
    * NeHe - Lesson 22
    * Clockwork Coders: Tutorial 8
    * Tutorial 22: Multitexturing

    Just google for OpenGL multitexturing.

    Multitexturing isn't that different from single texturing. You set up and bind your textures to texture units in the same way. You enable the right texture units, set how you want them to "combine" with each other, and render.

    However, your last post suggests you don't really want multitexturing (multiple textures applied to one polygon), but rather would just like to try and minimize texture binds by binding, say, the next 8, and then just render a bunch of polys, each of which uses only 1 of the 8 textures. Is this what you're trying to do? If so, you need shaders.

    Again, a small compilable test program would do wonders for clarity and understanding. Sample glGetError() after each call and make sure you've got GL_NO_ERROR. Then post it if you don't figure it out.


  7. #7
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Multitexturing does not works

    glBindTexture(GL_TEXTURE_2D, 0)
    So you unbind the texture here? Or is it a typo?

    I don't really know much about multitexturing or ARB combiners, as I never learned them (who would, if you have shaders), but AFAIK the multitexture is applied in layers. That is, you combine the results from texture 0 with texture 1, texture 2 etc. If you just enable texture 1 without enabling the 0, it probably won't work (speculation!). Try using two textures.

  8. #8
    Junior Member Newbie
    Join Date
    Jun 2008
    Location
    Russia - Samara - Togliatti
    Posts
    7

    Re: Multitexturing does not works

    What's the shaders in a short words? Can it serve as equivalent of multitexturing?

  9. #9
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Multitexturing does not works

    Shaders are small programs that run on GPU and allow you do all sorts of things, for example, combine as much textures as you want in a way you want

  10. #10
    Junior Member Newbie
    Join Date
    Jun 2008
    Location
    Russia - Samara - Togliatti
    Posts
    7

    Re: Multitexturing does not works

    Mmm... Ok, anyway, is it preferably to use multitexturing or "Shaders" can substitute it?

Page 1 of 2 12 LastLast

Similar Threads

  1. GPU never works
    By luizdrumond in forum OpenCL
    Replies: 1
    Last Post: 11-26-2012, 06:08 AM
  2. FBO renderbuffer how it works
    By OGNewBee in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-24-2011, 01:01 AM
  3. VERY OT: IT WORKS, ha ha ha ha ha.
    By dabeav in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 01-26-2003, 06:50 AM
  4. OT: Who works for whom?
    By Shag in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-18-2002, 05:34 PM
  5. Mac OS X, everything's carbonized, but nothing works!
    By in forum OpenGL: User Software
    Replies: 0
    Last Post: 03-31-2002, 01:51 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