Ejemplo n.º 1
0
// flip GL buffers
void graph3d_gtk::flip(void)
{ 
  /* Swap backbuffer to front */
  if(graphics && p_area && gtk_gl_rendering(p_area)) {
    gtk_gl_area_swapbuffers(GTK_GL_AREA(p_area));
  }
}
Ejemplo n.º 2
0
/* When widget is exposed it's contents are redrawn. */
gint draw(GtkWidget *widget, GdkEventExpose *event)
{
  /* Draw only last expose. */
  if (event->count > 0)
    return TRUE;

  if (gtk_gl_area_make_current(GTK_GL_AREA(widget)))
    game_render();

  /* Swap backbuffer to front */
  gtk_gl_area_swapbuffers(GTK_GL_AREA(widget));

  return TRUE;
}
Ejemplo n.º 3
0
gint initialize(GtkWidget *glarea, gpointer data) {
  if(gtk_gl_area_make_current(GTK_GL_AREA(glarea))) {
    GLfloat light_ambient[] = {0.5, 0.5, 0.5, 1.0};
    GLfloat light_diffuse[] = {0.75, 0.75, 0.75, 1.0};
    GLfloat light_position[] = {400, 400, 400, 1.0};

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_NORMALIZE);
    glEnable(GL_CULL_FACE);

    glClearColor(0, 0, 0, 0);
    glClearDepth(1.0);
    glDepthFunc(GL_LESS);
    glShadeModel(GL_SMOOTH);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);

    glViewport(0, 0, glarea->allocation.width, glarea->allocation.height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0, (double) glarea->allocation.width / (double) glarea->allocation.height, 3.0, 2500.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    gtk_gl_area_swapbuffers(GTK_GL_AREA(glarea));

    return TRUE;
  } else {
    // could not set context
    return FALSE;
  }
}
Ejemplo n.º 4
0
void GLArea::swap_buffers() {
  gtk_gl_area_swapbuffers(GTK_GL_AREA(m_glarea->gobj()));
}