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 7 of 7

Thread: help with semantics of Texture Mapping Units and sampler2D

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Intern Newbie
    Join Date
    Apr 2008
    Location
    California
    Posts
    45

    Question help with semantics of Texture Mapping Units and sampler2D

    A few years ago I asked a question about the semantics of texture units and shader2D uniform variables. The answers I got were rather rigid in their outlook:

    https://www.opengl.org/discussion_bo...-Mapping-Units

    I gave up then, but I'm back.

    I'm looking for a 'clean' way to abstract my code away from explicitly assigning texture units (GL_TEXTURE3 etc.) to sampler2D variables. I am using an Nvidia GTX960 and OpenGL reports it has just 4 texture units. The 0th texture unit is reserved for the fixed pipeline so there are really only three available. If I wish to use various sampler2D GLSL uniform variables I, rather obviously, don't care which texture unit they employ. What methods are commonly used to abstract away the necessary relationship?

    I'd like to have some OpenGL code to find a 'free' texture unit anytime I want to address a GLSL shader2D variable. When one writes in C there is no need to know how many registers the CPU has or the assignment of variables to them. The compiler does all of that. I can't change OpenGL or GLSL but I can attempt to hide the need to make manual 'register' assignments.

    There is a level of indirection/assignment that is getting in the way of my writing a 'clean' approach.
    Last edited by Clive; 12-17-2017 at 11:28 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
  •