0

I draw a tile map on screen and each tile light(grayscale) in a FBO. All are quads.

I store the view in a Rect. To move I change de Rect, then I do this...

glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(getViewRect().left, 
            getViewRect().left + getViewRect().width,
            getViewRect().top + getViewRect().height, 
            getViewRect().top, 
            -1, 
            1);
glMatrixMode(GL_MODELVIEW);

I only draw the tiles inside the Rect.

The problem is the FBO. I have to draw the same tiles( the lights of the tiles), that are visible.

I want to know if there is a better way than, drawing the same tiles to the fbo with the offset of the tiles, drawing a smaller quad on the borders when is not completly visible, and changing texcoord, because when I draw outside the FBO, it draw on the opposite side.

I use FBO, because I apply shader to the lights.

It works perfect if I dont move the view, but if I move I dont know how to draw on the FBO.

Quaternion
  • 10,380
  • 6
  • 51
  • 102

1 Answers1

0

You ought to be able to use glScissor to restrict all drawing within the FBO. Perform this operation after calling glBindBuffer(...) each time you bind it.

Hope this helps!

Ani
  • 10,826
  • 3
  • 27
  • 46
  • Hi,Im new to opengl and now I know about glScissor. – Martina Dec 11 '12 at 11:58
  • To draw the fbo(1) I bind the fbo texture and draw a fullscreen quad over the fbo(0). When I move the view I draw the quad, passing the ViewRect to the vertex, but it move faster than the fbo(0). – Martina Dec 11 '12 at 12:05
  • I don't understand - could you please post the actual and desired output so I can better understand your problem? – Ani Dec 11 '12 at 14:47