home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / mesa-1.2.8 / src / misc.c < prev    next >
C/C++ Source or Header  |  1996-05-27  |  17KB  |  698 lines

  1. /* $Id: misc.c,v 1.36 1996/05/01 20:46:01 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  1.2
  6.  * Copyright (C) 1995-1996  Brian Paul  (brianp@ssec.wisc.edu)
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25. $Log: misc.c,v $
  26.  * Revision 1.36  1996/05/01  20:46:01  brianp
  27.  * added GL_MESA_window_pos extension code
  28.  *
  29.  * Revision 1.35  1996/04/25  20:45:48  brianp
  30.  * replaced gl_clear_depth_buffer() call with DD.clear_depth_buffer()
  31.  * only call DD.finish and DD.flush if pointers are non-null
  32.  * updated version string to 1.2.8
  33.  *
  34.  * Revision 1.34  1996/03/01  20:04:20  brianp
  35.  * changed gl_error() for glGetString()
  36.  *
  37.  * Revision 1.33  1996/02/19  21:50:00  brianp
  38.  * added support for software alpha buffering
  39.  *
  40.  * Revision 1.32  1996/02/15  16:02:23  brianp
  41.  * added GL_EXT_vertex_array to extensions string
  42.  *
  43.  * Revision 1.31  1996/02/06  03:23:54  brianp
  44.  * removed gamma correction code
  45.  *
  46.  * Revision 1.30  1996/01/22  15:37:30  brianp
  47.  * changed version string to 1.2.6
  48.  * added DD/NeXT work-around, per Michael Johnson
  49.  *
  50.  * Revision 1.29  1996/01/05  01:18:01  brianp
  51.  * added profiling to glClear
  52.  *
  53.  * Revision 1.28  1995/11/30  00:19:19  brianp
  54.  * changed version string to 1.2.5
  55.  *
  56.  * Revision 1.27  1995/11/22  13:35:40  brianp
  57.  * check CC.NewState in glClear
  58.  *
  59.  * Revision 1.26  1995/11/13  22:08:29  brianp
  60.  * removed comma from extensions string
  61.  *
  62.  * Revision 1.25  1995/11/03  17:39:48  brianp
  63.  * removed unused variables
  64.  *
  65.  * Revision 1.24  1995/10/27  20:29:19  brianp
  66.  * added GL_EXT_polygon_offset to extensions string
  67.  *
  68.  * Revision 1.23  1995/10/19  15:48:05  brianp
  69.  * added gamma support
  70.  * changed DD.clear_color arguments to GLubytes
  71.  *
  72.  * Revision 1.22  1995/10/14  16:29:48  brianp
  73.  * new glReadBuffer and glDrawBuffer implementations
  74.  * added glColor/IndexMask support when clearing color buffer
  75.  *
  76.  * Revision 1.21  1995/09/20  18:20:58  brianp
  77.  * prototype device driver changes described
  78.  *
  79.  * Revision 1.20  1995/09/13  14:51:52  brianp
  80.  * moved glGetError to context.c
  81.  *
  82.  * Revision 1.19  1995/09/08  14:08:51  brianp
  83.  * use GL_QUADS instead of GL_POLYGON in glRect functions
  84.  * updated version string to 1.2.3
  85.  *
  86.  * Revision 1.18  1995/07/24  18:55:49  brianp
  87.  * added dd_finish()
  88.  *
  89.  * Revision 1.17  1995/07/18  20:23:58  brianp
  90.  * updated version string for 1.2.2
  91.  *
  92.  * Revision 1.16  1995/06/29  22:10:47  brianp
  93.  * don't call dd_clear_index() when in RGB mode
  94.  * don't call dd_clear_color() when in CI mode
  95.  *
  96.  * Revision 1.15  1995/06/09  21:48:38  brianp
  97.  * changed version string to 1.2.1
  98.  *
  99.  * Revision 1.14  1995/05/24  13:00:15  brianp
  100.  * updated version query functions to return 1.2
  101.  *
  102.  * Revision 1.13  1995/05/22  21:02:41  brianp
  103.  * Release 1.2
  104.  *
  105.  * Revision 1.12  1995/05/17  13:52:37  brianp
  106.  * implemented glIndexMask(0) and glColorMask(0,0,0,0)
  107.  *
  108.  * Revision 1.11  1995/05/12  16:57:22  brianp
  109.  * replaced CC.Mode!=0 with INSIDE_BEGIN_END
  110.  *
  111.  * Revision 1.10  1995/05/12  16:28:41  brianp
  112.  * added const to glGetString prototype
  113.  *
  114.  * Revision 1.9  1995/04/17  14:48:19  brianp
  115.  * updated glGetString for 1.1.4 beta
  116.  *
  117.  * Revision 1.8  1995/03/30  21:08:25  brianp
  118.  * glClear limited to scissor box, not viewport!
  119.  *
  120.  * Revision 1.7  1995/03/13  20:55:59  brianp
  121.  * new read buffer logic
  122.  *
  123.  * Revision 1.6  1995/03/10  16:25:19  brianp
  124.  * updated glGetString for blending extensions
  125.  *
  126.  * Revision 1.5  1995/03/08  15:15:04  brianp
  127.  * removed garbage characters from tail of file
  128.  *
  129.  * Revision 1.4  1995/03/08  15:10:02  brianp
  130.  * added support for dd_clear_index and dd_clear_color
  131.  *
  132.  * Revision 1.3  1995/03/07  14:21:10  brianp
  133.  * updated for new XSetForeground/GC scheme
  134.  *
  135.  * Revision 1.2  1995/03/04  19:29:44  brianp
  136.  * 1.1 beta revision
  137.  *
  138.  * Revision 1.1  1995/02/24  14:24:57  brianp
  139.  * Initial revision
  140.  *
  141.  */
  142.  
  143.  
  144. /*
  145.  * Miscellaneous functions
  146.  */
  147.  
  148.  
  149. #include <stdlib.h>
  150. #include <string.h>
  151. #include "accum.h"
  152. #include "alphabuf.h"
  153. #include "context.h"
  154. #include "depth.h"
  155. #include "dd.h"
  156. #include "list.h"
  157. #include "macros.h"
  158. #include "masking.h"
  159. #include "stencil.h"
  160.  
  161.  
  162.  
  163. /*
  164.  * This is a kludge to get Mesa to work on NeXTs.
  165.  * Contributed by Michael B. Johnson  (wave@welles.ThoughtPort.Net)
  166.  */
  167.  
  168. #ifdef __NeXT__
  169. struct dd_function_table DD;
  170. #endif
  171.  
  172.  
  173.  
  174.  
  175.  
  176. void
  177. glClearIndex( GLfloat c )
  178. {
  179.    if (CC.CompileFlag) {
  180.       gl_save_clearindex( c );
  181.    }
  182.    if (CC.ExecuteFlag) {
  183.       if (INSIDE_BEGIN_END) {
  184.      gl_error( GL_INVALID_OPERATION, "glClearIndex" );
  185.      return;
  186.       }
  187.       CC.Color.ClearIndex = (GLuint) c;
  188.       if (!CC.RGBAflag) {
  189.      /* it's OK to call glClearIndex in RGBA mode but it should be a NOP */
  190.      (*DD.clear_index)( CC.Color.ClearIndex );
  191.       }
  192.    }
  193. }
  194.  
  195.  
  196.  
  197. void
  198. glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
  199. {
  200.    if (CC.CompileFlag) {
  201.       gl_save_clearcolor( red, green, blue, alpha );
  202.    }
  203.    if (CC.ExecuteFlag) {
  204.       if (INSIDE_BEGIN_END) {
  205.      gl_error( GL_INVALID_OPERATION, "glClearColor" );
  206.      return;
  207.       }
  208.  
  209.       CC.Color.ClearColor[0] = CLAMP( red,   0.0F, 1.0F );
  210.       CC.Color.ClearColor[1] = CLAMP( green, 0.0F, 1.0F );
  211.       CC.Color.ClearColor[2] = CLAMP( blue,  0.0F, 1.0F );
  212.       CC.Color.ClearColor[3] = CLAMP( alpha, 0.0F, 1.0F );
  213.  
  214.       if (CC.RGBAflag) {
  215.          GLubyte r = (GLint) (CC.Color.ClearColor[0] * CC.RedScale);
  216.          GLubyte g = (GLint) (CC.Color.ClearColor[1] * CC.GreenScale);
  217.          GLubyte b = (GLint) (CC.Color.ClearColor[2] * CC.BlueScale);
  218.          GLubyte a = (GLint) (CC.Color.ClearColor[3] * CC.AlphaScale);
  219.      (*DD.clear_color)( r, g, b, a );
  220.       }
  221.    }
  222. }
  223.  
  224.  
  225.  
  226.  
  227. /*
  228.  * Clear the color buffer when glColorMask or glIndexMask is in effect.
  229.  */
  230. static void
  231. clear_color_buffer_with_masking( void )
  232. {
  233.    GLint x, y, height, width;
  234.  
  235.    /* Compute region to clear */
  236.    if (CC.Scissor.Enabled) {
  237.       x = CC.Scissor.Xmin;
  238.       y = CC.Scissor.Ymin;
  239.       height = CC.Scissor.Ymax - CC.Scissor.Ymin + 1;
  240.       width = CC.Scissor.Xmax - CC.Scissor.Xmin + 1;
  241.    }
  242.    else {
  243.       x = 0;
  244.       y = 0;
  245.       height = CC.BufferHeight;
  246.       width = CC.BufferWidth;
  247.    }
  248.  
  249.    if (CC.RGBAflag) {
  250.       /* RGBA mode */
  251.       GLubyte red[MAX_WIDTH], green[MAX_WIDTH];
  252.       GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH];
  253.       GLubyte r = CC.Color.ClearColor[0] * CC.RedScale;
  254.       GLubyte g = CC.Color.ClearColor[1] * CC.GreenScale;
  255.       GLubyte b = CC.Color.ClearColor[2] * CC.BlueScale;
  256.       GLubyte a = CC.Color.ClearColor[3] * CC.AlphaScale;
  257.       GLint i;
  258.       for (i=0;i<height;i++,y++) {
  259.          MEMSET( red,   (int) r, width );
  260.          MEMSET( green, (int) g, width );
  261.          MEMSET( blue,  (int) b, width );
  262.          MEMSET( alpha, (int) a, width );
  263.          gl_mask_color_span( width, x, y, red, green, blue, alpha );
  264.          (*DD.write_color_span)( width, x, y, red, green, blue, alpha, NULL );
  265.          if (CC.RasterMask & ALPHABUF_BIT) {
  266.             gl_write_alpha_span( width, x, y, alpha, NULL );
  267.          }
  268.       }
  269.    }
  270.    else {
  271.       /* Color index mode */
  272.       GLuint indx[MAX_WIDTH];
  273.       GLubyte mask[MAX_WIDTH];
  274.       GLint i, j;
  275.       MEMSET( mask, 1, width );
  276.       for (i=0;i<height;i++,y++) {
  277.          for (j=0;j<width;j++) {
  278.             indx[j] = CC.Color.ClearIndex;
  279.          }
  280.          gl_mask_index_span( width, x, y, indx );
  281.          (*DD.write_index_span)( width, x, y, indx, mask );
  282.       }
  283.    }
  284. }
  285.  
  286.  
  287.  
  288.  
  289. void
  290. glClear( GLbitfield mask )
  291. {
  292.    if (CC.CompileFlag) {
  293.       gl_save_clear( mask );
  294.    }
  295.    if (CC.ExecuteFlag) {
  296. #ifdef PROFILE
  297.       GLdouble t0 = gl_time();
  298. #endif
  299.  
  300.       if (INSIDE_BEGIN_END) {
  301.      gl_error( GL_INVALID_OPERATION, "glClear" );
  302.      return;
  303.       }
  304.  
  305.       if (CC.NewState) {
  306.          gl_update_state();
  307.       }
  308.  
  309.       if (mask & GL_DEPTH_BUFFER_BIT) {
  310.      (*DD.clear_depth_buffer)();
  311.       }
  312.  
  313.       if (mask & GL_ACCUM_BUFFER_BIT) {
  314.      gl_clear_accum_buffer();
  315.       }
  316.  
  317.       if (mask & GL_COLOR_BUFFER_BIT) {
  318.          if (CC.Color.SWmasking) {
  319.             clear_color_buffer_with_masking();
  320.          }
  321.          else {
  322.             (*DD.clear)( !CC.Scissor.Enabled,
  323.                          CC.Scissor.X, CC.Scissor.Y,
  324.                          CC.Scissor.Width, CC.Scissor.Height );
  325.             if (CC.RasterMask & ALPHABUF_BIT) {
  326.                gl_clear_alpha_buffers();
  327.             }
  328.          }
  329.       }
  330.  
  331.       if (mask & GL_STENCIL_BUFFER_BIT) {
  332.      gl_clear_stencil_buffer();
  333.       }
  334.  
  335. #ifdef PROFILE
  336.       CC.ClearTime += gl_time() - t0;
  337.       CC.ClearCount++;
  338. #endif
  339.  
  340.    }
  341. }
  342.  
  343.  
  344.  
  345. void
  346. glIndexMask( GLuint mask )
  347. {
  348.    if (CC.CompileFlag) {
  349.       gl_save_indexmask( mask );
  350.    }
  351.    if (CC.ExecuteFlag) {
  352.       if (INSIDE_BEGIN_END) {
  353.      gl_error( GL_INVALID_OPERATION, "glIndexMask" );
  354.      return;
  355.       }
  356.       CC.Color.IndexMask = mask;
  357.       CC.NewState = GL_TRUE;
  358.    }
  359. }
  360.  
  361.  
  362.  
  363. void
  364. glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha )
  365. {
  366.    if (CC.CompileFlag) {
  367.       gl_save_colormask( red, green, blue, alpha );
  368.    }
  369.    if (CC.ExecuteFlag) {
  370.       if (INSIDE_BEGIN_END) {
  371.      gl_error( GL_INVALID_OPERATION, "glColorMask" );
  372.      return;
  373.       }
  374.       CC.Color.ColorMask = (red << 3) | (green << 2) | (blue << 1) | alpha;
  375.       CC.NewState = GL_TRUE;
  376.    }
  377. }
  378.  
  379.  
  380.  
  381. const GLubyte *
  382. glGetString( GLenum name )
  383. {
  384.    static char *vendor = "Brian Paul";
  385.    static char *renderer = "Mesa";
  386.    static char *version = "1.2.8";
  387.    static char *extensions = "GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_logic_op GL_EXT_blend_subtract GL_EXT_polygon_offset GL_EXT_vertex_array GL_MESA_window_pos";
  388.  
  389.    if (INSIDE_BEGIN_END) {
  390.       gl_error( GL_INVALID_OPERATION, "glGetString" );
  391.       return (GLubyte *) 0;
  392.    }
  393.  
  394.    switch (name) {
  395.       case GL_VENDOR:
  396.          return (GLubyte *) vendor;
  397.       case GL_RENDERER:
  398.          return (GLubyte *) renderer;
  399.       case GL_VERSION:
  400.          return (GLubyte *) version;
  401.       case GL_EXTENSIONS:
  402.          return (GLubyte *) extensions;
  403.       default:
  404.          gl_error( GL_INVALID_ENUM, "glGetString" );
  405.          return (GLubyte *) 0;
  406.    }
  407. }
  408.  
  409.  
  410.  
  411. void
  412. glFinish( void )
  413. {
  414.    /* Don't compile into display list */
  415.    if (INSIDE_BEGIN_END) {
  416.       gl_error( GL_INVALID_OPERATION, "glFinish" );
  417.       return;
  418.    }
  419.    if (DD.finish) {
  420.       (*DD.finish)();
  421.    }
  422. }
  423.  
  424.  
  425.  
  426. void
  427. glFlush( void )
  428. {
  429.    /* Don't compile into display list */
  430.    if (INSIDE_BEGIN_END) {
  431.       gl_error( GL_INVALID_OPERATION, "glFlush" );
  432.       return;
  433.    }
  434.    if (DD.flush) {
  435.       (*DD.flush)();
  436.    }
  437. }
  438.  
  439.  
  440.  
  441. void glHint( GLenum target, GLenum mode )
  442. {
  443.    if (CC.CompileFlag) {
  444.       gl_save_hint( target, mode );
  445.    }
  446.    if (CC.ExecuteFlag) {
  447.       if (INSIDE_BEGIN_END) {
  448.      gl_error( GL_INVALID_OPERATION, "glHint" );
  449.      return;
  450.       }
  451.       if (mode!=GL_DONT_CARE && mode!=GL_FASTEST && mode!=GL_NICEST) {
  452.      gl_error( GL_INVALID_ENUM, "glHint(mode)" );
  453.      return;
  454.       }
  455.       switch (target) {
  456.      case GL_FOG_HINT:
  457.         CC.Hint.Fog = mode;
  458.         break;
  459.      case GL_LINE_SMOOTH_HINT:
  460.         CC.Hint.LineSmooth = mode;
  461.         break;
  462.      case GL_PERSPECTIVE_CORRECTION_HINT:
  463.         CC.Hint.PerspectiveCorrection = mode;
  464.         break;
  465.      case GL_POINT_SMOOTH_HINT:
  466.         CC.Hint.PointSmooth = mode;
  467.         break;
  468.      case GL_POLYGON_SMOOTH_HINT:
  469.         CC.Hint.PolygonSmooth = mode;
  470.         break;
  471.      default:
  472.         gl_error( GL_INVALID_ENUM, "glHint(target)" );
  473.       }
  474.    }
  475. }
  476.  
  477.  
  478.  
  479. void glDrawBuffer( GLenum mode )
  480. {
  481.    if (CC.CompileFlag) {
  482.       gl_save_drawbuffer( mode );
  483.    }
  484.    if (CC.ExecuteFlag) {
  485.       if (INSIDE_BEGIN_END) {
  486.      gl_error( GL_INVALID_OPERATION, "glDrawBuffer" );
  487.      return;
  488.       }
  489.       switch (mode) {
  490.      case GL_FRONT:
  491.      case GL_FRONT_LEFT:
  492.             if ( (*DD.set_buffer)( GL_FRONT ) == GL_FALSE ) {
  493.                gl_error( GL_INVALID_ENUM, "glDrawBuffer" );
  494.                return;
  495.             }
  496.             CC.Color.DrawBuffer = mode;
  497.             CC.AlphaBuffer = CC.FrontAlphaBuffer;
  498.             break;
  499.      case GL_BACK:
  500.      case GL_BACK_LEFT:
  501.             if ( (*DD.set_buffer)( GL_BACK ) == GL_FALSE) {
  502.                gl_error( GL_INVALID_ENUM, "glDrawBuffer" );
  503.                return;
  504.             }
  505.             CC.Color.DrawBuffer = mode;
  506.             CC.AlphaBuffer = CC.BackAlphaBuffer;
  507.             break;
  508.      case GL_NONE:
  509.      case GL_FRONT_RIGHT:
  510.      case GL_BACK_RIGHT:
  511.      case GL_LEFT:
  512.      case GL_RIGHT:
  513.      case GL_FRONT_AND_BACK:
  514.      case GL_AUX0:
  515.             gl_error( GL_INVALID_OPERATION, "glDrawBuffer" );
  516.             break;
  517.          default:
  518.             gl_error( GL_INVALID_ENUM, "glDrawBuffer" );
  519.       }
  520.    }
  521. }
  522.  
  523.  
  524.  
  525. void glReadBuffer( GLenum mode )
  526. {
  527.    if (CC.CompileFlag) {
  528.       gl_save_readbuffer( mode );
  529.    }
  530.    if (CC.ExecuteFlag) {
  531.       if (INSIDE_BEGIN_END) {
  532.      gl_error( GL_INVALID_OPERATION, "glReadBuffer" );
  533.      return;
  534.       }
  535.       switch (mode) {
  536.      case GL_FRONT:
  537.      case GL_FRONT_LEFT:
  538.             if ( (*DD.set_buffer)( GL_FRONT ) == GL_FALSE) {
  539.                gl_error( GL_INVALID_ENUM, "glReadBuffer" );
  540.                return;
  541.             }
  542.             CC.Pixel.ReadBuffer = mode;
  543.             CC.AlphaBuffer = CC.FrontAlphaBuffer;
  544.             break;
  545.      case GL_BACK:
  546.      case GL_BACK_LEFT:
  547.             if ( (*DD.set_buffer)( GL_BACK ) == GL_FALSE) {
  548.                gl_error( GL_INVALID_ENUM, "glReadBuffer" );
  549.                return;
  550.             }
  551.             CC.Pixel.ReadBuffer = mode;
  552.             CC.AlphaBuffer = CC.BackAlphaBuffer;
  553.             break;
  554.      case GL_FRONT_RIGHT:
  555.      case GL_BACK_RIGHT:
  556.      case GL_LEFT:
  557.      case GL_RIGHT:
  558.      case GL_AUX0:
  559.         gl_error( GL_INVALID_OPERATION, "glReadBuffer" );
  560.             break;
  561.          default:
  562.             gl_error( GL_INVALID_ENUM, "glReadBuffer" );
  563.       }
  564.    }
  565.  
  566.    /* Remember, the draw buffer is the default state */
  567.    (void) (*DD.set_buffer)( CC.Color.DrawBuffer );
  568. }
  569.  
  570.  
  571.  
  572. void glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 )
  573. {
  574.    /*
  575.     * TODO:  optimize all glRect calls to issue gl_save_vertex and/or
  576.     * gl_vertex calls, etc. depending on CC.ExecuteFlag and
  577.     * CC.CompileFlag.
  578.     */
  579.  
  580.    if (INSIDE_BEGIN_END) {
  581.       gl_error( GL_INVALID_OPERATION, "glRectd" );
  582.       return;
  583.    }
  584.    glBegin( GL_QUADS );
  585.    glVertex2d( x1, y1 );
  586.    glVertex2d( x2, y1 );
  587.    glVertex2d( x2, y2 );
  588.    glVertex2d( x1, y2 );
  589.    glEnd();
  590. }
  591.  
  592.  
  593. void glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
  594. {
  595.    if (INSIDE_BEGIN_END) {
  596.       gl_error( GL_INVALID_OPERATION, "glRectf" );
  597.       return;
  598.    }
  599.    glBegin( GL_QUADS );
  600.    glVertex2f( x1, y1 );
  601.    glVertex2f( x2, y1 );
  602.    glVertex2f( x2, y2 );
  603.    glVertex2f( x1, y2 );
  604.    glEnd();
  605. }
  606.  
  607.  
  608. void glRecti( GLint x1, GLint y1, GLint x2, GLint y2 )
  609. {
  610.    if (INSIDE_BEGIN_END) {
  611.       gl_error( GL_INVALID_OPERATION, "glRecti" );
  612.       return;
  613.    }
  614.    glBegin( GL_QUADS );
  615.    glVertex2i( x1, y1 );
  616.    glVertex2i( x2, y1 );
  617.    glVertex2i( x2, y2 );
  618.    glVertex2i( x1, y2 );
  619.    glEnd();
  620. }
  621.  
  622.  
  623. void glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 )
  624. {
  625.    if (INSIDE_BEGIN_END) {
  626.       gl_error( GL_INVALID_OPERATION, "glRects" );
  627.       return;
  628.    }
  629.    glBegin( GL_QUADS );
  630.    glVertex2s( x1, y1 );
  631.    glVertex2s( x2, y1 );
  632.    glVertex2s( x2, y2 );
  633.    glVertex2s( x1, y2 );
  634.    glEnd();
  635. }
  636.  
  637.  
  638. void glRectdv( const GLdouble *v1, const GLdouble *v2 )
  639. {
  640.    if (INSIDE_BEGIN_END) {
  641.       gl_error( GL_INVALID_OPERATION, "glRectdv" );
  642.       return;
  643.    }
  644.    glBegin( GL_QUADS );
  645.    glVertex2d( v1[0], v1[1] );
  646.    glVertex2d( v2[0], v1[1] );
  647.    glVertex2d( v2[0], v2[1] );
  648.    glVertex2d( v1[0], v2[1] );
  649.    glEnd();
  650. }
  651.  
  652.  
  653. void glRectfv( const GLfloat *v1, const GLfloat *v2 )
  654. {
  655.    if (INSIDE_BEGIN_END) {
  656.       gl_error( GL_INVALID_OPERATION, "glRectfv" );
  657.       return;
  658.    }
  659.    glBegin( GL_QUADS );
  660.    glVertex2f( v1[0], v1[1] );
  661.    glVertex2f( v2[0], v1[1] );
  662.    glVertex2f( v2[0], v2[1] );
  663.    glVertex2f( v1[0], v2[1] );
  664.    glEnd();
  665. }
  666.  
  667.  
  668. void glRectiv( const GLint *v1, const GLint *v2 )
  669. {
  670.    if (INSIDE_BEGIN_END) {
  671.       gl_error( GL_INVALID_OPERATION, "glRectiv" );
  672.       return;
  673.    }
  674.    glBegin( GL_QUADS );
  675.    glVertex2i( v1[0], v1[1] );
  676.    glVertex2i( v2[0], v1[1] );
  677.    glVertex2i( v2[0], v2[1] );
  678.    glVertex2i( v1[0], v2[1] );
  679.    glEnd();
  680. }
  681.  
  682.  
  683. void glRectsv( const GLshort *v1, const GLshort *v2 )
  684. {
  685.    if (INSIDE_BEGIN_END) {
  686.       gl_error( GL_INVALID_OPERATION, "glRectsv" );
  687.       return;
  688.    }
  689.    glBegin( GL_QUADS );
  690.    glVertex2s( v1[0], v1[1] );
  691.    glVertex2s( v2[0], v1[1] );
  692.    glVertex2s( v2[0], v2[1] );
  693.    glVertex2s( v1[0], v2[1] );
  694.    glEnd();
  695. }
  696.  
  697.  
  698.