I'm building a browser plugin which will draw pictures as a slideshow inside browser windows, however the plugin I created only draws on first plugin instance. If I open multiple instances of the plugin, it keeps on drawing on the first plugin window overlapping each picture.
I'm using opengl to draw picture from the url.
Following is a code which draws dummy opengl tringles in a loop using a thread:
FB::PluginWindowWin *pluginWindowWin = dynamic_cast(pluginWindow);
EnableOpenGL(pluginWindowWin->getHWND(), &hDC, &hRC);
SetFocus(pluginWindowWin->getHWND());
//FB::
static int fps = 1;
GLfloat rotate = 0;
static double start = 0, diff, wait;
wait = 1 / fps;
//return 0;
while (true)
{
//lets check for keyboard input
try
{
FB::Rect pos = pluginWindow->getWindowPosition();
PAINTSTRUCT ps;
if (pluginWindowWin){
hDC = BeginPaint(pluginWindowWin->getHWND(), &ps);
pos.right -= pos.left;
pos.left = 0;
pos.bottom -= pos.top;
pos.top = 0;
rotate += 0.1f;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotate, 0.0f, 1.0f, 0.0f);
glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f); glVertex2f(0.0f, 1.0f);
glColor3f(0.0f, 1.0f, 0.0f); glVertex2f(0.87f, -0.5f);
glColor3f(0.0f, 0.0f, 1.0f); glVertex2f(-0.87f, -0.5f);
glEnd();
glBegin(GL_QUADS); // Draw A Quad
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-0.5f, 0.5f, 0.0f); // Top Left
glColor3f(0.0f, 1.0f, 0.0f); glVertex3f(0.5f, 0.5f, 0.0f); // Top Right
glColor3f(0.0f, 0.0f, 1.0f); glVertex3f(0.5f, -0.5f, 0.0f); // Bottom Right
glColor3f(0.0f, 0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad
glPopMatrix();
glRotatef(rotate, 0.0f, 1.0f, 0.0f);
SwapBuffers(hDC);
}
//rtri+=0.1f;
::SetTextAlign(hDC, TA_CENTER | TA_BASELINE);
LPCTSTR pszText = _T("FireBreath Plugin!\n:-)");
::TextOut(hDC, pos.left + (pos.right - pos.left) / 2, pos.top + (pos.bottom - pos.top) / 2, pszText, lstrlen(pszText));
if (pluginWindowWin) {
// Release the device context
EndPaint(pluginWindowWin->getHWND(), &ps);
}
}
catch (...)
{
return 0;
}
Sleep(10);
}//end of while run
Any thing I'm doing wrong here?