summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-02-23 17:07:21 +0000
committerBrian Paul <[email protected]>2002-02-23 17:07:21 +0000
commit40519b3eb32749218e9a731a943e6af6c2a3ccb1 (patch)
treeb0b6b63d710486ba95fa520d45d874214e879894 /src
parentdcda68de3395bf4767b03a8975f2d45fea01b15f (diff)
DOS driver updates from Daniel Borca
Diffstat (limited to 'src')
-rw-r--r--src/glut/dos/Makefile.DJ21
-rw-r--r--src/glut/dos/PC_HW/pc_irq.S6
-rw-r--r--src/glut/dos/PC_HW/pc_mouse.c10
-rw-r--r--src/glut/dos/init.c3
-rw-r--r--src/glut/dos/internal.h6
-rw-r--r--src/glut/dos/state.c25
-rw-r--r--src/glut/dos/window.c106
-rw-r--r--src/mesa/drivers/dos/dmesa.c563
-rw-r--r--src/mesa/main/Makefile.DJ90
9 files changed, 651 insertions, 179 deletions
diff --git a/src/glut/dos/Makefile.DJ b/src/glut/dos/Makefile.DJ
index a8d176cbf4a..7cacd8d0090 100644
--- a/src/glut/dos/Makefile.DJ
+++ b/src/glut/dos/Makefile.DJ
@@ -20,7 +20,7 @@
# 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 glut makefile v0.1 for Mesa 4.0
+# DOS/DJGPP glut makefile v0.2 for Mesa 4.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : [email protected]
@@ -78,4 +78,21 @@ clean:
-$(RM) *.o
-$(RM) PC_HW\*.o
-include depend
+callback.o: callback.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
+color.o: color.c ../include/GL/glut.h
+font.o: font.c ../include/GL/glut.h
+globals.o: globals.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
+init.o: init.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
+menu.o: menu.c ../include/GL/glut.h
+models.o: models.c ../include/GL/glut.h
+overlay.o: overlay.c ../include/GL/glut.h
+state.o: state.c ../include/GL/glut.h internal.h pc_hw/pc_hw.h
+teapot.o: teapot.c ../include/GL/glut.h
+window.o: window.c ../include/GL/glut.h ../include/GL/dmesa.h internal.h \
+ PC_HW/pc_hw.h
+
+PC_HW/pc_hw.o: PC_HW/pc_hw.c PC_HW/pc_hw.h
+PC_HW/pc_keyb.o: PC_HW/pc_keyb.c PC_HW/pc_hw.h
+PC_HW/pc_mouse.o: PC_HW/pc_mouse.c PC_HW/pc_hw.h
+PC_HW/pc_timer.o: PC_HW/pc_timer.c PC_HW/pc_hw.h
+PC_HW/pc_irq.o: PC_HW/pc_irq.S
diff --git a/src/glut/dos/PC_HW/pc_irq.S b/src/glut/dos/PC_HW/pc_irq.S
index 2a6302f71a2..8f19f8eb9f4 100644
--- a/src/glut/dos/PC_HW/pc_irq.S
+++ b/src/glut/dos/PC_HW/pc_irq.S
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v0.1 for DOS/DJGPP
+ * PC/HW routine collection v0.2 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -129,7 +129,7 @@ __irq_wrapper_##x: ; \
pushl %es ; \
pushl %fs ; \
pushl %gs ; \
- movw %ss, %bx ; \
+ movl %ss, %ebx ; \
movl %esp, %esi ; \
movl %cs:___djgpp_ds_alias, %ss ; \
movl %cs:__irq_stack_##x, %esp ; \
@@ -141,7 +141,7 @@ __irq_wrapper_##x: ; \
pushl %fs ; \
popl %gs ; \
call *__irq_hook_##x ; \
- movw %bx, %ss ; \
+ movl %ebx, %ss ; \
movl %esi, %esp ; \
testl %eax, %eax ; \
popl %gs ; \
diff --git a/src/glut/dos/PC_HW/pc_mouse.c b/src/glut/dos/PC_HW/pc_mouse.c
index cc3396cb213..2a692eceb66 100644
--- a/src/glut/dos/PC_HW/pc_mouse.c
+++ b/src/glut/dos/PC_HW/pc_mouse.c
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v0.1 for DOS/DJGPP
+ * PC/HW routine collection v0.2 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -15,6 +15,12 @@
#define MOUSE_STACK_SIZE 16384
+#define CLEAR_MICKEYS() \
+ do { \
+ __asm__ __volatile__ ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \
+ ox = oy = 0; \
+ } while (0)
+
extern void mouse_wrapper (void);
extern void mouse_wrapper_end (void);
@@ -161,6 +167,8 @@ int pc_install_mouse (void)
mouse_regs.x.es = mouse_callback>>16;
__dpmi_int(0x33, &mouse_regs);
+ CLEAR_MICKEYS();
+
emulat3 = buttons<3;
pc_atexit(pc_remove_mouse);
return buttons;
diff --git a/src/glut/dos/init.c b/src/glut/dos/init.c
index d3f45821701..41170e37c92 100644
--- a/src/glut/dos/init.c
+++ b/src/glut/dos/init.c
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v0.1 for Mesa 4.0
+ * DOS/DJGPP glut driver v0.2 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -45,6 +45,7 @@ static void signal_handler (int num)
void APIENTRY glutInit (int *argcp, char **argv)
{
+ glutGet(GLUT_ELAPSED_TIME);
/* Hack alert:
only SIGINT (but not Ctrl-Break)
calls the destructors and will safely clean up
diff --git a/src/glut/dos/internal.h b/src/glut/dos/internal.h
index f6c2c4d00c4..2822c2c5ab0 100644
--- a/src/glut/dos/internal.h
+++ b/src/glut/dos/internal.h
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v0.1 for Mesa 4.0
+ * DOS/DJGPP glut driver v0.2 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -35,9 +35,11 @@
#include "pc_hw/pc_hw.h"
+#define MAX_WINDOWS 4
+
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
-#define COLOR_DEPTH 16
+#define DEFAULT_BPP 16
#define DEPTH_SIZE 16
#define STENCIL_SIZE 8
diff --git a/src/glut/dos/state.c b/src/glut/dos/state.c
index 9e5624deb4c..94ef0cac795 100644
--- a/src/glut/dos/state.c
+++ b/src/glut/dos/state.c
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v0.1 for Mesa 4.0
+ * DOS/DJGPP glut driver v0.2 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -28,6 +28,21 @@
#include "GL/glut.h"
+#include "internal.h"
+
+
+#define FREQUENCY 100
+
+
+static int timer_installed;
+static volatile int ticks;
+
+static void ticks_timer (void *p)
+{
+ (void)p;
+ ticks++;
+} ENDOFUNC(ticks_timer)
+
int APIENTRY glutGet (GLenum type)
@@ -35,6 +50,14 @@ int APIENTRY glutGet (GLenum type)
switch (type) {
case GLUT_WINDOW_RGBA:
return 1;
+ case GLUT_ELAPSED_TIME:
+ if (!timer_installed) {
+ timer_installed = !timer_installed;
+ LOCKDATA(ticks);
+ LOCKFUNC(ticks_timer);
+ pc_install_int(ticks_timer, NULL, FREQUENCY);
+ }
+ return ticks*1000/FREQUENCY;
default:
return 0;
}
diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c
index 6d52524dfbd..c110715ebb3 100644
--- a/src/glut/dos/window.c
+++ b/src/glut/dos/window.c
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v0.1 for Mesa 4.0
+ * DOS/DJGPP glut driver v0.2 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -32,50 +32,89 @@
#include "internal.h"
+
+static int window;
+
static DMesaVisual visual = NULL;
static DMesaContext context = NULL;
-static DMesaBuffer buffer = NULL;
+static DMesaBuffer buffer[MAX_WINDOWS];
+
static void clean (void)
{
- __asm__("movw $3, %%ax; int $0x10":::"%eax");
+ int i;
+
+ for (i=0; i<MAX_WINDOWS; i++) {
+ glutDestroyWindow(i+1);
+ }
+ if (context) DMesaDestroyContext(context);
+ if (visual) DMesaDestroyVisual(visual);
+
pc_close_stdout();
pc_close_stderr();
}
-int APIENTRY glutCreateWindow (const char *title)
-{
- if ((visual=DMesaCreateVisual(COLOR_DEPTH,
- g_display_mode & GLUT_DOUBLE,
- g_display_mode & GLUT_DEPTH ?DEPTH_SIZE :0,
- g_display_mode & GLUT_STENCIL?STENCIL_SIZE:0,
- g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {
- return GL_FALSE;
- }
- if ((context=DMesaCreateContext(visual, NULL))==NULL) {
- DMesaDestroyVisual(visual);
- return GL_FALSE;
- }
- if ((buffer=DMesaCreateBuffer(visual, g_width, g_height, g_xpos, g_ypos))==NULL) {
- DMesaDestroyContext(context);
- DMesaDestroyVisual(visual);
- return GL_FALSE;
+int APIENTRY glutCreateWindow (const char *title)
+{
+ int i;
+
+ if (!visual) {
+ int screen_w = DEFAULT_WIDTH;
+ int screen_h = DEFAULT_HEIGHT;
+
+ if ((g_width<=640) && (g_height<=480)) {
+ screen_w = 640;
+ screen_h = 480;
+ } else if ((g_width<=800) && (g_height<=600)) {
+ screen_w = 800;
+ screen_h = 600;
+ } else if ((g_width<=1024) && (g_height<=768)) {
+ screen_w = 1024;
+ screen_h = 768;
+ }
+
+ if ((visual=DMesaCreateVisual(screen_w, screen_h, DEFAULT_BPP,
+ g_display_mode & GLUT_DOUBLE,
+ g_display_mode & GLUT_DEPTH ?DEPTH_SIZE :0,
+ g_display_mode & GLUT_STENCIL?STENCIL_SIZE:0,
+ g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {
+ return 0;
+ }
+
+ if ((context=DMesaCreateContext(visual, NULL))==NULL) {
+ DMesaDestroyVisual(visual);
+ return 0;
+ }
+
+ pc_open_stdout();
+ pc_open_stderr();
+ pc_atexit(clean);
}
- if (!DMesaMakeCurrent(context, buffer)) {
- DMesaDestroyContext(context);
- DMesaDestroyVisual(visual);
- return GL_FALSE;
+ for (i=0; i<MAX_WINDOWS; i++) {
+ if (!buffer[i]) {
+ DMesaBuffer b;
+
+ if ((b=DMesaCreateBuffer(visual, g_xpos, g_ypos, g_width, g_height))==NULL) {
+ return 0;
+ }
+ if (!DMesaMakeCurrent(context, b)) {
+ DMesaDestroyBuffer(b);
+ return 0;
+ }
+ if (g_mouse) {
+ pc_mouse_area(g_xpos, g_ypos, g_xpos + g_width - 1, g_ypos + g_height - 1);
+ }
+
+ buffer[window = i] = b;
+ return i+1;
+ }
}
- pc_open_stdout();
- pc_open_stderr();
- pc_atexit(clean);
-
- return GL_TRUE;
+ return 0;
}
@@ -87,6 +126,10 @@ int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
void APIENTRY glutDestroyWindow (int win)
{
+ if (buffer[win-1]) {
+ DMesaDestroyBuffer(buffer[win-1]);
+ buffer[win-1] = NULL;
+ }
}
@@ -99,19 +142,20 @@ void APIENTRY glutPostRedisplay (void)
void APIENTRY glutSwapBuffers (void)
{
if (g_mouse) pc_scare_mouse();
- DMesaSwapBuffers(buffer);
+ DMesaSwapBuffers(buffer[window]);
if (g_mouse) pc_unscare_mouse();
}
int APIENTRY glutGetWindow (void)
{
- return 0;
+ return window + 1;
}
void APIENTRY glutSetWindow (int win)
{
+ window = win - 1;
}
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index 01be3012242..5ab323d33a9 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v0.1 for Mesa 4.0
+ * DOS/DJGPP device driver v0.2 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -37,10 +37,18 @@
#include "glheader.h"
#include "context.h"
#include "GL/dmesa.h"
+#include "extensions.h"
+#include "macros.h"
#include "matrix.h"
+#include "mmath.h"
#include "texformat.h"
#include "texstore.h"
#include "array_cache/acache.h"
+#include "swrast/s_context.h"
+#include "swrast/s_depth.h"
+#include "swrast/s_lines.h"
+#include "swrast/s_triangle.h"
+#include "swrast/s_trispan.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
@@ -48,8 +56,7 @@
#include "tnl/t_pipeline.h"
#endif
-#include "dvesa.h"
-#include "dmesaint.h"
+#include "video.h"
@@ -59,9 +66,10 @@
*/
struct dmesa_visual {
GLvisual *gl_visual;
- GLboolean db_flag; /* double buffered? */
GLboolean rgb_flag; /* RGB mode? */
GLuint depth; /* bits per pixel (1, 8, 24, etc) */
+
+ GLint caps; /* video mode capabilities */
};
/*
@@ -72,12 +80,14 @@ struct dmesa_buffer {
GLframebuffer *gl_buffer; /* The depth, stencil, accum, etc buffers */
void *the_window; /* your window handle, etc */
+ int xpos, ypos; /* position */
int width, height; /* size in pixels */
- int xpos, ypos; /* buffer position */
- int xsize, len; /* number of bytes in a line, then total */
- int delta; /* used to wrap around */
- int offset; /* offset in video */
- struct dvmode *video;
+ int pitch, len; /* number of bytes in a line, then total */
+ int cwidth; /* scan width */
+
+ int caps; /* video mode capabilities */
+
+ void (*tri_rgb_flat) ();
};
/*
@@ -104,40 +114,361 @@ static void dmesa_update_state (GLcontext *ctx, GLuint new_state);
-WRITE_RGBA_SPAN(15)
-WRITE_RGBA_SPAN(16)
-WRITE_RGBA_SPAN(24)
-WRITE_RGBA_SPAN(32)
+#define FLIP(y) (c->Buffer->height - (y) - 1)
+#define FLIP2(y) (h - (y) - 1)
+
+
+
+static void write_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte rgba[][4], const GLubyte mask[])
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint i, offset;
+
+ offset = c->Buffer->cwidth * FLIP(y) + x;
+ if (mask) {
+ /* draw some pixels */
+ for (i=0; i<n; i++, offset++) {
+ if (mask[i]) {
+ vl_putpixel(b, offset, vl_mixrgba(rgba[i]));
+ }
+ }
+ } else {
+ /* draw all pixels */
+ for (i=0; i<n; i++, offset++) {
+ vl_putpixel(b, offset, vl_mixrgba(rgba[i]));
+ }
+ }
+}
+
+static void write_rgb_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][3], const GLubyte mask[])
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint i, offset;
-WRITE_RGB_SPAN(15)
-WRITE_RGB_SPAN(16)
-WRITE_RGB_SPAN(24)
-WRITE_RGB_SPAN(32)
+ offset = c->Buffer->cwidth * FLIP(y) + x;
+ if (mask) {
+ /* draw some pixels */
+ for (i=0; i<n; i++, offset++) {
+ if (mask[i]) {
+ vl_putpixel(b, offset, vl_mixrgb(rgb[i]));
+ }
+ }
+ } else {
+ /* draw all pixels */
+ for (i=0; i<n; i++, offset++) {
+ vl_putpixel(b, offset, vl_mixrgb(rgb[i]));
+ }
+ }
+}
+
+static void write_mono_rgba_span (const GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ const GLchan color[4], const GLubyte mask[])
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint i, offset, rgba = vl_mixrgba(color);
+
+ offset = c->Buffer->cwidth * FLIP(y) + x;
+ if (mask) {
+ /* draw some pixels */
+ for (i=0; i<n; i++, offset++) {
+ if (mask[i]) {
+ vl_putpixel(b, offset, rgba);
+ }
+ }
+ } else {
+ /* draw all pixels */
+ for (i=0; i<n; i++, offset++) {
+ vl_putpixel(b, offset, rgba);
+ }
+ }
+}
+
+static void read_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint i, offset;
+
+ offset = c->Buffer->cwidth * FLIP(y) + x;
+ /* read all pixels */
+ for (i=0; i<n; i++, offset++) {
+ vl_getrgba(b, offset, rgba[i]);
+ }
+}
+
+static void write_rgba_pixels (const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLubyte rgba[][4], const GLubyte mask[])
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint i, w = c->Buffer->cwidth, h = c->Buffer->height;
-WRITE_MONO_RGBA_SPAN(15)
-WRITE_MONO_RGBA_SPAN(16)
-WRITE_MONO_RGBA_SPAN(24)
-WRITE_MONO_RGBA_SPAN(32)
+ if (mask) {
+ /* draw some pixels */
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ vl_putpixel(b, FLIP2(y[i])*w + x[i], vl_mixrgba(rgba[i]));
+ }
+ }
+ } else {
+ /* draw all pixels */
+ for (i=0; i<n; i++) {
+ vl_putpixel(b, FLIP2(y[i])*w + x[i], vl_mixrgba(rgba[i]));
+ }
+ }
+}
-READ_RGBA_SPAN(15)
-READ_RGBA_SPAN(16)
-READ_RGBA_SPAN(24)
-READ_RGBA_SPAN(32)
+static void write_mono_rgba_pixels (const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLchan color[4], const GLubyte mask[])
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint i, w = c->Buffer->cwidth, h = c->Buffer->height, rgba = vl_mixrgba(color);
-WRITE_RGBA_PIXELS(15)
-WRITE_RGBA_PIXELS(16)
-WRITE_RGBA_PIXELS(24)
-WRITE_RGBA_PIXELS(32)
+ if (mask) {
+ /* draw some pixels */
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ vl_putpixel(b, FLIP2(y[i])*w + x[i], rgba);
+ }
+ }
+ } else {
+ /* draw all pixels */
+ for (i=0; i<n; i++) {
+ vl_putpixel(b, FLIP2(y[i])*w + x[i], rgba);
+ }
+ }
+}
-WRITE_MONO_RGBA_PIXELS(15)
-WRITE_MONO_RGBA_PIXELS(16)
-WRITE_MONO_RGBA_PIXELS(24)
-WRITE_MONO_RGBA_PIXELS(32)
+static void read_rgba_pixels (const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4], const GLubyte mask[])
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint i, w = c->Buffer->cwidth, h = c->Buffer->height;
-READ_RGBA_PIXELS(15)
-READ_RGBA_PIXELS(16)
-READ_RGBA_PIXELS(24)
-READ_RGBA_PIXELS(32)
+ if (mask) {
+ /* read some pixels */
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ vl_getrgba(b, FLIP2(y[i])*w + x[i], rgba[i]);
+ }
+ }
+ } else {
+ /* read all pixels */
+ for (i=0; i<n; i++) {
+ vl_getrgba(b, FLIP2(y[i])*w + x[i], rgba[i]);
+ }
+ }
+}
+
+
+
+/**********************************************************************/
+/***** Optimized triangle rendering *****/
+/**********************************************************************/
+
+
+
+/*
+ * flat, NON-depth-buffered, triangle.
+ */
+static void tri_rgb_flat (GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint w = c->Buffer->cwidth, h = c->Buffer->height;
+
+ if (c->Buffer->tri_rgb_flat) {
+ c->Buffer->tri_rgb_flat(IROUND(v0->win[0]), IROUND(FLIP2(v0->win[1])),
+ IROUND(v1->win[0]), IROUND(FLIP2(v1->win[1])),
+ IROUND(v2->win[0]), IROUND(FLIP2(v2->win[1])),
+ vl_mixrgb(v2->color));
+ } else {
+#define SETUP_CODE GLuint rgb = vl_mixrgb(v2->color);
+
+#define RENDER_SPAN(span) \
+ GLuint i, offset = FLIP2(span.y)*w + span.x; \
+ for (i = 0; i < span.count; i++, offset++) { \
+ vl_putpixel(b, offset, rgb); \
+ }
+
+#include "swrast/s_tritemp.h"
+ }
+}
+
+
+
+/*
+ * flat, depth-buffered, triangle.
+ */
+static void tri_rgb_flat_z (GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint w = c->Buffer->cwidth, h = c->Buffer->height;
+
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define SETUP_CODE GLuint rgb = vl_mixrgb(v2->color);
+
+#define RENDER_SPAN(span) \
+ GLuint i, offset = FLIP2(span.y)*w + span.x; \
+ for (i = 0; i < span.count; i++, offset++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ vl_putpixel(b, offset, rgb); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+
+/*
+ * smooth, NON-depth-buffered, triangle.
+ */
+static void tri_rgb_smooth (GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint w = c->Buffer->cwidth, h = c->Buffer->height;
+
+#define INTERP_RGB 1
+#define RENDER_SPAN(span) \
+ GLuint i, offset = FLIP2(span.y)*w + span.x; \
+ for (i = 0; i < span.count; i++, offset++) { \
+ unsigned char rgb[3]; \
+ rgb[0] = FixedToInt(span.red); \
+ rgb[1] = FixedToInt(span.green); \
+ rgb[2] = FixedToInt(span.blue); \
+ vl_putpixel(b, offset, vl_mixrgb(rgb)); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+
+/*
+ * smooth, depth-buffered, triangle.
+ */
+static void tri_rgb_smooth_z (GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ void *b = c->Buffer->the_window;
+ GLuint w = c->Buffer->cwidth, h = c->Buffer->height;
+
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+
+#define RENDER_SPAN(span) \
+ GLuint i, offset = FLIP2(span.y)*w + span.x; \
+ for (i = 0; i < span.count; i++, offset++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned char rgb[3]; \
+ rgb[0] = FixedToInt(span.red); \
+ rgb[1] = FixedToInt(span.green); \
+ rgb[2] = FixedToInt(span.blue); \
+ vl_putpixel(b, offset, vl_mixrgb(rgb)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+
+/*
+ * Analyze context state to see if we can provide a fast triangle function
+ * Otherwise, return NULL.
+ */
+static swrast_tri_func dmesa_choose_tri_function (GLcontext *ctx)
+{
+ const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
+ if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
+ if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;
+
+ if (ctx->Light.ShadeModel==GL_SMOOTH
+ && swrast->_RasterMask==DEPTH_BIT
+ && ctx->Depth.Func==GL_LESS
+ && ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
+ && ctx->Polygon.StippleFlag==GL_FALSE) {
+ return tri_rgb_smooth_z;
+ }
+ if (ctx->Light.ShadeModel==GL_FLAT
+ && swrast->_RasterMask==DEPTH_BIT
+ && ctx->Depth.Func==GL_LESS
+ && ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
+ && ctx->Polygon.StippleFlag==GL_FALSE) {
+ return tri_rgb_flat_z;
+ }
+ if (swrast->_RasterMask==0 /* no depth test */
+ && ctx->Light.ShadeModel==GL_SMOOTH
+ && ctx->Polygon.StippleFlag==GL_FALSE) {
+ return tri_rgb_smooth;
+ }
+ if (swrast->_RasterMask==0 /* no depth test */
+ && ctx->Light.ShadeModel==GL_FLAT
+ && ctx->Polygon.StippleFlag==GL_FALSE) {
+ return tri_rgb_flat;
+ }
+
+ return (swrast_tri_func)NULL;
+}
+
+
+
+/* Override for the swrast triangle-selection function. Try to use one
+ * of our internal line functions, otherwise fall back to the
+ * standard swrast functions.
+ */
+static void dmesa_choose_tri (GLcontext *ctx)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (!(swrast->Triangle=dmesa_choose_tri_function(ctx)))
+ _swrast_choose_triangle(ctx);
+}
@@ -150,7 +481,7 @@ READ_RGBA_PIXELS(32)
static void clear_color (GLcontext *ctx, const GLchan color[4])
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
- c->ClearColor = dv_color(color);
+ c->ClearColor = vl_mixrgba(color);
}
@@ -171,15 +502,29 @@ 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) {
+ if (*colorMask==0xffffffff) {
+ if (mask & DD_BACK_LEFT_BIT) {
if (all) {
- dv_clear_virtual(b->the_window, b->len, c->ClearColor);
+ if CHECK_SOFTDB(b->caps) {
+ vl_clear_virtual(b->the_window, b->len, c->ClearColor);
+ } else {
+ vl_clear(b->the_window, 0, 0, b->width, b->height, c->ClearColor);
+ }
} else {
- dv_fillrect(b->the_window, b->width, x, y, width, height, c->ClearColor);
+ vl_clear(b->the_window, x, y, width, height, c->ClearColor);
}
mask &= ~DD_BACK_LEFT_BIT;
}
+ if (mask & DD_FRONT_LEFT_BIT) {
+ if (all) {
+ x = 0;
+ y = 0;
+ width = b->width;
+ height = b->height;
+ }
+ vl_clear(b->the_window, x, y, width, height, c->ClearColor);
+ mask &= ~DD_FRONT_LEFT_BIT;
+ }
}
if (mask) {
@@ -208,7 +553,7 @@ static void set_read_buffer (GLcontext *ctx, GLframebuffer *buffer,
*/
static GLboolean set_draw_buffer (GLcontext *ctx, GLenum mode)
{
- if (mode==GL_BACK_LEFT) {
+ if (mode==GL_BACK_LEFT || mode==GL_FRONT_LEFT) {
return GL_TRUE;
} else {
return GL_FALSE;
@@ -276,6 +621,29 @@ static void flush (GLcontext *ctx)
+#define DMESA_NEW_TRIANGLE (_NEW_POLYGON | \
+ _NEW_TEXTURE | \
+ _NEW_LIGHT | \
+ _NEW_DEPTH | \
+ _NEW_RENDERMODE | \
+ _SWRAST_NEW_RASTERMASK)
+
+
+
+/* Extend the software rasterizer with our line and triangle
+ * functions.
+ */
+static void dmesa_register_swrast_functions (GLcontext *ctx)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ swrast->choose_triangle = dmesa_choose_tri;
+
+ swrast->invalidate_triangle |= DMESA_NEW_TRIANGLE;
+}
+
+
+
/* Setup pointers and other driver state that is constant for the life
* of a context.
*/
@@ -361,44 +729,13 @@ static void dmesa_update_state (GLcontext *ctx, GLuint new_state)
swdd->SetReadBuffer = set_read_buffer;
/* RGB(A) span/pixel functions */
- switch (c->visual->depth) {
- case 15:
- swdd->WriteRGBASpan = write_rgba_span_15;
- swdd->WriteRGBSpan = write_rgb_span_15;
- swdd->WriteMonoRGBASpan = write_mono_rgba_span_15;
- swdd->WriteRGBAPixels = write_rgba_pixels_15;
- swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_15;
- swdd->ReadRGBASpan = read_rgba_span_15;
- swdd->ReadRGBAPixels = read_rgba_pixels_15;
- break;
- case 16:
- swdd->WriteRGBASpan = write_rgba_span_16;
- swdd->WriteRGBSpan = write_rgb_span_16;
- swdd->WriteMonoRGBASpan = write_mono_rgba_span_16;
- swdd->WriteRGBAPixels = write_rgba_pixels_16;
- swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_16;
- swdd->ReadRGBASpan = read_rgba_span_16;
- swdd->ReadRGBAPixels = read_rgba_pixels_16;
- break;
- case 24:
- swdd->WriteRGBASpan = write_rgba_span_24;
- swdd->WriteRGBSpan = write_rgb_span_24;
- swdd->WriteMonoRGBASpan = write_mono_rgba_span_24;
- swdd->WriteRGBAPixels = write_rgba_pixels_24;
- swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_24;
- swdd->ReadRGBASpan = read_rgba_span_24;
- swdd->ReadRGBAPixels = read_rgba_pixels_24;
- break;
- case 32:
- swdd->WriteRGBASpan = write_rgba_span_32;
- swdd->WriteRGBSpan = write_rgb_span_32;
- swdd->WriteMonoRGBASpan = write_mono_rgba_span_32;
- swdd->WriteRGBAPixels = write_rgba_pixels_32;
- swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_32;
- swdd->ReadRGBASpan = read_rgba_span_32;
- swdd->ReadRGBAPixels = read_rgba_pixels_32;
- break;
- }
+ swdd->WriteRGBASpan = write_rgba_span;
+ swdd->WriteRGBSpan = write_rgb_span;
+ swdd->WriteMonoRGBASpan = write_mono_rgba_span;
+ swdd->WriteRGBAPixels = write_rgba_pixels;
+ swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels;
+ swdd->ReadRGBASpan = read_rgba_span;
+ swdd->ReadRGBAPixels = read_rgba_pixels;
}
@@ -412,16 +749,16 @@ static void dmesa_update_state (GLcontext *ctx, GLuint new_state)
/*
* The exact arguments to this function will depend on your window system
*/
-DMesaVisual DMesaCreateVisual (GLint colDepth, GLboolean dbFlag,
- GLint depthSize, GLint stencilSize,
+DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
+ GLboolean dbFlag, GLint depthSize,
+ GLint stencilSize,
GLint accumSize)
{
DMesaVisual v;
GLint redBits, greenBits, blueBits, alphaBits;
+ GLint caps;
- if (!dbFlag) {
- return NULL;
- }
+ alphaBits = 0;
switch (colDepth) {
case 15:
redBits = 5;
@@ -433,8 +770,9 @@ DMesaVisual DMesaCreateVisual (GLint colDepth, GLboolean dbFlag,
greenBits = 6;
blueBits = 5;
break;
- case 24:
case 32:
+ alphaBits = 8;
+ case 24:
redBits = 8;
greenBits = 8;
blueBits = 8;
@@ -442,7 +780,14 @@ DMesaVisual DMesaCreateVisual (GLint colDepth, GLboolean dbFlag,
default:
return NULL;
}
- alphaBits = 8;
+
+ caps = 0;
+ if (!dbFlag) {
+ caps |= VL_SINGLE;
+ }
+ if (vl_video_init(width, height, colDepth, &caps)!=0) {
+ return NULL;
+ }
if ((v=(DMesaVisual)calloc(1, sizeof(struct dmesa_visual)))!=NULL) {
/* Create core visual */
@@ -463,7 +808,7 @@ DMesaVisual DMesaCreateVisual (GLint colDepth, GLboolean dbFlag,
1); /* numSamples */
v->depth = colDepth;
- v->db_flag = dbFlag;
+ v->caps = caps;
}
return v;
@@ -473,6 +818,7 @@ DMesaVisual DMesaCreateVisual (GLint colDepth, GLboolean dbFlag,
void DMesaDestroyVisual (DMesaVisual v)
{
+ vl_video_exit();
_mesa_destroy_visual(v->gl_visual);
free(v);
}
@@ -480,27 +826,27 @@ void DMesaDestroyVisual (DMesaVisual v)
DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
- GLint width, GLint height,
- GLint xpos, GLint ypos)
+ GLint xpos, GLint ypos,
+ GLint width, GLint height)
{
DMesaBuffer b;
if ((b=(DMesaBuffer)calloc(1, sizeof(struct dmesa_buffer)))!=NULL) {
- if (visual->db_flag) {
- if ((b->the_window=calloc(1, width*height*((visual->depth+7)/8)))==NULL) {
- return NULL;
- }
- }
b->gl_buffer = _mesa_create_framebuffer(visual->gl_visual,
visual->gl_visual->depthBits > 0,
visual->gl_visual->stencilBits > 0,
visual->gl_visual->accumRedBits > 0,
visual->gl_visual->alphaBits > 0);
- b->width = width;
- b->height = height;
b->xpos = xpos;
b->ypos = ypos;
+ b->width = width;
+ b->height = height;
+ b->caps = visual->caps;
+ b->pitch = b->width*((visual->depth+7)/8);
+ b->len = b->pitch*b->height;
+
+ b->tri_rgb_flat = vl_getprim(TRI_RGB_FLAT);
}
return b;
@@ -510,7 +856,9 @@ DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
void DMesaDestroyBuffer (DMesaBuffer b)
{
- free(b->the_window);
+ if CHECK_SOFTDB(b->caps) {
+ free(b->the_window);
+ }
_mesa_destroy_framebuffer(b->gl_buffer);
free(b);
}
@@ -528,6 +876,9 @@ DMesaContext DMesaCreateContext (DMesaVisual visual,
share ? share->gl_ctx : NULL,
(void *)c, direct);
+ _mesa_enable_sw_extensions(c->gl_ctx);
+ _mesa_enable_1_3_extensions(c->gl_ctx);
+
/* you probably have to do a bunch of other initializations here. */
c->visual = visual;
@@ -538,6 +889,7 @@ DMesaContext DMesaCreateContext (DMesaVisual visual,
_tnl_CreateContext(c->gl_ctx);
_swsetup_CreateContext(c->gl_ctx);
dmesa_init_pointers(c->gl_ctx);
+ dmesa_register_swrast_functions(c->gl_ctx);
}
return c;
@@ -559,13 +911,14 @@ void DMesaDestroyContext (DMesaContext c)
GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
{
if (c&&b) {
- c->Buffer = b;
- if ((b->video=dv_select_mode(b->xpos, b->ypos, b->width, b->height, c->visual->depth, &b->delta, &b->offset))==NULL) {
+ void *ptr = vl_sync_buffer(b->the_window, b->xpos, b->ypos, b->width, b->height, &b->cwidth);
+
+ if (b->cwidth==-1) {
return GL_FALSE;
}
- b->xsize = b->width*((c->visual->depth+7)/8);
- b->len = b->xsize*b->height;
+ b->the_window = ptr;
+ c->Buffer = b;
dmesa_update_state(c->gl_ctx, 0);
_mesa_make_current(c->gl_ctx, b->gl_buffer);
@@ -586,7 +939,5 @@ GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
void DMesaSwapBuffers (DMesaBuffer b)
{
/* copy/swap back buffer to front if applicable */
- if (b->the_window) {
- dv_dump_virtual(b->the_window, b->xsize, b->height, b->offset, b->delta);
- }
+ b->the_window = vl_flip(b->the_window, b->width, b->height, b->pitch);
}
diff --git a/src/mesa/main/Makefile.DJ b/src/mesa/main/Makefile.DJ
index 4895cc30088..e6be4205d6a 100644
--- a/src/mesa/main/Makefile.DJ
+++ b/src/mesa/main/Makefile.DJ
@@ -1,4 +1,26 @@
-# DOS/DJGPP core makefile v0.1 for Mesa 4.0.x
+# 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 core makefile v0.2 for Mesa 4.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : [email protected]
@@ -17,13 +39,14 @@ LIBDIR = $(TOP)/lib
GL_LIB = libgl.a
CORE_SOURCES = \
- accum.c \
+ swrast_setup/ss_context.c \
+ swrast_setup/ss_triangle.c \
+ swrast_setup/ss_vb.c \
api_arrayelt.c \
api_loopback.c \
api_noop.c \
api_validate.c \
- array_cache/ac_context.c \
- array_cache/ac_import.c \
+ accum.c \
attrib.c \
blend.c \
buffers.c \
@@ -53,6 +76,23 @@ CORE_SOURCES = \
imports.c \
light.c \
lines.c \
+ matrix.c \
+ mem.c \
+ mmath.c \
+ pixel.c \
+ points.c \
+ polygon.c \
+ rastpos.c \
+ state.c \
+ stencil.c \
+ texformat.c \
+ teximage.c \
+ texobj.c \
+ texstate.c \
+ texstore.c \
+ texutil.c \
+ varray.c \
+ vtxfmt.c \
math/m_debug_clip.c \
math/m_debug_norm.c \
math/m_debug_vertex.c \
@@ -63,15 +103,8 @@ CORE_SOURCES = \
math/m_vector.c \
math/m_vertices.c \
math/m_xform.c \
- matrix.c \
- mem.c \
- mmath.c \
- pixel.c \
- points.c \
- polygon.c \
- rastpos.c \
- state.c \
- stencil.c \
+ array_cache/ac_context.c \
+ array_cache/ac_import.c \
swrast/s_aaline.c \
swrast/s_aatriangle.c \
swrast/s_accum.c \
@@ -80,8 +113,8 @@ CORE_SOURCES = \
swrast/s_bitmap.c \
swrast/s_blend.c \
swrast/s_buffers.c \
- swrast/s_context.c \
swrast/s_copypix.c \
+ swrast/s_context.c \
swrast/s_depth.c \
swrast/s_drawpix.c \
swrast/s_feedback.c \
@@ -98,19 +131,10 @@ CORE_SOURCES = \
swrast/s_scissor.c \
swrast/s_span.c \
swrast/s_stencil.c \
- swrast/s_texstore.c \
swrast/s_texture.c \
+ swrast/s_texstore.c \
swrast/s_triangle.c \
swrast/s_zoom.c \
- swrast_setup/ss_context.c \
- swrast_setup/ss_triangle.c \
- swrast_setup/ss_vb.c \
- texformat.c \
- teximage.c \
- texobj.c \
- texstate.c \
- texstore.c \
- texutil.c \
tnl/t_array_api.c \
tnl/t_array_import.c \
tnl/t_context.c \
@@ -131,11 +155,9 @@ CORE_SOURCES = \
tnl/t_vb_render.c \
tnl/t_vb_texgen.c \
tnl/t_vb_texmat.c \
- tnl/t_vb_vertex.c \
- varray.c \
- vtxfmt.c
+ tnl/t_vb_vertex.c
-DRIVER_SOURCES = DOS/dmesa.c DOS/dvesa.c
+DRIVER_SOURCES = DOS/dmesa.c DOS/video.c DOS/vbeaf.c DOS/dpmi.c
SOURCES = $(CORE_SOURCES) $(DRIVER_SOURCES)
@@ -157,7 +179,11 @@ include depend
DOS/dmesa.o: DOS/dmesa.c glheader.h ../include/GL/gl.h context.h glapi.h \
mtypes.h config.h glapitable.h glthread.h math/m_matrix.h dd.h \
- ../include/GL/dmesa.h matrix.h texformat.h texstore.h array_cache/acache.h \
- swrast/swrast.h swrast_setup/swrast_setup.h tnl/tnl.h tnl/t_context.h \
- math/m_vector.h math/m_xform.h tnl/t_pipeline.h DOS/dvesa.h DOS/dmesaint.h
-DOS/dvesa.o: DOS/dvesa.c DOS/dvesa.h
+ ../include/GL/dmesa.h extensions.h macros.h matrix.h mmath.h texformat.h \
+ texstore.h array_cache/acache.h swrast/s_context.h swrast/swrast.h \
+ swrast/s_depth.h swrast/s_lines.h swrast/s_triangle.h swrast/s_trispan.h \
+ swrast_setup/swrast_setup.h tnl/tnl.h tnl/t_context.h math/m_vector.h \
+ math/m_xform.h tnl/t_pipeline.h DOS/video.h swrast/s_tritemp.h
+DOS/dpmi.o: DOS/dpmi.c DOS/vbeaf.h DOS/dpmiint.h
+DOS/vbeaf.o: DOS/vbeaf.c DOS/dpmiint.h DOS/vbeaf.h DOS/video.h
+DOS/video.o: DOS/video.c DOS/video.h DOS/dpmiint.h DOS/vbeafint.h DOS/vbeaf.h