예제 #1
0
static void drawTestGL(Ihandle* ih)
{
  Ihandle* glcanvas = IupGetAttributeHandle(ih, "PREVIEWGLCANVAS");
  if (glcanvas)
  {
    int w = IupGetInt(ih, "PREVIEWWIDTH");
    int h = IupGetInt(ih, "PREVIEWHEIGHT");

    IupGLMakeCurrent(glcanvas);
    glViewport(0,0,w,h);

    glClearColor(1.0, 0.0, 1.0, 1.f);  /* pink */
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glColor3f(1.0,0.0,0.0);  /* red */
    glBegin(GL_QUADS); 
    glVertex2f(0.9f,0.9f); 
    glVertex2f(0.9f,-0.9f); 
    glVertex2f(-0.9f,-0.9f); 
    glVertex2f(-0.9f,0.9f); 
    glEnd();

    IupGLSwapBuffers(glcanvas);
  }
  else
    drawTest(ih);
}
int repaint_cb(Ihandle *canvas) {

	register ListElem *elem;
	register float *xy, *xy_2;

//	if (IupGLIsCurrent(canvas) == 0) {
		IupGLMakeCurrent(canvas);                   /* Declare our canvas for OpenGL */
		glClearColor(0.0, 0.0, 0.0, 0.0);
		glPointSize(1.0);
//	}
	glClear(GL_COLOR_BUFFER_BIT);

	elem = list_head(&pointList);
	glBegin(GL_POINTS);

		while (elem != 0) {                         /* Draw all the lines from linked list */

			xy = (float*) list_data(elem);          /* One endpoint of the line being drawn */
			elem = list_next(elem);
			xy_2 = (float*) list_data(elem);        /* Another endpoint of the same line */
			
			mygl_drawGenericLine(*xy, *(xy + 1), *xy_2, *(xy_2 + 1));
			elem = list_next(elem);
		}
		
		clipal_drawClipRectangle();                 /* Draw clip rectangle on the canvas */

	glEnd();

	glFlush();

	return IUP_DEFAULT;
}
예제 #3
0
int ERN2DViewMethod::Idle_Action_CB (Ihandle* cnv_renderer)
{
  IupGLMakeCurrent (cnv_renderer);
  if (m_redisplay || m_auto_redisplay)
  {
    if (m_outdated)
    {
      if (!m_renderer.m_glsl_preintegrated_texture || Viewer::Instance ()->m_volumename.compare (m_volumename) != 0)
      {
        m_volumename = Viewer::Instance ()->m_volumename;
        m_renderer.ReloadVolume (Viewer::Instance ()->m_volume, Viewer::Instance ()->m_transfer_function);
      }

      UpdateIupUserInterface ();
      m_outdated = false;
    }

    if (m_renderer.m_glsl_preintegrated_texture)
    {
      m_renderer.Render (Viewer::Instance ()->m_CurrentWidth, Viewer::Instance ()->m_CurrentHeight);
      IupGLSwapBuffers (cnv_renderer);
    }
    m_redisplay = false;
  }
  return IUP_DEFAULT;
}
예제 #4
0
/* function called when the canvas is exposed in the screen.  self is the iuphandle of the canvas */
int repaint_cb(Ihandle *self) 
{
  int x,y;
  IupGLMakeCurrent(self);                /* all OpenGL primitives will be directed to this canvas */
  glClearColor(0.3f, 0.3f, 0.3f, 1.0f);  /* dark grey color in the RGBA mode A is the alpha channel (ignore) */
  glClear(GL_COLOR_BUFFER_BIT);          /* clear the color buffer */

  if (gc.image!=NULL) 
  {
	  int h = imgGetHeight(gc.image);
	  int w = imgGetWidth(gc.image);
	  /* assing to each pixel of the canvas the color of the corresponding pixel in the image */
	  glBegin(GL_POINTS);   
	  for (y=0;y<h;y++) {
		  for (x=0;x<w;x++) {
			  float r,g,b;
			  imgGetPixel3f(gc.image,x,y,&r,&g,&b); /* gets the RGB value the pixel (x,y) */ 
			  glColor3f(r,g,b);        /* define a current color in OpenGL */
			  glVertex2i(x,y);         /* paint the pixel */
		  }

	  }
	  glEnd();
  }
  IupGLSwapBuffers(self);  /* change the back buffer with the front buffer */
  return IUP_DEFAULT; /* returns the control to the main loop */
}
예제 #5
0
void GLCanvasCubeTest(void)
{
  Ihandle *dlg, *canvas, *box;

  IupGLCanvasOpen();

  box = IupVbox(NULL);
  IupSetAttribute(box, "MARGIN", "5x5");

  canvas = IupGLCanvas(NULL);
  IupSetCallback(canvas, "ACTION", action);
  IupSetCallback(canvas, "BUTTON_CB", (Icallback)button_cb);
  IupSetCallback(canvas, "MOTION_CB", (Icallback)motion_cb);
//  IupSetAttribute(canvas, "BUFFER", "DOUBLE");
  IupSetAttribute(canvas, "RASTERSIZE", "300x300");
  IupAppend(box, canvas);

  dlg = IupDialog(IupSetAttributes(IupFrame(box), "TITLE=Test"));
  IupSetAttribute(dlg, "TITLE", "IupGLCanvas Test");
//  IupSetAttribute(dlg, "COMPOSITED", "YES");

  IupMap(dlg);

  IupGLMakeCurrent(canvas);
//  init();
  printf("Vendor: %s\n", glGetString(GL_VENDOR));
  printf("Renderer: %s\n", glGetString(GL_RENDERER));
  printf("Version: %s\n", glGetString(GL_VERSION));
  IupSetAttribute(canvas, "RASTERSIZE", NULL);

  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
}
예제 #6
0
/* calcula uma linha da imagem a cada camada de idle */
int idle_cb(void)
{
	int x;
	/* Faz uma linha de pixels por vez */
	if (yc<height) {
		IupGLMakeCurrent(canvas);
		glBegin(GL_POINTS);
		for( x = 0; x < width; ++x ) {
			Color pixel;
			Vector ray;				

			ray = camGetRay( camera, x, yc );
			pixel = rayTrace( scene, eye, ray, 0 );

			imageSetPixel( image, x, yc, pixel );
			glColor3f((float)pixel.red,(float)pixel.green,(float)pixel.blue);
			glVertex2i(x,yc);

		}
		glEnd();
		glFlush();
		IupGLSwapBuffers(canvas);  /* change the back buffer with the front buffer */
		yc++;
	}
	else {
		IupSetFunction (IUP_IDLE_ACTION, (Icallback) NULL); /* a imagem ja' esta' completa */
		finish_time = clock();
		duration = (double)(finish_time - start_time)/CLOCKS_PER_SEC;
		IupSetfAttribute(label, "TITLE", "tempo=%.3lf s", duration);
	}

	return IUP_DEFAULT;
}
예제 #7
0
/* carrega uma nova cena */
int load_cb(void) {
	char* filename = get_file_name();  /* chama o dialogo de abertura de arquivo */
	char buffer[30];

	if (filename==NULL) return 0;

	/* Le a cena especificada */
	scene = sceLoad( filename );
	if( scene == NULL ) return IUP_DEFAULT;

	camera = sceGetCamera( scene );
	eye = camGetEye( camera );
	width = camGetScreenWidth( camera );
	height = camGetScreenHeight( camera );
	yc=0;

	if (image) imgDestroy(image);
	image = imgCreate( width, height );
	IupSetfAttribute(label, "TITLE", "%3dx%3d", width, height);
	sprintf(buffer,"%3dx%3d", width, height);
	IupSetAttribute(canvas,IUP_RASTERSIZE,buffer);
	IupSetFunction (IUP_IDLE_ACTION, (Icallback) idle_cb);
	start_time  = clock(); 

	IupGLMakeCurrent(canvas);
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT);
	glEnd();
	glFlush();
	IupGLSwapBuffers(canvas);  /* change the back buffer with the front buffer */

	return IUP_DEFAULT;
}
예제 #8
0
static int motion_cb(Ihandle *ih,int x,int y,char* status)
{
  (void)status;

  if (move)
  {
    double dif_x, dif_y;
    double dx, dy, dz;
    double x1, y1, z1;
    double x2, y2, z2;
    double angle, norma;
    int height = IupGetInt2(ih, "RASTERSIZE");
    double mv[16];
    double pm[16];
    int    vp[4];

    IupGLMakeCurrent(ih);

    glGetDoublev(GL_MODELVIEW_MATRIX, mv);
    glGetDoublev(GL_PROJECTION_MATRIX, pm);
    glGetIntegerv(GL_VIEWPORT, vp);

    dif_x = x - pos_x;
    dif_y = y - pos_y;

    if (dif_x == 0 && dif_y == 0)
      return IUP_DEFAULT;

    pos_x = x;
    pos_y = y;

    angle = sqrt(dif_x*dif_x + dif_y*dif_y);

    gluUnProject(pos_x, INVERT_Y(pos_y), 0.0,
      mv, pm, vp,
      &x1, &y1, &z1);
    gluUnProject((double)(dif_y + pos_x), (double)(dif_x + INVERT_Y(pos_y)), 0.0,
      mv, pm, vp,
      &x2, &y2, &z2);
    dx = x2-x1; dy = y2-y1; dz = z2-z1;
    norma = sqrt(dx*dx + dy*dy + dz*dz);
    dx /= norma; dy /= norma; dz /= norma;

    glMatrixMode(GL_MODELVIEW);
    glTranslated(0.5, 0.5, 0.5);
    glRotated (angle, dx, dy, dz);
    glTranslated(-0.5, -0.5, -0.5);
    glGetDoublev(GL_MODELVIEW_MATRIX, model_view_matrix);
    use_model_matrix = 1;

    draw_cube();
  
    IupGLSwapBuffers(ih); 
  }
  return IUP_DEFAULT;
}
예제 #9
0
static int GLMakeCurrent(lua_State *L)
{  
   IupGLMakeCurrent(iuplua_checkihandle(L,1));

   iuplua_get_env(L);
   iuplua_regstring(L, IupGetGlobal("GL_VENDOR"), "GL_VENDOR");
   iuplua_regstring(L, IupGetGlobal("GL_RENDERER"), "GL_RENDERER");
   iuplua_regstring(L, IupGetGlobal("GL_VERSION"), "GL_VERSION");

   return 0;
}
예제 #10
0
static int GLMakeCurrent(lua_State *L)
{  
   IupGLMakeCurrent(iuplua_checkihandle(L,1));

   iuplua_get_env(L);
   iuplua_regstring(L, (const char*)glGetString(GL_VENDOR), "GL_VENDOR");
   iuplua_regstring(L, (const char*)glGetString(GL_RENDERER), "GL_RENDERER");
   iuplua_regstring(L, (const char*)glGetString(GL_VERSION), "GL_VERSION");

   return 0;
}
예제 #11
0
static int action(Ihandle *ih)
{
  IupGLMakeCurrent(ih);

  init();

  draw_cube();

  IupGLSwapBuffers(ih); 

  return IUP_DEFAULT;
}
예제 #12
0
/* - Callback de repaint do canvas  */
int repaint_cb(Ihandle *self)
{
	int w,h;
	int x,y;
	Color rgb;

	if (yc==0){  /* e' a primeira vez: limpa o canvas */
		IupGLMakeCurrent(self);
		glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
		glClear(GL_COLOR_BUFFER_BIT);
		IupGLSwapBuffers(self);  /* change the back buffer with the front buffer */
		glFlush();
	}

	if (yc!=height) { /* esta callback so'desenha depois que o algoritmo termina a imagem */
		return IUP_DEFAULT; 
	}

	w = imgGetWidth(image);
	h = imgGetHeight(image);
	IupGLMakeCurrent(self);
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT);

	glBegin(GL_POINTS);
	for (y=0;y<h;y++) {
		for (x=0; x<w; x++) {
			rgb = imageGetPixel(image, x, y);
			glColor3f((float)rgb.red,(float)rgb.green,(float)rgb.blue);
			glVertex2i(x,y);
		}
	}
	glEnd();

	IupGLSwapBuffers(self);  /* change the back buffer with the front buffer */

	glFlush();
	return IUP_DEFAULT; /* retorna o controle para o gerenciador de eventos */
} 
예제 #13
0
파일: iupmain.c 프로젝트: Vulcanior/IUP
void SimpleUpdateSize(cdCanvas* cnv)
{
  Ihandle* canvas = IupGetHandle("SimpleCanvas");
  IupGLMakeCurrent(canvas);

  if (cnv)
  {
    int w, h;
    double res = IupGetDouble(NULL, "SCREENDPI") / 25.4;
    IupGetIntInt(canvas, "DRAWSIZE", &w, &h);

    cdCanvasSetfAttribute(cnv, "SIZE", "%dx%d %g", w, h, res);  /* no need to update resolution */
  }
}
예제 #14
0
static int iGLCanvasBoxACTION(Ihandle* ih, float posx, float posy)
{
  IFnff cb;

  IupGLMakeCurrent(ih);

  cb = (IFnff)IupGetCallback(ih, "APP_ACTION");
  if (cb)
    cb(ih, posx, posy);

  if (!iupStrEqualNoCase(iupAttribGetStr(ih, "BUFFER"), "DOUBLE"))
    iGLCanvasBoxSwapBuffers_CB(ih);

  return IUP_DEFAULT;
}
예제 #15
0
파일: iupglview.c 프로젝트: LuaDist/im
int app_repaint_cb(Ihandle* self)
{
  unsigned char* gl_data = (unsigned char*)IupGetAttribute(self, "APP_GL_DATA");
  int width = IupGetInt(self, "APP_GL_WIDTH");
  int height = IupGetInt(self, "APP_GL_HEIGHT");
  IupGLMakeCurrent(self);        /* activates this GL Canvas as the current drawing area. */
  glClear(GL_COLOR_BUFFER_BIT);  /* clears the back buffer */

  if (gl_data)
  {
    /* Draws the captured image at (0,0) */
    glRasterPos2f(0.f, 0.f); 
    glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, gl_data);
  }

  IupGLSwapBuffers(self);        /* swap data from back buffer to front buffer */
  return IUP_DEFAULT;
} 
예제 #16
0
파일: example4_2.c 프로젝트: sanikoyes/iup
int canvas_action_cb(Ihandle* canvas)
{
  int x, y, canvas_width, canvas_height;
  void* gldata;
  unsigned int ri, gi, bi;
  imImage* image;
  Ihandle* config = (Ihandle*)IupGetAttribute(canvas, "CONFIG");
  const char* background = IupConfigGetVariableStrDef(config, "MainWindow", "Background", "255 255 255");

  IupGetIntInt(canvas, "DRAWSIZE", &canvas_width, &canvas_height);

  IupGLMakeCurrent(canvas);

  /* OpenGL configuration */
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);           /* image data alignment is 1 */

  glViewport(0, 0, canvas_width, canvas_height);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(0, canvas_width, 0, canvas_height, -1, 1);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  /* draw the background */
  sscanf(background, "%u %u %u", &ri, &gi, &bi);
  glClearColor(ri / 255.f, gi / 255.f, bi / 255.f, 1);
  glClear(GL_COLOR_BUFFER_BIT);

  /* draw the image at the center of the canvas */
  image = (imImage*)IupGetAttribute(canvas, "IMAGE");
  if (image)
  {
    x = (canvas_width - image->width) / 2;
    y = (canvas_height - image->height) / 2;
    gldata = (void*)imImageGetAttribute(image, "GLDATA", NULL, NULL);
    glRasterPos2i(x, y);  /* this will not work for negative values, OpenGL limitation */
    glDrawPixels(image->width, image->height, GL_RGB, GL_UNSIGNED_BYTE, gldata);  /* no zoom support, must use texture */
  }

  IupGLSwapBuffers(canvas);
  return IUP_DEFAULT;
}
예제 #17
0
파일: glcube.c 프로젝트: defdef/iup
/* function called when the canvas is exposed in the screen */
static int repaint_cb(Ihandle *self) 
{
  IupGLMakeCurrent(self);
  glClearColor(0.3f, 0.3f, 0.3f, 1.0f);  /* White */
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glEnable(GL_DEPTH_TEST);

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();  /* saves current model view in a stack */
      glTranslatef( 0.0f, 0.0f , 0.0f );
      glScalef( 1.0f, 1.0f, 1.0f );
      glRotatef(t,0,0,1);
      colorCube();
   glPopMatrix();
 
  IupGLSwapBuffers(self);  /* change the back buffer with the front buffer */

  return IUP_DEFAULT; /* returns the control to the main loop */
}
예제 #18
0
/* calcula uma linha da imagem a cada camada de idle */
int idle_cb(void)
{
	int x;
	double ray[VECTOR];
	float pixel[COLOR];

  /* Faz uma linha de pixels por vez */
  if (yc < height) {

    IupGLMakeCurrent(canvas);
    glBegin(GL_POINTS);
    {
      for (x = 0; x < width; ++x) {

        camGetRay(camera, x, yc, ray);
        rayTrace(scene, eye, ray, 0, pixel);

        imageSetPixel(image, x, yc, pixel);
        glColor3f((float) pixel[RED], (float) pixel[GREEN], (float) pixel[BLUE]);
        glVertex2i(x, yc);

      }
    }
    glEnd();

    glFlush();

    IupGLSwapBuffers(canvas);
    
    yc++;
  } else {

		IupSetFunction (IUP_IDLE_ACTION, (Icallback) NULL); /* a imagem ja' esta' completa */
		finish_time = clock();
		duration = (double)(finish_time - start_time)/CLOCKS_PER_SEC;
		IupSetfAttribute(label, "TITLE", "tempo=%.3lf s", duration);

		glFlush();
	}


	return IUP_DEFAULT;
}
예제 #19
0
파일: glcube.c 프로젝트: defdef/iup
/* function called in the event of changes in the width or in the height of the canvas */
static int resize_cb(Ihandle *self, int width, int height)
{
  IupGLMakeCurrent(self);  /* Make the canvas current in OpenGL */

  /* define the entire canvas as the viewport  */
  glViewport(0, 0, width, height);

  /* transformation applied to each vertex */
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();           /* identity, i. e. no transformation */

  /* projection transformation (orthographic in the xy plane) */
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(60,4./3.,1.,15);
  gluLookAt(3,3,3, 0,0,0, 0,0,1);

  return IUP_DEFAULT; /* return to the IUP main loop */
}
예제 #20
0
static int action(Ihandle *ih)
{
  static int first = 1;
  IupGLMakeCurrent(ih);

  if (first)
  {
    init();
    first = 0;
  }

  glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

  draw_cube();

  glFlush();
  IupGLSwapBuffers(ih); 

  return IUP_DEFAULT;
}
예제 #21
0
/* - Callback de mudanca de tamanho no canvas (mesma para ambos os canvas) */
int resize_cb(Ihandle *self, int width, int height)
{
 IupGLMakeCurrent(self);  /* torna o foco do OpenGL para este canvas */

 /* define a area do canvas que deve receber as primitivas do OpenGL */
 glViewport(0,0,width,height);

 /* transformacao de instanciacao dos objetos no sistema de coordenadas da camera */
 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();           /* identidade,  ou seja nada */

 /* transformacao de projecao */
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 gluOrtho2D (0.0, (GLsizei)(width), 0.0, (GLsizei)(height));  /* ortografica no plano xy de [0,w]x[0,h] */
  
 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
 glClear(GL_COLOR_BUFFER_BIT);

 return IUP_DEFAULT; /* retorna o controle para o gerenciador de eventos */
}
예제 #22
0
static int motion_cb(Ihandle *ih,int x,int y,char* status)
{
  (void)status;

  if (move)
  {
    double dif_x, dif_y;
    double dx, dy, dz;
    double x1, y1, z1;
    double x2, y2, z2;
    double angle, norma;
    int height = IupGetInt2(ih, "RASTERSIZE");

    IupGLMakeCurrent(ih);

    dif_x = x - pos_x;
    dif_y = y - pos_y;

    pos_x = x;
    pos_y = y;

    angle = sqrt(dif_x*dif_x + dif_y*dif_y);

    unproject (pos_x, INVERT_Y(pos_y), &x1, &y1, &z1);
    unproject ((double)(dif_y+pos_x), (double)(dif_x+INVERT_Y(pos_y)), &x2, &y2, &z2);
    dx = x2-x1; dy = y2-y1; dz = z2-z1;
    norma = sqrt(dx*dx + dy*dy + dz*dz);
    dx /= norma; dy /= norma; dz /= norma;

    glTranslated(0.5, 0.5, 0.5);
    glRotated (angle, dx, dy, dz);
    glTranslated(-0.5, -0.5, -0.5);

    draw_cube();
  
    glFlush();
    IupGLSwapBuffers(ih); 
  }
  return IUP_DEFAULT;
}
예제 #23
0
void TransferFunctionsViewer::Redraw ()
{
  IupGLMakeCurrent (m_iup_canvas);
  
  vr::TransferFunction *tf = Viewer::Instance ()->m_transfer_function;
  if (tf)
  {
    for (int i = 0; i < 256; i++)
    {
      lqc::Vector4d c = tf->Get (i);
      for (int j = 0; j < 50; j++)
      {
        if (id < 2)
        {
          m_pixels[i * 4 + j * 258 * 4] = c.x;
          m_pixels[i * 4 + j * 258 * 4 + 1] = c.y;
          m_pixels[i * 4 + j * 258 * 4 + 2] = c.z;
          m_pixels[i * 4 + j * 258 * 4 + 3] = 1.0;
        }
        else
        {
          m_pixels[i * 4 + j * 258 * 4] = c.w;
          m_pixels[i * 4 + j * 258 * 4 + 1] = c.w;
          m_pixels[i * 4 + j * 258 * 4 + 2] = c.w;
          m_pixels[i * 4 + j * 258 * 4 + 3] = 1.0;
        }
      }
    }
  }
  
  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glDrawPixels (258, 50, GL_RGBA, GL_FLOAT, m_pixels);
  
  id = (id + 1) % 4;


  IupGLSwapBuffers (m_iup_canvas);
}
예제 #24
0
/* function called in the event of changes in the width or in the height of the canvas */
int resize_cb(Ihandle *self, int new_width, int new_height)
{
 IupGLMakeCurrent(self);  /* Make the canvas current in OpenGL */

 /* define the entire canvas as the viewport  */
 glViewport(0,0,new_width,new_height);

 /* transformation applied to each vertex */
 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();           /* identity, i. e. no transformation */

 /* projection transformation (orthographic in the xy plane) */
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 gluOrtho2D (0.0, (GLsizei)(new_width), 0.0, (GLsizei)(new_height));  /* window of interest [0,w]x[0,h] */

 /* update canvas size and repaint */
 gc.width=new_width;
 gc.height=new_height;
 repaint_cb(gc.canvas);

 return IUP_DEFAULT; /* return to the IUP main loop */
}
예제 #25
0
int redraw(Ihandle *self, float x, float y)
{
  int w, h;
  char *size = IupGetAttribute(self, "RASTERSIZE");
  sscanf(size, "%dx%d", &w, &h);

  IupGLMakeCurrent(self);
  
  glViewport(0, 0, w, h);
  glClearColor(1.0, 1.0, 1.0, 1.f);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glColor3f(1.0,0.0,0.0);
  glBegin(GL_QUADS); 
    glVertex2f( 0.9f,  0.9f); 
    glVertex2f( 0.9f, -0.9f); 
    glVertex2f(-0.9f, -0.9f); 
    glVertex2f(-0.9f,  0.9f); 
  glEnd();

  IupGLSwapBuffers(self); 

  return IUP_DEFAULT;
}
예제 #26
0
void GLCanvasCubeTest(void)
{
  Ihandle *dlg, *canvas, *box, *gtoggle, *gtoggle1, *gtoggle2,
    *hbox, *vbox, *glabel, *gsep1, *gsep2, *gbutton1, *gbutton2,
    *pbar1, *pbar2, *glink, *gval1, *gval2, *gframe1, *gframe2,
    *gexp1, *gexp2, *image_open, *image_close, *image_high,
    *gframe3, *vbox2, *gtoggle3, *gtoggle4, *gtoggle5, *gsbox,
    *text, *vbox3, *matrix, *image_val;

  IupGLCanvasOpen();
  IupGLControlsOpen();
  IupControlsOpen();

  glabel = IupGLLabel("Label");
//  IupSetAttribute(glabel, "FGCOLOR", "255 255 255");
  IupSetAttribute(glabel, "FONT", "Helvetica, 24");
  IupSetAttributeHandle(glabel, "IMAGE", load_image_Tecgraf());

  gbutton1 = IupGLButton("Button");
  IupSetAttribute(gbutton1, "PADDING", "5x5");
  //IupSetAttribute(gbutton1, "BGCOLOR", "245 0 245 92");
  IupSetCallback(gbutton1, "ACTION", button_action_cb);
  IupSetAttribute(gbutton1, "NAME", "button1");
  IupSetAttribute(gbutton1, "TIP", "Button Tip");
  //  IupSetAttribute(gbutton1, "RASTERSIZE", "x100");

  if (0)
  {
    Ihandle* pressed_back = IupLoadImage("../test/pressed_back.png");
    Ihandle* enabled_back = IupLoadImage("../test/enabled_back.png");
    Ihandle* highlighted_back = IupLoadImage("../test/highlighted_back.png");

    IupSetAttributeHandle(gbutton1, "BACKIMAGE", enabled_back);
    IupSetAttributeHandle(gbutton1, "BACKIMAGEPRESS", pressed_back);
    IupSetAttributeHandle(gbutton1, "BACKIMAGEHIGHLIGHT", highlighted_back);
    IupSetAttribute(gbutton1, "BORDERCOLOR", "0 0 0 0");
  }

  gbutton2 = IupGLButton(NULL);
  IupSetAttribute(gbutton2, "PADDING", "5x5");
  IupSetAttributeHandle(gbutton2, "IMAGE", load_image_FileSave());
  IupSetCallback(gbutton2, "ACTION", button_action_cb);
  IupSetAttribute(gbutton2, "NAME", "button2");

  gtoggle = IupGLToggle("Toggle");
  IupSetAttribute(gtoggle, "PADDING", "5x5");
  IupSetCallback(gtoggle, "ACTION", (Icallback)toggle_action_cb);
  IupSetAttribute(gtoggle, "NAME", "toggle");

  gtoggle1 = IupGLToggle(NULL);
  IupSetAttribute(gtoggle1, "PADDING", "5x5");
  IupSetAttributeHandle(gtoggle1, "IMAGE", load_image_Test());
  IupSetCallback(gtoggle1, "ACTION", (Icallback)toggle_action_cb);
  IupSetAttribute(gtoggle1, "NAME", "toggle1");

  gtoggle2 = IupGLToggle(NULL);
  IupSetAttribute(gtoggle2, "PADDING", "5x5");
  IupSetAttributeHandle(gtoggle2, "IMAGE", load_image_Test());
  IupSetCallback(gtoggle2, "ACTION", (Icallback)toggle_action_cb);
  IupSetAttribute(gtoggle2, "NAME", "toggle2");

  gsep1 = IupGLSeparator();

  glink = IupGLLink("http://www.tecgraf.puc-rio.br/iup", "IUP Toolkit");
  IupSetCallback(glink, "ACTION", (Icallback)link_action_cb);

  pbar1 = IupGLProgressBar();
  IupSetAttribute(pbar1, "VALUE", "0.3");
  IupSetAttribute(pbar1, "SHOWTEXT", "Yes");

  //image_val = IupLoadImage("../test/slider_handler.png");

  gval1 = IupGLVal();
  IupSetAttribute(gval1, "VALUE", "0.3");
  IupSetCallback(gval1, "VALUECHANGED_CB", val_action_cb);
  IupSetAttribute(gval1, "PROGRESSBAR", (char*)pbar1);
  IupSetAttribute(gval1, "NAME", "val1");
  IupSetAttribute(gval1, "TIP", "Val Tip");
  //IupSetAttributeHandle(gval1, "IMAGE", image_val);

  hbox = IupHbox(glabel, gsep1, gbutton1, gtoggle, glink, pbar1, gval1, NULL);
  IupSetAttribute(hbox, "ALIGNMENT", "ACENTER");
  IupSetAttribute(hbox, "MARGIN", "5x5");
  IupSetAttribute(hbox, "GAP", "5");

  pbar2 = IupGLProgressBar();
  IupSetAttribute(pbar2, "VALUE", "0.3");
  IupSetAttribute(pbar2, "ORIENTATION", "VERTICAL");

  gval2 = IupGLVal();
  IupSetAttribute(gval2, "VALUE", "0.3");
  IupSetAttribute(gval2, "ORIENTATION", "VERTICAL");
  IupSetCallback(gval2, "VALUECHANGED_CB", val_action_cb);
  IupSetAttribute(gval2, "PROGRESSBAR", (char*)pbar2);
  IupSetAttribute(gval2, "NAME", "val2");

  gsep2 = IupGLSeparator();
  IupSetAttribute(gsep2, "ORIENTATION", "HORIZONTAL");

  vbox = IupVbox(gbutton2, gsep2, 
    IupRadio(IupSetAttributes(IupVbox(gtoggle1, gtoggle2, NULL), "MARGIN=0x0")),
    pbar2,
    gval2,
    NULL);
  IupSetAttribute(vbox, "ALIGNMENT", "ACENTER");
  IupSetAttribute(vbox, "MARGIN", "5x5");
  IupSetAttribute(vbox, "GAP", "5");

  gtoggle5 = IupGLToggle("Toggle");
  IupSetAttribute(gtoggle5, "PADDING", "5x5");
  IupSetCallback(gtoggle5, "ACTION", (Icallback)toggle_action_cb);
  IupSetAttribute(gtoggle5, "NAME", "toggle5");
  IupSetAttribute(gtoggle5, "CHECKMARK", "Yes");
//  IupSetAttribute(gtoggle5, "RIGHTBUTTON", "Yes");

  gtoggle3 = IupGLToggle("Radio Toggle");
  IupSetAttribute(gtoggle3, "PADDING", "5x5");
  IupSetCallback(gtoggle3, "ACTION", (Icallback)toggle_action_cb);
  IupSetAttribute(gtoggle3, "NAME", "toggle3");
  IupSetAttribute(gtoggle3, "CHECKMARK", "Yes");

  gtoggle4 = IupGLToggle("Radio Toggle");
  IupSetAttribute(gtoggle4, "PADDING", "5x5");
  IupSetAttributeHandle(gtoggle4, "IMAGE", load_image_Test());
  IupSetCallback(gtoggle4, "ACTION", (Icallback)toggle_action_cb);
  IupSetAttribute(gtoggle4, "NAME", "toggle4");
  IupSetAttribute(gtoggle4, "CHECKMARK", "Yes");
//  IupSetAttribute(gtoggle4, "RIGHTBUTTON", "Yes");

  vbox2 = IupVbox(
    IupRadio(IupSetAttributes(IupVbox(gtoggle3, gtoggle4, NULL), "MARGIN=0x0")),
    gtoggle5,
    NULL);

  gsbox = IupSetAttributes(IupGLScrollBox(vbox2), "RASTERSIZE=90x90");
  gsbox = IupGLSizeBox(gsbox);

  gframe1 = IupSetAttributes(IupGLFrame(hbox), "TITLE=Frame1");
  gframe2 = IupSetAttributes(IupGLFrame(vbox), "BACKCOLOR=\"250 250 160 128\", FRAMECOLOR=\"250 250 160\"");
  gframe3 = IupSetAttributes(IupGLFrame(gsbox), "TITLE=Frame3, TITLEBOX=Yes");
//  IupSetAttributeHandle(gframe3, "TITLEBACKIMAGE", load_image_Tecgraf());

  gexp1 = IupSetAttributes(IupGLExpander(gframe1), "TITLE=Expander");
  gexp2 = IupSetAttributes(IupGLExpander(gframe2), "BARPOSITION=LEFT");

  text = IupText(NULL);
  IupSetAttribute(text, "VALUE", "Text");

  matrix = IupMatrix(NULL);
  IupSetAttribute(matrix, "NUMLIN", "3");
  IupSetAttribute(matrix, "NUMCOL", "2");
  IupSetAttribute(matrix, "NUMLIN_VISIBLE", "3");
  IupSetAttribute(matrix, "NUMCOL_VISIBLE", "2");
  IupSetAttribute(matrix, "0:0", "Inflation");
  IupSetAttribute(matrix, "1:0", "Medicine");
  IupSetAttribute(matrix, "2:0", "Food");
  IupSetAttribute(matrix, "3:0", "Energy");
  IupSetAttribute(matrix, "0:1", "January 2000");
  IupSetAttribute(matrix, "0:2", "February 2000");
  IupSetAttribute(matrix, "1:1", "5.6");
  IupSetAttribute(matrix, "2:1", "2.2");
  IupSetAttribute(matrix, "3:1", "4.1");
  IupSetAttribute(matrix, "1:2", "10");
  IupSetAttribute(matrix, "2:2", "1");
  IupSetAttribute(matrix, "3:2", "0.5");
//  IupSetAttribute(matrix, "EXPAND", "No");
  IupSetAttribute(matrix, "SCROLLBAR", "No");

  vbox3 = IupVbox(
    text,
    matrix,
    NULL);

  vbox3 = IupSetAttributes(IupGLFrame(vbox3), "TITLE=Frame4");

  canvas = IupGLCanvasBox(
    IupSetAttributes(gexp1, "HORIZONTALALIGN=ACENTER, VERTICALALIGN=ATOP, MOVEABLE=Yes, MOVETOTOP=Yes"),
    IupSetAttributes(gexp2, "HORIZONTALALIGN=ALEFT, VERTICALALIGN=ACENTER"),
    IupSetAttributes(gframe3, "MOVEABLE=Yes, POSITION=\"550,200\", MOVETOTOP=Yes"),
    IupSetAttributes(vbox3, "MOVEABLE=Yes, POSITION=\"250,350\""),
    NULL);
    
  IupSetAttribute(canvas, "DEPTH_SIZE", "16");

  image_open = IupImage(16, 16, img_open);
  image_close = IupImage(16, 16, img_close);
  image_high = IupImage(16, 16, img_close);
  IupSetAttribute(image_open, "0", "BGCOLOR");
  IupSetAttribute(image_open, "1", "192 192 192");
  IupSetAttribute(image_close, "0", "BGCOLOR");
  IupSetAttribute(image_close, "1", "192 192 192");
  IupSetAttribute(image_high, "1", "192 192 192");

  //  IupSetAttribute(gexp1, "BARSIZE", "50");
  //  IupSetAttributeHandle(gexp1, "IMAGE", image_close);
  //  IupSetAttributeHandle(gexp1, "IMOPEN", image_open);
  //  IupSetAttribute(gexp1, "IMAGE", "img1");
  IupSetCallback(gexp1, "ACTION", (Icallback)expand_cb);
  IupSetAttribute(gexp1, "EXTRABUTTONS", "3");
  IupSetCallback(gexp1, "EXTRABUTTON_CB", (Icallback)extrabutton_cb);
  IupSetAttributeHandle(gexp1, "IMAGEEXTRA1", image_close);
  IupSetAttributeHandle(gexp1, "IMAGEEXTRAPRESS1", image_open);
  IupSetAttributeHandle(gexp1, "IMAGEEXTRAHIGHLIGHT1", image_high);
  IupSetAttributeHandle(gexp1, "IMAGEEXTRA2", image_close);
  IupSetAttributeHandle(gexp1, "IMAGEEXTRAPRESS2", image_open);
  IupSetAttributeHandle(gexp1, "IMAGEEXTRAHIGHLIGHT2", image_high);
  IupSetAttributeHandle(gexp1, "IMAGEEXTRA3", image_close);
  IupSetAttributeHandle(gexp1, "IMAGEEXTRAPRESS3", image_open);
  IupSetAttributeHandle(gexp1, "IMAGEEXTRAHIGHLIGHT3", image_high);
  //IupSetAttribute(gexp1, "REDRAWALL", "No");

  IupSetCallback(canvas, "ACTION", action);
  IupSetCallback(canvas, "BUTTON_CB", (Icallback)button_cb);
  IupSetCallback(canvas, "MOTION_CB", (Icallback)motion_cb);
  IupSetAttribute(canvas, "BUFFER", "DOUBLE");
  IupSetAttribute(canvas, "MARGIN", "10x10");

  box = IupVbox(canvas, NULL);
  IupSetAttribute(box, "MARGIN", "25x25");

  dlg = IupDialog(box);
  IupSetAttribute(dlg, "TITLE", "IupGLCanvas Test");
  IupSetAttribute(dlg, "RASTERSIZE", "800x600");

  IupMap(dlg);

  IupGLMakeCurrent(canvas);
  printf("Vendor: %s\n", glGetString(GL_VENDOR));
  printf("Renderer: %s\n", glGetString(GL_RENDERER));
  printf("Version: %s\n", glGetString(GL_VERSION));

  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
  IupSetAttribute(dlg, "RASTERSIZE", NULL);
}
예제 #27
0
파일: iupglview.c 프로젝트: LuaDist/im
int app_resize_cb(Ihandle* self, int width, int height)
{
  IupGLMakeCurrent(self);
  appGLInit(width, height);
  return IUP_DEFAULT;
} 
예제 #28
0
static int wGLCanvasDefaultResize_CB(Ihandle *ih, int width, int height)
{
  IupGLMakeCurrent(ih);
  glViewport(0,0,width,height);
  return IUP_DEFAULT;
}
예제 #29
0
파일: iupglw.c 프로젝트: svn2github/iup-iup
static int defresize (Ihandle *cv, int width, int height)
{
  IupGLMakeCurrent(cv);
  glViewport(0,0,width,height);
  return IUP_DEFAULT;
}