summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dos
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dos')
-rw-r--r--src/mesa/drivers/dos/dmesa.c105
-rw-r--r--src/mesa/drivers/dos/null.c222
-rw-r--r--src/mesa/drivers/dos/null.h41
-rw-r--r--src/mesa/drivers/dos/video.c8
4 files changed, 325 insertions, 51 deletions
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index c8fd91864bd..e0744a88de8 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -69,11 +69,8 @@
*/
struct dmesa_visual {
GLvisual gl_visual;
- GLboolean db_flag; /* double buffered? */
- GLboolean rgb_flag; /* RGB mode? */
GLboolean sw_alpha; /* use Mesa's alpha buffer? */
- GLuint depth; /* bits per pixel (1, 8, 24, etc) */
- int zbuffer; /* Z=buffer: 0=no, 1=SW, -1=HW */
+ int z_buffer; /* Z=buffer: 0=no, 1=SW, -1=HW */
};
/*
@@ -95,7 +92,7 @@ struct dmesa_buffer {
struct dmesa_context {
GLcontext gl_ctx; /* the core library context */
DMesaVisual visual;
- DMesaBuffer Buffer;
+ DMesaBuffer buffer;
GLuint ClearColor;
GLuint ClearIndex;
/* etc... */
@@ -107,10 +104,10 @@ struct dmesa_context {
/****************************************************************************
* Read/Write pixels
***************************************************************************/
-#define FLIP(y) (dmesa->Buffer->height - (y) - 1)
+#define FLIP(y) (dmesa->buffer->height - (y) - 1)
#define FLIP2(y) (_b_ - (y))
-#define DSTRIDE dmesa->Buffer->width
+#define DSTRIDE dmesa->buffer->width
/****************************************************************************
* RGB[A]
@@ -208,7 +205,7 @@ static void write_rgba_pixels (const GLcontext *ctx,
const GLubyte rgba[][4], const GLubyte mask[])
{
const DMesaContext dmesa = (DMesaContext)ctx;
- GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;
+ GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1;
if (mask) {
/* draw some pixels */
@@ -232,7 +229,7 @@ static void write_mono_rgba_pixels (const GLcontext *ctx,
const GLchan color[4], const GLubyte mask[])
{
const DMesaContext dmesa = (DMesaContext)ctx;
- GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1, rgba = vl_mixrgba(color);
+ GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1, rgba = vl_mixrgba(color);
if (mask) {
/* draw some pixels */
@@ -256,7 +253,7 @@ static void read_rgba_pixels (const GLcontext *ctx,
GLubyte rgba[][4], const GLubyte mask[])
{
const DMesaContext dmesa = (DMesaContext)ctx;
- GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;
+ GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1;
if (mask) {
/* read some pixels */
@@ -371,7 +368,7 @@ static void write_index_pixels (const GLcontext *ctx,
const GLuint index[], const GLubyte mask[])
{
const DMesaContext dmesa = (DMesaContext)ctx;
- GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;
+ GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1;
if (mask) {
/* draw some pixels */
@@ -395,7 +392,7 @@ static void write_mono_index_pixels (const GLcontext *ctx,
GLuint colorIndex, const GLubyte mask[])
{
const DMesaContext dmesa = (DMesaContext)ctx;
- GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;
+ GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1;
if (mask) {
/* draw some pixels */
@@ -419,7 +416,7 @@ static void read_index_pixels (const GLcontext *ctx,
GLuint index[], const GLubyte mask[])
{
const DMesaContext dmesa = (DMesaContext)ctx;
- GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;
+ GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1;
if (mask) {
/* read some pixels */
@@ -455,8 +452,8 @@ static void read_index_pixels (const GLcontext *ctx,
#define SETUP_CODE \
const DMesaContext dmesa = (DMesaContext)ctx; \
- GLuint _b_ = dmesa->Buffer->height - 1; \
- GLuint _w_ = dmesa->Buffer->width; \
+ GLuint _b_ = dmesa->buffer->height - 1; \
+ GLuint _w_ = dmesa->buffer->width; \
GLuint rgb = vl_mixrgb(v2->color);
#define RENDER_SPAN(span) \
@@ -479,8 +476,8 @@ static void read_index_pixels (const GLcontext *ctx,
#define SETUP_CODE \
const DMesaContext dmesa = (DMesaContext)ctx; \
- GLuint _b_ = dmesa->Buffer->height - 1; \
- GLuint _w_ = dmesa->Buffer->width; \
+ GLuint _b_ = dmesa->buffer->height - 1; \
+ GLuint _w_ = dmesa->buffer->width; \
GLuint rgb = vl_mixrgb(v2->color);
#define RENDER_SPAN(span) \
@@ -507,8 +504,8 @@ static void read_index_pixels (const GLcontext *ctx,
#define SETUP_CODE \
const DMesaContext dmesa = (DMesaContext)ctx; \
- GLuint _b_ = dmesa->Buffer->height - 1; \
- GLuint _w_ = dmesa->Buffer->width;
+ GLuint _b_ = dmesa->buffer->height - 1; \
+ GLuint _w_ = dmesa->buffer->width;
#define RENDER_SPAN(span) \
GLuint i, offset = FLIP2(span.y)*_w_ + span.x; \
@@ -534,8 +531,8 @@ static void read_index_pixels (const GLcontext *ctx,
#define SETUP_CODE \
const DMesaContext dmesa = (DMesaContext)ctx; \
- GLuint _b_ = dmesa->Buffer->height - 1; \
- GLuint _w_ = dmesa->Buffer->width;
+ GLuint _b_ = dmesa->buffer->height - 1; \
+ GLuint _w_ = dmesa->buffer->width;
#define RENDER_SPAN(span) \
GLuint i, offset = FLIP2(span.y)*_w_ + span.x; \
@@ -616,8 +613,8 @@ static void dmesa_choose_tri (GLcontext *ctx)
#define SETUP_CODE \
const DMesaContext dmesa = (DMesaContext)ctx; \
- GLuint _b_ = dmesa->Buffer->height - 1; \
- GLuint _w_ = dmesa->Buffer->width; \
+ GLuint _b_ = dmesa->buffer->height - 1; \
+ GLuint _w_ = dmesa->buffer->width; \
GLuint rgb = vl_mixrgb(vert1->color);
#define PLOT(X,Y) vl_putpixel(FLIP2(Y) * _w_ + X, rgb);
@@ -638,8 +635,8 @@ static void dmesa_choose_tri (GLcontext *ctx)
#define SETUP_CODE \
const DMesaContext dmesa = (DMesaContext)ctx; \
- GLuint _b_ = dmesa->Buffer->height - 1; \
- GLuint _w_ = dmesa->Buffer->width; \
+ GLuint _b_ = dmesa->buffer->height - 1; \
+ GLuint _w_ = dmesa->buffer->width; \
GLuint rgb = vl_mixrgb(vert1->color);
#define PLOT(X,Y) \
@@ -751,7 +748,7 @@ static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all,
/* we can't handle color or index masking */
if ((*colorMask == 0xffffffff) && (ctx->Color.IndexMask == 0xffffffff)) {
if (mask & DD_BACK_LEFT_BIT) {
- int color = c->visual->rgb_flag ? c->ClearColor : c->ClearIndex;
+ int color = ((GLvisual *)(c->visual))->rgbMode ? c->ClearColor : c->ClearIndex;
if (all) {
vl_clear(color);
@@ -958,10 +955,6 @@ DMesaVisual DMesaCreateVisual (GLint width,
GLint redBits, greenBits, blueBits, alphaBits, indexBits;
GLboolean sw_alpha;
- if (!dbFlag) {
- return NULL;
- }
-
alphaBits = 0;
if (!rgbFlag) {
@@ -1017,6 +1010,9 @@ DMesaVisual DMesaCreateVisual (GLint width,
alphaBits = alphaSize;
sw_alpha = (alphaBits > 0);
+ if (!dbFlag) {
+ return NULL;
+ }
if ((colDepth=vl_video_init(width, height, colDepth, rgbFlag, refresh)) <= 0) {
return NULL;
}
@@ -1040,12 +1036,8 @@ DMesaVisual DMesaCreateVisual (GLint width,
alphaBits?accumSize:0, /* accumAlpha */
1); /* numSamples */
- v->depth = colDepth;
- v->db_flag = dbFlag;
- v->rgb_flag = rgbFlag;
v->sw_alpha = sw_alpha;
-
- v->zbuffer = (depthSize > 0) ? 1 : 0;
+ v->z_buffer = (depthSize > 0) ? 1 : 0;
}
return v;
@@ -1113,7 +1105,7 @@ DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
if ((b=(DMesaBuffer)CALLOC_STRUCT(dmesa_buffer)) != NULL) {
_mesa_initialize_framebuffer((GLframebuffer *)b,
(GLvisual *)visual,
- visual->zbuffer == 1,
+ visual->z_buffer == 1,
((GLvisual *)visual)->stencilBits > 0,
((GLvisual *)visual)->accumRedBits > 0,
visual->sw_alpha);
@@ -1134,7 +1126,9 @@ DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
void DMesaDestroyBuffer (DMesaBuffer b)
{
#ifndef FX
- free(b->the_window);
+ if (b->the_window != NULL) {
+ free(b->the_window);
+ }
_mesa_destroy_framebuffer((GLframebuffer *)b);
#endif
}
@@ -1179,7 +1173,7 @@ DMesaContext DMesaCreateContext (DMesaVisual visual,
tnl = TNL_CONTEXT(c);
tnl->Driver.RunPipeline = _tnl_run_pipeline;
/* swrast setup */
- if (visual->rgb_flag) dmesa_register_swrast_functions(c);
+ if (((GLvisual *)visual)->rgbMode) dmesa_register_swrast_functions(c);
dmesa_init_pointers(c);
_swsetup_Wakeup(c);
}
@@ -1212,19 +1206,16 @@ GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos)
{
#ifndef FX
GET_CURRENT_CONTEXT(ctx);
- DMesaBuffer b = ((DMesaContext)ctx)->Buffer;
+ DMesaBuffer b = ((DMesaContext)ctx)->buffer;
- if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) != 0) {
- return GL_FALSE;
- } else {
+ if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) == 0) {
b->xpos = xpos;
b->ypos = ypos;
return GL_TRUE;
}
+#endif
-#else
return GL_FALSE;
-#endif
}
@@ -1233,19 +1224,16 @@ GLboolean DMesaResizeBuffer (GLint width, GLint height)
{
#ifndef FX
GET_CURRENT_CONTEXT(ctx);
- DMesaBuffer b = ((DMesaContext)ctx)->Buffer;
+ DMesaBuffer b = ((DMesaContext)ctx)->buffer;
- if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) != 0) {
- return GL_FALSE;
- } else {
+ if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) == 0) {
b->width = width;
b->height = height;
return GL_TRUE;
}
+#endif
-#else
return GL_FALSE;
-#endif
}
@@ -1261,7 +1249,7 @@ GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
return GL_FALSE;
}
- c->Buffer = b;
+ c->buffer = b;
_mesa_make_current((GLcontext *)c, (GLframebuffer *)b);
if (((GLcontext *)c)->Viewport.Width == 0) {
@@ -1391,6 +1379,21 @@ int DMesaGetIntegerv (GLenum pname, GLint *params)
return n;
}
#endif
+ case DMESA_GET_BUFFER_ADDR:
+ #ifndef FX
+ {
+ DMesaContext c = (DMesaContext)DMesaGetCurrentContext();
+ if (c != NULL) {
+ DMesaBuffer b = c->buffer;
+ if (b != NULL) {
+ params[0] = (GLint)b->the_window;
+ }
+ }
+ }
+ #else
+ return -1;
+ #endif
+ break;
default:
return -1;
}
diff --git a/src/mesa/drivers/dos/null.c b/src/mesa/drivers/dos/null.c
new file mode 100644
index 00000000000..62e2c942ef9
--- /dev/null
+++ b/src/mesa/drivers/dos/null.c
@@ -0,0 +1,222 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * DOS/DJGPP device driver v1.6 for Mesa
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : [email protected]
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include <stdlib.h>
+#include <sys/segments.h>
+
+#include "video.h"
+#include "null.h"
+
+
+
+static vl_mode *modes;
+
+#define null_color_precision 8
+
+
+
+
+static void null_blit_nop (void)
+{
+}
+
+
+
+/* Desc: Attempts to detect VGA, check video modes and create selectors.
+ *
+ * In : -
+ * Out : mode array
+ *
+ * Note: -
+ */
+static vl_mode *null_init (void)
+{
+ static int m[][2] = {
+ {320, 200},
+ {320, 240},
+ {400, 300},
+ {512, 384},
+ {640, 400},
+ {640, 480},
+ {800, 600},
+ {1024, 768},
+ {1280, 1024},
+ {1600, 1200}
+ };
+ static int b[] = {
+ 8,
+ 15,
+ 16,
+ 24,
+ 32
+ };
+
+ unsigned int i, j, k;
+
+ if (modes == NULL) {
+ modes = malloc(sizeof(vl_mode) *
+ (1 + (sizeof(m) / sizeof(m[0]) * sizeof(b) / sizeof(b[0]))));
+
+ if (modes != NULL) {
+ for (k = 0, i = 0; i < sizeof(m) / sizeof(m[0]); i++) {
+ for (j = 0; j < sizeof(b) / sizeof(b[0]); j++, k++) {
+ modes[k].xres = m[i][0];
+ modes[k].yres = m[i][1];
+ modes[k].bpp = b[j];
+ modes[k].mode = 0x4000;
+ modes[k].scanlen = m[i][0] * ((b[j] + 7) / 8);
+ modes[k].sel = -1;
+ modes[k].gran = -1;
+ }
+ }
+ modes[k].xres = -1;
+ modes[k].yres = -1;
+ modes[k].bpp = -1;
+ modes[k].mode = 0xffff;
+ modes[k].scanlen = -1;
+ modes[k].sel = -1;
+ modes[k].gran = -1;
+ }
+ }
+
+ return modes;
+}
+
+
+
+/* Desc: Frees all resources allocated by VGA init code.
+ *
+ * In : -
+ * Out : -
+ *
+ * Note: -
+ */
+static void null_fini (void)
+{
+}
+
+
+
+/* Desc: Attempts to enter specified video mode.
+ *
+ * In : ptr to mode structure, refresh rate
+ * Out : 0 if success
+ *
+ * Note: -
+ */
+static int null_entermode (vl_mode *p, int refresh)
+{
+ NUL.blit = null_blit_nop;
+
+ return 0;
+
+ (void)(p && refresh); /* silence compiler warning */
+}
+
+
+
+/* Desc: Restores to the mode prior to first call to null_entermode.
+ *
+ * In : -
+ * Out : -
+ *
+ * Note: -
+ */
+static void null_restore (void)
+{
+}
+
+
+
+/* Desc: set one palette entry
+ *
+ * In : color index, R, G, B
+ * Out : -
+ *
+ * Note: uses integer values
+ */
+static void null_setCI_i (int index, int red, int green, int blue)
+{
+ (void)(index && red && green && blue); /* silence compiler warning */
+}
+
+
+
+/* Desc: set one palette entry
+ *
+ * In : color index, R, G, B
+ * Out : -
+ *
+ * Note: uses normalized values
+ */
+static void null_setCI_f (int index, float red, float green, float blue)
+{
+ float max = (1 << null_color_precision) - 1;
+
+ null_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
+}
+
+
+
+/* Desc: state retrieval
+ *
+ * In : parameter name, ptr to storage
+ * Out : 0 if request successfully processed
+ *
+ * Note: -
+ */
+static int null_get (int pname, int *params)
+{
+ switch (pname) {
+ default:
+ params[0] = params[0]; /* silence compiler warning */
+ return -1;
+ }
+ return 0;
+}
+
+
+
+/*
+ * the driver
+ */
+vl_driver NUL = {
+ null_init,
+ null_entermode,
+ NULL,
+ null_setCI_f,
+ null_setCI_i,
+ null_get,
+ null_restore,
+ null_fini
+};
diff --git a/src/mesa/drivers/dos/null.h b/src/mesa/drivers/dos/null.h
new file mode 100644
index 00000000000..a38accc8570
--- /dev/null
+++ b/src/mesa/drivers/dos/null.h
@@ -0,0 +1,41 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * DOS/DJGPP device driver v1.6 for Mesa
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : [email protected]
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#ifndef NULL_H_included
+#define NULL_H_included
+
+#include "internal.h"
+
+extern vl_driver NUL;
+
+#endif
diff --git a/src/mesa/drivers/dos/video.c b/src/mesa/drivers/dos/video.c
index 41903ebe799..d3774e7c3e4 100644
--- a/src/mesa/drivers/dos/video.c
+++ b/src/mesa/drivers/dos/video.c
@@ -38,6 +38,7 @@
#include "internal.h"
#include "vesa.h"
#include "vga.h"
+#include "null.h"
#include "video.h"
@@ -428,6 +429,13 @@ static vl_mode *v_init_hw (void)
static vl_mode *q = NULL;
if (q == NULL) {
+ /* are we forced to NUL driver? */
+ if (getenv("DMESA_NULDRV")) {
+ if ((q = NUL.init()) != NULL) {
+ drv = &NUL;
+ }
+ return q;
+ }
/* initialize hardware */
if ((q = VESA.init()) != NULL) {
drv = &VESA;