PDA

View Full Version : glDrawPixels stops working



Lindley
08-28-2010, 01:42 PM
I have a framebuffer object with a single floating point renderbuffer attached to color buffer 0.

I do a glDrawBuffer/glWindowPos(0,0)/glDrawPixels() combo at several points in my program in order to populate this renderbuffer prior to additional rendering. The idea is to put a background image into it first.

The first time I do this, it works fine. However, subsequent calls to glDrawPixels produce no obvious result, and no glGetError() indications of a problem either. The render still works fine but the background image is missing.

I've managed to narrow it down to the following block of code. The download at the beginning works; after this, it doesn't:



glViewport(0,0,w,h);

glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(bounds.x,bounds.x+bounds.w,bounds.y,bounds .y+bounds.h,0,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

Vector2d vert;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
err = glGetError();
glBegin(GL_TRIANGLES);
for (unsigned i = 0; i < hyps.size(); ++i)
{
const Cluster &amp;c = hyps[i].getCluster();
int inds[3];
getTriInds(c.triind,inds);

if (c.type == CLUSTER)
glColor4d(0.0,1.0,0.0,0.8);
else
glColor4d(1.0,0.0,0.0,0.8);
for (int k = 0; k < 3; k++)
{
vert = getVert(inds[k]);
glVertex2d(vert[0],vert[1]);
}
}
glEnd();

err = glGetError();

GLUquadric *quadric = gluNewQuadric();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslated(gpsloc[0],gpsloc[1],0);
glDisable(GL_LIGHTING);
glColor4d(1,.6,.3,1);
gluDisk(quadric,3.0,6.0,64,2);
gluDeleteQuadric(quadric);

glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);

err = glGetError();


Any ideas? Is glDrawPixels affected by the depth buffer or something?

arekkusu
08-30-2010, 09:33 AM
Drawpixels produces fragments. Those fragments are affected by the fragment shader, fog, depth testing, blending... everything.

BionicBytes
09-02-2010, 10:43 AM
if you have a 2D projection, then chances are you don't want depth testing - so disable with glDisable (GL_DEPTH_TEST).
That would most likely stop subsequent drawpixels commands...