Results 1 to 7 of 7

Thread: calling 2D in 3D

  1. #1
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Perth, WA, Australia
    Posts
    5

    calling 2D in 3D

    I want to draw a 3D pic with a mirror/picture frame image in it, and then draw a 2D pic in the frame. The 2D pic is half written, using opengl. Can I actually do this, and how? Anyone?
    Thanks.

  2. #2
    Member Contributor
    Join Date
    Apr 2000
    Location
    Austria
    Posts
    57

    Re: calling 2D in 3D

    hi,
    if i understood your question right, you wanna have something like a 2d-painting on a 3d-wall.. then you need texture-mapping..
    you can draw some pic and simply ( ) put it on your object..

  3. #3
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Perth, WA, Australia
    Posts
    5

    Re: calling 2D in 3D

    Would that work, even though the 2D picture is an opengl (written in C) program, with animation, and not a bitmap image?

  4. #4
    Member Contributor
    Join Date
    Apr 2000
    Location
    Austria
    Posts
    57

    Re: calling 2D in 3D

    well, there are several methods to "animate" a texture ( i think the simplest way is to change the texture every frame i.e. 10 different textures in a sec. for example )

    But i dont know if this good solution to your problem, maybe you find another way to include your 2D-scene into 3D.

    if you tell us how your 2D-program is made up, maybe someone can tell you..

    p.s.:
    if you want to move/rotate the 3D-parts with the 2d-image in it, i think a texture is the only way to do this

    [This message has been edited by sebastian (edited 05-26-2000).]

  5. #5
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Annapolis, MD
    Posts
    20

    Re: calling 2D in 3D

    I have been thinking about how to do this myself. I've never tried to impliment it, but I figured the code would have to be something to the effect of:

    if( update_painting ) {
    glDrawBuffer( GL_AUX1 ); //so we cant see it

    /*
    * sceen drawing instructions.
    */

    glReadBuffer( GL_AUX1 );
    glCopyTexImage2D( texname, 0, GL_RGB, 0, 0, resolutionX, resolutionY, 0 );

    glDrawBuffer( GL_BACK ); // rest of sceen gets hidden while drawing

    }

    I imagine this would kill a frame rate but I've never accually tried it. You'd prolly want some kind of test to make sure the user can see the painting before going through all
    the trouble of rendering it.

    humm... I hope that made some kind of sense.

    -Marrcke

  6. #6
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Perth, WA, Australia
    Posts
    5

    Re: calling 2D in 3D

    To clarify, only the 2D 'painting' is animated, not the 3D scene it's in.

    Could I test Maarcke's code by writing the 2D pic to the point where it works but as yet has no animation, and then using that code? ..I think that would work as a test. Only, what is glCopyTexImage?

  7. #7
    Junior Member Newbie
    Join Date
    May 2000
    Location
    Annapolis, MD
    Posts
    20

    Re: calling 2D in 3D

    Blue Book says:

    glCopyTexImage2D - copy pixels into a 2D texture image

    void glCopyTexImage2D(
    GLenum target, // specifies the target texture
    GLint level, // specifies level of mipmap detail reduction. Level 0 is the base image level
    GLenum internalformat, // format of pixels
    Glint x, y, // Window coords of the lower left corner of the region to be copied
    GLsizei width, // Width of the texture image. Must be 0 or 2^n+2*border for some integer n.
    GLsizei height, // Height of the texture image. Must be 0 or 2^m+2*border for some integer n.
    GLint border // Specifies the width of the border. Must be 0 or 1.

    That is, more or less, a quote from the refrence manual. They seem to imply that the width and height must be based on a power of two, but later in the description they imply that it's just the width and height of the region you want to grab.

    This will grab pixels out of where ever the current GL_READ_BUFFER points (usually the current display), hence the switch to AUX1.

    -Marrcke

Similar Threads

  1. glRotatef() Without Calling It
    By g0bl1n in forum OpenGL: General
    Replies: 5
    Last Post: 11-10-2011, 06:37 PM
  2. periodically calling a function
    By stanigator in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-09-2009, 05:53 PM
  3. calling glutCreateWindow from within a dll.
    By casterman in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-02-2003, 07:36 AM
  4. Problem calling GDI after SwapBuffers()
    By daniel_oberlin in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 11-22-2002, 07:40 AM
  5. Calling more than one program
    By littledevore in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-24-2002, 05:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean