diff options
Diffstat (limited to 'test/simple')
-rw-r--r-- | test/simple/config.mak | 13 | ||||
-rw-r--r-- | test/simple/iupmain.c | 51 | ||||
-rw-r--r-- | test/simple/simple.c | 23 | ||||
-rw-r--r-- | test/simple/simple.h | 1 | ||||
-rw-r--r-- | test/simple/simple.led | 1 | ||||
-rw-r--r-- | test/simple/simple_led.c | 1 |
6 files changed, 89 insertions, 1 deletions
diff --git a/test/simple/config.mak b/test/simple/config.mak index 5b84629..6baa00a 100644 --- a/test/simple/config.mak +++ b/test/simple/config.mak @@ -39,11 +39,19 @@ USE_STATIC = Yes #USE_IM = Yes +USE_OPENGL = Yes +ifdef USE_OPENGL + DEFINES += USE_OPENGL +endif + ifneq ($(findstring Win, $(TEC_SYSNAME)), ) LIBS = cdpdf pdflib ifndef GDK_CAIRO LIBS += cdcontextplus gdiplus endif + ifdef USE_OPENGL + LIBS += cdgl ftgl + endif else ifdef DBG_DIR CDLIB = $(CD)/lib/$(TEC_UNAME)d @@ -55,6 +63,9 @@ else ifndef GDK_CAIRO SLIB += $(CDLIB)/libcdcontextplus.a LIBS = Xrender Xft - else + endif + ifdef USE_OPENGL + SLIB += $(CDLIB)/libcdgl.a $(CDLIB)/libftgl.a + #LIBS = ftgl endif endif diff --git a/test/simple/iupmain.c b/test/simple/iupmain.c index daf058a..f417925 100644 --- a/test/simple/iupmain.c +++ b/test/simple/iupmain.c @@ -1,9 +1,19 @@ #include <stdlib.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 +21,14 @@ int cmdExit(void) void simple_loadled (void); +/* USE_OPENGL - add to linker: +iupgl +opengl32 +glu32 +cdgl +ftgl +*/ + int main(int argc, char** argv) { IupOpen(&argc, &argv); @@ -18,8 +36,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 +88,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); @@ -76,6 +111,22 @@ 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(); + } +#endif + IupMainLoop(); SimpleKillCanvas(); diff --git a/test/simple/simple.c b/test/simple/simple.c index 6f7a4cb..a15a242 100644 --- a/test/simple/simple.c +++ b/test/simple/simple.c @@ -29,6 +29,7 @@ #include "cddebug.h" #include "wd.h" #include "cdgdiplus.h" +#include "cdgl.h" #include "simple.h" @@ -473,6 +474,28 @@ int SimpleDrawImageRGB(void) return 0; } +#ifdef USE_OPENGL +int SimpleDrawGL(void) +{ + char StrData[100]; + int w, h; + double w_mm, h_mm; + cdActivate(curCanvas); + cdGetCanvasSize(&w, &h, &w_mm, &h_mm); + + sprintf(StrData, "%dx%d %g", w, h, ((double)w/w_mm)); + + if (dbCanvas) cdKillCanvas(dbCanvas); + + dbCanvas = cdCreateCanvas(CD_GL, StrData); + + curCanvas = dbCanvas; + SimpleDrawRepaint(); + + return 0; +} +#endif + int SimpleDrawSimulate(void) { cdActivate(curCanvas); diff --git a/test/simple/simple.h b/test/simple/simple.h index 933b714..b32fc59 100644 --- a/test/simple/simple.h +++ b/test/simple/simple.h @@ -35,6 +35,7 @@ int SimpleDrawClipboardEMF(void); int SimpleDrawImage(void); int SimpleDrawImageRGB(void); int SimpleDrawSimulate(void); +int SimpleDrawGL(void); int SimpleNotXor(void); int SimpleXor(void); diff --git a/test/simple/simple.led b/test/simple/simple.led index 63f3dc2..b1e67df 100644 --- a/test/simple/simple.led +++ b/test/simple/simple.led @@ -71,6 +71,7 @@ mnSurface = MENU ITEM("Window", SimpleDrawWindow), ITEM("Server Image", SimpleDrawImage), ITEM("Image RGB", SimpleDrawImageRGB) + ITEM("OpenGL", SimpleDrawGL) ) mnPrimitives = MENU diff --git a/test/simple/simple_led.c b/test/simple/simple_led.c index 626b849..9c5d786 100644 --- a/test/simple/simple_led.c +++ b/test/simple/simple_led.c @@ -92,6 +92,7 @@ void simple_loadled (void) IupItem( "Window", "SimpleDrawWindow" ), IupItem( "Server Image", "SimpleDrawImage" ), IupItem( "Image RGB", "SimpleDrawImageRGB" ), + IupItem( "OpenGL", "SimpleDrawGL" ), NULL), NULL ); named[8] = decl( "mnPrimitives", IupMenu( IupItem( "All", "SimpleDrawAll" ), |