Clone of mesa.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

uglalldemos.c 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /* uglalldemos.c - WindML/Mesa example program */
  2. /* Copyright (C) 2001 by Wind River Systems, Inc */
  3. /*
  4. * Mesa 3-D graphics library
  5. * Version: 3.5
  6. *
  7. * The MIT License
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the "Software"),
  10. * to deal in the Software without restriction, including without limitation
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. * and/or sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included
  16. * in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  21. * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  23. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  24. * DEALINGS IN THE SOFTWARE.
  25. */
  26. /*
  27. modification history
  28. --------------------
  29. 02a,29aug01,sra WindML mode added
  30. 01a,17jul01,sra written
  31. */
  32. /*
  33. DESCRIPTION
  34. Show all the UGL/Mesa demos
  35. */
  36. #include <stdio.h>
  37. #include <vxWorks.h>
  38. #include <taskLib.h>
  39. #include <ugl/ugl.h>
  40. #include <ugl/uglinput.h>
  41. #include <ugl/uglevent.h>
  42. #include <ugl/uglfont.h>
  43. #define BLACK 0
  44. #define RED 1
  45. struct _colorStruct
  46. {
  47. UGL_RGB rgbColor;
  48. UGL_COLOR uglColor;
  49. }
  50. colorTable[] =
  51. {
  52. { UGL_MAKE_RGB(0, 0, 0), 0},
  53. { UGL_MAKE_RGB(255, 0, 0), 0},
  54. };
  55. void windMLPoint (UGL_BOOL windMLMode);
  56. void windMLLine (UGL_BOOL windMLMode);
  57. void windMLFlip (UGL_BOOL windMLMode);
  58. void windMLCube (UGL_BOOL windMLMode);
  59. void windMLBounce (UGL_BOOL windMLMode);
  60. void windMLGears (UGL_BOOL windMLMode);
  61. void windMLIcoTorus (UGL_BOOL windMLMode);
  62. void windMLOlympic (UGL_BOOL windMLMode);
  63. void windMLTexCube (UGL_BOOL windMLMode);
  64. void windMLTexCyl (UGL_BOOL windMLMode);
  65. void windMLTeapot (UGL_BOOL windMLMode);
  66. void windMLStencil (UGL_BOOL windMLMode);
  67. void windMLDrawPix (UGL_BOOL windMLMode);
  68. void windMLAccum (UGL_BOOL windMLMode);
  69. void windMLAllDemos (void);
  70. void uglalldemos (void)
  71. {
  72. taskSpawn("tAllDemos", 210, VX_FP_TASK, 200000,
  73. (FUNCPTR)windMLAllDemos, 0,1,2,3,4,5,6,7,8,9);
  74. }
  75. void windMLAllDemos(void)
  76. {
  77. UGL_BOOL windMLFlag = UGL_FALSE;
  78. UGL_FB_INFO fbInfo;
  79. UGL_EVENT event;
  80. UGL_EVENT_SERVICE_ID eventServiceId;
  81. UGL_EVENT_Q_ID qId;
  82. UGL_INPUT_EVENT * pInputEvent;
  83. UGL_INPUT_DEVICE_ID keyboardDevId;
  84. UGL_DEVICE_ID devId;
  85. UGL_GC_ID gc;
  86. UGL_FONT_ID fontId;
  87. UGL_FONT_DEF fontDef;
  88. UGL_FONT_DRIVER_ID fontDrvId;
  89. UGL_ORD textOrigin = UGL_FONT_TEXT_UPPER_LEFT;
  90. int displayHeight, displayWidth;
  91. int textWidth, textHeight;
  92. static UGL_CHAR * message =
  93. "Do you want to use WindML exclusively ? (y/n) ";
  94. uglInitialize();
  95. uglDriverFind (UGL_DISPLAY_TYPE, 0, (UGL_UINT32 *)&devId);
  96. uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
  97. uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
  98. qId = uglEventQCreate (eventServiceId, 100);
  99. gc = uglGcCreate(devId);
  100. uglDriverFind (UGL_FONT_ENGINE_TYPE, 0, (UGL_UINT32 *)&fontDrvId);
  101. uglFontDriverInfo(fontDrvId, UGL_FONT_TEXT_ORIGIN, &textOrigin);
  102. uglFontFindString(fontDrvId, "familyName=Helvetica; pixelSize = 18",
  103. &fontDef);
  104. if ((fontId = uglFontCreate(fontDrvId, &fontDef)) == UGL_NULL)
  105. {
  106. printf("Font not found. Exiting.\n");
  107. return;
  108. }
  109. uglInfo(devId, UGL_FB_INFO_REQ, &fbInfo);
  110. displayWidth = fbInfo.width;
  111. displayHeight = fbInfo.height;
  112. uglColorAlloc (devId, &colorTable[BLACK].rgbColor, UGL_NULL,
  113. &colorTable[BLACK].uglColor, 1);
  114. uglColorAlloc(devId, &colorTable[RED].rgbColor, UGL_NULL,
  115. &colorTable[RED].uglColor, 1);
  116. uglBackgroundColorSet(gc, colorTable[BLACK].uglColor);
  117. uglForegroundColorSet(gc, colorTable[RED].uglColor);
  118. uglFontSet(gc, fontId);
  119. uglTextSizeGet(fontId, &textWidth, &textHeight, -1, message);
  120. uglTextDraw(gc, (displayWidth - textWidth) / 2,
  121. (displayHeight - textHeight) / 2 - textHeight, -1, message);
  122. /* flushQ();
  123. */
  124. if (uglEventGet (qId, &event, sizeof (event), UGL_WAIT_FOREVER)
  125. != UGL_STATUS_Q_EMPTY)
  126. {
  127. pInputEvent = (UGL_INPUT_EVENT *)&event;
  128. if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD &&
  129. pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
  130. {
  131. switch(pInputEvent->type.keyboard.key)
  132. {
  133. case 'Y':
  134. case 'y':
  135. windMLFlag = UGL_TRUE;
  136. break;
  137. default:
  138. windMLFlag = UGL_FALSE;
  139. }
  140. }
  141. }
  142. uglFontDestroy (fontId);
  143. uglGcDestroy (gc);
  144. uglEventQDestroy (eventServiceId, qId);
  145. uglDeinitialize();
  146. windMLPoint(windMLFlag);
  147. windMLLine(windMLFlag);
  148. windMLFlip(windMLFlag);
  149. windMLCube(windMLFlag);
  150. windMLBounce(windMLFlag);
  151. windMLGears(windMLFlag);
  152. windMLIcoTorus(windMLFlag);
  153. windMLOlympic(windMLFlag);
  154. windMLTexCube(windMLFlag);
  155. windMLTexCyl(windMLFlag);
  156. windMLTeapot(windMLFlag);
  157. windMLStencil(windMLFlag);
  158. windMLDrawPix(windMLFlag);
  159. windMLAccum(windMLFlag);
  160. return;
  161. }