From d577d991b97ae2b5ee1af23641bcffc3f83af5b2 Mon Sep 17 00:00:00 2001 From: Pixel Date: Wed, 4 Nov 2009 11:56:41 -0800 Subject: Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux. --- iup/test/glcanvas.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 iup/test/glcanvas.c (limited to 'iup/test/glcanvas.c') diff --git a/iup/test/glcanvas.c b/iup/test/glcanvas.c new file mode 100755 index 0000000..6a34c29 --- /dev/null +++ b/iup/test/glcanvas.c @@ -0,0 +1,77 @@ +#ifdef USE_OPENGL +#ifdef WIN32 +#include +#endif +#include + +#include +#include + +#include "iup.h" +#include "iupgl.h" + + +static int action(Ihandle *ih) +{ + IupGLMakeCurrent(ih); + + 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(ih); + + return IUP_DEFAULT; +} + +void GLCanvasTest(void) +{ + Ihandle *dlg, *canvas, *box; + + IupGLCanvasOpen(); + + box = IupVbox(NULL); + IupSetAttribute(box, "MARGIN", "5x5"); + + canvas = IupGLCanvas(NULL); + IupSetCallback(canvas, "ACTION", action); + IupSetAttribute(canvas, "BUFFER", "DOUBLE"); + IupSetAttribute(canvas, "BORDER", "NO"); + IupSetAttribute(canvas, "RASTERSIZE", "300x200"); + IupAppend(box, canvas); + + dlg = IupDialog(box); + IupSetAttribute(dlg, "TITLE", "IupGLCanvas Test"); + + 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); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupGLCanvasOpen(); + + GLCanvasTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif +#endif -- cgit v1.2.3