void tui::LayoutCanvas::OnpaintGL(wxPaintEvent&) {
    wxPaintDC dc(this);
   #ifndef __WXMOTIF__
      if (!GetContext()) return;
   #endif
   SetCurrent();
   update_viewport();
   //@TODO !! Check somewhere that RGBA mode is available!?
   // CTM matrix stuff
   glLoadIdentity();
   glOrtho(lp_BL.x(),lp_TR.x(),lp_TR.y(),lp_BL.y(),-1.0,1.0);
   if (invalid_window || !(tmp_wnd || rubber_band)) {
      // invalid_window indicates zooming. If that is false and the rest two 
      // variables are not set, means that the system request repaint 
      // In both cases - the entire window is redrawn
      glClear(GL_COLOR_BUFFER_BIT);
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glClear(GL_ACCUM_BUFFER_BIT);
      Properties->drawGrid();
      DATC->openGL_draw(Properties->drawprop());    // draw data
      glAccum(GL_LOAD, 1.0);
      if (rubber_band) rubber_paint();
      invalid_window = false;
   }
   else if (tmp_wnd) 
      // zooming using the mouse
      wnd_paint();
   else if (n_ScrMARKold != n_ScrMARK) 
      // the only reason to get to this point remains rubber_band == true
      // so the paint will be invoked only if we have something new to show on 
      //the screen
      rubber_paint();
   SwapBuffers();
}
Esempio n. 2
0
static int wheel_cb(Ihandle *ih,float delta,int x,int y,char* status)
{
  int canvas_w, canvas_h;
  cdCanvas *canvas = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS");
  (void)x;
  (void)y;
  (void)status;

  if (scale+delta==0) /* skip 0 */
  {
    if (scale > 0) 
      scale = -1;
    else 
      scale = 1;
  }
  else
    scale += (int)delta;

  cdCanvasActivate(canvas);
  cdCanvasGetSize(canvas, &canvas_w, &canvas_h, NULL, NULL);
  update_scrollbar(ih, canvas_w, canvas_h);
  update_viewport(ih, canvas, IupGetFloat(ih, "POSX"), IupGetFloat(ih, "POSY"));
  IupRedraw(ih, 0);
  return IUP_DEFAULT;
}
Esempio n. 3
0
static int scroll_cb(Ihandle *ih, int op, float posx, float posy)
{
  cdCanvas *canvas = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS");
  update_viewport(ih, canvas, posx, posy);
  IupRedraw(ih, 0);
  (void)op;
  return IUP_DEFAULT;
}
Esempio n. 4
0
bool Viewer::on_button_release_event(GdkEventButton* event) {
  const int axis = event->button - 1;
  axisActive[axis] = false;
  if (mode == VIEWPORT && axis == 0) {
    update_viewport(event->x, event->y);
  }
  return true;
}
Esempio n. 5
0
static int scroll_cb(Ihandle *ih, int op, float posx, float posy)
{
  cdCanvas *canvas = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS");
printf("SCROLL_CB(%g, %g)\n", posx, posy);
  cdCanvasActivate(canvas);
  update_viewport(ih, canvas, posx, posy);
  IupRedraw(ih, 0);
  (void)op;
  return IUP_DEFAULT;
}
Esempio n. 6
0
static int resize_cb(Ihandle *ih, int canvas_w, int canvas_h)
{
  cdCanvas *canvas = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS");

  /* update CD canvas */
  cdCanvasActivate(canvas);
 
  update_scrollbar(ih, canvas_w, canvas_h);
  update_viewport(ih, canvas, IupGetFloat(ih, "POSX"), IupGetFloat(ih, "POSY"));
  return IUP_DEFAULT;
}
Esempio n. 7
0
static void init_raster() {
    viewport_state_t *vp = &state.viewport;
    if (!vp->width || !vp->height) {
        GLint tmp[4];
        glGetIntegerv(GL_VIEWPORT, tmp);
        update_viewport(tmp[0], tmp[1], tmp[2], tmp[3]);
    }
    if (! state.raster.buf) {
        state.raster.buf = (GLubyte *)malloc(4 * vp->nwidth * vp->nheight * sizeof(GLubyte));
    }
}
void tui::LayoutCanvas::OnpaintGL(wxPaintEvent& event) {
    wxPaintDC dc(this);
   #ifndef __WXMOTIF__
      if (!GetContext()) return;
   #endif
   SetCurrent();
   // invalid_window indicates zooming.
   // event.GetEventType() == event.GetId() should means that database is updated
   // In both cases - the entire window is redrawn
   if ((invalid_window) || (event.GetEventType() == event.GetId()))
   {
      glMatrixMode( GL_MODELVIEW );
      glShadeModel( GL_FLAT ); // Single color
      update_viewport();
      //@TODO !! Check somewhere that RGBA mode is available!?
      // CTM matrix stuff
      glLoadIdentity();
      glOrtho(lp_BL.x(),lp_TR.x(),lp_TR.y(),lp_BL.y(),-1.0,1.0);
      glClear(GL_COLOR_BUFFER_BIT);
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glClear(GL_ACCUM_BUFFER_BIT);
      DATC->openGL_draw(_LayCTM);    // draw data
      glAccum(GL_LOAD, 1.0);
      invalid_window = false;
      if (rubber_band) rubber_paint();
   }
   else
   {
      glAccum(GL_RETURN, 1.0);
      if       (tmp_wnd)         wnd_paint();
      else if  (rubber_band)     rubber_paint();
   }
   // deal with the long cursor
   if (reperX || reperY)
   {
      glColor4f(1, 1, 1, .5);
      glBegin(GL_LINES);
      if (reperX)
      {
         glVertex2i(lp_BL.x(), ScrMARK.y()) ;
         glVertex2i(lp_TR.x(), ScrMARK.y());
      }
      if (reperY)
      {
         glVertex2i(ScrMARK.x() , lp_BL.y()) ;
         glVertex2i(ScrMARK.x() , lp_TR.y());
      }
      glEnd();
   }

   SwapBuffers();
}
Esempio n. 9
0
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
    PUSH_IF_COMPILING(glViewport);
    if (state.raster.buf) {
        render_raster();
    }
    if (width < 0 || height < 0) {
        ERROR(GL_INVALID_VALUE);
    }
    update_viewport(x, y, width, height);
    LOAD_GLES(glViewport);
    gles_glViewport(x, y, width, height);
}
Esempio n. 10
0
GPGX_EX int gpgx_state_load(void *src, int size)
{
	if (!size)
		return 0;

	if (state_load((unsigned char *) src) == size)
	{
		update_viewport();
		return 1;
	}
	else
		return 0;
}
Esempio n. 11
0
static void
on_mapped (GtkWidget *widget)
{
    GdkGLContext *gl_context = gtk_widget_get_gl_context (widget);
    GdkGLDrawable *gl_drawable = gtk_widget_get_gl_drawable (widget);

    g_return_if_fail (gl_context != NULL && gl_drawable != NULL);
    g_return_if_fail (gdk_gl_drawable_gl_begin (gl_drawable, gl_context));

    init_gl_resources ();
    update_viewport (widget);

    gdk_gl_drawable_gl_end (gl_drawable);
}
Esempio n. 12
0
void tui::LayoutCanvas::OnpaintGL(wxPaintEvent& event) {
   #ifndef __WXMOTIF__
      if (!GetContext()) return;
   #endif
   // invalid_window indicates zooming or refreshing after a tell operation.
   if (invalid_window)
   {
      wxPaintDC dc(this);
      SetCurrent();
      glMatrixMode( GL_MODELVIEW );
      glShadeModel( GL_FLAT ); // Single color
      update_viewport();
      // CTM matrix stuff
      glLoadIdentity();
      glOrtho(lp_BL.x(),lp_TR.x(),lp_TR.y(),lp_BL.y(),-1.0,1.0);
      glClear(GL_COLOR_BUFFER_BIT);
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glClear(GL_ACCUM_BUFFER_BIT);
      DATC->openGL_draw(_LayCTM);    // draw data
      glAccum(GL_LOAD, 1.0);
      invalid_window = false;
      if (rubber_band) rubber_paint();
   }
   else
   {
      glAccum(GL_RETURN, 1.0);
      if       (tmp_wnd)         wnd_paint();
      else if  (rubber_band)     rubber_paint();
   }
   // deal with the long cursor
   if (reperX || reperY)
   {
      glColor4f(1, 1, 1, .5);
      glBegin(GL_LINES);
      if (reperX)
      {
         glVertex2i(lp_BL.x(), ScrMARK.y()) ;
         glVertex2i(lp_TR.x(), ScrMARK.y());
      }
      if (reperY)
      {
         glVertex2i(ScrMARK.x() , lp_BL.y()) ;
         glVertex2i(ScrMARK.x() , lp_TR.y());
      }
      glEnd();
   }

   SwapBuffers();
}
Esempio n. 13
0
GPGX_EX void gpgx_advance(void)
{
	if (system_hw == SYSTEM_MCD)
		system_frame_scd(0);
	else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
		system_frame_gen(0);
	else
		system_frame_sms(0);

	if (bitmap.viewport.changed & 1)
	{
		bitmap.viewport.changed &= ~1;
		update_viewport();
	}

	nsamples = audio_update(soundbuffer);
}
Esempio n. 14
0
static gboolean 
on_configure (GtkWidget *widget, 
              GdkEventConfigure *event)
{
    if (GTK_WIDGET_MAPPED (widget)) {
        GdkGLContext *gl_context = gtk_widget_get_gl_context (widget);
        GdkGLDrawable *gl_drawable = gtk_widget_get_gl_drawable (widget);

        g_return_val_if_fail (gl_context != NULL && gl_drawable != NULL, TRUE);
        g_return_val_if_fail (gdk_gl_drawable_gl_begin (gl_drawable, gl_context), TRUE);

        update_viewport (widget);

        gdk_gl_drawable_gl_end (gl_drawable);
    }

    return FALSE;
}
Esempio n. 15
0
static int resize_cb(Ihandle *ih, int canvas_w, int canvas_h)
{
  cdCanvas *canvas = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS");

printf("RESIZE_CB(%d, %d) RASTERSIZE=%s DRAWSIZE=%s \n", canvas_w, canvas_h, IupGetAttribute(ih, "RASTERSIZE"), IupGetAttribute(ih, "DRAWSIZE"));
  /* When *AUTOHIDE=Yes, this can hide a scrollbar and so change the canvas drawsize */
  update_scrollbar(ih, canvas_w, canvas_h);  
printf("                                DRAWSIZE=%s \n", IupGetAttribute(ih, "DRAWSIZE"));
  /* update the canvas size */
  IupGetIntInt(ih, "DRAWSIZE", &canvas_w, &canvas_h);

  /* update the application */
  cdCanvasActivate(canvas);
  update_scrollbar(ih, canvas_w, canvas_h);  
  update_viewport(ih, canvas, IupGetFloat(ih, "POSX"), IupGetFloat(ih, "POSY"));

  return IUP_DEFAULT;
}
Esempio n. 16
0
bool Viewer::on_motion_notify_event(GdkEventMotion* event) {
  const int diff = event->x - lastMouseX;
  lastMouseX = event->x;
  bool anyChange = false;
  Vector3D transAmount;
  for (int axis = 0; axis < 3; axis++) {
    if (axisActive[axis]) {
      anyChange = true;
      transAmount[axis] = diff;
    }
  }
  if (DYNAMIC_VIEWPORT && mode == VIEWPORT && axisActive[0]) { // Left mouse button only.
    update_viewport(event->x, event->y);
  }
  if (anyChange) {
    LOG("Mouse translation " << transAmount);
    LOG("Now matrix is " << worldNode->getTransform());
    handleViewChange(transAmount);
    invalidate();
  }
  return true;
}