GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pixel level drawing in GTK

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
HappyCat
Familiar Face


Joined: 13 Aug 2007
Posts: 5

PostPosted: Mon Aug 13, 2007 5:57 pm    Post subject: Pixel level drawing in GTK Reply with quote

Hi, I am trying to create a game for which I need fast, double-buffered, pixel level drawing. I am not sure how to do this. I have used SDL and creating a software SDL surface does what I need, but the only thing I could find for GTK was the GTK_SDL widget, which relies on a hack and is very unreliable (it doesn't work for me). SDL does not work because I need many windows and GUI components, and also I am not fond of the rest of SDL. Is there any widgets that I can use to draw individual pixels very fast? Ideally, I will just have a pointer to an array of pixel data, and the program can write to that as necessary (similar to SDL_Surface->pixles), and then when I am done, I can call a swap buffers function. Optionally, I would prefer something that can maintain a constant size pixel buffer that I can write to, but the rendered image will stretch to be the size of the window. This is not necessary, however. Is there any good way to do this?
Back to top
rotalever
Familiar Face


Joined: 24 Feb 2007
Posts: 11

PostPosted: Fri Aug 17, 2007 7:01 pm    Post subject: Reply with quote

Fast rendering sound like hardware acceleration. You may want to use OpenGL which can also draw 2D-Images. If you do so, do not set pixels directly, that slows things down. Copy your sprites to OpenGL textures and you will get very good framerates. IMO this is the way to go.

GTK provides a widget which embeds OpenGL, but I dont know its name.
Back to top
caracal
GTK+ Geek


Joined: 21 Jun 2007
Posts: 89
Location: Wilkes Barre Pa

PostPosted: Tue Sep 11, 2007 12:09 pm    Post subject: Reply with quote

Its called GtkGLExt - an OpenGL extension to GTK 2.0 or later.
But there are other things you can do such as embedding a sdl window in a gtk window
or you can also use opengl in sdl and then embed sdl in a gtk window.
using gtk plug & socket.

Or you could use irrlich and wxgtk
http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=15338&highlight=wxgtk

here is a free linux game programming pdf book
http://www.losersjuegos.com.ar/referencia/libros/descargas/plg-final-pdf-no-really-i-mean-it-this-time.pdf

There are a bunch of other ways also.

GTK_SDL is for gtk1 not gtk2
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP