Re: [PyOpenGL-Users] 2D (Re: Bitmaps and Circles?)
Brought to you by:
mcfletch
|
From: Mike C. F. <mcf...@ro...> - 2004-04-27 05:43:57
|
sn...@so... wrote:
...
> perfectly). Now the last portion of the engine - for the initial
> release, at
> least - is the whole graphic shpiel.
> PyGame is very nice, I hope I'm not offending anyone - but it is, in my
> experience, a bit slow. OpenGL is fast (the demos seemed promising, I
> wrote
> a few quick programs and liked the resulting fps), and I figured I
> wouldn't
> mind going through some hoops to get OpenGL's speed into an oo-2d
> oriented
> interface.
Oh, then, go for it, but keep in mind that you're dealing with a system
that thinks in terms of points, lines and triangles, so you're going to
have to do your own tessellating (though there are some tools that will
help with that, such as GLU).
gluDisk gives you a simple filled circle if you set the inner radius to 0
setting gluQuadricDrawStyle to GLU_SILHOUETTE will give you empty
circles (no fill) with gluDisk. You could also just use the sin and cos
ufuncs from Numeric to generate coordinates and draw them using either
an array-drawing call or a display list:
a = arange(0.0,2*math.pi,.02)
xes = sin(a)
yes = cos(a)
coords = zeros( (len(xes),3),'d')
coords[:,0] = xes
coords[:,1] = yes
(the .02 there says to use .02 radians as the sampling rate, or around
1.1 degrees).
As for drawing bitmaps, there's an ARB extension ARB.window_pos which
gives simple positioning for bitmaps. There's also simple glDrawPixels
(normally pretty slow) and loading a bitmap into a texture and
displaying it on a properly-proportioned rectangle aligned with the
screen (fast, and basically the "right" way to do it (IMO)).
You might want to take a look at PyUI for sample code showing how to do
this kind of stuff. IIRC it is using lots of simple orthogonal display
of bitmaps, complex shapes (windows, text, etceteras) and is game-targeted.
HTH,
Mike
_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
|