Skip to main content
gamedev.net
🔒 Locked

pygame initialization question

Started by PsichoDM Dec 25, 2006 at 6:10 AM 2 replies 800+ views
Original Post
PsichoDM
PsichoDM
Hi! I've just started playing around with pygame and I'm following Sean Riley's book "Game Programming with Python". The first problem (in the first snippet of code) I encountered is that the following code: import pygame pygame.init() pygame.display.init( (800,600), OPENGL | DOUBLEBUF | HWSURFACE ) reports: NameError: name 'OPENGL' is not defined
Kylotan
Kylotan
Try "pygame.OPENGL". Same for the other 2 constants on that line. If that doesn't work, do a Find In Files through your pygame directory, and post back here with the location of wherever 'OPENGL' is defined.
LorenzoGatti
LorenzoGatti
You might need to familiarize with the different variants of the import statement (Python manual, Language Reference, §6.12).
"import pygame" loads the pygame module, "from pygame import *" also spills, so to speak, all symbols found in the pygame module into the global namespace so that you could refer to them as "OPENGL" rather than "pygame.OPENGL".
It goes without saying that from ... import * is a very lazy and dangerous practice, acceptable for simple examples and "private" library code only; the universally recommended style is the one in your snippet and Kylotan's good advice.
Omae Wa Mou Shindeiru
Beer Hunter
Beer Hunter
Pygame provides a module called pygame.locals which is intended for use as:
from pygame.locals import *
I'm pretty sure that OPENGL, DOUBLEBUF and the others are available in there.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.