Sign in to follow this  
Darkeye

Texture masking problem

Recommended Posts

Darkeye    134
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.

Share this post


Link to post
Share on other sites
zedzeek    528
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this