Texture masking problem
Hey,
I'm currently working on a 2d sideways scrolling game (using orthagonal mode), and I'm having trouble drawing the landscape. What I would like is a polygon rendered at the bottom of the screen and textured, and a sky texture drawn in the background.
I can get the terrain working with no background by:
1. filling the screen black
2. drawing the polygon in white
3. setting the blend function to GL_DST_COLOR, GL_ZERO
4. drawing a rectangle tiled with the texture over the polygon
This, however leaves me no way of drawing the background.
Another approach I tried was to set the clear color to transparent and then:
1. drawing the polygon in opaque white
2. setting the blend function to GL_DST_ALPHA, GL_ZERO
3. drawing the tiled rectangle opaque
4. setting the blend function to GL_ONE_MINUS_DST_ALPHA, GL_ZERO
5. drawing the background
The problem with this method was that it required the framebuffer to have an alpha component, which seemed to make my program run unacceptably slowly.
Is there a better approach to this? I took a look at stencil buffering, but I couldn't get that to work - and it also had a *massive* framerate hit.
for the background dont worry about farting around with blending etc
even though the game is 2d u can still use the depth buffer
ie draw the polygon/s with the background on it far away (or just turn off depth writes)
now all the other onjs will be drawn over it
even though the game is 2d u can still use the depth buffer
ie draw the polygon/s with the background on it far away (or just turn off depth writes)
now all the other onjs will be drawn over it
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement