Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: rendering, saving and recalling

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Israel
    Posts
    10

    rendering, saving and recalling

    Hi all.
    I posted this in the beginners section, but maybe I'll get more response here.
    I've been trying to get this answer for a while now .
    I want to render a 3D scene, save it (on the card's memory somewhere), and then recall it. In between I may want to render a different scene, and later recall that one too. I also want to manage the whole thing: I want to know how much more resources I have, so I don't overwrite previous scenes.
    I thought about using textures, i.e. render a scene and then copy it to a texture (glCopyTexImage), thus managing an array of textures. This is not great, because my scenes are 3D (I need the depth component as well).
    This is very frustrating, because this task seems very useful (in games for example), if you have a complex scene, and you want to do the complex rendering only once, but displaying many times.
    And by the way, aux buffers and pbuffers didn't look very attractive to me either.
    Thanks for any help.

  2. #2
    Member Regular Contributor
    Join Date
    Jul 2002
    Location
    Austria
    Posts
    280

    Re: rendering, saving and recalling

    If you want to keep everything in graphics memory, using render-to-texture (that is, using pbuffers) is the only reasonable way to go.
    XEngine - The Platform- and API-Independent 3D Engine
    with Programmable Pipeline Support: [URL=http://xengine.sourceforge.net
    My]http://xengine.sourceforge.net

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Israel
    Posts
    10

    Re: rendering, saving and recalling

    ok, thanks for the reponse.
    Is this what games or simulator applications do?
    Is there anyone with a code example of using pbuffers with resource management (i.e. querying how much memory I have free and so on)?

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    205

    Re: rendering, saving and recalling

    Try WGL_ARB_buffer_region you should be able to make copies of the color and depth buffers...

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: rendering, saving and recalling

    pbuffers are great for saving both depth and color information.

    However, if your camera moves, a saved scene is no use. A saved image of something like a single tree might be (known as an impostor). Games that let the camera move around typically won't save the scene bits, because that would be useless. Some games copy out the rendered scene for post-processing, though, which is related but different :-)
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Israel
    Posts
    10

    Re: rendering, saving and recalling

    Does anyone have a working example of pbuffers? I'm using windows, with vc6, I have opengl ver. 1.3.1 (that's what glGetString (GL_VERSION) says), with nvidia geforce4, but I can't compile wglGetExtensionsStringARB.

    Thanks.

  7. #7
    Junior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    Wake Forest, NC, USA
    Posts
    176

    Re: rendering, saving and recalling

    Originally posted by naf:
    Does anyone have a working example of pbuffers? I'm using windows, with vc6, I have opengl ver. 1.3.1 (that's what glGetString (GL_VERSION) says), with nvidia geforce4, but I can't compile wglGetExtensionsStringARB.

    Thanks.
    I assume you mean wglGetProcAddress() returns NULL when you pass in "wglGetExtensionsStringARB"? If so, you need to be sure that you have a current context when you call wglGetProcAddress() or it won't call into the OpenGL driver.

    Generally what this means is that you create a dummy window (doesn't have to be displayed), choose a hardware pixel format, create a dummy context, and call wglMakeCurrent() first. Then you can destroy the dummy context/window when you've gotten the information you need.

    It is confusing that you need to create a window/pixel format so you can query function pointers that help you work with pbuffers and pixel formats.

    Yes, I know it's stupid, but that's the way it works on Windows.

  8. #8
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: rendering, saving and recalling

    Originally posted by naf:
    Does anyone have a working example of pbuffers? I'm using windows, with vc6, I have opengl ver. 1.3.1 (that's what glGetString (GL_VERSION) says), with nvidia geforce4, but I can't compile wglGetExtensionsStringARB.

    Thanks.
    nvdia has a demo with a teapot spinning, rendered into a pbuffer, and copied to a texture, and mapped onto a spinning quad.

    It's called pbuffer_to_texture_rectangle

    V-man
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  9. #9
    Intern Contributor
    Join Date
    Sep 2002
    Location
    london, uk
    Posts
    64

    Re: rendering, saving and recalling

    regarding the wgl thingy: as stated above, since it's an extension (not in headers/libs), you have to get the dll entry point manually, using wglGetProcAddress().

    it's not necessary to waste time & effort with dummy windows - you just have to make sure that (warning, this is a bit technical) the opengl dll's are loaded before calling any win32 api functions which are dependent on opengl subsystem. (win32 won't load opengl32.dll unless linker)

    in practical terms, if you're linking statically (ie #include <gl/gl.h> and link with opengl32.lib), you must force the linker section to load opengl32.dll by making a call to opengl proper, like glClear() or whatever, even if it's in a function that's never called. as far as i know, the simplest way to do this is wglMakeCurrent(NULL, NULL) (unbind any context for current thread); i'm pretty sure that special form is guaranteed to be harmless.

    if you're loading opengl32.dll dynamically (quake2/3 style), make sure the dll init is done prior to making any wgl* calls...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •