Results 1 to 4 of 4

Thread: Simple problem

  1. #1
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Simple problem

    I'm having a problem with a simple OpenGL program. There is
    little GL code at all right now, just a framework for switching
    between different "scenes" and a couple of test triangles. I've
    zipped up the Python code and put it on my website
    (http://davemikesell.net/code.zip), but essentially the GL calls
    are happening in this order shown below. The first red triangle
    appears as expected, but the 2nd blue one does not after the scene is changed (i.e. the screen is black).

    I'm obviously doing something out of order, but I'm not sure what it
    is. What am I overlooking?


    # Resize, initialization
    glShadeModel(GL_SMOOTH)
    glClearColor(0.0, 0.0, 0.0, 1.0)
    glClearDepth(1.0)
    glViewport(0, 0, WIDTH, HEIGHT)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluOrtho2D(0.0, WIDTH, 0.0, HEIGHT)
    glMatrixMode(GL_MODELVIEW)

    # Draw red triangle
    glColor4f(1.0, 0.0, 0.0, 1.0)
    glBegin(GL_TRIANGLES)
    glVertex3f( 0.0, 1.0, 0.0)
    glVertex3f(-1.0,-1.0, 0.0)
    glVertex3f( 1.0,-1.0, 0.0)
    glEnd()

    # Scene switches

    # Resize, initialization
    glShadeModel(GL_SMOOTH)
    glClearColor(0.0, 0.0, 0.0, 1.0)
    glClearDepth(1.0)
    glViewport(0, 0, WIDTH, HEIGHT)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluOrtho2D(0.0, WIDTH, 0.0, HEIGHT)
    glMatrixMode(GL_MODELVIEW)

    # Draw blue triangle
    glColor4f(0.0, 0.0, 1.0, 1.0)
    glBegin(GL_TRIANGLES)
    glVertex3f( 0.0, 1.0, 0.0)
    glVertex3f(-1.0,-1.0, 0.0)
    glVertex3f( 1.0,-1.0, 0.0)
    glEnd()

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2007
    Location
    Fairfax, VA
    Posts
    252

    Re: Simple problem

    Try displaying the second scene first. If it works, then your problem is probably state-related---you certain you got all your glLoadIdentity() calls in there?

    If not, then there may be another problem.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: Simple problem

    Thanks - I did that before retiring last night, and the second scene displayed. Looks like I need to get my Eclipse/PyDev plugin working and step through it in the debugger.

  4. #4

    Re: Simple problem

    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()

    Hey, What's This ?!

Similar Threads

  1. Simple problem
    By Joshhua5 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-04-2011, 05:30 AM
  2. very simple texture problem
    By appdeveloper in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-12-2009, 07:25 AM
  3. simple problem i cant fix
    By stichedleg in forum OpenGL: Windows
    Replies: 2
    Last Post: 12-12-2004, 12:23 PM
  4. a simple problem
    By thunder2001 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-31-2004, 03:41 PM
  5. a simple but strange problem
    By Nil_z in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-21-2003, 09:07 AM

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