PDA

View Full Version : tiled offscreen textures?



ajbiv
09-14-2009, 07:11 AM
I use an offscreen texture to allow the user to draw a drawing. This works well.

Now I want to make enhancements....

conceptually, I want to change it so that the user is drawing on a set of horizontally tiled textures versus 1 single texture?

Is this possible? Any ideas as to how I could accomplish this?

Dark Photon
09-14-2009, 05:05 PM
conceptually, I want to change it so that the user is drawing on a set of horizontally tiled textures versus 1 single texture?

Is this possible? Any ideas as to how I could accomplish this?
Texture arrays, texture atlas, cube maps, or separate textures.
You're going to have to tell us more about what you're doing with these before we can say any of these would be better than the rest.

For instance, what's stopping you from just bumping up your X texture resolution?

Ilian Dinev
09-14-2009, 05:20 PM
If you're using glCopyTexSubImage2D to paste the dirty rectangle:


RECT DirtyRect; // computed by Brush_Position and Brush_Size
...

foreach_texture{
RECT tempRect;
if(!IntersectRect(&tempRect,&texPositionAndSize,&D irtyRect))continue;
int wid = tempRect.right-tempRect.left;
int hei = tempRect.bottom-tempRect.top;
glCopyTexSubImage2D(...); // x/y/width/height/xoffset/yoffset derived from tempRect and the texture-position onscreen
}

Ilian Dinev
09-14-2009, 05:34 PM
The glCopyTexSubImage2D approach is prone to the following pitfall, though: if the brush/DirtyRect is not completely in the viewport or even some window is partially obscuring it, the copied pixels will have undefined values.

This can be solved in many ways, but maybe the best+easiest would be to use FBOs and draw the brush on each FBO/texture it covers.

ajbiv
09-15-2009, 04:20 PM
ok. you can think of my app as a meter that is drawing intensity as the paper below it scrolls. the paper is my background texture. right now my paper is a single texture that is twice the size of my display (viewport). i change which portion i show from the texture to accomplish the "scrolling" it works, but the paper is real short :)

I then capture the entire image at the end for the user.

i want the "paper" to be infinite or longer that 2x.

does that help? i appreciate the suggestions. i am in the opengl es environment

Dark Photon
09-15-2009, 04:52 PM
i change which portion i show from the texture to accomplish the "scrolling" it works, but the paper is real short :) ... I then capture the entire image at the end for the user. ...i want the "paper" to be infinite or longer that 2x.
Ah, I see. So with infinite length, an open-ended array of textures is probably your best bet. Based on scroll position and zoom factor, you can dynamically decide which segments (textures) are within viewport, and draw just them. Or let GL cull them - your pick.

However, you might consider whether it might not make sense to rerender the raw data within the scroll window directly, rather than save the result off into a textures. Less memory consumption...


opengl es environment
...which is probably a bigger deal on your embedded platform.