summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/simple/iupmain.c39
-rw-r--r--test/simple/simple.c10
-rw-r--r--test/simple/simple.h1
3 files changed, 37 insertions, 13 deletions
diff --git a/test/simple/iupmain.c b/test/simple/iupmain.c
index f417925..df081e3 100644
--- a/test/simple/iupmain.c
+++ b/test/simple/iupmain.c
@@ -1,4 +1,6 @@
#include <stdlib.h>
+#include <stdio.h>
+
#include <iup.h>
#include <iupgl.h>
#include <cd.h>
@@ -28,6 +30,28 @@ glu32
cdgl
ftgl
*/
+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);
+ }
+}
+
int main(int argc, char** argv)
{
@@ -112,19 +136,8 @@ int main(int argc, char** argv)
SimpleDrawWindow();
#ifdef USE_OPENGL
- {
- 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();
- }
+ SimpleUpdateSize(NULL);
+ IupUpdate(IupGetHandle("SimpleCanvas"));
#endif
IupMainLoop();
diff --git a/test/simple/simple.c b/test/simple/simple.c
index a15a242..76676fd 100644
--- a/test/simple/simple.c
+++ b/test/simple/simple.c
@@ -51,6 +51,7 @@ int contextplus = 0;
int simple_draw = 0;
int use_transform = 0;
int simulate = 0;
+int use_opengl = 0;
enum {DRAW_ALL, DRAW_TEXTFONTS, DRAW_TEXTALIGN, DRAW_TEST};
@@ -490,7 +491,9 @@ int SimpleDrawGL(void)
dbCanvas = cdCreateCanvas(CD_GL, StrData);
curCanvas = dbCanvas;
+ use_opengl = 1;
SimpleDrawRepaint();
+ use_opengl = 0;
return 0;
}
@@ -542,6 +545,13 @@ int SimpleDrawAll(void)
{
cdCanvas* canvas = cdActiveCanvas();
int w, h;
+
+#ifdef USE_OPENGL
+ if (use_opengl)
+ SimpleUpdateSize(canvas);
+#endif
+
+
cdCanvasGetSize(canvas, &w, &h, NULL, NULL);
simple_draw = DRAW_ALL;
diff --git a/test/simple/simple.h b/test/simple/simple.h
index b32fc59..f400d2f 100644
--- a/test/simple/simple.h
+++ b/test/simple/simple.h
@@ -6,6 +6,7 @@
void SimpleCreateCanvas(char* data);
void SimpleKillCanvas(void);
+void SimpleUpdateSize(cdCanvas* cnv);
int SimplePlayClipboard(void);
int SimplePlayCGMBin(void);