gtk2.0 + gtkglarea problem
From: berthelot samuel (samuel.berthelot_at_voila.fr)
Date: 11/19/03
- Next message: Dan: "clone() doesen't run my process"
- Previous message: Fugitif: "Re: Retrieving available RAM"
- Next in thread: Brandon Niemczyk: "Re: gtk2.0 + gtkglarea problem"
- Reply: Brandon Niemczyk: "Re: gtk2.0 + gtkglarea problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 19 Nov 2003 08:55:38 -0800
Hi everyone,
I'm having some big troubles with GTK 2.0 and the gtkglarea widget.
First if I use this set of links and includes when compiling:
-I/usr/include/ -I/usr/include/gtk-1.2 -I/usr/include/glib-1.2
-I/usr/lib/glib/include -I/usr/X11R6/include
-lX11 -lXi -lXmu -lglut -lGL -lGLU -lm -lgtk -lgdk -rdynamic -lgmodule
-lglib -ldl -lXi -lXext -lgtkgl
Then I get the following message:
gcc -Wall -ggdb -I/usr/include/ -I/usr/include/gtk-1.2
-I/usr/include/glib-1.2 -I/usr/lib/glib/include -I/usr/X11R6/include
-o exe parseur.o processor.o object3D.o main.o -L/usr/X11R6/lib
-lX11 -lXi -lXmu -lglut -lGL -lGLU -lm -lgtk -lgdk -rdynamic -lgmodule
-lglib -ldl -lXi -lXext -lgtkgl
main.o(.text+0x1a7): In function `main':
/home/sam/Developpement/C/Project/InitGTK/main.c:77: undefined
reference to `gtk_window_set_resizable'
collect2: ld returned 1 exit status
make: *** [exe] Error 1
gtk_window_set_resizable is not recognized which makes no sense since
all the other gtk functions I use are recognized...
If I comment the line with the call to this function, then my program
works and display the gtkglarea widget with the others gtk widgets.
Now if I use the following set of links and includes when compiling:
-I/usr/include/ -I/usr/include/gtk-1.2 -I/usr/include/glib-1.2
-I/usr/lib/glib/include -I/usr/X11R6/include -I/usr/include/gtk-2.0
-I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0
-I/usr/include/pango-1.0
-lX11 -lXi -lXmu -lglut -lGL -lGLU -lm -lgtk -lgdk -rdynamic -lgmodule
-lglib -ldl -lXi -lXext -lgtkgl -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0
-lpangox-1.0 -lpango-1.0 -lgobject-2.0
Then it compiles properly. However when I execute the program the
following message appears
(process:4085): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
Segmentation fault
After I used the debugger I figured out that the segmentation fault
happens at the call
glarea = create_glarea ();
and basically will happen at any gtkglarea related functions...
If I comment the 3 lines related to gtkglarea the following appears
when executing :
(process:4095): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
(exe:4095): Gtk-WARNING **: invalid cast from `(unknown)' to
`(unknown)'
(exe:4095): Gtk-CRITICAL **: file gtksignal.c: line 725
(gtk_signal_connect): assertion `GTK_IS_OBJECT (object)' failed.
(exe:4095): Gtk-WARNING **: invalid cast from `(unknown)' to
`(unknown)'
(exe:4095): Gtk-WARNING **: invalid cast from `(unknown)' to
`(unknown)'
(exe:4095): Gtk-CRITICAL **: file gtksignal.c: line 725
(gtk_signal_connect): assertion `GTK_IS_OBJECT (object)' failed.
(exe:4095): Gtk-WARNING **: invalid cast from `(unknown)' to
`(unknown)'
(exe:4095): Gtk-CRITICAL **: file gtksignal.c: line 725
(gtk_signal_connect): assertion `GTK_IS_OBJECT (object)' failed.
(exe:4095): Gtk-WARNING **: invalid cast from `(unknown)' to
`(unknown)'
(exe:4095): Gtk-WARNING **: invalid cast from `(unknown)' to
`(unknown)'
(exe:4095): Gtk-WARNING **: invalid cast from `(unknown)' to
`(unknown)'
And the gtk window of my program appears. Obviously only the button
widget appears since I removed all calls to gtkglarea. However the
button does not work anymore when clicking on it...
This sounds a bit messy but I did my best to explain my problem as
clear as I could. I'm kinda desperate and on the point to give up
gtkglarea and gtk if I can't solve this problem. I could stick with
the first set or libraries and includes and not use
gtk_window_set_resizable but I've notices that other functions (that I
don't use at the moment but I might need them later) crash the program
as well....
Any help would be greatly appreciated !
Sam
Here is my code if needed :
#include <GL/gl.h>
#include <GL/glu.h>
#include <gtk/gtk.h>
#include <gtkgl/gtkglarea.h>
#include "parseur.h"
#include "processor.h"
void display(void);
void draw_points(void);
void draw_wireframe(void);
void draw_polygons(void);
void setOrthoViewVol(void);
void setGluPerspViewVol(void);
void setFrustViewVol(void);
GtkWidget* create_glarea (void);
gint glarea_button_release (GtkWidget*, GdkEventButton*);
gint glarea_button_press (GtkWidget*, GdkEventButton*);
gint glarea_motion_notify (GtkWidget*, GdkEventMotion*);
gint glarea_draw (GtkWidget*, GdkEventExpose*);
gint glarea_reshape (GtkWidget*, GdkEventConfigure*);
gint glarea_init (GtkWidget*);
gint glarea_destroy (GtkWidget*);
int main(int argc, char *argv[])
{
GtkWidget* window;
GtkWidget* button_quit;
GtkWidget* box_main;
GtkWidget* glarea;
gtk_init (&argc, &argv);
/* Main widget container */
box_main = gtk_vbox_new (FALSE, 10);
/* GTK GL Area */
glarea = create_glarea ();
/* Quit button */
button_quit = gtk_button_new_with_label ("Quit");
gtk_signal_connect (GTK_OBJECT(button_quit), "clicked",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
/* Main window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW(window), "GtkGLArea Demo");
/* destroy this window when exiting from gtk_main() */
gtk_quit_add_destroy (1, GTK_OBJECT(window));
gtk_signal_connect (GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
gtk_container_set_border_width (GTK_CONTAINER(window), 10);
/* Pack everything into the main box, add the main box to */
/* the top-level window, and 'show' all of the widgets. */
/* The window is 'shown' last so that when the user sees */
/* it, it's contents are already there. Otherwise they */
/* might see each widget come up. */
gtk_box_pack_start (GTK_BOX(box_main), glarea, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX(box_main), button_quit, FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER(window), box_main);
gtk_widget_show (glarea);
gtk_widget_show (button_quit);
gtk_widget_show (box_main);
gtk_widget_show (window);
gtk_main ();
return 1;
}
GtkWidget* create_glarea (void) {
GtkWidget* glarea;
int attrlist[] = {
GDK_GL_RGBA,
GDK_GL_DOUBLEBUFFER,
GDK_GL_DEPTH_SIZE, 1,
GDK_GL_NONE
};
if(gdk_gl_query() == FALSE) {
g_print("OpenGL not supported!\n");
return NULL;
}
if ((glarea = gtk_gl_area_new(attrlist)) == NULL) {
g_print("Error creating GtkGLArea!\n");
return NULL;
}
gtk_widget_set_events(GTK_WIDGET(glarea),
GDK_EXPOSURE_MASK|
GDK_BUTTON_PRESS_MASK|
GDK_BUTTON_RELEASE_MASK|
GDK_POINTER_MOTION_MASK|
GDK_POINTER_MOTION_HINT_MASK);
gtk_signal_connect (GTK_OBJECT(glarea), "motion_notify_event",
GTK_SIGNAL_FUNC(glarea_motion_notify), NULL);
gtk_signal_connect (GTK_OBJECT(glarea), "expose_event",
GTK_SIGNAL_FUNC(glarea_draw), NULL);
gtk_signal_connect (GTK_OBJECT(glarea), "configure_event",
GTK_SIGNAL_FUNC(glarea_reshape), NULL);
gtk_signal_connect (GTK_OBJECT(glarea), "realize",
GTK_SIGNAL_FUNC(glarea_init), NULL);
gtk_signal_connect (GTK_OBJECT(glarea), "destroy",
GTK_SIGNAL_FUNC (glarea_destroy), NULL);
gtk_widget_set_usize(GTK_WIDGET(glarea), 800, 600);
return (glarea);
}
gint glarea_motion_notify (GtkWidget* widget, GdkEventMotion* event)
{
return TRUE;
}
gint glarea_draw (GtkWidget* widget, GdkEventExpose* event)
{
if (event->count > 0)
{
return(TRUE);
}
g_print ("Expose Event\n");
if (gtk_gl_area_make_current(GTK_GL_AREA(widget)))
{
}
return (TRUE);
}
gint glarea_reshape (GtkWidget* widget, GdkEventConfigure* event)
{
int w = widget->allocation.width;
int h = widget->allocation.height;
g_print ("Reshape Event\n");
if (gtk_gl_area_make_current (GTK_GL_AREA(widget)))
{
}
return (TRUE);
}
gint glarea_init (GtkWidget* widget)
{
g_print ("Realize Event\n");
/* gtk_gl_area_make_current MUST be called before rendering */
/* into the GtkGLArea. */
if (gtk_gl_area_make_current (GTK_GL_AREA(widget)))
{
}
return TRUE;
}
gint glarea_destroy (GtkWidget* widget)
{
g_print ("GTK GL Area Destroy Event\n");
/* Insert any required cleanup */
/* code here. */
return TRUE;
}
- Next message: Dan: "clone() doesen't run my process"
- Previous message: Fugitif: "Re: Retrieving available RAM"
- Next in thread: Brandon Niemczyk: "Re: gtk2.0 + gtkglarea problem"
- Reply: Brandon Niemczyk: "Re: gtk2.0 + gtkglarea problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]