void SludgeGLApplication::on_drawingarea1_realize(GtkWidget *theWidget)
{
	GdkGLContext *glContext;
	GdkGLDrawable *glDrawable;

	if (theWidget->window == NULL)
	{
		return;
	}

	gtk_widget_add_events(theWidget, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
					 | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_SCROLL_MASK);  

	glContext = gtk_widget_get_gl_context (theWidget);
	glDrawable = gtk_widget_get_gl_drawable (theWidget);

	// Signal to gdk the start OpenGL operations.
	if (!gdk_gl_drawable_gl_begin (glDrawable, glContext))
	{
		return;
	}

	glViewport (0, 0, theWidget->allocation.width, theWidget->allocation.height);

	/* Your one-time OpenGL initialization code goes here */
    x = y = 0;
    w = theWidget->allocation.width;
    h = theWidget->allocation.height;
	prepareOpenGL();

	// Signal to gdk we're done with OpenGL operations.
	gdk_gl_drawable_gl_end (glDrawable);

	gdk_window_invalidate_rect (gtk_widget_get_parent_window (theWidget), &theWidget->allocation, TRUE);
}
Пример #2
0
gboolean SludgeFloorMaker::init(gboolean calledFromConstructor) 
{
	firstPoly = 0;
	noFloor(&firstPoly);
		
	backdrop.total=0;
	backdrop.type=2;
	backdrop.sprites=NULL;
	backdrop.myPalette.pal = NULL;
	backdrop.myPalette.r=NULL;
	backdrop.myPalette.g=NULL;
	backdrop.myPalette.b=NULL;

	if (!calledFromConstructor) {
		prepareOpenGL();
	}

	if (!reserveSpritePal(&backdrop.myPalette, 0)) {
			return TRUE;
	}

    return FALSE;
}