[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] PyGlyph



Kris Schnee wrote:

The PyGlyph examples work except for the unimportant resizing problem,

I'm guessing this is a Windows problem in which the GL context is destroyed when the window resizes; I've only tested under Linux. If someone does need a resizable window, they should reload fonts after resizing on Windows.


but when I tried to apply the code to my own project and draw some text atop my 3D landscape, nothing appeared. After some experimentation (like turning off drawing everything else, then running a dedicated draw-some-text loop instead of my normal drawing loop), I made a version of PyGlyph's "hello" example in a format I can use, ie. not using the example framework. This is what happened:
http://kschnee.xepher.net/code/font_test.jpg
(Text that looks like my monitor needs a new ink cartridge, and not centered.)
This is the code itself:
http://kschnee.xepher.net/code/font_test.py.txt


I'm not sure what the difference is that would cause this trouble. Something about the way I'm setting up OpenGL? For clarification, I'm using a function called OpenGLSwitchMode to switch between 2D (ortho) and 3D drawing modes because I'm trying to put text on the screen in an otherwise 3D game.

You're setting glOrtho for a window size of 400x300, but the window size is 640x480. On my computer this simply made it blurry, but I imagine it's also causing your artifacts too. Change resoltion=(300,400) to resolution=SCREEN_SIZE to fix.


Alex.