4 // Stereo display feature added by Li Wei
5 // Updated 1996/10/06 11:16:15 CST
6 // Paralell render feature added by Li Wei
7 // liwei@aiar.xjtu.edu.cn
8 // http://sun.aiar.xjtu.edu.cn
10 #define WMESA_STEREO_C
31 // Code added by Li Wei to enable stereo display and Paralell render
34 /*#include "mesa_extend.h"*/
36 #if !defined(NO_STEREO)
43 void WMesaCreateStereoBuffer(void);
45 void WMesaInterleave( GLenum aView
);
47 void WMesaDestroyStereoBuffer(void);
49 void WMesaShowStereo(GLuint list
);
51 #if !defined(NO_PARALLEL)
55 /* end of added code*/
57 /* Bit's used for dest: */
58 #define FRONT_PIXMAP 1
62 static PWMC Current
= NULL
;
63 WMesaContext WC
= NULL
;
66 #define assert(ignore) ((void) 0)
68 void Mesa_Assert(void *Cond
,void *File
,unsigned Line
)
71 sprintf(Msg
,"%s %s %d",Cond
,File
,Line
);
72 MessageBox(NULL
,Msg
,"Assertion failed.",MB_OK
);
75 #define assert(e) if (!e) Mesa_Assert(#e,__FILE__,__LINE__);
78 #define DD_GETDC ((Current->db_flag) ? Current->dib.hDC : Current->hDC )
81 //#define BEGINGDICALL if(Current->rgb_flag)wmFlushBits(Current);
83 //#define ENDGDICALL if(Current->rgb_flag)wmGetBits(Current);
86 #define FLIP(Y) (Current->height-(Y)-1)
89 #define ENDPROFILE(PARA)
91 static void FlushToFile(PWMC pwc
, PSTR szFile
);
93 BOOL
wmCreateBackingStore(PWMC pwc
, long lxSize
, long lySize
);
95 BOOL
wmDeleteBackingStore(PWMC pwc
);
97 void wmCreatePalette( PWMC pwdc
);
98 BOOL
wmSetDibColors(PWMC pwc
);
99 void wmSetPixel(PWMC pwc
, int iScanLine
, int iPixel
, BYTE r
, BYTE g
, BYTE b
);
101 void wmCreateDIBSection(
103 PWMC pwc
, // handle of device context
104 CONST BITMAPINFO
*pbmi
, // address of structure containing bitmap size, format, and color data
105 UINT iUsage
// color data type indicator: RGB values or palette indices
108 BOOL
wmFlush(PWMC pwc
);
112 Modified from file osmesa.c
115 #define PIXELADDR(X,Y) ((GLbyte *)Current->pbPixels + (Current->height-Y)* Current->ScanWidth + (X)*nBypp)
118 /* Finish all pending operations and synchronize. */
119 static void finish(GLcontext
* ctx
)
126 // We cache all gl draw routines until a flush is made
128 static void flush(GLcontext
* ctx
)
131 if(Current
->rgb_flag
&& !(Current
->dib
.fFlushed
)&&!(Current
->db_flag
)){
141 * Set the color index used to clear the color buffer.
143 static void clear_index(GLcontext
* ctx
, GLuint index
)
146 Current
->clearpixel
= index
;
147 ENDPROFILE(clear_index
)
153 * Set the color used to clear the color buffer.
155 static void clear_color( GLcontext
* ctx
, const GLchan color
[4] )
158 Current
->clearpixel
= RGB(color
[0], color
[1], color
[2]);
159 ENDPROFILE(clear_color
)
165 * Clear the specified region of the color buffer using the clear color
166 * or index as specified by one of the two functions above.
168 static void clear(GLcontext
* ctx
,
169 GLboolean all
,GLint x
, GLint y
, GLint width
, GLint height
)
173 LPDWORD lpdw
= (LPDWORD
)Current
->pbPixels
;
174 LPWORD lpw
= (LPWORD
)Current
->pbPixels
;
175 LPBYTE lpb
= Current
->pbPixels
;
181 width
=Current
->width
;
182 height
=Current
->height
;
184 if (Current
->rgb_flag
==GL_TRUE
){
185 if(Current
->db_flag
==GL_TRUE
){
186 UINT nBypp
= Current
->cColorBits
/ 8;
191 iSize
= (Current
->width
* Current
->height
) / nBypp
;
193 wColor
= BGR16(GetRValue(Current
->clearpixel
),
194 GetGValue(Current
->clearpixel
),
195 GetBValue(Current
->clearpixel
));
196 dwColor
= MAKELONG(wColor
, wColor
);
199 iSize
= (Current
->width
* Current
->height
);
201 dwColor
= BGR32(GetRValue(Current
->clearpixel
),
202 GetGValue(Current
->clearpixel
),
203 GetBValue(Current
->clearpixel
));
206 // This is the 24bit case
210 iSize
= (Current
->width
* Current
->height
) / nBypp
;
212 dwColor
= BGR24(GetRValue(Current
->clearpixel
),
213 GetGValue(Current
->clearpixel
),
214 GetBValue(Current
->clearpixel
));
235 else{ // For single buffer
237 HPEN Pen
=CreatePen(PS_SOLID
,1,Current
->clearpixel
);
238 HBRUSH Brush
=CreateSolidBrush(Current
->clearpixel
);
239 HPEN Old_Pen
=SelectObject(DC
,Pen
);
240 HBRUSH Old_Brush
=SelectObject(DC
,Brush
);
241 Rectangle(DC
,x
,y
,x
+width
,y
+height
);
242 SelectObject(DC
,Old_Pen
);
243 SelectObject(DC
,Old_Brush
);
251 char *Mem
=Current
->ScreenMem
+y
*Current
->ScanWidth
+x
;
252 for (i
=0; i
<height
; i
++){
253 memset(Mem
,Current
->clearpixel
,width
);
262 /* Set the current color index. */
263 static void set_index(GLcontext
* ctx
, GLuint index
)
266 Current
->pixel
=index
;
267 ENDPROFILE(set_index
)
272 /* Set the current RGBA color. */
273 static void set_color( GLcontext
* ctx
, GLubyte r
, GLubyte g
, GLubyte b
, GLubyte a
)
276 Current
->pixel
= RGB( r
, g
, b
);
277 ENDPROFILE(set_color
)
283 static GLboolean
set_buffer( GLcontext
* ctx
, GLenum mode
)
286 /* TODO: this could be better */
287 if (mode
==GL_FRONT
|| mode
==GL_BACK
) {
293 ENDPROFILE(set_buffer
)
298 /* Return characteristics of the output buffer. */
299 static void buffer_size( GLcontext
* ctx
, GLuint
*width
, GLuint
*height
/*, GLuint *depth */)
306 GetClientRect(Current
->Window
,&CR
);
310 // *depth = Current->depth;
312 New_Size
=((*width
)!=Current
->width
) || ((*height
)!=Current
->height
);
315 Current
->width
=*width
;
316 Current
->height
=*height
;
317 Current
->ScanWidth
=Current
->width
;
318 if ((Current
->ScanWidth
%sizeof(long))!=0)
319 Current
->ScanWidth
+=(sizeof(long)-(Current
->ScanWidth
%sizeof(long)));
321 if (Current
->db_flag
){
322 if (Current
->rgb_flag
==GL_TRUE
){
323 wmDeleteBackingStore(Current
);
324 wmCreateBackingStore(Current
, Current
->width
, Current
->height
);
327 Current
->ScanWidth
=Current
->width
;
328 if ((Current
->ScanWidth
%sizeof(long))!=0)
329 Current
->ScanWidth
+=(sizeof(long)-(Current
->ScanWidth
%sizeof(long)));
331 Current
->IndexFormat
->bmiHeader
.biWidth
=Current
->width
;
333 if (Current
->IndexFormat
->bmiHeader
.biHeight
<0)
334 Current
->IndexFormat
->bmiHeader
.biHeight
=-(Current
->height
);
336 Current
->IndexFormat
->bmiHeader
.biHeight
=Current
->height
;
338 Current
->Compat_BM
=WinGCreateBitmap(Current
->dib
.hDC
,Current
->IndexFormat
,&((void *) Current
->ScreenMem
));
340 DeleteObject(SelectObject(Current
->dib
.hDC
,Current
->Compat_BM
));
342 //Code added by Li Wei to enable stereo display
343 // Recreate stereo buffer when stereo_flag is TRUE while parallelFlag is FALSE
344 #if !defined(NO_STEREO)
346 #if !defined(NO_PARALLEL)
350 if(stereoBuffer
== GL_TRUE
)
351 WMesaDestroyStereoBuffer();
352 WMesaCreateStereoBuffer();
355 // Resize OsmesaBuffer if in Parallel mode
356 #if !defined(NO_PARALLEL)
358 PRSizeRenderBuffer(Current
->width
, Current
->height
,Current
->ScanWidth
,
359 Current
->rgb_flag
== GL_TRUE
? Current
->pbPixels
: Current
->ScreenMem
);
366 ENDPROFILE(buffer_size
)
371 /**********************************************************************/
372 /***** Accelerated point, line, polygon rendering *****/
373 /**********************************************************************/
376 static void fast_rgb_points( GLcontext
* ctx
, GLuint first
, GLuint last
)
384 if (Current
->gl_ctx
->VB
->MonoColor
) {
385 /* all drawn with current color */
386 for (i
=first
;i
<=last
;i
++) {
387 if (Current
->gl_ctx
->VB
->ClipMask
[i
]==0) {
389 x
= (GLint
) Current
->gl_ctx
->VB
->Win
[i
][0];
390 y
= FLIP( (GLint
) Current
->gl_ctx
->VB
->Win
[i
][1] );
391 wmSetPixel(pwc
, y
,x
,GetRValue(Current
->pixel
),
392 GetGValue(Current
->pixel
), GetBValue(Current
->pixel
));
397 /* draw points of different colors */
398 for (i
=first
;i
<=last
;i
++) {
399 if (Current
->gl_ctx
->VB
->ClipMask
[i
]==0) {
401 unsigned long pixel
=RGB(Current
->gl_ctx
->VB
->Color
[i
][0]*255.0,
402 Current
->gl_ctx
->VB
->Color
[i
][1]*255.0,
403 Current
->gl_ctx
->VB
->Color
[i
][2]*255.0);
404 x
= (GLint
) Current
->gl_ctx
->VB
->Win
[i
][0];
405 y
= FLIP( (GLint
) Current
->gl_ctx
->VB
->Win
[i
][1] );
406 wmSetPixel(pwc
, y
,x
,Current
->gl_ctx
->VB
->Color
[i
][0]*255.0,
407 Current
->gl_ctx
->VB
->Color
[i
][1]*255.0,
408 Current
->gl_ctx
->VB
->Color
[i
][2]*255.0);
413 ENDPROFILE(fast_rgb_points
)
418 /* Return pointer to accerated points function */
419 extern points_func
choose_points_function( GLcontext
* ctx
)
422 if (ctx
->Point
.Size
==1.0 && !ctx
->Point
.SmoothFlag
&& ctx
->_RasterMask
==0
423 && !ctx
->Texture
._ReallyEnabled
&& ctx
->Visual
->RGBAflag
) {
424 ENDPROFILE(choose_points_function
)
425 return fast_rgb_points
;
428 ENDPROFILE(choose_points_function
)
435 /* Draw a line using the color specified by Current->gl_ctx->VB->Color[pv] */
436 static void fast_flat_rgb_line( GLcontext
* ctx
, GLuint v0
, GLuint v1
, GLuint pv
)
445 if (Current
->gl_ctx
->VB
->MonoColor
) {
446 pixel
= Current
->pixel
; /* use current color */
449 pixel
= RGB(Current
->gl_ctx
->VB
->Color
[pv
][0]*255.0, Current
->gl_ctx
->VB
->Color
[pv
][1]*255.0, Current
->gl_ctx
->VB
->Color
[pv
][2]*255.0);
452 x0
= (int) Current
->gl_ctx
->VB
->Win
[v0
][0];
453 y0
= FLIP( (int) Current
->gl_ctx
->VB
->Win
[v0
][1] );
454 x1
= (int) Current
->gl_ctx
->VB
->Win
[v1
][0];
455 y1
= FLIP( (int) Current
->gl_ctx
->VB
->Win
[v1
][1] );
460 Pen
=CreatePen(PS_SOLID
,1,pixel
);
461 Old_Pen
=SelectObject(DC
,Pen
);
462 MoveToEx(DC
,x0
,y0
,NULL
);
464 SelectObject(DC
,Old_Pen
);
470 ENDPROFILE(fast_flat_rgb_line
)
475 /* Return pointer to accerated line function */
476 static line_func
choose_line_function( GLcontext
* ctx
)
479 if (ctx
->Line
.Width
==1.0 && !ctx
->Line
.SmoothFlag
&& !ctx
->Line
.StippleFlag
480 && ctx
->Light
.ShadeModel
==GL_FLAT
&& ctx
->_RasterMask
==0
481 && !ctx
->Texture
._ReallyEnabled
&& Current
->rgb_flag
) {
482 ENDPROFILE(choose_line_function
)
483 return fast_flat_rgb_line
;
486 ENDPROFILE(choose_line_function
)
491 /**********************************************************************/
492 /***** Optimized triangle rendering *****/
493 /**********************************************************************/
497 * Smooth-shaded, z-less triangle, RGBA color.
499 static void smooth_color_z_triangle( GLcontext
*ctx
, GLuint v0
, GLuint v1
,
500 GLuint v2
, GLuint pv
)
502 UINT nBypp
= Current
->cColorBits
/ 8;
505 GLuint
*img24
,*img32
;
508 #define INTERP_ALPHA 1
509 #define INNER_LOOP( LEFT, RIGHT, Y ) \
511 GLint i, len = RIGHT-LEFT; \
512 img = PIXELADDR(LEFT,Y); \
513 for (i=0;i<len;i++,img+=nBypp) { \
514 GLdepth z = FixedToDepth(ffz); \
516 img16 = img24 = img32 = img; \
518 *img16 = BGR16( FixedToInt(ffr), FixedToInt(ffg), \
521 *img24 = BGR24( FixedToInt(ffr), FixedToInt(ffg), \
524 *img32 = BGR32( FixedToInt(ffr), FixedToInt(ffg), \
528 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; ffa += fdadx;\
540 * Flat-shaded, z-less triangle, RGBA color.
542 static void flat_color_z_triangle( GLcontext
*ctx
, GLuint v0
, GLuint v1
,
543 GLuint v2
, GLuint pv
)
547 GLuint
*img24
, *img32
;
548 UINT nBypp
= Current
->cColorBits
/ 8;
550 GLushort pixel16
= BGR16(r
,g
,b
);
551 GLuint pixel24
= BGR24(r
,g
,b
);
552 GLuint pixel32
= BGR32(r
,g
,b
);
556 r = VB->Color[pv][0]; \
557 g = VB->Color[pv][1]; \
558 b = VB->Color[pv][2];
560 #define INNER_LOOP( LEFT, RIGHT, Y ) \
562 GLint i, len = RIGHT-LEFT; \
563 img = PIXELADDR(LEFT,Y); \
564 for (i=0;i<len;i++,img+=nBypp) { \
565 GLdepth z = FixedToDepth(ffz); \
567 img16 = img24 = img32 = img; \
586 * Return pointer to an accelerated triangle function if possible.
588 static triangle_func
choose_triangle_function( GLcontext
*ctx
)
590 if (ctx
->Polygon
.SmoothFlag
) return NULL
;
591 if (ctx
->Polygon
.StippleFlag
) return NULL
;
592 if (ctx
->Texture
._ReallyEnabled
) return NULL
;
594 if (ctx
->_RasterMask
==DEPTH_BIT
595 && ctx
->Depth
.Func
==GL_LESS
596 && ctx
->Depth
.Mask
==GL_TRUE
597 && ctx
->Visual
->RGBAflag
) {
598 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
599 return smooth_color_z_triangle
;
602 return flat_color_z_triangle
;
609 /* Draw a convex polygon using color Current->gl_ctx->VB->Color[pv] */
610 static void fast_flat_rgb_polygon( GLcontext
* ctx
, GLuint n
, GLuint vlist
[], GLuint pv
)
613 POINT
*Pts
=(POINT
*) malloc(n
*sizeof(POINT
));
622 if (Current
->gl_ctx
->VB
->MonoColor
) {
623 pixel
= Current
->pixel
; /* use current color */
626 pixel
= RGB(Current
->gl_ctx
->VB
->Color
[pv
][0]*255.0, Current
->gl_ctx
->VB
->Color
[pv
][1]*255.0, Current
->gl_ctx
->VB
->Color
[pv
][2]*255.0);
629 Pen
=CreatePen(PS_SOLID
,1,pixel
);
630 Brush
=CreateSolidBrush(pixel
);
631 Old_Pen
=SelectObject(DC
,Pen
);
632 Old_Brush
=SelectObject(DC
,Brush
);
634 for (i
=0; i
<n
; i
++) {
636 Pts
[i
].x
= (int) Current
->gl_ctx
->VB
->Win
[j
][0];
637 Pts
[i
].y
= FLIP( (int) Current
->gl_ctx
->VB
->Win
[j
][1] );
643 SelectObject(DC
,Old_Pen
);
644 SelectObject(DC
,Old_Brush
);
652 ENDPROFILE(fast_flat_rgb_polygon
)
657 /* Return pointer to accerated polygon function */
658 static polygon_func
choose_polygon_function( GLcontext
* ctx
)
661 if (!ctx
->Polygon
.SmoothFlag
&& !ctx
->Polygon
.StippleFlag
662 && ctx
->Light
.ShadeModel
==GL_FLAT
&& ctx
->_RasterMask
==0
663 && !ctx
->Texture
._ReallyEnabled
&& Current
->rgb_flag
==GL_TRUE
) {
664 ENDPROFILE(choose_polygon_function
)
665 return fast_flat_rgb_polygon
;
668 ENDPROFILE(choose_polygon_function
)
675 /**********************************************************************/
676 /***** Span-based pixel drawing *****/
677 /**********************************************************************/
680 /* Write a horizontal span of color-index pixels with a boolean mask. */
681 static void write_index_span( GLcontext
* ctx
,
682 GLuint n
, GLint x
, GLint y
,
683 const GLuint index
[],
684 const GLubyte mask
[] )
688 char *Mem
=Current
->ScreenMem
+y
*Current
->ScanWidth
+x
;
689 assert(Current
->rgb_flag
==GL_FALSE
);
693 ENDPROFILE(write_index_span
)
699 * Write a horizontal span of pixels with a boolean mask. The current
700 * color index is used for all pixels.
702 static void write_monoindex_span(GLcontext
* ctx
,
703 GLuint n
,GLint x
,GLint y
,
704 const GLubyte mask
[])
708 char *Mem
=Current
->ScreenMem
+y
*Current
->ScanWidth
+x
;
709 assert(Current
->rgb_flag
==GL_FALSE
);
712 Mem
[i
]=Current
->pixel
;
713 ENDPROFILE(write_monoindex_span
)
717 To improve the performance of this routine, frob the data into an actual scanline
718 and call bitblt on the complete scan line instead of SetPixel.
721 /* Write a horizontal span of color pixels with a boolean mask. */
722 static void write_color_span( GLcontext
* ctx
,
723 GLuint n
, GLint x
, GLint y
,
725 red
[], const GLubyte green
[],
726 const GLubyte blue
[], const GLubyte alpha
[],
727 const GLubyte mask
[] )
733 if (pwc
->rgb_flag
==GL_TRUE
)
742 wmSetPixel(pwc
, y
, x
+ i
,red
[i
], green
[i
], blue
[i
]);
747 wmSetPixel(pwc
, y
, x
+ i
, red
[i
], green
[i
], blue
[i
]);
757 char *Mem
=Current
->ScreenMem
+y
*Current
->ScanWidth
+x
;
761 Mem
[i
]=GetNearestPaletteIndex(Current
->hPal
,RGB(red
[i
],green
[i
],blue
[i
]));
765 Mem
[i
]=GetNearestPaletteIndex(Current
->hPal
,RGB(red
[i
],green
[i
],blue
[i
]));
768 ENDPROFILE(write_color_span
)
773 * Write a horizontal span of pixels with a boolean mask. The current color
774 * is used for all pixels.
776 static void write_monocolor_span( GLcontext
* ctx
,
777 GLuint n
, GLint x
, GLint y
,
778 const GLubyte mask
[])
785 assert(Current
->rgb_flag
==GL_TRUE
);
788 if(Current
->rgb_flag
==GL_TRUE
){
792 wmSetPixel(pwc
,y
,x
+i
,GetRValue(Current
->pixel
), GetGValue(Current
->pixel
), GetBValue(Current
->pixel
));
797 SetPixel(DC
, y
, x
+i
, Current
->pixel
);
802 ENDPROFILE(write_monocolor_span
)
807 /**********************************************************************/
808 /***** Array-based pixel drawing *****/
809 /**********************************************************************/
812 /* Write an array of pixels with a boolean mask. */
813 static void write_index_pixels( GLcontext
* ctx
,
814 GLuint n
, const GLint x
[], const GLint y
[],
815 const GLuint index
[], const GLubyte mask
[] )
819 assert(Current
->rgb_flag
==GL_FALSE
);
820 for (i
=0; i
<n
; i
++) {
822 char *Mem
=Current
->ScreenMem
+y
[i
]*Current
->ScanWidth
+x
[i
];
826 ENDPROFILE(write_index_pixels
)
832 * Write an array of pixels with a boolean mask. The current color
833 * index is used for all pixels.
835 static void write_monoindex_pixels( GLcontext
* ctx
,
837 const GLint x
[], const GLint y
[],
838 const GLubyte mask
[] )
842 assert(Current
->rgb_flag
==GL_FALSE
);
843 for (i
=0; i
<n
; i
++) {
845 char *Mem
=Current
->ScreenMem
+y
[i
]*Current
->ScanWidth
+x
[i
];
846 *Mem
= Current
->pixel
;
849 ENDPROFILE(write_monoindex_pixels
)
854 /* Write an array of pixels with a boolean mask. */
855 static void write_color_pixels( GLcontext
* ctx
,
856 GLuint n
, const GLint x
[], const GLint y
[],
857 const GLubyte r
[], const GLubyte g
[],
858 const GLubyte b
[], const GLubyte a
[],
859 const GLubyte mask
[] )
865 assert(Current
->rgb_flag
==GL_TRUE
);
868 wmSetPixel(pwc
, FLIP(y
[i
]),x
[i
],r
[i
],g
[i
],b
[i
]);
870 ENDPROFILE(write_color_pixels
)
876 * Write an array of pixels with a boolean mask. The current color
877 * is used for all pixels.
879 static void write_monocolor_pixels( GLcontext
* ctx
,
881 const GLint x
[], const GLint y
[],
882 const GLubyte mask
[] )
888 assert(Current
->rgb_flag
==GL_TRUE
);
891 wmSetPixel(pwc
, FLIP(y
[i
]),x
[i
],GetRValue(Current
->pixel
),
892 GetGValue(Current
->pixel
), GetBValue(Current
->pixel
));
894 ENDPROFILE(write_monocolor_pixels
)
899 /**********************************************************************/
900 /***** Read spans/arrays of pixels *****/
901 /**********************************************************************/
904 /* Read a horizontal span of color-index pixels. */
905 static void read_index_span( GLcontext
* ctx
, GLuint n
, GLint x
, GLint y
, GLuint index
[])
909 char *Mem
=Current
->ScreenMem
+y
*Current
->ScanWidth
+x
;
910 assert(Current
->rgb_flag
==GL_FALSE
);
913 ENDPROFILE(read_index_span
)
920 /* Read an array of color index pixels. */
921 static void read_index_pixels( GLcontext
* ctx
,
922 GLuint n
, const GLint x
[], const GLint y
[],
923 GLuint indx
[], const GLubyte mask
[] )
927 assert(Current
->rgb_flag
==GL_FALSE
);
928 for (i
=0; i
<n
; i
++) {
930 indx
[i
]=*(Current
->ScreenMem
+y
[i
]*Current
->ScanWidth
+x
[i
]);
933 ENDPROFILE(read_index_pixels
)
938 /* Read a horizontal span of color pixels. */
939 static void read_color_span( GLcontext
* ctx
,
940 GLuint n
, GLint x
, GLint y
,
941 GLubyte red
[], GLubyte green
[],
942 GLubyte blue
[], GLubyte alpha
[] )
948 assert(Current
->rgb_flag
==GL_TRUE
);
952 Color
=GetPixel(DC
,x
+i
,y
);
953 red
[i
]=GetRValue(Color
);
954 green
[i
]=GetGValue(Color
);
955 blue
[i
]=GetBValue(Color
);
959 memset(alpha
,0,n
*sizeof(GLint
));
960 ENDPROFILE(read_color_span
)
964 /* Read an array of color pixels. */
965 static void read_color_pixels( GLcontext
* ctx
,
966 GLuint n
, const GLint x
[], const GLint y
[],
967 GLubyte red
[], GLubyte green
[],
968 GLubyte blue
[], GLubyte alpha
[],
969 const GLubyte mask
[] )
975 assert(Current
->rgb_flag
==GL_TRUE
);
976 for (i
=0; i
<n
; i
++) {
978 Color
=GetPixel(DC
,x
[i
],FLIP(y
[i
]));
979 red
[i
]=GetRValue(Color
);
980 green
[i
]=GetGValue(Color
);
981 blue
[i
]=GetBValue(Color
);
986 memset(alpha
,0,n
*sizeof(GLint
));
987 ENDPROFILE(read_color_pixels
)
992 /**********************************************************************/
993 /**********************************************************************/
997 void setup_DD_pointers( GLcontext
* ctx
)
999 ctx
->Driver
.Finish
= finish
;
1000 ctx
->Driver
.Flush
= flush
;
1002 ctx
->Driver
.ClearIndex
= clear_index
;
1003 ctx
->Driver
.ClearColor
= clear_color
;
1004 ctx
->Driver
.Clear
= clear
;
1006 ctx
->Driver
.Index
= set_index
;
1007 ctx
->Driver
.Color
= set_color
;
1009 ctx
->Driver
.SetBuffer
= set_buffer
;
1010 ctx
->Driver
.GetBufferSize
= buffer_size
;
1012 ctx
->Driver
.PointsFunc
= choose_points_function(ctx
);
1013 ctx
->Driver
.LineFunc
= choose_line_function(ctx
);
1014 ctx
->Driver
.TriangleFunc
= choose_triangle_function( ctx
);
1015 // ctx->Driver.TriangleFunc = choose_polygon_function(ctx);
1017 /* Pixel/span writing functions: */
1018 ctx
->Driver
.WriteColorSpan
= write_color_span
;
1019 ctx
->Driver
.WriteMonocolorSpan
= write_monocolor_span
;
1020 ctx
->Driver
.WriteColorPixels
= write_color_pixels
;
1021 ctx
->Driver
.WriteMonocolorPixels
= write_monocolor_pixels
;
1022 ctx
->Driver
.WriteIndexSpan
= write_index_span
;
1023 ctx
->Driver
.WriteMonoindexSpan
= write_monoindex_span
;
1024 ctx
->Driver
.WriteIndexPixels
= write_index_pixels
;
1025 ctx
->Driver
.WriteMonoindexPixels
= write_monoindex_pixels
;
1027 /* Pixel/span reading functions: */
1028 ctx
->Driver
.ReadIndexSpan
= read_index_span
;
1029 ctx
->Driver
.ReadColorSpan
= read_color_span
;
1030 ctx
->Driver
.ReadIndexPixels
= read_index_pixels
;
1031 ctx
->Driver
.ReadColorPixels
= read_color_pixels
;
1035 // MesaGL32 is the DLL version of MesaGL for Win32
1038 /**********************************************************************/
1039 /***** WMesa API Functions *****/
1040 /**********************************************************************/
1044 #define PAL_SIZE 256
1045 static void GetPalette(HPALETTE Pal
,RGBQUAD
*aRGB
)
1053 WORD NumberOfEntries
;
1054 PALETTEENTRY aEntries
[PAL_SIZE
];
1062 GetPaletteEntries(Pal
,0,PAL_SIZE
,Palette
.aEntries
);
1064 GetSystemPaletteEntries(hdc
,0,PAL_SIZE
,Palette
.aEntries
);
1065 if (GetSystemPaletteUse(hdc
) == SYSPAL_NOSTATIC
)
1067 for(i
= 0; i
<PAL_SIZE
; i
++)
1068 Palette
.aEntries
[i
].peFlags
= PC_RESERVED
;
1069 Palette
.aEntries
[255].peRed
= 255;
1070 Palette
.aEntries
[255].peGreen
= 255;
1071 Palette
.aEntries
[255].peBlue
= 255;
1072 Palette
.aEntries
[255].peFlags
= 0;
1073 Palette
.aEntries
[0].peRed
= 0;
1074 Palette
.aEntries
[0].peGreen
= 0;
1075 Palette
.aEntries
[0].peBlue
= 0;
1076 Palette
.aEntries
[0].peFlags
= 0;
1082 nStaticColors
= GetDeviceCaps(hdc
, NUMCOLORS
)/2;
1083 for (i
=0; i
<nStaticColors
; i
++)
1084 Palette
.aEntries
[i
].peFlags
= 0;
1085 nUsableColors
= PAL_SIZE
-nStaticColors
;
1086 for (; i
<nUsableColors
; i
++)
1087 Palette
.aEntries
[i
].peFlags
= PC_RESERVED
;
1088 for (; i
<PAL_SIZE
-nStaticColors
; i
++)
1089 Palette
.aEntries
[i
].peFlags
= PC_RESERVED
;
1090 for (i
=PAL_SIZE
-nStaticColors
; i
<PAL_SIZE
; i
++)
1091 Palette
.aEntries
[i
].peFlags
= 0;
1093 ReleaseDC(NULL
,hdc
);
1094 for (i
=0; i
<PAL_SIZE
; i
++)
1096 aRGB
[i
].rgbRed
=Palette
.aEntries
[i
].peRed
;
1097 aRGB
[i
].rgbGreen
=Palette
.aEntries
[i
].peGreen
;
1098 aRGB
[i
].rgbBlue
=Palette
.aEntries
[i
].peBlue
;
1099 aRGB
[i
].rgbReserved
=Palette
.aEntries
[i
].peFlags
;
1101 ENDPROFILE(GetPalette
)
1105 WMesaContext
/*APIENTRY*/ WMesaCreateContext( HWND hWnd
, HPALETTE Pal
,
1106 /*HDC hDC,*/ GLboolean rgb_flag
,
1114 c
= (struct wmesa_context
* ) calloc(1,sizeof(struct wmesa_context
));
1119 c
->hDC
= GetDC(hWnd
);
1121 if (rgb_flag
==GL_FALSE
)
1123 c
->rgb_flag
= GL_FALSE
;
1125 db_flag
=GL_TRUE
; // WinG requires double buffering
1126 //c->gl_ctx->BufferDepth = windepth;
1130 c
->rgb_flag
= GL_TRUE
;
1133 GetClientRect(c
->Window
,&CR
);
1135 c
->height
=CR
.bottom
;
1139 // c->hDC GetDC(c->Window);
1140 /* Double buffered */
1141 if (c
->rgb_flag
==GL_TRUE
)
1143 //DC = c->hDC = hDC;
1145 // DC = c->hDC = GetDC(c->Window);
1146 wmCreateBackingStore(c
, c
->width
, c
->height
);
1147 // ReleaseDC(c->Window,DC);
1151 c
->dib
.hDC
=WinGCreateDC();
1152 Rec
=(BITMAPINFO
*) malloc(sizeof(BITMAPINFO
)+(PAL_SIZE
-1)*sizeof(RGBQUAD
));
1154 GetPalette(Pal
,Rec
->bmiColors
);
1155 WinGRecommendDIBFormat(Rec
);
1156 Rec
->bmiHeader
.biWidth
=c
->width
;
1157 Rec
->bmiHeader
.biHeight
*=c
->height
;
1158 Rec
->bmiHeader
.biClrUsed
=PAL_SIZE
;
1159 if (Rec
->bmiHeader
.biPlanes
!=1 || Rec
->bmiHeader
.biBitCount
!=8)
1161 MessageBox(NULL
,"Error.","This code presumes a 256 color, single plane, WinG Device.\n",MB_OK
);
1164 c
->Compat_BM
=WinGCreateBitmap(c
->dib
.hDC
,Rec
,&((void *) c
->ScreenMem
));
1165 c
->Old_Compat_BM
=SelectObject(c
->dib
.hDC
,c
->Compat_BM
);
1166 WinGSetDIBColorTable(c
->dib
.hDC
,0,PAL_SIZE
,Rec
->bmiColors
);
1168 c
->ScanWidth
=c
->width
;
1170 if ((c
->ScanWidth
%sizeof(long))!=0)
1171 c
->ScanWidth
+=(sizeof(long)-(c
->ScanWidth
%sizeof(long)));
1176 /* Single Buffered */
1179 // wmCreateBackingStore(c, c->width, c->height);
1184 c
->gl_visual
= _mesa_create_visual(rgb_flag
,
1185 db_flag
, /* db_flag */
1186 GL_TRUE
, /* stereo */
1187 8, 8, 8, 8,/* rgba bits */
1189 16, /* depth_bits */
1190 8, /* stencil_bits */
1191 16,16,16,16,/* accum_bits */
1194 if (!c
->gl_visual
) {
1198 /* allocate a new Mesa context */
1199 c
->gl_ctx
= _mesa_create_context( c
->gl_visual
, NULL
,c
);
1202 _mesa_destroy_visual( c
->gl_visual
);
1207 c
->gl_buffer
= _mesa_create_framebuffer( c
->gl_visual
);
1208 if (!c
->gl_buffer
) {
1209 _mesa_destroy_visual( c
->gl_visual
);
1210 _mesa_destroy_context( c
->gl_ctx
);
1214 // setup_DD_pointers(c->gl_ctx);
1221 void /*APIENTRY*/ WMesaDestroyContext( void )
1223 WMesaContext c
= Current
;
1224 ReleaseDC(c
->Window
,c
->hDC
);
1227 _mesa_destroy_visual( c
->gl_visual
);
1228 _mesa_destroy_framebuffer( c
->gl_buffer
);
1229 _mesa_destroy_context( c
->gl_ctx
);
1232 wmDeleteBackingStore(c
);
1234 //Code added by Li Wei to enable parallel render
1235 #if !defined(NO_STEREO)
1236 if(stereoBuffer
==GL_TRUE
){
1237 WMesaDestroyStereoBuffer();
1238 stereoBuffer
=GL_FALSE
;
1244 //Code added by Li Wei to enable parallel render
1245 // Parallel render only work in double buffer mode
1246 #if !defined(NO_PARALLEL)
1248 PRDestroyRenderBuffer();
1255 void /*APIENTRY*/ WMesaMakeCurrent( WMesaContext c
)
1263 // A little optimization
1264 // If it already is current,
1265 // don't set it again
1270 //gl_set_context( c->gl_ctx );
1271 _mesa_make_current(c
->gl_ctx
, c
->gl_buffer
);
1273 setup_DD_pointers(c
->gl_ctx
);
1274 if (Current
->gl_ctx
->Viewport
.Width
==0) {
1275 /* initialize viewport to window size */
1276 _mesa_set_viewport( Current
->gl_ctx
,
1277 0, 0, Current
->width
, Current
->height
);
1283 void /*APIENTRY*/ WMesaSwapBuffers( void )
1285 HDC DC
= Current
->hDC
;
1286 if (Current
->db_flag
)
1288 if (Current
->rgb_flag
)
1291 WinGBitBlt(DC
,0,0,Current
->width
,Current
->height
,Current
->dib
.hDC
,0,0);
1297 void /*APIENTRY*/ WMesaPaletteChange(HPALETTE Pal
)
1299 if (Current
&& Current
->rgb_flag
==GL_FALSE
)
1302 GetPalette(Pal
,Current
->IndexFormat
->bmiColors
);
1303 WinGSetDIBColorTable(Current
->dib
.hDC
,0,PAL_SIZE
,Current
->IndexFormat
->bmiColors
);
1308 // Free up the dib section that was created
1310 BOOL
wmDeleteBackingStore(PWMC pwc
)
1312 SelectObject(pwc
->dib
.hDC
, pwc
->hOldBitmap
);
1313 DeleteDC(pwc
->dib
.hDC
);
1314 DeleteObject(pwc
->hbmDIB
);
1315 UnmapViewOfFile(pwc
->dib
.base
);
1316 CloseHandle(pwc
->dib
.hFileMap
);
1322 // This function creates the DIB section that is used for combined
1325 BOOL
/*WINAPI*/ wmCreateBackingStore(PWMC pwc
, long lxSize
, long lySize
)
1328 LPBITMAPINFO pbmi
= &(pwc
->bmi
);
1331 pbmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1332 pbmi
->bmiHeader
.biWidth
= lxSize
;
1333 pbmi
->bmiHeader
.biHeight
= -lySize
;
1334 pbmi
->bmiHeader
.biPlanes
= 1;
1335 pbmi
->bmiHeader
.biBitCount
= GetDeviceCaps(pwc
->hDC
, BITSPIXEL
);
1336 pbmi
->bmiHeader
.biCompression
= BI_RGB
;
1337 pbmi
->bmiHeader
.biSizeImage
= 0;
1338 pbmi
->bmiHeader
.biXPelsPerMeter
= 0;
1339 pbmi
->bmiHeader
.biYPelsPerMeter
= 0;
1340 pbmi
->bmiHeader
.biClrUsed
= 0;
1341 pbmi
->bmiHeader
.biClrImportant
= 0;
1343 iUsage
= (pbmi
->bmiHeader
.biBitCount
<= 8) ? DIB_PAL_COLORS
: DIB_RGB_COLORS
;
1345 pwc
->cColorBits
= pbmi
->bmiHeader
.biBitCount
;
1346 pwc
->ScanWidth
= lxSize
;
1348 wmCreateDIBSection(hdc
, pwc
, pbmi
, iUsage
);
1350 if ((iUsage
== DIB_PAL_COLORS
) && !(pwc
->hGLPalette
)) {
1351 wmCreatePalette( pwc
);
1352 wmSetDibColors( pwc
);
1361 // This function copies one scan line in a DIB section to another
1363 BOOL GLWINAPI
wmSetDIBits(PWMC pwc
, UINT uiScanWidth
, UINT uiNumScans
, UINT nBypp
, UINT uiNewWidth
, LPBYTE pBits
)
1366 LPBYTE pDest
= pwc
->pbPixels
;
1367 DWORD dwNextScan
= uiScanWidth
;
1368 DWORD dwNewScan
= uiNewWidth
;
1369 DWORD dwScanWidth
= (uiScanWidth
* nBypp
);
1372 // We need to round up to the nearest DWORD
1373 // and multiply by the number of bytes per
1376 dwNextScan
= (((dwNextScan
* nBypp
)+ 3) & ~3);
1377 dwNewScan
= (((dwNewScan
* nBypp
)+ 3) & ~3);
1379 for(uiScans
= 0; uiScans
< uiNumScans
; uiScans
++){
1380 CopyMemory(pDest
, pBits
, dwScanWidth
);
1381 pBits
+= dwNextScan
;
1389 BOOL GLWINAPI
wmSetPixelFormat( PWMC pwdc
, HDC hDC
, DWORD dwFlags
)
1394 static unsigned char threeto8
[8] = {
1395 0, 0111>>1, 0222>>1, 0333>>1, 0444>>1, 0555>>1, 0666>>1, 0377
1398 static unsigned char twoto8
[4] = {
1402 static unsigned char oneto8
[2] = {
1406 static unsigned char componentFromIndex(UCHAR i
, UINT nbits
, UINT shift
)
1423 return threeto8
[val
];
1430 void /*WINAPI*/ wmCreatePalette( PWMC pwdc
)
1432 /* Create a compressed and re-expanded 3:3:2 palette */
1435 BYTE rb
, rs
, gb
, gs
, bb
, bs
;
1437 pwdc
->nColors
= 0x100;
1439 pPal
= (PLOGPALETTE
)malloc(sizeof(LOGPALETTE
) + pwdc
->nColors
* sizeof(PALETTEENTRY
));
1440 memset( pPal
, 0, sizeof(LOGPALETTE
) + pwdc
->nColors
* sizeof(PALETTEENTRY
) );
1442 pPal
->palVersion
= 0x300;
1451 if (pwdc
->db_flag
) {
1453 /* Need to make two palettes: one for the screen DC and one for the DIB. */
1454 pPal
->palNumEntries
= pwdc
->nColors
;
1455 for (i
= 0; i
< pwdc
->nColors
; i
++) {
1456 pPal
->palPalEntry
[i
].peRed
= componentFromIndex( i
, rb
, rs
);
1457 pPal
->palPalEntry
[i
].peGreen
= componentFromIndex( i
, gb
, gs
);
1458 pPal
->palPalEntry
[i
].peBlue
= componentFromIndex( i
, bb
, bs
);
1459 pPal
->palPalEntry
[i
].peFlags
= 0;
1461 pwdc
->hGLPalette
= CreatePalette( pPal
);
1462 pwdc
->hPalette
= CreatePalette( pPal
);
1466 pPal
->palNumEntries
= pwdc
->nColors
;
1467 for (i
= 0; i
< pwdc
->nColors
; i
++) {
1468 pPal
->palPalEntry
[i
].peRed
= componentFromIndex( i
, rb
, rs
);
1469 pPal
->palPalEntry
[i
].peGreen
= componentFromIndex( i
, gb
, gs
);
1470 pPal
->palPalEntry
[i
].peBlue
= componentFromIndex( i
, bb
, bs
);
1471 pPal
->palPalEntry
[i
].peFlags
= 0;
1473 pwdc
->hGLPalette
= CreatePalette( pPal
);
1481 // This function sets the color table of a DIB section
1482 // to match that of the destination DC
1484 BOOL
/*WINAPI*/ wmSetDibColors(PWMC pwc
)
1486 RGBQUAD
*pColTab
, *pRGB
;
1487 PALETTEENTRY
*pPal
, *pPE
;
1492 /* Build a color table in the DIB that maps to the
1493 selected palette in the DC.
1495 nColors
= 1 << pwc
->cColorBits
;
1496 pPal
= (PALETTEENTRY
*)malloc( nColors
* sizeof(PALETTEENTRY
));
1497 memset( pPal
, 0, nColors
* sizeof(PALETTEENTRY
) );
1498 GetPaletteEntries( pwc
->hGLPalette
, 0, nColors
, pPal
);
1499 pColTab
= (RGBQUAD
*)malloc( nColors
* sizeof(RGBQUAD
));
1500 for (i
= 0, pRGB
= pColTab
, pPE
= pPal
; i
< nColors
; i
++, pRGB
++, pPE
++) {
1501 pRGB
->rgbRed
= pPE
->peRed
;
1502 pRGB
->rgbGreen
= pPE
->peGreen
;
1503 pRGB
->rgbBlue
= pPE
->peBlue
;
1506 bRet
= SetDIBColorTable(pwc
->hDC
, 0, nColors
, pColTab
);
1509 dwErr
= GetLastError();
1517 void /*WINAPI*/ wmSetPixel(PWMC pwc
, int iScanLine
, int iPixel
, BYTE r
, BYTE g
, BYTE b
)
1519 if(Current
->db_flag
){
1520 LPBYTE lpb
= pwc
->pbPixels
;
1523 UINT nBypp
= pwc
->cColorBits
/ 8;
1524 UINT nOffset
= iPixel
% nBypp
;
1526 // Move the pixel buffer pointer to the scanline that we
1529 pwc
->dib
.fFlushed
= FALSE
;
1531 lpb
+= pwc
->ScanWidth
* iScanLine
;
1532 // Now move to the desired pixel
1533 lpb
+= iPixel
* nBypp
;
1535 lpdw
= (LPDWORD
)lpb
;
1539 *lpw
= BGR16(r
,g
,b
);
1540 else if (nBypp
== 3){
1541 *lpdw
= BGR24(r
,g
,b
);
1544 *lpdw
= BGR32(r
,g
,b
);
1548 SetPixel(DC
, iPixel
, iScanLine
, RGB(r
,g
,b
));
1553 void /*WINAPI*/ wmCreateDIBSection(
1555 PWMC pwc
, // handle of device context
1556 CONST BITMAPINFO
*pbmi
, // address of structure containing bitmap size, format, and color data
1557 UINT iUsage
// color data type indicator: RGB values or palette indices
1562 UINT nBypp
= pwc
->cColorBits
/ 8;
1565 dwScanWidth
= (((pwc
->ScanWidth
* nBypp
)+ 3) & ~3);
1567 pwc
->ScanWidth
= dwScanWidth
;
1569 dwSize
= sizeof(BITMAPINFO
) + (dwScanWidth
* pwc
->height
);
1571 pwc
->dib
.hFileMap
= CreateFileMapping((HANDLE
)PAGE_FILE
,
1573 PAGE_READWRITE
| SEC_COMMIT
,
1578 if (!pwc
->dib
.hFileMap
)
1581 pwc
->dib
.base
= MapViewOfFile(pwc
->dib
.hFileMap
,
1582 FILE_MAP_ALL_ACCESS
,
1588 CloseHandle(pwc
->dib
.hFileMap
);
1592 pwc
->pbPixels
= ((LPBYTE
)pwc
->dib
.base
) + sizeof(BITMAPINFO
);
1594 pwc
->dib
.hDC
= CreateCompatibleDC(hDC
);
1596 CopyMemory(pwc
->dib
.base
, pbmi
, sizeof(BITMAPINFO
));
1598 hic
= CreateIC("display", NULL
, NULL
, NULL
);
1600 /* pwc->hbmDIB = CreateDIBitmap(hic,
1601 &(pwc->bmi.bmiHeader),
1607 pwc
->hbmDIB
= CreateDIBSection(hic
,
1608 &(pwc
->bmi
.bmiHeader
),
1613 pwc
->hOldBitmap
= SelectObject(pwc
->dib
.hDC
, pwc
->hbmDIB
);
1622 // Blit memory DC to screen DC
1624 BOOL
/*WINAPI*/ wmFlush(PWMC pwc
)
1630 // wmFlushBits(pwc);
1632 bRet
= BitBlt(pwc
->hDC
, 0, 0, pwc
->width
, pwc
->height
,
1633 pwc
->dib
.hDC
, 0, 0, SRCCOPY
);
1636 dwErr
= GetLastError();
1638 pwc
->dib
.fFlushed
= TRUE
;
1645 // The following code is added by Li Wei to enable stereo display
1647 #if !defined(NO_STEREO)
1649 void WMesaCreateStereoBuffer()
1651 /* Must use double buffer and not in parallelMode */
1652 if (! Current
->db_flag
1653 #if !defined(NO_PARALLEL)
1659 Buffer_Stereo
= malloc( Current
->ScanWidth
* Current
->height
);
1660 ZeroMemory(Buffer_Stereo
,Current
->ScanWidth
* Current
->height
);
1661 stereoBuffer
= GL_TRUE
;
1664 void WMesaDestroyStereoBuffer()
1666 /* Must use double buffer and not in parallelMode */
1667 if (! Current
->db_flag
1668 #if !defined(NO_PARALLEL)
1674 free(Buffer_Stereo
);
1675 stereoBuffer
= GL_FALSE
;
1679 void WMesaInterleave(GLenum aView
)
1689 dest
= Buffer_Stereo
+ offset
* Current
->ScanWidth
;
1690 if(Current
->rgb_flag
)
1691 src
= Current
->pbPixels
+ Current
->ScanWidth
*(Current
->height
/2);
1693 src
= Current
->ScreenMem
;
1695 for(line
= 0; line
<Current
->height
/2; line
++){
1696 CopyMemory(dest
, src
, Current
->ScanWidth
);
1697 dest
+= 2*Current
->ScanWidth
;
1698 src
+= Current
->ScanWidth
;
1701 if(Current
->rgb_flag
)
1702 CopyMemory(Current
->pbPixels
, Buffer_Stereo
, Current
->ScanWidth
*Current
->height
);
1704 CopyMemory(Current
->ScreenMem
, Buffer_Stereo
, Current
->ScanWidth
*Current
->height
);
1707 void WMesaShowStereo(GLuint list
)
1710 GLbitfield mask
= GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
;
1712 // Must use double Buffer
1713 if( ! Current
-> db_flag
)
1716 glViewport(0,0,Current
->width
,Current
->height
/2);
1718 glGetFloatv(GL_MODELVIEW_MATRIX
,cm
);
1719 glMatrixMode(GL_MODELVIEW
);
1721 gluLookAt(viewDistance
/2,0.0,0.0 ,
1722 viewDistance
/2,0.0,-1.0,
1724 glMultMatrixf( cm
);
1725 glMatrixMode(GL_MODELVIEW
);
1730 WMesaInterleave( FIRST
);
1732 glGetFloatv(GL_MODELVIEW_MATRIX
,cm
);
1733 glMatrixMode(GL_MODELVIEW
);
1735 gluLookAt(-viewDistance
/2,0.0,0.0 ,
1736 -viewDistance
/2,0.0,-1.0,
1739 glMatrixMode(GL_MODELVIEW
);
1742 WMesaInterleave( SECOND
);
1743 glViewport(0,0,Current
->width
,Current
->height
);
1748 void toggleStereoMode()
1750 if(!Current
->db_flag
)
1754 if(stereoBuffer
==GL_FALSE
)
1755 #if !defined(NO_PARALLEL)
1759 WMesaCreateStereoBuffer();
1764 if(stereoBuffer
==GL_TRUE
)
1765 #if !defined(NO_PARALLEL)
1768 if(stereoBuffer
==GL_TRUE
){
1769 WMesaDestroyStereoBuffer();
1774 /* if in stereo mode, the following function is called */
1775 void glShowStereo(GLuint list
)
1777 WMesaShowStereo(list
);
1780 #endif // End if NO_STEREO not defined
1782 #if !defined(NO_PARALLEL)
1784 void toggleParallelMode(void)
1787 parallelFlag
= GL_TRUE
;
1788 if(parallelMachine
==GL_FALSE
){
1789 PRCreateRenderBuffer( Current
->rgb_flag
? GL_RGBA
:GL_COLOR_INDEX
,
1790 Current
->cColorBits
/8,
1791 Current
->width
,Current
->height
,
1793 Current
->rgb_flag
? Current
->pbPixels
: Current
->ScreenMem
);
1794 parallelMachine
= GL_TRUE
;
1798 parallelFlag
= GL_FALSE
;
1799 if(parallelMachine
==GL_TRUE
){
1800 PRDestroyRenderBuffer();
1801 parallelMachine
=GL_FALSE
;
1802 ReadyForNextFrame
= GL_TRUE
;
1805 /***********************************************
1806 // Seems something wrong!!!!
1807 ************************************************/
1809 WMesaMakeCurrent(Current
);
1810 #if !defined(NO_STEREO)
1811 stereo_flag
= GL_FALSE
;
1816 void PRShowRenderResult(void)
1819 if(!glImageRendered())
1828 #endif //End if NO_PARALLEL not defined