OpenGL Initialize Context With GLFW
From IronPython Cookbook
This example demonstrates how to use Tao with the GLFW binding to initialize an OpenGL context.
This has been tested with:
- IronPython 2.0Alpha8 (the original distribution)
- mono 1.2.6 under Ubuntu
- tao 2.0.0 (binary distribution deployed in the gac)
- GLFW 2.6
# -*- coding: utf-8 -*-
import clr
clr.AddReference('Tao.Glfw')
clr.AddReference('Tao.OpenGl')
from Tao.Glfw import Glfw
from Tao.OpenGl import Gl
def run():
# Initialize the Glfw context
Glfw.glfwInit()
# Create and open a Window
if not Glfw.glfwOpenWindow(320, 240, 0, 0, 0, 0, 0, 0, Glfw.GLFW_WINDOW):
Glfw.glfwTerminate()
return 2
running = True
# Loop until the Escape key is pressed or the window is closed
while running:
Glfw.glfwSwapBuffers()
running = ((Glfw.glfwGetKey(Glfw.GLFW_KEY_ESC) == Glfw.GLFW_RELEASE) and
Glfw.glfwGetWindowParam(Glfw.GLFW_OPENED) == Gl.GL_TRUE)
# Shutdown the Glfw context
Glfw.glfwTerminate()
if __name__ == '__main__':
run()
Back to Contents.


