From 976c26ca34f2ae8cc6f8b9f9b091efeba1311a94 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 20 Aug 2001 16:07:10 +0000 Subject: [PATCH] WindML driver (Stephane Raimbault) --- docs/README.WINDML | 144 +++++++++++ include/GL/uglglutshapes.h | 45 ++++ include/GL/uglmesa.h | 322 +++++++++++++++++++++++++ progs/windml/Makefile.ugl | 68 ++++++ progs/windml/readtex.c | 365 ++++++++++++++++++++++++++++ progs/windml/uglaccum.c | 240 +++++++++++++++++++ progs/windml/uglalldemos.c | 98 ++++++++ progs/windml/uglbounce.c | 268 +++++++++++++++++++++ progs/windml/uglcube.c | 253 ++++++++++++++++++++ progs/windml/ugldrawpix.c | 429 +++++++++++++++++++++++++++++++++ progs/windml/uglflip.c | 219 +++++++++++++++++ progs/windml/uglgears.c | 422 +++++++++++++++++++++++++++++++++ progs/windml/uglicotorus.c | 311 ++++++++++++++++++++++++ progs/windml/uglline.c | 270 +++++++++++++++++++++ progs/windml/uglolympic.c | 474 +++++++++++++++++++++++++++++++++++++ progs/windml/uglpoint.c | 266 +++++++++++++++++++++ progs/windml/uglstencil.c | 233 ++++++++++++++++++ progs/windml/uglteapot.c | 290 +++++++++++++++++++++++ progs/windml/ugltexcube.c | 460 +++++++++++++++++++++++++++++++++++ progs/windml/ugltexcyl.c | 399 +++++++++++++++++++++++++++++++ progs/windml/wrs_logo.bmp | Bin 0 -> 196662 bytes src/glu/mesa/Makefile.ugl | 96 ++++++++ src/mesa/main/Makefile.ugl | 367 ++++++++++++++++++++++++++++ 23 files changed, 6039 insertions(+) create mode 100644 docs/README.WINDML create mode 100644 include/GL/uglglutshapes.h create mode 100644 include/GL/uglmesa.h create mode 100644 progs/windml/Makefile.ugl create mode 100644 progs/windml/readtex.c create mode 100644 progs/windml/uglaccum.c create mode 100644 progs/windml/uglalldemos.c create mode 100644 progs/windml/uglbounce.c create mode 100644 progs/windml/uglcube.c create mode 100644 progs/windml/ugldrawpix.c create mode 100644 progs/windml/uglflip.c create mode 100644 progs/windml/uglgears.c create mode 100644 progs/windml/uglicotorus.c create mode 100644 progs/windml/uglline.c create mode 100644 progs/windml/uglolympic.c create mode 100644 progs/windml/uglpoint.c create mode 100644 progs/windml/uglstencil.c create mode 100644 progs/windml/uglteapot.c create mode 100644 progs/windml/ugltexcube.c create mode 100644 progs/windml/ugltexcyl.c create mode 100644 progs/windml/wrs_logo.bmp create mode 100644 src/glu/mesa/Makefile.ugl create mode 100644 src/mesa/main/Makefile.ugl diff --git a/docs/README.WINDML b/docs/README.WINDML new file mode 100644 index 00000000000..a227d42b4db --- /dev/null +++ b/docs/README.WINDML @@ -0,0 +1,144 @@ + + WindML Driver for Mesa 3.5 + + +Requirements +------------ + +Tornado 2 + WindML, Cumulative Patchs are recommended. + +I suppose you have a valid WindML installation. Double buffer hardware +gives better performance than double buffer software so if you can +compile your WindML driver with this option, just do it. I/O +redirection is adviced in target server. + +Tested on +--------- + +During the development, my main target was a CoolMonster: +- Video card: CT69000 +- CPU: PENTIUM 266MHz + +and my host a Windows NT + Tornado 2. + + +Installation +------------ + +1. Mesa sources must be in root directory (C:\) + +2. Add the following line to your torVars.bat: +set MESA_BASE=C:\Mesa + +OR copy the new torVars.bat in your bin path: +c:/Mesa/src/ugl/tornado/torVars.sample -> +/mnt/nt/Tornado/host/x86-win32/bin/torVars (for example) + +3. In a command prompt: +$ torVars +$ cd c:\Mesa +$ make -f Makefile.ugl CPU=PENTIUM + +Take a long while... + +5. Include all the files from ugldemos folder to build some downloadable + application modules + +4. Download UGL/Mesa object files on target + +For example via the WindShell: +ld < c:\Tornado\target\lib\objMesaGL.o +ld < c:\Tornado\target\lib\objMesaUGL.o +ld < c:\Tornado\target\lib\objMesaGLU.o +ld < c:\Tornado\target\lib\objGLUTshapes.o +ld < c:\Tornado\target\lib\objMesaOS.o + +6. Download the application modules. + +7. In WindShell, run: +-> uglalldemos + +During the show some messages will appear, it provides some useful +information on key management. + + +Coding +------ + +Sample Usage: + +In addition to the usual ugl calls to initialize UGL, (may be find an +input driver), you must do the following to use the UGL/Mesa interface: + +1. Call uglMesaCreateContext() to create a UGL/Mesa rendering context, + given the display format. + +2. Call uglMesaMakeCurrent() to bind the UGL/Mesa buffers to an + UGL/Mesa Context and to make the context the current one. + +3. Make gl* calls to render your graphics. + +4. Use uglMesaSwapBuffers() when double buffering to swap front/back buffers. + +5. Before the UGL is destroyed, call MesaDestroyContext(). + +6. Before exiting, call if required uglEventQDestroy and then uglDeinitialize(); + +Limitations +----------- + +I found the following limitations in my driver : + - Color Indexed management is only in 8 bits + - The front and the back buffer must have the structure (mode and + size). A structure umc->buffer is requisite if the front and back + buffers are different. + - It isn't possible to mix UGL/OpenGL application with a software + double buffer (to fix) + +Modifications +------------ + +New files in Mesa: +- Makefile.ugl +- rules.windmlmesa +- docs/README.UGL +- include/GL/uglmesa.h +- si-glu/Makefile.ugl +- src/Makefile.ugl +- src/ugl/torGLUTShapesInit.c +- src/ugl/torMesaUGLInit.c +- src/ugl/ugl_api.c +- src/ugl/ugl_dd.c +- src/ugl/ugl_glutshapes.c +- src/ugl/ugl_line.c +- src/ugl/ugl_span.c +- src/ugl/ugl_tri.c +- src/ugl/uglmesaP.h +- ugldemos/* + +Modified files in Tornado 2.0: +- c:\Tornado\host\x86-win32\bin\torVars.bat +rem Command line build environments +set WIND_HOST_TYPE=x86-win32 +set WIND_BASE=C:\Tornado +set MESA_BASE=C:\Mesa +set PATH=%WIND_BASE%\host\%WIND_HOST_TYPE%\bin;%PATH% +- c:\Tornado\target\config\comps\VxWorks\01uglmesa.cdf +- c:\Tornado\target\h\GL\* + +Todo +---- +- GCC 2.96, ASM compilation + +Thanks to: +---------- + +Precision Insight team for their great job around Mesa, XFree, and DRI. +Wind River Systems to take me as an intern. + + +Stephane Raimbault + + + +July 24, 2001 diff --git a/include/GL/uglglutshapes.h b/include/GL/uglglutshapes.h new file mode 100644 index 00000000000..28192de2d52 --- /dev/null +++ b/include/GL/uglglutshapes.h @@ -0,0 +1,45 @@ +/* uglglutshapes.h - Public header GLUT Shapes */ + +/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */ + +/* This program is freely distributable without licensing fees and is + provided without guarantee or warrantee expressed or implied. This + program is -not- in the public domain. */ + +#ifndef GLUTSHAPES_H +#define GLUTSHAPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void glutWireSphere (GLdouble radius, GLint slices, GLint stacks); +void glutSolidSphere (GLdouble radius, GLint slices, GLint stacks); +void glutWireCone (GLdouble base, GLdouble height, + GLint slices, GLint stacks); +void glutSolidCone (GLdouble base, GLdouble height, + GLint slices, GLint stacks); +void glutWireCube (GLdouble size); +void glutSolidCube (GLdouble size); +void glutWireTorus (GLdouble innerRadius, GLdouble outerRadius, + GLint sides, GLint rings); +void glutSolidTorus (GLdouble innerRadius, GLdouble outerRadius, + GLint sides, GLint rings); +void glutWireDodecahedron (void); +void glutSolidDodecahedron (void); +void glutWireOctahedron (void); +void glutSolidOctahedron (void); +void glutWireTetrahedron (void); +void glutSolidTetrahedron (void); +void glutWireIcosahedron (void); +void glutSolidIcosahedron (void); +void glutWireTeapot (GLdouble size); +void glutSolidTeapot (GLdouble size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/GL/uglmesa.h b/include/GL/uglmesa.h new file mode 100644 index 00000000000..44f8fc035ee --- /dev/null +++ b/include/GL/uglmesa.h @@ -0,0 +1,322 @@ +/* uglmesa.h - Public header UGL/Mesa */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Author: + * Stephane Raimbault + */ + +#ifndef UGLMESA_H +#define UGLMESA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define UGL_MESA_MAJOR_VERSION 1 +#define UGL_MESA_MINOR_VERSION 0 + +#include +#include + +/* + * Values for display mode of uglMesaCreateContext () + */ + +#define UGL_MESA_SINGLE 0x00 +#define UGL_MESA_DOUBLE 0x01 +#define UGL_MESA_DOUBLE_SW 0x02 +#define UGL_MESA_DOUBLE_HW 0x03 + +#define UGL_MESA_FULLSCREEN_WIDTH 0x0 +#define UGL_MESA_FULLSCREEN_HEIGHT 0x0 + +/* + * Pixel format + */ +#define UGL_MESA_ARGB8888 0x01 +#define UGL_MESA_RGB565 0x02 +#define UGL_MESA_RGB888 0x03 +#define UGL_MESA_ARGB4444 0x04 +#define UGL_MESA_CI 0x05 +#define UGL_MESA_DITHER_RGB 0x10 + +/* + * uglMesaPixelStore() parameters: + */ + +#define UGL_MESA_ROW_LENGTH 0x10 +#define UGL_MESA_Y_UP 0x11 + +/* + * Accepted by uglMesaGetIntegerv: + */ + +#define UGL_MESA_LEFT_X 0x18 +#define UGL_MESA_TOP_Y 0x19 +#define UGL_MESA_WIDTH 0x20 +#define UGL_MESA_HEIGHT 0x21 +#define UGL_MESA_DISPLAY_WIDTH 0x22 +#define UGL_MESA_DISPLAY_HEIGHT 0x23 +#define UGL_MESA_COLOR_FORMAT 0x24 +#define UGL_MESA_COLOR_MODEL 0x25 +#define UGL_MESA_PIXEL_FORMAT 0x26 +#define UGL_MESA_TYPE 0x27 +#define UGL_MESA_RGB 0x28 +#define UGL_MESA_COLOR_INDEXED 0x29 + +/* + * typedefs + */ + +typedef struct uglMesaContext * UGL_MESA_CONTEXT; + +/* + * Create an Mesa/UGL rendering context. The attributes needed are + * double buffer flag and a context sharelist. + * + * It's necessary to first call this function before use uglMakeCurrentContext. + * This function provides neither stencil nor accumulation buffer only + * a depth buffer to reduce memory footprint. + * + * Input: db_mode - UGL_MESA_SINGLE = single buffer mode + * UGL_MESA_DOUBLE = double buffer mode (HW fallback -> SW) + * UGL_MESA_DOUBLE_SW = double buffer software + * UGL_MESA_DOUBLE_HW = double buffer hardware + * share_list - specifies another UGL_MESA_CONTEXT with which to share + * display lists. NULL indicates no sharing. + * + * Return: a UGL_MESA_CONTEXT, or zero if error + */ + +UGL_MESA_CONTEXT uglMesaCreateNewContext (GLenum db_mode, + UGL_MESA_CONTEXT share_list); + +/* + * Create an UGL/Mesa rendering context and specify desired + * size of depth buffer, stencil buffer and accumulation buffer. + * If you specify zero for depth_bits, stencil_bits, + * accum_[red|gren|blue]_bits, you can save some memory. + * + * INPUT: db_mode - double buffer mode + * depth_bits - depth buffer size + * stencil_bits - stencil buffer size + * accum_red_bits - accumulation red buffer size + * accum_green_bits - accumulation green buffer size + * accum_blue_bits -accumulation blue buffer size + * accum_alpha_bits -accumulation alpha buffer size + * share_list - specifies another UGL_MESA_CONTEXT with which to share + * display lists. NULL indicates no sharing. + */ +UGL_MESA_CONTEXT uglMesaCreateNewContextExt (GLenum db_flag, + GLint depth_bits, + GLint stencil_bits, + GLint accum_red_bits, + GLint accum_green_bits, + GLint accum_blue_bits, + GLint accum_alpha_bits, + UGL_MESA_CONTEXT share_list); + +/* + * Bind an UGL_MESA_CONTEXT to an image buffer. The image buffer is + * just a block of memory which the client provides. Its size must be + * at least as large as width*height*sizeof(type). Its address should + * be a multiple of 4 if using RGBA mode. + * + * Image data is stored in the order of glDrawPixels: row-major order + * with the lower-left image pixel stored in the first array position + * (ie. bottom-to-top). + * + * Since the only type initially supported is GL_UNSIGNED_BYTE, if the + * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA + * value. If the context is in color indexed mode, each pixel will be + * stored as a 1-byte value. + * + * If the context's viewport hasn't been initialized yet, it will now be + * initialized to (0, 0, width, height). + * + * Input: umc - a rendering context + * left, top - coordinates in pixels of (left,top) pixel + * (0,0) in fullscreen mode. + * width, height - size of image buffer in pixels, at least 1 + * else fullscreen dimensions are used (UGL_MESA_DISPLAY_WIDTH + * and UGL_MESA_DISPLAY_HEIGHT). + * + * Return: GL_TRUE if success, GL_FALSE if error because of invalid umc, + * width<1, height<1, width>internal limit or height>internal limit. + */ + +GLboolean uglMesaMakeCurrentContext (UGL_MESA_CONTEXT umc, + GLsizei left, GLsizei top, + GLsizei width, GLsizei height); + +/* + * Move an OpenGL window by a delta value + * + * Input: dx, dy - delta values in pixels + * + * Return: GL_TRUE if success, GL_FALSE if error because of invalid + * coordinates. + */ +GLboolean uglMesaMoveWindow (GLsizei dx, GLsizei dy); + +/* + * Move an OpenGL window to an absolute position + * + * Input: left, top - new coordinates in pixels + * + * Return: GL_TRUE if success, GL_FALSE if error because of invalid + * coordinates. + */ +GLboolean uglMesaMoveToWindow (GLsizei left, GLsizei top); + +/* + * Resize an OpenGL window by a delta value + * + * Input: dw, dh - delta values in pixels + * + * Return: GL_TRUE if success, GL_FALSE if error because of invalid + * coordinates. + */ +GLboolean uglMesaResizeWindow (GLsizei dw, GLsizei dh); + +/* + * Resize an OpenGL window to an absolute size + * + * Input: width, height - new dimensions in pixels + * + * Return: GL_TRUE if success, GL_FALSE if error because of invalid + * coordinates. + */ +GLboolean uglMesaResizeToWindow (GLsizei width, GLsizei height); + +/* + * Destroy the current UGL/Mesa rendering context + * + */ +void uglMesaDestroyContext (void); + +/* + * Return the current UGL/Mesa context + * + * Return: a UGL/Mesa context, or NULL if error + * + */ +UGL_MESA_CONTEXT uglMesaGetCurrentContext (void); + +/* + * Swap front and back buffers in double buffering mode. This + * function is a no-op if there's no back buffer. In case of software + * double buffering a copy occurs from off-screen buffer to front + * buffer. Works faster with an hardware support. + */ + +void uglMesaSwapBuffers (void); + +/* + * Set pixel store/packing parameters for the current context. This + * is similar to glPixelStore. UGL uses Y coordinates increase + * downward. + * + * Input: pname - UGL_MESA_ROW_LENGTH + * zero, same as image width (default). + * value specify actual pixels per row in image buffer + * UGL_MESA_Y_UP: + * zero = Y coordinates increase downward (default) + * non-zero = Y coordinates increase upward + * value - value for the parameter pname + */ + +void uglMesaPixelStore (GLint pname, GLint value); + +/* + * Return an integer value like glGetIntegerv. + * + * Input: pname - UGL_MESA_LEFT_X return the x axis value + * of the most left pixel + * UGL_MESA_TOP_Y return the y axis value + * of the topper pixel + * UGL_MESA_WIDTH return current image width + * UGL_MESA_HEIGHT return current image height + * UGL_MESA_COLOR_FORMAT return image color format + * UGL_MESA_COLOR_MODEL return image color model + * UGL_MESA_PIXEL_FORMAT return pixel format + * UGL_MESA_ROW_LENGTH return row length in pixels + * UGL_MESA_RGB return true if RGB + * UGL_MESA_COLOR_INDEXED return true if color indexed + * value - pointer to integer in which to return result. + */ +void uglMesaGetIntegerv (GLint pname, GLint *value); + +/* + * Return the depth buffer associated with an UGL/Mesa context. + * + * Output: width, height - size of buffer in pixels + * bytesPerValue - bytes per depth value (2 or 4) + * buffer - pointer to depth buffer values + * Return: GL_TRUE or GL_FALSE to indicate success or failure. + * + */ +GLboolean uglMesaGetDepthBuffer (GLint *width, GLint *height, + GLint *bytesPerValue, void **buffer); + +/* + * Return the color buffer associated with an UGL/Mesa context. + * Input: c - the UGL/Mesa context + * Output: width, height - size of buffer in pixels + * format - buffer format (UGLMESA_FORMAT) + * buffer - pointer to color buffer values + * Return: GL_TRUE or GL_FALSE to indicate success or failure. + * + */ +GLboolean uglMesaGetColorBuffer (GLint *width, GLint *height, + GLint *format, void **buffer); + +/* + * Color allocation in indexed mode. + * This function does nothing in RGB mode. + * + * Input: index - Value for the current color index + * red - Red component (between 0 and 1) + * green - Green component (between 0 and 1) + * blue - Blue component (between 0 and 1) + * + * Return: GL_TRUE if success, or GL_FALSE if index<0 or * clutSize>$@ +endif +else +Makefile + @ $(RM) $@ + @ $(ECHO) "Creating depend.$(CPU)$(TOOL)" +ifneq ($(SOURCES),) + @ for FILE in $(filter-out $(NODEPENDOBJS), $(SOURCES)); \ + do \ + $(CC) -MM $(CFLAGS) $$FILE \ + | $(TCL) $(BIN_DIR)/depend.tcl $(TGT_DIR) >>$@; \ + done +endif +endif + +.PHONY = clean + +clean: + $(RM) $(DEMO_OBJECTS) + $(RM) depend.$(CPU)$(TOOL) diff --git a/progs/windml/readtex.c b/progs/windml/readtex.c new file mode 100644 index 00000000000..659c49de8de --- /dev/null +++ b/progs/windml/readtex.c @@ -0,0 +1,365 @@ +/* readtex.c */ + +/* + * Read an SGI .rgb image file and generate a mipmap texture set. + * Much of this code was borrowed from SGI's tk OpenGL toolkit. + */ + +#include +#include +#include +#include +#include +#include "../util/readtex.h" + + +#ifndef SEEK_SET +# define SEEK_SET 0 +#endif + + +/* +** RGB Image Structure +*/ + +typedef struct _TK_RGBImageRec { + GLint sizeX, sizeY; + GLint components; + unsigned char *data; +} TK_RGBImageRec; + + + +/******************************************************************************/ + +typedef struct _rawImageRec { + unsigned short imagic; + unsigned short type; + unsigned short dim; + unsigned short sizeX, sizeY, sizeZ; + unsigned long min, max; + unsigned long wasteBytes; + char name[80]; + unsigned long colorMap; + FILE *file; + unsigned char *tmp, *tmpR, *tmpG, *tmpB, *tmpA; + unsigned long rleEnd; + GLuint *rowStart; + GLint *rowSize; +} rawImageRec; + +/******************************************************************************/ + +static void ConvertShort(unsigned short *array, long length) +{ + unsigned long b1, b2; + unsigned char *ptr; + + ptr = (unsigned char *)array; + while (length--) { + b1 = *ptr++; + b2 = *ptr++; + *array++ = (unsigned short) ((b1 << 8) | (b2)); + } +} + +static void ConvertLong(GLuint *array, long length) +{ + unsigned long b1, b2, b3, b4; + unsigned char *ptr; + + ptr = (unsigned char *)array; + while (length--) { + b1 = *ptr++; + b2 = *ptr++; + b3 = *ptr++; + b4 = *ptr++; + *array++ = (b1 << 24) | (b2 << 16) | (b3 << 8) | (b4); + } +} + +static rawImageRec *RawImageOpen(const char *fileName) +{ + union { + int testWord; + char testByte[4]; + } endianTest; + rawImageRec *raw; + GLenum swapFlag; + int x; + + endianTest.testWord = 1; + if (endianTest.testByte[0] == 1) { + swapFlag = GL_TRUE; + } else { + swapFlag = GL_FALSE; + } + + raw = (rawImageRec *)malloc(sizeof(rawImageRec)); + if (raw == NULL) { + fprintf(stderr, "Out of memory!\n"); + return NULL; + } + if ((raw->file = fopen(fileName, "rb")) == NULL) { + perror(fileName); + return NULL; + } + + fread(raw, 1, 12, raw->file); + + if (swapFlag) { + ConvertShort(&raw->imagic, 6); + } + + raw->tmp = (unsigned char *)malloc(raw->sizeX*256); + raw->tmpR = (unsigned char *)malloc(raw->sizeX*256); + raw->tmpG = (unsigned char *)malloc(raw->sizeX*256); + raw->tmpB = (unsigned char *)malloc(raw->sizeX*256); + if (raw->sizeZ==4) { + raw->tmpA = (unsigned char *)malloc(raw->sizeX*256); + } + if (raw->tmp == NULL || raw->tmpR == NULL || raw->tmpG == NULL || + raw->tmpB == NULL) { + fprintf(stderr, "Out of memory!\n"); + return NULL; + } + + if ((raw->type & 0xFF00) == 0x0100) { + x = raw->sizeY * raw->sizeZ * sizeof(GLuint); + raw->rowStart = (GLuint *)malloc(x); + raw->rowSize = (GLint *)malloc(x); + if (raw->rowStart == NULL || raw->rowSize == NULL) { + fprintf(stderr, "Out of memory!\n"); + return NULL; + } + raw->rleEnd = 512 + (2 * x); + fseek(raw->file, 512, SEEK_SET); + fread(raw->rowStart, 1, x, raw->file); + fread(raw->rowSize, 1, x, raw->file); + if (swapFlag) { + ConvertLong(raw->rowStart, (long) (x/sizeof(GLuint))); + ConvertLong((GLuint *)raw->rowSize, (long) (x/sizeof(GLint))); + } + } + return raw; +} + +static void RawImageClose(rawImageRec *raw) +{ + + fclose(raw->file); + free(raw->tmp); + free(raw->tmpR); + free(raw->tmpG); + free(raw->tmpB); + if (raw->sizeZ>3) { + free(raw->tmpA); + } + free(raw); +} + +static void RawImageGetRow(rawImageRec *raw, unsigned char *buf, int y, int z) +{ + unsigned char *iPtr, *oPtr, pixel; + int count, done = 0; + + if ((raw->type & 0xFF00) == 0x0100) { + fseek(raw->file, (long) raw->rowStart[y+z*raw->sizeY], SEEK_SET); + fread(raw->tmp, 1, (unsigned int)raw->rowSize[y+z*raw->sizeY], + raw->file); + + iPtr = raw->tmp; + oPtr = buf; + while (!done) { + pixel = *iPtr++; + count = (int)(pixel & 0x7F); + if (!count) { + done = 1; + return; + } + if (pixel & 0x80) { + while (count--) { + *oPtr++ = *iPtr++; + } + } else { + pixel = *iPtr++; + while (count--) { + *oPtr++ = pixel; + } + } + } + } else { + fseek(raw->file, 512+(y*raw->sizeX)+(z*raw->sizeX*raw->sizeY), + SEEK_SET); + fread(buf, 1, raw->sizeX, raw->file); + } +} + + +static void RawImageGetData(rawImageRec *raw, TK_RGBImageRec *final) +{ + unsigned char *ptr; + int i, j; + + final->data = (unsigned char *)malloc((raw->sizeX+1)*(raw->sizeY+1)*4); + if (final->data == NULL) { + fprintf(stderr, "Out of memory!\n"); + } + + ptr = final->data; + for (i = 0; i < (int)(raw->sizeY); i++) { + RawImageGetRow(raw, raw->tmpR, i, 0); + RawImageGetRow(raw, raw->tmpG, i, 1); + RawImageGetRow(raw, raw->tmpB, i, 2); + if (raw->sizeZ>3) { + RawImageGetRow(raw, raw->tmpA, i, 3); + } + for (j = 0; j < (int)(raw->sizeX); j++) { + *ptr++ = *(raw->tmpR + j); + *ptr++ = *(raw->tmpG + j); + *ptr++ = *(raw->tmpB + j); + if (raw->sizeZ>3) { + *ptr++ = *(raw->tmpA + j); + } + } + } +} + + +static TK_RGBImageRec *tkRGBImageLoad(const char *fileName) +{ + rawImageRec *raw; + TK_RGBImageRec *final; + + raw = RawImageOpen(fileName); + if (!raw) { + fprintf(stderr, "File not found\n"); + return NULL; + } + final = (TK_RGBImageRec *)malloc(sizeof(TK_RGBImageRec)); + if (final == NULL) { + fprintf(stderr, "Out of memory!\n"); + return NULL; + } + final->sizeX = raw->sizeX; + final->sizeY = raw->sizeY; + final->components = raw->sizeZ; + RawImageGetData(raw, final); + RawImageClose(raw); + return final; +} + + +static void FreeImage( TK_RGBImageRec *image ) +{ + free(image->data); + free(image); +} + + +/* + * Load an SGI .rgb file and generate a set of 2-D mipmaps from it. + * Input: imageFile - name of .rgb to read + * intFormat - internal texture format to use, or number of components + * Return: GL_TRUE if success, GL_FALSE if error. + */ +GLboolean LoadRGBMipmaps( const char *imageFile, GLint intFormat ) +{ + GLint w, h; + return LoadRGBMipmaps2( imageFile, GL_TEXTURE_2D, intFormat, &w, &h ); +} + + + +GLboolean LoadRGBMipmaps2( const char *imageFile, GLenum target, + GLint intFormat, GLint *width, GLint *height ) +{ + GLint error; + GLenum format; + TK_RGBImageRec *image; + + image = tkRGBImageLoad( imageFile ); + if (!image) { + return GL_FALSE; + } + + if (image->components==3) { + format = GL_RGB; + } + else if (image->components==4) { + format = GL_RGBA; + } + else { + /* not implemented */ + fprintf(stderr, + "Error in LoadRGBMipmaps %d-component images not implemented\n", + image->components ); + return GL_FALSE; + } + + error = gluBuild2DMipmaps( target, + intFormat, + image->sizeX, image->sizeY, + format, + GL_UNSIGNED_BYTE, + image->data ); + + *width = image->sizeX; + *height = image->sizeY; + + FreeImage(image); + + return error ? GL_FALSE : GL_TRUE; +} + + + +/* + * Load an SGI .rgb file and return a pointer to the image data. + * Input: imageFile - name of .rgb to read + * Output: width - width of image + * height - height of image + * format - format of image (GL_RGB or GL_RGBA) + * Return: pointer to image data or NULL if error + */ +GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height, + GLenum *format ) +{ + TK_RGBImageRec *image; + GLint bytes; + GLubyte *buffer; + + image = tkRGBImageLoad( imageFile ); + if (!image) { + return NULL; + } + + if (image->components==3) { + *format = GL_RGB; + } + else if (image->components==4) { + *format = GL_RGBA; + } + else { + /* not implemented */ + fprintf(stderr, + "Error in LoadRGBImage %d-component images not implemented\n", + image->components ); + return NULL; + } + + *width = image->sizeX; + *height = image->sizeY; + + bytes = image->sizeX * image->sizeY * image->components; + buffer = (GLubyte *) malloc(bytes); + if (!buffer) + return NULL; + + memcpy( (void *) buffer, (void *) image->data, bytes ); + + FreeImage(image); + + return buffer; +} + diff --git a/progs/windml/uglaccum.c b/progs/windml/uglaccum.c new file mode 100644 index 00000000000..4748618d624 --- /dev/null +++ b/progs/windml/uglaccum.c @@ -0,0 +1,240 @@ + +/* Copyright (c) Mark J. Kilgard, 1994. */ + +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ + +/* Original name: accanti.c + * + * Conversion to UGL/Mesa by Stephane Raimbault + */ + +#include +#include + +#include +#include +#include + +#include +#include + +#include "../book/jitter.h" + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +/* Initialize lighting and other values. + */ +UGL_LOCAL void initGL(GLsizei w, GLsizei h) + { + GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 0.0, 0.0, 10.0, 1.0 }; + GLfloat lm_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 50.0); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lm_ambient); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glShadeModel (GL_FLAT); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearAccum(0.0, 0.0, 0.0, 0.0); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0); + else + glOrtho (-2.25*w/h, 2.25*w/h, -2.25, 2.25, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + } + +UGL_LOCAL void displayObjects(void) + { + GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 }; + GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 }; + GLfloat sphere_diffuse[] = { 0.7, 0.0, 0.7, 1.0 }; + GLfloat octa_diffuse[] = { 0.7, 0.4, 0.4, 1.0 }; + + glPushMatrix (); + glRotatef (30.0, 1.0, 0.0, 0.0); + + glPushMatrix (); + glTranslatef (-0.80, 0.35, 0.0); + glRotatef (100.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, torus_diffuse); + glutSolidTorus (0.275, 0.85, 16, 16); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (-0.75, -0.50, 0.0); + glRotatef (45.0, 0.0, 0.0, 1.0); + glRotatef (45.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, cube_diffuse); + glutSolidCube (1.5); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.75, 0.60, 0.0); + glRotatef (30.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, sphere_diffuse); + glutSolidSphere (1.0, 16, 16); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.70, -0.90, 0.25); + glMaterialfv(GL_FRONT, GL_DIFFUSE, octa_diffuse); + glutSolidOctahedron (); + glPopMatrix (); + + glPopMatrix (); + } + +#define ACSIZE 8 + +UGL_LOCAL void drawGL(void) + { + GLint viewport[4]; + int jitter; + + glGetIntegerv (GL_VIEWPORT, viewport); + + glClear(GL_ACCUM_BUFFER_BIT); + for (jitter = 0; jitter < ACSIZE; jitter++) + { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix (); +/* Note that 4.5 is the distance in world space between + * left and right and bottom and top. + * This formula converts fractional pixel movement to + * world coordinates. + */ + glTranslatef (j8[jitter].x*4.5/viewport[2], + j8[jitter].y*4.5/viewport[3], 0.0); + displayObjects (); + glPopMatrix (); + glAccum(GL_ACCUM, 1.0/ACSIZE); + } + glAccum (GL_RETURN, 1.0); + glFlush(); + + uglMesaSwapBuffers(); + } + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +void windMLAccum (void); + +void uglaccum (void) + { + taskSpawn("tAccum", 210, VX_FP_TASK, 100000, + (FUNCPTR)windMLAccum, 0,1,2,3,4,5,6,7,8,9); + } + +void windMLAccum(void) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + GLsizei width, height; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + umc = uglMesaCreateNewContextExt(GL_TRUE, + 16, + 0, + 8,8,8,0, + NULL); + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, + UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL(width, height); + + while (!getEvent()) + drawGL(); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/uglalldemos.c b/progs/windml/uglalldemos.c new file mode 100644 index 00000000000..ebb2f27378a --- /dev/null +++ b/progs/windml/uglalldemos.c @@ -0,0 +1,98 @@ + +/* uglalldemos.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* +modification history +-------------------- +01a,17jul01,sra written +*/ + +/* +DESCRIPTION +Show all the UGL/Mesa demos +*/ + +#include +#include + +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); +void windMLAllDemos (void); + +void uglalldemos (void) + { + taskSpawn("tAllDemos", 210, VX_FP_TASK, 200000, + (FUNCPTR)windMLAllDemos, 0,1,2,3,4,5,6,7,8,9); + } + +void windMLAllDemos(void) + { + + windMLPoint(); + + windMLLine(); + + windMLFlip(); + + windMLCube(); + + windMLBounce(); + + windMLGears(); + + windMLIcoTorus(); + + windMLOlympic(); + + windMLTexCube(); + + windMLTexCyl(); + + windMLTeapot(); + + windMLStencil(); + + windMLDrawPix(); + + windMLAccum(); + + return; + } diff --git a/progs/windml/uglbounce.c b/progs/windml/uglbounce.c new file mode 100644 index 00000000000..bcabf449632 --- /dev/null +++ b/progs/windml/uglbounce.c @@ -0,0 +1,268 @@ +/* + * Bouncing ball demo. + * + * This program is in the public domain + * + * Brian Paul + * + * Conversion to GLUT by Mark J. Kilgard + * + * Conversion to UGL/Mesa by Stephane Raimbault + */ + +#include +#include +#include + +#include +#include +#include + +#include + +#define COS(X) cos( (X) * 3.14159/180.0 ) +#define SIN(X) sin( (X) * 3.14159/180.0 ) + +#define RED 1 +#define WHITE 2 +#define CYAN 3 + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL GLuint Ball; +UGL_LOCAL GLfloat Zrot, Zstep; +UGL_LOCAL GLfloat Xpos, Ypos; +UGL_LOCAL GLfloat Xvel, Yvel; +UGL_LOCAL GLfloat Xmin, Xmax; +UGL_LOCAL GLfloat Ymin; +/* UGL_LOCAL GLfloat Ymax = 4.0; */ +UGL_LOCAL GLfloat G; + +UGL_LOCAL GLuint make_ball(void) + { + GLuint list; + GLfloat a, b; + GLfloat da = 18.0, db = 18.0; + GLfloat radius = 1.0; + GLuint color; + GLfloat x, y, z; + + list = glGenLists(1); + + glNewList(list, GL_COMPILE); + + color = 0; + for (a = -90.0; a + da <= 90.0; a += da) + { + glBegin(GL_QUAD_STRIP); + for (b = 0.0; b <= 360.0; b += db) + { + if (color) + { + glIndexi(RED); + glColor3f(1, 0, 0); + } + else + { + glIndexi(WHITE); + glColor3f(1, 1, 1); + } + + x = radius * COS(b) * COS(a); + y = radius * SIN(b) * COS(a); + z = radius * SIN(a); + glVertex3f(x, y, z); + + x = radius * COS(b) * COS(a + da); + y = radius * SIN(b) * COS(a + da); + z = radius * SIN(a + da); + glVertex3f(x, y, z); + + color = 1 - color; + } + glEnd(); + + } + + glEndList(); + + return list; + } + +UGL_LOCAL void initGL(GLsizei width, GLsizei height) + { + float aspect = (float) width / (float) height; + glViewport(0, 0, (GLint) width, (GLint) height); + + uglMesaSetColor(RED, 1.0, 0.0, 0.0); + uglMesaSetColor(WHITE, 1.0, 1.0, 1.0); + uglMesaSetColor(CYAN, 0.0, 1.0, 1.0); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-6.0 * aspect, 6.0 * aspect, -6.0, 6.0, -6.0, 6.0); + glMatrixMode(GL_MODELVIEW); + + } + +UGL_LOCAL void drawGL(void) + { + GLint i; + static float vel0 = -100.0; + + glClear(GL_COLOR_BUFFER_BIT); + + glIndexi(CYAN); + glColor3f(0, 1, 1); + glBegin(GL_LINES); + for (i = -5; i <= 5; i++) + { + glVertex2i(i, -5); + glVertex2i(i, 5); + } + for (i = -5; i <= 5; i++) + { + glVertex2i(-5, i); + glVertex2i(5, i); + } + for (i = -5; i <= 5; i++) + { + glVertex2i(i, -5); + glVertex2f(i * 1.15, -5.9); + } + glVertex2f(-5.3, -5.35); + glVertex2f(5.3, -5.35); + glVertex2f(-5.75, -5.9); + glVertex2f(5.75, -5.9); + glEnd(); + + glPushMatrix(); + glTranslatef(Xpos, Ypos, 0.0); + glScalef(2.0, 2.0, 2.0); + glRotatef(8.0, 0.0, 0.0, 1.0); + glRotatef(90.0, 1.0, 0.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + + glCallList(Ball); + + glPopMatrix(); + + glFlush(); + + uglMesaSwapBuffers(); + + Zrot += Zstep; + + Xpos += Xvel; + if (Xpos >= Xmax) + { + Xpos = Xmax; + Xvel = -Xvel; + Zstep = -Zstep; + } + if (Xpos <= Xmin) + { + Xpos = Xmin; + Xvel = -Xvel; + Zstep = -Zstep; + } + Ypos += Yvel; + Yvel += G; + if (Ypos < Ymin) + { + Ypos = Ymin; + if (vel0 == -100.0) + vel0 = fabs(Yvel); + Yvel = vel0; + } + } + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +void windMLBounce (void); + +void uglbounce (void) + { + taskSpawn("tBounce", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLBounce, + 0,1,2,3,4,5,6,7,8,9); + } + +void windMLBounce(void) + { + GLsizei width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + Zrot = 0.0; + Zstep = 6.0; + Xpos = 0.0; + Ypos = 1.0; + Xvel = 0.2; + Yvel = 0.0; + Xmin = -4.0; + Xmax = 4.0; + Ymin = -3.8; + G = -0.1; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + Ball = make_ball(); + glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); + glDisable(GL_DITHER); + glShadeModel(GL_FLAT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL(width, height); + + while(!getEvent()) + drawGL(); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize (); + + return; + } diff --git a/progs/windml/uglcube.c b/progs/windml/uglcube.c new file mode 100644 index 00000000000..9080ba1fb98 --- /dev/null +++ b/progs/windml/uglcube.c @@ -0,0 +1,253 @@ +/* uglcube.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* +DESCRIPTION +Draw a smooth cube. +*/ + +#include +#include + +#include +#include + +#include +#include + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; +UGL_LOCAL GLfloat rotx; +UGL_LOCAL GLfloat roty; +UGL_LOCAL GLuint theCube; + +UGL_LOCAL void cube() + { + + /* Front */ + glBegin(GL_QUADS); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + glEnd(); + + + /* Back */ + glBegin(GL_QUADS); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + glEnd(); + + + /* Right */ + glBegin(GL_QUADS); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + glEnd(); + + /* Left */ + glBegin(GL_QUADS); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + glEnd(); + + /* Top */ + glBegin(GL_QUADS); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + glEnd(); + + + /* Bottom */ + glBegin(GL_QUADS); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + glEnd(); + } + +UGL_LOCAL void initGL + ( + int Width, + int Height + ) + { + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glShadeModel(GL_SMOOTH); + + theCube = glGenLists(1); + glNewList(theCube, GL_COMPILE); + cube(); + glEndList(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0f, (GLfloat) Width / (GLfloat) Height, 0.1f, 100.0f); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, -6.0f); + } + + +/* The main drawing function. */ + +UGL_LOCAL void drawGL() + { + + /* Clear The Screen And The Depth Buffer */ + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + /* Rotate the cube */ + + glRotatef(rotx, 1.0f, 0.0f, 0.0f); + glRotatef(roty, 0.0f, 1.0f, 0.0f); + + glCallList(theCube); + + glFlush(); + + uglMesaSwapBuffers(); + } + + +/* The function called whenever a key is pressed. */ + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +void windMLCube (void); + +void uglcube (void) + { + taskSpawn("tCube", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLCube, + 0,1,2,3,4,5,6,7,8,9); + } + +void windMLCube (void) + { + GLsizei width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + rotx = 2.5f; + roty = 1.0f; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, + (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK) + { + qId = uglEventQCreate (eventServiceId, 100); + } + else + { + eventServiceId = UGL_NULL; + } + + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + /* Initialize our window. */ + + initGL(width, height); + + while (!getEvent()) + drawGL(); + + if (eventServiceId != UGL_NULL) + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/ugldrawpix.c b/progs/windml/ugldrawpix.c new file mode 100644 index 00000000000..678f423d2e3 --- /dev/null +++ b/progs/windml/ugldrawpix.c @@ -0,0 +1,429 @@ +/* + * glDrawPixels demo/test/benchmark + * + * Brian Paul September 25, 1997 This file is in the public domain. + * + * Conversion to UGL/Mesa by Stephane Raimbault july, 2001 + */ + +/* + * $Log: ugldrawpix.c,v $ + * Revision 1.1 2001/08/20 16:07:11 brianp + * WindML driver (Stephane Raimbault) + * + * Revision 1.5 2000/12/24 22:53:54 pesco + * * demos/Makefile.am (INCLUDES): Added -I$(top_srcdir)/util. + * * demos/Makefile.X11, demos/Makefile.BeOS-R4, demos/Makefile.cygnus: + * Essentially the same. + * Program files updated to include "readtex.c", not "../util/readtex.c". + * * demos/reflect.c: Likewise for "showbuffer.c". + * + * + * * Makefile.am (EXTRA_DIST): Added top-level regular files. + * + * * include/GL/Makefile.am (INC_X11): Added glxext.h. + * + * + * * src/GGI/include/ggi/mesa/Makefile.am (EXTRA_HEADERS): Include + * Mesa GGI headers in dist even if HAVE_GGI is not given. + * + * * configure.in: Look for GLUT and demo source dirs in $srcdir. + * + * * src/swrast/Makefile.am (libMesaSwrast_la_SOURCES): Set to *.[ch]. + * More source list updates in various Makefile.am's. + * + * * Makefile.am (dist-hook): Remove CVS directory from distribution. + * (DIST_SUBDIRS): List all possible subdirs here. + * (SUBDIRS): Only list subdirs selected for build again. + * The above two applied to all subdir Makefile.am's also. + * + * Revision 1.4 2000/09/08 21:45:21 brianp + * added dither key option + * + * Revision 1.3 1999/10/28 18:23:29 brianp + * minor changes to Usage() function + * + * Revision 1.2 1999/10/21 22:13:58 brianp + * added f key to toggle front/back drawing + * + * Revision 1.1.1.1 1999/08/19 00:55:40 jtg + * Imported sources + * + * Revision 3.3 1999/03/28 18:18:33 brianp + * minor clean-up + * + * Revision 3.2 1998/11/05 04:34:04 brianp + * moved image files to ../images/ directory + * + * Revision 3.1 1998/02/22 16:43:17 brianp + * added a few casts to silence compiler warnings + * + * Revision 3.0 1998/02/14 18:42:29 brianp + * initial rev + * + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "../util/readtex.h" + +#define IMAGE_FILE "Mesa/images/girl.rgb" + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL volatile UGL_BOOL stopWex; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL int ImgWidth, ImgHeight; +UGL_LOCAL GLenum ImgFormat; +UGL_LOCAL GLubyte *Image; + +UGL_LOCAL int Xpos, Ypos; +UGL_LOCAL int SkipPixels, SkipRows; +UGL_LOCAL int DrawWidth, DrawHeight; +UGL_LOCAL float Xzoom, Yzoom; +UGL_LOCAL GLboolean Scissor; +UGL_LOCAL GLboolean DrawFront; +UGL_LOCAL GLboolean Dither; + +UGL_LOCAL void cleanUp (void); + +UGL_LOCAL void reset(void) + { + Xpos = Ypos = 20; + DrawWidth = ImgWidth; + DrawHeight = ImgHeight; + SkipPixels = SkipRows = 0; + Scissor = GL_FALSE; + Xzoom = Yzoom = 1.0; + } + +UGL_LOCAL void initGL(GLboolean ciMode, GLsizei width, GLsizei height) + { + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + Image = LoadRGBImage(IMAGE_FILE, &ImgWidth, &ImgHeight, &ImgFormat); + if (!Image) + { + printf("Couldn't read %s\n", IMAGE_FILE); + cleanUp(); + exit(1); + } + + glScissor(width/4, height/4, width/2, height/2); + + if (ciMode) + { + /* Convert RGB image to grayscale */ + GLubyte *indexImage = malloc( ImgWidth * ImgHeight ); + GLint i; + for (i=0; i 0) + DrawWidth--; + break; + case 'W': + DrawWidth++; + break; + case 'h': + if (DrawHeight > 0) + DrawHeight--; + break; + case 'H': + DrawHeight++; + break; + case 'p': + if (SkipPixels > 0) + SkipPixels--; + break; + case 'P': + SkipPixels++; + break; + case 'r': + if (SkipRows > 0) + SkipRows--; + break; + case 'R': + SkipRows++; + break; + case 's': + Scissor = !Scissor; + break; + case 'x': + Xzoom -= 0.1; + break; + case 'X': + Xzoom += 0.1; + break; + case 'y': + Yzoom -= 0.1; + break; + case 'Y': + Yzoom += 0.1; + break; + case 'b': + benchmark(); + break; + case 'f': + DrawFront = !DrawFront; + if (DrawFront) + glDrawBuffer(GL_FRONT); + else + glDrawBuffer(GL_BACK); + printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK"); + break; + case UGL_UNI_UP_ARROW: + Ypos += 1; + break; + case UGL_UNI_DOWN_ARROW: + Ypos -= 1; + break; + case UGL_UNI_LEFT_ARROW: + Xpos -= 1; + break; + case UGL_UNI_RIGHT_ARROW: + Xpos += 1; + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +UGL_LOCAL void cleanUp (void) + { + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize (); + } + +void windMLDrawPix (void); + +void ugldrawpix (void) + { + taskSpawn ("tDrawPix", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLDrawPix, + 0,1,2,3,4,5,6,7,8,9); + } + +void windMLDrawPix (void) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + GLuint ciMode; + GLsizei width, height; + + Image = NULL; + Scissor = GL_FALSE; + DrawFront = GL_FALSE; + Dither = GL_TRUE; + + uglInitialize (); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, + (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + /* Double buffering */ + umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL); + if (umc == NULL) + { + uglDeinitialize (); + return; + } + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_COLOR_INDEXED, &ciMode); + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL(ciMode, width, height); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + cleanUp(); + + return; + } diff --git a/progs/windml/uglflip.c b/progs/windml/uglflip.c new file mode 100644 index 00000000000..ffc6ece2db1 --- /dev/null +++ b/progs/windml/uglflip.c @@ -0,0 +1,219 @@ + +/* uglflip.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Stephane Raimbault + */ + +/* +DESCRIPTION +Draw a triangle and flip the screen +*/ + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#define BLACK (0) +#define RED (1) +#define GREEN (2) +#define BLUE (3) +#define CI_OFFSET 4 + +UGL_LOCAL GLuint rgb; +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL volatile UGL_BOOL stopWex; + +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL void initGL (void) + { + uglMesaSetColor(BLACK, 0.0, 0.0, 0.0); + uglMesaSetColor(RED, 1.0, 0.3, 0.3); + uglMesaSetColor(GREEN, 0.3, 1.0, 0.3); + uglMesaSetColor(BLUE, 0.3, 0.3, 1.0); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(BLACK); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + } + +UGL_LOCAL void drawGL (void) + { + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + (rgb) ? glColor3f(1.0, 0.3, 0.3) : glIndexi(RED); + glVertex2f(0.75, -0.50); + (rgb) ? glColor3f(0.3, 1.0, 0.3) : glIndexi(GREEN); + glVertex2f(0.0, 0.75); + (rgb) ? glColor3f(0.3, 0.3, 1.0) : glIndexi(BLUE); + glVertex2f(-0.75, -0.50); + glEnd(); + + glBegin(GL_LINES); + (rgb) ? glColor3f(1.0, 0.3, 0.3) : glIndexi(RED); + glVertex2f(-1.0, 1.0); + (rgb) ? glColor3f(0.3, 0.3, 1.0) : glIndexi(BLUE); + glVertex2f(1.0, -1.0); + glEnd(); + + glFlush(); + + uglMesaSwapBuffers(); + } + +UGL_LOCAL void echoUse(void) + { + printf("tFlip keys:\n"); + printf(" d Toggle dithering\n"); + printf(" up Reduce the window\n"); + printf(" down Enlarge the window\n"); + printf(" page up Y==0 is the bottom line and increases upward\n"); + printf(" page down Y==0 is the bottom line and increases downward\n"); + printf(" ESC Exit\n"); + } + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + + switch(key) + { + case UGL_UNI_UP_ARROW: + uglMesaResizeWindow(8, 8); + break; + case UGL_UNI_DOWN_ARROW: + glDrawBuffer(GL_FRONT_LEFT); + glClear(GL_COLOR_BUFFER_BIT); + glDrawBuffer(GL_BACK_LEFT); + uglMesaResizeWindow(-8, -8); + break; + case UGL_UNI_PAGE_UP: + uglMesaPixelStore(UGL_MESA_Y_UP, GL_TRUE); + break; + case UGL_UNI_PAGE_DOWN: + uglMesaPixelStore(UGL_MESA_Y_UP, GL_FALSE); + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + case 'd': + if (glIsEnabled(GL_DITHER)) + glDisable(GL_DITHER); + else + glEnable(GL_DITHER); + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + drawGL(); + + UGL_FOREVER + { + 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) + { + readKey(pInputEvent->type.keyboard.key); + drawGL(); + } + } + + if (stopWex) + break; + } + } + +void windMLFlip (void); + +void uglflip (void) + { + taskSpawn("tFlip", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLFlip, + 0,1,2,3,4,5,6,7,8,9); + } + +void windMLFlip(void) + { + + UGL_INPUT_DEVICE_ID keyboardDevId; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE_SW, NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_RGB, &rgb); + + initGL(); + + echoUse(); + stopWex = UGL_FALSE; + loopEvent(); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/uglgears.c b/progs/windml/uglgears.c new file mode 100644 index 00000000000..fe750a57d8d --- /dev/null +++ b/progs/windml/uglgears.c @@ -0,0 +1,422 @@ + +/* uglgears.c - WindML/Mesa example program */ + +/* + * 3-D gear wheels. This program is in the public domain. + * + * Brian Paul + * + * Conversion to GLUT by Mark J. Kilgard + * Conversion to UGL/Mesa from GLUT by Stephane Raimbault + */ + +/* +DESCRIPTION +Spinning gears demo +*/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define COUNT_FRAMES + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL volatile UGL_BOOL stopWex; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL GLfloat view_rotx, view_roty, view_rotz; +UGL_LOCAL GLint gear1, gear2, gear3; +UGL_LOCAL GLfloat angle; + +UGL_LOCAL GLuint limit; +UGL_LOCAL GLuint count; +UGL_LOCAL GLuint tickStart, tickStop, tickBySec; + + +/* +* Draw a gear wheel. You'll probably want to call this function when +* building a display list since we do a lot of trig here. +* +* Input: inner_radius - radius of hole at center +* outer_radius - radius at center of teeth +* width - width of gear +* teeth - number of teeth +* tooth_depth - depth of tooth +*/ + +UGL_LOCAL void gear + ( + GLfloat inner_radius, + GLfloat outer_radius, + GLfloat width, + GLint teeth, + GLfloat tooth_depth + ) + { + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth/2.0; + r2 = outer_radius + tooth_depth/2.0; + + da = 2.0*M_PI / teeth / 4.0; + + glShadeModel (GL_FLAT); + + glNormal3f (0.0, 0.0, 1.0); + + /* draw front face */ + glBegin (GL_QUAD_STRIP); + for (i=0;i<=teeth;i++) + { + angle = i * 2.0*M_PI / teeth; + glVertex3f (r0*cos (angle), r0*sin (angle), width*0.5); + glVertex3f (r1*cos (angle), r1*sin (angle), width*0.5); + glVertex3f (r0*cos (angle), r0*sin (angle), width*0.5); + glVertex3f (r1*cos (angle+3*da), r1*sin (angle+3*da), width*0.5); + } + glEnd (); + + /* draw front sides of teeth */ + glBegin (GL_QUADS); + da = 2.0*M_PI / teeth / 4.0; + for (i=0; i limit) + { + tickStop = tickGet (); + time = (tickStop-tickStart)/tickBySec; + printf (" %i fps\n", count/time); + tickStart = tickStop; + count = 0; + } + else + count++; +#endif +} + + +UGL_LOCAL void initGL (GLsizei width, GLsizei height) + { + UGL_LOCAL GLfloat pos[4] = {5.0, 5.0, 10.0, 1.0 }; + UGL_LOCAL GLfloat red[4] = {0.8, 0.1, 0.0, 1.0 }; + UGL_LOCAL GLfloat green[4] = {0.0, 0.8, 0.2, 1.0 }; + UGL_LOCAL GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0 }; + + glLightfv (GL_LIGHT0, GL_POSITION, pos); + glEnable (GL_CULL_FACE); + glEnable (GL_LIGHTING); + glEnable (GL_LIGHT0); + glEnable (GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists (1); + glNewList (gear1, GL_COMPILE); + glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear (1.0, 4.0, 1.0, 20, 0.7); + glEndList (); + + gear2 = glGenLists (1); + glNewList (gear2, GL_COMPILE); + glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear (0.5, 2.0, 2.0, 10, 0.7); + glEndList (); + + gear3 = glGenLists (1); + glNewList (gear3, GL_COMPILE); + glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear (1.3, 2.0, 0.5, 10, 0.7); + glEndList (); + + glEnable (GL_NORMALIZE); + + glViewport (0, 0, width, height); + + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + if (width>height) + { + GLfloat w = (GLfloat) width / (GLfloat) height; + glFrustum (-w, w, -1.0, 1.0, 5.0, 60.0); + } + else + { + GLfloat h = (GLfloat) height / (GLfloat) width; + glFrustum (-1.0, 1.0, -h, h, 5.0, 60.0); + } + + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + glTranslatef (0.0, 0.0, -40.0); + +#ifdef COUNT_FRAMES + tickStart = tickGet (); + tickBySec = sysClkRateGet (); +#endif +} + +UGL_LOCAL void echoUse(void) + { + printf("tGears keys:\n"); + printf(" z Counter clockwise rotation (z-axis)\n"); + printf(" Z Clockwise rotation (z-axis)\n"); + printf(" Up Counter clockwise rotation (x-axis)\n"); + printf(" Down Clockwise rotation (x-axis)\n"); + printf(" Left Counter clockwise rotation (y-axis)\n"); + printf(" Right Clockwise rotation (y-axis)\n"); + printf(" ESC Exit\n"); + } + + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + + switch(key) + { + case 'z': + view_rotz += 5.0; + break; + case 'Z': + view_rotz -= 5.0; + break; + case UGL_UNI_UP_ARROW: + view_rotx += 5.0; + break; + case UGL_UNI_DOWN_ARROW: + view_rotx -= 5.0; + break; + case UGL_UNI_LEFT_ARROW: + view_roty += 5.0; + break; + case UGL_UNI_RIGHT_ARROW: + view_roty -= 5.0; + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +void windMLGears (void); + +void uglgears (void) + { + taskSpawn ("tGears", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLGears, + 0,1,2,3,4,5,6,7,8,9); + } + +void windMLGears (void) + { + GLsizei width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + view_rotx=20.0; + view_roty=30.0; + view_rotz=0.0; + angle = 0.0; + limit = 100; + count = 1; + + uglInitialize (); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, + (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + /* Double buffering */ + + umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL); + if (umc == NULL) + { + uglDeinitialize (); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext (umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL (width, height); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize (); + + return; + } diff --git a/progs/windml/uglicotorus.c b/progs/windml/uglicotorus.c new file mode 100644 index 00000000000..46226f1e82c --- /dev/null +++ b/progs/windml/uglicotorus.c @@ -0,0 +1,311 @@ +/* uglicotorus.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* +modification history +-------------------- +01a,jun01,sra +*/ + +#include +#include + +#include +#include +#include + +#include +#include + +/* Need GLUT_SHAPES */ + +#include + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; +UGL_LOCAL volatile UGL_BOOL stopWex; + +UGL_LOCAL GLfloat angle; +UGL_LOCAL GLboolean chaos_on; +UGL_LOCAL GLboolean color_on; + +UGL_LOCAL GLuint theIco, theTorus, theSphere, theCube; + +UGL_LOCAL void initGL + ( + int w, + int h + ) + { + glViewport(0,0,(GLsizei)w,(GLsizei)h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0,(GLfloat)w/(GLfloat)h,1.0,60.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + gluLookAt(0.0,0.0,25.0,0.0,0.0,0.0,0.0,1.0,0.0); + + glClearColor(0.0,0.0,0.0,0.0); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glEnable(GL_COLOR_MATERIAL); + + theIco = glGenLists(1); + glNewList(theIco, GL_COMPILE); + glutSolidIcosahedron(); + glEndList(); + + theTorus = glGenLists(1); + glNewList(theTorus, GL_COMPILE); + glutSolidTorus(0.2,1.0,10,10); + glEndList(); + + theSphere = glGenLists(1); + glNewList(theSphere, GL_COMPILE); + glutSolidSphere(2.5,20,20); + glEndList(); + + theCube = glGenLists(1); + glNewList(theCube, GL_COMPILE); + glutSolidCube(4.0); + glEndList(); + + } + +UGL_LOCAL void createIcoToruses + ( + int i + ) + { + glPushMatrix(); + glRotatef(angle,1.0,1.0,1.0); + glCallList(theIco); + + switch (i) + { + case 9 : + glColor3f(1.0,0.0,0.0); + break; + case 0 : + glColor3f(1.0,0.1,0.7); + break; + case 1 : + glColor3f(1.0,0.0,1.0); + break; + case 2 : + glColor3f(0.0,0.0,1.0); + break; + case 3 : + glColor3f(0.0,0.5,1.0); + break; + case 4 : + glColor3f(0.0,1.0,0.7); + break; + case 5 : + glColor3f(0.0,1.0,0.0); + break; + case 6 : + glColor3f(0.5,1.0,0.0); + break; + case 7 : + glColor3f(1.0,1.0,0.0); + break; + case 8 : + glColor3f(1.0,0.5,0.0); + break; + } + + glRotatef(angle,1.0,1.0,1.0); + glCallList(theTorus); + glRotatef(-2*angle,1.0,1.0,1.0); + glCallList(theTorus); + glPopMatrix(); + } + +UGL_LOCAL void drawGL (void) + { + int i; + + if (color_on) + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + else + glClear(GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + + if (chaos_on) + glRotatef(angle,1.0,1.0,1.0); + + glPushMatrix(); + glRotatef(angle,1.0,1.0,1.0); + glColor3f(1.0,0.5,0.0); + glCallList(theSphere); + glColor3f(1.0,0.0,0.0); + glCallList(theCube); + glPopMatrix(); + + glRotatef(-angle,0.0,0.0,1.0); + glPushMatrix(); + /* draw ten icosahedrons */ + for (i = 0; i < 10; i++) + { + glPushMatrix(); + glRotatef(36*i,0.0,0.0,1.0); + glTranslatef(10.0,0.0,0.0); + glRotatef(2*angle,0.0,1.0,0.0); + glTranslatef(0.0,0.0,2.0); + + createIcoToruses(i); + glPopMatrix(); + } + glPopMatrix(); + + glPopMatrix(); + + uglMesaSwapBuffers(); + + angle += 1.0; + + } + +UGL_LOCAL void echoUse(void) + { + printf("tIcoTorus keys:\n"); + printf(" c Toggle color buffer clear\n"); + printf(" SPACE Toggle chaos mode\n"); + printf(" ESC Exit\n"); + } + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + + switch(key) + { + case 'c': + color_on = !color_on; + break; + case UGL_UNI_SPACE: + chaos_on = !chaos_on; + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +void windMLIcoTorus (void); + +void uglicotorus (void) + { + taskSpawn ("tIcoTorus", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLIcoTorus, + 0,1,2,3,4,5,6,7,8,9); + } + +void windMLIcoTorus (void) + { + GLsizei width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + angle = 0.0; + chaos_on = GL_TRUE; + color_on = GL_TRUE; + + uglInitialize (); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, + (UGL_UINT32 *)&keyboardDevId); + + if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, + (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK) + { + qId = uglEventQCreate (eventServiceId, 100); + } + else + { + eventServiceId = UGL_NULL; + } + + /* Double buffering */ + umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize (); + return; + } + + uglMesaMakeCurrentContext (umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL (width, height); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + if (eventServiceId != UGL_NULL) + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext (); + uglDeinitialize (); + + return; + } + diff --git a/progs/windml/uglline.c b/progs/windml/uglline.c new file mode 100644 index 00000000000..fd100fff4b4 --- /dev/null +++ b/progs/windml/uglline.c @@ -0,0 +1,270 @@ + +/* uglline.c - WindML/Mesa example program */ + +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* +modification history +-------------------- +01a,jun01,sra Ported to UGL/Mesa and modifications +*/ + +/* +DESCRIPTION +Draw circular lines +*/ + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#define BLACK (0) +#define YELLOW (1) +#define GREEN (2) +#define BLUE (3) +#define CI_OFFSET 4 + +UGL_LOCAL GLuint rgb; +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL volatile UGL_BOOL stopWex; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL GLboolean mode1, mode2; +UGL_LOCAL GLint size; + +UGL_LOCAL GLfloat pntA[3] = { + -10.0, 0.0, 0.0 +}; +UGL_LOCAL GLfloat pntB[3] = { + -5.0, 0.0, 0.0 +}; + +UGL_LOCAL GLint angleA; + +UGL_LOCAL void initGL (void) + { + GLint i; + + uglMesaSetColor(BLACK, 0.0, 0.0, 0.0); + uglMesaSetColor(YELLOW, 1.0, 1.0, 0.0); + uglMesaSetColor(GREEN, 0.0, 1.0, 0.0); + uglMesaSetColor(BLUE, 0.0, 0.0, 1.0); + + for (i = 0; i < 16; i++) + { + uglMesaSetColor(CI_OFFSET+i, i/15.0, i/15.0, 0.0); + } + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(BLACK); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-10, 10, -10, 10, -10.0, 10.0); + + glMatrixMode(GL_MODELVIEW); + + glLineStipple(1, 0xF0E0); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + + mode1 = GL_FALSE; + mode2 = GL_FALSE; + size = 1; + } + +UGL_LOCAL void drawGL (void) + { + + GLint ci, i; + + glClear(GL_COLOR_BUFFER_BIT); + + glLineWidth(size); + + if (mode1) { + glEnable(GL_LINE_STIPPLE); + } else { + glDisable(GL_LINE_STIPPLE); + } + + if (mode2) { + ci = CI_OFFSET; + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + } else { + ci = YELLOW; + glDisable(GL_LINE_SMOOTH); + glDisable(GL_BLEND); + } + + glPushMatrix(); + + glRotatef(angleA, 1, 0, 1); + angleA = angleA++ % 360; + + for (i = 0; i < 360; i += 5) { + glRotatef(5.0, 0, 0, 1); + + glColor3f(1.0, 1.0, 0.0); + glBegin(GL_LINE_STRIP); + glVertex3fv(pntA); + glVertex3fv(pntB); + glEnd(); + + glPointSize(1); + + glColor3f(0.0, 1.0, 0.0); + glBegin(GL_POINTS); + glVertex3fv(pntA); + glVertex3fv(pntB); + glEnd(); + } + + glPopMatrix(); + + glFlush(); + + uglMesaSwapBuffers(); + + } + +UGL_LOCAL void echoUse(void) + { + printf("tLine keys:\n"); + printf(" b Blending/antialiasing\n"); + printf(" n Line stipple\n"); + printf(" Up/Down Pixel size\n"); + printf(" ESC Exit\n"); + } + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + switch(key) + { + case 'n': + mode1 = (mode1) ? GL_FALSE: GL_TRUE; + break; + case 'b': + mode2 = (mode2) ? GL_FALSE: GL_TRUE; + break; + case UGL_UNI_DOWN_ARROW: + if(size>0) + size--; + break; + case UGL_UNI_UP_ARROW: + size++; + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +void windMLLine (void); + +void uglline (void) + { + taskSpawn("tLine", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLLine, + 0,1,2,3,4,5,6,7,8,9); + } + + +void windMLLine(void) + { + + UGL_INPUT_DEVICE_ID keyboardDevId; + + angleA = 0; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + /* Double buffer */ + + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_RGB, &rgb); + + initGL(); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + uglEventQDestroy(eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/uglolympic.c b/progs/windml/uglolympic.c new file mode 100644 index 00000000000..de7c278b1a7 --- /dev/null +++ b/progs/windml/uglolympic.c @@ -0,0 +1,474 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * Nov 20, 1995 use stdlib's rand()/srand() instead of random()/srand48(), etc. + */ + +/* + * Modified by Stephane Raimbault to be able to run in VxWorks 07/18/01 + * + * Modified by Li Wei(liwei@aiar.xjtu.edu.cn) to be able to run in Windows + * 6/13 + * + * Modified by Brian Paul to compile with Windows OR Unix. 7/23/97 + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#ifndef RAND_MAX +# define RAND_MAX 32767 +#endif + +#define XSIZE 100 +#define YSIZE 75 + +#define RINGS 5 +#define BLUERING 0 +#define BLACKRING 1 +#define REDRING 2 +#define YELLOWRING 3 +#define GREENRING 4 + +#define BACKGROUND 8 + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; +UGL_LOCAL volatile UGL_BOOL stopWex; + +UGL_LOCAL int rgb; +UGL_LOCAL unsigned char rgb_colors[RINGS][3]; +UGL_LOCAL int mapped_colors[RINGS]; +UGL_LOCAL float dests[RINGS][3]; +UGL_LOCAL float offsets[RINGS][3]; +UGL_LOCAL float angs[RINGS]; +UGL_LOCAL float rotAxis[RINGS][3]; +UGL_LOCAL int iters[RINGS]; +UGL_LOCAL GLuint theTorus; + +enum { + COLOR_BLACK = 0, + COLOR_RED, + COLOR_GREEN, + COLOR_YELLOW, + COLOR_BLUE, + COLOR_MAGENTA, + COLOR_CYAN, + COLOR_WHITE +}; + +/* +UGL_LOCAL float RGBMap[9][3] = { + {0, 0, 0}, + {1, 0, 0}, + {0, 1, 0}, + {1, 1, 0}, + {0, 0, 1}, + {1, 0, 1}, + {0, 1, 1}, + {1, 1, 1}, + {0.5, 0.5, 0.5} +}; + +UGL_LOCAL void SetColor(int c) + { + (rgb) ? glColor3fv(RGBMap[c]): glIndexf(c); + } + +UGL_LOCAL void InitMap(void) + { + int i; + + if (rgb) + return; + + for (i = 0; i < 9; i++) + uglMesaSetColor(i, RGBMap[i][0], RGBMap[i][1], RGBMap[i][2]); + } + +UGL_LOCAL void SetFogRamp(int density, int startIndex) + { + int fogValues, colorValues; + int i, j, k; + float intensity; + + fogValues = 1 << density; + colorValues = 1 << startIndex; + for (i = 0; i < colorValues; i++) + { + for (j = 0; j < fogValues; j++) + { + k = i * fogValues + j; + intensity = (i * fogValues + j * colorValues) / 255.0; + uglMesaSetColor(k, intensity, intensity, intensity); + } + } + } + +UGL_LOCAL void SetGreyRamp(void) + { + int i; + float intensity; + + for (i = 0; i < 255; i++) + { + intensity = i / 255.0; + uglMesaSetColor(i, intensity, intensity, intensity); + } + } +*/ + +UGL_LOCAL void FillTorus(float rc, int numc, float rt, int numt) + { + int i, j, k; + double s, t; + double x, y, z; + double pi, twopi; + + pi = 3.14159265358979323846; + twopi = 2 * pi; + + for (i = 0; i < numc; i++) + { + glBegin(GL_QUAD_STRIP); + for (j = 0; j <= numt; j++) + { + for (k = 1; k >= 0; k--) + { + s = (i + k) % numc + 0.5; + t = j % numt; + + x = cos(t*twopi/numt) * cos(s*twopi/numc); + y = sin(t*twopi/numt) * cos(s*twopi/numc); + z = sin(s*twopi/numc); + glNormal3f(x, y, z); + + x = (rt + rc * cos(s*twopi/numc)) * cos(t*twopi/numt); + y = (rt + rc * cos(s*twopi/numc)) * sin(t*twopi/numt); + z = rc * sin(s*twopi/numc); + glVertex3f(x, y, z); + } + } + glEnd(); + } + } + +UGL_LOCAL float Clamp(int iters_left, float t) + { + if (iters_left < 3) + { + return 0.0; + } + return (iters_left-2)*t/iters_left; + } + +UGL_LOCAL void drawGL(void) + { + int i, j; + + for (i = 0; i < RINGS; i++) + { + if (iters[i]) { + for (j = 0; j < 3; j++) + { + offsets[i][j] = Clamp(iters[i], offsets[i][j]); + } + angs[i] = Clamp(iters[i], angs[i]); + iters[i]--; + } + } + + glPushMatrix(); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + gluLookAt(0,0,10, 0,0,0, 0,1,0); + + for (i = 0; i < RINGS; i++) + { + if (rgb) + { + glColor3ubv(rgb_colors[i]); + } + else + { + glIndexi(mapped_colors[i]); + } + glPushMatrix(); + glTranslatef(dests[i][0]+offsets[i][0], dests[i][1]+offsets[i][1], + dests[i][2]+offsets[i][2]); + glRotatef(angs[i], rotAxis[i][0], rotAxis[i][1], rotAxis[i][2]); + glCallList(theTorus); + glPopMatrix(); + } + + glPopMatrix(); + + glFlush(); + + uglMesaSwapBuffers(); + } + +UGL_LOCAL float MyRand(void) + { + return 10.0 * ( (float) rand() / (float) RAND_MAX - 0.5 ); + } + +UGL_LOCAL void ReInit(void) + { + int i; + float deviation; + + deviation = MyRand() / 2; + deviation = deviation * deviation; + for (i = 0; i < RINGS; i++) + { + offsets[i][0] = MyRand(); + offsets[i][1] = MyRand(); + offsets[i][2] = MyRand(); + angs[i] = 260.0 * MyRand(); + rotAxis[i][0] = MyRand(); + rotAxis[i][1] = MyRand(); + rotAxis[i][2] = MyRand(); + iters[i] = (deviation * MyRand() + 60.0); + } + } + +UGL_LOCAL void initGL(void) + { + float base, height; + float aspect, x, y; + int i; + + float top_y = 1.0; + float bottom_y = 0.0; + float top_z = 0.15; + float bottom_z = 0.69; + float spacing = 2.5; + static float lmodel_ambient[] = {0.0, 0.0, 0.0, 0.0}; + static float lmodel_twoside[] = {GL_FALSE}; + static float lmodel_local[] = {GL_FALSE}; + static float light0_ambient[] = {0.1, 0.1, 0.1, 1.0}; + static float light0_diffuse[] = {1.0, 1.0, 1.0, 0.0}; + static float light0_position[] = {0.8660254, 0.5, 1, 0}; + static float light0_specular[] = {1.0, 1.0, 1.0, 0.0}; + static float bevel_mat_ambient[] = {0.0, 0.0, 0.0, 1.0}; + static float bevel_mat_shininess[] = {40.0}; + static float bevel_mat_specular[] = {1.0, 1.0, 1.0, 0.0}; + static float bevel_mat_diffuse[] = {1.0, 0.0, 0.0, 0.0}; + + ReInit(); + + for (i = 0; i < RINGS; i++) + { + rgb_colors[i][0] = rgb_colors[i][1] = rgb_colors[i][2] = 0; + } + rgb_colors[BLUERING][2] = 255; + rgb_colors[REDRING][0] = 255; + rgb_colors[GREENRING][1] = 255; + rgb_colors[YELLOWRING][0] = 255; + rgb_colors[YELLOWRING][1] = 255; + mapped_colors[BLUERING] = COLOR_BLUE; + mapped_colors[REDRING] = COLOR_RED; + mapped_colors[GREENRING] = COLOR_GREEN; + mapped_colors[YELLOWRING] = COLOR_YELLOW; + mapped_colors[BLACKRING] = COLOR_BLACK; + + dests[BLUERING][0] = -spacing; + dests[BLUERING][1] = top_y; + dests[BLUERING][2] = top_z; + + dests[BLACKRING][0] = 0.0; + dests[BLACKRING][1] = top_y; + dests[BLACKRING][2] = top_z; + + dests[REDRING][0] = spacing; + dests[REDRING][1] = top_y; + dests[REDRING][2] = top_z; + + dests[YELLOWRING][0] = -spacing / 2.0; + dests[YELLOWRING][1] = bottom_y; + dests[YELLOWRING][2] = bottom_z; + + dests[GREENRING][0] = spacing / 2.0; + dests[GREENRING][1] = bottom_y; + dests[GREENRING][2] = bottom_z; + + base = 2.0; + height = 2.0; + theTorus = glGenLists(1); + glNewList(theTorus, GL_COMPILE); + FillTorus(0.1, 8, 1.0, 25); + glEndList(); + + x = (float)XSIZE; + y = (float)YSIZE; + aspect = x / y; + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + glEnable(GL_DEPTH_TEST); + glClearDepth(1.0); + + if (rgb) + { + glClearColor(0.5, 0.5, 0.5, 0.0); + glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light0_position); + glEnable(GL_LIGHT0); + + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local); + glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glEnable(GL_LIGHTING); + + glMaterialfv(GL_FRONT, GL_AMBIENT, bevel_mat_ambient); + glMaterialfv(GL_FRONT, GL_SHININESS, bevel_mat_shininess); + glMaterialfv(GL_FRONT, GL_SPECULAR, bevel_mat_specular); + glMaterialfv(GL_FRONT, GL_DIFFUSE, bevel_mat_diffuse); + + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glEnable(GL_COLOR_MATERIAL); + glShadeModel(GL_SMOOTH); + } + else + { + glClearIndex(BACKGROUND); + glShadeModel(GL_FLAT); + } + + glMatrixMode(GL_PROJECTION); + gluPerspective(45, 1.33, 0.1, 100.0); + glMatrixMode(GL_MODELVIEW); + } + +UGL_LOCAL void echoUse(void) + { + printf("tOlympic keys:\n"); + printf(" SPACE Reinitialize\n"); + printf(" ESC Exit\n"); + } + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + switch(key) + { + case UGL_UNI_SPACE: + ReInit(); + break; + case UGL_UNI_ESCAPE: + stopWex = 1; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +void windMLOlympic (void); + +void uglolympic (void) + { + taskSpawn("tOlympic", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLOlympic, + 0,1,2,3,4,5,6,7,8,9); + } + +void windMLOlympic(void) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, + (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK) + { + qId = uglEventQCreate (eventServiceId, 100); + } + else + { + eventServiceId = UGL_NULL; + } + + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_RGB, &rgb); + + initGL(); + + echoUse(); + + stopWex = 0; + loopEvent(); + + if (eventServiceId != UGL_NULL) + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/uglpoint.c b/progs/windml/uglpoint.c new file mode 100644 index 00000000000..e184eaa7550 --- /dev/null +++ b/progs/windml/uglpoint.c @@ -0,0 +1,266 @@ + +/* uglpoint.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Stephane Raimbault + */ + +/* +DESCRIPTION +Draw a single point. +*/ + +#include +#include + +#include +#include +#include + +#include + +#define DOUBLE_BUFFER GL_TRUE + +enum { + BLACK = 0, + RED, + GREEN, + BLUE, + WHITE +}; + +UGL_LOCAL GLuint rgb; +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; +UGL_LOCAL GLint angleT; + +UGL_LOCAL void initGL (void) + { + /* By passed in RGB mode */ + uglMesaSetColor(BLACK, 0.0, 0.0, 0.0); + uglMesaSetColor(RED, 1.0, 0.0, 0.0); + uglMesaSetColor(GREEN, 0.0, 1.0, 0.0); + uglMesaSetColor(BLUE, 0.0, 0.0, 1.0); + uglMesaSetColor(WHITE, 1.0, 1.0, 1.0); + + glOrtho(0.0, 1.0, 0.0, 1.0, -20.0, 20.0); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(BLACK); + } + +UGL_LOCAL void drawGL (void) + { + GLint i; + GLfloat x, y; + + /* Avoid blinking in single buffer */ + + if (DOUBLE_BUFFER) + glClear(GL_COLOR_BUFFER_BIT); + + /* Random points */ + + glBegin(GL_POINTS); + (rgb) ? glColor3f(1.0, 0.0, 0.0): glIndexi(RED); + + for (i=0; i<150; i++) + { + x = rand() / (RAND_MAX+1.0); + y = rand() / (RAND_MAX+1.0); + glVertex2f(x, y); + } + + (rgb) ? glColor3f(0.0, 1.0, 0.0): glIndexi(GREEN); + + for (i=0; i<150; i++) + { + x = (rand() / (RAND_MAX+1.0)); + y = (rand() / (RAND_MAX+1.0)); + glVertex2f(x, y); + } + + (rgb) ? glColor3f(0.0, 0.0, 1.0): glIndexi(BLUE); + glVertex2f(0.5,0.5); + + for (i=0; i<150; i++) + { + x = rand() / (RAND_MAX+1.0); + y = rand() / (RAND_MAX+1.0); + glVertex2f(x, y); + } + + glEnd(); + + /* Smooth triangle */ + + glPushMatrix(); + glTranslatef(0.5, 0.5, 0); + 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); + glEnd(); + glPopMatrix(); + + /* Flush and swap */ + + glFlush(); + + if(DOUBLE_BUFFER) + uglMesaSwapBuffers(); + } + +/************************************************************************ +* +* getEvent +* +* RETURNS: true or false +* +* NOMANUAL +* +*/ + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +void windMLPoint (void); + +void uglpoint (void) + { + taskSpawn("tPoint", 210, VX_FP_TASK, 100000, + (FUNCPTR)windMLPoint, 0,1,2,3,4,5,6,7,8,9); + } + +void windMLPoint(void) + { + GLubyte pPixels[4]; + GLsizei width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + angleT = 0; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, + (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK) + { + qId = uglEventQCreate (eventServiceId, 100); + } + else + { + eventServiceId = UGL_NULL; + } + + if (DOUBLE_BUFFER) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_SINGLE, NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + /* RGB or CI ? */ + + uglMesaGetIntegerv(UGL_MESA_RGB, &rgb); + + initGL(); + + while (!getEvent()) + drawGL(); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + printf ("glReadPixel return "); + if (rgb) + { + glReadPixels(width/2, height/2, + 1, 1, GL_RGB, + GL_UNSIGNED_BYTE, pPixels); + glFlush(); + printf ("R:%i G:%i B:%i (RGB)", pPixels[0], pPixels[1], pPixels[2]); + } + else + { + glReadPixels(width/2, height/2, + 1, 1, GL_COLOR_INDEX, + GL_UNSIGNED_BYTE, pPixels); + glFlush(); + if (pPixels[0] == BLUE) + printf ("BLUE (CI)"); + else + printf ("%i (CI))", pPixels[0]); + } + + printf(" for %ix%i\n", width/2, height/2); + + if (eventServiceId != UGL_NULL) + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/uglstencil.c b/progs/windml/uglstencil.c new file mode 100644 index 00000000000..94e9f502596 --- /dev/null +++ b/progs/windml/uglstencil.c @@ -0,0 +1,233 @@ + +/* Copyright (c) Mark J. Kilgard, 1994. */ + +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* stencil.c + * This program draws two rotated tori in a window. + * A diamond in the center of the window masks out part + * of the scene. Within this mask, a different model + * (a sphere) is drawn in a different color. + */ + +/* + * Conversion to UGL/Mesa by Stephane Raimbault, 2001 + */ + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#define YELLOWMAT 1 +#define BLUEMAT 2 + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL void initGL (GLsizei w, GLsizei h) + { + GLfloat yellow_diffuse[] = { 0.7, 0.7, 0.0, 1.0 }; + GLfloat yellow_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + + GLfloat blue_diffuse[] = { 0.1, 0.1, 0.7, 1.0 }; + GLfloat blue_specular[] = { 0.1, 1.0, 1.0, 1.0 }; + + GLfloat position_one[] = { 1.0, 1.0, 1.0, 0.0 }; + + glNewList(YELLOWMAT, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_DIFFUSE, yellow_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, yellow_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 64.0); + glEndList(); + + glNewList(BLUEMAT, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_DIFFUSE, blue_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, blue_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 45.0); + glEndList(); + + glLightfv(GL_LIGHT0, GL_POSITION, position_one); + + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + + glClearStencil(0x0); + glEnable(GL_STENCIL_TEST); + + glClear(GL_STENCIL_BUFFER_BIT); + +/* create a diamond shaped stencil area */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-3.0, 3.0, -3.0, 3.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glStencilFunc (GL_ALWAYS, 0x1, 0x1); + glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE); + glBegin(GL_QUADS); + glVertex3f (-1.0, 0.0, 0.0); + glVertex3f (0.0, 1.0, 0.0); + glVertex3f (1.0, 0.0, 0.0); + glVertex3f (0.0, -1.0, 0.0); + glEnd(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0, (GLfloat) w/(GLfloat) h, 3.0, 7.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -5.0); + } + +/* Draw a sphere in a diamond-shaped section in the + * middle of a window with 2 tori. + */ +UGL_LOCAL void drawGL(void) + { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); + +/* draw blue sphere where the stencil is 1 */ + glStencilFunc (GL_EQUAL, 0x1, 0x1); + glCallList (BLUEMAT); + glutSolidSphere (0.5, 15, 15); + +/* draw the tori where the stencil is not 1 */ + glStencilFunc (GL_NOTEQUAL, 0x1, 0x1); + glPushMatrix(); + glRotatef (45.0, 0.0, 0.0, 1.0); + glRotatef (45.0, 0.0, 1.0, 0.0); + glCallList (YELLOWMAT); + glutSolidTorus (0.275, 0.85, 15, 15); + glPushMatrix(); + glRotatef (90.0, 1.0, 0.0, 0.0); + glutSolidTorus (0.275, 0.85, 15, 15); + glPopMatrix(); + glPopMatrix(); + + glFlush(); + + uglMesaSwapBuffers(); + } + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +void windMLStencil (void); + +void uglstencil (void) + { + taskSpawn("tStencil", 210, VX_FP_TASK, 100000, + (FUNCPTR)windMLStencil, 0,1,2,3,4,5,6,7,8,9); + } + +void windMLStencil(void) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + GLsizei width, height; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + 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 (umc == NULL) + { + uglDeinitialize(); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL(width, height); + + drawGL(); + + while (!getEvent()); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } + diff --git a/progs/windml/uglteapot.c b/progs/windml/uglteapot.c new file mode 100644 index 00000000000..26c766d8346 --- /dev/null +++ b/progs/windml/uglteapot.c @@ -0,0 +1,290 @@ +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Linux Magazine July 2001 + * Conversion to UGL/Mesa from GLUT by Stephane Raimbault, 2001 + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +/* Need GLUT_SHAPES */ + +#include + +#ifndef PI +#define PI 3.14159265 +#endif + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; +UGL_LOCAL volatile UGL_BOOL stopWex; + +UGL_LOCAL GLint angle; +UGL_LOCAL GLfloat Sin[360], Cos[360]; +UGL_LOCAL GLfloat L0pos[]={0.0, 2.0, -1.0}; +UGL_LOCAL GLfloat L0dif[]={0.3, 0.3, 0.8}; +UGL_LOCAL GLfloat L1pos[]={2.0, 2.0, 2.0}; +UGL_LOCAL GLfloat L1dif[]={0.5, 0.5, 0.5}; +UGL_LOCAL GLfloat Mspec[3]; +UGL_LOCAL GLfloat Mshiny; +UGL_LOCAL GLuint theTeapot; + +UGL_LOCAL void calcTableCosSin() +{ + int i; + for(i=0;i<360;i++) { + Cos[i] = cos(((float)i)/180.0*PI); + Sin[i] = sin(((float)i)/180.0*PI); + } +} + +UGL_LOCAL void initGL(void) + { + glClearColor(0.0, 0.0, 0.0, 0.0); + glColor3f(1.0, 0.0, 0.0); + glEnable(GL_DEPTH_TEST); + + glShadeModel(GL_SMOOTH); + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHT1); + glLightfv(GL_LIGHT0, GL_DIFFUSE, L0dif); + glLightfv(GL_LIGHT0, GL_SPECULAR, L0dif); + glLightfv(GL_LIGHT1, GL_DIFFUSE, L1dif); + glLightfv(GL_LIGHT1, GL_SPECULAR, L1dif); + + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Mspec); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Mshiny); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0, 1.0, 0.1, 10.0); + glMatrixMode(GL_MODELVIEW); + + theTeapot = glGenLists(1); + glNewList(theTeapot, GL_COMPILE); + glutSolidTeapot(1.0); + glEndList(); + + } + +UGL_LOCAL void drawGL() + { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glLoadIdentity(); + + gluLookAt(4.5*Cos[angle], 2.0,4.5*Sin[angle],0.0,0.0,0.0,0.0, + 1.0,0.0); + glLightfv(GL_LIGHT0, GL_POSITION, L0pos); + glLightfv(GL_LIGHT1, GL_POSITION, L1pos); + + glCallList(theTeapot); + + glFlush(); + + uglMesaSwapBuffers(); + } + +UGL_LOCAL void echoUse(void) + { + printf("tTeapot keys:\n"); + printf(" Left Counter clockwise rotation (y-axis)\n"); + printf(" Right Clockwise rotation (y-axis)\n"); + printf(" j Enable/disable Light0\n"); + printf(" k Enable/disable Light1\n"); + printf(" m Add specular\n"); + printf(" l Remove specular\n"); + printf(" o Add shininess\n"); + printf(" p Remove shininess\n"); + printf(" ESC Exit\n"); + } + + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + switch(key) + { + case UGL_UNI_RIGHT_ARROW: + angle +=2; + if (angle>= 360) + angle-=360; + break; + case UGL_UNI_LEFT_ARROW: + angle -=2; + if (angle<0) + angle+=360; + break; + case 'j': + glIsEnabled(GL_LIGHT0) ? + glDisable(GL_LIGHT0) : glEnable(GL_LIGHT0); + break; + case 'k': + glIsEnabled(GL_LIGHT1) ? + glDisable(GL_LIGHT1) : glEnable(GL_LIGHT1); + break; + case 'm': + Mspec[0]+=0.1; + if(Mspec[0]>1) + Mspec[0]=1; + Mspec[1]+=0.1; + if(Mspec[1]>1) + Mspec[1]=1; + Mspec[2]+=0.1; + if(Mspec[2]>1) + Mspec[2]=1; + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Mspec); + break; + case 'l': + Mspec[0]-=0.1; + if(Mspec[0]>1) + Mspec[0]=1; + Mspec[1]-=0.1; + if(Mspec[1]>1) + Mspec[1]=1; + Mspec[2]-=0.1; + if(Mspec[2]>1) + Mspec[2]=1; + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Mspec); + break; + case 'o': + Mshiny -= 1; + if (Mshiny<0) + Mshiny=0; + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Mshiny); + break; + case 'p': + Mshiny += 1; + if (Mshiny>128) + Mshiny=128; + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Mshiny); + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +void windMLTeapot (void); + +void uglteapot (void) + { + taskSpawn ("tTeapot", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTeapot, + 0,1,2,3,4,5,6,7,8,9); + } + +void windMLTeapot (void) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + GLsizei displayWidth, displayHeight; + GLsizei x, y, w, h; + + angle = 45; + Mspec[0] = 0.5; + Mspec[1] = 0.5; + Mspec[2] = 0.5; + Mshiny = 50; + + uglInitialize (); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, + (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + /* Double buffering */ + umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL); + if (umc == NULL) + { + uglDeinitialize (); + return; + } + + uglMesaMakeCurrentContext (umc, 0, 0, 1, 1); + + uglMesaGetIntegerv(UGL_MESA_DISPLAY_WIDTH, &displayWidth); + uglMesaGetIntegerv(UGL_MESA_DISPLAY_HEIGHT, &displayHeight); + + h = (displayHeight*2)/3; + w = h; + x = (displayWidth-w)/2; + y = (displayHeight-h)/2; + + uglMesaMoveToWindow(x, y); + uglMesaResizeToWindow(w, h); + + calcTableCosSin(); + + initGL (); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize (); + + return; + } diff --git a/progs/windml/ugltexcube.c b/progs/windml/ugltexcube.c new file mode 100644 index 00000000000..1ce6666b65a --- /dev/null +++ b/progs/windml/ugltexcube.c @@ -0,0 +1,460 @@ + +/* ugltexcube.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Stephane Raimbault + */ + +/* +DESCRIPTION +Draw a textured cube +*/ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#define IMAGE_FILE "Mesa/windmldemos/wrs_logo.bmp" + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL GLfloat xrot, yrot, zrot; +UGL_LOCAL GLuint texture[1]; +UGL_LOCAL GLuint theTexCube; + +typedef struct { + unsigned long sizeX; + unsigned long sizeY; + char *data; + } 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; idata[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; + + texImage = (TEX_IMAGE *) malloc(sizeof(TEX_IMAGE)); + + if (texImage == NULL) + { + printf("Error allocating space for image"); + cleanUp(); + exit(1); + } + + if (!imageLoad(IMAGE_FILE, texImage)) + { + printf("Error allocating space for image data"); + free(texImage); + cleanUp(); + exit(1); + } + + /* Create Texture */ + glGenTextures(1, &texture[0]); + glBindTexture(GL_TEXTURE_2D, texture[0]); + glTexImage2D(GL_TEXTURE_2D, 0, 3, + texImage->sizeX, texImage->sizeY, + 0, GL_RGB, GL_UNSIGNED_BYTE, texImage->data); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + free(texImage->data); + free(texImage); + } + +UGL_LOCAL void initGL(int width, int height) + { + + /* Load the texture(s) */ + loadGLTexture(); + + /* Enable texture mapping */ + glEnable(GL_TEXTURE_2D); + + /* Clear the background color to black */ + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + + glEnable(GL_CULL_FACE); + + /* Enables smooth color shading */ + glShadeModel(GL_SMOOTH); + +/* glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); */ +/* glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); */ + + theTexCube = glGenLists(1); + glNewList(theTexCube, GL_COMPILE); + + /* Choose the texture to use */ + glBindTexture(GL_TEXTURE_2D, texture[0]); + + /* Begin drawing a cube */ + glBegin(GL_QUADS); + + /* Front face (note that the texture's corners have to match the + quad's corners) */ + + /* Bottom left of the texture and quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + + /* Back Face */ + + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + + /* Bottom Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + + + /* Top Face */ + + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + + /* Bottom Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + + /* Bottom Face */ + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + + /* Bottom Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + + + /* Right face */ + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + + /* Bottom Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + + + /* Left Face */ + /* Bottom Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + + glEnd(); /* done with the polygon */ + glEndList(); + + glMatrixMode(GL_PROJECTION); + /* Reset the projection matrix */ + glLoadIdentity(); + /* Calculate the aspect ratio of the window */ + gluPerspective(45.0f, (GLfloat) width / (GLfloat) height, 0.1f, 100.0f); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + } + +UGL_LOCAL void drawGL() + { + glClear(GL_COLOR_BUFFER_BIT); + + /* Reset The View */ + glPushMatrix(); + + /* Move 8 units into the screen */ + glTranslatef(0.0f, 0.0f, -8.0f); + + /* Rotate on the X axis */ + glRotatef(xrot, 1.0f, 0.0f, 0.0f); + + /* Rotate on the Y axis */ + glRotatef(yrot, 0.0f, 1.0f, 0.0f); + + /* Rotate On The Z Axis */ + glRotatef(zrot, 0.0f, 0.0f, 1.0f); + + glCallList(theTexCube); + + glFlush(); + + uglMesaSwapBuffers(); + + glPopMatrix(); + + xrot += 1.6f; + yrot += 1.6f; + zrot += 1.6f; +} + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +UGL_LOCAL void cleanUp (void) + { + if (eventServiceId != UGL_NULL) + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + } + +void windMLTexCube (void); + +void ugltexcube (void) + { + taskSpawn("tTexCube", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTexCube, + 0,1,2,3,4,5,6,7,8,9); + } + + +void windMLTexCube(void) + { + GLuint width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, + (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK) + { + qId = uglEventQCreate (eventServiceId, 100); + } + else + { + eventServiceId = UGL_NULL; + } + + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + uglMesaMakeCurrentContext(umc, 0, 0, + UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL(width, height); + + while(!getEvent()) + drawGL(); + + cleanUp(); + + return; + } + + diff --git a/progs/windml/ugltexcyl.c b/progs/windml/ugltexcyl.c new file mode 100644 index 00000000000..d83c20b2f38 --- /dev/null +++ b/progs/windml/ugltexcyl.c @@ -0,0 +1,399 @@ +/* + * Textured cylinder demo: lighting, texturing, reflection mapping. + * + * Brian Paul May 1997 This program is in the public domain. + * + * Conversion to UGL/Mesa by Stephane Raimbault + */ + +/* + * $Log: ugltexcyl.c,v $ + * Revision 1.1 2001/08/20 16:07:11 brianp + * WindML driver (Stephane Raimbault) + * + * Revision 1.5 2001/03/27 17:35:26 brianp + * set initial window pos + * + * Revision 1.4 2000/12/24 22:53:54 pesco + * * demos/Makefile.am (INCLUDES): Added -I$(top_srcdir)/util. + * * demos/Makefile.X11, demos/Makefile.BeOS-R4, demos/Makefile.cygnus: + * Essentially the same. + * Program files updated to include "readtex.c", not "../util/readtex.c". + * * demos/reflect.c: Likewise for "showbuffer.c". + * + * + * * Makefile.am (EXTRA_DIST): Added top-level regular files. + * + * * include/GL/Makefile.am (INC_X11): Added glxext.h. + * + * + * * src/GGI/include/ggi/mesa/Makefile.am (EXTRA_HEADERS): Include + * Mesa GGI headers in dist even if HAVE_GGI is not given. + * + * * configure.in: Look for GLUT and demo source dirs in $srcdir. + * + * * src/swrast/Makefile.am (libMesaSwrast_la_SOURCES): Set to *.[ch]. + * More source list updates in various Makefile.am's. + * + * * Makefile.am (dist-hook): Remove CVS directory from distribution. + * (DIST_SUBDIRS): List all possible subdirs here. + * (SUBDIRS): Only list subdirs selected for build again. + * The above two applied to all subdir Makefile.am's also. + * + * Revision 1.3 2000/09/29 23:09:39 brianp + * added fps output + * + * Revision 1.2 1999/10/21 16:39:06 brianp + * added -info command line option + * + * Revision 1.1.1.1 1999/08/19 00:55:40 jtg + * Imported sources + * + * Revision 3.3 1999/03/28 18:24:37 brianp + * minor clean-up + * + * Revision 3.2 1998/11/05 04:34:04 brianp + * moved image files to ../images/ directory + * + * Revision 3.1 1998/06/23 03:16:51 brianp + * added Point/Linear sampling menu items + * + * Revision 3.0 1998/02/14 18:42:29 brianp + * initial rev + * + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "../util/readtex.h" + +#define TEXTURE_FILE "Mesa/images/reflect.rgb" + +#define LIT 1 +#define TEXTURED 2 +#define REFLECT 3 +#define ANIMATE 10 +#define POINT_FILTER 20 +#define LINEAR_FILTER 21 +#define QUIT 100 +#define COUNT_FRAMES + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL volatile UGL_BOOL stopWex; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL GLuint CylinderObj; +UGL_LOCAL GLboolean Animate; +UGL_LOCAL GLboolean linearFilter; + +UGL_LOCAL GLfloat Xrot, Yrot, Zrot; +UGL_LOCAL GLfloat DXrot, DYrot; + +UGL_LOCAL GLuint limit; +UGL_LOCAL GLuint count; +UGL_LOCAL GLuint tickStart, tickStop, tickBySec; + +UGL_LOCAL void cleanUp (void); + +UGL_LOCAL void drawGL(void) + { +#ifdef COUNT_FRAMES + int time; +#endif + + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glScalef(5.0, 5.0, 5.0); + glCallList(CylinderObj); + + glPopMatrix(); + + uglMesaSwapBuffers(); + + if (Animate) + { + Xrot += DXrot; + Yrot += DYrot; + } + +#ifdef COUNT_FRAMES + if (count > limit) + { + tickStop = tickGet (); + time = (tickStop-tickStart)/tickBySec; + printf (" %i fps\n", count/time); + tickStart = tickStop; + count = 0; + } + else + count++; +#endif + + } + +UGL_LOCAL void echoUse(void) + { + printf("Keys:\n"); + printf(" Up/Down Rotate on Y\n"); + printf(" Left/Right Rotate on X\n"); + printf(" a Toggle animation\n"); + printf(" f Toggle point/linear filtered\n"); + printf(" l Lit\n"); + printf(" t Textured\n"); + printf(" r Reflect\n"); + printf(" ESC Exit\n"); + } + +UGL_LOCAL void readKey(UGL_WCHAR key) + { + float step = 3.0; + switch (key) + { + case 'a': + Animate = !Animate; + break; + case 'f': + if(linearFilter) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + GL_NEAREST); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + GL_LINEAR); + } + linearFilter = !linearFilter; + break; + case 'l': + glEnable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + break; + case 't': + glDisable(GL_LIGHTING); + glEnable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + break; + case 'r': + glDisable(GL_LIGHTING); + glEnable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + break; + case UGL_UNI_UP_ARROW: + Xrot += step; + break; + case UGL_UNI_DOWN_ARROW: + Xrot -= step; + break; + case UGL_UNI_LEFT_ARROW: + Yrot += step; + break; + case UGL_UNI_RIGHT_ARROW: + Yrot -= step; + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +UGL_LOCAL void initGL(void) + { + GLUquadricObj *q = gluNewQuadric(); + CylinderObj = glGenLists(1); + glNewList(CylinderObj, GL_COMPILE); + + glTranslatef(0.0, 0.0, -1.0); + + /* cylinder */ + gluQuadricNormals(q, GL_SMOOTH); + gluQuadricTexture(q, GL_TRUE); + gluCylinder(q, 0.6, 0.6, 2.0, 24, 1); + + /* end cap */ + glTranslatef(0.0, 0.0, 2.0); + gluDisk(q, 0.0, 0.6, 24, 1); + + /* other end cap */ + glTranslatef(0.0, 0.0, -2.0); + gluQuadricOrientation(q, GLU_INSIDE); + gluDisk(q, 0.0, 0.6, 24, 1); + + glEndList(); + gluDeleteQuadric(q); + + /* lighting */ + glEnable(GL_LIGHTING); + { + GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0}; + GLfloat white[4] = {1.0, 1.0, 1.0, 1.0}; + GLfloat teal[4] = { 0.0, 1.0, 0.8, 1.0 }; + glMaterialfv(GL_FRONT, GL_DIFFUSE, teal); + glLightfv(GL_LIGHT0, GL_AMBIENT, gray); + glLightfv(GL_LIGHT0, GL_DIFFUSE, white); + glEnable(GL_LIGHT0); + } + + /* fitering = nearest, initially */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) + { + printf("Error: couldn't load texture image\n"); + cleanUp(); + exit(1); + } + + glEnable(GL_CULL_FACE); /* don't need Z testing for convex objects */ + + glEnable(GL_LIGHTING); + + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 ); + 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)); + printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); + +#ifdef COUNT_FRAMES + tickStart = tickGet (); + tickBySec = sysClkRateGet (); +#endif + + } + +UGL_LOCAL void cleanUp (void) + { + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize (); + } + +void windMLTexCyl (void); + +void ugltexcyl (void) + { + taskSpawn ("tTexCyl", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTexCyl, + 0,1,2,3,4,5,6,7,8,9); + } + +void windMLTexCyl (void) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + GLsizei displayWidth, displayHeight; + GLsizei x, y, w, h; + + CylinderObj = 0; + Animate = GL_TRUE; + linearFilter = GL_FALSE; + Xrot = 0.0; + Yrot = 0.0; + Zrot = 0.0; + DXrot = 1.0; + DYrot = 2.5; + limit = 100; + count = 1; + + uglInitialize (); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, + (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + /* Double buffering */ + umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL); + if (umc == NULL) + { + uglDeinitialize (); + return; + } + + uglMesaMakeCurrentContext (umc, 0, 0, 1, 1); + + uglMesaGetIntegerv(UGL_MESA_DISPLAY_WIDTH, &displayWidth); + uglMesaGetIntegerv(UGL_MESA_DISPLAY_HEIGHT, &displayHeight); + + h = (displayHeight*3)/4; + w = h; + x = (displayWidth-w)/2; + y = (displayHeight-h)/2; + + uglMesaMoveToWindow(x, y); + uglMesaResizeToWindow(w, h); + + initGL (); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + cleanUp(); + + return; + } + diff --git a/progs/windml/wrs_logo.bmp b/progs/windml/wrs_logo.bmp new file mode 100644 index 0000000000000000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000000000..fc189bd8047 --- /dev/null +++ b/src/glu/mesa/Makefile.ugl @@ -0,0 +1,96 @@ +# Mesa 3-D graphics library +# Version: 3.5 +# +# Copyright (C) 2001 Wind River Systems, Inc + +# The MIT License +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +# Makefile for GLU library + +##### MACROS ##### +GLU_MAJOR = 1 +GLU_MINOR = 3 +GLU_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY) + +##### RULES ##### + +include ../rules.windml + +GLU_SOURCES = \ + glu.c \ + mipmap.c \ + nurbs.c \ + nurbscrv.c \ + nurbssrf.c \ + nurbsutl.c \ + polytest.c \ + project.c \ + quadric.c \ + tess.c \ + tesselat.c \ + ../src/windml/tornado/torMesaGLUInit.c + +GLU_OBJECTS = $(GLU_SOURCES:.c=.o) +GLU_OBJNAME = $(MESA_LIBDIR)/objMesaGLU.o + +SOURCES = $(GLU_SOURCES) + +##### TARGETS ##### + +all: depend.$(CPU)$(TOOL) $(GLU_OBJNAME) + +# Make the GLU library +$(GLU_OBJNAME): $(GLU_OBJECTS) +# $(LD) -r $(GLU_OBJECTS) -o $(MESA_OBJNAME) + $(LD) -r $(GLU_OBJECTS) -o $(GLU_OBJNAME) +# $(AR) rus $(MESA_LIBNAME) $(GLU_OBJNAME) +# $(AR) rus $(VX_LIBNAME) $(GLU_OBJNAME) + +depend.$(CPU)$(TOOL): +ifeq ($(WIND_HOST_TYPE),x86-win32) + @ $(RM) $@ + @ $(ECHO) Creating depend.$(CPU)$(TOOL) +ifneq ($(SOURCES),) + @ for %f in ($(SOURCES)) do \ + $(CC) -MM $(CFLAGS) %f >>$@ +endif +else +Makefile + @ $(RM) $@ + @ $(ECHO) "Creating depend.$(CPU)$(TOOL)" +ifneq ($(SOURCES),) + @ for FILE in $(filter-out $(NODEPENDOBJS), $(SOURCES)); \ + do \ + $(CC) -MM $(CFLAGS) $$FILE \ + | $(TCL) $(BIN_DIR)/depend.tcl $(TGT_DIR) >>$@; \ + done +endif +endif + +.PHONY = clean + +clean: +# $(AR) d $(MESA_LIBNAME) $(GLU_OBJNAME) +# $(AR) d $(VX_LIBNAME) $(GLU_OBJNAME) + $(RM) $(GLU_OBJNAME) + $(RM) $(GLU_OBJECTS) + $(RM) depend.$(CPU)$(TOOL) + +include depend.$(CPU)$(TOOL) diff --git a/src/mesa/main/Makefile.ugl b/src/mesa/main/Makefile.ugl new file mode 100644 index 00000000000..2dcca3c2155 --- /dev/null +++ b/src/mesa/main/Makefile.ugl @@ -0,0 +1,367 @@ +# Mesa 3-D graphics library +# Version: 3.5 +# +# Copyright (C) 2001 Wind River Systems, Inc + +# The MIT License +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +# Makefile for core library + +# This makefile can moved all objects files in MESA_OBJ for use with +# ld in windShell or create a library from objects files in their +# associated .c folder. +# +# For an easy inclusion of lib$(CPU)$(TOOL)GL.a in vxworks image, this +# makefile collects together all .o in an only file +# (obj$(CPU)$(TOOL)GL.o). This operation is unnecessary for +# lib$(CPU)$(TOOL)OSMesa.a and lib$(CPU)$(TOOL)UglMesa.a because they +# already contain only one file. +# +##### MACROS ##### +MESA_MAJOR=3 +MESA_MINOR=5 +MESA_TINY=0 +VERSION=$(MESA_MAJOR).$(MESA_MINOR) + +GL_MAJOR = 1 +GL_MINOR = 2 +GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY) + +##### RULES ##### + +include ..\rules.windml + +#### GL ##### + +GL_SOURCES = \ + api_arrayelt.c \ + api_loopback.c \ + api_noop.c \ + api_validate.c \ + accum.c \ + attrib.c \ + blend.c \ + buffers.c \ + clip.c \ + colortab.c \ + config.c \ + context.c \ + convolve.c \ + debug.c \ + depth.c \ + dispatch.c \ + dlist.c \ + drawpix.c \ + enable.c \ + enums.c \ + eval.c \ + extensions.c \ + feedback.c \ + fog.c \ + get.c \ + glapi.c \ + glthread.c \ + hash.c \ + hint.c \ + histogram.c \ + image.c \ + imports.c \ + light.c \ + lines.c \ + matrix.c \ + mem.c \ + mmath.c \ + pixel.c \ + points.c \ + polygon.c \ + rastpos.c \ + state.c \ + stencil.c \ + texformat.c \ + teximage.c \ + texobj.c \ + texstate.c \ + texstore.c \ + texutil.c \ + varray.c \ + vtxfmt.c \ + X86/x86.c \ + X86/common_x86.c \ + X86/3dnow.c \ + X86/sse.c \ + math/m_debug_clip.c \ + math/m_debug_norm.c \ + math/m_debug_vertex.c \ + math/m_debug_xform.c \ + math/m_eval.c \ + math/m_matrix.c \ + math/m_translate.c \ + math/m_vector.c \ + math/m_vertices.c \ + math/m_xform.c \ + array_cache/ac_context.c \ + array_cache/ac_import.c \ + swrast/s_aaline.c \ + swrast/s_aatriangle.c \ + swrast/s_accum.c \ + swrast/s_alpha.c \ + swrast/s_alphabuf.c \ + swrast/s_bitmap.c \ + swrast/s_blend.c \ + swrast/s_buffers.c \ + swrast/s_copypix.c \ + swrast/s_context.c \ + swrast/s_depth.c \ + swrast/s_drawpix.c \ + swrast/s_feedback.c \ + swrast/s_fog.c \ + swrast/s_histogram.c \ + swrast/s_imaging.c \ + swrast/s_lines.c \ + swrast/s_logic.c \ + swrast/s_masking.c \ + swrast/s_pb.c \ + swrast/s_pixeltex.c \ + swrast/s_points.c \ + swrast/s_readpix.c \ + swrast/s_scissor.c \ + swrast/s_span.c \ + swrast/s_stencil.c \ + swrast/s_texture.c \ + swrast/s_texstore.c \ + swrast/s_triangle.c \ + swrast/s_zoom.c \ + swrast_setup/ss_context.c \ + swrast_setup/ss_triangle.c \ + swrast_setup/ss_vb.c \ + tnl/t_array_api.c \ + tnl/t_array_import.c \ + tnl/t_context.c \ + tnl/t_eval_api.c \ + tnl/t_imm_alloc.c \ + tnl/t_imm_api.c \ + tnl/t_imm_debug.c \ + tnl/t_imm_dlist.c \ + tnl/t_imm_elt.c \ + tnl/t_imm_eval.c \ + tnl/t_imm_exec.c \ + tnl/t_imm_fixup.c \ + tnl/t_pipeline.c \ + tnl/t_vb_fog.c \ + tnl/t_vb_light.c \ + tnl/t_vb_normals.c \ + tnl/t_vb_points.c \ + tnl/t_vb_render.c \ + tnl/t_vb_texgen.c \ + tnl/t_vb_texmat.c \ + tnl/t_vb_vertex.c + +GL_OBJECTS = $(GL_SOURCES:.c=.o) +GL_OBJNAME = $(MESA_LIBDIR)/objMesaGL.o + +#### X86 ##### + +x86_files = \ + X86/common_x86_asm.S \ + X86/glapi_x86.S \ + X86/x86_cliptest.S \ + X86/x86_vertex.S \ + X86/x86_xform2.S \ + X86/x86_xform3.S \ + X86/x86_xform4.S \ + +x3dnow_files = \ + X86/3dnow_normal.S \ + X86/3dnow_vertex.S \ + X86/3dnow_xform1.S \ + X86/3dnow_xform2.S \ + X86/3dnow_xform3.S \ + X86/3dnow_xform4.S + +sse_files = \ + X86/sse_normal.S \ + X86/sse_vertex.S \ + X86/sse_xform1.S \ + X86/sse_xform2.S \ + X86/sse_xform3.S \ + X86/sse_xform4.S + +mmx_files = X86/mmx_blend.S + +X86_OBJNAME = $(MESA_LIBDIR)/objMesaX86.o + +##### UGL ##### + +UGL_SOURCES = \ + windml/ugl_api.c \ + windml/ugl_dd.c \ + windml/ugl_span.c \ + windml/ugl_line.c \ + windml/ugl_tri.c \ + windml/tornado/torMesaUGLInit.c + +UGL_OBJECTS = $(UGL_SOURCES:.c=.o) +UGL_OBJNAME = $(MESA_LIBDIR)/objMesaUGL.o + +##### OS ##### + +OS_SOURCES = OSmesa/osmesa.c windml/tornado/torMesaOSInit.c +OS_OBJECTS = $(OS_SOURCES:.c=.o) +OS_OBJNAME = $(MESA_LIBDIR)/objMesaOS.o + +##### GLUTSHAPES ##### + +GLUTSHAPES_SOURCES = \ + windml/ugl_glutshapes.c \ + windml/tornado/torGLUTShapesInit.c + +GLUTSHAPES_OBJECTS = $(GLUTSHAPES_SOURCES:.c=.o) +GLUTSHAPES_OBJNAME = $(MESA_LIBDIR)/objGLUTShapes.o + +SOURCES = $(GL_SOURCES) $(UGL_SOURCES) $(OS_SOURCES) \ + $(GLUTSHAPES_SOURCES) + +##### TARGETS ##### + +all: depend.$(CPU)$(TOOL) cfgX86 $(X86_OBJNAME) $(GL_OBJNAME)\ +$(UGL_OBJNAME) $(OS_OBJNAME) $(GLUTSHAPES_OBJNAME) + +#histogram.o: +# $(CC) $(CFLAGS) -O1 $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME)$@ $< + +#image.o: +# $(CC) $(CFLAGS) -O1 $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME)$@ $< + +cfgX86: +ifdef HAVE_3DNOW +x3dnow_sources = $(x3dnow_files) +CFLAGS_3DNOW = -DUSE_3DNOW_ASM +HAVE_X86 = 1 +endif +ifdef HAVE_SSE +sse_sources = $(sse_files) +CFLAGS_SSE = -DUSE_SSE_ASM +HAVE_X86 = 1 +endif +ifdef HAVE_MMX +mmx_sources = $(mmx_files) +CFLAGS_MMX = -DUSE_MMX_ASM +HAVE_X86 = 1 +endif +ifdef HAVE_X86 +x86_sources = $(x86_files) +CFLAGS_X86 = -DUSE_X86_ASM +endif +X86_SOURCES = $(x86_sources) $(mmx_sources) \ + $(x3dnow_sources) $(sse_sources) +X86_OBJECTS = $(X86_SOURCES:.S=.o) +CFLAGS_USE_X86 = $(CFLAGS_3DNOW) $(CFLAGS_SSE) $(CFLAGS_MMX) $(CFLAGS_X86) + +#X86/matypes.h: mtypes.h tnl/t_context.h X86/gen_matypes.c +# $(CC) -I ./ X86/gen_matypes.c -o X86/gen_matypes +# ./X86/gen_matypes > X86/matypes.h +# $(RM) X86/gen_matypes +# $(RM) X86/gen_matypes.o + +# Make the Mesax86 library +$(X86_OBJNAME): $(X86_OBJECTS) +ifdef HAVE_X86 +# $(LD) -r $(X86_OBJECTS) -o $(MESA_OBJNAME) + $(LD) -r $(X86_OBJECTS) -o $(X86_OBJNAME) +# $(AR) rus $(MESA_LIBNAME) $(X86_OBJNAME) +# $(RM) $(X86_OBJNAME) +endif + +# Make the GL library +$(GL_OBJNAME): $(GL_OBJECTS) +# $(LD) -r $(GL_OBJECTS) -o $(MESA_OBJNAME) + $(LD) -r $(GL_OBJECTS) -o $(GL_OBJNAME) +# $(AR) rus $(MESA_LIBNAME) $(GL_OBJNAME) +# $(AR) rus $(VX_LIBNAME) $(GL_OBJNAME) +# $(RM) $(GL_OBJNAME) + +# Make the UGLMesa library +$(UGL_OBJNAME): $(UGL_OBJECTS) +# $(LD) -r $(UGL_OBJECTS) -o $(MESA_OBJNAME) + $(LD) -r $(UGL_OBJECTS) -o $(UGL_OBJNAME) +# $(AR) rus $(MESA_LIBNAME) $(UGL_OBJNAME) +# $(AR) rus $(VX_LIBNAME) $(UGL_OBJNAME) +# $(RM) $(UGL_OBJNAME) + +# Make the OSMesa library +$(OS_OBJNAME): $(OS_OBJECTS) +# $(LD) -r $(OS_OBJECTS) -o $(MESA_OBJNAME) + $(LD) -r $(OS_OBJECTS) -o $(OS_OBJNAME) +# $(AR) rus $(MESA_LIBNAME) $(OS_OBJNAME) +# $(AR) rus $(VX_LIBNAME) $(OS_OBJNAME) +# $(RM) $(OS_OBJNAME) + +# Make the GLUT Shapes library +$(GLUTSHAPES_OBJNAME): $(GLUTSHAPES_OBJECTS) +# $(LD) -r $(GLUTSHAPES_OBJECTS) -o $(MESA_OBJNAME) + $(LD) -r $(GLUTSHAPES_OBJECTS) -o $(GLUTSHAPES_OBJNAME) +# $(AR) rus $(MESA_LIBNAME) $(GLUTSHAPES_OBJNAME) +# $(AR) rus $(VX_LIBNAME) $(GLUTSHAPES_OBJNAME) +# $(RM) $(GLUTSHAPES_OBJNAME) + +depend.$(CPU)$(TOOL): +ifeq ($(WIND_HOST_TYPE),x86-win32) + @ $(RM) $@ + @ $(ECHO) Creating depend.$(CPU)$(TOOL) +ifneq ($(SOURCES),) + @ for %f in ($(SOURCES)) do \ + $(CC) -MM $(CFLAGS) %f >>$@ +endif +else +Makefile + @ $(RM) $@ + @ $(ECHO) "Creating depend.$(CPU)$(TOOL)" +ifneq ($(SOURCES),) + @ for FILE in $(filter-out $(NODEPENDOBJS), $(SOURCES)); \ + do \ + $(CC) -MM $(CFLAGS) $$FILE \ + | $(TCL) $(BIN_DIR)/depend.tcl $(TGT_DIR) >>$@; \ + done +endif +endif + +.PHONY = clean + +clean: +# $(AR) d $(MESA_LIBNAME) $(GL_OBJNAME) +# $(AR) d $(MESA_LIBNAME) $(UGL_OBJNAME) +# $(AR) d $(MESA_LIBNAME) $(OS_OBJNAME) +# $(AR) d $(MESA_LIBNAME) $(GLUTSHAPES_OBJNAME) +# $(AR) d $(VX_LIBNAME) $(GL_OBJNAME) +# $(AR) d $(VX_LIBNAME) $(UGL_OBJNAME) +# $(AR) d $(VX_LIBNAME) $(OS_OBJNAME) +# $(AR) d $(VX_LIBNAME) $(GLUTSHAPES_OBJNAME) + $(RM) $(GL_OBJECTS) + $(RM) $(UGL_OBJECTS) + $(RM) $(OS_OBJECTS) + $(RM) $(GLUTSHAPES_OBJECTS) + $(RM) $(GL_OBJNAME) + $(RM) $(UGL_OBJNAME) + $(RM) $(OS_OBJNAME) + $(RM) $(GLUTSHAPES_OBJNAME) + $(RM) depend.$(CPU)$(TOOL) + +include depend.$(CPU)$(TOOL) + -- 2.30.2