Jump to content
  • Advertisement
Sign in to follow this  
plopper

Flickering but not double buffer related

This topic is 2720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've injected my dll into another process and am attempting to draw on it. I have hooked wglSwapBuffers and am drawing there.
I am unsure why it is flickering (only the box is flickering not the whole screen), maybe im doing something wrong in my draw function?

I know double buffering is enabled because of this:


int WINAPI myChoosePixelFormat(HDC hdc,CONST PIXELFORMATDESCRIPTOR *ppfd)
{
if (ppfd->dwFlags & PFD_DOUBLEBUFFER) MessageBox(0,"double buffering enabled.","",0);
return oChoosePixelFormat(hdc,ppfd);
}

Here is how i draw:


void APIENTRY mywglSwapBuffers(HDC hDC)
{
Draw();
owglSwapBuffers(hDC);
}


void Draw()
{
POINT pos;
GetCursorPos(&pos);
ScreenToClient(FindWindow(NULL,"Game26"),&pos);

GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
GLfloat winX, winY, winZ;
GLdouble posX, posY, posZ;

glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
glGetDoublev( GL_PROJECTION_MATRIX, projection );
glGetIntegerv( GL_VIEWPORT, viewport );

winX = (float)pos.x;
winY = (float)viewport[3] - (float)pos.y;
glReadPixels( pos.x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );

gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);

glPushAttrib(GL_ACCUM_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_EVAL_BIT | GL_FOG_BIT | GL_HINT_BIT | GL_LIGHTING_BIT | GL_LINE_BIT | GL_LIST_BIT | GL_PIXEL_MODE_BIT | GL_POINT_BIT | GL_POLYGON_BIT | GL_POLYGON_STIPPLE_BIT | GL_SCISSOR_BIT | GL_STENCIL_BUFFER_BIT | GL_TEXTURE_BIT | GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);

oglBegin(GL_LINE_STRIP);
glVertex2f(posX,posY); // top line start
glVertex2f(posX+100.0f,posY); // top line end
glVertex2f(posX+100.0f,posY+100.0f); // right line
glVertex2f(posX,posY+100.0f); // bottom line
glVertex2f(posX,posY); // back to top
glEnd();

glPopAttrib();

}

Any ideas on how to stop the flickering?

**EDIT**

disregard, was my drawing function. should have debugged better. I should have been drawing like this:


void Draw()
{
float posX = 100.0f, posY = 100.0f;
glPushAttrib(GL_ACCUM_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_EVAL_BIT | GL_FOG_BIT | GL_HINT_BIT | GL_LIGHTING_BIT | GL_LINE_BIT | GL_LIST_BIT | GL_PIXEL_MODE_BIT | GL_POINT_BIT | GL_POLYGON_BIT | GL_POLYGON_STIPPLE_BIT | GL_SCISSOR_BIT | GL_STENCIL_BUFFER_BIT | GL_TEXTURE_BIT | GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);

glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
glDisable(GL_TEXTURE_2D);

oglBegin(GL_LINE_STRIP);
glVertex2f(posX,posY); // top line start
glVertex2f(posX+100.0f,posY); // top line end
glVertex2f(posX+100.0f,posY+100.0f); // right line
glVertex2f(posX,posY+100.0f); // bottom line
glVertex2f(posX,posY); // back to top
glEnd();

glEnable(GL_TEXTURE_2D);
glPopAttrib();
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!