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
, GLubyte r
, GLubyte g
, GLubyte b
, GLubyte a
)
158 Current
->clearpixel
=RGB(r
, g
, b
);
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
)
282 /* Set the index mode bitplane mask. */
283 static GLboolean
index_mask(GLcontext
* ctx
, GLuint mask
)
285 /* can't implement */
291 /* Set the RGBA drawing mask. */
292 static GLboolean
color_mask( GLcontext
* ctx
,
293 GLboolean rmask
, GLboolean gmask
,
294 GLboolean bmask
, GLboolean amask
)
296 /* can't implement */
302 static void dither( GLcontext
* ctx
, GLboolean enable
)
309 static GLboolean
set_buffer( GLcontext
* ctx
, GLenum mode
)
312 /* TODO: this could be better */
313 if (mode
==GL_FRONT
|| mode
==GL_BACK
) {
319 ENDPROFILE(set_buffer
)
324 /* Return characteristics of the output buffer. */
325 static void buffer_size( GLcontext
* ctx
, GLuint
*width
, GLuint
*height
/*, GLuint *depth */)
332 GetClientRect(Current
->Window
,&CR
);
336 // *depth = Current->depth;
338 New_Size
=((*width
)!=Current
->width
) || ((*height
)!=Current
->height
);
341 Current
->width
=*width
;
342 Current
->height
=*height
;
343 Current
->ScanWidth
=Current
->width
;
344 if ((Current
->ScanWidth
%sizeof(long))!=0)
345 Current
->ScanWidth
+=(sizeof(long)-(Current
->ScanWidth
%sizeof(long)));
347 if (Current
->db_flag
){
348 if (Current
->rgb_flag
==GL_TRUE
){
349 wmDeleteBackingStore(Current
);
350 wmCreateBackingStore(Current
, Current
->width
, Current
->height
);
353 Current
->ScanWidth
=Current
->width
;
354 if ((Current
->ScanWidth
%sizeof(long))!=0)
355 Current
->ScanWidth
+=(sizeof(long)-(Current
->ScanWidth
%sizeof(long)));
357 Current
->IndexFormat
->bmiHeader
.biWidth
=Current
->width
;
359 if (Current
->IndexFormat
->bmiHeader
.biHeight
<0)
360 Current
->IndexFormat
->bmiHeader
.biHeight
=-(Current
->height
);
362 Current
->IndexFormat
->bmiHeader
.biHeight
=Current
->height
;
364 Current
->Compat_BM
=WinGCreateBitmap(Current
->dib
.hDC
,Current
->IndexFormat
,&((void *) Current
->ScreenMem
));
366 DeleteObject(SelectObject(Current
->dib
.hDC
,Current
->Compat_BM
));
368 //Code added by Li Wei to enable stereo display
369 // Recreate stereo buffer when stereo_flag is TRUE while parallelFlag is FALSE
370 #if !defined(NO_STEREO)
372 #if !defined(NO_PARALLEL)
376 if(stereoBuffer
== GL_TRUE
)
377 WMesaDestroyStereoBuffer();
378 WMesaCreateStereoBuffer();
381 // Resize OsmesaBuffer if in Parallel mode
382 #if !defined(NO_PARALLEL)
384 PRSizeRenderBuffer(Current
->width
, Current
->height
,Current
->ScanWidth
,
385 Current
->rgb_flag
== GL_TRUE
? Current
->pbPixels
: Current
->ScreenMem
);
392 ENDPROFILE(buffer_size
)
397 /**********************************************************************/
398 /***** Accelerated point, line, polygon rendering *****/
399 /**********************************************************************/
402 static void fast_rgb_points( GLcontext
* ctx
, GLuint first
, GLuint last
)
410 if (Current
->gl_ctx
->VB
->MonoColor
) {
411 /* all drawn with current color */
412 for (i
=first
;i
<=last
;i
++) {
413 if (Current
->gl_ctx
->VB
->ClipMask
[i
]==0) {
415 x
= (GLint
) Current
->gl_ctx
->VB
->Win
[i
][0];
416 y
= FLIP( (GLint
) Current
->gl_ctx
->VB
->Win
[i
][1] );
417 wmSetPixel(pwc
, y
,x
,GetRValue(Current
->pixel
),
418 GetGValue(Current
->pixel
), GetBValue(Current
->pixel
));
423 /* draw points of different colors */
424 for (i
=first
;i
<=last
;i
++) {
425 if (Current
->gl_ctx
->VB
->ClipMask
[i
]==0) {
427 unsigned long pixel
=RGB(Current
->gl_ctx
->VB
->Color
[i
][0]*255.0,
428 Current
->gl_ctx
->VB
->Color
[i
][1]*255.0,
429 Current
->gl_ctx
->VB
->Color
[i
][2]*255.0);
430 x
= (GLint
) Current
->gl_ctx
->VB
->Win
[i
][0];
431 y
= FLIP( (GLint
) Current
->gl_ctx
->VB
->Win
[i
][1] );
432 wmSetPixel(pwc
, y
,x
,Current
->gl_ctx
->VB
->Color
[i
][0]*255.0,
433 Current
->gl_ctx
->VB
->Color
[i
][1]*255.0,
434 Current
->gl_ctx
->VB
->Color
[i
][2]*255.0);
439 ENDPROFILE(fast_rgb_points
)
444 /* Return pointer to accerated points function */
445 extern points_func
choose_points_function( GLcontext
* ctx
)
448 if (ctx
->Point
.Size
==1.0 && !ctx
->Point
.SmoothFlag
&& ctx
->RasterMask
==0
449 && !ctx
->Texture
.Enabled
&& ctx
->Visual
->RGBAflag
) {
450 ENDPROFILE(choose_points_function
)
451 return fast_rgb_points
;
454 ENDPROFILE(choose_points_function
)
461 /* Draw a line using the color specified by Current->gl_ctx->VB->Color[pv] */
462 static void fast_flat_rgb_line( GLcontext
* ctx
, GLuint v0
, GLuint v1
, GLuint pv
)
471 if (Current
->gl_ctx
->VB
->MonoColor
) {
472 pixel
= Current
->pixel
; /* use current color */
475 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);
478 x0
= (int) Current
->gl_ctx
->VB
->Win
[v0
][0];
479 y0
= FLIP( (int) Current
->gl_ctx
->VB
->Win
[v0
][1] );
480 x1
= (int) Current
->gl_ctx
->VB
->Win
[v1
][0];
481 y1
= FLIP( (int) Current
->gl_ctx
->VB
->Win
[v1
][1] );
486 Pen
=CreatePen(PS_SOLID
,1,pixel
);
487 Old_Pen
=SelectObject(DC
,Pen
);
488 MoveToEx(DC
,x0
,y0
,NULL
);
490 SelectObject(DC
,Old_Pen
);
496 ENDPROFILE(fast_flat_rgb_line
)
501 /* Return pointer to accerated line function */
502 static line_func
choose_line_function( GLcontext
* ctx
)
505 if (ctx
->Line
.Width
==1.0 && !ctx
->Line
.SmoothFlag
&& !ctx
->Line
.StippleFlag
506 && ctx
->Light
.ShadeModel
==GL_FLAT
&& ctx
->RasterMask
==0
507 && !ctx
->Texture
.Enabled
&& Current
->rgb_flag
) {
508 ENDPROFILE(choose_line_function
)
509 return fast_flat_rgb_line
;
512 ENDPROFILE(choose_line_function
)
517 /**********************************************************************/
518 /***** Optimized triangle rendering *****/
519 /**********************************************************************/
523 * Smooth-shaded, z-less triangle, RGBA color.
525 static void smooth_color_z_triangle( GLcontext
*ctx
, GLuint v0
, GLuint v1
,
526 GLuint v2
, GLuint pv
)
528 UINT nBypp
= Current
->cColorBits
/ 8;
531 GLuint
*img24
,*img32
;
534 #define INTERP_ALPHA 1
535 #define INNER_LOOP( LEFT, RIGHT, Y ) \
537 GLint i, len = RIGHT-LEFT; \
538 img = PIXELADDR(LEFT,Y); \
539 for (i=0;i<len;i++,img+=nBypp) { \
540 GLdepth z = FixedToDepth(ffz); \
542 img16 = img24 = img32 = img; \
544 *img16 = BGR16( FixedToInt(ffr), FixedToInt(ffg), \
547 *img24 = BGR24( FixedToInt(ffr), FixedToInt(ffg), \
550 *img32 = BGR32( FixedToInt(ffr), FixedToInt(ffg), \
554 ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; ffa += fdadx;\
566 * Flat-shaded, z-less triangle, RGBA color.
568 static void flat_color_z_triangle( GLcontext
*ctx
, GLuint v0
, GLuint v1
,
569 GLuint v2
, GLuint pv
)
573 GLuint
*img24
, *img32
;
574 UINT nBypp
= Current
->cColorBits
/ 8;
576 GLushort pixel16
= BGR16(r
,g
,b
);
577 GLuint pixel24
= BGR24(r
,g
,b
);
578 GLuint pixel32
= BGR32(r
,g
,b
);
582 r = VB->Color[pv][0]; \
583 g = VB->Color[pv][1]; \
584 b = VB->Color[pv][2];
586 #define INNER_LOOP( LEFT, RIGHT, Y ) \
588 GLint i, len = RIGHT-LEFT; \
589 img = PIXELADDR(LEFT,Y); \
590 for (i=0;i<len;i++,img+=nBypp) { \
591 GLdepth z = FixedToDepth(ffz); \
593 img16 = img24 = img32 = img; \
612 * Return pointer to an accelerated triangle function if possible.
614 static triangle_func
choose_triangle_function( GLcontext
*ctx
)
616 if (ctx
->Polygon
.SmoothFlag
) return NULL
;
617 if (ctx
->Polygon
.StippleFlag
) return NULL
;
618 if (ctx
->Texture
.Enabled
) return NULL
;
620 if (ctx
->RasterMask
==DEPTH_BIT
621 && ctx
->Depth
.Func
==GL_LESS
622 && ctx
->Depth
.Mask
==GL_TRUE
623 && ctx
->Visual
->RGBAflag
) {
624 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
625 return smooth_color_z_triangle
;
628 return flat_color_z_triangle
;
635 /* Draw a convex polygon using color Current->gl_ctx->VB->Color[pv] */
636 static void fast_flat_rgb_polygon( GLcontext
* ctx
, GLuint n
, GLuint vlist
[], GLuint pv
)
639 POINT
*Pts
=(POINT
*) malloc(n
*sizeof(POINT
));
648 if (Current
->gl_ctx
->VB
->MonoColor
) {
649 pixel
= Current
->pixel
; /* use current color */
652 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);
655 Pen
=CreatePen(PS_SOLID
,1,pixel
);
656 Brush
=CreateSolidBrush(pixel
);
657 Old_Pen
=SelectObject(DC
,Pen
);
658 Old_Brush
=SelectObject(DC
,Brush
);
660 for (i
=0; i
<n
; i
++) {
662 Pts
[i
].x
= (int) Current
->gl_ctx
->VB
->Win
[j
][0];
663 Pts
[i
].y
= FLIP( (int) Current
->gl_ctx
->VB
->Win
[j
][1] );
669 SelectObject(DC
,Old_Pen
);
670 SelectObject(DC
,Old_Brush
);
678 ENDPROFILE(fast_flat_rgb_polygon
)
683 /* Return pointer to accerated polygon function */
684 static polygon_func
choose_polygon_function( GLcontext
* ctx
)
687 if (!ctx
->Polygon
.SmoothFlag
&& !ctx
->Polygon
.StippleFlag
688 && ctx
->Light
.ShadeModel
==GL_FLAT
&& ctx
->RasterMask
==0
689 && !ctx
->Texture
.Enabled
&& Current
->rgb_flag
==GL_TRUE
) {
690 ENDPROFILE(choose_polygon_function
)
691 return fast_flat_rgb_polygon
;
694 ENDPROFILE(choose_polygon_function
)
701 /**********************************************************************/
702 /***** Span-based pixel drawing *****/
703 /**********************************************************************/
706 /* Write a horizontal span of color-index pixels with a boolean mask. */
707 static void write_index_span( GLcontext
* ctx
,
708 GLuint n
, GLint x
, GLint y
,
709 const GLuint index
[],
710 const GLubyte mask
[] )
714 char *Mem
=Current
->ScreenMem
+y
*Current
->ScanWidth
+x
;
715 assert(Current
->rgb_flag
==GL_FALSE
);
719 ENDPROFILE(write_index_span
)
725 * Write a horizontal span of pixels with a boolean mask. The current
726 * color index is used for all pixels.
728 static void write_monoindex_span(GLcontext
* ctx
,
729 GLuint n
,GLint x
,GLint y
,
730 const GLubyte mask
[])
734 char *Mem
=Current
->ScreenMem
+y
*Current
->ScanWidth
+x
;
735 assert(Current
->rgb_flag
==GL_FALSE
);
738 Mem
[i
]=Current
->pixel
;
739 ENDPROFILE(write_monoindex_span
)
743 To improve the performance of this routine, frob the data into an actual scanline
744 and call bitblt on the complete scan line instead of SetPixel.
747 /* Write a horizontal span of color pixels with a boolean mask. */
748 static void write_color_span( GLcontext
* ctx
,
749 GLuint n
, GLint x
, GLint y
,
751 red
[], const GLubyte green
[],
752 const GLubyte blue
[], const GLubyte alpha
[],
753 const GLubyte mask
[] )
759 if (pwc
->rgb_flag
==GL_TRUE
)
768 wmSetPixel(pwc
, y
, x
+ i
,red
[i
], green
[i
], blue
[i
]);
773 wmSetPixel(pwc
, y
, x
+ i
, red
[i
], green
[i
], blue
[i
]);
783 char *Mem
=Current
->ScreenMem
+y
*Current
->ScanWidth
+x
;
787 Mem
[i
]=GetNearestPaletteIndex(Current
->hPal
,RGB(red
[i
],green
[i
],blue
[i
]));
791 Mem
[i
]=GetNearestPaletteIndex(Current
->hPal
,RGB(red
[i
],green
[i
],blue
[i
]));
794 ENDPROFILE(write_color_span
)
799 * Write a horizontal span of pixels with a boolean mask. The current color
800 * is used for all pixels.
802 static void write_monocolor_span( GLcontext
* ctx
,
803 GLuint n
, GLint x
, GLint y
,
804 const GLubyte mask
[])
811 assert(Current
->rgb_flag
==GL_TRUE
);
814 if(Current
->rgb_flag
==GL_TRUE
){
818 wmSetPixel(pwc
,y
,x
+i
,GetRValue(Current
->pixel
), GetGValue(Current
->pixel
), GetBValue(Current
->pixel
));
823 SetPixel(DC
, y
, x
+i
, Current
->pixel
);
828 ENDPROFILE(write_monocolor_span
)
833 /**********************************************************************/
834 /***** Array-based pixel drawing *****/
835 /**********************************************************************/
838 /* Write an array of pixels with a boolean mask. */
839 static void write_index_pixels( GLcontext
* ctx
,
840 GLuint n
, const GLint x
[], const GLint y
[],
841 const GLuint index
[], const GLubyte mask
[] )
845 assert(Current
->rgb_flag
==GL_FALSE
);
846 for (i
=0; i
<n
; i
++) {
848 char *Mem
=Current
->ScreenMem
+y
[i
]*Current
->ScanWidth
+x
[i
];
852 ENDPROFILE(write_index_pixels
)
858 * Write an array of pixels with a boolean mask. The current color
859 * index is used for all pixels.
861 static void write_monoindex_pixels( GLcontext
* ctx
,
863 const GLint x
[], const GLint y
[],
864 const GLubyte mask
[] )
868 assert(Current
->rgb_flag
==GL_FALSE
);
869 for (i
=0; i
<n
; i
++) {
871 char *Mem
=Current
->ScreenMem
+y
[i
]*Current
->ScanWidth
+x
[i
];
872 *Mem
= Current
->pixel
;
875 ENDPROFILE(write_monoindex_pixels
)
880 /* Write an array of pixels with a boolean mask. */
881 static void write_color_pixels( GLcontext
* ctx
,
882 GLuint n
, const GLint x
[], const GLint y
[],
883 const GLubyte r
[], const GLubyte g
[],
884 const GLubyte b
[], const GLubyte a
[],
885 const GLubyte mask
[] )
891 assert(Current
->rgb_flag
==GL_TRUE
);
894 wmSetPixel(pwc
, FLIP(y
[i
]),x
[i
],r
[i
],g
[i
],b
[i
]);
896 ENDPROFILE(write_color_pixels
)
902 * Write an array of pixels with a boolean mask. The current color
903 * is used for all pixels.
905 static void write_monocolor_pixels( GLcontext
* ctx
,
907 const GLint x
[], const GLint y
[],
908 const GLubyte mask
[] )
914 assert(Current
->rgb_flag
==GL_TRUE
);
917 wmSetPixel(pwc
, FLIP(y
[i
]),x
[i
],GetRValue(Current
->pixel
),
918 GetGValue(Current
->pixel
), GetBValue(Current
->pixel
));
920 ENDPROFILE(write_monocolor_pixels
)
925 /**********************************************************************/
926 /***** Read spans/arrays of pixels *****/
927 /**********************************************************************/
930 /* Read a horizontal span of color-index pixels. */
931 static void read_index_span( GLcontext
* ctx
, GLuint n
, GLint x
, GLint y
, GLuint index
[])
935 char *Mem
=Current
->ScreenMem
+y
*Current
->ScanWidth
+x
;
936 assert(Current
->rgb_flag
==GL_FALSE
);
939 ENDPROFILE(read_index_span
)
946 /* Read an array of color index pixels. */
947 static void read_index_pixels( GLcontext
* ctx
,
948 GLuint n
, const GLint x
[], const GLint y
[],
949 GLuint indx
[], const GLubyte mask
[] )
953 assert(Current
->rgb_flag
==GL_FALSE
);
954 for (i
=0; i
<n
; i
++) {
956 indx
[i
]=*(Current
->ScreenMem
+y
[i
]*Current
->ScanWidth
+x
[i
]);
959 ENDPROFILE(read_index_pixels
)
964 /* Read a horizontal span of color pixels. */
965 static void read_color_span( GLcontext
* ctx
,
966 GLuint n
, GLint x
, GLint y
,
967 GLubyte red
[], GLubyte green
[],
968 GLubyte blue
[], GLubyte alpha
[] )
974 assert(Current
->rgb_flag
==GL_TRUE
);
978 Color
=GetPixel(DC
,x
+i
,y
);
979 red
[i
]=GetRValue(Color
);
980 green
[i
]=GetGValue(Color
);
981 blue
[i
]=GetBValue(Color
);
985 memset(alpha
,0,n
*sizeof(GLint
));
986 ENDPROFILE(read_color_span
)
990 /* Read an array of color pixels. */
991 static void read_color_pixels( GLcontext
* ctx
,
992 GLuint n
, const GLint x
[], const GLint y
[],
993 GLubyte red
[], GLubyte green
[],
994 GLubyte blue
[], GLubyte alpha
[],
995 const GLubyte mask
[] )
1001 assert(Current
->rgb_flag
==GL_TRUE
);
1002 for (i
=0; i
<n
; i
++) {
1004 Color
=GetPixel(DC
,x
[i
],FLIP(y
[i
]));
1005 red
[i
]=GetRValue(Color
);
1006 green
[i
]=GetGValue(Color
);
1007 blue
[i
]=GetBValue(Color
);
1012 memset(alpha
,0,n
*sizeof(GLint
));
1013 ENDPROFILE(read_color_pixels
)
1018 /**********************************************************************/
1019 /**********************************************************************/
1023 void setup_DD_pointers( GLcontext
* ctx
)
1025 ctx
->Driver
.Finish
= finish
;
1026 ctx
->Driver
.Flush
= flush
;
1028 ctx
->Driver
.ClearIndex
= clear_index
;
1029 ctx
->Driver
.ClearColor
= clear_color
;
1030 ctx
->Driver
.Clear
= clear
;
1032 ctx
->Driver
.Index
= set_index
;
1033 ctx
->Driver
.Color
= set_color
;
1034 ctx
->Driver
.IndexMask
= index_mask
;
1035 ctx
->Driver
.ColorMask
= color_mask
;
1037 ctx
->Driver
.Dither
= dither
;
1039 ctx
->Driver
.SetBuffer
= set_buffer
;
1040 ctx
->Driver
.GetBufferSize
= buffer_size
;
1042 ctx
->Driver
.PointsFunc
= choose_points_function(ctx
);
1043 ctx
->Driver
.LineFunc
= choose_line_function(ctx
);
1044 ctx
->Driver
.TriangleFunc
= choose_triangle_function( ctx
);
1045 // ctx->Driver.TriangleFunc = choose_polygon_function(ctx);
1047 /* Pixel/span writing functions: */
1048 ctx
->Driver
.WriteColorSpan
= write_color_span
;
1049 ctx
->Driver
.WriteMonocolorSpan
= write_monocolor_span
;
1050 ctx
->Driver
.WriteColorPixels
= write_color_pixels
;
1051 ctx
->Driver
.WriteMonocolorPixels
= write_monocolor_pixels
;
1052 ctx
->Driver
.WriteIndexSpan
= write_index_span
;
1053 ctx
->Driver
.WriteMonoindexSpan
= write_monoindex_span
;
1054 ctx
->Driver
.WriteIndexPixels
= write_index_pixels
;
1055 ctx
->Driver
.WriteMonoindexPixels
= write_monoindex_pixels
;
1057 /* Pixel/span reading functions: */
1058 ctx
->Driver
.ReadIndexSpan
= read_index_span
;
1059 ctx
->Driver
.ReadColorSpan
= read_color_span
;
1060 ctx
->Driver
.ReadIndexPixels
= read_index_pixels
;
1061 ctx
->Driver
.ReadColorPixels
= read_color_pixels
;
1065 // MesaGL32 is the DLL version of MesaGL for Win32
1068 /**********************************************************************/
1069 /***** WMesa API Functions *****/
1070 /**********************************************************************/
1074 #define PAL_SIZE 256
1075 static void GetPalette(HPALETTE Pal
,RGBQUAD
*aRGB
)
1083 WORD NumberOfEntries
;
1084 PALETTEENTRY aEntries
[PAL_SIZE
];
1092 GetPaletteEntries(Pal
,0,PAL_SIZE
,Palette
.aEntries
);
1094 GetSystemPaletteEntries(hdc
,0,PAL_SIZE
,Palette
.aEntries
);
1095 if (GetSystemPaletteUse(hdc
) == SYSPAL_NOSTATIC
)
1097 for(i
= 0; i
<PAL_SIZE
; i
++)
1098 Palette
.aEntries
[i
].peFlags
= PC_RESERVED
;
1099 Palette
.aEntries
[255].peRed
= 255;
1100 Palette
.aEntries
[255].peGreen
= 255;
1101 Palette
.aEntries
[255].peBlue
= 255;
1102 Palette
.aEntries
[255].peFlags
= 0;
1103 Palette
.aEntries
[0].peRed
= 0;
1104 Palette
.aEntries
[0].peGreen
= 0;
1105 Palette
.aEntries
[0].peBlue
= 0;
1106 Palette
.aEntries
[0].peFlags
= 0;
1112 nStaticColors
= GetDeviceCaps(hdc
, NUMCOLORS
)/2;
1113 for (i
=0; i
<nStaticColors
; i
++)
1114 Palette
.aEntries
[i
].peFlags
= 0;
1115 nUsableColors
= PAL_SIZE
-nStaticColors
;
1116 for (; i
<nUsableColors
; i
++)
1117 Palette
.aEntries
[i
].peFlags
= PC_RESERVED
;
1118 for (; i
<PAL_SIZE
-nStaticColors
; i
++)
1119 Palette
.aEntries
[i
].peFlags
= PC_RESERVED
;
1120 for (i
=PAL_SIZE
-nStaticColors
; i
<PAL_SIZE
; i
++)
1121 Palette
.aEntries
[i
].peFlags
= 0;
1123 ReleaseDC(NULL
,hdc
);
1124 for (i
=0; i
<PAL_SIZE
; i
++)
1126 aRGB
[i
].rgbRed
=Palette
.aEntries
[i
].peRed
;
1127 aRGB
[i
].rgbGreen
=Palette
.aEntries
[i
].peGreen
;
1128 aRGB
[i
].rgbBlue
=Palette
.aEntries
[i
].peBlue
;
1129 aRGB
[i
].rgbReserved
=Palette
.aEntries
[i
].peFlags
;
1131 ENDPROFILE(GetPalette
)
1135 WMesaContext
/*APIENTRY*/ WMesaCreateContext( HWND hWnd
, HPALETTE Pal
,
1136 /*HDC hDC,*/ GLboolean rgb_flag
,
1144 c
= (struct wmesa_context
* ) calloc(1,sizeof(struct wmesa_context
));
1149 c
->hDC
= GetDC(hWnd
);
1151 if (rgb_flag
==GL_FALSE
)
1153 c
->rgb_flag
= GL_FALSE
;
1155 db_flag
=GL_TRUE
; // WinG requires double buffering
1156 //c->gl_ctx->BufferDepth = windepth;
1160 c
->rgb_flag
= GL_TRUE
;
1163 GetClientRect(c
->Window
,&CR
);
1165 c
->height
=CR
.bottom
;
1169 // c->hDC GetDC(c->Window);
1170 /* Double buffered */
1171 if (c
->rgb_flag
==GL_TRUE
)
1173 //DC = c->hDC = hDC;
1175 // DC = c->hDC = GetDC(c->Window);
1176 wmCreateBackingStore(c
, c
->width
, c
->height
);
1177 // ReleaseDC(c->Window,DC);
1181 c
->dib
.hDC
=WinGCreateDC();
1182 Rec
=(BITMAPINFO
*) malloc(sizeof(BITMAPINFO
)+(PAL_SIZE
-1)*sizeof(RGBQUAD
));
1184 GetPalette(Pal
,Rec
->bmiColors
);
1185 WinGRecommendDIBFormat(Rec
);
1186 Rec
->bmiHeader
.biWidth
=c
->width
;
1187 Rec
->bmiHeader
.biHeight
*=c
->height
;
1188 Rec
->bmiHeader
.biClrUsed
=PAL_SIZE
;
1189 if (Rec
->bmiHeader
.biPlanes
!=1 || Rec
->bmiHeader
.biBitCount
!=8)
1191 MessageBox(NULL
,"Error.","This code presumes a 256 color, single plane, WinG Device.\n",MB_OK
);
1194 c
->Compat_BM
=WinGCreateBitmap(c
->dib
.hDC
,Rec
,&((void *) c
->ScreenMem
));
1195 c
->Old_Compat_BM
=SelectObject(c
->dib
.hDC
,c
->Compat_BM
);
1196 WinGSetDIBColorTable(c
->dib
.hDC
,0,PAL_SIZE
,Rec
->bmiColors
);
1198 c
->ScanWidth
=c
->width
;
1200 if ((c
->ScanWidth
%sizeof(long))!=0)
1201 c
->ScanWidth
+=(sizeof(long)-(c
->ScanWidth
%sizeof(long)));
1206 /* Single Buffered */
1209 // wmCreateBackingStore(c, c->width, c->height);
1214 c
->gl_visual
= gl_create_visual(rgb_flag
,
1215 GL_FALSE
, /* software alpha */
1216 db_flag
, /* db_flag */
1217 16, /* depth_bits */
1218 8, /* stencil_bits */
1221 255.0, 255.0, 255.0, 255.0 );
1223 if (!c
->gl_visual
) {
1227 /* allocate a new Mesa context */
1228 c
->gl_ctx
= gl_create_context( c
->gl_visual
, NULL
,c
);
1231 gl_destroy_visual( c
->gl_visual
);
1236 c
->gl_buffer
= gl_create_framebuffer( c
->gl_visual
);
1237 if (!c
->gl_buffer
) {
1238 gl_destroy_visual( c
->gl_visual
);
1239 gl_destroy_context( c
->gl_ctx
);
1243 // setup_DD_pointers(c->gl_ctx);
1250 void /*APIENTRY*/ WMesaDestroyContext( void )
1252 WMesaContext c
= Current
;
1253 ReleaseDC(c
->Window
,c
->hDC
);
1256 gl_destroy_visual( c
->gl_visual
);
1257 gl_destroy_framebuffer( c
->gl_buffer
);
1258 gl_destroy_context( c
->gl_ctx
);
1261 wmDeleteBackingStore(c
);
1263 //Code added by Li Wei to enable parallel render
1264 #if !defined(NO_STEREO)
1265 if(stereoBuffer
==GL_TRUE
){
1266 WMesaDestroyStereoBuffer();
1267 stereoBuffer
=GL_FALSE
;
1273 //Code added by Li Wei to enable parallel render
1274 // Parallel render only work in double buffer mode
1275 #if !defined(NO_PARALLEL)
1277 PRDestroyRenderBuffer();
1284 void /*APIENTRY*/ WMesaMakeCurrent( WMesaContext c
)
1292 // A little optimization
1293 // If it already is current,
1294 // don't set it again
1299 //gl_set_context( c->gl_ctx );
1300 gl_make_current(c
->gl_ctx
, c
->gl_buffer
);
1302 setup_DD_pointers(c
->gl_ctx
);
1303 if (Current
->gl_ctx
->Viewport
.Width
==0) {
1304 /* initialize viewport to window size */
1305 gl_Viewport( Current
->gl_ctx
,
1306 0, 0, Current
->width
, Current
->height
);
1312 void /*APIENTRY*/ WMesaSwapBuffers( void )
1314 HDC DC
= Current
->hDC
;
1315 if (Current
->db_flag
)
1317 if (Current
->rgb_flag
)
1320 WinGBitBlt(DC
,0,0,Current
->width
,Current
->height
,Current
->dib
.hDC
,0,0);
1326 void /*APIENTRY*/ WMesaPaletteChange(HPALETTE Pal
)
1328 if (Current
&& Current
->rgb_flag
==GL_FALSE
)
1331 GetPalette(Pal
,Current
->IndexFormat
->bmiColors
);
1332 WinGSetDIBColorTable(Current
->dib
.hDC
,0,PAL_SIZE
,Current
->IndexFormat
->bmiColors
);
1337 // Free up the dib section that was created
1339 BOOL
wmDeleteBackingStore(PWMC pwc
)
1341 SelectObject(pwc
->dib
.hDC
, pwc
->hOldBitmap
);
1342 DeleteDC(pwc
->dib
.hDC
);
1343 DeleteObject(pwc
->hbmDIB
);
1344 UnmapViewOfFile(pwc
->dib
.base
);
1345 CloseHandle(pwc
->dib
.hFileMap
);
1351 // This function creates the DIB section that is used for combined
1354 BOOL
/*WINAPI*/ wmCreateBackingStore(PWMC pwc
, long lxSize
, long lySize
)
1357 LPBITMAPINFO pbmi
= &(pwc
->bmi
);
1360 pbmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1361 pbmi
->bmiHeader
.biWidth
= lxSize
;
1362 pbmi
->bmiHeader
.biHeight
= -lySize
;
1363 pbmi
->bmiHeader
.biPlanes
= 1;
1364 pbmi
->bmiHeader
.biBitCount
= GetDeviceCaps(pwc
->hDC
, BITSPIXEL
);
1365 pbmi
->bmiHeader
.biCompression
= BI_RGB
;
1366 pbmi
->bmiHeader
.biSizeImage
= 0;
1367 pbmi
->bmiHeader
.biXPelsPerMeter
= 0;
1368 pbmi
->bmiHeader
.biYPelsPerMeter
= 0;
1369 pbmi
->bmiHeader
.biClrUsed
= 0;
1370 pbmi
->bmiHeader
.biClrImportant
= 0;
1372 iUsage
= (pbmi
->bmiHeader
.biBitCount
<= 8) ? DIB_PAL_COLORS
: DIB_RGB_COLORS
;
1374 pwc
->cColorBits
= pbmi
->bmiHeader
.biBitCount
;
1375 pwc
->ScanWidth
= lxSize
;
1377 wmCreateDIBSection(hdc
, pwc
, pbmi
, iUsage
);
1379 if ((iUsage
== DIB_PAL_COLORS
) && !(pwc
->hGLPalette
)) {
1380 wmCreatePalette( pwc
);
1381 wmSetDibColors( pwc
);
1390 // This function copies one scan line in a DIB section to another
1392 BOOL GLWINAPI
wmSetDIBits(PWMC pwc
, UINT uiScanWidth
, UINT uiNumScans
, UINT nBypp
, UINT uiNewWidth
, LPBYTE pBits
)
1395 LPBYTE pDest
= pwc
->pbPixels
;
1396 DWORD dwNextScan
= uiScanWidth
;
1397 DWORD dwNewScan
= uiNewWidth
;
1398 DWORD dwScanWidth
= (uiScanWidth
* nBypp
);
1401 // We need to round up to the nearest DWORD
1402 // and multiply by the number of bytes per
1405 dwNextScan
= (((dwNextScan
* nBypp
)+ 3) & ~3);
1406 dwNewScan
= (((dwNewScan
* nBypp
)+ 3) & ~3);
1408 for(uiScans
= 0; uiScans
< uiNumScans
; uiScans
++){
1409 CopyMemory(pDest
, pBits
, dwScanWidth
);
1410 pBits
+= dwNextScan
;
1418 BOOL GLWINAPI
wmSetPixelFormat( PWMC pwdc
, HDC hDC
, DWORD dwFlags
)
1423 static unsigned char threeto8
[8] = {
1424 0, 0111>>1, 0222>>1, 0333>>1, 0444>>1, 0555>>1, 0666>>1, 0377
1427 static unsigned char twoto8
[4] = {
1431 static unsigned char oneto8
[2] = {
1435 static unsigned char componentFromIndex(UCHAR i
, UINT nbits
, UINT shift
)
1452 return threeto8
[val
];
1459 void /*WINAPI*/ wmCreatePalette( PWMC pwdc
)
1461 /* Create a compressed and re-expanded 3:3:2 palette */
1464 BYTE rb
, rs
, gb
, gs
, bb
, bs
;
1466 pwdc
->nColors
= 0x100;
1468 pPal
= (PLOGPALETTE
)malloc(sizeof(LOGPALETTE
) + pwdc
->nColors
* sizeof(PALETTEENTRY
));
1469 memset( pPal
, 0, sizeof(LOGPALETTE
) + pwdc
->nColors
* sizeof(PALETTEENTRY
) );
1471 pPal
->palVersion
= 0x300;
1480 if (pwdc
->db_flag
) {
1482 /* Need to make two palettes: one for the screen DC and one for the DIB. */
1483 pPal
->palNumEntries
= pwdc
->nColors
;
1484 for (i
= 0; i
< pwdc
->nColors
; i
++) {
1485 pPal
->palPalEntry
[i
].peRed
= componentFromIndex( i
, rb
, rs
);
1486 pPal
->palPalEntry
[i
].peGreen
= componentFromIndex( i
, gb
, gs
);
1487 pPal
->palPalEntry
[i
].peBlue
= componentFromIndex( i
, bb
, bs
);
1488 pPal
->palPalEntry
[i
].peFlags
= 0;
1490 pwdc
->hGLPalette
= CreatePalette( pPal
);
1491 pwdc
->hPalette
= CreatePalette( pPal
);
1495 pPal
->palNumEntries
= pwdc
->nColors
;
1496 for (i
= 0; i
< pwdc
->nColors
; i
++) {
1497 pPal
->palPalEntry
[i
].peRed
= componentFromIndex( i
, rb
, rs
);
1498 pPal
->palPalEntry
[i
].peGreen
= componentFromIndex( i
, gb
, gs
);
1499 pPal
->palPalEntry
[i
].peBlue
= componentFromIndex( i
, bb
, bs
);
1500 pPal
->palPalEntry
[i
].peFlags
= 0;
1502 pwdc
->hGLPalette
= CreatePalette( pPal
);
1510 // This function sets the color table of a DIB section
1511 // to match that of the destination DC
1513 BOOL
/*WINAPI*/ wmSetDibColors(PWMC pwc
)
1515 RGBQUAD
*pColTab
, *pRGB
;
1516 PALETTEENTRY
*pPal
, *pPE
;
1521 /* Build a color table in the DIB that maps to the
1522 selected palette in the DC.
1524 nColors
= 1 << pwc
->cColorBits
;
1525 pPal
= (PALETTEENTRY
*)malloc( nColors
* sizeof(PALETTEENTRY
));
1526 memset( pPal
, 0, nColors
* sizeof(PALETTEENTRY
) );
1527 GetPaletteEntries( pwc
->hGLPalette
, 0, nColors
, pPal
);
1528 pColTab
= (RGBQUAD
*)malloc( nColors
* sizeof(RGBQUAD
));
1529 for (i
= 0, pRGB
= pColTab
, pPE
= pPal
; i
< nColors
; i
++, pRGB
++, pPE
++) {
1530 pRGB
->rgbRed
= pPE
->peRed
;
1531 pRGB
->rgbGreen
= pPE
->peGreen
;
1532 pRGB
->rgbBlue
= pPE
->peBlue
;
1535 bRet
= SetDIBColorTable(pwc
->hDC
, 0, nColors
, pColTab
);
1538 dwErr
= GetLastError();
1546 void /*WINAPI*/ wmSetPixel(PWMC pwc
, int iScanLine
, int iPixel
, BYTE r
, BYTE g
, BYTE b
)
1548 if(Current
->db_flag
){
1549 LPBYTE lpb
= pwc
->pbPixels
;
1552 UINT nBypp
= pwc
->cColorBits
/ 8;
1553 UINT nOffset
= iPixel
% nBypp
;
1555 // Move the pixel buffer pointer to the scanline that we
1558 pwc
->dib
.fFlushed
= FALSE
;
1560 lpb
+= pwc
->ScanWidth
* iScanLine
;
1561 // Now move to the desired pixel
1562 lpb
+= iPixel
* nBypp
;
1564 lpdw
= (LPDWORD
)lpb
;
1568 *lpw
= BGR16(r
,g
,b
);
1569 else if (nBypp
== 3){
1570 *lpdw
= BGR24(r
,g
,b
);
1573 *lpdw
= BGR32(r
,g
,b
);
1577 SetPixel(DC
, iPixel
, iScanLine
, RGB(r
,g
,b
));
1582 void /*WINAPI*/ wmCreateDIBSection(
1584 PWMC pwc
, // handle of device context
1585 CONST BITMAPINFO
*pbmi
, // address of structure containing bitmap size, format, and color data
1586 UINT iUsage
// color data type indicator: RGB values or palette indices
1591 UINT nBypp
= pwc
->cColorBits
/ 8;
1594 dwScanWidth
= (((pwc
->ScanWidth
* nBypp
)+ 3) & ~3);
1596 pwc
->ScanWidth
= dwScanWidth
;
1598 dwSize
= sizeof(BITMAPINFO
) + (dwScanWidth
* pwc
->height
);
1600 pwc
->dib
.hFileMap
= CreateFileMapping((HANDLE
)PAGE_FILE
,
1602 PAGE_READWRITE
| SEC_COMMIT
,
1607 if (!pwc
->dib
.hFileMap
)
1610 pwc
->dib
.base
= MapViewOfFile(pwc
->dib
.hFileMap
,
1611 FILE_MAP_ALL_ACCESS
,
1617 CloseHandle(pwc
->dib
.hFileMap
);
1621 pwc
->pbPixels
= ((LPBYTE
)pwc
->dib
.base
) + sizeof(BITMAPINFO
);
1623 pwc
->dib
.hDC
= CreateCompatibleDC(hDC
);
1625 CopyMemory(pwc
->dib
.base
, pbmi
, sizeof(BITMAPINFO
));
1627 hic
= CreateIC("display", NULL
, NULL
, NULL
);
1629 /* pwc->hbmDIB = CreateDIBitmap(hic,
1630 &(pwc->bmi.bmiHeader),
1636 pwc
->hbmDIB
= CreateDIBSection(hic
,
1637 &(pwc
->bmi
.bmiHeader
),
1642 pwc
->hOldBitmap
= SelectObject(pwc
->dib
.hDC
, pwc
->hbmDIB
);
1651 // Blit memory DC to screen DC
1653 BOOL
/*WINAPI*/ wmFlush(PWMC pwc
)
1659 // wmFlushBits(pwc);
1661 bRet
= BitBlt(pwc
->hDC
, 0, 0, pwc
->width
, pwc
->height
,
1662 pwc
->dib
.hDC
, 0, 0, SRCCOPY
);
1665 dwErr
= GetLastError();
1667 pwc
->dib
.fFlushed
= TRUE
;
1674 // The following code is added by Li Wei to enable stereo display
1676 #if !defined(NO_STEREO)
1678 void WMesaCreateStereoBuffer()
1680 /* Must use double buffer and not in parallelMode */
1681 if (! Current
->db_flag
1682 #if !defined(NO_PARALLEL)
1688 Buffer_Stereo
= malloc( Current
->ScanWidth
* Current
->height
);
1689 ZeroMemory(Buffer_Stereo
,Current
->ScanWidth
* Current
->height
);
1690 stereoBuffer
= GL_TRUE
;
1693 void WMesaDestroyStereoBuffer()
1695 /* Must use double buffer and not in parallelMode */
1696 if (! Current
->db_flag
1697 #if !defined(NO_PARALLEL)
1703 free(Buffer_Stereo
);
1704 stereoBuffer
= GL_FALSE
;
1708 void WMesaInterleave(GLenum aView
)
1718 dest
= Buffer_Stereo
+ offset
* Current
->ScanWidth
;
1719 if(Current
->rgb_flag
)
1720 src
= Current
->pbPixels
+ Current
->ScanWidth
*(Current
->height
/2);
1722 src
= Current
->ScreenMem
;
1724 for(line
= 0; line
<Current
->height
/2; line
++){
1725 CopyMemory(dest
, src
, Current
->ScanWidth
);
1726 dest
+= 2*Current
->ScanWidth
;
1727 src
+= Current
->ScanWidth
;
1730 if(Current
->rgb_flag
)
1731 CopyMemory(Current
->pbPixels
, Buffer_Stereo
, Current
->ScanWidth
*Current
->height
);
1733 CopyMemory(Current
->ScreenMem
, Buffer_Stereo
, Current
->ScanWidth
*Current
->height
);
1736 void WMesaShowStereo(GLuint list
)
1739 GLbitfield mask
= GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
;
1741 // Must use double Buffer
1742 if( ! Current
-> db_flag
)
1745 glViewport(0,0,Current
->width
,Current
->height
/2);
1747 glGetFloatv(GL_MODELVIEW_MATRIX
,cm
);
1748 glMatrixMode(GL_MODELVIEW
);
1750 gluLookAt(viewDistance
/2,0.0,0.0 ,
1751 viewDistance
/2,0.0,-1.0,
1753 glMultMatrixf( cm
);
1754 glMatrixMode(GL_MODELVIEW
);
1759 WMesaInterleave( FIRST
);
1761 glGetFloatv(GL_MODELVIEW_MATRIX
,cm
);
1762 glMatrixMode(GL_MODELVIEW
);
1764 gluLookAt(-viewDistance
/2,0.0,0.0 ,
1765 -viewDistance
/2,0.0,-1.0,
1768 glMatrixMode(GL_MODELVIEW
);
1771 WMesaInterleave( SECOND
);
1772 glViewport(0,0,Current
->width
,Current
->height
);
1777 void toggleStereoMode()
1779 if(!Current
->db_flag
)
1783 if(stereoBuffer
==GL_FALSE
)
1784 #if !defined(NO_PARALLEL)
1788 WMesaCreateStereoBuffer();
1793 if(stereoBuffer
==GL_TRUE
)
1794 #if !defined(NO_PARALLEL)
1797 if(stereoBuffer
==GL_TRUE
){
1798 WMesaDestroyStereoBuffer();
1803 /* if in stereo mode, the following function is called */
1804 void glShowStereo(GLuint list
)
1806 WMesaShowStereo(list
);
1809 #endif // End if NO_STEREO not defined
1811 #if !defined(NO_PARALLEL)
1813 void toggleParallelMode(void)
1816 parallelFlag
= GL_TRUE
;
1817 if(parallelMachine
==GL_FALSE
){
1818 PRCreateRenderBuffer( Current
->rgb_flag
? GL_RGBA
:GL_COLOR_INDEX
,
1819 Current
->cColorBits
/8,
1820 Current
->width
,Current
->height
,
1822 Current
->rgb_flag
? Current
->pbPixels
: Current
->ScreenMem
);
1823 parallelMachine
= GL_TRUE
;
1827 parallelFlag
= GL_FALSE
;
1828 if(parallelMachine
==GL_TRUE
){
1829 PRDestroyRenderBuffer();
1830 parallelMachine
=GL_FALSE
;
1831 ReadyForNextFrame
= GL_TRUE
;
1834 /***********************************************
1835 // Seems something wrong!!!!
1836 ************************************************/
1838 WMesaMakeCurrent(Current
);
1839 #if !defined(NO_STEREO)
1840 stereo_flag
= GL_FALSE
;
1845 void PRShowRenderResult(void)
1848 if(!glImageRendered())
1857 #endif //End if NO_PARALLEL not defined