Jeremy L. Moles
2007-06-06 19:09:48 UTC
I've tried googling and asking this question in various other OpenGL
places with no success--so I figured I'd try here, since I know there
are some OpenGL gurus around. In fact, I was told in #opengl on Freenode
it wasn't possible, but I doubt it sense people have been doing this for
ages used fixed-function OpenGL.
I'm working on a UI toolkit using native OSG objects (no weird
"gluecode" or external library) and have come across something I can't
readily get the answer to.
Imagine an interface "window"; at the minimum you'll have about 9
regions that describe this window:
- upper left and right corners
- lower left and right corners
- top, left, bottom, and right "bars"
- center
Now imagine a texture you want to use as the window's "skin." Ideally,
you'll load an image into the texture and position the TexCoords so that
you can create the illusion of having a true, decorated and composed
window. This is fairly straightforward in concept except for one aspect.
Lets say you want to texture the "top bar" region of your window. Well,
by default, unless this portion of your image (or skin) is cleverly
positioned in the texture itself, there's really no way I know of to
"tile" it across the geometry. You can stretch it across, but this is
often quite ugly.
My question: is it possible in OpenGL to somehow manipulate the texture
matrix (or something else) to only operate on a "sub-region" of a
texture such that you can tile just that portion? CEGUI does this
somehow, but it's API is so abstracted I can't really track it's
implementation down.
I _know_ it's possible using a GLSL shader, but at this point it's
really academic for me to find out how to do it otherwise, I know game
makers have been doing this for years w/out shaders, and it's really
bugging me to find out how! :) Any advice or guidance on the issue would
be enormously appreciated...
places with no success--so I figured I'd try here, since I know there
are some OpenGL gurus around. In fact, I was told in #opengl on Freenode
it wasn't possible, but I doubt it sense people have been doing this for
ages used fixed-function OpenGL.
I'm working on a UI toolkit using native OSG objects (no weird
"gluecode" or external library) and have come across something I can't
readily get the answer to.
Imagine an interface "window"; at the minimum you'll have about 9
regions that describe this window:
- upper left and right corners
- lower left and right corners
- top, left, bottom, and right "bars"
- center
Now imagine a texture you want to use as the window's "skin." Ideally,
you'll load an image into the texture and position the TexCoords so that
you can create the illusion of having a true, decorated and composed
window. This is fairly straightforward in concept except for one aspect.
Lets say you want to texture the "top bar" region of your window. Well,
by default, unless this portion of your image (or skin) is cleverly
positioned in the texture itself, there's really no way I know of to
"tile" it across the geometry. You can stretch it across, but this is
often quite ugly.
My question: is it possible in OpenGL to somehow manipulate the texture
matrix (or something else) to only operate on a "sub-region" of a
texture such that you can tile just that portion? CEGUI does this
somehow, but it's API is so abstracted I can't really track it's
implementation down.
I _know_ it's possible using a GLSL shader, but at this point it's
really academic for me to find out how to do it otherwise, I know game
makers have been doing this for years w/out shaders, and it's really
bugging me to find out how! :) Any advice or guidance on the issue would
be enormously appreciated...