- Mesa 4.0.1 DOS/DJGPP Port version 0.1\r
+ Mesa 4.0.1 DOS/DJGPP Port version 0.2\r
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
\r
\r
\r
-First of all...\r
-~~~~~~~~~~~~~~~\r
+Description:\r
+~~~~~~~~~~~~\r
\r
-This is a DOS port for MESA 4.0.1. I didn't bother to consider any DOS C\r
-compiler other than gcc, so this port was written using DJGPP v2. To be more\r
-precise:\r
- djdev 2.03\r
- gcc v3.0.3\r
- make v3.79\r
-\r
-Almost all demos were compiled and ran succesfully on my system:\r
- CPU: Intel Pentium w/ MMX @166 MHz\r
- Mainboard: ViA Apollo VP2 w/ 128 MB SDRAM\r
- Video card: Matrox Millenium I w/ 4096 kB WRAM, Matrox BIOS v3.0\r
-\r
-Since I don't have access to any accelerated video hardware, this port is\r
-entirely based on VESA/SuperVGA. My little attempt to use FreeBE/AF ended in\r
-a failure, but that's another story: it seemed to work fine with my older\r
-Matrox Millenium w/ 2MB, and then I got another Matrox Millenium w/ 4MB. The\r
-problem with latter was it had a dead BIOS; I hot-flashed it and made it work\r
-in all environments (Windows 95, VESA, etc) but FreeBE/AF.\r
+This is the DOS port of MESA 4.0, for DJGPP programmers... It features some\r
+sort of hardware acceleration, but it's pretty thin: it is entirely based on\r
+VBEAF.DRV from the FreeBE/AF project (http://www.talula.demon.co.uk/freebe/).\r
+Note that SciTech's driver isn't supported because I hate the `nearptr' hack.\r
+Anyway, these drivers don't provide ANY 3D function :-( Moreover, it seems to\r
+me the FreeBE/AF project is not really up to date... Well, it's not much, my\r
+intention was to open the door ;-)\r
\r
\r
\r
Legal:\r
~~~~~~\r
\r
-This software is distributed under the terms of the GNU Lesser General Public\r
-License.\r
+MESA copyright applies.\r
+\r
+\r
+\r
+Installation:\r
+~~~~~~~~~~~~~\r
+\r
+Type "make -f Makefile.DJ" to compile the libraries. Long filename support is\r
+required during compilation. The examples are not built automagically (see\r
+Pitfalls below).\r
\r
-Source code written by others is subject to its respective copyright.\r
+Tested on:\r
+ CPU: Intel Pentium w/ MMX @166 MHz\r
+ Mainboard: ViA Apollo VP2 w/ 128 MB SDRAM\r
+ Video card: Matrox Millenium 2064W w/ 2048 kB WRAM, BIOS v3.0\r
+ DJGPP: djdev 2.03\r
+ gcc v3.0.3\r
+ make v3.79\r
\r
\r
\r
libGL (the core):\r
~~~~~~~~~~~~~~~~~\r
\r
-Of course, MESA 4.0.1 core sources are required. It will probably work with\r
+Of course, MESA 4.0 core sources are required. It will probably work with\r
MESA 3.5, but not a chance with earlier versions due to major changes to the\r
MESA driver interface and the directory tree. All should compile succesfully.\r
\r
The driver has its origins in ddsample.c, written by Brian Paul and found by\r
me in MESA 3.4.2. I touched almost all the functions, changing the coding\r
-style ;-( Sorry!\r
+style :-( Sorry!\r
\r
Pitfalls:\r
1. The current version supports only RGB[A] modes, for it made no sense to me\r
to endorse color-index (aka palette) modes.\r
-2. Only double-buffered is allowed because it was simpler to implement at\r
- that moment. Single-buffered will appear soon, especially if I can find a\r
- way to use hardware acceleration.\r
-3. Another weird "feature" is that buffer width & height must be multiple of\r
- 4 (I'm a lazy programmer and I found that the easiest way to keep buffer\r
- handling at peak performance ;-).\r
-4. The video mode selector is tricky: it searches for the smallest mode which\r
- will entirely contain the buffer at its current position. If you want a\r
- small buffer in a high-res mode, try to position it very far to the right\r
- (or down). I'd really use some ideas here!!!\r
+2. Double-buffered uses page flipping if acceleration is available, else falls\r
+ back to virtual buffer.\r
+3. Single-buffered is not allowed with 24-bit modes, because direct access was\r
+ wrong and fixing it would mean to slow down the other routines; until this\r
+ is really, really necessary, it won't get reimplemented.\r
+4. Another weird "feature" is that buffer width must be multiple of 4 (I'm a\r
+ lazy programmer and I found that the easiest way to keep buffer handling at\r
+ peak performance ;-).\r
+5. The FreeBE/AF driver is searched in the current directory only; therefore,\r
+ to disable hardware acceleration, make sure you don't have VBEAF.DRV where\r
+ your application resides.\r
\r
\r
\r
libGLU:\r
~~~~~~~\r
\r
-Mesa GLU sources are required. Everything should run smooth.\r
+Mesa GLU sources are required. No comment!\r
\r
\r
\r
Bernhard Tschirren, Mark Kilgard, Brian Paul and probably others (or probably\r
not ;-). I only changed it to be self-standing (Allegro-free). The keyboard,\r
mouse and timer drivers were inspired from an old project of mine (D3Xl) and\r
-fixed with some Allegro "infusions"; my deeply thanks to Shawn Hargreaves and\r
-co.\r
+fixed with some Allegro "infusions"; I deeply thank to Shawn Hargreaves et co.\r
\r
My keyboard driver used only scancodes, but since GLUT requires ASCII values\r
for keys, I borrowed the translation tables (and maybe more) from Allegro.\r
at all.\r
\r
Window creating defaults: 640x480x16 at (0,0), 8-bit stencil, 16-bit accum.\r
-\r
-\r
-\r
-Installation:\r
-~~~~~~~~~~~~~\r
-\r
-Unzip into the MESA directory, and type "make -f Makefile.DJ" to compile all\r
-libraries. Long filename support is required during compilation. The examples\r
-are not built automagically (see Pitfalls above).\r
+However, the video mode is chosen in such a way that first window will fit.\r
\r
\r
\r
~~~~~~~~\r
\r
v0.1 feb-2002 initial release\r
-v0.2 ..soon..\r
+v0.2 feb-2002 + fast triangle rasterizers\r
+ + enabled sw and 1.3 extensions\r
+ + hardware acceleration: FreeBE/AF\r
+ + single-buffer modes (15-, 16-, and 32-bit)\r
+ * video mode is set by CreateVisual, not MakeCurrent\r
+ * internal changes to support multi-buf (unfinished)\r
+ ! fixed some alpha issues... (thanks, Brian)\r
+ + glut has now an internal timer\r
+ * glut changed to support multi-window (unfinished)\r
+ ! minor PC_HW corrections\r
\r
\r
\r
*/\r
\r
/*\r
- * DOS/DJGPP device driver v0.1 for Mesa 4.0\r
+ * DOS/DJGPP device driver v0.2 for Mesa 4.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
#include "glheader.h"\r
#include "context.h"\r
#include "GL/dmesa.h"\r
+#include "extensions.h"\r
+#include "macros.h"\r
#include "matrix.h"\r
+#include "mmath.h"\r
#include "texformat.h"\r
#include "texstore.h"\r
#include "array_cache/acache.h"\r
+#include "swrast/s_context.h"\r
+#include "swrast/s_depth.h"\r
+#include "swrast/s_lines.h"\r
+#include "swrast/s_triangle.h"\r
+#include "swrast/s_trispan.h"\r
#include "swrast/swrast.h"\r
#include "swrast_setup/swrast_setup.h"\r
#include "tnl/tnl.h"\r
#include "tnl/t_pipeline.h"\r
#endif\r
\r
-#include "dvesa.h"\r
-#include "dmesaint.h"\r
+#include "video.h"\r
\r
\r
\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
GLframebuffer *gl_buffer; /* The depth, stencil, accum, etc buffers */\r
void *the_window; /* your window handle, etc */\r
\r
+ int xpos, ypos; /* position */\r
int width, height; /* size in pixels */\r
- int xpos, ypos; /* buffer position */\r
- int xsize, len; /* number of bytes in a line, then total */\r
- int delta; /* used to wrap around */\r
- int offset; /* offset in video */\r
- struct dvmode *video;\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
};\r
\r
/*\r
\r
\r
\r
-WRITE_RGBA_SPAN(15)\r
-WRITE_RGBA_SPAN(16)\r
-WRITE_RGBA_SPAN(24)\r
-WRITE_RGBA_SPAN(32)\r
+#define FLIP(y) (c->Buffer->height - (y) - 1)\r
+#define FLIP2(y) (h - (y) - 1)\r
+\r
+\r
+\r
+static void write_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,\r
+ const GLubyte rgba[][4], const GLubyte mask[])\r
+{\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+ void *b = c->Buffer->the_window;\r
+ GLuint i, offset;\r
+\r
+ offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ if (mask) {\r
+ /* draw some pixels */\r
+ for (i=0; i<n; i++, offset++) {\r
+ if (mask[i]) {\r
+ vl_putpixel(b, offset, vl_mixrgba(rgba[i]));\r
+ }\r
+ }\r
+ } else {\r
+ /* draw all pixels */\r
+ for (i=0; i<n; i++, offset++) {\r
+ vl_putpixel(b, offset, vl_mixrgba(rgba[i]));\r
+ }\r
+ }\r
+}\r
+\r
+static void write_rgb_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,\r
+ const GLubyte rgb[][3], const GLubyte mask[])\r
+{\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+ void *b = c->Buffer->the_window;\r
+ GLuint i, offset;\r
\r
-WRITE_RGB_SPAN(15)\r
-WRITE_RGB_SPAN(16)\r
-WRITE_RGB_SPAN(24)\r
-WRITE_RGB_SPAN(32)\r
+ offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ if (mask) {\r
+ /* draw some pixels */\r
+ for (i=0; i<n; i++, offset++) {\r
+ if (mask[i]) {\r
+ vl_putpixel(b, offset, vl_mixrgb(rgb[i]));\r
+ }\r
+ }\r
+ } else {\r
+ /* draw all pixels */\r
+ for (i=0; i<n; i++, offset++) {\r
+ vl_putpixel(b, offset, vl_mixrgb(rgb[i]));\r
+ }\r
+ }\r
+}\r
+\r
+static void write_mono_rgba_span (const GLcontext *ctx,\r
+ GLuint n, GLint x, GLint y,\r
+ const GLchan color[4], const GLubyte mask[])\r
+{\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\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
+ if (mask) {\r
+ /* draw some pixels */\r
+ for (i=0; i<n; i++, offset++) {\r
+ if (mask[i]) {\r
+ vl_putpixel(b, offset, rgba);\r
+ }\r
+ }\r
+ } else {\r
+ /* draw all pixels */\r
+ for (i=0; i<n; i++, offset++) {\r
+ vl_putpixel(b, offset, rgba);\r
+ }\r
+ }\r
+}\r
+\r
+static void read_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,\r
+ GLubyte rgba[][4])\r
+{\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+ void *b = c->Buffer->the_window;\r
+ GLuint i, offset;\r
+\r
+ offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ /* read all pixels */\r
+ for (i=0; i<n; i++, offset++) {\r
+ vl_getrgba(b, offset, rgba[i]);\r
+ }\r
+}\r
+\r
+static void write_rgba_pixels (const GLcontext *ctx,\r
+ GLuint n, const GLint x[], const GLint y[],\r
+ const GLubyte rgba[][4], const GLubyte mask[])\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
\r
-WRITE_MONO_RGBA_SPAN(15)\r
-WRITE_MONO_RGBA_SPAN(16)\r
-WRITE_MONO_RGBA_SPAN(24)\r
-WRITE_MONO_RGBA_SPAN(32)\r
+ if (mask) {\r
+ /* draw some pixels */\r
+ for (i=0; i<n; i++) {\r
+ if (mask[i]) {\r
+ vl_putpixel(b, FLIP2(y[i])*w + x[i], vl_mixrgba(rgba[i]));\r
+ }\r
+ }\r
+ } else {\r
+ /* draw all pixels */\r
+ for (i=0; i<n; i++) {\r
+ vl_putpixel(b, FLIP2(y[i])*w + x[i], vl_mixrgba(rgba[i]));\r
+ }\r
+ }\r
+}\r
\r
-READ_RGBA_SPAN(15)\r
-READ_RGBA_SPAN(16)\r
-READ_RGBA_SPAN(24)\r
-READ_RGBA_SPAN(32)\r
+static void write_mono_rgba_pixels (const GLcontext *ctx,\r
+ GLuint n, const GLint x[], const GLint y[],\r
+ const GLchan color[4], const GLubyte mask[])\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
\r
-WRITE_RGBA_PIXELS(15)\r
-WRITE_RGBA_PIXELS(16)\r
-WRITE_RGBA_PIXELS(24)\r
-WRITE_RGBA_PIXELS(32)\r
+ if (mask) {\r
+ /* draw some pixels */\r
+ for (i=0; i<n; i++) {\r
+ if (mask[i]) {\r
+ vl_putpixel(b, FLIP2(y[i])*w + x[i], rgba);\r
+ }\r
+ }\r
+ } else {\r
+ /* draw all pixels */\r
+ for (i=0; i<n; i++) {\r
+ vl_putpixel(b, FLIP2(y[i])*w + x[i], rgba);\r
+ }\r
+ }\r
+}\r
\r
-WRITE_MONO_RGBA_PIXELS(15)\r
-WRITE_MONO_RGBA_PIXELS(16)\r
-WRITE_MONO_RGBA_PIXELS(24)\r
-WRITE_MONO_RGBA_PIXELS(32)\r
+static void read_rgba_pixels (const GLcontext *ctx,\r
+ GLuint n, const GLint x[], const GLint y[],\r
+ GLubyte rgba[][4], const GLubyte mask[])\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
\r
-READ_RGBA_PIXELS(15)\r
-READ_RGBA_PIXELS(16)\r
-READ_RGBA_PIXELS(24)\r
-READ_RGBA_PIXELS(32)\r
+ if (mask) {\r
+ /* read some pixels */\r
+ for (i=0; i<n; i++) {\r
+ if (mask[i]) {\r
+ vl_getrgba(b, FLIP2(y[i])*w + x[i], rgba[i]);\r
+ }\r
+ }\r
+ } else {\r
+ /* read all pixels */\r
+ for (i=0; i<n; i++) {\r
+ vl_getrgba(b, FLIP2(y[i])*w + x[i], rgba[i]);\r
+ }\r
+ }\r
+}\r
+\r
+\r
+\r
+/**********************************************************************/\r
+/***** Optimized triangle rendering *****/\r
+/**********************************************************************/\r
+\r
+\r
+\r
+/*\r
+ * flat, NON-depth-buffered, triangle.\r
+ */\r
+static void tri_rgb_flat (GLcontext *ctx,\r
+ const SWvertex *v0,\r
+ const SWvertex *v1,\r
+ const SWvertex *v2)\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
+\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
+\r
+#include "swrast/s_tritemp.h"\r
+ }\r
+}\r
+\r
+\r
+\r
+/*\r
+ * flat, depth-buffered, triangle.\r
+ */\r
+static void tri_rgb_flat_z (GLcontext *ctx,\r
+ const SWvertex *v0,\r
+ const SWvertex *v1,\r
+ const SWvertex *v2)\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
+\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
+\r
+#include "swrast/s_tritemp.h"\r
+}\r
+\r
+\r
+\r
+/*\r
+ * smooth, NON-depth-buffered, triangle.\r
+ */\r
+static void tri_rgb_smooth (GLcontext *ctx,\r
+ const SWvertex *v0,\r
+ const SWvertex *v1,\r
+ const SWvertex *v2)\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
+\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
+\r
+#include "swrast/s_tritemp.h"\r
+}\r
+\r
+\r
+\r
+/*\r
+ * smooth, depth-buffered, triangle.\r
+ */\r
+static void tri_rgb_smooth_z (GLcontext *ctx,\r
+ const SWvertex *v0,\r
+ const SWvertex *v1,\r
+ const SWvertex *v2)\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
+\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
+\r
+#include "swrast/s_tritemp.h"\r
+}\r
+\r
+\r
+\r
+/*\r
+ * Analyze context state to see if we can provide a fast triangle function\r
+ * Otherwise, return NULL.\r
+ */\r
+static swrast_tri_func dmesa_choose_tri_function (GLcontext *ctx)\r
+{\r
+ const SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
+\r
+ if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;\r
+ if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;\r
+ if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;\r
+\r
+ if (ctx->Light.ShadeModel==GL_SMOOTH\r
+ && swrast->_RasterMask==DEPTH_BIT\r
+ && ctx->Depth.Func==GL_LESS\r
+ && ctx->Depth.Mask==GL_TRUE\r
+ && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS\r
+ && ctx->Polygon.StippleFlag==GL_FALSE) {\r
+ return tri_rgb_smooth_z;\r
+ }\r
+ if (ctx->Light.ShadeModel==GL_FLAT\r
+ && swrast->_RasterMask==DEPTH_BIT\r
+ && ctx->Depth.Func==GL_LESS\r
+ && ctx->Depth.Mask==GL_TRUE\r
+ && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS\r
+ && ctx->Polygon.StippleFlag==GL_FALSE) {\r
+ return tri_rgb_flat_z;\r
+ }\r
+ if (swrast->_RasterMask==0 /* no depth test */\r
+ && ctx->Light.ShadeModel==GL_SMOOTH\r
+ && ctx->Polygon.StippleFlag==GL_FALSE) {\r
+ return tri_rgb_smooth;\r
+ }\r
+ if (swrast->_RasterMask==0 /* no depth test */\r
+ && ctx->Light.ShadeModel==GL_FLAT\r
+ && ctx->Polygon.StippleFlag==GL_FALSE) {\r
+ return tri_rgb_flat;\r
+ }\r
+\r
+ return (swrast_tri_func)NULL;\r
+}\r
+\r
+\r
+\r
+/* Override for the swrast triangle-selection function. Try to use one\r
+ * of our internal line functions, otherwise fall back to the\r
+ * standard swrast functions.\r
+ */\r
+static void dmesa_choose_tri (GLcontext *ctx)\r
+{\r
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
+\r
+ if (!(swrast->Triangle=dmesa_choose_tri_function(ctx)))\r
+ _swrast_choose_triangle(ctx);\r
+}\r
\r
\r
\r
static void clear_color (GLcontext *ctx, const GLchan color[4])\r
{\r
DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
- c->ClearColor = dv_color(color);\r
+ c->ClearColor = vl_mixrgba(color);\r
}\r
\r
\r
*/\r
\r
/* we can't handle color or index masking */\r
- if (*colorMask==0xffffffff && ctx->Color.IndexMask==0xffffffff) {\r
- if (mask&DD_BACK_LEFT_BIT) {\r
+ if (*colorMask==0xffffffff) {\r
+ if (mask & DD_BACK_LEFT_BIT) {\r
if (all) {\r
- dv_clear_virtual(b->the_window, b->len, c->ClearColor);\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
} else {\r
- dv_fillrect(b->the_window, b->width, x, y, width, height, c->ClearColor);\r
+ vl_clear(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) {\r
+ if (mode==GL_BACK_LEFT || mode==GL_FRONT_LEFT) {\r
return GL_TRUE;\r
} else {\r
return GL_FALSE;\r
\r
\r
\r
+#define DMESA_NEW_TRIANGLE (_NEW_POLYGON | \\r
+ _NEW_TEXTURE | \\r
+ _NEW_LIGHT | \\r
+ _NEW_DEPTH | \\r
+ _NEW_RENDERMODE | \\r
+ _SWRAST_NEW_RASTERMASK)\r
+\r
+\r
+\r
+/* Extend the software rasterizer with our line and triangle\r
+ * functions.\r
+ */\r
+static void dmesa_register_swrast_functions (GLcontext *ctx)\r
+{\r
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
+\r
+ swrast->choose_triangle = dmesa_choose_tri;\r
+\r
+ swrast->invalidate_triangle |= DMESA_NEW_TRIANGLE;\r
+}\r
+\r
+\r
+\r
/* Setup pointers and other driver state that is constant for the life\r
* of a context.\r
*/\r
swdd->SetReadBuffer = set_read_buffer;\r
\r
/* RGB(A) span/pixel functions */\r
- switch (c->visual->depth) {\r
- case 15:\r
- swdd->WriteRGBASpan = write_rgba_span_15;\r
- swdd->WriteRGBSpan = write_rgb_span_15;\r
- swdd->WriteMonoRGBASpan = write_mono_rgba_span_15;\r
- swdd->WriteRGBAPixels = write_rgba_pixels_15;\r
- swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_15;\r
- swdd->ReadRGBASpan = read_rgba_span_15;\r
- swdd->ReadRGBAPixels = read_rgba_pixels_15;\r
- break;\r
- case 16:\r
- swdd->WriteRGBASpan = write_rgba_span_16;\r
- swdd->WriteRGBSpan = write_rgb_span_16;\r
- swdd->WriteMonoRGBASpan = write_mono_rgba_span_16;\r
- swdd->WriteRGBAPixels = write_rgba_pixels_16;\r
- swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_16;\r
- swdd->ReadRGBASpan = read_rgba_span_16;\r
- swdd->ReadRGBAPixels = read_rgba_pixels_16;\r
- break;\r
- case 24:\r
- swdd->WriteRGBASpan = write_rgba_span_24;\r
- swdd->WriteRGBSpan = write_rgb_span_24;\r
- swdd->WriteMonoRGBASpan = write_mono_rgba_span_24;\r
- swdd->WriteRGBAPixels = write_rgba_pixels_24;\r
- swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_24;\r
- swdd->ReadRGBASpan = read_rgba_span_24;\r
- swdd->ReadRGBAPixels = read_rgba_pixels_24;\r
- break;\r
- case 32:\r
- swdd->WriteRGBASpan = write_rgba_span_32;\r
- swdd->WriteRGBSpan = write_rgb_span_32;\r
- swdd->WriteMonoRGBASpan = write_mono_rgba_span_32;\r
- swdd->WriteRGBAPixels = write_rgba_pixels_32;\r
- swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_32;\r
- swdd->ReadRGBASpan = read_rgba_span_32;\r
- swdd->ReadRGBAPixels = read_rgba_pixels_32;\r
- break;\r
- }\r
+ swdd->WriteRGBASpan = write_rgba_span;\r
+ swdd->WriteRGBSpan = write_rgb_span;\r
+ swdd->WriteMonoRGBASpan = write_mono_rgba_span;\r
+ swdd->WriteRGBAPixels = write_rgba_pixels;\r
+ swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels;\r
+ swdd->ReadRGBASpan = read_rgba_span;\r
+ swdd->ReadRGBAPixels = read_rgba_pixels;\r
}\r
\r
\r
/*\r
* The exact arguments to this function will depend on your window system\r
*/\r
-DMesaVisual DMesaCreateVisual (GLint colDepth, GLboolean dbFlag,\r
- GLint depthSize, GLint stencilSize,\r
+DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,\r
+ GLboolean dbFlag, GLint depthSize,\r
+ GLint stencilSize,\r
GLint accumSize)\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
redBits = 5;\r
greenBits = 6;\r
blueBits = 5;\r
break;\r
- case 24:\r
case 32:\r
+ alphaBits = 8;\r
+ case 24:\r
redBits = 8;\r
greenBits = 8;\r
blueBits = 8;\r
default:\r
return NULL;\r
}\r
- alphaBits = 8;\r
+\r
+ caps = 0;\r
+ if (!dbFlag) {\r
+ caps |= VL_SINGLE;\r
+ }\r
+ if (vl_video_init(width, height, colDepth, &caps)!=0) {\r
+ return NULL;\r
+ }\r
\r
if ((v=(DMesaVisual)calloc(1, sizeof(struct dmesa_visual)))!=NULL) {\r
/* Create core visual */\r
1); /* numSamples */\r
\r
v->depth = colDepth;\r
- v->db_flag = dbFlag;\r
+ v->caps = caps;\r
}\r
\r
return v;\r
\r
void DMesaDestroyVisual (DMesaVisual v)\r
{\r
+ vl_video_exit();\r
_mesa_destroy_visual(v->gl_visual);\r
free(v);\r
}\r
\r
\r
DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,\r
- GLint width, GLint height,\r
- GLint xpos, GLint ypos)\r
+ GLint xpos, GLint ypos,\r
+ GLint width, GLint height)\r
{\r
DMesaBuffer b;\r
\r
if ((b=(DMesaBuffer)calloc(1, sizeof(struct dmesa_buffer)))!=NULL) {\r
- if (visual->db_flag) {\r
- if ((b->the_window=calloc(1, width*height*((visual->depth+7)/8)))==NULL) {\r
- return NULL;\r
- }\r
- }\r
\r
b->gl_buffer = _mesa_create_framebuffer(visual->gl_visual,\r
visual->gl_visual->depthBits > 0,\r
visual->gl_visual->stencilBits > 0,\r
visual->gl_visual->accumRedBits > 0,\r
visual->gl_visual->alphaBits > 0);\r
- b->width = width;\r
- b->height = height;\r
b->xpos = xpos;\r
b->ypos = ypos;\r
+ b->width = width;\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
}\r
\r
return b;\r
\r
void DMesaDestroyBuffer (DMesaBuffer b)\r
{\r
- free(b->the_window);\r
+ if CHECK_SOFTDB(b->caps) {\r
+ free(b->the_window);\r
+ }\r
_mesa_destroy_framebuffer(b->gl_buffer);\r
free(b);\r
}\r
share ? share->gl_ctx : NULL,\r
(void *)c, direct);\r
\r
+ _mesa_enable_sw_extensions(c->gl_ctx);\r
+ _mesa_enable_1_3_extensions(c->gl_ctx);\r
+\r
/* you probably have to do a bunch of other initializations here. */\r
c->visual = visual;\r
\r
_tnl_CreateContext(c->gl_ctx);\r
_swsetup_CreateContext(c->gl_ctx);\r
dmesa_init_pointers(c->gl_ctx);\r
+ dmesa_register_swrast_functions(c->gl_ctx);\r
}\r
\r
return c;\r
GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)\r
{\r
if (c&&b) {\r
- c->Buffer = b;\r
- if ((b->video=dv_select_mode(b->xpos, b->ypos, b->width, b->height, c->visual->depth, &b->delta, &b->offset))==NULL) {\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
return GL_FALSE;\r
}\r
\r
- b->xsize = b->width*((c->visual->depth+7)/8);\r
- b->len = b->xsize*b->height;\r
+ b->the_window = ptr;\r
+ c->Buffer = b;\r
\r
dmesa_update_state(c->gl_ctx, 0);\r
_mesa_make_current(c->gl_ctx, b->gl_buffer);\r
void DMesaSwapBuffers (DMesaBuffer b)\r
{\r
/* copy/swap back buffer to front if applicable */\r
- if (b->the_window) {\r
- dv_dump_virtual(b->the_window, b->xsize, b->height, b->offset, b->delta);\r
- }\r
+ b->the_window = vl_flip(b->the_window, b->width, b->height, b->pitch);\r
}\r