Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Texture Units and Mixing - Only One Texture Rendering

  1. #1
    Junior Member Newbie
    Join Date
    May 2017
    Posts
    6

    Texture Units and Mixing - Only One Texture Rendering

    Hey yall,

    So I have been wracking my brain for a solid 3 days now trying to get texture units working for me. I have gone over my code dozens of times comparing it to other sources as well as trying every iteration I can imagine of using texture units. Specifically, my problem is that I have two textures, a wood texture and a face texture, that I'm assigning to two texture units and mixing in my fragment shader. The problem is that only one of these textures is rendering and the mixing is not happening. And if I swap the order in which I'm defining the textures (i.e. face texture before wood texture), then only the wood texture will display. The second texture defined trumps even though it's a different texture unit. Here is a github repo for my OpenGL learning project with the main file and vertex and fragment shaders I'm using.

    If anyone has any insight into my issue I would greatly appreciate the info! Thanks.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,521
    Code :
    texture1 = GLuint(0)
    ....
    glGenTextures(1, texture1)
    With PyOpenGL, you need to use
    Code :
    texture1 = glGenTextures(1)
    or
    Code :
    texture1, texture2 = glGenTextures(2)

    If you absolutely need the C-style interface, the underlying ctypes wrapper can be obtained from OpenGL.raw:
    Code :
    from OpenGL.GL import arrays
    from OpenGL.raw.GL.VERSION.GL_1_1 import glGenTextures
    tex = arrays.GLuintArray.zeros(2)
    glGenTextures(2, tex)
    texture1, texture2 = tex

    In general, if a function takes an "output" array as a parameter, the PyOpenGL wrapper will omit that parameter, allocating the array itself and using it as the function's return value.

    Also, unless you explicitly set OpenGL.SIZE_1_ARRAY_UNPACK=False, glGenTextures(1) returns a single integer, while glGenTextures(n) for n>1 returns an array. If you set OpenGL.SIZE_1_ARRAY_UNPACK=False, it always returns an array.

  3. #3
    Junior Member Newbie
    Join Date
    May 2017
    Posts
    6
    Huzzah! Finally! Thanks for the information. I haven't found any documentation about this case in the PyOpenGL docs since it mostly just redirects you to other various OpenGL tutorials which while helpful don't fully explain the Python implementation. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •