示例#1
0
static gboolean cb_reshape_ext(GtkWidget *widget, GdkEventConfigure *ev, void *_object)
{
	/* recuperation du contexte et de la surface de notre widget */
	GdkGLContext *context;
	GdkGLDrawable *surface;

	if (!THIS->init)
		return TRUE;
	
	//fprintf(stderr, "cb_reshape_ext: %p\n", THIS);
		
	if (!gtk_widget_is_gl_capable(widget))
	{
		fprintf(stderr, "not capable!\n");
		return TRUE;
	}
	
	context = gtk_widget_get_gl_context(widget);
	surface = gtk_widget_get_gl_drawable(widget);

	/* activation du contexte */
	if(gdk_gl_drawable_gl_begin(surface, context))
	{
		//reshape(ev−>height,ev−>width); // redimensionnement Opengl
		GB.Raise(THIS, EVENT_Resize, 0);
		gdk_gl_drawable_gl_end(surface); // désactivation du contexte
	}

	return TRUE;
}
示例#2
0
static gboolean cb_draw_ext(GtkWidget *widget, GdkEventExpose *e, void *_object)
{
	/* recuperation du contexte et de la surface de notre widget */
	GdkGLContext *context;
	GdkGLDrawable *surface;

	//fprintf(stderr, "cb_draw_ext: %p\n", THIS);
	
	if (!gtk_widget_is_gl_capable(widget))
	{
		fprintf(stderr, "not capable!\n");
		return TRUE;
	}
	
	context = gtk_widget_get_gl_context(widget);
	surface = gtk_widget_get_gl_drawable(widget);

	/* activation du contexte */
	if(gdk_gl_drawable_gl_begin(surface, context))
	{
		//draw(); // dessin Opengl
		init_control(THIS);
		GB.Raise(THIS, EVENT_Draw, 0);
		gdk_gl_drawable_swap_buffers(surface); // permutation tampons
		gdk_gl_drawable_gl_end(surface); // désactivation du contexte
	}

	return TRUE;
}
示例#3
0
static gboolean _chisel_native_openglview_configure_event( GtkWidget *widget, GdkEvent *event, gpointer native_data ) {
	if ( GTK_WIDGET_REALIZED(widget) ) {
		printf( "resize!\n" );
		assert( gtk_widget_is_gl_capable( widget ) );
		
		GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable( widget );
		GdkGLContext *glcontext = gtk_widget_get_gl_context( widget );
		
		assert( gdk_gl_drawable_gl_begin( gldrawable, glcontext ) );

		/*_chisel_native_openglview_reshape_callback( (native_handle)widget );
		
		GtkAllocation allocation;
		gtk_widget_get_allocation( GTK_WIDGET(widget), &allocation );*/
		
		glViewport (0, 0,
              widget->allocation.width, widget->allocation.height);

		
		gdk_gl_drawable_gl_end( gldrawable );
		
		/*// now invalidate!
		Rect rect;
		rect.origin.x = 0;//allocation.x;
		rect.origin.y = 0;//allocation.y;
		rect.size.width = allocation.width;
		rect.size.height = allocation.height;
		_chisel_native_view_invalidate_rect( (native_handle)widget, rect );*/
	}
	
	return TRUE;
}
示例#4
0
static gboolean _chisel_native_openglview_expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer native_data ) {
	if ( GTK_WIDGET_REALIZED(widget) ) {
		assert( gtk_widget_is_gl_capable( widget ) );
		
		GdkGLContext *glcontext = gtk_widget_get_gl_context( widget );
		GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable( widget );
		
		assert( gdk_gl_drawable_gl_begin( gldrawable, glcontext ) );
		
		Rect rect;
		rect.origin.x = event->area.x;
		rect.origin.y = event->area.y;
		rect.size.width = event->area.width;
		rect.size.height = event->area.height;
		printf( "expose!\n" );
		//_chisel_native_view_draw_rect_callback( (native_handle)widget, rect );
		
		glViewport (0, 0,
                widget->allocation.width, widget->allocation.height); 
		
		glClearColor( 0.0f, 0.0f, 1.0f, 1.0f );
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
		
		if (gdk_gl_drawable_is_double_buffered (gldrawable))
			gdk_gl_drawable_swap_buffers (gldrawable);
		else
			glFlush ();

	
		gdk_gl_drawable_gl_end( gldrawable );
	}
	
	return TRUE;
}
示例#5
0
文件: gtkglext.c 项目: ifreedom/lgob
static int lglext_widget_is_gl_capable(lua_State* L)
{
	luaL_checktype(L, 1, LUA_TUSERDATA);
	Object* obj = lua_touserdata(L, 1);

	gboolean res = gtk_widget_is_gl_capable(GTK_WIDGET(obj->pointer));
	lua_pushboolean(L, res);

	return 1;
}
示例#6
0
gboolean glwidget_enable_gl( GtkWidget* widget, GtkWidget* widget2, gpointer data ){
	if ( widget2 == 0 && !gtk_widget_is_gl_capable( widget ) ) {
		GdkGLConfig* glconfig = ( g_object_get_data( G_OBJECT( widget ), "zbuffer" ) ) ? glconfig_new_with_depth() : glconfig_new();
		ASSERT_MESSAGE( glconfig != 0, "failed to create OpenGL config" );

		gtk_widget_set_gl_capability( widget, glconfig, g_shared != 0 ? gtk_widget_get_gl_context( g_shared ) : 0,  TRUE, GDK_GL_RGBA_TYPE );

		gtk_widget_realize( widget );
		if ( g_shared == 0 ) {
			g_shared = widget;
		}

		// free glconfig?
	}
	return FALSE;
}
示例#7
0
gboolean GLWidget::onHierarchyChanged(GtkWidget* widget,
		GtkWidget* previous_toplevel, GLWidget* self) {
	if (previous_toplevel == NULL && !gtk_widget_is_gl_capable(widget)) {
		// Create a new GL config structure
		GdkGLConfig* glconfig = (self->_zBuffer) ? createGLConfigWithDepth()
				: createGLConfig();
		ASSERT_MESSAGE(glconfig != NULL, "failed to create OpenGL config");

		gtk_widget_set_gl_capability(widget, glconfig,
				g_shared != NULL ? gtk_widget_get_gl_context(g_shared) : NULL,
				TRUE, GDK_GL_RGBA_TYPE);

		gtk_widget_realize(widget);

		// Shared not set yet?
		if (g_shared == 0) {
			g_shared = widget;
		}
	}

	return FALSE;
}