Results 1 to 3 of 3

Thread: Use GL_TEXTURE_ENV_COLOR in the second texture stage.

  1. #1

    Use GL_TEXTURE_ENV_COLOR in the second texture stage.

    Working with the fixed pipeline, assuming that in the first texture unit a texture is dot(3)ted with the primary color (set using glColor4f), is it possible (and how) in the second texture unit to modulate the result from previous stage with GL_TEXTURE_ENV_COLOR ?

    In the detail, I need to realize the follwing operation (without to bind a 1x1 texture containing color1 in the second texture unit):

    out = (tex0 dot3 color0) * color1

    I tried with:

    Code :
    glActiveTexture(GL_TEXTURE0);
    glColor4f(color0.r, color0.g, color0.b, color0.a);
    glEnable(texture.target);
    glBindTexture(texture.target, texture.glHandle);
    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGBA);
    // the first stage (tex0 dot3 color0) works fine!
     
    glActiveTexture(GL_TEXTURE1);
    glTexEnvfv(GL_TEXTURE_ENV, GL_TEX_ENV_COLOR, color1);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
    but it doesn't work.

    Thanks in advance!
    AmanithVG Lead Programmer

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Use GL_TEXTURE_ENV_COLOR in the second texture stage.

    You must have a valid texture bound to texture unit 1 and texturing must be enabled, even if you're not using the result from that texture. It's an odd API restriction that dates back to the time when OpenGL had no COMBINE texture environment.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3

    Re: Use GL_TEXTURE_ENV_COLOR in the second texture stage.

    Quote Originally Posted by Xmas
    You must have a valid texture bound to texture unit 1 and texturing must be enabled, even if you're not using the result from that texture. It's an odd API restriction that dates back to the time when OpenGL had no COMBINE texture environment.
    Many thanks Georg!
    AmanithVG Lead Programmer

Similar Threads

  1. Texture Objects and texture management
    By alh in forum OpenGL ES general technical discussions
    Replies: 4
    Last Post: 02-13-2005, 02:19 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
  •