2 /* uglline.c - WindML/Mesa example program */
5 * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
7 * Permission to use, copy, modify, distribute, and sell this software and
8 * its documentation for any purpose is hereby granted without fee, provided
9 * that (i) the above copyright notices and this permission notice appear in
10 * all copies of the software and related documentation, and (ii) the name of
11 * Silicon Graphics may not be used in any advertising or
12 * publicity relating to the software without the specific, prior written
13 * permission of Silicon Graphics.
15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
17 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
20 * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
21 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
22 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
23 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
24 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
31 01a,jun01,sra Ported to UGL/Mesa and modifications
43 #include <ugl/uglucode.h>
44 #include <ugl/uglevent.h>
45 #include <ugl/uglinput.h>
47 #include <GL/uglmesa.h>
57 UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId
;
58 UGL_LOCAL UGL_EVENT_Q_ID qId
;
59 UGL_LOCAL
volatile UGL_BOOL stopWex
;
60 UGL_LOCAL UGL_MESA_CONTEXT umc
;
62 UGL_LOCAL GLboolean mode1
, mode2
;
65 UGL_LOCAL GLfloat pntA
[3] = {
68 UGL_LOCAL GLfloat pntB
[3] = {
72 UGL_LOCAL GLint angleA
;
74 UGL_LOCAL
void initGL (void)
78 uglMesaSetColor(BLACK
, 0.0, 0.0, 0.0);
79 uglMesaSetColor(YELLOW
, 1.0, 1.0, 0.0);
80 uglMesaSetColor(GREEN
, 0.0, 1.0, 0.0);
81 uglMesaSetColor(BLUE
, 0.0, 0.0, 1.0);
83 for (i
= 0; i
< 16; i
++)
85 uglMesaSetColor(CI_OFFSET
+i
, i
/15.0, i
/15.0, 0.0);
88 glClearColor(0.0, 0.0, 0.0, 0.0);
91 glMatrixMode(GL_PROJECTION
);
93 glOrtho(-10, 10, -10, 10, -10.0, 10.0);
95 glMatrixMode(GL_MODELVIEW
);
97 glLineStipple(1, 0xF0E0);
98 glBlendFunc(GL_SRC_ALPHA
, GL_ONE
);
105 UGL_LOCAL
void drawGL (void)
110 glClear(GL_COLOR_BUFFER_BIT
);
115 glEnable(GL_LINE_STIPPLE
);
117 glDisable(GL_LINE_STIPPLE
);
122 glEnable(GL_LINE_SMOOTH
);
126 glDisable(GL_LINE_SMOOTH
);
132 glRotatef(angleA
, 1, 0, 1);
133 angleA
= angleA
++ % 360;
135 for (i
= 0; i
< 360; i
+= 5) {
136 glRotatef(5.0, 0, 0, 1);
138 glColor3f(1.0, 1.0, 0.0);
139 glBegin(GL_LINE_STRIP
);
146 glColor3f(0.0, 1.0, 0.0);
157 uglMesaSwapBuffers();
161 UGL_LOCAL
void echoUse(void)
163 printf("tLine keys:\n");
164 printf(" b Blending/antialiasing\n");
165 printf(" n Line stipple\n");
166 printf(" Up/Down Pixel size\n");
167 printf(" ESC Exit\n");
170 UGL_LOCAL
void readKey (UGL_WCHAR key
)
175 mode1
= (mode1
) ? GL_FALSE
: GL_TRUE
;
178 mode2
= (mode2
) ? GL_FALSE
: GL_TRUE
;
180 case UGL_UNI_DOWN_ARROW
:
184 case UGL_UNI_UP_ARROW
:
193 UGL_LOCAL
void loopEvent(void)
196 UGL_INPUT_EVENT
* pInputEvent
;
200 if (uglEventGet (qId
, &event
, sizeof (event
), UGL_NO_WAIT
)
201 != UGL_STATUS_Q_EMPTY
)
203 pInputEvent
= (UGL_INPUT_EVENT
*)&event
;
205 if (pInputEvent
->header
.type
== UGL_EVENT_TYPE_KEYBOARD
&&
206 pInputEvent
->modifiers
& UGL_KEYBOARD_KEYDOWN
)
207 readKey(pInputEvent
->type
.keyboard
.key
);
216 void windMLLine (UGL_BOOL windMLMode
);
220 taskSpawn("tLine", 210, VX_FP_TASK
, 100000, (FUNCPTR
)windMLLine
,
221 UGL_FALSE
,1,2,3,4,5,6,7,8,9);
225 void windMLLine(UGL_BOOL windMLMode
)
228 UGL_INPUT_DEVICE_ID keyboardDevId
;
234 uglDriverFind (UGL_KEYBOARD_TYPE
, 0, (UGL_UINT32
*)&keyboardDevId
);
236 uglDriverFind (UGL_EVENT_SERVICE_TYPE
, 0, (UGL_UINT32
*)&eventServiceId
);
238 qId
= uglEventQCreate (eventServiceId
, 100);
243 umc
= uglMesaCreateNewContext(UGL_MESA_DOUBLE
244 | UGL_MESA_WINDML_EXCLUSIVE
, NULL
);
246 umc
= uglMesaCreateNewContext(UGL_MESA_DOUBLE
, NULL
);
256 uglMesaMakeCurrentContext(umc
, 0, 0, UGL_MESA_FULLSCREEN_WIDTH
,
257 UGL_MESA_FULLSCREEN_HEIGHT
);
259 uglMesaGetIntegerv(UGL_MESA_RGB
, &rgb
);
268 uglEventQDestroy(eventServiceId
, qId
);
270 uglMesaDestroyContext();