diff options
Diffstat (limited to 'progs/windml')
-rw-r--r-- | progs/windml/uglaccum.c | 30 | ||||
-rw-r--r-- | progs/windml/uglalldemos.c | 156 | ||||
-rw-r--r-- | progs/windml/uglbounce.c | 14 | ||||
-rw-r--r-- | progs/windml/uglcube.c | 12 | ||||
-rw-r--r-- | progs/windml/ugldrawpix.c | 21 | ||||
-rw-r--r-- | progs/windml/uglflip.c | 15 | ||||
-rw-r--r-- | progs/windml/uglgears.c | 14 | ||||
-rw-r--r-- | progs/windml/uglicotorus.c | 14 | ||||
-rw-r--r-- | progs/windml/uglline.c | 12 | ||||
-rw-r--r-- | progs/windml/uglolympic.c | 11 | ||||
-rw-r--r-- | progs/windml/uglpoint.c | 39 | ||||
-rw-r--r-- | progs/windml/uglstencil.c | 27 | ||||
-rw-r--r-- | progs/windml/uglteapot.c | 13 | ||||
-rw-r--r-- | progs/windml/ugltexcube.c | 129 | ||||
-rw-r--r-- | progs/windml/ugltexcyl.c | 18 |
15 files changed, 314 insertions, 211 deletions
diff --git a/progs/windml/uglaccum.c b/progs/windml/uglaccum.c index 4748618d62..fd7cb3125c 100644 --- a/progs/windml/uglaccum.c +++ b/progs/windml/uglaccum.c @@ -185,15 +185,15 @@ UGL_LOCAL int getEvent(void) return(retVal); } -void windMLAccum (void); +void windMLAccum (UGL_BOOL windMLMode); void uglaccum (void) { taskSpawn("tAccum", 210, VX_FP_TASK, 100000, - (FUNCPTR)windMLAccum, 0,1,2,3,4,5,6,7,8,9); + (FUNCPTR)windMLAccum,UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLAccum(void) +void windMLAccum (UGL_BOOL windMLMode) { UGL_INPUT_DEVICE_ID keyboardDevId; GLsizei width, height; @@ -205,12 +205,21 @@ void windMLAccum(void) uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); qId = uglEventQCreate (eventServiceId, 100); + + if (windMLMode) + umc = uglMesaCreateNewContextExt(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, + 16, + 0, + 8,8,8,0, + NULL); + else + umc = uglMesaCreateNewContextExt(UGL_MESA_DOUBLE, + 16, + 0, + 8,8,8,0, + NULL); - umc = uglMesaCreateNewContextExt(GL_TRUE, - 16, - 0, - 8,8,8,0, - NULL); if (umc == NULL) { uglDeinitialize(); @@ -228,8 +237,9 @@ void windMLAccum(void) initGL(width, height); - while (!getEvent()) - drawGL(); + drawGL(); + + while (!getEvent()); uglEventQDestroy (eventServiceId, qId); diff --git a/progs/windml/uglalldemos.c b/progs/windml/uglalldemos.c index ebb2f27378..283e487074 100644 --- a/progs/windml/uglalldemos.c +++ b/progs/windml/uglalldemos.c @@ -30,6 +30,7 @@ /* modification history -------------------- +02a,29aug01,sra WindML mode added 01a,17jul01,sra written */ @@ -38,23 +39,42 @@ DESCRIPTION Show all the UGL/Mesa demos */ +#include <stdio.h> #include <vxWorks.h> #include <taskLib.h> +#include <ugl/ugl.h> +#include <ugl/uglinput.h> +#include <ugl/uglevent.h> +#include <ugl/uglfont.h> -void windMLPoint (void); -void windMLLine (void); -void windMLFlip (void); -void windMLCube (void); -void windMLBounce (void); -void windMLGears (void); -void windMLIcoTorus (void); -void windMLOlympic (void); -void windMLTexCube (void); -void windMLTexCyl (void); -void windMLTeapot (void); -void windMLStencil (void); -void windMLDrawPix (void); -void windMLAccum (void); +#define BLACK 0 +#define RED 1 + +struct _colorStruct + { + UGL_RGB rgbColor; + UGL_COLOR uglColor; + } +colorTable[] = + { + { UGL_MAKE_RGB(0, 0, 0), 0}, + { UGL_MAKE_RGB(255, 0, 0), 0}, + }; + +void windMLPoint (UGL_BOOL windMLMode); +void windMLLine (UGL_BOOL windMLMode); +void windMLFlip (UGL_BOOL windMLMode); +void windMLCube (UGL_BOOL windMLMode); +void windMLBounce (UGL_BOOL windMLMode); +void windMLGears (UGL_BOOL windMLMode); +void windMLIcoTorus (UGL_BOOL windMLMode); +void windMLOlympic (UGL_BOOL windMLMode); +void windMLTexCube (UGL_BOOL windMLMode); +void windMLTexCyl (UGL_BOOL windMLMode); +void windMLTeapot (UGL_BOOL windMLMode); +void windMLStencil (UGL_BOOL windMLMode); +void windMLDrawPix (UGL_BOOL windMLMode); +void windMLAccum (UGL_BOOL windMLMode); void windMLAllDemos (void); void uglalldemos (void) @@ -65,34 +85,114 @@ void uglalldemos (void) void windMLAllDemos(void) { + UGL_BOOL windMLFlag = UGL_FALSE; + UGL_FB_INFO fbInfo; + UGL_EVENT event; + UGL_EVENT_SERVICE_ID eventServiceId; + UGL_EVENT_Q_ID qId; + UGL_INPUT_EVENT * pInputEvent; + UGL_INPUT_DEVICE_ID keyboardDevId; + UGL_DEVICE_ID devId; + UGL_GC_ID gc; + UGL_FONT_ID fontId; + UGL_FONT_DEF fontDef; + UGL_FONT_DRIVER_ID fontDrvId; + UGL_ORD textOrigin = UGL_FONT_TEXT_UPPER_LEFT; + int displayHeight, displayWidth; + int textWidth, textHeight; + static UGL_CHAR * message = + "Do you want to use WindML exclusively ? (y/n) "; + + uglInitialize(); + + uglDriverFind (UGL_DISPLAY_TYPE, 0, (UGL_UINT32 *)&devId); + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + qId = uglEventQCreate (eventServiceId, 100); + + gc = uglGcCreate(devId); + + uglDriverFind (UGL_FONT_ENGINE_TYPE, 0, (UGL_UINT32 *)&fontDrvId); + uglFontDriverInfo(fontDrvId, UGL_FONT_TEXT_ORIGIN, &textOrigin); + + uglFontFindString(fontDrvId, "familyName=Helvetica; pixelSize = 18", + &fontDef); - windMLPoint(); + if ((fontId = uglFontCreate(fontDrvId, &fontDef)) == UGL_NULL) + { + printf("Font not found. Exiting.\n"); + return; + } - windMLLine(); + uglInfo(devId, UGL_FB_INFO_REQ, &fbInfo); + displayWidth = fbInfo.width; + displayHeight = fbInfo.height; + + uglColorAlloc (devId, &colorTable[BLACK].rgbColor, UGL_NULL, + &colorTable[BLACK].uglColor, 1); + uglColorAlloc(devId, &colorTable[RED].rgbColor, UGL_NULL, + &colorTable[RED].uglColor, 1); + + uglBackgroundColorSet(gc, colorTable[BLACK].uglColor); + uglForegroundColorSet(gc, colorTable[RED].uglColor); + uglFontSet(gc, fontId); + uglTextSizeGet(fontId, &textWidth, &textHeight, -1, message); + uglTextDraw(gc, (displayWidth - textWidth) / 2, + (displayHeight - textHeight) / 2 - textHeight, -1, message); +/* flushQ(); + */ + if (uglEventGet (qId, &event, sizeof (event), UGL_WAIT_FOREVER) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + { + switch(pInputEvent->type.keyboard.key) + { + case 'Y': + case 'y': + windMLFlag = UGL_TRUE; + break; + default: + windMLFlag = UGL_FALSE; + } + } + } + + uglFontDestroy (fontId); + uglGcDestroy (gc); + uglEventQDestroy (eventServiceId, qId); + uglDeinitialize(); + + windMLPoint(windMLFlag); + + windMLLine(windMLFlag); - windMLFlip(); + windMLFlip(windMLFlag); - windMLCube(); + windMLCube(windMLFlag); - windMLBounce(); + windMLBounce(windMLFlag); - windMLGears(); + windMLGears(windMLFlag); - windMLIcoTorus(); + windMLIcoTorus(windMLFlag); - windMLOlympic(); + windMLOlympic(windMLFlag); - windMLTexCube(); + windMLTexCube(windMLFlag); - windMLTexCyl(); + windMLTexCyl(windMLFlag); - windMLTeapot(); + windMLTeapot(windMLFlag); - windMLStencil(); + windMLStencil(windMLFlag); - windMLDrawPix(); + windMLDrawPix(windMLFlag); - windMLAccum(); + windMLAccum(windMLFlag); return; } diff --git a/progs/windml/uglbounce.c b/progs/windml/uglbounce.c index bcabf44963..287015a413 100644 --- a/progs/windml/uglbounce.c +++ b/progs/windml/uglbounce.c @@ -200,15 +200,15 @@ UGL_LOCAL int getEvent(void) return(retVal); } -void windMLBounce (void); +void windMLBounce (UGL_BOOL windMLMode); void uglbounce (void) { taskSpawn("tBounce", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLBounce, - 0,1,2,3,4,5,6,7,8,9); + UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLBounce(void) +void windMLBounce(UGL_BOOL windMLMode) { GLsizei width, height; UGL_INPUT_DEVICE_ID keyboardDevId; @@ -231,8 +231,12 @@ void windMLBounce(void) uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); qId = uglEventQCreate (eventServiceId, 100); - - umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); if (umc == NULL) { diff --git a/progs/windml/uglcube.c b/progs/windml/uglcube.c index 9080ba1fb9..e701d8db46 100644 --- a/progs/windml/uglcube.c +++ b/progs/windml/uglcube.c @@ -196,15 +196,15 @@ UGL_LOCAL int getEvent(void) return(retVal); } -void windMLCube (void); +void windMLCube (UGL_BOOL windMLMode); void uglcube (void) { taskSpawn("tCube", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLCube, - 0,1,2,3,4,5,6,7,8,9); + UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLCube (void) +void windMLCube (UGL_BOOL windMLMode) { GLsizei width, height; UGL_INPUT_DEVICE_ID keyboardDevId; @@ -226,7 +226,11 @@ void windMLCube (void) eventServiceId = UGL_NULL; } - umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); /* Fullscreen */ diff --git a/progs/windml/ugldrawpix.c b/progs/windml/ugldrawpix.c index 678f423d2e..b33be2c6ae 100644 --- a/progs/windml/ugldrawpix.c +++ b/progs/windml/ugldrawpix.c @@ -8,6 +8,9 @@ /* * $Log: ugldrawpix.c,v $ + * Revision 1.2 2001/09/10 19:21:13 brianp + * WindML updates (Stephane Raimbault) + * * Revision 1.1 2001/08/20 16:07:11 brianp * WindML driver (Stephane Raimbault) * @@ -79,7 +82,7 @@ #include "../util/readtex.h" -#define IMAGE_FILE "Mesa/images/girl.rgb" +#define IMAGE_FILE "Mesa/images/wrs_logo.rgb" UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; UGL_LOCAL UGL_EVENT_Q_ID qId; @@ -373,15 +376,15 @@ UGL_LOCAL void cleanUp (void) uglDeinitialize (); } -void windMLDrawPix (void); +void windMLDrawPix (UGL_BOOL windMLMode); void ugldrawpix (void) { taskSpawn ("tDrawPix", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLDrawPix, - 0,1,2,3,4,5,6,7,8,9); + UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLDrawPix (void) +void windMLDrawPix (UGL_BOOL windMLMode) { UGL_INPUT_DEVICE_ID keyboardDevId; GLuint ciMode; @@ -402,7 +405,12 @@ void windMLDrawPix (void) qId = uglEventQCreate (eventServiceId, 100); /* Double buffering */ - umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL); + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + if (umc == NULL) { uglDeinitialize (); @@ -424,6 +432,7 @@ void windMLDrawPix (void) loopEvent(); cleanUp(); - + free(Image); + return; } diff --git a/progs/windml/uglflip.c b/progs/windml/uglflip.c index ffc6ece2db..0ca068f417 100644 --- a/progs/windml/uglflip.c +++ b/progs/windml/uglflip.c @@ -171,15 +171,15 @@ UGL_LOCAL void loopEvent(void) } } -void windMLFlip (void); +void windMLFlip (UGL_BOOL windMLMode); void uglflip (void) { - taskSpawn("tFlip", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLFlip, - 0,1,2,3,4,5,6,7,8,9); + taskSpawn ("tFlip", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLFlip, + UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLFlip(void) +void windMLFlip (UGL_BOOL windMLMode) { UGL_INPUT_DEVICE_ID keyboardDevId; @@ -192,13 +192,18 @@ void windMLFlip(void) qId = uglEventQCreate (eventServiceId, 100); - umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE_SW, NULL); + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_SINGLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE_SOFTWARE, NULL); if (umc == NULL) { uglDeinitialize(); return; } + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, UGL_MESA_FULLSCREEN_HEIGHT); diff --git a/progs/windml/uglgears.c b/progs/windml/uglgears.c index fe750a57d8..468fe89980 100644 --- a/progs/windml/uglgears.c +++ b/progs/windml/uglgears.c @@ -219,6 +219,8 @@ UGL_LOCAL void drawGL (void) glPopMatrix (); + glFlush(); + uglMesaSwapBuffers (); #ifdef COUNT_FRAMES @@ -360,15 +362,15 @@ UGL_LOCAL void loopEvent(void) } } -void windMLGears (void); +void windMLGears (UGL_BOOL windMLMode); void uglgears (void) { taskSpawn ("tGears", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLGears, - 0,1,2,3,4,5,6,7,8,9); + UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLGears (void) +void windMLGears (UGL_BOOL windMLMode) { GLsizei width, height; UGL_INPUT_DEVICE_ID keyboardDevId; @@ -390,8 +392,12 @@ void windMLGears (void) qId = uglEventQCreate (eventServiceId, 100); /* Double buffering */ + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); - umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL); if (umc == NULL) { uglDeinitialize (); diff --git a/progs/windml/uglicotorus.c b/progs/windml/uglicotorus.c index 46226f1e82..c09b6d1b52 100644 --- a/progs/windml/uglicotorus.c +++ b/progs/windml/uglicotorus.c @@ -246,15 +246,15 @@ UGL_LOCAL void loopEvent(void) } } -void windMLIcoTorus (void); +void windMLIcoTorus (UGL_BOOL windMLMode); void uglicotorus (void) { taskSpawn ("tIcoTorus", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLIcoTorus, - 0,1,2,3,4,5,6,7,8,9); + UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLIcoTorus (void) +void windMLIcoTorus (UGL_BOOL windMLMode) { GLsizei width, height; UGL_INPUT_DEVICE_ID keyboardDevId; @@ -279,8 +279,12 @@ void windMLIcoTorus (void) } /* Double buffering */ - umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL); - + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + if (umc == NULL) { uglDeinitialize (); diff --git a/progs/windml/uglline.c b/progs/windml/uglline.c index fd100fff4b..e58f071ea4 100644 --- a/progs/windml/uglline.c +++ b/progs/windml/uglline.c @@ -213,16 +213,16 @@ UGL_LOCAL void loopEvent(void) } } -void windMLLine (void); +void windMLLine (UGL_BOOL windMLMode); void uglline (void) { taskSpawn("tLine", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLLine, - 0,1,2,3,4,5,6,7,8,9); + UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLLine(void) +void windMLLine(UGL_BOOL windMLMode) { UGL_INPUT_DEVICE_ID keyboardDevId; @@ -239,7 +239,11 @@ void windMLLine(void) /* Double buffer */ - umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); if (umc == NULL) { diff --git a/progs/windml/uglolympic.c b/progs/windml/uglolympic.c index de7c278b1a..282558dacb 100644 --- a/progs/windml/uglolympic.c +++ b/progs/windml/uglolympic.c @@ -419,7 +419,7 @@ UGL_LOCAL void loopEvent(void) } } -void windMLOlympic (void); +void windMLOlympic (UGL_BOOL windMLMode); void uglolympic (void) { @@ -427,7 +427,7 @@ void uglolympic (void) 0,1,2,3,4,5,6,7,8,9); } -void windMLOlympic(void) +void windMLOlympic(UGL_BOOL windMLMode) { UGL_INPUT_DEVICE_ID keyboardDevId; @@ -444,8 +444,13 @@ void windMLOlympic(void) { eventServiceId = UGL_NULL; } + + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); - umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); if (umc == NULL) { uglDeinitialize(); diff --git a/progs/windml/uglpoint.c b/progs/windml/uglpoint.c index e184eaa755..49c432c3a4 100644 --- a/progs/windml/uglpoint.c +++ b/progs/windml/uglpoint.c @@ -127,12 +127,12 @@ UGL_LOCAL void drawGL (void) glRotatef(angleT, 1.0, -1.0, 0.0); angleT = angleT++ % 360; glBegin(GL_TRIANGLES); - (rgb) ? glColor3f(1.0, 0.0, 0.0): glIndexi(RED); - glVertex2f(0.75, 0.25); - (rgb) ? glColor3f(0.0, 1.0, 0.0): glIndexi(GREEN); - glVertex2f(0.75, 0.75); - (rgb) ? glColor3f(0.0, 0.0, 1.0): glIndexi(BLUE); - glVertex2f(0.25, 0.75); + (rgb) ? glColor3f(1.0, 0.0, 0.0): glIndexi(RED); + glVertex2f(0.75, 0.25); + (rgb) ? glColor3f(0.0, 1.0, 0.0): glIndexi(GREEN); + glVertex2f(0.75, 0.75); + (rgb) ? glColor3f(0.0, 0.0, 1.0): glIndexi(BLUE); + glVertex2f(0.25, 0.75); glEnd(); glPopMatrix(); @@ -140,8 +140,7 @@ UGL_LOCAL void drawGL (void) glFlush(); - if(DOUBLE_BUFFER) - uglMesaSwapBuffers(); + uglMesaSwapBuffers(); } /************************************************************************ @@ -175,15 +174,15 @@ UGL_LOCAL int getEvent(void) return(retVal); } -void windMLPoint (void); +void windMLPoint (UGL_BOOL windMLMode); void uglpoint (void) { - taskSpawn("tPoint", 210, VX_FP_TASK, 100000, - (FUNCPTR)windMLPoint, 0,1,2,3,4,5,6,7,8,9); + taskSpawn ("tPoint", 210, VX_FP_TASK, 100000, + (FUNCPTR)windMLPoint, UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLPoint(void) +void windMLPoint (UGL_BOOL windMLMode) { GLubyte pPixels[4]; GLsizei width, height; @@ -206,9 +205,21 @@ void windMLPoint(void) } if (DOUBLE_BUFFER) - umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + { + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + } else - umc = uglMesaCreateNewContext(UGL_MESA_SINGLE, NULL); + { + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_SINGLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_SINGLE, NULL); + } if (umc == NULL) { diff --git a/progs/windml/uglstencil.c b/progs/windml/uglstencil.c index 94e9f50259..07e8fc626f 100644 --- a/progs/windml/uglstencil.c +++ b/progs/windml/uglstencil.c @@ -177,15 +177,15 @@ UGL_LOCAL int getEvent(void) return(retVal); } -void windMLStencil (void); +void windMLStencil (UGL_BOOL windMLMode); void uglstencil (void) { taskSpawn("tStencil", 210, VX_FP_TASK, 100000, - (FUNCPTR)windMLStencil, 0,1,2,3,4,5,6,7,8,9); + (FUNCPTR)windMLStencil,UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLStencil(void) +void windMLStencil(UGL_BOOL windMLMode) { UGL_INPUT_DEVICE_ID keyboardDevId; GLsizei width, height; @@ -197,12 +197,21 @@ void windMLStencil(void) uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); qId = uglEventQCreate (eventServiceId, 100); - - umc = uglMesaCreateNewContextExt(GL_FALSE, - 16, - 8, - 0,0,0,0, - NULL); + + if (windMLMode) + umc = uglMesaCreateNewContextExt(UGL_MESA_SINGLE + | UGL_MESA_WINDML_EXCLUSIVE, + 16, + 8, + 0,0,0,0, + NULL); + else + umc = uglMesaCreateNewContextExt(UGL_MESA_SINGLE, + 16, + 8, + 0,0,0,0, + NULL); + if (umc == NULL) { uglDeinitialize(); diff --git a/progs/windml/uglteapot.c b/progs/windml/uglteapot.c index 26c766d834..651fe0990e 100644 --- a/progs/windml/uglteapot.c +++ b/progs/windml/uglteapot.c @@ -222,15 +222,15 @@ UGL_LOCAL void loopEvent(void) } } -void windMLTeapot (void); +void windMLTeapot (UGL_BOOL windMLMode); void uglteapot (void) { taskSpawn ("tTeapot", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTeapot, - 0,1,2,3,4,5,6,7,8,9); + UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLTeapot (void) +void windMLTeapot (UGL_BOOL windMLMode) { UGL_INPUT_DEVICE_ID keyboardDevId; GLsizei displayWidth, displayHeight; @@ -252,7 +252,12 @@ void windMLTeapot (void) qId = uglEventQCreate (eventServiceId, 100); /* Double buffering */ - umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL); + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + if (umc == NULL) { uglDeinitialize (); diff --git a/progs/windml/ugltexcube.c b/progs/windml/ugltexcube.c index 1ce6666b65..62b0306e64 100644 --- a/progs/windml/ugltexcube.c +++ b/progs/windml/ugltexcube.c @@ -47,7 +47,9 @@ Draw a textured cube #include <GL/uglmesa.h> #include <GL/glu.h> -#define IMAGE_FILE "Mesa/windmldemos/wrs_logo.bmp" +#include "../util/readtex.h" + +#define IMAGE_FILE "Mesa/images/wrs_logo.rgb" UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; UGL_LOCAL UGL_EVENT_Q_ID qId; @@ -58,103 +60,13 @@ UGL_LOCAL GLuint texture[1]; UGL_LOCAL GLuint theTexCube; typedef struct { - unsigned long sizeX; - unsigned long sizeY; - char *data; - } TEX_IMAGE; + GLubyte *data; + int width, height; + GLenum format; + } TEX_IMAGE; UGL_LOCAL void cleanUp (void); -UGL_LOCAL GLboolean imageLoad(char *filename, TEX_IMAGE * texImage) - { - FILE * file = NULL; - unsigned long size; - unsigned long i; - unsigned short int planes; - unsigned short int bpp; - char temp; - - if ((file = fopen(filename, "rb")) == NULL) - { - printf("File Not Found : %s\n", filename); - return GL_FALSE; - } - - fseek(file, 18, SEEK_CUR); - - if ((i = fread(&texImage->sizeX, 4, 1, file)) != 1) - { - printf("Error reading width from %s.\n", filename); - return GL_FALSE; - } - - printf("Width of %s: %lu\n", filename, texImage->sizeX); - - if ((i = fread(&texImage->sizeY, 4, 1, file)) != 1) - { - printf("Error reading height from %s.\n", filename); - return GL_FALSE; - } - - printf("Height of %s: %lu\n", filename, texImage->sizeY); - size = texImage->sizeX * texImage->sizeY * 3; - - if ((fread(&planes, 2, 1, file)) != 1) - { - printf("Error reading planes from %s.\n", filename); - return GL_FALSE; - } - - if (planes != 1) - { - printf("Planes from %s is not 1: %u\n", filename, planes); - return GL_FALSE; - } - - if ((i = fread(&bpp, 2, 1, file)) != 1) - { - printf("Error reading bpp from %s.\n", filename); - return GL_FALSE; - } - - if (bpp != 24) - { - printf("Bpp from %s is not 24: %u\n", filename, bpp); - return GL_FALSE; - } - - fseek(file, 24, SEEK_CUR); - - texImage->data = (char *) malloc(size); - - if (texImage->data == NULL) - { - printf("Error allocating memory for color-corrected texImage data"); - return GL_FALSE; - } - - if ((i = fread(texImage->data, size, 1, file)) != 1) - { - printf("Error reading texImage data from %s.\n", filename); - free(texImage->data); - return GL_FALSE; - } - - /* bgr -> rgb */ - - for (i=0; i<size; i+=3) - { - temp = texImage->data[i]; - texImage->data[i] = texImage->data[i + 2]; - texImage->data[i + 2] = temp; - } - - fclose(file); - - return GL_TRUE; - } - - UGL_LOCAL void loadGLTexture() { TEX_IMAGE * texImage=NULL; @@ -167,10 +79,12 @@ UGL_LOCAL void loadGLTexture() cleanUp(); exit(1); } - - if (!imageLoad(IMAGE_FILE, texImage)) + + texImage->data = LoadRGBImage(IMAGE_FILE, &texImage->width, + &texImage->height, &texImage->format); + if (!texImage->data) { - printf("Error allocating space for image data"); + printf("Couldn't read %s\n", IMAGE_FILE); free(texImage); cleanUp(); exit(1); @@ -180,7 +94,7 @@ UGL_LOCAL void loadGLTexture() glGenTextures(1, &texture[0]); glBindTexture(GL_TEXTURE_2D, texture[0]); glTexImage2D(GL_TEXTURE_2D, 0, 3, - texImage->sizeX, texImage->sizeY, + texImage->width, texImage->height, 0, GL_RGB, GL_UNSIGNED_BYTE, texImage->data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -330,7 +244,8 @@ UGL_LOCAL void initGL(int width, int height) glEnd(); /* done with the polygon */ glEndList(); - + + glDisable(GL_DITHER); glMatrixMode(GL_PROJECTION); /* Reset the projection matrix */ glLoadIdentity(); @@ -403,16 +318,16 @@ UGL_LOCAL void cleanUp (void) uglDeinitialize(); } -void windMLTexCube (void); +void windMLTexCube (UGL_BOOL windMLMode); void ugltexcube (void) { taskSpawn("tTexCube", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTexCube, - 0,1,2,3,4,5,6,7,8,9); + UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLTexCube(void) +void windMLTexCube(UGL_BOOL windMLMode) { GLuint width, height; UGL_INPUT_DEVICE_ID keyboardDevId; @@ -430,8 +345,12 @@ void windMLTexCube(void) { eventServiceId = UGL_NULL; } - - umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); if (umc == NULL) { diff --git a/progs/windml/ugltexcyl.c b/progs/windml/ugltexcyl.c index d83c20b2f3..d2fe687b92 100644 --- a/progs/windml/ugltexcyl.c +++ b/progs/windml/ugltexcyl.c @@ -8,6 +8,9 @@ /* * $Log: ugltexcyl.c,v $ + * Revision 1.2 2001/09/10 19:21:13 brianp + * WindML updates (Stephane Raimbault) + * * Revision 1.1 2001/08/20 16:07:11 brianp * WindML driver (Stephane Raimbault) * @@ -309,7 +312,7 @@ UGL_LOCAL void initGL(void) glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef( 0.0, 0.0, -70.0 ); - + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); @@ -330,15 +333,15 @@ UGL_LOCAL void cleanUp (void) uglDeinitialize (); } -void windMLTexCyl (void); +void windMLTexCyl (UGL_BOOL windMLMode); void ugltexcyl (void) { taskSpawn ("tTexCyl", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTexCyl, - 0,1,2,3,4,5,6,7,8,9); + UGL_FALSE,1,2,3,4,5,6,7,8,9); } -void windMLTexCyl (void) +void windMLTexCyl (UGL_BOOL windMLMode) { UGL_INPUT_DEVICE_ID keyboardDevId; GLsizei displayWidth, displayHeight; @@ -365,7 +368,12 @@ void windMLTexCyl (void) qId = uglEventQCreate (eventServiceId, 100); /* Double buffering */ - umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL); + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + if (umc == NULL) { uglDeinitialize (); |