2 /* uglalldemos.c - WindML/Mesa example program */
4 /* Copyright (C) 2001 by Wind River Systems, Inc */
7 * Mesa 3-D graphics library
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 * DEALINGS IN THE SOFTWARE.
33 02a,29aug01,sra WindML mode added
34 01a,17jul01,sra written
39 Show all the UGL/Mesa demos
46 #include <ugl/uglinput.h>
47 #include <ugl/uglevent.h>
48 #include <ugl/uglfont.h>
60 { UGL_MAKE_RGB(0, 0, 0), 0},
61 { UGL_MAKE_RGB(255, 0, 0), 0},
64 void windMLPoint (UGL_BOOL windMLMode
);
65 void windMLLine (UGL_BOOL windMLMode
);
66 void windMLFlip (UGL_BOOL windMLMode
);
67 void windMLCube (UGL_BOOL windMLMode
);
68 void windMLBounce (UGL_BOOL windMLMode
);
69 void windMLGears (UGL_BOOL windMLMode
);
70 void windMLIcoTorus (UGL_BOOL windMLMode
);
71 void windMLOlympic (UGL_BOOL windMLMode
);
72 void windMLTexCube (UGL_BOOL windMLMode
);
73 void windMLTexCyl (UGL_BOOL windMLMode
);
74 void windMLTeapot (UGL_BOOL windMLMode
);
75 void windMLStencil (UGL_BOOL windMLMode
);
76 void windMLDrawPix (UGL_BOOL windMLMode
);
77 void windMLAccum (UGL_BOOL windMLMode
);
78 void windMLAllDemos (void);
80 void uglalldemos (void)
82 taskSpawn("tAllDemos", 210, VX_FP_TASK
, 200000,
83 (FUNCPTR
)windMLAllDemos
, 0,1,2,3,4,5,6,7,8,9);
86 void windMLAllDemos(void)
88 UGL_BOOL windMLFlag
= UGL_FALSE
;
91 UGL_EVENT_SERVICE_ID eventServiceId
;
93 UGL_INPUT_EVENT
* pInputEvent
;
94 UGL_INPUT_DEVICE_ID keyboardDevId
;
99 UGL_FONT_DRIVER_ID fontDrvId
;
100 UGL_ORD textOrigin
= UGL_FONT_TEXT_UPPER_LEFT
;
101 int displayHeight
, displayWidth
;
102 int textWidth
, textHeight
;
103 static UGL_CHAR
* message
=
104 "Do you want to use WindML exclusively ? (y/n) ";
108 uglDriverFind (UGL_DISPLAY_TYPE
, 0, (UGL_UINT32
*)&devId
);
109 uglDriverFind (UGL_KEYBOARD_TYPE
, 0, (UGL_UINT32
*)&keyboardDevId
);
110 uglDriverFind (UGL_EVENT_SERVICE_TYPE
, 0, (UGL_UINT32
*)&eventServiceId
);
111 qId
= uglEventQCreate (eventServiceId
, 100);
113 gc
= uglGcCreate(devId
);
115 uglDriverFind (UGL_FONT_ENGINE_TYPE
, 0, (UGL_UINT32
*)&fontDrvId
);
116 uglFontDriverInfo(fontDrvId
, UGL_FONT_TEXT_ORIGIN
, &textOrigin
);
118 uglFontFindString(fontDrvId
, "familyName=Helvetica; pixelSize = 18",
121 if ((fontId
= uglFontCreate(fontDrvId
, &fontDef
)) == UGL_NULL
)
123 printf("Font not found. Exiting.\n");
127 uglInfo(devId
, UGL_FB_INFO_REQ
, &fbInfo
);
128 displayWidth
= fbInfo
.width
;
129 displayHeight
= fbInfo
.height
;
131 uglColorAlloc (devId
, &colorTable
[BLACK
].rgbColor
, UGL_NULL
,
132 &colorTable
[BLACK
].uglColor
, 1);
133 uglColorAlloc(devId
, &colorTable
[RED
].rgbColor
, UGL_NULL
,
134 &colorTable
[RED
].uglColor
, 1);
136 uglBackgroundColorSet(gc
, colorTable
[BLACK
].uglColor
);
137 uglForegroundColorSet(gc
, colorTable
[RED
].uglColor
);
138 uglFontSet(gc
, fontId
);
139 uglTextSizeGet(fontId
, &textWidth
, &textHeight
, -1, message
);
140 uglTextDraw(gc
, (displayWidth
- textWidth
) / 2,
141 (displayHeight
- textHeight
) / 2 - textHeight
, -1, message
);
144 if (uglEventGet (qId
, &event
, sizeof (event
), UGL_WAIT_FOREVER
)
145 != UGL_STATUS_Q_EMPTY
)
147 pInputEvent
= (UGL_INPUT_EVENT
*)&event
;
149 if (pInputEvent
->header
.type
== UGL_EVENT_TYPE_KEYBOARD
&&
150 pInputEvent
->modifiers
& UGL_KEYBOARD_KEYDOWN
)
152 switch(pInputEvent
->type
.keyboard
.key
)
156 windMLFlag
= UGL_TRUE
;
159 windMLFlag
= UGL_FALSE
;
164 uglFontDestroy (fontId
);
166 uglEventQDestroy (eventServiceId
, qId
);
169 windMLPoint(windMLFlag
);
171 windMLLine(windMLFlag
);
173 windMLFlip(windMLFlag
);
175 windMLCube(windMLFlag
);
177 windMLBounce(windMLFlag
);
179 windMLGears(windMLFlag
);
181 windMLIcoTorus(windMLFlag
);
183 windMLOlympic(windMLFlag
);
185 windMLTexCube(windMLFlag
);
187 windMLTexCyl(windMLFlag
);
189 windMLTeapot(windMLFlag
);
191 windMLStencil(windMLFlag
);
193 windMLDrawPix(windMLFlag
);
195 windMLAccum(windMLFlag
);