Sign in to follow this  
lol

gluUnProject raising TypeError

Recommended Posts

I'm making a python program to test a feature of my game engine, but couldn't seem to figure out why gluUnProject keeps raising a TypeError. I tried making a simple 60 line program to see if maybe this is happening because of something happening in my engine (which is an extension written in C), but the problem still persists. This is my source (the program is supposed to print the 3d coordinates of the cursor whenever the user clicks something):
[source lang = "Python"]
import pygame
from OpenGL.GL import *
from OpenGL.GLU import *



def SetUpCamera(res):
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	gluPerspective(90, float(res[0]) / float(res[1]), 1.0 / 100.0, 100.0)

	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
	glTranslatef(0.0, 0.0, -1.0)

resolution = (800, 600)
IsRunning = True

pygame.init()

pygame.display.set_mode(resolution, pygame.OPENGL | pygame.DOUBLEBUF)



while IsRunning:

	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			IsRunning = False
		elif event.type == pygame.MOUSEBUTTONDOWN:
			SetUpCamera(resolution)

			try:
				coords = gluUnProject(event.pos[0], event.pos[1], 0.0)
			except TypeError, arg:
				print arg
			else:
				print coords



	#draw a triangle
	glEnable(GL_DEPTH_TEST)
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

	SetUpCamera(resolution)

	glBegin(GL_TRIANGLES)

	glColor3f(1, 0, 0)
	glVertex3f(-1, 0, 0)

	glColor3f(0, 1, 0)
	glVertex3f(0, 1, 0)

	glColor3f(0, 0, 1)
	glVertex3f(1, 0, 0)

	glEnd()

	pygame.display.flip()

pygame.quit()

and the exception raised by gluUnProject is:
Quote:
("Can't create NULL pointer filled with values", 'Failure in cConverter <OpenGL.converters.SizedOutput object at 0x15ec668>', [GL_MODELVIEW_MATRIX], 1, <OpenGL.wrapper.glGetDoublev object at 0x15f1518>)
I can't seem to figure out why this is happening. Does anyone know how to fix it?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this