Copy screen & render with OpenGL
-
Hi, i am writing an app that copies the screen, warps/distorts the image, then draws it back. I already got the code working in a visualization i am making for Windows Media Player but for some reason it won't work now.
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);enableBlend();
glColor4f(1.0f, 1.0f, 1.0f, 0.9f);
renderBackground(wf); // Render warped backgroundenableTexture(image);
glBegin(GL_QUADS); // Draw image over background
glTexCoord2f(0, 1); glVertex2f(0, 0);
glTexCoord2f(0, 0); glVertex2f(0, 512);
glTexCoord2f(1, 0); glVertex2f(512, 512);
glTexCoord2f(1, 1); glVertex2f(512, 0);
glEnd();glBindTexture(GL_TEXTURE_2D, backTexture);// Copy image to texture
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0);disableTexture();
disableBlend();That's basically it, renderBackground() draws the texture over a grid of warp points which is stored in a WarpFile object. The enable/disable methods are just wrappers for the OpenGL commands. Is there anything i am doing wrong? I tried pbuffers do copy/render to but it was too hard. If you need me to post more code (like the renderBackground method) just ask thanks
-------------------------------- Customer in computer shop: "Can you copy the Internet onto this disk for me?"
-
Hi, i am writing an app that copies the screen, warps/distorts the image, then draws it back. I already got the code working in a visualization i am making for Windows Media Player but for some reason it won't work now.
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);enableBlend();
glColor4f(1.0f, 1.0f, 1.0f, 0.9f);
renderBackground(wf); // Render warped backgroundenableTexture(image);
glBegin(GL_QUADS); // Draw image over background
glTexCoord2f(0, 1); glVertex2f(0, 0);
glTexCoord2f(0, 0); glVertex2f(0, 512);
glTexCoord2f(1, 0); glVertex2f(512, 512);
glTexCoord2f(1, 1); glVertex2f(512, 0);
glEnd();glBindTexture(GL_TEXTURE_2D, backTexture);// Copy image to texture
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0);disableTexture();
disableBlend();That's basically it, renderBackground() draws the texture over a grid of warp points which is stored in a WarpFile object. The enable/disable methods are just wrappers for the OpenGL commands. Is there anything i am doing wrong? I tried pbuffers do copy/render to but it was too hard. If you need me to post more code (like the renderBackground method) just ask thanks
-------------------------------- Customer in computer shop: "Can you copy the Internet onto this disk for me?"
I FIXED IT! These are the 3 lines directly before the code above:
if (bgType = BG_BLUR)
renderBlur(wf, 20, 0.2f);
else if (bgType = BG_WARP) {
// All of the above code is here
}See something wrong? I didn't until just then. = instead of == !!! I can't believe i made such a simple mistake. I know everyone makes silly mistakes but i seem to be getting == confused with = a lot lately. Sorry if i'm rambling on, i just had to say this. That one bug has really been pissing me off :mad::confused::wtf::(:((
-------------------------------- Customer in computer shop: "Can you copy the Internet onto this disk for me?"
-
I FIXED IT! These are the 3 lines directly before the code above:
if (bgType = BG_BLUR)
renderBlur(wf, 20, 0.2f);
else if (bgType = BG_WARP) {
// All of the above code is here
}See something wrong? I didn't until just then. = instead of == !!! I can't believe i made such a simple mistake. I know everyone makes silly mistakes but i seem to be getting == confused with = a lot lately. Sorry if i'm rambling on, i just had to say this. That one bug has really been pissing me off :mad::confused::wtf::(:((
-------------------------------- Customer in computer shop: "Can you copy the Internet onto this disk for me?"
VizCoder wrote:
That one bug has really been p...
You should consider switching to a modern programming language ... :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
I FIXED IT! These are the 3 lines directly before the code above:
if (bgType = BG_BLUR)
renderBlur(wf, 20, 0.2f);
else if (bgType = BG_WARP) {
// All of the above code is here
}See something wrong? I didn't until just then. = instead of == !!! I can't believe i made such a simple mistake. I know everyone makes silly mistakes but i seem to be getting == confused with = a lot lately. Sorry if i'm rambling on, i just had to say this. That one bug has really been pissing me off :mad::confused::wtf::(:((
-------------------------------- Customer in computer shop: "Can you copy the Internet onto this disk for me?"
Get in the habit of doing this: if (BG_WARP == bgType) That won't compile with the single =
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )