From 91cb54015437f9087f6679288295c8604a21228b Mon Sep 17 00:00:00 2001 From: scuri Date: Mon, 21 Jun 2010 23:52:19 +0000 Subject: *** empty log message *** --- test/simple/iupmain.c | 39 ++++++++++++++++++++++++++------------- test/simple/simple.c | 10 ++++++++++ test/simple/simple.h | 1 + 3 files changed, 37 insertions(+), 13 deletions(-) (limited to 'test') 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 +#include + #include #include #include @@ -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); -- cgit v1.2.3