*/\r
\r
/*\r
- * DOS/DJGPP device driver v0.2 for Mesa 4.0\r
+ * DOS/DJGPP device driver v0.3 for Mesa 4.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
*/\r
struct dmesa_visual {\r
GLvisual *gl_visual;\r
+ GLboolean db_flag; /* double buffered? */\r
GLboolean rgb_flag; /* RGB mode? */\r
GLuint depth; /* bits per pixel (1, 8, 24, etc) */\r
-\r
- GLint caps; /* video mode capabilities */\r
};\r
\r
/*\r
\r
int xpos, ypos; /* position */\r
int width, height; /* size in pixels */\r
- int pitch, len; /* number of bytes in a line, then total */\r
- int cwidth; /* scan width */\r
-\r
- int caps; /* video mode capabilities */\r
-\r
- void (*tri_rgb_flat) ();\r
+ int bwidth, len; /* bytes in a line, then total */\r
};\r
\r
/*\r
void *b = c->Buffer->the_window;\r
GLuint i, offset;\r
\r
- offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ offset = c->Buffer->width * FLIP(y) + x;\r
if (mask) {\r
/* draw some pixels */\r
for (i=0; i<n; i++, offset++) {\r
void *b = c->Buffer->the_window;\r
GLuint i, offset;\r
\r
- offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ offset = c->Buffer->width * FLIP(y) + x;\r
if (mask) {\r
/* draw some pixels */\r
for (i=0; i<n; i++, offset++) {\r
void *b = c->Buffer->the_window;\r
GLuint i, offset, rgba = vl_mixrgba(color);\r
\r
- offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ offset = c->Buffer->width * FLIP(y) + x;\r
if (mask) {\r
/* draw some pixels */\r
for (i=0; i<n; i++, offset++) {\r
void *b = c->Buffer->the_window;\r
GLuint i, offset;\r
\r
- offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ offset = c->Buffer->width * FLIP(y) + x;\r
/* read all pixels */\r
for (i=0; i<n; i++, offset++) {\r
vl_getrgba(b, offset, rgba[i]);\r
{\r
DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
void *b = c->Buffer->the_window;\r
- GLuint i, w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint i, w = c->Buffer->width, h = c->Buffer->height;\r
\r
if (mask) {\r
/* draw some pixels */\r
{\r
DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
void *b = c->Buffer->the_window;\r
- GLuint i, w = c->Buffer->cwidth, h = c->Buffer->height, rgba = vl_mixrgba(color);\r
+ GLuint i, w = c->Buffer->width, h = c->Buffer->height, rgba = vl_mixrgba(color);\r
\r
if (mask) {\r
/* draw some pixels */\r
{\r
DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
void *b = c->Buffer->the_window;\r
- GLuint i, w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint i, w = c->Buffer->width, h = c->Buffer->height;\r
\r
if (mask) {\r
/* read some pixels */\r
{\r
DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
void *b = c->Buffer->the_window;\r
- GLuint w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint w = c->Buffer->width, h = c->Buffer->height;\r
\r
- if (c->Buffer->tri_rgb_flat) {\r
- c->Buffer->tri_rgb_flat(IROUND(v0->win[0]), IROUND(FLIP2(v0->win[1])),\r
- IROUND(v1->win[0]), IROUND(FLIP2(v1->win[1])),\r
- IROUND(v2->win[0]), IROUND(FLIP2(v2->win[1])),\r
- vl_mixrgb(v2->color));\r
- } else {\r
#define SETUP_CODE GLuint rgb = vl_mixrgb(v2->color);\r
\r
#define RENDER_SPAN(span) \\r
- GLuint i, offset = FLIP2(span.y)*w + span.x; \\r
- for (i = 0; i < span.count; i++, offset++) { \\r
- vl_putpixel(b, offset, rgb); \\r
- }\r
+ GLuint i, offset = FLIP2(span.y)*w + span.x; \\r
+ for (i = 0; i < span.count; i++, offset++) { \\r
+ vl_putpixel(b, offset, rgb); \\r
+ }\r
\r
#include "swrast/s_tritemp.h"\r
- }\r
}\r
\r
\r
{\r
DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
void *b = c->Buffer->the_window;\r
- GLuint w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint w = c->Buffer->width, h = c->Buffer->height;\r
\r
#define INTERP_Z 1\r
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE\r
#define SETUP_CODE GLuint rgb = vl_mixrgb(v2->color);\r
\r
#define RENDER_SPAN(span) \\r
- GLuint i, offset = FLIP2(span.y)*w + span.x; \\r
- for (i = 0; i < span.count; i++, offset++) { \\r
- const DEPTH_TYPE z = FixedToDepth(span.z); \\r
- if (z < zRow[i]) { \\r
- vl_putpixel(b, offset, rgb); \\r
- zRow[i] = z; \\r
- } \\r
- span.z += span.zStep; \\r
- }\r
+ GLuint i, offset = FLIP2(span.y)*w + span.x; \\r
+ for (i = 0; i < span.count; i++, offset++) { \\r
+ const DEPTH_TYPE z = FixedToDepth(span.z); \\r
+ if (z < zRow[i]) { \\r
+ vl_putpixel(b, offset, rgb); \\r
+ zRow[i] = z; \\r
+ } \\r
+ span.z += span.zStep; \\r
+ }\r
\r
#include "swrast/s_tritemp.h"\r
}\r
{\r
DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
void *b = c->Buffer->the_window;\r
- GLuint w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint w = c->Buffer->width, h = c->Buffer->height;\r
\r
#define INTERP_RGB 1\r
#define RENDER_SPAN(span) \\r
- GLuint i, offset = FLIP2(span.y)*w + span.x; \\r
- for (i = 0; i < span.count; i++, offset++) { \\r
- unsigned char rgb[3]; \\r
- rgb[0] = FixedToInt(span.red); \\r
- rgb[1] = FixedToInt(span.green); \\r
- rgb[2] = FixedToInt(span.blue); \\r
- vl_putpixel(b, offset, vl_mixrgb(rgb)); \\r
- span.red += span.redStep; \\r
- span.green += span.greenStep; \\r
- span.blue += span.blueStep; \\r
- }\r
+ GLuint i, offset = FLIP2(span.y)*w + span.x; \\r
+ for (i = 0; i < span.count; i++, offset++) { \\r
+ unsigned char rgb[3]; \\r
+ rgb[0] = FixedToInt(span.red); \\r
+ rgb[1] = FixedToInt(span.green); \\r
+ rgb[2] = FixedToInt(span.blue); \\r
+ vl_putpixel(b, offset, vl_mixrgb(rgb)); \\r
+ span.red += span.redStep; \\r
+ span.green += span.greenStep; \\r
+ span.blue += span.blueStep; \\r
+ }\r
\r
#include "swrast/s_tritemp.h"\r
}\r
{\r
DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
void *b = c->Buffer->the_window;\r
- GLuint w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint w = c->Buffer->width, h = c->Buffer->height;\r
\r
#define INTERP_Z 1\r
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE\r
#define INTERP_RGB 1\r
\r
#define RENDER_SPAN(span) \\r
- GLuint i, offset = FLIP2(span.y)*w + span.x; \\r
- for (i = 0; i < span.count; i++, offset++) { \\r
- const DEPTH_TYPE z = FixedToDepth(span.z); \\r
- if (z < zRow[i]) { \\r
- unsigned char rgb[3]; \\r
- rgb[0] = FixedToInt(span.red); \\r
- rgb[1] = FixedToInt(span.green); \\r
- rgb[2] = FixedToInt(span.blue); \\r
- vl_putpixel(b, offset, vl_mixrgb(rgb)); \\r
- zRow[i] = z; \\r
- } \\r
- span.red += span.redStep; \\r
- span.green += span.greenStep; \\r
- span.blue += span.blueStep; \\r
- span.z += span.zStep; \\r
- }\r
+ GLuint i, offset = FLIP2(span.y)*w + span.x; \\r
+ for (i = 0; i < span.count; i++, offset++) { \\r
+ const DEPTH_TYPE z = FixedToDepth(span.z); \\r
+ if (z < zRow[i]) { \\r
+ unsigned char rgb[3]; \\r
+ rgb[0] = FixedToInt(span.red); \\r
+ rgb[1] = FixedToInt(span.green); \\r
+ rgb[2] = FixedToInt(span.blue); \\r
+ vl_putpixel(b, offset, vl_mixrgb(rgb)); \\r
+ zRow[i] = z; \\r
+ } \\r
+ span.red += span.redStep; \\r
+ span.green += span.greenStep; \\r
+ span.blue += span.blueStep; \\r
+ span.z += span.zStep; \\r
+ }\r
\r
#include "swrast/s_tritemp.h"\r
}\r
if (*colorMask==0xffffffff) {\r
if (mask & DD_BACK_LEFT_BIT) {\r
if (all) {\r
- if CHECK_SOFTDB(b->caps) {\r
- vl_clear_virtual(b->the_window, b->len, c->ClearColor);\r
- } else {\r
- vl_clear(b->the_window, 0, 0, b->width, b->height, c->ClearColor);\r
- }\r
+ vl_clear(b->the_window, b->len, c->ClearColor);\r
} else {\r
- vl_clear(b->the_window, x, y, width, height, c->ClearColor);\r
+ vl_rect(b->the_window, x, y, width, height, c->ClearColor);\r
}\r
mask &= ~DD_BACK_LEFT_BIT;\r
}\r
- if (mask & DD_FRONT_LEFT_BIT) {\r
- if (all) {\r
- x = 0;\r
- y = 0;\r
- width = b->width;\r
- height = b->height;\r
- }\r
- vl_clear(b->the_window, x, y, width, height, c->ClearColor);\r
- mask &= ~DD_FRONT_LEFT_BIT;\r
- }\r
}\r
\r
if (mask) {\r
*/\r
static GLboolean set_draw_buffer (GLcontext *ctx, GLenum mode)\r
{\r
- if (mode==GL_BACK_LEFT || mode==GL_FRONT_LEFT) {\r
+ if (mode==GL_BACK_LEFT) {\r
return GL_TRUE;\r
} else {\r
return GL_FALSE;\r
{\r
DMesaVisual v;\r
GLint redBits, greenBits, blueBits, alphaBits;\r
- GLint caps;\r
\r
+ if (!dbFlag) {\r
+ return NULL;\r
+ }\r
alphaBits = 0;\r
switch (colDepth) {\r
case 15:\r
return NULL;\r
}\r
\r
- caps = 0;\r
- if (!dbFlag) {\r
- caps |= VL_SINGLE;\r
- }\r
- if (vl_video_init(width, height, colDepth, &caps)!=0) {\r
+ if (vl_video_init(width, height, colDepth)!=0) {\r
return NULL;\r
}\r
\r
1); /* numSamples */\r
\r
v->depth = colDepth;\r
- v->caps = caps;\r
+ v->db_flag = dbFlag;\r
}\r
\r
return v;\r
\r
void DMesaDestroyVisual (DMesaVisual v)\r
{\r
- vl_video_exit();\r
+ vl_video_exit(!0);\r
_mesa_destroy_visual(v->gl_visual);\r
free(v);\r
}\r
b->xpos = xpos;\r
b->ypos = ypos;\r
b->width = width;\r
+ b->bwidth = width * ((visual->depth+7)/8);\r
b->height = height;\r
- b->caps = visual->caps;\r
- b->pitch = b->width*((visual->depth+7)/8);\r
- b->len = b->pitch*b->height;\r
-\r
- b->tri_rgb_flat = vl_getprim(TRI_RGB_FLAT);\r
+ b->len = b->bwidth * b->height;\r
}\r
\r
return b;\r
\r
void DMesaDestroyBuffer (DMesaBuffer b)\r
{\r
- if CHECK_SOFTDB(b->caps) {\r
- free(b->the_window);\r
- }\r
+ free(b->the_window);\r
_mesa_destroy_framebuffer(b->gl_buffer);\r
free(b);\r
}\r
GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)\r
{\r
if (c&&b) {\r
- void *ptr = vl_sync_buffer(b->the_window, b->xpos, b->ypos, b->width, b->height, &b->cwidth);\r
-\r
- if (b->cwidth==-1) {\r
+ if ((b->the_window=vl_sync_buffer(b->the_window, b->xpos, b->ypos, b->width, b->height))==NULL) {\r
return GL_FALSE;\r
}\r
\r
- b->the_window = ptr;\r
c->Buffer = b;\r
\r
dmesa_update_state(c->gl_ctx, 0);\r
void DMesaSwapBuffers (DMesaBuffer b)\r
{\r
/* copy/swap back buffer to front if applicable */\r
- b->the_window = vl_flip(b->the_window, b->width, b->height, b->pitch);\r
+ vl_flip(b->the_window, b->bwidth, b->height);\r
}\r