OpenGL problems
-
Hi, i am writing a small app for a WMP Visualization. The app can be downloaded here[^] and the viz can be found here[^]. Can someone please have a look at the code and tell me what's wrong. For starters, i want to render an image in the background then warp it and draw it back to the screen. There are some problems with that. I use RAD C++ for the GUI (http://www.radcpp.com). Here is some of the code
//////////////////////////////////////////////////////////////////////////////
// Draws background, then copies the screen to texture
//////////////////////////////////////////////////////////////////////////////
void Graphics::copyToTexture(WarpFile &wf) {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glColor4f(1.0f, 1.0f, 1.0f, 0.8f); renderBackground(wf); // Render warped background glCallList(displayList\[DL\_TEX\_ENABLE\]); glBindTexture(GL\_TEXTURE\_2D, 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(); // Copy image to texture glBindTexture(GL\_TEXTURE\_2D, backTexture); glCopyTexImage2D(GL\_TEXTURE\_2D, 0, GL\_RGBA, 0, 0, 512, 512, 0); glCallList(displayList\[DL\_TEX\_DISABLE\]); glBindTexture(GL\_TEXTURE\_2D,0); SwapBuffers(hdc);
}
It needs to be compiled with Dev-C++, you may need OpenGLUT.dll i forgot to include it in the zip file. Can someone please help me
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
-
Hi, i am writing a small app for a WMP Visualization. The app can be downloaded here[^] and the viz can be found here[^]. Can someone please have a look at the code and tell me what's wrong. For starters, i want to render an image in the background then warp it and draw it back to the screen. There are some problems with that. I use RAD C++ for the GUI (http://www.radcpp.com). Here is some of the code
//////////////////////////////////////////////////////////////////////////////
// Draws background, then copies the screen to texture
//////////////////////////////////////////////////////////////////////////////
void Graphics::copyToTexture(WarpFile &wf) {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glColor4f(1.0f, 1.0f, 1.0f, 0.8f); renderBackground(wf); // Render warped background glCallList(displayList\[DL\_TEX\_ENABLE\]); glBindTexture(GL\_TEXTURE\_2D, 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(); // Copy image to texture glBindTexture(GL\_TEXTURE\_2D, backTexture); glCopyTexImage2D(GL\_TEXTURE\_2D, 0, GL\_RGBA, 0, 0, 512, 512, 0); glCallList(displayList\[DL\_TEX\_DISABLE\]); glBindTexture(GL\_TEXTURE\_2D,0); SwapBuffers(hdc);
}
It needs to be compiled with Dev-C++, you may need OpenGLUT.dll i forgot to include it in the zip file. Can someone please help me
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
I would like to help, but you don't say what the problem is. And I don't want to spend an afternoon going through code. Maybe you could say what you expected to obtain and what it is that you are obtaining? Also, I know OpenGL but I don't know what is a WMP. It seems to me you are trying to draw something and then make OpenGL modify it for you. I'm not sure I understand what you want but in general you already have to have your data ready when you call OpenGL to render a 3D world. OpenGL is the one doing all the drawing (generally speaking) and usually doesn't process (or modify) an already drawn image. I once made an application to wrap the real-time video feed from a web cam onto a 3D virtual object in the OpenGL world. Do you want to do something like that? Rilhas
-
I would like to help, but you don't say what the problem is. And I don't want to spend an afternoon going through code. Maybe you could say what you expected to obtain and what it is that you are obtaining? Also, I know OpenGL but I don't know what is a WMP. It seems to me you are trying to draw something and then make OpenGL modify it for you. I'm not sure I understand what you want but in general you already have to have your data ready when you call OpenGL to render a 3D world. OpenGL is the one doing all the drawing (generally speaking) and usually doesn't process (or modify) an already drawn image. I once made an application to wrap the real-time video feed from a web cam onto a 3D virtual object in the OpenGL world. Do you want to do something like that? Rilhas
Rilhas wrote:
I once made an application to wrap the real-time video feed from a web cam onto a 3D virtual object in the OpenGL world. Do you want to do something like that?
Pretty much. WMP stands for Windows Media Player and i am making a visualization for it. That is the image that is shown when you play a song. It is a moving image that is rendered in real-time and usually moves to the beat of the song. I want to warp the image i have drawn using a 2D array of warp points. I am currenty making an app that edits those points. When it draws the image, it renders it to a texture then draws quads using the points and maps the a section of the texture to it's respective quad. I then copy the screen (with the warped image) back to that texture and do the whole thing again each frame. The result is that the image has a blur/trace effect where the warped image constantly fades into the background. Here are some pics http://img519.imageshack.us/img519/1388/viz1kx4.th.png http://img99.imageshack.us/img99/4991/screenshot4kj7.th.jpg Check out the SwapBuffers post to see my latest problem and see if you can help me their.
Customer in computer shop: "Can you copy the Internet onto this disk for me?"