More than one 'SwapBuffers(HDC)'
-
Hi, i am writing a small app which renders OpenGL to a frame inside a window. I want it to be rendered every time an event occurs such as creating a new file (which would reset the view). However, i also want to render in frames per second when it is enabled. In this case, a timer causes an event every, say, 100ms. Now, that event causes a render function to be called which copies the OpenGL screen to a texture, warps it, and renders it back. Every time any other event occurs, all that needs to be done is to draw the warped image. So, how do i use SwapBuffers(HDC) twice, once in each render function, but so that the image does not flicker. Download here[^] and get my WMP visualization here[^]. Run the program before you try to compile, because if Dev-Cpp can't compile it will delete the exe.
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
-
Hi, i am writing a small app which renders OpenGL to a frame inside a window. I want it to be rendered every time an event occurs such as creating a new file (which would reset the view). However, i also want to render in frames per second when it is enabled. In this case, a timer causes an event every, say, 100ms. Now, that event causes a render function to be called which copies the OpenGL screen to a texture, warps it, and renders it back. Every time any other event occurs, all that needs to be done is to draw the warped image. So, how do i use SwapBuffers(HDC) twice, once in each render function, but so that the image does not flicker. Download here[^] and get my WMP visualization here[^]. Run the program before you try to compile, because if Dev-Cpp can't compile it will delete the exe.
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
don't copy the buffer, render straight to texture so that you can warp it to your heart's content. http://www.paulsprojects.net/opengl/rtotex/rtotex.html[^]
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
-
don't copy the buffer, render straight to texture so that you can warp it to your heart's content. http://www.paulsprojects.net/opengl/rtotex/rtotex.html[^]
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
I'm not sure if you know what i mean. Did you download my files? Look at the effect in my Visualization, that is the kind of effect i want. Here is a pic: http://img519.imageshack.us/my.php?image=viz1kx4.png Do you mean for me to render directly to a texture, then display that? How exactly would i do that? btw, your link is broken
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
-
I'm not sure if you know what i mean. Did you download my files? Look at the effect in my Visualization, that is the kind of effect i want. Here is a pic: http://img519.imageshack.us/my.php?image=viz1kx4.png Do you mean for me to render directly to a texture, then display that? How exactly would i do that? btw, your link is broken
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
VizCoder wrote:
Do you mean for me to render directly to a texture, then display that? How exactly would i do that?
Yes, that is exactly what I mean. Using pbuffers and render to texture you no longer have to render to a screen (double buffered or not) and then copy back the image. You can render directly to a pbuffer which allows you to copy the image directly to memory on your computer, or you can render directly to texture memory which can then be used for rendering as a texture on another object, all in the same scene. Also you can achieve the same process by manually controlling bufferswap so that you never see it. This is how it was done before pbuffers and render to texture calls: render(sceneA); glFlush(); glCopyPixels(); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); createyourtexture(); render(sceneB); swapbuffers(); the problem with this style is that it broke the rendering cycle several times 1) with the glFlush() 2) with the read-back cycle of glCopyPixels() and 3) with the texture binding procedures.
VizCoder wrote:
btw, your link is broken
It still works for me.... so just google "render to texture"
VizCoder wrote:
Did you download my files?
Advice is free, debugging your code takes a lot more time. Sorry, maybe someone else will.
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
-
VizCoder wrote:
Do you mean for me to render directly to a texture, then display that? How exactly would i do that?
Yes, that is exactly what I mean. Using pbuffers and render to texture you no longer have to render to a screen (double buffered or not) and then copy back the image. You can render directly to a pbuffer which allows you to copy the image directly to memory on your computer, or you can render directly to texture memory which can then be used for rendering as a texture on another object, all in the same scene. Also you can achieve the same process by manually controlling bufferswap so that you never see it. This is how it was done before pbuffers and render to texture calls: render(sceneA); glFlush(); glCopyPixels(); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); createyourtexture(); render(sceneB); swapbuffers(); the problem with this style is that it broke the rendering cycle several times 1) with the glFlush() 2) with the read-back cycle of glCopyPixels() and 3) with the texture binding procedures.
VizCoder wrote:
btw, your link is broken
It still works for me.... so just google "render to texture"
VizCoder wrote:
Did you download my files?
Advice is free, debugging your code takes a lot more time. Sorry, maybe someone else will.
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
El Corazon wrote:
Advice is free, debugging your code takes a lot more time. Sorry, maybe someone else will.
that's ok, i can't expect everyone to go searching through my code finding bugs. I just wanted you to see my viz to get an idea of what i want to do. As for your solution, i don't really know much about OpenGL so i might read a few tutorials before attempting anything like that
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
-
Hi, i am writing a small app which renders OpenGL to a frame inside a window. I want it to be rendered every time an event occurs such as creating a new file (which would reset the view). However, i also want to render in frames per second when it is enabled. In this case, a timer causes an event every, say, 100ms. Now, that event causes a render function to be called which copies the OpenGL screen to a texture, warps it, and renders it back. Every time any other event occurs, all that needs to be done is to draw the warped image. So, how do i use SwapBuffers(HDC) twice, once in each render function, but so that the image does not flicker. Download here[^] and get my WMP visualization here[^]. Run the program before you try to compile, because if Dev-Cpp can't compile it will delete the exe.
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
Hi, I agree with previous posts. I will take a lot of time to download your files, compile them, run them... even if the resulting images are quite cool. I come here once in a while to give some advice if I think they can be usefull, but I have my own project and many other things to ocupy my time. So I would like to invite you to state what your problem is. In other words, what it is that is happening that is not as you expected? I think this is a good starting point for me to try to help. Anyway, I suspect that SwapBuffers() 2 times results in not swapping at all. At least with double buffering. So I don't know why you would want that. I have the feeling you would want something like: 1. WaitEvent() 2. TakePrimaryBufferAndCopyItToTexture() 3. WarpItAsNecessary() 4. DrawToSecondaryBuffer() 5. SwapBuffersOnceToMakeSecondaryBecomePrimary() 6. goto 1. Is this not what you want? I hope this helps, Rilhas
-
VizCoder wrote:
Do you mean for me to render directly to a texture, then display that? How exactly would i do that?
Yes, that is exactly what I mean. Using pbuffers and render to texture you no longer have to render to a screen (double buffered or not) and then copy back the image. You can render directly to a pbuffer which allows you to copy the image directly to memory on your computer, or you can render directly to texture memory which can then be used for rendering as a texture on another object, all in the same scene. Also you can achieve the same process by manually controlling bufferswap so that you never see it. This is how it was done before pbuffers and render to texture calls: render(sceneA); glFlush(); glCopyPixels(); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); createyourtexture(); render(sceneB); swapbuffers(); the problem with this style is that it broke the rendering cycle several times 1) with the glFlush() 2) with the read-back cycle of glCopyPixels() and 3) with the texture binding procedures.
VizCoder wrote:
btw, your link is broken
It still works for me.... so just google "render to texture"
VizCoder wrote:
Did you download my files?
Advice is free, debugging your code takes a lot more time. Sorry, maybe someone else will.
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
Well, i have taken the leap to using pbuffers. I really have no idea about OpenGL let alone pbuffers so i am just picking things up as i go along. I got some code of the internet which uses pbuffers but i can't get it to work. There were 3 ways of doing it, i did the second one since my hardware doesn't support the 3rd way (see here[^], "Off-screen Rendering Using Pixel Buffers" Version #2). I was wondering if i need a certain version(?) of wglext.h since they included one in the download and i didn't have one before so i just copied that. I keep getting errors when trying to switch contexts between rendering to the pbuffer and rendering to the screen, i,e wglMakeCurrent() fails. Any ideas, just of the top of your head since i can't post my whole code. Could it be the way i'm doing it or is it my hardware? (The example exe from the site worked but i didn't compile)
Customer in computer shop: "Can you copy the Internet onto this disk for me?"