Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: OpenGL?  (Read 5627 times)

0 Members and 1 Guest are viewing this topic.

Pol

  • Newbie
  • *
  • Posts: 18
    • View Profile
OpenGL?
« on: August 14, 2009, 01:34:35 am »
Hey.. I'm encountering a strange problem intermixing OpenGL into PySFML code..

I'm using two methods..

The first: directly accessing GL using ctypes
The second: accessing GL through PyOpenGL (which directly accesses GL using ctypes)

Other than the method for importing the GL lib, the code is the same.. but the first method fails...

First:

Code: [Select]
from ctypes import CDLL
from ctypes.util import find_library, sys
if sys.platform == 'win32': GL = CDLL( find_library( 'opengl32' ) )
else: GL = CDLL( find_library( 'GL' ) )

from PySFML import sf
window = sf.RenderWindow( sf.VideoMode( 800, 600 ), 'title' )
GL.glClearColor( 255, 0, 0, 255 )
while True:
    GL.glClear( 0x00004000 ) # mask == GL_COLOR_CLEAR_VALUE
    window.Display()



Second:

Code: [Select]
from OpenGL import GL

from PySFML import sf
window = sf.RenderWindow( sf.VideoMode( 800, 600 ), 'title' )
GL.glClearColor( 255, 0, 0, 255 )
while True:
    GL.glClear( 0x00004000 ) # mask == GL_COLOR_CLEAR_VALUE
    window.Display()


Basically, the first results in a constant BLACK window while the second results in a constant RED window, as expected.

The glClear() call in the first example obviously 'works' because the window is getting cleared, but it's not the correct color.

PyOpenGL at http://pyopengl.sourceforge.net/

Again, PyOpenGL accesses OpenGL via ctypes as I'm trying to do on a lower level, so this must be possible, *somehow*.

My ideas are that glClearColor() might be failing to set the color for some reason, or PyOpenGL is doing some essential initializations that I'm missing..

I'll be looking through PyOpenGL source until I figure this out.

Any ideas?

Pol

  • Newbie
  • *
  • Posts: 18
    • View Profile
OpenGL?
« Reply #1 on: August 14, 2009, 02:56:22 am »
Ah, nevermind .. glClearColor needs to be passed in floats ;)