Simon Wittber | 1 May 2005 12:28
Picon
Gravatar

Re: OpenGL 2D Game

I've made things much more simple.

All you have to do now is:

import pygame_gl

When you import pygame_gl, it decorates and overrides the normal
pygame methods so that OpenGL stuff happens behind the scenes, without
the need for any OpenGL knowhow. Most things should still work as
expected.

Get it from: http://developer.berlios.de/project/showfiles.php?group_id=2847&release_id=5636

It's the pygame_gl package.

Sw.

Shandy Brown | 2 May 2005 17:30

Re: OpenGL 2D Game

Hi Simon.

Cool.  I'm really excited about trying this out when I get home.  Do you
know if it works with python 2.3?

-sjbrown

On Sun, 1 May 2005, Simon Wittber wrote:

> I've made things much more simple.
>
> All you have to do now is:
>
> import pygame_gl
>
> When you import pygame_gl, it decorates and overrides the normal
> pygame methods so that OpenGL stuff happens behind the scenes, without
> the need for any OpenGL knowhow. Most things should still work as
> expected.
>
> Get it from: http://developer.berlios.de/project/showfiles.php?group_id=2847&release_id=5636
>
> It's the pygame_gl package.
>
> Sw.
>

Simon Wittber | 3 May 2005 02:42
Picon
Gravatar

Re: OpenGL 2D Game

> Cool.  I'm really excited about trying this out when I get home.  Do you
> know if it works with python 2.3?

Well, I haven't tested with 2.3, but there is nothing in there that is
2.4 specific...

I've only implemented a small subset of the pygame API. Just enough
for my own stuff.

Sw.

Giorgos Giagas | 3 May 2005 10:48
Picon

Re: OpenGL 2D Game

On the subject of OpenGL and python...
What can I expect from it?
I am trying for scrolling of the background at 1024x768.
this leaves me with a texture of ie. 2048x1024 and it doesn't scroll
smothlly. (about 40-50fps but it sometimes drops to 5-10 for a while)
would i have beter fps if i split the image in smaller parts before
loading to the card (ie 256x256 each image)?
What i am trying to create is something like the classic 2.5D
adventure games so it has to be one big image in the background.
Is this realistic to be done with python and OpenGL?

Ben Friman | 3 May 2005 11:17

Re: Smooth scaling using WMF drawings

Thanks, Atul. I had been blindly pursuing the WMF route, forgetting 
that this was a Windows-only solution. This seems to be on the right 
track. The only problem is that I "lost" my C / C++ compiler a few 
years ago! 

I had a look at Cairo (http://cairographics.org) and it seems that 
there are already python bindings for it. However, there's no 
Windows binaries so I would need to compile unless anyone out 
there has already done so and can let me have the binaries?

> Since no one else has responded to this yet, I'll give it a try,
> although it's a bit of a long shot.
> 
> If you're interested in working with vector graphics and you have some
> C/C++ experience, you may want to consider integrating a 2D vector
> graphics library with SDL/Pygame.  One such vector graphics library,
> the Anti-Grain Geometry project (http://www.antigrain.com), is a
> collection of algorithms that blit the rendering result to a
> framebuffer, which can have any of a variety of pixel formats.  It's
> not very difficult to "hook up" this rendering pipeline to SDL by
> pointing it to the "pixels" property of a SDL_Surface structure and
> telling it what pixel format the buffer uses.  The end result is that
> there's no conversion or copying of pixel information from one library
> to another: the 2D vector pipeline simply rasterizes its output
> directly to your screen (or any other SDL/Pygame surface you provide),
> which is extremely efficient.
> 
> Thanks to Pygame's C API, it shouldn't be hard to write a Python
> extension module that works with Pygame to do all this.  It could even
> be a cool new extension to Pygame itself.
(Continue reading)

Sami Hangaslammi | 3 May 2005 11:55
Picon

Re: OpenGL 2D Game

On 5/3/05, Giorgos Giagas <giorgosg@...> wrote:
> On the subject of OpenGL and python...
> What can I expect from it?
> I am trying for scrolling of the background at 1024x768.
> this leaves me with a texture of ie. 2048x1024 and it doesn't scroll
> smothlly. (about 40-50fps but it sometimes drops to 5-10 for a while)
> would i have beter fps if i split the image in smaller parts before
> loading to the card (ie 256x256 each image)?
> What i am trying to create is something like the classic 2.5D
> adventure games so it has to be one big image in the background.
> Is this realistic to be done with python and OpenGL?

Definately break it up into smaller pieces. Using textures that large
will outright not work on some older cards, and you should get a much
better performance by tiling smaller rectangles (256x256 should be a
good size).

--

-- 
Sami Hangaslammi

Giorgos Giagas | 3 May 2005 14:53
Picon

Re: OpenGL 2D Game

On 5/3/05, Sami Hangaslammi <sami.hangaslammi@...> wrote:
> Definately break it up into smaller pieces. Using textures that large
> will outright not work on some older cards, and you should get a much
> better performance by tiling smaller rectangles (256x256 should be a
> good size).
> 
I knew it doesn't work on some cards.
What I was thinking was to detect the max texture size and break the
image acordinglly if needed.
I will try your suggestion too when i implement this.
anyhow i learned about opengl call lists and it everything runs much better now.

Shandy Brown | 3 May 2005 16:04

Re: Smooth scaling using WMF drawings

Has anyone taken a look at inkscape for this?  Perhaps they've modularized
their engine into a library.  I know that the Inkscape client works on
both linux & windows, and includes a command-line tool that can create
bitmaps from SVG.

sjbrown

On Tue, 3 May 2005, Ben Friman wrote:

> Thanks, Atul. I had been blindly pursuing the WMF route, forgetting
> that this was a Windows-only solution. This seems to be on the right
> track. The only problem is that I "lost" my C / C++ compiler a few
> years ago!
>
> I had a look at Cairo (http://cairographics.org) and it seems that
> there are already python bindings for it. However, there's no
> Windows binaries so I would need to compile unless anyone out
> there has already done so and can let me have the binaries?
>
>

James Reeves | 4 May 2005 00:14
Picon

Improved pygame inputbox

I've been fiddling around with pygame for some simple AI tests, and I've 
discovered a little more about inputting text. Here's an improved version of 
the inputbox script mentioned a little while ago. The benefits are:

- Cleaner and smaller source
- Text aligned a little better (at least in Linux)
- Handles modifiers right: you can type in "A?! <at> &^" and it renders correctly.
- Quits on the QUIT signal
- Uses far less CPU time

Hope it's of some use.

####################################################
# Adapted by James Reeves from an inputbox by Timothy Downs
# http://www.pygame.org/pcr/inputbox/inputbox.py

import sys
import pygame
from pygame.locals import *

def display_box(screen, message):
	"Print a message in a box in the middle of the screen"
	font = pygame.font.Font(None, 18)
	rect = pygame.Rect([0, 0, 220, 22])
	offset = (3, 3)

	center = screen.get_rect().center
	rect.center = center

	pygame.draw.rect(screen, (0, 0, 0), rect, 0)
(Continue reading)

James Reeves | 4 May 2005 00:21
Picon

Re: Improved pygame inputbox

On Tuesday 03 May 2005 11:14 pm, James Reeves wrote:
> 	center = screen.get_rect().center
> 	rect.center = center
Uh, this can obviously be shortened to:
	rect.center = screen.get_rect().center

D'oh :)

--

-- 
James Reeves
http://www.monkeyengines.co.uk/


Gmane