OpenGL win32 Python

gintare statkute g.statkute at gmail.com
Fri Apr 17 15:27:25 CEST 2009


 Hello,

i found an example for OpenGL in windows.
It is incredibly helpful, but how to rewrite it to be useful in Python.

 How to give address of pfd in Python?:
iFormat = ChoosePixelFormat( hDC, &pfd );
SetPixelFormat( hDC, iFormat, &pfd );

I found syntax for sizeof and pfd:

#! /usr/include/pyhton2.4 python
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL import *
import win32api
import sizeof
pfd=Gdi.PIXELFORMATDESCRIPTOR()
ZeroMemory( pfd, ctypes.sizeof( pfd ) )

regards,
Gintare Statkute

p.s. whole code which i want to use in Python:
http://www.nullterminator.net/opengl32.html
only the addresses and pointer are not clear (marked in red above)


void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
{
    PIXELFORMATDESCRIPTOR pfd;
    int iFormat;

    // get the device context (DC)
    *hDC = GetDC( hWnd );

    // set the pixel format for the DC
    ZeroMemory( &pfd, sizeof( pfd ) );
    pfd.nSize = sizeof( pfd );
    pfd.nVersion = 1;
    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
                  PFD_DOUBLEBUFFER;
    pfd.iPixelType = PFD_TYPE_RGBA;
    pfd.cColorBits = 24;
    pfd.cDepthBits = 16;
    pfd.iLayerType = PFD_MAIN_PLANE;
    iFormat = ChoosePixelFormat( *hDC, &pfd );
    SetPixelFormat( *hDC, iFormat, &pfd );

    // create and enable the render context (RC)
    *hRC = wglCreateContext( *hDC );
    wglMakeCurrent( *hDC, *hRC );
}

void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC)
{
    wglMakeCurrent( NULL, NULL );
    wglDeleteContext( hRC );
    ReleaseDC( hWnd, hDC );
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090417/c446c220/attachment.html>


More information about the Python-list mailing list