2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * DOS/DJGPP device driver v1.4 for Mesa
28 * Copyright (c) 2003 - Borca Daniel
29 * Email : dborca@users.sourceforge.net
30 * Web : http://www.geocities.com/dborca
37 #include "extensions.h"
41 #include "texformat.h"
45 #include "array_cache/acache.h"
46 #include "swrast/s_context.h"
47 #include "swrast/s_depth.h"
48 #include "swrast/s_lines.h"
49 #include "swrast/s_triangle.h"
50 #include "swrast/swrast.h"
51 #include "swrast_setup/swrast_setup.h"
53 #include "tnl/t_context.h"
54 #include "tnl/t_pipeline.h"
61 #include "GL/fxmesa.h"
69 * In C++ terms, this class derives from the GLvisual class.
70 * Add system-specific fields to it.
74 GLboolean db_flag
; /* double buffered? */
75 GLboolean rgb_flag
; /* RGB mode? */
76 GLuint depth
; /* bits per pixel (1, 8, 24, etc) */
80 int zbuffer
; /* Z=buffer: 0=no, 1=SW, -1=HW */
84 * In C++ terms, this class derives from the GLframebuffer class.
85 * Add system-specific fields to it.
88 GLframebuffer gl_buffer
; /* The depth, stencil, accum, etc buffers */
89 void *the_window
; /* your window handle, etc */
91 int xpos
, ypos
; /* position */
92 int width
, height
; /* size in pixels */
96 * In C++ terms, this class derives from the GLcontext class.
97 * Add system-specific fields to it.
99 struct dmesa_context
{
100 GLcontext gl_ctx
; /* the core library context */
111 /****************************************************************************
113 ***************************************************************************/
114 #define FLIP(y) (dmesa->Buffer->height - (y) - 1)
115 #define FLIP2(y) (_b_ - (y))
119 #define DSTRIDE dmesa->Buffer->width
121 #define DSTRIDE dmesa->visual->stride_in_pixels
122 #define vl_putpixel mga_putpixel
123 #define vl_mixrgba mga_mixrgb
124 #define vl_mixrgb mga_mixrgb
125 #define vl_getrgba mga_getrgba
126 #define vl_setz mga_setz
127 #define vl_getz mga_getz
130 /****************************************************************************
132 ***************************************************************************/
133 static void write_rgba_span (const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
134 const GLubyte rgba
[][4], const GLubyte mask
[])
136 const DMesaContext dmesa
= (DMesaContext
)ctx
;
140 offset
= DSTRIDE
* FLIP(y
) + x
;
142 /* draw some pixels */
143 for (i
=0; i
<n
; i
++, offset
++) {
145 vl_putpixel(offset
, vl_mixrgba(rgba
[i
]));
149 /* draw all pixels */
150 for (i
=0; i
<n
; i
++, offset
++) {
151 vl_putpixel(offset
, vl_mixrgba(rgba
[i
]));
157 /* draw some pixels */
159 for (i
= 0; i
< n
; i
++) {
164 mga_draw_span_rgb_tx32(x
+ i
- offset
, y
, offset
, (const unsigned long *)(&rgba
[i
-offset
]));
170 mga_draw_span_rgb_tx32(x
+ n
- offset
, y
, offset
, (const unsigned long *)(&rgba
[n
-offset
]));
173 /* draw all pixels */
174 mga_draw_span_rgb_tx32(x
, y
, n
, (const unsigned long *)rgba
);
181 static void write_rgb_span (const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
182 const GLubyte rgb
[][3], const GLubyte mask
[])
184 const DMesaContext dmesa
= (DMesaContext
)ctx
;
187 offset
= DSTRIDE
* FLIP(y
) + x
;
189 /* draw some pixels */
190 for (i
=0; i
<n
; i
++, offset
++) {
192 vl_putpixel(offset
, vl_mixrgb(rgb
[i
]));
196 /* draw all pixels */
197 for (i
=0; i
<n
; i
++, offset
++) {
198 vl_putpixel(offset
, vl_mixrgb(rgb
[i
]));
205 static void write_mono_rgba_span (const GLcontext
*ctx
,
206 GLuint n
, GLint x
, GLint y
,
207 const GLchan color
[4], const GLubyte mask
[])
209 const DMesaContext dmesa
= (DMesaContext
)ctx
;
210 GLuint i
, offset
, rgba
= vl_mixrgba(color
);
212 offset
= DSTRIDE
* FLIP(y
) + x
;
214 /* draw some pixels */
215 for (i
=0; i
<n
; i
++, offset
++) {
217 vl_putpixel(offset
, rgba
);
221 /* draw all pixels */
222 for (i
=0; i
<n
; i
++, offset
++) {
223 vl_putpixel(offset
, rgba
);
230 static void read_rgba_span (const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
233 const DMesaContext dmesa
= (DMesaContext
)ctx
;
236 offset
= DSTRIDE
* FLIP(y
) + x
;
237 /* read all pixels */
238 for (i
=0; i
<n
; i
++, offset
++) {
239 vl_getrgba(offset
, rgba
[i
]);
245 static void write_rgba_pixels (const GLcontext
*ctx
,
246 GLuint n
, const GLint x
[], const GLint y
[],
247 const GLubyte rgba
[][4], const GLubyte mask
[])
249 const DMesaContext dmesa
= (DMesaContext
)ctx
;
250 GLuint i
, _w_
= DSTRIDE
, _b_
= dmesa
->Buffer
->height
- 1;
253 /* draw some pixels */
254 for (i
=0; i
<n
; i
++) {
256 vl_putpixel(FLIP2(y
[i
])*_w_
+ x
[i
], vl_mixrgba(rgba
[i
]));
260 /* draw all pixels */
261 for (i
=0; i
<n
; i
++) {
262 vl_putpixel(FLIP2(y
[i
])*_w_
+ x
[i
], vl_mixrgba(rgba
[i
]));
269 static void write_mono_rgba_pixels (const GLcontext
*ctx
,
270 GLuint n
, const GLint x
[], const GLint y
[],
271 const GLchan color
[4], const GLubyte mask
[])
273 const DMesaContext dmesa
= (DMesaContext
)ctx
;
274 GLuint i
, _w_
= DSTRIDE
, _b_
= dmesa
->Buffer
->height
- 1, rgba
= vl_mixrgba(color
);
277 /* draw some pixels */
278 for (i
=0; i
<n
; i
++) {
280 vl_putpixel(FLIP2(y
[i
])*_w_
+ x
[i
], rgba
);
284 /* draw all pixels */
285 for (i
=0; i
<n
; i
++) {
286 vl_putpixel(FLIP2(y
[i
])*_w_
+ x
[i
], rgba
);
293 static void read_rgba_pixels (const GLcontext
*ctx
,
294 GLuint n
, const GLint x
[], const GLint y
[],
295 GLubyte rgba
[][4], const GLubyte mask
[])
297 const DMesaContext dmesa
= (DMesaContext
)ctx
;
298 GLuint i
, _w_
= DSTRIDE
, _b_
= dmesa
->Buffer
->height
- 1;
301 /* read some pixels */
302 for (i
=0; i
<n
; i
++) {
304 vl_getrgba(FLIP2(y
[i
])*_w_
+ x
[i
], rgba
[i
]);
308 /* read all pixels */
309 for (i
=0; i
<n
; i
++) {
310 vl_getrgba(FLIP2(y
[i
])*_w_
+ x
[i
], rgba
[i
]);
317 /****************************************************************************
319 ***************************************************************************/
321 static void write_index_span (const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
322 const GLuint index
[], const GLubyte mask
[])
324 const DMesaContext dmesa
= (DMesaContext
)ctx
;
327 offset
= DSTRIDE
* FLIP(y
) + x
;
329 /* draw some pixels */
330 for (i
=0; i
<n
; i
++, offset
++) {
332 vl_putpixel(offset
, index
[i
]);
336 /* draw all pixels */
337 for (i
=0; i
<n
; i
++, offset
++) {
338 vl_putpixel(offset
, index
[i
]);
345 static void write_index8_span (const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
346 const GLubyte index
[], const GLubyte mask
[])
348 const DMesaContext dmesa
= (DMesaContext
)ctx
;
351 offset
= DSTRIDE
* FLIP(y
) + x
;
353 /* draw some pixels */
354 for (i
=0; i
<n
; i
++, offset
++) {
356 vl_putpixel(offset
, index
[i
]);
360 /* draw all pixels */
361 for (i
=0; i
<n
; i
++, offset
++) {
362 vl_putpixel(offset
, index
[i
]);
369 static void write_mono_index_span (const GLcontext
*ctx
,
370 GLuint n
, GLint x
, GLint y
,
371 GLuint colorIndex
, const GLubyte mask
[])
373 const DMesaContext dmesa
= (DMesaContext
)ctx
;
376 offset
= DSTRIDE
* FLIP(y
) + x
;
378 /* draw some pixels */
379 for (i
=0; i
<n
; i
++, offset
++) {
381 vl_putpixel(offset
, colorIndex
);
385 /* draw all pixels */
386 for (i
=0; i
<n
; i
++, offset
++) {
387 vl_putpixel(offset
, colorIndex
);
394 static void read_index_span (const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
397 const DMesaContext dmesa
= (DMesaContext
)ctx
;
400 offset
= DSTRIDE
* FLIP(y
) + x
;
401 /* read all pixels */
402 for (i
=0; i
<n
; i
++, offset
++) {
403 index
[i
] = vl_getpixel(offset
);
409 static void write_index_pixels (const GLcontext
*ctx
,
410 GLuint n
, const GLint x
[], const GLint y
[],
411 const GLuint index
[], const GLubyte mask
[])
413 const DMesaContext dmesa
= (DMesaContext
)ctx
;
414 GLuint i
, _w_
= DSTRIDE
, _b_
= dmesa
->Buffer
->height
- 1;
417 /* draw some pixels */
418 for (i
=0; i
<n
; i
++) {
420 vl_putpixel(FLIP2(y
[i
])*_w_
+ x
[i
], index
[i
]);
424 /* draw all pixels */
425 for (i
=0; i
<n
; i
++) {
426 vl_putpixel(FLIP2(y
[i
])*_w_
+ x
[i
], index
[i
]);
433 static void write_mono_index_pixels (const GLcontext
*ctx
,
434 GLuint n
, const GLint x
[], const GLint y
[],
435 GLuint colorIndex
, const GLubyte mask
[])
437 const DMesaContext dmesa
= (DMesaContext
)ctx
;
438 GLuint i
, _w_
= DSTRIDE
, _b_
= dmesa
->Buffer
->height
- 1;
441 /* draw some pixels */
442 for (i
=0; i
<n
; i
++) {
444 vl_putpixel(FLIP2(y
[i
])*_w_
+ x
[i
], colorIndex
);
448 /* draw all pixels */
449 for (i
=0; i
<n
; i
++) {
450 vl_putpixel(FLIP2(y
[i
])*_w_
+ x
[i
], colorIndex
);
457 static void read_index_pixels (const GLcontext
*ctx
,
458 GLuint n
, const GLint x
[], const GLint y
[],
459 GLuint index
[], const GLubyte mask
[])
461 const DMesaContext dmesa
= (DMesaContext
)ctx
;
462 GLuint i
, _w_
= DSTRIDE
, _b_
= dmesa
->Buffer
->height
- 1;
465 /* read some pixels */
466 for (i
=0; i
<n
; i
++) {
468 index
[i
] = vl_getpixel(FLIP2(y
[i
])*_w_
+ x
[i
]);
472 /* read all pixels */
473 for (i
=0; i
<n
; i
++) {
474 index
[i
] = vl_getpixel(FLIP2(y
[i
])*_w_
+ x
[i
]);
482 /****************************************************************************
484 ***************************************************************************/
486 static void write_depth_span (GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
487 const GLdepth depth
[], const GLubyte mask
[])
489 const DMesaContext dmesa
= (DMesaContext
)ctx
;
492 offset
= DSTRIDE
* FLIP(y
) + x
;
494 /* draw some values */
495 for (i
=0; i
<n
; i
++, offset
++) {
497 vl_setz(offset
, depth
[i
]);
501 /* draw all values */
502 for (i
=0; i
<n
; i
++, offset
++) {
503 vl_setz(offset
, depth
[i
]);
510 static void read_depth_span (GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
513 const DMesaContext dmesa
= (DMesaContext
)ctx
;
516 offset
= DSTRIDE
* FLIP(y
) + x
;
517 /* read all values */
518 for (i
=0; i
<n
; i
++, offset
++) {
519 depth
[i
] = vl_getz(offset
);
525 static void write_depth_pixels (GLcontext
*ctx
, GLuint n
,
526 const GLint x
[], const GLint y
[],
527 const GLdepth depth
[], const GLubyte mask
[])
529 const DMesaContext dmesa
= (DMesaContext
)ctx
;
530 GLuint i
, _w_
= DSTRIDE
, _b_
= dmesa
->Buffer
->height
- 1;
533 /* draw some values */
534 for (i
=0; i
<n
; i
++) {
536 vl_setz(FLIP2(y
[i
])*_w_
+ x
[i
], depth
[i
]);
540 /* draw all values */
541 for (i
=0; i
<n
; i
++) {
542 vl_setz(FLIP2(y
[i
])*_w_
+ x
[i
], depth
[i
]);
549 static void read_depth_pixels (GLcontext
*ctx
, GLuint n
,
550 const GLint x
[], const GLint y
[],
553 const DMesaContext dmesa
= (DMesaContext
)ctx
;
554 GLuint i
, _w_
= DSTRIDE
, _b_
= dmesa
->Buffer
->height
- 1;
556 /* read all values */
557 for (i
=0; i
<n
; i
++) {
558 depth
[i
] = vl_getz(FLIP2(y
[i
])*_w_
+ x
[i
]);
565 /****************************************************************************
566 * Optimized triangle rendering
567 ***************************************************************************/
570 * NON-depth-buffered flat triangle.
574 #define NAME tri_rgb_flat
577 const DMesaContext dmesa = (DMesaContext)ctx; \
578 GLuint _b_ = dmesa->Buffer->height - 1; \
579 GLuint _w_ = dmesa->Buffer->width; \
580 GLuint rgb = vl_mixrgb(v2->color);
582 #define RENDER_SPAN(span) \
583 GLuint i, offset = FLIP2(span.y)*_w_ + span.x; \
584 for (i = 0; i < span.end; i++, offset++) { \
585 vl_putpixel(offset, rgb); \
588 #include "swrast/s_tritemp.h"
592 static void tri_rgb_flat (GLcontext
*ctx
,
597 const DMesaContext dmesa
= (DMesaContext
)ctx
;
598 GLuint _b_
= dmesa
->Buffer
->height
- 1;
599 MGAvertex m0
, m1
, m2
;
600 m0
.win
[0] = v0
->win
[0];
601 m0
.win
[1] = FLIP2(v0
->win
[1]);
602 m1
.win
[0] = v1
->win
[0];
603 m1
.win
[1] = FLIP2(v1
->win
[1]);
604 m2
.win
[0] = v2
->win
[0];
605 m2
.win
[1] = FLIP2(v2
->win
[1]);
606 *(unsigned long *)m2
.color
= *(unsigned long *)v2
->color
;
607 mga_draw_tri_rgb_flat((int)SWRAST_CONTEXT(ctx
)->_backface_sign
, &m0
, &m1
, &m2
);
614 * Z-less flat triangle.
618 #define NAME tri_rgb_flat_zless
621 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
624 const DMesaContext dmesa = (DMesaContext)ctx; \
625 GLuint _b_ = dmesa->Buffer->height - 1; \
626 GLuint _w_ = dmesa->Buffer->width; \
627 GLuint rgb = vl_mixrgb(v2->color);
629 #define RENDER_SPAN(span) \
630 GLuint i, offset = FLIP2(span.y)*_w_ + span.x; \
631 for (i = 0; i < span.end; i++, offset++) { \
632 const DEPTH_TYPE z = FixedToDepth(span.z); \
634 vl_putpixel(offset, rgb); \
637 span.z += span.zStep; \
640 #include "swrast/s_tritemp.h"
644 static void tri_rgb_flat_zless (GLcontext
*ctx
,
649 const DMesaContext dmesa
= (DMesaContext
)ctx
;
650 GLuint _b_
= dmesa
->Buffer
->height
- 1;
651 MGAvertex m0
, m1
, m2
;
652 m0
.win
[0] = v0
->win
[0];
653 m0
.win
[1] = FLIP2(v0
->win
[1]);
654 m0
.win
[2] = v0
->win
[2];
655 m1
.win
[0] = v1
->win
[0];
656 m1
.win
[1] = FLIP2(v1
->win
[1]);
657 m1
.win
[2] = v1
->win
[2];
658 m2
.win
[0] = v2
->win
[0];
659 m2
.win
[1] = FLIP2(v2
->win
[1]);
660 m2
.win
[2] = v2
->win
[2];
661 *(unsigned long *)m2
.color
= *(unsigned long *)v2
->color
;
662 mga_draw_tri_rgb_flat_zless((int)SWRAST_CONTEXT(ctx
)->_backface_sign
, &m0
, &m1
, &m2
);
669 * NON-depth-buffered iterated triangle.
673 #define NAME tri_rgb_iter
678 const DMesaContext dmesa = (DMesaContext)ctx; \
679 GLuint _b_ = dmesa->Buffer->height - 1; \
680 GLuint _w_ = dmesa->Buffer->width;
682 #define RENDER_SPAN(span) \
683 GLuint i, offset = FLIP2(span.y)*_w_ + span.x; \
684 for (i = 0; i < span.end; i++, offset++) { \
685 vl_putpixel(offset, vl_mixfix(span.red, span.green, span.blue)); \
686 span.red += span.redStep; \
687 span.green += span.greenStep; \
688 span.blue += span.blueStep; \
691 #include "swrast/s_tritemp.h"
695 static void tri_rgb_iter (GLcontext
*ctx
,
700 const DMesaContext dmesa
= (DMesaContext
)ctx
;
701 GLuint _b_
= dmesa
->Buffer
->height
- 1;
702 MGAvertex m0
, m1
, m2
;
703 m0
.win
[0] = v0
->win
[0];
704 m0
.win
[1] = FLIP2(v0
->win
[1]);
705 m1
.win
[0] = v1
->win
[0];
706 m1
.win
[1] = FLIP2(v1
->win
[1]);
707 m2
.win
[0] = v2
->win
[0];
708 m2
.win
[1] = FLIP2(v2
->win
[1]);
709 *(unsigned long *)m0
.color
= *(unsigned long *)v0
->color
;
710 *(unsigned long *)m1
.color
= *(unsigned long *)v1
->color
;
711 *(unsigned long *)m2
.color
= *(unsigned long *)v2
->color
;
712 mga_draw_tri_rgb_iter((int)SWRAST_CONTEXT(ctx
)->_backface_sign
, &m0
, &m1
, &m2
);
719 * Z-less iterated triangle.
723 #define NAME tri_rgb_iter_zless
726 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
730 const DMesaContext dmesa = (DMesaContext)ctx; \
731 GLuint _b_ = dmesa->Buffer->height - 1; \
732 GLuint _w_ = dmesa->Buffer->width;
734 #define RENDER_SPAN(span) \
735 GLuint i, offset = FLIP2(span.y)*_w_ + span.x; \
736 for (i = 0; i < span.end; i++, offset++) { \
737 const DEPTH_TYPE z = FixedToDepth(span.z); \
739 vl_putpixel(offset, vl_mixfix(span.red, span.green, span.blue));\
742 span.red += span.redStep; \
743 span.green += span.greenStep; \
744 span.blue += span.blueStep; \
745 span.z += span.zStep; \
748 #include "swrast/s_tritemp.h"
752 static void tri_rgb_iter_zless (GLcontext
*ctx
,
757 const DMesaContext dmesa
= (DMesaContext
)ctx
;
758 GLuint _b_
= dmesa
->Buffer
->height
- 1;
759 MGAvertex m0
, m1
, m2
;
760 m0
.win
[0] = v0
->win
[0];
761 m0
.win
[1] = FLIP2(v0
->win
[1]);
762 m0
.win
[2] = v0
->win
[2];
763 m1
.win
[0] = v1
->win
[0];
764 m1
.win
[1] = FLIP2(v1
->win
[1]);
765 m1
.win
[2] = v1
->win
[2];
766 m2
.win
[0] = v2
->win
[0];
767 m2
.win
[1] = FLIP2(v2
->win
[1]);
768 m2
.win
[2] = v2
->win
[2];
769 *(unsigned long *)m0
.color
= *(unsigned long *)v0
->color
;
770 *(unsigned long *)m1
.color
= *(unsigned long *)v1
->color
;
771 *(unsigned long *)m2
.color
= *(unsigned long *)v2
->color
;
772 mga_draw_tri_rgb_iter_zless((int)SWRAST_CONTEXT(ctx
)->_backface_sign
, &m0
, &m1
, &m2
);
779 * Analyze context state to see if we can provide a fast triangle function
780 * Otherwise, return NULL.
782 static swrast_tri_func
dmesa_choose_tri_function (GLcontext
*ctx
)
784 const SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
786 if ((ctx
->RenderMode
!= GL_RENDER
)
787 || (ctx
->Polygon
.SmoothFlag
)
788 || (ctx
->Polygon
.StippleFlag
)
789 || (ctx
->Texture
._EnabledUnits
)
790 || (swrast
->_RasterMask
& MULTI_DRAW_BIT
)
791 || (ctx
->Polygon
.CullFlag
&& ctx
->Polygon
.CullFaceMode
== GL_FRONT_AND_BACK
)) {
792 return (swrast_tri_func
)NULL
;
795 if (swrast
->_RasterMask
==DEPTH_BIT
796 && ctx
->Depth
.Func
==GL_LESS
797 && ctx
->Depth
.Mask
==GL_TRUE
798 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
) {
799 return (ctx
->Light
.ShadeModel
==GL_SMOOTH
) ? tri_rgb_iter_zless
: tri_rgb_flat_zless
;
802 if (swrast
->_RasterMask
==0) { /* no depth test */
803 return (ctx
->Light
.ShadeModel
==GL_SMOOTH
) ? tri_rgb_iter
: tri_rgb_flat
;
806 return (swrast_tri_func
)NULL
;
811 /* Override for the swrast triangle-selection function. Try to use one
812 * of our internal triangle functions, otherwise fall back to the
813 * standard swrast functions.
815 static void dmesa_choose_tri (GLcontext
*ctx
)
817 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
819 if (!(swrast
->Triangle
=dmesa_choose_tri_function(ctx
)))
820 _swrast_choose_triangle(ctx
);
825 /****************************************************************************
826 * Optimized line rendering
827 ***************************************************************************/
830 static __inline
void matrox_line_clip_hack (GLcontext
*ctx
, int _b_
, MGAvertex
*m0
, const SWvertex
*vert0
, MGAvertex
*m1
, const SWvertex
*vert1
)
832 int x0
= vert0
->win
[0];
833 int y0
= vert0
->win
[1];
834 int x1
= vert1
->win
[0];
835 int y1
= vert1
->win
[1];
837 GLint w
= ctx
->DrawBuffer
->Width
;
838 GLint h
= ctx
->DrawBuffer
->Height
;
839 if ((x0
==w
) | (x1
==w
)) {
840 if ((x0
==w
) & (x1
==w
))
845 if ((y0
==h
) | (y1
==h
)) {
846 if ((y0
==h
) & (y1
==h
))
853 m0
->win
[1] = FLIP2(y0
);
855 m1
->win
[1] = FLIP2(y1
);
860 * NON-depth-buffered flat line.
864 #define NAME line_rgb_flat
870 const DMesaContext dmesa = (DMesaContext)ctx; \
871 GLuint _b_ = dmesa->Buffer->height - 1; \
872 GLuint _w_ = dmesa->Buffer->width; \
873 GLuint rgb = vl_mixrgb(vert1->color);
875 #define PLOT(X,Y) vl_putpixel(FLIP2(Y) * _w_ + X, rgb);
877 #include "swrast/s_linetemp.h"
881 static void line_rgb_flat (GLcontext
*ctx
,
882 const SWvertex
*vert0
,
883 const SWvertex
*vert1
)
885 const DMesaContext dmesa
= (DMesaContext
)ctx
;
886 GLuint _b_
= dmesa
->Buffer
->height
- 1;
888 matrox_line_clip_hack(ctx
, _b_
, &m0
, vert0
, &m1
, vert1
);
889 *(unsigned long *)m1
.color
= *(unsigned long *)vert1
->color
;
890 mga_draw_line_rgb_flat(&m0
, &m1
);
901 #define NAME line_rgb_flat_zless
905 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
909 const DMesaContext dmesa = (DMesaContext)ctx; \
910 GLuint _b_ = dmesa->Buffer->height - 1; \
911 GLuint _w_ = dmesa->Buffer->width; \
912 GLuint rgb = vl_mixrgb(vert1->color);
917 vl_putpixel(FLIP2(Y) * _w_ + X, rgb); \
920 #include "swrast/s_linetemp.h"
924 static void line_rgb_flat_zless (GLcontext
*ctx
,
925 const SWvertex
*vert0
,
926 const SWvertex
*vert1
)
928 const DMesaContext dmesa
= (DMesaContext
)ctx
;
929 GLuint _b_
= dmesa
->Buffer
->height
- 1;
931 matrox_line_clip_hack(ctx
, _b_
, &m0
, vert0
, &m1
, vert1
);
932 m0
.win
[2] = vert0
->win
[2];
933 m1
.win
[2] = vert1
->win
[2];
934 *(unsigned long *)m1
.color
= *(unsigned long *)vert1
->color
;
935 mga_draw_line_rgb_flat_zless(&m0
, &m1
);
942 #define line_rgb_iter NULL
943 #define line_rgb_iter_zless NULL
946 * NON-depth-buffered iterated line.
948 static void line_rgb_iter (GLcontext
*ctx
,
949 const SWvertex
*vert0
,
950 const SWvertex
*vert1
)
952 const DMesaContext dmesa
= (DMesaContext
)ctx
;
953 GLuint _b_
= dmesa
->Buffer
->height
- 1;
955 matrox_line_clip_hack(ctx
, _b_
, &m0
, vert0
, &m1
, vert1
);
956 *(unsigned long *)m0
.color
= *(unsigned long *)vert0
->color
;
957 *(unsigned long *)m1
.color
= *(unsigned long *)vert1
->color
;
958 mga_draw_line_rgb_iter(&m0
, &m1
);
964 * Z-less iterated line.
966 static void line_rgb_iter_zless (GLcontext
*ctx
,
967 const SWvertex
*vert0
,
968 const SWvertex
*vert1
)
970 const DMesaContext dmesa
= (DMesaContext
)ctx
;
971 GLuint _b_
= dmesa
->Buffer
->height
- 1;
973 matrox_line_clip_hack(ctx
, _b_
, &m0
, vert0
, &m1
, vert1
);
974 m0
.win
[2] = vert0
->win
[2];
975 m1
.win
[2] = vert1
->win
[2];
976 *(unsigned long *)m0
.color
= *(unsigned long *)vert0
->color
;
977 *(unsigned long *)m1
.color
= *(unsigned long *)vert1
->color
;
978 mga_draw_line_rgb_iter_zless(&m0
, &m1
);
985 * Analyze context state to see if we can provide a fast line function
986 * Otherwise, return NULL.
988 static swrast_line_func
dmesa_choose_line_function (GLcontext
*ctx
)
990 const SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
992 if ((ctx
->RenderMode
!= GL_RENDER
)
993 || (ctx
->Line
.SmoothFlag
)
994 || (ctx
->Texture
._EnabledUnits
)
995 || (ctx
->Line
.StippleFlag
)
996 || (swrast
->_RasterMask
& MULTI_DRAW_BIT
)
997 || (ctx
->Line
.Width
!=1.0F
)) {
998 return (swrast_line_func
)NULL
;
1001 if (swrast
->_RasterMask
==DEPTH_BIT
1002 && ctx
->Depth
.Func
==GL_LESS
1003 && ctx
->Depth
.Mask
==GL_TRUE
1004 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
) {
1005 return (ctx
->Light
.ShadeModel
==GL_SMOOTH
) ? line_rgb_iter_zless
: line_rgb_flat_zless
;
1008 if (swrast
->_RasterMask
==0) { /* no depth test */
1009 return (ctx
->Light
.ShadeModel
==GL_SMOOTH
) ? line_rgb_iter
: line_rgb_flat
;
1012 return (swrast_line_func
)NULL
;
1017 /* Override for the swrast line-selection function. Try to use one
1018 * of our internal line functions, otherwise fall back to the
1019 * standard swrast functions.
1021 static void dmesa_choose_line (GLcontext
*ctx
)
1023 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1025 if (!(swrast
->Line
=dmesa_choose_line_function(ctx
)))
1026 _swrast_choose_line(ctx
);
1031 /****************************************************************************
1032 * Miscellaneous device driver funcs
1033 ***************************************************************************/
1035 static void clear_index (GLcontext
*ctx
, GLuint index
)
1037 ((DMesaContext
)ctx
)->ClearIndex
= index
;
1040 static void clear_color (GLcontext
*ctx
, const GLfloat color
[4])
1043 CLAMPED_FLOAT_TO_UBYTE(col
[0], color
[0]);
1044 CLAMPED_FLOAT_TO_UBYTE(col
[1], color
[1]);
1045 CLAMPED_FLOAT_TO_UBYTE(col
[2], color
[2]);
1046 CLAMPED_FLOAT_TO_UBYTE(col
[3], color
[3]);
1047 ((DMesaContext
)ctx
)->ClearColor
= vl_mixrgba(col
);
1052 static void clear (GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
1053 GLint x
, GLint y
, GLint width
, GLint height
)
1055 const DMesaContext c
= (DMesaContext
)ctx
;
1056 const GLuint
*colorMask
= (GLuint
*)&ctx
->Color
.ColorMask
;
1059 * Clear the specified region of the buffers indicated by 'mask'
1060 * using the clear color or index as specified by one of the two
1062 * If all==GL_TRUE, clear whole buffer, else just clear region defined
1063 * by x,y,width,height
1066 /* we can't handle color or index masking */
1067 if ((*colorMask
== 0xffffffff) && (ctx
->Color
.IndexMask
== 0xffffffff)) {
1069 if (mask
& DD_BACK_LEFT_BIT
) {
1070 int color
= c
->visual
->rgb_flag
? c
->ClearColor
: c
->ClearIndex
;
1075 vl_rect(x
, y
, width
, height
, color
);
1078 mask
&= ~DD_BACK_LEFT_BIT
;
1081 unsigned short z
= -1;
1082 int color
= c
->ClearColor
;
1083 if (mask
& DD_DEPTH_BIT
) {
1084 z
= ctx
->Depth
.Clear
* 0xffff;
1087 mga_clear(mask
& DD_FRONT_LEFT_BIT
,
1088 mask
& DD_BACK_LEFT_BIT
,
1089 mask
& DD_DEPTH_BIT
,
1090 0, 0, c
->Buffer
->width
, c
->Buffer
->height
,
1093 mga_clear(mask
& DD_FRONT_LEFT_BIT
,
1094 mask
& DD_BACK_LEFT_BIT
,
1095 mask
& DD_DEPTH_BIT
,
1096 x
, y
, width
, height
,
1099 mask
&= ~(DD_FRONT_LEFT_BIT
| DD_BACK_LEFT_BIT
| DD_DEPTH_BIT
);
1104 _swrast_Clear(ctx
, mask
, all
, x
, y
, width
, height
);
1110 static void set_buffer (GLcontext
*ctx
, GLframebuffer
*colorBuffer
, GLuint bufferBit
)
1113 * XXX todo - examine bufferBit and set read/write pointers
1120 * Return the width and height of the current buffer.
1121 * If anything special has to been done when the buffer/window is
1122 * resized, do it now.
1124 static void get_buffer_size (GLframebuffer
*buffer
, GLuint
*width
, GLuint
*height
)
1126 DMesaBuffer b
= (DMesaBuffer
)buffer
;
1129 *height
= b
->height
;
1134 static const GLubyte
* get_string (GLcontext
*ctx
, GLenum name
)
1138 return (const GLubyte
*)"Mesa DJGPP"
1145 "\0port (c) Borca Daniel aug-2003";
1153 static void finish (GLcontext
*ctx
)
1156 * XXX todo - OPTIONAL FUNCTION: implements glFinish if possible
1162 static void flush (GLcontext
*ctx
)
1165 * XXX todo - OPTIONAL FUNCTION: implements glFlush if possible
1171 /****************************************************************************
1173 ***************************************************************************/
1174 #define DMESA_NEW_LINE (_NEW_LINE | \
1179 _SWRAST_NEW_RASTERMASK)
1181 #define DMESA_NEW_TRIANGLE (_NEW_POLYGON | \
1186 _SWRAST_NEW_RASTERMASK)
1188 /* Extend the software rasterizer with our line and triangle
1191 static void dmesa_register_swrast_functions (GLcontext
*ctx
)
1193 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1195 swrast
->choose_line
= dmesa_choose_line
;
1196 swrast
->choose_triangle
= dmesa_choose_tri
;
1198 swrast
->invalidate_line
|= DMESA_NEW_LINE
;
1199 swrast
->invalidate_triangle
|= DMESA_NEW_TRIANGLE
;
1204 /* Setup pointers and other driver state that is constant for the life
1207 static void dmesa_init_pointers (GLcontext
*ctx
)
1210 struct swrast_device_driver
*dd
= _swrast_GetDeviceDriverReference(ctx
);
1212 ctx
->Driver
.GetString
= get_string
;
1213 ctx
->Driver
.GetBufferSize
= get_buffer_size
;
1214 ctx
->Driver
.Flush
= flush
;
1215 ctx
->Driver
.Finish
= finish
;
1217 /* Software rasterizer pixel paths:
1219 ctx
->Driver
.Accum
= _swrast_Accum
;
1220 ctx
->Driver
.Bitmap
= _swrast_Bitmap
;
1221 ctx
->Driver
.Clear
= clear
;
1222 ctx
->Driver
.ResizeBuffers
= _swrast_alloc_buffers
;
1223 ctx
->Driver
.CopyPixels
= _swrast_CopyPixels
;
1224 ctx
->Driver
.DrawPixels
= _swrast_DrawPixels
;
1225 ctx
->Driver
.ReadPixels
= _swrast_ReadPixels
;
1226 ctx
->Driver
.DrawBuffer
= _swrast_DrawBuffer
;
1228 /* Software texture functions:
1230 ctx
->Driver
.ChooseTextureFormat
= _mesa_choose_tex_format
;
1231 ctx
->Driver
.TexImage1D
= _mesa_store_teximage1d
;
1232 ctx
->Driver
.TexImage2D
= _mesa_store_teximage2d
;
1233 ctx
->Driver
.TexImage3D
= _mesa_store_teximage3d
;
1234 ctx
->Driver
.TexSubImage1D
= _mesa_store_texsubimage1d
;
1235 ctx
->Driver
.TexSubImage2D
= _mesa_store_texsubimage2d
;
1236 ctx
->Driver
.TexSubImage3D
= _mesa_store_texsubimage3d
;
1237 ctx
->Driver
.TestProxyTexImage
= _mesa_test_proxy_teximage
;
1239 ctx
->Driver
.CopyTexImage1D
= _swrast_copy_teximage1d
;
1240 ctx
->Driver
.CopyTexImage2D
= _swrast_copy_teximage2d
;
1241 ctx
->Driver
.CopyTexSubImage1D
= _swrast_copy_texsubimage1d
;
1242 ctx
->Driver
.CopyTexSubImage2D
= _swrast_copy_texsubimage2d
;
1243 ctx
->Driver
.CopyTexSubImage3D
= _swrast_copy_texsubimage3d
;
1245 ctx
->Driver
.CompressedTexImage1D
= _mesa_store_compressed_teximage1d
;
1246 ctx
->Driver
.CompressedTexImage2D
= _mesa_store_compressed_teximage2d
;
1247 ctx
->Driver
.CompressedTexImage3D
= _mesa_store_compressed_teximage3d
;
1248 ctx
->Driver
.CompressedTexSubImage1D
= _mesa_store_compressed_texsubimage1d
;
1249 ctx
->Driver
.CompressedTexSubImage2D
= _mesa_store_compressed_texsubimage2d
;
1250 ctx
->Driver
.CompressedTexSubImage3D
= _mesa_store_compressed_texsubimage3d
;
1252 /* Swrast hooks for imaging extensions:
1254 ctx
->Driver
.CopyColorTable
= _swrast_CopyColorTable
;
1255 ctx
->Driver
.CopyColorSubTable
= _swrast_CopyColorSubTable
;
1256 ctx
->Driver
.CopyConvolutionFilter1D
= _swrast_CopyConvolutionFilter1D
;
1257 ctx
->Driver
.CopyConvolutionFilter2D
= _swrast_CopyConvolutionFilter2D
;
1259 /* Statechange callbacks:
1261 ctx
->Driver
.ClearColor
= clear_color
;
1262 ctx
->Driver
.ClearIndex
= clear_index
;
1264 /* Initialize the TNL driver interface:
1266 tnl
= TNL_CONTEXT(ctx
);
1267 tnl
->Driver
.RunPipeline
= _tnl_run_pipeline
;
1269 dd
->SetBuffer
= set_buffer
;
1271 /* Install swsetup for tnl->Driver.Render.*:
1273 _swsetup_Wakeup(ctx
);
1275 /* The span functions should be in `dmesa_update_state', but I'm
1276 * pretty sure they will never change during the life of the Visual
1279 if (((DMesaContext
)ctx
)->visual
->zbuffer
== -1) {
1280 /* Depth span/pixel functions */
1281 dd
->WriteDepthSpan
= write_depth_span
;
1282 dd
->WriteDepthPixels
= write_depth_pixels
;
1283 dd
->ReadDepthSpan
= read_depth_span
;
1284 dd
->ReadDepthPixels
= read_depth_pixels
;
1289 /* Index span/pixel functions */
1290 dd
->WriteCI32Span
= write_index_span
;
1291 dd
->WriteCI8Span
= write_index8_span
;
1292 dd
->WriteMonoCISpan
= write_mono_index_span
;
1293 dd
->WriteCI32Pixels
= write_index_pixels
;
1294 dd
->WriteMonoCIPixels
= write_mono_index_pixels
;
1295 dd
->ReadCI32Span
= read_index_span
;
1296 dd
->ReadCI32Pixels
= read_index_pixels
;
1299 /* RGB(A) span/pixel functions */
1300 dd
->WriteRGBASpan
= write_rgba_span
;
1301 dd
->WriteRGBSpan
= write_rgb_span
;
1302 dd
->WriteMonoRGBASpan
= write_mono_rgba_span
;
1303 dd
->WriteRGBAPixels
= write_rgba_pixels
;
1304 dd
->WriteMonoRGBAPixels
= write_mono_rgba_pixels
;
1305 dd
->ReadRGBASpan
= read_rgba_span
;
1306 dd
->ReadRGBAPixels
= read_rgba_pixels
;
1311 static void dmesa_update_state (GLcontext
*ctx
, GLuint new_state
)
1313 /* Propogate statechange information to swrast and swrast_setup
1314 * modules. The DMesa driver has no internal GL-dependent state.
1316 _swrast_InvalidateState( ctx
, new_state
);
1317 _ac_InvalidateState( ctx
, new_state
);
1318 _tnl_InvalidateState( ctx
, new_state
);
1319 _swsetup_InvalidateState( ctx
, new_state
);
1325 /****************************************************************************
1326 * DMesa Public API Functions
1327 ***************************************************************************/
1330 * The exact arguments to this function will depend on your window system
1332 DMesaVisual
DMesaCreateVisual (GLint width
,
1338 GLboolean alphaFlag
,
1345 GLint redBits
, greenBits
, blueBits
, alphaBits
, indexBits
;
1395 if ((colDepth
=vl_video_init(width
, height
, colDepth
, rgbFlag
, refresh
)) <= 0) {
1399 if (mga_open(width
, height
, colDepth
, dbFlag
? 2 : 1, depthSize
== 16, refresh
) < 0) {
1404 if (alphaFlag
&& (alphaBits
==0)) {
1408 if ((v
=(DMesaVisual
)CALLOC_STRUCT(dmesa_visual
)) != NULL
) {
1409 /* Create core visual */
1410 _mesa_initialize_visual((GLvisual
*)v
,
1413 GL_FALSE
, /* stereo */
1418 indexBits
, /* indexBits */
1421 accumSize
, /* accumRed */
1422 accumSize
, /* accumGreen */
1423 accumSize
, /* accumBlue */
1424 alphaFlag
?accumSize
:0, /* accumAlpha */
1425 1); /* numSamples */
1427 v
->depth
= colDepth
;
1428 v
->db_flag
= dbFlag
;
1429 v
->rgb_flag
= rgbFlag
;
1431 v
->zbuffer
= (depthSize
> 0) ? 1 : 0;
1433 mga_get(MGA_GET_HPIXELS
, &v
->stride_in_pixels
);
1434 if (depthSize
== 16) {
1444 int i
= 0, fx_attrib
[32];
1450 if (dbFlag
) fx_attrib
[i
++] = FXMESA_DOUBLEBUFFER
;
1451 if (depthSize
> 0) { fx_attrib
[i
++] = FXMESA_DEPTH_SIZE
; fx_attrib
[i
++] = depthSize
; }
1452 if (stencilSize
> 0) { fx_attrib
[i
++] = FXMESA_STENCIL_SIZE
; fx_attrib
[i
++] = stencilSize
; }
1453 if (accumSize
> 0) { fx_attrib
[i
++] = FXMESA_ACCUM_SIZE
; fx_attrib
[i
++] = accumSize
; }
1454 if (alphaFlag
) { fx_attrib
[i
++] = FXMESA_ALPHA_SIZE
; fx_attrib
[i
++] = 1; }
1455 fx_attrib
[i
++] = FXMESA_COLORDEPTH
;
1456 fx_attrib
[i
++] = colDepth
;
1457 fx_attrib
[i
] = FXMESA_NONE
;
1459 return (DMesaVisual
)fxMesaCreateBestContext(-1, width
, height
, fx_attrib
);
1465 void DMesaDestroyVisual (DMesaVisual v
)
1468 _mesa_destroy_visual((GLvisual
*)v
);
1477 fxMesaDestroyContext((fxMesaContext
)v
);
1483 DMesaBuffer
DMesaCreateBuffer (DMesaVisual visual
,
1484 GLint xpos
, GLint ypos
,
1485 GLint width
, GLint height
)
1490 if ((b
=(DMesaBuffer
)CALLOC_STRUCT(dmesa_buffer
)) != NULL
) {
1491 _mesa_initialize_framebuffer((GLframebuffer
*)b
,
1493 visual
->zbuffer
== 1,
1494 ((GLvisual
*)visual
)->stencilBits
> 0,
1495 ((GLvisual
*)visual
)->accumRedBits
> 0,
1496 ((GLvisual
*)visual
)->alphaBits
> 0);
1505 return (DMesaBuffer
)visual
;
1511 void DMesaDestroyBuffer (DMesaBuffer b
)
1515 free(b
->the_window
);
1517 _mesa_destroy_framebuffer((GLframebuffer
*)b
);
1523 DMesaContext
DMesaCreateContext (DMesaVisual visual
,
1528 GLboolean direct
= GL_FALSE
;
1530 if ((c
=(DMesaContext
)CALLOC_STRUCT(dmesa_context
)) != NULL
) {
1531 _mesa_initialize_context((GLcontext
*)c
,
1536 _mesa_enable_sw_extensions((GLcontext
*)c
);
1537 _mesa_enable_1_3_extensions((GLcontext
*)c
);
1538 _mesa_enable_1_4_extensions((GLcontext
*)c
);
1539 _mesa_enable_1_5_extensions((GLcontext
*)c
);
1541 /* you probably have to do a bunch of other initializations here. */
1544 ((GLcontext
*)c
)->Driver
.UpdateState
= dmesa_update_state
;
1546 /* Initialize the software rasterizer and helper modules.
1548 _swrast_CreateContext((GLcontext
*)c
);
1549 _ac_CreateContext((GLcontext
*)c
);
1550 _tnl_CreateContext((GLcontext
*)c
);
1551 _swsetup_CreateContext((GLcontext
*)c
);
1552 if (visual
->rgb_flag
) dmesa_register_swrast_functions((GLcontext
*)c
);
1553 dmesa_init_pointers((GLcontext
*)c
);
1559 return (DMesaContext
)visual
;
1565 void DMesaDestroyContext (DMesaContext c
)
1569 _swsetup_DestroyContext((GLcontext
*)c
);
1570 _swrast_DestroyContext((GLcontext
*)c
);
1571 _tnl_DestroyContext((GLcontext
*)c
);
1572 _ac_DestroyContext((GLcontext
*)c
);
1573 _mesa_destroy_context((GLcontext
*)c
);
1580 GLboolean
DMesaMoveBuffer (GLint xpos
, GLint ypos
)
1582 #if !defined(FX) && !defined(MATROX)
1583 GET_CURRENT_CONTEXT(ctx
);
1584 DMesaBuffer b
= ((DMesaContext
)ctx
)->Buffer
;
1586 if (vl_sync_buffer(&b
->the_window
, xpos
, ypos
, b
->width
, b
->height
) != 0) {
1601 GLboolean
DMesaResizeBuffer (GLint width
, GLint height
)
1603 #if !defined(FX) && !defined(MATROX)
1604 GET_CURRENT_CONTEXT(ctx
);
1605 DMesaBuffer b
= ((DMesaContext
)ctx
)->Buffer
;
1607 if (vl_sync_buffer(&b
->the_window
, b
->xpos
, b
->ypos
, width
, height
) != 0) {
1623 * Make the specified context and buffer the current one.
1625 GLboolean
DMesaMakeCurrent (DMesaContext c
, DMesaBuffer b
)
1628 if ((c
!= NULL
) && (b
!= NULL
)) {
1630 if (vl_sync_buffer(&b
->the_window
, b
->xpos
, b
->ypos
, b
->width
, b
->height
) != 0) {
1637 _mesa_make_current((GLcontext
*)c
, (GLframebuffer
*)b
);
1638 if (((GLcontext
*)c
)->Viewport
.Width
== 0) {
1639 /* initialize viewport to window size */
1640 _mesa_Viewport(0, 0, b
->width
, b
->height
);
1644 _mesa_make_current(NULL
, NULL
);
1648 fxMesaMakeCurrent((fxMesaContext
)c
);
1656 void DMesaSwapBuffers (DMesaBuffer b
)
1658 /* copy/swap back buffer to front if applicable */
1660 GET_CURRENT_CONTEXT(ctx
);
1661 _mesa_notifySwapBuffers(ctx
);
1665 if (((DMesaContext
)ctx
)->visual
->db_flag
) {
1670 fxMesaSwapBuffers();
1676 void DMesaSetCI (int ndx
, GLfloat red
, GLfloat green
, GLfloat blue
)
1678 #if !defined(FX) && !defined(MATROX)
1679 vl_setCI(ndx
, red
, green
, blue
);
1685 void *DMesaGetCurrentContext (void)
1688 GET_CURRENT_CONTEXT(ctx
);
1691 return fxMesaGetCurrentContext();
1697 int DMesaGetIntegerv (GLenum pname
, GLint
*params
)
1699 if (DMesaGetCurrentContext() == NULL
) {
1704 case DMESA_GET_SCREEN_SIZE
:
1707 vl_get(VL_GET_SCREEN_SIZE
, params
);
1709 mga_get(MGA_GET_SCREEN_SIZE
, params
);
1712 fxGetScreenGeometry(¶ms
[0], ¶ms
[1]);
1715 case DMESA_GET_DRIVER_CAPS
:
1718 params
[0] = DMESA_DRIVER_SWDB_BIT
;
1723 params
[0] = DMESA_DRIVER_LLWO_BIT
;