Newbiw - PypenGL and OpenGLContext

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve T

    #1

    Newbiw - PypenGL and OpenGLContext

    I have been searching for a language to help with a product I am
    developing - last week I discovered PYOpenGL - looks really useful. I
    found some demos which I studied to create part of what I need (a heap
    of boxes) but when I try and add an image to the box faces it looks as
    if I have to delve into OpenGLContext. Now from here drawing boxes is
    no longer as simple. My main driver is speed of _development_ (not
    graphics speed) so I would really like to be able to say
    box(position_ve ctor, size_vector,tex ture_file).

    Am I on the wrong track entirely here, should I pursue OpenGLContext
    or am I misusing the visual.* parts of PYOpenGL?

    TIA

    PS Couldn't find a FAQ that helped.
  • Mike C. Fletcher

    #2
    Re: Newbiw - PypenGL and OpenGLContext

    Steve T wrote:
    [color=blue]
    >I have been searching for a language to help with a product I am
    >developing - last week I discovered PYOpenGL - looks really useful. I
    >found some demos which I studied to create part of what I need (a heap
    >of boxes) but when I try and add an image to the box faces it looks as
    >if I have to delve into OpenGLContext. Now from here drawing boxes is
    >no longer as simple. My main driver is speed of _development_ (not
    >graphics speed) so I would really like to be able to say
    >box(position_v ector, size_vector,tex ture_file).
    >
    >Am I on the wrong track entirely here, should I pursue OpenGLContext
    >or am I misusing the visual.* parts of PYOpenGL?
    >
    >[/color]
    If you are really just drawing boxes, then raw PyOpenGL *may* be
    appropriate, but you'll need to figure out the wonders of texturing.
    You can find some pretty good code for that in the NeHe demos (I believe
    around the 6th or 7th). They create a rotating textured, lit box, so if
    that's all you need, you're golden.

    If your goal is to eventually produce a more involved scene, you will
    likely want one of the scenegraph engines. Obviously I'm biased toward
    OpenGLContext, but it's visual-alike package (i.e. a simplified
    scenegraph model) is not yet ready for prime time, so you'd have to use
    the full VRML97 model to create your boxes. That would look something
    like this:

    from OpenGLContext import testingcontext
    BaseContext, MainFunction = testingcontext. getInteractive( )
    from OpenGLContext.s cenegraph.basen odes import *

    class TestContext( BaseContext ):
    def OnInit( self ):
    """Initiali se and set up the scenegraph"""
    self.sg = sceneGraph(
    children = [
    Transform(
    rotation = (0,1,0,.8),
    children = [
    Shape(
    geometry = Box( size=(4,4,2) ),
    appearance = Appearance(
    material = Material(
    diffuseColor =(1,1,1)
    ),
    texture = ImageTexture(
    url =
    "http://blog.vrplumber. com/images/ruminations.jpg ",
    ),
    ),
    ),
    ],
    ),
    ],
    )
    def getSceneGraph( self ):
    """With older OpenGLContext versions need to explicitly
    return this"""
    return self.sg

    if __name__ == "__main__":
    MainFunction( TestContext )

    There are other retained-mode/scenegraph engines available besides
    OpenGLContext, you can find a listing of some of them here:



    HTH,
    Mike

    _______________ _______________ _______________ ___
    Mike C. Fletcher
    Designer, VR Plumber, Coder



    Comment

    Working...