summaryrefslogtreecommitdiff
path: root/cd/test/simple/iupmain.c
diff options
context:
space:
mode:
Diffstat (limited to 'cd/test/simple/iupmain.c')
-rwxr-xr-xcd/test/simple/iupmain.c81
1 files changed, 76 insertions, 5 deletions
diff --git a/cd/test/simple/iupmain.c b/cd/test/simple/iupmain.c
index daf058a..de01979 100755
--- a/cd/test/simple/iupmain.c
+++ b/cd/test/simple/iupmain.c
@@ -1,9 +1,21 @@
#include <stdlib.h>
+#include <stdio.h>
+
#include <iup.h>
+#include <iupgl.h>
#include <cd.h>
#include "simple.h"
+#ifdef USE_OPENGL
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+#endif
+
int cmdExit(void)
{
return IUP_CLOSE;
@@ -11,6 +23,43 @@ int cmdExit(void)
void simple_loadled (void);
+#ifdef USE_OPENGL
+/* USE_OPENGL - add to linker:
+cdgl
+iupgl
+ftgl
+glu32
+opengl32
+*/
+
+void SimpleUpdateSize(cdCanvas* cnv)
+{
+ Ihandle* canvas = IupGetHandle("SimpleCanvas");
+ int w = IupGetInt(canvas, "RASTERSIZE");
+ int h = IupGetInt2(canvas, "RASTERSIZE");
+ IupGLMakeCurrent(canvas);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluOrtho2D(0, w, 0, h);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ if (cnv)
+ {
+ char StrData[100];
+ sprintf(StrData, "%dx%d", w, h); /* no need to update resolution */
+ cdCanvasSetAttribute(cnv, "SIZE", StrData);
+ }
+}
+
+void SimpleFlush(void)
+{
+ IupGLSwapBuffers(IupGetHandle("SimpleCanvas"));
+}
+#endif
+
int main(int argc, char** argv)
{
IupOpen(&argc, &argv);
@@ -18,8 +67,21 @@ int main(int argc, char** argv)
#ifdef USE_CONTEXTPLUS
cdInitContextPlus();
#endif
+#ifdef USE_OPENGL
+ IupGLCanvasOpen();
+#endif
simple_loadled();
+#ifdef USE_OPENGL
+ {
+ Ihandle* dialog = IupGetHandle("SimpleDialog");
+ Ihandle* canvas = IupGetHandle("SimpleCanvas");
+ IupDestroy(canvas);
+ canvas = IupGLCanvas("SimpleRepaint");
+ IupSetHandle("SimpleCanvas", canvas);
+ IupAppend(dialog, canvas);
+ }
+#endif
IupSetAttribute(IupGetHandle("SimpleDialog"), "PLACEMENT", "MAXIMIZED");
IupShow(IupGetHandle("SimpleDialog"));
@@ -57,6 +119,10 @@ int main(int argc, char** argv)
IupSetFunction("SimpleDrawImageRGB", (Icallback) SimpleDrawImageRGB);
IupSetFunction("SimpleDrawSimulate", (Icallback) SimpleDrawSimulate);
+#ifdef USE_OPENGL
+ IupSetFunction("SimpleDrawGL", (Icallback) SimpleDrawGL);
+#endif
+
IupSetFunction("SimpleNotXor", (Icallback) SimpleNotXor);
IupSetFunction("SimpleXor", (Icallback) SimpleXor);
IupSetFunction("SimpleReplace", (Icallback) SimpleReplace);
@@ -67,15 +133,20 @@ int main(int argc, char** argv)
IupSetFunction("SimpleContextPlus", (Icallback) SimpleContextPlus);
IupSetFunction("SimpleTransform", (Icallback) SimpleTransform);
- IupSetFunction("SimpleDrawAll", (Icallback) SimpleDrawAll);
- IupSetFunction("SimpleDrawTextAlign", (Icallback) SimpleDrawTextAlign);
- IupSetFunction("SimpleDrawTextFonts", (Icallback) SimpleDrawTextFonts);
- IupSetFunction("SimpleDrawTest", (Icallback) SimpleDrawTest);
+ IupSetFunction("SimpleAll", (Icallback) SimpleAll);
+ IupSetFunction("SimpleTextAlign", (Icallback) SimpleTextAlign);
+ IupSetFunction("SimpleTextFonts", (Icallback) SimpleTextFonts);
+ IupSetFunction("SimpleTest", (Icallback) SimpleTest);
- IupSetFunction("SimpleRepaint", (Icallback) SimpleDrawRepaint);
+ IupSetFunction("SimpleRepaint", (Icallback) SimpleRepaint);
SimpleDrawWindow();
+#ifdef USE_OPENGL
+ SimpleUpdateSize(NULL);
+ IupUpdate(IupGetHandle("SimpleCanvas"));
+#endif
+
IupMainLoop();
SimpleKillCanvas();