GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Oct 25, 2014 4:03 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Sample C code for GTK and OpenGL contexts, using GtkGLExt.
PostPosted: Tue Feb 10, 2009 1:44 pm 
Offline
Familiar Face

Joined: Tue Feb 10, 2009 1:19 pm
Posts: 7
Location: London, England
Hi folks, to help out anyone who is looking into using OpenGL within GTK windows (using GtkGLExt) I have released fully documented sample code in C to be used freely as you wish.

It provides safe render-process locking and smooth timer-based rendering while being simple, efficient and easy to understand what is going on.

Edit July 2009: The demo has been updated to use GtkBuilder and is now hosted on Sourceforge: http://gtkglapp.sourceforge.net/

Edit December 2010: Now with realtime GStreamer rendering (see below). Update at: http://sourceforge.net/projects/gtkglapp/files/Release/GtkGLAppGStreamer.tar.gz/download

To import the project into Eclipse IDE:
Open the menu 'File->Import...'.
From the 'General' options folder, select 'Existing Projects into Workspace' and click on the 'Next >' button.
Choose the 'Select archive file:' option and next to it click on the 'Browse...' button to navigate to the project archive (ending in '.tgz') you downloaded.
The project name will appear below - click on 'Finish'.
The project will be imported and opened in your Eclipse workspace.

For command-line users:
Please note that to run the application successfully outside of the Eclipse IDE environment (e.g. from a 'make' within the "../Debug/" directory) the GUI file "gtk_gl_tester.gtk" must reside in the same directory as the compiled binary for it to run.


Last edited by IIR on Fri Dec 10, 2010 3:52 am, edited 6 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 3:29 am 
Offline
GTK+ Guru

Joined: Thu Jun 21, 2007 1:52 pm
Posts: 198
Location: Wilkes Barre Pa
Nice and clean good job and thanks :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 31, 2009 9:36 pm 
Offline
Familiar Face

Joined: Tue Feb 10, 2009 1:19 pm
Posts: 7
Location: London, England
Updated to use GtkBuilder and new host on Sourceforge.


Top
 Profile  
 
 Post subject: Update!
PostPosted: Fri Dec 10, 2010 3:50 am 
Offline
Familiar Face

Joined: Tue Feb 10, 2009 1:19 pm
Posts: 7
Location: London, England
From demand to see a more advanced form of GStreamer video working within GTK+ the example now renders GStreamer realtime into multiple OpenGL drawables inside a GTK+ Builder window. It's also easy to read. :)

Update is at: http://sourceforge.net/projects/gtkglapp/files/Release/GtkGLAppGStreamer.tar.gz/download


Top
 Profile  
 
 Post subject: Re: Sample C code for GTK and OpenGL contexts, using GtkGLEx
PostPosted: Tue Jan 03, 2012 7:22 am 
Offline

Joined: Tue Jan 03, 2012 7:07 am
Posts: 2
Hi IIR! Thank you for your work. But i currently can't run this code. I use Ubuntu and Eclipse, and i follow your step-by-step instructions. But i get linker error in Eclipse console:
Quote:
Building target: GtkGLAppGStreamer
Invoking: GCC C Linker
gcc -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lxml2 -lgthread-2.0 -lrt -lglib-2.0 -rdynamic -o"GtkGLAppGStreamer" ./src/main.o -lxml2 -lGLU -lgtkglext-x11-1.0 -lGL -lgstapp-0.10 -lglut
/usr/bin/ld: ./src/main.o: undefined reference to symbol 'gdk_gl_context_new'
/usr/bin/ld: note: 'gdk_gl_context_new' is defined in DSO /usr/lib/libgdkglext-x11-1.0.so.0 so try adding it to the linker command line
/usr/lib/libgdkglext-x11-1.0.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [GtkGLAppGStreamer] Error 1

...but it already added to linker command line, as i see.
The same error raises when i try to run this command from command line, outside the Eclipse.
I'm too novice in C, and can't find solutions for similar problems on the web. I also see this file is exist:
Quote:
$ sudo find / -name "*gtkglext-x11-1.0*"
/usr/lib/libgtkglext-x11-1.0.so.0.0.0
/usr/lib/pkgconfig/gtkglext-x11-1.0.pc
/usr/lib/libgtkglext-x11-1.0.a
/usr/lib/libgtkglext-x11-1.0.so.0
/usr/lib/libgtkglext-x11-1.0.la
/usr/lib/libgtkglext-x11-1.0.so

Can you help me please? Thank you very much!


Top
 Profile  
 
 Post subject: Re: Sample C code for GTK and OpenGL contexts, using GtkGLEx
PostPosted: Tue Feb 14, 2012 1:02 pm 
Offline
Familiar Face

Joined: Tue Feb 10, 2009 1:19 pm
Posts: 7
Location: London, England
Hi! Just spotted this! Due to some goalposts being moved in pkg-config, I have redone the project file to use the needed libraries directly; update is on SourceForge :)


Top
 Profile  
 
 Post subject: Re: Sample C code for GTK and OpenGL contexts, using GtkGLEx
PostPosted: Thu Feb 23, 2012 1:11 pm 
Offline

Joined: Tue Jan 03, 2012 7:07 am
Posts: 2
Hi IIR!
Thank you so much!
Now it works out-of-box!
It is really important for me.
Thank you for your work!
:-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group