DOS updates from Daniel Borca
This commit is contained in:
parent
c7a3356746
commit
e0193a9425
102
docs/README.DJ
102
docs/README.DJ
|
@ -1,73 +1,77 @@
|
|||
Mesa 4.0.1 DOS/DJGPP Port version 0.1
|
||||
Mesa 4.0.1 DOS/DJGPP Port version 0.2
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
First of all...
|
||||
~~~~~~~~~~~~~~~
|
||||
Description:
|
||||
~~~~~~~~~~~~
|
||||
|
||||
This is a DOS port for MESA 4.0.1. I didn't bother to consider any DOS C
|
||||
compiler other than gcc, so this port was written using DJGPP v2. To be more
|
||||
precise:
|
||||
djdev 2.03
|
||||
gcc v3.0.3
|
||||
make v3.79
|
||||
|
||||
Almost all demos were compiled and ran succesfully on my system:
|
||||
CPU: Intel Pentium w/ MMX @166 MHz
|
||||
Mainboard: ViA Apollo VP2 w/ 128 MB SDRAM
|
||||
Video card: Matrox Millenium I w/ 4096 kB WRAM, Matrox BIOS v3.0
|
||||
|
||||
Since I don't have access to any accelerated video hardware, this port is
|
||||
entirely based on VESA/SuperVGA. My little attempt to use FreeBE/AF ended in
|
||||
a failure, but that's another story: it seemed to work fine with my older
|
||||
Matrox Millenium w/ 2MB, and then I got another Matrox Millenium w/ 4MB. The
|
||||
problem with latter was it had a dead BIOS; I hot-flashed it and made it work
|
||||
in all environments (Windows 95, VESA, etc) but FreeBE/AF.
|
||||
This is the DOS port of MESA 4.0, for DJGPP programmers... It features some
|
||||
sort of hardware acceleration, but it's pretty thin: it is entirely based on
|
||||
VBEAF.DRV from the FreeBE/AF project (http://www.talula.demon.co.uk/freebe/).
|
||||
Note that SciTech's driver isn't supported because I hate the `nearptr' hack.
|
||||
Anyway, these drivers don't provide ANY 3D function :-( Moreover, it seems to
|
||||
me the FreeBE/AF project is not really up to date... Well, it's not much, my
|
||||
intention was to open the door ;-)
|
||||
|
||||
|
||||
|
||||
Legal:
|
||||
~~~~~~
|
||||
|
||||
This software is distributed under the terms of the GNU Lesser General Public
|
||||
License.
|
||||
MESA copyright applies.
|
||||
|
||||
Source code written by others is subject to its respective copyright.
|
||||
|
||||
|
||||
Installation:
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Type "make -f Makefile.DJ" to compile the libraries. Long filename support is
|
||||
required during compilation. The examples are not built automagically (see
|
||||
Pitfalls below).
|
||||
|
||||
Tested on:
|
||||
CPU: Intel Pentium w/ MMX @166 MHz
|
||||
Mainboard: ViA Apollo VP2 w/ 128 MB SDRAM
|
||||
Video card: Matrox Millenium 2064W w/ 2048 kB WRAM, BIOS v3.0
|
||||
DJGPP: djdev 2.03
|
||||
gcc v3.0.3
|
||||
make v3.79
|
||||
|
||||
|
||||
|
||||
libGL (the core):
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Of course, MESA 4.0.1 core sources are required. It will probably work with
|
||||
Of course, MESA 4.0 core sources are required. It will probably work with
|
||||
MESA 3.5, but not a chance with earlier versions due to major changes to the
|
||||
MESA driver interface and the directory tree. All should compile succesfully.
|
||||
|
||||
The driver has its origins in ddsample.c, written by Brian Paul and found by
|
||||
me in MESA 3.4.2. I touched almost all the functions, changing the coding
|
||||
style ;-( Sorry!
|
||||
style :-( Sorry!
|
||||
|
||||
Pitfalls:
|
||||
1. The current version supports only RGB[A] modes, for it made no sense to me
|
||||
to endorse color-index (aka palette) modes.
|
||||
2. Only double-buffered is allowed because it was simpler to implement at
|
||||
that moment. Single-buffered will appear soon, especially if I can find a
|
||||
way to use hardware acceleration.
|
||||
3. Another weird "feature" is that buffer width & height must be multiple of
|
||||
4 (I'm a lazy programmer and I found that the easiest way to keep buffer
|
||||
handling at peak performance ;-).
|
||||
4. The video mode selector is tricky: it searches for the smallest mode which
|
||||
will entirely contain the buffer at its current position. If you want a
|
||||
small buffer in a high-res mode, try to position it very far to the right
|
||||
(or down). I'd really use some ideas here!!!
|
||||
2. Double-buffered uses page flipping if acceleration is available, else falls
|
||||
back to virtual buffer.
|
||||
3. Single-buffered is not allowed with 24-bit modes, because direct access was
|
||||
wrong and fixing it would mean to slow down the other routines; until this
|
||||
is really, really necessary, it won't get reimplemented.
|
||||
4. Another weird "feature" is that buffer width must be multiple of 4 (I'm a
|
||||
lazy programmer and I found that the easiest way to keep buffer handling at
|
||||
peak performance ;-).
|
||||
5. The FreeBE/AF driver is searched in the current directory only; therefore,
|
||||
to disable hardware acceleration, make sure you don't have VBEAF.DRV where
|
||||
your application resides.
|
||||
|
||||
|
||||
|
||||
libGLU:
|
||||
~~~~~~~
|
||||
|
||||
Mesa GLU sources are required. Everything should run smooth.
|
||||
Mesa GLU sources are required. No comment!
|
||||
|
||||
|
||||
|
||||
|
@ -78,8 +82,7 @@ Well, this "skeletal" GLUT implementation is not mine. Thanks should go to
|
|||
Bernhard Tschirren, Mark Kilgard, Brian Paul and probably others (or probably
|
||||
not ;-). I only changed it to be self-standing (Allegro-free). The keyboard,
|
||||
mouse and timer drivers were inspired from an old project of mine (D3Xl) and
|
||||
fixed with some Allegro "infusions"; my deeply thanks to Shawn Hargreaves and
|
||||
co.
|
||||
fixed with some Allegro "infusions"; I deeply thank to Shawn Hargreaves et co.
|
||||
|
||||
My keyboard driver used only scancodes, but since GLUT requires ASCII values
|
||||
for keys, I borrowed the translation tables (and maybe more) from Allegro.
|
||||
|
@ -102,15 +105,7 @@ in bulk! A bit of a hack, I know, but I think it's better than to miss them
|
|||
at all.
|
||||
|
||||
Window creating defaults: 640x480x16 at (0,0), 8-bit stencil, 16-bit accum.
|
||||
|
||||
|
||||
|
||||
Installation:
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Unzip into the MESA directory, and type "make -f Makefile.DJ" to compile all
|
||||
libraries. Long filename support is required during compilation. The examples
|
||||
are not built automagically (see Pitfalls above).
|
||||
However, the video mode is chosen in such a way that first window will fit.
|
||||
|
||||
|
||||
|
||||
|
@ -118,7 +113,16 @@ History:
|
|||
~~~~~~~~
|
||||
|
||||
v0.1 feb-2002 initial release
|
||||
v0.2 ..soon..
|
||||
v0.2 feb-2002 + fast triangle rasterizers
|
||||
+ enabled sw and 1.3 extensions
|
||||
+ hardware acceleration: FreeBE/AF
|
||||
+ single-buffer modes (15-, 16-, and 32-bit)
|
||||
* video mode is set by CreateVisual, not MakeCurrent
|
||||
* internal changes to support multi-buf (unfinished)
|
||||
! fixed some alpha issues... (thanks, Brian)
|
||||
+ glut has now an internal timer
|
||||
* glut changed to support multi-window (unfinished)
|
||||
! minor PC_HW corrections
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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 : dborca@yahoo.com
|
||||
|
@ -45,20 +45,20 @@ typedef struct dmesa_buffer *DMesaBuffer;
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
void DMesaDestroyVisual (DMesaVisual v);
|
||||
|
||||
DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
|
||||
GLint width, GLint height,
|
||||
GLint xpos, GLint ypos);
|
||||
GLint xpos, GLint ypos,
|
||||
GLint width, GLint height);
|
||||
|
||||
void DMesaDestroyBuffer (DMesaBuffer b);
|
||||
|
||||
DMesaContext DMesaCreateContext (DMesaVisual visual,
|
||||
DMesaContext share);
|
||||
DMesaContext DMesaCreateContext (DMesaVisual visual, DMesaContext share);
|
||||
|
||||
void DMesaDestroyContext (DMesaContext c);
|
||||
|
||||
|
|
|
@ -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 : dborca@yahoo.com
|
||||
|
@ -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
|
||||
|
|
|
@ -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 : dborca@yahoo.com
|
||||
|
@ -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 ; \
|
||||
|
|
|
@ -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 : dborca@yahoo.com
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 : dborca@yahoo.com
|
||||
|
@ -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
|
||||
|
|
|
@ -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 : dborca@yahoo.com
|
||||
|
@ -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
|
||||
|
|
|
@ -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 : dborca@yahoo.com
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 : dborca@yahoo.com
|
||||
|
@ -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;
|
||||
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 ((context=DMesaCreateContext(visual, NULL))==NULL) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if ((buffer=DMesaCreateBuffer(visual, g_width, g_height, g_xpos, g_ypos))==NULL) {
|
||||
DMesaDestroyContext(context);
|
||||
DMesaDestroyVisual(visual);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (!DMesaMakeCurrent(context, buffer)) {
|
||||
DMesaDestroyContext(context);
|
||||
DMesaDestroyVisual(visual);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 : dborca@yahoo.com
|
||||
|
@ -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)
|
||||
|
||||
WRITE_RGB_SPAN(15)
|
||||
WRITE_RGB_SPAN(16)
|
||||
WRITE_RGB_SPAN(24)
|
||||
WRITE_RGB_SPAN(32)
|
||||
|
||||
WRITE_MONO_RGBA_SPAN(15)
|
||||
WRITE_MONO_RGBA_SPAN(16)
|
||||
WRITE_MONO_RGBA_SPAN(24)
|
||||
WRITE_MONO_RGBA_SPAN(32)
|
||||
|
||||
READ_RGBA_SPAN(15)
|
||||
READ_RGBA_SPAN(16)
|
||||
READ_RGBA_SPAN(24)
|
||||
READ_RGBA_SPAN(32)
|
||||
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;
|
||||
|
||||
WRITE_RGBA_PIXELS(15)
|
||||
WRITE_RGBA_PIXELS(16)
|
||||
WRITE_RGBA_PIXELS(24)
|
||||
WRITE_RGBA_PIXELS(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_mixrgba(rgba[i]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* draw all pixels */
|
||||
for (i=0; i<n; i++, offset++) {
|
||||
vl_putpixel(b, offset, vl_mixrgba(rgba[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WRITE_MONO_RGBA_PIXELS(15)
|
||||
WRITE_MONO_RGBA_PIXELS(16)
|
||||
WRITE_MONO_RGBA_PIXELS(24)
|
||||
WRITE_MONO_RGBA_PIXELS(32)
|
||||
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;
|
||||
|
||||
READ_RGBA_PIXELS(15)
|
||||
READ_RGBA_PIXELS(16)
|
||||
READ_RGBA_PIXELS(24)
|
||||
READ_RGBA_PIXELS(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;
|
||||
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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 : dborca@yahoo.com
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue