Clone of mesa.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

polygon.c 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /* $Id: polygon.c,v 1.6 1999/11/08 15:28:08 brianp Exp $ */
  2. /*
  3. * Mesa 3-D graphics library
  4. * Version: 3.1
  5. *
  6. * Copyright (C) 1999 Brian Paul All Rights Reserved.
  7. *
  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. * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  22. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. */
  25. /* $XFree86: xc/lib/GL/mesa/src/polygon.c,v 1.3 1999/04/04 00:20:29 dawes Exp $ */
  26. #ifdef PC_HEADER
  27. #include "all.h"
  28. #else
  29. #ifndef XFree86Server
  30. #include <assert.h>
  31. #include <stdlib.h>
  32. #include <stdio.h>
  33. #include <string.h>
  34. #else
  35. #include "GL/xf86glx.h"
  36. #endif
  37. #include "context.h"
  38. #include "image.h"
  39. #include "enums.h"
  40. #include "macros.h"
  41. #include "polygon.h"
  42. #include "types.h"
  43. #endif
  44. void gl_CullFace( GLcontext *ctx, GLenum mode )
  45. {
  46. ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCullFace");
  47. if (MESA_VERBOSE&VERBOSE_API)
  48. fprintf(stderr, "glCullFace %s\n", gl_lookup_enum_by_nr(mode));
  49. if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) {
  50. gl_error( ctx, GL_INVALID_ENUM, "glCullFace" );
  51. return;
  52. }
  53. ctx->Polygon.CullFaceMode = mode;
  54. ctx->NewState |= NEW_POLYGON;
  55. if (ctx->Driver.CullFace)
  56. ctx->Driver.CullFace( ctx, mode );
  57. }
  58. void gl_FrontFace( GLcontext *ctx, GLenum mode )
  59. {
  60. ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glFrontFace");
  61. if (MESA_VERBOSE&VERBOSE_API)
  62. fprintf(stderr, "glFrontFace %s\n", gl_lookup_enum_by_nr(mode));
  63. if (mode!=GL_CW && mode!=GL_CCW) {
  64. gl_error( ctx, GL_INVALID_ENUM, "glFrontFace" );
  65. return;
  66. }
  67. ctx->Polygon.FrontFace = mode;
  68. ctx->Polygon.FrontBit = (GLboolean) (mode == GL_CW);
  69. ctx->NewState |= NEW_POLYGON;
  70. if (ctx->Driver.FrontFace)
  71. ctx->Driver.FrontFace( ctx, mode );
  72. }
  73. void gl_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
  74. {
  75. ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonMode");
  76. if (MESA_VERBOSE&VERBOSE_API)
  77. fprintf(stderr, "glPolygonMode %s %s\n",
  78. gl_lookup_enum_by_nr(face),
  79. gl_lookup_enum_by_nr(mode));
  80. if (face!=GL_FRONT && face!=GL_BACK && face!=GL_FRONT_AND_BACK) {
  81. gl_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
  82. return;
  83. }
  84. else if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) {
  85. gl_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" );
  86. return;
  87. }
  88. if (face==GL_FRONT || face==GL_FRONT_AND_BACK) {
  89. ctx->Polygon.FrontMode = mode;
  90. }
  91. if (face==GL_BACK || face==GL_FRONT_AND_BACK) {
  92. ctx->Polygon.BackMode = mode;
  93. }
  94. /* Compute a handy "shortcut" value: */
  95. ctx->TriangleCaps &= ~DD_TRI_UNFILLED;
  96. ctx->Polygon.Unfilled = GL_FALSE;
  97. if (ctx->Polygon.FrontMode!=GL_FILL || ctx->Polygon.BackMode!=GL_FILL) {
  98. ctx->Polygon.Unfilled = GL_TRUE;
  99. ctx->TriangleCaps |= DD_TRI_UNFILLED;
  100. }
  101. ctx->NewState |= (NEW_POLYGON | NEW_RASTER_OPS);
  102. if (ctx->Driver.PolygonMode) {
  103. (*ctx->Driver.PolygonMode)( ctx, face, mode );
  104. }
  105. }
  106. /*
  107. * NOTE: stipple pattern has already been unpacked.
  108. */
  109. void gl_PolygonStipple( GLcontext *ctx, const GLuint pattern[32] )
  110. {
  111. ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonStipple");
  112. if (MESA_VERBOSE&VERBOSE_API)
  113. fprintf(stderr, "glPolygonStipple\n");
  114. MEMCPY( ctx->PolygonStipple, pattern, 32 * 4 );
  115. if (ctx->Polygon.StippleFlag) {
  116. ctx->NewState |= NEW_RASTER_OPS;
  117. }
  118. }
  119. void gl_GetPolygonStipple( GLcontext *ctx, GLubyte *dest )
  120. {
  121. ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonOffset");
  122. if (MESA_VERBOSE&VERBOSE_API)
  123. fprintf(stderr, "glGetPolygonStipple\n");
  124. gl_pack_polygon_stipple( ctx, ctx->PolygonStipple, dest );
  125. }
  126. void gl_PolygonOffset( GLcontext *ctx,
  127. GLfloat factor, GLfloat units )
  128. {
  129. ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonOffset");
  130. if (MESA_VERBOSE&VERBOSE_API)
  131. fprintf(stderr, "glPolygonOffset %f %f\n", factor, units);
  132. ctx->Polygon.OffsetFactor = factor;
  133. ctx->Polygon.OffsetUnits = units;
  134. }