From 295a02549d74559831023455d1bb0ebf42bc1415 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Mon, 22 Feb 2010 22:27:49 +0200 Subject: glapi: fix es after mv --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ea5751d947..3e92e1312e 100644 --- a/Makefile +++ b/Makefile @@ -314,9 +314,9 @@ MAIN_FILES = \ ES_FILES = \ $(DIRECTORY)/include/GLES/*.h \ $(DIRECTORY)/include/GLES2/*.h \ - $(DIRECTORY)/src/mesa/glapi/*.xml \ - $(DIRECTORY)/src/mesa/glapi/*.py \ - $(DIRECTORY)/src/mesa/glapi/*.dtd \ + $(DIRECTORY)/src/mesa/glapi/gen/*.xml \ + $(DIRECTORY)/src/mesa/glapi/gen/*.py \ + $(DIRECTORY)/src/mesa/glapi/gen/*.dtd \ $(DIRECTORY)/src/mesa/es/glapi/Makefile \ $(DIRECTORY)/src/mesa/es/glapi/*.xml \ $(DIRECTORY)/src/mesa/es/glapi/*.py \ -- cgit v1.2.3 From 4387580e50f49d642160982208c807da858cd1ab Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 25 Feb 2010 15:49:18 -0500 Subject: Remove directfb support --- Makefile | 8 +- configs/linux-directfb | 38 - configure.ac | 2 +- docs/README.directfb | 29 - include/GL/directfbgl.h | 89 --- progs/directfb/.gitignore | 4 - progs/directfb/Makefile | 38 - progs/directfb/df_gears.c | 480 ------------ progs/directfb/df_morph3d.c | 1013 -------------------------- progs/directfb/df_reflect.c | 489 ------------- progs/directfb/multi_window.c | 240 ------ src/glut/directfb/Makefile | 87 --- src/glut/directfb/NOTES | 9 - src/glut/directfb/callback.c | 300 -------- src/glut/directfb/color.c | 39 - src/glut/directfb/cursor.c | 175 ----- src/glut/directfb/cursors.h | 306 -------- src/glut/directfb/events.c | 492 ------------- src/glut/directfb/ext.c | 202 ----- src/glut/directfb/font.c | 213 ------ src/glut/directfb/font.h | 58 -- src/glut/directfb/game.c | 153 ---- src/glut/directfb/globals.c | 63 -- src/glut/directfb/init.c | 128 ---- src/glut/directfb/internal.h | 188 ----- src/glut/directfb/menu.c | 87 --- src/glut/directfb/models.c | 599 --------------- src/glut/directfb/overlay.c | 62 -- src/glut/directfb/state.c | 219 ------ src/glut/directfb/teapot.c | 212 ------ src/glut/directfb/window.c | 597 --------------- src/mesa/drivers/directfb/Makefile | 67 -- src/mesa/drivers/directfb/idirectfbgl_mesa.c | 982 ------------------------- 33 files changed, 2 insertions(+), 7666 deletions(-) delete mode 100644 configs/linux-directfb delete mode 100644 docs/README.directfb delete mode 100644 include/GL/directfbgl.h delete mode 100644 progs/directfb/.gitignore delete mode 100644 progs/directfb/Makefile delete mode 100644 progs/directfb/df_gears.c delete mode 100644 progs/directfb/df_morph3d.c delete mode 100644 progs/directfb/df_reflect.c delete mode 100644 progs/directfb/multi_window.c delete mode 100644 src/glut/directfb/Makefile delete mode 100644 src/glut/directfb/NOTES delete mode 100644 src/glut/directfb/callback.c delete mode 100644 src/glut/directfb/color.c delete mode 100644 src/glut/directfb/cursor.c delete mode 100644 src/glut/directfb/cursors.h delete mode 100644 src/glut/directfb/events.c delete mode 100644 src/glut/directfb/ext.c delete mode 100644 src/glut/directfb/font.c delete mode 100644 src/glut/directfb/font.h delete mode 100644 src/glut/directfb/game.c delete mode 100644 src/glut/directfb/globals.c delete mode 100644 src/glut/directfb/init.c delete mode 100644 src/glut/directfb/internal.h delete mode 100644 src/glut/directfb/menu.c delete mode 100644 src/glut/directfb/models.c delete mode 100644 src/glut/directfb/overlay.c delete mode 100644 src/glut/directfb/state.c delete mode 100644 src/glut/directfb/teapot.c delete mode 100644 src/glut/directfb/window.c delete mode 100644 src/mesa/drivers/directfb/Makefile delete mode 100644 src/mesa/drivers/directfb/idirectfbgl_mesa.c (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3e92e1312e..0527fa0d82 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ install: done -.PHONY: default doxygen clean realclean distclean install linux-directfb-install +.PHONY: default doxygen clean realclean distclean install # If there's no current configuration file $(TOP)/configs/current: @@ -109,7 +109,6 @@ linux-alpha-static \ linux-cell \ linux-cell-debug \ linux-debug \ -linux-directfb \ linux-dri \ linux-dri-debug \ linux-dri-x86 \ @@ -271,8 +270,6 @@ MAIN_FILES = \ $(DIRECTORY)/src/mesa/drivers/beos/Makefile \ $(DIRECTORY)/src/mesa/drivers/common/*.[ch] \ $(DIRECTORY)/src/mesa/drivers/common/descrip.mms \ - $(DIRECTORY)/src/mesa/drivers/directfb/*.[ch] \ - $(DIRECTORY)/src/mesa/drivers/directfb/Makefile \ $(DIRECTORY)/src/mesa/drivers/dos/*.[chS] \ $(DIRECTORY)/src/mesa/drivers/fbdev/Makefile \ $(DIRECTORY)/src/mesa/drivers/fbdev/glfbdev.c \ @@ -483,9 +480,6 @@ GLUT_FILES = \ $(DIRECTORY)/src/glut/fbdev/*[ch] \ $(DIRECTORY)/src/glut/mini/*[ch] \ $(DIRECTORY)/src/glut/mini/glut.pc.in \ - $(DIRECTORY)/src/glut/directfb/Makefile \ - $(DIRECTORY)/src/glut/directfb/NOTES \ - $(DIRECTORY)/src/glut/directfb/*[ch] DEPEND_FILES = \ $(TOP)/src/mesa/depend \ diff --git a/configs/linux-directfb b/configs/linux-directfb deleted file mode 100644 index 9ae3de96d1..0000000000 --- a/configs/linux-directfb +++ /dev/null @@ -1,38 +0,0 @@ -# Configuration for DirectFB - -include $(TOP)/configs/default - -CONFIG_NAME = linux-directfb - -# Compiler and flags -CC = gcc -CXX = g++ - -CFLAGS = -Wall -O3 -ffast-math -fPIC -std=c99 -D_GNU_SOURCE -D_POSIX_SOURCE -D_SVID_SOURCE \ - -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DPTHREADS - -CXXFLAGS = -Wall -O3 -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE - -# Work around aliasing bugs - developers should comment this out -CFLAGS += -fno-strict-aliasing -CXXFLAGS += -fno-strict-aliasing - -HAVE_X86 = $(shell uname -m | grep 'i[3-6]86' >/dev/null && echo yes) -ifeq ($(HAVE_X86), yes) - CFLAGS += -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM - CXXFLAGS += -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM - MESA_ASM_SOURCES = $(X86_SOURCES) - GLAPI_ASM_SOURCES = $(X86_API) -endif - -# Directories -SRC_DIRS = gallium mesa glu glut/directfb glew -GLU_DIRS = sgi -DRIVER_DIRS = directfb -PROGRAM_DIRS = demos directfb - -# Library/program dependencies -GL_LIB_DEPS = -lm -lpthread -GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -l$(GLU_LIB) -APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -l$(GLU_LIB) -l$(GLUT_LIB) - diff --git a/configure.ac b/configure.ac index 485836a428..b4561000d2 100644 --- a/configure.ac +++ b/configure.ac @@ -395,7 +395,7 @@ fi dnl dnl Driver configuration. Options are xlib, dri and osmesa right now. -dnl More later: directfb, fbdev, ... +dnl More later: fbdev, ... dnl default_driver="xlib" diff --git a/docs/README.directfb b/docs/README.directfb deleted file mode 100644 index d66ca8d3ca..0000000000 --- a/docs/README.directfb +++ /dev/null @@ -1,29 +0,0 @@ - - Mesa DirectFB Information - - -Requirements -============ - - To build Mesa with DirectFB (DirectFBGL) support you need: - - DirectFB at least 1.0.0 (http://directfb.org) - - pkg-config at least 0.9 (http://pkgconfig.sf.net) - - -Installation -============ - Run - - make linux-directfb - - to build Mesa and DirectFBGL module, - - make install - - to install OpenGL libraries and - - cd src/mesa/drivers/directfb ; make install - - to install DirectFBGL module in the proper location. - Actually, that last command may not be needed. Please provide feedback. - diff --git a/include/GL/directfbgl.h b/include/GL/directfbgl.h deleted file mode 100644 index 984c4b1427..0000000000 --- a/include/GL/directfbgl.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __DIRECTFBGL_H__ -#define __DIRECTFBGL_H__ - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - - -typedef struct { - int buffer_size; - int depth_size; - int stencil_size; - int aux_buffers; - - int red_size; - int green_size; - int blue_size; - int alpha_size; - - int accum_red_size; - int accum_green_size; - int accum_blue_size; - int accum_alpha_size; - - DFBBoolean double_buffer; - DFBBoolean stereo; -} DFBGLAttributes; - - -DEFINE_INTERFACE( IDirectFBGL, - - /** Context handling **/ - - /* - * Acquire the hardware lock. - */ - DFBResult (*Lock) ( - IDirectFBGL *thiz - ); - - /* - * Release the lock. - */ - DFBResult (*Unlock) ( - IDirectFBGL *thiz - ); - - /* - * Query the OpenGL attributes. - */ - DFBResult (*GetAttributes) ( - IDirectFBGL *thiz, - DFBGLAttributes *attributes - ); -) - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/progs/directfb/.gitignore b/progs/directfb/.gitignore deleted file mode 100644 index 55d65fb5b0..0000000000 --- a/progs/directfb/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -df_gears -df_morph3d -df_reflect -multi_window diff --git a/progs/directfb/Makefile b/progs/directfb/Makefile deleted file mode 100644 index 93c2a7df14..0000000000 --- a/progs/directfb/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# progs/directfb/Makefile - -TOP = ../.. -include $(TOP)/configs/current - - -INCDIR = $(TOP)/include -I$(TOP)/progs - -LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) - -CFLAGS += $(shell pkg-config --cflags directfb) -APP_LIB_DEPS += $(shell pkg-config --libs directfb) - -LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) - -PROGS = df_gears \ - df_reflect \ - df_morph3d \ - multi_window - -##### RULES ##### - -.SUFFIXES: -.SUFFIXES: .c - -.c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ - - -##### TARGETS ##### - -default: $(PROGS) - - -clean: - -rm -f $(PROGS) - -rm -f *.o *~ - diff --git a/progs/directfb/df_gears.c b/progs/directfb/df_gears.c deleted file mode 100644 index c480767bd3..0000000000 --- a/progs/directfb/df_gears.c +++ /dev/null @@ -1,480 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include - -#include -#include - -#include - - -/* the super interface */ -IDirectFB *dfb; - -/* the primary surface (surface of primary layer) */ -IDirectFBSurface *primary; - -/* the GL context */ -IDirectFBGL *primary_gl; - -/* our font */ -IDirectFBFont *font; - -/* event buffer */ -IDirectFBEventBuffer *events; - -/* macro for a safe call to DirectFB functions */ -#define DFBCHECK(x...) \ - { \ - err = x; \ - if (err != DFB_OK) { \ - fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ - DirectFBErrorFatal( #x, err ); \ - } \ - } - -static int screen_width, screen_height; - -static unsigned long T0 = 0; -static GLint Frames = 0; -static GLfloat fps = 0; - -static inline unsigned long get_millis() -{ - struct timeval tv; - - gettimeofday (&tv, NULL); - return (tv.tv_sec * 1000 + tv.tv_usec / 1000); -} - - -#ifndef M_PI -#define M_PI 3.14159265 -#endif - -/** - - Draw a gear wheel. You'll probably want to call this function when - building a display list since we do a lot of trig here. - - Input: inner_radius - radius of hole at center - outer_radius - radius at center of teeth - width - width of gear - teeth - number of teeth - tooth_depth - depth of tooth - - **/ - -static void -gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, - GLint teeth, GLfloat tooth_depth) -{ - GLint i; - GLfloat r0, r1, r2; - GLfloat angle, da; - GLfloat u, v, len; - - r0 = inner_radius; - r1 = outer_radius - tooth_depth / 2.0; - r2 = outer_radius + tooth_depth / 2.0; - - da = 2.0 * M_PI / teeth / 4.0; - - glShadeModel(GL_FLAT); - - glNormal3f(0.0, 0.0, 1.0); - - /* draw front face */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); - glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); - if (i < teeth) { - glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); - } - } - glEnd(); - - /* draw front sides of teeth */ - glBegin(GL_QUADS); - da = 2.0 * M_PI / teeth / 4.0; - for (i = 0; i < teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - - glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); - } - glEnd(); - - glNormal3f(0.0, 0.0, -1.0); - - /* draw back face */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); - glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); - if (i < teeth) { - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); - glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); - } - } - glEnd(); - - /* draw back sides of teeth */ - glBegin(GL_QUADS); - da = 2.0 * M_PI / teeth / 4.0; - for (i = 0; i < teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); - glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); - } - glEnd(); - - /* draw outward faces of teeth */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i < teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - - glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); - glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); - u = r2 * cos(angle + da) - r1 * cos(angle); - v = r2 * sin(angle + da) - r1 * sin(angle); - len = sqrt(u * u + v * v); - u /= len; - v /= len; - glNormal3f(v, -u, 0.0); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); - glNormal3f(cos(angle), sin(angle), 0.0); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); - u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); - v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); - glNormal3f(v, -u, 0.0); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); - glNormal3f(cos(angle), sin(angle), 0.0); - } - - glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); - glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); - - glEnd(); - - glShadeModel(GL_SMOOTH); - - /* draw inside radius cylinder */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - glNormal3f(-cos(angle), -sin(angle), 0.0); - glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); - glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); - } - glEnd(); - -} - -static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; -static GLfloat inc_rotx = 0, inc_roty = 0, inc_rotz = 0; -static GLint gear1, gear2, gear3; -static GLfloat angle = 0.0; - -static void -draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); - glRotatef(view_rotx, 1.0, 0.0, 0.0); - glRotatef(view_roty, 0.0, 1.0, 0.0); - glRotatef(view_rotz, 0.0, 0.0, 1.0); - - glPushMatrix(); - glTranslatef(-3.0, -2.0, 0.0); - glRotatef(angle, 0.0, 0.0, 1.0); - glCallList(gear1); - glPopMatrix(); - - glPushMatrix(); - glTranslatef(3.1, -2.0, 0.0); - glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0); - glCallList(gear2); - glPopMatrix(); - - glPushMatrix(); - glTranslatef(-3.1, 4.2, 0.0); - glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); - glCallList(gear3); - glPopMatrix(); - - glPopMatrix(); -} - -/* new window size or exposure */ -static void -reshape(int width, int height) -{ - GLfloat h = (GLfloat) height / (GLfloat) width; - - glViewport(0, 0, (GLint) width, (GLint) height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -40.0); -} - -static void -init(int argc, char *argv[]) -{ - static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0}; - static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0}; - static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0}; - static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0}; - GLint i; - - glLightfv(GL_LIGHT0, GL_POSITION, pos); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - - /* make the gears */ - gear1 = glGenLists(1); - glNewList(gear1, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); - gear(1.0, 4.0, 1.0, 20, 0.7); - glEndList(); - - gear2 = glGenLists(1); - glNewList(gear2, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); - gear(0.5, 2.0, 2.0, 10, 0.7); - glEndList(); - - gear3 = glGenLists(1); - glNewList(gear3, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); - gear(1.3, 2.0, 0.5, 10, 0.7); - glEndList(); - - glEnable(GL_NORMALIZE); - - for ( i=1; iCreateInputEventBuffer( dfb, DICAPS_KEYS | DICAPS_AXES, - DFB_FALSE, &events )); - - /* set our cooperative level to DFSCL_FULLSCREEN - for exclusive access to the primary layer */ - dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN ); - - /* get the primary surface, i.e. the surface of the - primary layer we have exclusive access to */ - dsc.flags = DSDESC_CAPS; - dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE; - - DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary )); - - /* get the size of the surface and fill it */ - DFBCHECK(primary->GetSize( primary, &screen_width, &screen_height )); - DFBCHECK(primary->FillRectangle( primary, 0, 0, - screen_width, screen_height )); - primary->Flip( primary, NULL, 0 ); - - /* create the default font and set it */ - DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font )); - DFBCHECK(primary->SetFont( primary, font )); - - /* get the GL context */ - DFBCHECK(primary->GetGL( primary, &primary_gl )); - - DFBCHECK(primary_gl->Lock( primary_gl )); - - init(argc, argv); - reshape(screen_width, screen_height); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - T0 = get_millis(); - - while (!quit) { - DFBInputEvent evt; - unsigned long t; - - DFBCHECK(primary_gl->Lock( primary_gl )); - - draw(); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - if (fps) { - char buf[64]; - - snprintf(buf, 64, "%4.1f FPS\n", fps); - - primary->SetColor( primary, 0xff, 0, 0, 0xff ); - primary->DrawString( primary, buf, -1, screen_width - 5, 5, DSTF_TOPRIGHT ); - } - - primary->Flip( primary, NULL, 0 ); - Frames++; - - - t = get_millis(); - if (t - T0 >= 2000) { - GLfloat seconds = (t - T0) / 1000.0; - - fps = Frames / seconds; - - T0 = t; - Frames = 0; - } - - - while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) { - switch (evt.type) { - case DIET_KEYPRESS: - switch (evt.key_symbol) { - case DIKS_ESCAPE: - quit = 1; - break; - case DIKS_CURSOR_UP: - inc_rotx = 5.0; - break; - case DIKS_CURSOR_DOWN: - inc_rotx = -5.0; - break; - case DIKS_CURSOR_LEFT: - inc_roty = 5.0; - break; - case DIKS_CURSOR_RIGHT: - inc_roty = -5.0; - break; - case DIKS_PAGE_UP: - inc_rotz = 5.0; - break; - case DIKS_PAGE_DOWN: - inc_rotz = -5.0; - break; - default: - ; - } - break; - case DIET_KEYRELEASE: - switch (evt.key_symbol) { - case DIKS_CURSOR_UP: - inc_rotx = 0; - break; - case DIKS_CURSOR_DOWN: - inc_rotx = 0; - break; - case DIKS_CURSOR_LEFT: - inc_roty = 0; - break; - case DIKS_CURSOR_RIGHT: - inc_roty = 0; - break; - case DIKS_PAGE_UP: - inc_rotz = 0; - break; - case DIKS_PAGE_DOWN: - inc_rotz = 0; - break; - default: - ; - } - break; - case DIET_AXISMOTION: - if (evt.flags & DIEF_AXISREL) { - switch (evt.axis) { - case DIAI_X: - view_roty += evt.axisrel / 2.0; - break; - case DIAI_Y: - view_rotx += evt.axisrel / 2.0; - break; - case DIAI_Z: - view_rotz += evt.axisrel / 2.0; - break; - default: - ; - } - } - break; - default: - ; - } - } - - angle += 2.0; - - view_rotx += inc_rotx; - view_roty += inc_roty; - view_rotz += inc_rotz; - } - - /* release our interfaces to shutdown DirectFB */ - primary_gl->Release( primary_gl ); - primary->Release( primary ); - font->Release( font ); - events->Release( events ); - dfb->Release( dfb ); - - return 0; -} - diff --git a/progs/directfb/df_morph3d.c b/progs/directfb/df_morph3d.c deleted file mode 100644 index 2730fa6156..0000000000 --- a/progs/directfb/df_morph3d.c +++ /dev/null @@ -1,1013 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -/*- - * morph3d.c - Shows 3D morphing objects - * - * Converted to GLUT by brianp on 1/1/98 - * - * This program was inspired on a WindowsNT(R)'s screen saver. It was written - * from scratch and it was not based on any other source code. - * - * Porting it to xlock (the final objective of this code since the moment I - * decided to create it) was possible by comparing the original Mesa's gear - * demo with it's ported version, so thanks for Danny Sung for his indirect - * help (look at gear.c in xlock source tree). NOTE: At the moment this code - * was sent to Brian Paul for package inclusion, the XLock Version was not - * available. In fact, I'll wait it to appear on the next Mesa release (If you - * are reading this, it means THIS release) to send it for xlock package - * inclusion). It will probably there be a GLUT version too. - * - * Thanks goes also to Brian Paul for making it possible and inexpensive - * to use OpenGL at home. - * - * Since I'm not a native english speaker, my apologies for any gramatical - * mistake. - * - * My e-mail addresses are - * - * vianna@cat.cbpf.br - * and - * marcelo@venus.rdc.puc-rio.br - * - * Marcelo F. Vianna (Feb-13-1997) - */ - -/* -This document is VERY incomplete, but tries to describe the mathematics used -in the program. At this moment it just describes how the polyhedra are -generated. On futhurer versions, this document will be probabbly improved. - -Since I'm not a native english speaker, my apologies for any gramatical -mistake. - -Marcelo Fernandes Vianna -- Undergraduate in Computer Engeneering at Catholic Pontifical University -- of Rio de Janeiro (PUC-Rio) Brasil. -- e-mail: vianna@cat.cbpf.br or marcelo@venus.rdc.puc-rio.br -- Feb-13-1997 - -POLYHEDRA GENERATION - -For the purpose of this program it's not sufficient to know the polyhedra -vertexes coordinates. Since the morphing algorithm applies a nonlinear -transformation over the surfaces (faces) of the polyhedron, each face has -to be divided into smaller ones. The morphing algorithm needs to transform -each vertex of these smaller faces individually. It's a very time consoming -task. - -In order to reduce calculation overload, and since all the macro faces of -the polyhedron are transformed by the same way, the generation is made by -creating only one face of the polyhedron, morphing it and then rotating it -around the polyhedron center. - -What we need to know is the face radius of the polyhedron (the radius of -the inscribed sphere) and the angle between the center of two adjacent -faces using the center of the sphere as the angle's vertex. - -The face radius of the regular polyhedra are known values which I decided -to not waste my time calculating. Following is a table of face radius for -the regular polyhedra with edge length = 1: - - TETRAHEDRON : 1/(2*sqrt(2))/sqrt(3) - CUBE : 1/2 - OCTAHEDRON : 1/sqrt(6) - DODECAHEDRON : T^2 * sqrt((T+2)/5) / 2 -> where T=(sqrt(5)+1)/2 - ICOSAHEDRON : (3*sqrt(3)+sqrt(15))/12 - -I've not found any reference about the mentioned angles, so I needed to -calculate them, not a trivial task until I figured out how :) -Curiously these angles are the same for the tetrahedron and octahedron. -A way to obtain this value is inscribing the tetrahedron inside the cube -by matching their vertexes. So you'll notice that the remaining unmatched -vertexes are in the same straight line starting in the cube/tetrahedron -center and crossing the center of each tetrahedron's face. At this point -it's easy to obtain the bigger angle of the isosceles triangle formed by -the center of the cube and two opposite vertexes on the same cube face. -The edges of this triangle have the following lenghts: sqrt(2) for the base -and sqrt(3)/2 for the other two other edges. So the angle we want is: - +-----------------------------------------------------------+ - | 2*ARCSIN(sqrt(2)/sqrt(3)) = 109.47122063449069174 degrees | - +-----------------------------------------------------------+ -For the cube this angle is obvious, but just for formality it can be -easily obtained because we also know it's isosceles edge lenghts: -sqrt(2)/2 for the base and 1/2 for the other two edges. So the angle we -want is: - +-----------------------------------------------------------+ - | 2*ARCSIN((sqrt(2)/2)/1) = 90.000000000000000000 degrees | - +-----------------------------------------------------------+ -For the octahedron we use the same idea used for the tetrahedron, but now -we inscribe the cube inside the octahedron so that all cubes's vertexes -matches excatly the center of each octahedron's face. It's now clear that -this angle is the same of the thetrahedron one: - +-----------------------------------------------------------+ - | 2*ARCSIN(sqrt(2)/sqrt(3)) = 109.47122063449069174 degrees | - +-----------------------------------------------------------+ -For the dodecahedron it's a little bit harder because it's only relationship -with the cube is useless to us. So we need to solve the problem by another -way. The concept of Face radius also exists on 2D polygons with the name -Edge radius: - Edge Radius For Pentagon (ERp) - ERp = (1/2)/TAN(36 degrees) * VRp = 0.6881909602355867905 - (VRp is the pentagon's vertex radio). - Face Radius For Dodecahedron - FRd = T^2 * sqrt((T+2)/5) / 2 = 1.1135163644116068404 -Why we need ERp? Well, ERp and FRd segments forms a 90 degrees angle, -completing this triangle, the lesser angle is a half of the angle we are -looking for, so this angle is: - +-----------------------------------------------------------+ - | 2*ARCTAN(ERp/FRd) = 63.434948822922009981 degrees | - +-----------------------------------------------------------+ -For the icosahedron we can use the same method used for dodecahedron (well -the method used for dodecahedron may be used for all regular polyhedra) - Edge Radius For Triangle (this one is well known: 1/3 of the triangle height) - ERt = sin(60)/3 = sqrt(3)/6 = 0.2886751345948128655 - Face Radius For Icosahedron - FRi= (3*sqrt(3)+sqrt(15))/12 = 0.7557613140761707538 -So the angle is: - +-----------------------------------------------------------+ - | 2*ARCTAN(ERt/FRi) = 41.810314895778596167 degrees | - +-----------------------------------------------------------+ - -*/ - - -#include -#include -#include -#include -#include - -#include -#include - -#include - - -/* the super interface */ -IDirectFB *dfb; - -/* the primary surface (surface of primary layer) */ -IDirectFBSurface *primary; - -/* the GL context */ -IDirectFBGL *primary_gl; - -/* our font */ -IDirectFBFont *font; - -/* event buffer */ -IDirectFBEventBuffer *events; - -/* macro for a safe call to DirectFB functions */ -#define DFBCHECK(x...) \ - { \ - err = x; \ - if (err != DFB_OK) { \ - fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ - DirectFBErrorFatal( #x, err ); \ - } \ - } - -static int screen_width, screen_height; - -static unsigned long T0 = 0; -static GLint Frames = 0; -static GLfloat fps = 0; - -static inline unsigned long get_millis() -{ - struct timeval tv; - - gettimeofday (&tv, NULL); - return (tv.tv_sec * 1000 + tv.tv_usec / 1000); -} - - - -#define Scale 0.3 - -#define VectMul(X1,Y1,Z1,X2,Y2,Z2) (Y1)*(Z2)-(Z1)*(Y2),(Z1)*(X2)-(X1)*(Z2),(X1)*(Y2)-(Y1)*(X2) -#define sqr(A) ((A)*(A)) - -/* Increasing this values produces better image quality, the price is speed. */ -/* Very low values produces erroneous/incorrect plotting */ -#define tetradivisions 23 -#define cubedivisions 20 -#define octadivisions 21 -#define dodecadivisions 10 -#define icodivisions 15 - -#define tetraangle 109.47122063449069174 -#define cubeangle 90.000000000000000000 -#define octaangle 109.47122063449069174 -#define dodecaangle 63.434948822922009981 -#define icoangle 41.810314895778596167 - -#ifndef Pi -#define Pi 3.1415926535897932385 -#endif -#define SQRT2 1.4142135623730951455 -#define SQRT3 1.7320508075688771932 -#define SQRT5 2.2360679774997898051 -#define SQRT6 2.4494897427831778813 -#define SQRT15 3.8729833462074170214 -#define cossec36_2 0.8506508083520399322 -#define cos72 0.3090169943749474241 -#define sin72 0.9510565162951535721 -#define cos36 0.8090169943749474241 -#define sin36 0.5877852522924731292 - -/*************************************************************************/ - -static int mono=0; -static int smooth=1; -static GLint WindH, WindW; -static GLfloat step=0; -static GLfloat seno; -static int object; -static int edgedivisions; -static void (*draw_object)( void ); -static float Magnitude; -static float *MaterialColor[20]; - -static float front_shininess[] = {60.0}; -static float front_specular[] = { 0.7, 0.7, 0.7, 1.0 }; -static float ambient[] = { 0.0, 0.0, 0.0, 1.0 }; -static float diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; -static float position0[] = { 1.0, 1.0, 1.0, 0.0 }; -static float position1[] = {-1.0,-1.0, 1.0, 0.0 }; -static float lmodel_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; -static float lmodel_twoside[] = {GL_TRUE}; - -static float MaterialRed[] = { 0.7, 0.0, 0.0, 1.0 }; -static float MaterialGreen[] = { 0.1, 0.5, 0.2, 1.0 }; -static float MaterialBlue[] = { 0.0, 0.0, 0.7, 1.0 }; -static float MaterialCyan[] = { 0.2, 0.5, 0.7, 1.0 }; -static float MaterialYellow[] = { 0.7, 0.7, 0.0, 1.0 }; -static float MaterialMagenta[] = { 0.6, 0.2, 0.5, 1.0 }; -static float MaterialWhite[] = { 0.7, 0.7, 0.7, 1.0 }; -static float MaterialGray[] = { 0.2, 0.2, 0.2, 1.0 }; - -#define TRIANGLE(Edge, Amp, Divisions, Z) \ -{ \ - GLfloat Xf,Yf,Xa,Yb,Xf2,Yf2; \ - GLfloat Factor,Factor1,Factor2; \ - GLfloat VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ; \ - GLfloat Ax,Ay,Bx; \ - int Ri,Ti; \ - GLfloat Vr=(Edge)*SQRT3/3; \ - GLfloat AmpVr2=(Amp)/sqr(Vr); \ - GLfloat Zf=(Edge)*(Z); \ - \ - Ax=(Edge)*(+0.5/(Divisions)), Ay=(Edge)*(-SQRT3/(2*Divisions)); \ - Bx=(Edge)*(-0.5/(Divisions)); \ - \ - for (Ri=1; Ri<=(Divisions); Ri++) { \ - glBegin(GL_TRIANGLE_STRIP); \ - for (Ti=0; TiFlip( primary, NULL, 0 ); - - glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); - glLightfv(GL_LIGHT0, GL_POSITION, position0); - glLightfv(GL_LIGHT1, GL_AMBIENT, ambient); - glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse); - glLightfv(GL_LIGHT1, GL_POSITION, position1); - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); - glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_LIGHT1); - glEnable(GL_DEPTH_TEST); - glEnable(GL_NORMALIZE); - - glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular); - - glHint(GL_FOG_HINT, GL_FASTEST); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); - glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); - - pinit(); -} - -int main( int argc, char *argv[] ) -{ - int quit = 0; - DFBResult err; - DFBSurfaceDescription dsc; - - DFBCHECK(DirectFBInit( &argc, &argv )); - - /* create the super interface */ - DFBCHECK(DirectFBCreate( &dfb )); - - /* create an event buffer for all devices with these caps */ - DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS, DFB_FALSE, &events )); - - /* set our cooperative level to DFSCL_FULLSCREEN - for exclusive access to the primary layer */ - dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN ); - - /* get the primary surface, i.e. the surface of the - primary layer we have exclusive access to */ - dsc.flags = DSDESC_CAPS; - dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE; - - DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary )); - - /* get the size of the surface and fill it */ - DFBCHECK(primary->GetSize( primary, &screen_width, &screen_height )); - DFBCHECK(primary->FillRectangle( primary, 0, 0, - screen_width, screen_height )); - - /* create the default font and set it */ - DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font )); - DFBCHECK(primary->SetFont( primary, font )); - - /* get the GL context */ - DFBCHECK(primary->GetGL( primary, &primary_gl )); - - DFBCHECK(primary_gl->Lock( primary_gl )); - - init(); - reshape(screen_width, screen_height); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - T0 = get_millis(); - - while (!quit) { - DFBInputEvent evt; - unsigned long t; - - primary->Clear( primary, 0, 0, 0, 0 ); - - DFBCHECK(primary_gl->Lock( primary_gl )); - - draw(); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - if (fps) { - char buf[64]; - - sprintf(buf, "%4.1f FPS\n", fps); - primary->SetColor( primary, 0xff, 0, 0, 0xff ); - primary->DrawString( primary, buf, -1, screen_width - 5, 5, DSTF_TOPRIGHT ); - } - - primary->Flip( primary, NULL, 0 ); - Frames++; - - - t = get_millis(); - if (t - T0 >= 1000) { - GLfloat seconds = (t - T0) / 1000.0; - - fps = Frames / seconds; - - T0 = t; - Frames = 0; - } - - - while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) { - switch (evt.type) { - case DIET_KEYPRESS: - switch (evt.key_symbol) { - case DIKS_ESCAPE: - quit = 1; - break; - case DIKS_1: object=1; break; - case DIKS_2: object=2; break; - case DIKS_3: object=3; break; - case DIKS_4: object=4; break; - case DIKS_5: object=5; break; - case DIKS_SPACE: mono^=1; break; - case DIKS_ENTER: smooth^=1; break; - default: - ; - } - pinit(); - break; - default: - ; - } - } - } - - /* release our interfaces to shutdown DirectFB */ - primary_gl->Release( primary_gl ); - primary->Release( primary ); - font->Release( font ); - events->Release( events ); - dfb->Release( dfb ); - - return 0; -} - diff --git a/progs/directfb/df_reflect.c b/progs/directfb/df_reflect.c deleted file mode 100644 index a0e789c387..0000000000 --- a/progs/directfb/df_reflect.c +++ /dev/null @@ -1,489 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include - -#include -#include - -#include - -#include "util/showbuffer.c" -#include "util/readtex.c" - - -/* the super interface */ -IDirectFB *dfb; - -/* the primary surface (surface of primary layer) */ -IDirectFBSurface *primary; - -/* the GL context */ -IDirectFBGL *primary_gl; - -/* our font */ -IDirectFBFont *font; - -/* event buffer */ -IDirectFBEventBuffer *events; - -/* macro for a safe call to DirectFB functions */ -#define DFBCHECK(x...) \ - { \ - err = x; \ - if (err != DFB_OK) { \ - fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ - DirectFBErrorFatal( #x, err ); \ - } \ - } - -static int screen_width, screen_height; - -static unsigned long T0 = 0; -static GLint Frames = 0; -static GLfloat fps = 0; - -static inline unsigned long get_millis() -{ - struct timeval tv; - - gettimeofday (&tv, NULL); - return (tv.tv_sec * 1000 + tv.tv_usec / 1000); -} - -/*******************************/ - -#define DEG2RAD (3.14159/180.0) - -#define TABLE_TEXTURE "../images/tile.rgb" - -static GLint ImgWidth, ImgHeight; -static GLenum ImgFormat; -static GLubyte *Image = NULL; - -#define MAX_OBJECTS 2 -static GLint table_list; -static GLint objects_list[MAX_OBJECTS]; - -static GLfloat xrot, yrot; -static GLfloat spin; - -static GLint Width = 400, Height = 300; -static GLenum ShowBuffer = GL_NONE; - - -static void make_table( void ) -{ - static GLfloat table_mat[] = { 1.0, 1.0, 1.0, 0.6 }; - static GLfloat gray[] = { 0.4, 0.4, 0.4, 1.0 }; - - table_list = glGenLists(1); - glNewList( table_list, GL_COMPILE ); - - /* load table's texture */ - glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, table_mat ); -/* glMaterialfv( GL_FRONT, GL_EMISSION, gray );*/ - glMaterialfv( GL_FRONT, GL_DIFFUSE, table_mat ); - glMaterialfv( GL_FRONT, GL_AMBIENT, gray ); - - /* draw textured square for the table */ - glPushMatrix(); - glScalef( 4.0, 4.0, 4.0 ); - glBegin( GL_POLYGON ); - glNormal3f( 0.0, 1.0, 0.0 ); - glTexCoord2f( 0.0, 0.0 ); glVertex3f( -1.0, 0.0, 1.0 ); - glTexCoord2f( 1.0, 0.0 ); glVertex3f( 1.0, 0.0, 1.0 ); - glTexCoord2f( 1.0, 1.0 ); glVertex3f( 1.0, 0.0, -1.0 ); - glTexCoord2f( 0.0, 1.0 ); glVertex3f( -1.0, 0.0, -1.0 ); - glEnd(); - glPopMatrix(); - - glDisable( GL_TEXTURE_2D ); - - glEndList(); -} - - -static void make_objects( void ) -{ - GLUquadricObj *q; - - static GLfloat cyan[] = { 0.0, 1.0, 1.0, 1.0 }; - static GLfloat green[] = { 0.2, 1.0, 0.2, 1.0 }; - static GLfloat black[] = { 0.0, 0.0, 0.0, 0.0 }; - - q = gluNewQuadric(); - gluQuadricDrawStyle( q, GLU_FILL ); - gluQuadricNormals( q, GLU_SMOOTH ); - - objects_list[0] = glGenLists(1); - glNewList( objects_list[0], GL_COMPILE ); - glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, cyan ); - glMaterialfv( GL_FRONT, GL_EMISSION, black ); - gluCylinder( q, 0.5, 0.5, 1.0, 15, 1 ); - glEndList(); - - objects_list[1] = glGenLists(1); - glNewList( objects_list[1], GL_COMPILE ); - glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green ); - glMaterialfv( GL_FRONT, GL_EMISSION, black ); - gluCylinder( q, 1.5, 0.0, 2.5, 15, 1 ); - glEndList(); -} - - -static void init( void ) -{ - make_table(); - make_objects(); - - Image = LoadRGBImage( TABLE_TEXTURE, &ImgWidth, &ImgHeight, &ImgFormat ); - if (!Image) { - printf("Couldn't read %s\n", TABLE_TEXTURE); - exit(0); - } - - gluBuild2DMipmaps(GL_TEXTURE_2D, 3, ImgWidth, ImgHeight, - ImgFormat, GL_UNSIGNED_BYTE, Image); - - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - - xrot = 30.0; - yrot = 50.0; - spin = 0.0; - - glShadeModel( GL_FLAT ); - - glEnable( GL_LIGHT0 ); - glEnable( GL_LIGHTING ); - - glClearColor( 0.5, 0.5, 0.9, 0.0 ); - - glEnable( GL_NORMALIZE ); -} - - - -static void reshape(int w, int h) -{ - GLfloat yAspect = 2.5; - GLfloat xAspect = yAspect * (float) w / (float) h; - Width = w; - Height = h; - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum( -xAspect, xAspect, -yAspect, yAspect, 10.0, 30.0 ); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - - - -static void draw_objects( GLfloat eyex, GLfloat eyey, GLfloat eyez ) -{ - (void) eyex; - (void) eyey; - (void) eyez; -#ifndef USE_ZBUFFER - if (eyex<0.5) { -#endif - glPushMatrix(); - glTranslatef( 1.0, 1.5, 0.0 ); - glRotatef( spin, 1.0, 0.5, 0.0 ); - glRotatef( 0.5*spin, 0.0, 0.5, 1.0 ); - glCallList( objects_list[0] ); - glPopMatrix(); - - glPushMatrix(); - glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*spin) ), 0.0 ); - glRotatef( 0.5*spin, 0.0, 0.5, 1.0 ); - glRotatef( spin, 1.0, 0.5, 0.0 ); - glScalef( 0.5, 0.5, 0.5 ); - glCallList( objects_list[1] ); - glPopMatrix(); -#ifndef USE_ZBUFFER - } - else { - glPushMatrix(); - glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*spin) ), 0.0 ); - glRotatef( 0.5*spin, 0.0, 0.5, 1.0 ); - glRotatef( spin, 1.0, 0.5, 0.0 ); - glScalef( 0.5, 0.5, 0.5 ); - glCallList( objects_list[1] ); - glPopMatrix(); - - glPushMatrix(); - glTranslatef( 1.0, 1.5, 0.0 ); - glRotatef( spin, 1.0, 0.5, 0.0 ); - glRotatef( 0.5*spin, 0.0, 0.5, 1.0 ); - glCallList( objects_list[0] ); - glPopMatrix(); - } -#endif -} - - - -static void draw_table( void ) -{ - glCallList( table_list ); -} - - - -static void draw( void ) -{ - static GLfloat light_pos[] = { 0.0, 20.0, 0.0, 1.0 }; - GLfloat dist = 20.0; - GLfloat eyex, eyey, eyez; - - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - - - eyex = dist * cos(yrot*DEG2RAD) * cos(xrot*DEG2RAD); - eyez = dist * sin(yrot*DEG2RAD) * cos(xrot*DEG2RAD); - eyey = dist * sin(xrot*DEG2RAD); - - /* view from top */ - glPushMatrix(); - gluLookAt( eyex, eyey, eyez, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ); - - glLightfv( GL_LIGHT0, GL_POSITION, light_pos ); - - /* draw table into stencil planes */ - glDisable( GL_DEPTH_TEST ); - glEnable( GL_STENCIL_TEST ); - glStencilFunc( GL_ALWAYS, 1, 0xffffffff ); - glStencilOp( GL_REPLACE, GL_REPLACE, GL_REPLACE ); - glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); - draw_table(); - glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); - - glEnable( GL_DEPTH_TEST ); - - /* render view from below (reflected viewport) */ - /* only draw where stencil==1 */ - if (eyey>0.0) { - glPushMatrix(); - - glStencilFunc( GL_EQUAL, 1, 0xffffffff ); /* draw if ==1 */ - glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); - glScalef( 1.0, -1.0, 1.0 ); - - /* Reposition light in reflected space. */ - glLightfv(GL_LIGHT0, GL_POSITION, light_pos); - - draw_objects(eyex, eyey, eyez); - glPopMatrix(); - - /* Restore light's original unreflected position. */ - glLightfv(GL_LIGHT0, GL_POSITION, light_pos); - } - - glDisable( GL_STENCIL_TEST ); - - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - - glEnable( GL_TEXTURE_2D ); - draw_table(); - glDisable( GL_TEXTURE_2D ); - glDisable( GL_BLEND ); - - /* view from top */ - glPushMatrix(); - - draw_objects(eyex, eyey, eyez); - - glPopMatrix(); - - glPopMatrix(); - - if (ShowBuffer == GL_DEPTH) { - ShowDepthBuffer(Width, Height, 1.0, 0.0); - } - else if (ShowBuffer == GL_STENCIL) { - ShowStencilBuffer(Width, Height, 255.0, 0.0); - } - else if (ShowBuffer == GL_ALPHA) { - ShowAlphaBuffer(Width, Height); - } -} - -/*******************************/ - -int main( int argc, char *argv[] ) -{ - int quit = 0; - DFBResult err; - DFBSurfaceDescription dsc; - - DFBCHECK(DirectFBInit( &argc, &argv )); - - /* create the super interface */ - DFBCHECK(DirectFBCreate( &dfb )); - - /* create an event buffer for all devices with these caps */ - DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_ALL, DFB_FALSE, &events )); - - /* set our cooperative level to DFSCL_FULLSCREEN - for exclusive access to the primary layer */ - dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN ); - - /* get the primary surface, i.e. the surface of the - primary layer we have exclusive access to */ - dsc.flags = DSDESC_CAPS; - dsc.caps = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY | DSCAPS_DOUBLE); - - DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary )); - - /* get the size of the surface and fill it */ - DFBCHECK(primary->GetSize( primary, &screen_width, &screen_height )); - DFBCHECK(primary->FillRectangle( primary, 0, 0, - screen_width, screen_height )); - - /* create the default font and set it */ - DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font )); - DFBCHECK(primary->SetFont( primary, font )); - - /* get the GL context */ - DFBCHECK(primary->GetGL( primary, &primary_gl )); - - DFBCHECK(primary_gl->Lock( primary_gl )); - - init(); - reshape(screen_width, screen_height); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - T0 = get_millis(); - - while (!quit) { - DFBInputEvent evt; - unsigned long t; - - DFBCHECK(primary_gl->Lock( primary_gl )); - - draw(); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - if (fps) { - char buf[64]; - - sprintf(buf, "%4.1f FPS\n", fps); - primary->SetColor( primary, 0xff, 0, 0, 0xff ); - primary->DrawString( primary, buf, -1, screen_width - 5, 5, DSTF_TOPRIGHT ); - } - - primary->Flip( primary, NULL, (DFBSurfaceFlipFlags)0 ); - Frames++; - - - t = get_millis(); - if (t - T0 >= 1000) { - GLfloat seconds = (t - T0) / 1000.0; - - fps = Frames / seconds; - - T0 = t; - Frames = 0; - } - - - while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) { - switch (evt.type) { - case DIET_KEYPRESS: - switch (DFB_LOWER_CASE(evt.key_symbol)) { - case DIKS_ESCAPE: - quit = 1; - break; - case DIKS_CURSOR_UP: - xrot += 3.0; - if ( xrot > 85 ) - xrot = 85; - break; - case DIKS_CURSOR_DOWN: - xrot -= 3.0; - if ( xrot < 5 ) - xrot = 5; - break; - case DIKS_CURSOR_LEFT: - yrot += 3.0; - break; - case DIKS_CURSOR_RIGHT: - yrot -= 3.0; - break; - case DIKS_SMALL_D: - ShowBuffer = GL_DEPTH; - break; - case DIKS_SMALL_S: - ShowBuffer = GL_STENCIL; - break; - case DIKS_SMALL_A: - ShowBuffer = GL_ALPHA; - break; - default: - ShowBuffer = GL_NONE; - } - break; - case DIET_AXISMOTION: - if (evt.flags & DIEF_AXISREL) { - switch (evt.axis) { - case DIAI_X: - yrot += evt.axisrel / 2.0; - break; - case DIAI_Y: - xrot += evt.axisrel / 2.0; - break; - default: - ; - } - } - break; - default: - ; - } - } - - spin += 2.0; - yrot += 3.0; - } - - /* release our interfaces to shutdown DirectFB */ - primary_gl->Release( primary_gl ); - primary->Release( primary ); - font->Release( font ); - events->Release( events ); - dfb->Release( dfb ); - - return 0; -} - diff --git a/progs/directfb/multi_window.c b/progs/directfb/multi_window.c deleted file mode 100644 index 9bb0e4be8e..0000000000 --- a/progs/directfb/multi_window.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include - -#include -#include - -#include -#include - - -typedef struct { - IDirectFBWindow *window; - IDirectFBSurface *surface; - IDirectFBGL *gl; - - int width; - int height; - - unsigned long last_time; - int frames; - float fps; -} Context; - -static const GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0}; - -static IDirectFB *dfb; -static IDirectFBDisplayLayer *layer; -static IDirectFBFont *font; -static IDirectFBEventBuffer *events = NULL; - -/* macro for a safe call to DirectFB functions */ -#define DFBCHECK(x...) \ - do { \ - ret = x; \ - if (ret != DFB_OK) { \ - fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ - DirectFBErrorFatal( #x, ret ); \ - } \ - } while (0) - - -static inline unsigned long get_millis() -{ - struct timeval tv; - - gettimeofday (&tv, NULL); - return (tv.tv_sec * 1000 + tv.tv_usec / 1000); -} - - -static void -setup( Context *context ) -{ - GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0}; - - context->surface->GetSize( context->surface, - &context->width, &context->height ); - - context->gl->Lock( context->gl ); - - glLightfv(GL_LIGHT0, GL_POSITION, pos); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - - glViewport(0, 0, context->width, context->height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(70.0, context->width / (float) context->height, 1.0, 80.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -40.0); - - context->gl->Unlock( context->gl ); -} - -static void -update( Context *context ) -{ - unsigned long t; - IDirectFBSurface *surface = context->surface; - static __u8 r = 0, g = 0, b = 0; - - - context->gl->Lock( context->gl ); - - glClearColor( r++/255.0, g++/255.0, b++/255.0, 1.0 ); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - context->gl->Unlock( context->gl ); - - if (context->fps) { - char buf[16]; - - snprintf(buf, sizeof(buf), "%.1f FPS\n", context->fps); - - surface->SetColor( surface, 0xff, 0x00, 0x00, 0xff ); - surface->DrawString( surface, buf, -1, - context->width - 5, 5, DSTF_TOPRIGHT ); - } - - surface->Flip( surface, NULL, 0 ); - - context->frames++; - - t = get_millis(); - if (t - context->last_time >= 2000) { - float seconds = (t - context->last_time) / 1000.0f; - - context->fps = context->frames / seconds; - - context->last_time = t; - context->frames = 0; - } -} - -int -main( int argc, char *argv[] ) -{ - DFBResult ret; - int i; - int quit = 0; - const int num = 2; - Context contexts[num]; - - DFBCHECK(DirectFBInit( &argc, &argv )); - - /* create the super interface */ - DFBCHECK(DirectFBCreate( &dfb )); - - DFBCHECK(dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer )); - - /* create the default font */ - DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font )); - - for (i=0; iCreateWindow( layer, &desc, &window )); - DFBCHECK(window->GetSurface( window, &surface )); - DFBCHECK(surface->GetGL( surface, &gl )); - - contexts[i].window = window; - contexts[i].surface = surface; - contexts[i].gl = gl; - - contexts[i].last_time = get_millis(); - contexts[i].frames = 0; - contexts[i].fps = 0; - - setup( &contexts[i] ); - - if (events) - DFBCHECK(window->AttachEventBuffer( window, events )); - else - DFBCHECK(window->CreateEventBuffer( window, &events )); - - DFBCHECK(surface->SetFont( surface, font )); - - window->SetOpacity( window, 0xff ); - } - - while (!quit) { - DFBWindowEvent evt; - - for (i=0; iGetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) { - switch (evt.type) { - case DWET_KEYDOWN: - switch (evt.key_symbol) { - case DIKS_ESCAPE: - quit = 1; - break; - - default: - break; - } - break; - - default: - break; - } - } - } - - events->Release( events ); - - for (i=0; iRelease( contexts[i].gl ); - contexts[i].surface->Release( contexts[i].surface ); - contexts[i].window->Release( contexts[i].window ); - } - - font->Release( font ); - layer->Release( layer ); - dfb->Release( dfb ); - - return 0; -} - diff --git a/src/glut/directfb/Makefile b/src/glut/directfb/Makefile deleted file mode 100644 index bf93d63e30..0000000000 --- a/src/glut/directfb/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -# subset glut - -TOP = ../../.. -include $(TOP)/configs/current - -MARK = $(TOP)/src/glut/glx - -GLUT_MAJOR = 3 -GLUT_MINOR = 7 -GLUT_TINY = 1 - -INCLUDES = -I$(TOP)/include -I$(MARK) $(shell pkg-config --cflags directfb) - -GLUT_LIB_DEPS += $(shell pkg-config --libs directfb) - -CORE_SOURCES = \ - callback.c \ - color.c \ - cursor.c \ - ext.c \ - events.c \ - font.c \ - game.c \ - globals.c \ - init.c \ - menu.c \ - models.c \ - overlay.c \ - state.c \ - teapot.c \ - window.c \ - - -MARK_SOURCES = \ - $(MARK)/glut_8x13.c \ - $(MARK)/glut_9x15.c \ - $(MARK)/glut_hel10.c \ - $(MARK)/glut_hel12.c \ - $(MARK)/glut_hel18.c \ - $(MARK)/glut_tr10.c \ - $(MARK)/glut_tr24.c - -SOURCES = $(CORE_SOURCES) $(MARK_SOURCES) - -OBJECTS = $(SOURCES:.c=.o) - - -##### RULES ##### - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ - -.S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ - - -##### TARGETS ##### - -default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) - - -# Make the library -$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) - $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \ - $(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \ - $(MKLIB_OPTIONS) $(OBJECTS) - - -# Run 'make -f Makefile.solo dep' to update the dependencies if you change -# what's included by any source file. -depend: $(SOURCES) - rm -f depend - touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) > /dev/null - -# Emacs tags -tags: - etags `find . -name \*.[ch]` `find ../include` - - -# Remove .o and backup files -clean: depend - -rm -f depend depend.bak - -rm -f *.o *~ *.o *~ *.so libglut.so.3.7 - -include depend diff --git a/src/glut/directfb/NOTES b/src/glut/directfb/NOTES deleted file mode 100644 index af917c6667..0000000000 --- a/src/glut/directfb/NOTES +++ /dev/null @@ -1,9 +0,0 @@ -DirectFB GLUT Implementation NOTES ----------------------------------- - -* To have high performance rendering, it's really important to - use glutEnterGameMode() instead of glutCreateWindow()/glutFullScreen(). - You can also force a windowed application to game mode by setting - the environment variable "__GLUT_GAME_MODE". - - diff --git a/src/glut/directfb/callback.c b/src/glut/directfb/callback.c deleted file mode 100644 index 7c9768aac0..0000000000 --- a/src/glut/directfb/callback.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include -#include - -#include "internal.h" - - -typedef void (GLUTCALLBACK *__GlutTimerCallback) ( int value ); - -typedef struct __GlutTimer_s { - struct timeval interval; - struct timeval expire; - - __GlutTimerCallback func; - int value; - - struct __GlutTimer_s *next; -} __GlutTimer; - -/*****************************************************************************/ - -static __GlutTimer *g_timers = NULL; - -/*****************************************************************************/ - - -void GLUTAPIENTRY -glutDisplayFunc( void (GLUTCALLBACK *func) (void) ) -{ - display_func = func; -} - - -void GLUTAPIENTRY -glutReshapeFunc( void (GLUTCALLBACK *func) (int width, int height) ) -{ - reshape_func = func; -} - - -void GLUTAPIENTRY -glutKeyboardFunc( void (GLUTCALLBACK *func) (unsigned char key, int x, int y) ) -{ - keyboard_func = func; -} - - -void GLUTAPIENTRY -glutMouseFunc( void (GLUTCALLBACK *func) (int button, int state, int x, int y) ) -{ - mouse_func = func; -} - - -void GLUTAPIENTRY -glutMotionFunc( void (GLUTCALLBACK *func) (int x, int y) ) -{ - motion_func = func; -} - - -void GLUTAPIENTRY -glutPassiveMotionFunc( void (GLUTCALLBACK *func) (int x, int y) ) -{ - passive_motion_func = func; -} - - -void GLUTAPIENTRY -glutEntryFunc( void (GLUTCALLBACK *func) (int state) ) -{ - entry_func = func; -} - - -void GLUTAPIENTRY -glutVisibilityFunc( void (GLUTCALLBACK *func) (int state) ) -{ - visibility_func = func; -} - - -void GLUTAPIENTRY -glutMenuStateFunc( void (GLUTCALLBACK *func) (int state) ) -{ - menu_state_func = func; -} - - -void GLUTAPIENTRY -glutSpecialFunc( void (GLUTCALLBACK *func) (int key, int x, int y) ) -{ - special_func = func; -} - - -void GLUTAPIENTRY -glutSpaceballMotionFunc( void (GLUTCALLBACK *func) (int x, int y, int z) ) -{ -} - - -void GLUTAPIENTRY -glutSpaceballRotateFunc( void (GLUTCALLBACK *func) (int x, int y, int z) ) -{ -} - - -void GLUTAPIENTRY -glutSpaceballButtonFunc( void (GLUTCALLBACK *func) (int button, int state) ) -{ -} - - -void GLUTAPIENTRY -glutButtonBoxFunc( void (GLUTCALLBACK *func) (int button, int state) ) -{ -} - - -void GLUTAPIENTRY -glutDialsFunc( void (GLUTCALLBACK *func) (int dial, int value) ) -{ -} - - -void GLUTAPIENTRY -glutTabletMotionFunc( void (GLUTCALLBACK *func) (int x, int y) ) -{ -} - - -void GLUTAPIENTRY -glutTabletButtonFunc( void (GLUTCALLBACK *func) (int button, int state, int x, int y) ) -{ -} - - -void GLUTAPIENTRY -glutMenuStatusFunc( void (GLUTCALLBACK *func) (int status, int x, int y) ) -{ -} - - -void GLUTAPIENTRY -glutOverlayDisplayFunc( void (GLUTCALLBACK *func) (void) ) -{ -} - - -void GLUTAPIENTRY -glutWindowStatusFunc( void (GLUTCALLBACK *func) (int state) ) -{ -} - - -void GLUTAPIENTRY -glutKeyboardUpFunc( void (GLUTCALLBACK *func) (unsigned char key, int x, int y) ) -{ - keyboard_up_func = func; -} - - -void GLUTAPIENTRY -glutSpecialUpFunc( void (GLUTCALLBACK *func) (int key, int x, int y) ) -{ - special_up_func = func; -} - - -void GLUTAPIENTRY -glutJoystickFunc( void (GLUTCALLBACK *func)(unsigned int buttons, int x, int y, int z), int pollInterval ) -{ - joystick_func = func; - /* FIXME: take care of pollInterval */ -} - - -void GLUTAPIENTRY -glutIdleFunc( void (GLUTCALLBACK *func) (void) ) -{ - idle_func = func; -} - - -void GLUTAPIENTRY -glutTimerFunc( unsigned int msec, void (GLUTCALLBACK *func) (int value), int value ) -{ - __GlutTimer *timer; - - if (!func) - return; - - timer = calloc( 1, sizeof(__GlutTimer) ); - if (!timer) - __glutFatalError( "out of memory" ); - - timer->interval.tv_sec = msec / 1000; - timer->interval.tv_usec = (msec % 1000) * 1000; - - gettimeofday( &timer->expire, NULL ); - timer->expire.tv_usec += timer->interval.tv_usec; - timer->expire.tv_sec += timer->interval.tv_sec + timer->expire.tv_usec/1000000; - timer->expire.tv_usec %= 1000000; - - timer->func = func; - timer->value = value; - - timer->next = g_timers; - g_timers = timer; -} - - -void -__glutHandleTimers( void ) -{ - __GlutTimer *cur; - struct timeval now; - - for (cur = g_timers; cur; cur = cur->next ) { - gettimeofday( &now, NULL ); - - if (cur->expire.tv_sec > now.tv_sec || - (cur->expire.tv_sec == now.tv_sec && - cur->expire.tv_usec >= now.tv_usec)) - { - g_idle = GL_FALSE; - - cur->func( cur->value ); - - cur->expire.tv_usec += cur->interval.tv_usec; - cur->expire.tv_sec += cur->interval.tv_sec + cur->expire.tv_usec/1000000; - cur->expire.tv_usec %= 1000000; - } - } -} - - -GLboolean -__glutGetTimeout( int *ret_msec ) -{ - __GlutTimer *cur; - struct timeval *time = NULL; - struct timeval now; - - for (cur = g_timers; cur; cur = cur->next) { - if (time == NULL || - time->tv_sec > cur->expire.tv_sec || - (time->tv_sec == cur->expire.tv_sec && - time->tv_usec > cur->expire.tv_usec)) { - time = &cur->expire; - } - } - - if (time == NULL) - return GL_FALSE; - - gettimeofday( &now, NULL ); - - *ret_msec = (time->tv_sec - now.tv_sec) * 1000 + - (time->tv_usec - now.tv_usec + 999) / 1000; - - return GL_TRUE; -} - - -void -__glutFreeTimers( void ) -{ - __GlutTimer *cur = g_timers; - - while (cur) { - __GlutTimer *next = cur->next; - free( cur ); - cur = next; - } - - g_timers = NULL; -} - diff --git a/src/glut/directfb/color.c b/src/glut/directfb/color.c deleted file mode 100644 index 26c514c6d5..0000000000 --- a/src/glut/directfb/color.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "internal.h" - - -void GLUTAPIENTRY -glutSetColor( int index, GLfloat red, GLfloat green, GLfloat blue ) -{ -} - - -GLfloat GLUTAPIENTRY -glutGetColor( int index, int component ) -{ - return 0.0; -} - - -void GLUTAPIENTRY -glutCopyColormap( int win ) -{ -} diff --git a/src/glut/directfb/cursor.c b/src/glut/directfb/cursor.c deleted file mode 100644 index aca3fcc921..0000000000 --- a/src/glut/directfb/cursor.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "internal.h" - -#include "cursors.h" - - -void GLUTAPIENTRY -glutSetCursor( int type ) -{ - const unsigned char *cursor; - DFBSurfaceDescription dsc; - IDirectFBSurface *shape; - - if (!g_current || !g_current->window) - return; - - if (g_current->cursor == type) - return; - - switch (type) { - case GLUT_CURSOR_RIGHT_ARROW: - cursor = &cur_right_arrow[0]; - break; - case GLUT_CURSOR_LEFT_ARROW: - cursor = &cur_left_arrow[0]; - break; - case GLUT_CURSOR_INFO: - cursor = &cur_info[0]; - break; - case GLUT_CURSOR_DESTROY: - cursor = &cur_destroy[0]; - break; - case GLUT_CURSOR_HELP: - cursor = &cur_help[0]; - break; - case GLUT_CURSOR_CYCLE: - cursor = &cur_cycle[0]; - break; - case GLUT_CURSOR_SPRAY: - cursor = &cur_spray[0]; - break; - case GLUT_CURSOR_WAIT: - cursor = &cur_wait[0]; - break; - case GLUT_CURSOR_TEXT: - cursor = &cur_text[0]; - break; - case GLUT_CURSOR_CROSSHAIR: - cursor = &cur_crosshair[0]; - break; - case GLUT_CURSOR_UP_DOWN: - cursor = &cur_up_down[0]; - break; - case GLUT_CURSOR_LEFT_RIGHT: - cursor = &cur_left_right[0]; - break; - case GLUT_CURSOR_TOP_SIDE: - cursor = &cur_top_side[0]; - break; - case GLUT_CURSOR_BOTTOM_SIDE: - cursor = &cur_bottom_side[0]; - break; - case GLUT_CURSOR_LEFT_SIDE: - cursor = &cur_left_side[0]; - break; - case GLUT_CURSOR_RIGHT_SIDE: - cursor = &cur_right_side[0]; - break; - case GLUT_CURSOR_TOP_LEFT_CORNER: - cursor = &cur_top_left[0]; - break; - case GLUT_CURSOR_TOP_RIGHT_CORNER: - cursor = &cur_top_right[0]; - break; - case GLUT_CURSOR_BOTTOM_RIGHT_CORNER: - cursor = &cur_bottom_right[0]; - break; - case GLUT_CURSOR_BOTTOM_LEFT_CORNER: - cursor = &cur_bottom_left[0]; - break; - case GLUT_CURSOR_NONE: - cursor = NULL; - break; - default: - cursor = &cur_right_arrow[0]; - break; - } - - dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT; - dsc.width = - dsc.height = cursor ? cursor[0] : 8; - dsc.pixelformat = DSPF_ARGB; - - if (dfb->CreateSurface( dfb, &dsc, &shape )) - return; - - if (cursor) { - __u8 *src = (__u8*) &cursor[3]; - __u8 *msk = src + cursor[0]*cursor[0]/8; - void *dst; - int pitch; - int x, y; - - if (shape->Lock( shape, DSLF_WRITE, &dst, &pitch )) { - shape->Release( shape ); - return; - } - - for (y = 0; y < cursor[0]; y++) { - for (x = 0; x < cursor[0]; x++) { - ((__u32*)dst)[x] = - ((src[x>>3] & (0x80 >> (x&7))) ? 0 : 0x00ffffff) | - ((msk[x>>3] & (0x80 >> (x&7))) ? 0xff000000 : 0); - } - - dst += pitch; - src += cursor[0]/8; - msk += cursor[0]/8; - } - - shape->Unlock( shape ); - } - else { - /* Invisible cursor */ - shape->Clear( shape, 0, 0, 0, 0 ); - } - - g_current->window->SetCursorShape( g_current->window, shape, - cursor ? cursor[1] : 0, - cursor ? cursor[2] : 0 ); - g_current->cursor = type; - - shape->Release( shape ); -} - - -void GLUTAPIENTRY -glutWarpPointer( int x, int y ) -{ - if (g_current) { - if (!g_game) { - int wx, wy; - g_current->window->GetPosition( g_current->window, &wx, &wy ); - primary->WarpCursor( primary, wx+x, wy+y ); - } - else { - g_current->cx = x; - g_current->cy = y; - } - } -} - - diff --git a/src/glut/directfb/cursors.h b/src/glut/directfb/cursors.h deleted file mode 100644 index 30ab7c348e..0000000000 --- a/src/glut/directfb/cursors.h +++ /dev/null @@ -1,306 +0,0 @@ -#ifndef __GLUT_CURSORS_H__ -#define __GLUT_CURSORS_H__ - - -static const unsigned char cur_right_arrow[] = { - 16, /* size */ - 1, 2, /* hotspot */ - /* data */ - 0x00, 0x00, 0x60, 0x00, 0x78, 0x00, 0x3e, 0x00, - 0x3f, 0x80, 0x1f, 0xe0, 0x1f, 0xf8, 0x0f, 0x80, - 0x0f, 0xc0, 0x06, 0xe0, 0x06, 0x70, 0x02, 0x38, - 0x02, 0x1c, 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, - /* mask */ - 0xe0, 0x00, 0xf8, 0x00, 0xfe, 0x00, 0x7f, 0x80, - 0x7f, 0xe0, 0x3f, 0xf8, 0x3f, 0xfc, 0x1f, 0xfc, - 0x1f, 0xe0, 0x0f, 0xf0, 0x0f, 0xf8, 0x07, 0x7c, - 0x07, 0x3e, 0x02, 0x1f, 0x00, 0x0e, 0x00, 0x04, -}; - -static const unsigned char cur_left_arrow[] = { - 16, /* size */ - 1, 15, /* hotspot */ - /* data */ - 0x00, 0x00, 0x80, 0x06, 0x00, 0x1e, 0x00, 0x7c, - 0x01, 0xfc, 0x07, 0xf8, 0x1f, 0xf8, 0x01, 0xf0, - 0x01, 0xf0, 0x02, 0x60, 0x04, 0x60, 0x08, 0x40, - 0x10, 0x40, 0x20, 0x00, 0x40, 0x00, 0x00, 0x00, - /* mask */ - 0x00, 0x07, 0x00, 0x1f, 0x00, 0x7f, 0x01, 0xfe, - 0x07, 0xfe, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xf8, - 0x03, 0xf8, 0x07, 0xf0, 0x0e, 0xf0, 0x1c, 0xe0, - 0x38, 0xe0, 0x70, 0xe0, 0xe0, 0x00, 0xc0, 0x00, -}; - -static const unsigned char cur_info[] = { - 16, /* size */ - 0, 2, /* hotspot */ - /* data */ - 0x30, 0x00, 0x3c, 0x00, 0x0f, 0x00, 0x07, 0x80, - 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x07, 0xf4, - 0x0f, 0xfe, 0x0f, 0xfa, 0x07, 0xe0, 0x03, 0xe0, - 0x00, 0x52, 0x00, 0x46, 0x00, 0x2c, 0x00, 0x18, - /* mask */ - 0xb8, 0x00, 0x3e, 0x00, 0x1f, 0x80, 0x0f, 0xc0, - 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xfc, 0x1f, 0xfe, - 0x1f, 0xfe, 0x1f, 0xfe, 0x0f, 0xfe, 0x07, 0xfe, - 0x03, 0xfe, 0x00, 0xfe, 0x00, 0x7e, 0x00, 0x3c, -}; - -static const unsigned char cur_destroy[] = { - 16, /* size */ - 12, 8, /* hotspot */ - /* data */ - 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0c, 0xcc, - 0x0c, 0xcc, 0x07, 0xf8, 0x03, 0xf0, 0x01, 0xe0, - 0x21, 0xe1, 0x61, 0xe1, 0x10, 0xc2, 0x0e, 0x1c, - 0x01, 0xe0, 0x47, 0xf8, 0x7c, 0x0f, 0x20, 0x01, - /* mask */ - 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xfc, 0x1f, 0xfe, - 0x1f, 0xfe, 0x0f, 0xfc, 0x07, 0xf8, 0x83, 0xf1, - 0xe3, 0xf1, 0xf3, 0xf3, 0x39, 0xef, 0x1e, 0x1e, - 0x01, 0xe0, 0xc7, 0xfe, 0xff, 0xff, 0x7c, 0x0f, -}; - -static const unsigned char cur_help[] = { - 16, /* size */ - 7, 8, /* hotspot */ - /* data */ - 0x83, 0xe0, 0x07, 0xf0, 0x0e, 0x38, 0x0c, 0x18, - 0x0c, 0x38, 0x0e, 0x30, 0x07, 0x00, 0x03, 0xc0, - 0x01, 0xc0, 0x01, 0x40, 0x01, 0x40, 0x07, 0x70, - 0x03, 0x60, 0x01, 0xc0, 0x00, 0x80, 0x00, 0x00, - /* mask */ - 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, - 0x1e, 0x3c, 0x1e, 0x7c, 0x1f, 0x78, 0x0f, 0xf0, - 0x07, 0xe0, 0x03, 0xe0, 0x03, 0xe0, 0x07, 0xf0, - 0x0f, 0xf8, 0x07, 0xf0, 0x03, 0xe0, 0x01, 0xc0, -}; - -static const unsigned char cur_cycle[] = { - 16, /* size */ - 7, 9, /* hotspot */ - /* data */ - 0x00, 0x00, 0x07, 0xe2, 0x0f, 0xf6, 0x18, 0x3e, - 0x10, 0x12, 0x00, 0x32, 0x00, 0x7e, 0x00, 0x00, - 0x00, 0x00, 0x7e, 0x00, 0x4c, 0x00, 0x48, 0x08, - 0x7c, 0x18, 0x6f, 0xf0, 0x47, 0xe0, 0x00, 0x00, - /* mask */ - 0x07, 0xe3, 0x0f, 0xf7, 0x1f, 0xff, 0x3f, 0xff, - 0x38, 0x3f, 0x30, 0xff, 0x00, 0xff, 0x00, 0xff, - 0xff, 0x00, 0xff, 0x00, 0xfe, 0x0c, 0xfc, 0x1c, - 0xff, 0xfc, 0xff, 0xf8, 0xef, 0xf0, 0xc7, 0xe0, -}; - -static const unsigned char cur_spray[] = { - 16, /* size */ - 2, 4, /* hotspot */ - /* data */ - 0x98, 0x00, 0x02, 0x00, 0x18, 0xb0, 0x02, 0x78, - 0x18, 0x58, 0x00, 0xfc, 0x00, 0x84, 0x00, 0x9c, - 0x00, 0x94, 0x00, 0x9c, 0x00, 0x94, 0x00, 0x9c, - 0x00, 0x9c, 0x00, 0x84, 0x00, 0x84, 0x00, 0xfc, - /* mask */ - 0x30, 0x00, 0x34, 0x60, 0x35, 0xf0, 0x35, 0xf0, - 0x35, 0xf8, 0x03, 0xfc, 0x03, 0xfc, 0x03, 0xfc, - 0x03, 0xfc, 0x03, 0xfc, 0x03, 0xfc, 0x03, 0xfc, - 0x03, 0xfc, 0x03, 0xfc, 0x03, 0xfc, 0x03, 0xfc, -}; - -static const unsigned char cur_wait[] = { - 16, /* size */ - 9, 1, /* hotspot */ - /* data */ - 0x07, 0xf8, 0x07, 0xf8, 0x07, 0xf8, 0x0f, 0xfc, - 0x18, 0x86, 0x30, 0x83, 0xe0, 0x81, 0xe1, 0xc1, - 0xe1, 0xc1, 0xe0, 0x21, 0x30, 0x13, 0x18, 0x06, - 0x0f, 0xfc, 0x07, 0xf8, 0x07, 0xf8, 0x07, 0xf8, - /* mask */ - 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x1f, 0xfe, - 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, - 0x1f, 0xfe, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, -}; - -static const unsigned char cur_text[] = { - 16, /* size */ - 8, 8, /* hotspot */ - /* data */ - 0x00, 0x00, 0x0f, 0x70, 0x09, 0xc0, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x01, 0xc0, 0x07, 0x70, 0x00, 0x00, - /* mask */ - 0x0f, 0x78, 0x0f, 0xf8, 0x0f, 0xf8, 0x03, 0xe0, - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x03, 0xe0, 0x0f, 0xf8, 0x0f, 0xf8, 0x0f, 0x78, -}; - -static const unsigned char cur_crosshair[] = { - 16, /* size */ - 7, 9, /* hotspot */ - /* data */ - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0xff, 0x7f, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, - /* mask */ - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x01, 0xc0, 0x01, 0xc0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, -}; - -static const unsigned char cur_up_down[] = { - 16, /* size */ - 7, 8, /* hotspot */ - /* data */ - 0x00, 0x80, 0x09, 0xc0, 0x03, 0xe0, 0x07, 0xf0, - 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, - 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x07, 0xf0, - 0x03, 0xe0, 0x01, 0xc0, 0x00, 0x80, 0x00, 0x00, - /* mask */ - 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, - 0x0f, 0xf8, 0x03, 0xe0, 0x03, 0xe0, 0x03, 0xe0, - 0x03, 0xe0, 0x03, 0xe0, 0x0f, 0xf8, 0x0f, 0xf8, - 0x07, 0xf0, 0x03, 0xe0, 0x01, 0xc0, 0x00, 0x00, -}; - -static const unsigned char cur_left_right[] = { - 16, /* size */ - 7, 8, /* hotspot */ - /* data */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x08, 0x18, 0x0c, 0x3f, 0xfe, 0x78, 0x0f, - 0x3f, 0xfe, 0x18, 0x0c, 0x08, 0x08, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* mask */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x18, - 0x1c, 0x1c, 0x3f, 0xfe, 0x7f, 0xff, 0x7f, 0xff, - 0x7f, 0xff, 0x3f, 0xfe, 0x1c, 0x1c, 0x0c, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -static const unsigned char cur_top_side[] = { - 16, /* size */ - 1, 8, /* hotspot */ - /* data */ - 0x00, 0x00, 0xff, 0xfe, 0x3f, 0xfe, 0x00, 0x00, - 0x00, 0x80, 0x01, 0xc0, 0x02, 0xa0, 0x04, 0x90, - 0x08, 0x88, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, - /* mask */ - 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, - 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, - 0x1d, 0xdc, 0x19, 0xcc, 0x01, 0xc0, 0x01, 0xc0, - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, -}; - -static const unsigned char cur_bottom_side[] = { - 16, /* size */ - 14, 8, /* hotspot */ - /* data */ - 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x08, 0x88, - 0x04, 0x90, 0x02, 0xa0, 0x01, 0xc0, 0x00, 0x80, - 0x00, 0x00, 0x3f, 0xfe, 0x3f, 0xfe, 0x00, 0x00, - /* mask */ - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x01, 0xc0, 0x01, 0xc0, 0x19, 0xcc, 0x1d, 0xdc, - 0x0f, 0xf8, 0x07, 0xf0, 0x03, 0xe0, 0x01, 0xc0, - 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, -}; - -static const unsigned char cur_left_side[] = { - 16, /* size */ - 7, 15, /* hotspot */ - /* data */ - 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x01, 0x06, - 0x00, 0x86, 0x00, 0x46, 0x00, 0x26, 0x7f, 0xf6, - 0x00, 0x26, 0x00, 0x46, 0x00, 0x86, 0x01, 0x06, - 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, - /* mask */ - 0x00, 0x0f, 0x00, 0x0f, 0x03, 0x0f, 0x03, 0x8f, - 0x01, 0xcf, 0x00, 0xef, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x00, 0xef, 0x01, 0xcf, 0x03, 0x8f, - 0x03, 0x0f, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x00, -}; - -static const unsigned char cur_right_side[] = { - 16, /* size */ - 7, 2, /* hotspot */ - /* data */ - 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x80, - 0x61, 0x00, 0x62, 0x00, 0x64, 0x00, 0x6f, 0xfe, - 0x64, 0x00, 0x62, 0x00, 0x61, 0x00, 0x60, 0x80, - 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, - /* mask */ - 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0xc0, 0xf1, 0xc0, - 0xf3, 0x80, 0xf7, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf7, 0x00, 0xf3, 0x80, 0xf1, 0xc0, - 0xf0, 0xc0, 0xf0, 0x00, 0xf0, 0x00, 0x00, 0x00, -}; - -static const unsigned char cur_top_left[] = { - 16, /* size */ - 1, 15, /* hotspot */ - /* data */ - 0x00, 0x00, 0xff, 0xfe, 0x7f, 0xfe, 0x00, 0x06, - 0x00, 0x06, 0x00, 0x06, 0x1f, 0xc6, 0x00, 0xc6, - 0x01, 0x46, 0x02, 0x46, 0x04, 0x46, 0x08, 0x46, - 0x10, 0x46, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, - /* mask */ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x0f, 0x3f, 0xef, 0x3f, 0xef, 0x3f, 0xef, - 0x03, 0xef, 0x07, 0xef, 0x0e, 0xef, 0x1c, 0xef, - 0x38, 0xef, 0x30, 0xef, 0x00, 0x0f, 0x00, 0x0f, -}; - -static const unsigned char cur_top_right[] = { - 16, /* size */ - 1, 2, /* hotspot */ - /* data */ - 0x00, 0x00, 0xff, 0xfe, 0x7f, 0xfe, 0x60, 0x00, - 0x60, 0x00, 0x60, 0x00, 0x63, 0xf8, 0x63, 0x00, - 0x62, 0x80, 0x62, 0x40, 0x62, 0x20, 0x62, 0x10, - 0x62, 0x08, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, - /* mask */ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf0, 0x00, 0xf7, 0xfc, 0xf7, 0xfc, 0xf7, 0xfc, - 0xf7, 0xc0, 0xf7, 0xe0, 0xf7, 0x70, 0xf7, 0x38, - 0xf7, 0x1c, 0xf7, 0x0c, 0xf0, 0x00, 0xf0, 0x00, -}; - -static const unsigned char cur_bottom_right[] = { - 16, /* size */ - 14, 2, /* hotspot */ - /* data */ - 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x62, 0x08, - 0x62, 0x10, 0x62, 0x20, 0x62, 0x40, 0x62, 0x80, - 0x63, 0x00, 0x63, 0xf8, 0x60, 0x00, 0x60, 0x00, - 0x60, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, - /* mask */ - 0xf0, 0x00, 0xf0, 0x00, 0xf7, 0x0c, 0xf7, 0x1c, - 0xf7, 0x38, 0xf7, 0x70, 0xf7, 0xe0, 0xf7, 0xc0, - 0xf7, 0xfc, 0xf7, 0xfc, 0xf7, 0xfc, 0xf0, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -}; - -static const unsigned char cur_bottom_left[] = { - 16, /* size */ - 14, 15, /* hotspot */ - /* data */ - 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x10, 0x46, - 0x08, 0x46, 0x04, 0x46, 0x02, 0x46, 0x01, 0x46, - 0x00, 0xc6, 0x1f, 0xc6, 0x00, 0x06, 0x00, 0x06, - 0x00, 0x06, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, - /* mask */ - 0x00, 0x0f, 0x00, 0x0f, 0x30, 0xef, 0x38, 0xef, - 0x1c, 0xef, 0x0e, 0xef, 0x07, 0xef, 0x03, 0xef, - 0x3f, 0xef, 0x3f, 0xef, 0x3f, 0xef, 0x00, 0x0f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -}; - - -#endif /* __GLUT_CURSORS_H__ */ diff --git a/src/glut/directfb/events.c b/src/glut/directfb/events.c deleted file mode 100644 index 6ebdd166ac..0000000000 --- a/src/glut/directfb/events.c +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "internal.h" - - -/*****************************************************************************/ - -static int g_ignore_key_repeat = 0; - -/*****************************************************************************/ - - -int GLUTAPIENTRY -glutDeviceGet( GLenum type ) -{ - switch (type) { - case GLUT_HAS_KEYBOARD: - return (keyboard != NULL); - case GLUT_HAS_MOUSE: - return (mouse != NULL); - case GLUT_NUM_MOUSE_BUTTONS: - if (mouse) { - DFBInputDeviceDescription dsc; - mouse->GetDescription( mouse, &dsc ); - return dsc.max_button+1; - } - break; - case GLUT_DEVICE_IGNORE_KEY_REPEAT: - return g_ignore_key_repeat; - case GLUT_DEVICE_KEY_REPEAT: - return (g_ignore_key_repeat) ? GLUT_KEY_REPEAT_OFF - : GLUT_KEY_REPEAT_ON; - case GLUT_HAS_JOYSTICK: - case GLUT_OWNS_JOYSTICK: - return (g_game && joystick); /* only available in game mode */ - case GLUT_JOYSTICK_BUTTONS: - if (joystick) { - DFBInputDeviceDescription dsc; - joystick->GetDescription( joystick, &dsc ); - return dsc.max_button+1; - } - break; - case GLUT_JOYSTICK_AXES: - if (joystick) { - DFBInputDeviceDescription dsc; - joystick->GetDescription( joystick, &dsc ); - return dsc.max_axis+1; - } - break; - case GLUT_JOYSTICK_POLL_RATE: - if (joystick) - return 1; /* hack */ - break; - default: - break; - } - - return 0; -} - - -int GLUTAPIENTRY -glutGetModifiers( void ) -{ - if (g_current) - return g_current->modifiers; - return 0; -} - - -void GLUTAPIENTRY -glutIgnoreKeyRepeat( int ignore ) -{ - g_ignore_key_repeat = ignore; -} - - -void GLUTAPIENTRY -glutSetKeyRepeat( int mode ) -{ - g_ignore_key_repeat = (mode == GLUT_KEY_REPEAT_OFF); -} - - -void GLUTAPIENTRY -glutForceJoystickFunc( void ) -{ - if (g_game && joystick && joystick_func) { - joystick_func( g_game->buttons, - g_game->jx, g_game->jy, g_game->jz ); - } -} - - -static int -__glutSpecialKey( DFBInputDeviceKeySymbol key ) -{ - switch (key) { - case DIKS_F1: - return GLUT_KEY_F1; - case DIKS_F2: - return GLUT_KEY_F2; - case DIKS_F3: - return GLUT_KEY_F3; - case DIKS_F4: - return GLUT_KEY_F4; - case DIKS_F5: - return GLUT_KEY_F5; - case DIKS_F6: - return GLUT_KEY_F6; - case DIKS_F7: - return GLUT_KEY_F7; - case DIKS_F8: - return GLUT_KEY_F8; - case DIKS_F9: - return GLUT_KEY_F9; - case DIKS_F10: - return GLUT_KEY_F10; - case DIKS_F11: - return GLUT_KEY_F11; - case DIKS_F12: - return GLUT_KEY_F12; - case DIKS_CURSOR_LEFT: - return GLUT_KEY_LEFT; - case DIKS_CURSOR_UP: - return GLUT_KEY_UP; - case DIKS_CURSOR_RIGHT: - return GLUT_KEY_RIGHT; - case DIKS_CURSOR_DOWN: - return GLUT_KEY_DOWN; - case DIKS_PAGE_UP: - return GLUT_KEY_PAGE_UP; - case DIKS_PAGE_DOWN: - return GLUT_KEY_PAGE_DOWN; - case DIKS_HOME: - return GLUT_KEY_HOME; - case DIKS_END: - return GLUT_KEY_END; - case DIKS_INSERT: - return GLUT_KEY_INSERT; - default: - break; - } - - return 0; -} - - -static int -__glutButton( DFBInputDeviceButtonIdentifier button ) -{ - switch (button) { - case DIBI_LEFT: - return GLUT_LEFT_BUTTON; - case DIBI_MIDDLE: - return GLUT_MIDDLE_BUTTON; - case DIBI_RIGHT: - return GLUT_RIGHT_BUTTON; - default: - break; - } - - return 0; -} - - -static int -__glutModifiers( DFBInputDeviceModifierMask mask ) -{ - return ((mask & DIMM_SHIFT) ? GLUT_ACTIVE_SHIFT : 0) | - ((mask & DIMM_CONTROL) ? GLUT_ACTIVE_CTRL : 0) | - ((mask & DIMM_ALT) ? GLUT_ACTIVE_ALT : 0); -} - - -static void -__glutWindowEvent( DFBWindowEvent *e, DFBWindowEvent *p ) -{ - __GlutWindow *window; - - window = __glutFindWindow( e->window_id ); - if (!window) /* window was destroyed */ - return; - - switch (e->type) { - case DWET_KEYDOWN: - window->modifiers = __glutModifiers( e->modifiers ); - if (g_ignore_key_repeat && p) { - if (p->type == DWET_KEYDOWN && - p->window_id == e->window_id && - p->key_symbol == e->key_symbol) - break; - } - if (DFB_KEY_IS_ASCII( e->key_symbol )) { - if (keyboard_func) { - __glutSetWindow( window ); - keyboard_func( e->key_symbol, e->x, e->y ); - } - } - else { - int key = __glutSpecialKey( e->key_symbol ); - if (key && special_func) { - __glutSetWindow( window ); - special_func( key, e->x, e->y ); - } - } - break; - case DWET_KEYUP: - window->modifiers = __glutModifiers( e->modifiers ); - if (DFB_KEY_IS_ASCII( e->key_symbol )) { - if (keyboard_up_func) { - __glutSetWindow( window ); - keyboard_up_func( e->key_symbol, e->x, e->y ); - } - } - else { - int key = __glutSpecialKey( e->key_symbol ); - if (key && special_up_func) { - __glutSetWindow( window ); - special_up_func( key, e->x, e->y ); - } - } - break; - case DWET_BUTTONDOWN: - if (mouse_func) { - __glutSetWindow( window ); - mouse_func( __glutButton( e->button ), GLUT_DOWN, e->x, e->y ); - } - break; - case DWET_BUTTONUP: - if (mouse_func) { - __glutSetWindow( window ); - mouse_func( __glutButton( e->button ), GLUT_UP, e->x, e->y ); - } - break; - case DWET_MOTION: - if (e->buttons) { - if (motion_func) { - __glutSetWindow( window ); - motion_func( e->cx, e->cy ); - } - } - else { - if (passive_motion_func) { - __glutSetWindow( window ); - passive_motion_func( e->cx, e->cy ); - } - } - break; - case DWET_ENTER: - if (entry_func) { - __glutSetWindow( window ); - entry_func( GLUT_ENTERED ); - } - break; - case DWET_LEAVE: - if (entry_func) { - __glutSetWindow( window ); - entry_func( GLUT_LEFT ); - } - break; - case DWET_SIZE: - window->reshape = GL_TRUE; - window->redisplay = GL_TRUE; - break; - default: - break; - } -} - - -static void -__glutInputEvent( DFBInputEvent *e, DFBInputEvent *p ) -{ - __glutAssert( g_game != NULL ); - - switch (e->type) { - case DIET_KEYPRESS: - g_game->modifiers = __glutModifiers( e->modifiers ); - if (g_ignore_key_repeat && p) { - if (p->type == DIET_KEYPRESS && - p->key_symbol == e->key_symbol) - break; - } - if (DFB_KEY_IS_ASCII( e->key_symbol )) { - if (keyboard_func) { - __glutSetWindow( g_game ); - keyboard_func( e->key_symbol, g_game->cx, g_game->cy ); - } - } - else { - int key = __glutSpecialKey( e->key_symbol ); - if (key && special_func) { - __glutSetWindow( g_game ); - special_func( key, g_game->cx, g_game->cy ); - } - } - break; - case DIET_KEYRELEASE: - g_game->modifiers = __glutModifiers( e->modifiers ); - if (DFB_KEY_IS_ASCII( e->key_symbol )) { - if (keyboard_up_func) { - __glutSetWindow( g_game ); - keyboard_up_func( e->key_symbol, g_game->cx, g_game->cy ); - } - } - else { - int key = __glutSpecialKey( e->key_symbol ); - if (key && special_up_func) { - __glutSetWindow( g_game ); - special_up_func( key, g_game->cx, g_game->cy ); - } - } - break; - case DIET_BUTTONPRESS: - if (e->device_id == DIDID_JOYSTICK) { - g_game->buttons = e->buttons; - if (joystick_func) { - __glutSetWindow( g_game ); - joystick_func( g_game->buttons, - g_game->jx, g_game->jy, g_game->jz ); - } - } - else { - if (mouse_func) { - __glutSetWindow( g_game ); - mouse_func( __glutButton( e->button ), - GLUT_DOWN, g_game->cx, g_game->cy ); - } - } - break; - case DIET_BUTTONRELEASE: - if (e->device_id == DIDID_JOYSTICK) { - g_game->buttons = e->buttons; - if (joystick_func) { - __glutSetWindow( g_game ); - joystick_func( g_game->buttons, - g_game->jx, g_game->jy, g_game->jz ); - } - } - else { - if (mouse_func) { - __glutSetWindow( g_game ); - mouse_func( __glutButton( e->button ), - GLUT_UP, g_game->cx, g_game->cy ); - } - } - break; - case DIET_AXISMOTION: - if (e->device_id == DIDID_JOYSTICK) { - switch (e->axis) { - case DIAI_X: - if (e->flags & DIEF_AXISABS) - g_game->jx = e->axisabs; - else if (e->flags & DIEF_AXISREL) - g_game->jx += e->axisrel; - break; - case DIAI_Y: - if (e->flags & DIEF_AXISABS) - g_game->jy = e->axisabs; - else if (e->flags & DIEF_AXISREL) - g_game->jy += e->axisrel; - break; - case DIAI_Z: - if (e->flags & DIEF_AXISABS) - g_game->jz = e->axisabs; - else if (e->flags & DIEF_AXISREL) - g_game->jz += e->axisrel; - break; - default: - break; - } - if (joystick_func) { - __glutSetWindow( g_game ); - joystick_func( g_game->buttons, - g_game->jx, g_game->jy, g_game->jz ); - } - } - else { - switch (e->axis) { - case DIAI_X: - if (e->flags & DIEF_AXISABS) - g_game->cx = e->axisabs; - else if (e->flags & DIEF_AXISREL) - g_game->cx += e->axisrel; - break; - case DIAI_Y: - if (e->flags & DIEF_AXISABS) - g_game->cy = e->axisabs; - else if (e->flags & DIEF_AXISREL) - g_game->cy += e->axisrel; - break; - default: - return; - } - if (e->buttons && motion_func) { - __glutSetWindow( g_game ); - motion_func( g_game->cx, g_game->cy ); - } - else if (!e->buttons && passive_motion_func) { - __glutSetWindow( g_game ); - passive_motion_func( g_game->cx, g_game->cy ); - } - } - break; - default: - break; - } -} - - -void GLUTAPIENTRY -glutMainLoop( void ) -{ - __glutAssert( events != NULL ); - - __glutHandleWindows(); - - while (GL_TRUE) { - DFBEvent evt, prev; - - g_idle = GL_TRUE; - - __glutHandleTimers(); - - prev.clazz = DFEC_NONE; - - while (events->GetEvent( events, &evt ) == DFB_OK) { - g_idle = GL_FALSE; - - switch (evt.clazz) { - case DFEC_WINDOW: - if (prev.clazz == DFEC_WINDOW) - __glutWindowEvent( &evt.window, &prev.window ); - else - __glutWindowEvent( &evt.window, NULL ); - break; - case DFEC_INPUT: - if (prev.clazz == DFEC_INPUT) - __glutInputEvent( &evt.input, &prev.input ); - else - __glutInputEvent( &evt.input, NULL ); - break; - default: - __glutWarning( "unexpected event class %d!\n", evt.clazz ); - break; - } - - prev = evt; - - __glutHandleTimers(); - } - - __glutHandleWindows(); - - if (g_idle) { - if (idle_func) { - idle_func(); - } - else { - int msec; - __glutSetWindow( NULL ); - if (__glutGetTimeout( &msec )) - events->WaitForEventWithTimeout( events, msec/1000, msec%1000 ); - else - events->WaitForEvent( events ); - } - } - } -} - diff --git a/src/glut/directfb/ext.c b/src/glut/directfb/ext.c deleted file mode 100644 index e37ecf5afa..0000000000 --- a/src/glut/directfb/ext.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "internal.h" - - -static const struct { - const char *name; - const GLUTproc address; -} glut_functions[] = { - { "glutInit", (const GLUTproc) glutInit }, - { "glutInitDisplayMode", (const GLUTproc) glutInitDisplayMode }, - { "glutInitDisplayString", (const GLUTproc) glutInitDisplayString }, - { "glutInitWindowPosition", (const GLUTproc) glutInitWindowPosition }, - { "glutInitWindowSize", (const GLUTproc) glutInitWindowSize }, - { "glutMainLoop", (const GLUTproc) glutMainLoop }, - { "glutCreateWindow", (const GLUTproc) glutCreateWindow }, - { "glutCreateSubWindow", (const GLUTproc) glutCreateSubWindow }, - { "glutDestroyWindow", (const GLUTproc) glutDestroyWindow }, - { "glutPostRedisplay", (const GLUTproc) glutPostRedisplay }, - { "glutPostWindowRedisplay", (const GLUTproc) glutPostWindowRedisplay }, - { "glutSwapBuffers", (const GLUTproc) glutSwapBuffers }, - { "glutGetWindow", (const GLUTproc) glutGetWindow }, - { "glutSetWindow", (const GLUTproc) glutSetWindow }, - { "glutSetWindowTitle", (const GLUTproc) glutSetWindowTitle }, - { "glutSetIconTitle", (const GLUTproc) glutSetIconTitle }, - { "glutPositionWindow", (const GLUTproc) glutPositionWindow }, - { "glutReshapeWindow", (const GLUTproc) glutReshapeWindow }, - { "glutPopWindow", (const GLUTproc) glutPopWindow }, - { "glutPushWindow", (const GLUTproc) glutPushWindow }, - { "glutIconifyWindow", (const GLUTproc) glutIconifyWindow }, - { "glutShowWindow", (const GLUTproc) glutShowWindow }, - { "glutHideWindow", (const GLUTproc) glutHideWindow }, - { "glutFullScreen", (const GLUTproc) glutFullScreen }, - { "glutSetCursor", (const GLUTproc) glutSetCursor }, - { "glutWarpPointer", (const GLUTproc) glutWarpPointer }, - { "glutEstablishOverlay", (const GLUTproc) glutEstablishOverlay }, - { "glutRemoveOverlay", (const GLUTproc) glutRemoveOverlay }, - { "glutUseLayer", (const GLUTproc) glutUseLayer }, - { "glutPostOverlayRedisplay", (const GLUTproc) glutPostOverlayRedisplay }, - { "glutPostWindowOverlayRedisplay", (const GLUTproc) glutPostWindowOverlayRedisplay }, - { "glutShowOverlay", (const GLUTproc) glutShowOverlay }, - { "glutHideOverlay", (const GLUTproc) glutHideOverlay }, - { "glutCreateMenu", (const GLUTproc) glutCreateMenu }, - { "glutDestroyMenu", (const GLUTproc) glutDestroyMenu }, - { "glutGetMenu", (const GLUTproc) glutGetMenu }, - { "glutSetMenu", (const GLUTproc) glutSetMenu }, - { "glutAddMenuEntry", (const GLUTproc) glutAddMenuEntry }, - { "glutAddSubMenu", (const GLUTproc) glutAddSubMenu }, - { "glutChangeToMenuEntry", (const GLUTproc) glutChangeToMenuEntry }, - { "glutChangeToSubMenu", (const GLUTproc) glutChangeToSubMenu }, - { "glutRemoveMenuItem", (const GLUTproc) glutRemoveMenuItem }, - { "glutAttachMenu", (const GLUTproc) glutAttachMenu }, - { "glutDetachMenu", (const GLUTproc) glutDetachMenu }, - { "glutDisplayFunc", (const GLUTproc) glutDisplayFunc }, - { "glutReshapeFunc", (const GLUTproc) glutReshapeFunc }, - { "glutKeyboardFunc", (const GLUTproc) glutKeyboardFunc }, - { "glutMouseFunc", (const GLUTproc) glutMouseFunc }, - { "glutMotionFunc", (const GLUTproc) glutMotionFunc }, - { "glutPassiveMotionFunc", (const GLUTproc) glutPassiveMotionFunc }, - { "glutEntryFunc", (const GLUTproc) glutEntryFunc }, - { "glutVisibilityFunc", (const GLUTproc) glutVisibilityFunc }, - { "glutIdleFunc", (const GLUTproc) glutIdleFunc }, - { "glutTimerFunc", (const GLUTproc) glutTimerFunc }, - { "glutMenuStateFunc", (const GLUTproc) glutMenuStateFunc }, - { "glutSpecialFunc", (const GLUTproc) glutSpecialFunc }, - { "glutSpaceballMotionFunc", (const GLUTproc) glutSpaceballMotionFunc }, - { "glutSpaceballRotateFunc", (const GLUTproc) glutSpaceballRotateFunc }, - { "glutSpaceballButtonFunc", (const GLUTproc) glutSpaceballButtonFunc }, - { "glutButtonBoxFunc", (const GLUTproc) glutButtonBoxFunc }, - { "glutDialsFunc", (const GLUTproc) glutDialsFunc }, - { "glutTabletMotionFunc", (const GLUTproc) glutTabletMotionFunc }, - { "glutTabletButtonFunc", (const GLUTproc) glutTabletButtonFunc }, - { "glutMenuStatusFunc", (const GLUTproc) glutMenuStatusFunc }, - { "glutOverlayDisplayFunc", (const GLUTproc) glutOverlayDisplayFunc }, - { "glutWindowStatusFunc", (const GLUTproc) glutWindowStatusFunc }, - { "glutKeyboardUpFunc", (const GLUTproc) glutKeyboardUpFunc }, - { "glutSpecialUpFunc", (const GLUTproc) glutSpecialUpFunc }, - { "glutJoystickFunc", (const GLUTproc) glutJoystickFunc }, - { "glutSetColor", (const GLUTproc) glutSetColor }, - { "glutGetColor", (const GLUTproc) glutGetColor }, - { "glutCopyColormap", (const GLUTproc) glutCopyColormap }, - { "glutGet", (const GLUTproc) glutGet }, - { "glutDeviceGet", (const GLUTproc) glutDeviceGet }, - { "glutExtensionSupported", (const GLUTproc) glutExtensionSupported }, - { "glutGetModifiers", (const GLUTproc) glutGetModifiers }, - { "glutLayerGet", (const GLUTproc) glutLayerGet }, - { "glutGetProcAddress", (const GLUTproc) glutGetProcAddress }, - { "glutBitmapCharacter", (const GLUTproc) glutBitmapCharacter }, - { "glutBitmapWidth", (const GLUTproc) glutBitmapWidth }, - { "glutStrokeCharacter", (const GLUTproc) glutStrokeCharacter }, - { "glutStrokeWidth", (const GLUTproc) glutStrokeWidth }, - { "glutBitmapLength", (const GLUTproc) glutBitmapLength }, - { "glutStrokeLength", (const GLUTproc) glutStrokeLength }, - { "glutWireSphere", (const GLUTproc) glutWireSphere }, - { "glutSolidSphere", (const GLUTproc) glutSolidSphere }, - { "glutWireCone", (const GLUTproc) glutWireCone }, - { "glutSolidCone", (const GLUTproc) glutSolidCone }, - { "glutWireCube", (const GLUTproc) glutWireCube }, - { "glutSolidCube", (const GLUTproc) glutSolidCube }, - { "glutWireTorus", (const GLUTproc) glutWireTorus }, - { "glutSolidTorus", (const GLUTproc) glutSolidTorus }, - { "glutWireDodecahedron", (const GLUTproc) glutWireDodecahedron }, - { "glutSolidDodecahedron", (const GLUTproc) glutSolidDodecahedron }, - { "glutWireTeapot", (const GLUTproc) glutWireTeapot }, - { "glutSolidTeapot", (const GLUTproc) glutSolidTeapot }, - { "glutWireOctahedron", (const GLUTproc) glutWireOctahedron }, - { "glutSolidOctahedron", (const GLUTproc) glutSolidOctahedron }, - { "glutWireTetrahedron", (const GLUTproc) glutWireTetrahedron }, - { "glutSolidTetrahedron", (const GLUTproc) glutSolidTetrahedron }, - { "glutWireIcosahedron", (const GLUTproc) glutWireIcosahedron }, - { "glutSolidIcosahedron", (const GLUTproc) glutSolidIcosahedron }, -// { "glutVideoResizeGet", (const GLUTproc) glutVideoResizeGet }, -// { "glutSetupVideoResizing", (const GLUTproc) glutSetupVideoResizing }, -// { "glutStopVideoResizing", (const GLUTproc) glutStopVideoResizing }, -// { "glutVideoResize", (const GLUTproc) glutVideoResize }, -// { "glutVideoPan", (const GLUTproc) glutVideoPan }, - { "glutReportErrors", (const GLUTproc) glutReportErrors }, - { "glutIgnoreKeyRepeat", (const GLUTproc) glutIgnoreKeyRepeat }, - { "glutSetKeyRepeat", (const GLUTproc) glutSetKeyRepeat }, - { "glutForceJoystickFunc", (const GLUTproc) glutForceJoystickFunc }, - { "glutGameModeString", (const GLUTproc) glutGameModeString }, - { "glutEnterGameMode", (const GLUTproc) glutEnterGameMode }, - { "glutLeaveGameMode", (const GLUTproc) glutLeaveGameMode }, - { "glutGameModeGet", (const GLUTproc) glutGameModeGet }, -}; - - -GLUTproc GLUTAPIENTRY -glutGetProcAddress( const char *name ) -{ - int i; - - for (i = 0; i < sizeof(glut_functions)/sizeof(glut_functions[0]); i++) { - if (!strcmp( name, glut_functions[i].name )) - return glut_functions[i].address; - } - -#if DIRECTFBGL_INTERFACE_VERSION >= 1 - if (g_current) { - void *address = NULL; - g_current->gl->GetProcAddress( g_current->gl, name, &address ); - return address; - } -#endif - return NULL; -} - - -int GLUTAPIENTRY -glutExtensionSupported( const char *name ) -{ - GLubyte *extensions; - int length; - - if (!name || !*name) - return 0; - - length = strlen( name ); - extensions = (GLubyte*) glGetString( GL_EXTENSIONS ); - - while (extensions && *extensions) { - GLubyte *next; - - next = strchr( extensions, ' ' ); - if (next) { - if (length == (int)(next - extensions)) { - if (!strncmp( extensions, name, length )) - return 1; - } - extensions = next+1; - } - else { - if (!strcmp( extensions, name )) - return 1; - break; - } - } - - return 0; -} - diff --git a/src/glut/directfb/font.c b/src/glut/directfb/font.c deleted file mode 100644 index 0139cddbec..0000000000 --- a/src/glut/directfb/font.c +++ /dev/null @@ -1,213 +0,0 @@ -/* Copyright (c) Mark J. Kilgard, 1994, 1998. - - This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or - implied. This program is -not- in the public domain. */ - -#include "internal.h" -#include "font.h" - - -#if defined(_WIN32) || defined (GLUT_IMPORT_LIB) - -static inline void* -__glutFont( void *font ) -{ - switch((long)font) { - case (long)GLUT_STROKE_ROMAN: - return &glutStrokeRoman; - case (long)GLUT_STROKE_MONO_ROMAN: - return &glutStrokeMonoRoman; - case (long)GLUT_BITMAP_9_BY_15: - return &glutBitmap9By15; - case (long)GLUT_BITMAP_8_BY_13: - return &glutBitmap8By13; - case (long)GLUT_BITMAP_TIMES_ROMAN_10: - return &glutBitmapTimesRoman10; - case (long)GLUT_BITMAP_TIMES_ROMAN_24: - return &glutBitmapTimesRoman24; - case (long)GLUT_BITMAP_HELVETICA_10: - return &glutBitmapHelvetica10; - case (long)GLUT_BITMAP_HELVETICA_12: - return &glutBitmapHelvetica12; - case (long)GLUT_BITMAP_HELVETICA_18: - return &glutBitmapHelvetica18; - } - - return NULL; -} - -#else - -static inline void* -__glutFont( void *font ) -{ - return font; -} - -#endif - - -void GLUTAPIENTRY -glutBitmapCharacter( GLUTbitmapFont font, int c ) -{ - const BitmapCharRec *ch; - BitmapFontPtr fontinfo; - GLint swapbytes, lsbfirst, rowlength; - GLint skiprows, skippixels, alignment; - - fontinfo = (BitmapFontPtr) __glutFont( font ); - - if (!fontinfo || c < fontinfo->first || - c >= fontinfo->first + fontinfo->num_chars) - return; - - ch = fontinfo->ch[c - fontinfo->first]; - if (ch) { - /* Save current modes. */ - glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes); - glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst); - glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength); - glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows); - glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels); - glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); - /* Little endian machines (DEC Alpha for example) could - benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE - instead of GL_FALSE, but this would require changing the - generated bitmaps too. */ - glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); - glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glBitmap(ch->width, ch->height, ch->xorig, ch->yorig, - ch->advance, 0, ch->bitmap); - /* Restore saved modes. */ - glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes); - glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst); - glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength); - glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels); - glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); - } -} - - -int GLUTAPIENTRY -glutBitmapWidth( GLUTbitmapFont font, int c ) -{ - BitmapFontPtr fontinfo; - const BitmapCharRec *ch; - - fontinfo = (BitmapFontPtr) __glutFont( font ); - - if (!fontinfo || c < fontinfo->first || - c >= fontinfo->first + fontinfo->num_chars) - return 0; - - ch = fontinfo->ch[c - fontinfo->first]; - if (ch) - return ch->advance; - - return 0; -} - - -int GLUTAPIENTRY -glutBitmapLength( GLUTbitmapFont font, const unsigned char *string ) -{ - int c, length; - BitmapFontPtr fontinfo; - const BitmapCharRec *ch; - - fontinfo = (BitmapFontPtr) __glutFont( font ); - if (!fontinfo) - return 0; - - for (length = 0; *string != '\0'; string++) { - c = *string; - if (c >= fontinfo->first && - c < fontinfo->first + fontinfo->num_chars) { - ch = fontinfo->ch[c - fontinfo->first]; - if (ch) - length += ch->advance; - } - } - - return length; -} - - -void GLUTAPIENTRY -glutStrokeCharacter( GLUTstrokeFont font, int c ) -{ - const StrokeCharRec *ch; - const StrokeRec *stroke; - const CoordRec *coord; - StrokeFontPtr fontinfo; - int i, j; - - fontinfo = (StrokeFontPtr) __glutFont( font ); - - if (!fontinfo || c < 0 || c >= fontinfo->num_chars) - return; - - ch = &(fontinfo->ch[c]); - if (ch) { - for (i = ch->num_strokes, stroke = ch->stroke; - i > 0; i--, stroke++) { - glBegin(GL_LINE_STRIP); - for (j = stroke->num_coords, coord = stroke->coord; - j > 0; j--, coord++) { - glVertex2f(coord->x, coord->y); - } - glEnd(); - } - glTranslatef(ch->right, 0.0, 0.0); - } -} - - -int GLUTAPIENTRY -glutStrokeWidth( GLUTstrokeFont font, int c ) -{ - StrokeFontPtr fontinfo; - const StrokeCharRec *ch; - - fontinfo = (StrokeFontPtr) __glutFont( font ); - - if (!fontinfo || c < 0 || c >= fontinfo->num_chars) - return 0; - - ch = &(fontinfo->ch[c]); - if (ch) - return ch->right; - - return 0; -} - - -int GLUTAPIENTRY -glutStrokeLength( GLUTstrokeFont font, const unsigned char *string ) -{ - int c, length; - StrokeFontPtr fontinfo; - const StrokeCharRec *ch; - - fontinfo = (StrokeFontPtr) __glutFont( font ); - if (!fontinfo) - return 0; - - for (length = 0; *string != '\0'; string++) { - c = *string; - if (c >= 0 && c < fontinfo->num_chars) { - ch = &(fontinfo->ch[c]); - if (ch) - length += ch->right; - } - } - - return length; -} - diff --git a/src/glut/directfb/font.h b/src/glut/directfb/font.h deleted file mode 100644 index b1e76838a0..0000000000 --- a/src/glut/directfb/font.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) Mark J. Kilgard, 1994, 1998. */ - -/* This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or - implied. This program is -not- in the public domain. */ - -#ifndef __GLUT_FONT_H__ -#define __GLUT_FONT_H__ - - -typedef struct { - const GLsizei width; - const GLsizei height; - const GLfloat xorig; - const GLfloat yorig; - const GLfloat advance; - const GLubyte *bitmap; -} BitmapCharRec, *BitmapCharPtr; - -typedef struct { - const char *name; - const int num_chars; - const int first; - const BitmapCharRec * const *ch; -} BitmapFontRec, *BitmapFontPtr; - -typedef void *GLUTbitmapFont; - - -typedef struct { - float x; - float y; -} CoordRec, *CoordPtr; - -typedef struct { - int num_coords; - const CoordRec *coord; -} StrokeRec, *StrokePtr; - -typedef struct { - int num_strokes; - const StrokeRec *stroke; - float center; - float right; -} StrokeCharRec, *StrokeCharPtr; - -typedef struct { - const char *name; - int num_chars; - const StrokeCharRec *ch; - float top; - float bottom; -} StrokeFontRec, *StrokeFontPtr; - -typedef void *GLUTstrokeFont; - - -#endif /* __GLUT_FONT_H__ */ diff --git a/src/glut/directfb/game.c b/src/glut/directfb/game.c deleted file mode 100644 index 4c027a68f6..0000000000 --- a/src/glut/directfb/game.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "internal.h" - - -/*****************************************************************************/ - -static int g_display_changed = 0; - -/*****************************************************************************/ - - -void GLUTAPIENTRY -glutGameModeString( const char *string ) -{ - int x, y, bpp; - char *tmp; - - if (!string) - return; - - tmp = strchr( string, 'x' ); - if (tmp) { - x = strtol( string, NULL, 10 ); - y = strtol( tmp+1, NULL, 10 ); - - if (x > 0 && y > 0) { - g_width = x; - g_height = y; - } - } - - tmp = strchr( string, ':' ); - if (tmp) { - bpp = strtol( tmp+1, NULL, 10 ); - - if (bpp > 0) - g_bpp = bpp; - } -} - - -int GLUTAPIENTRY -glutEnterGameMode( void ) -{ - DFBDisplayLayerConfig prev, cur; - - glutInit( NULL, NULL ); - - primary->GetConfiguration( primary, &prev ); - primary->SetCooperativeLevel( primary, DLSCL_EXCLUSIVE ); - - if (g_game) - __glutDestroyWindow( g_game ); - - g_game = __glutCreateWindow( GL_TRUE ); - if (!g_game) - return 0; - - __glutSetWindow( g_game ); - g_game->cursor = GLUT_CURSOR_NONE; - - primary->GetConfiguration( primary, &cur ); - g_display_changed = (cur.width != prev.width || - cur.height != prev.height || - cur.pixelformat != prev.pixelformat); - - return g_game->id; -} - - -void GLUTAPIENTRY -glutLeaveGameMode( void ) -{ - if (g_game) - __glutDestroyWindow( g_game ); - - primary->SetCooperativeLevel( primary, DLSCL_ADMINISTRATIVE ); -} - - -int GLUTAPIENTRY -glutGameModeGet( GLenum type ) -{ - switch (type) { - case GLUT_GAME_MODE_ACTIVE: - return (g_game != NULL); - case GLUT_GAME_MODE_POSSIBLE: - if (primary) { - DFBDisplayLayerConfig c; - c.flags = DLCONF_WIDTH | DLCONF_HEIGHT; - c.width = g_width; - c.height = g_height; - /* XXX: bpp */ - if (primary->TestConfiguration( primary, &c, 0 ) == DFB_OK) - return 1; - } - break; - case GLUT_GAME_MODE_WIDTH: - if (g_game) { - int w; - g_game->surface->GetSize( g_game->surface, &w, 0 ); - return w; - } - break; - case GLUT_GAME_MODE_HEIGHT: - if (g_game) { - int h; - g_game->surface->GetSize( g_game->surface, 0, &h ); - return h; - } - break; - case GLUT_GAME_MODE_PIXEL_DEPTH: - if (g_game) { - DFBSurfacePixelFormat f; - g_game->surface->GetPixelFormat( g_game->surface, &f ); - return DFB_COLOR_BITS_PER_PIXEL( f ); - } - break; - case GLUT_GAME_MODE_REFRESH_RATE: - return 60; /* assume 60hz */ - case GLUT_GAME_MODE_DISPLAY_CHANGED: - return g_display_changed; - default: - break; - } - - return 0; -} - - - diff --git a/src/glut/directfb/globals.c b/src/glut/directfb/globals.c deleted file mode 100644 index 2a5291137e..0000000000 --- a/src/glut/directfb/globals.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "internal.h" - -IDirectFB *dfb = NULL; -IDirectFBDisplayLayer *primary = NULL; -IDirectFBEventBuffer *events = NULL; -IDirectFBInputDevice *keyboard = NULL; -IDirectFBInputDevice *mouse = NULL; -IDirectFBInputDevice *joystick = NULL; - -GLenum g_display_mode = 0; -GLuint g_width = DEFAULT_WIDTH; -GLuint g_height = DEFAULT_HEIGHT; -GLint g_xpos = 0; -GLint g_ypos = 0; -GLint g_bpp = 0; -GLboolean g_idle = GL_TRUE; -__GlutWindow *g_current = NULL; -__GlutWindow *g_game = NULL; - - -void (GLUTCALLBACK *display_func) (void) = 0; -void (GLUTCALLBACK *reshape_func) (int width, int height) = 0; -void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y) = 0; -void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y) = 0; -void (GLUTCALLBACK *motion_func) (int x, int y) = 0; -void (GLUTCALLBACK *passive_motion_func) (int x, int y) = 0; -void (GLUTCALLBACK *entry_func) (int state) = 0; -void (GLUTCALLBACK *visibility_func) (int state) = 0; -void (GLUTCALLBACK *idle_func) (void) = 0; -void (GLUTCALLBACK *menu_state_func) (int state) = 0; -void (GLUTCALLBACK *special_func) (int key, int x, int y) = 0; -void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z) = 0; -void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z) = 0; -void (GLUTCALLBACK *spaceball_button_func) (int button, int state) = 0; -void (GLUTCALLBACK *button_box_func) (int button, int state) = 0; -void (GLUTCALLBACK *dials_func) (int dial, int value) = 0; -void (GLUTCALLBACK *tablet_motion_func) (int x, int y) = 0; -void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y) = 0; -void (GLUTCALLBACK *menu_status_func) (int status, int x, int y) = 0; -void (GLUTCALLBACK *overlay_display_func) (void) = 0; -void (GLUTCALLBACK *window_status_func) (int state) = 0; -void (GLUTCALLBACK *keyboard_up_func) (unsigned char key, int x, int y) = 0; -void (GLUTCALLBACK *special_up_func) (int key, int x, int y) = 0; -void (GLUTCALLBACK *joystick_func) (unsigned int buttons, int x, int y, int z) = 0; diff --git a/src/glut/directfb/init.c b/src/glut/directfb/init.c deleted file mode 100644 index ba1a49adf2..0000000000 --- a/src/glut/directfb/init.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "internal.h" - - -static void -__glutExit( void ) -{ - __glutFreeTimers(); - __glutDestroyWindows(); - - if (events) { - events->Release( events ); - events = NULL; - } - - if (joystick) { - joystick->Release( joystick ); - joystick = NULL; - } - - if (mouse) { - mouse->Release( mouse ); - mouse = NULL; - } - - if (keyboard) { - keyboard->Release( keyboard ); - keyboard = NULL; - } - - if (primary) { - primary->Release( primary ); - primary = NULL; - } - - if (dfb) { - dfb->Release( dfb ); - dfb = NULL; - } -} - - -void GLUTAPIENTRY -glutInit( int *argcp, char **argv ) -{ - DFBResult ret; - - if (dfb) - return; - - glutGet( GLUT_ELAPSED_TIME ); - - ret = DirectFBInit( argcp, argv ? &argv : NULL ); - if (ret) - DirectFBErrorFatal( "DirectFBInit()", ret ); - - ret = DirectFBCreate( &dfb ); - if (ret) - DirectFBErrorFatal( "DirectFBCreate()", ret ); - - ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &primary ); - if (ret) - DirectFBErrorFatal( "IDirectFB::GetDisplayLayer()", ret ); - - ret = dfb->CreateEventBuffer( dfb, &events ); - if (ret) - DirectFBErrorFatal( "IDirectFB::CreateEventBuffer()", ret ); - - dfb->GetInputDevice( dfb, DIDID_KEYBOARD, &keyboard ); - dfb->GetInputDevice( dfb, DIDID_MOUSE, &mouse ); - dfb->GetInputDevice( dfb, DIDID_JOYSTICK, &joystick ); - - primary->SetCooperativeLevel( primary, DLSCL_ADMINISTRATIVE ); - - atexit( __glutExit ); -} - - -void GLUTAPIENTRY -glutInitDisplayMode( unsigned int mode ) -{ - g_display_mode = mode; -} - - -void GLUTAPIENTRY -glutInitWindowPosition( int x, int y ) -{ - g_xpos = x; - g_ypos = y; -} - - -void GLUTAPIENTRY -glutInitWindowSize( int width, int height ) -{ - g_width = width; - g_height = height; -} - - -void GLUTAPIENTRY -glutInitDisplayString( const char *string ) -{ -} - diff --git a/src/glut/directfb/internal.h b/src/glut/directfb/internal.h deleted file mode 100644 index 55c4b5ce28..0000000000 --- a/src/glut/directfb/internal.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef __GLUT_INTERNAL_H__ -#define __GLUT_INTERNAL_H__ - -#include -#include - -#include -#include - -#include - -#include "GL/glut.h" - - -#define VERSION_CODE( M, m, r ) (((M) << 16) | ((m) << 8) | ((r))) - -#define DIRECTFB_VERSION_CODE VERSION_CODE( DIRECTFB_MAJOR_VERSION, \ - DIRECTFB_MINOR_VERSION, \ - DIRECTFB_MICRO_VERSION ) - - -#define DEFAULT_WIDTH 640 -#define DEFAULT_HEIGHT 480 - -/* - * Window request flags - */ -#define WINDOW_REQUEST_POSITION 0x00000001 -#define WINDOW_REQUEST_RESIZE 0x00000002 -#define WINDOW_REQUEST_RESTACK 0x00000004 -#define WINDOW_REQUEST_SHOW 0x00000008 -#define WINDOW_REQUEST_HIDE 0x00000010 -#define WINDOW_REQUEST_DESTROY 0x00000020 - -/* - * GLUT Window implementation - */ -typedef struct __GlutWindow_s { - int id; - DFBWindowID wid; - - IDirectFBWindow *window; /* NULL = fullscreen (game mode) */ - IDirectFBSurface *surface; - IDirectFBGL *gl; - - /* display mode */ - GLenum mode; - - /* cursor position in fullscreen mode */ - int cx; - int cy; - /* joystick position */ - int jx; - int jy; - int jz; - /* pressed modifiers */ - int modifiers; - /* pressed buttons */ - int buttons; - /* current cursor shape */ - int cursor; - - struct { - int flags; - int x; - int y; - int w; - int h; - int z; - } req; - - GLboolean visible; - GLboolean redisplay; - GLboolean reshape; - GLboolean visibility; - - struct __GlutWindow_s *next; - struct __GlutWindow_s *prev; -} __GlutWindow; - - -/* Global Vars */ -extern IDirectFB *dfb; -extern IDirectFBDisplayLayer *primary; -extern IDirectFBEventBuffer *events; -extern IDirectFBInputDevice *keyboard; -extern IDirectFBInputDevice *mouse; -extern IDirectFBInputDevice *joystick; - -extern GLenum g_display_mode; -extern GLuint g_width; -extern GLuint g_height; -extern GLint g_xpos; -extern GLint g_ypos; -extern GLint g_bpp; -extern GLboolean g_idle; -extern __GlutWindow *g_current; -extern __GlutWindow *g_game; - - -/* Global Funcs */ -/* window.c */ -extern __GlutWindow* __glutCreateWindow( GLboolean fullscreen ); -extern __GlutWindow* __glutFindWindow( DFBWindowID id ); -extern void __glutSetWindow( __GlutWindow *window ); -extern void __glutHandleWindows( void ); -extern void __glutDestroyWindow( __GlutWindow *window ); -extern void __glutDestroyWindows( void ); -/* callback.c */ -extern void __glutHandleTimers( void ); -extern GLboolean __glutGetTimeout( int *ret_msec ); -extern void __glutFreeTimers( void ); - - -/* Global Callbacks */ -extern void (GLUTCALLBACK *display_func) (void); -extern void (GLUTCALLBACK *reshape_func) (int width, int height); -extern void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y); -extern void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y); -extern void (GLUTCALLBACK *motion_func) (int x, int y); -extern void (GLUTCALLBACK *passive_motion_func) (int x, int y); -extern void (GLUTCALLBACK *entry_func) (int state); -extern void (GLUTCALLBACK *visibility_func) (int state); -extern void (GLUTCALLBACK *idle_func) (void); -extern void (GLUTCALLBACK *menu_state_func) (int state); -extern void (GLUTCALLBACK *special_func) (int key, int x, int y); -extern void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z); -extern void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z); -extern void (GLUTCALLBACK *spaceball_button_func) (int button, int state); -extern void (GLUTCALLBACK *button_box_func) (int button, int state); -extern void (GLUTCALLBACK *dials_func) (int dial, int value); -extern void (GLUTCALLBACK *tablet_motion_func) (int x, int y); -extern void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y); -extern void (GLUTCALLBACK *menu_status_func) (int status, int x, int y); -extern void (GLUTCALLBACK *overlay_display_func) (void); -extern void (GLUTCALLBACK *window_status_func) (int state); -extern void (GLUTCALLBACK *keyboard_up_func) (unsigned char key, int x, int y); -extern void (GLUTCALLBACK *special_up_func) (int key, int x, int y); -extern void (GLUTCALLBACK *joystick_func) (unsigned int buttons, int x, int y, int z); - - -#ifdef DEBUG -# define __glutAssert( exp ) {\ - if (!(exp)) {\ - fprintf( stderr, "(!!) *** Assertion [%s] failed in %s() ***\n",\ - #exp, __FUNCTION__ ); - fflush( stderr );\ - exit( -1 );\ - }\ - } -#else -# define __glutAssert( exp ) -#endif - -#define __glutWarning( format, ... ) {\ - fprintf( stderr, "(!) GLUT: " format "!\n", ## __VA_ARGS__ );\ - fflush( stderr );\ -} - -#define __glutFatalError( format, ... ) {\ - fprintf( stderr, "(!) GLUT: " format "!\n", ## __VA_ARGS__ );\ - fprintf( stderr, "\t-> from %s() at line %d\n", __FUNCTION__, __LINE__ );\ - fflush( stderr );\ - exit( -1 );\ -} - - -#endif /* __GLUT_INTERNAL_H__ */ - diff --git a/src/glut/directfb/menu.c b/src/glut/directfb/menu.c deleted file mode 100644 index 400e966bbb..0000000000 --- a/src/glut/directfb/menu.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "internal.h" - - -int GLUTAPIENTRY -glutCreateMenu( void (GLUTCALLBACK *func) (int) ) -{ - return 0; -} - -void GLUTAPIENTRY -glutDestroyMenu( int menu ) -{ -} - - -int GLUTAPIENTRY -glutGetMenu( void ) -{ - return 0; -} - - -void GLUTAPIENTRY -glutSetMenu( int menu ) -{ -} - - -void GLUTAPIENTRY -glutAddMenuEntry( const char *label, int value ) -{ -} - - -void GLUTAPIENTRY -glutAddSubMenu( const char *label, int submenu ) -{ -} - - -void GLUTAPIENTRY -glutChangeToMenuEntry( int item, const char *label, int value ) -{ -} - - -void GLUTAPIENTRY -glutChangeToSubMenu( int item, const char *label, int submenu ) -{ -} - - -void GLUTAPIENTRY -glutRemoveMenuItem( int item ) -{ -} - - -void GLUTAPIENTRY -glutAttachMenu( int button ) -{ -} - - -void GLUTAPIENTRY -glutDetachMenu( int button ) -{ -} diff --git a/src/glut/directfb/models.c b/src/glut/directfb/models.c deleted file mode 100644 index d96a8f5077..0000000000 --- a/src/glut/directfb/models.c +++ /dev/null @@ -1,599 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994, 1997. */ - -/** -(c) Copyright 1993, Silicon Graphics, Inc. - -ALL RIGHTS RESERVED - -Permission to use, copy, modify, and distribute this software -for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that -both the copyright notice and this permission notice appear in -supporting documentation, and that the name of Silicon -Graphics, Inc. not be used in advertising or publicity -pertaining to distribution of the software without specific, -written prior permission. - -THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU -"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR -OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO -EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE -ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER, -INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE, -SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR -NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY -OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR -PERFORMANCE OF THIS SOFTWARE. - -US Government Users Restricted Rights - -Use, duplication, or disclosure by the Government is subject to -restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -(c)(1)(ii) of the Rights in Technical Data and Computer -Software clause at DFARS 252.227-7013 and/or in similar or -successor clauses in the FAR or the DOD or NASA FAR -Supplement. Unpublished-- rights reserved under the copyright -laws of the United States. Contractor/manufacturer is Silicon -Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA -94039-7311. - -OpenGL(TM) is a trademark of Silicon Graphics, Inc. -*/ - -#include -#include -#include - -#include "internal.h" - -/* Some files do not define M_PI... */ -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -static GLUquadricObj *quadObj; - -#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); } - -static void -initQuadObj(void) -{ - quadObj = gluNewQuadric(); - if (!quadObj) - __glutFatalError("out of memory"); -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireSphere(GLdouble radius, GLint slices, GLint stacks) -{ - QUAD_OBJ_INIT(); - gluQuadricDrawStyle(quadObj, GLU_LINE); - gluQuadricNormals(quadObj, GLU_SMOOTH); - /* If we ever changed/used the texture or orientation state - of quadObj, we'd need to change it to the defaults here - with gluQuadricTexture and/or gluQuadricOrientation. */ - gluSphere(quadObj, radius, slices, stacks); -} - -void GLUTAPIENTRY -glutSolidSphere(GLdouble radius, GLint slices, GLint stacks) -{ - QUAD_OBJ_INIT(); - gluQuadricDrawStyle(quadObj, GLU_FILL); - gluQuadricNormals(quadObj, GLU_SMOOTH); - /* If we ever changed/used the texture or orientation state - of quadObj, we'd need to change it to the defaults here - with gluQuadricTexture and/or gluQuadricOrientation. */ - gluSphere(quadObj, radius, slices, stacks); -} - -void GLUTAPIENTRY -glutWireCone(GLdouble base, GLdouble height, - GLint slices, GLint stacks) -{ - QUAD_OBJ_INIT(); - gluQuadricDrawStyle(quadObj, GLU_LINE); - gluQuadricNormals(quadObj, GLU_SMOOTH); - /* If we ever changed/used the texture or orientation state - of quadObj, we'd need to change it to the defaults here - with gluQuadricTexture and/or gluQuadricOrientation. */ - gluCylinder(quadObj, base, 0.0, height, slices, stacks); -} - -void GLUTAPIENTRY -glutSolidCone(GLdouble base, GLdouble height, - GLint slices, GLint stacks) -{ - QUAD_OBJ_INIT(); - gluQuadricDrawStyle(quadObj, GLU_FILL); - gluQuadricNormals(quadObj, GLU_SMOOTH); - /* If we ever changed/used the texture or orientation state - of quadObj, we'd need to change it to the defaults here - with gluQuadricTexture and/or gluQuadricOrientation. */ - gluCylinder(quadObj, base, 0.0, height, slices, stacks); -} - -/* ENDCENTRY */ - -static void -drawBox(GLfloat size, GLenum type) -{ - static GLfloat n[6][3] = - { - {-1.0, 0.0, 0.0}, - {0.0, 1.0, 0.0}, - {1.0, 0.0, 0.0}, - {0.0, -1.0, 0.0}, - {0.0, 0.0, 1.0}, - {0.0, 0.0, -1.0} - }; - static GLint faces[6][4] = - { - {0, 1, 2, 3}, - {3, 2, 6, 7}, - {7, 6, 5, 4}, - {4, 5, 1, 0}, - {5, 6, 2, 1}, - {7, 4, 0, 3} - }; - GLfloat v[8][3]; - GLint i; - - v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2; - v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2; - v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2; - v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2; - v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2; - v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2; - - for (i = 5; i >= 0; i--) { - glBegin(type); -/* glNormal3fv(&n[i][0]); */ - glVertex3fv(&v[faces[i][0]][0]); - glVertex3fv(&v[faces[i][1]][0]); - glVertex3fv(&v[faces[i][2]][0]); - glVertex3fv(&v[faces[i][3]][0]); - glEnd(); - } -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireCube(GLdouble size) -{ - drawBox(size, GL_LINE_LOOP); -} - -void GLUTAPIENTRY -glutSolidCube(GLdouble size) -{ - drawBox(size, GL_QUADS); -} - -/* ENDCENTRY */ - -static void -doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings) -{ - int i, j; - GLfloat theta, phi, theta1; - GLfloat cosTheta, sinTheta; - GLfloat cosTheta1, sinTheta1; - GLfloat ringDelta, sideDelta; - - ringDelta = 2.0 * M_PI / rings; - sideDelta = 2.0 * M_PI / nsides; - - theta = 0.0; - cosTheta = 1.0; - sinTheta = 0.0; - for (i = rings - 1; i >= 0; i--) { - theta1 = theta + ringDelta; - cosTheta1 = cos(theta1); - sinTheta1 = sin(theta1); - glBegin(GL_QUAD_STRIP); - phi = 0.0; - for (j = nsides; j >= 0; j--) { - GLfloat cosPhi, sinPhi, dist; - - phi += sideDelta; - cosPhi = cos(phi); - sinPhi = sin(phi); - dist = R + r * cosPhi; - -/* glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); */ - glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); -/* glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); */ - glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi); - } - glEnd(); - theta = theta1; - cosTheta = cosTheta1; - sinTheta = sinTheta1; - } -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, - GLint nsides, GLint rings) -{ -/* glPushAttrib(GL_POLYGON_BIT); */ -/* glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); */ - doughnut(innerRadius, outerRadius, nsides, rings); -/* glPopAttrib(); */ -} - -void GLUTAPIENTRY -glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, - GLint nsides, GLint rings) -{ - doughnut(innerRadius, outerRadius, nsides, rings); -} - -/* ENDCENTRY */ - -static GLfloat dodec[20][3]; - -static void -initDodecahedron(void) -{ - GLfloat alpha, beta; - - alpha = sqrt(2.0 / (3.0 + sqrt(5.0))); - beta = 1.0 + sqrt(6.0 / (3.0 + sqrt(5.0)) - - 2.0 + 2.0 * sqrt(2.0 / (3.0 + sqrt(5.0)))); - /* *INDENT-OFF* */ - dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta; - dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta; - dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1; - dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1; - dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1; - dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1; - dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1; - dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1; - dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1; - dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1; - dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0; - dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0; - dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0; - dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0; - dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta; - dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta; - dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha; - dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha; - dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha; - dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha; - /* *INDENT-ON* */ - -} - -#define DIFF3(_a,_b,_c) { \ - (_c)[0] = (_a)[0] - (_b)[0]; \ - (_c)[1] = (_a)[1] - (_b)[1]; \ - (_c)[2] = (_a)[2] - (_b)[2]; \ -} - -static void -crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3]) -{ - GLfloat p[3]; /* in case prod == v1 or v2 */ - - p[0] = v1[1] * v2[2] - v2[1] * v1[2]; - p[1] = v1[2] * v2[0] - v2[2] * v1[0]; - p[2] = v1[0] * v2[1] - v2[0] * v1[1]; - prod[0] = p[0]; - prod[1] = p[1]; - prod[2] = p[2]; -} - -static void -normalize(GLfloat v[3]) -{ - GLfloat d; - - d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); - if (d == 0.0) { -/* __glutWarning("normalize: zero length vector"); */ - v[0] = d = 1.0; - } - d = 1 / d; - v[0] *= d; - v[1] *= d; - v[2] *= d; -} - -static void -pentagon(int a, int b, int c, int d, int e, GLenum shadeType) -{ - GLfloat n0[3], d1[3], d2[3]; - - DIFF3(dodec[a], dodec[b], d1); - DIFF3(dodec[b], dodec[c], d2); - crossprod(d1, d2, n0); - normalize(n0); - - glBegin(shadeType); -/* glNormal3fv(n0); */ - glVertex3fv(&dodec[a][0]); - glVertex3fv(&dodec[b][0]); - glVertex3fv(&dodec[c][0]); - glVertex3fv(&dodec[d][0]); - glVertex3fv(&dodec[e][0]); - glEnd(); -} - -static void -dodecahedron(GLenum type) -{ - static int inited = 0; - - if (inited == 0) { - inited = 1; - initDodecahedron(); - } - pentagon(0, 1, 9, 16, 5, type); - pentagon(1, 0, 3, 18, 7, type); - pentagon(1, 7, 11, 10, 9, type); - pentagon(11, 7, 18, 19, 6, type); - pentagon(8, 17, 16, 9, 10, type); - pentagon(2, 14, 15, 6, 19, type); - pentagon(2, 13, 12, 4, 14, type); - pentagon(2, 19, 18, 3, 13, type); - pentagon(3, 0, 5, 12, 13, type); - pentagon(6, 15, 8, 10, 11, type); - pentagon(4, 17, 8, 15, 14, type); - pentagon(4, 12, 5, 16, 17, type); -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireDodecahedron(void) -{ - dodecahedron(GL_LINE_LOOP); -} - -void GLUTAPIENTRY -glutSolidDodecahedron(void) -{ - dodecahedron(GL_TRIANGLE_FAN); -} - -/* ENDCENTRY */ - -static void -recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3, - GLenum shadeType) -{ - GLfloat q0[3], q1[3]; - - DIFF3(n1, n2, q0); - DIFF3(n2, n3, q1); - crossprod(q0, q1, q1); - normalize(q1); - - glBegin(shadeType); -/* glNormal3fv(q1); */ - glVertex3fv(n1); - glVertex3fv(n2); - glVertex3fv(n3); - glEnd(); -} - -static void -subdivide(GLfloat * v0, GLfloat * v1, GLfloat * v2, - GLenum shadeType) -{ - int depth; - GLfloat w0[3], w1[3], w2[3]; - GLfloat l; - int i, j, k, n; - - depth = 1; - for (i = 0; i < depth; i++) { - for (j = 0; i + j < depth; j++) { - k = depth - i - j; - for (n = 0; n < 3; n++) { - w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth; - w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n]) - / depth; - w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n]) - / depth; - } - l = sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]); - w0[0] /= l; - w0[1] /= l; - w0[2] /= l; - l = sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]); - w1[0] /= l; - w1[1] /= l; - w1[2] /= l; - l = sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]); - w2[0] /= l; - w2[1] /= l; - w2[2] /= l; - recorditem(w1, w0, w2, shadeType); - } - } -} - -static void -drawtriangle(int i, GLfloat data[][3], int ndx[][3], - GLenum shadeType) -{ - GLfloat *x0, *x1, *x2; - - x0 = data[ndx[i][0]]; - x1 = data[ndx[i][1]]; - x2 = data[ndx[i][2]]; - subdivide(x0, x1, x2, shadeType); -} - -/* octahedron data: The octahedron produced is centered at the - origin and has radius 1.0 */ -static GLfloat odata[6][3] = -{ - {1.0, 0.0, 0.0}, - {-1.0, 0.0, 0.0}, - {0.0, 1.0, 0.0}, - {0.0, -1.0, 0.0}, - {0.0, 0.0, 1.0}, - {0.0, 0.0, -1.0} -}; - -static int ondex[8][3] = -{ - {0, 4, 2}, - {1, 2, 4}, - {0, 3, 4}, - {1, 4, 3}, - {0, 2, 5}, - {1, 5, 2}, - {0, 5, 3}, - {1, 3, 5} -}; - -static void -octahedron(GLenum shadeType) -{ - int i; - - for (i = 7; i >= 0; i--) { - drawtriangle(i, odata, ondex, shadeType); - } -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireOctahedron(void) -{ - octahedron(GL_LINE_LOOP); -} - -void GLUTAPIENTRY -glutSolidOctahedron(void) -{ - octahedron(GL_TRIANGLES); -} - -/* ENDCENTRY */ - -/* icosahedron data: These numbers are rigged to make an - icosahedron of radius 1.0 */ - -#define X .525731112119133606 -#define Z .850650808352039932 - -static GLfloat idata[12][3] = -{ - {-X, 0, Z}, - {X, 0, Z}, - {-X, 0, -Z}, - {X, 0, -Z}, - {0, Z, X}, - {0, Z, -X}, - {0, -Z, X}, - {0, -Z, -X}, - {Z, X, 0}, - {-Z, X, 0}, - {Z, -X, 0}, - {-Z, -X, 0} -}; - -static int index[20][3] = -{ - {0, 4, 1}, - {0, 9, 4}, - {9, 5, 4}, - {4, 5, 8}, - {4, 8, 1}, - {8, 10, 1}, - {8, 3, 10}, - {5, 3, 8}, - {5, 2, 3}, - {2, 7, 3}, - {7, 10, 3}, - {7, 6, 10}, - {7, 11, 6}, - {11, 0, 6}, - {0, 1, 6}, - {6, 1, 10}, - {9, 0, 11}, - {9, 11, 2}, - {9, 2, 5}, - {7, 2, 11}, -}; - -static void -icosahedron(GLenum shadeType) -{ - int i; - - for (i = 19; i >= 0; i--) { - drawtriangle(i, idata, index, shadeType); - } -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireIcosahedron(void) -{ - icosahedron(GL_LINE_LOOP); -} - -void GLUTAPIENTRY -glutSolidIcosahedron(void) -{ - icosahedron(GL_TRIANGLES); -} - -/* ENDCENTRY */ - -/* tetrahedron data: */ - -#define T 1.73205080756887729 - -static GLfloat tdata[4][3] = -{ - {T, T, T}, - {T, -T, -T}, - {-T, T, -T}, - {-T, -T, T} -}; - -static int tndex[4][3] = -{ - {0, 1, 3}, - {2, 1, 0}, - {3, 2, 0}, - {1, 2, 3} -}; - -static void -tetrahedron(GLenum shadeType) -{ - int i; - - for (i = 3; i >= 0; i--) - drawtriangle(i, tdata, tndex, shadeType); -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireTetrahedron(void) -{ - tetrahedron(GL_LINE_LOOP); -} - -void GLUTAPIENTRY -glutSolidTetrahedron(void) -{ - tetrahedron(GL_TRIANGLES); -} - -/* ENDCENTRY */ diff --git a/src/glut/directfb/overlay.c b/src/glut/directfb/overlay.c deleted file mode 100644 index 714be5f1a2..0000000000 --- a/src/glut/directfb/overlay.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "internal.h" - - -void GLUTAPIENTRY -glutEstablishOverlay( void ) -{ -} - - -void GLUTAPIENTRY -glutRemoveOverlay( void ) -{ -} - - -void GLUTAPIENTRY -glutUseLayer( GLenum layer ) -{ -} - - -void GLUTAPIENTRY -glutPostOverlayRedisplay( void ) -{ -} - - -void GLUTAPIENTRY -glutPostWindowOverlayRedisplay( int win ) -{ -} - - -void GLUTAPIENTRY -glutShowOverlay( void ) -{ -} - - -void GLUTAPIENTRY -glutHideOverlay( void ) -{ -} diff --git a/src/glut/directfb/state.c b/src/glut/directfb/state.c deleted file mode 100644 index 194d5bbb62..0000000000 --- a/src/glut/directfb/state.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "GL/glu.h" - -#include "internal.h" - - -int GLUTAPIENTRY -glutGet( GLenum type ) -{ - switch (type) { - case GLUT_WINDOW_X: - if (g_current && g_current->window) { - int x; - g_current->window->GetPosition( g_current->window, &x, 0 ); - return x; - } - break; - case GLUT_WINDOW_Y: - if (g_current && g_current->window) { - int y; - g_current->window->GetPosition( g_current->window, 0, &y ); - return y; - } - break; - - case GLUT_WINDOW_WIDTH: - if (g_current) { - int w; - g_current->surface->GetSize( g_current->surface, &w, 0 ); - return w; - } - break; - case GLUT_WINDOW_HEIGHT: - if (g_current) { - int h; - g_current->surface->GetSize( g_current->surface, 0, &h ); - return h; - } - break; - - case GLUT_WINDOW_BUFFER_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.buffer_size; - } - break; - case GLUT_WINDOW_STENCIL_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.stencil_size; - } - break; - case GLUT_WINDOW_DEPTH_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.depth_size; - } - break; - case GLUT_WINDOW_RED_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.red_size; - } - break; - case GLUT_WINDOW_GREEN_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.green_size; - } - break; - case GLUT_WINDOW_BLUE_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.blue_size; - } - break; - case GLUT_WINDOW_ALPHA_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.alpha_size; - } - break; - case GLUT_WINDOW_ACCUM_RED_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.accum_red_size; - } - break; - case GLUT_WINDOW_ACCUM_GREEN_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.accum_green_size; - } - break; - case GLUT_WINDOW_ACCUM_BLUE_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.accum_blue_size; - } - break; - case GLUT_WINDOW_ACCUM_ALPHA_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.accum_alpha_size; - } - break; - case GLUT_WINDOW_DOUBLEBUFFER: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.double_buffer; - } - break; - - case GLUT_WINDOW_RGBA: - return 1; - - case GLUT_WINDOW_CURSOR: - if (g_current) - return g_current->cursor; - break; - - case GLUT_SCREEN_WIDTH: - if (primary) { - DFBDisplayLayerConfig c; - primary->GetConfiguration( primary, &c ); - return c.width; - } - break; - case GLUT_SCREEN_HEIGHT: - if (primary) { - DFBDisplayLayerConfig c; - primary->GetConfiguration( primary, &c ); - return c.height; - } - break; - - case GLUT_INIT_DISPLAY_MODE: - return g_display_mode; - case GLUT_INIT_WINDOW_X: - return g_xpos; - case GLUT_INIT_WINDOW_Y: - return g_ypos; - case GLUT_INIT_WINDOW_WIDTH: - return g_width; - case GLUT_INIT_WINDOW_HEIGHT: - return g_height; - - case GLUT_ELAPSED_TIME: - { - static long long start = -1; - struct timeval t; - - gettimeofday( &t, NULL ); - if (start == -1) { - start = t.tv_sec * 1000ll + t.tv_usec / 1000ll; - return 0; - } - return (t.tv_sec * 1000ll + t.tv_usec / 1000ll - start); - } - break; - - default: - break; - } - - return 0; -} - - -int GLUTAPIENTRY -glutLayerGet( GLenum type ) -{ - return 0; -} - -void GLUTAPIENTRY -glutReportErrors( void ) -{ - GLenum error; - - while ((error = glGetError()) != GL_NO_ERROR) - __glutWarning( "**OpenGL Error** %s", gluErrorString( error ) ); -} - - diff --git a/src/glut/directfb/teapot.c b/src/glut/directfb/teapot.c deleted file mode 100644 index e7f1ee812f..0000000000 --- a/src/glut/directfb/teapot.c +++ /dev/null @@ -1,212 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/** -(c) Copyright 1993, Silicon Graphics, Inc. - -ALL RIGHTS RESERVED - -Permission to use, copy, modify, and distribute this software -for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that -both the copyright notice and this permission notice appear in -supporting documentation, and that the name of Silicon -Graphics, Inc. not be used in advertising or publicity -pertaining to distribution of the software without specific, -written prior permission. - -THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU -"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR -OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO -EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE -ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER, -INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE, -SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR -NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY -OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR -PERFORMANCE OF THIS SOFTWARE. - -US Government Users Restricted Rights - -Use, duplication, or disclosure by the Government is subject to -restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -(c)(1)(ii) of the Rights in Technical Data and Computer -Software clause at DFARS 252.227-7013 and/or in similar or -successor clauses in the FAR or the DOD or NASA FAR -Supplement. Unpublished-- rights reserved under the copyright -laws of the United States. Contractor/manufacturer is Silicon -Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA -94039-7311. - -OpenGL(TM) is a trademark of Silicon Graphics, Inc. -*/ - -#include -#include -#include "GL/glut.h" - -/* Rim, body, lid, and bottom data must be reflected in x and - y; handle and spout data across the y axis only. */ - -static int patchdata[][16] = -{ - /* rim */ - {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15}, - /* body */ - {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27}, - {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40}, - /* lid */ - {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101, - 101, 0, 1, 2, 3,}, - {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112, - 113, 114, 115, 116, 117}, - /* bottom */ - {118, 118, 118, 118, 124, 122, 119, 121, 123, 126, - 125, 120, 40, 39, 38, 37}, - /* handle */ - {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56}, - {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 28, 65, 66, 67}, - /* spout */ - {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83}, - {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95} -}; -/* *INDENT-OFF* */ - -static float cpdata[][3] = -{ - {0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0, - -0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125}, - {0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375, - 0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375, - 2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84, - 2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875}, - {1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75, - 1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35}, - {0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2, - 0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12, - 0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225}, - {1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225}, - {1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0, - -1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5, - -0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3, - 2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0, - 2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0, - 2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8}, - {-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3, - -0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3, - 1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2, - -0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0, - 1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0, - 0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66, - 0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1}, - {2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7, - -0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0, - 2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375}, - {3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475}, - {3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4}, - {2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0, - 3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8, - 3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4, - -0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0, - 2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4, - 2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3, - 2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4}, - {0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425, - -0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425, - 0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075}, - {0.84, -1.5, 0.075} -}; - -static float tex[2][2][2] = -{ - { {0, 0}, - {1, 0}}, - { {0, 1}, - {1, 1}} -}; - -/* *INDENT-ON* */ - -static void -teapot(GLint grid, GLdouble scale, GLenum type) -{ - float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3]; - long i, j, k, l; - - glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - glEnable(GL_MAP2_VERTEX_3); - glEnable(GL_MAP2_TEXTURE_COORD_2); - glPushMatrix(); - glRotatef(270.0, 1.0, 0.0, 0.0); - glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale); - glTranslatef(0.0, 0.0, -1.5); - for (i = 0; i < 10; i++) { - for (j = 0; j < 4; j++) { - for (k = 0; k < 4; k++) { - for (l = 0; l < 3; l++) { - p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; - q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l]; - if (l == 1) - q[j][k][l] *= -1.0; - if (i < 6) { - r[j][k][l] = - cpdata[patchdata[i][j * 4 + (3 - k)]][l]; - if (l == 0) - r[j][k][l] *= -1.0; - s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; - if (l == 0) - s[j][k][l] *= -1.0; - if (l == 1) - s[j][k][l] *= -1.0; - } - } - } - } - glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, - &tex[0][0][0]); - glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, - &p[0][0][0]); - glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0); - glEvalMesh2(type, 0, grid, 0, grid); - glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, - &q[0][0][0]); - glEvalMesh2(type, 0, grid, 0, grid); - if (i < 6) { - glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, - &r[0][0][0]); - glEvalMesh2(type, 0, grid, 0, grid); - glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, - &s[0][0][0]); - glEvalMesh2(type, 0, grid, 0, grid); - } - } - glPopMatrix(); - glPopAttrib(); -} - -/* CENTRY */ -void GLUTAPIENTRY -glutSolidTeapot(GLdouble scale) -{ - teapot(7, scale, GL_FILL); -} - -void GLUTAPIENTRY -glutWireTeapot(GLdouble scale) -{ - teapot(10, scale, GL_LINE); -} - -/* ENDCENTRY */ diff --git a/src/glut/directfb/window.c b/src/glut/directfb/window.c deleted file mode 100644 index 62cf8bb33e..0000000000 --- a/src/glut/directfb/window.c +++ /dev/null @@ -1,597 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include -#include - -#include "internal.h" - - -/*****************************************************************************/ - -static __GlutWindow *g_stack = NULL; - -/*****************************************************************************/ - - -__GlutWindow* -__glutCreateWindow( GLboolean fullscreen ) -{ - __GlutWindow *new; - DFBResult ret; - static int curid = 1; - - new = calloc( 1, sizeof(__GlutWindow) ); - if (!new) - __glutFatalError( "out of memory" ); - - new->id = curid++; - - if (fullscreen) { - DFBDisplayLayerConfig config; - DFBDisplayLayerConfigFlags fail = 0; - - config.flags = DLCONF_WIDTH | DLCONF_HEIGHT | - DLCONF_BUFFERMODE; - config.width = g_width; - config.height = g_height; - - if (g_display_mode & GLUT_DOUBLE) - config.buffermode = DLBM_BACKVIDEO; - else - config.buffermode = DLBM_FRONTONLY; - - if (g_bpp) { - config.flags |= DLCONF_PIXELFORMAT; - - switch (g_bpp) { - case 8: - config.pixelformat = DSPF_RGB332; - break; - case 12: - config.pixelformat = DSPF_ARGB4444; - break; - case 15: - config.pixelformat = DSPF_ARGB1555; - break; - case 16: - config.pixelformat = DSPF_RGB16; - break; - case 24: - case 32: - config.pixelformat = DSPF_RGB32; - break; - default: - config.flags &= ~DLCONF_PIXELFORMAT; - break; - } - } - - primary->TestConfiguration( primary, &config, &fail ); - config.flags &= ~fail; - primary->SetConfiguration( primary, &config ); - - ret = primary->GetSurface( primary, &new->surface ); - if (ret) { - DirectFBError( "IDirectFBDisplayLayer::GetSurface()", ret ); - free( new ); - return NULL; - } - - ret = new->surface->GetGL( new->surface, &new->gl ); - if (ret) { - DirectFBError( "IDirectFBSurface::GetGL()", ret ); - new->surface->Release( new->surface ); - free( new ); - return NULL; - } - - events->Reset( events ); - if (keyboard) - keyboard->AttachEventBuffer( keyboard, events ); - if (mouse) - mouse->AttachEventBuffer( mouse, events ); - if (joystick) - joystick->AttachEventBuffer( joystick, events ); - - new->visible = GL_TRUE; - } - else { - DFBWindowDescription dsc; - - dsc.flags = DWDESC_CAPS | DWDESC_POSX | DWDESC_POSY | - DWDESC_WIDTH | DWDESC_HEIGHT; - dsc.caps = DWCAPS_NONE; - dsc.posx = g_xpos; - dsc.posy = g_ypos; - dsc.width = g_width; - dsc.height = g_height; - - if (g_display_mode & GLUT_DOUBLE) - dsc.caps |= DWCAPS_DOUBLEBUFFER; - if (g_display_mode & GLUT_ALPHA) - dsc.caps |= DWCAPS_ALPHACHANNEL; - - ret = primary->CreateWindow( primary, &dsc, &new->window ); - if (ret) { - DirectFBError( "IDirectFBDisplayLayer::CreateWindow()", ret ); - free( new ); - return NULL; - } - - new->window->GetID( new->window, &new->wid ); - - ret = new->window->GetSurface( new->window, &new->surface ); - if (ret) { - DirectFBError( "IDirectFBWindow::GetSurface()", ret ); - new->window->Release( new->window ); - free( new ); - return NULL; - } - - ret = new->surface->GetGL( new->surface, &new->gl ); - if (ret) { - DirectFBError( "IDirectFBSurface::GetGl()", ret ); - new->surface->Release( new->surface ); - new->window->Release( new->window ); - free( new ); - return NULL; - } - - new->window->AttachEventBuffer( new->window, events ); - /* enable only handled events */ - new->window->DisableEvents( new->window, DWET_ALL ); - new->window->EnableEvents( new->window, DWET_KEYDOWN | DWET_KEYUP | - DWET_BUTTONDOWN | DWET_BUTTONUP | - DWET_ENTER | DWET_LEAVE | - DWET_MOTION | DWET_SIZE ); - - new->req.flags |= WINDOW_REQUEST_SHOW; - } - - new->mode = g_display_mode; - - new->reshape = GL_TRUE; - new->visibility = GL_TRUE; - new->redisplay = GL_TRUE; - - if (g_stack) { - new->prev = g_stack->prev; - g_stack->prev->next = new; - g_stack->prev = new; - } - else { - new->prev = new; - g_stack = new; - } - - return new; -} - - -__GlutWindow* -__glutFindWindow( DFBWindowID id ) -{ - __GlutWindow *cur; - - for (cur = g_stack; cur; cur = cur->next) { - if (cur->wid == id) - return cur; - } - - __glutFatalError( "Window %d not found", id ); - - return NULL; -} - - -void -__glutSetWindow( __GlutWindow *window ) -{ - if (g_current) { - if (g_current == window) - return; - g_current->gl->Unlock( g_current->gl ); - } - - if (window) - window->gl->Lock( window->gl ); - g_current = window; -} - - -void -__glutHandleWindows( void ) -{ - __GlutWindow *cur = g_stack; - - while (cur) { - __GlutWindow *next = cur->next; - GLboolean displayed = GL_FALSE; - - if (cur->window && cur->req.flags) { - if (cur == g_current) - cur->gl->Unlock( cur->gl ); - - if (cur->req.flags & WINDOW_REQUEST_DESTROY) { - __glutDestroyWindow( cur ); - cur = next; - continue; - } - - if (cur->req.flags & WINDOW_REQUEST_POSITION) { - cur->window->MoveTo( cur->window, - cur->req.x, cur->req.y ); - } - - if (cur->req.flags & WINDOW_REQUEST_RESIZE) { - cur->window->Resize( cur->window, - cur->req.w, cur->req.h ); - cur->reshape = GL_TRUE; - cur->redisplay = GL_TRUE; - } - - if (cur->req.flags & WINDOW_REQUEST_RESTACK) { - while (cur->req.z > 0) { - if (cur->req.z >= +1000) { - cur->window->RaiseToTop( cur->window ); - cur->req.z = 0; - break; - } - - cur->window->Raise( cur->window ); - cur->req.z--; - } - - while (cur->req.z < 0) { - if (cur->req.z <= -1000) { - cur->window->LowerToBottom( cur->window ); - cur->req.z = 0; - break; - } - - cur->window->Lower( cur->window ); - cur->req.z++; - } - } - - if (cur->req.flags & WINDOW_REQUEST_SHOW) { - cur->window->SetOpacity( cur->window, 0xff ); - cur->visible = GL_TRUE; - cur->visibility = GL_TRUE; - } - else if (cur->req.flags & WINDOW_REQUEST_HIDE) { - cur->window->SetOpacity( cur->window, 0x00 ); - cur->visible = GL_FALSE; - cur->visibility = GL_TRUE; - } - - cur->req.flags = 0; - - if (cur == g_current) - cur->gl->Lock( cur->gl ); - } - - if (cur->reshape && reshape_func) { - int w, h; - g_idle = GL_FALSE; - cur->surface->GetSize( cur->surface, &w, &h ); - __glutSetWindow( cur ); - reshape_func( w, h ); - displayed = GL_TRUE; - } - - if (cur->visibility && visibility_func) { - g_idle = GL_FALSE; - __glutSetWindow( cur ); - visibility_func( cur->visible ? GLUT_VISIBLE : GLUT_NOT_VISIBLE ); - displayed = GL_TRUE; - } - - if (cur->redisplay && display_func) { - g_idle = GL_FALSE; - __glutSetWindow( cur ); - display_func(); - displayed = GL_TRUE; - } - - if (displayed && cur->window && cur->visible) { - if (!(cur->mode & GLUT_DOUBLE)) { - cur->gl->Unlock( cur->gl ); - cur->surface->Flip( cur->surface, NULL, 0 ); - cur->gl->Lock( cur->gl ); - } - } - - cur->reshape = GL_FALSE; - cur->visibility = GL_FALSE; - cur->redisplay = GL_FALSE; - - cur = next; - } -} - - -void -__glutDestroyWindow( __GlutWindow *window ) -{ - __GlutWindow *next = window->next; - __GlutWindow *prev = window->prev; - - __glutAssert( window != NULL ); - - if (window == g_current) - g_current = NULL; - if (window == g_game) - g_game = NULL; - - window->gl->Unlock( window->gl ); - window->gl->Release( window->gl ); - window->surface->Release( window->surface ); - - if (window->window) { -#if DIRECTFB_VERSION_CODE >= VERSION_CODE(0,9,26) - window->window->DetachEventBuffer( window->window, events ); -#else - window->window->Destroy( window->window ); -#endif - window->window->Release( window->window ); - } - else { -#if DIRECTFB_VERSION_CODE >= VERSION_CODE(0,9,26) - if (joystick) - joystick->DetachEventBuffer( joystick, events ); - if (mouse) - mouse->DetachEventBuffer( mouse, events ); - if (keyboard) - keyboard->DetachEventBuffer( keyboard, events ); -#endif - events->Reset( events ); - } - - free( window ); - - if (next) - next->prev = prev; - else - g_stack->prev = prev; - - if (window == g_stack) - g_stack = next; - else - prev->next = next; -} - - -void -__glutDestroyWindows( void ) -{ - __GlutWindow *cur = g_stack; - - while (cur) { - __GlutWindow *next = cur->next; - __glutDestroyWindow( cur ); - cur = next; - } -} - - -int GLUTAPIENTRY -glutCreateWindow( const char *title ) -{ - __GlutWindow *window; - - if (getenv( "__GLUT_GAME_MODE" )) - return glutEnterGameMode(); - - glutInit( NULL, NULL ); - - window = __glutCreateWindow( GL_FALSE ); - if (!window) - return 0; - - __glutSetWindow( window ); - glutSetCursor( GLUT_CURSOR_INHERIT ); - - return window->id; -} - - -int GLUTAPIENTRY -glutCreateSubWindow( int win, int x, int y, int width, int height ) -{ - return GL_FALSE; -} - - -void GLUTAPIENTRY -glutDestroyWindow( int win ) -{ - __GlutWindow *cur; - - for (cur = g_stack; cur; cur = cur->next) { - if (cur->id == win) { - if (cur->window) - cur->window->Destroy( cur->window ); - - cur->req.flags |= WINDOW_REQUEST_DESTROY; - break; - } - } -} - - -void GLUTAPIENTRY -glutPostRedisplay( void ) -{ - if (g_current) - g_current->redisplay = GL_TRUE; -} - - -void GLUTAPIENTRY -glutPostWindowRedisplay( int win ) -{ - __GlutWindow *cur; - - for (cur = g_stack; cur; cur = cur->next) { - if (cur->id == win) { - cur->redisplay = GL_TRUE; - break; - } - } -} - - -void GLUTAPIENTRY -glutSwapBuffers( void ) -{ - if (g_current) { - g_current->gl->Unlock( g_current->gl ); - g_current->surface->Flip( g_current->surface, NULL, 0 ); - g_current->gl->Lock( g_current->gl ); - } -} - - -int GLUTAPIENTRY -glutGetWindow( void ) -{ - return (g_current) ? g_current->id : 0; -} - - -void GLUTAPIENTRY -glutSetWindow( int win ) -{ - __GlutWindow *cur; - - if (g_current && g_current->id == win) - return; - - for (cur = g_stack; cur; cur = cur->next) { - if (cur->id == win) { - __glutSetWindow( cur ); - break; - } - } -} - - -void GLUTAPIENTRY -glutSetWindowTitle( const char *title ) -{ -} - - -void GLUTAPIENTRY -glutSetIconTitle( const char *title ) -{ -} - - -void GLUTAPIENTRY -glutFullScreen( void ) -{ - if (g_current && !g_game) { - DFBDisplayLayerConfig config; - - primary->GetConfiguration( primary, &config ); - - g_current->req.flags |= WINDOW_REQUEST_POSITION | - WINDOW_REQUEST_RESIZE | - WINDOW_REQUEST_RESTACK; - g_current->req.x = 0; - g_current->req.y = 0; - g_current->req.w = config.width; - g_current->req.h = config.height; - g_current->req.z = 1000; - } -} - - -void GLUTAPIENTRY -glutPositionWindow( int x, int y ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_POSITION; - g_current->req.x = x; - g_current->req.y = y; - } -} - - -void GLUTAPIENTRY -glutReshapeWindow( int width, int height ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_RESIZE; - g_current->req.w = width; - g_current->req.h = height; - } -} - - -void GLUTAPIENTRY -glutPopWindow( void ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_RESTACK; - g_current->req.z--; - } -} - - -void GLUTAPIENTRY -glutPushWindow( void ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_RESTACK; - g_current->req.z++; - } -} - - -void GLUTAPIENTRY -glutIconifyWindow( void ) -{ -} - - -void GLUTAPIENTRY -glutShowWindow( void ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_SHOW; - g_current->req.flags &= ~WINDOW_REQUEST_HIDE; - } -} - - -void GLUTAPIENTRY -glutHideWindow( void ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_HIDE; - g_current->req.flags &= ~WINDOW_REQUEST_SHOW; - } -} - diff --git a/src/mesa/drivers/directfb/Makefile b/src/mesa/drivers/directfb/Makefile deleted file mode 100644 index 94c82a2c9c..0000000000 --- a/src/mesa/drivers/directfb/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# src/mesa/drivers/directfb/Makefile - -TOP = ../../../.. - -include $(TOP)/configs/current - - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main \ - -I$(TOP)/src/mesa/glapi \ - -I$(TOP)/src/mesa/math \ - -I$(TOP)/src/mesa/tnl \ - -I$(TOP)/src/mesa/shader \ - -I$(TOP)/src/mesa/swrast \ - -I$(TOP)/src/mesa/swrast_setup - -DFB_CFLAGS = $(shell pkg-config --cflags directfb) -DFB_MODULEDIR = $(shell pkg-config --variable=moduledir directfb-internal) - -DIRECTFBGL_MESA_SOURCES = ../common/driverfuncs.c idirectfbgl_mesa.c - -DIRECTFBGL_MESA_OBJECTS = $(DIRECTFBGL_MESA_SOURCES:.c=.o) - -DIRECTFBGL_MESA = libidirectfbgl_mesa.so - -LIBS = $(TOP)/src/mesa/libmesa.a $(TOP)/src/mesa/libglapi.a - - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(DFB_CFLAGS) $< -o $@ - - -default: directfb-libgl directfbgl_mesa - - -# XXX this used to be in src/mesa/Makefile and is probably broken now -directfb-libgl: $(LIBS) - @ $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \ - -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(LIBS) \ - $(GL_LIB_DEPS) - - - -# Mesa DirectFBGL module -directfbgl_mesa: $(DIRECTFBGL_MESA_OBJECTS) - $(CC) -shared $(CFLAGS) $(DIRECTFBGL_MESA_OBJECTS) -o $(DIRECTFBGL_MESA) \ - -Wl,-soname -Wl,$(DIRECTFBGL_MESA) -L$(TOP)/$(LIB_DIR) -lGL -lm - - -install: - @if test -d $(DFB_MODULEDIR); then \ - echo "Installing DirectFBGL module."; \ - else \ - echo "*** Failed to determine DirectFB module's directory."; \ - echo "*** Installation aborted."; \ - exit 1; \ - fi; - test -d $(DFB_MODULEDIR)/interfaces/IDirectFBGL/ || mkdir $(DFB_MODULEDIR)/interfaces/IDirectFBGL/ - install -m 755 $(DIRECTFBGL_MESA) $(DFB_MODULEDIR)/interfaces/IDirectFBGL/ - - -clean: - -rm -f *.o *.so - diff --git a/src/mesa/drivers/directfb/idirectfbgl_mesa.c b/src/mesa/drivers/directfb/idirectfbgl_mesa.c deleted file mode 100644 index 85a6f03672..0000000000 --- a/src/mesa/drivers/directfb/idirectfbgl_mesa.c +++ /dev/null @@ -1,982 +0,0 @@ -/* - * Copyright (C) 2004-2007 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * Based on glfbdev.c, written by Brian Paul. - * - */ - -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include - -#undef CLAMP -#include "main/glheader.h" -#include "main/buffers.h" -#include "main/context.h" -#include "main/extensions.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/imports.h" -#include "main/texformat.h" -#include "main/teximage.h" -#include "main/texstore.h" -#include "vbo/vbo.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" -#include "drivers/common/driverfuncs.h" - - -#define VERSION_CODE( M, m, r ) (((M) * 1000) + ((m) * 100) + ((r))) -#define DIRECTFB_VERSION_CODE VERSION_CODE( DIRECTFB_MAJOR_VERSION, \ - DIRECTFB_MINOR_VERSION, \ - DIRECTFB_MICRO_VERSION ) - - -static DFBResult -Probe( void *data ); - -static DFBResult -Construct( IDirectFBGL *thiz, - IDirectFBSurface *surface ); - -#include - -DIRECT_INTERFACE_IMPLEMENTATION( IDirectFBGL, Mesa ) - -/* - * private data struct of IDirectFBGL - */ -typedef struct { - int ref; /* reference counter */ - - int locked; - - IDirectFBSurface *surface; - DFBSurfacePixelFormat format; - int width; - int height; - - struct { - GLubyte *start; - GLubyte *end; - int pitch; - } video; - - GLvisual visual; - GLframebuffer framebuffer; - GLcontext context; - struct gl_renderbuffer render; -} IDirectFBGL_data; - -/******************************************************************************/ - -static pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER; -static unsigned int global_ref = 0; - -static INLINE int directfbgl_init( void ) -{ - pthread_mutexattr_t attr; - int ret; - - if (global_ref++) - return 0; - - pthread_mutexattr_init( &attr ); - pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK ); - ret = pthread_mutex_init( &global_lock, &attr ); - pthread_mutexattr_destroy( &attr ); - - return ret; -} - -static INLINE void directfbgl_finish( void ) -{ - if (--global_ref == 0) - pthread_mutex_destroy( &global_lock ); -} - -#define directfbgl_lock() pthread_mutex_lock( &global_lock ) -#define directfbgl_unlock() pthread_mutex_unlock( &global_lock ) - -/******************************************************************************/ - -static bool directfbgl_init_visual ( GLvisual *visual, - DFBSurfacePixelFormat format ); -static bool directfbgl_create_context ( GLcontext *context, - GLframebuffer *framebuffer, - GLvisual *visual, - IDirectFBGL_data *data ); -static void directfbgl_destroy_context( GLcontext *context, - GLframebuffer *framebuffer ); - -/******************************************************************************/ - - -static void -IDirectFBGL_Mesa_Destruct( IDirectFBGL *thiz ) -{ - IDirectFBGL_data *data = (IDirectFBGL_data*) thiz->priv; - - directfbgl_destroy_context( &data->context, &data->framebuffer ); - - if (data->surface) - data->surface->Release( data->surface ); - - DIRECT_DEALLOCATE_INTERFACE( thiz ); - - directfbgl_finish(); -} - -static DFBResult -IDirectFBGL_Mesa_AddRef( IDirectFBGL *thiz ) -{ - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - - data->ref++; - - return DFB_OK; -} - -static DFBResult -IDirectFBGL_Mesa_Release( IDirectFBGL *thiz ) -{ - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ) - - if (--data->ref == 0) - IDirectFBGL_Mesa_Destruct( thiz ); - - return DFB_OK; -} - -static DFBResult -IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) -{ - IDirectFBSurface *surface; - int width = 0; - int height = 0; - DFBResult ret; - - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - - if (data->locked) { - data->locked++; - return DFB_OK; - } - - if (directfbgl_lock()) - return DFB_LOCKED; - - surface = data->surface; - surface->GetSize( surface, &width, &height ); - - ret = surface->Lock( surface, DSLF_READ | DSLF_WRITE, - (void*)&data->video.start, &data->video.pitch ); - if (ret) { - D_ERROR( "DirectFBGL/Mesa: couldn't lock surface.\n" ); - directfbgl_unlock(); - return ret; - } - data->video.end = data->video.start + (height-1) * data->video.pitch; - - data->render.Data = data->video.start; - - _mesa_make_current( &data->context, - &data->framebuffer, &data->framebuffer ); - - if (data->width != width || data->height != height) { - _mesa_resize_framebuffer( &data->context, - &data->framebuffer, width, height ); - data->width = width; - data->height = height; - } - - data->locked++; - - return DFB_OK; -} - -static DFBResult -IDirectFBGL_Mesa_Unlock( IDirectFBGL *thiz ) -{ - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - - if (!data->locked) - return DFB_OK; - - if (--data->locked == 0) { - _mesa_make_current( NULL, NULL, NULL ); - - data->surface->Unlock( data->surface ); - - directfbgl_unlock(); - } - - return DFB_OK; -} - -static DFBResult -IDirectFBGL_Mesa_GetAttributes( IDirectFBGL *thiz, - DFBGLAttributes *attributes ) -{ - DFBSurfaceCapabilities caps; - GLvisual *visual; - - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - - if (!attributes) - return DFB_INVARG; - - data->surface->GetCapabilities( data->surface, &caps ); - - visual = &data->visual; - - attributes->buffer_size = visual->rgbBits ? : visual->indexBits; - attributes->depth_size = visual->depthBits; - attributes->stencil_size = visual->stencilBits; - attributes->aux_buffers = visual->numAuxBuffers; - attributes->red_size = visual->redBits; - attributes->green_size = visual->greenBits; - attributes->blue_size = visual->blueBits; - attributes->alpha_size = visual->alphaBits; - attributes->accum_red_size = visual->accumRedBits; - attributes->accum_green_size = visual->accumGreenBits; - attributes->accum_blue_size = visual->accumBlueBits; - attributes->accum_alpha_size = visual->accumAlphaBits; - attributes->double_buffer = ((caps & DSCAPS_FLIPPING) != 0); - attributes->stereo = (visual->stereoMode != 0); - - return DFB_OK; -} - -#if DIRECTFBGL_INTERFACE_VERSION >= 1 -static DFBResult -IDirectFBGL_Mesa_GetProcAddress( IDirectFBGL *thiz, - const char *name, - void **ret_address ) -{ - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - - if (!name) - return DFB_INVARG; - - if (!ret_address) - return DFB_INVARG; - - *ret_address = _glapi_get_proc_address( name ); - - return (*ret_address) ? DFB_OK : DFB_UNSUPPORTED; -} -#endif - - -/* exported symbols */ - -static DFBResult -Probe( void *data ) -{ - return DFB_OK; -} - -static DFBResult -Construct( IDirectFBGL *thiz, IDirectFBSurface *surface ) -{ - DFBResult ret; - - /* Initialize global resources. */ - if (directfbgl_init()) - return DFB_INIT; - - /* Allocate interface data. */ - DIRECT_ALLOCATE_INTERFACE_DATA( thiz, IDirectFBGL ); - - /* Initialize interface data. */ - data->ref = 1; - - /* Duplicate destination surface. */ - ret = surface->GetSubSurface( surface, NULL, &data->surface ); - if (ret) { - IDirectFBGL_Mesa_Destruct( thiz ); - return ret; - } - - data->surface->GetPixelFormat( data->surface, &data->format ); - data->surface->GetSize( data->surface, &data->width, &data->height ); - - /* Configure visual. */ - if (!directfbgl_init_visual( &data->visual, data->format )) { - D_ERROR( "DirectFBGL/Mesa: failed to initialize visual.\n" ); - IDirectFBGL_Mesa_Destruct( thiz ); - return DFB_UNSUPPORTED; - } - - /* Create context. */ - if (!directfbgl_create_context( &data->context, - &data->framebuffer, - &data->visual, data )) { - D_ERROR( "DirectFBGL/Mesa: failed to create context.\n" ); - IDirectFBGL_Mesa_Destruct( thiz ); - return DFB_UNSUPPORTED; - } - - /* Assign interface pointers. */ - thiz->AddRef = IDirectFBGL_Mesa_AddRef; - thiz->Release = IDirectFBGL_Mesa_Release; - thiz->Lock = IDirectFBGL_Mesa_Lock; - thiz->Unlock = IDirectFBGL_Mesa_Unlock; - thiz->GetAttributes = IDirectFBGL_Mesa_GetAttributes; -#if DIRECTFBGL_INTERFACE_VERSION >= 1 - thiz->GetProcAddress = IDirectFBGL_Mesa_GetProcAddress; -#endif - - return DFB_OK; -} - - -/***************************** Driver functions ******************************/ - -static const GLubyte* -dfbGetString( GLcontext *ctx, GLenum pname ) -{ - return NULL; -} - -static void -dfbUpdateState( GLcontext *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); -} - -static void -dfbGetBufferSize( GLframebuffer *buffer, GLuint *width, GLuint *height ) -{ - GLcontext *ctx = _mesa_get_current_context(); - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; - - *width = (GLuint) data->width; - *height = (GLuint) data->height; -} - -/** - * We only implement this function as a mechanism to check if the - * framebuffer size has changed (and update corresponding state). - */ -static void -dfbSetViewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) -{ - /* Nothing to do (the surface can't be resized while it's locked). */ - return; -} - -static void -dfbClear( GLcontext *ctx, GLbitfield mask ) -{ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; - -#define BUFFER_BIT_MASK (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT | \ - BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT ) - if (mask & BUFFER_BIT_MASK && - ctx->Color.ColorMask[0][0] && - ctx->Color.ColorMask[0][1] && - ctx->Color.ColorMask[0][2] && - ctx->Color.ColorMask[0][3]) - { - DFBRegion clip; - GLubyte a, r, g, b; - - UNCLAMPED_FLOAT_TO_UBYTE( a, ctx->Color.ClearColor[ACOMP] ); - UNCLAMPED_FLOAT_TO_UBYTE( r, ctx->Color.ClearColor[RCOMP] ); - UNCLAMPED_FLOAT_TO_UBYTE( g, ctx->Color.ClearColor[GCOMP] ); - UNCLAMPED_FLOAT_TO_UBYTE( b, ctx->Color.ClearColor[BCOMP] ); - - clip.x1 = ctx->DrawBuffer->_Xmin; - clip.y1 = ctx->DrawBuffer->_Ymin; - clip.x2 = ctx->DrawBuffer->_Xmax - 1; - clip.y2 = ctx->DrawBuffer->_Ymax - 1; - data->surface->SetClip( data->surface, &clip ); - - data->surface->Unlock( data->surface ); - - data->surface->Clear( data->surface, r, g, b, a ); - - data->surface->Lock( data->surface, DSLF_READ | DSLF_WRITE, - (void*)&data->video.start, &data->video.pitch ); - data->video.end = data->video.start + (data->height-1) * data->video.pitch; - data->render.Data = data->video.start; - - mask &= ~BUFFER_BIT_MASK; - } -#undef BUFFER_BIT_MASK - - if (mask) - _swrast_Clear( ctx, mask ); -} - - -/************************ RenderBuffer functions *****************************/ - -static void -dfbDeleteRenderbuffer( struct gl_renderbuffer *render ) -{ - return; -} - -static GLboolean -dfbRenderbufferStorage( GLcontext *ctx, struct gl_renderbuffer *render, - GLenum internalFormat, GLuint width, GLuint height ) -{ - return GL_TRUE; -} - - -/***************************** Span functions ********************************/ - -/* RGB332 */ -#define NAME(PREFIX) PREFIX##_RGB332 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte *P = data->video.end - (Y) * data->video.pitch + (X); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[RCOMP]) & 0xe0) ) | \ - (((S[GCOMP]) & 0xe0) >> 3) | \ - (((S[BCOMP]) ) >> 6) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0xe0) ); \ - D[GCOMP] = ((*P & 0x1c) << 3); \ - D[BCOMP] = ((*P & 0x03) << 6); \ - D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* ARGB4444 */ -#define NAME(PREFIX) PREFIX##_ARGB4444 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL_RGB(P, X, Y, S) \ - *P = ( 0xf000 | \ - (((S[RCOMP]) & 0xf0) << 4) | \ - (((S[GCOMP]) & 0xf0) ) | \ - (((S[BCOMP]) & 0xf0) >> 4) ) -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[ACOMP]) & 0xf0) << 8) | \ - (((S[RCOMP]) & 0xf0) << 4) | \ - (((S[GCOMP]) & 0xf0) ) | \ - (((S[BCOMP]) & 0xf0) >> 4) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >> 8); \ - D[GCOMP] = ((*P & 0x00f0) ) | ((*P & 0x00f0) >> 4); \ - D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f) ); \ - D[ACOMP] = ((*P & 0xf000) >> 8) | ((*P & 0xf000) >> 12) - -#include "swrast/s_spantemp.h" - -/* RGB444 */ -#define NAME(PREFIX) PREFIX##_RGB444 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[RCOMP]) & 0xf0) << 4) | \ - (((S[GCOMP]) & 0xf0) ) | \ - (((S[BCOMP]) & 0xf0) >> 4) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >> 8); \ - D[GCOMP] = ((*P & 0x00f0) ) | ((*P & 0x00f0) >> 4); \ - D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f) ); \ - D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* ARGB2554 */ -#define NAME(PREFIX) PREFIX##_ARGB2554 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL_RGB(P, X, Y, S) \ - *P = ( 0xc000 | \ - (((S[RCOMP]) & 0xf8) << 6) | \ - (((S[GCOMP]) & 0xf8) << 1) | \ - (((S[BCOMP]) & 0xf0) >> 4) ) -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[ACOMP]) & 0xc0) << 8) | \ - (((S[RCOMP]) & 0xf8) << 6) | \ - (((S[GCOMP]) & 0xf8) << 1) | \ - (((S[BCOMP]) & 0xf0) >> 4) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x3e00) >> 9); \ - D[GCOMP] = ((*P & 0x01f0) >> 4); \ - D[BCOMP] = ((*P & 0x000f) << 4); \ - D[ACOMP] = ((*P & 0xc000) >> 14) - -#include "swrast/s_spantemp.h" - -/* ARGB1555 */ -#define NAME(PREFIX) PREFIX##_ARGB1555 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL_RGB(P, X, Y, S) \ - *P = ( 0x8000 | \ - (((S[RCOMP]) & 0xf8) << 7) | \ - (((S[GCOMP]) & 0xf8) << 2) | \ - (((S[BCOMP]) ) >> 3) ) -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[ACOMP]) & 0x80) << 16) | \ - (((S[RCOMP]) & 0xf8) << 7) | \ - (((S[GCOMP]) & 0xf8) << 2) | \ - (((S[BCOMP]) ) >> 3) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \ - D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >> 7); \ - D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) << 2); \ - D[ACOMP] = ((*P & 0x8000) ? 0xff : 0) - -#include "swrast/s_spantemp.h" - -/* RGB555 */ -#define NAME(PREFIX) PREFIX##_RGB555 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[RCOMP]) & 0xf8) << 7) | \ - (((S[GCOMP]) & 0xf8) << 2) | \ - (((S[BCOMP]) ) >> 3) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \ - D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >> 7); \ - D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) << 2); \ - D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* RGB16 */ -#define NAME(PREFIX) PREFIX##_RGB16 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[RCOMP]) & 0xf8) << 8) | \ - (((S[GCOMP]) & 0xfc) << 3) | \ - (((S[BCOMP]) ) >> 3) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0xf800) >> 8) | ((*P & 0xf800) >> 13); \ - D[GCOMP] = ((*P & 0x07e0) >> 3) | ((*P & 0x07e0) >> 9); \ - D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) >> 2); \ - D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* RGB24 */ -#define NAME(PREFIX) PREFIX##_RGB24 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte *P = data->video.end - (Y) * data->video.pitch + (X) * 3; -#define INC_PIXEL_PTR(P) P += 3 -#define STORE_PIXEL(P, X, Y, S) \ - P[0] = S[BCOMP]; P[1] = S[GCOMP]; P[2] = S[BCOMP] -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = P[2]; D[GCOMP] = P[1]; D[BCOMP] = P[0]; D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* RGB32 */ -#define NAME(PREFIX) PREFIX##_RGB32 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( ((S[RCOMP]) << 16) | \ - ((S[GCOMP]) << 8) | \ - ((S[BCOMP]) ) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x00ff0000) >> 16); \ - D[GCOMP] = ((*P & 0x0000ff00) >> 8); \ - D[BCOMP] = ((*P & 0x000000ff) ); \ - D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* ARGB */ -#define NAME(PREFIX) PREFIX##_ARGB -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL_RGB(P, X, Y, S) \ - *P = ( 0xff000000 | \ - ((S[RCOMP]) << 16) | \ - ((S[GCOMP]) << 8) | \ - ((S[BCOMP]) ) ) -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( ((S[ACOMP]) << 24) | \ - ((S[RCOMP]) << 16) | \ - ((S[GCOMP]) << 8) | \ - ((S[BCOMP]) ) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x00ff0000) >> 16); \ - D[GCOMP] = ((*P & 0x0000ff00) >> 8); \ - D[BCOMP] = ((*P & 0x000000ff) ); \ - D[ACOMP] = ((*P & 0xff000000) >> 24) - -#include "swrast/s_spantemp.h" - -/* AiRGB */ -#define NAME(PREFIX) PREFIX##_AiRGB -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL_RGB(P, X, Y, S) \ - *P = ( ((S[RCOMP]) << 16) | \ - ((S[GCOMP]) << 8) | \ - ((S[BCOMP]) ) ) -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[ACOMP]) ^ 0xff) << 24) | \ - (((S[RCOMP]) ) << 16) | \ - (((S[GCOMP]) ) << 8) | \ - (((S[BCOMP]) ) ) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x00ff0000) >> 16); \ - D[GCOMP] = ((*P & 0x0000ff00) >> 8); \ - D[BCOMP] = ((*P & 0x000000ff) ); \ - D[ACOMP] = (((*P & 0xff000000) >> 24) ^ 0xff) - -#include "swrast/s_spantemp.h" - - -/*****************************************************************************/ - -static bool -directfbgl_init_visual( GLvisual *visual, - DFBSurfacePixelFormat format ) -{ - GLboolean rgbFlag = GL_TRUE; - GLboolean dbFlag = GL_FALSE; - GLboolean stereoFlag = GL_FALSE; - GLint redBits = 0; - GLint blueBits = 0; - GLint greenBits = 0; - GLint alphaBits = 0; - GLint indexBits = 0; - GLint depthBits = 0; - GLint stencilBits = 0; - GLint accumRedBits = 0; - GLint accumGreenBits = 0; - GLint accumBlueBits = 0; - GLint accumAlphaBits = 0; - GLint numSamples = 0; - - /* FIXME: LUT8 support. */ - switch (format) { - case DSPF_RGB332: - redBits = 3; - greenBits = 3; - blueBits = 2; - break; - case DSPF_ARGB4444: - alphaBits = 4; - case DSPF_RGB444: - redBits = 4; - greenBits = 4; - blueBits = 4; - break; - case DSPF_ARGB2554: - alphaBits = 2; - redBits = 5; - greenBits = 5; - blueBits = 4; - break; - case DSPF_ARGB1555: - alphaBits = 1; - case DSPF_RGB555: - redBits = 5; - greenBits = 5; - blueBits = 5; - break; - case DSPF_RGB16: - redBits = 5; - greenBits = 6; - blueBits = 5; - break; - case DSPF_ARGB: - case DSPF_AiRGB: - alphaBits = 8; - case DSPF_RGB24: - case DSPF_RGB32: - redBits = 8; - greenBits = 8; - blueBits = 8; - break; - default: - D_WARN( "unsupported pixelformat" ); - return false; - } - - if (rgbFlag) { - accumRedBits = redBits; - accumGreenBits = greenBits; - accumBlueBits = blueBits; - accumAlphaBits = alphaBits; - depthBits = redBits + greenBits + blueBits; - stencilBits = alphaBits; - } else - depthBits = 8; - - return _mesa_initialize_visual( visual, - rgbFlag, dbFlag, stereoFlag, - redBits, greenBits, blueBits, alphaBits, - indexBits, depthBits, stencilBits, - accumRedBits, accumGreenBits, - accumBlueBits, accumAlphaBits, - numSamples ); -} - -static bool -directfbgl_create_context( GLcontext *context, - GLframebuffer *framebuffer, - GLvisual *visual, - IDirectFBGL_data *data ) -{ - struct dd_function_table functions; - - _mesa_initialize_window_framebuffer( framebuffer, visual ); - - _mesa_init_driver_functions( &functions ); - functions.GetString = dfbGetString; - functions.UpdateState = dfbUpdateState; - functions.GetBufferSize = dfbGetBufferSize; - functions.Viewport = dfbSetViewport; - functions.Clear = dfbClear; - - if (!_mesa_initialize_context( context, visual, NULL, - &functions, (void*) data )) { - D_DEBUG( "DirectFBGL/Mesa: _mesa_initialize_context() failed.\n" ); - _mesa_free_framebuffer_data( framebuffer ); - return false; - } - - _swrast_CreateContext( context ); - _vbo_CreateContext( context ); - _tnl_CreateContext( context ); - _swsetup_CreateContext( context ); - _swsetup_Wakeup( context ); - - _mesa_init_renderbuffer( &data->render, 0 ); - data->render.InternalFormat = GL_RGBA; - data->render._BaseFormat = GL_RGBA; - data->render.DataType = GL_UNSIGNED_BYTE; - data->render.Data = data->video.start; - data->render.Delete = dfbDeleteRenderbuffer; - data->render.AllocStorage = dfbRenderbufferStorage; - - switch (data->format) { - case DSPF_RGB332: - data->render.GetRow = get_row_RGB332; - data->render.GetValues = get_values_RGB332; - data->render.PutRow = put_row_RGB332; - data->render.PutRowRGB = put_row_rgb_RGB332; - data->render.PutMonoRow = put_mono_row_RGB332; - data->render.PutValues = put_values_RGB332; - data->render.PutMonoValues = put_mono_values_RGB332; - break; - case DSPF_ARGB4444: - data->render.GetRow = get_row_ARGB4444; - data->render.GetValues = get_values_ARGB4444; - data->render.PutRow = put_row_ARGB4444; - data->render.PutRowRGB = put_row_rgb_ARGB4444; - data->render.PutMonoRow = put_mono_row_ARGB4444; - data->render.PutValues = put_values_ARGB4444; - data->render.PutMonoValues = put_mono_values_ARGB4444; - break; - case DSPF_RGB444: - data->render.GetRow = get_row_RGB444; - data->render.GetValues = get_values_RGB444; - data->render.PutRow = put_row_RGB444; - data->render.PutRowRGB = put_row_rgb_RGB444; - data->render.PutMonoRow = put_mono_row_RGB444; - data->render.PutValues = put_values_RGB444; - data->render.PutMonoValues = put_mono_values_RGB444; - break; - case DSPF_ARGB2554: - data->render.GetRow = get_row_ARGB2554; - data->render.GetValues = get_values_ARGB2554; - data->render.PutRow = put_row_ARGB2554; - data->render.PutRowRGB = put_row_rgb_ARGB2554; - data->render.PutMonoRow = put_mono_row_ARGB2554; - data->render.PutValues = put_values_ARGB2554; - data->render.PutMonoValues = put_mono_values_ARGB2554; - break; - case DSPF_ARGB1555: - data->render.GetRow = get_row_ARGB1555; - data->render.GetValues = get_values_ARGB1555; - data->render.PutRow = put_row_ARGB1555; - data->render.PutRowRGB = put_row_rgb_ARGB1555; - data->render.PutMonoRow = put_mono_row_ARGB1555; - data->render.PutValues = put_values_ARGB1555; - data->render.PutMonoValues = put_mono_values_ARGB1555; - break; - case DSPF_RGB555: - data->render.GetRow = get_row_RGB555; - data->render.GetValues = get_values_RGB555; - data->render.PutRow = put_row_RGB555; - data->render.PutRowRGB = put_row_rgb_RGB555; - data->render.PutMonoRow = put_mono_row_RGB555; - data->render.PutValues = put_values_RGB555; - data->render.PutMonoValues = put_mono_values_RGB555; - break; - case DSPF_RGB16: - data->render.GetRow = get_row_RGB16; - data->render.GetValues = get_values_RGB16; - data->render.PutRow = put_row_RGB16; - data->render.PutRowRGB = put_row_rgb_RGB16; - data->render.PutMonoRow = put_mono_row_RGB16; - data->render.PutValues = put_values_RGB16; - data->render.PutMonoValues = put_mono_values_RGB16; - break; - case DSPF_RGB24: - data->render.GetRow = get_row_RGB24; - data->render.GetValues = get_values_RGB24; - data->render.PutRow = put_row_RGB24; - data->render.PutRowRGB = put_row_rgb_RGB24; - data->render.PutMonoRow = put_mono_row_RGB24; - data->render.PutValues = put_values_RGB24; - data->render.PutMonoValues = put_mono_values_RGB24; - break; - case DSPF_RGB32: - data->render.GetRow = get_row_RGB32; - data->render.GetValues = get_values_RGB32; - data->render.PutRow = put_row_RGB32; - data->render.PutRowRGB = put_row_rgb_RGB32; - data->render.PutMonoRow = put_mono_row_RGB32; - data->render.PutValues = put_values_RGB32; - data->render.PutMonoValues = put_mono_values_RGB32; - break; - case DSPF_ARGB: - data->render.GetRow = get_row_ARGB; - data->render.GetValues = get_values_ARGB; - data->render.PutRow = put_row_ARGB; - data->render.PutRowRGB = put_row_rgb_ARGB; - data->render.PutMonoRow = put_mono_row_ARGB; - data->render.PutValues = put_values_ARGB; - data->render.PutMonoValues = put_mono_values_ARGB; - break; - case DSPF_AiRGB: - data->render.GetRow = get_row_AiRGB; - data->render.GetValues = get_values_AiRGB; - data->render.PutRow = put_row_AiRGB; - data->render.PutRowRGB = put_row_rgb_AiRGB; - data->render.PutMonoRow = put_mono_row_AiRGB; - data->render.PutValues = put_values_AiRGB; - data->render.PutMonoValues = put_mono_values_AiRGB; - break; - default: - D_BUG( "unexpected pixelformat" ); - return false; - } - - data->render.Width = data->width; - data->render.Height = data->height; - - _mesa_add_renderbuffer( framebuffer, BUFFER_FRONT_LEFT, &data->render ); - - _mesa_add_soft_renderbuffers( framebuffer, - GL_FALSE, - visual->haveDepthBuffer, - visual->haveStencilBuffer, - visual->haveAccumBuffer, - GL_FALSE, - GL_FALSE ); - - TNL_CONTEXT( context )->Driver.RunPipeline = _tnl_run_pipeline; - - _mesa_enable_sw_extensions( context ); - - return true; -} - -static void -directfbgl_destroy_context( GLcontext *context, - GLframebuffer *framebuffer ) -{ - _swsetup_DestroyContext( context ); - _swrast_DestroyContext( context ); - _tnl_DestroyContext( context ); - _vbo_DestroyContext( context ); - //_mesa_free_framebuffer_data( framebuffer ); - _mesa_free_context_data( context ); -} - -- cgit v1.2.3 From b5c3199afe0d90787223cb57c35ff22e38b3c920 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 25 Feb 2010 15:55:00 -0500 Subject: Remove dos driver --- Makefile | 3 - include/GL/Makefile.am | 2 +- src/mesa/drivers/dos/blit.S | 1040 --------------------------------------- src/mesa/drivers/dos/dmesa.c | 359 -------------- src/mesa/drivers/dos/dpmi.c | 166 ------- src/mesa/drivers/dos/internal.h | 105 ---- src/mesa/drivers/dos/null.c | 224 --------- src/mesa/drivers/dos/null.h | 41 -- src/mesa/drivers/dos/vesa.c | 719 --------------------------- src/mesa/drivers/dos/vesa.h | 65 --- src/mesa/drivers/dos/vga.c | 289 ----------- src/mesa/drivers/dos/vga.h | 42 -- src/mesa/drivers/dos/video.c | 442 ----------------- src/mesa/drivers/dos/video.h | 56 --- 14 files changed, 1 insertion(+), 3552 deletions(-) delete mode 100644 src/mesa/drivers/dos/blit.S delete mode 100644 src/mesa/drivers/dos/dmesa.c delete mode 100644 src/mesa/drivers/dos/dpmi.c delete mode 100644 src/mesa/drivers/dos/internal.h delete mode 100644 src/mesa/drivers/dos/null.c delete mode 100644 src/mesa/drivers/dos/null.h delete mode 100644 src/mesa/drivers/dos/vesa.c delete mode 100644 src/mesa/drivers/dos/vesa.h delete mode 100644 src/mesa/drivers/dos/vga.c delete mode 100644 src/mesa/drivers/dos/vga.h delete mode 100644 src/mesa/drivers/dos/video.c delete mode 100644 src/mesa/drivers/dos/video.h (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0527fa0d82..659e11c5fb 100644 --- a/Makefile +++ b/Makefile @@ -270,7 +270,6 @@ MAIN_FILES = \ $(DIRECTORY)/src/mesa/drivers/beos/Makefile \ $(DIRECTORY)/src/mesa/drivers/common/*.[ch] \ $(DIRECTORY)/src/mesa/drivers/common/descrip.mms \ - $(DIRECTORY)/src/mesa/drivers/dos/*.[chS] \ $(DIRECTORY)/src/mesa/drivers/fbdev/Makefile \ $(DIRECTORY)/src/mesa/drivers/fbdev/glfbdev.c \ $(DIRECTORY)/src/mesa/drivers/glide/*.[ch] \ @@ -472,8 +471,6 @@ GLUT_FILES = \ $(DIRECTORY)/src/glut/beos/*.[ch] \ $(DIRECTORY)/src/glut/beos/*.cpp \ $(DIRECTORY)/src/glut/beos/Makefile \ - $(DIRECTORY)/src/glut/dos/*.[ch] \ - $(DIRECTORY)/src/glut/dos/PC_HW/*.[chS] \ $(DIRECTORY)/src/glut/ggi/*.[ch] \ $(DIRECTORY)/src/glut/ggi/Makefile \ $(DIRECTORY)/src/glut/fbdev/Makefile \ diff --git a/include/GL/Makefile.am b/include/GL/Makefile.am index ca528f606d..a62495766c 100644 --- a/include/GL/Makefile.am +++ b/include/GL/Makefile.am @@ -28,7 +28,7 @@ if NEED_GLUT sel_inc_glut = $(INC_GLUT) endif -EXTRA_HEADERS = amesa.h dosmesa.h foomesa.h glut_h.dja mesa_wgl.h mglmesa.h \ +EXTRA_HEADERS = amesa.h foomesa.h glut_h.dja mesa_wgl.h mglmesa.h \ vms_x_fix.h wmesa.h \ $(INC_GGI) $(INC_OSMESA) $(INC_SVGA) $(INC_X11) $(INC_GLUT) diff --git a/src/mesa/drivers/dos/blit.S b/src/mesa/drivers/dos/blit.S deleted file mode 100644 index 02dc8400d8..0000000000 --- a/src/mesa/drivers/dos/blit.S +++ /dev/null @@ -1,1040 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@yahoo.com - * Web : http://www.geocities.com/dborca - */ - - - .file "blit.S" - -/* - * extern unsigned int vesa_gran_mask, vesa_gran_shift; - * extern int vl_video_selector; - - * extern void *vl_current_draw_buffer; - * extern int vl_current_stride, vl_current_height; - * extern int vl_current_offset, vl_current_delta; - */ - - .text - -/* Desc: VESA bank switching routine (BIOS) - * - * In : EBX=0, EDX = bank number - * Out : - - * - * Note: thrashes EAX - */ - .p2align 5,,31 -_vesa_swbankBIOS: - movw $0x4f05, %ax - int $0x10 - ret - - .p2align 2,,3 - .global _vesa_swbank -_vesa_swbank: .long _vesa_swbankBIOS - -/* Desc: void vesa_b_dump_virtual (void); - * - * In : - - * Out : - - * - * Note: uses current draw buffer - */ - .p2align 5,,31 - .global _vesa_b_dump_virtual -_vesa_b_dump_virtual: - cld - pushl %es - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl _vl_video_selector, %es - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vesa_gran_shift, %ecx - movl _vesa_gran_mask, %ebp - movl %edi, %edx - xorl %ebx, %ebx - andl %ebp, %edi - shrl %cl, %edx - incl %ebp - call *_vesa_swbank - movl _vl_current_stride, %ecx - movl _vl_current_height, %eax - movl _vl_current_delta, %ebx - shrl $2, %ecx - .balign 4 - 0: - pushl %ecx - .balign 4 - 1: - cmpl %ebp, %edi - jb 2f - pushl %eax - pushl %ebx - incl %edx - xorl %ebx, %ebx - call *_vesa_swbank - popl %ebx - popl %eax - subl %ebp, %edi - .balign 4 - 2: - movsl - decl %ecx - jnz 1b - popl %ecx - addl %ebx, %edi - decl %eax - jnz 0b - popl %ebp - popl %edi - popl %esi - popl %ebx - popl %es - ret - -/* Desc: void vesa_l_dump_virtual (void); - * - * In : - - * Out : - - * - * Note: uses current draw buffer - */ - .p2align 5,,31 - .global _vesa_l_dump_virtual -_vesa_l_dump_virtual: - cld - pushl %es - pushl %esi - pushl %edi - movl _vl_video_selector, %es - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vl_current_stride, %ecx - movl _vl_current_height, %edx - movl _vl_current_delta, %eax - shrl $2, %ecx - .balign 4 - 0: - pushl %ecx - rep; movsl - popl %ecx - addl %eax, %edi - decl %edx - jnz 0b - popl %edi - popl %esi - popl %es - ret - -/* Desc: void vesa_l_dump_virtual_mmx (void); - * - * In : - - * Out : - - * - * Note: uses current draw buffer - */ - .p2align 5,,31 - .global _vesa_l_dump_virtual_mmx -_vesa_l_dump_virtual_mmx: -#ifdef USE_MMX_ASM - pushl %esi - pushl %edi - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vl_current_stride, %ecx - movl _vl_current_height, %edx - movl _vl_current_delta, %eax - shrl $3, %ecx - .balign 4 - 0: - pushl %ecx - .balign 4 - 1: - movq (%esi), %mm0 - addl $8, %esi - movq %mm0, %fs:(%edi) - addl $8, %edi - decl %ecx - jnz 1b - popl %ecx - addl %eax, %edi - decl %edx - jnz 0b - popl %edi - popl %esi - emms -#endif - ret - - - -#define CVT_32_TO_16(s, tmp) \ - /* SRC = bbbbbbbbggggggggrrrrrrrr******** */\ - movl %e##s##x, %tmp ;\ - /* TMP = bbbbbbbbggggggggrrrrrrrr******** */\ - shrb $2, %s##h ;\ - /* SRC = bbbbbbbbgggggg00rrrrrrrr******** */\ - andl $0xF80000, %tmp ;\ - /* TMP = 0000000000000000000rrrrr00000000 */\ - shrw $3, %s##x ;\ - /* SRC = bbbbbgggggg00000rrrrrrrr******** */\ - shrl $8, %tmp ;\ - /* TMP = 00000000000rrrrr0000000000000000 */\ - orl %tmp, %e##s##x ;\ - /* SRC = bbbbbggggggrrrrrrrrrrrrr******** */ - -#define CVT_32_TO_15(s, tmp) \ - /* SRC = bbbbbbbbggggggggrrrrrrrr******** */\ - movl %e##s##x, %tmp ;\ - /* TMP = bbbbbbbbggggggggrrrrrrrr******** */\ - shrb $3, %s##h ;\ - /* SRC = bbbbbbbbgggggg00rrrrrrrr******** */\ - andl $0xF80000, %tmp ;\ - /* TMP = 0000000000000000000rrrrr00000000 */\ - shrw $3, %s##x ;\ - /* SRC = bbbbbgggggg00000rrrrrrrr******** */\ - shrl $9, %tmp ;\ - /* TMP = 00000000000rrrrr0000000000000000 */\ - orl %tmp, %e##s##x ;\ - /* SRC = bbbbbggggggrrrrrrrrrrrrr******** */ - -#define CVT_16_TO_15(src, tmp) \ - /* SRC = bbbbbggggggrrrrrBBBBBGGGGGGRRRRR */\ - movl %src, %tmp ;\ - /* TMP = bbbbbggggggrrrrrBBBBBGGGGGGRRRRR */\ - andl $0x1F001F, %src ;\ - /* SRC = bbbbb00000000000BBBBB00000000000 */\ - andl $0xFFC0FFC0, %tmp ;\ - /* TMP = 000000gggggrrrrr000000GGGGGRRRRR */\ - shrl %tmp ;\ - /* TMP = 00000gggggrrrrr000000GGGGGRRRRR0 */\ - orl %tmp, %src ;\ - /* SRC = bbbbbgggggrrrrr0BBBBBGGGGGRRRRR0 */\ - - - -/* transform BGRA to BGR */ - .p2align 5,,31 - .global _vesa_l_dump_32_to_24 -_vesa_l_dump_32_to_24: - pushl %ebx - pushl %esi - pushl %edi - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vl_current_stride, %ecx - movl _vl_current_height, %edx - movl _vl_current_delta, %ebx - .balign 4 - 0: - pushl %ecx - 1: - movl (%esi), %eax - addl $4, %esi - movw %ax, %fs:(%edi) - shrl $16, %eax - movb %al, %fs:2(%edi) - addl $3, %edi - subl $3, %ecx - jnz 1b - popl %ecx - addl %ebx, %edi - decl %edx - jnz 0b - popl %edi - popl %esi - popl %ebx - ret - -/* transform BGRA to B5G6R5 */ - .p2align 5,,31 - .global _vesa_l_dump_32_to_16 -_vesa_l_dump_32_to_16: - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vl_current_stride, %ecx - movl _vl_current_height, %edx - movl _vl_current_delta, %ebx - .balign 4 - 0: - pushl %ecx - 1: - movl (%esi), %eax - addl $4, %esi - CVT_32_TO_16(a, ebp) - movw %ax, %fs:(%edi) - addl $2, %edi - subl $2, %ecx - jnz 1b - popl %ecx - addl %ebx, %edi - decl %edx - jnz 0b - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - -/* transform BGRA to B5G5R5 */ - .p2align 5,,31 - .global _vesa_l_dump_32_to_15 -_vesa_l_dump_32_to_15: - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vl_current_stride, %ecx - movl _vl_current_height, %edx - movl _vl_current_delta, %ebx - .balign 4 - 0: - pushl %ecx - 1: - movl (%esi), %eax - addl $4, %esi - CVT_32_TO_15(a, ebp) - movw %ax, %fs:(%edi) - addl $2, %edi - subl $2, %ecx - jnz 1b - popl %ecx - addl %ebx, %edi - decl %edx - jnz 0b - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - -/* transform BGRA to fake8 */ - .p2align 5,,31 - .global _vesa_l_dump_32_to_8 -_vesa_l_dump_32_to_8: - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vl_current_stride, %ecx - movl _vl_current_height, %edx - movl _vl_current_delta, %ebx - .balign 4 - 0: - pushl %edx - pushl %ecx - pushl %ebx - 1: - movl (%esi), %eax - addl $4, %esi -#if 1 - xorl %ebx, %ebx - movl %eax, %edx - movb %ah, %bl - shrl $16, %edx - andl $0xFF, %edx - andl $0xFF, %eax - - movb _array_b(%eax), %al - movb _array_r(%edx), %dl - movb _array_g(%ebx), %bl - - imull $36, %eax - imull $6, %ebx - addl %edx, %eax - addl %ebx, %eax -#endif - movb %al, %fs:(%edi) - incl %edi - decl %ecx - jnz 1b - popl %ebx - popl %ecx - popl %edx - addl %ebx, %edi - decl %edx - jnz 0b - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - -/* transform BGR to BGRx */ - .p2align 5,,31 - .global _vesa_l_dump_24_to_32 -_vesa_l_dump_24_to_32: - pushl %ebx - pushl %esi - pushl %edi - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vl_current_stride, %ecx - movl _vl_current_height, %edx - movl _vl_current_delta, %ebx - .balign 4 - 0: - pushl %ecx - 1: - movl (%esi), %eax - addl $3, %esi - movl %eax, %fs:(%edi) - addl $4, %edi - subl $4, %ecx - jnz 1b - popl %ecx - addl %ebx, %edi - decl %edx - jnz 0b - popl %edi - popl %esi - popl %ebx - ret - -/* transform BGR to fake8 */ - .p2align 5,,31 - .global _vesa_l_dump_24_to_8 -_vesa_l_dump_24_to_8: - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vl_current_stride, %ecx - movl _vl_current_height, %edx - movl _vl_current_delta, %ebx - .balign 4 - 0: - pushl %edx - pushl %ecx - pushl %ebx - 1: - movl (%esi), %eax - addl $3, %esi -#if 1 - xorl %ebx, %ebx - movl %eax, %edx - movb %ah, %bl - shrl $16, %edx - andl $0xFF, %edx - andl $0xFF, %eax - - movb _array_b(%eax), %al - movb _array_r(%edx), %dl - movb _array_g(%ebx), %bl - - imull $36, %eax - imull $6, %ebx - addl %edx, %eax - addl %ebx, %eax -#endif - movb %al, %fs:(%edi) - incl %edi - decl %ecx - jnz 1b - popl %ebx - popl %ecx - popl %edx - addl %ebx, %edi - decl %edx - jnz 0b - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - -/* transform B5G6R5 to B5G5R5 */ - .p2align 5,,31 - .global _vesa_l_dump_16_to_15 -_vesa_l_dump_16_to_15: - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vl_current_stride, %ecx - movl _vl_current_height, %edx - movl _vl_current_delta, %ebx - .balign 4 - 0: - pushl %ecx - 1: - movl (%esi), %eax - addl $4, %esi - CVT_16_TO_15(eax, ebp) - movl %eax, %fs:(%edi) - addl $4, %edi - subl $4, %ecx - jnz 1b - popl %ecx - addl %ebx, %edi - decl %edx - jnz 0b - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - -/* transform B5G6R5 to fake8 */ - .p2align 5,,31 - .global _vesa_l_dump_16_to_8 -_vesa_l_dump_16_to_8: - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vl_current_stride, %ecx - movl _vl_current_height, %edx - movl _vl_current_delta, %ebx - .balign 4 - 0: - pushl %ecx - pushl %ebx - 1: - movl (%esi), %eax - addl $4, %esi -#if 1 - movl %eax, %ebx - andl $0xFFFF, %eax - shrl $16, %ebx - movb _tab_16_8(%eax), %al - movb _tab_16_8(%ebx), %ah -#endif - movw %ax, %fs:(%edi) - addl $2, %edi - subl $2, %ecx - jnz 1b - popl %ebx - popl %ecx - addl %ebx, %edi - decl %edx - jnz 0b - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - - - - .p2align 5,,31 - .global _vesa_b_dump_32_to_24 -_vesa_b_dump_32_to_24: - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vesa_gran_shift, %ecx - movl _vesa_gran_mask, %ebp - movl %edi, %edx - xorl %ebx, %ebx - andl %ebp, %edi - shrl %cl, %edx - incl %ebp - call *_vesa_swbank - movl _vl_current_stride, %ecx - movl _vl_current_height, %eax - movl $0x00FFFFFF, %ebx - .balign 4 - 0: - pushl %eax - pushl %ecx - .balign 4 - 1: - cmpl %ebp, %edi - jb 2f - pushl %ebx - incl %edx - xorl %ebx, %ebx - call *_vesa_swbank - popl %ebx - subl %ebp, %edi - .balign 4 - 2: - movb (%esi), %al /* XXX too many accesses */ - incl %esi - rorl $8, %ebx - jnc 2b - movb %al, %fs:(%edi) - incl %edi - decl %ecx - jnz 1b - popl %ecx - popl %eax - addl _vl_current_delta, %edi - decl %eax - jnz 0b - popl %ebp - popl %edi - popl %esi - popl %ebx - ret - - .p2align 5,,31 - .global _vesa_b_dump_32_to_16 -_vesa_b_dump_32_to_16: - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vesa_gran_shift, %ecx - movl _vesa_gran_mask, %ebp - movl %edi, %edx - xorl %ebx, %ebx - andl %ebp, %edi - shrl %cl, %edx - incl %ebp - call *_vesa_swbank - movl _vl_current_stride, %ecx - movl _vl_current_height, %eax - .balign 4 - 0: - pushl %eax - pushl %ecx - .balign 4 - 1: - cmpl %ebp, %edi - jb 2f - incl %edx - xorl %ebx, %ebx - call *_vesa_swbank - subl %ebp, %edi - .balign 4 - 2: - movl (%esi), %eax - addl $4, %esi - CVT_32_TO_16(a, ebx) - movw %ax, %fs:(%edi) - addl $2, %edi - subl $2, %ecx - jnz 1b - popl %ecx - popl %eax - addl _vl_current_delta, %edi - decl %eax - jnz 0b - popl %ebp - popl %edi - popl %esi - popl %ebx - ret - - .p2align 5,,31 - .global _vesa_b_dump_32_to_15 -_vesa_b_dump_32_to_15: - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vesa_gran_shift, %ecx - movl _vesa_gran_mask, %ebp - movl %edi, %edx - xorl %ebx, %ebx - andl %ebp, %edi - shrl %cl, %edx - incl %ebp - call *_vesa_swbank - movl _vl_current_stride, %ecx - movl _vl_current_height, %eax - .balign 4 - 0: - pushl %eax - pushl %ecx - .balign 4 - 1: - cmpl %ebp, %edi - jb 2f - incl %edx - xorl %ebx, %ebx - call *_vesa_swbank - subl %ebp, %edi - .balign 4 - 2: - movl (%esi), %eax - addl $4, %esi - CVT_32_TO_15(a, ebx) - movw %ax, %fs:(%edi) - addl $2, %edi - subl $2, %ecx - jnz 1b - popl %ecx - popl %eax - addl _vl_current_delta, %edi - decl %eax - jnz 0b - popl %ebp - popl %edi - popl %esi - popl %ebx - ret - - .p2align 5,,31 - .global _vesa_b_dump_32_to_8 -_vesa_b_dump_32_to_8: - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vesa_gran_shift, %ecx - movl _vesa_gran_mask, %ebp - movl %edi, %edx - xorl %ebx, %ebx - andl %ebp, %edi - shrl %cl, %edx - incl %ebp - call *_vesa_swbank - movl _vl_current_stride, %ecx - movl _vl_current_height, %eax - .balign 4 - 0: - pushl %eax - pushl %ecx - pushl %edx - .balign 4 - 1: - cmpl %ebp, %edi - jb 2f - popl %edx - incl %edx - pushl %edx - xorl %ebx, %ebx - call *_vesa_swbank - subl %ebp, %edi - .balign 4 - 2: - movl (%esi), %eax - addl $4, %esi -#if 1 - xorl %ebx, %ebx - movl %eax, %edx - movb %ah, %bl - shrl $16, %edx - andl $0xFF, %edx - andl $0xFF, %eax - - movb _array_b(%eax), %al - movb _array_r(%edx), %dl - movb _array_g(%ebx), %bl - - imull $36, %eax - imull $6, %ebx - addl %edx, %eax - addl %ebx, %eax -#endif - movb %al, %fs:(%edi) - incl %edi - decl %ecx - jnz 1b - popl %edx - popl %ecx - popl %eax - addl _vl_current_delta, %edi - decl %eax - jnz 0b - popl %ebp - popl %edi - popl %esi - popl %ebx - ret - - .p2align 5,,31 - .global _vesa_b_dump_24_to_32 -_vesa_b_dump_24_to_32: - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vesa_gran_shift, %ecx - movl _vesa_gran_mask, %ebp - movl %edi, %edx - xorl %ebx, %ebx - andl %ebp, %edi - shrl %cl, %edx - incl %ebp - call *_vesa_swbank - movl _vl_current_stride, %ecx - movl _vl_current_height, %eax - movl _vl_current_delta, %ebx - .balign 4 - 0: - pushl %eax - pushl %ecx - .balign 4 - 1: - cmpl %ebp, %edi - jb 2f - pushl %ebx - incl %edx - xorl %ebx, %ebx - call *_vesa_swbank - popl %ebx - subl %ebp, %edi - .balign 4 - 2: - movl (%esi), %eax - addl $3, %esi - movl %eax, %fs:(%edi) - addl $4, %edi - subl $4, %ecx - jnz 1b - popl %ecx - popl %eax - addl %ebx, %edi - decl %eax - jnz 0b - popl %ebp - popl %edi - popl %esi - popl %ebx - ret - - .p2align 5,,31 - .global _vesa_b_dump_24_to_8 -_vesa_b_dump_24_to_8: - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vesa_gran_shift, %ecx - movl _vesa_gran_mask, %ebp - movl %edi, %edx - xorl %ebx, %ebx - andl %ebp, %edi - shrl %cl, %edx - incl %ebp - call *_vesa_swbank - movl _vl_current_stride, %ecx - movl _vl_current_height, %eax - .balign 4 - 0: - pushl %eax - pushl %ecx - pushl %edx - .balign 4 - 1: - cmpl %ebp, %edi - jb 2f - popl %edx - incl %edx - pushl %edx - xorl %ebx, %ebx - call *_vesa_swbank - subl %ebp, %edi - .balign 4 - 2: - movl (%esi), %eax - addl $3, %esi -#if 1 - xorl %ebx, %ebx - movl %eax, %edx - movb %ah, %bl - shrl $16, %edx - andl $0xFF, %edx - andl $0xFF, %eax - - movb _array_b(%eax), %al - movb _array_r(%edx), %dl - movb _array_g(%ebx), %bl - - imull $36, %eax - imull $6, %ebx - addl %edx, %eax - addl %ebx, %eax -#endif - movb %al, %fs:(%edi) - incl %edi - decl %ecx - jnz 1b - popl %edx - popl %ecx - popl %eax - addl _vl_current_delta, %edi - decl %eax - jnz 0b - popl %ebp - popl %edi - popl %esi - popl %ebx - ret - - .p2align 5,,31 - .global _vesa_b_dump_16_to_15 -_vesa_b_dump_16_to_15: - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vesa_gran_shift, %ecx - movl _vesa_gran_mask, %ebp - movl %edi, %edx - xorl %ebx, %ebx - andl %ebp, %edi - shrl %cl, %edx - incl %ebp - call *_vesa_swbank - movl _vl_current_stride, %ecx - movl _vl_current_height, %eax - .balign 4 - 0: - pushl %eax - pushl %ecx - .balign 4 - 1: - cmpl %ebp, %edi - jb 2f - incl %edx - xorl %ebx, %ebx - call *_vesa_swbank - subl %ebp, %edi - .balign 4 - 2: - movw (%esi), %ax - addl $2, %esi - CVT_16_TO_15(eax, ebx) - movw %ax, %fs:(%edi) - addl $2, %edi - subl $2, %ecx - jnz 1b - popl %ecx - popl %eax - addl _vl_current_delta, %edi - decl %eax - jnz 0b - popl %ebp - popl %edi - popl %esi - popl %ebx - ret - - .p2align 5,,31 - .global _vesa_b_dump_16_to_8 -_vesa_b_dump_16_to_8: - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl _vl_video_selector, %fs - movl _vl_current_draw_buffer, %esi - movl _vl_current_offset, %edi - movl _vesa_gran_shift, %ecx - movl _vesa_gran_mask, %ebp - movl %edi, %edx - xorl %ebx, %ebx - andl %ebp, %edi - shrl %cl, %edx - incl %ebp - call *_vesa_swbank - movl _vl_current_stride, %ecx - movl _vl_current_height, %eax - movl _vl_current_delta, %ebx - .balign 4 - 0: - pushl %eax - pushl %ecx - .balign 4 - 1: - cmpl %ebp, %edi - jb 2f - pushl %ebx - incl %edx - xorl %ebx, %ebx - call *_vesa_swbank - popl %ebx - subl %ebp, %edi - .balign 4 - 2: - movw (%esi), %ax - addl $2, %esi -#if 1 - andl $0xFFFF, %eax - movb _tab_16_8(%eax), %al -#endif - movb %al, %fs:(%edi) - addl $1, %edi - subl $1, %ecx - jnz 1b - popl %ecx - popl %eax - addl %ebx, %edi - decl %eax - jnz 0b - popl %ebp - popl %edi - popl %esi - popl %ebx - ret diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c deleted file mode 100644 index 003c06a8ff..0000000000 --- a/src/mesa/drivers/dos/dmesa.c +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2004 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@users.sourceforge.net - * Web : http://www.geocities.com/dborca - */ - - -#include "main/context.h" -#include "main/imports.h" -#include "main/mtypes.h" - -#include "video.h" - -#include "GL/osmesa.h" -#include "GL/dmesa.h" - - -/* - * This has nothing to do with Mesa Visual structure. - * We keep this one around for backwards compatibility, - * and to store video mode data for DMesaCreateContext. - */ -struct dmesa_visual { - GLenum format; /* OSMesa framebuffer format */ - GLint depthBits; - GLint stencilBits; - GLint accumBits; -}; - -/* - * This has nothing to do with Mesa Buffer structure. - * We keep this one around for backwards compatibility, - * and to store various data. - */ -struct dmesa_buffer { - int xpos, ypos; /* position */ - int width, height; /* size in pixels */ - GLenum type; - void *the_window; /* your window handle, etc */ -}; - -/* - * This has nothing to do with Mesa Context structure. - * We keep this one around for backwards compatibility, - * and to store real off-screen context. - */ -struct dmesa_context { - OSMesaContext osmesa; - DMesaBuffer buffer; -}; - - -static DMesaContext ctx; - - -/**************************************************************************** - * DMesa Public API Functions - ***************************************************************************/ - -/* - * The exact arguments to this function will depend on your window system - */ -DMesaVisual -DMesaCreateVisual (GLint width, - GLint height, - GLint colDepth, - GLint refresh, - GLboolean dbFlag, - GLboolean rgbFlag, - GLint alphaSize, - GLint depthSize, - GLint stencilSize, - GLint accumSize) -{ - DMesaVisual visual; - GLenum format; - int fbbits; - - if (dbFlag) { - return NULL; - } - - if (!rgbFlag) { - format = OSMESA_COLOR_INDEX; - fbbits = 8; - } else if (alphaSize) { - format = OSMESA_BGRA; - fbbits = 32; - } else if (colDepth == 15 || colDepth == 16) { - format = OSMESA_RGB_565; - fbbits = 16; - } else { - format = OSMESA_BGR; - fbbits = 24; - } - - if ((visual = (DMesaVisual)CALLOC_STRUCT(dmesa_visual)) == NULL) { - return NULL; - } - - if (vl_video_init(width, height, colDepth, rgbFlag, refresh, fbbits) <= 0) { - FREE(visual); - return NULL; - } - - visual->format = format; - visual->depthBits = depthSize; - visual->stencilBits = stencilSize; - visual->accumBits = accumSize; - return visual; -} - - -void -DMesaDestroyVisual (DMesaVisual visual) -{ - vl_video_exit(); - FREE(visual); -} - - -DMesaBuffer -DMesaCreateBuffer (DMesaVisual visual, - GLint xpos, GLint ypos, - GLint width, GLint height) -{ - DMesaBuffer buffer; - GLenum type; - int bytesPerPixel; - - switch (visual->format) { - case OSMESA_COLOR_INDEX: - bytesPerPixel = 1; - type = CHAN_TYPE; - break; - case OSMESA_RGB_565: - bytesPerPixel = 2; - type = GL_UNSIGNED_SHORT_5_6_5; - break; - case OSMESA_BGR: - bytesPerPixel = 3; - type = CHAN_TYPE; - break; - default: - bytesPerPixel = 4; - type = CHAN_TYPE; - } - - if ((buffer = (DMesaBuffer)CALLOC_STRUCT(dmesa_buffer)) != NULL) { - buffer->xpos = xpos; - buffer->ypos = ypos; - buffer->width = width; - buffer->height = height; - buffer->type = type; - buffer->the_window = MALLOC(width * height * bytesPerPixel + 1); - if (buffer->the_window == NULL) { - FREE(buffer); - buffer = NULL; - } - } - - return buffer; -} - - -void -DMesaDestroyBuffer (DMesaBuffer buffer) -{ - FREE(buffer->the_window); - FREE(buffer); -} - - -DMesaContext -DMesaCreateContext (DMesaVisual visual, DMesaContext share) -{ - DMesaContext dmesa; - if ((dmesa = (DMesaContext)CALLOC_STRUCT(dmesa_context)) != NULL) { - dmesa->osmesa = OSMesaCreateContextExt( - visual->format, - visual->depthBits, - visual->stencilBits, - visual->accumBits, - (share != NULL) ? share->osmesa : NULL); - if (dmesa->osmesa == NULL) { - FREE(dmesa); - dmesa = NULL; - } - } - return dmesa; -} - - -void -DMesaDestroyContext (DMesaContext dmesa) -{ - OSMesaDestroyContext(dmesa->osmesa); - FREE(dmesa); -} - - -GLboolean -DMesaMoveBuffer (GLint xpos, GLint ypos) -{ - const DMesaContext dmesa = DMesaGetCurrentContext(); - DMesaBuffer b = dmesa->buffer; - - if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) == 0) { - b->xpos = xpos; - b->ypos = ypos; - return GL_TRUE; - } - - return GL_FALSE; -} - - -GLboolean -DMesaResizeBuffer (GLint width, GLint height) -{ - const DMesaContext dmesa = DMesaGetCurrentContext(); - DMesaBuffer b = dmesa->buffer; - - if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) == 0) { - b->width = width; - b->height = height; - return GL_TRUE; - } - - return GL_FALSE; -} - - -GLboolean -DMesaMakeCurrent (DMesaContext dmesa, DMesaBuffer buffer) -{ - if (dmesa == NULL || buffer == NULL) { - ctx = NULL; - return GL_TRUE; - } - if (OSMesaMakeCurrent(dmesa->osmesa, buffer->the_window, - buffer->type, - buffer->width, buffer->height) && - vl_sync_buffer(&buffer->the_window, buffer->xpos, buffer->ypos, buffer->width, buffer->height) == 0) { - OSMesaPixelStore(OSMESA_Y_UP, GL_FALSE); - dmesa->buffer = buffer; - ctx = dmesa; - return GL_TRUE; - } - return GL_FALSE; -} - - -void -DMesaSwapBuffers (DMesaBuffer buffer) -{ - /* copy/swap back buffer to front if applicable */ - GET_CURRENT_CONTEXT(ctx); - _mesa_notifySwapBuffers(ctx); - vl_flip(); - (void)buffer; -} - - -void -DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue) -{ - vl_setCI(ndx, red, green, blue); -} - - -DMesaContext -DMesaGetCurrentContext (void) -{ - return ctx; -} - - -DMesaBuffer -DMesaGetCurrentBuffer (void) -{ - const DMesaContext dmesa = DMesaGetCurrentContext(); - - if (dmesa != NULL) { - return dmesa->buffer; - } - - return NULL; -} - - -DMesaProc -DMesaGetProcAddress (const char *name) -{ - DMesaProc p = (DMesaProc)_glapi_get_proc_address(name); - - /* TODO: handle DMesa* namespace - if (p == NULL) { - } - */ - - return p; -} - - -int -DMesaGetIntegerv (GLenum pname, GLint *params) -{ - switch (pname) { - case DMESA_GET_SCREEN_SIZE: - vl_get(VL_GET_SCREEN_SIZE, params); - break; - case DMESA_GET_DRIVER_CAPS: - params[0] = 0; - break; - case DMESA_GET_VIDEO_MODES: - return vl_get(VL_GET_VIDEO_MODES, params); - case DMESA_GET_BUFFER_ADDR: { - const DMesaContext dmesa = DMesaGetCurrentContext(); - if (dmesa != NULL) { - DMesaBuffer b = dmesa->buffer; - if (b != NULL) { - params[0] = (GLint)b->the_window; - } - } - break; - } - default: - return -1; - } - - return 0; -} diff --git a/src/mesa/drivers/dos/dpmi.c b/src/mesa/drivers/dos/dpmi.c deleted file mode 100644 index bd33b8856c..0000000000 --- a/src/mesa/drivers/dos/dpmi.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@yahoo.com - * Web : http://www.geocities.com/dborca - */ - - -#include - -#include "internal.h" - - -#ifndef MAX -#define MAX(x, y) (((x) < (y)) ? (y) : (x)) -#endif - - -/* _create_linear_mapping: - * Maps a physical address range into linear memory. - */ -int -_create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size) -{ - __dpmi_meminfo meminfo; - - if (physaddr >= 0x100000) { - /* map into linear memory */ - meminfo.address = physaddr; - meminfo.size = size; - if (__dpmi_physical_address_mapping(&meminfo) != 0) { - return -1; - } - - *linear = meminfo.address; - } else { - /* exploit 1 -> 1 physical to linear mapping in low megabyte */ - *linear = physaddr; - } - - return 0; -} - - -/* _remove_linear_mapping: - * Frees the DPMI resources being used to map a linear address range. - */ -void -_remove_linear_mapping (unsigned long *linear) -{ - __dpmi_meminfo meminfo; - - if (*linear) { - if (*linear >= 0x100000) { - meminfo.address = *linear; - __dpmi_free_physical_address_mapping(&meminfo); - } - - *linear = 0; - } -} - - -/* _create_selector: - * Allocates a selector to access a region of linear memory. - */ -int -_create_selector (int *segment, unsigned long base, int size) -{ - /* allocate an ldt descriptor */ - if ((*segment=__dpmi_allocate_ldt_descriptors(1)) < 0) { - *segment = 0; - return -1; - } - - /* create the linear mapping */ - if (_create_linear_mapping(&base, base, size)) { - __dpmi_free_ldt_descriptor(*segment); - *segment = 0; - return -1; - } - - /* set the descriptor base and limit */ - __dpmi_set_segment_base_address(*segment, base); - __dpmi_set_segment_limit(*segment, MAX(size-1, 0xFFFF)); - - return 0; -} - - -/* _remove_selector: - * Frees a DPMI segment selector. - */ -void -_remove_selector (int *segment) -{ - if (*segment) { - unsigned long base; - __dpmi_get_segment_base_address(*segment, &base); - _remove_linear_mapping(&base); - __dpmi_free_ldt_descriptor(*segment); - *segment = 0; - } -} - - -/* Desc: retrieve CPU MMX capability - * - * In : - - * Out : FALSE if CPU cannot do MMX - * - * Note: - - */ -int -_can_mmx (void) -{ -#ifdef USE_MMX_ASM - int x86_cpu_features = 0; - __asm("\n\ - pushfl \n\ - popl %%eax \n\ - movl %%eax, %%ecx \n\ - xorl $0x200000, %%eax\n\ - pushl %%eax \n\ - popfl \n\ - pushfl \n\ - popl %%eax \n\ - pushl %%ecx \n\ - popfl \n\ - xorl %%ecx, %%eax \n\ - jz 0f \n\ - movl $1, %%eax \n\ - cpuid \n\ - movl %%edx, %0 \n\ - 0: \n\ - ":"=g"(x86_cpu_features)::"%eax", "%ebx", "%ecx", "%edx"); - return (x86_cpu_features & 0x00800000); -#else - return 0; -#endif -} diff --git a/src/mesa/drivers/dos/internal.h b/src/mesa/drivers/dos/internal.h deleted file mode 100644 index 0fa7c77222..0000000000 --- a/src/mesa/drivers/dos/internal.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@users.sourceforge.net - * Web : http://www.geocities.com/dborca - */ - - -#ifndef INTERNAL_H_included -#define INTERNAL_H_included - -#include "../main/mtypes.h" - - -/* - * general purpose defines, etc. - */ -#ifndef FALSE -#define FALSE 0 -#define TRUE !FALSE -#endif - -#define __PACKED__ __attribute__((packed)) - -typedef unsigned char word8; -typedef unsigned short word16; -typedef unsigned long word32; - -#define _16_ *(word16 *)& -#define _32_ *(word32 *)& - -typedef void (*BLTFUNC) (void); - - -/* - * video mode structure - */ -typedef struct vl_mode { - int xres, yres; - int bpp; - - int mode; - int scanlen; - - int sel; - int gran; -} vl_mode; - - -/* - * video driver structure - */ -typedef struct { - vl_mode *(*init) (void); - int (*entermode) (vl_mode *p, int refresh, int fbbits); - void (*blit) (void); - void (*setCI_f) (int index, float red, float green, float blue); - void (*setCI_i) (int index, int red, int green, int blue); - int (*get) (int pname, int *params); - void (*restore) (void); - void (*fini) (void); -} vl_driver; - - -/* - * memory mapping - */ -int _create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size); -void _remove_linear_mapping (unsigned long *linear); -int _create_selector (int *segment, unsigned long base, int size); -void _remove_selector (int *segment); - - -/* - * system routines - */ -int _can_mmx (void); - - -#endif diff --git a/src/mesa/drivers/dos/null.c b/src/mesa/drivers/dos/null.c deleted file mode 100644 index 55846299fb..0000000000 --- a/src/mesa/drivers/dos/null.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@users.sourceforge.net - * Web : http://www.geocities.com/dborca - */ - - -#include -#include - -#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 NUL, 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 - }; - const unsigned int m_count = sizeof(m) / sizeof(m[0]); - const unsigned int b_count = sizeof(b) / sizeof(b[0]); - - unsigned int i, j, k; - - if (modes == NULL) { - modes = malloc(sizeof(vl_mode) * (1 + m_count * b_count)); - - if (modes != NULL) { - for (k = 0, i = 0; i < m_count; i++) { - for (j = 0; j < b_count; 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 NUL init code. - * - * In : - - * Out : - - * - * Note: - - */ -static void -null_fini (void) -{ - if (modes != NULL) { - free(modes); - modes = NULL; - } -} - - -/* 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, int fbbits) -{ - NUL.blit = null_blit_nop; - - return 0; - - (void)(p && refresh && fbbits); /* 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 deleted file mode 100644 index bbdc7966e0..0000000000 --- a/src/mesa/drivers/dos/null.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@yahoo.com - * 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/vesa.c b/src/mesa/drivers/dos/vesa.c deleted file mode 100644 index 3fdd3e25db..0000000000 --- a/src/mesa/drivers/dos/vesa.c +++ /dev/null @@ -1,719 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@users.sourceforge.net - * Web : http://www.geocities.com/dborca - */ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "video.h" -#include "vesa.h" - - -static vl_mode modes[128]; - -static word16 vesa_ver; -static int banked_selector, linear_selector; -static int oldmode = -1; - -static int vesa_color_precision = 6; - -static word16 *vesa_pmcode; -unsigned int vesa_gran_mask, vesa_gran_shift; - - -/* - * VESA info - */ -#define V_SIGN 0 -#define V_MINOR 4 -#define V_MAJOR 5 -#define V_OEM_OFS 6 -#define V_OEM_SEG 8 -#define V_MODE_OFS 14 -#define V_MODE_SEG 16 -#define V_MEMORY 18 - -/* - * mode info - */ -#define M_ATTR 0 -#define M_GRAN 4 -#define M_SCANLEN 16 -#define M_XRES 18 -#define M_YRES 20 -#define M_BPP 25 -#define M_RED 31 -#define M_GREEN 33 -#define M_BLUE 35 -#define M_PHYS_PTR 40 - -/* - * VESA 3.0 CRTC timings structure - */ -typedef struct CRTCInfoBlock { - unsigned short HorizontalTotal; - unsigned short HorizontalSyncStart; - unsigned short HorizontalSyncEnd; - unsigned short VerticalTotal; - unsigned short VerticalSyncStart; - unsigned short VerticalSyncEnd; - unsigned char Flags; - unsigned long PixelClock; /* units of Hz */ - unsigned short RefreshRate; /* units of 0.01 Hz */ - unsigned char reserved[40]; -} __PACKED__ CRTCInfoBlock; - -#define HNEG (1 << 2) -#define VNEG (1 << 3) -#define DOUBLESCAN (1 << 0) - - -/* Desc: Attempts to detect VESA, check video modes and create selectors. - * - * In : - - * Out : mode array - * - * Note: - - */ -static vl_mode * -vesa_init (void) -{ - __dpmi_regs r; - word16 *p; - vl_mode *q; - char vesa_info[512], tmp[512]; - int maxsize = 0; - word32 linearfb = 0; - - if (vesa_ver) { - return modes; - } - - _farpokel(_stubinfo->ds_selector, 0, 0x32454256); - r.x.ax = 0x4f00; - r.x.di = 0; - r.x.es = _stubinfo->ds_segment; - __dpmi_int(0x10, &r); - movedata(_stubinfo->ds_selector, 0, _my_ds(), (unsigned)vesa_info, 512); - if ((r.x.ax != 0x004f) || ((_32_ vesa_info[V_SIGN]) != 0x41534556)) { - return NULL; - } - - p = (word16 *)(((_16_ vesa_info[V_MODE_SEG]) << 4) + (_16_ vesa_info[V_MODE_OFS])); - q = modes; - do { - if ((q->mode = _farpeekw(__djgpp_dos_sel, (unsigned long)(p++))) == 0xffff) { - break; - } - - r.x.ax = 0x4f01; - r.x.cx = q->mode; - r.x.di = 512; - r.x.es = _stubinfo->ds_segment; - __dpmi_int(0x10, &r); - movedata(_stubinfo->ds_selector, 512, _my_ds(), (unsigned)tmp, 256); - switch (tmp[M_BPP]) { - case 16: - q->bpp = tmp[M_RED] + tmp[M_GREEN] + tmp[M_BLUE]; - break; - case 8: - case 15: - case 24: - case 32: - q->bpp = tmp[M_BPP]; - break; - default: - q->bpp = 0; - } - if ((r.x.ax == 0x004f) && ((tmp[M_ATTR] & 0x11) == 0x11) && q->bpp) { - q->xres = _16_ tmp[M_XRES]; - q->yres = _16_ tmp[M_YRES]; - q->scanlen = _16_ tmp[M_SCANLEN]; - q->gran = (_16_ tmp[M_GRAN]) << 10; - if (tmp[M_ATTR] & 0x80) { - vl_mode *q1 = q + 1; - *q1 = *q++; - linearfb = _32_ tmp[M_PHYS_PTR]; - q->mode |= 0x4000; - } - if (maxsize < (q->scanlen * q->yres)) { - maxsize = q->scanlen * q->yres; - } - q++; - } - } while (TRUE); - - if (q == modes) { - return NULL; - } - if (_create_selector(&banked_selector, 0xa0000, modes[0].gran)) { - return NULL; - } - if (linearfb) { - maxsize = ((maxsize + 0xfffUL) & ~0xfffUL); - if (_create_selector(&linear_selector, linearfb, maxsize)) { - linear_selector = banked_selector; - } - } - - for (q = modes; q->mode != 0xffff; q++) { - q->sel = banked_selector; - if (q->mode & 0x4000) { - if (linear_selector != banked_selector) { - q->sel = linear_selector; - } else { - q->mode &= ~0x4000; - } - } - } - - if (vesa_info[V_MAJOR] >= 2) { - r.x.ax = 0x4f0a; - r.x.bx = 0; - __dpmi_int(0x10, &r); - if (r.x.ax == 0x004f) { - vesa_pmcode = (word16 *)malloc(r.x.cx); - if (vesa_pmcode != NULL) { - movedata(__djgpp_dos_sel, (r.x.es << 4) + r.x.di, _my_ds(), (unsigned)vesa_pmcode, r.x.cx); - if (vesa_pmcode[3]) { - p = (word16 *)((long)vesa_pmcode + vesa_pmcode[3]); - while (*p++ != 0xffff) { - } - } else { - p = NULL; - } - if (p && (*p != 0xffff)) { - free(vesa_pmcode); - vesa_pmcode = NULL; - } else { - vesa_swbank = (void *)((long)vesa_pmcode + vesa_pmcode[0]); - } - } - } - } - - vesa_ver = _16_ vesa_info[V_MINOR]; - return modes; -} - - -/* Desc: Frees all resources allocated by VESA init code. - * - * In : - - * Out : - - * - * Note: - - */ -static void -vesa_fini (void) -{ - if (vesa_ver) { - _remove_selector(&linear_selector); - _remove_selector(&banked_selector); - if (vesa_pmcode != NULL) { - free(vesa_pmcode); - vesa_pmcode = NULL; - } - } -} - - -/* Desc: Uses VESA 3.0 function 0x4F0B to find the closest pixel clock to the requested value. - * - * In : mode, clock - * Out : desired clock - * - * Note: - - */ -static unsigned long -_closest_pixclk (int mode_no, unsigned long vclk) -{ - __dpmi_regs r; - - r.x.ax = 0x4F0B; - r.h.bl = 0; - r.d.ecx = vclk; - r.x.dx = mode_no; - __dpmi_int(0x10, &r); - - return (r.x.ax == 0x004f) ? r.d.ecx : 0; -} - - -/* Desc: Calculates CRTC mode timings. - * - * In : crtc block, geometry, adjust - * Out : - * - * Note: - */ -static void -_crtc_timing (CRTCInfoBlock *crtc, int xres, int yres, int xadjust, int yadjust) -{ - int HTotal, VTotal; - int HDisp, VDisp; - int HSS, VSS; - int HSE, VSE; - int HSWidth, VSWidth; - int SS, SE; - int doublescan = FALSE; - - if (yres < 400) { - doublescan = TRUE; - yres *= 2; - } - - HDisp = xres; - HTotal = (int)(HDisp * 1.27) & ~0x7; - HSWidth = (int)((HTotal - HDisp) / 5) & ~0x7; - HSS = HDisp + 16; - HSE = HSS + HSWidth; - VDisp = yres; - VTotal = VDisp * 1.07; - VSWidth = (VTotal / 100) + 1; - VSS = VDisp + ((int)(VTotal - VDisp) / 5) + 1; - VSE = VSS + VSWidth; - - SS = HSS + xadjust; - SE = HSE + xadjust; - - if (xadjust < 0) { - if (SS < (HDisp + 8)) { - SS = HDisp + 8; - SE = SS + HSWidth; - } - } else { - if ((HTotal - 24) < SE) { - SE = HTotal - 24; - SS = SE - HSWidth; - } - } - - HSS = SS; - HSE = SE; - - SS = VSS + yadjust; - SE = VSE + yadjust; - - if (yadjust < 0) { - if (SS < (VDisp + 3)) { - SS = VDisp + 3; - SE = SS + VSWidth; - } - } else { - if ((VTotal - 4) < SE) { - SE = VTotal - 4; - SS = SE - VSWidth; - } - } - - VSS = SS; - VSE = SE; - - crtc->HorizontalTotal = HTotal; - crtc->HorizontalSyncStart = HSS; - crtc->HorizontalSyncEnd = HSE; - crtc->VerticalTotal = VTotal; - crtc->VerticalSyncStart = VSS; - crtc->VerticalSyncEnd = VSE; - crtc->Flags = HNEG | VNEG; - - if (doublescan) { - crtc->Flags |= DOUBLESCAN; - } -} - - -/* Desc: Attempts to choose a suitable blitter. - * - * In : ptr to mode structure, software framebuffer bits - * Out : blitter funciton, or NULL - * - * Note: - - */ -static BLTFUNC -_choose_blitter (vl_mode *p, int fbbits) -{ - BLTFUNC blitter; - - if (p->mode & 0x4000) { - blitter = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual; - switch (p->bpp) { - case 8: - switch (fbbits) { - case 8: - break; - case 16: - blitter = vesa_l_dump_16_to_8; - break; - case 24: - blitter = vesa_l_dump_24_to_8; - break; - case 32: - blitter = vesa_l_dump_32_to_8; - break; - case 15: - default: - return NULL; - } - break; - case 15: - switch (fbbits) { - case 16: - blitter = vesa_l_dump_16_to_15; - break; - case 32: - blitter = vesa_l_dump_32_to_15; - break; - case 8: - case 15: - case 24: - default: - return NULL; - } - break; - case 16: - switch (fbbits) { - case 16: - break; - case 32: - blitter = vesa_l_dump_32_to_16; - break; - case 8: - case 15: - case 24: - default: - return NULL; - } - break; - case 24: - switch (fbbits) { - case 24: - break; - case 32: - blitter = vesa_l_dump_32_to_24; - break; - case 8: - case 15: - case 16: - default: - return NULL; - } - break; - case 32: - switch (fbbits) { - case 24: - blitter = vesa_l_dump_24_to_32; - break; - case 32: - break; - case 8: - case 15: - case 16: - default: - return NULL; - } - break; - } - } else { - blitter = vesa_b_dump_virtual; - switch (p->bpp) { - case 8: - switch (fbbits) { - case 8: - break; - case 16: - blitter = vesa_b_dump_16_to_8; - break; - case 24: - blitter = vesa_b_dump_24_to_8; - break; - case 32: - blitter = vesa_b_dump_32_to_8; - break; - case 15: - default: - return NULL; - } - break; - case 15: - switch (fbbits) { - case 16: - blitter = vesa_b_dump_16_to_15; - break; - case 32: - blitter = vesa_b_dump_32_to_15; - break; - case 8: - case 15: - case 24: - default: - return NULL; - } - break; - case 16: - switch (fbbits) { - case 16: - break; - case 32: - blitter = vesa_b_dump_32_to_16; - break; - case 8: - case 15: - case 24: - default: - return NULL; - } - break; - case 24: - switch (fbbits) { - case 24: - break; - case 32: - blitter = vesa_b_dump_32_to_24; - break; - case 8: - case 15: - case 16: - default: - return NULL; - } - break; - case 32: - switch (fbbits) { - case 24: - blitter = vesa_b_dump_24_to_32; - break; - case 32: - break; - case 8: - case 15: - case 16: - default: - return NULL; - } - break; - } - } - - return blitter; -} - - -/* Desc: Attempts to enter specified video mode. - * - * In : ptr to mode structure, refresh rate - * Out : 0 if success - * - * Note: - - */ -static int -vesa_entermode (vl_mode *p, int refresh, int fbbits) -{ - __dpmi_regs r; - - if (!(p->mode & 0x4000)) { - { int n; for (vesa_gran_shift = 0, n = p->gran; n; vesa_gran_shift++, n >>= 1); } - vesa_gran_mask = (1 << (--vesa_gran_shift)) - 1; - if ((unsigned)p->gran != (vesa_gran_mask + 1)) { - return !0; - } - } - - VESA.blit = _choose_blitter(p, fbbits); - if (VESA.blit == NULL) { - return !0; - } - - if (oldmode == -1) { - r.x.ax = 0x4f03; - __dpmi_int(0x10, &r); - oldmode = r.x.bx; - } - - r.x.ax = 0x4f02; - r.x.bx = p->mode; - - if (refresh && ((vesa_ver >> 8) >= 3)) { - /* VESA 3.0 stuff for controlling the refresh rate */ - CRTCInfoBlock crtc; - unsigned long vclk; - double f0; - - _crtc_timing(&crtc, p->xres, p->yres, 0, 0); - - vclk = (double)crtc.HorizontalTotal * crtc.VerticalTotal * refresh; - vclk = _closest_pixclk(p->mode, vclk); - - if (vclk != 0) { - f0 = (double)vclk / (crtc.HorizontalTotal * crtc.VerticalTotal); - /*_current_refresh_rate = (int)(f0 + 0.5);*/ - - crtc.PixelClock = vclk; - crtc.RefreshRate = refresh * 100; - - movedata(_my_ds(), (unsigned)&crtc, _stubinfo->ds_selector, 0, sizeof(crtc)); - - r.x.di = 0; - r.x.es = _stubinfo->ds_segment; - r.x.bx |= 0x0800; - } - } - - __dpmi_int(0x10, &r); - if (r.x.ax != 0x004f) { - return !0; - } - - if (p->bpp == 8) { - r.x.ax = 0x4f08; - r.x.bx = 0x0800; - __dpmi_int(0x10, &r); - if (r.x.ax == 0x004f) { - r.x.ax = 0x4f08; - r.h.bl = 0x01; - __dpmi_int(0x10, &r); - vesa_color_precision = r.h.bh; - } - } - - return 0; -} - - -/* Desc: Restores to the mode prior to first call to vesa_entermode. - * - * In : - - * Out : - - * - * Note: - - */ -static void -vesa_restore (void) -{ - __dpmi_regs r; - - if (oldmode != -1) { - if (oldmode < 0x100) { - __asm("int $0x10"::"a"(oldmode)); - } else { - r.x.ax = 0x4f02; - r.x.bx = oldmode; - __dpmi_int(0x10, &r); - } - oldmode = -1; - } -} - - -/* Desc: set one palette entry - * - * In : color index, R, G, B - * Out : - - * - * Note: uses integer values - */ -static void -vesa_setCI_i (int index, int red, int green, int blue) -{ -#if 0 - __asm("\n\ - movw $0x1010, %%ax \n\ - movb %1, %%dh \n\ - movb %2, %%ch \n\ - int $0x10 \n\ - "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx"); -#else - outportb(0x03C8, index); - outportb(0x03C9, red); - outportb(0x03C9, green); - outportb(0x03C9, blue); -#endif -} - - -/* Desc: set one palette entry - * - * In : color index, R, G, B - * Out : - - * - * Note: uses normalized values - */ -static void -vesa_setCI_f (int index, float red, float green, float blue) -{ - float max = (1 << vesa_color_precision) - 1; - - vesa_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 -vesa_get (int pname, int *params) -{ - switch (pname) { - case VL_GET_CI_PREC: - params[0] = vesa_color_precision; - break; - default: - return -1; - } - return 0; -} - - -/* - * the driver - */ -vl_driver VESA = { - vesa_init, - vesa_entermode, - NULL, - vesa_setCI_f, - vesa_setCI_i, - vesa_get, - vesa_restore, - vesa_fini -}; diff --git a/src/mesa/drivers/dos/vesa.h b/src/mesa/drivers/dos/vesa.h deleted file mode 100644 index 4b3c3ab832..0000000000 --- a/src/mesa/drivers/dos/vesa.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@yahoo.com - * Web : http://www.geocities.com/dborca - */ - - -#ifndef VESA_H_included -#define VESA_H_included - -#include "internal.h" - -extern void *vesa_swbank; - -extern void vesa_b_dump_virtual (void); -extern void vesa_l_dump_virtual (void); -extern void vesa_l_dump_virtual_mmx (void); - -extern void vesa_l_dump_32_to_24 (void); -extern void vesa_l_dump_32_to_16 (void); -extern void vesa_l_dump_32_to_15 (void); -extern void vesa_l_dump_32_to_8 (void); -extern void vesa_l_dump_24_to_32 (void); -extern void vesa_l_dump_24_to_8 (void); -extern void vesa_l_dump_16_to_15 (void); -extern void vesa_l_dump_16_to_8 (void); - -extern void vesa_b_dump_32_to_24 (void); -extern void vesa_b_dump_32_to_16 (void); -extern void vesa_b_dump_32_to_15 (void); -extern void vesa_b_dump_32_to_8 (void); -extern void vesa_b_dump_24_to_32 (void); -extern void vesa_b_dump_24_to_8 (void); -extern void vesa_b_dump_16_to_15 (void); -extern void vesa_b_dump_16_to_8 (void); - -extern vl_driver VESA; - -#endif diff --git a/src/mesa/drivers/dos/vga.c b/src/mesa/drivers/dos/vga.c deleted file mode 100644 index 5a6447dd87..0000000000 --- a/src/mesa/drivers/dos/vga.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@users.sourceforge.net - * Web : http://www.geocities.com/dborca - */ - - -#include -#include - -#include "video.h" -#include "vga.h" - - -static vl_mode modes[] = { - { - /* .xres = */ 320, - /* .yres = */ 200, - /* .bpp = */ 8, - /* .mode = */ 0x13 | 0x4000, - /* .scanlen = */ 320, - /* .sel = */ -1, - /* .gran = */ 320*200 - }, - { - /* .xres = */ -1, - /* .yres = */ -1, - /* .bpp = */ -1, - /* .mode = */ 0xffff, - /* .scanlen = */ -1, - /* .sel = */ -1, - /* .gran = */ -1 - } -}; - -static word16 vga_ver; -static int linear_selector; -static int oldmode = -1; - -#define vga_color_precision 6 - - -/* Desc: Attempts to detect VGA, check video modes and create selectors. - * - * In : - - * Out : mode array - * - * Note: - - */ -static vl_mode * -vga_init (void) -{ - int rv = 0; - - if (vga_ver) { - return modes; - } - - __asm("\n\ - movw $0x1a00, %%ax \n\ - int $0x10 \n\ - cmpb $0x1a, %%al \n\ - jne 0f \n\ - cmpb $0x07, %%bl \n\ - jb 0f \n\ - andl $0xff, %%ebx \n\ - movl %%ebx, %0 \n\ - 0:":"=g"(rv)::"%eax", "%ebx"); - if (rv == 0) { - return NULL; - } - - if (_create_selector(&linear_selector, 0xa0000, 0x10000)) { - return NULL; - } - - modes[0].sel = linear_selector; - - vga_ver = rv; - return modes; -} - - -/* Desc: Frees all resources allocated by VGA init code. - * - * In : - - * Out : - - * - * Note: - - */ -static void -vga_fini (void) -{ - if (vga_ver) { - _remove_selector(&linear_selector); - } -} - - -/* Desc: Attempts to choose a suitable blitter. - * - * In : ptr to mode structure, software framebuffer bits - * Out : blitter funciton, or NULL - * - * Note: - - */ -static BLTFUNC -_choose_blitter (vl_mode *p, int fbbits) -{ - BLTFUNC blitter; - - switch (fbbits) { - case 8: - blitter = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual; - break; - case 16: - blitter = vesa_l_dump_16_to_8; - break; - case 24: - blitter = vesa_l_dump_24_to_8; - break; - case 32: - blitter = vesa_l_dump_32_to_8; - break; - default: - return NULL; - } - - return blitter; - - (void)p; -} - - -/* Desc: Attempts to enter specified video mode. - * - * In : ptr to mode structure, refresh rate - * Out : 0 if success - * - * Note: - - */ -static int -vga_entermode (vl_mode *p, int refresh, int fbbits) -{ - if (!(p->mode & 0x4000)) { - return -1; - } - - VGA.blit = _choose_blitter(p, fbbits); - if (VGA.blit == NULL) { - return !0; - } - - if (oldmode == -1) { - __asm("\n\ - movb $0x0f, %%ah \n\ - int $0x10 \n\ - andl $0xff, %%eax \n\ - movl %%eax, %0 \n\ - ":"=g"(oldmode)::"%eax", "%ebx"); - } - - __asm("int $0x10"::"a"(p->mode&0xff)); - - return 0; - - (void)refresh; /* silence compiler warning */ -} - - -/* Desc: Restores to the mode prior to first call to vga_entermode. - * - * In : - - * Out : - - * - * Note: - - */ -static void -vga_restore (void) -{ - if (oldmode != -1) { - __asm("int $0x10"::"a"(oldmode)); - oldmode = -1; - } -} - - -/* Desc: set one palette entry - * - * In : color index, R, G, B - * Out : - - * - * Note: uses integer values - */ -static void -vga_setCI_i (int index, int red, int green, int blue) -{ -#if 0 - __asm("\n\ - movw $0x1010, %%ax \n\ - movb %1, %%dh \n\ - movb %2, %%ch \n\ - int $0x10 \n\ - "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx"); -#else - outportb(0x03C8, index); - outportb(0x03C9, red); - outportb(0x03C9, green); - outportb(0x03C9, blue); -#endif -} - - -/* Desc: set one palette entry - * - * In : color index, R, G, B - * Out : - - * - * Note: uses normalized values - */ -static void -vga_setCI_f (int index, float red, float green, float blue) -{ - float max = (1 << vga_color_precision) - 1; - - vga_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 -vga_get (int pname, int *params) -{ - switch (pname) { - case VL_GET_CI_PREC: - params[0] = vga_color_precision; - break; - default: - return -1; - } - return 0; -} - - -/* - * the driver - */ -vl_driver VGA = { - vga_init, - vga_entermode, - NULL, - vga_setCI_f, - vga_setCI_i, - vga_get, - vga_restore, - vga_fini -}; diff --git a/src/mesa/drivers/dos/vga.h b/src/mesa/drivers/dos/vga.h deleted file mode 100644 index 7c17625a3c..0000000000 --- a/src/mesa/drivers/dos/vga.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@yahoo.com - * Web : http://www.geocities.com/dborca - */ - - -#ifndef VGA_H_included -#define VGA_H_included - -#include "internal.h" -#include "vesa.h" - -extern vl_driver VGA; - -#endif diff --git a/src/mesa/drivers/dos/video.c b/src/mesa/drivers/dos/video.c deleted file mode 100644 index 468207fbf6..0000000000 --- a/src/mesa/drivers/dos/video.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@users.sourceforge.net - * Web : http://www.geocities.com/dborca - * - * Thanks to CrazyPyro (Neil Funk) for FakeColor - */ - - -#include - -#include "internal.h" -#include "vesa.h" -#include "vga.h" -#include "null.h" -#include "video.h" - - -static vl_driver *drv; -/* based upon mode specific data: valid entire session */ -int vl_video_selector; -static vl_mode *video_mode; -static int video_scanlen, video_bypp; -/* valid until next buffer */ -void *vl_current_draw_buffer, *vl_current_read_buffer; -int vl_current_stride, vl_current_width, vl_current_height, vl_current_bytes; -int vl_current_offset, vl_current_delta; - - -void (*vl_flip) (void); - - -/* FakeColor data */ -#define R_CNT 6 -#define G_CNT 6 -#define B_CNT 6 - -#define R_BIAS 7 -#define G_BIAS 7 -#define B_BIAS 7 - -static word32 VGAPalette[256]; -word8 array_r[256]; -word8 array_g[256]; -word8 array_b[256]; -word8 tab_16_8[0x10000]; - - -/* lookup table for scaling 5 bit colors up to 8 bits */ -static int _rgb_scale_5[32] = { - 0, 8, 16, 25, 33, 41, 49, 58, - 66, 74, 82, 90, 99, 107, 115, 123, - 132, 140, 148, 156, 165, 173, 181, 189, - 197, 206, 214, 222, 230, 239, 247, 255 -}; - -/* lookup table for scaling 6 bit colors up to 8 bits */ -static int _rgb_scale_6[64] = { - 0, 4, 8, 12, 16, 20, 24, 28, - 32, 36, 40, 45, 49, 53, 57, 61, - 65, 69, 73, 77, 81, 85, 89, 93, - 97, 101, 105, 109, 113, 117, 121, 125, - 130, 134, 138, 142, 146, 150, 154, 158, - 162, 166, 170, 174, 178, 182, 186, 190, - 194, 198, 202, 206, 210, 215, 219, 223, - 227, 231, 235, 239, 243, 247, 251, 255 -}; - - -/* Desc: color composition (w/o ALPHA) - * - * In : array of integers (R, G, B) - * Out : color - * - * Note: - - */ -static int -v_mixrgb8fake (const unsigned char rgb[]) -{ - return array_b[rgb[2]]*G_CNT*R_CNT - + array_g[rgb[1]]*R_CNT - + array_r[rgb[0]]; -} - - -/* Desc: color decomposition - * - * In : pixel offset, array of integers to hold color components (R, G, B, A) - * Out : - - * - * Note: uses current read buffer - */ -static void -v_getrgb8fake6 (unsigned int offset, unsigned char rgb[]) -{ - word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]]; - rgb[0] = _rgb_scale_6[(c >> 16) & 0x3F]; - rgb[1] = _rgb_scale_6[(c >> 8) & 0x3F]; - rgb[2] = _rgb_scale_6[ c & 0x3F]; -} -static void -v_getrgb8fake8 (unsigned int offset, unsigned char rgb[]) -{ - word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]]; - rgb[0] = c >> 16; - rgb[1] = c >> 8; - rgb[2] = c; -} - - -/* Desc: create R5G6B5 to FakeColor table lookup - * - * In : - - * Out : - - * - * Note: - - */ -static void -init_tab_16_8 (void) -{ - int i; - for (i = 0; i < 0x10000; i++) { - unsigned char rgb[3]; - rgb[0] = _rgb_scale_5[(i >> 11) & 0x1F]; - rgb[1] = _rgb_scale_6[(i >> 5) & 0x3F]; - rgb[2] = _rgb_scale_5[ i & 0x1F]; - tab_16_8[i] = v_mixrgb8fake(rgb); - } - (void)v_getrgb8fake6; - (void)v_getrgb8fake8; -} - - -/* Desc: set one palette entry - * - * In : index, R, G, B - * Out : - - * - * Note: color components are in range [0.0 .. 1.0] - */ -void -vl_setCI (int index, float red, float green, float blue) -{ - drv->setCI_f(index, red, green, blue); -} - - -/* Desc: set one palette entry - * - * In : color, R, G, B - * Out : - - * - * Note: - - */ -static void -fake_setcolor (int c, int r, int g, int b) -{ - VGAPalette[c] = 0xff000000 | (r<<16) | (g<<8) | b; - - drv->setCI_i(c, r, g, b); -} - - -/* Desc: build FakeColor palette - * - * In : CI precision in bits - * Out : - - * - * Note: - - */ -static void -fake_buildpalette (int bits) -{ - double c_r, c_g, c_b; - int r, g, b, color = 0; - - double max = (1 << bits) - 1; - - for (b = 0; b < B_CNT; ++b) { - for (g = 0; g < G_CNT; ++g) { - for (r = 0; r < R_CNT; ++r) { - c_r = 0.5 + (double)r * (max-R_BIAS) / (R_CNT-1.) + R_BIAS; - c_g = 0.5 + (double)g * (max-G_BIAS) / (G_CNT-1.) + G_BIAS; - c_b = 0.5 + (double)b * (max-B_BIAS) / (B_CNT-1.) + B_BIAS; - fake_setcolor(color++, (int)c_r, (int)c_g, (int)c_b); - } - } - } - - for (color = 0; color < 256; color++) { - c_r = (double)color * R_CNT / 256.; - c_g = (double)color * G_CNT / 256.; - c_b = (double)color * B_CNT / 256.; - array_r[color] = (int)c_r; - array_g[color] = (int)c_g; - array_b[color] = (int)c_b; - } -} - - -/* Desc: initialize hardware - * - * In : - - * Out : list of available modes - * - * Note: when returning non-NULL, global variable `drv' is guaranteed to be ok - */ -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; - } else if ((q = VGA.init()) != NULL) { - drv = &VGA; - } else { - drv = NULL; - } - } - - return q; -} - - -/* Desc: sync buffer with video hardware - * - * In : ptr to old buffer, position, size - * Out : 0 if success - * - * Note: - - */ -int -vl_sync_buffer (void **buffer, int x, int y, int width, int height) -{ - if ((/*XXX*/width & 7) || (x < 0) || (y < 0) || (x+width > video_mode->xres) || (y+height > video_mode->yres)) { - return -1; - } else { - void *newbuf = *buffer; - - if ((newbuf == NULL) || (vl_current_width != width) || (vl_current_height != height)) { - newbuf = realloc(newbuf, width * height * video_bypp); - } - - if (newbuf == NULL) { - return -2; - } - - vl_current_width = width; - vl_current_height = height; - vl_current_stride = vl_current_width * video_bypp; - vl_current_bytes = vl_current_stride * height; - - vl_current_offset = video_scanlen * y + video_bypp * x; - vl_current_delta = video_scanlen - vl_current_stride; - - vl_current_draw_buffer = vl_current_read_buffer = *buffer = newbuf; - return 0; - } -} - - -/* Desc: state retrieval - * - * In : name, storage - * Out : -1 for an error - * - * Note: - - */ -int -vl_get (int pname, int *params) -{ - switch (pname) { - case VL_GET_SCREEN_SIZE: - params[0] = video_mode->xres; - params[1] = video_mode->yres; - break; - case VL_GET_VIDEO_MODES: { - int n; - vl_mode *q; - if ((q = v_init_hw()) == NULL) { - return -1; - } - /* count available visuals */ - for (n = 0; q->mode != 0xffff; q++) { - if ((q + 1)->mode == (q->mode | 0x4000)) { - /* same mode, but linear */ - q++; - } - if (params) { - params[n] = (int)q; - } - n++; - } - return n; - } - default: - return (drv != NULL) ? drv->get(pname, params) : -1; - } - return 0; -} - - -/* Desc: setup mode - * - * In : ptr to mode definition - * Out : 0 if success - * - * Note: - - */ -static int -vl_setup_mode (vl_mode *p) -{ - if (p == NULL) { - return -1; - } - - switch (p->bpp) { - case 8: - break; - case 15: - break; - case 16: - break; - case 24: - break; - case 32: - break; - default: - return -1; - } - - video_mode = p; - video_bypp = (p->bpp+7)/8; - video_scanlen = p->scanlen; - vl_video_selector = p->sel; - - return 0; -} - - -/* Desc: restore to the mode prior to first call to `vl_video_init'. - * - * In : - - * Out : - - * - * Note: - - */ -void -vl_video_exit (void) -{ - drv->restore(); - drv->fini(); - video_mode = NULL; -} - - -/* Desc: enter mode - * - * In : xres, yres, bits/pixel, RGB, refresh rate - * Out : pixel width in bits if success - * - * Note: - - */ -int -vl_video_init (int width, int height, int bpp, int rgb, int refresh, int fbbits) -{ - int fake; - vl_mode *p, *q; - unsigned int min; - - fake = 0; - if (!rgb) { - bpp = 8; - } else if (bpp == 8) { - fake = 1; - } - - /* initialize hardware */ - if ((q = v_init_hw()) == NULL) { - return 0; - } - - /* search for a mode that fits our request */ - for (min = -1, p = NULL; q->mode != 0xffff; q++) { - if ((q->xres >= width) && (q->yres >= height) && (q->bpp == bpp)) { - if (min >= (unsigned)(q->xres * q->yres)) { - min = q->xres * q->yres; - p = q; - } - } - } - - /* setup and enter mode */ - if ((vl_setup_mode(p) == 0) && (drv->entermode(p, refresh, fbbits) == 0)) { - vl_flip = drv->blit; - if (fake) { - drv->get(VL_GET_CI_PREC, (int *)(&min)); - fake_buildpalette(min); - init_tab_16_8(); - } - return bpp; - } - - /* abort */ - return 0; -} diff --git a/src/mesa/drivers/dos/video.h b/src/mesa/drivers/dos/video.h deleted file mode 100644 index e084116742..0000000000 --- a/src/mesa/drivers/dos/video.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@users.sourceforge.net - * Web : http://www.geocities.com/dborca - */ - - -#ifndef VIDEO_H_included -#define VIDEO_H_included - -typedef int fixed; - -#define VL_GET_CARD_NAME 0x0100 -#define VL_GET_VRAM 0x0101 -#define VL_GET_CI_PREC 0x0200 -#define VL_GET_HPIXELS 0x0201 -#define VL_GET_SCREEN_SIZE 0x0202 -#define VL_GET_VIDEO_MODES 0x0300 - -extern void (*vl_flip) (void); - -void vl_setCI (int index, float red, float green, float blue); - -int vl_sync_buffer (void **buffer, int x, int y, int width, int height); -int vl_get (int pname, int *params); - -void vl_video_exit (void); -int vl_video_init (int width, int height, int bpp, int rgb, int refresh, int fbbits); - -#endif -- cgit v1.2.3 From 230d263aca86854104645c589d75f2862c50abe6 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 25 Feb 2010 16:00:45 -0500 Subject: Remove GGI support --- Makefile | 11 - progs/ggi/asc-view.c | 377 -------- progs/ggi/blah | 2 - progs/ggi/blat | 7 - progs/ggi/box.asc | 66 -- progs/ggi/cone.asc | 198 ----- progs/ggi/gears.c | 339 -------- progs/ggi/gears2.c | 390 --------- progs/ggi/sphere.asc | 132 --- progs/ggi/torus.asc | 264 ------ progs/ggi/tube.asc | 396 --------- src/glut/ggi/Makefile | 53 -- src/glut/ggi/debug.h | 259 ------ src/glut/ggi/ggiglut.c | 959 --------------------- src/mesa/drivers/ggi/default/.gitignore | 1 - src/mesa/drivers/ggi/default/genkgi.conf.in | 4 - src/mesa/drivers/ggi/default/genkgi.h | 76 -- src/mesa/drivers/ggi/default/genkgi_mode.c | 97 --- src/mesa/drivers/ggi/default/genkgi_visual.c | 190 ---- src/mesa/drivers/ggi/default/linear.c | 409 --------- src/mesa/drivers/ggi/default/linear_15.c | 36 - src/mesa/drivers/ggi/default/linear_16.c | 36 - src/mesa/drivers/ggi/default/linear_24.c | 36 - src/mesa/drivers/ggi/default/linear_32.c | 36 - src/mesa/drivers/ggi/default/linear_8.c | 36 - src/mesa/drivers/ggi/default/stubs.c | 512 ----------- src/mesa/drivers/ggi/display/.gitignore | 1 - src/mesa/drivers/ggi/display/fbdev.conf.in | 4 - src/mesa/drivers/ggi/display/fbdev_mode.c | 130 --- src/mesa/drivers/ggi/display/fbdev_visual.c | 138 --- src/mesa/drivers/ggi/ggimesa.c | 670 -------------- src/mesa/drivers/ggi/ggimesa.conf.in | 13 - src/mesa/drivers/ggi/include/ggi/mesa/debug.h | 260 ------ .../drivers/ggi/include/ggi/mesa/display_fbdev.h | 20 - src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h | 84 -- .../drivers/ggi/include/ggi/mesa/ggimesa_int.h | 44 - 36 files changed, 6286 deletions(-) delete mode 100644 progs/ggi/asc-view.c delete mode 100644 progs/ggi/blah delete mode 100644 progs/ggi/blat delete mode 100644 progs/ggi/box.asc delete mode 100644 progs/ggi/cone.asc delete mode 100644 progs/ggi/gears.c delete mode 100644 progs/ggi/gears2.c delete mode 100644 progs/ggi/sphere.asc delete mode 100644 progs/ggi/torus.asc delete mode 100644 progs/ggi/tube.asc delete mode 100644 src/glut/ggi/Makefile delete mode 100644 src/glut/ggi/debug.h delete mode 100644 src/glut/ggi/ggiglut.c delete mode 100644 src/mesa/drivers/ggi/default/.gitignore delete mode 100644 src/mesa/drivers/ggi/default/genkgi.conf.in delete mode 100644 src/mesa/drivers/ggi/default/genkgi.h delete mode 100644 src/mesa/drivers/ggi/default/genkgi_mode.c delete mode 100644 src/mesa/drivers/ggi/default/genkgi_visual.c delete mode 100644 src/mesa/drivers/ggi/default/linear.c delete mode 100644 src/mesa/drivers/ggi/default/linear_15.c delete mode 100644 src/mesa/drivers/ggi/default/linear_16.c delete mode 100644 src/mesa/drivers/ggi/default/linear_24.c delete mode 100644 src/mesa/drivers/ggi/default/linear_32.c delete mode 100644 src/mesa/drivers/ggi/default/linear_8.c delete mode 100644 src/mesa/drivers/ggi/default/stubs.c delete mode 100644 src/mesa/drivers/ggi/display/.gitignore delete mode 100644 src/mesa/drivers/ggi/display/fbdev.conf.in delete mode 100644 src/mesa/drivers/ggi/display/fbdev_mode.c delete mode 100644 src/mesa/drivers/ggi/display/fbdev_visual.c delete mode 100644 src/mesa/drivers/ggi/ggimesa.c delete mode 100644 src/mesa/drivers/ggi/ggimesa.conf.in delete mode 100644 src/mesa/drivers/ggi/include/ggi/mesa/debug.h delete mode 100644 src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h delete mode 100644 src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h delete mode 100644 src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h (limited to 'Makefile') diff --git a/Makefile b/Makefile index 659e11c5fb..b99a87b8ba 100644 --- a/Makefile +++ b/Makefile @@ -211,7 +211,6 @@ MAIN_FILES = \ $(DIRECTORY)/docs/*.spec \ $(DIRECTORY)/include/GL/internal/glcore.h \ $(DIRECTORY)/include/GL/dmesa.h \ - $(DIRECTORY)/include/GL/ggimesa.h \ $(DIRECTORY)/include/GL/gl.h \ $(DIRECTORY)/include/GL/glext.h \ $(DIRECTORY)/include/GL/gl_mangle.h \ @@ -273,13 +272,6 @@ MAIN_FILES = \ $(DIRECTORY)/src/mesa/drivers/fbdev/Makefile \ $(DIRECTORY)/src/mesa/drivers/fbdev/glfbdev.c \ $(DIRECTORY)/src/mesa/drivers/glide/*.[ch] \ - $(DIRECTORY)/src/mesa/drivers/ggi/*.[ch] \ - $(DIRECTORY)/src/mesa/drivers/ggi/ggimesa.conf.in \ - $(DIRECTORY)/src/mesa/drivers/ggi/default/*.c \ - $(DIRECTORY)/src/mesa/drivers/ggi/default/genkgi.conf.in \ - $(DIRECTORY)/src/mesa/drivers/ggi/display/*.c \ - $(DIRECTORY)/src/mesa/drivers/ggi/display/fbdev.conf.in \ - $(DIRECTORY)/src/mesa/drivers/ggi/include/ggi/mesa/*.h \ $(DIRECTORY)/src/mesa/drivers/osmesa/Makefile \ $(DIRECTORY)/src/mesa/drivers/osmesa/Makefile.win \ $(DIRECTORY)/src/mesa/drivers/osmesa/descrip.mms \ @@ -458,7 +450,6 @@ DEMO_FILES = \ $(DIRECTORY)/progs/windml/Makefile.ugl \ $(DIRECTORY)/progs/windml/*.c \ $(DIRECTORY)/progs/windml/*.bmp \ - $(DIRECTORY)/progs/ggi/*.c GLUT_FILES = \ $(DIRECTORY)/include/GL/glut.h \ @@ -471,8 +462,6 @@ GLUT_FILES = \ $(DIRECTORY)/src/glut/beos/*.[ch] \ $(DIRECTORY)/src/glut/beos/*.cpp \ $(DIRECTORY)/src/glut/beos/Makefile \ - $(DIRECTORY)/src/glut/ggi/*.[ch] \ - $(DIRECTORY)/src/glut/ggi/Makefile \ $(DIRECTORY)/src/glut/fbdev/Makefile \ $(DIRECTORY)/src/glut/fbdev/*[ch] \ $(DIRECTORY)/src/glut/mini/*[ch] \ diff --git a/progs/ggi/asc-view.c b/progs/ggi/asc-view.c deleted file mode 100644 index d37fba9d9f..0000000000 --- a/progs/ggi/asc-view.c +++ /dev/null @@ -1,377 +0,0 @@ -/* - test program for the ggi-mesa driver - - Copyright (C) 1997,1998 Uwe Maurer - uwe_maurer@t-online.de - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -ggi_visual_t vis,vis_mem; - -GGIMesaContext ctx; - -int screen_x=GGI_AUTO,screen_y=GGI_AUTO; -ggi_graphtype bpp=GT_AUTO; - -//#define ZBUFFER - -//#define SMOOTH_NORMALS - -void Init() -{ - GLfloat h=(GLfloat)3/4; - GLfloat pos[4]={5,5,-20,0}; - GLfloat specular[4]={.4,.4,.4,1}; - GLfloat diffuse[4]={.3,.3,.3,1}; - GLfloat ambient[4]={.2,.2,.2,1}; - - int err; - - if (ggiInit()<0) - { - printf("ggiInit() failed\n"); - exit(1); - } - ctx=GGIMesaCreateContext(); - if (ctx==NULL) - { - printf("Can't create Context!\n"); - exit(1); - } - - vis=ggiOpen(NULL); - vis_mem=ggiOpen("display-memory",NULL); - if (vis==NULL || vis_mem==NULL) - { - printf("Can't open ggi_visuals!\n"); - exit(1); - } - err=ggiSetGraphMode(vis,screen_x,screen_y,screen_x,screen_y,bpp); - err+=ggiSetGraphMode(vis_mem,screen_x,screen_y,screen_x,screen_y,bpp); - if (err) - { - printf("Can't set %ix%i\n",screen_x,screen_y); - exit(1); - } - - if (GGIMesaSetVisual(ctx,vis_mem,GL_TRUE,GL_FALSE)<0) - { - printf("GGIMesaSetVisual() failed!\n"); - exit(1); - } - - GGIMesaMakeCurrent(ctx); - - glViewport(0,0,screen_x,screen_y); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-1,1,-h,h,1,50); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0,0,-9); - glShadeModel(GL_FLAT); - - glFrontFace(GL_CW); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - - glLightfv(GL_LIGHT0,GL_POSITION,pos); - - glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuse); - glLightfv(GL_LIGHT0,GL_AMBIENT,ambient); - glLightfv(GL_LIGHT0,GL_SPECULAR,specular); - - #ifdef ZBUFFER - glEnable(GL_DEPTH_TEST); - #endif -} - - -#define MAX_VERTS 1000 -#define MAX_TRIS 2000 -#define MAX_LEN 1024 -#define MAX_F 100000000 - -void LoadAsc(GLuint *list,char *file) -{ - FILE *fp; - - GLfloat p[MAX_VERTS][3]; - GLfloat normal[MAX_VERTS][3]; - float ncount[MAX_VERTS]; - int v[MAX_TRIS][3]; - char line[MAX_LEN]; - char *s; - int i,j; - int verts,faces; - GLuint v0,v1,v2; - GLfloat n[3]; - GLfloat len,k; - GLfloat min[3]={MAX_F,MAX_F,MAX_F}; - GLfloat max[3]={-MAX_F,-MAX_F,-MAX_F}; - char *coord_str[]={"X","Z","Y"}; - - fp=fopen(file,"r"); - if (!fp) - { - printf("Can't open %s!\n",file); - exit(1); - } - - while (strncmp(fgets(line,MAX_LEN,fp),"Tri-mesh",8)) ; - - s=strstr(line,":")+1; - verts=atoi(s); - s=strstr(s,":")+1; - faces=atoi(s); - - if (verts>MAX_VERTS) - { - printf("Too many vertices..\n"); - exit(1); - } - - while (strncmp(fgets(line,MAX_LEN,fp),"Vertex list",11)) ; - - for (i=0;imax[j]) max[j]=k; - if (klen) {len=k;j=i;} - n[i]=(max[i]+min[i])/2; - } - - len/=2; - - for (i=0;iread); - rotate+=10; - frames++; - if (frames==(*maxframes)) break; - - if (ggiKbhit(vis)) - { - *maxframes=frames; - break; - } - } - - gettimeofday(&stop,NULL); - len=(double)(stop.tv_sec-start.tv_sec)+ - (double)(stop.tv_usec-start.tv_usec)/1e6; - return len; -} - -void visible(int vis) -{ - if (vis == GLUT_VISIBLE) - glutIdleFunc(idle); - else - glutIdleFunc(NULL); -} - -int main(int argc, char *argv[]) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); - - glutInitWindowPosition(0, 0); - glutInitWindowSize(300, 300); - glutCreateWindow("asc-view"); - init(); - - glutDisplayFunc(draw); - glutReshapeFunc(reshape); - glutKeyboardFunc(key); - glutSpecialFunc(special); - glutVisibilityFunc(visible); - - glutMainLoop(); -#if 0 - GLuint l; - char *file; - int maxframes=0; - double len; - - Init(); - - file=(argc>1) ? argv[1] : "asc/box.asc"; - if (argc>2) maxframes=atoi(argv[2]); - - if (argc==1) - { - printf("usage: %s filename.asc\n",argv[0]); - } - - LoadAsc(&l,file); - - len=Display(l,&maxframes); - - printf("\ttime: %.3f sec\n",len); - printf("\tframes: %i\n",maxframes); - printf("\tfps: %.3f \n",(double)maxframes/len); - - GGIMesaDestroyContext(ctx); - ggiClose(vis); - ggiClose(vis_mem); - ggiExit(); -#endif - return 0; -} - diff --git a/progs/ggi/blah b/progs/ggi/blah deleted file mode 100644 index 2c1664d7d0..0000000000 --- a/progs/ggi/blah +++ /dev/null @@ -1,2 +0,0 @@ -Terminating on signal 11 - diff --git a/progs/ggi/blat b/progs/ggi/blat deleted file mode 100644 index 7ff64a9d10..0000000000 --- a/progs/ggi/blat +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -function foobar() { - echo "foo!" -} - -foobar diff --git a/progs/ggi/box.asc b/progs/ggi/box.asc deleted file mode 100644 index f8b23fd85a..0000000000 --- a/progs/ggi/box.asc +++ /dev/null @@ -1,66 +0,0 @@ -Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216 - -Named object: "Object01" -Tri-mesh, Vertices: 8 Faces: 12 -Vertex list: -Vertex 0: X: -20 Y: -19.999998 Z: 20.000002 -Vertex 1: X: 20 Y: -19.999998 Z: 20.000002 -Vertex 2: X: 20 Y: 20.000002 Z: 19.999998 -Vertex 3: X: -20 Y: 20.000002 Z: 19.999998 -Vertex 4: X: -20 Y: -20.000002 Z: -19.999998 -Vertex 5: X: 20 Y: -20.000002 Z: -19.999998 -Vertex 6: X: 20 Y: 19.999998 Z: -20.000002 -Vertex 7: X: -20 Y: 19.999998 Z: -20.000002 -Face list: -Face 0: A:0 B:1 C:2 AB:1 BC:1 CA:0 -Smoothing: 1 -Face 1: A:0 B:2 C:3 AB:0 BC:1 CA:1 -Smoothing: 1 -Face 2: A:0 B:4 C:5 AB:1 BC:1 CA:0 -Smoothing: 2 -Face 3: A:0 B:5 C:1 AB:0 BC:1 CA:1 -Smoothing: 2 -Face 4: A:1 B:5 C:6 AB:1 BC:1 CA:0 -Smoothing: 3 -Face 5: A:1 B:6 C:2 AB:0 BC:1 CA:1 -Smoothing: 3 -Face 6: A:2 B:6 C:7 AB:1 BC:1 CA:0 -Smoothing: 4 -Face 7: A:2 B:7 C:3 AB:0 BC:1 CA:1 -Smoothing: 4 -Face 8: A:3 B:7 C:4 AB:1 BC:1 CA:0 -Smoothing: 5 -Face 9: A:3 B:4 C:0 AB:0 BC:1 CA:1 -Smoothing: 5 -Face 10: A:4 B:7 C:6 AB:1 BC:1 CA:0 -Smoothing: 6 -Face 11: A:4 B:6 C:5 AB:0 BC:1 CA:1 -Smoothing: 6 - - - - - - - - - - - - - - - - - - - - - - - - - Page 1 - - - diff --git a/progs/ggi/cone.asc b/progs/ggi/cone.asc deleted file mode 100644 index 5c52285996..0000000000 --- a/progs/ggi/cone.asc +++ /dev/null @@ -1,198 +0,0 @@ -Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216 - -Named object: "Object01" -Tri-mesh, Vertices: 34 Faces: 64 -Vertex list: -Vertex 0: X: 60.167416 Y: -87.419525 Z: -53.3088 -Vertex 1: X: 76.70787 Y: -87.419518 Z: -29.84565 -Vertex 2: X: 83.0103 Y: -87.419518 Z: -1.838764 -Vertex 3: X: 78.115204 Y: -87.419518 Z: 26.448057 -Vertex 4: X: 62.767834 Y: -87.41951 Z: 50.708401 -Vertex 5: X: 39.304672 Y: -87.41951 Z: 67.248848 -Vertex 6: X: 11.297782 Y: -87.41951 Z: 73.551254 -Vertex 7: X: -16.989004 Y: -87.41951 Z: 68.656158 -Vertex 8: X: -41.249344 Y: -87.41951 Z: 53.308777 -Vertex 9: X: -57.789783 Y: -87.419518 Z: 29.845612 -Vertex 10: X: -64.092194 Y: -87.419518 Z: 1.838721 -Vertex 11: X: -59.197079 Y: -87.419518 Z: -26.448097 -Vertex 12: X: -43.849678 Y: -87.419525 Z: -50.708427 -Vertex 13: X: -20.386503 Y: -87.419525 Z: -67.248856 -Vertex 14: X: 7.62039 Y: -87.419525 Z: -73.551239 -Vertex 15: X: 35.907204 Y: -87.419525 Z: -68.656105 -Vertex 16: X: 101.684875 Y: 94.590591 Z: -96.955391 -Vertex 17: X: 131.767838 Y: 94.590591 Z: -54.281792 -Vertex 18: X: 143.230377 Y: 94.590599 Z: -3.344275 -Vertex 19: X: 134.327423 Y: 94.590607 Z: 48.102379 -Vertex 20: X: 106.414383 Y: 94.590607 Z: 92.225876 -Vertex 21: X: 63.740765 Y: 94.590607 Z: 122.3088 -Vertex 22: X: 12.803238 Y: 94.590614 Z: 133.771301 -Vertex 23: X: -38.643349 Y: 94.590607 Z: 124.868355 -Vertex 24: X: -82.766846 Y: 94.590607 Z: 96.955307 -Vertex 25: X: -112.849762 Y: 94.590607 Z: 54.281677 -Vertex 26: X: -124.312256 Y: 94.590599 Z: 3.344152 -Vertex 27: X: -115.409271 Y: 94.590591 Z: -48.102493 -Vertex 28: X: -87.496201 Y: 94.590591 Z: -92.225967 -Vertex 29: X: -44.822552 Y: 94.590591 Z: -122.308861 -Vertex 30: X: 6.114983 Y: 94.590584 Z: -133.771332 -Vertex 31: X: 57.561623 Y: 94.590591 Z: -124.868301 -Vertex 32: X: 9.459057 Y: -87.419518 Z: 0.000008 -Vertex 33: X: 9.459057 Y: 94.590599 Z: -0.000008 -Face list: -Face 0: A:0 B:1 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 1: A:1 B:2 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 2: A:2 B:3 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 3: A:3 B:4 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 4: A:4 B:5 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 5: A:5 B:6 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 6: A:6 B:7 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 7: A:7 B:8 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 8: A:8 B:9 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 9: A:9 B:10 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 10: A:10 B:11 C:32 AB:1 BC:0 CA:0 - - Page 1 - - - -Smoothing: 1 -Face 11: A:11 B:12 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 12: A:12 B:13 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 13: A:13 B:14 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 14: A:14 B:15 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 15: A:15 B:0 C:32 AB:1 BC:0 CA:0 -Smoothing: 1 -Face 16: A:0 B:16 C:17 AB:1 BC:1 CA:0 -Smoothing: 2 -Face 17: A:0 B:17 C:1 AB:0 BC:1 CA:1 -Smoothing: 2 -Face 18: A:1 B:17 C:18 AB:1 BC:1 CA:0 -Smoothing: 3 -Face 19: A:1 B:18 C:2 AB:0 BC:1 CA:1 -Smoothing: 3 -Face 20: A:2 B:18 C:19 AB:1 BC:1 CA:0 -Smoothing: 4 -Face 21: A:2 B:19 C:3 AB:0 BC:1 CA:1 -Smoothing: 4 -Face 22: A:3 B:19 C:20 AB:1 BC:1 CA:0 -Smoothing: 5 -Face 23: A:3 B:20 C:4 AB:0 BC:1 CA:1 -Smoothing: 5 -Face 24: A:4 B:20 C:21 AB:1 BC:1 CA:0 -Smoothing: 6 -Face 25: A:4 B:21 C:5 AB:0 BC:1 CA:1 -Smoothing: 6 -Face 26: A:5 B:21 C:22 AB:1 BC:1 CA:0 -Smoothing: 7 -Face 27: A:5 B:22 C:6 AB:0 BC:1 CA:1 -Smoothing: 7 -Face 28: A:6 B:22 C:23 AB:1 BC:1 CA:0 -Smoothing: 8 -Face 29: A:6 B:23 C:7 AB:0 BC:1 CA:1 -Smoothing: 8 -Face 30: A:7 B:23 C:24 AB:1 BC:1 CA:0 -Smoothing: 9 -Face 31: A:7 B:24 C:8 AB:0 BC:1 CA:1 -Smoothing: 9 -Face 32: A:8 B:24 C:25 AB:1 BC:1 CA:0 -Smoothing: 10 -Face 33: A:8 B:25 C:9 AB:0 BC:1 CA:1 -Smoothing: 10 -Face 34: A:9 B:25 C:26 AB:1 BC:1 CA:0 -Smoothing: 11 -Face 35: A:9 B:26 C:10 AB:0 BC:1 CA:1 -Smoothing: 11 -Face 36: A:10 B:26 C:27 AB:1 BC:1 CA:0 -Smoothing: 12 -Face 37: A:10 B:27 C:11 AB:0 BC:1 CA:1 -Smoothing: 12 -Face 38: A:11 B:27 C:28 AB:1 BC:1 CA:0 -Smoothing: 13 -Face 39: A:11 B:28 C:12 AB:0 BC:1 CA:1 -Smoothing: 13 -Face 40: A:12 B:28 C:29 AB:1 BC:1 CA:0 -Smoothing: 14 - - Page 2 - - - -Face 41: A:12 B:29 C:13 AB:0 BC:1 CA:1 -Smoothing: 14 -Face 42: A:13 B:29 C:30 AB:1 BC:1 CA:0 -Smoothing: 15 -Face 43: A:13 B:30 C:14 AB:0 BC:1 CA:1 -Smoothing: 15 -Face 44: A:14 B:30 C:31 AB:1 BC:1 CA:0 -Smoothing: 16 -Face 45: A:14 B:31 C:15 AB:0 BC:1 CA:1 -Smoothing: 16 -Face 46: A:15 B:31 C:16 AB:1 BC:1 CA:0 -Smoothing: 17 -Face 47: A:15 B:16 C:0 AB:0 BC:1 CA:1 -Smoothing: 17 -Face 48: A:16 B:33 C:17 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 49: A:17 B:33 C:18 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 50: A:18 B:33 C:19 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 51: A:19 B:33 C:20 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 52: A:20 B:33 C:21 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 53: A:21 B:33 C:22 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 54: A:22 B:33 C:23 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 55: A:23 B:33 C:24 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 56: A:24 B:33 C:25 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 57: A:25 B:33 C:26 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 58: A:26 B:33 C:27 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 59: A:27 B:33 C:28 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 60: A:28 B:33 C:29 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 61: A:29 B:33 C:30 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 62: A:30 B:33 C:31 AB:0 BC:0 CA:1 -Smoothing: 18 -Face 63: A:31 B:33 C:16 AB:0 BC:0 CA:1 -Smoothing: 18 - - - - - - - - - - - - - - - - - Page 3 - - - diff --git a/progs/ggi/gears.c b/progs/ggi/gears.c deleted file mode 100644 index 2b3231d8ae..0000000000 --- a/progs/ggi/gears.c +++ /dev/null @@ -1,339 +0,0 @@ - -/* - * 3-D gear wheels. This program is in the public domain. - * - * Brian Paul - */ - -/* Conversion to GLUT by Mark J. Kilgard */ - -#include -#include -#include -#include - -#ifndef M_PI -#define M_PI 3.14159265 -#endif - -static GLint T0 = 0; -static GLint Frames = 0; - - -/** - - Draw a gear wheel. You'll probably want to call this function when - building a display list since we do a lot of trig here. - - Input: inner_radius - radius of hole at center - outer_radius - radius at center of teeth - width - width of gear - teeth - number of teeth - tooth_depth - depth of tooth - - **/ - -static void -gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, - GLint teeth, GLfloat tooth_depth) -{ - GLint i; - GLfloat r0, r1, r2; - GLfloat angle, da; - GLfloat u, v, len; - - r0 = inner_radius; - r1 = outer_radius - tooth_depth / 2.0; - r2 = outer_radius + tooth_depth / 2.0; - - da = 2.0 * M_PI / teeth / 4.0; - - glShadeModel(GL_FLAT); - - glNormal3f(0.0, 0.0, 1.0); - - /* draw front face */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); - glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); - if (i < teeth) { - glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); - } - } - glEnd(); - - /* draw front sides of teeth */ - glBegin(GL_QUADS); - da = 2.0 * M_PI / teeth / 4.0; - for (i = 0; i < teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - - glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); - } - glEnd(); - - glNormal3f(0.0, 0.0, -1.0); - - /* draw back face */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); - glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); - if (i < teeth) { - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); - glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); - } - } - glEnd(); - - /* draw back sides of teeth */ - glBegin(GL_QUADS); - da = 2.0 * M_PI / teeth / 4.0; - for (i = 0; i < teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); - glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); - } - glEnd(); - - /* draw outward faces of teeth */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i < teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - - glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); - glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); - u = r2 * cos(angle + da) - r1 * cos(angle); - v = r2 * sin(angle + da) - r1 * sin(angle); - len = sqrt(u * u + v * v); - u /= len; - v /= len; - glNormal3f(v, -u, 0.0); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); - glNormal3f(cos(angle), sin(angle), 0.0); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); - u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); - v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); - glNormal3f(v, -u, 0.0); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); - glNormal3f(cos(angle), sin(angle), 0.0); - } - - glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); - glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); - - glEnd(); - - glShadeModel(GL_SMOOTH); - - /* draw inside radius cylinder */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - glNormal3f(-cos(angle), -sin(angle), 0.0); - glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); - glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); - } - glEnd(); - -} - -static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; -static GLint gear1, gear2, gear3; -static GLfloat angle = 0.0; - -static void -draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); - glRotatef(view_rotx, 1.0, 0.0, 0.0); - glRotatef(view_roty, 0.0, 1.0, 0.0); - glRotatef(view_rotz, 0.0, 0.0, 1.0); - - glPushMatrix(); - glTranslatef(-3.0, -2.0, 0.0); - glRotatef(angle, 0.0, 0.0, 1.0); - glCallList(gear1); - glPopMatrix(); - - glPushMatrix(); - glTranslatef(3.1, -2.0, 0.0); - glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0); - glCallList(gear2); - glPopMatrix(); - - glPushMatrix(); - glTranslatef(-3.1, 4.2, 0.0); - glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); - glCallList(gear3); - glPopMatrix(); - - glPopMatrix(); - - glutSwapBuffers(); - - Frames++; - { - GLint t = glutGet(GLUT_ELAPSED_TIME); - if (t - T0 >= 5000) { - GLfloat seconds = (t - T0) / 1000.0; - GLfloat fps = Frames / seconds; - printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps); - T0 = t; - Frames = 0; - } - } -} - - -static void -idle(void) -{ - angle += 2.0; - glutPostRedisplay(); -} - -/* change view angle, exit upon ESC */ -/* ARGSUSED1 */ -static void -key(unsigned char k, int x, int y) -{ - switch (k) { - case 'z': - view_rotz += 5.0; - break; - case 'Z': - view_rotz -= 5.0; - break; - case 27: /* Escape */ - exit(0); /* FIXME: Shutdown and free resources cleanly in ggiglut */ - break; - default: - return; - } - glutPostRedisplay(); -} - -/* change view angle */ -/* ARGSUSED1 */ -static void -special(int k, int x, int y) -{ - switch (k) { - case GLUT_KEY_UP: - view_rotx += 5.0; - break; - case GLUT_KEY_DOWN: - view_rotx -= 5.0; - break; - case GLUT_KEY_LEFT: - view_roty += 5.0; - break; - case GLUT_KEY_RIGHT: - view_roty -= 5.0; - break; - default: - return; - } - glutPostRedisplay(); -} - -/* new window size or exposure */ -static void -reshape(int width, int height) -{ - GLfloat h = (GLfloat) height / (GLfloat) width; - - glViewport(0, 0, (GLint) width, (GLint) height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -40.0); -} - -static void -init(void) -{ - static GLfloat pos[4] = - {5.0, 5.0, 10.0, 0.0}; - static GLfloat red[4] = - {0.8, 0.1, 0.0, 1.0}; - static GLfloat green[4] = - {0.0, 0.8, 0.2, 1.0}; - static GLfloat blue[4] = - {0.2, 0.2, 1.0, 1.0}; - - glLightfv(GL_LIGHT0, GL_POSITION, pos); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - - /* make the gears */ - gear1 = glGenLists(1); - glNewList(gear1, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); - gear(1.0, 4.0, 1.0, 20, 0.7); - glEndList(); - - gear2 = glGenLists(1); - glNewList(gear2, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); - gear(0.5, 2.0, 2.0, 10, 0.7); - glEndList(); - - gear3 = glGenLists(1); - glNewList(gear3, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); - gear(1.3, 2.0, 0.5, 10, 0.7); - glEndList(); - - glEnable(GL_NORMALIZE); -} - -void -visible(int vis) -{ - if (vis == GLUT_VISIBLE) - glutIdleFunc(idle); - else - glutIdleFunc(NULL); -} - -int main(int argc, char *argv[]) -{ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); - -// glutInitWindowPosition(0, 0); -// glutInitWindowSize(300, 300); - glutCreateWindow("Gears"); - init(); - - glutDisplayFunc(draw); - glutReshapeFunc(reshape); - glutKeyboardFunc(key); - glutSpecialFunc(special); - glutVisibilityFunc(visible); - - glutMainLoop(); - - return 0; -} diff --git a/progs/ggi/gears2.c b/progs/ggi/gears2.c deleted file mode 100644 index 9468c03177..0000000000 --- a/progs/ggi/gears2.c +++ /dev/null @@ -1,390 +0,0 @@ -/* gears.c */ - -/* - * 3-D gear wheels. This program is in the public domain. - * - * Brian Paul - * modified by Uwe Maurer (uwe_maurer@t-online.de) - */ - -#include -#include -#include -#include -#include -#ifndef M_PI -# define M_PI 3.14159265 -#endif - - -ggi_visual_t vis; -char text[100]; -int db_flag,vis_x, vis_y, vir_x, vir_y, gt; - -/* - * Draw a gear wheel. You'll probably want to call this function when - * building a display list since we do a lot of trig here. - * - * Input: inner_radius - radius of hole at center - * outer_radius - radius at center of teeth - * width - width of gear - * teeth - number of teeth - * tooth_depth - depth of tooth - */ -static void gear( GLfloat inner_radius, GLfloat outer_radius, GLfloat width, - GLint teeth, GLfloat tooth_depth ) -{ - GLint i; - GLfloat r0, r1, r2; - GLfloat angle, da; - GLfloat u, v, len; - - r0 = inner_radius; - r1 = outer_radius - tooth_depth/2.0; - r2 = outer_radius + tooth_depth/2.0; - - da = 2.0*M_PI / teeth / 4.0; - - glShadeModel( GL_FLAT ); - - glNormal3f( 0.0, 0.0, 1.0 ); - - /* draw front face */ - glBegin( GL_QUAD_STRIP ); - for (i=0;i<=teeth;i++) { - angle = i * 2.0*M_PI / teeth; - glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 ); - glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 ); - glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 ); - glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 ); - } - glEnd(); - - /* draw front sides of teeth */ - glBegin( GL_QUADS ); - da = 2.0*M_PI / teeth / 4.0; - for (i=0;i GGI"); - ggiPuts(vis,0,ggiGetInfo(vis)->mode->visible.y," Mesa -> GGI"); - - ggiPuts(vis,0,16,text); - ggiPuts(vis,0,ggiGetInfo(vis)->mode->visible.y+16,text); -#endif - - if(db_flag) - ggiMesaSwapBuffers(); - - count++; - if (count==limit) { - exit(1); - } - ++n; - /* - if (!(n%10)){ - ggi_color rgb = { 10000, 10000, 10000 }; - ggiSetSimpleMode(vis,vis_x+(n/10),vis_y+(n/10),db_flag?2:1, gt); - glViewport(0, 0,vis_x+(n/10),vis_y+(n/10)); - ggiSetGCForeground(vis, ggiMapColor(vis, &rgb)); - ggiDrawBox(vis, 20, 20, 100, 100); - if(db_flag) - ggiSetWriteFrame(vis, 1); - } - */ -} - -static void idle( void ) -{ - angle += 2.0; - draw(); -} - -/* new window size or exposure */ -static void reshape( int width, int height ) -{ - GLfloat h = (GLfloat) height / (GLfloat) width; - - if(db_flag) - glDrawBuffer(GL_BACK); - else - glDrawBuffer(GL_FRONT); - glViewport(0, 0, (GLint)width, (GLint)height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum( -1.0, 1.0, -h, h, 5.0, 60.0 ); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef( 0.0, 0.0, -40.0 ); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - -} - - -static void init( void ) -{ - static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0 }; - static GLfloat red[4] = {0.9, 0.9, 0.9, 1.0 }; - static GLfloat green[4] = {0.0, 0.8, 0.9, 1.0 }; - static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0 }; - - glLightfv( GL_LIGHT0, GL_POSITION, pos ); - glEnable( GL_CULL_FACE ); - glEnable( GL_LIGHTING ); - glEnable( GL_LIGHT0 ); - glEnable( GL_DEPTH_TEST ); - - /* make the gears */ - gear1 = glGenLists(1); - glNewList(gear1, GL_COMPILE); - glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red ); - glIndexi(1); - gear( 1.0, 4.0, 1.0, 20, 0.7 ); - glEndList(); - - gear2 = glGenLists(1); - glNewList(gear2, GL_COMPILE); - glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green ); - glIndexi(2); - gear( 0.5, 2.0, 2.0, 10, 0.7 ); - glEndList(); - - gear3 = glGenLists(1); - glNewList(gear3, GL_COMPILE); - glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue ); - glIndexi(3); - gear( 1.3, 2.0, 0.5, 10, 0.7 ); - glEndList(); - - glEnable( GL_NORMALIZE ); -} - -static void usage(char *s) -{ - printf("%s visible_x visible_y virtual_x virtual_y bpp db_flag\n",s); - printf("example:\n"); - printf("%s 320 200 320 400 8 1\n",s); - exit(1); -} - -int main( int argc, char *argv[] ) -{ - ggi_mesa_context_t ctx; - ggi_mode mode; - int bpp; - - limit=0; - - if (argc<7) usage(argv[0]); - - vis_x=atoi(argv[1]); - vis_y=atoi(argv[2]); - vir_x=atoi(argv[3]); - vir_y=atoi(argv[4]); - bpp=atoi(argv[5]); - db_flag=atoi(argv[6]); - - switch(bpp) - { - case 4: gt=GT_4BIT;break; - case 8: gt=GT_8BIT;break; - case 15:gt=GT_15BIT;break; - case 16:gt=GT_16BIT;break; - case 24:gt=GT_24BIT;break; - case 32:gt=GT_32BIT;break; - default: - printf("%i Bits per Pixel ???\n",bpp); - exit(1); - } - sprintf(text,"%sx%s %i colors, RGB mode, %s", - argv[1],argv[2],1< -#include -#include -#include - - -__BEGIN_DECLS - -/* Exported variables */ -#ifdef BUILDING_GGIGLUT -extern uint32 _ggiglutDebugState; -extern int _ggiglutDebugSync; -#else -IMPORTVAR uint32 _ggiglutDebugState; -IMPORTVAR int _ggiglutDebugSync; -#endif - -__END_DECLS - - -/* Debugging types - * bit 0 is reserved! */ - -#define GGIGLUTDEBUG_CORE (1<<1) /* 2 */ -#define GGIGLUTDEBUG_MODE (1<<2) /* 4 */ -#define GGIGLUTDEBUG_COLOR (1<<3) /* 8 */ -#define GGIGLUTDEBUG_DRAW (1<<4) /* 16 */ -#define GGIGLUTDEBUG_MISC (1<<5) /* 32 */ -#define GGIGLUTDEBUG_LIBS (1<<6) /* 64 */ -#define GGIGLUTDEBUG_EVENTS (1<<7) /* 128 */ - -#define GGIGLUTDEBUG_ALL 0xffffffff - -#ifdef __GNUC__ - -#ifdef DEBUG -#define GGIGLUTDPRINT(form,args...) if (_ggiglutDebugState) { ggDPrintf(_ggiglutDebugSync, "GGIGLUT",form, ##args); } -#define GGIGLUTDPRINT_CORE(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_CORE) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); } -#define GGIGLUTDPRINT_MODE(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_MODE) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); } -#define GGIGLUTDPRINT_COLOR(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_COLOR) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); } -#define GGIGLUTDPRINT_DRAW(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_DRAW) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); } -#define GGIGLUTDPRINT_MISC(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_MISC) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); } -#define GGIGLUTDPRINT_LIBS(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_LIBS) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); } -#define GGIGLUTDPRINT_EVENTS(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_EVENTS) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); } -#else /* DEBUG */ -#define GGIGLUTDPRINT(form,args...) do{}while(0) -#define GGIGLUTDPRINT_CORE(form,args...) do{}while(0) -#define GGIGLUTDPRINT_MODE(form,args...) do{}while(0) -#define GGIGLUTDPRINT_COLOR(form,args...) do{}while(0) -#define GGIGLUTDPRINT_DRAW(form,args...) do{}while(0) -#define GGIGLUTDPRINT_MISC(form,args...) do{}while(0) -#define GGIGLUTDPRINT_LIBS(form,args...) do{}while(0) -#define GGIGLUTDPRINT_EVENTS(form,args...) do{}while(0) -#endif /* DEBUG */ - -#else /* __GNUC__ */ - -__BEGIN_DECLS - -static inline void GGIGLUTDPRINT(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState) { - va_list args; - - fprintf(stderr, "GGIGLUT: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggiglutDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIGLUTDPRINT_CORE(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_CORE) { - va_list args; - - fprintf(stderr, "GGIGLUT: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggiglutDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIGLUTDPRINT_MODE(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_MODE) { - va_list args; - - fprintf(stderr, "GGIGLUT: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggiglutDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIGLUTDPRINT_COLOR(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_COLOR) { - va_list args; - - fprintf(stderr, "GGIGLUT: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggiglutDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIGLUTDPRINT_DRAW(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_DRAW) { - va_list args; - - fprintf(stderr, "GGIGLUT: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggiglutDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIGLUTDPRINT_MISC(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_MISC) { - va_list args; - - fprintf(stderr, "GGIGLUT: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggiglutDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIGLUTDPRINT_LIBS(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_LIBS) { - va_list args; - - fprintf(stderr, "GGIGLUT: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggiglutDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIGLUTDPRINT_EVENTS(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_EVENTS) { - va_list args; - - fprintf(stderr, "GGIGLUT: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggiglutDebugSync) fflush(stderr); - } -#endif -} - -__END_DECLS - -#endif /* __GNUC__ */ - -#ifdef DEBUG -#define GGIGLUT_ASSERT(x,str) \ -{ if (!(x)) { \ - fprintf(stderr,"GGIGLUT:%s:%d: INTERNAL ERROR: %s\n",__FILE__,__LINE__,str); \ - exit(1); \ -} } -#define GGIGLUT_APPASSERT(x,str) \ -{ if (!(x)) { \ - fprintf(stderr,"GGIGLUT:%s:%d: APPLICATION ERROR: %s\n",__FILE__,__LINE__,str); \ - exit(1); \ -} } -#else /* DEBUG */ -#define GGIGLUT_ASSERT(x,str) do{}while(0) -#define GGIGLUT_APPASSERT(x,str) do{}while(0) -#endif /* DEBUG */ - -#ifdef DEBUG -# define GGIGLUTD0(x) x -#else -# define GGIGLUTD0(x) /* empty */ -#endif - -#ifdef GGIGLUTDLEV -# if GGIGLUTDLEV == 1 -# define GGIGLUTD1(x) x -# define GGIGLUTD2(x) /* empty */ -# define GGIGLUTD3(x) /* empty */ -# elif GGIGLUTDLEV == 2 -# define GGIGLUTD1(x) x -# define GGIGLUTD2(x) x -# define GGIGLUTD3(x) /* empty */ -# elif GGIGLUTDLEV > 2 -# define GGIGLUTD1(x) x -# define GGIGLUTD2(x) x -# define GGIGLUTD3(x) x -# endif -#else -# define GGIGLUTD1(x) /* empty */ -# define GGIGLUTD2(x) /* empty */ -# define GGIGLUTD3(x) /* empty */ -#endif - -#endif /* _GGI_MESA_INTERNAL_DEBUG_H */ diff --git a/src/glut/ggi/ggiglut.c b/src/glut/ggi/ggiglut.c deleted file mode 100644 index 2fe65a154c..0000000000 --- a/src/glut/ggi/ggiglut.c +++ /dev/null @@ -1,959 +0,0 @@ -/* ************************************************************************** - * ggiglut.c - * ************************************************************************** - * - * Copyright (C) 1998 Uwe Maurer - uwe_maurer@t-online.de - * Copyright (C) 1999 James Simmons - * Copyright (C) 1999 Jon Taylor - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * ************************************************************************** - * To-do: - * - Make everything use the portable ggi_* types - * - */ - -#define BUILDING_GGIGLUT - -#define WIDTH 640 -#define HEIGHT 480 -#define GRAPHTYPE_RGB GT_16BIT -#define GRAPHTYPE_INDEX GT_8BIT - -/*************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "GL/ggimesa.h" -#include "debug.h" - -#include -#include - -int _ggiglutDebugSync = 0; -uint32 _ggiglutDebugState = 0; - -char *__glutProgramName = "GGI"; - -static ggi_visual_t __glut_vis; - -static ggi_mesa_context_t __glut_ctx; - -//static int __glut_width = WIDTH; -//static int __glut_height = HEIGHT; -//static ggi_graphtype __glut_gt_rgb = GRAPHTYPE_RGB; -//static ggi_graphtype __glut_gt_index = GRAPHTYPE_INDEX; -static int __glut_width = GGI_AUTO; -static int __glut_height = GGI_AUTO; -static ggi_graphtype __glut_gt_rgb = GT_AUTO; -static ggi_graphtype __glut_gt_index = GT_8BIT; -static int __glut_init = GL_FALSE; - -static int mousex = WIDTH / 2; -static int mousey = HEIGHT / 2; -static int mouse_moved = GL_FALSE; -static int mouse_down = GL_FALSE; -static int mouse_showcursor = GL_FALSE; - -static void (*__glut_reshape)(int, int); -static void (*__glut_display)(void); -static void (*__glut_idle)(void); -static void (*__glut_keyboard)(unsigned char, int, int); -static void (*__glut_special)(int, int, int); -static void (*__glut_mouse)(int, int, int, int); -static void (*__glut_motion)(int, int); -static void (*__glut_passive_motion)(int, int); -static void (*__glut_visibility)(int); - -static unsigned int __glut_mode = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH; - -static int __glut_mod_keys = 0; - -static int __glut_redisplay = GL_FALSE; - -/* Menu */ -static int __glut_menubutton = -1; -static int __glut_menuactive = GL_FALSE; - -#define MAX_ENTRIES 64 - -typedef struct menu_s -{ - char *label[MAX_ENTRIES]; - int value[MAX_ENTRIES]; - struct menu_s * submenu[MAX_ENTRIES]; - void (*func)(int); - int max_strlen; - int num_entries; -} menu_t; - -static menu_t *mainmenu; -static menu_t *curmenu; -static menu_t *activemenu; - -void glutInit(int *argc, char **argv) -{ - ggi_graphtype gt; - int i, k; - char *str; - - GGIGLUTDPRINT_CORE("glutInit() called\n"); - - #define REMOVE {for (k=i;k<*argc-1;k++) argv[k]=argv[k+1]; \ - (*argc)--; i--; } - - if (__glut_init) return; - - str = getenv("GGIGLUT_DEBUG"); - if (str != NULL) { - _ggiglutDebugState = atoi(str); - fprintf(stderr, "Debugging=%d\n", _ggiglutDebugState); - GGIGLUTDPRINT_CORE("Debugging=%d\n", _ggiglutDebugState); - } - - str = getenv("GGIGLUT_DEBUGSYNC"); - if (str != NULL) { - _ggiglutDebugSync = 1; - } - - if (argc && argv) - { - - for (i = 1; i < *argc; i++) - { - if (strcmp(argv[i], "-mouse") == 0) - { - mouse_showcursor = GL_TRUE; - REMOVE; - } - else - if (strcmp(argv[i], "-bpp") == 0 && (i + 1) < (*argc)) - { - switch(atoi(argv[i + 1])) - { - case 4: gt = GT_4BIT; break; - case 8: gt = GT_8BIT; break; - case 15: gt = GT_15BIT; break; - case 16: gt = GT_16BIT; break; - case 24: gt = GT_24BIT; break; - case 32: gt = GT_32BIT; break; - default: - ggiPanic("\"%s\" bits per pixel?\n", argv[i+1]); - } - __glut_gt_rgb = __glut_gt_index = gt; - REMOVE; - REMOVE; - } - else - if (strcmp(argv[i], "-size") == 0 && (i + 2) < (*argc)) - { - __glut_width = atoi(argv[i + 1]); - __glut_height = atoi(argv[i + 2]); - REMOVE; - REMOVE; - REMOVE; - } - } - } - - if (ggiInit() < 0) - { - ggiPanic("ggiInit() failed!\n"); - } - __glut_init = GL_TRUE; - -#undef REMOVE -} - -void glutInitWindowPosition(int x, int y) -{ - GGIGLUTDPRINT_CORE("glutInitWindowPosition() called\n"); -} - -void glutInitWindowSize(int x, int y) -{ - GGIGLUTDPRINT_CORE("glutInitWindowsSize() called\n"); -} - -void glutFullScreen(void) -{ - GGIGLUTDPRINT_CORE("glutFullScreen() called\n"); -} - -void glutInitDisplayMode(unsigned int mode) -{ - GGIGLUTDPRINT_CORE("glutInitDisplayMode() called\n"); - - __glut_mode = mode; -} - -void glutInitDisplayString(const char *string) -{ - GGIGLUTDPRINT_CORE("glutInitDisplayString(%s) called\n", string); -} - -int glutCreateWindow(const char *title) -{ - ggi_graphtype gt; - ggi_mode mode = - { - 1, - { GGI_AUTO, GGI_AUTO }, - { GGI_AUTO, GGI_AUTO }, - { 0, 0 }, - GT_AUTO, - { GGI_AUTO, GGI_AUTO } - }; - int frames; - int rgb; - int err; - - GGIGLUTDPRINT_CORE("glutCreateWindow() called\n"); - - if (!__glut_init) - glutInit(NULL, NULL); - - GGIGLUTDPRINT("GGIGLUT: %s\n", title); - - rgb = !(__glut_mode & GLUT_INDEX); - frames = (__glut_mode & GLUT_DOUBLE) ? 2 : 1; - - gt = (rgb) ? __glut_gt_rgb : __glut_gt_index; - - __glut_vis = ggiOpen(NULL); - if (__glut_vis == NULL) - { - ggiPanic("ggiOpen() failed!\n"); - /* return GL_FALSE; */ - } - - ggiSetFlags(__glut_vis, GGIFLAG_ASYNC); - - ggiCheckMode(__glut_vis, &mode); - - err = ggiSetMode(__glut_vis, &mode); - if (err < 0) - { - ggiPanic("Can't set graphic mode!\n"); - /* return GL_FALSE; */ - } - - if (ggiMesaExtendVisual(__glut_vis, GL_FALSE, GL_FALSE, - 16, 0, 0, 0, 0, 0, 1) < 0) - { - ggiPanic("GGIMesaSetVisual failed!\n"); - } - - __glut_ctx = ggiMesaCreateContext(__glut_vis); - - if (__glut_ctx == NULL) - ggiPanic("Can't create mesa-context\n"); - - ggiGetMode(__glut_vis, &mode); - - - __glut_width = mode.visible.x; - __glut_height = mode.visible.y; - - mousex = mode.visible.x / 2; - mousey = mode.visible.y / 2; - - ggiMesaMakeCurrent(__glut_ctx, __glut_vis); - - if (__glut_reshape) - __glut_reshape(__glut_width, __glut_height); - - return GL_TRUE; -} - -void glutReshapeFunc(void (*func)(int, int)) -{ - GGIGLUTDPRINT_CORE("glutReshapeFunc() called\n"); - - __glut_reshape = func; - if (__glut_vis && __glut_reshape) - __glut_reshape(__glut_width, __glut_height); -} - -void glutKeyboardFunc(void (*keyboard)(unsigned char key, int x, int y)) -{ - GGIGLUTDPRINT_CORE("glutKeyBoardFunc() called\n"); - - __glut_keyboard = keyboard; -} - -int glutGetModifiers(void) -{ - GGIGLUTDPRINT_CORE("glutGetModifiers() called\n"); - - return __glut_mod_keys; -} - -void glutEntryFunc(void (*func)(int state)) -{ - GGIGLUTDPRINT_CORE("glutEntryFunc() called\n"); -} - -void glutVisibilitFunc(void (*func)(int state)) -{ - GGIGLUTDPRINT_CORE("glutVisibilityFunc() called\n"); -} - -void glutTimerFunc(unsigned int millis, void (*func)(int value), int value) -{ - GGIGLUTDPRINT_CORE("glutTimerFunc() called\n"); -} - -void glutMenuStateFunc(void (*func)(int state)) -{ - GGIGLUTDPRINT_CORE("glutMenuStateFunc() called\n"); -} - -int glutGet(GLenum type) -{ - GGIGLUTDPRINT_CORE("glutGet() called\n"); - - switch(type) - { - case GLUT_WINDOW_X: - return 0; - case GLUT_WINDOW_Y: - return 0; - case GLUT_WINDOW_WIDTH: - return __glut_width; - case GLUT_WINDOW_HEIGHT: - return __glut_height; - case GLUT_MENU_NUM_ITEMS: - if (curmenu) - return curmenu->num_entries; - else - return 0; - default: - GGIGLUTDPRINT("glutGet: unknown type %i\n", type); - } - return 0; -} - -void glutSpecialFunc(void (*special)(int key, int x, int y)) -{ - GGIGLUTDPRINT_CORE("glutSpecialFunc() called\n"); - - __glut_special=special; -} - -void glutDisplayFunc(void (*disp)(void)) -{ - GGIGLUTDPRINT_CORE("glutDisplayFunc() called\n"); - __glut_display=disp; -} - -void glutSetColor(int index, GLfloat red, GLfloat green, GLfloat blue) -{ - ggi_color c; - GLfloat max; - - GGIGLUTDPRINT_CORE("glutSetColor() called\n"); - - if (red > 1.0) red = 1.0; - if (red < 0.0) red = 0.0; - if (green > 1.0) green = 1.0; - if (green < 0.0) green = 0.0; - if (blue > 1.0) blue = 1.0; - if (blue < 0.0) blue = 0.0; - - max = (float)((1 << GGI_COLOR_PRECISION) - 1); - - c.r = (int)(max * red); - c.g = (int)(max * green); - c.b = (int)(max * blue); - ggiSetPalette(__glut_vis, index, 1, &c); -} - -void glutPostRedisplay(void) -{ - GGIGLUTDPRINT_CORE("glutPostRedisplay() called\n"); - - __glut_redisplay = GL_TRUE; -} - -void glutPostWindowRedisplay(int win) -{ - GGIGLUTDPRINT_CORE("glutPostWindowRedisplay() called\n"); - - __glut_redisplay = GL_TRUE; -} - -void glutSwapBuffers(void) -{ - GGIGLUTDPRINT_CORE("glutSwapBuffers() called\n"); - - ggiMesaSwapBuffers(); -} - -void glutIdleFunc(void (*idle)(void)) -{ - GGIGLUTDPRINT_CORE("glutIdleFunc() called\n"); - - __glut_idle = idle; -} - -static void keyboard(ggi_event *ev) -{ - int sym; - int modifer = 0, key = 0; - - GGIGLUTDPRINT_CORE("keyboard() called\n"); - - sym = ev->key.sym; - - modifer = ev->key.modifiers; - if (modifer == GII_KM_SHIFT) - __glut_mod_keys |= GLUT_ACTIVE_SHIFT; - if (modifer == GII_KM_CTRL) - __glut_mod_keys |= GLUT_ACTIVE_CTRL; - if (modifer == GII_KM_ALT) - __glut_mod_keys |= GLUT_ACTIVE_ALT; - - /* if (__glut_special && key) __glut_special(GII_KTYP(key),0,0); */ - - if (__glut_keyboard) -// __glut_keyboard(GII_UNICODE(sym), 0, 0); - __glut_keyboard(sym, 0, 0); -} - -static void mouseabs(ggi_event *ev) -{ - int oldx = mousex; - int oldy = mousey; - - mousex = ev->pmove.x; - mousey = ev->pmove.y; - - if (mousex < 0) mousex = 0; - if (mousey < 0) mousey = 0; - if (mousex >= __glut_width) mousex = __glut_width - 1; - if (mousey >= __glut_height) mousey = __glut_height - 1; - - if (mousex != oldx || mousey != oldy) mouse_moved = GL_TRUE; -} - -static void mouse(ggi_event *ev) -{ - int oldx = mousex; - int oldy = mousey; - - GGIGLUTDPRINT_CORE("mouse() called\n"); - - mousex += ev->pmove.x >> 1; - mousey += ev->pmove.y >> 1; - - if (mousex < 0) mousex = 0; - if (mousey < 0) mousey = 0; - if (mousex >= __glut_width) mousex = __glut_width - 1; - if (mousey >= __glut_height) mousey = __glut_height - 1; - - if (mousex != oldx || mousey != oldy) mouse_moved = GL_TRUE; - -} - -static void showmenu(void); -static int clickmenu(void); -static void updatemouse(void); -static void drawmouse(void); - -static void mousemove(void) -{ - GGIGLUTDPRINT_CORE("mousemove() called\n"); - - if (mouse_moved) { - if (__glut_motion && mouse_down) { - __glut_motion(mousex,mousey); - } - - if (__glut_passive_motion && (!mouse_down)) { - __glut_passive_motion(mousex,mousey); - } - - if (__glut_menuactive) updatemouse(); - mouse_moved=GL_FALSE; - } -} - -static void button(ggi_event *ev) -{ - int i; - int btn[4] = { - 0, - GLUT_LEFT_BUTTON, - GLUT_RIGHT_BUTTON, - GLUT_MIDDLE_BUTTON - }; - - GGIGLUTDPRINT_CORE("button() called\n"); - - mousemove(); - - if (ev->pbutton.button <= 3) { /* GGI can have >3 buttons ! */ - char state = ev->any.type == evPtrButtonPress ? GLUT_DOWN : GLUT_UP; - if (__glut_menuactive) { - if (state == GLUT_UP && clickmenu()) { - glutPostRedisplay(); - __glut_menuactive = GL_FALSE; - } - } else - if (btn[ev->pbutton.button] == __glut_menubutton) { - __glut_menuactive = GL_TRUE; - activemenu = mainmenu; - showmenu(); - } else - if (__glut_mouse) { - __glut_mouse(btn[ev->pbutton.button], state, mousex, mousey); - } - if (state == GLUT_DOWN) { - mouse_down |= (1 << (ev->pbutton.button - 1)); - } - else mouse_down &= ~( 1 << (ev->pbutton.button - 1)); - } -} - -void glutMainLoop(void) -{ - ggi_event ev; - ggi_event_mask evmask = (emKeyPress | emKeyRepeat | emPtrMove | emPtrButton); - - GGIGLUTDPRINT_CORE("glutMainLoop() called\n"); - - ggiSetEventMask(__glut_vis, evmask); - - glutPostRedisplay(); - - if (__glut_visibility) - __glut_visibility(GLUT_VISIBLE); - - while (1) - { - if (!__glut_menuactive) - { - if (__glut_idle) - __glut_idle(); - if (__glut_redisplay && __glut_display) - { - __glut_redisplay = GL_FALSE; - __glut_display(); - } - } - - while (1) - { - struct timeval t = {0, 0}; - - if (ggiEventPoll(__glut_vis, evmask, &t) == 0) - break; - - ggiEventRead(__glut_vis, &ev, evmask); - - switch (ev.any.type) - { - case evKeyPress: - case evKeyRepeat: - keyboard(&ev); - break; - case evPtrAbsolute: - mouseabs(&ev); - break; - case evPtrRelative: - mouse(&ev); - break; - case evPtrButtonPress: - case evPtrButtonRelease: - button(&ev); - break; - } - } - mousemove(); - } -} - -static void showmenu() -{ - int y,i; - ggi_color col = { 0xffff, 0xffff, 0xffff }; - - GGIGLUTDPRINT_CORE("showmenu() called\n"); - - ggiSetGCForeground(__glut_vis,ggiMapColor(__glut_vis,&col)); - ggiSetOrigin(__glut_vis,0,0); - - for (y = i = 0; i < activemenu->num_entries; i++, y += 8) { - ggiPuts(__glut_vis, 0, y, activemenu->label[i]); - } - drawmouse(); -} - -static int clickmenu(void) -{ - int i; - int w, h; - - GGIGLUTDPRINT_CORE("clickmenu() called\n"); - - i = mousey / 8; - - if (i >= activemenu->num_entries) return GL_TRUE; - if (mousex >= 8 * strlen(activemenu->label[i])) return GL_TRUE; - - if (activemenu->submenu[i]) { - ggi_color col={0,0,0}; - ggiSetGCForeground(__glut_vis,ggiMapColor(__glut_vis,&col)); - h=activemenu->num_entries*8; - w=activemenu->max_strlen*8; - ggiDrawBox(__glut_vis,0,0,w,h); - activemenu=activemenu->submenu[i]; - showmenu(); - return GL_FALSE; - } - curmenu=activemenu; - activemenu->func(activemenu->value[i]); - return GL_TRUE; -} - -static int oldx=-1; -static int oldy=-1; -static char buffer[16*16*4]; - -static void updatemouse() -{ - GGIGLUTDPRINT_CORE("updatemouse() called\n"); - - ggiPutBox(__glut_vis,oldx,oldy,16,16,buffer); - drawmouse(); -} - -static void drawmouse() -{ - int x,y; - - GGIGLUTDPRINT_CORE("drawmouse() called\n"); - - x=mousex-8; - if (x<0) x=0; - y=mousey-8; - if (y<0) y=0; - ggiGetBox(__glut_vis,x,y,16,16,buffer); - ggiDrawLine(__glut_vis,mousex-2,mousey,mousex+2,mousey); - ggiDrawLine(__glut_vis,mousex,mousey-2,mousex,mousey+2); - oldx=x; - oldy=y; -} - -int glutCreateMenu(void(*func)(int)) -{ - menu_t *m; - - GGIGLUTDPRINT_CORE("glutCreateMenu() called\n"); - - m=malloc(sizeof(menu_t)); - memset(m,0,sizeof(menu_t)); - curmenu=m; - curmenu->func=func; - return (int)curmenu; -} - -static void addEntry(const char *label,int value,menu_t *submenu) -{ - int i=curmenu->num_entries; - - GGIGLUTDPRINT_CORE("addEntry() called\n"); - - /* printf("%i %i %s %p\n",i,value,label,submenu); */ - if (ilabel[i]=strdup(label); - curmenu->value[i]=value; - curmenu->submenu[i]=submenu; - - if (strlen(label)>curmenu->max_strlen) - curmenu->max_strlen=strlen(label); - curmenu->num_entries++; - } -} - -void glutAddMenuEntry(const char *label,int value) -{ - GGIGLUTDPRINT_CORE("glutAddMenuEntry() called\n"); - - addEntry(label,value,NULL); -} - -void glutAddSubMenu(const char *label,int submenu) -{ - char text[100]; - - GGIGLUTDPRINT_CORE("glutAddSubMenu() called\n"); - - if (!curmenu) return; - strncpy(text,label,98); - text[98]=0; - text[strlen(text)+1]=0; - text[strlen(text)]='>'; - - addEntry(text,0,(menu_t *) submenu); -} - -void glutAttachMenu(int button) -{ - GGIGLUTDPRINT_CORE("glutAttachMenu() called\n"); - - mainmenu=curmenu; - __glut_menubutton=button; -} - -void glutDetachMenu(int button) -{ - GGIGLUTDPRINT_CORE("glutDetachMenu() called\n"); -} - -void glutVisibilityFunc(void (*func)(int state)) -{ - GGIGLUTDPRINT_CORE("glutVisibilityFunc() called\n"); - - __glut_visibility=func; -} - -void glutMouseFunc(void (*mouse)(int, int, int, int)) -{ - GGIGLUTDPRINT_CORE("glutMouseFunc() called\n"); - - __glut_mouse=mouse; -} - -void glutMotionFunc(void (*motion)(int,int)) -{ - GGIGLUTDPRINT_CORE("glutMotionFunc() called\n"); - - __glut_motion=motion; -} - -void glutPassiveMotionFunc(void (*motion)(int,int)) -{ - GGIGLUTDPRINT_CORE("glutPassiveMotionFunc() called\n"); - - __glut_passive_motion=motion; -} - -void glutSetWindowTitle(const char *title) -{ - GGIGLUTDPRINT_CORE("glutSetWindowTitle() called\n"); -} - -void glutSetIconTitle(const char *title) -{ - GGIGLUTDPRINT_CORE("glutSetIconTitle() called\n"); -} - -void glutChangeToMenuEntry(int item,const char *label,int value) -{ - GGIGLUTDPRINT_CORE("glutChangeToMenuEntry() called\n"); - - if (item>0 && item<=curmenu->num_entries) { - item--; - free(curmenu->label[item]); - curmenu->label[item]=strdup(label); - curmenu->value[item]=value; - curmenu->submenu[item]=NULL; - } -} -void glutChangeToSubMenu(int item,const char *label,int submenu) -{ - GGIGLUTDPRINT_CORE("glutChengeToSubMenu() called\n"); - - if (item>0 && item<=curmenu->num_entries) { - item--; - free(curmenu->label[item]); - curmenu->label[item]=strdup(label); - curmenu->value[item]=0; - curmenu->submenu[item]=(menu_t *)submenu; - } -} - -void glutDestroyMenu(int menu) -{ - menu_t *m=(menu_t *)menu; - int i; - - GGIGLUTDPRINT_CORE("glutDestroyMenu() called\n"); - - for (i=0;inum_entries;i++) { - free(m->label[i]); - } - free(m); -} - -int glutCreateSubWindow(int win,int x,int y,int w,int h) -{ - GGIGLUTDPRINT_CORE("glutCreateSubWindow() called\n"); - - return 0; -} - -void glutDestroyWindow(int win) -{ - GGIGLUTDPRINT_CORE("glutDestroyWindow() called\n"); -} - -int glutGetWindow(void) -{ - GGIGLUTDPRINT_CORE("glutGetWindow() called\n"); - - return 0; -} - -void glutSetWindow(int win) -{ - GGIGLUTDPRINT_CORE("glutSetWindow() called\n"); -} - -void glutPositionWindow(int x,int y) -{ - GGIGLUTDPRINT_CORE("glutPositionWindow() called\n"); -} - -void glutReshapeWindow(int x,int y) -{ - GGIGLUTDPRINT_CORE("glutReshapeWindow() called\n"); -} - -void glutPushWindow(void) -{ - GGIGLUTDPRINT_CORE("glutPushWindow() called\n"); -} - -void glutPopWindow(void) -{ - GGIGLUTDPRINT_CORE("glutPopWindow() called\n"); -} - -void glutIconifyWindow(void) -{ - GGIGLUTDPRINT_CORE("glutIconifyWindow() called\n"); -} - -void glutShowWindow() -{ - GGIGLUTDPRINT_CORE("glutShowWindow() called\n"); -} - -void glutHideWindow() -{ - GGIGLUTDPRINT_CORE("glutHideWindow() called\n"); -} - -void glutSetCursor(int cursor) -{ - GGIGLUTDPRINT_CORE("glutSetCursor() called\n"); -} - -void glutWarpPointer(int x,int y) -{ - GGIGLUTDPRINT_CORE("glutWarpPointer() called\n"); -} - -void glutEstablishOverlay(void) -{ - GGIGLUTDPRINT_CORE("glutEstablishOverlay() called\n"); -} - -void glutRemoveOverlay(void) -{ - GGIGLUTDPRINT_CORE("glutRemoveOverlay() called\n"); -} - -void glutUseLayer(GLenum layer) -{ - GGIGLUTDPRINT_CORE("glutUseLayer() called\n"); -} - -int glutLayerGet(GLenum type) -{ - GGIGLUTDPRINT_CORE("glutLayerGet() called\n"); - return 0; -} - -void glutPostOverlayRedisplay(void) -{ - GGIGLUTDPRINT_CORE("glutPostOverlayRedisplay() called\n"); -} - -void glutPostWindowOverlayRedisplay(int w) -{ - GGIGLUTDPRINT_CORE("glutPostWindowOverlayRedisplay() called\n"); -} - -void glutShowOverlay(void) -{ - GGIGLUTDPRINT_CORE("glutShowOverlay() called\n"); -} - -void glutHideOverlay(void) -{ - GGIGLUTDPRINT_CORE("glutHideOverlay() called\n"); -} - -int glutGetMenu(void) -{ - GGIGLUTDPRINT_CORE("glutGetMenu() called\n"); - return 0; -} - -void glutSetMenu(int menu) -{ - GGIGLUTDPRINT_CORE("glutSetMenu() called\n"); -} - -void glutRemoveMenuItem(int item) -{ - GGIGLUTDPRINT_CORE("glutRemoveMenuItem() called\n"); -} - -void glutSpaceBallMotionFunc(void (*func)(int key,int x,int y)) -{ - GGIGLUTDPRINT_CORE("glutSpaceBallMotionFunc() called\n"); -} - -void glutSpaceBallRotateFunc(void (*func)(int x,int y,int z)) -{ - GGIGLUTDPRINT_CORE("glutSpaceBallRotateFunc() called\n"); -} - -void glutSpaceBallButtonFunc(void (*func)(int button,int state)) -{ - GGIGLUTDPRINT_CORE("glutSpaceBallButtonFunc() called\n"); -} - -void glutCopyColormap(int win) -{ - GGIGLUTDPRINT_CORE("glutCopyColormap() called\n"); -} - -int glutDeviceGet(GLenum param) -{ - GGIGLUTDPRINT_CORE("glutDeviceGet() called\n"); - - return 0; -} diff --git a/src/mesa/drivers/ggi/default/.gitignore b/src/mesa/drivers/ggi/default/.gitignore deleted file mode 100644 index c8a526b14d..0000000000 --- a/src/mesa/drivers/ggi/default/.gitignore +++ /dev/null @@ -1 +0,0 @@ -genkgi.conf diff --git a/src/mesa/drivers/ggi/default/genkgi.conf.in b/src/mesa/drivers/ggi/default/genkgi.conf.in deleted file mode 100644 index 02acad2a19..0000000000 --- a/src/mesa/drivers/ggi/default/genkgi.conf.in +++ /dev/null @@ -1,4 +0,0 @@ -# GGIMesa genkgi helper configuration -.root: @ggi_libdir@/ggi/mesa/default - -tgt-fbdev-kgicon-d3dim-mesa d3dim.so diff --git a/src/mesa/drivers/ggi/default/genkgi.h b/src/mesa/drivers/ggi/default/genkgi.h deleted file mode 100644 index 6d0963416f..0000000000 --- a/src/mesa/drivers/ggi/default/genkgi.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -****************************************************************************** - - GGIMesa - KGIcon specific overrides for fbcon-mesa - API header - - Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] - - 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 - THE AUTHOR(S) 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. - -****************************************************************************** -*/ - -#ifndef _GENKGI_MESA_H -#define _GENKGI_MESA_H - -#undef KGI_USE_PPBUFS - -#include -#include - -#include -#include -#include - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -/* FIXME: LibGGI needs to export its genkgi.h */ -struct genkgi_priv -{ - ggi_gc *mapped_gc; - unsigned int gc_size; - ggifunc_drawline *drawline; - ggifunc_drawbox *drawbox; - ggifunc_fillscreen *fillscreen; - int fd_gc; - int close_gc; - int fd_kgicommand; - uint8 *mapped_kgicommand; - uint8 *kgicommand_ptr; - unsigned int kgicommand_buffersize; -}; - -#define GENKGI_PRIV(vis) ((struct genkgi_priv *)FBDEV_PRIV(vis)->accelpriv) - -extern ggifunc_getapi GGIMesa_genkgi_getapi; -extern ggifunc_flush GGIMesa_genkgi_flush; - -struct genkgi_priv_mesa -{ - char accel[100]; - int have_accel; - void *accelpriv; /* Private data of subdrivers */ - struct genkgi_priv *oldpriv; /* LibGGI's private data */ -}; - -#define GENKGI_PRIV_MESA(vis) ((struct genkgi_priv_mesa *)FBDEV_PRIV_MESA(vis)->accelpriv) - -#endif /* _GENKHI_MESA_H */ diff --git a/src/mesa/drivers/ggi/default/genkgi_mode.c b/src/mesa/drivers/ggi/default/genkgi_mode.c deleted file mode 100644 index f81d6a45bd..0000000000 --- a/src/mesa/drivers/ggi/default/genkgi_mode.c +++ /dev/null @@ -1,97 +0,0 @@ -/* -****************************************************************************** - - display-fbdev-kgicon-generic-mesa - - Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] - - 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 - THE AUTHOR(S) 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. - -****************************************************************************** -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "genkgi.h" - -int GGIMesa_genkgi_getapi(ggi_visual *vis, int num, char *apiname, char *arguments) -{ - struct genkgi_priv_mesa *priv = GENKGI_PRIV_MESA(vis); - - GGIMESADPRINT_CORE("Entered mesa_genkgi_getapi, num=%d\n", num); - - strcpy(arguments, ""); - - switch(num) - { - case 0: - if (priv->have_accel) - { - strcpy(apiname, priv->accel); - return 0; - } - break; - } - return -1; -} - -int GGIMesa_genkgi_flush(ggi_visual *vis, int x, int y, int w, int h, int tryflag) -{ - struct genkgi_priv_mesa *priv = GENKGI_PRIV_MESA(vis); - int junkval; - - priv->oldpriv->kgicommand_ptr += getpagesize(); - (kgiu32)(priv->oldpriv->kgicommand_ptr) &= 0xfffff000; - junkval = *((int *)(priv->oldpriv->kgicommand_ptr)); - - /* Check if we are now in the last page, and reset the - * FIFO if so. We can't use the last page to send - * more commands, since there's no page after it that - * we can touch to fault in the last page's commands. - * - * FIXME: This will be replaced with a flush-and-reset handler - * on the end-of-buffer pagefault at some point.... - * - */ - if ((priv->oldpriv->kgicommand_ptr - priv->oldpriv->mapped_kgicommand) - >= (priv->oldpriv->kgicommand_buffersize - getpagesize())) - { - munmap(priv->oldpriv->mapped_kgicommand, priv->oldpriv->kgicommand_buffersize); - if ((priv->oldpriv->mapped_kgicommand = - mmap(NULL, - priv->oldpriv->kgicommand_buffersize, - PROT_READ | PROT_WRITE, - MAP_SHARED, - priv->oldpriv->fd_kgicommand, - 0)) == MAP_FAILED) - { - ggiPanic("Failed to remap kgicommand!"); - } - priv->oldpriv->kgicommand_ptr = priv->oldpriv->mapped_kgicommand; - } - return 0; -} diff --git a/src/mesa/drivers/ggi/default/genkgi_visual.c b/src/mesa/drivers/ggi/default/genkgi_visual.c deleted file mode 100644 index d7838cae6e..0000000000 --- a/src/mesa/drivers/ggi/default/genkgi_visual.c +++ /dev/null @@ -1,190 +0,0 @@ -/* -****************************************************************************** - - genkgi_visual.c: visual handling for the generic KGI helper - - Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] - - 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 - THE AUTHOR(S) 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. - -****************************************************************************** -*/ - -#include -#include -#include -#include -#include "genkgi.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_SYS_VT_H -#include -#else -#include -#endif -#ifdef HAVE_LINUX_KDEV_T_H -#include -#endif -#include - -#define DEFAULT_FBNUM 0 - -static char accel_prefix[] = "tgt-fbdev-kgicon-"; -#define PREFIX_LEN (sizeof(accel_prefix)) - -typedef struct { - int async; - char *str; -} accel_info; - -static accel_info accel_strings[] = -{ - { 0, "d3dim" }, /* Direct3D Immediate Mode */ -}; - -#define NUM_ACCELS (sizeof(accel_strings)/sizeof(accel_info)) - -/* FIXME: These should be defined in the makefile system */ -#define CONF_FILE "/usr/local/etc/ggi/mesa/targets/genkgi.conf" -void *_configHandle; -char confstub[512] = CONF_FILE; -char *conffile = confstub; - -static int changed(ggi_visual_t vis, int whatchanged) -{ - GGIMESADPRINT_CORE("Entered ggimesa_genkgi_changed\n"); - - switch (whatchanged) - { - case GGI_CHG_APILIST: - { - char api[256]; - char args[256]; - int i; - const char *fname; - ggi_dlhandle *lib; - - for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++) - { - strcat(api, "-mesa"); - GGIMESADPRINT_CORE("ggimesa_genkgi_changed: api=%s, i=%d\n", api, i); - fname = ggMatchConfig(_configHandle, api, NULL); - if (fname == NULL) - { - /* No special implementation for this sublib */ - continue; - } - - lib = ggiExtensionLoadDL(vis, fname, args, NULL); - } - } - break; - } - return 0; -} - -static int GGIdlinit(ggi_visual *vis, struct ggi_dlhandle *dlh, - const char *args, void *argptr, uint32 *dlret) -{ - struct genkgi_priv_mesa *priv; - char libname[256], libargs[256]; - int id, err; - struct stat junk; - ggifunc_getapi *oldgetapi; - - GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: GGIdlinit start\n"); - - GENKGI_PRIV_MESA(vis) = priv = malloc(sizeof(struct genkgi_priv_mesa)); - if (priv == NULL) - { - fprintf(stderr, "Failed to allocate genkgi private data\n"); - return GGI_DL_ERROR; - } - - priv->oldpriv = GENKGI_PRIV(vis); -#if 0 - err = ggLoadConfig(conffile, &_configHandle); - if (err != GGI_OK) - { - gl_ggiPrint("display-fbdev-kgicon-mesa: Couldn't open %s\n", conffile); - return err; - } - - /* Hack city here. We need to probe the KGI driver properly for - * suggest-strings to discover the acceleration type(s). - */ - priv->have_accel = 0; - - if (stat("/proc/gfx0", &junk) == 0) - { - sprintf(priv->accel, "%s%s", accel_prefix, "d3dim"); - priv->have_accel = 1; - GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: Using accel: \"%s\"\n", priv->accel); - } - - /* Mode management */ - vis->opdisplay->getapi = GGIMesa_genkgi_getapi; - ggiIndicateChange(vis, GGI_CHG_APILIST); - - /* Give the accel sublibs a chance to set up a driver */ - if (priv->have_accel == 1) - { - oldgetapi = vis->opdisplay->getapi; - vis->opdisplay->getapi = GGIMesa_genkgi_getapi; - changed(vis, GGI_CHG_APILIST); - /* If the accel sublibs didn't produce, back up - * and keep looking */ - if ((LIBGGI_MESAEXT(vis)->update_state == NULL) || - (LIBGGI_MESAEXT(vis)->setup_driver == NULL)) - vis->opdisplay->getapi = oldgetapi; - } - - LIBGGI_MESAEXT(vis)->update_state = genkgi_update_state; - LIBGGI_MESAEXT(vis)->setup_driver = genkgi_setup_driver; -#endif - GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: GGIdlinit finished\n"); - - *dlret = GGI_DL_OPDRAW; - return 0; -} - -int MesaGGIdl_fbdev(int func, void **funcptr) -{ - switch (func) { - case GGIFUNC_open: - *funcptr = GGIopen; - return 0; - case GGIFUNC_exit: - case GGIFUNC_close: - *funcptr = NULL; - return 0; - default: - *funcptr = NULL; - } - return GGI_ENOTFOUND; -} - -#include diff --git a/src/mesa/drivers/ggi/default/linear.c b/src/mesa/drivers/ggi/default/linear.c deleted file mode 100644 index 9d29761ad5..0000000000 --- a/src/mesa/drivers/ggi/default/linear.c +++ /dev/null @@ -1,409 +0,0 @@ -/* GGI-Driver for MESA - * - * Copyright (C) 1997 Uwe Maurer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * --------------------------------------------------------------------- - * This code was derived from the following source of information: - * - * svgamesa.c and ddsample.c by Brian Paul - * - */ - -#include -#include -#include -#include "swrast/swrast.h" - -#define RMASK ((1<>RS) << (G+B)) | \ - ((color[GCOMP]>>GS) << B) | \ - ((color[BCOMP]>>BS))) - -#define FLIP(coord) (LIBGGI_VIRTY(ggi_ctx->ggi_visual) - (coord) - 1) - - -/**********************************************************************/ -/***** Write spans of pixels *****/ -/**********************************************************************/ - -void GGIwrite_ci32_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLuint ci[], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - FB_TYPE *fb; - fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + - FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; - - if (mask) { - while (n--) { - if (*mask++) - *fb = *ci; - fb++; - ci++; - } - } else { - while (n--) *fb++ = *ci++; - } -} - -void GGIwrite_ci8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLubyte ci[], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - FB_TYPE *fb; - fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + - FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; - - if (mask) { - while (n--) { - if (*mask++) - *fb = *ci; - fb++; - ci++; - } - } else { - while (n--) *fb++ = *ci++; - } -} - - -void GGIwrite_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLchan rgba[][4], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - FB_TYPE *fb; - fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + - FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; - - if (mask) { - while (n--) { - if (*mask++) - *fb = PACK(rgba[0]); - fb++; - rgba++; - } - } else { - while (n--) { - *fb++ = PACK(rgba[0]); - rgba++; - } - } -} - -void GGIwrite_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLchan rgba[][3], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - FB_TYPE *fb; - fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + - FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; - - if (mask) { - while (n--) { - if (*mask++) - *fb = PACK(rgba[0]); - fb++; - rgba++; - } - } else { - while (n--) { - *fb++ = PACK(rgba[0]); - rgba++; - } - } -} - - -void GGIwrite_mono_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLchan color[4], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - FB_TYPE *fb; - fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + - FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; - - if (mask) { - while (n--){ - if (*mask++) - *fb = PACK(color); - ++fb; - } - } else { - while (n--) - *fb++ = PACK(color); - - /* Alternatively we could write a potentialy faster HLine - ggiSetGCForeground(ggi_ctx->ggi_visual, color); - ggiDrawHLine(ggi_ctx->ggi_visual,x,FLIP(y),n); - */ - } -} - -void GGIwrite_mono_ci_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLuint ci, const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - FB_TYPE *fb; - fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + - FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; - - if (mask){ - while (n--){ - if (*mask++) - *fb = ci; - ++fb; - } - } else { - while (n--) - *fb++ = ci; - - /* Alternatively we could write a potentialy faster HLine - ggiSetGCForeground(ggi_ctx->ggi_visual, ci); - ggiDrawHLine(ggi_ctx->ggi_visual, x, FLIP(y), n); - */ - } -} - - -/**********************************************************************/ -/***** Read spans of pixels *****/ -/**********************************************************************/ - - -void GGIread_ci32_span(const GLcontext *ctx, - GLuint n, GLint x, GLint y, GLuint ci[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - FB_TYPE *fb; - fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + - FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; - - while (n--) - *ci++ = (GLuint)*fb++; -} - -void GGIread_rgba_span(const GLcontext *ctx, - GLuint n, GLint x, GLint y, GLchan rgba[][4]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - FB_TYPE color; - FB_TYPE *fb; - fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + - FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; - - while (n--) { - color = *fb++; - rgba[0][RCOMP] = (GLubyte) (color>>(G+B))<>B)& ((1<DriverCtx; - int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); - char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); - - while (n--) { - if (*mask++){ - FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; - *dst = *ci; - } - ci++; - x++; - y++; - } -} - -void GGIwrite_mono_ci_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLuint ci, const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); - char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); - - while (n--) { - if (*mask++){ - FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; - *dst = ci; - } - x++; - y++; - } -} - -void GGIwrite_rgba_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLchan rgba[][4], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); - char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); - - while (n--) { - if (*mask++){ - FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; - *dst = PACK(rgba[0]); - } - x++; - y++; - rgba++; - } -} - -void GGIwrite_mono_rgba_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLchan rgba[4], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); - char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); - - while (n--) { - if (*mask++){ - FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; - *dst = PACK(rgba); - } - - x++; - y++; - } -} - -/**********************************************************************/ -/***** Read arrays of pixels *****/ -/**********************************************************************/ - -void GGIread_ci32_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLuint ci[], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); - char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); - - while (n--) { - if (*mask++){ - FB_TYPE *src = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; - *ci = *src; - } - ci++; - x++; - y++; - } -} - -void GGIread_rgba_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); - char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); - FB_TYPE color; - - while (n--) { - if (*mask++) { - FB_TYPE *src = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; - color = *src; - - rgba[0][RCOMP] = (GLubyte)(color>>(G+B))<>B)& ((1<gl_ctx); - - GGIMESADPRINT_LIBS("linear_%d: GGIsetup_driver\n", sizeof(FB_TYPE)*8); - - swdd->WriteRGBASpan = GGIwrite_rgba_span; - swdd->WriteRGBSpan = GGIwrite_rgb_span; - swdd->WriteMonoRGBASpan = GGIwrite_mono_rgba_span; - swdd->WriteRGBAPixels = GGIwrite_rgba_pixels; - swdd->WriteMonoRGBAPixels = GGIwrite_mono_rgba_pixels; - - swdd->WriteCI32Span = GGIwrite_ci32_span; - swdd->WriteCI8Span = GGIwrite_ci8_span; - swdd->WriteMonoCISpan = GGIwrite_mono_ci_span; - swdd->WriteCI32Pixels = GGIwrite_ci32_pixels; - swdd->WriteMonoCIPixels = GGIwrite_mono_ci_pixels; - - swdd->ReadCI32Span = GGIread_ci32_span; - swdd->ReadRGBASpan = GGIread_rgba_span; - swdd->ReadCI32Pixels = GGIread_ci32_pixels; - swdd->ReadRGBAPixels = GGIread_rgba_pixels; - - swdd->SetBuffer = GGIset_buffer; - - return 0; -} - -static int GGIopen(ggi_visual_t vis,struct ggi_dlhandle *dlh, - const char *args,void *argptr, uint32 *dlret) -{ - GGIMESADPRINT_CORE("linear_%d: GGIOpen\n", sizeof(FB_TYPE)*8); - LIBGGI_MESAEXT(vis)->setup_driver = GGIsetup_driver; - - *dlret = GGI_DL_OPDRAW; - return 0; -} - -int DLOPENFUNC(int func, void **funcptr) -{ - switch (func) { - case GGIFUNC_open: - *funcptr = GGIopen; - return 0; - case GGIFUNC_exit: - case GGIFUNC_close: - *funcptr = NULL; - return 0; - default: - *funcptr = NULL; - } - return GGI_ENOTFOUND; -} - diff --git a/src/mesa/drivers/ggi/default/linear_15.c b/src/mesa/drivers/ggi/default/linear_15.c deleted file mode 100644 index ead7cc5847..0000000000 --- a/src/mesa/drivers/ggi/default/linear_15.c +++ /dev/null @@ -1,36 +0,0 @@ -/* GGI-Driver for MESA - * - * Copyright (C) 1997 Uwe Maurer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * --------------------------------------------------------------------- - * This code was derived from the following source of information: - * - * svgamesa.c and ddsample.c by Brian Paul - * - */ - -#include - -#define R 5 -#define G 5 -#define B 5 - -#define FB_TYPE uint16 -#define FB_BITS 15 -#define DLOPENFUNC MesaGGIdl_linear_15 - -#include "linear.c" - diff --git a/src/mesa/drivers/ggi/default/linear_16.c b/src/mesa/drivers/ggi/default/linear_16.c deleted file mode 100644 index 6028699bbc..0000000000 --- a/src/mesa/drivers/ggi/default/linear_16.c +++ /dev/null @@ -1,36 +0,0 @@ -/* GGI-Driver for MESA - * - * Copyright (C) 1997 Uwe Maurer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * --------------------------------------------------------------------- - * This code was derived from the following source of information: - * - * svgamesa.c and ddsample.c by Brian Paul - * - */ - -#include - -#define R 5 -#define G 6 -#define B 5 - -#define FB_TYPE uint16 -#define FB_BITS 16 -#define DLOPENFUNC MesaGGIdl_linear_16 - -#include "linear.c" - diff --git a/src/mesa/drivers/ggi/default/linear_24.c b/src/mesa/drivers/ggi/default/linear_24.c deleted file mode 100644 index 7a2236f124..0000000000 --- a/src/mesa/drivers/ggi/default/linear_24.c +++ /dev/null @@ -1,36 +0,0 @@ -/* GGI-Driver for MESA - * - * Copyright (C) 1997 Uwe Maurer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * --------------------------------------------------------------------- - * This code was derived from the following source of information: - * - * svgamesa.c and ddsample.c by Brian Paul - * - */ - -#include - -#define R 8 -#define G 8 -#define B 8 - -#define FB_TYPE uint32 -#define FB_BITS 24 -#define DLOPENFUNC MesaGGIdl_linear_24 - -#include "linear.c" - diff --git a/src/mesa/drivers/ggi/default/linear_32.c b/src/mesa/drivers/ggi/default/linear_32.c deleted file mode 100644 index 7cbf945f35..0000000000 --- a/src/mesa/drivers/ggi/default/linear_32.c +++ /dev/null @@ -1,36 +0,0 @@ -/* GGI-Driver for MESA - * - * Copyright (C) 1997 Uwe Maurer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * --------------------------------------------------------------------- - * This code was derived from the following source of information: - * - * svgamesa.c and ddsample.c by Brian Paul - * - */ - -#include - -#define R 8 -#define G 8 -#define B 8 - -#define FB_TYPE uint32 -#define FB_BITS 32 -#define DLOPENFUNC MesaGGIdl_linear_32 - -#include "linear.c" - diff --git a/src/mesa/drivers/ggi/default/linear_8.c b/src/mesa/drivers/ggi/default/linear_8.c deleted file mode 100644 index 9c7b5d712f..0000000000 --- a/src/mesa/drivers/ggi/default/linear_8.c +++ /dev/null @@ -1,36 +0,0 @@ -/* GGI-Driver for MESA - * - * Copyright (C) 1997 Uwe Maurer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * --------------------------------------------------------------------- - * This code was derived from the following source of information: - * - * svgamesa.c and ddsample.c by Brian Paul - * - */ - -#include - -#define R 3 -#define G 3 -#define B 2 - -#define FB_TYPE uint8 -#define FB_BITS 8 -#define DLOPENFUNC MesaGGIdl_linear_8 - -#include "linear.c" - diff --git a/src/mesa/drivers/ggi/default/stubs.c b/src/mesa/drivers/ggi/default/stubs.c deleted file mode 100644 index 62722972b2..0000000000 --- a/src/mesa/drivers/ggi/default/stubs.c +++ /dev/null @@ -1,512 +0,0 @@ -/* GGI-Driver for MESA - * - * Copyright (C) 1997 Uwe Maurer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * --------------------------------------------------------------------- - * This code was derived from the following source of information: - * - * svgamesa.c and ddsample.c by Brian Paul - * - */ - -#include - -#include -#include -#include - -#include "swrast/swrast.h" -//#include "swrast_setup/swrast_setup.h" -//#include "swrast/s_context.h" -//#include "swrast/s_depth.h" -//#include "swrast/s_triangle.h" - -#define FLIP(coord) (LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y-(coord)-1) - -/**********************************************************************/ -/***** Write spans of pixels *****/ -/**********************************************************************/ - -void GGIwrite_ci32_span(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLuint ci[], - const GLubyte mask[] ) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - y = FLIP(y); - if (mask) - { - while (n--) { - if (*mask++) - ggiPutPixel(ggi_ctx->ggi_visual, x, y, *ci); - x++; - ci++; - } - } - else - { - while (n--) - ggiPutPixel(ggi_ctx->ggi_visual, x++, y, *ci++); - } -} - -void GGIwrite_ci8_span(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte ci[], - const GLubyte mask[] ) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - y = FLIP(y); - if (mask) - { - while (n--) { - if (*mask++) - ggiPutPixel(ggi_ctx->ggi_visual, x, y, *ci); - x++; - ci++; - } - } - else - { - while (n--) - ggiPutPixel(ggi_ctx->ggi_visual, x++, y, *ci++); - } -} - -void GGIwrite_mono_ci_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLuint ci, const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - y = FLIP(y); - if (mask) - { - while (n--) { - if (*mask++) - ggiPutPixel(ggi_ctx->ggi_visual, x, y, ci); - x++; - } - } - else - { - while (n--) - ggiPutPixel(ggi_ctx->ggi_visual, x++, y, ci); - } -} - -void GGIwrite_mono_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLchan rgba[4], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - ggi_color rgb; - ggi_pixel col; - - y = FLIP(y); - - rgb.r = (uint16)(rgba[RCOMP]) << SHIFT; - rgb.g = (uint16)(rgba[GCOMP]) << SHIFT; - rgb.b = (uint16)(rgba[BCOMP]) << SHIFT; - col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); - - if (mask) - { - while (n--) { - if (*mask++) - ggiPutPixel(ggi_ctx->ggi_visual, x, y, col); - x++; - } - } - else - { - ggiDrawHLine(ggi_ctx->ggi_visual, x, y, n); - } -} - -void GGIwrite_rgba_span( const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte rgba[][4], - const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - ggi_color rgb; - ggi_pixel col; - y = FLIP(y); - - if (mask) - { - while (n--) { - if (*mask++) - { - rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT; - rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT; - rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT; - col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); - ggiPutPixel(ggi_ctx->ggi_visual, x, y, col); - } - x++; - rgba++; - } - } - else - { - while (n--) - { - rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT; - rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT; - rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT; - col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); - ggiPutPixel(ggi_ctx->ggi_visual, x++, y, col); - rgba++; - } - } -} - -void GGIwrite_rgb_span( const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte rgba[][3], - const GLubyte mask[] ) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - ggi_color rgb; - ggi_pixel col; - y = FLIP(y); - - if (mask) - { - while (n--) { - if (*mask++) - { - rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT; - rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT; - rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT; - col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); - ggiPutPixel(ggi_ctx->ggi_visual, x, y, col); - } - x++; - rgba++; - } - } - else - { - while (n--) - { - rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT; - rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT; - rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT; - col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); - ggiPutPixel(ggi_ctx->ggi_visual, x++, y, col); - rgba++; - } - } -} - - - -/**********************************************************************/ -/***** Read spans of pixels *****/ -/**********************************************************************/ - - -void GGIread_ci32_span( const GLcontext *ctx, - GLuint n, GLint x, GLint y, GLuint ci[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - y = FLIP(y); - while (n--) - ggiGetPixel(ggi_ctx->ggi_visual, x++, y, ci++); -} - -void GGIread_rgba_span( const GLcontext *ctx, - GLuint n, GLint x, GLint y, - GLubyte rgba[][4]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - ggi_color rgb; - ggi_pixel col; - - y = FLIP(y); - - while (n--) - { - ggiGetPixel(ggi_ctx->ggi_visual, x++, y, &col); - ggiUnmapPixel(ggi_ctx->ggi_visual, col, &rgb); - rgba[0][RCOMP] = (GLubyte) (rgb.r >> SHIFT); - rgba[0][GCOMP] = (GLubyte) (rgb.g >> SHIFT); - rgba[0][BCOMP] = (GLubyte) (rgb.b >> SHIFT); - rgba[0][ACOMP] = 0; - rgba++; - } -} - -/**********************************************************************/ -/***** Write arrays of pixels *****/ -/**********************************************************************/ - -void GGIwrite_ci32_pixels( const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLuint ci[], const GLubyte mask[] ) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - while (n--) { - if (*mask++) - ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), *ci); - ci++; - x++; - y++; - } -} - -void GGIwrite_mono_ci_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLuint ci, const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - while (n--) { - if (*mask++) - ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), ci); - x++; - y++; - } -} - -void GGIwrite_rgba_pixels( const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLubyte rgba[][4], - const GLubyte mask[] ) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - ggi_pixel col; - ggi_color rgb; - while (n--) { - if (*mask++) { - rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT; - rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT; - rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT; - col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); - ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), col); - } - x++; - y++; - rgba++; - } -} - -void GGIwrite_mono_rgba_pixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLchan rgba[4], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - ggi_color rgb; - ggi_pixel col; - - rgb.r = (uint16)(rgba[RCOMP]) << SHIFT; - rgb.g = (uint16)(rgba[GCOMP]) << SHIFT; - rgb.b = (uint16)(rgba[BCOMP]) << SHIFT; - col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); - - while (n--) { - if (*mask++) - ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), col); - x++; - y++; - } -} - -/**********************************************************************/ -/***** Read arrays of pixels *****/ -/**********************************************************************/ - -void GGIread_ci32_pixels( const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLuint ci[], const GLubyte mask[]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - while (n--) { - if (*mask++) - ggiGetPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), ci); - ci++; - x++; - y++; - } -} - -void GGIread_rgba_pixels( const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], - const GLubyte mask[] ) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - ggi_color rgb; - ggi_pixel col; - - while (n--) - { - if (*mask++) - { - ggiGetPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), &col); - ggiUnmapPixel(ggi_ctx->ggi_visual, col, &rgb); - rgba[0][RCOMP] = rgb.r >> SHIFT; - rgba[0][GCOMP] = rgb.g >> SHIFT; - rgba[0][BCOMP] = rgb.b >> SHIFT; - rgba[0][ACOMP] = 0; - } - x++; - y++; - rgba++; - } -} - -int GGIextend_visual(ggi_visual_t vis) -{ - return 0; -} - -//static swrast_tri_func ggimesa_stubs_get_triangle_func(GLcontext *ctx); - -int GGIsetup_driver(ggi_mesa_context_t ggi_ctx) -{ - struct swrast_device_driver *swdd = - _swrast_GetDeviceDriverReference(ggi_ctx->gl_ctx); - - GGIMESADPRINT_CORE("stubs: setup_driver\n"); - - swdd->WriteRGBASpan = GGIwrite_rgba_span; - swdd->WriteRGBSpan = GGIwrite_rgb_span; - swdd->WriteMonoRGBASpan = GGIwrite_mono_rgba_span; - swdd->WriteRGBAPixels = GGIwrite_rgba_pixels; - swdd->WriteMonoRGBAPixels = GGIwrite_mono_rgba_pixels; - - swdd->WriteCI32Span = GGIwrite_ci32_span; - swdd->WriteCI8Span = GGIwrite_ci8_span; - swdd->WriteMonoCISpan = GGIwrite_mono_ci_span; - swdd->WriteCI32Pixels = GGIwrite_ci32_pixels; - swdd->WriteMonoCIPixels = GGIwrite_mono_ci_pixels; - - swdd->ReadCI32Span = GGIread_ci32_span; - swdd->ReadRGBASpan = GGIread_rgba_span; - swdd->ReadCI32Pixels = GGIread_ci32_pixels; - swdd->ReadRGBAPixels = GGIread_rgba_pixels; - - return 0; -} - -void GGIupdate_state(ggi_mesa_context_t *ctx) -{ - //ctx->Driver.TriangleFunc = _swsetup_Triangle; -} - -/* -void GGItriangle_flat(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1, const SWvertex *v2) -{ -//#define INTERP_Z 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE - -#define SETUP_CODE \ - ggi_color color; \ - color.r = v0->color[0]; \ - color.g = v0->color[1]; \ - color.b = v0->color[2]; \ - color.a = v0->color[3]; \ - ggiSetGCForeground(VIS, ggiMapColor(VIS, &color)); - -#define INNER_LOOP(LEFT,RIGHT,Y) \ - ggiDrawHLine(VIS,LEFT,FLIP(Y),RIGHT-LEFT); - -#include "swrast/s_tritemp.h" -} - - -static void GGItriangle_flat_depth(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1, const SWvertex *v2) -{ -#define INTERP_Z 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE - -#define SETUP_CODE \ - ggi_color color; \ - color.r = v0->color[0]; \ - color.g = v0->color[1]; \ - color.b = v0->color[2]; \ - color.a = v0->color[3]; \ - ggiSetGCForeground(VIS, ggiMapColor(VIS, &color)); - -#define INNER_LOOP(LEFT,RIGHT,Y) \ - { \ - GLint i,xx=LEFT,yy=FLIP(Y),n=RIGHT-LEFT,length=0; \ - GLint startx=xx; \ - for (i=0;iStencil._Enabled) return NULL; - if (ctx->Polygon.SmoothFlag) return NULL; - if (ctx->Polygon.StippleFlag) return NULL; - if (ctx->Texture._ReallyEnabled) return NULL; - if (ctx->Light.ShadeModel==GL_SMOOTH) return NULL; - if (ctx->Depth.Test && ctx->Depth.Func != GL_LESS) return NULL; - - if (ctx->Depth.Test) - return GGItriangle_flat_depth; - - return GGItriangle_flat; -} -*/ -static int GGIopen(ggi_visual_t vis, struct ggi_dlhandle *dlh, - const char *args, void *argptr, uint32 *dlret) -{ - LIBGGI_MESAEXT(vis)->update_state = GGIupdate_state; - LIBGGI_MESAEXT(vis)->setup_driver = GGIsetup_driver; - - *dlret = GGI_DL_OPDRAW; - return 0; -} - -int MesaGGIdl_stubs(int func, void **funcptr) -{ - switch (func) { - case GGIFUNC_open: - *funcptr = GGIopen; - return 0; - case GGIFUNC_exit: - case GGIFUNC_close: - *funcptr = NULL; - return 0; - default: - *funcptr = NULL; - } - return GGI_ENOTFOUND; -} diff --git a/src/mesa/drivers/ggi/display/.gitignore b/src/mesa/drivers/ggi/display/.gitignore deleted file mode 100644 index 98858db2c0..0000000000 --- a/src/mesa/drivers/ggi/display/.gitignore +++ /dev/null @@ -1 +0,0 @@ -fbdev.conf diff --git a/src/mesa/drivers/ggi/display/fbdev.conf.in b/src/mesa/drivers/ggi/display/fbdev.conf.in deleted file mode 100644 index 2acb89426f..0000000000 --- a/src/mesa/drivers/ggi/display/fbdev.conf.in +++ /dev/null @@ -1,4 +0,0 @@ -# GGIMesa fbdev target configuration -.root: @ggi_libdir@/ggi/mesa/default - -tgt-fbdev-kgicon-generic-mesa genkgi.so diff --git a/src/mesa/drivers/ggi/display/fbdev_mode.c b/src/mesa/drivers/ggi/display/fbdev_mode.c deleted file mode 100644 index 85c35ffe0e..0000000000 --- a/src/mesa/drivers/ggi/display/fbdev_mode.c +++ /dev/null @@ -1,130 +0,0 @@ -/****************************************************************************** - - display-fbdev-mesa - - Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] - - 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 - THE AUTHOR(S) 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. - -****************************************************************************** -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#ifndef MAP_FAILED -#define MAP_FAILED ((void*)-1) -#endif - -#define FB_KLUDGE_FONTX 8 -#define FB_KLUDGE_FONTY 16 -#define FB_KLUDGE_TEXTMODE 13 -#define TIMINGFILE "/etc/fb.modes" - -int GGIMesa_fbdev_getapi(ggi_visual *vis, int num, char *apiname, char *arguments) -{ - struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis); - - arguments = '\0'; - - switch(num) { - case 0: - if (priv->oldpriv->have_accel) { - strcpy(apiname, priv->oldpriv->accel); - return 0; - } - break; - } - - return -1; -} - -static int do_setmode(ggi_visual *vis) -{ - struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis); - int err, id; - char libname[GGI_API_MAXLEN], libargs[GGI_API_MAXLEN]; - ggi_graphtype gt; - - _ggiZapMode(vis, ~GGI_DL_OPDISPLAY); - priv->have_accel = 0; - - for (id = 1; GGIMesa_fbdev_getapi(vis, id, libname, libargs) == 0; id++) { - if (_ggiOpenDL(vis, libname, libargs, NULL) == 0) { - GGIMESADPRINT_LIBS(stderr, "display-fbdev-mesa: Error opening the " - "%s (%s) library.\n", libname, libargs); - return GGI_EFATAL; - } - - GGIMESADPRINT_CORE("Success in loading %s (%s)\n", - libname, libargs); - } - - if (priv->oldpriv->accel && - _ggiOpenDL(vis, priv->accel, NULL, NULL) != 0) { - priv->have_accel = 1; - } else { - priv->have_accel = 0; - } - vis->accelactive = 0; - - ggiIndicateChange(vis, GGI_CHG_APILIST); - - GGIMESADPRINT_CORE("display-fbdev-mesa: do_setmode SUCCESS\n"); - - return 0; -} - - -int GGIMesa_fbdev_setmode(ggi_visual *vis, ggi_mode *mode) -{ - int err; - - if ((err = ggiCheckMode(vis, mode)) != 0) { - return err; - } - - GGIMESADPRINT_CORE("display-fbdev-mesa: setmode %dx%d#%dx%dF%d[0x%02x]\n", - mode->visible.x, mode->visible.y, - mode->virt.x, mode->virt.y, - mode->frames, mode->graphtype); - - memcpy(LIBGGI_MODE(vis), mode, sizeof(ggi_mode)); - - /* Now actually set the mode */ - err = do_setmode(vis); - if (err != 0) { - return err; - } - - GGIMESADPRINT_CORE("display-fbdev-mesa: setmode success.\n"); - - return 0; -} diff --git a/src/mesa/drivers/ggi/display/fbdev_visual.c b/src/mesa/drivers/ggi/display/fbdev_visual.c deleted file mode 100644 index f0c1771c77..0000000000 --- a/src/mesa/drivers/ggi/display/fbdev_visual.c +++ /dev/null @@ -1,138 +0,0 @@ -/****************************************************************************** - - display-fbdev-mesa: visual handling - - Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] - - 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 - THE AUTHOR(S) 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. - -****************************************************************************** -*/ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - -#ifdef HAVE_SYS_VT_H -#include -#else -#include -#endif -#ifdef HAVE_LINUX_KDEV_T_H -#include -#endif -#include - -#define MAX_DEV_LEN 63 -#define DEFAULT_FBNUM 0 - -static char accel_prefix[] = "tgt-fbdev-"; -#define PREFIX_LEN (sizeof(accel_prefix)) - -typedef struct { - int async; - char *str; -} accel_info; - -static accel_info accel_strings[] = { - { 0, "kgicon-generic",}, /* no accel - check for KGIcon */ - { 0, NULL }, /* Atari Blitter */ -}; - -#define NUM_ACCELS (sizeof(accel_strings)/sizeof(accel_info)) - - - -static int GGIopen(ggi_visual *vis, struct ggi_dlhandle *dlh, - const char *args, void *argptr, uint32 *dlret) -{ - int err; - struct fbdev_priv_mesa *priv; - ggifunc_getapi *oldgetapi; - - - priv->oldpriv = LIBGGI_PRIVATE(vis); /* Hook back */ - - GGIMESA_PRIV(vis) = priv = malloc(sizeof(struct fbdev_priv_mesa)); - if (priv == NULL) { - fprintf(stderr, "GGIMesa: Failed to allocate fbdev private data\n"); - return GGI_ENOMEM; - } - - oldgetapi = vis->opdisplay->getapi; - vis->opdisplay->getapi = GGIMesa_fbdev_getapi; - changed(vis, GGI_CHG_APILIST); - - /* If the accel sublibs didn't sucessfuly hook a driver, - * back up and keep looking */ - if ((LIBGGI_MESAEXT(vis)->update_state == NULL) || - (LIBGGI_MESAEXT(vis)->setup_driver == NULL)) - { - vis->opdisplay->getapi = oldgetapi; - } - - *dlret = GGI_DL_EXTENSION; - return 0; -} - - -static int GGIclose(ggi_visual *vis, struct ggi_dlhandle *dlh) -{ - struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis); - - if (priv) { - LIBGGI_PRIVATE(vis) = priv->oldpriv; - free(priv); - } - - return 0; -} - - -int MesaGGIdl_fbdev_mesa(int func, void **funcptr) -{ - switch (func) { - case GGIFUNC_open: - *funcptr = GGIopen; - return 0; - case GGIFUNC_exit: - *funcptr = NULL; - return 0; - case GGIFUNC_close: - *funcptr = GGIclose; - return 0; - default: - *funcptr = NULL; - } - - return GGI_ENOTFOUND; -} - - -#include diff --git a/src/mesa/drivers/ggi/ggimesa.c b/src/mesa/drivers/ggi/ggimesa.c deleted file mode 100644 index bc08144d66..0000000000 --- a/src/mesa/drivers/ggi/ggimesa.c +++ /dev/null @@ -1,670 +0,0 @@ -/* GGI-Driver for MESA - * - * Copyright (C) 1997-1998 Uwe Maurer - uwe_maurer@t-online.de - * 2002 Filip Spacek - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * --------------------------------------------------------------------- - * This code was derived from the following source of information: - * - * svgamesa.c and ddsample.c by Brian Paul - * - */ - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#include -#include -#include "main/extensions.h" -#include "main/buffers.h" -#include "main/colormac.h" -#include "main/imports.h" -#include "main/matrix.h" -#include "main/teximage.h" -#include "main/texformat.h" -#include "main/texstore.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" -#include "vbo/vbo.h" - -/* We use LibGG to manage config files */ -#include - - -/* XXX: Those #defines should be provided via - * config.h - */ -#define GGIMESAPATHTAG "pAtHTAg" -#define GGIMESACONFDIR "pAtHTAg/usr/local/etc/ggi" -#define GGIMESATAGLEN 7 -#define GGIMESACONFFILE "ggimesa.conf" - - -/* Static variables - */ -static int _ggimesaLibIsUp = 0; -static void *_ggimesaConfigHandle; -static char _ggimesaconfstub[512] = GGIMESACONFDIR; -static char *_ggimesaconfdir = _ggimesaconfstub+GGIMESATAGLEN; - -int _ggimesaDebugSync = 0; -uint32 _ggimesaDebugState = 0; - - - -/* Extension ID. Defaulting to -1 should make segfault on abuse more likely... - */ -ggi_extid _ggiMesaID = -1; - - -#define SUBLIB_PREFIX "MesaGGIdl_" - - -/* - * Returns the directory where global config files are kept - */ - -const char *ggiMesaGetConfDir(void) -{ -#ifdef __WIN32__ - /* On Win32 we allow overriding of the compiled in path. */ - const char *envdir = getenv("GGI_CONFDIR"); - if (envdir) return envdir; -#endif - return _ggimesaconfdir; -} - - -/* Dummy function which returns -1 - We use this to reset the function pointers */ -static int _ggi_error(void) -{ - GGIMESADPRINT_CORE("_ggi_error() called\n"); - - return -1; -} - - -static int changed(ggi_visual_t vis, int whatchanged) -{ - GLcontext *ctx; - ctx = _mesa_get_current_context(); - - GGIMESADPRINT_CORE("changed() called\n"); - - switch (whatchanged) { - case GGI_CHG_APILIST: - { - char api[GGI_MAX_APILEN]; - char args[GGI_MAX_APILEN]; - int i; - const char *fname; - ggi_dlhandle *lib; - - GLvisual *gl_vis = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual); - GLframebuffer *gl_fb = &(LIBGGI_MESAEXT(vis)->mesa_buffer); - - /* Initialize the framebuffer to provide all necessary - buffers in software. The target libraries that are loaded - next are free to modify this according to their - capabilities. - */ - /* FIXME: if the target changes capabilities we'll leak - swrast's memory !!! Need to deallocate first */ - _mesa_initialize_framebuffer(gl_fb, gl_vis, - gl_vis->depthBits > 0, - gl_vis->stencilBits > 0, - gl_vis->accumRedBits > 0, - gl_vis->alphaBits > 0); - - for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++) { - strcat(api, "-mesa"); - GGIMESADPRINT_CORE("GGIMesa: looking for" - "a sublib named %s\n", api); - fname = ggMatchConfig(_ggimesaConfigHandle, api, NULL); - if (fname == NULL) { - /* No special implementation for this sublib */ - continue; - } - lib = ggiExtensionLoadDL(vis, fname, args, NULL, - SUBLIB_PREFIX); - } - - /* The targets have cleared everything they can do from - the framebuffer structure so we provide the rest in sw - */ - /*_swrast_alloc_buffers(gl_fb);*/ - - break; - } - } - return 0; -} - - -int ggiMesaInit() -{ - int err; - char *str; - char *conffile; - - GGIMESADPRINT_CORE("ggiMesaInit() called\n"); - - _ggimesaLibIsUp++; - if (_ggimesaLibIsUp > 1) return 0; /* Initialize only at first call */ - - str = getenv("GGIMESA_DEBUGSYNC"); - if (str != NULL) { - _ggimesaDebugSync = 1; - } - - str = getenv("GGIMESA_DEBUG"); - if (str != NULL) { - _ggimesaDebugState = atoi(str); - GGIMESADPRINT_CORE("%s Debugging=%d\n", - _ggimesaDebugSync ? "sync" : "async", - _ggimesaDebugState); - } - - - conffile = malloc(strlen(ggiMesaGetConfDir()) + 1 - + strlen(GGIMESACONFFILE) +1); - if (conffile == NULL) { - fprintf(stderr, "GGIMesa: unable to allocate memory for config filename.\n"); - return GGI_ENOMEM; - } - sprintf(conffile, "%s%c%s", - ggiMesaGetConfDir(), '/', GGIMESACONFFILE); - err = ggLoadConfig(conffile, &_ggimesaConfigHandle); - if (err != GGI_OK) { - fprintf(stderr, "GGIMesa: Couldn't open %s\n", - conffile); - free(conffile); - _ggimesaLibIsUp--; - return err; - } - free(conffile); - - _ggiMesaID = ggiExtensionRegister("GGIMesa", - sizeof(struct ggi_mesa_ext), changed); - if (_ggiMesaID < 0) { - fprintf(stderr, "GGIMesa: failed to register as extension\n"); - _ggimesaLibIsUp--; - ggFreeConfig(_ggimesaConfigHandle); - return _ggiMesaID; - } - - return 0; -} - -int ggiMesaExit(void) -{ - int rc; - - GGIMESADPRINT_CORE("ggiMesaExit() called\n"); - - if (!_ggimesaLibIsUp) return -1; - - if (_ggimesaLibIsUp > 1) { - /* Exit only at last call */ - _ggimesaLibIsUp--; - return 0; - } - - rc = ggiExtensionUnregister(_ggiMesaID); - ggFreeConfig(_ggimesaConfigHandle); - - _ggimesaLibIsUp = 0; - - return rc; -} - - - - -static void gl_ggiUpdateState(GLcontext *ctx, GLuint new_state); - - -static void gl_ggiGetSize(GLframebuffer *fb, GLuint *width, GLuint *height) -{ - /* FIXME: this is a hack to work around the new interface */ - GLcontext *ctx; - ggi_mesa_context_t ggi_ctx; - ctx = _mesa_get_current_context(); - ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - - GGIMESADPRINT_CORE("gl_ggiGetSize() called\n"); - - *width = LIBGGI_VIRTX(ggi_ctx->ggi_visual); - *height = LIBGGI_VIRTY(ggi_ctx->ggi_visual); - printf("returning %d, %d\n", *width, *height); -} - -/** - * We only implement this function as a mechanism to check if the - * framebuffer size has changed (and update corresponding state). - */ -static void gl_ggiViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ - GLuint newWidth, newHeight; - GLframebuffer *buffer = ctx->WinSysDrawBuffer; - gl_ggiGetSize( buffer, &newWidth, &newHeight ); - if (buffer->Width != newWidth || buffer->Height != newHeight) { - _mesa_resize_framebuffer(ctx, buffer, newWidth, newHeight ); - } -} - - -static void gl_ggiSetIndex(GLcontext *ctx, GLuint ci) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - - GGIMESADPRINT_CORE("gl_ggiSetIndex() called\n"); - - ggiSetGCForeground(ggi_ctx->ggi_visual, ci); - ggi_ctx->color = (ggi_pixel)ci; -} - -static void gl_ggiSetClearIndex(GLcontext *ctx, GLuint ci) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - - GGIMESADPRINT_CORE("gl_ggiSetClearIndex() called\n"); - - ggiSetGCForeground(ggi_ctx->ggi_visual, ci); - ggi_ctx->clearcolor = (ggi_pixel)ci; -} - -static void gl_ggiSetClearColor(GLcontext *ctx, const GLfloat color[4]) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - ggi_color rgb; - ggi_pixel col; - GLubyte byteColor[3]; - - GGIMESADPRINT_CORE("gl_ggiSetClearColor() called\n"); - - CLAMPED_FLOAT_TO_UBYTE(byteColor[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(byteColor[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(byteColor[2], color[2]); - - rgb.r = (uint16)byteColor[0] << SHIFT; - rgb.g = (uint16)byteColor[1] << SHIFT; - rgb.b = (uint16)byteColor[2] << SHIFT; - col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); - ggiSetGCForeground(ggi_ctx->ggi_visual, col); - ggi_ctx->clearcolor = col; -} - -static void gl_ggiClear(GLcontext *ctx, GLbitfield mask) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - int x = ctx->DrawBuffer->_Xmin; - int y = ctx->DrawBuffer->_Ymin; - int w = ctx->DrawBuffer->_Xmax - x; - int h = ctx->DrawBuffer->_Ymax - y; - GLboolean all = (w == ctx->DrawBuffer->Width && h == ctx->DrawBuffer->height) - - GGIMESADPRINT_CORE("gl_ggiClear() called\n"); - - if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) { - ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->clearcolor); - - if (all) { - int w, h; - w = LIBGGI_VIRTX(ggi_ctx->ggi_visual); - h = LIBGGI_VIRTX(ggi_ctx->ggi_visual); - ggiDrawBox(ggi_ctx->ggi_visual, 0, 0, w, h); - } else { - ggiDrawBox(ggi_ctx->ggi_visual, x, y, //FLIP(y), - width, height); - } - ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->color); - - mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT); - } - _swrast_Clear(ctx, mask); - -} - - -/* Set the buffer used for reading */ -/* XXX support for separate read/draw buffers hasn't been tested */ -static GLboolean gl_ggiSetBuffer(GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - - printf("set read %d\n", bufferBit); - GGIMESADPRINT_CORE("gl_ggiSetBuffer() called\n"); - - if (bufferBit == DD_FRONT_LEFT_BIT) - { - ggiSetReadFrame(ggi_ctx->ggi_visual, - ggiGetDisplayFrame(ggi_ctx->ggi_visual)); - ggiSetWriteFrame(ggi_ctx->ggi_visual, - ggiGetDisplayFrame(ggi_ctx->ggi_visual)); - return GL_TRUE; - } - else if (bufferBit == DD_BACK_LEFT_BIT) - { - ggiSetReadFrame(ggi_ctx->ggi_visual, - ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1); - ggiSetWriteFrame(ggi_ctx->ggi_visual, - ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1); - return GL_TRUE; - } - else - return GL_FALSE; -} - - -static const GLubyte * gl_ggiGetString(GLcontext *ctx, GLenum name) -{ - GGIMESADPRINT_CORE("gl_ggiGetString() called\n"); - - if (name == GL_RENDERER) { - return (GLubyte *) "Mesa GGI"; - } else { - return NULL; - } -} - -static void gl_ggiFlush(GLcontext *ctx) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - - GGIMESADPRINT_CORE("gl_ggiFlush() called\n"); - - ggiFlush(ggi_ctx->ggi_visual); -} - -static void gl_ggiIndexMask(GLcontext *ctx, GLuint mask) -{ - GGIMESADPRINT_CORE("gl_ggiIndexMask() called\n"); -} - -static void gl_ggiColorMask(GLcontext *ctx, GLboolean rmask, GLboolean gmask, - GLboolean bmask, GLboolean amask) -{ - GGIMESADPRINT_CORE("gl_ggiColorMask() called\n"); -} - -static void gl_ggiEnable(GLcontext *ctx, GLenum pname, GLboolean state) -{ - GGIMESADPRINT_CORE("gl_ggiEnable() called\n"); -} - -static void gl_ggiSetupPointers(GLcontext *ctx) -{ - TNLcontext *tnl; - - GGIMESADPRINT_CORE("gl_ggiSetupPointers() called\n"); - - /* Plug in default driver functions */ - _mesa_init_driver_functions(&ctx->Driver); - - /* Plug in ggi-specific functions */ - ctx->Driver.GetString = gl_ggiGetString; - ctx->Driver.GetBufferSize = gl_ggiGetSize; - ctx->Driver.Viewport = gl_ggiViewport; - ctx->Driver.Finish = gl_ggiFlush; - ctx->Driver.Flush = gl_ggiFlush; - ctx->Driver.Clear = gl_ggiClear; - ctx->Driver.ClearIndex = gl_ggiSetClearIndex; - ctx->Driver.ClearColor = gl_ggiSetClearColor; - ctx->Driver.IndexMask = gl_ggiIndexMask; - ctx->Driver.ColorMask = gl_ggiColorMask; - ctx->Driver.Enable = gl_ggiEnable; - ctx->Driver.UpdateState = gl_ggiUpdateState; - - /* Initialize TNL driver interface */ - tnl = TNL_CONTEXT(ctx); - tnl->Driver.RunPipeline = _tnl_run_pipeline; - - /* Install setup for tnl */ - _swsetup_Wakeup(ctx); -} - -static void get_mode_info(ggi_visual_t vis, int *r, int *g, int *b, - GLboolean *rgb, GLboolean *db, int *ci) -{ - unsigned int i; - - *r = 0; - *g = 0; - *b = 0; - - for(i = 0; i < sizeof(ggi_pixel)*8; ++i) { - int mask = 1 << i; - if (LIBGGI_PIXFMT(vis)->red_mask & mask) - ++(*r); - if (LIBGGI_PIXFMT(vis)->green_mask & mask) - ++(*g); - if (LIBGGI_PIXFMT(vis)->blue_mask & mask) - ++(*b); - } - - *rgb = GT_SCHEME(LIBGGI_MODE(vis)->graphtype) == GT_TRUECOLOR; - *db = LIBGGI_MODE(vis)->frames > 1; - *ci = GT_SIZE(LIBGGI_MODE(vis)->graphtype); - - printf("rgb (%d, %d, %d) db %d, rgb %d ci %d\n",*r,*g,*b,*db,*rgb,*ci); -} - - -int ggiMesaAttach(ggi_visual_t vis) -{ - int rc; - - GGIMESADPRINT_CORE("ggiMesaAttach() called\n"); - - rc = ggiExtensionAttach(vis, _ggiMesaID); - if (rc == 0) - { - int r, g, b, ci; - GLboolean rgb, db; - GLvisual *gl_visual; - - /* We are creating the primary instance */ - memset(LIBGGI_MESAEXT(vis), 0, sizeof(struct ggi_mesa_ext)); - LIBGGI_MESAEXT(vis)->update_state = (void *)_ggi_error; - LIBGGI_MESAEXT(vis)->setup_driver = (void *)_ggi_error; - - /* Initialize default mesa visual */ - get_mode_info(vis, &r, &g, &b, &rgb, &db, &ci); - gl_visual = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual); - _mesa_initialize_visual(gl_visual, - rgb, db, 0 /* No stereo */, - r, g, b, 0 /* No alpha */, ci, - 0 /* No depth */, 0 /* No stencil */, - 0, 0, 0, 0 /* No accum */, 0); - - /* Now fake an "API change" so the right libs get loaded */ - changed(vis, GGI_CHG_APILIST); - } - - return rc; -} - -int ggiMesaDetach(ggi_visual_t vis) -{ - GGIMESADPRINT_CORE("ggiMesaDetach() called\n"); - - return ggiExtensionDetach(vis, _ggiMesaID); -} - -int ggiMesaExtendVisual(ggi_visual_t vis, GLboolean alpha_flag, - GLboolean stereo_flag, GLint depth_size, - GLint stencil_size, GLint accum_red_size, - GLint accum_green_size, GLint accum_blue_size, - GLint accum_alpha_size, GLint num_samples) -{ - GLvisual *gl_vis = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual); - int r, g, b, ci; - GLboolean db, rgb; - - get_mode_info(vis, &r, &g, &b, &rgb, &db, &ci); - - /* Initialize the visual with the provided information */ - _mesa_initialize_visual(gl_vis, - rgb, db, stereo_flag, - r, g, b, 0 /* FIXME */, ci, - depth_size, stencil_size, - accum_red_size, accum_green_size, - accum_blue_size, accum_alpha_size, 0); - - /* Now fake an "API change" so the right libs get loaded. After all, - extending the visual by all these new buffers could be considered - a "mode change" which requires an "API change". - */ - changed(vis, GGI_CHG_APILIST); - - return 0; -} - - -ggi_mesa_context_t ggiMesaCreateContext(ggi_visual_t vis) -{ - ggi_mesa_context_t ctx; - int err; - - GGIMESADPRINT_CORE("ggiMesaCreateContext() called\n"); - - ctx = (ggi_mesa_context_t)malloc(sizeof(struct ggi_mesa_context)); - if (!ctx) - return NULL; - - ctx->ggi_visual = vis; - ctx->color = 0; - - ctx->gl_ctx = - _mesa_create_context(&(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual), - NULL, (void *) ctx, GL_FALSE); - if (!ctx->gl_ctx) - goto free_context; - - _mesa_enable_sw_extensions(ctx->gl_ctx); - - _swrast_CreateContext(ctx->gl_ctx); - _vbo_CreateContext(ctx->gl_ctx); - _tnl_CreateContext(ctx->gl_ctx); - _swsetup_CreateContext(ctx->gl_ctx); - - gl_ggiSetupPointers(ctx->gl_ctx); - - /* Make sure that an appropriate sublib has been loaded */ - if (!LIBGGI_MESAEXT(ctx->ggi_visual)->setup_driver){ - GGIMESADPRINT_CORE("setup_driver==NULL!\n"); - GGIMESADPRINT_CORE("Please check your config files!\n"); - goto free_context; - } - - /* Set up the sublib driver */ - err = LIBGGI_MESAEXT(ctx->ggi_visual)->setup_driver(ctx); - if (err){ - GGIMESADPRINT_CORE("setup_driver failed (err = %d)", err); - goto free_gl_context; - } - - return ctx; - -free_gl_context: - _mesa_destroy_context(ctx->gl_ctx); -free_context: - free(ctx); - - return NULL; -} - -void ggiMesaDestroyContext(ggi_mesa_context_t ctx) -{ - GGIMESADPRINT_CORE("ggiMesaDestroyContext() called\n"); - - if(!ctx) - return; - - _mesa_destroy_context(ctx->gl_ctx); - free(ctx); -} - -void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis) -{ - GGIMESADPRINT_CORE("ggiMesaMakeCurrent(ctx = %p) called\n", ctx); - - /* FIXME: clean up where are ggi_vis */ - if (ctx->ggi_visual != vis) { - GGIMESADPRINT_CORE("Cannot migrate GL contexts\n"); - return; - } - - _mesa_make_current(ctx->gl_ctx, &LIBGGI_MESAEXT(vis)->mesa_buffer); -} - - -/* - * Swap front/back buffers for current context if double buffered. - */ -void ggiMesaSwapBuffers(void) -{ - GLcontext *ctx; - ggi_mesa_context_t ggi_ctx; - ctx = _mesa_get_current_context(); - ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - - GGIMESADPRINT_CORE("ggiMesaSwapBuffers() called\n"); - - _mesa_notifySwapBuffers(ctx); - gl_ggiFlush(ctx); - - ggiSetDisplayFrame(ggi_ctx->ggi_visual, - !ggiGetDisplayFrame(ggi_ctx->ggi_visual)); - ggiSetWriteFrame(ggi_ctx->ggi_visual, - !ggiGetWriteFrame(ggi_ctx->ggi_visual)); - ggiSetReadFrame(ggi_ctx->ggi_visual, - !ggiGetReadFrame(ggi_ctx->ggi_visual)); - - GGIMESADPRINT_CORE("swap disp: %d, write %d\n", - ggiGetDisplayFrame(ggi_ctx->ggi_visual), - ggiGetWriteFrame(ggi_ctx->ggi_visual)); -} - -static void gl_ggiUpdateState(GLcontext *ctx, GLuint new_state) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - - GGIMESADPRINT_CORE("gl_ggiUpdateState() called\n"); - - /* Propogate statechange information to swrast and swrast_setup - * modules. The GGI driver has no internal GL-dependent state. - */ - _swrast_InvalidateState(ctx, new_state); - _swsetup_InvalidateState(ctx, new_state); - _tnl_InvalidateState(ctx, new_state); - - /* XXX: Better use an assertion that bails out here on failure */ - if (!LIBGGI_MESAEXT(ggi_ctx->ggi_visual)->update_state) { - GGIMESADPRINT_CORE("update_state == NULL!\n"); - GGIMESADPRINT_CORE("Please check your config files!\n"); - ggiPanic(""); - } - - LIBGGI_MESAEXT(ggi_ctx->ggi_visual)->update_state(ggi_ctx); -} - diff --git a/src/mesa/drivers/ggi/ggimesa.conf.in b/src/mesa/drivers/ggi/ggimesa.conf.in deleted file mode 100644 index 72132334fd..0000000000 --- a/src/mesa/drivers/ggi/ggimesa.conf.in +++ /dev/null @@ -1,13 +0,0 @@ -# GGIMesa global configuration -.root: @ggi_libdir@/ggi/mesa - -generic-stubs-mesa default/stubs.so -generic-linear-8-mesa default/linear_8.so -generic-linear-15-mesa default/linear_15.so -generic-linear-16-mesa default/linear_16.so -generic-linear-24-mesa default/linear_24.so -generic-linear-32-mesa default/linear_32.so - -display-fbdev-mesa display/fbdev.so - -# .include @ggi_confdir@/ggi/mesa/targets/fbdev.conf diff --git a/src/mesa/drivers/ggi/include/ggi/mesa/debug.h b/src/mesa/drivers/ggi/include/ggi/mesa/debug.h deleted file mode 100644 index f461fee72c..0000000000 --- a/src/mesa/drivers/ggi/include/ggi/mesa/debug.h +++ /dev/null @@ -1,260 +0,0 @@ -/* -****************************************************************************** - - GGIMesa debugging macros - - Copyright (C) 1998-1999 Marcus Sundberg [marcus@ggi-project.org] - Copyright (C) 1999-2000 Jon Taylor [taylorj@ggi-project.org] - - 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 - THE AUTHOR(S) 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. - -****************************************************************************** -*/ - -#ifndef _GGI_MESA_INTERNAL_DEBUG_H -#define _GGI_MESA_INTERNAL_DEBUG_H - -#include -#include -#include -#include - -#ifndef DEBUG -#define DEBUG -#endif - -__BEGIN_DECLS - -/* Exported variables */ -#ifdef BUILDING_GGIMESA -extern uint32 _ggimesaDebugState; -extern int _ggimesaDebugSync; -#else -IMPORTVAR uint32 _ggimesaDebugState; -IMPORTVAR int _ggimesaDebugSync; -#endif - -__END_DECLS - - -/* Debugging types - * bit 0 is reserved! */ - -#define GGIMESADEBUG_CORE (1<<1) /* 2 */ -#define GGIMESADEBUG_MODE (1<<2) /* 4 */ -#define GGIMESADEBUG_COLOR (1<<3) /* 8 */ -#define GGIMESADEBUG_DRAW (1<<4) /* 16 */ -#define GGIMESADEBUG_MISC (1<<5) /* 32 */ -#define GGIMESADEBUG_LIBS (1<<6) /* 64 */ -#define GGIMESADEBUG_EVENTS (1<<7) /* 128 */ - -#define GGIMESADEBUG_ALL 0xffffffff - -#ifdef __GNUC__ - -#ifdef DEBUG -#define GGIMESADPRINT(args...) if (_ggimesaDebugState) { ggDPrintf(_ggimesaDebugSync, "GGIMesa",args); } -#define GGIMESADPRINT_CORE(args...) if (_ggimesaDebugState & GGIMESADEBUG_CORE) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } -#define GGIMESADPRINT_MODE(args...) if (_ggimesaDebugState & GGIMESADEBUG_MODE) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } -#define GGIMESADPRINT_COLOR(args...) if (_ggimesaDebugState & GGIMESADEBUG_COLOR) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } -#define GGIMESADPRINT_DRAW(args...) if (_ggimesaDebugState & GGIMESADEBUG_DRAW) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } -#define GGIMESADPRINT_MISC(args...) if (_ggimesaDebugState & GGIMESADEBUG_MISC) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } -#define GGIMESADPRINT_LIBS(args...) if (_ggimesaDebugState & GGIMESADEBUG_LIBS) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } -#define GGIMESADPRINT_EVENTS(args...) if (_ggimesaDebugState & GGIMESADEBUG_EVENTS) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } -#else /* DEBUG */ -#define GGIMESADPRINT(args...) do{}while(0) -#define GGIMESADPRINT_CORE(args...) do{}while(0) -#define GGIMESADPRINT_MODE(args...) do{}while(0) -#define GGIMESADPRINT_COLOR(args...) do{}while(0) -#define GGIMESADPRINT_DRAW(args...) do{}while(0) -#define GGIMESADPRINT_MISC(args...) do{}while(0) -#define GGIMESADPRINT_LIBS(args...) do{}while(0) -#define GGIMESADPRINT_EVENTS(args...) do{}while(0) -#endif /* DEBUG */ - -#else /* __GNUC__ */ - -__BEGIN_DECLS - -static inline void GGIMESADPRINT(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState) { - va_list args; - - fprintf(stderr, "GGIMesa: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggimesaDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIMESADPRINT_CORE(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_CORE) { - va_list args; - - fprintf(stderr, "GGIMesa: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggimesaDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIMESADPRINT_MODE(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_MODE) { - va_list args; - - fprintf(stderr, "GGIMesa: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggimesaDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIMESADPRINT_COLOR(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_COLOR) { - va_list args; - - fprintf(stderr, "GGIMesa: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggimesaDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIMESADPRINT_DRAW(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_DRAW) { - va_list args; - - fprintf(stderr, "GGIMesa: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggimesaDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIMESADPRINT_MISC(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_MISC) { - va_list args; - - fprintf(stderr, "GGIMesa: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggimesaDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIMESADPRINT_LIBS(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_LIBS) { - va_list args; - - fprintf(stderr, "GGIMesa: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggimesaDebugSync) fflush(stderr); - } -#endif -} - -static inline void GGIMESADPRINT_EVENTS(const char *form,...) -{ -#ifdef DEBUG - if (_ggiDebugState & GGIDEBUG_EVENTS) { - va_list args; - - fprintf(stderr, "GGIMesa: "); - va_start(args, form); - vfprintf(stderr, form, args); - va_end(args); - if (_ggimesaDebugSync) fflush(stderr); - } -#endif -} - -__END_DECLS - -#endif /* __GNUC__ */ - -#ifdef DEBUG -#define GGIMESA_ASSERT(x,str) \ -{ if (!(x)) { \ - fprintf(stderr,"GGIMESA:%s:%d: INTERNAL ERROR: %s\n",__FILE__,__LINE__,str); \ - exit(1); \ -} } -#define GGIMESA_APPASSERT(x,str) \ -{ if (!(x)) { \ - fprintf(stderr,"GGIMESA:%s:%d: APPLICATION ERROR: %s\n",__FILE__,__LINE__,str); \ - exit(1); \ -} } -#else /* DEBUG */ -#define GGIMESA_ASSERT(x,str) do{}while(0) -#define GGIMESA_APPASSERT(x,str) do{}while(0) -#endif /* DEBUG */ - -#ifdef DEBUG -# define GGIMESAD0(x) x -#else -# define GGIMESAD0(x) /* empty */ -#endif - -#ifdef GGIMESADLEV -# if GGIMESADLEV == 1 -# define GGIMESAD1(x) x -# define GGIMESAD2(x) /* empty */ -# define GGIMESAD3(x) /* empty */ -# elif GGIMESADLEV == 2 -# define GGIMESAD1(x) x -# define GGIMESAD2(x) x -# define GGIMESAD3(x) /* empty */ -# elif GGIMESADLEV > 2 -# define GGIMESAD1(x) x -# define GGIMESAD2(x) x -# define GGIMESAD3(x) x -# endif -#else -# define GGIMESAD1(x) /* empty */ -# define GGIMESAD2(x) /* empty */ -# define GGIMESAD3(x) /* empty */ -#endif - -#endif /* _GGI_MESA_INTERNAL_DEBUG_H */ diff --git a/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h b/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h deleted file mode 100644 index 5c3c1e290c..0000000000 --- a/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _GGIMESA_DISPLAY_FBDEV_H -#define _GGIMESA_DISPLAY_FBDEV_H - -#include -#include - -ggifunc_setmode GGIMesa_fbdev_setmode; -ggifunc_getapi GGIMesa_fbdev_getapi; - -#define FBDEV_PRIV_MESA(vis) ((struct fbdev_priv_mesa *)(FBDEV_PRIV(vis)->accelpriv)) - -struct fbdev_priv_mesa -{ - char *accel; - int have_accel; - void *accelpriv; - ggi_fbdev_priv *oldpriv; /* Hooks back to the LibGGI fbdev target's private data */ -}; - -#endif /* _GGIMESA_DISPLAY_FBDEV_H */ diff --git a/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h b/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h deleted file mode 100644 index ecdbe414f8..0000000000 --- a/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h +++ /dev/null @@ -1,84 +0,0 @@ -/* GGI-Driver for MESA - * - * Copyright (C) 1997 Uwe Maurer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * --------------------------------------------------------------------- - * This code was derived from the following source of information: - * - * svgamesa.c and ddsample.c by Brian Paul - * - */ - -#ifndef _GGIMESA_H -#define _GGIMESA_H - -#include -#include -#include -#include "config.h" -#include "context.h" -#include "drawpix.h" -#include "imports.h" -#include "matrix.h" -#include "state.h" -#include "mtypes.h" -#include "macros.h" -#include "depth.h" - -#undef ASSERT /* ASSERT is redefined */ - -#include -#include -#include -#include "GL/ggimesa.h" - -/* - * GGIMesa visual configuration. - * - * This structure "derives" from Mesa's GLvisual and extends it by - * GGI's visual. Combination of these two structures is enough to fully - * describe the mode the application is currently running in. GGI - * visual provides information about color configuration and buffering - * method, GLvisual fills the rest. - */ -struct ggi_mesa_visual { - GLvisual gl_visual; - ggi_visual_t ggi_visual; -}; - -/* - * GGIMesa context. - * - * GGIMesa context expands the Mesa's context (it doesn't actualy derive - * from it, but this ability isn't needed, and it is best if GL context - * creation is left up to Mesa). It also contains a reference to the GGI - * visual it is attached to, which is very useful for all Mesa callbacks. - */ -struct ggi_mesa_context -{ - GLcontext *gl_ctx; - ggi_visual_t ggi_visual; - - ggi_pixel color; /* Current color or index*/ - ggi_pixel clearcolor; - - void *priv; -}; - -#define SHIFT (GGI_COLOR_PRECISION - 8) - -#endif - diff --git a/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h b/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h deleted file mode 100644 index faafc779e6..0000000000 --- a/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _GGI_MESA_INT_H -#define _GGI_MESA_INT_H - -#include -#include "ggimesa.h" - - -extern ggi_extid _ggiMesaID; - -ggifunc_setmode GGIMesa_setmode; -ggifunc_getapi GGIMesa_getapi; - -typedef struct ggi_mesa_ext -{ - /* - * How mesa extends this visual; i.e., size of the depth buffer etc. - * - * By default (upon attaching) this structure is initialized to what - * libggi is guaranteed to handle without any help: single buffered - * visual without any ancilary buffers. - */ - struct ggi_mesa_visual mesa_visual; - - /* - * Mesa framebuffer is a collection of all ancilary buffers required. - * - * This structure contains the ancilary buffers provided in in - * software. On each mode change it is loaded with the list of - * required buffers and the target is expected to clear the ones - * it can provide in hw. The remaining ones are then provided in sw. - * - */ - GLframebuffer mesa_buffer; - - void (*update_state)(ggi_mesa_context_t ctx); - int (*setup_driver)(ggi_mesa_context_t ctx); - - void *private; -} ggi_mesa_ext_t; - -#define LIBGGI_MESAEXT(vis) ((ggi_mesa_ext_t *)LIBGGI_EXT(vis,_ggiMesaID)) -#define GGIMESA_PRIV(vis) ((LIBGGI_MESAEXT(vis)->priv)) - -#endif /* _GGI_MISC_INT_H */ -- cgit v1.2.3 From e14a5b14b2db2ef2e744b49024ac341b998d1711 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 25 Feb 2010 16:08:59 -0500 Subject: Drop glide driver --- Makefile | 3 - configs/linux-glide | 23 - configs/linux-x86-glide | 28 - src/mesa/drivers/glide/fxapi.c | 951 --------------- src/mesa/drivers/glide/fxdd.c | 2197 ----------------------------------- src/mesa/drivers/glide/fxddspan.c | 638 ---------- src/mesa/drivers/glide/fxddtex.c | 1836 ----------------------------- src/mesa/drivers/glide/fxdrv.h | 773 ------------- src/mesa/drivers/glide/fxg.c | 2309 ------------------------------------- src/mesa/drivers/glide/fxg.h | 382 ------ src/mesa/drivers/glide/fxglidew.c | 269 ----- src/mesa/drivers/glide/fxglidew.h | 228 ---- src/mesa/drivers/glide/fxsetup.c | 2220 ----------------------------------- src/mesa/drivers/glide/fxsetup.h | 850 -------------- src/mesa/drivers/glide/fxtexman.c | 874 -------------- src/mesa/drivers/glide/fxtris.c | 1832 ----------------------------- src/mesa/drivers/glide/fxvb.c | 838 -------------- src/mesa/drivers/glide/fxvbtmp.h | 370 ------ 18 files changed, 16621 deletions(-) delete mode 100644 configs/linux-glide delete mode 100644 configs/linux-x86-glide delete mode 100644 src/mesa/drivers/glide/fxapi.c delete mode 100644 src/mesa/drivers/glide/fxdd.c delete mode 100644 src/mesa/drivers/glide/fxddspan.c delete mode 100644 src/mesa/drivers/glide/fxddtex.c delete mode 100644 src/mesa/drivers/glide/fxdrv.h delete mode 100644 src/mesa/drivers/glide/fxg.c delete mode 100644 src/mesa/drivers/glide/fxg.h delete mode 100644 src/mesa/drivers/glide/fxglidew.c delete mode 100644 src/mesa/drivers/glide/fxglidew.h delete mode 100644 src/mesa/drivers/glide/fxsetup.c delete mode 100644 src/mesa/drivers/glide/fxsetup.h delete mode 100644 src/mesa/drivers/glide/fxtexman.c delete mode 100644 src/mesa/drivers/glide/fxtris.c delete mode 100644 src/mesa/drivers/glide/fxvb.c delete mode 100644 src/mesa/drivers/glide/fxvbtmp.h (limited to 'Makefile') diff --git a/Makefile b/Makefile index b99a87b8ba..f2ec3bf20f 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,6 @@ linux-dri-xcb \ linux-egl \ linux-indirect \ linux-fbdev \ -linux-glide \ linux-ia64-icc \ linux-ia64-icc-static \ linux-icc \ @@ -149,7 +148,6 @@ linux-x86-64 \ linux-x86-64-debug \ linux-x86-64-profile \ linux-x86-64-static \ -linux-x86-glide \ linux-x86-profile \ linux-x86-static \ netbsd \ @@ -271,7 +269,6 @@ MAIN_FILES = \ $(DIRECTORY)/src/mesa/drivers/common/descrip.mms \ $(DIRECTORY)/src/mesa/drivers/fbdev/Makefile \ $(DIRECTORY)/src/mesa/drivers/fbdev/glfbdev.c \ - $(DIRECTORY)/src/mesa/drivers/glide/*.[ch] \ $(DIRECTORY)/src/mesa/drivers/osmesa/Makefile \ $(DIRECTORY)/src/mesa/drivers/osmesa/Makefile.win \ $(DIRECTORY)/src/mesa/drivers/osmesa/descrip.mms \ diff --git a/configs/linux-glide b/configs/linux-glide deleted file mode 100644 index 31475c81d8..0000000000 --- a/configs/linux-glide +++ /dev/null @@ -1,23 +0,0 @@ -# Configuration for generic Linux with 3Dfx Glide driver - -include $(TOP)/configs/default - -CONFIG_NAME = linux-glide - -# Compiler and flags -CC = gcc -CXX = g++ - -CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include -DFX -I/usr/include/glide -I/usr/local/glide/include -CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -GLUT_CFLAGS = -fexceptions - -# Work around aliasing bugs - developers should comment this out -CFLAGS += -fno-strict-aliasing -CXXFLAGS += -fno-strict-aliasing - -# Library/program dependencies -GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -L/usr/local/glide/lib -lglide3x -lm -lpthread -GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm -GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11 -APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/local/glide/lib -lglide3x -lm diff --git a/configs/linux-x86-glide b/configs/linux-x86-glide deleted file mode 100644 index 603b2bf758..0000000000 --- a/configs/linux-x86-glide +++ /dev/null @@ -1,28 +0,0 @@ -# Configuration for Linux with 3Dfx Glide driver and x86 optimizations - -include $(TOP)/configs/default - -CONFIG_NAME = linux-x86-glide - -# Compiler and flags -CC = gcc -CXX = g++ - -CFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -I/usr/X11R6/include -DFX -I/usr/include/glide -I/usr/local/glide/include - -CXXFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE - -GLUT_CFLAGS = -fexceptions - -# Work around aliasing bugs - developers should comment this out -CFLAGS += -fno-strict-aliasing -CXXFLAGS += -fno-strict-aliasing - -MESA_ASM_SOURCES = $(X86_SOURCES) -GLAPI_ASM_SOURCES = $(X86_API) - -# Library/program dependencies -GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -L/usr/local/glide/lib -lglide3x -lm -lpthread -GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm -GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11 -APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/local/glide/lib -lglide3x -lm diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c deleted file mode 100644 index 238f491599..0000000000 --- a/src/mesa/drivers/glide/fxapi.c +++ /dev/null @@ -1,951 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * Copyright (C) 1999-2001 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. - */ - -/* Authors: - * David Bucciarelli - * Brian Paul - * Daryll Strauss - * Keith Whitwell - * Daniel Borca - * Hiroshi Morii - */ - - -/* fxapi.c - public interface to FX/Mesa functions (fxmesa.h) */ - - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#if defined(FX) -#include "fxdrv.h" - -#include "drivers/common/driverfuncs.h" -#include "main/framebuffer.h" - -#ifndef TDFX_DEBUG -int TDFX_DEBUG = (0 -/* | VERBOSE_VARRAY */ -/* | VERBOSE_TEXTURE */ -/* | VERBOSE_IMMEDIATE */ -/* | VERBOSE_PIPELINE */ -/* | VERBOSE_DRIVER */ -/* | VERBOSE_STATE */ -/* | VERBOSE_API */ -/* | VERBOSE_DISPLAY_LIST */ -/* | VERBOSE_LIGHTING */ -/* | VERBOSE_PRIMS */ -/* | VERBOSE_VERTS */ - ); -#endif - -static fxMesaContext fxMesaCurrentCtx = NULL; - -/* - * Status of 3Dfx hardware initialization - */ - -static int glbGlideInitialized = 0; -static int glb3DfxPresent = 0; -static int glbTotNumCtx = 0; - -static GrHwConfiguration glbHWConfig; -static int glbCurrentBoard = 0; - - -#if defined(__WIN32__) -static int -cleangraphics(void) -{ - glbTotNumCtx = 1; - fxMesaDestroyContext(fxMesaCurrentCtx); - - return 0; -} -#elif defined(__linux__) -static void -cleangraphics(void) -{ - glbTotNumCtx = 1; - fxMesaDestroyContext(fxMesaCurrentCtx); -} - -static void -cleangraphics_handler(int s) -{ - fprintf(stderr, "fxmesa: ERROR: received a not handled signal %d\n", s); - - cleangraphics(); -/* abort(); */ - exit(1); -} -#endif - - -/* - * Query 3Dfx hardware presence/kind - */ -static GLboolean GLAPIENTRY fxQueryHardware (void) -{ - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxQueryHardware()\n"); - } - - if (!glbGlideInitialized) { - grGlideInit(); - glb3DfxPresent = FX_grSstQueryHardware(&glbHWConfig); - - glbGlideInitialized = 1; - -#if defined(__WIN32__) - _onexit((_onexit_t) cleangraphics); -#elif defined(__linux__) - /* Only register handler if environment variable is not defined. */ - if (!getenv("MESA_FX_NO_SIGNALS")) { - atexit(cleangraphics); - } -#endif - } - - return glb3DfxPresent; -} - - -/* - * Select the Voodoo board to use when creating - * a new context. - */ -GLint GLAPIENTRY fxMesaSelectCurrentBoard (int n) -{ - fxQueryHardware(); - - if ((n < 0) || (n >= glbHWConfig.num_sst)) - return -1; - - return glbHWConfig.SSTs[glbCurrentBoard = n].type; -} - - -fxMesaContext GLAPIENTRY fxMesaGetCurrentContext (void) -{ - return fxMesaCurrentCtx; -} - - -void GLAPIENTRY fxGetScreenGeometry (GLint *w, GLint *h) -{ - GLint width = 0; - GLint height = 0; - - if (fxMesaCurrentCtx != NULL) { - width = fxMesaCurrentCtx->screen_width; - height = fxMesaCurrentCtx->screen_height; - } - - if (w != NULL) { - *w = width; - } - if (h != NULL) { - *h = height; - } -} - - -/* - * The 3Dfx Global Palette extension for GLQuake. - * More a trick than a real extesion, use the shared global - * palette extension. - */ -extern void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint * pal); /* silence warning */ -void GLAPIENTRY -gl3DfxSetPaletteEXT(GLuint * pal) -{ - fxMesaContext fxMesa = fxMesaCurrentCtx; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - int i; - - fprintf(stderr, "gl3DfxSetPaletteEXT(...)\n"); - - for (i = 0; i < 256; i++) { - fprintf(stderr, "\t%x\n", pal[i]); - } - } - - if (fxMesa) { - fxMesa->haveGlobalPaletteTexture = 1; - - grTexDownloadTable(GR_TEXTABLE_PALETTE, (GuTexPalette *) pal); - } -} - - -static GrScreenResolution_t fxBestResolution (int width, int height) -{ - static int resolutions[][3] = { - { GR_RESOLUTION_320x200, 320, 200 }, - { GR_RESOLUTION_320x240, 320, 240 }, - { GR_RESOLUTION_400x256, 400, 256 }, - { GR_RESOLUTION_512x384, 512, 384 }, - { GR_RESOLUTION_640x200, 640, 200 }, - { GR_RESOLUTION_640x350, 640, 350 }, - { GR_RESOLUTION_640x400, 640, 400 }, - { GR_RESOLUTION_640x480, 640, 480 }, - { GR_RESOLUTION_800x600, 800, 600 }, - { GR_RESOLUTION_960x720, 960, 720 }, - { GR_RESOLUTION_856x480, 856, 480 }, - { GR_RESOLUTION_512x256, 512, 256 }, - { GR_RESOLUTION_1024x768, 1024, 768 }, - { GR_RESOLUTION_1280x1024, 1280, 1024 }, - { GR_RESOLUTION_1600x1200, 1600, 1200 }, - { GR_RESOLUTION_400x300, 400, 300 }, - { GR_RESOLUTION_1152x864, 1152, 864 }, - { GR_RESOLUTION_1280x960, 1280, 960 }, - { GR_RESOLUTION_1600x1024, 1600, 1024 }, - { GR_RESOLUTION_1792x1344, 1792, 1344 }, - { GR_RESOLUTION_1856x1392, 1856, 1392 }, - { GR_RESOLUTION_1920x1440, 1920, 1440 }, - { GR_RESOLUTION_2048x1536, 2048, 1536 }, - { GR_RESOLUTION_2048x2048, 2048, 2048 } - }; - - int i, size; - int lastvalidres = GR_RESOLUTION_640x480; - int min = 2048 * 2048; /* max is GR_RESOLUTION_2048x2048 */ - GrResolution resTemplate = { - GR_QUERY_ANY, - GR_QUERY_ANY, - 2 /*GR_QUERY_ANY */, - GR_QUERY_ANY - }; - GrResolution *presSupported; - - fxQueryHardware(); - - size = grQueryResolutions(&resTemplate, NULL); - presSupported = malloc(size); - - size /= sizeof(GrResolution); - grQueryResolutions(&resTemplate, presSupported); - - for (i = 0; i < size; i++) { - int r = presSupported[i].resolution; - if ((width <= resolutions[r][1]) && (height <= resolutions[r][2])) { - if (min > (resolutions[r][1] * resolutions[r][2])) { - min = resolutions[r][1] * resolutions[r][2]; - lastvalidres = r; - } - } - } - - free(presSupported); - - return resolutions[lastvalidres][0]; -} - - -fxMesaContext GLAPIENTRY -fxMesaCreateBestContext(GLuint win, GLint width, GLint height, - const GLint attribList[]) -{ - int res = fxBestResolution(width, height); - - if (res == -1) { - return NULL; - } - - return fxMesaCreateContext(win, res, GR_REFRESH_60Hz, attribList); -} - - -/* - * Create a new FX/Mesa context and return a handle to it. - */ -fxMesaContext GLAPIENTRY -fxMesaCreateContext(GLuint win, - GrScreenResolution_t res, - GrScreenRefresh_t ref, const GLint attribList[]) -{ - fxMesaContext fxMesa = NULL; - GLcontext *ctx = NULL, *shareCtx = NULL; - struct dd_function_table functions; - - int i; - const char *str; - int sliaa, numSLI, samplesPerChip; - struct SstCard_St *voodoo; - struct tdfx_glide *Glide; - - GLboolean aux; - GLboolean doubleBuffer; - GLuint colDepth; - GLuint depthSize, alphaSize, stencilSize, accumSize; - GLuint redBits, greenBits, blueBits, alphaBits; - GrPixelFormat_t pixFmt; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxMesaCreateContext(...)\n"); - } - - /* Okay, first process the user flags */ - aux = GL_FALSE; - doubleBuffer = GL_FALSE; - colDepth = 16; - depthSize = alphaSize = stencilSize = accumSize = 0; - - i = 0; - while (attribList[i] != FXMESA_NONE) { - switch (attribList[i]) { - case FXMESA_COLORDEPTH: - colDepth = attribList[++i]; - break; - case FXMESA_DOUBLEBUFFER: - doubleBuffer = GL_TRUE; - break; - case FXMESA_ALPHA_SIZE: - if ((alphaSize = attribList[++i])) { - aux = GL_TRUE; - } - break; - case FXMESA_DEPTH_SIZE: - if ((depthSize = attribList[++i])) { - aux = GL_TRUE; - } - break; - case FXMESA_STENCIL_SIZE: - stencilSize = attribList[++i]; - break; - case FXMESA_ACCUM_SIZE: - accumSize = attribList[++i]; - break; - /* XXX ugly hack here for sharing display lists */ - case FXMESA_SHARE_CONTEXT: - shareCtx = (GLcontext *)attribList[++i]; - break; - default: - fprintf(stderr, "fxMesaCreateContext: ERROR: wrong parameter (%d) passed\n", attribList[i]); - return NULL; - } - i++; - } - - if (!fxQueryHardware()) { - str = "no Voodoo hardware!"; - goto errorhandler; - } - - grSstSelect(glbCurrentBoard); - /*grEnable(GR_OPENGL_MODE_EXT);*/ /* [koolsmoky] */ - voodoo = &glbHWConfig.SSTs[glbCurrentBoard]; - - fxMesa = (fxMesaContext)CALLOC_STRUCT(tfxMesaContext); - if (!fxMesa) { - str = "private context"; - goto errorhandler; - } - - if (getenv("MESA_FX_INFO")) { - fxMesa->verbose = GL_TRUE; - } - - fxMesa->type = voodoo->type; - fxMesa->HavePalExt = voodoo->HavePalExt && !getenv("MESA_FX_IGNORE_PALEXT"); - fxMesa->HavePixExt = voodoo->HavePixExt && !getenv("MESA_FX_IGNORE_PIXEXT"); - fxMesa->HaveTexFmt = voodoo->HaveTexFmt && !getenv("MESA_FX_IGNORE_TEXFMT"); - fxMesa->HaveCmbExt = voodoo->HaveCmbExt && !getenv("MESA_FX_IGNORE_CMBEXT"); - fxMesa->HaveMirExt = voodoo->HaveMirExt && !getenv("MESA_FX_IGNORE_MIREXT"); - fxMesa->HaveTexUma = voodoo->HaveTexUma && !getenv("MESA_FX_IGNORE_TEXUMA"); - fxMesa->Glide = glbHWConfig.Glide; - Glide = &fxMesa->Glide; - fxMesa->HaveTexus2 = Glide->txImgQuantize && - Glide->txMipQuantize && - Glide->txPalToNcc && !getenv("MESA_FX_IGNORE_TEXUS2"); - - /* Determine if we need vertex swapping, RGB order and SLI/AA */ - sliaa = 0; - switch (fxMesa->type) { - case GR_SSTTYPE_VOODOO: - case GR_SSTTYPE_SST96: - case GR_SSTTYPE_Banshee: - fxMesa->bgrOrder = GL_TRUE; - fxMesa->snapVertices = (getenv("MESA_FX_NOSNAP") == NULL); - break; - case GR_SSTTYPE_Voodoo2: - fxMesa->bgrOrder = GL_TRUE; - fxMesa->snapVertices = GL_FALSE; - break; - case GR_SSTTYPE_Voodoo4: - case GR_SSTTYPE_Voodoo5: - /* number of SLI units and AA Samples per chip */ - if ((str = Glide->grGetRegistryOrEnvironmentStringExt("SSTH3_SLI_AA_CONFIGURATION")) != NULL) { - sliaa = atoi(str); - } - case GR_SSTTYPE_Voodoo3: - default: - fxMesa->bgrOrder = GL_FALSE; - fxMesa->snapVertices = GL_FALSE; - break; - } - /* XXX todo - Add the old SLI/AA settings for Napalm. */ - switch(voodoo->numChips) { - case 4: /* 4 chips */ - switch(sliaa) { - case 8: /* 8 Sample AA */ - numSLI = 1; - samplesPerChip = 2; - break; - case 7: /* 4 Sample AA */ - numSLI = 1; - samplesPerChip = 1; - break; - case 6: /* 2 Sample AA */ - numSLI = 2; - samplesPerChip = 1; - break; - default: - numSLI = 4; - samplesPerChip = 1; - } - break; - case 2: /* 2 chips */ - switch(sliaa) { - case 4: /* 4 Sample AA */ - numSLI = 1; - samplesPerChip = 2; - break; - case 3: /* 2 Sample AA */ - numSLI = 1; - samplesPerChip = 1; - break; - default: - numSLI = 2; - samplesPerChip = 1; - } - break; - default: /* 1 chip */ - switch(sliaa) { - case 1: /* 2 Sample AA */ - numSLI = 1; - samplesPerChip = 2; - break; - default: - numSLI = 1; - samplesPerChip = 1; - } - } - - fxMesa->fsaa = samplesPerChip * voodoo->numChips / numSLI; /* 1:noFSAA, 2:2xFSAA, 4:4xFSAA, 8:8xFSAA */ - - switch (fxMesa->colDepth = colDepth) { - case 15: - redBits = 5; - greenBits = 5; - blueBits = 5; - alphaBits = depthSize ? 1 : 8; - switch(fxMesa->fsaa) { - case 8: - pixFmt = GR_PIXFMT_AA_8_ARGB_1555; - break; - case 4: - pixFmt = GR_PIXFMT_AA_4_ARGB_1555; - break; - case 2: - pixFmt = GR_PIXFMT_AA_2_ARGB_1555; - break; - default: - pixFmt = GR_PIXFMT_ARGB_1555; - } - break; - case 16: - redBits = 5; - greenBits = 6; - blueBits = 5; - alphaBits = depthSize ? 0 : 8; - switch(fxMesa->fsaa) { - case 8: - pixFmt = GR_PIXFMT_AA_8_RGB_565; - break; - case 4: - pixFmt = GR_PIXFMT_AA_4_RGB_565; - break; - case 2: - pixFmt = GR_PIXFMT_AA_2_RGB_565; - break; - default: - pixFmt = GR_PIXFMT_RGB_565; - } - break; - case 24: - fxMesa->colDepth = 32; - case 32: - redBits = 8; - greenBits = 8; - blueBits = 8; - alphaBits = 8; - switch(fxMesa->fsaa) { - case 8: - pixFmt = GR_PIXFMT_AA_8_ARGB_8888; - break; - case 4: - pixFmt = GR_PIXFMT_AA_4_ARGB_8888; - break; - case 2: - pixFmt = GR_PIXFMT_AA_2_ARGB_8888; - break; - default: - pixFmt = GR_PIXFMT_ARGB_8888; - } - break; - default: - str = "pixelFormat"; - goto errorhandler; - } - - /* Tips: - * 1. we don't bother setting/checking AUX for stencil, because we'll decide - * later whether we have HW stencil, based on depth buffer (thus AUX is - * properly set) - * 2. when both DEPTH and ALPHA are enabled, depth should win. However, it is - * not clear whether 15bpp and 32bpp require AUX alpha buffer. Furthermore, - * alpha buffering is required only if destination alpha is used in alpha - * blending; alpha blending modes that do not use destination alpha can be - * used w/o alpha buffer. - * 3. `alphaBits' is what we can provide - * `alphaSize' is what app requests - * if we cannot provide enough bits for alpha buffer, we should fallback to - * SW alpha. However, setting `alphaBits' to `alphaSize' might confuse some - * of the span functions... - */ - - fxMesa->haveHwAlpha = GL_FALSE; - if (alphaSize && (alphaSize <= alphaBits)) { - alphaSize = alphaBits; - fxMesa->haveHwAlpha = GL_TRUE; - } - - fxMesa->haveHwStencil = (fxMesa->HavePixExt && stencilSize && depthSize == 24); - - fxMesa->haveZBuffer = depthSize > 0; - fxMesa->haveDoubleBuffer = doubleBuffer; - fxMesa->haveGlobalPaletteTexture = GL_FALSE; - fxMesa->board = glbCurrentBoard; - - fxMesa->haveTwoTMUs = (voodoo->nTexelfx > 1); - - if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_NUM_TMU"))) { - if (atoi(str) <= 1) { - fxMesa->haveTwoTMUs = GL_FALSE; - } - } - - if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_SWAPPENDINGCOUNT"))) { - fxMesa->maxPendingSwapBuffers = atoi(str); - if (fxMesa->maxPendingSwapBuffers > 6) { - fxMesa->maxPendingSwapBuffers = 6; - } else if (fxMesa->maxPendingSwapBuffers < 0) { - fxMesa->maxPendingSwapBuffers = 0; - } - } else { - fxMesa->maxPendingSwapBuffers = 2; - } - - if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_SWAPINTERVAL"))) { - fxMesa->swapInterval = atoi(str); - } else { - fxMesa->swapInterval = 0; - } - - BEGIN_BOARD_LOCK(); - if (fxMesa->HavePixExt) { - fxMesa->glideContext = Glide->grSstWinOpenExt((FxU32)win, res, ref, - GR_COLORFORMAT_ABGR, GR_ORIGIN_LOWER_LEFT, - pixFmt, - 2, aux); - } else if (pixFmt == GR_PIXFMT_RGB_565) { - fxMesa->glideContext = grSstWinOpen((FxU32)win, res, ref, - GR_COLORFORMAT_ABGR, GR_ORIGIN_LOWER_LEFT, - 2, aux); - } else { - fxMesa->glideContext = 0; - } - END_BOARD_LOCK(); - if (!fxMesa->glideContext) { - str = "grSstWinOpen"; - goto errorhandler; - } - - /* screen */ - fxMesa->screen_width = FX_grSstScreenWidth(); - fxMesa->screen_height = FX_grSstScreenHeight(); - - /* window inside screen */ - fxMesa->width = fxMesa->screen_width; - fxMesa->height = fxMesa->screen_height; - - /* scissor inside window */ - fxMesa->clipMinX = 0; - fxMesa->clipMaxX = fxMesa->width; - fxMesa->clipMinY = 0; - fxMesa->clipMaxY = fxMesa->height; - - if (fxMesa->verbose) { - FxI32 tmuRam, fbRam; - - /* Not that it matters, but tmuRam and fbRam change after grSstWinOpen. */ - tmuRam = voodoo->tmuConfig[GR_TMU0].tmuRam; - fbRam = voodoo->fbRam; - BEGIN_BOARD_LOCK(); - grGet(GR_MEMORY_TMU, 4, &tmuRam); - grGet(GR_MEMORY_FB, 4, &fbRam); - END_BOARD_LOCK(); - - fprintf(stderr, "Voodoo Using Glide %s\n", grGetString(GR_VERSION)); - fprintf(stderr, "Voodoo Board: %d/%d, %s, %d GPU\n", - fxMesa->board + 1, - glbHWConfig.num_sst, - grGetString(GR_HARDWARE), - voodoo->numChips); - fprintf(stderr, "Voodoo Memory: FB = %ld, TM = %d x %ld\n", - fbRam, - voodoo->nTexelfx, - tmuRam); - fprintf(stderr, "Voodoo Screen: %dx%d:%d %s, %svertex snapping\n", - fxMesa->screen_width, - fxMesa->screen_height, - colDepth, - fxMesa->bgrOrder ? "BGR" : "RGB", - fxMesa->snapVertices ? "" : "no "); - } - - sprintf(fxMesa->rendererString, "Mesa %s v0.63 %s%s", - grGetString(GR_RENDERER), - grGetString(GR_HARDWARE), - ((fxMesa->type < GR_SSTTYPE_Voodoo4) && (voodoo->numChips > 1)) ? " SLI" : ""); - - fxMesa->glVis = _mesa_create_visual(GL_TRUE, /* RGB mode */ - doubleBuffer, - GL_FALSE, /* stereo */ - redBits, /* RGBA.R bits */ - greenBits, /* RGBA.G bits */ - blueBits, /* RGBA.B bits */ - alphaSize, /* RGBA.A bits */ - 0, /* index bits */ - depthSize, /* depth_size */ - stencilSize, /* stencil_size */ - accumSize, - accumSize, - accumSize, - alphaSize ? accumSize : 0, - 1); - if (!fxMesa->glVis) { - str = "_mesa_create_visual"; - goto errorhandler; - } - - _mesa_init_driver_functions(&functions); - ctx = fxMesa->glCtx = _mesa_create_context(fxMesa->glVis, shareCtx, - &functions, (void *) fxMesa); - if (!ctx) { - str = "_mesa_create_context"; - goto errorhandler; - } - - - if (!fxDDInitFxMesaContext(fxMesa)) { - str = "fxDDInitFxMesaContext"; - goto errorhandler; - } - - - fxMesa->glBuffer = _mesa_create_framebuffer(fxMesa->glVis); -#if 0 -/* XXX this is a complete mess :( - * _mesa_add_soft_renderbuffers - * driNewRenderbuffer - */ - GL_FALSE, /* no software depth */ - stencilSize && !fxMesa->haveHwStencil, - fxMesa->glVis->accumRedBits > 0, - alphaSize && !fxMesa->haveHwAlpha); -#endif - if (!fxMesa->glBuffer) { - str = "_mesa_create_framebuffer"; - goto errorhandler; - } - - glbTotNumCtx++; - - /* install signal handlers */ -#if defined(__linux__) - /* Only install if environment var. is not set. */ - if (!getenv("MESA_FX_NO_SIGNALS")) { - signal(SIGINT, cleangraphics_handler); - signal(SIGHUP, cleangraphics_handler); - signal(SIGPIPE, cleangraphics_handler); - signal(SIGFPE, cleangraphics_handler); - signal(SIGBUS, cleangraphics_handler); - signal(SIGILL, cleangraphics_handler); - signal(SIGSEGV, cleangraphics_handler); - signal(SIGTERM, cleangraphics_handler); - } -#endif - - return fxMesa; - -errorhandler: - if (fxMesa) { - if (fxMesa->glideContext) { - grSstWinClose(fxMesa->glideContext); - fxMesa->glideContext = 0; - } - - if (fxMesa->state) { - FREE(fxMesa->state); - } - if (fxMesa->fogTable) { - FREE(fxMesa->fogTable); - } - if (fxMesa->glBuffer) { - _mesa_reference_framebuffer(&fxMesa->glBuffer, NULL); - } - if (fxMesa->glVis) { - _mesa_destroy_visual(fxMesa->glVis); - } - if (fxMesa->glCtx) { - _mesa_destroy_context(fxMesa->glCtx); - } - FREE(fxMesa); - } - - fprintf(stderr, "fxMesaCreateContext: ERROR: %s\n", str); - return NULL; -} - - -/* - * Function to set the new window size in the context (mainly for the Voodoo Rush) - */ -void GLAPIENTRY -fxMesaUpdateScreenSize(fxMesaContext fxMesa) -{ - fxMesa->width = FX_grSstScreenWidth(); - fxMesa->height = FX_grSstScreenHeight(); -} - - -/* - * Destroy the given FX/Mesa context. - */ -void GLAPIENTRY -fxMesaDestroyContext(fxMesaContext fxMesa) -{ - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxMesaDestroyContext(...)\n"); - } - - if (!fxMesa) - return; - - if (fxMesa->verbose) { - fprintf(stderr, "Misc Stats:\n"); - fprintf(stderr, " # swap buffer: %u\n", fxMesa->stats.swapBuffer); - - if (!fxMesa->stats.swapBuffer) - fxMesa->stats.swapBuffer = 1; - - fprintf(stderr, "Textures Stats:\n"); - fprintf(stderr, " Free texture memory on TMU0: %d\n", - fxMesa->freeTexMem[FX_TMU0]); - if (fxMesa->haveTwoTMUs) - fprintf(stderr, " Free texture memory on TMU1: %d\n", - fxMesa->freeTexMem[FX_TMU1]); - fprintf(stderr, " # request to TMM to upload a texture objects: %u\n", - fxMesa->stats.reqTexUpload); - fprintf(stderr, - " # request to TMM to upload a texture objects per swapbuffer: %.2f\n", - fxMesa->stats.reqTexUpload / (float) fxMesa->stats.swapBuffer); - fprintf(stderr, " # texture objects uploaded: %u\n", - fxMesa->stats.texUpload); - fprintf(stderr, " # texture objects uploaded per swapbuffer: %.2f\n", - fxMesa->stats.texUpload / (float) fxMesa->stats.swapBuffer); - fprintf(stderr, " # MBs uploaded to texture memory: %.2f\n", - fxMesa->stats.memTexUpload / (float) (1 << 20)); - fprintf(stderr, - " # MBs uploaded to texture memory per swapbuffer: %.2f\n", - (fxMesa->stats.memTexUpload / - (float) fxMesa->stats.swapBuffer) / (float) (1 << 20)); - } - - glbTotNumCtx--; - - if (!glbTotNumCtx && getenv("MESA_FX_INFO")) { - GrSstPerfStats_t st; - - FX_grSstPerfStats(&st); - - fprintf(stderr, "Pixels Stats:\n"); - fprintf(stderr, " # pixels processed (minus buffer clears): %u\n", - (unsigned) st.pixelsIn); - fprintf(stderr, " # pixels not drawn due to chroma key test failure: %u\n", - (unsigned) st.chromaFail); - fprintf(stderr, " # pixels not drawn due to depth test failure: %u\n", - (unsigned) st.zFuncFail); - fprintf(stderr, - " # pixels not drawn due to alpha test failure: %u\n", - (unsigned) st.aFuncFail); - fprintf(stderr, " # pixels drawn (including buffer clears and LFB writes): %u\n", - (unsigned) st.pixelsOut); - } - - /* close the hardware first, - * so we can debug atexit problems (memory leaks, etc). - */ - grSstWinClose(fxMesa->glideContext); - fxCloseHardware(); - - fxDDDestroyFxMesaContext(fxMesa); /* must be before _mesa_destroy_context */ - _mesa_destroy_visual(fxMesa->glVis); - _mesa_destroy_context(fxMesa->glCtx); - _mesa_reference_framebuffer(&fxMesa->glBuffer, NULL); - fxTMClose(fxMesa); /* must be after _mesa_destroy_context */ - - FREE(fxMesa); - - if (fxMesa == fxMesaCurrentCtx) - fxMesaCurrentCtx = NULL; -} - - -/* - * Make the specified FX/Mesa context the current one. - */ -void GLAPIENTRY -fxMesaMakeCurrent(fxMesaContext fxMesa) -{ - if (!fxMesa) { - _mesa_make_current(NULL, NULL, NULL); - fxMesaCurrentCtx = NULL; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxMesaMakeCurrent(NULL)\n"); - } - - return; - } - - /* if this context is already the current one, we can return early */ - if (fxMesaCurrentCtx == fxMesa - && fxMesaCurrentCtx->glCtx == _mesa_get_current_context()) { - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxMesaMakeCurrent(NOP)\n"); - } - - return; - } - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxMesaMakeCurrent(...)\n"); - } - - if (fxMesaCurrentCtx) - grGlideGetState((GrState *) fxMesaCurrentCtx->state); - - fxMesaCurrentCtx = fxMesa; - - grSstSelect(fxMesa->board); - grGlideSetState((GrState *) fxMesa->state); - - _mesa_make_current(fxMesa->glCtx, fxMesa->glBuffer, fxMesa->glBuffer); - - fxSetupDDPointers(fxMesa->glCtx); -} - - -/* - * Swap front/back buffers for current context if double buffered. - */ -void GLAPIENTRY -fxMesaSwapBuffers(void) -{ - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxMesaSwapBuffers()\n"); - } - - if (fxMesaCurrentCtx) { - _mesa_notifySwapBuffers(fxMesaCurrentCtx->glCtx); - - if (fxMesaCurrentCtx->haveDoubleBuffer) { - - grBufferSwap(fxMesaCurrentCtx->swapInterval); - -#if 0 - /* - * Don't allow swap buffer commands to build up! - */ - while (FX_grGetInteger(GR_PENDING_BUFFERSWAPS) > - fxMesaCurrentCtx->maxPendingSwapBuffers) - /* The driver is able to sleep when waiting for the completation - of multiple swapbuffer operations instead of wasting - CPU time (NOTE: you must uncomment the following line in the - in order to enable this option) */ - /* usleep(10000); */ - ; -#endif - - fxMesaCurrentCtx->stats.swapBuffer++; - } - } -} - - -/* - * Shutdown Glide library - */ -void GLAPIENTRY -fxCloseHardware(void) -{ - if (glbGlideInitialized) { - if (glbTotNumCtx == 0) { - grGlideShutdown(); - glbGlideInitialized = 0; - } - } -} - - -#else - - -/* - * Need this to provide at least one external definition. - */ -extern int gl_fx_dummy_function_api(void); -int -gl_fx_dummy_function_api(void) -{ - return 0; -} - -#endif /* FX */ diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c deleted file mode 100644 index b78b101240..0000000000 --- a/src/mesa/drivers/glide/fxdd.c +++ /dev/null @@ -1,2197 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 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. - */ - -/* Authors: - * David Bucciarelli - * Brian Paul - * Daryll Strauss - * Keith Whitwell - * Daniel Borca - * Hiroshi Morii - */ - -/* fxdd.c - 3Dfx VooDoo Mesa device driver functions */ - - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#if defined(FX) - -#include "main/image.h" -#include "main/mtypes.h" -#include "fxdrv.h" -#include "main/buffers.h" -#include "main/enums.h" -#include "main/extensions.h" -#include "main/macros.h" -#include "main/texstore.h" -#include "main/teximage.h" -#include "swrast/swrast.h" -#include "swrast/s_context.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" -#include "vbo/vbo.h" - - - -/* lookup table for scaling 4 bit colors up to 8 bits */ -GLuint FX_rgb_scale_4[16] = { - 0, 17, 34, 51, 68, 85, 102, 119, - 136, 153, 170, 187, 204, 221, 238, 255 -}; - -/* lookup table for scaling 5 bit colors up to 8 bits */ -GLuint FX_rgb_scale_5[32] = { - 0, 8, 16, 25, 33, 41, 49, 58, - 66, 74, 82, 90, 99, 107, 115, 123, - 132, 140, 148, 156, 165, 173, 181, 189, - 197, 206, 214, 222, 230, 239, 247, 255 -}; - -/* lookup table for scaling 6 bit colors up to 8 bits */ -GLuint FX_rgb_scale_6[64] = { - 0, 4, 8, 12, 16, 20, 24, 28, - 32, 36, 40, 45, 49, 53, 57, 61, - 65, 69, 73, 77, 81, 85, 89, 93, - 97, 101, 105, 109, 113, 117, 121, 125, - 130, 134, 138, 142, 146, 150, 154, 158, - 162, 166, 170, 174, 178, 182, 186, 190, - 194, 198, 202, 206, 210, 215, 219, 223, - 227, 231, 235, 239, 243, 247, 251, 255 -}; - - -/* - * Disable color by masking out R, G, B, A - */ -static void fxDisableColor (fxMesaContext fxMesa) -{ - if (fxMesa->colDepth == 32) { - /* 32bpp mode */ - fxMesa->Glide.grColorMaskExt(FXFALSE, FXFALSE, FXFALSE, FXFALSE); - } else { - /* 15/16 bpp mode */ - grColorMask(FXFALSE, FXFALSE); - } -} - - -/**********************************************************************/ -/***** Miscellaneous functions *****/ -/**********************************************************************/ - -/* Return buffer size information */ -static void -fxDDGetBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height) -{ - GET_CURRENT_CONTEXT(ctx); - if (ctx && FX_CONTEXT(ctx)) { - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxDDGetBufferSize(...)\n"); - } - - *width = fxMesa->width; - *height = fxMesa->height; - } -} - - -/** - * We only implement this function as a mechanism to check if the - * framebuffer size has changed (and update corresponding state). - */ -static void -fxDDViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ - GLuint newWidth, newHeight; - GLframebuffer *buffer = ctx->WinSysDrawBuffer; - fxDDGetBufferSize( buffer, &newWidth, &newHeight ); - if (buffer->Width != newWidth || buffer->Height != newHeight) { - _mesa_resize_framebuffer(ctx, buffer, newWidth, newHeight ); - } -} - - -/* Implements glClearColor() */ -static void -fxDDClearColor(GLcontext * ctx, const GLfloat color[4]) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLubyte col[4]; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxDDClearColor(%f, %f, %f, %f)\n", - color[0], color[1], color[2], color[3]); - } - - CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(col[3], color[3]); - - fxMesa->clearC = FXCOLOR4(col); - fxMesa->clearA = col[3]; -} - - -/* Clear the color and/or depth buffers */ -static void fxDDClear( GLcontext *ctx, GLbitfield mask ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLbitfield softwareMask = mask & (BUFFER_BIT_ACCUM); - const GLuint stencil_size = fxMesa->haveHwStencil ? ctx->Visual.stencilBits : 0; - const FxU32 clearD = (FxU32) (ctx->DrawBuffer->_DepthMaxF * ctx->Depth.Clear); - const FxU8 clearS = (FxU8) (ctx->Stencil.Clear & 0xff); - - if ( TDFX_DEBUG & MESA_VERBOSE ) { - fprintf( stderr, "fxDDClear\n"); - } - - /* we can't clear accum buffers nor stereo */ - mask &= ~(BUFFER_BIT_ACCUM | BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT); - - /* Need this check to respond to certain HW updates */ - if (fxMesa->new_state & (FX_NEW_SCISSOR | FX_NEW_COLOR_MASK)) { - fxSetupScissor(ctx); - fxSetupColorMask(ctx); - fxMesa->new_state &= ~(FX_NEW_SCISSOR | FX_NEW_COLOR_MASK); - } - - /* - * As per GL spec, color masking should be obeyed when clearing - */ - if (ctx->Visual.greenBits != 8) { - /* can only do color masking if running in 24/32bpp on Napalm */ - if (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] || - ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]) { - softwareMask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)); - mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT); - } - } - - if (fxMesa->haveHwStencil) { - /* - * If we want to clear stencil, it must be enabled - * in the HW, even if the stencil test is not enabled - * in the OGL state. - */ - BEGIN_BOARD_LOCK(); - if (mask & BUFFER_BIT_STENCIL) { - fxMesa->Glide.grStencilMaskExt(fxMesa->unitsState.stencilWriteMask); - /* set stencil ref value = desired clear value */ - fxMesa->Glide.grStencilFuncExt(GR_CMP_ALWAYS, clearS, 0xff); - fxMesa->Glide.grStencilOpExt(GR_STENCILOP_REPLACE, - GR_STENCILOP_REPLACE, GR_STENCILOP_REPLACE); - grEnable(GR_STENCIL_MODE_EXT); - } - else { - grDisable(GR_STENCIL_MODE_EXT); - } - END_BOARD_LOCK(); - } else if (mask & BUFFER_BIT_STENCIL) { - softwareMask |= (mask & (BUFFER_BIT_STENCIL)); - mask &= ~(BUFFER_BIT_STENCIL); - } - - /* - * This may be ugly, but it's needed in order to work around a number - * of Glide bugs. - */ - BEGIN_CLIP_LOOP(); - { - /* - * This could probably be done fancier but doing each possible case - * explicitly is less error prone. - */ - switch (mask & ~BUFFER_BIT_STENCIL) { - case BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH: - /* back buffer & depth */ - grDepthMask(FXTRUE); - grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) { - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - } - else - grBufferClear(fxMesa->clearC, - fxMesa->clearA, - clearD); - break; - case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_DEPTH: - /* XXX it appears that the depth buffer isn't cleared when - * glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set. - * This is a work-around/ - */ - /* clear depth */ - grDepthMask(FXTRUE); - fxDisableColor(fxMesa); - grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - else - grBufferClear(fxMesa->clearC, - fxMesa->clearA, - clearD); - fxSetupColorMask(ctx); - grDepthMask(FXFALSE); - /* clear front */ - grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - else - grBufferClear(fxMesa->clearC, - fxMesa->clearA, - clearD); - break; - case BUFFER_BIT_BACK_LEFT: - /* back buffer only */ - grDepthMask(FXFALSE); - grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - else - grBufferClear(fxMesa->clearC, - fxMesa->clearA, - clearD); - break; - case BUFFER_BIT_FRONT_LEFT: - /* front buffer only */ - grDepthMask(FXFALSE); - grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - else - grBufferClear(fxMesa->clearC, - fxMesa->clearA, - clearD); - break; - case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT: - /* front and back */ - grDepthMask(FXFALSE); - grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - else - grBufferClear(fxMesa->clearC, - fxMesa->clearA, - clearD); - grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - else - grBufferClear(fxMesa->clearC, - fxMesa->clearA, - clearD); - break; - case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH: - /* clear back and depth */ - grDepthMask(FXTRUE); - grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - else - grBufferClear(fxMesa->clearC, - fxMesa->clearA, - clearD); - /* clear front */ - grDepthMask(FXFALSE); - grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - else - grBufferClear(fxMesa->clearC, - fxMesa->clearA, - clearD); - break; - case BUFFER_BIT_DEPTH: - /* just the depth buffer */ - grDepthMask(FXTRUE); - fxDisableColor(fxMesa); - grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - else - grBufferClear(fxMesa->clearC, - fxMesa->clearA, - clearD); - fxSetupColorMask(ctx); - break; - default: - /* clear no color buffers or depth buffer but might clear stencil */ - if ((stencil_size > 0) && (mask & BUFFER_BIT_STENCIL)) { - /* XXX need this RenderBuffer call to work around Glide bug */ - grDepthMask(FXFALSE); - grRenderBuffer(GR_BUFFER_BACKBUFFER); - fxDisableColor(fxMesa); - fxMesa->Glide.grBufferClearExt(fxMesa->clearC, - fxMesa->clearA, - clearD, clearS); - fxSetupColorMask(ctx); - } - } - } - END_CLIP_LOOP(); - - if (fxMesa->haveHwStencil) { - /* We changed the stencil state above. Restore it! */ - fxSetupStencil(ctx); - } - fxSetupDepthTest(ctx); - grRenderBuffer(fxMesa->currentFB); - - if (softwareMask) - _swrast_Clear( ctx, softwareMask ); -} - - -/* Set the buffer used for drawing */ -/* XXX support for separate read/draw buffers hasn't been tested */ -/* XXX GL_NONE disables color, but fails to correctly maintain state */ -static void -fxDDSetDrawBuffer(GLcontext * ctx, GLenum mode) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxDDSetDrawBuffer(%x)\n", (int)mode); - } - - if (mode == GL_FRONT_LEFT) { - fxMesa->currentFB = GR_BUFFER_FRONTBUFFER; - grRenderBuffer(fxMesa->currentFB); - } - else if (mode == GL_BACK_LEFT) { - fxMesa->currentFB = GR_BUFFER_BACKBUFFER; - grRenderBuffer(fxMesa->currentFB); - } - else if (mode == GL_NONE) { - fxDisableColor(fxMesa); - } - else { - /* we'll need a software fallback */ - /* XXX not implemented */ - } - - /* update s/w fallback state */ - _swrast_DrawBuffer(ctx, mode); -} - - -static void -fxDDDrawBitmap2 (GLcontext *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GrLfbInfo_t info; - GrLfbWriteMode_t mode; - FxU16 color; - const struct gl_pixelstore_attrib *finalUnpack; - struct gl_pixelstore_attrib scissoredUnpack; - - /* check if there's any raster operations enabled which we can't handle */ - if (swrast->_RasterMask & (ALPHATEST_BIT | - /*BLEND_BIT |*/ /* blending ok, through pixpipe */ - DEPTH_BIT | /* could be done with RGB:DEPTH */ - FOG_BIT | /* could be done with RGB:DEPTH */ - LOGIC_OP_BIT | - /*CLIP_BIT |*/ /* clipping ok, below */ - STENCIL_BIT | - MASKING_BIT | - MULTI_DRAW_BIT | - OCCLUSION_BIT | /* nope! at least not yet */ - TEXTURE_BIT | - FRAGPROG_BIT)) { - _swrast_Bitmap(ctx, px, py, width, height, unpack, bitmap); - return; - } - - /* make sure the pixelpipe is configured correctly */ - fxSetupFXUnits(ctx); - - /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */ - if (ctx->Scissor.Enabled) { - /* This is a bit tricky, but by carefully adjusting the px, py, - * width, height, skipPixels and skipRows values we can do - * scissoring without special code in the rendering loop. - */ - - /* we'll construct a new pixelstore struct */ - finalUnpack = &scissoredUnpack; - scissoredUnpack = *unpack; - if (scissoredUnpack.RowLength == 0) - scissoredUnpack.RowLength = width; - - /* clip left */ - if (px < ctx->Scissor.X) { - scissoredUnpack.SkipPixels += (ctx->Scissor.X - px); - width -= (ctx->Scissor.X - px); - px = ctx->Scissor.X; - } - /* clip right */ - if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) { - width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width)); - } - /* clip bottom */ - if (py < ctx->Scissor.Y) { - scissoredUnpack.SkipRows += (ctx->Scissor.Y - py); - height -= (ctx->Scissor.Y - py); - py = ctx->Scissor.Y; - } - /* clip top */ - if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) { - height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height)); - } - - if (width <= 0 || height <= 0) - return; - } - else { - finalUnpack = unpack; - } - - /* compute pixel value */ - { - GLint r = (GLint) (ctx->Current.RasterColor[RCOMP] * 255.0f); - GLint g = (GLint) (ctx->Current.RasterColor[GCOMP] * 255.0f); - GLint b = (GLint) (ctx->Current.RasterColor[BCOMP] * 255.0f); - GLint a = (GLint) (ctx->Current.RasterColor[ACOMP] * 255.0f); - if (fxMesa->colDepth == 15) { - color = TDFXPACKCOLOR1555(b, g, r, a); - mode = GR_LFBWRITEMODE_1555; - } else { - color = fxMesa->bgrOrder ? TDFXPACKCOLOR565(r, g, b) : TDFXPACKCOLOR565(b, g, r); - mode = GR_LFBWRITEMODE_565; - } - } - - info.size = sizeof(info); - if (!grLfbLock(GR_LFB_WRITE_ONLY, - fxMesa->currentFB, - mode, - GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) { - _swrast_Bitmap(ctx, px, py, width, height, finalUnpack, bitmap); - return; - } - - { - const GLint winX = 0; - const GLint winY = 0; - /* The dest stride depends on the hardware and whether we're drawing - * to the front or back buffer. This compile-time test seems to do - * the job for now. - */ - const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */ - - GLint row; - /* compute dest address of bottom-left pixel in bitmap */ - GLushort *dst = (GLushort *) info.lfbPtr - + (winY + py) * dstStride + (winX + px); - - for (row = 0; row < height; row++) { - const GLubyte *src = - (const GLubyte *) _mesa_image_address2d(finalUnpack, - bitmap, width, height, - GL_COLOR_INDEX, GL_BITMAP, - row, 0); - if (finalUnpack->LsbFirst) { - /* least significan bit first */ - GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); - GLint col; - for (col = 0; col < width; col++) { - if (*src & mask) { - dst[col] = color; - } - if (mask == 128U) { - src++; - mask = 1U; - } - else { - mask = mask << 1; - } - } - if (mask != 1) - src++; - } - else { - /* most significan bit first */ - GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7); - GLint col; - for (col = 0; col < width; col++) { - if (*src & mask) { - dst[col] = color; - } - if (mask == 1U) { - src++; - mask = 128U; - } - else { - mask = mask >> 1; - } - } - if (mask != 128) - src++; - } - dst += dstStride; - } - } - - grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); -} - -static void -fxDDDrawBitmap4 (GLcontext *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GrLfbInfo_t info; - FxU32 color; - const struct gl_pixelstore_attrib *finalUnpack; - struct gl_pixelstore_attrib scissoredUnpack; - - /* check if there's any raster operations enabled which we can't handle */ - if ((swrast->_RasterMask & (/*ALPHATEST_BIT |*/ - /*BLEND_BIT |*/ /* blending ok, through pixpipe */ - DEPTH_BIT | /* could be done with RGB:DEPTH */ - FOG_BIT | /* could be done with RGB:DEPTH */ - LOGIC_OP_BIT | - /*CLIP_BIT |*/ /* clipping ok, below */ - STENCIL_BIT | - /*MASKING_BIT |*/ /* masking ok, we're in 32bpp */ - MULTI_DRAW_BIT | - OCCLUSION_BIT | /* nope! at least not yet */ - TEXTURE_BIT | - FRAGPROG_BIT)) - ) { - _swrast_Bitmap(ctx, px, py, width, height, unpack, bitmap); - return; - } - - /* make sure the pixelpipe is configured correctly */ - fxSetupFXUnits(ctx); - - /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */ - if (ctx->Scissor.Enabled) { - /* This is a bit tricky, but by carefully adjusting the px, py, - * width, height, skipPixels and skipRows values we can do - * scissoring without special code in the rendering loop. - */ - - /* we'll construct a new pixelstore struct */ - finalUnpack = &scissoredUnpack; - scissoredUnpack = *unpack; - if (scissoredUnpack.RowLength == 0) - scissoredUnpack.RowLength = width; - - /* clip left */ - if (px < ctx->Scissor.X) { - scissoredUnpack.SkipPixels += (ctx->Scissor.X - px); - width -= (ctx->Scissor.X - px); - px = ctx->Scissor.X; - } - /* clip right */ - if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) { - width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width)); - } - /* clip bottom */ - if (py < ctx->Scissor.Y) { - scissoredUnpack.SkipRows += (ctx->Scissor.Y - py); - height -= (ctx->Scissor.Y - py); - py = ctx->Scissor.Y; - } - /* clip top */ - if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) { - height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height)); - } - - if (width <= 0 || height <= 0) - return; - } - else { - finalUnpack = unpack; - } - - /* compute pixel value */ - { - GLint r = (GLint) (ctx->Current.RasterColor[RCOMP] * 255.0f); - GLint g = (GLint) (ctx->Current.RasterColor[GCOMP] * 255.0f); - GLint b = (GLint) (ctx->Current.RasterColor[BCOMP] * 255.0f); - GLint a = (GLint) (ctx->Current.RasterColor[ACOMP] * 255.0f); - color = TDFXPACKCOLOR8888(b, g, r, a); - } - - info.size = sizeof(info); - if (!grLfbLock(GR_LFB_WRITE_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_8888, - GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) { - _swrast_Bitmap(ctx, px, py, width, height, finalUnpack, bitmap); - return; - } - - { - const GLint winX = 0; - const GLint winY = 0; - /* The dest stride depends on the hardware and whether we're drawing - * to the front or back buffer. This compile-time test seems to do - * the job for now. - */ - const GLint dstStride = info.strideInBytes / 4; /* stride in GLuints */ - - GLint row; - /* compute dest address of bottom-left pixel in bitmap */ - GLuint *dst = (GLuint *) info.lfbPtr - + (winY + py) * dstStride + (winX + px); - - for (row = 0; row < height; row++) { - const GLubyte *src = - (const GLubyte *) _mesa_image_address2d(finalUnpack, - bitmap, width, height, - GL_COLOR_INDEX, GL_BITMAP, - row, 0); - if (finalUnpack->LsbFirst) { - /* least significan bit first */ - GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); - GLint col; - for (col = 0; col < width; col++) { - if (*src & mask) { - dst[col] = color; - } - if (mask == 128U) { - src++; - mask = 1U; - } - else { - mask = mask << 1; - } - } - if (mask != 1) - src++; - } - else { - /* most significan bit first */ - GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7); - GLint col; - for (col = 0; col < width; col++) { - if (*src & mask) { - dst[col] = color; - } - if (mask == 1U) { - src++; - mask = 128U; - } - else { - mask = mask >> 1; - } - } - if (mask != 128) - src++; - } - dst += dstStride; - } - } - - grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); -} - - -static void -fxDDReadPixels565 (GLcontext * ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid *dstImage) -{ - if (ctx->_ImageTransferState/* & (IMAGE_SCALE_BIAS_BIT|IMAGE_MAP_COLOR_BIT)*/) { - _swrast_ReadPixels(ctx, x, y, width, height, format, type, - packing, dstImage); - return; - } - else { - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrLfbInfo_t info; - - BEGIN_BOARD_LOCK(); - info.size = sizeof(info); - if (grLfbLock(GR_LFB_READ_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_ANY, - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { - const GLint winX = 0; - const GLint winY = fxMesa->height - 1; - const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */ - const GLushort *src = (const GLushort *) info.lfbPtr - + (winY - y) * srcStride + (winX + x); - GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage, - width, height, format, - type, 0, 0); - GLint dstStride = - _mesa_image_row_stride(packing, width, format, type); - - if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { - /* convert 5R6G5B into 8R8G8B */ - GLint row, col; - const GLint halfWidth = width >> 1; - const GLint extraPixel = (width & 1); - for (row = 0; row < height; row++) { - GLubyte *d = dst; - for (col = 0; col < halfWidth; col++) { - const GLuint pixel = ((const GLuint *) src)[col]; - *d++ = FX_rgb_scale_5[(pixel >> 11) & 0x1f]; - *d++ = FX_rgb_scale_6[(pixel >> 5) & 0x3f]; - *d++ = FX_rgb_scale_5[ pixel & 0x1f]; - *d++ = FX_rgb_scale_5[(pixel >> 27) & 0x1f]; - *d++ = FX_rgb_scale_6[(pixel >> 21) & 0x3f]; - *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f]; - } - if (extraPixel) { - GLushort pixel = src[width - 1]; - *d++ = FX_rgb_scale_5[(pixel >> 11) & 0x1f]; - *d++ = FX_rgb_scale_6[(pixel >> 5) & 0x3f]; - *d++ = FX_rgb_scale_5[ pixel & 0x1f]; - } - dst += dstStride; - src -= srcStride; - } - } - else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { - /* convert 5R6G5B into 8R8G8B8A */ - GLint row, col; - const GLint halfWidth = width >> 1; - const GLint extraPixel = (width & 1); - for (row = 0; row < height; row++) { - GLubyte *d = dst; - for (col = 0; col < halfWidth; col++) { - const GLuint pixel = ((const GLuint *) src)[col]; - *d++ = FX_rgb_scale_5[(pixel >> 11) & 0x1f]; - *d++ = FX_rgb_scale_6[(pixel >> 5) & 0x3f]; - *d++ = FX_rgb_scale_5[ pixel & 0x1f]; - *d++ = 255; - *d++ = FX_rgb_scale_5[(pixel >> 27) & 0x1f]; - *d++ = FX_rgb_scale_6[(pixel >> 21) & 0x3f]; - *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f]; - *d++ = 255; - } - if (extraPixel) { - const GLushort pixel = src[width - 1]; - *d++ = FX_rgb_scale_5[(pixel >> 11) & 0x1f]; - *d++ = FX_rgb_scale_6[(pixel >> 5) & 0x3f]; - *d++ = FX_rgb_scale_5[ pixel & 0x1f]; - *d++ = 255; - } - dst += dstStride; - src -= srcStride; - } - } - else if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { - /* directly memcpy 5R6G5B pixels into client's buffer */ - const GLint widthInBytes = width * 2; - GLint row; - for (row = 0; row < height; row++) { - memcpy(dst, src, widthInBytes); - dst += dstStride; - src -= srcStride; - } - } - else { - grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); - END_BOARD_LOCK(); - _swrast_ReadPixels(ctx, x, y, width, height, format, type, - packing, dstImage); - return; - } - - grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); - } - END_BOARD_LOCK(); - } -} - -static void -fxDDReadPixels555 (GLcontext * ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid *dstImage) -{ - if (ctx->_ImageTransferState/* & (IMAGE_SCALE_BIAS_BIT|IMAGE_MAP_COLOR_BIT)*/) { - _swrast_ReadPixels(ctx, x, y, width, height, format, type, - packing, dstImage); - return; - } - else { - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrLfbInfo_t info; - - BEGIN_BOARD_LOCK(); - info.size = sizeof(info); - if (grLfbLock(GR_LFB_READ_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_ANY, - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { - const GLint winX = 0; - const GLint winY = fxMesa->height - 1; - const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */ - const GLushort *src = (const GLushort *) info.lfbPtr - + (winY - y) * srcStride + (winX + x); - GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage, - width, height, format, - type, 0, 0); - GLint dstStride = - _mesa_image_row_stride(packing, width, format, type); - - if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { - /* convert 5R5G5B into 8R8G8B */ - GLint row, col; - const GLint halfWidth = width >> 1; - const GLint extraPixel = (width & 1); - for (row = 0; row < height; row++) { - GLubyte *d = dst; - for (col = 0; col < halfWidth; col++) { - const GLuint pixel = ((const GLuint *) src)[col]; - *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f]; - *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f]; - *d++ = FX_rgb_scale_5[ pixel & 0x1f]; - *d++ = FX_rgb_scale_5[(pixel >> 26) & 0x1f]; - *d++ = FX_rgb_scale_5[(pixel >> 21) & 0x1f]; - *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f]; - } - if (extraPixel) { - GLushort pixel = src[width - 1]; - *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f]; - *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f]; - *d++ = FX_rgb_scale_5[ pixel & 0x1f]; - } - dst += dstStride; - src -= srcStride; - } - } - else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { - /* convert 5R6G5B into 8R8G8B8A */ - GLint row, col; - const GLint halfWidth = width >> 1; - const GLint extraPixel = (width & 1); - for (row = 0; row < height; row++) { - GLubyte *d = dst; - for (col = 0; col < halfWidth; col++) { - const GLuint pixel = ((const GLuint *) src)[col]; - *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f]; - *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f]; - *d++ = FX_rgb_scale_5[ pixel & 0x1f]; - *d++ = (pixel & 0x8000) ? 255 : 0; - *d++ = FX_rgb_scale_5[(pixel >> 26) & 0x1f]; - *d++ = FX_rgb_scale_5[(pixel >> 21) & 0x1f]; - *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f]; - *d++ = (pixel & 0x80000000) ? 255 : 0; - } - if (extraPixel) { - const GLushort pixel = src[width - 1]; - *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f]; - *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f]; - *d++ = FX_rgb_scale_5[ pixel & 0x1f]; - *d++ = (pixel & 0x8000) ? 255 : 0; - } - dst += dstStride; - src -= srcStride; - } - } - else if (format == GL_BGRA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV) { - /* directly memcpy 5R5G5B pixels into client's buffer */ - const GLint widthInBytes = width * 2; - GLint row; - for (row = 0; row < height; row++) { - memcpy(dst, src, widthInBytes); - dst += dstStride; - src -= srcStride; - } - } - else { - grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); - END_BOARD_LOCK(); - _swrast_ReadPixels(ctx, x, y, width, height, format, type, - packing, dstImage); - return; - } - - grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); - } - END_BOARD_LOCK(); - } -} - -static void -fxDDReadPixels8888 (GLcontext * ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid *dstImage) -{ - if (ctx->_ImageTransferState/* & (IMAGE_SCALE_BIAS_BIT|IMAGE_MAP_COLOR_BIT)*/) { - _swrast_ReadPixels(ctx, x, y, width, height, format, type, - packing, dstImage); - return; - } - else { - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrLfbInfo_t info; - - BEGIN_BOARD_LOCK(); - info.size = sizeof(info); - if (grLfbLock(GR_LFB_READ_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_ANY, - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { - const GLint winX = 0; - const GLint winY = fxMesa->height - 1; - const GLint srcStride = info.strideInBytes / 4; /* stride in GLuints */ - const GLuint *src = (const GLuint *) info.lfbPtr - + (winY - y) * srcStride + (winX + x); - GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage, - width, height, format, - type, 0, 0); - GLint dstStride = - _mesa_image_row_stride(packing, width, format, type); - - if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { - /* convert 8A8R8G8B into 8R8G8B */ - GLint row, col; - for (row = 0; row < height; row++) { - GLubyte *d = dst; - for (col = 0; col < width; col++) { - const GLuint pixel = ((const GLuint *) src)[col]; - *d++ = pixel >> 16; - *d++ = pixel >> 8; - *d++ = pixel; - } - dst += dstStride; - src -= srcStride; - } - } - else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { - /* 8A8R8G8B pixels into client's buffer */ - GLint row, col; - for (row = 0; row < height; row++) { - GLubyte *d = dst; - for (col = 0; col < width; col++) { - const GLuint pixel = ((const GLuint *) src)[col]; - *d++ = pixel >> 16; - *d++ = pixel >> 8; - *d++ = pixel; - *d++ = pixel >> 24; - } - dst += dstStride; - src -= srcStride; - } - } - else if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { - /* convert 8A8R8G8B into 5R6G5B */ - GLint row, col; - for (row = 0; row < height; row++) { - GLushort *d = (GLushort *)dst; - for (col = 0; col < width; col++) { - const GLuint pixel = ((const GLuint *) src)[col]; - *d++ = (((pixel >> 16) & 0xf8) << 8) | - (((pixel >> 8) & 0xfc) << 3) | - ((pixel & 0xf8) >> 3); - } - dst += dstStride; - src -= srcStride; - } - } - else { - grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); - END_BOARD_LOCK(); - _swrast_ReadPixels(ctx, x, y, width, height, format, type, - packing, dstImage); - return; - } - - grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); - } - END_BOARD_LOCK(); - } -} - - -static void -fxDDDrawPixels555 (GLcontext * ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid * pixels) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GrLfbInfo_t info; - const struct gl_pixelstore_attrib *finalUnpack; - struct gl_pixelstore_attrib scissoredUnpack; - - if (ctx->Pixel.ZoomX != 1.0F || - ctx->Pixel.ZoomY != 1.0F || - (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT| - IMAGE_MAP_COLOR_BIT)) || - (swrast->_RasterMask & (ALPHATEST_BIT | - /*BLEND_BIT |*/ /* blending ok, through pixpipe */ - DEPTH_BIT | /* could be done with RGB:DEPTH */ - FOG_BIT | /* could be done with RGB:DEPTH */ - LOGIC_OP_BIT | - /*CLIP_BIT |*/ /* clipping ok, below */ - STENCIL_BIT | - MASKING_BIT | - MULTI_DRAW_BIT | - OCCLUSION_BIT | /* nope! at least not yet */ - TEXTURE_BIT | - FRAGPROG_BIT)) || - fxMesa->fallback) - { - _swrast_DrawPixels( ctx, x, y, width, height, format, type, - unpack, pixels ); - return; - } - - /* make sure the pixelpipe is configured correctly */ - fxSetupFXUnits(ctx); - - /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */ - if (ctx->Scissor.Enabled) { - /* This is a bit tricky, but by carefully adjusting the px, py, - * width, height, skipPixels and skipRows values we can do - * scissoring without special code in the rendering loop. - */ - - /* we'll construct a new pixelstore struct */ - finalUnpack = &scissoredUnpack; - scissoredUnpack = *unpack; - if (scissoredUnpack.RowLength == 0) - scissoredUnpack.RowLength = width; - - /* clip left */ - if (x < ctx->Scissor.X) { - scissoredUnpack.SkipPixels += (ctx->Scissor.X - x); - width -= (ctx->Scissor.X - x); - x = ctx->Scissor.X; - } - /* clip right */ - if (x + width >= ctx->Scissor.X + ctx->Scissor.Width) { - width -= (x + width - (ctx->Scissor.X + ctx->Scissor.Width)); - } - /* clip bottom */ - if (y < ctx->Scissor.Y) { - scissoredUnpack.SkipRows += (ctx->Scissor.Y - y); - height -= (ctx->Scissor.Y - y); - y = ctx->Scissor.Y; - } - /* clip top */ - if (y + height >= ctx->Scissor.Y + ctx->Scissor.Height) { - height -= (y + height - (ctx->Scissor.Y + ctx->Scissor.Height)); - } - - if (width <= 0 || height <= 0) - return; - } - else { - finalUnpack = unpack; - } - - info.size = sizeof(info); - if (!grLfbLock(GR_LFB_WRITE_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_1555, - GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) { - _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels); - return; - } - - { - const GLint winX = 0; - const GLint winY = 0; - - const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */ - GLushort *dst = (GLushort *) info.lfbPtr + (winY + y) * dstStride + (winX + x); - - if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { - GLint row; - for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, - pixels, width, height, format, type, row, 0); - GLint col; - for (col = 0; col < width; col++) { - dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], src[3]); - src += 4; - } - dst += dstStride; - } - } - else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { - GLint row; - for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, - pixels, width, height, format, type, row, 0); - GLint col; - for (col = 0; col < width; col++) { - dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], 255); - src += 3; - } - dst += dstStride; - } - } - else { - grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); - _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels); - return; - } - - } - - grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); -} - - -static void -fxDDDrawPixels565 (GLcontext * ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid * pixels) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GrLfbInfo_t info; - const struct gl_pixelstore_attrib *finalUnpack; - struct gl_pixelstore_attrib scissoredUnpack; - - if (ctx->Pixel.ZoomX != 1.0F || - ctx->Pixel.ZoomY != 1.0F || - (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT| - IMAGE_MAP_COLOR_BIT)) || - (swrast->_RasterMask & (ALPHATEST_BIT | - /*BLEND_BIT |*/ /* blending ok, through pixpipe */ - DEPTH_BIT | /* could be done with RGB:DEPTH */ - FOG_BIT | /* could be done with RGB:DEPTH */ - LOGIC_OP_BIT | - /*CLIP_BIT |*/ /* clipping ok, below */ - STENCIL_BIT | - MASKING_BIT | - MULTI_DRAW_BIT | - OCCLUSION_BIT | /* nope! at least not yet */ - TEXTURE_BIT | - FRAGPROG_BIT)) || - fxMesa->fallback) - { - _swrast_DrawPixels( ctx, x, y, width, height, format, type, - unpack, pixels ); - return; - } - - /* make sure the pixelpipe is configured correctly */ - fxSetupFXUnits(ctx); - - /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */ - if (ctx->Scissor.Enabled) { - /* This is a bit tricky, but by carefully adjusting the px, py, - * width, height, skipPixels and skipRows values we can do - * scissoring without special code in the rendering loop. - */ - - /* we'll construct a new pixelstore struct */ - finalUnpack = &scissoredUnpack; - scissoredUnpack = *unpack; - if (scissoredUnpack.RowLength == 0) - scissoredUnpack.RowLength = width; - - /* clip left */ - if (x < ctx->Scissor.X) { - scissoredUnpack.SkipPixels += (ctx->Scissor.X - x); - width -= (ctx->Scissor.X - x); - x = ctx->Scissor.X; - } - /* clip right */ - if (x + width >= ctx->Scissor.X + ctx->Scissor.Width) { - width -= (x + width - (ctx->Scissor.X + ctx->Scissor.Width)); - } - /* clip bottom */ - if (y < ctx->Scissor.Y) { - scissoredUnpack.SkipRows += (ctx->Scissor.Y - y); - height -= (ctx->Scissor.Y - y); - y = ctx->Scissor.Y; - } - /* clip top */ - if (y + height >= ctx->Scissor.Y + ctx->Scissor.Height) { - height -= (y + height - (ctx->Scissor.Y + ctx->Scissor.Height)); - } - - if (width <= 0 || height <= 0) - return; - } - else { - finalUnpack = unpack; - } - - info.size = sizeof(info); - if (!grLfbLock(GR_LFB_WRITE_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_565, - GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) { - _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels); - return; - } - - { - const GLint winX = 0; - const GLint winY = 0; - - const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */ - GLushort *dst = (GLushort *) info.lfbPtr + (winY + y) * dstStride + (winX + x); - - if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { - GLint row; - for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, - pixels, width, height, format, type, row, 0); - GLint col; - for (col = 0; col < width; col++) { - dst[col] = TDFXPACKCOLOR565(src[2], src[1], src[0]); - src += 4; - } - dst += dstStride; - } - } - else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { - GLint row; - for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, - pixels, width, height, format, type, row, 0); - GLint col; - for (col = 0; col < width; col++) { - dst[col] = TDFXPACKCOLOR565(src[2], src[1], src[0]); - src += 3; - } - dst += dstStride; - } - } - else { - grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); - _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels); - return; - } - - } - - grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); -} - - -static void -fxDDDrawPixels565_rev (GLcontext * ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid * pixels) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GrLfbInfo_t info; - const struct gl_pixelstore_attrib *finalUnpack; - struct gl_pixelstore_attrib scissoredUnpack; - - if (ctx->Pixel.ZoomX != 1.0F || - ctx->Pixel.ZoomY != 1.0F || - (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT| - IMAGE_MAP_COLOR_BIT)) || - (swrast->_RasterMask & (ALPHATEST_BIT | - /*BLEND_BIT |*/ /* blending ok, through pixpipe */ - DEPTH_BIT | /* could be done with RGB:DEPTH */ - FOG_BIT | /* could be done with RGB:DEPTH */ - LOGIC_OP_BIT | - /*CLIP_BIT |*/ /* clipping ok, below */ - STENCIL_BIT | - MASKING_BIT | - MULTI_DRAW_BIT | - OCCLUSION_BIT | /* nope! at least not yet */ - TEXTURE_BIT | - FRAGPROG_BIT)) || - fxMesa->fallback) - { - _swrast_DrawPixels( ctx, x, y, width, height, format, type, - unpack, pixels ); - return; - } - - /* make sure the pixelpipe is configured correctly */ - fxSetupFXUnits(ctx); - - /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */ - if (ctx->Scissor.Enabled) { - /* This is a bit tricky, but by carefully adjusting the px, py, - * width, height, skipPixels and skipRows values we can do - * scissoring without special code in the rendering loop. - */ - - /* we'll construct a new pixelstore struct */ - finalUnpack = &scissoredUnpack; - scissoredUnpack = *unpack; - if (scissoredUnpack.RowLength == 0) - scissoredUnpack.RowLength = width; - - /* clip left */ - if (x < ctx->Scissor.X) { - scissoredUnpack.SkipPixels += (ctx->Scissor.X - x); - width -= (ctx->Scissor.X - x); - x = ctx->Scissor.X; - } - /* clip right */ - if (x + width >= ctx->Scissor.X + ctx->Scissor.Width) { - width -= (x + width - (ctx->Scissor.X + ctx->Scissor.Width)); - } - /* clip bottom */ - if (y < ctx->Scissor.Y) { - scissoredUnpack.SkipRows += (ctx->Scissor.Y - y); - height -= (ctx->Scissor.Y - y); - y = ctx->Scissor.Y; - } - /* clip top */ - if (y + height >= ctx->Scissor.Y + ctx->Scissor.Height) { - height -= (y + height - (ctx->Scissor.Y + ctx->Scissor.Height)); - } - - if (width <= 0 || height <= 0) - return; - } - else { - finalUnpack = unpack; - } - - info.size = sizeof(info); - if (!grLfbLock(GR_LFB_WRITE_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_565, - GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) { - _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels); - return; - } - - { - const GLint winX = 0; - const GLint winY = 0; - - const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */ - GLushort *dst = (GLushort *) info.lfbPtr + (winY + y) * dstStride + (winX + x); - - if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { - GLint row; - for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, - pixels, width, height, format, type, row, 0); - GLint col; - for (col = 0; col < width; col++) { - dst[col] = TDFXPACKCOLOR565(src[0], src[1], src[2]); - src += 4; - } - dst += dstStride; - } - } - else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { - GLint row; - for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, - pixels, width, height, format, type, row, 0); - GLint col; - for (col = 0; col < width; col++) { - dst[col] = TDFXPACKCOLOR565(src[0], src[1], src[2]); - src += 3; - } - dst += dstStride; - } - } - else { - grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); - _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels); - return; - } - - } - - grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); -} - - -static void -fxDDDrawPixels8888 (GLcontext * ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid * pixels) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GrLfbInfo_t info; - const struct gl_pixelstore_attrib *finalUnpack; - struct gl_pixelstore_attrib scissoredUnpack; - - if (ctx->Pixel.ZoomX != 1.0F || - ctx->Pixel.ZoomY != 1.0F || - (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT| - IMAGE_MAP_COLOR_BIT)) || - (swrast->_RasterMask & (/*ALPHATEST_BIT |*/ - /*BLEND_BIT |*/ /* blending ok, through pixpipe */ - DEPTH_BIT | /* could be done with RGB:DEPTH */ - FOG_BIT | /* could be done with RGB:DEPTH */ - LOGIC_OP_BIT | - /*CLIP_BIT |*/ /* clipping ok, below */ - STENCIL_BIT | - /*MASKING_BIT |*/ /* masking ok, we're in 32bpp */ - MULTI_DRAW_BIT | - OCCLUSION_BIT | /* nope! at least not yet */ - TEXTURE_BIT | - FRAGPROG_BIT)) || - fxMesa->fallback) - { - _swrast_DrawPixels( ctx, x, y, width, height, format, type, - unpack, pixels ); - return; - } - - /* make sure the pixelpipe is configured correctly */ - fxSetupFXUnits(ctx); - - /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */ - if (ctx->Scissor.Enabled) { - /* This is a bit tricky, but by carefully adjusting the px, py, - * width, height, skipPixels and skipRows values we can do - * scissoring without special code in the rendering loop. - */ - - /* we'll construct a new pixelstore struct */ - finalUnpack = &scissoredUnpack; - scissoredUnpack = *unpack; - if (scissoredUnpack.RowLength == 0) - scissoredUnpack.RowLength = width; - - /* clip left */ - if (x < ctx->Scissor.X) { - scissoredUnpack.SkipPixels += (ctx->Scissor.X - x); - width -= (ctx->Scissor.X - x); - x = ctx->Scissor.X; - } - /* clip right */ - if (x + width >= ctx->Scissor.X + ctx->Scissor.Width) { - width -= (x + width - (ctx->Scissor.X + ctx->Scissor.Width)); - } - /* clip bottom */ - if (y < ctx->Scissor.Y) { - scissoredUnpack.SkipRows += (ctx->Scissor.Y - y); - height -= (ctx->Scissor.Y - y); - y = ctx->Scissor.Y; - } - /* clip top */ - if (y + height >= ctx->Scissor.Y + ctx->Scissor.Height) { - height -= (y + height - (ctx->Scissor.Y + ctx->Scissor.Height)); - } - - if (width <= 0 || height <= 0) - return; - } - else { - finalUnpack = unpack; - } - - info.size = sizeof(info); - if (!grLfbLock(GR_LFB_WRITE_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_8888, - GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) { - _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels); - return; - } - - { - const GLint winX = 0; - const GLint winY = 0; - - const GLint dstStride = info.strideInBytes / 4; /* stride in GLuints */ - GLuint *dst = (GLuint *) info.lfbPtr + (winY + y) * dstStride + (winX + x); - - if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { - /* directly memcpy 8A8R8G8B pixels to screen */ - const GLint widthInBytes = width * 4; - GLint row; - for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, - pixels, width, height, format, type, row, 0); - memcpy(dst, src, widthInBytes); - dst += dstStride; - } - } - else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { - GLint row; - for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, - pixels, width, height, format, type, row, 0); - GLint col; - for (col = 0; col < width; col++) { - dst[col] = TDFXPACKCOLOR8888(src[2], src[1], src[0], 255); - src += 3; - } - dst += dstStride; - } - } - else { - grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); - _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels); - return; - } - - } - - grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); -} - - -static void -fxDDFinish(GLcontext * ctx) -{ - grFlush(); -} - - - - - -/* KW: Put the word Mesa in the render string because quakeworld - * checks for this rather than doing a glGet(GL_MAX_TEXTURE_SIZE). - * Why? - */ -static const GLubyte * -fxDDGetString(GLcontext * ctx, GLenum name) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - switch (name) { - case GL_RENDERER: - return (GLubyte *)fxMesa->rendererString; -#if __WIN32__ /* hack to advertise vanilla extension names */ - case GL_EXTENSIONS: - if (ctx->Extensions.String == NULL) { - GLubyte *ext = _mesa_make_extension_string(ctx); - if (ext != NULL) { - ctx->Extensions.String = malloc(strlen((char *)ext) + 256); - if (ctx->Extensions.String != NULL) { - strcpy((char *)ctx->Extensions.String, (char *)ext); - /* put any additional extension names here */ -#if 0 - strcat((char *)ctx->Extensions.String, " 3DFX_set_global_palette"); -#endif -#if __WIN32__ - strcat((char *)ctx->Extensions.String, " WGL_3DFX_gamma_control"); - strcat((char *)ctx->Extensions.String, " WGL_EXT_swap_control"); - strcat((char *)ctx->Extensions.String, " WGL_EXT_extensions_string WGL_ARB_extensions_string"); -#endif - /* put any additional extension names here */ - free(ext); - } else { - ctx->Extensions.String = ext; - } - } - } - return ctx->Extensions.String; -#endif - default: - return NULL; - } -} - -static const struct tnl_pipeline_stage *fx_pipeline[] = { - &_tnl_vertex_transform_stage, /* XXX todo - Add the fastpath here */ - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - &_tnl_fog_coordinate_stage, - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - &_tnl_point_attenuation_stage, -#if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program) - &_tnl_vertex_program_stage, -#endif - &_tnl_render_stage, - 0, -}; - - - - -int -fxDDInitFxMesaContext(fxMesaContext fxMesa) -{ - GLcontext *ctx = fxMesa->glCtx; - - FX_setupGrVertexLayout(); - - fxMesa->color = 0xffffffff; - fxMesa->clearC = 0; - fxMesa->clearA = 0; - - fxMesa->stats.swapBuffer = 0; - fxMesa->stats.reqTexUpload = 0; - fxMesa->stats.texUpload = 0; - fxMesa->stats.memTexUpload = 0; - - fxMesa->tmuSrc = FX_TMU_NONE; - fxMesa->lastUnitsMode = FX_UM_NONE; - fxTMInit(fxMesa); - - /* FX units setup */ - - fxMesa->unitsState.alphaTestEnabled = GL_FALSE; - fxMesa->unitsState.alphaTestFunc = GL_ALWAYS; - fxMesa->unitsState.alphaTestRefValue = 0.0; - - fxMesa->unitsState.blendEnabled = GL_FALSE; - fxMesa->unitsState.blendSrcFuncRGB = GR_BLEND_ONE; - fxMesa->unitsState.blendDstFuncRGB = GR_BLEND_ZERO; - fxMesa->unitsState.blendSrcFuncAlpha = GR_BLEND_ONE; - fxMesa->unitsState.blendDstFuncAlpha = GR_BLEND_ZERO; - fxMesa->unitsState.blendEqRGB = GR_BLEND_OP_ADD; - fxMesa->unitsState.blendEqAlpha = GR_BLEND_OP_ADD; - - fxMesa->unitsState.depthTestEnabled = GL_FALSE; - fxMesa->unitsState.depthMask = GL_TRUE; - fxMesa->unitsState.depthTestFunc = GL_LESS; - fxMesa->unitsState.depthBias = 0; - - fxMesa->unitsState.stencilWriteMask = 0xff; - - if (fxMesa->colDepth == 32) { - /* 32bpp */ - fxMesa->Glide.grColorMaskExt(FXTRUE, FXTRUE, FXTRUE, fxMesa->haveHwAlpha); - } else { - /* 15/16 bpp mode */ - grColorMask(FXTRUE, fxMesa->haveHwAlpha); - } - - fxMesa->currentFB = fxMesa->haveDoubleBuffer ? GR_BUFFER_BACKBUFFER : GR_BUFFER_FRONTBUFFER; - grRenderBuffer(fxMesa->currentFB); - - fxMesa->state = MALLOC(FX_grGetInteger(GR_GLIDE_STATE_SIZE)); - fxMesa->fogTable = (GrFog_t *) MALLOC(FX_grGetInteger(GR_FOG_TABLE_ENTRIES) * - sizeof(GrFog_t)); - - if (!fxMesa->state || !fxMesa->fogTable) { - if (fxMesa->state) - FREE(fxMesa->state); - if (fxMesa->fogTable) - FREE(fxMesa->fogTable); - return 0; - } - - if (fxMesa->haveZBuffer) { - grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); - } - - if (!fxMesa->bgrOrder) { - grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); - } - - if (fxMesa->Glide.grSetNumPendingBuffers != NULL) { - fxMesa->Glide.grSetNumPendingBuffers(fxMesa->maxPendingSwapBuffers); - } - - fxMesa->textureAlign = FX_grGetInteger(GR_TEXTURE_ALIGN); - /* [koolsmoky] */ - { - char *env; - int textureLevels = 0; - int textureSize = FX_grGetInteger(GR_MAX_TEXTURE_SIZE); - do { - textureLevels++; - } while ((textureSize >>= 0x1) & 0x7ff); - ctx->Const.MaxTextureLevels = textureLevels; - ctx->Const.MaxTextureLodBias = /*textureLevels - 1*/8; /* Glide bug */ -#if FX_RESCALE_BIG_TEXURES_HACK - fxMesa->textureMaxLod = textureLevels - 1; - if ((env = getenv("MESA_FX_MAXLOD")) != NULL) { - int maxLevels = atoi(env) + 1; - if ((maxLevels <= MAX_TEXTURE_LEVELS) && (maxLevels > textureLevels)) { - ctx->Const.MaxTextureLevels = maxLevels; - } - } -#endif - } - ctx->Const.MaxTextureCoordUnits = - ctx->Const.MaxTextureImageUnits = fxMesa->haveTwoTMUs ? 2 : 1; - ctx->Const.MaxTextureUnits = MAX2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits); - - ctx->Const.MaxDrawBuffers = 1; - - fxMesa->new_state = _NEW_ALL; - if (!fxMesa->haveHwStencil) { - /* don't touch stencil if there is none */ - fxMesa->new_state &= ~FX_NEW_STENCIL; - } - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext(ctx); - _vbo_CreateContext(ctx); - _tnl_CreateContext(ctx); - _swsetup_CreateContext(ctx); - - /* Install customized pipeline */ - _tnl_destroy_pipeline(ctx); - _tnl_install_pipeline(ctx, fx_pipeline); - - fxAllocVB(ctx); - - fxSetupDDPointers(ctx); - fxDDInitTriFuncs(ctx); - - /* Tell the software rasterizer to use pixel fog always. - */ - _swrast_allow_vertex_fog(ctx, GL_FALSE); - _swrast_allow_pixel_fog(ctx, GL_TRUE); - _tnl_allow_vertex_fog( ctx, GL_FALSE ); - _tnl_allow_pixel_fog( ctx, GL_TRUE ); - - /* Tell tnl not to calculate or use vertex fog factors. (Needed to - * tell render stage not to clip fog coords). - */ -/* _tnl_calculate_vertex_fog( ctx, GL_FALSE ); */ - - fxDDInitExtensions(ctx); - -#if 0 - /* do we want dither? It just looks bad... */ - grEnable(GR_ALLOW_MIPMAP_DITHER); -#endif - grGlideGetState((GrState *) fxMesa->state); - - return 1; -} - -/* Undo the above. - */ -void -fxDDDestroyFxMesaContext(fxMesaContext fxMesa) -{ - _swsetup_DestroyContext(fxMesa->glCtx); - _tnl_DestroyContext(fxMesa->glCtx); - _vbo_DestroyContext(fxMesa->glCtx); - _swrast_DestroyContext(fxMesa->glCtx); - - if (fxMesa->state) - FREE(fxMesa->state); - if (fxMesa->fogTable) - FREE(fxMesa->fogTable); - fxFreeVB(fxMesa->glCtx); -} - - - - -void -fxDDInitExtensions(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - -#if 1 /* multipass ColorSum stage */ - _mesa_enable_extension(ctx, "GL_EXT_secondary_color"); -#endif - - _mesa_enable_extension(ctx, "GL_ARB_point_sprite"); - _mesa_enable_extension(ctx, "GL_EXT_point_parameters"); - _mesa_enable_extension(ctx, "GL_EXT_paletted_texture"); - _mesa_enable_extension(ctx, "GL_EXT_texture_lod_bias"); - _mesa_enable_extension(ctx, "GL_EXT_shared_texture_palette"); - _mesa_enable_extension(ctx, "GL_EXT_blend_func_separate"); - _mesa_enable_extension(ctx, "GL_EXT_texture_env_add"); - _mesa_enable_extension(ctx, "GL_EXT_stencil_wrap"); - _mesa_enable_extension(ctx, "GL_EXT_stencil_two_side"); - - if (fxMesa->haveTwoTMUs) { - _mesa_enable_extension(ctx, "GL_ARB_multitexture"); - } - - if (fxMesa->type >= GR_SSTTYPE_Voodoo4) { - _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1"); - _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); - _mesa_enable_extension(ctx, "GL_S3_s3tc"); - _mesa_enable_extension(ctx, "GL_NV_blend_square"); - } else { - /* [dBorca] - * We should enable generic texture compression functions, - * but some poorly written apps automatically assume S3TC. - * Binding NCC to GL_COMPRESSED_RGB[A] is an unnecessary hassle, - * since it's slow and ugly (better with palette textures, then). - * Moreover, NCC is not an OpenGL standard, so we can't use - * precompressed textures. Last, but not least, NCC runs amok - * when multitexturing on a Voodoo3 and up (see POINTCAST vs UMA). - * Note: this is also a problem with palette textures, but - * faking multitex by multipass is evil... - * Implementing NCC requires three stages: - * fxDDChooseTextureFormat: - * bind GL_COMPRESSED_RGB[A] to _mesa_texformat_argb8888, - * so we can quantize properly, at a later time - * fxDDTexImage: - * if GL_COMPRESSED_RGB - * use _mesa_texformat_l8 to get 1bpt and set GR_TEXFMT_YIQ_422 - * if GL_COMPRESSED_RGBA - * use _mesa_texformat_al88 to get 2bpt and set GR_TEXFMT_AYIQ_8422 - * txMipQuantize(...); - * if (level == 0) { - * txPalToNcc((GuNccTable *)(&(ti->palette)), pxMip.pal); - * } - * fxSetupSingleTMU_NoLock/fxSetupDoubleTMU_NoLock: - * grTexDownloadTable(GR_TEXTABLE_NCC0, &(ti->palette)); - */ - _mesa_enable_extension(ctx, "GL_SGIS_generate_mipmap"); - } - - if (fxMesa->HaveCmbExt) { - _mesa_enable_extension(ctx, "GL_ARB_texture_env_combine"); - _mesa_enable_extension(ctx, "GL_EXT_texture_env_combine"); - } - - if (fxMesa->HavePixExt) { - _mesa_enable_extension(ctx, "GL_EXT_blend_subtract"); - _mesa_enable_extension(ctx, "GL_EXT_blend_equation_separate"); - } - - if (fxMesa->HaveMirExt) { - _mesa_enable_extension(ctx, "GL_ARB_texture_mirrored_repeat"); - } - - if (fxMesa->type >= GR_SSTTYPE_Voodoo2) { - _mesa_enable_extension(ctx, "GL_EXT_fog_coord"); - } - - /* core-level extensions */ - /* dangerous */ - if (getenv("MESA_FX_ALLOW_VP")) { - _mesa_enable_extension(ctx, "GL_ARB_vertex_program"); - _mesa_enable_extension(ctx, "GL_NV_vertex_program"); - _mesa_enable_extension(ctx, "GL_NV_vertex_program1_1"); - } -#if 0 - /* this requires _tnl_vertex_cull_stage in the pipeline */ - _mesa_enable_extension(ctx, "EXT_cull_vertex"); -#endif -} - - -/************************************************************************/ -/************************************************************************/ -/************************************************************************/ - -/* Check if the hardware supports the current context - * - * Performs similar work to fxDDChooseRenderState() - should be merged. - */ -GLuint -fx_check_IsInHardware(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (ctx->RenderMode != GL_RENDER) { - return FX_FALLBACK_RENDER_MODE; - } - - if (ctx->Stencil._Enabled && !fxMesa->haveHwStencil) { - return FX_FALLBACK_STENCIL; - } - - if ((ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_FRONT_LEFT) && - (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_BACK_LEFT)) { - return FX_FALLBACK_DRAW_BUFFER; - } - - if (ctx->Color.BlendEnabled) { - if (ctx->Color.BlendEquationRGB != GL_FUNC_ADD) { - if (!fxMesa->HavePixExt || - ((ctx->Color.BlendEquationRGB != GL_FUNC_SUBTRACT) && - (ctx->Color.BlendEquationRGB != GL_FUNC_REVERSE_SUBTRACT))) { - return FX_FALLBACK_BLEND; - } - } - - if (ctx->Color.BlendEquationA != GL_FUNC_ADD) { - if (!fxMesa->HavePixExt || - ((ctx->Color.BlendEquationA != GL_FUNC_SUBTRACT) && - (ctx->Color.BlendEquationA != GL_FUNC_REVERSE_SUBTRACT))) { - return FX_FALLBACK_BLEND; - } - } - -#if 0 - /* [dBorca] - * We fail the spec here, unless certain blending modes: - * RGB: (GL_ONE + GL_*) or (GL_ZERO + GL_*) or ... - */ - if (NEED_SECONDARY_COLOR(ctx)) { - if ((ctx->Color.BlendEquationRGB != GL_FUNC_ADD) && - (ctx->Color.BlendSrcRGB != GL_ONE)) { - /* Can't use multipass to blend ColorSum stage */ - return FX_FALLBACK_SPECULAR; - } - } -#endif - } - - /* [dBorca] - * We could avoid this for certain `sfactor/dfactor' - * I do not think that is even worthwhile to check - * because if someone is using blending they use more - * interesting settings and also it would add more - * state tracking to a lot of the code. - */ - if (ctx->Color.ColorLogicOpEnabled && (ctx->Color.LogicOp != GL_COPY)) { - return FX_FALLBACK_LOGICOP; - } - - if ((fxMesa->colDepth != 32) && - ((ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP]) || - (ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]))) { - return FX_FALLBACK_COLORMASK; - } - - /* Unsupported texture/multitexture cases */ - - /* we can only do 1D/2D textures */ - if (ctx->Texture.Unit[0]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT)) - return FX_FALLBACK_TEXTURE_MAP; - - if (fxMesa->haveTwoTMUs) { - if (ctx->Texture.Unit[1]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT)) - return FX_FALLBACK_TEXTURE_MAP; - - if (ctx->Texture.Unit[0]._ReallyEnabled) { - if (fxMesa->type < GR_SSTTYPE_Voodoo2) - if (ctx->Texture.Unit[0].EnvMode == GL_BLEND && - (ctx->Texture.Unit[1]._ReallyEnabled || - ctx->Texture.Unit[0].EnvColor[0] != 0 || - ctx->Texture.Unit[0].EnvColor[1] != 0 || - ctx->Texture.Unit[0].EnvColor[2] != 0 || - ctx->Texture.Unit[0].EnvColor[3] != 1)) { - return FX_FALLBACK_TEXTURE_ENV; - } - if (ctx->Texture.Unit[0]._Current->Image[0][0]->Border > 0) - return FX_FALLBACK_TEXTURE_BORDER; - } - - if (ctx->Texture.Unit[1]._ReallyEnabled) { - if (fxMesa->type < GR_SSTTYPE_Voodoo2) - if (ctx->Texture.Unit[1].EnvMode == GL_BLEND) - return FX_FALLBACK_TEXTURE_ENV; - if (ctx->Texture.Unit[1]._Current->Image[0][0]->Border > 0) - return FX_FALLBACK_TEXTURE_BORDER; - } - - if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) - fprintf(stderr, "fx_check_IsInHardware: envmode is %s/%s\n", - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode), - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode)); - - /* KW: This was wrong (I think) and I changed it... which doesn't mean - * it is now correct... - * BP: The old condition just seemed to test if both texture units - * were enabled. That's easy! - */ - if (ctx->Texture._EnabledUnits == 0x3) { -#if 0 - /* Can't use multipass to blend a multitextured triangle - fall - * back to software. - */ - if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) { - return FX_FALLBACK_TEXTURE_MULTI; - } -#endif - - if (!fxMesa->HaveCmbExt && - (ctx->Texture.Unit[0].EnvMode != ctx->Texture.Unit[1].EnvMode) && - (ctx->Texture.Unit[0].EnvMode != GL_MODULATE) && - (ctx->Texture.Unit[0].EnvMode != GL_REPLACE)) { /* q2, seems ok... */ - if (TDFX_DEBUG & VERBOSE_DRIVER) - fprintf(stderr, "fx_check_IsInHardware: unsupported multitex env mode\n"); - return FX_FALLBACK_TEXTURE_MULTI; - } - } - } - else { - /* we have just one texture unit */ - if (ctx->Texture._EnabledUnits > 0x1) { - return FX_FALLBACK_TEXTURE_MULTI; - } - - if (fxMesa->type < GR_SSTTYPE_Voodoo2) - if (ctx->Texture.Unit[0]._ReallyEnabled && - (ctx->Texture.Unit[0].EnvMode == GL_BLEND)) { - return FX_FALLBACK_TEXTURE_ENV; - } - } - - return 0; -} - - - -static void -fxDDUpdateDDPointers(GLcontext * ctx, GLuint new_state) -{ - /* TNLcontext *tnl = TNL_CONTEXT(ctx); */ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxDDUpdateDDPointers(%08x)\n", new_state); - } - - _swrast_InvalidateState(ctx, new_state); - _vbo_InvalidateState(ctx, new_state); - _tnl_InvalidateState(ctx, new_state); - _swsetup_InvalidateState(ctx, new_state); - - fxMesa->new_gl_state |= new_state; -} - - - - -void -fxSetupDDPointers(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - /* TNLcontext *tnl = TNL_CONTEXT(ctx); */ - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupDDPointers()\n"); - } - - ctx->Driver.UpdateState = fxDDUpdateDDPointers; - ctx->Driver.GetString = fxDDGetString; - ctx->Driver.ClearIndex = NULL; - ctx->Driver.ClearColor = fxDDClearColor; - ctx->Driver.Clear = fxDDClear; - ctx->Driver.DrawBuffer = fxDDSetDrawBuffer; - ctx->Driver.GetBufferSize = fxDDGetBufferSize; - ctx->Driver.Viewport = fxDDViewport; - switch (fxMesa->colDepth) { - case 15: - ctx->Driver.DrawPixels = fxDDDrawPixels555; - ctx->Driver.ReadPixels = fxDDReadPixels555; - ctx->Driver.Bitmap = fxDDDrawBitmap2; - break; - case 16: - ctx->Driver.DrawPixels = !fxMesa->bgrOrder ? fxDDDrawPixels565 : fxDDDrawPixels565_rev; - ctx->Driver.ReadPixels = fxDDReadPixels565; - ctx->Driver.Bitmap = fxDDDrawBitmap2; - break; - case 32: - ctx->Driver.DrawPixels = fxDDDrawPixels8888; - ctx->Driver.ReadPixels = fxDDReadPixels8888; - ctx->Driver.Bitmap = fxDDDrawBitmap4; - break; - } - ctx->Driver.Finish = fxDDFinish; - ctx->Driver.Flush = NULL; - ctx->Driver.ChooseTextureFormat = fxDDChooseTextureFormat; - ctx->Driver.TexImage1D = fxDDTexImage1D; - ctx->Driver.TexImage2D = fxDDTexImage2D; - ctx->Driver.TexSubImage1D = fxDDTexSubImage1D; - ctx->Driver.TexSubImage2D = fxDDTexSubImage2D; - ctx->Driver.CompressedTexImage2D = fxDDCompressedTexImage2D; - ctx->Driver.CompressedTexSubImage2D = fxDDCompressedTexSubImage2D; - ctx->Driver.TestProxyTexImage = fxDDTestProxyTexImage; - ctx->Driver.TexEnv = fxDDTexEnv; - ctx->Driver.TexParameter = fxDDTexParam; - ctx->Driver.BindTexture = fxDDTexBind; - ctx->Driver.DeleteTexture = fxDDTexDel; - ctx->Driver.IsTextureResident = fxDDIsTextureResident; - ctx->Driver.UpdateTexturePalette = fxDDTexPalette; - ctx->Driver.AlphaFunc = fxDDAlphaFunc; - ctx->Driver.BlendFuncSeparate = fxDDBlendFuncSeparate; - ctx->Driver.BlendEquationSeparate = fxDDBlendEquationSeparate; - ctx->Driver.DepthFunc = fxDDDepthFunc; - ctx->Driver.DepthMask = fxDDDepthMask; - ctx->Driver.ColorMask = fxDDColorMask; - ctx->Driver.Fogfv = fxDDFogfv; - ctx->Driver.Scissor = fxDDScissor; - ctx->Driver.FrontFace = fxDDFrontFace; - ctx->Driver.CullFace = fxDDCullFace; - ctx->Driver.ShadeModel = fxDDShadeModel; - ctx->Driver.Enable = fxDDEnable; - if (fxMesa->haveHwStencil) { - ctx->Driver.StencilFuncSeparate = fxDDStencilFuncSeparate; - ctx->Driver.StencilMaskSeparate = fxDDStencilMaskSeparate; - ctx->Driver.StencilOpSeparate = fxDDStencilOpSeparate; - } - - fxSetupDDSpanPointers(ctx); - fxDDUpdateDDPointers(ctx, ~0); -} - - -#else - - -/* - * Need this to provide at least one external definition. - */ - -extern int gl_fx_dummy_function_dd(void); -int -gl_fx_dummy_function_dd(void) -{ - return 0; -} - -#endif /* FX */ diff --git a/src/mesa/drivers/glide/fxddspan.c b/src/mesa/drivers/glide/fxddspan.c deleted file mode 100644 index d3a58a301c..0000000000 --- a/src/mesa/drivers/glide/fxddspan.c +++ /dev/null @@ -1,638 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * Copyright (C) 1999-2001 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. - */ - -/* Authors: - * David Bucciarelli - * Brian Paul - * Daryll Strauss - * Keith Whitwell - * Daniel Borca - * Hiroshi Morii - */ - - -/* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */ - - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#if defined(FX) - -#include "fxdrv.h" -#include "fxglidew.h" -#include "swrast/swrast.h" - - -/************************************************************************/ -/***** Span functions *****/ -/************************************************************************/ - -#define DBG 0 - - -#define LOCAL_VARS \ - GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER; \ - GLuint pitch = info.strideInBytes; \ - GLuint height = fxMesa->height; \ - char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */); \ - GLuint p; \ - (void) buf; (void) p; - -#define CLIPPIXEL( _x, _y ) ( _x >= minx && _x < maxx && \ - _y >= miny && _y < maxy ) - -#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \ - if ( _y < miny || _y >= maxy ) { \ - _n1 = 0, _x1 = x; \ - } else { \ - _n1 = _n; \ - _x1 = _x; \ - if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx;\ - if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \ - } - -#define Y_FLIP(_y) (height - _y - 1) - -#define HW_WRITE_LOCK() \ - fxMesaContext fxMesa = FX_CONTEXT(ctx); \ - GrLfbInfo_t info; \ - info.size = sizeof(GrLfbInfo_t); \ - if ( grLfbLock( GR_LFB_WRITE_ONLY, \ - currentFB, LFB_MODE, \ - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) { - -#define HW_WRITE_UNLOCK() \ - grLfbUnlock( GR_LFB_WRITE_ONLY, currentFB ); \ - } - -#define HW_READ_LOCK() \ - fxMesaContext fxMesa = FX_CONTEXT(ctx); \ - GrLfbInfo_t info; \ - info.size = sizeof(GrLfbInfo_t); \ - if ( grLfbLock( GR_LFB_READ_ONLY, currentFB, \ - LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) { - -#define HW_READ_UNLOCK() \ - grLfbUnlock( GR_LFB_READ_ONLY, currentFB ); \ - } - -#define HW_WRITE_CLIPLOOP() \ - do { \ - /* remember, we need to flip the scissor, too */ \ - /* is it better to do it inside fxDDScissor? */ \ - const int minx = fxMesa->clipMinX; \ - const int maxy = Y_FLIP(fxMesa->clipMinY); \ - const int maxx = fxMesa->clipMaxX; \ - const int miny = Y_FLIP(fxMesa->clipMaxY); - -#define HW_READ_CLIPLOOP() \ - do { \ - /* remember, we need to flip the scissor, too */ \ - /* is it better to do it inside fxDDScissor? */ \ - const int minx = fxMesa->clipMinX; \ - const int maxy = Y_FLIP(fxMesa->clipMinY); \ - const int maxx = fxMesa->clipMaxX; \ - const int miny = Y_FLIP(fxMesa->clipMaxY); - -#define HW_ENDCLIPLOOP() \ - } while (0) - - -/* 16 bit, ARGB1555 color spanline and pixel functions */ - -#undef LFB_MODE -#define LFB_MODE GR_LFBWRITEMODE_1555 - -#undef BYTESPERPIXEL -#define BYTESPERPIXEL 2 - -#undef INIT_MONO_PIXEL -#define INIT_MONO_PIXEL(p, color) \ - p = TDFXPACKCOLOR1555( color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP] ) - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \ - TDFXPACKCOLOR1555( r, g, b, a ) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch); \ - rgba[0] = FX_rgb_scale_5[(p >> 10) & 0x1F]; \ - rgba[1] = FX_rgb_scale_5[(p >> 5) & 0x1F]; \ - rgba[2] = FX_rgb_scale_5[ p & 0x1F]; \ - rgba[3] = (p & 0x8000) ? 255 : 0; \ - } while (0) - -#define TAG(x) tdfx##x##_ARGB1555 -#include "../dri/common/spantmp.h" - - -/* 16 bit, RGB565 color spanline and pixel functions */ -/* [dBorca] Hack alert: - * This is wrong. The alpha value is lost, even when we provide - * HW alpha (565 w/o depth buffering). To really update alpha buffer, - * we would need to do the 565 writings via 8888 colorformat and rely - * on the Voodoo to perform color scaling. In which case our 565 span - * would look nicer! But this violates FSAA rules... - */ - -#undef LFB_MODE -#define LFB_MODE GR_LFBWRITEMODE_565 - -#undef BYTESPERPIXEL -#define BYTESPERPIXEL 2 - -#undef INIT_MONO_PIXEL -#define INIT_MONO_PIXEL(p, color) \ - p = TDFXPACKCOLOR565( color[RCOMP], color[GCOMP], color[BCOMP] ) - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \ - TDFXPACKCOLOR565( r, g, b ) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch); \ - rgba[0] = FX_rgb_scale_5[(p >> 11) & 0x1F]; \ - rgba[1] = FX_rgb_scale_6[(p >> 5) & 0x3F]; \ - rgba[2] = FX_rgb_scale_5[ p & 0x1F]; \ - rgba[3] = 0xff; \ - } while (0) - -#define TAG(x) tdfx##x##_RGB565 -#include "../dri/common/spantmp.h" - - -/* 32 bit, ARGB8888 color spanline and pixel functions */ - -#undef LFB_MODE -#define LFB_MODE GR_LFBWRITEMODE_8888 - -#undef BYTESPERPIXEL -#define BYTESPERPIXEL 4 - -#undef INIT_MONO_PIXEL -#define INIT_MONO_PIXEL(p, color) \ - p = TDFXPACKCOLOR8888( color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP] ) - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \ - TDFXPACKCOLOR8888( r, g, b, a ) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLuint p = *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch); \ - rgba[0] = (p >> 16) & 0xff; \ - rgba[1] = (p >> 8) & 0xff; \ - rgba[2] = (p >> 0) & 0xff; \ - rgba[3] = (p >> 24) & 0xff; \ - } while (0) - -#define TAG(x) tdfx##x##_ARGB8888 -#include "../dri/common/spantmp.h" - - -/************************************************************************/ -/***** Depth functions *****/ -/************************************************************************/ - -#define DBG 0 - -#undef HW_WRITE_LOCK -#undef HW_WRITE_UNLOCK -#undef HW_READ_LOCK -#undef HW_READ_UNLOCK - -#define HW_CLIPLOOP HW_WRITE_CLIPLOOP - -#define LOCAL_DEPTH_VARS \ - GLuint pitch = info.strideInBytes; \ - GLuint height = fxMesa->height; \ - char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */); \ - (void) buf; - -#define HW_WRITE_LOCK() \ - fxMesaContext fxMesa = FX_CONTEXT(ctx); \ - GrLfbInfo_t info; \ - info.size = sizeof(GrLfbInfo_t); \ - if ( grLfbLock( GR_LFB_WRITE_ONLY, \ - GR_BUFFER_AUXBUFFER, LFB_MODE, \ - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) { - -#define HW_WRITE_UNLOCK() \ - grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_AUXBUFFER); \ - } - -#define HW_READ_LOCK() \ - fxMesaContext fxMesa = FX_CONTEXT(ctx); \ - GrLfbInfo_t info; \ - info.size = sizeof(GrLfbInfo_t); \ - if ( grLfbLock( GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER, \ - LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) { - -#define HW_READ_UNLOCK() \ - grLfbUnlock( GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER); \ - } - - -/* 16 bit, depth spanline and pixel functions */ - -#undef LFB_MODE -#define LFB_MODE GR_LFBWRITEMODE_ZA16 - -#undef BYTESPERPIXEL -#define BYTESPERPIXEL 2 - -#define VALUE_TYPE GLushort - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d - -#define READ_DEPTH( d, _x, _y ) \ - d = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) - -#define TAG(x) tdfx##x##_Z16 -#include "../dri/common/depthtmp.h" - - -/* 24 bit, depth spanline and pixel functions (for use w/ stencil) */ -/* [dBorca] Hack alert: - * This is evil. The incoming Mesa's 24bit depth value - * is shifted left 8 bits, to obtain a full 32bit value, - * which will be thrown into the framebuffer. We rely on - * the fact that Voodoo hardware transforms a 32bit value - * into 24bit value automatically and, MOST IMPORTANT, won't - * alter the upper 8bits of the value already existing in the - * framebuffer (where stencil resides). - */ - -#undef LFB_MODE -#define LFB_MODE GR_LFBWRITEMODE_Z32 - -#undef BYTESPERPIXEL -#define BYTESPERPIXEL 4 - -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d << 8 - -#define READ_DEPTH( d, _x, _y ) \ - d = (*(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch)) & 0xffffff - -#define TAG(x) tdfx##x##_Z24 -#include "../dri/common/depthtmp.h" - - -/* 32 bit, depth spanline and pixel functions (for use w/o stencil) */ -/* [dBorca] Hack alert: - * This is more evil. We make Mesa run in 32bit depth, but - * tha Voodoo HW can only handle 24bit depth. Well, exploiting - * the pixel pipeline, we can achieve 24:8 format for greater - * precision... - * If anyone tells me how to really store 32bit values into the - * depth buffer, I'll write the *_Z32 routines. Howver, bear in - * mind that means running without stencil! - */ - -/************************************************************************/ -/***** Span functions (optimized) *****/ -/************************************************************************/ - -/* - * Read a span of 15-bit RGB pixels. Note, we don't worry about cliprects - * since OpenGL says obscured pixels have undefined values. - */ -static void fxReadRGBASpan_ARGB1555 (const GLcontext * ctx, - struct gl_renderbuffer *rb, - GLuint n, - GLint x, GLint y, - GLubyte rgba[][4]) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER; - GrLfbInfo_t info; - info.size = sizeof(GrLfbInfo_t); - if (grLfbLock(GR_LFB_READ_ONLY, currentFB, - GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { - const GLint winX = 0; - const GLint winY = fxMesa->height - 1; - const GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr + - (winY - y) * info.strideInBytes + - (winX + x) * 2); - const GLuint *data32 = (const GLuint *) data16; - GLuint i, j; - GLuint extraPixel = (n & 1); - n -= extraPixel; - - for (i = j = 0; i < n; i += 2, j++) { - GLuint pixel = data32[j]; - rgba[i][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F]; - rgba[i][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F]; - rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F]; - rgba[i][3] = (pixel & 0x8000) ? 255 : 0; - rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 26) & 0x1F]; - rgba[i+1][1] = FX_rgb_scale_5[(pixel >> 21) & 0x1F]; - rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F]; - rgba[i+1][3] = (pixel & 0x80000000) ? 255 : 0; - } - if (extraPixel) { - GLushort pixel = data16[n]; - rgba[n][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F]; - rgba[n][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F]; - rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F]; - rgba[n][3] = (pixel & 0x8000) ? 255 : 0; - } - - grLfbUnlock(GR_LFB_READ_ONLY, currentFB); - } -} - -/* - * Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects - * since OpenGL says obscured pixels have undefined values. - */ -static void fxReadRGBASpan_RGB565 (const GLcontext * ctx, - struct gl_renderbuffer *rb, - GLuint n, - GLint x, GLint y, - GLubyte rgba[][4]) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER; - GrLfbInfo_t info; - info.size = sizeof(GrLfbInfo_t); - if (grLfbLock(GR_LFB_READ_ONLY, currentFB, - GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { - const GLint winX = 0; - const GLint winY = fxMesa->height - 1; - const GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr + - (winY - y) * info.strideInBytes + - (winX + x) * 2); - const GLuint *data32 = (const GLuint *) data16; - GLuint i, j; - GLuint extraPixel = (n & 1); - n -= extraPixel; - - for (i = j = 0; i < n; i += 2, j++) { - GLuint pixel = data32[j]; - rgba[i][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F]; - rgba[i][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F]; - rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F]; - rgba[i][3] = 255; - rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 27) & 0x1F]; - rgba[i+1][1] = FX_rgb_scale_6[(pixel >> 21) & 0x3F]; - rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F]; - rgba[i+1][3] = 255; - } - if (extraPixel) { - GLushort pixel = data16[n]; - rgba[n][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F]; - rgba[n][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F]; - rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F]; - rgba[n][3] = 255; - } - - grLfbUnlock(GR_LFB_READ_ONLY, currentFB); - } -} - -/* - * Read a span of 32-bit RGB pixels. Note, we don't worry about cliprects - * since OpenGL says obscured pixels have undefined values. - */ -static void fxReadRGBASpan_ARGB8888 (const GLcontext * ctx, - struct gl_renderbuffer *rb, - GLuint n, - GLint x, GLint y, - GLubyte rgba[][4]) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER; - GLuint i; - grLfbReadRegion(currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba); - for (i = 0; i < n; i++) { - GLubyte c = rgba[i][0]; - rgba[i][0] = rgba[i][2]; - rgba[i][2] = c; - } -} - - -/************************************************************************/ -/***** Depth functions (optimized) *****/ -/************************************************************************/ - -static void -fxReadDepthSpan_Z16(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, GLuint depth[]) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLint bottom = fxMesa->height - 1; - GLushort depth16[MAX_WIDTH]; - GLuint i; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxReadDepthSpan_Z16(...)\n"); - } - - grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16); - for (i = 0; i < n; i++) { - depth[i] = depth16[i]; - } -} - - -static void -fxReadDepthSpan_Z24(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, GLuint depth[]) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLint bottom = fxMesa->height - 1; - GLuint i; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxReadDepthSpan_Z24(...)\n"); - } - - grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth); - for (i = 0; i < n; i++) { - depth[i] &= 0xffffff; - } -} - - -/************************************************************************/ -/***** Stencil functions (optimized) *****/ -/************************************************************************/ - -static void -fxWriteStencilSpan (GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const GLstencil stencil[], const GLubyte mask[]) -{ - /* - * XXX todo - */ -} - -static void -fxReadStencilSpan(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, GLstencil stencil[]) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLint bottom = fxMesa->height - 1; - GLuint zs32[MAX_WIDTH]; - GLuint i; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxReadStencilSpan(...)\n"); - } - - grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, zs32); - for (i = 0; i < n; i++) { - stencil[i] = zs32[i] >> 24; - } -} - -static void -fxWriteStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, - const GLint x[], const GLint y[], - const GLstencil stencil[], - const GLubyte mask[]) -{ - /* - * XXX todo - */ -} - -static void -fxReadStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, - const GLint x[], const GLint y[], - GLstencil stencil[]) -{ - /* - * XXX todo - */ -} - - -void -fxSetupDDSpanPointers(GLcontext * ctx) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx ); - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - switch (fxMesa->colDepth) { - case 15: - swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB1555; - swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB1555; - swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB1555; - swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB1555; - swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB1555; - swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB1555; - swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB1555; - - swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z16; - swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z16; - swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z16; - swdd->ReadDepthPixels = tdfxReadDepthPixels_Z16; - break; - case 16: - swdd->WriteRGBASpan = tdfxWriteRGBASpan_RGB565; - swdd->WriteRGBSpan = tdfxWriteRGBSpan_RGB565; - swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_RGB565; - swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_RGB565; - swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_RGB565; - swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_RGB565; - swdd->ReadRGBAPixels = tdfxReadRGBAPixels_RGB565; - - swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z16; - swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z16; - swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z16; - swdd->ReadDepthPixels = tdfxReadDepthPixels_Z16; - break; - case 32: - swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB8888; - swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB8888; - swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB8888; - swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB8888; - swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB8888; - swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB8888; - swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB8888; - - swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z24; - swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z24; - swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z24; - swdd->ReadDepthPixels = tdfxReadDepthPixels_Z24; - break; - } - - if (fxMesa->haveHwStencil) { - swdd->WriteStencilSpan = fxWriteStencilSpan; - swdd->ReadStencilSpan = fxReadStencilSpan; - swdd->WriteStencilPixels = fxWriteStencilPixels; - swdd->ReadStencilPixels = fxReadStencilPixels; - } -#if 0 - swdd->WriteCI8Span = NULL; - swdd->WriteCI32Span = NULL; - swdd->WriteMonoCISpan = NULL; - swdd->WriteCI32Pixels = NULL; - swdd->WriteMonoCIPixels = NULL; - swdd->ReadCI32Span = NULL; - swdd->ReadCI32Pixels = NULL; - - swdd->SpanRenderStart = tdfxSpanRenderStart; /* BEGIN_BOARD_LOCK */ - swdd->SpanRenderFinish = tdfxSpanRenderFinish; /* END_BOARD_LOCK */ -#endif -} - - -#else - - -/* - * Need this to provide at least one external definition. - */ - -extern int gl_fx_dummy_function_span(void); -int -gl_fx_dummy_function_span(void) -{ - return 0; -} - -#endif /* FX */ diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c deleted file mode 100644 index b35874fffc..0000000000 --- a/src/mesa/drivers/glide/fxddtex.c +++ /dev/null @@ -1,1836 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * Copyright (C) 1999-2001 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. - */ - -/* Authors: - * David Bucciarelli - * Brian Paul - * Daryll Strauss - * Keith Whitwell - * Daniel Borca - * Hiroshi Morii - */ - - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#if defined(FX) - -#include "fxdrv.h" -#include "main/enums.h" -#include "main/formats.h" -#include "main/image.h" -#include "main/teximage.h" -#include "main/texstore.h" -#include "main/texformat.h" -#include "main/texcompress.h" -#include "main/texobj.h" -#include "main/texstore.h" - - -/* no borders! can't halve 1x1! (stride > width * comp) not allowed */ -static void -_mesa_halve2x2_teximage2d ( GLcontext *ctx, - struct gl_texture_image *texImage, - GLuint bytesPerPixel, - GLint srcWidth, GLint srcHeight, - const GLvoid *srcImage, GLvoid *dstImage ) -{ - GLint i, j, k; - GLint dstWidth = srcWidth / 2; - GLint dstHeight = srcHeight / 2; - GLint srcRowStride = srcWidth * bytesPerPixel; - GLubyte *src = (GLubyte *)srcImage; - GLubyte *dst = dstImage; - - GLuint bpt = 0; - GLubyte *_s = NULL; - GLubyte *_d = NULL; - GLenum _t = 0; - - if (texImage->TexFormat->MesaFormat == MESA_FORMAT_RGB565) { - _t = GL_UNSIGNED_SHORT_5_6_5_REV; - bpt = bytesPerPixel; - } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB4444) { - _t = GL_UNSIGNED_SHORT_4_4_4_4_REV; - bpt = bytesPerPixel; - } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB1555) { - _t = GL_UNSIGNED_SHORT_1_5_5_5_REV; - bpt = bytesPerPixel; - } - if (bpt) { - bytesPerPixel = 4; - srcRowStride = srcWidth * bytesPerPixel; - if (dstWidth == 0) { - dstWidth = 1; - } - if (dstHeight == 0) { - dstHeight = 1; - } - _s = src = MALLOC(srcRowStride * srcHeight); - _d = dst = MALLOC(dstWidth * bytesPerPixel * dstHeight); - _mesa_texstore(ctx, 2, GL_RGBA, - &_mesa_texformat_rgba8888_rev, src, - 0, 0, 0, /* dstX/Y/Zoffset */ - srcRowStride, /* dstRowStride */ - 0, /* dstImageStride */ - srcWidth, srcHeight, 1, - texImage->_BaseFormat, _t, - srcImage, &ctx->DefaultPacking); - } - - if (srcHeight == 1) { - for (i = 0; i < dstWidth; i++) { - for (k = 0; k < bytesPerPixel; k++) { - dst[0] = (src[0] + src[bytesPerPixel] + 1) / 2; - src++; - dst++; - } - src += bytesPerPixel; - } - } else if (srcWidth == 1) { - for (j = 0; j < dstHeight; j++) { - for (k = 0; k < bytesPerPixel; k++) { - dst[0] = (src[0] + src[srcRowStride] + 1) / 2; - src++; - dst++; - } - src += srcRowStride; - } - } else { - for (j = 0; j < dstHeight; j++) { - for (i = 0; i < dstWidth; i++) { - for (k = 0; k < bytesPerPixel; k++) { - dst[0] = (src[0] + - src[bytesPerPixel] + - src[srcRowStride] + - src[srcRowStride + bytesPerPixel] + 2) / 4; - src++; - dst++; - } - src += bytesPerPixel; - } - src += srcRowStride; - } - } - - if (bpt) { - src = _s; - dst = _d; - _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, dstImage, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstWidth * bpt, - 0, /* dstImageStride */ - dstWidth, dstHeight, 1, - GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking); - FREE(dst); - FREE(src); - } -} - - -void -fxPrintTextureData(tfxTexInfo * ti) -{ - fprintf(stderr, "Texture Data:\n"); - if (ti->tObj) { - fprintf(stderr, "\tName: %d\n", ti->tObj->Name); - fprintf(stderr, "\tBaseLevel: %d\n", ti->tObj->BaseLevel); - fprintf(stderr, "\tSize: %d x %d\n", - ti->tObj->Image[0][ti->tObj->BaseLevel]->Width, - ti->tObj->Image[0][ti->tObj->BaseLevel]->Height); - } - else - fprintf(stderr, "\tName: UNNAMED\n"); - fprintf(stderr, "\tLast used: %d\n", ti->lastTimeUsed); - fprintf(stderr, "\tTMU: %ld\n", ti->whichTMU); - fprintf(stderr, "\t%s\n", (ti->isInTM) ? "In TMU" : "Not in TMU"); - if (ti->tm[0]) - fprintf(stderr, "\tMem0: %x-%x\n", (unsigned) ti->tm[0]->startAddr, - (unsigned) ti->tm[0]->endAddr); - if (ti->tm[1]) - fprintf(stderr, "\tMem1: %x-%x\n", (unsigned) ti->tm[1]->startAddr, - (unsigned) ti->tm[1]->endAddr); - fprintf(stderr, "\tMipmaps: %d-%d\n", ti->minLevel, ti->maxLevel); - fprintf(stderr, "\tFilters: min %d max %d\n", - (int) ti->minFilt, (int) ti->maxFilt); - fprintf(stderr, "\tClamps: s %d t %d\n", (int) ti->sClamp, - (int) ti->tClamp); - fprintf(stderr, "\tScales: s %f t %f\n", ti->sScale, ti->tScale); - fprintf(stderr, "\t%s\n", - (ti->fixedPalette) ? "Fixed palette" : "Non fixed palette"); - fprintf(stderr, "\t%s\n", (ti->validated) ? "Validated" : "Not validated"); -} - - -/************************************************************************/ -/*************************** Texture Mapping ****************************/ -/************************************************************************/ - -static void -fxTexInvalidate(GLcontext * ctx, struct gl_texture_object *tObj) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxTexInfo *ti; - - ti = fxTMGetTexInfo(tObj); - if (ti->isInTM) - fxTMMoveOutTM(fxMesa, tObj); /* TO DO: SLOW but easy to write */ - - ti->validated = GL_FALSE; - fxMesa->new_state |= FX_NEW_TEXTURING; -} - -static tfxTexInfo * -fxAllocTexObjData(fxMesaContext fxMesa) -{ - tfxTexInfo *ti; - - if (!(ti = CALLOC(sizeof(tfxTexInfo)))) { - fprintf(stderr, "fxAllocTexObjData: ERROR: out of memory !\n"); - fxCloseHardware(); - exit(-1); - } - - ti->validated = GL_FALSE; - ti->isInTM = GL_FALSE; - - ti->whichTMU = FX_TMU_NONE; - - ti->tm[FX_TMU0] = NULL; - ti->tm[FX_TMU1] = NULL; - - ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - ti->maxFilt = GR_TEXTUREFILTER_BILINEAR; - - ti->sClamp = GR_TEXTURECLAMP_WRAP; - ti->tClamp = GR_TEXTURECLAMP_WRAP; - - ti->mmMode = GR_MIPMAP_NEAREST; - ti->LODblend = FXFALSE; - - return ti; -} - -void -fxDDTexBind(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxTexInfo *ti; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxDDTexBind(%d, %x)\n", tObj->Name, (GLuint)tObj->DriverData); - } - - if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D)) - return; - - if (!tObj->DriverData) { - tObj->DriverData = fxAllocTexObjData(fxMesa); - } - ti = fxTMGetTexInfo(tObj); - - fxMesa->texBindNumber++; - ti->lastTimeUsed = fxMesa->texBindNumber; - - fxMesa->new_state |= FX_NEW_TEXTURING; -} - -void -fxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname, - const GLfloat * param) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - if (param) - fprintf(stderr, "fxDDTexEnv(%x, %x)\n", pname, (GLint) (*param)); - else - fprintf(stderr, "fxDDTexEnv(%x)\n", pname); - } - - /* apply any lod biasing right now */ - if (pname == GL_TEXTURE_LOD_BIAS_EXT) { - GLfloat bias = *param; - bias = CLAMP(bias, - -ctx->Const.MaxTextureLodBias, - ctx->Const.MaxTextureLodBias - 0.25); - - grTexLodBiasValue(GR_TMU0, bias); - - if (fxMesa->haveTwoTMUs) { - grTexLodBiasValue(GR_TMU1, bias); - } - - } - - fxMesa->new_state |= FX_NEW_TEXTURING; -} - -void -fxDDTexParam(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj, - GLenum pname, const GLfloat * params) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLenum param = (GLenum) (GLint) params[0]; - tfxTexInfo *ti; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxDDTexParam(%d, %x, %s, %s)\n", - tObj->Name, (GLuint) tObj->DriverData, - _mesa_lookup_enum_by_nr(pname), - _mesa_lookup_enum_by_nr(param)); - } - - if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D)) - return; - - if (!tObj->DriverData) - tObj->DriverData = fxAllocTexObjData(fxMesa); - ti = fxTMGetTexInfo(tObj); - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - switch (param) { - case GL_NEAREST: - ti->mmMode = GR_MIPMAP_DISABLE; - ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - ti->LODblend = FXFALSE; - break; - case GL_LINEAR: - ti->mmMode = GR_MIPMAP_DISABLE; - ti->minFilt = GR_TEXTUREFILTER_BILINEAR; - ti->LODblend = FXFALSE; - break; - case GL_NEAREST_MIPMAP_LINEAR: - /* [dBorca] - * currently Napalm can't do single-pass trilinear, - * because the way its combiners are set. So we fall back - * to GL_NEAREST_MIPMAP_NEAREST. We'll let true trilinear - * enabled for V2, V3. - */ - if (!fxMesa->HaveCmbExt) { - if (fxMesa->haveTwoTMUs) { - ti->mmMode = GR_MIPMAP_NEAREST; - ti->LODblend = FXTRUE; - } else { - ti->mmMode = GR_MIPMAP_NEAREST_DITHER; - ti->LODblend = FXFALSE; - } - ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - break; - } - case GL_NEAREST_MIPMAP_NEAREST: - ti->mmMode = GR_MIPMAP_NEAREST; - ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - ti->LODblend = FXFALSE; - break; - case GL_LINEAR_MIPMAP_LINEAR: - /* [dBorca] - * currently Napalm can't do single-pass trilinear, - * because the way its combiners are set. So we fall back - * to GL_LINEAR_MIPMAP_NEAREST. We'll let true trilinear - * enabled for V2, V3. - */ - if (!fxMesa->HaveCmbExt) { - if (fxMesa->haveTwoTMUs) { - ti->mmMode = GR_MIPMAP_NEAREST; - ti->LODblend = FXTRUE; - } else { - ti->mmMode = GR_MIPMAP_NEAREST_DITHER; - ti->LODblend = FXFALSE; - } - ti->minFilt = GR_TEXTUREFILTER_BILINEAR; - break; - } - case GL_LINEAR_MIPMAP_NEAREST: - ti->mmMode = GR_MIPMAP_NEAREST; - ti->minFilt = GR_TEXTUREFILTER_BILINEAR; - ti->LODblend = FXFALSE; - break; - default: - break; - } - fxTexInvalidate(ctx, tObj); - break; - - case GL_TEXTURE_MAG_FILTER: - switch (param) { - case GL_NEAREST: - ti->maxFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - break; - case GL_LINEAR: - ti->maxFilt = GR_TEXTUREFILTER_BILINEAR; - break; - default: - break; - } - fxMesa->new_state |= FX_NEW_TEXTURING; - break; - - case GL_TEXTURE_WRAP_S: - switch (param) { - case GL_MIRRORED_REPEAT: - ti->sClamp = GR_TEXTURECLAMP_MIRROR_EXT; - break; - case GL_CLAMP_TO_BORDER: /* no-no, but don't REPEAT, either */ - case GL_CLAMP_TO_EDGE: /* CLAMP discarding border */ - case GL_CLAMP: - ti->sClamp = GR_TEXTURECLAMP_CLAMP; - break; - case GL_REPEAT: - ti->sClamp = GR_TEXTURECLAMP_WRAP; - break; - default: - break; - } - fxMesa->new_state |= FX_NEW_TEXTURING; - break; - - case GL_TEXTURE_WRAP_T: - switch (param) { - case GL_MIRRORED_REPEAT: - ti->tClamp = GR_TEXTURECLAMP_MIRROR_EXT; - break; - case GL_CLAMP_TO_BORDER: /* no-no, but don't REPEAT, either */ - case GL_CLAMP_TO_EDGE: /* CLAMP discarding border */ - case GL_CLAMP: - ti->tClamp = GR_TEXTURECLAMP_CLAMP; - break; - case GL_REPEAT: - ti->tClamp = GR_TEXTURECLAMP_WRAP; - break; - default: - break; - } - fxMesa->new_state |= FX_NEW_TEXTURING; - break; - - case GL_TEXTURE_BORDER_COLOR: - /* TO DO */ - break; - - case GL_TEXTURE_MIN_LOD: - /* TO DO */ - break; - case GL_TEXTURE_MAX_LOD: - /* TO DO */ - break; - case GL_TEXTURE_BASE_LEVEL: - fxTexInvalidate(ctx, tObj); - break; - case GL_TEXTURE_MAX_LEVEL: - fxTexInvalidate(ctx, tObj); - break; - - default: - break; - } -} - -void -fxDDTexDel(GLcontext * ctx, struct gl_texture_object *tObj) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxDDTexDel(%d, %p)\n", tObj->Name, (void *) ti); - } - - if (!ti) - return; - - fxTMFreeTexture(fxMesa, tObj); - - FREE(ti); - tObj->DriverData = NULL; - - /* Free mipmap images and the texture object itself */ - _mesa_delete_texture_object(ctx, tObj); -} - - -/** - * Allocate a new texture object. - * Called via ctx->Driver.NewTextureObject. - * Note: this function will be called during context creation to - * allocate the default texture objects. - */ -struct gl_texture_object * -fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - obj = _mesa_new_texture_object(ctx, name, target); - return obj; -} - - -/* - * Return true if texture is resident, false otherwise. - */ -GLboolean -fxDDIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj) -{ - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - return (ti && ti->isInTM); -} - - - -/* - * Convert a gl_color_table texture palette to Glide's format. - */ -static GrTexTable_t -convertPalette(const fxMesaContext fxMesa, FxU32 data[256], const struct gl_color_table *table) -{ - const GLubyte *tableUB = (const GLubyte *) table->Table; - GLint width = table->Size; - FxU32 r, g, b, a; - GLint i; - - ASSERT(table->Type == GL_UNSIGNED_BYTE); - - switch (table->_BaseFormat) { - case GL_INTENSITY: - for (i = 0; i < width; i++) { - r = tableUB[i]; - g = tableUB[i]; - b = tableUB[i]; - a = tableUB[i]; - data[i] = (a << 24) | (r << 16) | (g << 8) | b; - } - return fxMesa->HavePalExt ? GR_TEXTABLE_PALETTE_6666_EXT : GR_TEXTABLE_PALETTE; - case GL_LUMINANCE: - for (i = 0; i < width; i++) { - r = tableUB[i]; - g = tableUB[i]; - b = tableUB[i]; - a = 255; - data[i] = (a << 24) | (r << 16) | (g << 8) | b; - } - return GR_TEXTABLE_PALETTE; - case GL_ALPHA: - for (i = 0; i < width; i++) { - r = g = b = 255; - a = tableUB[i]; - data[i] = (a << 24) | (r << 16) | (g << 8) | b; - } - return fxMesa->HavePalExt ? GR_TEXTABLE_PALETTE_6666_EXT : GR_TEXTABLE_PALETTE; - case GL_LUMINANCE_ALPHA: - for (i = 0; i < width; i++) { - r = g = b = tableUB[i * 2 + 0]; - a = tableUB[i * 2 + 1]; - data[i] = (a << 24) | (r << 16) | (g << 8) | b; - } - return fxMesa->HavePalExt ? GR_TEXTABLE_PALETTE_6666_EXT : GR_TEXTABLE_PALETTE; - default: - case GL_RGB: - for (i = 0; i < width; i++) { - r = tableUB[i * 3 + 0]; - g = tableUB[i * 3 + 1]; - b = tableUB[i * 3 + 2]; - a = 255; - data[i] = (a << 24) | (r << 16) | (g << 8) | b; - } - return GR_TEXTABLE_PALETTE; - case GL_RGBA: - for (i = 0; i < width; i++) { - r = tableUB[i * 4 + 0]; - g = tableUB[i * 4 + 1]; - b = tableUB[i * 4 + 2]; - a = tableUB[i * 4 + 3]; - data[i] = (a << 24) | (r << 16) | (g << 8) | b; - } - return fxMesa->HavePalExt ? GR_TEXTABLE_PALETTE_6666_EXT : GR_TEXTABLE_PALETTE; - } -} - - -void -fxDDTexPalette(GLcontext * ctx, struct gl_texture_object *tObj) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (tObj) { - /* per-texture palette */ - tfxTexInfo *ti; - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxDDTexPalette(%d, %x)\n", - tObj->Name, (GLuint) tObj->DriverData); - } - /* This might be a proxy texture. */ - if (!tObj->Palette.Table) - return; - if (!tObj->DriverData) - tObj->DriverData = fxAllocTexObjData(fxMesa); - ti = fxTMGetTexInfo(tObj); - ti->paltype = convertPalette(fxMesa, ti->palette.data, &tObj->Palette); - fxTexInvalidate(ctx, tObj); - } - else { - /* global texture palette */ - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxDDTexPalette(global)\n"); - } - fxMesa->glbPalType = convertPalette(fxMesa, fxMesa->glbPalette.data, &ctx->Texture.Palette); - fxMesa->new_state |= FX_NEW_TEXTURING; - - grTexDownloadTable(fxMesa->glbPalType, &(fxMesa->glbPalette)); - } -} - - -void -fxDDTexUseGlbPalette(GLcontext * ctx, GLboolean state) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxDDTexUseGlbPalette(%d)\n", state); - } - - fxMesa->haveGlobalPaletteTexture = state; - fxMesa->new_state |= FX_NEW_TEXTURING; -} - - -static int -logbase2(int n) -{ - GLint i = 1; - GLint log2 = 0; - - if (n < 0) { - return -1; - } - - while (n > i) { - i *= 2; - log2++; - } - if (i != n) { - return -1; - } - else { - return log2; - } -} - - -/* fxTexGetInfo - * w, h - source texture width and height - * lodlevel - Glide lod level token for the larger texture dimension - * ar - Glide aspect ratio token - * sscale - S scale factor used during triangle setup - * tscale - T scale factor used during triangle setup - * wscale - OpenGL -> Glide image width scale factor - * hscale - OpenGL -> Glide image height scale factor - */ -int -fxTexGetInfo(int w, int h, GrLOD_t * lodlevel, GrAspectRatio_t * ar, - float *sscale, float *tscale, - int *wscale, int *hscale) -{ - int logw, logh, ws, hs; - GrLOD_t l; - GrAspectRatio_t aspectratio; - float s, t; - - logw = logbase2(w); - logh = logbase2(h); - - l = MAX2(logw, logh); - aspectratio = logw - logh; - ws = hs = 1; - s = t = 256.0f; - - /* hardware only allows a maximum aspect ratio of 8x1, so handle - * |aspectratio| > 3 by scaling the image and using an 8x1 aspect - * ratio - */ - switch (aspectratio) { - case 0: - break; - case 1: - t = 128.0f; - break; - case 2: - t = 64.0f; - break; - case 3: - t = 32.0f; - break; - case -1: - s = 128.0f; - break; - case -2: - s = 64.0f; - break; - case -3: - s = 32.0f; - break; - default: - if (aspectratio > 3) { - t = 32.0f; - hs = 1 << (aspectratio - 3); - aspectratio = GR_ASPECT_LOG2_8x1; - } else /*if (aspectratio < -3)*/ { - s = 32.0f; - ws = 1 << (-aspectratio - 3); - aspectratio = GR_ASPECT_LOG2_1x8; - } - } - - if (lodlevel) - (*lodlevel) = l; - - if (ar) - (*ar) = aspectratio; - - if (sscale) - (*sscale) = s; - - if (tscale) - (*tscale) = t; - - if (wscale) - (*wscale) = ws; - - if (hscale) - (*hscale) = hs; - - - return 1; -} - -static GLboolean -fxIsTexSupported(GLenum target, GLint internalFormat, - const struct gl_texture_image *image) -{ - if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D)) - return GL_FALSE; - -#if 0 - if (!fxTexGetInfo(image->Width, image->Height, NULL, NULL, NULL, NULL, NULL, NULL)) - return GL_FALSE; -#endif - - if (image->Border > 0) - return GL_FALSE; - - return GL_TRUE; -} - - -/**********************************************************************/ -/**** NEW TEXTURE IMAGE FUNCTIONS ****/ -/**********************************************************************/ -extern void -fxt1_decode_1 (const void *texture, int width, - int i, int j, unsigned char *rgba); - -/* Texel-fetch functions for software texturing and glGetTexImage(). - * We should have been able to use some "standard" fetch functions (which - * may get defined in texutil.c) but we have to account for scaled texture - * images on tdfx hardware (the 8:1 aspect ratio limit). - * Hence, we need special functions here. - */ - -static void -fetch_intensity8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - const GLubyte *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLubyte *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = *texel; - rgba[GCOMP] = *texel; - rgba[BCOMP] = *texel; - rgba[ACOMP] = *texel; -} - - -static void -fetch_luminance8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - const GLubyte *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLubyte *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = *texel; - rgba[GCOMP] = *texel; - rgba[BCOMP] = *texel; - rgba[ACOMP] = 255; -} - - -static void -fetch_alpha8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - const GLubyte *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLubyte *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = 255; - rgba[GCOMP] = 255; - rgba[BCOMP] = 255; - rgba[ACOMP] = *texel; -} - - -static void -fetch_index8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *indexOut) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - const GLubyte *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLubyte *) texImage->Data) + j * mml->width + i; - *indexOut = *texel; -} - - -static void -fetch_luminance8_alpha8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - const GLubyte *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLubyte *) texImage->Data) + (j * mml->width + i) * 2; - rgba[RCOMP] = texel[0]; - rgba[GCOMP] = texel[0]; - rgba[BCOMP] = texel[0]; - rgba[ACOMP] = texel[1]; -} - - -static void -fetch_r5g6b5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - const GLushort *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLushort *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = FX_rgb_scale_5[(*texel >> 11) & 0x1F]; - rgba[GCOMP] = FX_rgb_scale_6[(*texel >> 5) & 0x3F]; - rgba[BCOMP] = FX_rgb_scale_5[ *texel & 0x1F]; - rgba[ACOMP] = 255; -} - - -static void -fetch_r4g4b4a4(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - const GLushort *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLushort *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = FX_rgb_scale_4[(*texel >> 8) & 0xF]; - rgba[GCOMP] = FX_rgb_scale_4[(*texel >> 4) & 0xF]; - rgba[BCOMP] = FX_rgb_scale_4[ *texel & 0xF]; - rgba[ACOMP] = FX_rgb_scale_4[(*texel >> 12) & 0xF]; -} - - -static void -fetch_r5g5b5a1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - const GLushort *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLushort *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = FX_rgb_scale_5[(*texel >> 10) & 0x1F]; - rgba[GCOMP] = FX_rgb_scale_5[(*texel >> 5) & 0x1F]; - rgba[BCOMP] = FX_rgb_scale_5[ *texel & 0x1F]; - rgba[ACOMP] = (*texel >> 15) * 255; -} - - -static void -fetch_a8r8g8b8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - const GLuint *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLuint *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = (((*texel) >> 16) & 0xff); - rgba[GCOMP] = (((*texel) >> 8) & 0xff); - rgba[BCOMP] = (((*texel) ) & 0xff); - rgba[ACOMP] = (((*texel) >> 24) & 0xff); -} - - -static void -fetch_rgb_fxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - fxt1_decode_1(texImage->Data, mml->width, i, j, rgba); - rgba[ACOMP] = 255; -} - - -static void -fetch_rgba_fxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - fxt1_decode_1(texImage->Data, mml->width, i, j, rgba); -} - - -static void -fetch_rgb_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - _mesa_texformat_rgb_dxt1.FetchTexel2D(texImage, i, j, k, rgba); -} - - -static void -fetch_rgba_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - _mesa_texformat_rgba_dxt1.FetchTexel2D(texImage, i, j, k, rgba); -} - - -static void -fetch_rgba_dxt3(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - _mesa_texformat_rgba_dxt3.FetchTexel2D(texImage, i, j, k, rgba); -} - - -static void -fetch_rgba_dxt5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - _mesa_texformat_rgba_dxt5.FetchTexel2D(texImage, i, j, k, rgba); -} - - -#if 0 /* break glass in case of emergency */ -static void -PrintTexture(int w, int h, int c, const GLubyte * data) -{ - int i, j; - for (i = 0; i < h; i++) { - for (j = 0; j < w; j++) { - if (c == 2) - fprintf(stderr, "%02x %02x ", data[0], data[1]); - else if (c == 3) - fprintf(stderr, "%02x %02x %02x ", data[0], data[1], data[2]); - data += c; - } - fprintf(stderr, "\n"); - } -} -#endif - - -gl_format -fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat, - GLenum srcFormat, GLenum srcType ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLboolean allow32bpt = fxMesa->HaveTexFmt; - - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxDDChooseTextureFormat(...)\n"); - } - - switch (internalFormat) { - case GL_COMPRESSED_RGB: - /* intentional fall through */ - case 3: - case GL_RGB: - if ( srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5 ) { - return MESA_FORMAT_RGB565; - } - /* intentional fall through */ - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return (allow32bpt) ? MESA_FORMAT_ARGB8888 - : MESA_FORMAT_RGB565; - case GL_RGBA2: - case GL_RGBA4: - return MESA_FORMAT_ARGB4444; - case GL_COMPRESSED_RGBA: - /* intentional fall through */ - case 4: - case GL_RGBA: - if ( srcFormat == GL_BGRA ) { - if ( srcType == GL_UNSIGNED_INT_8_8_8_8_REV ) { - return MESA_FORMAT_ARGB8888; - } - else if ( srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ) { - return MESA_FORMAT_ARGB4444; - } - else if ( srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ) { - return MESA_FORMAT_ARGB1555; - } - } - /* intentional fall through */ - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return (allow32bpt) ? MESA_FORMAT_ARGB8888 - : MESA_FORMAT_ARGB4444; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_COMPRESSED_INTENSITY: - return MESA_FORMAT_I8; - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_COMPRESSED_LUMINANCE: - return MESA_FORMAT_L8; - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_COMPRESSED_ALPHA: - return MESA_FORMAT_A8; - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - return MESA_FORMAT_CI8; - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - case GL_COMPRESSED_LUMINANCE_ALPHA: - return MESA_FORMAT_AL88; - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - return MESA_FORMAT_RGB565; - case GL_RGB5_A1: - return MESA_FORMAT_ARGB1555; - /* GL_EXT_texture_compression_s3tc */ - /* GL_S3_s3tc */ - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - return MESA_FORMAT_RGB_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return MESA_FORMAT_RGBA_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - return MESA_FORMAT_RGBA_DXT3; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return MESA_FORMAT_RGBA_DXT5; - /* GL_3DFX_texture_compression_FXT1 */ - case GL_COMPRESSED_RGB_FXT1_3DFX: - return MESA_FORMAT_RGB_FXT1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return MESA_FORMAT_RGBA_FXT1; - default: - _mesa_problem(NULL, "unexpected format in fxDDChooseTextureFormat"); - return MESA_FORMAT_NONE; - } -} - - -static GrTextureFormat_t -fxGlideFormat(GLint mesaFormat) -{ - switch (mesaFormat) { - case MESA_FORMAT_I8: - return GR_TEXFMT_ALPHA_8; - case MESA_FORMAT_A8: - return GR_TEXFMT_ALPHA_8; - case MESA_FORMAT_L8: - return GR_TEXFMT_INTENSITY_8; - case MESA_FORMAT_CI8: - return GR_TEXFMT_P_8; - case MESA_FORMAT_AL88: - return GR_TEXFMT_ALPHA_INTENSITY_88; - case MESA_FORMAT_RGB565: - return GR_TEXFMT_RGB_565; - case MESA_FORMAT_ARGB4444: - return GR_TEXFMT_ARGB_4444; - case MESA_FORMAT_ARGB1555: - return GR_TEXFMT_ARGB_1555; - case MESA_FORMAT_ARGB8888: - return GR_TEXFMT_ARGB_8888; - case MESA_FORMAT_RGB_FXT1: - case MESA_FORMAT_RGBA_FXT1: - return GR_TEXFMT_ARGB_CMP_FXT1; - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_RGBA_DXT1: - return GR_TEXFMT_ARGB_CMP_DXT1; - case MESA_FORMAT_RGBA_DXT3: - return GR_TEXFMT_ARGB_CMP_DXT3; - case MESA_FORMAT_RGBA_DXT5: - return GR_TEXFMT_ARGB_CMP_DXT5; - default: - _mesa_problem(NULL, "Unexpected format in fxGlideFormat"); - return 0; - } -} - - -static FetchTexelFuncC -fxFetchFunction(GLint mesaFormat) -{ - switch (mesaFormat) { - case MESA_FORMAT_I8: - return &fetch_intensity8; - case MESA_FORMAT_A8: - return &fetch_alpha8; - case MESA_FORMAT_L8: - return &fetch_luminance8; - case MESA_FORMAT_CI8: - return &fetch_index8; - case MESA_FORMAT_AL88: - return &fetch_luminance8_alpha8; - case MESA_FORMAT_RGB565: - return &fetch_r5g6b5; - case MESA_FORMAT_ARGB4444: - return &fetch_r4g4b4a4; - case MESA_FORMAT_ARGB1555: - return &fetch_r5g5b5a1; - case MESA_FORMAT_ARGB8888: - return &fetch_a8r8g8b8; - case MESA_FORMAT_RGB_FXT1: - return &fetch_rgb_fxt1; - case MESA_FORMAT_RGBA_FXT1: - return &fetch_rgba_fxt1; - case MESA_FORMAT_RGB_DXT1: - return &fetch_rgb_dxt1; - case MESA_FORMAT_RGBA_DXT1: - return &fetch_rgba_dxt1; - case MESA_FORMAT_RGBA_DXT3: - return &fetch_rgba_dxt3; - case MESA_FORMAT_RGBA_DXT5: - return &fetch_rgba_dxt5; - default: - _mesa_problem(NULL, "Unexpected format in fxFetchFunction"); - return NULL; - } -} - - -static GLboolean -adjust2DRatio (GLcontext *ctx, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - tfxMipMapLevel *mml, - struct gl_texture_image *texImage, - GLint texelBytes, - GLint dstRowStride) -{ - const GLint newWidth = width * mml->wScale; - const GLint newHeight = height * mml->hScale; - GLvoid *tempImage; - - if (!_mesa_is_format_compressed(texImage->TexFormat)) { - GLubyte *destAddr; - - tempImage = MALLOC(width * height * texelBytes); - if (!tempImage) { - return GL_FALSE; - } - - _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, tempImage, - 0, 0, 0, /* dstX/Y/Zoffset */ - width * texelBytes, /* dstRowStride */ - 0, /* dstImageStride */ - width, height, 1, - format, type, pixels, packing); - - /* now rescale */ - /* compute address of dest subimage within the overal tex image */ - destAddr = (GLubyte *) texImage->Data - + (yoffset * mml->hScale * mml->width - + xoffset * mml->wScale) * texelBytes; - - _mesa_rescale_teximage2d(texelBytes, - width, - dstRowStride, /* dst stride */ - width, height, - newWidth, newHeight, - tempImage, destAddr); - } else { - const GLint rawBytes = 4; - GLvoid *rawImage = MALLOC(width * height * rawBytes); - - if (!rawImage) { - return GL_FALSE; - } - tempImage = MALLOC(newWidth * newHeight * rawBytes); - if (!tempImage) { - return GL_FALSE; - } - /* unpack image, apply transfer ops and store in rawImage */ - _mesa_texstore(ctx, 2, GL_RGBA, - &_mesa_texformat_rgba8888_rev, rawImage, - 0, 0, 0, /* dstX/Y/Zoffset */ - width * rawBytes, /* dstRowStride */ - 0, /* dstImageStride */ - width, height, 1, - format, type, pixels, packing); - _mesa_rescale_teximage2d(rawBytes, - width, - newWidth * rawBytes, /* dst stride */ - width, height, /* src */ - newWidth, newHeight, /* dst */ - rawImage /*src*/, tempImage /*dst*/ ); - _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, texImage->Data, - xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */ - dstRowStride, - 0, /* dstImageStride */ - newWidth, newHeight, 1, - GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking); - FREE(rawImage); - } - - FREE(tempImage); - - return GL_TRUE; -} - - -void -fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level, - GLint internalFormat, GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxTexInfo *ti; - tfxMipMapLevel *mml; - GLint texelBytes, dstRowStride; - - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxDDTexImage2D: id=%d int 0x%x format 0x%x type 0x%x %dx%d\n", - texObj->Name, texImage->InternalFormat, format, type, - texImage->Width, texImage->Height); - } - - if (!fxIsTexSupported(target, internalFormat, texImage)) { - _mesa_problem(NULL, "fx Driver: unsupported texture in fxDDTexImg()\n"); - return; - } - - if (!texObj->DriverData) { - texObj->DriverData = fxAllocTexObjData(fxMesa); - if (!texObj->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } - ti = fxTMGetTexInfo(texObj); - - if (!texImage->DriverData) { - texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel)); - if (!texImage->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } - mml = FX_MIPMAP_DATA(texImage); - - fxTexGetInfo(width, height, NULL, NULL, NULL, NULL, - &mml->wScale, &mml->hScale); - - mml->width = width * mml->wScale; - mml->height = height * mml->hScale; - -#if FX_COMPRESS_S3TC_AS_FXT1_HACK - /* [koolsmoky] substitute FXT1 for DXTn and Legacy S3TC */ - if (!ctx->Mesa_DXTn && _mesa_is_format_compressed(texImage->TexFormat)) { - switch (internalFormat) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - internalFormat = GL_COMPRESSED_RGB_FXT1_3DFX; - break; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - internalFormat = GL_COMPRESSED_RGBA_FXT1_3DFX; - } - texImage->InternalFormat = internalFormat; - } -#endif -#if FX_TC_NAPALM - if (fxMesa->type >= GR_SSTTYPE_Voodoo4) { - GLenum texNapalm = 0; - if (internalFormat == GL_COMPRESSED_RGB) { - texNapalm = GL_COMPRESSED_RGB_FXT1_3DFX; - } else if (internalFormat == GL_COMPRESSED_RGBA) { - texNapalm = GL_COMPRESSED_RGBA_FXT1_3DFX; - } - if (texNapalm) { - texImage->InternalFormat = internalFormat = texNapalm; - } - } -#endif - - texelBytes = _mesa_get_format_bytes(texImage->TexFormat->MesaFormat); - /*if (!fxMesa->HaveTexFmt) assert(texelBytes == 1 || texelBytes == 2);*/ - - mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat); - - /* allocate mipmap buffer */ - assert(!texImage->Data); - if (_mesa_is_format_compressed(texImage->TexFormat)) { - texImage->CompressedSize = _mesa_format_image_size(texImage->TexFormat, - mml->width, - mml->height, 1); - dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width); - texImage->Data = malloc(texImage->CompressedSize); - } else { - dstRowStride = mml->width * texelBytes; - texImage->Data = malloc(mml->width * mml->height * texelBytes); - } - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - - if (pixels != NULL) { - if (mml->wScale != 1 || mml->hScale != 1) { - /* rescale image to overcome 1:8 aspect limitation */ - if (!adjust2DRatio(ctx, - 0, 0, - width, height, - format, type, pixels, - packing, - mml, - texImage, - texelBytes, - dstRowStride) - ) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } - else { - /* no rescaling needed */ - /* unpack image, apply transfer ops and store in texImage->Data */ - _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - 0, /* dstImageStride */ - width, height, 1, - format, type, pixels, packing); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - GLint mipWidth, mipHeight; - tfxMipMapLevel *mip; - struct gl_texture_image *mipImage; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target); - - assert(!_mesa_is_format_compressed(texImage->TexFormat)); - - while (level < texObj->MaxLevel && level < maxLevels - 1) { - mipWidth = width / 2; - if (!mipWidth) { - mipWidth = 1; - } - mipHeight = height / 2; - if (!mipHeight) { - mipHeight = 1; - } - if ((mipWidth == width) && (mipHeight == height)) { - break; - } - _mesa_TexImage2D(target, ++level, internalFormat, - mipWidth, mipHeight, border, - format, type, - NULL); - mipImage = _mesa_select_tex_image(ctx, texUnit, target, level); - mip = FX_MIPMAP_DATA(mipImage); - _mesa_halve2x2_teximage2d(ctx, - texImage, - texelBytes, - mml->width, mml->height, - texImage->Data, mipImage->Data); - texImage = mipImage; - mml = mip; - width = mipWidth; - height = mipHeight; - } - } - } - - ti->info.format = mml->glideFormat; - texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat); - - fxTexInvalidate(ctx, texObj); -} - - -void -fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxTexInfo *ti; - tfxMipMapLevel *mml; - GLint texelBytes, dstRowStride; - - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxDDTexSubImage2D: id=%d\n", texObj->Name); - } - - if (!texObj->DriverData) { - _mesa_problem(ctx, "problem in fxDDTexSubImage2D"); - return; - } - - ti = fxTMGetTexInfo(texObj); - assert(ti); - mml = FX_MIPMAP_DATA(texImage); - assert(mml); - - assert(texImage->Data); /* must have an existing texture image! */ - assert(texImage->_BaseFormat); - - texelBytes = _mesa_get_format_bytes(texImage->TexFormat->MesaFormat); - if (_mesa_is_format_compressed(texImage->TexFormat)) { - dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width); - } else { - dstRowStride = mml->width * texelBytes; - } - - if (mml->wScale != 1 || mml->hScale != 1) { - /* need to rescale subimage to match mipmap level's rescale factors */ - if (!adjust2DRatio(ctx, - xoffset, yoffset, - width, height, - format, type, pixels, - packing, - mml, - texImage, - texelBytes, - dstRowStride) - ) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); - return; - } - } - else { - /* no rescaling needed */ - _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, (GLubyte *) texImage->Data, - xoffset, yoffset, 0, /* dstX/Y/Zoffset */ - dstRowStride, - 0, /* dstImageStride */ - width, height, 1, - format, type, pixels, packing); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - GLint mipWidth, mipHeight; - tfxMipMapLevel *mip; - struct gl_texture_image *mipImage; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target); - - assert(!_mesa_is_format_compressed(texImage->TexFormat)); - - width = texImage->Width; - height = texImage->Height; - while (level < texObj->MaxLevel && level < maxLevels - 1) { - mipWidth = width / 2; - if (!mipWidth) { - mipWidth = 1; - } - mipHeight = height / 2; - if (!mipHeight) { - mipHeight = 1; - } - if ((mipWidth == width) && (mipHeight == height)) { - break; - } - ++level; - mipImage = _mesa_select_tex_image(ctx, texUnit, target, level); - mip = FX_MIPMAP_DATA(mipImage); - _mesa_halve2x2_teximage2d(ctx, - texImage, - texelBytes, - mml->width, mml->height, - texImage->Data, mipImage->Data); - texImage = mipImage; - mml = mip; - width = mipWidth; - height = mipHeight; - } - } - - if (ti->validated && ti->isInTM && !texObj->GenerateMipmap) - fxTMReloadMipMapLevel(fxMesa, texObj, level); - else - fxTexInvalidate(ctx, texObj); -} - - -void -fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxTexInfo *ti; - tfxMipMapLevel *mml; - - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxDDCompressedTexImage2D: id=%d int 0x%x %dx%d\n", - texObj->Name, internalFormat, - width, height); - } - - assert(_mesa_is_format_compressed(texImage->TexFormat)); - - if (!fxIsTexSupported(target, internalFormat, texImage)) { - _mesa_problem(NULL, "fx Driver: unsupported texture in fxDDCompressedTexImg()\n"); - return; - } - - if (!texObj->DriverData) { - texObj->DriverData = fxAllocTexObjData(fxMesa); - if (!texObj->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - } - ti = fxTMGetTexInfo(texObj); - - if (!texImage->DriverData) { - texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel)); - if (!texImage->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - } - mml = FX_MIPMAP_DATA(texImage); - - fxTexGetInfo(width, height, NULL, NULL, NULL, NULL, - &mml->wScale, &mml->hScale); - - mml->width = width * mml->wScale; - mml->height = height * mml->hScale; - - /* Determine the appropriate Glide texel format, - * given the user's internal texture format hint. - */ - mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat); - - /* allocate new storage for texture image, if needed */ - if (!texImage->Data) { - texImage->CompressedSize = _mesa_format_image_size(texImage->TexFormat, - mml->width, - mml->height, 1); - texImage->Data = malloc(texImage->CompressedSize); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - } - - /* save the texture data */ - if (mml->wScale != 1 || mml->hScale != 1) { - /* [dBorca] Hack alert: - * now we're screwed. We can't decompress, - * unless we do it in HW (via textureBuffer). - * We still have some chances: - * 1) we got FXT1 textures - we CAN decompress, rescale for - * aspectratio, then compress back. - * 2) there is a chance that MIN("s", "t") won't be overflowed. - * Thus, we don't care about textureclamp and we could lower - * MIN("uscale", "vscale") below 32. We still have to have - * our data aligned inside a 8:1 rectangle. - * 3) just in case if MIN("s", "t") gets overflowed with GL_REPEAT, - * we replicate the data over the padded area. - * For now, we take 2) + 3) but texelfetchers will be wrong! - */ - GLuint srcRowStride = _mesa_format_row_stride(texImage->TexFormat, width); - - GLuint destRowStride = _mesa_format_row_stride(texImage->TexFormat, - mml->width); - - _mesa_upscale_teximage2d(srcRowStride, (height+3) / 4, - destRowStride, (mml->height+3) / 4, - 1, data, srcRowStride, - texImage->Data); - ti->padded = GL_TRUE; - } else { - memcpy(texImage->Data, data, texImage->CompressedSize); - } - - ti->info.format = mml->glideFormat; - texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat); - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - assert(!_mesa_is_format_compressed(texImage->TexFormat)); - } - - fxTexInvalidate(ctx, texObj); -} - - -void -fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target, - GLint level, GLint xoffset, - GLint yoffset, GLsizei width, - GLint height, GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxTexInfo *ti; - tfxMipMapLevel *mml; - GLint destRowStride, srcRowStride; - GLint i, rows; - GLubyte *dest; - - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxDDCompressedTexSubImage2D: id=%d\n", texObj->Name); - } - - ti = fxTMGetTexInfo(texObj); - assert(ti); - mml = FX_MIPMAP_DATA(texImage); - assert(mml); - - srcRowStride = _mesa_format_row_stride(texImage->TexFormat, width); - - destRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width); - dest = _mesa_compressed_image_address(xoffset, yoffset, 0, - texImage->InternalFormat, - mml->width, - (GLubyte*) texImage->Data); - - rows = height / 4; /* hardcoded 4, but works for FXT1/DXTC */ - - for (i = 0; i < rows; i++) { - memcpy(dest, data, srcRowStride); - dest += destRowStride; - data = (GLvoid *)((GLuint)data + (GLuint)srcRowStride); - } - - /* [dBorca] Hack alert: - * see fxDDCompressedTexImage2D for caveats - */ - if (mml->wScale != 1 || mml->hScale != 1) { - srcRowStride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width); - - destRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width); - _mesa_upscale_teximage2d(srcRowStride, texImage->Height / 4, - destRowStride, mml->height / 4, - 1, texImage->Data, destRowStride, - texImage->Data); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - assert(!_mesa_is_format_compressed(texImage->TexFormat)); - } - - if (ti->validated && ti->isInTM) - fxTMReloadMipMapLevel(fxMesa, texObj, level); - else - fxTexInvalidate(ctx, texObj); -} - - -void -fxDDTexImage1D (GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - fxDDTexImage2D(ctx, target, level, - internalFormat, width, 1, border, - format, type, pixels, - packing, - texObj, - texImage); -} - - -void -fxDDTexSubImage1D(GLcontext * ctx, GLenum target, GLint level, - GLint xoffset, - GLsizei width, - GLenum format, GLenum type, const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - fxDDTexSubImage2D(ctx, target, level, - xoffset, 0, width, 1, - format, type, pixels, - packing, - texObj, - texImage); -} - - -GLboolean -fxDDTestProxyTexImage (GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLint width, GLint height, - GLint depth, GLint border) -{ - /* XXX todo - maybe through fxTexValidate() */ - return _mesa_test_proxy_teximage(ctx, target, - level, internalFormat, - format, type, - width, height, - depth, border); -} - - -#else /* FX */ - -/* - * Need this to provide at least one external definition. - */ - -extern int gl_fx_dummy_function_ddtex(void); -int -gl_fx_dummy_function_ddtex(void) -{ - return 0; -} - -#endif /* FX */ diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h deleted file mode 100644 index bee10de2f4..0000000000 --- a/src/mesa/drivers/glide/fxdrv.h +++ /dev/null @@ -1,773 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * Copyright (C) 1999-2001 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. - */ - -/* Authors: - * David Bucciarelli - * Brian Paul - * Daryll Strauss - * Keith Whitwell - * Daniel Borca - * Hiroshi Morii - */ - -/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */ - - -#ifndef FXDRV_H -#define FXDRV_H - -/* If you comment out this define, a variable takes its place, letting - * you turn debugging on/off from the debugger. - */ - -#include "glheader.h" - - -#if defined(__linux__) -#include -#endif - -#include "main/context.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/matrix.h" -#include "main/mtypes.h" - -#include "GL/fxmesa.h" -#include "fxglidew.h" - -#include "math/m_vector.h" - - -#define COPY_FLOAT(dst, src) (dst) = (src) - -/* Define some shorter names for these things. - */ -#define XCOORD GR_VERTEX_X_OFFSET -#define YCOORD GR_VERTEX_Y_OFFSET -#define ZCOORD GR_VERTEX_OOZ_OFFSET -#define OOWCOORD GR_VERTEX_OOW_OFFSET - -#define S0COORD GR_VERTEX_SOW_TMU0_OFFSET -#define T0COORD GR_VERTEX_TOW_TMU0_OFFSET -#define S1COORD GR_VERTEX_SOW_TMU1_OFFSET -#define T1COORD GR_VERTEX_TOW_TMU1_OFFSET - - - -#ifdef __i386__ -#define FXCOLOR4( c ) (* (int *)c) -#else -#define FXCOLOR4( c ) ( \ - ( ((unsigned int)(c[3]))<<24 ) | \ - ( ((unsigned int)(c[2]))<<16 ) | \ - ( ((unsigned int)(c[1]))<<8 ) | \ - ( (unsigned int)(c[0])) ) -#endif - -#define TDFXPACKCOLOR1555( r, g, b, a ) \ - ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \ - ((a) ? 0x8000 : 0)) -#define TDFXPACKCOLOR565( r, g, b ) \ - ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3)) -#define TDFXPACKCOLOR8888( r, g, b, a ) \ - (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - - - -/* fastpath flags first - */ -#define SETUP_TMU0 0x1 -#define SETUP_TMU1 0x2 -#define SETUP_RGBA 0x4 -#define SETUP_SNAP 0x8 -#define SETUP_XYZW 0x10 -#define SETUP_PTEX 0x20 -#define SETUP_PSIZ 0x40 -#define SETUP_SPEC 0x80 -#define SETUP_FOGC 0x100 -#define MAX_SETUP 0x200 - - -#define FX_NUM_TMU 2 - -#define FX_TMU0 GR_TMU0 -#define FX_TMU1 GR_TMU1 -#define FX_TMU_SPLIT 98 -#define FX_TMU_BOTH 99 -#define FX_TMU_NONE 100 - -/* Used for fxMesa->lastUnitsMode */ - -#define FX_UM_NONE 0x00000000 - -#define FX_UM_E0_REPLACE 0x00000001 -#define FX_UM_E0_MODULATE 0x00000002 -#define FX_UM_E0_DECAL 0x00000004 -#define FX_UM_E0_BLEND 0x00000008 -#define FX_UM_E0_ADD 0x00000010 - -#define FX_UM_E1_REPLACE 0x00000020 -#define FX_UM_E1_MODULATE 0x00000040 -#define FX_UM_E1_DECAL 0x00000080 -#define FX_UM_E1_BLEND 0x00000100 -#define FX_UM_E1_ADD 0x00000200 - -#define FX_UM_E_ENVMODE 0x000003ff - -#define FX_UM_E0_ALPHA 0x00001000 -#define FX_UM_E0_LUMINANCE 0x00002000 -#define FX_UM_E0_LUMINANCE_ALPHA 0x00004000 -#define FX_UM_E0_INTENSITY 0x00008000 -#define FX_UM_E0_RGB 0x00010000 -#define FX_UM_E0_RGBA 0x00020000 - -#define FX_UM_E1_ALPHA 0x00040000 -#define FX_UM_E1_LUMINANCE 0x00080000 -#define FX_UM_E1_LUMINANCE_ALPHA 0x00100000 -#define FX_UM_E1_INTENSITY 0x00200000 -#define FX_UM_E1_RGB 0x00400000 -#define FX_UM_E1_RGBA 0x00800000 - -#define FX_UM_E_IFMT 0x00fff000 - -#define FX_UM_COLOR_ITERATED 0x01000000 -#define FX_UM_COLOR_CONSTANT 0x02000000 -#define FX_UM_ALPHA_ITERATED 0x04000000 -#define FX_UM_ALPHA_CONSTANT 0x08000000 - - -/* for Voodoo3/Banshee's grColorCombine() and grAlphaCombine() */ -struct tdfx_combine { - GrCombineFunction_t Function; /* Combine function */ - GrCombineFactor_t Factor; /* Combine scale factor */ - GrCombineLocal_t Local; /* Local combine source */ - GrCombineOther_t Other; /* Other combine source */ - FxBool Invert; /* Combine result inversion flag */ -}; - -/* for Voodoo3's grTexCombine() */ -struct tdfx_texcombine { - GrCombineFunction_t FunctionRGB; - GrCombineFactor_t FactorRGB; - GrCombineFunction_t FunctionAlpha; - GrCombineFactor_t FactorAlpha; - FxBool InvertRGB; - FxBool InvertAlpha; -}; - - -/* for Voodoo5's grColorCombineExt() */ -struct tdfx_combine_color_ext { - GrCCUColor_t SourceA; - GrCombineMode_t ModeA; - GrCCUColor_t SourceB; - GrCombineMode_t ModeB; - GrCCUColor_t SourceC; - FxBool InvertC; - GrCCUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* for Voodoo5's grAlphaCombineExt() */ -struct tdfx_combine_alpha_ext { - GrACUColor_t SourceA; - GrCombineMode_t ModeA; - GrACUColor_t SourceB; - GrCombineMode_t ModeB; - GrACUColor_t SourceC; - FxBool InvertC; - GrACUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* for Voodoo5's grTexColorCombineExt() */ -struct tdfx_color_texenv { - GrTCCUColor_t SourceA; - GrCombineMode_t ModeA; - GrTCCUColor_t SourceB; - GrCombineMode_t ModeB; - GrTCCUColor_t SourceC; - FxBool InvertC; - GrTCCUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* for Voodoo5's grTexAlphaCombineExt() */ -struct tdfx_alpha_texenv { - GrTACUColor_t SourceA; - GrCombineMode_t ModeA; - GrTACUColor_t SourceB; - GrCombineMode_t ModeB; - GrTACUColor_t SourceC; - FxBool InvertC; - GrTCCUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* Voodoo5's texture combine environment */ -struct tdfx_texcombine_ext { - struct tdfx_alpha_texenv Alpha; - struct tdfx_color_texenv Color; - GrColor_t EnvColor; -}; - - -/* - Memory range from startAddr to endAddr-1 -*/ -typedef struct MemRange_t -{ - struct MemRange_t *next; - FxU32 startAddr, endAddr; -} -MemRange; - -typedef struct -{ - GLsizei width, height; /* image size */ - GLint wScale, hScale; /* image scale factor */ - GrTextureFormat_t glideFormat; /* Glide image format */ -} -tfxMipMapLevel; - -/* - * TDFX-specific texture object data. This hangs off of the - * struct gl_texture_object DriverData pointer. - */ -typedef struct tfxTexInfo_t -{ - struct tfxTexInfo_t *next; - struct gl_texture_object *tObj; - - GLuint lastTimeUsed; - FxU32 whichTMU; - GLboolean isInTM; - - MemRange *tm[FX_NUM_TMU]; - - GLint minLevel, maxLevel; - GLint baseLevelInternalFormat; - - GrTexInfo info; - - GrTextureFilterMode_t minFilt; - GrTextureFilterMode_t maxFilt; - FxBool LODblend; - - GrTextureClampMode_t sClamp; - GrTextureClampMode_t tClamp; - - GrMipMapMode_t mmMode; - - GLfloat sScale, tScale; - - GrTexTable_t paltype; - GuTexPalette palette; - - GLboolean fixedPalette; - GLboolean validated; - - GLboolean padded; -} -tfxTexInfo; - -typedef struct -{ - GLuint swapBuffer; - GLuint reqTexUpload; - GLuint texUpload; - GLuint memTexUpload; -} -tfxStats; - - - -typedef struct -{ - /* Alpha test */ - - GLboolean alphaTestEnabled; - GrCmpFnc_t alphaTestFunc; - GLfloat alphaTestRefValue; - - /* Blend function */ - - GLboolean blendEnabled; - GrAlphaBlendFnc_t blendSrcFuncRGB; - GrAlphaBlendFnc_t blendDstFuncRGB; - GrAlphaBlendFnc_t blendSrcFuncAlpha; - GrAlphaBlendFnc_t blendDstFuncAlpha; - GrAlphaBlendOp_t blendEqRGB; - GrAlphaBlendOp_t blendEqAlpha; - - /* Depth test */ - - GLboolean depthTestEnabled; - GLboolean depthMask; - GrCmpFnc_t depthTestFunc; - FxI32 depthBias; - - /* Stencil */ - - GLboolean stencilEnabled; - GrCmpFnc_t stencilFunction; /* Stencil function */ - GrStencil_t stencilRefValue; /* Stencil reference value */ - GrStencil_t stencilValueMask; /* Value mask */ - GrStencil_t stencilWriteMask; /* Write mask */ - GrCmpFnc_t stencilFailFunc; /* Stencil fail function */ - GrCmpFnc_t stencilZFailFunc; /* Stencil pass, depth fail function */ - GrCmpFnc_t stencilZPassFunc; /* Stencil pass, depth pass function */ - GrStencil_t stencilClear; /* Buffer clear value */ -} -tfxUnitsState; - - - - -/* Flags for fxMesa->new_state - */ -#define FX_NEW_TEXTURING 0x1 -#define FX_NEW_BLEND 0x2 -#define FX_NEW_ALPHA 0x4 -#define FX_NEW_DEPTH 0x8 -#define FX_NEW_FOG 0x10 -#define FX_NEW_SCISSOR 0x20 -#define FX_NEW_COLOR_MASK 0x40 -#define FX_NEW_CULL 0x80 -#define FX_NEW_STENCIL 0x100 - - -#define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx)) - -#define FX_TEXTURE_DATA(texUnit) fxTMGetTexInfo((texUnit)->_Current) - -#define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData)) - -#define FX_MIPMAP_DATA(img) ((tfxMipMapLevel *) (img)->DriverData) - -#define BEGIN_BOARD_LOCK() -#define END_BOARD_LOCK() -#define BEGIN_CLIP_LOOP() -#define END_CLIP_LOOP() - - - - -/* Covers the state referenced by IsInHardware: - */ -#define _FX_NEW_IS_IN_HARDWARE (_NEW_TEXTURE| \ - _NEW_HINT| \ - _NEW_STENCIL| \ - _NEW_BUFFERS| \ - _NEW_COLOR| \ - _NEW_LIGHT) - -/* Covers the state referenced by fxDDChooseRenderState - */ -#define _FX_NEW_RENDERSTATE (_FX_NEW_IS_IN_HARDWARE | \ - _DD_NEW_FLATSHADE | \ - _DD_NEW_TRI_LIGHT_TWOSIDE| \ - _DD_NEW_TRI_OFFSET | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_SMOOTH | \ - _DD_NEW_TRI_STIPPLE | \ - _DD_NEW_LINE_SMOOTH | \ - _DD_NEW_LINE_STIPPLE | \ - _DD_NEW_LINE_WIDTH | \ - _DD_NEW_POINT_SMOOTH | \ - _DD_NEW_POINT_SIZE | \ - _NEW_LINE) - - -/* Covers the state referenced by fxDDChooseSetupFunction. - */ -#define _FX_NEW_SETUP_FUNCTION (_NEW_LIGHT| \ - _NEW_FOG| \ - _NEW_TEXTURE| \ - _NEW_COLOR) \ - - -/* lookup table for scaling y bit colors up to 8 bits */ -extern GLuint FX_rgb_scale_4[16]; -extern GLuint FX_rgb_scale_5[32]; -extern GLuint FX_rgb_scale_6[64]; - -typedef void (*fx_tri_func) (fxMesaContext, GrVertex *, GrVertex *, GrVertex *); -typedef void (*fx_line_func) (fxMesaContext, GrVertex *, GrVertex *); -typedef void (*fx_point_func) (fxMesaContext, GrVertex *); - -struct tfxMesaContext -{ - GrTexTable_t glbPalType; - GuTexPalette glbPalette; - - GLcontext *glCtx; /* the core Mesa context */ - GLvisual *glVis; /* describes the color buffer */ - GLframebuffer *glBuffer; /* the ancillary buffers */ - - GLint board; /* the board used for this context */ - GLint width, height; /* size of color buffer */ - - GrBuffer_t currentFB; - - GLboolean bgrOrder; - GrColor_t color; - GrColor_t clearC; - GrAlpha_t clearA; - GLuint constColor; - GrCullMode_t cullMode; - - tfxUnitsState unitsState; - tfxUnitsState restoreUnitsState; /* saved during multipass */ - GLboolean multipass; /* true when drawing intermediate pass */ - - GLuint new_state; - GLuint new_gl_state; - - /* Texture Memory Manager Data - */ - GLuint texBindNumber; - GLint tmuSrc; - GLuint lastUnitsMode; - GLuint freeTexMem[FX_NUM_TMU]; - MemRange *tmPool; - MemRange *tmFree[FX_NUM_TMU]; - - GLenum fogTableMode; - GLfloat fogDensity; - GLfloat fogStart, fogEnd; - GrFog_t *fogTable; - GLint textureAlign; - GLint textureMaxLod; - - /* Vertex building and storage: - */ - GLuint tmu_source[FX_NUM_TMU]; - GLuint SetupIndex; - GLuint stw_hint_state; /* for grHints */ - GrVertex *verts; - GLboolean snapVertices; /* needed for older Voodoo hardware */ - - /* Rasterization: - */ - GLuint render_index; - GLuint fallback; - GLenum render_primitive; - GLenum raster_primitive; - - /* Current rasterization functions - */ - fx_point_func draw_point; - fx_line_func draw_line; - fx_tri_func draw_tri; - - - /* Keep texture scales somewhere handy: - */ - GLfloat s0scale; - GLfloat s1scale; - GLfloat t0scale; - GLfloat t1scale; - - GLfloat inv_s0scale; - GLfloat inv_s1scale; - GLfloat inv_t0scale; - GLfloat inv_t1scale; - - /* Glide stuff - */ - tfxStats stats; - void *state; - - /* Options */ - - GLboolean verbose; - GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */ - GLboolean haveHwAlpha; - GLboolean haveHwStencil; - GLboolean haveZBuffer; - GLboolean haveDoubleBuffer; - GLboolean haveGlobalPaletteTexture; - GLint swapInterval; - GLint maxPendingSwapBuffers; - - GrContext_t glideContext; - - int screen_width; - int screen_height; - int clipMinX; - int clipMaxX; - int clipMinY; - int clipMaxY; - - int colDepth; - GLboolean fsaa; - - /* Glide (per card) capabilities. These get mirrored - * from `glbHWConfig' when creating a new context... - */ - GrSstType type; - FxBool HavePalExt; /* PALETTE6666 */ - FxBool HavePixExt; /* PIXEXT */ - FxBool HaveTexFmt; /* TEXFMT */ - FxBool HaveCmbExt; /* COMBINE */ - FxBool HaveMirExt; /* TEXMIRROR */ - FxBool HaveTexUma; /* TEXUMA */ - FxBool HaveTexus2; /* Texus 2 - FXT1 */ - struct tdfx_glide Glide; - char rendererString[64]; -}; - - -extern void fxSetupFXUnits(GLcontext *); -extern void fxSetupDDPointers(GLcontext *); - -/* fxvb.c: - */ -extern void fxAllocVB(GLcontext * ctx); -extern void fxFreeVB(GLcontext * ctx); -extern void fxPrintSetupFlags(char *msg, GLuint flags ); -extern void fxCheckTexSizes( GLcontext *ctx ); -extern void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint end, - GLuint newinputs ); -extern void fxChooseVertexState( GLcontext *ctx ); - - - - - - -/* fxtrifuncs: - */ -extern void fxDDInitTriFuncs(GLcontext *); -extern void fxDDChooseRenderState(GLcontext * ctx); - - -extern void fxUpdateDDSpanPointers(GLcontext *); -extern void fxSetupDDSpanPointers(GLcontext *); - -extern void fxPrintTextureData(tfxTexInfo * ti); - -extern const struct gl_texture_format * -fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat, - GLenum srcFormat, GLenum srcType ); -extern void fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level, - GLint internalFormat, GLint width, GLint height, - GLint border, GLenum format, GLenum type, - const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); -extern void fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); -extern void fxDDCompressedTexImage2D(GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); -extern void fxDDCompressedTexSubImage2D(GLcontext *ctx, GLenum target, - GLint level, GLint xoffset, - GLint yoffset, GLsizei width, - GLint height, GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); -extern void fxDDTexImage1D(GLcontext * ctx, GLenum target, GLint level, - GLint internalFormat, GLint width, - GLint border, GLenum format, GLenum type, - const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); -extern void fxDDTexSubImage1D(GLcontext * ctx, GLenum target, GLint level, - GLint xoffset, GLint width, - GLenum format, GLenum type, - const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); -extern GLboolean fxDDTestProxyTexImage (GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLint width, GLint height, - GLint depth, GLint border); -extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *); -extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *, - GLenum, const GLfloat *); -extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *); -extern struct gl_texture_object *fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target ); -extern void fxDDTexDel(GLcontext *, struct gl_texture_object *); -extern GLboolean fxDDIsTextureResident(GLcontext *, struct gl_texture_object *); -extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *); -extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean); - -extern void fxDDEnable(GLcontext *, GLenum, GLboolean); -extern void fxDDAlphaFunc(GLcontext *, GLenum, GLfloat); -extern void fxDDBlendFuncSeparate(GLcontext *, GLenum, GLenum, GLenum, GLenum); -extern void fxDDBlendEquationSeparate(GLcontext *, GLenum, GLenum); -extern void fxDDDepthMask(GLcontext *, GLboolean); -extern void fxDDDepthFunc(GLcontext *, GLenum); -extern void fxDDStencilFuncSeparate (GLcontext *ctx, GLenum face, GLenum func, GLint ref, GLuint mask); -extern void fxDDStencilMaskSeparate (GLcontext *ctx, GLenum face, GLuint mask); -extern void fxDDStencilOpSeparate (GLcontext *ctx, GLenum face, GLenum sfail, GLenum zfail, GLenum zpass); - -extern void fxDDInitExtensions(GLcontext * ctx); - -extern void fxTMInit(fxMesaContext ctx); -extern void fxTMClose(fxMesaContext ctx); -extern void fxTMRestoreTextures_NoLock(fxMesaContext ctx); -extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint); -extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *); -#define fxTMMoveOutTM_NoLock fxTMMoveOutTM -extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *); -extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *, - GLint); -extern void fxTMReloadSubMipMapLevel(fxMesaContext, - struct gl_texture_object *, GLint, GLint, - GLint); -extern int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti); - -extern void fxTexGetFormat(GLcontext *, GLenum, GrTextureFormat_t *, GLint *); /* [koolsmoky] */ - -extern int fxTexGetInfo(int, int, GrLOD_t *, GrAspectRatio_t *, - float *, float *, int *, int *); - -extern void fxDDScissor(GLcontext * ctx, - GLint x, GLint y, GLsizei w, GLsizei h); -extern void fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params); -extern void fxDDColorMask(GLcontext * ctx, - GLboolean r, GLboolean g, GLboolean b, GLboolean a); - -extern void fxDDWriteDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y, - const GLuint depth[], const GLubyte mask[]); - -extern void fxDDReadDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y, - GLuint depth[]); - -extern void fxDDWriteDepthPixels(GLcontext * ctx, GLuint n, - const GLint x[], const GLint y[], - const GLuint depth[], const GLubyte mask[]); - -extern void fxDDReadDepthPixels(GLcontext * ctx, GLuint n, - const GLint x[], const GLint y[], - GLuint depth[]); - -extern void fxDDShadeModel(GLcontext * ctx, GLenum mode); - -extern void fxDDCullFace(GLcontext * ctx, GLenum mode); -extern void fxDDFrontFace(GLcontext * ctx, GLenum mode); - -extern void fxPrintRenderState(const char *msg, GLuint state); -extern void fxPrintHintState(const char *msg, GLuint state); - -extern int fxDDInitFxMesaContext(fxMesaContext fxMesa); -extern void fxDDDestroyFxMesaContext(fxMesaContext fxMesa); - - -extern void fxSetScissorValues(GLcontext * ctx); -extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa, - struct gl_texture_object *tObj, GLint where); - -extern void fxCheckIsInHardware(GLcontext *ctx); - -/* fxsetup: - * semi-private functions - */ -void fxSetupCull (GLcontext * ctx); -void fxSetupScissor (GLcontext * ctx); -void fxSetupColorMask (GLcontext * ctx); -void fxSetupBlend (GLcontext *ctx); -void fxSetupDepthTest (GLcontext *ctx); -void fxSetupTexture (GLcontext *ctx); -void fxSetupStencil (GLcontext *ctx); -void fxSetupStencilFace (GLcontext *ctx, GLint face); - -/* Flags for software fallback cases */ -#define FX_FALLBACK_TEXTURE_MAP 0x0001 -#define FX_FALLBACK_DRAW_BUFFER 0x0002 -#define FX_FALLBACK_SPECULAR 0x0004 -#define FX_FALLBACK_STENCIL 0x0008 -#define FX_FALLBACK_RENDER_MODE 0x0010 -#define FX_FALLBACK_LOGICOP 0x0020 -#define FX_FALLBACK_TEXTURE_ENV 0x0040 -#define FX_FALLBACK_TEXTURE_BORDER 0x0080 -#define FX_FALLBACK_COLORMASK 0x0100 -#define FX_FALLBACK_BLEND 0x0200 -#define FX_FALLBACK_TEXTURE_MULTI 0x0400 - -extern GLuint fx_check_IsInHardware(GLcontext *ctx); - -/*** - *** CNORM: clamp float to [0,1] and map to float in [0,255] - ***/ -#if defined(USE_IEEE) && !defined(DEBUG) -#define IEEE_0996 0x3f7f0000 /* 0.996 or so */ -#define CNORM(N, F) \ - do { \ - fi_type __tmp; \ - __tmp.f = (F); \ - if (__tmp.i < 0) \ - N = 0; \ - else if (__tmp.i >= IEEE_0996) \ - N = 255.0f; \ - else { \ - N = (F) * 255.0f; \ - } \ - } while (0) -#else -#define CNORM(n, f) \ - n = (CLAMP((f), 0.0F, 1.0F) * 255.0F) -#endif - -/* run-time debugging */ -#ifndef FX_DEBUG -#define FX_DEBUG 0 -#endif -#if FX_DEBUG -extern int TDFX_DEBUG; -#else -#define TDFX_DEBUG 0 -#endif - -/* dirty hacks */ -#define FX_RESCALE_BIG_TEXURES_HACK 1 -#define FX_COMPRESS_S3TC_AS_FXT1_HACK 1 - -#endif diff --git a/src/mesa/drivers/glide/fxg.c b/src/mesa/drivers/glide/fxg.c deleted file mode 100644 index afb9441ade..0000000000 --- a/src/mesa/drivers/glide/fxg.c +++ /dev/null @@ -1,2309 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.0.1 - * - * Copyright (C) 1999-2003 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. - */ - -/* - * Mesa/FX device driver. Interface to Glide3. - * - * Copyright (c) 2003 - Daniel Borca - * Email : dborca@users.sourceforge.net - * Web : http://www.geocities.com/dborca - */ - - -#ifdef FX - -#include -#include -#include -#include - -#define FX_TRAP_GLIDE_internal -#include "fxg.h" - - - -/****************************************************************************\ -* logging * -\****************************************************************************/ -#if FX_TRAP_GLIDE -#define TRAP_LOG trp_printf -#ifdef __GNUC__ -__attribute__ ((format(printf, 1, 2))) -#endif /* __GNUC__ */ -int trp_printf (const char *format, ...) -{ - va_list arg; - int n; - FILE *trap_file; - va_start(arg, format); - trap_file = fopen("trap.log", "a"); - if (trap_file == NULL) { - trap_file = stderr; - } - n = vfprintf(trap_file, format, arg); - fclose(trap_file); - va_end(arg); - return n; -} -#else /* FX_TRAP_GLIDE */ -#ifdef __GNUC__ -#define TRAP_LOG(format, ...) do {} while (0) -#else /* __GNUC__ */ -#define TRAP_LOG 0 && (unsigned long) -#endif /* __GNUC__ */ -#endif /* FX_TRAP_GLIDE */ - - - -#if FX_TRAP_GLIDE -/****************************************************************************\ -* helpers * -\****************************************************************************/ - -#define GOT "\t" - -const char *TRP_BOOL (FxBool b) -{ - return b ? "FXTRUE" : "FXFALSE"; -} - -#define TRAP_CASE_STRING(name) case name: return #name -#define TRAP_NODEFAULT default: assert(0) - -const char *TRP_PARAM (FxU32 mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_PARAM_DISABLE); - TRAP_CASE_STRING(GR_PARAM_ENABLE); - TRAP_NODEFAULT; - } -} - -const char *TRP_VTX (FxU32 param) -{ - switch (param) { - TRAP_CASE_STRING(GR_PARAM_XY); - TRAP_CASE_STRING(GR_PARAM_Z); - TRAP_CASE_STRING(GR_PARAM_W); - TRAP_CASE_STRING(GR_PARAM_Q); - TRAP_CASE_STRING(GR_PARAM_FOG_EXT); - TRAP_CASE_STRING(GR_PARAM_A); - TRAP_CASE_STRING(GR_PARAM_RGB); - TRAP_CASE_STRING(GR_PARAM_PARGB); - TRAP_CASE_STRING(GR_PARAM_ST0); - TRAP_CASE_STRING(GR_PARAM_ST1); - TRAP_CASE_STRING(GR_PARAM_ST2); - TRAP_CASE_STRING(GR_PARAM_Q0); - TRAP_CASE_STRING(GR_PARAM_Q1); - TRAP_CASE_STRING(GR_PARAM_Q2); - TRAP_NODEFAULT; - } -} - -const char *TRP_ARRAY (FxU32 mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_POINTS); - TRAP_CASE_STRING(GR_LINE_STRIP); - TRAP_CASE_STRING(GR_LINES); - TRAP_CASE_STRING(GR_POLYGON); - TRAP_CASE_STRING(GR_TRIANGLE_STRIP); - TRAP_CASE_STRING(GR_TRIANGLE_FAN); - TRAP_CASE_STRING(GR_TRIANGLES); - TRAP_CASE_STRING(GR_TRIANGLE_STRIP_CONTINUE); - TRAP_CASE_STRING(GR_TRIANGLE_FAN_CONTINUE); - TRAP_NODEFAULT; - } -} - -const char *TRP_BUFFER (GrBuffer_t buffer) -{ - switch (buffer) { - TRAP_CASE_STRING(GR_BUFFER_FRONTBUFFER); - TRAP_CASE_STRING(GR_BUFFER_BACKBUFFER); - TRAP_CASE_STRING(GR_BUFFER_AUXBUFFER); - TRAP_CASE_STRING(GR_BUFFER_DEPTHBUFFER); - TRAP_CASE_STRING(GR_BUFFER_ALPHABUFFER); - TRAP_CASE_STRING(GR_BUFFER_TRIPLEBUFFER); - TRAP_CASE_STRING(GR_BUFFER_TEXTUREBUFFER_EXT); - TRAP_CASE_STRING(GR_BUFFER_TEXTUREAUXBUFFER_EXT); - TRAP_NODEFAULT; - } -} - -const char *TRP_ORIGIN (GrOriginLocation_t origin_location) -{ - switch (origin_location) { - TRAP_CASE_STRING(GR_ORIGIN_UPPER_LEFT); - TRAP_CASE_STRING(GR_ORIGIN_LOWER_LEFT); - TRAP_CASE_STRING(GR_ORIGIN_ANY); - TRAP_NODEFAULT; - } -} - -const char *TRP_REFRESH (GrScreenRefresh_t refresh_rate) -{ - switch (refresh_rate) { - TRAP_CASE_STRING(GR_REFRESH_60Hz); - TRAP_CASE_STRING(GR_REFRESH_70Hz); - TRAP_CASE_STRING(GR_REFRESH_72Hz); - TRAP_CASE_STRING(GR_REFRESH_75Hz); - TRAP_CASE_STRING(GR_REFRESH_80Hz); - TRAP_CASE_STRING(GR_REFRESH_90Hz); - TRAP_CASE_STRING(GR_REFRESH_100Hz); - TRAP_CASE_STRING(GR_REFRESH_85Hz); - TRAP_CASE_STRING(GR_REFRESH_120Hz); - TRAP_CASE_STRING(GR_REFRESH_NONE); - TRAP_NODEFAULT; - } -} - -const char *TRP_COLFMT (GrColorFormat_t color_format) -{ - switch (color_format) { - TRAP_CASE_STRING(GR_COLORFORMAT_ARGB); - TRAP_CASE_STRING(GR_COLORFORMAT_ABGR); - TRAP_CASE_STRING(GR_COLORFORMAT_RGBA); - TRAP_CASE_STRING(GR_COLORFORMAT_BGRA); - TRAP_NODEFAULT; - } -} - -const char *TRP_RESOLUTION (GrScreenResolution_t screen_resolution) -{ - switch (screen_resolution) { - TRAP_CASE_STRING(GR_RESOLUTION_320x200); - TRAP_CASE_STRING(GR_RESOLUTION_320x240); - TRAP_CASE_STRING(GR_RESOLUTION_400x256); - TRAP_CASE_STRING(GR_RESOLUTION_512x384); - TRAP_CASE_STRING(GR_RESOLUTION_640x200); - TRAP_CASE_STRING(GR_RESOLUTION_640x350); - TRAP_CASE_STRING(GR_RESOLUTION_640x400); - TRAP_CASE_STRING(GR_RESOLUTION_640x480); - TRAP_CASE_STRING(GR_RESOLUTION_800x600); - TRAP_CASE_STRING(GR_RESOLUTION_960x720); - TRAP_CASE_STRING(GR_RESOLUTION_856x480); - TRAP_CASE_STRING(GR_RESOLUTION_512x256); - TRAP_CASE_STRING(GR_RESOLUTION_1024x768); - TRAP_CASE_STRING(GR_RESOLUTION_1280x1024); - TRAP_CASE_STRING(GR_RESOLUTION_1600x1200); - TRAP_CASE_STRING(GR_RESOLUTION_400x300); - TRAP_CASE_STRING(GR_RESOLUTION_1152x864); - TRAP_CASE_STRING(GR_RESOLUTION_1280x960); - TRAP_CASE_STRING(GR_RESOLUTION_1600x1024); - TRAP_CASE_STRING(GR_RESOLUTION_1792x1344); - TRAP_CASE_STRING(GR_RESOLUTION_1856x1392); - TRAP_CASE_STRING(GR_RESOLUTION_1920x1440); - TRAP_CASE_STRING(GR_RESOLUTION_2048x1536); - TRAP_CASE_STRING(GR_RESOLUTION_2048x2048); - TRAP_CASE_STRING(GR_RESOLUTION_NONE); - TRAP_NODEFAULT; - } -} - -const char *TRP_BLEND (GrAlphaBlendFnc_t func) -{ - switch (func) { - TRAP_CASE_STRING(GR_BLEND_ZERO); - TRAP_CASE_STRING(GR_BLEND_SRC_ALPHA); - TRAP_CASE_STRING(GR_BLEND_SRC_COLOR); - /*TRAP_CASE_STRING(GR_BLEND_DST_COLOR); ==GR_BLEND_SRC_COLOR*/ - TRAP_CASE_STRING(GR_BLEND_DST_ALPHA); - TRAP_CASE_STRING(GR_BLEND_ONE); - TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_SRC_ALPHA); - TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_SRC_COLOR); - /*TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_DST_COLOR); ==GR_BLEND_ONE_MINUS_SRC_COLOR*/ - TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_DST_ALPHA); - TRAP_CASE_STRING(GR_BLEND_SAME_COLOR_EXT); - /*TRAP_CASE_STRING(GR_BLEND_RESERVED_8); ==GR_BLEND_SAME_COLOR_EXT*/ - TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_SAME_COLOR_EXT); - /*TRAP_CASE_STRING(GR_BLEND_RESERVED_9); ==GR_BLEND_ONE_MINUS_SAME_COLOR_EXT*/ - TRAP_CASE_STRING(GR_BLEND_RESERVED_A); - TRAP_CASE_STRING(GR_BLEND_RESERVED_B); - TRAP_CASE_STRING(GR_BLEND_RESERVED_C); - TRAP_CASE_STRING(GR_BLEND_RESERVED_D); - TRAP_CASE_STRING(GR_BLEND_RESERVED_E); - TRAP_CASE_STRING(GR_BLEND_ALPHA_SATURATE); - /*TRAP_CASE_STRING(GR_BLEND_PREFOG_COLOR); ==GR_BLEND_ALPHA_SATURATE*/ - TRAP_NODEFAULT; - } -} - -const char *TRP_CMBFUNC (GrCombineFunction_t cfunc) -{ - switch (cfunc) { - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_ZERO); - /*TRAP_CASE_STRING(GR_COMBINE_FUNCTION_NONE); ==GR_COMBINE_FUNCTION_ZERO*/ - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_LOCAL); - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_LOCAL_ALPHA); - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER); - /*TRAP_CASE_STRING(GR_COMBINE_FUNCTION_BLEND_OTHER); ==GR_COMBINE_FUNCTION_SCALE_OTHER*/ - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL); - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA); - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL); - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL); - /*TRAP_CASE_STRING(GR_COMBINE_FUNCTION_BLEND); ==GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL*/ - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA); - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL); - /*TRAP_CASE_STRING(GR_COMBINE_FUNCTION_BLEND_LOCAL); ==GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL*/ - TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA); - TRAP_NODEFAULT; - } -} - -const char *TRP_CMBFACT (GrCombineFactor_t cfactor) -{ - switch (cfactor) { - TRAP_CASE_STRING(GR_COMBINE_FACTOR_ZERO); - /*TRAP_CASE_STRING(GR_COMBINE_FACTOR_NONE); ==GR_COMBINE_FACTOR_ZERO*/ - TRAP_CASE_STRING(GR_COMBINE_FACTOR_LOCAL); - TRAP_CASE_STRING(GR_COMBINE_FACTOR_OTHER_ALPHA); - TRAP_CASE_STRING(GR_COMBINE_FACTOR_LOCAL_ALPHA); - TRAP_CASE_STRING(GR_COMBINE_FACTOR_TEXTURE_ALPHA); - TRAP_CASE_STRING(GR_COMBINE_FACTOR_TEXTURE_RGB); - /*TRAP_CASE_STRING(GR_COMBINE_FACTOR_DETAIL_FACTOR); ==GR_COMBINE_FACTOR_TEXTURE_ALPHA*/ - /*TRAP_CASE_STRING(GR_COMBINE_FACTOR_LOD_FRACTION); ==GR_COMBINE_FACTOR_TEXTURE_RGB ???*/ - TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE); - TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_LOCAL); - TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_OTHER_ALPHA); - TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_LOCAL_ALPHA); - TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA); - /*TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR); ==GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA*/ - TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION); - TRAP_NODEFAULT; - } -} - -const char *TRP_CMBLOCAL (GrCombineLocal_t clocal) -{ - switch (clocal) { - TRAP_CASE_STRING(GR_COMBINE_LOCAL_ITERATED); - TRAP_CASE_STRING(GR_COMBINE_LOCAL_CONSTANT); - /*TRAP_CASE_STRING(GR_COMBINE_LOCAL_NONE); ==GR_COMBINE_LOCAL_CONSTANT*/ - TRAP_CASE_STRING(GR_COMBINE_LOCAL_DEPTH); - TRAP_NODEFAULT; - } -} - -const char *TRP_CMBOTHER (GrCombineOther_t cother) -{ - switch (cother) { - TRAP_CASE_STRING(GR_COMBINE_OTHER_ITERATED); - TRAP_CASE_STRING(GR_COMBINE_OTHER_TEXTURE); - TRAP_CASE_STRING(GR_COMBINE_OTHER_CONSTANT); - /*TRAP_CASE_STRING(GR_COMBINE_OTHER_NONE); ==GR_COMBINE_OTHER_CONSTANT*/ - TRAP_NODEFAULT; - } -} - -const char *TRP_CMPFUNC (GrCmpFnc_t function) -{ - switch (function) { - TRAP_CASE_STRING(GR_CMP_NEVER); - TRAP_CASE_STRING(GR_CMP_LESS); - TRAP_CASE_STRING(GR_CMP_EQUAL); - TRAP_CASE_STRING(GR_CMP_LEQUAL); - TRAP_CASE_STRING(GR_CMP_GREATER); - TRAP_CASE_STRING(GR_CMP_NOTEQUAL); - TRAP_CASE_STRING(GR_CMP_GEQUAL); - TRAP_CASE_STRING(GR_CMP_ALWAYS); - TRAP_NODEFAULT; - } -} - -const char *TRP_CKMODE (GrChromakeyMode_t mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_CHROMAKEY_DISABLE); - TRAP_CASE_STRING(GR_CHROMAKEY_ENABLE); - TRAP_NODEFAULT; - } -} - -const char *TRP_CULLMODE (GrCullMode_t mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_CULL_DISABLE); - TRAP_CASE_STRING(GR_CULL_NEGATIVE); - TRAP_CASE_STRING(GR_CULL_POSITIVE); - TRAP_NODEFAULT; - } -} - -const char *TRP_DEPTHMODE (GrDepthBufferMode_t mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_DEPTHBUFFER_DISABLE); - TRAP_CASE_STRING(GR_DEPTHBUFFER_ZBUFFER); - TRAP_CASE_STRING(GR_DEPTHBUFFER_WBUFFER); - TRAP_CASE_STRING(GR_DEPTHBUFFER_ZBUFFER_COMPARE_TO_BIAS); - TRAP_CASE_STRING(GR_DEPTHBUFFER_WBUFFER_COMPARE_TO_BIAS); - TRAP_NODEFAULT; - } -} - -const char *TRP_DITHERMODE (GrDitherMode_t mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_DITHER_DISABLE); - TRAP_CASE_STRING(GR_DITHER_2x2); - TRAP_CASE_STRING(GR_DITHER_4x4); - TRAP_NODEFAULT; - } -} - -const char *TRP_FOGMODE (GrFogMode_t mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_FOG_DISABLE); - TRAP_CASE_STRING(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); - TRAP_CASE_STRING(GR_FOG_WITH_TABLE_ON_Q); - /*TRAP_CASE_STRING(GR_FOG_WITH_TABLE_ON_W); ==GR_FOG_WITH_TABLE_ON_Q*/ - TRAP_CASE_STRING(GR_FOG_WITH_ITERATED_Z); - TRAP_CASE_STRING(GR_FOG_WITH_ITERATED_ALPHA_EXT); - TRAP_CASE_STRING(GR_FOG_MULT2); - TRAP_CASE_STRING(GR_FOG_ADD2); - TRAP_NODEFAULT; - } -} - -const char *TRP_GETNAME (FxU32 pname) -{ - switch (pname) { - TRAP_CASE_STRING(GR_BITS_DEPTH); - TRAP_CASE_STRING(GR_BITS_RGBA); - TRAP_CASE_STRING(GR_FIFO_FULLNESS); - TRAP_CASE_STRING(GR_FOG_TABLE_ENTRIES); - TRAP_CASE_STRING(GR_GAMMA_TABLE_ENTRIES); - TRAP_CASE_STRING(GR_GLIDE_STATE_SIZE); - TRAP_CASE_STRING(GR_GLIDE_VERTEXLAYOUT_SIZE); - TRAP_CASE_STRING(GR_IS_BUSY); - TRAP_CASE_STRING(GR_LFB_PIXEL_PIPE); - TRAP_CASE_STRING(GR_MAX_TEXTURE_SIZE); - TRAP_CASE_STRING(GR_MAX_TEXTURE_ASPECT_RATIO); - TRAP_CASE_STRING(GR_MEMORY_FB); - TRAP_CASE_STRING(GR_MEMORY_TMU); - TRAP_CASE_STRING(GR_MEMORY_UMA); - TRAP_CASE_STRING(GR_NUM_BOARDS); - TRAP_CASE_STRING(GR_NON_POWER_OF_TWO_TEXTURES); - TRAP_CASE_STRING(GR_NUM_FB); - TRAP_CASE_STRING(GR_NUM_SWAP_HISTORY_BUFFER); - TRAP_CASE_STRING(GR_NUM_TMU); - TRAP_CASE_STRING(GR_PENDING_BUFFERSWAPS); - TRAP_CASE_STRING(GR_REVISION_FB); - TRAP_CASE_STRING(GR_REVISION_TMU); - TRAP_CASE_STRING(GR_STATS_LINES); - TRAP_CASE_STRING(GR_STATS_PIXELS_AFUNC_FAIL); - TRAP_CASE_STRING(GR_STATS_PIXELS_CHROMA_FAIL); - TRAP_CASE_STRING(GR_STATS_PIXELS_DEPTHFUNC_FAIL); - TRAP_CASE_STRING(GR_STATS_PIXELS_IN); - TRAP_CASE_STRING(GR_STATS_PIXELS_OUT); - TRAP_CASE_STRING(GR_STATS_PIXELS); - TRAP_CASE_STRING(GR_STATS_POINTS); - TRAP_CASE_STRING(GR_STATS_TRIANGLES_IN); - TRAP_CASE_STRING(GR_STATS_TRIANGLES_OUT); - TRAP_CASE_STRING(GR_STATS_TRIANGLES); - TRAP_CASE_STRING(GR_SWAP_HISTORY); - TRAP_CASE_STRING(GR_SUPPORTS_PASSTHRU); - TRAP_CASE_STRING(GR_TEXTURE_ALIGN); - TRAP_CASE_STRING(GR_VIDEO_POSITION); - TRAP_CASE_STRING(GR_VIEWPORT); - TRAP_CASE_STRING(GR_WDEPTH_MIN_MAX); - TRAP_CASE_STRING(GR_ZDEPTH_MIN_MAX); - TRAP_CASE_STRING(GR_VERTEX_PARAMETER); - TRAP_CASE_STRING(GR_BITS_GAMMA); - TRAP_CASE_STRING(GR_GET_RESERVED_1); - TRAP_NODEFAULT; - } -} - -const char *TRP_GETSTRING (FxU32 pname) -{ - switch (pname) { - TRAP_CASE_STRING(GR_EXTENSION); - TRAP_CASE_STRING(GR_HARDWARE); - TRAP_CASE_STRING(GR_RENDERER); - TRAP_CASE_STRING(GR_VENDOR); - TRAP_CASE_STRING(GR_VERSION); - TRAP_NODEFAULT; - } -} - -const char *TRP_ENABLE (GrEnableMode_t mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_AA_ORDERED); - TRAP_CASE_STRING(GR_ALLOW_MIPMAP_DITHER); - TRAP_CASE_STRING(GR_PASSTHRU); - TRAP_CASE_STRING(GR_SHAMELESS_PLUG); - TRAP_CASE_STRING(GR_VIDEO_SMOOTHING); - TRAP_CASE_STRING(GR_TEXTURE_UMA_EXT); - TRAP_CASE_STRING(GR_STENCIL_MODE_EXT); - TRAP_CASE_STRING(GR_OPENGL_MODE_EXT); - TRAP_NODEFAULT; - } -} - -const char *TRP_COORD (GrCoordinateSpaceMode_t mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_WINDOW_COORDS); - TRAP_CASE_STRING(GR_CLIP_COORDS); - TRAP_NODEFAULT; - } -} - -const char *TRP_STIPPLEMODE (GrStippleMode_t mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_STIPPLE_DISABLE); - TRAP_CASE_STRING(GR_STIPPLE_PATTERN); - TRAP_CASE_STRING(GR_STIPPLE_ROTATE); - TRAP_NODEFAULT; - } -} - -const char *TRP_LODLEVEL (GrLOD_t lod) -{ - switch (lod) { - TRAP_CASE_STRING(GR_LOD_LOG2_2048); - TRAP_CASE_STRING(GR_LOD_LOG2_1024); - TRAP_CASE_STRING(GR_LOD_LOG2_512); - TRAP_CASE_STRING(GR_LOD_LOG2_256); - TRAP_CASE_STRING(GR_LOD_LOG2_128); - TRAP_CASE_STRING(GR_LOD_LOG2_64); - TRAP_CASE_STRING(GR_LOD_LOG2_32); - TRAP_CASE_STRING(GR_LOD_LOG2_16); - TRAP_CASE_STRING(GR_LOD_LOG2_8); - TRAP_CASE_STRING(GR_LOD_LOG2_4); - TRAP_CASE_STRING(GR_LOD_LOG2_2); - TRAP_CASE_STRING(GR_LOD_LOG2_1); - TRAP_NODEFAULT; - } -} - -const char *TRP_ASPECTRATIO (GrAspectRatio_t aspect) -{ - switch (aspect) { - TRAP_CASE_STRING(GR_ASPECT_LOG2_8x1); - TRAP_CASE_STRING(GR_ASPECT_LOG2_4x1); - TRAP_CASE_STRING(GR_ASPECT_LOG2_2x1); - TRAP_CASE_STRING(GR_ASPECT_LOG2_1x1); - TRAP_CASE_STRING(GR_ASPECT_LOG2_1x2); - TRAP_CASE_STRING(GR_ASPECT_LOG2_1x4); - TRAP_CASE_STRING(GR_ASPECT_LOG2_1x8); - TRAP_NODEFAULT; - } -} - -const char *TRP_TEXFMT (GrTextureFormat_t fmt) -{ - switch (fmt) { - TRAP_CASE_STRING(GR_TEXFMT_8BIT); - /*TRAP_CASE_STRING(GR_TEXFMT_RGB_332); ==GR_TEXFMT_8BIT*/ - TRAP_CASE_STRING(GR_TEXFMT_YIQ_422); - TRAP_CASE_STRING(GR_TEXFMT_ALPHA_8); - TRAP_CASE_STRING(GR_TEXFMT_INTENSITY_8); - TRAP_CASE_STRING(GR_TEXFMT_ALPHA_INTENSITY_44); - TRAP_CASE_STRING(GR_TEXFMT_P_8); - TRAP_CASE_STRING(GR_TEXFMT_RSVD0); - /*TRAP_CASE_STRING(GR_TEXFMT_P_8_6666); ==GR_TEXFMT_RSVD0*/ - /*TRAP_CASE_STRING(GR_TEXFMT_P_8_6666_EXT); ==GR_TEXFMT_RSVD0*/ - TRAP_CASE_STRING(GR_TEXFMT_RSVD1); - TRAP_CASE_STRING(GR_TEXFMT_16BIT); - /*TRAP_CASE_STRING(GR_TEXFMT_ARGB_8332); ==GR_TEXFMT_16BIT*/ - TRAP_CASE_STRING(GR_TEXFMT_AYIQ_8422); - TRAP_CASE_STRING(GR_TEXFMT_RGB_565); - TRAP_CASE_STRING(GR_TEXFMT_ARGB_1555); - TRAP_CASE_STRING(GR_TEXFMT_ARGB_4444); - TRAP_CASE_STRING(GR_TEXFMT_ALPHA_INTENSITY_88); - TRAP_CASE_STRING(GR_TEXFMT_AP_88); - TRAP_CASE_STRING(GR_TEXFMT_RSVD2); - /*TRAP_CASE_STRING(GR_TEXFMT_RSVD4); ==GR_TEXFMT_RSVD2*/ - TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_FXT1); - TRAP_CASE_STRING(GR_TEXFMT_ARGB_8888); - TRAP_CASE_STRING(GR_TEXFMT_YUYV_422); - TRAP_CASE_STRING(GR_TEXFMT_UYVY_422); - TRAP_CASE_STRING(GR_TEXFMT_AYUV_444); - TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_DXT1); - TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_DXT2); - TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_DXT3); - TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_DXT4); - TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_DXT5); - TRAP_CASE_STRING(GR_TEXTFMT_RGB_888); - TRAP_NODEFAULT; - } -} - -const char *TRP_EVENODD (FxU32 evenOdd) -{ - switch (evenOdd) { - TRAP_CASE_STRING(GR_MIPMAPLEVELMASK_EVEN); - TRAP_CASE_STRING(GR_MIPMAPLEVELMASK_ODD); - TRAP_CASE_STRING(GR_MIPMAPLEVELMASK_BOTH); - TRAP_NODEFAULT; - } -} - -const char *TRP_NCC (GrNCCTable_t table) -{ - switch (table) { - TRAP_CASE_STRING(GR_NCCTABLE_NCC0); - TRAP_CASE_STRING(GR_NCCTABLE_NCC1); - TRAP_NODEFAULT; - } -} - -const char *TRP_CLAMPMODE (GrTextureClampMode_t clampmode) -{ - switch (clampmode) { - TRAP_CASE_STRING(GR_TEXTURECLAMP_WRAP); - TRAP_CASE_STRING(GR_TEXTURECLAMP_CLAMP); - TRAP_CASE_STRING(GR_TEXTURECLAMP_MIRROR_EXT); - TRAP_NODEFAULT; - } -} - -const char *TRP_TEXFILTER (GrTextureFilterMode_t filter_mode) -{ - switch (filter_mode) { - TRAP_CASE_STRING(GR_TEXTUREFILTER_POINT_SAMPLED); - TRAP_CASE_STRING(GR_TEXTUREFILTER_BILINEAR); - TRAP_NODEFAULT; - } -} - -const char *TRP_TABLE (GrTexTable_t type) -{ - switch (type) { - TRAP_CASE_STRING(GR_TEXTABLE_NCC0); - TRAP_CASE_STRING(GR_TEXTABLE_NCC1); - TRAP_CASE_STRING(GR_TEXTABLE_PALETTE); - TRAP_CASE_STRING(GR_TEXTABLE_PALETTE_6666_EXT); - TRAP_NODEFAULT; - } -} - -const char *TRP_MIPMODE (GrMipMapMode_t mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_MIPMAP_DISABLE); - TRAP_CASE_STRING(GR_MIPMAP_NEAREST); - TRAP_CASE_STRING(GR_MIPMAP_NEAREST_DITHER); - TRAP_NODEFAULT; - } -} - -const char *TRP_TEXBASERANGE (GrTexBaseRange_t range) -{ - switch (range) { - TRAP_CASE_STRING(GR_TEXBASE_2048); - TRAP_CASE_STRING(GR_TEXBASE_1024); - TRAP_CASE_STRING(GR_TEXBASE_512); - TRAP_CASE_STRING(GR_TEXBASE_256_TO_1); - TRAP_CASE_STRING(GR_TEXBASE_256); - TRAP_CASE_STRING(GR_TEXBASE_128); - TRAP_CASE_STRING(GR_TEXBASE_64); - TRAP_CASE_STRING(GR_TEXBASE_32_TO_1); - TRAP_NODEFAULT; - } -} - -const char *TRP_LOCKTYPE (GrLock_t type) -{ - switch (type) { - TRAP_CASE_STRING(GR_LFB_READ_ONLY); - TRAP_CASE_STRING(GR_LFB_WRITE_ONLY); - /*TRAP_CASE_STRING(GR_LFB_IDLE); ==GR_LFB_READ_ONLY*/ - TRAP_CASE_STRING(GR_LFB_NOIDLE); - TRAP_CASE_STRING(GR_LFB_WRITE_ONLY_EXPLICIT_EXT); - TRAP_NODEFAULT; - } -} - -const char *TRP_WRITEMODE (GrLfbWriteMode_t writeMode) -{ - switch (writeMode) { - TRAP_CASE_STRING(GR_LFBWRITEMODE_565); - TRAP_CASE_STRING(GR_LFBWRITEMODE_555); - TRAP_CASE_STRING(GR_LFBWRITEMODE_1555); - TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED1); - TRAP_CASE_STRING(GR_LFBWRITEMODE_888); - TRAP_CASE_STRING(GR_LFBWRITEMODE_8888); - TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED2); - TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED3); - TRAP_CASE_STRING(GR_LFBWRITEMODE_Z32); - TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED5); - TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED6); - TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED7); - TRAP_CASE_STRING(GR_LFBWRITEMODE_565_DEPTH); - TRAP_CASE_STRING(GR_LFBWRITEMODE_555_DEPTH); - TRAP_CASE_STRING(GR_LFBWRITEMODE_1555_DEPTH); - TRAP_CASE_STRING(GR_LFBWRITEMODE_ZA16); - TRAP_CASE_STRING(GR_LFBWRITEMODE_ANY); - TRAP_NODEFAULT; - } -} - -const char *TRP_SRCFMT (GrLfbSrcFmt_t src_format) -{ - switch (src_format) { - TRAP_CASE_STRING(GR_LFB_SRC_FMT_565); - TRAP_CASE_STRING(GR_LFB_SRC_FMT_555); - TRAP_CASE_STRING(GR_LFB_SRC_FMT_1555); - TRAP_CASE_STRING(GR_LFB_SRC_FMT_888); - TRAP_CASE_STRING(GR_LFB_SRC_FMT_8888); - TRAP_CASE_STRING(GR_LFB_SRC_FMT_565_DEPTH); - TRAP_CASE_STRING(GR_LFB_SRC_FMT_555_DEPTH); - TRAP_CASE_STRING(GR_LFB_SRC_FMT_1555_DEPTH); - TRAP_CASE_STRING(GR_LFB_SRC_FMT_ZA16); - TRAP_CASE_STRING(GR_LFB_SRC_FMT_RLE16); - TRAP_CASE_STRING(GR_LFBWRITEMODE_Z32); /*???*/ - TRAP_NODEFAULT; - } -} - -const char *TRP_CRMODE (GrChromaRangeMode_t mode) -{ - switch (mode) { - TRAP_CASE_STRING(GR_CHROMARANGE_DISABLE_EXT); - /*TRAP_CASE_STRING(GR_CHROMARANGE_RGB_ALL_EXT); ==GR_CHROMARANGE_DISABLE_EXT*/ - TRAP_CASE_STRING(GR_CHROMARANGE_ENABLE_EXT); - TRAP_NODEFAULT; - } -} - -const char *TRP_PIXFMT (GrPixelFormat_t pixelformat) -{ - switch (pixelformat) { - TRAP_CASE_STRING(GR_PIXFMT_I_8); - TRAP_CASE_STRING(GR_PIXFMT_AI_88); - TRAP_CASE_STRING(GR_PIXFMT_RGB_565); - TRAP_CASE_STRING(GR_PIXFMT_ARGB_1555); - TRAP_CASE_STRING(GR_PIXFMT_ARGB_8888); - TRAP_CASE_STRING(GR_PIXFMT_AA_2_RGB_565); - TRAP_CASE_STRING(GR_PIXFMT_AA_2_ARGB_1555); - TRAP_CASE_STRING(GR_PIXFMT_AA_2_ARGB_8888); - TRAP_CASE_STRING(GR_PIXFMT_AA_4_RGB_565); - TRAP_CASE_STRING(GR_PIXFMT_AA_4_ARGB_1555); - TRAP_CASE_STRING(GR_PIXFMT_AA_4_ARGB_8888); - TRAP_CASE_STRING(GR_PIXFMT_AA_8_RGB_565); - TRAP_CASE_STRING(GR_PIXFMT_AA_8_ARGB_1555); - TRAP_CASE_STRING(GR_PIXFMT_AA_8_ARGB_8888); - TRAP_NODEFAULT; - } -} - -const char *TRP_STENCILOP (GrStencilOp_t op) -{ - switch (op) { - TRAP_CASE_STRING(GR_STENCILOP_KEEP); - TRAP_CASE_STRING(GR_STENCILOP_ZERO); - TRAP_CASE_STRING(GR_STENCILOP_REPLACE); - TRAP_CASE_STRING(GR_STENCILOP_INCR_CLAMP); - TRAP_CASE_STRING(GR_STENCILOP_DECR_CLAMP); - TRAP_CASE_STRING(GR_STENCILOP_INVERT); - TRAP_CASE_STRING(GR_STENCILOP_INCR_WRAP); - TRAP_CASE_STRING(GR_STENCILOP_DECR_WRAP); - TRAP_NODEFAULT; - } -} - -const char *TRP_BLENDOP (GrAlphaBlendOp_t op) -{ - switch (op) { - TRAP_CASE_STRING(GR_BLEND_OP_ADD); - TRAP_CASE_STRING(GR_BLEND_OP_SUB); - TRAP_CASE_STRING(GR_BLEND_OP_REVSUB); - TRAP_NODEFAULT; - } -} - -const char *TRP_CU (GrCCUColor_t a) -{ - switch (a) { - TRAP_CASE_STRING(GR_CMBX_ZERO); - TRAP_CASE_STRING(GR_CMBX_TEXTURE_ALPHA); - TRAP_CASE_STRING(GR_CMBX_ALOCAL); - TRAP_CASE_STRING(GR_CMBX_AOTHER); - TRAP_CASE_STRING(GR_CMBX_B); - TRAP_CASE_STRING(GR_CMBX_CONSTANT_ALPHA); - TRAP_CASE_STRING(GR_CMBX_CONSTANT_COLOR); - TRAP_CASE_STRING(GR_CMBX_DETAIL_FACTOR); - TRAP_CASE_STRING(GR_CMBX_ITALPHA); - TRAP_CASE_STRING(GR_CMBX_ITRGB); - TRAP_CASE_STRING(GR_CMBX_LOCAL_TEXTURE_ALPHA); - TRAP_CASE_STRING(GR_CMBX_LOCAL_TEXTURE_RGB); - TRAP_CASE_STRING(GR_CMBX_LOD_FRAC); - TRAP_CASE_STRING(GR_CMBX_OTHER_TEXTURE_ALPHA); - TRAP_CASE_STRING(GR_CMBX_OTHER_TEXTURE_RGB); - TRAP_CASE_STRING(GR_CMBX_TEXTURE_RGB); - TRAP_CASE_STRING(GR_CMBX_TMU_CALPHA); - TRAP_CASE_STRING(GR_CMBX_TMU_CCOLOR); - TRAP_NODEFAULT; - } -} - -const char *TRP_CMBMODE (GrCombineMode_t a_mode) -{ - switch (a_mode) { - TRAP_CASE_STRING(GR_FUNC_MODE_ZERO); - TRAP_CASE_STRING(GR_FUNC_MODE_X); - TRAP_CASE_STRING(GR_FUNC_MODE_ONE_MINUS_X); - TRAP_CASE_STRING(GR_FUNC_MODE_NEGATIVE_X); - TRAP_CASE_STRING(GR_FUNC_MODE_X_MINUS_HALF); - TRAP_NODEFAULT; - } -} - -const char *TRP_TMU (GrChipID_t tmu) -{ - switch (tmu) { - TRAP_CASE_STRING(GR_TMU0); - TRAP_CASE_STRING(GR_TMU1); - TRAP_NODEFAULT; - } -} - -const char *TRP_TXDITHER (FxU32 dither) -{ - switch (dither) { - TRAP_CASE_STRING(TX_DITHER_NONE); - TRAP_CASE_STRING(TX_DITHER_4x4); - TRAP_CASE_STRING(TX_DITHER_ERR); - TRAP_NODEFAULT; - } -} - -const char *TRP_TXCOMPRESS (FxU32 compress) -{ - switch (compress) { - TRAP_CASE_STRING(TX_COMPRESSION_STATISTICAL); - TRAP_CASE_STRING(TX_COMPRESSION_HEURISTIC); - TRAP_NODEFAULT; - } -} - - - -/****************************************************************************\ -* REAL POINTERS * -\****************************************************************************/ - -/* -** glide extensions -*/ -void (FX_CALL *real_grSetNumPendingBuffers) (FxI32 NumPendingBuffers); -char * (FX_CALL *real_grGetRegistryOrEnvironmentStringExt) (char *theEntry); -void (FX_CALL *real_grGetGammaTableExt) (FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue); -void (FX_CALL *real_grChromaRangeModeExt) (GrChromakeyMode_t mode); -void (FX_CALL *real_grChromaRangeExt) (GrColor_t color, GrColor_t range, GrChromaRangeMode_t match_mode); -void (FX_CALL *real_grTexChromaModeExt) (GrChipID_t tmu, GrChromakeyMode_t mode); -void (FX_CALL *real_grTexChromaRangeExt) (GrChipID_t tmu, GrColor_t min, GrColor_t max, GrTexChromakeyMode_t mode); - -/* pointcast */ -void (FX_CALL *real_grTexDownloadTableExt) (GrChipID_t tmu, GrTexTable_t type, void *data); -void (FX_CALL *real_grTexDownloadTablePartialExt) (GrChipID_t tmu, GrTexTable_t type, void *data, int start, int end); -void (FX_CALL *real_grTexNCCTableExt) (GrChipID_t tmu, GrNCCTable_t table); - -/* tbext */ -void (FX_CALL *real_grTextureBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask); -void (FX_CALL *real_grTextureAuxBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask); -void (FX_CALL *real_grAuxBufferExt) (GrBuffer_t buffer); - -/* napalm */ -GrContext_t (FX_CALL *real_grSstWinOpenExt) (FxU32 hWnd, GrScreenResolution_t resolution, GrScreenRefresh_t refresh, GrColorFormat_t format, GrOriginLocation_t origin, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers); -void (FX_CALL *real_grStencilFuncExt) (GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask); -void (FX_CALL *real_grStencilMaskExt) (GrStencil_t value); -void (FX_CALL *real_grStencilOpExt) (GrStencilOp_t stencil_fail, GrStencilOp_t depth_fail, GrStencilOp_t depth_pass); -void (FX_CALL *real_grLfbConstantStencilExt) (GrStencil_t value); -void (FX_CALL *real_grBufferClearExt) (GrColor_t color, GrAlpha_t alpha, FxU32 depth, GrStencil_t stencil); -void (FX_CALL *real_grColorCombineExt) (GrCCUColor_t a, GrCombineMode_t a_mode, GrCCUColor_t b, GrCombineMode_t b_mode, GrCCUColor_t c, FxBool c_invert, GrCCUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert); -void (FX_CALL *real_grAlphaCombineExt) (GrACUColor_t a, GrCombineMode_t a_mode, GrACUColor_t b, GrCombineMode_t b_mode, GrACUColor_t c, FxBool c_invert, GrACUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert); -void (FX_CALL *real_grTexColorCombineExt) (GrChipID_t tmu, GrTCCUColor_t a, GrCombineMode_t a_mode, GrTCCUColor_t b, GrCombineMode_t b_mode, GrTCCUColor_t c, FxBool c_invert, GrTCCUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert); -void (FX_CALL *real_grTexAlphaCombineExt) (GrChipID_t tmu, GrTACUColor_t a, GrCombineMode_t a_mode, GrTACUColor_t b, GrCombineMode_t b_mode, GrTACUColor_t c, FxBool c_invert, GrTACUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert); -void (FX_CALL *real_grConstantColorValueExt) (GrChipID_t tmu, GrColor_t value); -void (FX_CALL *real_grColorMaskExt) (FxBool r, FxBool g, FxBool b, FxBool a); -void (FX_CALL *real_grAlphaBlendFunctionExt) (GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, GrAlphaBlendOp_t rgb_op, GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df, GrAlphaBlendOp_t alpha_op); -void (FX_CALL *real_grTBufferWriteMaskExt) (FxU32 tmask); - -/* -** texus -*/ -void (FX_CALL *real_txImgQuantize) (char *dst, char *src, int w, int h, FxU32 format, FxU32 dither); -void (FX_CALL *real_txMipQuantize) (TxMip *pxMip, TxMip *txMip, int fmt, FxU32 d, FxU32 comp); -void (FX_CALL *real_txPalToNcc) (GuNccTable *ncc_table, const FxU32 *pal); - - - -/****************************************************************************\ -* DEBUG HOOKS * -\****************************************************************************/ - -/* -** rendering functions -*/ -void FX_CALL trap_grDrawPoint (const void *pt) -{ -#define FN_NAME "grDrawPoint" - TRAP_LOG("%s(%p)\n", FN_NAME, pt); - grDrawPoint(pt); -#undef FN_NAME -} - -void FX_CALL trap_grDrawLine (const void *v1, - const void *v2) -{ -#define FN_NAME "grDrawLine" - TRAP_LOG("%s(%p, %p)\n", FN_NAME, v1, v2); - grDrawLine(v1, v2); -#undef FN_NAME -} - -void FX_CALL trap_grDrawTriangle (const void *a, - const void *b, - const void *c) -{ -#define FN_NAME "grDrawTriangle" - TRAP_LOG("%s(%p, %p, %p)\n", FN_NAME, a, b, c); - grDrawTriangle(a, b, c); -#undef FN_NAME -} - -void FX_CALL trap_grVertexLayout (FxU32 param, - FxI32 offset, - FxU32 mode) -{ -#define FN_NAME "grVertexLayout" - TRAP_LOG("%s(%s, %ld, %s)\n", FN_NAME, TRP_VTX(param), offset, TRP_PARAM(mode)); - grVertexLayout(param, offset, mode); -#undef FN_NAME -} - -void FX_CALL trap_grDrawVertexArray (FxU32 mode, - FxU32 Count, - void *pointers) -{ -#define FN_NAME "grDrawVertexArray" - TRAP_LOG("%s(%s, %lu, %p)\n", FN_NAME, TRP_ARRAY(mode), Count, pointers); - grDrawVertexArray(mode, Count, pointers); -#undef FN_NAME -} - -void FX_CALL trap_grDrawVertexArrayContiguous (FxU32 mode, - FxU32 Count, - void *pointers, - FxU32 stride) -{ -#define FN_NAME "grDrawVertexArrayContiguous" - TRAP_LOG("%s(%s, %lu, %p, %lu)\n", FN_NAME, TRP_ARRAY(mode), Count, pointers, stride); - grDrawVertexArrayContiguous(mode, Count, pointers, stride); -#undef FN_NAME -} - -/* -** Antialiasing Functions -*/ -void FX_CALL trap_grAADrawTriangle (const void *a, - const void *b, - const void *c, - FxBool ab_antialias, - FxBool bc_antialias, - FxBool ca_antialias) -{ -#define FN_NAME "grAADrawTriangle" - TRAP_LOG("%s(%p, %p, %p, %s, %s, %s)\n", FN_NAME, a, b, c, TRP_BOOL(ab_antialias), TRP_BOOL(bc_antialias), TRP_BOOL(ca_antialias)); - grAADrawTriangle(a, b, c, ab_antialias, bc_antialias, ca_antialias); -#undef FN_NAME -} - -/* -** buffer management -*/ -void FX_CALL trap_grBufferClear (GrColor_t color, - GrAlpha_t alpha, - FxU32 depth) -{ -#define FN_NAME "grBufferClear" - TRAP_LOG("%s(%08lx, %02x, %08lx)\n", FN_NAME, color, alpha, depth); - grBufferClear(color, alpha, depth); -#undef FN_NAME -} - -void FX_CALL trap_grBufferSwap (FxU32 swap_interval) -{ -#define FN_NAME "grBufferSwap" - TRAP_LOG("%s(%lu)\n", FN_NAME, swap_interval); - grBufferSwap(swap_interval); -#undef FN_NAME -} - -void FX_CALL trap_grRenderBuffer (GrBuffer_t buffer) -{ -#define FN_NAME "grRenderBuffer" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_BUFFER(buffer)); - grRenderBuffer(buffer); -#undef FN_NAME -} - -/* -** error management -*/ -void FX_CALL trap_grErrorSetCallback (GrErrorCallbackFnc_t fnc) -{ -#define FN_NAME "grErrorSetCallback" - TRAP_LOG("%s(%p)\n", FN_NAME, (void *)fnc); - grErrorSetCallback(fnc); -#undef FN_NAME -} - -/* -** SST routines -*/ -void FX_CALL trap_grFinish (void) -{ -#define FN_NAME "grFinish" - TRAP_LOG("%s()\n", FN_NAME); - grFinish(); -#undef FN_NAME -} - -void FX_CALL trap_grFlush (void) -{ -#define FN_NAME "grFlush" - TRAP_LOG("%s()\n", FN_NAME); - grFlush(); -#undef FN_NAME -} - -GrContext_t FX_CALL trap_grSstWinOpen (FxU32 hWnd, - GrScreenResolution_t screen_resolution, - GrScreenRefresh_t refresh_rate, - GrColorFormat_t color_format, - GrOriginLocation_t origin_location, - int nColBuffers, - int nAuxBuffers) -{ -#define FN_NAME "grSstWinOpen" - GrContext_t rv; - TRAP_LOG("%s(%08lx, %s, %s, %s, %s, %d, %d)\n", FN_NAME, hWnd, TRP_RESOLUTION(screen_resolution), TRP_REFRESH(refresh_rate), TRP_COLFMT(color_format), TRP_ORIGIN(origin_location), nColBuffers, nAuxBuffers); - rv = grSstWinOpen(hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers); - TRAP_LOG(GOT "%p\n", (void *)rv); - return rv; -#undef FN_NAME -} - -FxBool FX_CALL trap_grSstWinClose (GrContext_t context) -{ -#define FN_NAME "grSstWinClose" - FxBool rv; - TRAP_LOG("%s(%p)\n", FN_NAME, (void *)context); - rv = grSstWinClose(context); - TRAP_LOG(GOT "%s\n", TRP_BOOL(rv)); - return rv; -#undef FN_NAME -} - -FxBool FX_CALL trap_grSelectContext (GrContext_t context) -{ -#define FN_NAME "grSelectContext" - FxBool rv; - TRAP_LOG("%s(%p)\n", FN_NAME, (void *)context); - rv = grSelectContext(context); - TRAP_LOG(GOT "%s\n", TRP_BOOL(rv)); - return rv; -#undef FN_NAME -} - -void FX_CALL trap_grSstOrigin (GrOriginLocation_t origin) -{ -#define FN_NAME "grSstOrigin" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_ORIGIN(origin)); - grSstOrigin(origin); -#undef FN_NAME -} - -void FX_CALL trap_grSstSelect (int which_sst) -{ -#define FN_NAME "grSstSelect" - TRAP_LOG("%s(%d)\n", FN_NAME, which_sst); - grSstSelect(which_sst); -#undef FN_NAME -} - -/* -** Glide configuration and special effect maintenance functions -*/ -void FX_CALL trap_grAlphaBlendFunction (GrAlphaBlendFnc_t rgb_sf, - GrAlphaBlendFnc_t rgb_df, - GrAlphaBlendFnc_t alpha_sf, - GrAlphaBlendFnc_t alpha_df) -{ -#define FN_NAME "grAlphaBlendFunction" - TRAP_LOG("%s(%s, %s, %s, %s)\n", FN_NAME, TRP_BLEND(rgb_sf), TRP_BLEND(rgb_df), TRP_BLEND(alpha_sf), TRP_BLEND(alpha_df)); - grAlphaBlendFunction(rgb_sf, rgb_df, alpha_sf, alpha_df); -#undef FN_NAME -} - -void FX_CALL trap_grAlphaCombine (GrCombineFunction_t function, - GrCombineFactor_t factor, - GrCombineLocal_t local, - GrCombineOther_t other, - FxBool invert) -{ -#define FN_NAME "grAlphaCombine" - TRAP_LOG("%s(%s, %s, %s, %s, %s)\n", FN_NAME, TRP_CMBFUNC(function), TRP_CMBFACT(factor), TRP_CMBLOCAL(local), TRP_CMBOTHER(other), TRP_BOOL(invert)); - grAlphaCombine(function, factor, local, other, invert); -#undef FN_NAME -} - -void FX_CALL trap_grAlphaControlsITRGBLighting (FxBool enable) -{ -#define FN_NAME "grAlphaControlsITRGBLighting" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_BOOL(enable)); - grAlphaControlsITRGBLighting(enable); -#undef FN_NAME -} - -void FX_CALL trap_grAlphaTestFunction (GrCmpFnc_t function) -{ -#define FN_NAME "grAlphaTestFunction" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_CMPFUNC(function)); - grAlphaTestFunction(function); -#undef FN_NAME -} - -void FX_CALL trap_grAlphaTestReferenceValue (GrAlpha_t value) -{ -#define FN_NAME "grAlphaTestReferenceValue" - TRAP_LOG("%s(%02x)\n", FN_NAME, value); - grAlphaTestReferenceValue(value); -#undef FN_NAME -} - -void FX_CALL trap_grChromakeyMode (GrChromakeyMode_t mode) -{ -#define FN_NAME "grChromakeyMode" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_CKMODE(mode)); - grChromakeyMode(mode); -#undef FN_NAME -} - -void FX_CALL trap_grChromakeyValue (GrColor_t value) -{ -#define FN_NAME "grChromakeyValue" - TRAP_LOG("%s(%08lx)\n", FN_NAME, value); - grChromakeyValue(value); -#undef FN_NAME -} - -void FX_CALL trap_grClipWindow (FxU32 minx, - FxU32 miny, - FxU32 maxx, - FxU32 maxy) -{ -#define FN_NAME "grClipWindow" - TRAP_LOG("%s(%lu, %lu, %lu, %lu)\n", FN_NAME, minx, miny, maxx, maxy); - grClipWindow(minx, miny, maxx, maxy); -#undef FN_NAME -} - -void FX_CALL trap_grColorCombine (GrCombineFunction_t function, - GrCombineFactor_t factor, - GrCombineLocal_t local, - GrCombineOther_t other, - FxBool invert) -{ -#define FN_NAME "grColorCombine" - TRAP_LOG("%s(%s, %s, %s, %s, %s)\n", FN_NAME, TRP_CMBFUNC(function), TRP_CMBFACT(factor), TRP_CMBLOCAL(local), TRP_CMBOTHER(other), TRP_BOOL(invert)); - grColorCombine(function, factor, local, other, invert); -#undef FN_NAME -} - -void FX_CALL trap_grColorMask (FxBool rgb, - FxBool a) -{ -#define FN_NAME "grColorMask" - TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_BOOL(rgb), TRP_BOOL(a)); - grColorMask(rgb, a); -#undef FN_NAME -} - -void FX_CALL trap_grCullMode (GrCullMode_t mode) -{ -#define FN_NAME "grCullMode" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_CULLMODE(mode)); - grCullMode(mode); -#undef FN_NAME -} - -void FX_CALL trap_grConstantColorValue (GrColor_t value) -{ -#define FN_NAME "grConstantColorValue" - TRAP_LOG("%s(%08lx)\n", FN_NAME, value); - grConstantColorValue(value); -#undef FN_NAME -} - -void FX_CALL trap_grDepthBiasLevel (FxI32 level) -{ -#define FN_NAME "grDepthBiasLevel" - TRAP_LOG("%s(%ld)\n", FN_NAME, level); - grDepthBiasLevel(level); -#undef FN_NAME -} - -void FX_CALL trap_grDepthBufferFunction (GrCmpFnc_t function) -{ -#define FN_NAME "grDepthBufferFunction" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_CMPFUNC(function)); - grDepthBufferFunction(function); -#undef FN_NAME -} - -void FX_CALL trap_grDepthBufferMode (GrDepthBufferMode_t mode) -{ -#define FN_NAME "grDepthBufferMode" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_DEPTHMODE(mode)); - grDepthBufferMode(mode); -#undef FN_NAME -} - -void FX_CALL trap_grDepthMask (FxBool mask) -{ -#define FN_NAME "grDepthMask" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_BOOL(mask)); - grDepthMask(mask); -#undef FN_NAME -} - -void FX_CALL trap_grDisableAllEffects (void) -{ -#define FN_NAME "grDisableAllEffects" - TRAP_LOG("%s()\n", FN_NAME); - grDisableAllEffects(); -#undef FN_NAME -} - -void FX_CALL trap_grDitherMode (GrDitherMode_t mode) -{ -#define FN_NAME "grDitherMode" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_DITHERMODE(mode)); - grDitherMode(mode); -#undef FN_NAME -} - -void FX_CALL trap_grFogColorValue (GrColor_t fogcolor) -{ -#define FN_NAME "grFogColorValue" - TRAP_LOG("%s(%08lx)\n", FN_NAME, fogcolor); - grFogColorValue(fogcolor); -#undef FN_NAME -} - -void FX_CALL trap_grFogMode (GrFogMode_t mode) -{ -#define FN_NAME "grFogMode" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_FOGMODE(mode)); - grFogMode(mode); -#undef FN_NAME -} - -void FX_CALL trap_grFogTable (const GrFog_t ft[]) -{ -#define FN_NAME "grFogTable" - TRAP_LOG("%s(%p)\n", FN_NAME, ft); - grFogTable(ft); -#undef FN_NAME -} - -void FX_CALL trap_grLoadGammaTable (FxU32 nentries, - FxU32 *red, - FxU32 *green, - FxU32 *blue) -{ -#define FN_NAME "grLoadGammaTable" - TRAP_LOG("%s(%lu, %p, %p, %p)\n", FN_NAME, nentries, (void *)red, (void *)green, (void *)blue); - grLoadGammaTable(nentries, red, green, blue); -#undef FN_NAME -} - -void FX_CALL trap_grSplash (float x, - float y, - float width, - float height, - FxU32 frame) -{ -#define FN_NAME "grSplash" - TRAP_LOG("%s(%f, %f, %f, %f, %lu)\n", FN_NAME, x, y, width, height, frame); - grSplash(x, y, width, height, frame); -#undef FN_NAME -} - -FxU32 FX_CALL trap_grGet (FxU32 pname, - FxU32 plength, - FxI32 *params) -{ -#define FN_NAME "grGet" - FxU32 rv, i; - TRAP_LOG("%s(%s, %lu, %p)\n", FN_NAME, TRP_GETNAME(pname), plength, (void *)params); - rv = grGet(pname, plength, params); - TRAP_LOG(GOT "["); - for (i = 0; i < (rv/sizeof(FxI32)); i++) { - TRAP_LOG("%s%ld", i ? ", " : "", params[i]); - } - TRAP_LOG("]\n"); - return rv; -#undef FN_NAME -} - -const char *FX_CALL trap_grGetString (FxU32 pname) -{ -#define FN_NAME "grGetString" - const char *rv; - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_GETSTRING(pname)); - rv = grGetString(pname); - if (rv) { - TRAP_LOG(GOT "\"%s\"\n", rv); - } else { - TRAP_LOG(GOT "NULL\n"); - } - return rv; -#undef FN_NAME -} - -FxI32 FX_CALL trap_grQueryResolutions (const GrResolution *resTemplate, - GrResolution *output) -{ -#define FN_NAME "grQueryResolutions" - FxI32 rv; - TRAP_LOG("%s(%p, %p)\n", FN_NAME, (void *)resTemplate, (void *)output); - rv = grQueryResolutions(resTemplate, output); - TRAP_LOG(GOT "%ld\n", rv); - return rv; -#undef FN_NAME -} - -FxBool FX_CALL trap_grReset (FxU32 what) -{ -#define FN_NAME "grReset" - FxBool rv; - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_GETNAME(what)); - rv = grReset(what); - TRAP_LOG(GOT "%s\n", TRP_BOOL(rv)); - return rv; -#undef FN_NAME -} - -GrProc FX_CALL trap_grGetProcAddress (char *procName) -{ -#define FN_NAME "grGetProcAddress" - GrProc rv; - TRAP_LOG("%s(%s)\n", FN_NAME, procName); - rv = grGetProcAddress(procName); - TRAP_LOG(GOT "%p\n", (void *)rv); - return rv; -#undef FN_NAME -} - -void FX_CALL trap_grEnable (GrEnableMode_t mode) -{ -#define FN_NAME "grEnable" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_ENABLE(mode)); - grEnable(mode); -#undef FN_NAME -} - -void FX_CALL trap_grDisable (GrEnableMode_t mode) -{ -#define FN_NAME "grDisable" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_ENABLE(mode)); - grDisable(mode); -#undef FN_NAME -} - -void FX_CALL trap_grCoordinateSpace (GrCoordinateSpaceMode_t mode) -{ -#define FN_NAME "grCoordinateSpace" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_COORD(mode)); - grCoordinateSpace(mode); -#undef FN_NAME -} - -void FX_CALL trap_grDepthRange (FxFloat n, - FxFloat f) -{ -#define FN_NAME "grDepthRange" - TRAP_LOG("%s(%f, %f)\n", FN_NAME, n, f); - grDepthRange(n, f); -#undef FN_NAME -} - -void FX_CALL trap_grStippleMode (GrStippleMode_t mode) -{ -#define FN_NAME "grStippleMode" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_STIPPLEMODE(mode)); - grStippleMode(mode); /* some Glide libs don't have it; not used anyway */ -#undef FN_NAME -} - -void FX_CALL trap_grStipplePattern (GrStipplePattern_t mode) -{ -#define FN_NAME "grStipplePattern" - TRAP_LOG("%s(%08lx)\n", FN_NAME, mode); - grStipplePattern(mode); /* some Glide libs don't have it; not used anyway */ -#undef FN_NAME -} - -void FX_CALL trap_grViewport (FxI32 x, - FxI32 y, - FxI32 width, - FxI32 height) -{ -#define FN_NAME "grViewport" - TRAP_LOG("%s(%ld, %ld, %ld, %ld)\n", FN_NAME, x, y, width, height); - grViewport(x, y, width, height); -#undef FN_NAME -} - -/* -** texture mapping control functions -*/ -FxU32 FX_CALL trap_grTexCalcMemRequired (GrLOD_t lodmin, - GrLOD_t lodmax, - GrAspectRatio_t aspect, - GrTextureFormat_t fmt) -{ -#define FN_NAME "grTexCalcMemRequired" - FxU32 rv; - TRAP_LOG("%s(%s, %s, %s, %s)\n", FN_NAME, TRP_LODLEVEL(lodmin), TRP_LODLEVEL(lodmax), TRP_ASPECTRATIO(aspect), TRP_TEXFMT(fmt)); - rv = grTexCalcMemRequired(lodmin, lodmax, aspect, fmt); - TRAP_LOG(GOT "%lu\n", rv); - return rv; -#undef FN_NAME -} - -FxU32 FX_CALL trap_grTexTextureMemRequired (FxU32 evenOdd, - GrTexInfo *info) -{ -#define FN_NAME "grTexTextureMemRequired" - FxU32 rv; - TRAP_LOG("%s(%s, %p)\n", FN_NAME, TRP_EVENODD(evenOdd), (void *)info); - rv = grTexTextureMemRequired(evenOdd, info); - TRAP_LOG(GOT "%lu\n", rv); - return rv; -#undef FN_NAME -} - -FxU32 FX_CALL trap_grTexMinAddress (GrChipID_t tmu) -{ -#define FN_NAME "grTexMinAddress" - FxU32 rv; - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_TMU(tmu)); - rv = grTexMinAddress(tmu); - TRAP_LOG(GOT "%lu\n", rv); - return rv; -#undef FN_NAME -} - -FxU32 FX_CALL trap_grTexMaxAddress (GrChipID_t tmu) -{ -#define FN_NAME "grTexMaxAddress" - FxU32 rv; - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_TMU(tmu)); - rv = grTexMaxAddress(tmu); - TRAP_LOG(GOT "%lu\n", rv); - return rv; -#undef FN_NAME -} - -void FX_CALL trap_grTexNCCTable (GrNCCTable_t table) -{ -#define FN_NAME "grTexNCCTable" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_NCC(table)); - grTexNCCTable(table); -#undef FN_NAME -} - -void FX_CALL trap_grTexSource (GrChipID_t tmu, - FxU32 startAddress, - FxU32 evenOdd, - GrTexInfo *info) -{ -#define FN_NAME "grTexSource" - TRAP_LOG("%s(%s, %08lx, %s, %p)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_EVENODD(evenOdd), (void *)info); - grTexSource(tmu, startAddress, evenOdd, info); -#undef FN_NAME -} - -void FX_CALL trap_grTexClampMode (GrChipID_t tmu, - GrTextureClampMode_t s_clampmode, - GrTextureClampMode_t t_clampmode) -{ -#define FN_NAME "grTexClampMode" - TRAP_LOG("%s(%s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_CLAMPMODE(s_clampmode), TRP_CLAMPMODE(t_clampmode)); - grTexClampMode(tmu, s_clampmode, t_clampmode); -#undef FN_NAME -} - -void FX_CALL trap_grTexCombine (GrChipID_t tmu, - GrCombineFunction_t rgb_function, - GrCombineFactor_t rgb_factor, - GrCombineFunction_t alpha_function, - GrCombineFactor_t alpha_factor, - FxBool rgb_invert, - FxBool alpha_invert) -{ -#define FN_NAME "grTexCombine" - TRAP_LOG("%s(%s, %s, %s, %s, %s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_CMBFUNC(rgb_function), TRP_CMBFACT(rgb_factor), TRP_CMBFUNC(alpha_function), TRP_CMBFACT(alpha_factor), TRP_BOOL(rgb_invert), TRP_BOOL(alpha_invert)); - grTexCombine(tmu, rgb_function, rgb_factor, alpha_function, alpha_factor, rgb_invert, alpha_invert); -#undef FN_NAME -} - -void FX_CALL trap_grTexDetailControl (GrChipID_t tmu, - int lod_bias, - FxU8 detail_scale, - float detail_max) -{ -#define FN_NAME "grTexDetailControl" - TRAP_LOG("%s(%s, %u, %d, %f)\n", FN_NAME, TRP_TMU(tmu), lod_bias, detail_scale, detail_max); - grTexDetailControl(tmu, lod_bias, detail_scale, detail_max); -#undef FN_NAME -} - -void FX_CALL trap_grTexFilterMode (GrChipID_t tmu, - GrTextureFilterMode_t minfilter_mode, - GrTextureFilterMode_t magfilter_mode) -{ -#define FN_NAME "grTexFilterMode" - TRAP_LOG("%s(%s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_TEXFILTER(minfilter_mode), TRP_TEXFILTER(magfilter_mode)); - grTexFilterMode(tmu, minfilter_mode, magfilter_mode); -#undef FN_NAME -} - -void FX_CALL trap_grTexLodBiasValue (GrChipID_t tmu, - float bias) -{ -#define FN_NAME "grTexLodBiasValue" - TRAP_LOG("%s(%s, %f)\n", FN_NAME, TRP_TMU(tmu), bias); - grTexLodBiasValue(tmu, bias); -#undef FN_NAME -} - -void FX_CALL trap_grTexDownloadMipMap (GrChipID_t tmu, - FxU32 startAddress, - FxU32 evenOdd, - GrTexInfo *info) -{ -#define FN_NAME "grTexDownloadMipMap" - TRAP_LOG("%s(%s, %08lx, %s, %p)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_EVENODD(evenOdd), (void *)info); - grTexDownloadMipMap(tmu, startAddress, evenOdd, info); -#undef FN_NAME -} - -void FX_CALL trap_grTexDownloadMipMapLevel (GrChipID_t tmu, - FxU32 startAddress, - GrLOD_t thisLod, - GrLOD_t largeLod, - GrAspectRatio_t aspectRatio, - GrTextureFormat_t format, - FxU32 evenOdd, - void *data) -{ -#define FN_NAME "grTexDownloadMipMapLevel" - TRAP_LOG("%s(%s, %08lx, %s, %s, %s, %s, %s, %p)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_LODLEVEL(thisLod), TRP_LODLEVEL(largeLod), TRP_ASPECTRATIO(aspectRatio), TRP_TEXFMT(format), TRP_EVENODD(evenOdd), data); - grTexDownloadMipMapLevel(tmu, startAddress, thisLod, largeLod, aspectRatio, format, evenOdd, data); -#undef FN_NAME -} - -FxBool FX_CALL trap_grTexDownloadMipMapLevelPartial (GrChipID_t tmu, - FxU32 startAddress, - GrLOD_t thisLod, - GrLOD_t largeLod, - GrAspectRatio_t aspectRatio, - GrTextureFormat_t format, - FxU32 evenOdd, - void *data, - int start, - int end) -{ -#define FN_NAME "grTexDownloadMipMapLevelPartial" - FxBool rv; - TRAP_LOG("%s(%s, %08lx, %s, %s, %s, %s, %s, %p, %d, %d)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_LODLEVEL(thisLod), TRP_LODLEVEL(largeLod), TRP_ASPECTRATIO(aspectRatio), TRP_TEXFMT(format), TRP_EVENODD(evenOdd), data, start, end); - rv = grTexDownloadMipMapLevelPartial(tmu, startAddress, thisLod, largeLod, aspectRatio, format, evenOdd, data, start, end); - TRAP_LOG(GOT "%s\n", TRP_BOOL(rv)); - return rv; -#undef FN_NAME -} - -void FX_CALL trap_grTexDownloadTable (GrTexTable_t type, - void *data) -{ -#define FN_NAME "grTexDownloadTable" - TRAP_LOG("%s(%s, %p)\n", FN_NAME, TRP_TABLE(type), data); - grTexDownloadTable(type, data); -#undef FN_NAME -} - -void FX_CALL trap_grTexDownloadTablePartial (GrTexTable_t type, - void *data, - int start, - int end) -{ -#define FN_NAME "grTexDownloadTablePartial" - TRAP_LOG("%s(%s, %p, %d, %d)\n", FN_NAME, TRP_TABLE(type), data, start, end); - grTexDownloadTablePartial(type, data, start, end); -#undef FN_NAME -} - -void FX_CALL trap_grTexMipMapMode (GrChipID_t tmu, - GrMipMapMode_t mode, - FxBool lodBlend) -{ -#define FN_NAME "grTexMipMapMode" - TRAP_LOG("%s(%s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_MIPMODE(mode), TRP_BOOL(lodBlend)); - grTexMipMapMode(tmu, mode, lodBlend); -#undef FN_NAME -} - -void FX_CALL trap_grTexMultibase (GrChipID_t tmu, - FxBool enable) -{ -#define FN_NAME "grTexMultibase" - TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_BOOL(enable)); - grTexMultibase(tmu, enable); -#undef FN_NAME -} - -void FX_CALL trap_grTexMultibaseAddress (GrChipID_t tmu, - GrTexBaseRange_t range, - FxU32 startAddress, - FxU32 evenOdd, - GrTexInfo *info) -{ -#define FN_NAME "grTexMultibaseAddress" - TRAP_LOG("%s(%s, %s, %08lx, %s, %p)\n", FN_NAME, TRP_TMU(tmu), TRP_TEXBASERANGE(range), startAddress, TRP_EVENODD(evenOdd), (void *)info); - grTexMultibaseAddress(tmu, range, startAddress, evenOdd, info); -#undef FN_NAME -} - -/* -** linear frame buffer functions -*/ -FxBool FX_CALL trap_grLfbLock (GrLock_t type, - GrBuffer_t buffer, - GrLfbWriteMode_t writeMode, - GrOriginLocation_t origin, - FxBool pixelPipeline, - GrLfbInfo_t *info) -{ -#define FN_NAME "grLfbLock" - FxBool rv; - TRAP_LOG("%s(%s, %s, %s, %s, %s, %p)\n", FN_NAME, TRP_LOCKTYPE(type), TRP_BUFFER(buffer), TRP_WRITEMODE(writeMode), TRP_ORIGIN(origin), TRP_BOOL(pixelPipeline), (void *)info); - rv = grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info); - TRAP_LOG(GOT "%s\n", TRP_BOOL(rv)); - return rv; -#undef FN_NAME -} - -FxBool FX_CALL trap_grLfbUnlock (GrLock_t type, - GrBuffer_t buffer) -{ -#define FN_NAME "grLfbUnlock" - FxBool rv; - TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_LOCKTYPE(type), TRP_BUFFER(buffer)); - rv = grLfbUnlock(type, buffer); - TRAP_LOG(GOT "%s\n", TRP_BOOL(rv)); - return rv; -#undef FN_NAME -} - -void FX_CALL trap_grLfbConstantAlpha (GrAlpha_t alpha) -{ -#define FN_NAME "grLfbConstantAlpha" - TRAP_LOG("%s(%02x)\n", FN_NAME, alpha); - grLfbConstantAlpha(alpha); -#undef FN_NAME -} - -void FX_CALL trap_grLfbConstantDepth (FxU32 depth) -{ -#define FN_NAME "grLfbConstantDepth" - TRAP_LOG("%s(%08lx)\n", FN_NAME, depth); - grLfbConstantDepth(depth); -#undef FN_NAME -} - -void FX_CALL trap_grLfbWriteColorSwizzle (FxBool swizzleBytes, - FxBool swapWords) -{ -#define FN_NAME "grLfbWriteColorSwizzle" - TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_BOOL(swizzleBytes), TRP_BOOL(swapWords)); - grLfbWriteColorSwizzle(swizzleBytes, swapWords); -#undef FN_NAME -} - -void FX_CALL trap_grLfbWriteColorFormat (GrColorFormat_t colorFormat) -{ -#define FN_NAME "grLfbWriteColorFormat" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_COLFMT(colorFormat)); - grLfbWriteColorFormat(colorFormat); -#undef FN_NAME -} - -FxBool FX_CALL trap_grLfbWriteRegion (GrBuffer_t dst_buffer, - FxU32 dst_x, - FxU32 dst_y, - GrLfbSrcFmt_t src_format, - FxU32 src_width, - FxU32 src_height, - FxBool pixelPipeline, - FxI32 src_stride, - void *src_data) -{ -#define FN_NAME "grLfbWriteRegion" - FxBool rv; - TRAP_LOG("%s(%s, %lu, %lu, %s, %lu, %lu, %s, %ld, %p)\n", FN_NAME, TRP_BUFFER(dst_buffer), dst_x, dst_y, TRP_SRCFMT(src_format), src_width, src_height, TRP_BOOL(pixelPipeline), src_stride, src_data); - rv = grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format, src_width, src_height, pixelPipeline, src_stride, src_data); - TRAP_LOG(GOT "%s\n", TRP_BOOL(rv)); - return rv; -#undef FN_NAME -} - -FxBool FX_CALL trap_grLfbReadRegion (GrBuffer_t src_buffer, - FxU32 src_x, - FxU32 src_y, - FxU32 src_width, - FxU32 src_height, - FxU32 dst_stride, - void *dst_data) -{ -#define FN_NAME "grLfbReadRegion" - FxBool rv; - TRAP_LOG("%s(%s, %lu, %lu, %lu, %lu, %ld, %p)\n", FN_NAME, TRP_BUFFER(src_buffer), src_x, src_y, src_width, src_height, dst_stride, dst_data); - rv = grLfbReadRegion(src_buffer, src_x, src_y, src_width, src_height, dst_stride, dst_data); - TRAP_LOG(GOT "%s\n", TRP_BOOL(rv)); - return rv; -#undef FN_NAME -} - -/* -** glide management functions -*/ -void FX_CALL trap_grGlideInit (void) -{ -#define FN_NAME "grGlideInit" - TRAP_LOG("%s()\n", FN_NAME); - grGlideInit(); -#undef FN_NAME -} - -void FX_CALL trap_grGlideShutdown (void) -{ -#define FN_NAME "grGlideShutdown" - TRAP_LOG("%s()\n", FN_NAME); - grGlideShutdown(); -#undef FN_NAME -} - -void FX_CALL trap_grGlideGetState (void *state) -{ -#define FN_NAME "grGlideGetState" - TRAP_LOG("%s(%p)\n", FN_NAME, state); - grGlideGetState(state); -#undef FN_NAME -} - -void FX_CALL trap_grGlideSetState (const void *state) -{ -#define FN_NAME "grGlideSetState" - TRAP_LOG("%s(%p)\n", FN_NAME, state); - grGlideSetState(state); -#undef FN_NAME -} - -void FX_CALL trap_grGlideGetVertexLayout (void *layout) -{ -#define FN_NAME "grGlideGetVertexLayout" - TRAP_LOG("%s(%p)\n", FN_NAME, layout); - grGlideGetVertexLayout(layout); -#undef FN_NAME -} - -void FX_CALL trap_grGlideSetVertexLayout (const void *layout) -{ -#define FN_NAME "grGlideSetVertexLayout" - TRAP_LOG("%s(%p)\n", FN_NAME, layout); - grGlideSetVertexLayout(layout); -#undef FN_NAME -} - -/* -** glide utility functions -*/ -void FX_CALL trap_guGammaCorrectionRGB (FxFloat red, - FxFloat green, - FxFloat blue) -{ -#define FN_NAME "guGammaCorrectionRGB" - TRAP_LOG("%s(%f, %f, %f)\n", FN_NAME, red, green, blue); - guGammaCorrectionRGB(red, green, blue); -#undef FN_NAME -} - -float FX_CALL trap_guFogTableIndexToW (int i) -{ -#define FN_NAME "guFogTableIndexToW" - float rv; - TRAP_LOG("%s(%d)\n", FN_NAME, i); - rv = guFogTableIndexToW(i); - TRAP_LOG(GOT "%f\n", rv); - return rv; -#undef FN_NAME -} - -void FX_CALL trap_guFogGenerateExp (GrFog_t *fogtable, - float density) -{ -#define FN_NAME "guFogGenerateExp" - TRAP_LOG("%s(%p, %f)\n", FN_NAME, fogtable, density); - guFogGenerateExp(fogtable, density); -#undef FN_NAME -} - -void FX_CALL trap_guFogGenerateExp2 (GrFog_t *fogtable, - float density) -{ -#define FN_NAME "guFogGenerateExp2" - TRAP_LOG("%s(%p, %f)\n", FN_NAME, fogtable, density); - guFogGenerateExp2(fogtable, density); -#undef FN_NAME -} - -void FX_CALL trap_guFogGenerateLinear (GrFog_t *fogtable, - float nearZ, - float farZ) -{ -#define FN_NAME "guFogGenerateLinear" - TRAP_LOG("%s(%p, %f, %f)\n", FN_NAME, fogtable, nearZ, farZ); - guFogGenerateLinear(fogtable, nearZ, farZ); -#undef FN_NAME -} - -/* -** glide extensions -*/ -void FX_CALL trap_grSetNumPendingBuffers (FxI32 NumPendingBuffers) -{ -#define FN_NAME "grSetNumPendingBuffers" - TRAP_LOG("%s(%ld)\n", FN_NAME, NumPendingBuffers); - assert(real_grSetNumPendingBuffers); - (*real_grSetNumPendingBuffers)(NumPendingBuffers); -#undef FN_NAME -} - -char *FX_CALL trap_grGetRegistryOrEnvironmentStringExt (char *theEntry) -{ -#define FN_NAME "grGetRegistryOrEnvironmentStringExt" - char *rv; - TRAP_LOG("%s(\"%s\")\n", FN_NAME, theEntry); - assert(real_grGetRegistryOrEnvironmentStringExt); - rv = (*real_grGetRegistryOrEnvironmentStringExt)(theEntry); - if (rv) { - TRAP_LOG(GOT "\"%s\"\n", rv); - } else { - TRAP_LOG(GOT "NULL\n"); - } - return rv; -#undef FN_NAME -} - -void FX_CALL trap_grGetGammaTableExt (FxU32 nentries, - FxU32 *red, - FxU32 *green, - FxU32 *blue) -{ -#define FN_NAME "grGetGammaTableExt" - TRAP_LOG("%s(%lu, %p, %p, %p)\n", FN_NAME, nentries, (void *)red, (void *)green, (void *)blue); - assert(real_grGetGammaTableExt); - (*real_grGetGammaTableExt)(nentries, red, green, blue); -#undef FN_NAME -} - -void FX_CALL trap_grChromaRangeModeExt (GrChromakeyMode_t mode) -{ -#define FN_NAME "grChromaRangeModeExt" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_CKMODE(mode)); - assert(real_grChromaRangeModeExt); - (*real_grChromaRangeModeExt)(mode); -#undef FN_NAME -} - -void FX_CALL trap_grChromaRangeExt (GrColor_t color, - GrColor_t range, - GrChromaRangeMode_t match_mode) -{ -#define FN_NAME "grChromaRangeExt" - TRAP_LOG("%s(%08lx, %08lx, %s)\n", FN_NAME, color, range, TRP_CRMODE(match_mode)); - assert(real_grChromaRangeExt); - (*real_grChromaRangeExt)(color, range, match_mode); -#undef FN_NAME -} - -void FX_CALL trap_grTexChromaModeExt (GrChipID_t tmu, - GrChromakeyMode_t mode) -{ -#define FN_NAME "grTexChromaModeExt" - TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_CKMODE(mode)); - assert(real_grTexChromaModeExt); - (*real_grTexChromaModeExt)(tmu, mode); -#undef FN_NAME -} - -void FX_CALL trap_grTexChromaRangeExt (GrChipID_t tmu, - GrColor_t min, - GrColor_t max, - GrTexChromakeyMode_t mode) -{ -#define FN_NAME "grTexChromaRangeExt" - TRAP_LOG("%s(%s, %08lx, %08lx, %s)\n", FN_NAME, TRP_TMU(tmu), min, max, TRP_CRMODE(mode)); - assert(real_grTexChromaRangeExt); - (*real_grTexChromaRangeExt)(tmu, min, max, mode); -#undef FN_NAME -} - - /* pointcast */ -void FX_CALL trap_grTexDownloadTableExt (GrChipID_t tmu, - GrTexTable_t type, - void *data) -{ -#define FN_NAME "grTexDownloadTableExt" - TRAP_LOG("%s(%s, %s, %p)\n", FN_NAME, TRP_TMU(tmu), TRP_TABLE(type), data); - assert(real_grTexDownloadTableExt); - (*real_grTexDownloadTableExt)(tmu, type, data); -#undef FN_NAME -} - -void FX_CALL trap_grTexDownloadTablePartialExt (GrChipID_t tmu, - GrTexTable_t type, - void *data, - int start, - int end) -{ -#define FN_NAME "grTexDownloadTablePartialExt" - TRAP_LOG("%s(%s, %s, %p, %d, %d)\n", FN_NAME, TRP_TMU(tmu), TRP_TABLE(type), data, start, end); - assert(real_grTexDownloadTablePartialExt); - (*real_grTexDownloadTablePartialExt)(tmu, type, data, start, end); -#undef FN_NAME -} - -void FX_CALL trap_grTexNCCTableExt (GrChipID_t tmu, - GrNCCTable_t table) -{ -#define FN_NAME "grTexNCCTableExt" - TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_NCC(table)); - assert(real_grTexNCCTableExt); - (*real_grTexNCCTableExt)(tmu, table); -#undef FN_NAME -} - - /* tbext */ -void FX_CALL trap_grTextureBufferExt (GrChipID_t tmu, - FxU32 startAddress, - GrLOD_t thisLOD, - GrLOD_t largeLOD, - GrAspectRatio_t aspectRatio, - GrTextureFormat_t format, - FxU32 odd_even_mask) -{ -#define FN_NAME "grTextureBufferExt" - TRAP_LOG("%s(%s, %08lx, %s, %s, %s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_LODLEVEL(thisLOD), TRP_LODLEVEL(largeLOD), TRP_ASPECTRATIO(aspectRatio), TRP_TEXFMT(format), TRP_EVENODD(odd_even_mask)); - assert(real_grTextureBufferExt); - (*real_grTextureBufferExt)(tmu, startAddress, thisLOD, largeLOD, aspectRatio, format, odd_even_mask); -#undef FN_NAME -} - -void FX_CALL trap_grTextureAuxBufferExt (GrChipID_t tmu, - FxU32 startAddress, - GrLOD_t thisLOD, - GrLOD_t largeLOD, - GrAspectRatio_t aspectRatio, - GrTextureFormat_t format, - FxU32 odd_even_mask) -{ -#define FN_NAME "grTextureAuxBufferExt" - TRAP_LOG("%s(%s, %08lx, %s, %s, %s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_LODLEVEL(thisLOD), TRP_LODLEVEL(largeLOD), TRP_ASPECTRATIO(aspectRatio), TRP_TEXFMT(format), TRP_EVENODD(odd_even_mask)); - assert(real_grTextureAuxBufferExt); - (*real_grTextureAuxBufferExt)(tmu, startAddress, thisLOD, largeLOD, aspectRatio, format, odd_even_mask); -#undef FN_NAME -} - -void FX_CALL trap_grAuxBufferExt (GrBuffer_t buffer) -{ -#define FN_NAME "grAuxBufferExt" - TRAP_LOG("%s(%s)\n", FN_NAME, TRP_BUFFER(buffer)); - assert(real_grAuxBufferExt); - (*real_grAuxBufferExt)(buffer); -#undef FN_NAME -} - - /* napalm */ -GrContext_t FX_CALL trap_grSstWinOpenExt (FxU32 hWnd, - GrScreenResolution_t resolution, - GrScreenRefresh_t refresh, - GrColorFormat_t format, - GrOriginLocation_t origin, - GrPixelFormat_t pixelformat, - int nColBuffers, - int nAuxBuffers) -{ -#define FN_NAME "grSstWinOpenExt" - GrContext_t rv; - TRAP_LOG("%s(%08lx, %s, %s, %s, %s, %s, %d, %d)\n", FN_NAME, hWnd, TRP_RESOLUTION(resolution), TRP_REFRESH(refresh), TRP_COLFMT(format), TRP_ORIGIN(origin), TRP_PIXFMT(pixelformat), nColBuffers, nAuxBuffers); - assert(real_grSstWinOpenExt); - rv = (*real_grSstWinOpenExt)(hWnd, resolution, refresh, format, origin, pixelformat, nColBuffers, nAuxBuffers); - TRAP_LOG(GOT "%p\n", (void *)rv); - return rv; -#undef FN_NAME -} - -void FX_CALL trap_grStencilFuncExt (GrCmpFnc_t fnc, - GrStencil_t ref, - GrStencil_t mask) -{ -#define FN_NAME "grStencilFuncExt" - TRAP_LOG("%s(%s, %02x, %02x)\n", FN_NAME, TRP_CMPFUNC(fnc), ref, mask); - assert(real_grStencilFuncExt); - (*real_grStencilFuncExt)(fnc, ref, mask); -#undef FN_NAME -} - -void FX_CALL trap_grStencilMaskExt (GrStencil_t value) -{ -#define FN_NAME "grStencilMaskExt" - TRAP_LOG("%s(%02x)\n", FN_NAME, value); - assert(real_grStencilMaskExt); - (*real_grStencilMaskExt)(value); -#undef FN_NAME -} - -void FX_CALL trap_grStencilOpExt (GrStencilOp_t stencil_fail, - GrStencilOp_t depth_fail, - GrStencilOp_t depth_pass) -{ -#define FN_NAME "grStencilOpExt" - TRAP_LOG("%s(%s, %s, %s)\n", FN_NAME, TRP_STENCILOP(stencil_fail), TRP_STENCILOP(depth_fail), TRP_STENCILOP(depth_pass)); - assert(real_grStencilOpExt); - (*real_grStencilOpExt)(stencil_fail, depth_fail, depth_pass); -#undef FN_NAME -} - -void FX_CALL trap_grLfbConstantStencilExt (GrStencil_t value) -{ -#define FN_NAME "grLfbConstantStencilExt" - TRAP_LOG("%s(%02x)\n", FN_NAME, value); - assert(real_grLfbConstantStencilExt); - (*real_grLfbConstantStencilExt)(value); -#undef FN_NAME -} - -void FX_CALL trap_grBufferClearExt (GrColor_t color, - GrAlpha_t alpha, - FxU32 depth, - GrStencil_t stencil) -{ -#define FN_NAME "grBufferClearExt" - TRAP_LOG("%s(%08lx, %02x, %08lx, %02x)\n", FN_NAME, color, alpha, depth, stencil); - assert(real_grBufferClearExt); - (*real_grBufferClearExt)(color, alpha, depth, stencil); -#undef FN_NAME -} - -void FX_CALL trap_grColorCombineExt (GrCCUColor_t a, - GrCombineMode_t a_mode, - GrCCUColor_t b, - GrCombineMode_t b_mode, - GrCCUColor_t c, - FxBool c_invert, - GrCCUColor_t d, - FxBool d_invert, - FxU32 shift, - FxBool invert) -{ -#define FN_NAME "grColorCombineExt" - TRAP_LOG("%s(%s, %s, %s, %s, %s, %s, %s, %s, %lu, %s)\n", FN_NAME, TRP_CU(a), TRP_CMBMODE(a_mode), TRP_CU(b), TRP_CMBMODE(b_mode), TRP_CU(c), TRP_BOOL(c_invert), TRP_CU(d), TRP_BOOL(d_invert), shift, TRP_BOOL(invert)); - assert(real_grColorCombineExt); - (*real_grColorCombineExt)(a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); -#undef FN_NAME -} - -void FX_CALL trap_grAlphaCombineExt (GrACUColor_t a, - GrCombineMode_t a_mode, - GrACUColor_t b, - GrCombineMode_t b_mode, - GrACUColor_t c, - FxBool c_invert, - GrACUColor_t d, - FxBool d_invert, - FxU32 shift, - FxBool invert) -{ -#define FN_NAME "grAlphaCombineExt" - TRAP_LOG("%s(%s, %s, %s, %s, %s, %s, %s, %s, %lu, %s)\n", FN_NAME, TRP_CU(a), TRP_CMBMODE(a_mode), TRP_CU(b), TRP_CMBMODE(b_mode), TRP_CU(c), TRP_BOOL(c_invert), TRP_CU(d), TRP_BOOL(d_invert), shift, TRP_BOOL(invert)); - assert(real_grAlphaCombineExt); - (*real_grAlphaCombineExt)(a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); -#undef FN_NAME -} - -void FX_CALL trap_grTexColorCombineExt (GrChipID_t tmu, - GrTCCUColor_t a, - GrCombineMode_t a_mode, - GrTCCUColor_t b, - GrCombineMode_t b_mode, - GrTCCUColor_t c, - FxBool c_invert, - GrTCCUColor_t d, - FxBool d_invert, - FxU32 shift, - FxBool invert) -{ -#define FN_NAME "grTexColorCombineExt" - TRAP_LOG("%s(%s, %s, %s, %s, %s, %s, %s, %s, %s, %lu, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_CU(a), TRP_CMBMODE(a_mode), TRP_CU(b), TRP_CMBMODE(b_mode), TRP_CU(c), TRP_BOOL(c_invert), TRP_CU(d), TRP_BOOL(d_invert), shift, TRP_BOOL(invert)); - assert(real_grTexColorCombineExt); - (*real_grTexColorCombineExt)(tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); -#undef FN_NAME -} - -void FX_CALL trap_grTexAlphaCombineExt (GrChipID_t tmu, - GrTACUColor_t a, - GrCombineMode_t a_mode, - GrTACUColor_t b, - GrCombineMode_t b_mode, - GrTACUColor_t c, - FxBool c_invert, - GrTACUColor_t d, - FxBool d_invert, - FxU32 shift, - FxBool invert) -{ -#define FN_NAME "grTexAlphaCombineExt" - TRAP_LOG("%s(%s, %s, %s, %s, %s, %s, %s, %s, %s, %lu, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_CU(a), TRP_CMBMODE(a_mode), TRP_CU(b), TRP_CMBMODE(b_mode), TRP_CU(c), TRP_BOOL(c_invert), TRP_CU(d), TRP_BOOL(d_invert), shift, TRP_BOOL(invert)); - assert(real_grTexAlphaCombineExt); - (*real_grTexAlphaCombineExt)(tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); -#undef FN_NAME -} - -void FX_CALL trap_grConstantColorValueExt (GrChipID_t tmu, - GrColor_t value) -{ -#define FN_NAME "grConstantColorValueExt" - TRAP_LOG("%s(%s, %08lx)\n", FN_NAME, TRP_TMU(tmu), value); - assert(real_grConstantColorValueExt); - (*real_grConstantColorValueExt)(tmu, value); -#undef FN_NAME -} - -void FX_CALL trap_grColorMaskExt (FxBool r, - FxBool g, - FxBool b, - FxBool a) -{ -#define FN_NAME "grColorMaskExt" - TRAP_LOG("%s(%s, %s, %s, %s)\n", FN_NAME, TRP_BOOL(r), TRP_BOOL(g), TRP_BOOL(b), TRP_BOOL(a)); - assert(real_grColorMaskExt); - (*real_grColorMaskExt)(r, g, b, a); -#undef FN_NAME -} - -void FX_CALL trap_grAlphaBlendFunctionExt (GrAlphaBlendFnc_t rgb_sf, - GrAlphaBlendFnc_t rgb_df, - GrAlphaBlendOp_t rgb_op, - GrAlphaBlendFnc_t alpha_sf, - GrAlphaBlendFnc_t alpha_df, - GrAlphaBlendOp_t alpha_op) -{ -#define FN_NAME "grAlphaBlendFunctionExt" - TRAP_LOG("%s(%s, %s, %s, %s, %s, %s)\n", FN_NAME, TRP_BLEND(rgb_sf), TRP_BLEND(rgb_df), TRP_BLENDOP(rgb_op), TRP_BLEND(alpha_sf), TRP_BLEND(alpha_df), TRP_BLENDOP(alpha_op)); - assert(real_grAlphaBlendFunctionExt); - (*real_grAlphaBlendFunctionExt)(rgb_sf, rgb_df, rgb_op, alpha_sf, alpha_df, alpha_op); -#undef FN_NAME -} - -void FX_CALL trap_grTBufferWriteMaskExt (FxU32 tmask) -{ -#define FN_NAME "grTBufferWriteMaskExt" - TRAP_LOG("%s(%08lx)\n", FN_NAME, tmask); - assert(real_grTBufferWriteMaskExt); - (*real_grTBufferWriteMaskExt)(tmask); -#undef FN_NAME -} - -/* -** texus functions -*/ -void FX_CALL trap_txImgQuantize (char *dst, - char *src, - int w, - int h, - FxU32 format, - FxU32 dither) -{ -#define FN_NAME "txImgQuantize" - TRAP_LOG("%s(%p, %p, %d, %d, %s, %s)\n", FN_NAME, dst, src, w, h, TRP_TEXFMT(format), TRP_TXDITHER(dither)); - assert(real_txImgQuantize); - (*real_txImgQuantize)(dst, src, w, h, format, dither); -#undef FN_NAME -} - -void FX_CALL trap_txMipQuantize (TxMip *pxMip, - TxMip *txMip, - int fmt, - FxU32 d, - FxU32 comp) -{ -#define FN_NAME "txMipQuantize" - TRAP_LOG("%s(%p, %p, %s, %s, %s)\n", FN_NAME, (void *)pxMip, (void *)txMip, TRP_TEXFMT(fmt), TRP_TXDITHER(d), TRP_TXCOMPRESS(comp)); - assert(real_txMipQuantize); - (*real_txMipQuantize)(pxMip, txMip, fmt, d, comp); -#undef FN_NAME -} - -void FX_CALL trap_txPalToNcc (GuNccTable *ncc_table, - const FxU32 *pal) -{ -#define FN_NAME "txPalToNcc" - TRAP_LOG("%s(%p, %p)\n", FN_NAME, (void *)ncc_table, (void *)pal); - assert(real_txPalToNcc); - (*real_txPalToNcc)(ncc_table, pal); -#undef FN_NAME -} -#endif - - - -/****************************************************************************\ -* housekeeping (fake pointers) * -\****************************************************************************/ -char *FX_CALL fake_grGetRegistryOrEnvironmentStringExt (char *theEntry) -{ - return getenv(theEntry); -} - -void FX_CALL fake_grTexDownloadTableExt (GrChipID_t tmu, - GrTexTable_t type, - void *data) -{ - (void)tmu; - grTexDownloadTable(type, data); -} - -void FX_CALL fake_grTexDownloadTablePartialExt (GrChipID_t tmu, - GrTexTable_t type, - void *data, - int start, - int end) -{ - (void)tmu; - grTexDownloadTablePartial(type, data, start, end); -} - -void FX_CALL fake_grTexNCCTableExt (GrChipID_t tmu, - GrNCCTable_t table) -{ - (void)tmu; - grTexNCCTable(table); -} - - - -/****************************************************************************\ -* interface * -\****************************************************************************/ -void tdfx_hook_glide (struct tdfx_glide *Glide, int pointcast) -{ -/* GET_EXT_ADDR: get function pointer - * GET_EXT_FAKE: get function pointer if possible, else use a fake function - * GET_EXT_NULL: get function pointer if possible, else leave NULL pointer - */ -#if FX_TRAP_GLIDE -#define GET_EXT_ADDR(name) *(GrProc *)&real_##name = grGetProcAddress(#name), Glide->name = trap_##name -#define GET_EXT_FAKE(name) GET_EXT_ADDR(name); if (real_##name == NULL) real_##name = fake_##name -#define GET_EXT_NULL(name) GET_EXT_ADDR(name); if (real_##name == NULL) Glide->name = NULL -#else /* FX_TRAP_GLIDE */ -#define GET_EXT_ADDR(name) *(GrProc *)&Glide->name = grGetProcAddress(#name) -#define GET_EXT_FAKE(name) GET_EXT_ADDR(name); if (Glide->name == NULL) Glide->name = fake_##name -#define GET_EXT_NULL(name) GET_EXT_ADDR(name) -#endif /* FX_TRAP_GLIDE */ - - /* - ** glide extensions - */ - GET_EXT_NULL(grSetNumPendingBuffers); - GET_EXT_FAKE(grGetRegistryOrEnvironmentStringExt); - GET_EXT_ADDR(grGetGammaTableExt); - GET_EXT_ADDR(grChromaRangeModeExt); - GET_EXT_ADDR(grChromaRangeExt); - GET_EXT_ADDR(grTexChromaModeExt); - GET_EXT_ADDR(grTexChromaRangeExt); - /* pointcast */ - if (pointcast) { - GET_EXT_FAKE(grTexDownloadTableExt); - GET_EXT_FAKE(grTexDownloadTablePartialExt); - GET_EXT_FAKE(grTexNCCTableExt); - } else { - Glide->grTexDownloadTableExt = fake_grTexDownloadTableExt; - Glide->grTexDownloadTablePartialExt = fake_grTexDownloadTablePartialExt; - Glide->grTexNCCTableExt = fake_grTexNCCTableExt; - } - /* tbext */ - GET_EXT_ADDR(grTextureBufferExt); - GET_EXT_ADDR(grTextureAuxBufferExt); - GET_EXT_ADDR(grAuxBufferExt); - /* napalm */ - GET_EXT_ADDR(grSstWinOpenExt); - GET_EXT_ADDR(grStencilFuncExt); - GET_EXT_ADDR(grStencilMaskExt); - GET_EXT_ADDR(grStencilOpExt); - GET_EXT_ADDR(grLfbConstantStencilExt); - GET_EXT_ADDR(grBufferClearExt); - GET_EXT_ADDR(grColorCombineExt); - GET_EXT_ADDR(grAlphaCombineExt); - GET_EXT_ADDR(grTexColorCombineExt); - GET_EXT_ADDR(grTexAlphaCombineExt); - GET_EXT_ADDR(grConstantColorValueExt); - GET_EXT_ADDR(grColorMaskExt); - GET_EXT_ADDR(grAlphaBlendFunctionExt); - GET_EXT_ADDR(grTBufferWriteMaskExt); - - /* - ** texus - */ - GET_EXT_NULL(txImgQuantize); - GET_EXT_NULL(txMipQuantize); - GET_EXT_NULL(txPalToNcc); - -#undef GET_EXT_ADDR -} - -#endif /* FX */ diff --git a/src/mesa/drivers/glide/fxg.h b/src/mesa/drivers/glide/fxg.h deleted file mode 100644 index e712011168..0000000000 --- a/src/mesa/drivers/glide/fxg.h +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.0.1 - * - * Copyright (C) 1999-2003 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. - */ - -/* - * Mesa/FX device driver. Interface to Glide3. - * - * Copyright (c) 2003 - Daniel Borca - * Email : dborca@users.sourceforge.net - * Web : http://www.geocities.com/dborca - */ - - -#ifndef TDFX_GLIDE_H_included -#define TDFX_GLIDE_H_included - -#include -#include - -#ifndef FX_TRAP_GLIDE -#define FX_TRAP_GLIDE 0 -#endif - -#if FX_TRAP_GLIDE -/* -** rendering functions -*/ -void FX_CALL trap_grDrawPoint (const void *pt); -void FX_CALL trap_grDrawLine (const void *v1, const void *v2); -void FX_CALL trap_grDrawTriangle (const void *a, const void *b, const void *c); -void FX_CALL trap_grVertexLayout (FxU32 param, FxI32 offset, FxU32 mode); -void FX_CALL trap_grDrawVertexArray (FxU32 mode, FxU32 Count, void *pointers); -void FX_CALL trap_grDrawVertexArrayContiguous (FxU32 mode, FxU32 Count, void *pointers, FxU32 stride); - -/* -** Antialiasing Functions -*/ -void FX_CALL trap_grAADrawTriangle (const void *a, const void *b, const void *c, FxBool ab_antialias, FxBool bc_antialias, FxBool ca_antialias); - -/* -** buffer management -*/ -void FX_CALL trap_grBufferClear (GrColor_t color, GrAlpha_t alpha, FxU32 depth); -void FX_CALL trap_grBufferSwap (FxU32 swap_interval); -void FX_CALL trap_grRenderBuffer (GrBuffer_t buffer); - -/* -** error management -*/ -void FX_CALL trap_grErrorSetCallback (GrErrorCallbackFnc_t fnc); - -/* -** SST routines -*/ -void FX_CALL trap_grFinish (void); -void FX_CALL trap_grFlush (void); -GrContext_t FX_CALL trap_grSstWinOpen (FxU32 hWnd, GrScreenResolution_t screen_resolution, GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers); -FxBool FX_CALL trap_grSstWinClose (GrContext_t context); -FxBool FX_CALL trap_grSelectContext (GrContext_t context); -void FX_CALL trap_grSstOrigin (GrOriginLocation_t origin); -void FX_CALL trap_grSstSelect (int which_sst); - -/* -** Glide configuration and special effect maintenance functions -*/ -void FX_CALL trap_grAlphaBlendFunction (GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df); -void FX_CALL trap_grAlphaCombine (GrCombineFunction_t function, GrCombineFactor_t factor, GrCombineLocal_t local, GrCombineOther_t other, FxBool invert); -void FX_CALL trap_grAlphaControlsITRGBLighting (FxBool enable); -void FX_CALL trap_grAlphaTestFunction (GrCmpFnc_t function); -void FX_CALL trap_grAlphaTestReferenceValue (GrAlpha_t value); -void FX_CALL trap_grChromakeyMode (GrChromakeyMode_t mode); -void FX_CALL trap_grChromakeyValue (GrColor_t value); -void FX_CALL trap_grClipWindow (FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy); -void FX_CALL trap_grColorCombine (GrCombineFunction_t function, GrCombineFactor_t factor, GrCombineLocal_t local, GrCombineOther_t other, FxBool invert); -void FX_CALL trap_grColorMask (FxBool rgb, FxBool a); -void FX_CALL trap_grCullMode (GrCullMode_t mode); -void FX_CALL trap_grConstantColorValue (GrColor_t value); -void FX_CALL trap_grDepthBiasLevel (FxI32 level); -void FX_CALL trap_grDepthBufferFunction (GrCmpFnc_t function); -void FX_CALL trap_grDepthBufferMode (GrDepthBufferMode_t mode); -void FX_CALL trap_grDepthMask (FxBool mask); -void FX_CALL trap_grDisableAllEffects (void); -void FX_CALL trap_grDitherMode (GrDitherMode_t mode); -void FX_CALL trap_grFogColorValue (GrColor_t fogcolor); -void FX_CALL trap_grFogMode (GrFogMode_t mode); -void FX_CALL trap_grFogTable (const GrFog_t ft[]); -void FX_CALL trap_grLoadGammaTable (FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue); -void FX_CALL trap_grSplash (float x, float y, float width, float height, FxU32 frame); -FxU32 FX_CALL trap_grGet (FxU32 pname, FxU32 plength, FxI32 *params); -const char * FX_CALL trap_grGetString (FxU32 pname); -FxI32 FX_CALL trap_grQueryResolutions (const GrResolution *resTemplate, GrResolution *output); -FxBool FX_CALL trap_grReset (FxU32 what); -GrProc FX_CALL trap_grGetProcAddress (char *procName); -void FX_CALL trap_grEnable (GrEnableMode_t mode); -void FX_CALL trap_grDisable (GrEnableMode_t mode); -void FX_CALL trap_grCoordinateSpace (GrCoordinateSpaceMode_t mode); -void FX_CALL trap_grDepthRange (FxFloat n, FxFloat f); -void FX_CALL trap_grStippleMode (GrStippleMode_t mode); -void FX_CALL trap_grStipplePattern (GrStipplePattern_t mode); -void FX_CALL trap_grViewport (FxI32 x, FxI32 y, FxI32 width, FxI32 height); - -/* -** texture mapping control functions -*/ -FxU32 FX_CALL trap_grTexCalcMemRequired (GrLOD_t lodmin, GrLOD_t lodmax, GrAspectRatio_t aspect, GrTextureFormat_t fmt); -FxU32 FX_CALL trap_grTexTextureMemRequired (FxU32 evenOdd, GrTexInfo *info); -FxU32 FX_CALL trap_grTexMinAddress (GrChipID_t tmu); -FxU32 FX_CALL trap_grTexMaxAddress (GrChipID_t tmu); -void FX_CALL trap_grTexNCCTable (GrNCCTable_t table); -void FX_CALL trap_grTexSource (GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info); -void FX_CALL trap_grTexClampMode (GrChipID_t tmu, GrTextureClampMode_t s_clampmode, GrTextureClampMode_t t_clampmode); -void FX_CALL trap_grTexCombine (GrChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor, GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, FxBool rgb_invert, FxBool alpha_invert); -void FX_CALL trap_grTexDetailControl (GrChipID_t tmu, int lod_bias, FxU8 detail_scale, float detail_max); -void FX_CALL trap_grTexFilterMode (GrChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTextureFilterMode_t magfilter_mode); -void FX_CALL trap_grTexLodBiasValue (GrChipID_t tmu, float bias); -void FX_CALL trap_grTexDownloadMipMap (GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info); -void FX_CALL trap_grTexDownloadMipMapLevel (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 evenOdd, void *data); -FxBool FX_CALL trap_grTexDownloadMipMapLevelPartial (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 evenOdd, void *data, int start, int end); -void FX_CALL trap_grTexDownloadTable (GrTexTable_t type, void *data); -void FX_CALL trap_grTexDownloadTablePartial (GrTexTable_t type, void *data, int start, int end); -void FX_CALL trap_grTexMipMapMode (GrChipID_t tmu, GrMipMapMode_t mode, FxBool lodBlend); -void FX_CALL trap_grTexMultibase (GrChipID_t tmu, FxBool enable); -void FX_CALL trap_grTexMultibaseAddress (GrChipID_t tmu, GrTexBaseRange_t range, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info); - -/* -** linear frame buffer functions -*/ -FxBool FX_CALL trap_grLfbLock (GrLock_t type, GrBuffer_t buffer, GrLfbWriteMode_t writeMode, GrOriginLocation_t origin, FxBool pixelPipeline, GrLfbInfo_t *info); -FxBool FX_CALL trap_grLfbUnlock (GrLock_t type, GrBuffer_t buffer); -void FX_CALL trap_grLfbConstantAlpha (GrAlpha_t alpha); -void FX_CALL trap_grLfbConstantDepth (FxU32 depth); -void FX_CALL trap_grLfbWriteColorSwizzle (FxBool swizzleBytes, FxBool swapWords); -void FX_CALL trap_grLfbWriteColorFormat (GrColorFormat_t colorFormat); -FxBool FX_CALL trap_grLfbWriteRegion (GrBuffer_t dst_buffer, FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format, FxU32 src_width, FxU32 src_height, FxBool pixelPipeline, FxI32 src_stride, void *src_data); -FxBool FX_CALL trap_grLfbReadRegion (GrBuffer_t src_buffer, FxU32 src_x, FxU32 src_y, FxU32 src_width, FxU32 src_height, FxU32 dst_stride, void *dst_data); - -/* -** glide management functions -*/ -void FX_CALL trap_grGlideInit (void); -void FX_CALL trap_grGlideShutdown (void); -void FX_CALL trap_grGlideGetState (void *state); -void FX_CALL trap_grGlideSetState (const void *state); -void FX_CALL trap_grGlideGetVertexLayout (void *layout); -void FX_CALL trap_grGlideSetVertexLayout (const void *layout); - -/* -** glide utility functions -*/ -void FX_CALL trap_guGammaCorrectionRGB (FxFloat red, FxFloat green, FxFloat blue); -float FX_CALL trap_guFogTableIndexToW (int i); -void FX_CALL trap_guFogGenerateExp (GrFog_t *fogtable, float density); -void FX_CALL trap_guFogGenerateExp2 (GrFog_t *fogtable, float density); -void FX_CALL trap_guFogGenerateLinear (GrFog_t *fogtable, float nearZ, float farZ); - -#ifndef FX_TRAP_GLIDE_internal -/* -** rendering functions -*/ -#define grDrawPoint trap_grDrawPoint -#define grDrawLine trap_grDrawLine -#define grDrawTriangle trap_grDrawTriangle -#define grVertexLayout trap_grVertexLayout -#define grDrawVertexArray trap_grDrawVertexArray -#define grDrawVertexArrayContiguous trap_grDrawVertexArrayContiguous - -/* -** Antialiasing Functions -*/ -#define grAADrawTriangle trap_grAADrawTriangle - -/* -** buffer management -*/ -#define grBufferClear trap_grBufferClear -#define grBufferSwap trap_grBufferSwap -#define grRenderBuffer trap_grRenderBuffer - -/* -** error management -*/ -#define grErrorSetCallback trap_grErrorSetCallback - -/* -** SST routines -*/ -#define grFinish trap_grFinish -#define grFlush trap_grFlush -#define grSstWinOpen trap_grSstWinOpen -#define grSstWinClose trap_grSstWinClose -#define grSelectContext trap_grSelectContext -#define grSstOrigin trap_grSstOrigin -#define grSstSelect trap_grSstSelect - -/* -** Glide configuration and special effect maintenance functions -*/ -#define grAlphaBlendFunction trap_grAlphaBlendFunction -#define grAlphaCombine trap_grAlphaCombine -#define grAlphaControlsITRGBLighting trap_grAlphaControlsITRGBLighting -#define grAlphaTestFunction trap_grAlphaTestFunction -#define grAlphaTestReferenceValue trap_grAlphaTestReferenceValue -#define grChromakeyMode trap_grChromakeyMode -#define grChromakeyValue trap_grChromakeyValue -#define grClipWindow trap_grClipWindow -#define grColorCombine trap_grColorCombine -#define grColorMask trap_grColorMask -#define grCullMode trap_grCullMode -#define grConstantColorValue trap_grConstantColorValue -#define grDepthBiasLevel trap_grDepthBiasLevel -#define grDepthBufferFunction trap_grDepthBufferFunction -#define grDepthBufferMode trap_grDepthBufferMode -#define grDepthMask trap_grDepthMask -#define grDisableAllEffects trap_grDisableAllEffects -#define grDitherMode trap_grDitherMode -#define grFogColorValue trap_grFogColorValue -#define grFogMode trap_grFogMode -#define grFogTable trap_grFogTable -#define grLoadGammaTable trap_grLoadGammaTable -#define grSplash trap_grSplash -#define grGet trap_grGet -#define grGetString trap_grGetString -#define grQueryResolutions trap_grQueryResolutions -#define grReset trap_grReset -#define grGetProcAddress trap_grGetProcAddress -#define grEnable trap_grEnable -#define grDisable trap_grDisable -#define grCoordinateSpace trap_grCoordinateSpace -#define grDepthRange trap_grDepthRange -#define grStippleMode trap_grStippleMode -#define grStipplePattern trap_grStipplePattern -#define grViewport trap_grViewport - -/* -** texture mapping control functions -*/ -#define grTexCalcMemRequired trap_grTexCalcMemRequired -#define grTexTextureMemRequired trap_grTexTextureMemRequired -#define grTexMinAddress trap_grTexMinAddress -#define grTexMaxAddress trap_grTexMaxAddress -#define grTexNCCTable trap_grTexNCCTable -#define grTexSource trap_grTexSource -#define grTexClampMode trap_grTexClampMode -#define grTexCombine trap_grTexCombine -#define grTexDetailControl trap_grTexDetailControl -#define grTexFilterMode trap_grTexFilterMode -#define grTexLodBiasValue trap_grTexLodBiasValue -#define grTexDownloadMipMap trap_grTexDownloadMipMap -#define grTexDownloadMipMapLevel trap_grTexDownloadMipMapLevel -#define grTexDownloadMipMapLevelPartial trap_grTexDownloadMipMapLevelPartial -#define grTexDownloadTable trap_grTexDownloadTable -#define grTexDownloadTablePartial trap_grTexDownloadTablePartial -#define grTexMipMapMode trap_grTexMipMapMode -#define grTexMultibase trap_grTexMultibase -#define grTexMultibaseAddress trap_grTexMultibaseAddress - -/* -** linear frame buffer functions -*/ -#define grLfbLock trap_grLfbLock -#define grLfbUnlock trap_grLfbUnlock -#define grLfbConstantAlpha trap_grLfbConstantAlpha -#define grLfbConstantDepth trap_grLfbConstantDepth -#define grLfbWriteColorSwizzle trap_grLfbWriteColorSwizzle -#define grLfbWriteColorFormat trap_grLfbWriteColorFormat -#define grLfbWriteRegion trap_grLfbWriteRegion -#define grLfbReadRegion trap_grLfbReadRegion - -/* -** glide management functions -*/ -#define grGlideInit trap_grGlideInit -#define grGlideShutdown trap_grGlideShutdown -#define grGlideGetState trap_grGlideGetState -#define grGlideSetState trap_grGlideSetState -#define grGlideGetVertexLayout trap_grGlideGetVertexLayout -#define grGlideSetVertexLayout trap_grGlideSetVertexLayout - -/* -** glide utility functions -*/ -#define guGammaCorrectionRGB trap_guGammaCorrectionRGB -#define guFogTableIndexToW trap_guFogTableIndexToW -#define guFogGenerateExp trap_guFogGenerateExp -#define guFogGenerateExp2 trap_guFogGenerateExp2 -#define guFogGenerateLinear trap_guFogGenerateLinear -#endif /* FX_TRAP_GLIDE_internal */ -#endif /* FX_TRAP_GLIDE */ - - - -/* */ -#define TX_MAX_LEVEL 16 -typedef struct _TxMip { - int format; - int width; - int height; - int depth; - int size; - void *data[TX_MAX_LEVEL]; - FxU32 pal[256]; -} TxMip; - -#define TX_DITHER_NONE 0x00000000 -#define TX_DITHER_4x4 0x00000001 -#define TX_DITHER_ERR 0x00000002 - -#define TX_COMPRESSION_STATISTICAL 0x00000000 -#define TX_COMPRESSION_HEURISTIC 0x00000010 -/* */ - - - -struct tdfx_glide { - /* - ** glide extensions - */ - void (FX_CALL *grSetNumPendingBuffers) (FxI32 NumPendingBuffers); - char * (FX_CALL *grGetRegistryOrEnvironmentStringExt) (char *theEntry); - void (FX_CALL *grGetGammaTableExt) (FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue); - void (FX_CALL *grChromaRangeModeExt) (GrChromakeyMode_t mode); - void (FX_CALL *grChromaRangeExt) (GrColor_t color, GrColor_t range, GrChromaRangeMode_t match_mode); - void (FX_CALL *grTexChromaModeExt) (GrChipID_t tmu, GrChromakeyMode_t mode); - void (FX_CALL *grTexChromaRangeExt) (GrChipID_t tmu, GrColor_t min, GrColor_t max, GrTexChromakeyMode_t mode); - - /* pointcast */ - void (FX_CALL *grTexDownloadTableExt) (GrChipID_t tmu, GrTexTable_t type, void *data); - void (FX_CALL *grTexDownloadTablePartialExt) (GrChipID_t tmu, GrTexTable_t type, void *data, int start, int end); - void (FX_CALL *grTexNCCTableExt) (GrChipID_t tmu, GrNCCTable_t table); - - /* tbext */ - void (FX_CALL *grTextureBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask); - void (FX_CALL *grTextureAuxBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask); - void (FX_CALL *grAuxBufferExt) (GrBuffer_t buffer); - - /* napalm */ - GrContext_t (FX_CALL *grSstWinOpenExt) (FxU32 hWnd, GrScreenResolution_t resolution, GrScreenRefresh_t refresh, GrColorFormat_t format, GrOriginLocation_t origin, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers); - void (FX_CALL *grStencilFuncExt) (GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask); - void (FX_CALL *grStencilMaskExt) (GrStencil_t value); - void (FX_CALL *grStencilOpExt) (GrStencilOp_t stencil_fail, GrStencilOp_t depth_fail, GrStencilOp_t depth_pass); - void (FX_CALL *grLfbConstantStencilExt) (GrStencil_t value); - void (FX_CALL *grBufferClearExt) (GrColor_t color, GrAlpha_t alpha, FxU32 depth, GrStencil_t stencil); - void (FX_CALL *grColorCombineExt) (GrCCUColor_t a, GrCombineMode_t a_mode, GrCCUColor_t b, GrCombineMode_t b_mode, GrCCUColor_t c, FxBool c_invert, GrCCUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert); - void (FX_CALL *grAlphaCombineExt) (GrACUColor_t a, GrCombineMode_t a_mode, GrACUColor_t b, GrCombineMode_t b_mode, GrACUColor_t c, FxBool c_invert, GrACUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert); - void (FX_CALL *grTexColorCombineExt) (GrChipID_t tmu, GrTCCUColor_t a, GrCombineMode_t a_mode, GrTCCUColor_t b, GrCombineMode_t b_mode, GrTCCUColor_t c, FxBool c_invert, GrTCCUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert); - void (FX_CALL *grTexAlphaCombineExt) (GrChipID_t tmu, GrTACUColor_t a, GrCombineMode_t a_mode, GrTACUColor_t b, GrCombineMode_t b_mode, GrTACUColor_t c, FxBool c_invert, GrTACUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert); - void (FX_CALL *grConstantColorValueExt) (GrChipID_t tmu, GrColor_t value); - void (FX_CALL *grColorMaskExt) (FxBool r, FxBool g, FxBool b, FxBool a); - void (FX_CALL *grAlphaBlendFunctionExt) (GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, GrAlphaBlendOp_t rgb_op, GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df, GrAlphaBlendOp_t alpha_op); - void (FX_CALL *grTBufferWriteMaskExt) (FxU32 tmask); - - /* - ** Texus2 functions - */ - void (FX_CALL *txImgQuantize) (char *dst, char *src, int w, int h, FxU32 format, FxU32 dither); - void (FX_CALL *txMipQuantize) (TxMip *pxMip, TxMip *txMip, int fmt, FxU32 d, FxU32 comp); - void (FX_CALL *txPalToNcc) (GuNccTable *ncc_table, const FxU32 *pal); -}; - -void tdfx_hook_glide (struct tdfx_glide *Glide, int pointcast); - -#endif diff --git a/src/mesa/drivers/glide/fxglidew.c b/src/mesa/drivers/glide/fxglidew.c deleted file mode 100644 index 1fedf2ab96..0000000000 --- a/src/mesa/drivers/glide/fxglidew.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * Copyright (C) 1999-2001 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. - */ - -/* Authors: - * David Bucciarelli - * Brian Paul - * Daryll Strauss - * Keith Whitwell - * Daniel Borca - * Hiroshi Morii - */ - -/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */ - - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#if defined(FX) -#include "fxglidew.h" -#include "fxdrv.h" - -#include -#include - -FxI32 -FX_grGetInteger_NoLock(FxU32 pname) -{ - FxI32 result; - - if (grGet(pname, 4, &result)) { - return result; - } - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "FX_grGetInteger_NoLock: wrong parameter (%lx)\n", pname); - } - return -1; -} - -FxBool -FX_grSstControl(FxU32 code) -{ - /* The glide 3 sources call for grEnable/grDisable to be called in exchange - * for grSstControl. */ - switch (code) { - case GR_CONTROL_ACTIVATE: - grEnable(GR_PASSTHRU); - break; - case GR_CONTROL_DEACTIVATE: - grDisable(GR_PASSTHRU); - break; - } - /* Appearently GR_CONTROL_RESIZE can be ignored. */ - return 1; /* OK? */ -} - - -int -FX_grSstScreenWidth() -{ - FxI32 result[4]; - - BEGIN_BOARD_LOCK(); - grGet(GR_VIEWPORT, sizeof(FxI32) * 4, result); - END_BOARD_LOCK(); - - return result[2]; -} - -int -FX_grSstScreenHeight() -{ - FxI32 result[4]; - - BEGIN_BOARD_LOCK(); - grGet(GR_VIEWPORT, sizeof(FxI32) * 4, result); - END_BOARD_LOCK(); - - return result[3]; -} - -void -FX_grSstPerfStats(GrSstPerfStats_t * st) -{ - FxI32 n; - grGet(GR_STATS_PIXELS_IN, 4, &n); - st->pixelsIn = n; - grGet(GR_STATS_PIXELS_CHROMA_FAIL, 4, &n); - st->chromaFail = n; - grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &n); - st->zFuncFail = n; - grGet(GR_STATS_PIXELS_AFUNC_FAIL, 4, &n); - st->aFuncFail = n; - grGet(GR_STATS_PIXELS_OUT, 4, &n); - st->pixelsOut = n; -} - -void -FX_setupGrVertexLayout(void) -{ - BEGIN_BOARD_LOCK(); - grReset(GR_VERTEX_PARAMETER); - - grCoordinateSpace(GR_WINDOW_COORDS); - grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE); -#if FX_PACKEDCOLOR - grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE); -#else /* !FX_PACKEDCOLOR */ - grVertexLayout(GR_PARAM_RGB, GR_VERTEX_RGB_OFFSET << 2, GR_PARAM_ENABLE); - grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE); -#endif /* !FX_PACKEDCOLOR */ - grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE); - grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE); - grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, - GR_PARAM_ENABLE); - grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, - GR_PARAM_DISABLE); - grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, - GR_PARAM_DISABLE); - grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, - GR_PARAM_DISABLE); - END_BOARD_LOCK(); -} - -void -FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask) -{ - switch (hintType) { - case GR_HINT_STWHINT: - { - if (hintMask & GR_STWHINT_W_DIFF_TMU0) - grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, - GR_PARAM_ENABLE); - else - grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, - GR_PARAM_DISABLE); - - if (hintMask & GR_STWHINT_ST_DIFF_TMU1) - grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, - GR_PARAM_ENABLE); - else - grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, - GR_PARAM_DISABLE); - - if (hintMask & GR_STWHINT_W_DIFF_TMU1) - grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, - GR_PARAM_ENABLE); - else - grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, - GR_PARAM_DISABLE); - - } - } -} - -/* - * Glide3 doesn't have the grSstQueryHardware function anymore. - * Instead, we call grGet() and fill in the data structures ourselves. - */ -int -FX_grSstQueryHardware(GrHwConfiguration * config) -{ - int i, j; - int numFB; - - BEGIN_BOARD_LOCK(); - - grGet(GR_NUM_BOARDS, 4, (void *) &(config->num_sst)); - if (config->num_sst == 0) - return 0; - - for (i = 0; i < config->num_sst; i++) { - FxI32 result; - const char *extension; - - grSstSelect(i); - - extension = grGetString(GR_HARDWARE); - if (strstr(extension, "Rush")) { - config->SSTs[i].type = GR_SSTTYPE_SST96; - } else if (strstr(extension, "Voodoo2")) { - config->SSTs[i].type = GR_SSTTYPE_Voodoo2; - } else if (strstr(extension, "Voodoo Banshee")) { - config->SSTs[i].type = GR_SSTTYPE_Banshee; - } else if (strstr(extension, "Voodoo3")) { - config->SSTs[i].type = GR_SSTTYPE_Voodoo3; - } else if (strstr(extension, "Voodoo4")) { - config->SSTs[i].type = GR_SSTTYPE_Voodoo4; - } else if (strstr(extension, "Voodoo5")) { - config->SSTs[i].type = GR_SSTTYPE_Voodoo5; - } else { - config->SSTs[i].type = GR_SSTTYPE_VOODOO; - } - - grGet(GR_MEMORY_FB, 4, &result); - config->SSTs[i].fbRam = result / (1024 * 1024); - - grGet(GR_NUM_TMU, 4, &result); - config->SSTs[i].nTexelfx = result; - - grGet(GR_REVISION_FB, 4, &result); - config->SSTs[i].fbiRev = result; - - for (j = 0; j < config->SSTs[i].nTexelfx; j++) { - grGet(GR_MEMORY_TMU, 4, &result); - config->SSTs[i].tmuConfig[j].tmuRam = result / (1024 * 1024); - grGet(GR_REVISION_TMU, 4, &result); - config->SSTs[i].tmuConfig[j].tmuRev = result; - } - - extension = grGetString(GR_EXTENSION); - config->SSTs[i].HavePalExt = (strstr(extension, " PALETTE6666 ") != NULL); - config->SSTs[i].HavePixExt = (strstr(extension, " PIXEXT ") != NULL); - config->SSTs[i].HaveTexFmt = (strstr(extension, " TEXFMT ") != NULL); - config->SSTs[i].HaveCmbExt = (strstr(extension, " COMBINE ") != NULL); - config->SSTs[i].HaveMirExt = (strstr(extension, " TEXMIRROR ") != NULL); - config->SSTs[i].HaveTexUma = (strstr(extension, " TEXUMA ") != NULL); - - /* number of Voodoo chips */ - grGet(GR_NUM_FB, 4, (void *) &numFB); - config->SSTs[i].numChips = numFB; - - } - - tdfx_hook_glide(&config->Glide, getenv("MESA_FX_POINTCAST") != NULL); - - END_BOARD_LOCK(); - return 1; -} - - - -#else - -/* - * Need this to provide at least one external definition. - */ - -extern int gl_fx_dummy_function_glidew(void); -int -gl_fx_dummy_function_glidew(void) -{ - return 0; -} - -#endif /* FX */ diff --git a/src/mesa/drivers/glide/fxglidew.h b/src/mesa/drivers/glide/fxglidew.h deleted file mode 100644 index a19d0b58c7..0000000000 --- a/src/mesa/drivers/glide/fxglidew.h +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * Copyright (C) 1999-2001 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. - */ - -/* Authors: - * David Bucciarelli - * Brian Paul - * Daryll Strauss - * Keith Whitwell - * Daniel Borca - * Hiroshi Morii - */ - - -#ifndef __FX_GLIDE_WARPER__ -#define __FX_GLIDE_WARPER__ - - -#include "fxg.h" - -#ifndef FX_PACKEDCOLOR -#define FX_PACKEDCOLOR 1 -#endif - -#define MAX_NUM_SST 4 - -enum { - GR_SSTTYPE_VOODOO = 0, - GR_SSTTYPE_SST96 = 1, - GR_SSTTYPE_AT3D = 2, - GR_SSTTYPE_Voodoo2 = 3, - GR_SSTTYPE_Banshee = 4, - GR_SSTTYPE_Voodoo3 = 5, - GR_SSTTYPE_Voodoo4 = 6, - GR_SSTTYPE_Voodoo5 = 7 -}; - -#define GrState void - -typedef int GrSstType; - -typedef struct GrTMUConfig_St { - int tmuRev; /* Rev of Texelfx chip */ - int tmuRam; /* 1, 2, or 4 MB */ -} GrTMUConfig_t; - -typedef struct { - int num_sst; /* # of HW units in the system */ - struct SstCard_St { - GrSstType type; /* Which hardware is it? */ - int fbRam; /* 1, 2, or 4 MB */ - int fbiRev; /* Rev of Pixelfx chip */ - int nTexelfx; /* How many texelFX chips are there? */ - int numChips; /* Number of Voodoo chips */ - GrTMUConfig_t tmuConfig[GLIDE_NUM_TMU]; /* Configuration of the Texelfx chips */ - /* Glide3 extensions */ - FxBool HavePalExt; /* PALETTE6666 */ - FxBool HavePixExt; /* PIXEXT */ - FxBool HaveTexFmt; /* TEXFMT */ - FxBool HaveCmbExt; /* COMBINE */ - FxBool HaveMirExt; /* TEXMIRROR */ - FxBool HaveTexUma; /* TEXUMA */ - } - SSTs[MAX_NUM_SST]; /* configuration for each board */ - struct tdfx_glide Glide; -} GrHwConfiguration; - - - -typedef FxU32 GrHint_t; -#define GR_HINTTYPE_MIN 0 -#define GR_HINT_STWHINT 0 - -typedef FxU32 GrSTWHint_t; -#define GR_STWHINT_W_DIFF_FBI FXBIT(0) -#define GR_STWHINT_W_DIFF_TMU0 FXBIT(1) -#define GR_STWHINT_ST_DIFF_TMU0 FXBIT(2) -#define GR_STWHINT_W_DIFF_TMU1 FXBIT(3) -#define GR_STWHINT_ST_DIFF_TMU1 FXBIT(4) -#define GR_STWHINT_W_DIFF_TMU2 FXBIT(5) -#define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6) - -#define GR_CONTROL_ACTIVATE 1 -#define GR_CONTROL_DEACTIVATE 0 - - - -/* -** move the vertex layout defintion to application -*/ -typedef struct { - float sow; /* s texture ordinate (s over w) */ - float tow; /* t texture ordinate (t over w) */ - float oow; /* 1/w (used mipmapping - really 0xfff/w) */ -} GrTmuVertex; - -#if FX_PACKEDCOLOR -typedef struct { - float x, y; /* X and Y in screen space */ - float ooz; /* 65535/Z (used for Z-buffering) */ - float oow; /* 1/W (used for W-buffering, texturing) */ - unsigned char pargb[4]; /* B, G, R, A [0..255] */ - GrTmuVertex tmuvtx[GLIDE_NUM_TMU]; - float fog; /* fog coordinate */ - unsigned char pspec[4]; /* B, G, R, A [0..255] */ - float psize; /* point size */ - long pad[16 - 14]; /* ensure 64b structure */ -} GrVertex; - -#define GR_VERTEX_X_OFFSET 0 -#define GR_VERTEX_Y_OFFSET 1 -#define GR_VERTEX_OOZ_OFFSET 2 -#define GR_VERTEX_OOW_OFFSET 3 -#define GR_VERTEX_PARGB_OFFSET 4 -#define GR_VERTEX_SOW_TMU0_OFFSET 5 -#define GR_VERTEX_TOW_TMU0_OFFSET 6 -#define GR_VERTEX_OOW_TMU0_OFFSET 7 -#define GR_VERTEX_SOW_TMU1_OFFSET 8 -#define GR_VERTEX_TOW_TMU1_OFFSET 9 -#define GR_VERTEX_OOW_TMU1_OFFSET 10 -#define GR_VERTEX_FOG_OFFSET 11 -#define GR_VERTEX_PSPEC_OFFSET 12 -#else /* !FX_PACKEDCOLOR */ -typedef struct { - float x, y; /* X and Y in screen space */ - float ooz; /* 65535/Z (used for Z-buffering) */ - float oow; /* 1/W (used for W-buffering, texturing) */ - float r, g, b, a; /* R, G, B, A [0..255] */ - GrTmuVertex tmuvtx[GLIDE_NUM_TMU]; - float fog; /* fog coordinate */ - float r1, g1, b1; /* R, G, B [0..255] */ - float psize; /* point size */ - long pad[20 - 19]; /* ensure multiple of 16 */ -} GrVertex; - -#define GR_VERTEX_X_OFFSET 0 -#define GR_VERTEX_Y_OFFSET 1 -#define GR_VERTEX_OOZ_OFFSET 2 -#define GR_VERTEX_OOW_OFFSET 3 -#define GR_VERTEX_RGB_OFFSET 4 -#define GR_VERTEX_A_OFFSET 7 -#define GR_VERTEX_SOW_TMU0_OFFSET 8 -#define GR_VERTEX_TOW_TMU0_OFFSET 9 -#define GR_VERTEX_OOW_TMU0_OFFSET 10 -#define GR_VERTEX_SOW_TMU1_OFFSET 11 -#define GR_VERTEX_TOW_TMU1_OFFSET 12 -#define GR_VERTEX_OOW_TMU1_OFFSET 13 -#define GR_VERTEX_FOG_OFFSET 14 -#define GR_VERTEX_SPEC_OFFSET 15 -#endif /* !FX_PACKEDCOLOR */ - - - -/* - * For Lod/LodLog2 conversion. - */ -#define FX_largeLodLog2(info) (info).largeLodLog2 -#define FX_aspectRatioLog2(info) (info).aspectRatioLog2 -#define FX_smallLodLog2(info) (info).smallLodLog2 -#define FX_lodToValue(val) ((int)(GR_LOD_LOG2_256-val)) -#define FX_largeLodValue(info) ((int)(GR_LOD_LOG2_256-(info).largeLodLog2)) -#define FX_smallLodValue(info) ((int)(GR_LOD_LOG2_256-(info).smallLodLog2)) -#define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_LOG2_256-val)) - - - -/* - * Query - */ -extern int FX_grSstScreenWidth(void); -extern int FX_grSstScreenHeight(void); -extern void FX_grSstPerfStats(GrSstPerfStats_t *st); -extern int FX_grSstQueryHardware(GrHwConfiguration *config); -#define FX_grGetInteger FX_grGetInteger_NoLock -extern FxI32 FX_grGetInteger_NoLock(FxU32 pname); - - - -/* - * GrHints - */ -#define FX_grHints FX_grHints_NoLock -extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask); - - - -/* - * Needed for Glide3 only, to set up Glide2 compatible vertex layout. - */ -extern void FX_setupGrVertexLayout(void); - - - -/* - * grSstControl stuff - */ -extern FxBool FX_grSstControl(FxU32 code); - -#define FX_grBufferClear(c, a, d) \ - do { \ - BEGIN_CLIP_LOOP(); \ - grBufferClear(c, a, d); \ - END_CLIP_LOOP(); \ - } while (0) - - - -#endif /* __FX_GLIDE_WARPER__ */ diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c deleted file mode 100644 index 9bb352fcb8..0000000000 --- a/src/mesa/drivers/glide/fxsetup.c +++ /dev/null @@ -1,2220 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * Copyright (C) 1999-2001 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. - */ - -/* Authors: - * David Bucciarelli - * Brian Paul - * Daryll Strauss - * Keith Whitwell - * Daniel Borca - * Hiroshi Morii - */ - -/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */ - - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#if defined(FX) - -#include "fxdrv.h" -#include "main/enums.h" -#include "main/formats.h" -#include "main/texstore.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "swrast/swrast.h" - - -static void -fxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj) -{ - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - GLint minl, maxl; - - if (ti->validated) { - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxTexValidate(NOP)\n"); - } - return; - } - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxTexValidate(%p (%d))\n", (void *)tObj, tObj->Name); - } - - ti->tObj = tObj; - minl = ti->minLevel = tObj->BaseLevel; - maxl = ti->maxLevel = MIN2(tObj->MaxLevel, tObj->Image[0][0]->MaxLog2); - -#if FX_RESCALE_BIG_TEXURES_HACK -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - /* [dBorca] - * Fake textures larger than HW supports: - * 1) we have mipmaps. Then we just push up to the first supported - * LOD. A possible drawback is that Mesa will ignore the skipped - * LODs on further texture handling. - * Will this interfere with GL_TEXTURE_[MIN|BASE]_LEVEL? How? - * 2) we don't have mipmaps. We need to rescale the big LOD in place. - * The above approach is somehow dumb! we might have rescaled - * once in TexImage2D to accomodate aspect ratio, and now we - * are rescaling again. The thing is, in TexImage2D we don't - * know whether we'll hit 1) or 2) by the time of validation. - */ - if ((tObj->MinFilter == GL_NEAREST) || (tObj->MinFilter == GL_LINEAR)) { - /* no mipmaps! */ - struct gl_texture_image *texImage = tObj->Image[0][minl]; - tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - GLint _w, _h, maxSize = 1 << fxMesa->textureMaxLod; - if ((mml->width > maxSize) || (mml->height > maxSize)) { - /* need to rescale */ - GLint texelBytes = _mesa_get_format_bytes(texImage->TexFormat->MesaFormat); - GLvoid *texImage_Data = texImage->Data; - _w = MIN2(texImage->Width, maxSize); - _h = MIN2(texImage->Height, maxSize); - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxTexValidate: rescaling %d x %d -> %d x %d\n", - texImage->Width, texImage->Height, _w, _h); - } - /* we should leave these as is and... (!) */ - texImage->Width = _w; - texImage->Height = _h; - fxTexGetInfo(_w, _h, NULL, NULL, NULL, NULL, - &(mml->wScale), &(mml->hScale)); - _w *= mml->wScale; - _h *= mml->hScale; - texImage->Data = malloc(_w * _h * texelBytes); - _mesa_rescale_teximage2d(texelBytes, - mml->width, - _w * texelBytes, /* dst stride */ - mml->width, mml->height, /* src */ - _w, _h, /* dst */ - texImage_Data /*src*/, texImage->Data /*dst*/ ); - free(texImage_Data); - mml->width = _w; - mml->height = _h; - /* (!) ... and set mml->wScale = _w / texImage->Width */ - } - } else { - /* mipmapping */ - if (maxl - minl > fxMesa->textureMaxLod) { - /* skip a certain number of LODs */ - minl += maxl - fxMesa->textureMaxLod; - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxTexValidate: skipping %d LODs\n", minl - ti->minLevel); - } - ti->minLevel = tObj->BaseLevel = minl; - } - } -} -#endif - - fxTexGetInfo(tObj->Image[0][minl]->Width, tObj->Image[0][minl]->Height, - &(FX_largeLodLog2(ti->info)), &(FX_aspectRatioLog2(ti->info)), - &(ti->sScale), &(ti->tScale), - NULL, NULL); - - if ((tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR)) - fxTexGetInfo(tObj->Image[0][maxl]->Width, tObj->Image[0][maxl]->Height, - &(FX_smallLodLog2(ti->info)), NULL, - NULL, NULL, NULL, NULL); - else - FX_smallLodLog2(ti->info) = FX_largeLodLog2(ti->info); - - /* [dBorca] this is necessary because of fxDDCompressedTexImage2D */ - if (ti->padded) { - struct gl_texture_image *texImage = tObj->Image[0][minl]; - tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - if (mml->wScale != 1 || mml->hScale != 1) { - ti->sScale /= mml->wScale; - ti->tScale /= mml->hScale; - } - } - - ti->baseLevelInternalFormat = tObj->Image[0][minl]->Format; - - ti->validated = GL_TRUE; - - ti->info.data = NULL; -} - -static void -fxPrintUnitsMode(const char *msg, GLuint mode) -{ - fprintf(stderr, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", - msg, - mode, - (mode & FX_UM_E0_REPLACE) ? "E0_REPLACE, " : "", - (mode & FX_UM_E0_MODULATE) ? "E0_MODULATE, " : "", - (mode & FX_UM_E0_DECAL) ? "E0_DECAL, " : "", - (mode & FX_UM_E0_BLEND) ? "E0_BLEND, " : "", - (mode & FX_UM_E1_REPLACE) ? "E1_REPLACE, " : "", - (mode & FX_UM_E1_MODULATE) ? "E1_MODULATE, " : "", - (mode & FX_UM_E1_DECAL) ? "E1_DECAL, " : "", - (mode & FX_UM_E1_BLEND) ? "E1_BLEND, " : "", - (mode & FX_UM_E0_ALPHA) ? "E0_ALPHA, " : "", - (mode & FX_UM_E0_LUMINANCE) ? "E0_LUMINANCE, " : "", - (mode & FX_UM_E0_LUMINANCE_ALPHA) ? "E0_LUMINANCE_ALPHA, " : "", - (mode & FX_UM_E0_INTENSITY) ? "E0_INTENSITY, " : "", - (mode & FX_UM_E0_RGB) ? "E0_RGB, " : "", - (mode & FX_UM_E0_RGBA) ? "E0_RGBA, " : "", - (mode & FX_UM_E1_ALPHA) ? "E1_ALPHA, " : "", - (mode & FX_UM_E1_LUMINANCE) ? "E1_LUMINANCE, " : "", - (mode & FX_UM_E1_LUMINANCE_ALPHA) ? "E1_LUMINANCE_ALPHA, " : "", - (mode & FX_UM_E1_INTENSITY) ? "E1_INTENSITY, " : "", - (mode & FX_UM_E1_RGB) ? "E1_RGB, " : "", - (mode & FX_UM_E1_RGBA) ? "E1_RGBA, " : "", - (mode & FX_UM_COLOR_ITERATED) ? "COLOR_ITERATED, " : "", - (mode & FX_UM_COLOR_CONSTANT) ? "COLOR_CONSTANT, " : "", - (mode & FX_UM_ALPHA_ITERATED) ? "ALPHA_ITERATED, " : "", - (mode & FX_UM_ALPHA_CONSTANT) ? "ALPHA_CONSTANT, " : ""); -} - -static GLuint -fxGetTexSetConfiguration(GLcontext * ctx, - struct gl_texture_object *tObj0, - struct gl_texture_object *tObj1) -{ - GLuint unitsmode = 0; - GLuint envmode = 0; - GLuint ifmt = 0; - - if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 || - (ctx->Point.SmoothFlag) || - (ctx->Line.SmoothFlag) || - (ctx->Polygon.SmoothFlag)) unitsmode |= FX_UM_ALPHA_ITERATED; - else - unitsmode |= FX_UM_ALPHA_CONSTANT; - - if (ctx->Light.ShadeModel == GL_SMOOTH || 1) - unitsmode |= FX_UM_COLOR_ITERATED; - else - unitsmode |= FX_UM_COLOR_CONSTANT; - - - - /* - OpenGL Feeds Texture 0 into Texture 1 - Glide Feeds Texture 1 into Texture 0 - */ - if (tObj0) { - tfxTexInfo *ti0 = fxTMGetTexInfo(tObj0); - - switch (ti0->baseLevelInternalFormat) { - case GL_ALPHA: - ifmt |= FX_UM_E0_ALPHA; - break; - case GL_LUMINANCE: - ifmt |= FX_UM_E0_LUMINANCE; - break; - case GL_LUMINANCE_ALPHA: - ifmt |= FX_UM_E0_LUMINANCE_ALPHA; - break; - case GL_INTENSITY: - ifmt |= FX_UM_E0_INTENSITY; - break; - case GL_RGB: - ifmt |= FX_UM_E0_RGB; - break; - case GL_RGBA: - ifmt |= FX_UM_E0_RGBA; - break; - } - - switch (ctx->Texture.Unit[0].EnvMode) { - case GL_DECAL: - envmode |= FX_UM_E0_DECAL; - break; - case GL_MODULATE: - envmode |= FX_UM_E0_MODULATE; - break; - case GL_REPLACE: - envmode |= FX_UM_E0_REPLACE; - break; - case GL_BLEND: - envmode |= FX_UM_E0_BLEND; - break; - case GL_ADD: - envmode |= FX_UM_E0_ADD; - break; - default: - /* do nothing */ - break; - } - } - - if (tObj1) { - tfxTexInfo *ti1 = fxTMGetTexInfo(tObj1); - - switch (ti1->baseLevelInternalFormat) { - case GL_ALPHA: - ifmt |= FX_UM_E1_ALPHA; - break; - case GL_LUMINANCE: - ifmt |= FX_UM_E1_LUMINANCE; - break; - case GL_LUMINANCE_ALPHA: - ifmt |= FX_UM_E1_LUMINANCE_ALPHA; - break; - case GL_INTENSITY: - ifmt |= FX_UM_E1_INTENSITY; - break; - case GL_RGB: - ifmt |= FX_UM_E1_RGB; - break; - case GL_RGBA: - ifmt |= FX_UM_E1_RGBA; - break; - default: - /* do nothing */ - break; - } - - switch (ctx->Texture.Unit[1].EnvMode) { - case GL_DECAL: - envmode |= FX_UM_E1_DECAL; - break; - case GL_MODULATE: - envmode |= FX_UM_E1_MODULATE; - break; - case GL_REPLACE: - envmode |= FX_UM_E1_REPLACE; - break; - case GL_BLEND: - envmode |= FX_UM_E1_BLEND; - break; - case GL_ADD: - envmode |= FX_UM_E1_ADD; - break; - default: - /* do nothing */ - break; - } - } - - unitsmode |= (ifmt | envmode); - - if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) - fxPrintUnitsMode("fxGetTexSetConfiguration", unitsmode); - - return unitsmode; -} - -/************************************************************************/ -/************************* Rendering Mode SetUp *************************/ -/************************************************************************/ - -/************************* Single Texture Set ***************************/ - -static void -fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj) -{ - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - int tmu; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupSingleTMU_NoLock(%p (%d))\n", (void *)tObj, tObj->Name); - } - - ti->lastTimeUsed = fxMesa->texBindNumber; - - /* Make sure we're not loaded incorrectly */ - if (ti->isInTM) { - if (ti->LODblend) { - if (ti->whichTMU != FX_TMU_SPLIT) - fxTMMoveOutTM(fxMesa, tObj); - } - else { - if (ti->whichTMU == FX_TMU_SPLIT) - fxTMMoveOutTM(fxMesa, tObj); - } - } - - /* Make sure we're loaded correctly */ - if (!ti->isInTM) { - if (ti->LODblend) - fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU_SPLIT); - else { - if (fxMesa->haveTwoTMUs) { - if (fxTMCheckStartAddr(fxMesa, FX_TMU0, ti)) { - fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0); - } - else { - fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU1); - } - } - else - fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0); - } - } - - if (ti->LODblend && ti->whichTMU == FX_TMU_SPLIT) { - /* broadcast */ - if ((ti->info.format == GR_TEXFMT_P_8) - && (!fxMesa->haveGlobalPaletteTexture)) { - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupSingleTMU_NoLock: uploading texture palette\n"); - } - grTexDownloadTable(ti->paltype, &(ti->palette)); - } - - grTexClampMode(GR_TMU0, ti->sClamp, ti->tClamp); - grTexClampMode(GR_TMU1, ti->sClamp, ti->tClamp); - grTexFilterMode(GR_TMU0, ti->minFilt, ti->maxFilt); - grTexFilterMode(GR_TMU1, ti->minFilt, ti->maxFilt); - grTexMipMapMode(GR_TMU0, ti->mmMode, ti->LODblend); - grTexMipMapMode(GR_TMU1, ti->mmMode, ti->LODblend); - - grTexSource(GR_TMU0, ti->tm[FX_TMU0]->startAddr, - GR_MIPMAPLEVELMASK_ODD, &(ti->info)); - grTexSource(GR_TMU1, ti->tm[FX_TMU1]->startAddr, - GR_MIPMAPLEVELMASK_EVEN, &(ti->info)); - } - else { - if (ti->whichTMU == FX_TMU_BOTH) - tmu = FX_TMU0; - else - tmu = ti->whichTMU; - - /* pointcast */ - if ((ti->info.format == GR_TEXFMT_P_8) - && (!fxMesa->haveGlobalPaletteTexture)) { - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupSingleTMU_NoLock: uploading texture palette\n"); - } - fxMesa->Glide.grTexDownloadTableExt(tmu, ti->paltype, &(ti->palette)); - } - - /* KW: The alternative is to do the download to the other tmu. If - * we get to this point, I think it means we are thrashing the - * texture memory, so perhaps it's not a good idea. - */ - if (ti->LODblend && (TDFX_DEBUG & VERBOSE_DRIVER)) { - fprintf(stderr, "fxSetupSingleTMU_NoLock: not blending texture - only one tmu\n"); - } - - grTexClampMode(tmu, ti->sClamp, ti->tClamp); - grTexFilterMode(tmu, ti->minFilt, ti->maxFilt); - grTexMipMapMode(tmu, ti->mmMode, FXFALSE); - - grTexSource(tmu, ti->tm[tmu]->startAddr, GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); - } -} - -static void -fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, FxBool LODblend) -{ - struct tdfx_texcombine tex0, tex1; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSelectSingleTMUSrc_NoLock(%d, %d)\n", tmu, LODblend); - } - - tex0.InvertRGB = FXFALSE; - tex0.InvertAlpha = FXFALSE; - tex1.InvertRGB = FXFALSE; - tex1.InvertAlpha = FXFALSE; - - if (LODblend) { - tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND; - tex0.FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND; - tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION; - - tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - - fxMesa->tmuSrc = FX_TMU_SPLIT; - } - else { - if (tmu != FX_TMU1) { - tex0.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex0.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex0.FactorAlpha = GR_COMBINE_FACTOR_NONE; - - tex1.FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_ZERO; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - - fxMesa->tmuSrc = FX_TMU0; - } - else { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - - /* correct values to set TMU0 in passthrough mode */ - tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND; - tex0.FactorRGB = GR_COMBINE_FACTOR_ONE; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND; - tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE; - - fxMesa->tmuSrc = FX_TMU1; - } - } - - grTexCombine(GR_TMU0, - tex0.FunctionRGB, - tex0.FactorRGB, - tex0.FunctionAlpha, - tex0.FactorAlpha, - tex0.InvertRGB, - tex0.InvertAlpha); - if (fxMesa->haveTwoTMUs) { - grTexCombine(GR_TMU1, - tex1.FunctionRGB, - tex1.FactorRGB, - tex1.FunctionAlpha, - tex1.FactorAlpha, - tex1.InvertRGB, - tex1.InvertAlpha); - } -} - -static void -fxSetupTextureSingleTMU_NoLock(GLcontext * ctx, GLuint textureset) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - struct tdfx_combine alphaComb, colorComb; - GrCombineLocal_t localc, locala; - GLuint unitsmode; - GLint ifmt; - tfxTexInfo *ti; - struct gl_texture_object *tObj = ctx->Texture.Unit[textureset]._Current; - int tmu; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupTextureSingleTMU_NoLock(%d)\n", textureset); - } - - ti = fxTMGetTexInfo(tObj); - - fxTexValidate(ctx, tObj); - - fxSetupSingleTMU_NoLock(fxMesa, tObj); - - if (ti->whichTMU == FX_TMU_BOTH) - tmu = FX_TMU0; - else - tmu = ti->whichTMU; - if (fxMesa->tmuSrc != tmu) - fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend); - - if (textureset == 0 || !fxMesa->haveTwoTMUs) - unitsmode = fxGetTexSetConfiguration(ctx, tObj, NULL); - else - unitsmode = fxGetTexSetConfiguration(ctx, NULL, tObj); - -/* if(fxMesa->lastUnitsMode==unitsmode) */ -/* return; */ - - fxMesa->lastUnitsMode = unitsmode; - - fxMesa->stw_hint_state = 0; - FX_grHints_NoLock(GR_HINT_STWHINT, 0); - - ifmt = ti->baseLevelInternalFormat; - - if (unitsmode & FX_UM_ALPHA_ITERATED) - locala = GR_COMBINE_LOCAL_ITERATED; - else - locala = GR_COMBINE_LOCAL_CONSTANT; - - if (unitsmode & FX_UM_COLOR_ITERATED) - localc = GR_COMBINE_LOCAL_ITERATED; - else - localc = GR_COMBINE_LOCAL_CONSTANT; - - if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) - fprintf(stderr, "fxSetupTextureSingleTMU_NoLock: envmode is %s\n", - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode)); - - alphaComb.Local = locala; - alphaComb.Invert = FXFALSE; - colorComb.Local = localc; - colorComb.Invert = FXFALSE; - - switch (ctx->Texture.Unit[textureset].EnvMode) { - case GL_DECAL: - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - - colorComb.Function = GR_COMBINE_FUNCTION_BLEND; - colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - break; - case GL_MODULATE: - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - - if (ifmt == GL_ALPHA) { - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Other = GR_COMBINE_OTHER_NONE; - } else { - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_LOCAL; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - } - break; - case GL_BLEND: - if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) { - /* Av = Af */ - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - } - else if (ifmt == GL_INTENSITY) { - /* Av = Af * (1 - It) + Ac * It */ - alphaComb.Function = GR_COMBINE_FUNCTION_BLEND; - alphaComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA; - alphaComb.Other = GR_COMBINE_OTHER_CONSTANT; - } - else { - /* Av = Af * At */ - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - } - - if (ifmt == GL_ALPHA) { - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Other = GR_COMBINE_OTHER_NONE; - } else { - if (fxMesa->type >= GR_SSTTYPE_Voodoo2) { - colorComb.Function = GR_COMBINE_FUNCTION_BLEND; - colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_RGB; - colorComb.Other = GR_COMBINE_OTHER_CONSTANT; - } else if (ifmt == GL_INTENSITY) { - /* just a hack: RGB == ALPHA */ - colorComb.Function = GR_COMBINE_FUNCTION_BLEND; - colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA; - colorComb.Other = GR_COMBINE_OTHER_CONSTANT; - } else { - /* Only Voodoo^2 can GL_BLEND (GR_COMBINE_FACTOR_TEXTURE_RGB) - * These settings assume that the TexEnv color is black and - * incoming fragment color is white. - */ - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - colorComb.Invert = FXTRUE; - _mesa_problem(NULL, "can't GL_BLEND with SST1"); - } - } - - grConstantColorValue( - (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[0] * 255.0f)) ) | - (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[1] * 255.0f)) << 8) | - (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[2] * 255.0f)) << 16) | - (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[3] * 255.0f)) << 24)); - break; - case GL_REPLACE: - if ((ifmt == GL_RGB) || (ifmt == GL_LUMINANCE)) { - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - } else { - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_ONE; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - } - - if (ifmt == GL_ALPHA) { - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Other = GR_COMBINE_OTHER_NONE; - } else { - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - } - break; - case GL_ADD: - if (ifmt == GL_ALPHA || - ifmt == GL_LUMINANCE_ALPHA || - ifmt == GL_RGBA) { - /* product of texel and fragment alpha */ - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - } - else if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) { - /* fragment alpha is unchanged */ - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - } - else { - /* sum of texel and fragment alpha */ - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_ONE; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - } - - if (ifmt == GL_ALPHA) { - /* rgb unchanged */ - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Other = GR_COMBINE_OTHER_NONE; - } - else { - /* sum of texel and fragment rgb */ - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - } - break; - default: - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupTextureSingleTMU_NoLock: %x Texture.EnvMode not yet supported\n", - ctx->Texture.Unit[textureset].EnvMode); - } - return; - } - - grAlphaCombine(alphaComb.Function, - alphaComb.Factor, - alphaComb.Local, - alphaComb.Other, - alphaComb.Invert); - grColorCombine(colorComb.Function, - colorComb.Factor, - colorComb.Local, - colorComb.Other, - colorComb.Invert); -} - -#if 00 -static void -fxSetupTextureSingleTMU(GLcontext * ctx, GLuint textureset) -{ - BEGIN_BOARD_LOCK(); - fxSetupTextureSingleTMU_NoLock(ctx, textureset); - END_BOARD_LOCK(); -} -#endif - - -/************************* Double Texture Set ***************************/ - -static void -fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, - struct gl_texture_object *tObj0, - struct gl_texture_object *tObj1) -{ -#define T0_NOT_IN_TMU 0x01 -#define T1_NOT_IN_TMU 0x02 -#define T0_IN_TMU0 0x04 -#define T1_IN_TMU0 0x08 -#define T0_IN_TMU1 0x10 -#define T1_IN_TMU1 0x20 - - tfxTexInfo *ti0 = fxTMGetTexInfo(tObj0); - tfxTexInfo *ti1 = fxTMGetTexInfo(tObj1); - GLuint tstate = 0; - int tmu0 = 0, tmu1 = 1; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupDoubleTMU_NoLock(...)\n"); - } - - /* We shouldn't need to do this. There is something wrong with - mutlitexturing when the TMUs are swapped. So, we're forcing - them to always be loaded correctly. !!! */ - if (ti0->whichTMU == FX_TMU1) - fxTMMoveOutTM_NoLock(fxMesa, tObj0); - if (ti1->whichTMU == FX_TMU0) - fxTMMoveOutTM_NoLock(fxMesa, tObj1); - - if (ti0->isInTM) { - switch (ti0->whichTMU) { - case FX_TMU0: - tstate |= T0_IN_TMU0; - break; - case FX_TMU1: - tstate |= T0_IN_TMU1; - break; - case FX_TMU_BOTH: - tstate |= T0_IN_TMU0 | T0_IN_TMU1; - break; - case FX_TMU_SPLIT: - tstate |= T0_NOT_IN_TMU; - break; - } - } - else - tstate |= T0_NOT_IN_TMU; - - if (ti1->isInTM) { - switch (ti1->whichTMU) { - case FX_TMU0: - tstate |= T1_IN_TMU0; - break; - case FX_TMU1: - tstate |= T1_IN_TMU1; - break; - case FX_TMU_BOTH: - tstate |= T1_IN_TMU0 | T1_IN_TMU1; - break; - case FX_TMU_SPLIT: - tstate |= T1_NOT_IN_TMU; - break; - } - } - else - tstate |= T1_NOT_IN_TMU; - - ti0->lastTimeUsed = fxMesa->texBindNumber; - ti1->lastTimeUsed = fxMesa->texBindNumber; - - /* Move texture maps into TMUs */ - - if (!(((tstate & T0_IN_TMU0) && (tstate & T1_IN_TMU1)) || - ((tstate & T0_IN_TMU1) && (tstate & T1_IN_TMU0)))) { - if (tObj0 == tObj1) - fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU_BOTH); - else { - /* Find the minimal way to correct the situation */ - if ((tstate & T0_IN_TMU0) || (tstate & T1_IN_TMU1)) { - /* We have one in the standard order, setup the other */ - if (tstate & T0_IN_TMU0) { /* T0 is in TMU0, put T1 in TMU1 */ - fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1); - } - else { - fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0); - } - /* tmu0 and tmu1 are setup */ - } - else if ((tstate & T0_IN_TMU1) || (tstate & T1_IN_TMU0)) { - /* we have one in the reverse order, setup the other */ - if (tstate & T1_IN_TMU0) { /* T1 is in TMU0, put T0 in TMU1 */ - fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU1); - } - else { - fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0); - } - tmu0 = 1; - tmu1 = 0; - } - else { /* Nothing is loaded */ - fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0); - fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1); - /* tmu0 and tmu1 are setup */ - } - } - } - - /* [dBorca] Hack alert: - * we put these in reverse order, so that if we can't - * do _REAL_ pointcast, the TMU0 table gets broadcasted - */ - if (!fxMesa->haveGlobalPaletteTexture) { - /* pointcast */ - if (ti1->info.format == GR_TEXFMT_P_8) { - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupDoubleTMU_NoLock: uploading texture palette for TMU1\n"); - } - fxMesa->Glide.grTexDownloadTableExt(ti1->whichTMU, ti1->paltype, &(ti1->palette)); - } - if (ti0->info.format == GR_TEXFMT_P_8) { - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupDoubleTMU_NoLock: uploading texture palette for TMU0\n"); - } - fxMesa->Glide.grTexDownloadTableExt(ti0->whichTMU, ti0->paltype, &(ti0->palette)); - } - } - - grTexSource(tmu0, ti0->tm[tmu0]->startAddr, - GR_MIPMAPLEVELMASK_BOTH, &(ti0->info)); - grTexClampMode(tmu0, ti0->sClamp, ti0->tClamp); - grTexFilterMode(tmu0, ti0->minFilt, ti0->maxFilt); - grTexMipMapMode(tmu0, ti0->mmMode, FXFALSE); - - grTexSource(tmu1, ti1->tm[tmu1]->startAddr, - GR_MIPMAPLEVELMASK_BOTH, &(ti1->info)); - grTexClampMode(tmu1, ti1->sClamp, ti1->tClamp); - grTexFilterMode(tmu1, ti1->minFilt, ti1->maxFilt); - grTexMipMapMode(tmu1, ti1->mmMode, FXFALSE); - -#undef T0_NOT_IN_TMU -#undef T1_NOT_IN_TMU -#undef T0_IN_TMU0 -#undef T1_IN_TMU0 -#undef T0_IN_TMU1 -#undef T1_IN_TMU1 -} - -static void -fxSetupTextureDoubleTMU_NoLock(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - struct tdfx_combine alphaComb, colorComb; - struct tdfx_texcombine tex0, tex1; - GrCombineLocal_t localc, locala; - tfxTexInfo *ti0, *ti1; - struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current; - struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current; - GLuint envmode, ifmt, unitsmode; - int tmu0 = 0, tmu1 = 1; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupTextureDoubleTMU_NoLock(...)\n"); - } - - ti0 = fxTMGetTexInfo(tObj0); - fxTexValidate(ctx, tObj0); - - ti1 = fxTMGetTexInfo(tObj1); - fxTexValidate(ctx, tObj1); - - fxSetupDoubleTMU_NoLock(fxMesa, tObj0, tObj1); - - unitsmode = fxGetTexSetConfiguration(ctx, tObj0, tObj1); - -/* if(fxMesa->lastUnitsMode==unitsmode) */ -/* return; */ - - fxMesa->lastUnitsMode = unitsmode; - - fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1; - FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state); - - envmode = unitsmode & FX_UM_E_ENVMODE; - ifmt = unitsmode & FX_UM_E_IFMT; - - if (unitsmode & FX_UM_ALPHA_ITERATED) - locala = GR_COMBINE_LOCAL_ITERATED; - else - locala = GR_COMBINE_LOCAL_CONSTANT; - - if (unitsmode & FX_UM_COLOR_ITERATED) - localc = GR_COMBINE_LOCAL_ITERATED; - else - localc = GR_COMBINE_LOCAL_CONSTANT; - - - if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) - fprintf(stderr, "fxSetupTextureDoubleTMU_NoLock: envmode is %s/%s\n", - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode), - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode)); - - - if ((ti0->whichTMU == FX_TMU1) || (ti1->whichTMU == FX_TMU0)) { - tmu0 = 1; - tmu1 = 0; - } - fxMesa->tmuSrc = FX_TMU_BOTH; - - tex0.InvertRGB = FXFALSE; - tex0.InvertAlpha = FXFALSE; - tex1.InvertRGB = FXFALSE; - tex1.InvertAlpha = FXFALSE; - alphaComb.Local = locala; - alphaComb.Invert = FXFALSE; - colorComb.Local = localc; - colorComb.Invert = FXFALSE; - - switch (envmode) { - case (FX_UM_E0_MODULATE | FX_UM_E1_MODULATE): - { - GLboolean isalpha[FX_NUM_TMU]; - - isalpha[tmu0] = (ti0->baseLevelInternalFormat == GL_ALPHA); - isalpha[tmu1] = (ti1->baseLevelInternalFormat == GL_ALPHA); - - if (isalpha[FX_TMU1]) { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - tex1.InvertRGB = FXTRUE; - } else { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - } - - if (isalpha[FX_TMU0]) { - tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorRGB = GR_COMBINE_FACTOR_ONE; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - } else { - tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorRGB = GR_COMBINE_FACTOR_LOCAL; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - } - - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_LOCAL; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - break; - } - case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND): /* Only for GLQuake */ - if (tmu0 == FX_TMU1) { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - tex1.InvertRGB = FXTRUE; - - tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorRGB = GR_COMBINE_FACTOR_LOCAL; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - } - else { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - - tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL; - } - - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - break; - case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE): /* Quake 2 and 3 */ - if (tmu1 == FX_TMU1) { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_ZERO; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - tex1.InvertAlpha = FXTRUE; - - tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorRGB = GR_COMBINE_FACTOR_LOCAL; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - } - else { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - - tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorRGB = GR_COMBINE_FACTOR_LOCAL; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE; - } - - if (ti0->baseLevelInternalFormat == GL_RGB) { - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - } else { - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_ONE; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - } - - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - break; - - - case (FX_UM_E0_MODULATE | FX_UM_E1_ADD): /* Quake 3 Sky */ - { - GLboolean isalpha[FX_NUM_TMU]; - - isalpha[tmu0] = (ti0->baseLevelInternalFormat == GL_ALPHA); - isalpha[tmu1] = (ti1->baseLevelInternalFormat == GL_ALPHA); - - if (isalpha[FX_TMU1]) { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - tex1.InvertRGB = FXTRUE; - } else { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - } - - if (isalpha[FX_TMU0]) { - tex0.FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER; - tex0.FactorRGB = GR_COMBINE_FACTOR_ONE; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE; - } else { - tex0.FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - tex0.FactorRGB = GR_COMBINE_FACTOR_ONE; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE; - } - - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_LOCAL; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - break; - } - - case (FX_UM_E0_REPLACE | FX_UM_E1_ADD): /* Vulpine Sky */ - { - GLboolean isalpha[FX_NUM_TMU]; - - isalpha[tmu0] = (ti0->baseLevelInternalFormat == GL_ALPHA); - isalpha[tmu1] = (ti1->baseLevelInternalFormat == GL_ALPHA); - - if (isalpha[FX_TMU1]) { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - tex1.InvertRGB = FXTRUE; - } else { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - } - - if (isalpha[FX_TMU0]) { - tex0.FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER; - tex0.FactorRGB = GR_COMBINE_FACTOR_ONE; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE; - } else { - tex0.FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - tex0.FactorRGB = GR_COMBINE_FACTOR_ONE; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE; - } - - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_ONE; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - break; - } - - case (FX_UM_E0_MODULATE | FX_UM_E1_REPLACE): /* Homeworld2 */ - { - tex1.FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - tex1.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex1.FunctionAlpha = GR_COMBINE_FUNCTION_ZERO; - tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE; - - tex0.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - tex0.FactorRGB = GR_COMBINE_FACTOR_NONE; - tex0.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - tex0.FactorAlpha = GR_COMBINE_FACTOR_NONE; - - if (ifmt & (FX_UM_E0_RGB | FX_UM_E0_LUMINANCE)) { - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - } else { - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_ONE; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - } - - if (ifmt & FX_UM_E0_ALPHA) { - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Other = GR_COMBINE_OTHER_NONE; - } else { - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - } - break; - } - default: - fprintf(stderr, "fxSetupTextureDoubleTMU_NoLock: Unexpected dual texture mode encountered\n"); - return; - } - - grAlphaCombine(alphaComb.Function, - alphaComb.Factor, - alphaComb.Local, - alphaComb.Other, - alphaComb.Invert); - grColorCombine(colorComb.Function, - colorComb.Factor, - colorComb.Local, - colorComb.Other, - colorComb.Invert); - grTexCombine(GR_TMU0, - tex0.FunctionRGB, - tex0.FactorRGB, - tex0.FunctionAlpha, - tex0.FactorAlpha, - tex0.InvertRGB, - tex0.InvertAlpha); - grTexCombine(GR_TMU1, - tex1.FunctionRGB, - tex1.FactorRGB, - tex1.FunctionAlpha, - tex1.FactorAlpha, - tex1.InvertRGB, - tex1.InvertAlpha); -} - -/************************* No Texture ***************************/ - -static void -fxSetupTextureNone_NoLock(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrCombineLocal_t localc, locala; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupTextureNone_NoLock(...)\n"); - } - - if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 || - (ctx->Point.SmoothFlag) || - (ctx->Line.SmoothFlag) || - (ctx->Polygon.SmoothFlag)) locala = GR_COMBINE_LOCAL_ITERATED; - else - locala = GR_COMBINE_LOCAL_CONSTANT; - - if (ctx->Light.ShadeModel == GL_SMOOTH || 1) - localc = GR_COMBINE_LOCAL_ITERATED; - else - localc = GR_COMBINE_LOCAL_CONSTANT; - - grAlphaCombine(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - grColorCombine(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - localc, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - fxMesa->lastUnitsMode = FX_UM_NONE; -} - -#include "fxsetup.h" - -/************************************************************************/ -/************************** Texture Mode SetUp **************************/ -/************************************************************************/ - -static void -fxSetupTexture_NoLock(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupTexture_NoLock(...)\n"); - } - - if (fxMesa->HaveCmbExt) { - /* Texture Combine, Color Combine and Alpha Combine. */ - if ((ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) && - (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) && - fxMesa->haveTwoTMUs) { - fxSetupTextureDoubleTMUNapalm_NoLock(ctx); - } - else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - fxSetupTextureSingleTMUNapalm_NoLock(ctx, 0); - } - else if (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - fxSetupTextureSingleTMUNapalm_NoLock(ctx, 1); - } - else { - fxSetupTextureNoneNapalm_NoLock(ctx); - } - } else { - /* Texture Combine, Color Combine and Alpha Combine. */ - if ((ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) && - (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) && - fxMesa->haveTwoTMUs) { - fxSetupTextureDoubleTMU_NoLock(ctx); - } - else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - fxSetupTextureSingleTMU_NoLock(ctx, 0); - } - else if (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - fxSetupTextureSingleTMU_NoLock(ctx, 1); - } - else { - fxSetupTextureNone_NoLock(ctx); - } - } -} - -void -fxSetupTexture(GLcontext * ctx) -{ - BEGIN_BOARD_LOCK(); - fxSetupTexture_NoLock(ctx); - END_BOARD_LOCK(); -} - -/************************************************************************/ -/**************************** Blend SetUp *******************************/ -/************************************************************************/ - -void -fxDDBlendFuncSeparate(GLcontext * ctx, GLenum sfactor, GLenum dfactor, GLenum asfactor, GLenum adfactor) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - GLboolean isNapalm = (fxMesa->type >= GR_SSTTYPE_Voodoo4); - GLboolean have32bpp = (fxMesa->colDepth == 32); - GLboolean haveAlpha = fxMesa->haveHwAlpha; - GrAlphaBlendFnc_t sfact, dfact, asfact, adfact; - - /* - * 15/16 BPP alpha channel alpha blending modes - * 0x0 AZERO Zero - * 0x4 AONE One - * - * 32 BPP alpha channel alpha blending modes - * 0x0 AZERO Zero - * 0x1 ASRC_ALPHA Source alpha - * 0x3 ADST_ALPHA Destination alpha - * 0x4 AONE One - * 0x5 AOMSRC_ALPHA 1 - Source alpha - * 0x7 AOMDST_ALPHA 1 - Destination alpha - * - * If we don't have HW alpha buffer: - * DST_ALPHA == 1 - * ONE_MINUS_DST_ALPHA == 0 - * Unsupported modes are: - * 1 if used as src blending factor - * 0 if used as dst blending factor - */ - - switch (sfactor) { - case GL_ZERO: - sfact = GR_BLEND_ZERO; - break; - case GL_ONE: - sfact = GR_BLEND_ONE; - break; - case GL_DST_COLOR: - sfact = GR_BLEND_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - sfact = GR_BLEND_ONE_MINUS_DST_COLOR; - break; - case GL_SRC_ALPHA: - sfact = GR_BLEND_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - sfact = GR_BLEND_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - sfact = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/; - break; - case GL_ONE_MINUS_DST_ALPHA: - sfact = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/; - break; - case GL_SRC_ALPHA_SATURATE: - sfact = GR_BLEND_ALPHA_SATURATE; - break; - case GL_SRC_COLOR: - if (isNapalm) { - sfact = GR_BLEND_SAME_COLOR_EXT; - break; - } - case GL_ONE_MINUS_SRC_COLOR: - if (isNapalm) { - sfact = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT; - break; - } - default: - sfact = GR_BLEND_ONE; - break; - } - - switch (asfactor) { - case GL_ZERO: - asfact = GR_BLEND_ZERO; - break; - case GL_ONE: - asfact = GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - case GL_SRC_ALPHA: - asfact = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ONE/*bad*/; - break; - case GL_ONE_MINUS_SRC_COLOR: - case GL_ONE_MINUS_SRC_ALPHA: - asfact = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ONE/*bad*/; - break; - case GL_DST_COLOR: - case GL_DST_ALPHA: - asfact = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/; - break; - case GL_ONE_MINUS_DST_COLOR: - case GL_ONE_MINUS_DST_ALPHA: - asfact = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/; - break; - case GL_SRC_ALPHA_SATURATE: - asfact = GR_BLEND_ONE; - break; - default: - asfact = GR_BLEND_ONE; - break; - } - - switch (dfactor) { - case GL_ZERO: - dfact = GR_BLEND_ZERO; - break; - case GL_ONE: - dfact = GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - dfact = GR_BLEND_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - dfact = GR_BLEND_ONE_MINUS_SRC_COLOR; - break; - case GL_SRC_ALPHA: - dfact = GR_BLEND_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - dfact = GR_BLEND_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - dfact = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/; - break; - case GL_ONE_MINUS_DST_ALPHA: - dfact = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/; - break; - case GL_DST_COLOR: - if (isNapalm) { - dfact = GR_BLEND_SAME_COLOR_EXT; - break; - } - case GL_ONE_MINUS_DST_COLOR: - if (isNapalm) { - dfact = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT; - break; - } - default: - dfact = GR_BLEND_ZERO; - break; - } - - switch (adfactor) { - case GL_ZERO: - adfact = GR_BLEND_ZERO; - break; - case GL_ONE: - adfact = GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - case GL_SRC_ALPHA: - adfact = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ZERO/*bad*/; - break; - case GL_ONE_MINUS_SRC_COLOR: - case GL_ONE_MINUS_SRC_ALPHA: - adfact = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ZERO/*bad*/; - break; - case GL_DST_COLOR: - case GL_DST_ALPHA: - adfact = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/; - break; - case GL_ONE_MINUS_DST_COLOR: - case GL_ONE_MINUS_DST_ALPHA: - adfact = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/; - break; - default: - adfact = GR_BLEND_ZERO; - break; - } - - if ((sfact != us->blendSrcFuncRGB) || (asfact != us->blendSrcFuncAlpha)) { - us->blendSrcFuncRGB = sfact; - us->blendSrcFuncAlpha = asfact; - fxMesa->new_state |= FX_NEW_BLEND; - } - - if ((dfact != us->blendDstFuncRGB) || (adfact != us->blendDstFuncAlpha)) { - us->blendDstFuncRGB = dfact; - us->blendDstFuncAlpha = adfact; - fxMesa->new_state |= FX_NEW_BLEND; - } -} - -void -fxDDBlendEquationSeparate(GLcontext * ctx, GLenum modeRGB, GLenum modeA) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - GrAlphaBlendOp_t q; - - switch (modeRGB) { - case GL_FUNC_ADD: - q = GR_BLEND_OP_ADD; - break; - case GL_FUNC_SUBTRACT: - q = GR_BLEND_OP_SUB; - break; - case GL_FUNC_REVERSE_SUBTRACT: - q = GR_BLEND_OP_REVSUB; - break; - default: - q = us->blendEqRGB; - } - if (q != us->blendEqRGB) { - us->blendEqRGB = q; - fxMesa->new_state |= FX_NEW_BLEND; - } - - switch (modeA) { - case GL_FUNC_ADD: - q = GR_BLEND_OP_ADD; - break; - case GL_FUNC_SUBTRACT: - q = GR_BLEND_OP_SUB; - break; - case GL_FUNC_REVERSE_SUBTRACT: - q = GR_BLEND_OP_REVSUB; - break; - default: - q = us->blendEqAlpha; - } - if (q != us->blendEqAlpha) { - us->blendEqAlpha = q; - fxMesa->new_state |= FX_NEW_BLEND; - } -} - -void -fxSetupBlend(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (fxMesa->HavePixExt) { - if (us->blendEnabled) { - fxMesa->Glide.grAlphaBlendFunctionExt(us->blendSrcFuncRGB, us->blendDstFuncRGB, - us->blendEqRGB, - us->blendSrcFuncAlpha, us->blendDstFuncAlpha, - us->blendEqAlpha); - } else { - fxMesa->Glide.grAlphaBlendFunctionExt(GR_BLEND_ONE, GR_BLEND_ZERO, - GR_BLEND_OP_ADD, - GR_BLEND_ONE, GR_BLEND_ZERO, - GR_BLEND_OP_ADD); - } - } else { - if (us->blendEnabled) { - grAlphaBlendFunction(us->blendSrcFuncRGB, us->blendDstFuncRGB, - us->blendSrcFuncAlpha, us->blendDstFuncAlpha); - } else { - grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, - GR_BLEND_ONE, GR_BLEND_ZERO); - } - } -} - -/************************************************************************/ -/************************** Alpha Test SetUp ****************************/ -/************************************************************************/ - -void -fxDDAlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if ( - (us->alphaTestFunc != func) - || - (us->alphaTestRefValue != ref) - ) { - us->alphaTestFunc = func; - us->alphaTestRefValue = ref; - fxMesa->new_state |= FX_NEW_ALPHA; - } -} - -static void -fxSetupAlphaTest(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (us->alphaTestEnabled) { - GrAlpha_t ref = (GLint) (us->alphaTestRefValue * 255.0); - grAlphaTestFunction(us->alphaTestFunc - GL_NEVER + GR_CMP_NEVER); - grAlphaTestReferenceValue(ref); - } - else - grAlphaTestFunction(GR_CMP_ALWAYS); -} - -/************************************************************************/ -/************************** Depth Test SetUp ****************************/ -/************************************************************************/ - -void -fxDDDepthFunc(GLcontext * ctx, GLenum func) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (us->depthTestFunc != func) { - us->depthTestFunc = func; - fxMesa->new_state |= FX_NEW_DEPTH; - } -} - -void -fxDDDepthMask(GLcontext * ctx, GLboolean flag) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (flag != us->depthMask) { - us->depthMask = flag; - fxMesa->new_state |= FX_NEW_DEPTH; - } -} - -void -fxSetupDepthTest(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (us->depthTestEnabled) { - grDepthBufferFunction(us->depthTestFunc - GL_NEVER + GR_CMP_NEVER); - grDepthMask(us->depthMask); - } - else { - grDepthBufferFunction(GR_CMP_ALWAYS); - grDepthMask(FXFALSE); - } -} - -/************************************************************************/ -/************************** Stencil SetUp *******************************/ -/************************************************************************/ - -static GrStencil_t convertGLStencilOp( GLenum op ) -{ - switch ( op ) { - case GL_KEEP: - return GR_STENCILOP_KEEP; - case GL_ZERO: - return GR_STENCILOP_ZERO; - case GL_REPLACE: - return GR_STENCILOP_REPLACE; - case GL_INCR: - return GR_STENCILOP_INCR_CLAMP; - case GL_DECR: - return GR_STENCILOP_DECR_CLAMP; - case GL_INVERT: - return GR_STENCILOP_INVERT; - case GL_INCR_WRAP_EXT: - return GR_STENCILOP_INCR_WRAP; - case GL_DECR_WRAP_EXT: - return GR_STENCILOP_DECR_WRAP; - default: - _mesa_problem( NULL, "bad stencil op in convertGLStencilOp" ); - } - return GR_STENCILOP_KEEP; /* never get, silence compiler warning */ -} - -void -fxDDStencilFuncSeparate (GLcontext *ctx, GLenum face, GLenum func, - GLint ref, GLuint mask) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (ctx->Stencil.ActiveFace) { - return; - } - - if ( - (us->stencilFunction != func) - || - (us->stencilRefValue != ref) - || - (us->stencilValueMask != mask) - ) { - us->stencilFunction = func; - us->stencilRefValue = ref; - us->stencilValueMask = mask; - fxMesa->new_state |= FX_NEW_STENCIL; - } -} - -void -fxDDStencilMaskSeparate (GLcontext *ctx, GLenum face, GLuint mask) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (ctx->Stencil.ActiveFace) { - return; - } - - if (us->stencilWriteMask != mask) { - us->stencilWriteMask = mask; - fxMesa->new_state |= FX_NEW_STENCIL; - } -} - -void -fxDDStencilOpSeparate (GLcontext *ctx, GLenum face, GLenum sfail, - GLenum zfail, GLenum zpass) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (ctx->Stencil.ActiveFace) { - return; - } - - if ( - (us->stencilFailFunc != sfail) - || - (us->stencilZFailFunc != zfail) - || - (us->stencilZPassFunc != zpass) - ) { - us->stencilFailFunc = sfail; - us->stencilZFailFunc = zfail; - us->stencilZPassFunc = zpass; - fxMesa->new_state |= FX_NEW_STENCIL; - } -} - -void -fxSetupStencil (GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (us->stencilEnabled) { - GrCmpFnc_t stencilFailFunc = GR_STENCILOP_KEEP; - GrCmpFnc_t stencilZFailFunc = GR_STENCILOP_KEEP; - GrCmpFnc_t stencilZPassFunc = GR_STENCILOP_KEEP; - if (!fxMesa->multipass) { - stencilFailFunc = convertGLStencilOp(us->stencilFailFunc); - stencilZFailFunc = convertGLStencilOp(us->stencilZFailFunc); - stencilZPassFunc = convertGLStencilOp(us->stencilZPassFunc); - } - grEnable(GR_STENCIL_MODE_EXT); - fxMesa->Glide.grStencilOpExt(stencilFailFunc, - stencilZFailFunc, - stencilZPassFunc); - fxMesa->Glide.grStencilFuncExt(us->stencilFunction - GL_NEVER + GR_CMP_NEVER, - us->stencilRefValue, - us->stencilValueMask); - fxMesa->Glide.grStencilMaskExt(us->stencilWriteMask); - } else { - grDisable(GR_STENCIL_MODE_EXT); - } -} - -void -fxSetupStencilFace (GLcontext * ctx, GLint face) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (us->stencilEnabled) { - GrCmpFnc_t stencilFailFunc = GR_STENCILOP_KEEP; - GrCmpFnc_t stencilZFailFunc = GR_STENCILOP_KEEP; - GrCmpFnc_t stencilZPassFunc = GR_STENCILOP_KEEP; - if (!fxMesa->multipass) { - stencilFailFunc = convertGLStencilOp(ctx->Stencil.FailFunc[face]); - stencilZFailFunc = convertGLStencilOp(ctx->Stencil.ZFailFunc[face]); - stencilZPassFunc = convertGLStencilOp(ctx->Stencil.ZPassFunc[face]); - } - grEnable(GR_STENCIL_MODE_EXT); - fxMesa->Glide.grStencilOpExt(stencilFailFunc, - stencilZFailFunc, - stencilZPassFunc); - fxMesa->Glide.grStencilFuncExt(ctx->Stencil.Function[face] - GL_NEVER + GR_CMP_NEVER, - ctx->Stencil.Ref[face], - ctx->Stencil.ValueMask[face]); - fxMesa->Glide.grStencilMaskExt(ctx->Stencil.WriteMask[face]); - } else { - grDisable(GR_STENCIL_MODE_EXT); - } -} - -/************************************************************************/ -/**************************** Color Mask SetUp **************************/ -/************************************************************************/ - -void -fxDDColorMask(GLcontext * ctx, - GLboolean r, GLboolean g, GLboolean b, GLboolean a) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - fxMesa->new_state |= FX_NEW_COLOR_MASK; - (void) r; - (void) g; - (void) b; - (void) a; -} - -void -fxSetupColorMask(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (fxMesa->colDepth == 32) { - /* 32bpp mode */ - fxMesa->Glide.grColorMaskExt(ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] && fxMesa->haveHwAlpha); - } - else { - /* 15/16 bpp mode */ - grColorMask(ctx->Color.ColorMask[RCOMP] | - ctx->Color.ColorMask[GCOMP] | - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] && fxMesa->haveHwAlpha); - } -} - - - - -/************************************************************************/ -/**************************** Fog Mode SetUp ****************************/ -/************************************************************************/ - -/* - * This is called during state update in order to update the Glide fog state. - */ -static void -fxSetupFog(GLcontext * ctx) -{ - if (ctx->Fog.Enabled /*&& ctx->FogMode==FOG_FRAGMENT */ ) { - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - /* update fog color */ - GLubyte col[4]; - col[0] = (unsigned int) (255 * ctx->Fog.Color[0]); - col[1] = (unsigned int) (255 * ctx->Fog.Color[1]); - col[2] = (unsigned int) (255 * ctx->Fog.Color[2]); - col[3] = (unsigned int) (255 * ctx->Fog.Color[3]); - grFogColorValue(FXCOLOR4(col)); - - if (fxMesa->fogTableMode != ctx->Fog.Mode || - fxMesa->fogDensity != ctx->Fog.Density || - fxMesa->fogStart != ctx->Fog.Start || - fxMesa->fogEnd != ctx->Fog.End) { - /* reload the fog table */ - switch (ctx->Fog.Mode) { - case GL_LINEAR: - guFogGenerateLinear(fxMesa->fogTable, ctx->Fog.Start, - ctx->Fog.End); - if (fxMesa->fogTable[0] > 63) { - /* [dBorca] Hack alert: - * As per Glide3 Programming Guide: - * The difference between consecutive fog values - * must be less than 64. - */ - fxMesa->fogTable[0] = 63; - } - break; - case GL_EXP: - guFogGenerateExp(fxMesa->fogTable, ctx->Fog.Density); - break; - case GL_EXP2: - guFogGenerateExp2(fxMesa->fogTable, ctx->Fog.Density); - break; - default: - ; - } - fxMesa->fogTableMode = ctx->Fog.Mode; - fxMesa->fogDensity = ctx->Fog.Density; - fxMesa->fogStart = ctx->Fog.Start; - fxMesa->fogEnd = ctx->Fog.End; - } - - grFogTable(fxMesa->fogTable); - if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) { - grVertexLayout(GR_PARAM_FOG_EXT, GR_VERTEX_FOG_OFFSET << 2, - GR_PARAM_ENABLE); - grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); - } else { - grVertexLayout(GR_PARAM_FOG_EXT, GR_VERTEX_FOG_OFFSET << 2, - GR_PARAM_DISABLE); - grFogMode(GR_FOG_WITH_TABLE_ON_Q); - } - } - else { - grFogMode(GR_FOG_DISABLE); - } -} - -void -fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params) -{ - FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG; - switch (pname) { - case GL_FOG_COORDINATE_SOURCE_EXT: { - GLenum p = (GLenum)*params; - if (p == GL_FOG_COORDINATE_EXT) { - _swrast_allow_vertex_fog(ctx, GL_TRUE); - _swrast_allow_pixel_fog(ctx, GL_FALSE); - _tnl_allow_vertex_fog( ctx, GL_TRUE); - _tnl_allow_pixel_fog( ctx, GL_FALSE); - } else { - _swrast_allow_vertex_fog(ctx, GL_FALSE); - _swrast_allow_pixel_fog(ctx, GL_TRUE); - _tnl_allow_vertex_fog( ctx, GL_FALSE); - _tnl_allow_pixel_fog( ctx, GL_TRUE); - } - break; - } - default: - ; - } -} - -/************************************************************************/ -/************************** Scissor Test SetUp **************************/ -/************************************************************************/ - -/* This routine is used in managing the lock state, and therefore can't lock */ -void -fxSetScissorValues(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - int xmin, xmax; - int ymin, ymax; - - if (ctx->Scissor.Enabled) { - xmin = ctx->Scissor.X; - xmax = ctx->Scissor.X + ctx->Scissor.Width; - ymin = ctx->Scissor.Y; - ymax = ctx->Scissor.Y + ctx->Scissor.Height; - - if (xmin < 0) - xmin = 0; - if (xmax > fxMesa->width) - xmax = fxMesa->width; - if (ymin < fxMesa->screen_height - fxMesa->height) - ymin = fxMesa->screen_height - fxMesa->height; - if (ymax > fxMesa->screen_height - 0) - ymax = fxMesa->screen_height - 0; - } - else { - xmin = 0; - ymin = 0; - xmax = fxMesa->width; - ymax = fxMesa->height; - } - - fxMesa->clipMinX = xmin; - fxMesa->clipMinY = ymin; - fxMesa->clipMaxX = xmax; - fxMesa->clipMaxY = ymax; - grClipWindow(xmin, ymin, xmax, ymax); -} - -void -fxSetupScissor(GLcontext * ctx) -{ - BEGIN_BOARD_LOCK(); - fxSetScissorValues(ctx); - END_BOARD_LOCK(); -} - -void -fxDDScissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ - FX_CONTEXT(ctx)->new_state |= FX_NEW_SCISSOR; -} - -/************************************************************************/ -/*************************** Cull mode setup ****************************/ -/************************************************************************/ - - -void -fxDDCullFace(GLcontext * ctx, GLenum mode) -{ - (void) mode; - FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL; -} - -void -fxDDFrontFace(GLcontext * ctx, GLenum mode) -{ - (void) mode; - FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL; -} - - -void -fxSetupCull(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrCullMode_t mode = GR_CULL_DISABLE; - - if (ctx->Polygon.CullFlag && (fxMesa->raster_primitive == GL_TRIANGLES)) { - switch (ctx->Polygon.CullFaceMode) { - case GL_BACK: - if (ctx->Polygon.FrontFace == GL_CCW) - mode = GR_CULL_NEGATIVE; - else - mode = GR_CULL_POSITIVE; - break; - case GL_FRONT: - if (ctx->Polygon.FrontFace == GL_CCW) - mode = GR_CULL_POSITIVE; - else - mode = GR_CULL_NEGATIVE; - break; - case GL_FRONT_AND_BACK: - /* Handled as a fallback on triangles in tdfx_tris.c */ - return; - default: - ASSERT(0); - break; - } - } - - if (fxMesa->cullMode != mode) { - fxMesa->cullMode = mode; - grCullMode(mode); - } -} - - -/************************************************************************/ -/****************************** DD Enable ******************************/ -/************************************************************************/ - -void -fxDDEnable(GLcontext * ctx, GLenum cap, GLboolean state) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "%s(%s)\n", state ? "fxDDEnable" : "fxDDDisable", - _mesa_lookup_enum_by_nr(cap)); - } - - switch (cap) { - case GL_ALPHA_TEST: - if (state != us->alphaTestEnabled) { - us->alphaTestEnabled = state; - fxMesa->new_state |= FX_NEW_ALPHA; - } - break; - case GL_BLEND: - if (state != us->blendEnabled) { - us->blendEnabled = state; - fxMesa->new_state |= FX_NEW_BLEND; - } - break; - case GL_DEPTH_TEST: - if (state != us->depthTestEnabled) { - us->depthTestEnabled = state; - fxMesa->new_state |= FX_NEW_DEPTH; - } - break; - case GL_STENCIL_TEST: - if (fxMesa->haveHwStencil && state != us->stencilEnabled) { - us->stencilEnabled = state; - fxMesa->new_state |= FX_NEW_STENCIL; - } - break; - case GL_DITHER: - if (state) { - grDitherMode(GR_DITHER_4x4); - } - else { - grDitherMode(GR_DITHER_DISABLE); - } - break; - case GL_SCISSOR_TEST: - fxMesa->new_state |= FX_NEW_SCISSOR; - break; - case GL_SHARED_TEXTURE_PALETTE_EXT: - fxDDTexUseGlbPalette(ctx, state); - break; - case GL_FOG: - fxMesa->new_state |= FX_NEW_FOG; - break; - case GL_CULL_FACE: - fxMesa->new_state |= FX_NEW_CULL; - break; - case GL_LINE_SMOOTH: - case GL_LINE_STIPPLE: - case GL_POINT_SMOOTH: - case GL_POLYGON_SMOOTH: - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - fxMesa->new_state |= FX_NEW_TEXTURING; - break; - default: - ; /* XXX no-op? */ - } -} - - - - -/************************************************************************/ -/************************** Changes to units state **********************/ -/************************************************************************/ - - -/* All units setup is handled under texture setup. - */ -void -fxDDShadeModel(GLcontext * ctx, GLenum mode) -{ - FX_CONTEXT(ctx)->new_state |= FX_NEW_TEXTURING; -} - - - -/************************************************************************/ -/****************************** Units SetUp *****************************/ -/************************************************************************/ -static void -fx_print_state_flags(const char *msg, GLuint flags) -{ - fprintf(stderr, - "%s: (0x%x) %s%s%s%s%s%s%s%s\n", - msg, - flags, - (flags & FX_NEW_TEXTURING) ? "texture, " : "", - (flags & FX_NEW_BLEND) ? "blend, " : "", - (flags & FX_NEW_ALPHA) ? "alpha, " : "", - (flags & FX_NEW_FOG) ? "fog, " : "", - (flags & FX_NEW_SCISSOR) ? "scissor, " : "", - (flags & FX_NEW_COLOR_MASK) ? "colormask, " : "", - (flags & FX_NEW_CULL) ? "cull, " : "", - (flags & FX_NEW_STENCIL) ? "stencil, " : ""); -} - -void -fxSetupFXUnits(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLuint newstate = fxMesa->new_state; - - if (TDFX_DEBUG & VERBOSE_DRIVER) - fx_print_state_flags("fxSetupFXUnits", newstate); - - if (newstate) { - if (newstate & FX_NEW_TEXTURING) - fxSetupTexture(ctx); - - if (newstate & FX_NEW_BLEND) - fxSetupBlend(ctx); - - if (newstate & FX_NEW_ALPHA) - fxSetupAlphaTest(ctx); - - if (newstate & FX_NEW_DEPTH) - fxSetupDepthTest(ctx); - - if (newstate & FX_NEW_STENCIL) - fxSetupStencil(ctx); - - if (newstate & FX_NEW_FOG) - fxSetupFog(ctx); - - if (newstate & FX_NEW_SCISSOR) - fxSetupScissor(ctx); - - if (newstate & FX_NEW_COLOR_MASK) - fxSetupColorMask(ctx); - - if (newstate & FX_NEW_CULL) - fxSetupCull(ctx); - - fxMesa->new_state = 0; - } -} - - - -#else - - -/* - * Need this to provide at least one external definition. - */ - -extern int gl_fx_dummy_function_setup(void); -int -gl_fx_dummy_function_setup(void) -{ - return 0; -} - -#endif /* FX */ diff --git a/src/mesa/drivers/glide/fxsetup.h b/src/mesa/drivers/glide/fxsetup.h deleted file mode 100644 index 9d337d4b0d..0000000000 --- a/src/mesa/drivers/glide/fxsetup.h +++ /dev/null @@ -1,850 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * Copyright (C) 1999-2001 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. - */ - -/* Authors: - * David Bucciarelli - * Brian Paul - * Daryll Strauss - * Keith Whitwell - * Daniel Borca - * Hiroshi Morii - */ - -/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */ -/* This code belongs to fxsetup.c, but I didn't want to clutter - * the original code with Napalm specifics, in order to keep things - * clear -- especially for backward compatibility. I should have - * put it into another .c file, but I didn't want to export so many - * things... - * The point is, Napalm uses a different technique for texture env. - * SST1 Single texturing: - * setup standard grTexCombine - * fiddle with grColorCombine/grAlphaCombine - * SST1 Multi texturing: - * fiddle with grTexCombine/grColorCombine/grAlphaCombine - * Napalm Single texturing: - * setup standard grColorCombineExt/grAlphaCombineExt - * fiddle with grTexColorCombine/grTexAlphaCombine - * Napalm Multi texturing: - * setup standard grColorCombineExt/grAlphaCombineExt - * fiddle with grTexColorCombine/grTexAlphaCombine - */ - -/* - * These macros are used below when handling COMBINE_EXT. - */ -#define TEXENV_OPERAND_INVERTED(operand) \ - (((operand) == GL_ONE_MINUS_SRC_ALPHA) \ - || ((operand) == GL_ONE_MINUS_SRC_COLOR)) -#define TEXENV_OPERAND_ALPHA(operand) \ - (((operand) == GL_SRC_ALPHA) || ((operand) == GL_ONE_MINUS_SRC_ALPHA)) -#define TEXENV_SETUP_ARG_A(param, source, operand, iteratedAlpha) \ - switch (source) { \ - case GL_TEXTURE: \ - param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \ - break; \ - case GL_CONSTANT_EXT: \ - param = GR_CMBX_TMU_CALPHA; \ - break; \ - case GL_PRIMARY_COLOR_EXT: \ - param = GR_CMBX_ITALPHA; \ - break; \ - case GL_PREVIOUS_EXT: \ - param = iteratedAlpha; \ - break; \ - default: \ - /* \ - * This is here just to keep from getting \ - * compiler warnings. \ - */ \ - param = GR_CMBX_ZERO; \ - break; \ - } - -#define TEXENV_SETUP_ARG_RGB(param, source, operand, iteratedColor, iteratedAlpha) \ - if (!TEXENV_OPERAND_ALPHA(operand)) { \ - switch (source) { \ - case GL_TEXTURE: \ - param = GR_CMBX_LOCAL_TEXTURE_RGB; \ - break; \ - case GL_CONSTANT_EXT: \ - param = GR_CMBX_TMU_CCOLOR; \ - break; \ - case GL_PRIMARY_COLOR_EXT: \ - param = GR_CMBX_ITRGB; \ - break; \ - case GL_PREVIOUS_EXT: \ - param = iteratedColor; \ - break; \ - default: \ - /* \ - * This is here just to keep from getting \ - * compiler warnings. \ - */ \ - param = GR_CMBX_ZERO; \ - break; \ - } \ - } else { \ - switch (source) { \ - case GL_TEXTURE: \ - param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \ - break; \ - case GL_CONSTANT_EXT: \ - param = GR_CMBX_TMU_CALPHA; \ - break; \ - case GL_PRIMARY_COLOR_EXT: \ - param = GR_CMBX_ITALPHA; \ - break; \ - case GL_PREVIOUS_EXT: \ - param = iteratedAlpha; \ - break; \ - default: \ - /* \ - * This is here just to keep from getting \ - * compiler warnings. \ - */ \ - param = GR_CMBX_ZERO; \ - break; \ - } \ - } - -#define TEXENV_SETUP_MODE_RGB(param, operand) \ - switch (operand) { \ - case GL_SRC_COLOR: \ - case GL_SRC_ALPHA: \ - param = GR_FUNC_MODE_X; \ - break; \ - case GL_ONE_MINUS_SRC_ALPHA: \ - case GL_ONE_MINUS_SRC_COLOR: \ - param = GR_FUNC_MODE_ONE_MINUS_X; \ - break; \ - default: \ - param = GR_FUNC_MODE_ZERO; \ - break; \ - } - -#define TEXENV_SETUP_MODE_A(param, operand) \ - switch (operand) { \ - case GL_SRC_ALPHA: \ - param = GR_FUNC_MODE_X; \ - break; \ - case GL_ONE_MINUS_SRC_ALPHA: \ - param = GR_FUNC_MODE_ONE_MINUS_X; \ - break; \ - default: \ - param = GR_FUNC_MODE_ZERO; \ - break; \ - } - -static void -fxSetupTextureEnvNapalm_NoLock(GLcontext * ctx, GLuint textureset, GLuint tmu, GLboolean iterated) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[textureset]; - struct tdfx_combine_alpha_ext alphaComb; - struct tdfx_combine_color_ext colorComb; - const GLfloat *envColor = texUnit->EnvColor; - GrCombineLocal_t localc, locala; /* fragmentColor/Alpha */ - GLint ifmt; - tfxTexInfo *ti; - struct gl_texture_object *tObj = texUnit->_Current; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupTextureEnvNapalm_NoLock(unit %u, TMU %u, iterated %d)\n", - textureset, tmu, iterated); - } - - ti = fxTMGetTexInfo(tObj); - - ifmt = ti->baseLevelInternalFormat; - - if (iterated) { - /* we don't have upstream TMU */ - locala = GR_CMBX_ITALPHA; - localc = GR_CMBX_ITRGB; - } else { - /* we have upstream TMU */ - locala = GR_CMBX_OTHER_TEXTURE_ALPHA; - localc = GR_CMBX_OTHER_TEXTURE_RGB; - } - - alphaComb.InvertD = FXFALSE; - alphaComb.Shift = 0; - alphaComb.Invert = FXFALSE; - colorComb.InvertD = FXFALSE; - colorComb.Shift = 0; - colorComb.Invert = FXFALSE; - - switch (texUnit->EnvMode) { - case GL_DECAL: - alphaComb.SourceA = locala; - alphaComb.ModeA = GR_FUNC_MODE_X; - alphaComb.SourceB = GR_CMBX_ZERO; - alphaComb.ModeB = GR_FUNC_MODE_X; - alphaComb.SourceC = GR_CMBX_ZERO; - alphaComb.InvertC = FXTRUE; - alphaComb.SourceD = GR_CMBX_ZERO; - - colorComb.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB; - colorComb.ModeA = GR_FUNC_MODE_X; - colorComb.SourceB = localc; - colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X; - colorComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA; - colorComb.InvertC = FXFALSE; - colorComb.SourceD = GR_CMBX_B; - break; - case GL_MODULATE: - if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) { - alphaComb.SourceA = locala; - alphaComb.ModeA = GR_FUNC_MODE_X; - alphaComb.SourceB = GR_CMBX_ZERO; - alphaComb.ModeB = GR_FUNC_MODE_X; - alphaComb.SourceC = GR_CMBX_ZERO; - alphaComb.InvertC = FXTRUE; - alphaComb.SourceD = GR_CMBX_ZERO; - } else { - alphaComb.SourceA = locala; - alphaComb.ModeA = GR_FUNC_MODE_X; - alphaComb.SourceB = GR_CMBX_ZERO; - alphaComb.ModeB = GR_FUNC_MODE_X; - alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA; - alphaComb.InvertC = FXFALSE; - alphaComb.SourceD = GR_CMBX_ZERO; - } - - if (ifmt == GL_ALPHA) { - colorComb.SourceA = localc; - colorComb.ModeA = GR_FUNC_MODE_X; - colorComb.SourceB = GR_CMBX_ZERO; - colorComb.ModeB = GR_FUNC_MODE_X; - colorComb.SourceC = GR_CMBX_ZERO; - colorComb.InvertC = FXTRUE; - colorComb.SourceD = GR_CMBX_ZERO; - } else { - colorComb.SourceA = localc; - colorComb.ModeA = GR_FUNC_MODE_X; - colorComb.SourceB = GR_CMBX_ZERO; - colorComb.ModeB = GR_FUNC_MODE_X; - colorComb.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB; - colorComb.InvertC = FXFALSE; - colorComb.SourceD = GR_CMBX_ZERO; - } - break; - case GL_BLEND: - if (ifmt == GL_INTENSITY) { - alphaComb.SourceA = GR_CMBX_TMU_CALPHA; - alphaComb.ModeA = GR_FUNC_MODE_X; - alphaComb.SourceB = locala; - alphaComb.ModeB = GR_FUNC_MODE_X; - alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA; - alphaComb.InvertC = FXFALSE; - alphaComb.SourceD = GR_CMBX_ZERO; - } else { - alphaComb.SourceA = locala; - alphaComb.ModeA = GR_FUNC_MODE_X; - alphaComb.SourceB = GR_CMBX_ZERO; - alphaComb.ModeB = GR_FUNC_MODE_X; - alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA; - alphaComb.InvertC = FXFALSE; - alphaComb.SourceD = GR_CMBX_ZERO; - } - - if (ifmt == GL_ALPHA) { - colorComb.SourceA = localc; - colorComb.ModeA = GR_FUNC_MODE_X; - colorComb.SourceB = GR_CMBX_ZERO; - colorComb.ModeB = GR_FUNC_MODE_X; - colorComb.SourceC = GR_CMBX_ZERO; - colorComb.InvertC = FXTRUE; - colorComb.SourceD = GR_CMBX_ZERO; - } else { - colorComb.SourceA = GR_CMBX_TMU_CCOLOR; - colorComb.ModeA = GR_FUNC_MODE_X; - colorComb.SourceB = localc; - colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X; - colorComb.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB; - colorComb.InvertC = FXFALSE; - colorComb.SourceD = GR_CMBX_B; - } - - fxMesa->Glide.grConstantColorValueExt(tmu, - (((GLuint)(envColor[0] * 255.0f)) ) | - (((GLuint)(envColor[1] * 255.0f)) << 8) | - (((GLuint)(envColor[2] * 255.0f)) << 16) | - (((GLuint)(envColor[3] * 255.0f)) << 24)); - break; - case GL_REPLACE: - if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) { - alphaComb.SourceA = locala; - alphaComb.ModeA = GR_FUNC_MODE_X; - alphaComb.SourceB = GR_CMBX_ZERO; - alphaComb.ModeB = GR_FUNC_MODE_X; - alphaComb.SourceC = GR_CMBX_ZERO; - alphaComb.InvertC = FXTRUE; - alphaComb.SourceD = GR_CMBX_ZERO; - } else { - alphaComb.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA; - alphaComb.ModeA = GR_FUNC_MODE_X; - alphaComb.SourceB = GR_CMBX_ZERO; - alphaComb.ModeB = GR_FUNC_MODE_X; - alphaComb.SourceC = GR_CMBX_ZERO; - alphaComb.InvertC = FXTRUE; - alphaComb.SourceD = GR_CMBX_ZERO; - } - - if (ifmt == GL_ALPHA) { - colorComb.SourceA = localc; - colorComb.ModeA = GR_FUNC_MODE_X; - colorComb.SourceB = GR_CMBX_ZERO; - colorComb.ModeB = GR_FUNC_MODE_X; - colorComb.SourceC = GR_CMBX_ZERO; - colorComb.InvertC = FXTRUE; - colorComb.SourceD = GR_CMBX_ZERO; - } else { - colorComb.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB; - colorComb.ModeA = GR_FUNC_MODE_X; - colorComb.SourceB = GR_CMBX_ZERO; - colorComb.ModeB = GR_FUNC_MODE_X; - colorComb.SourceC = GR_CMBX_ZERO; - colorComb.InvertC = FXTRUE; - colorComb.SourceD = GR_CMBX_ZERO; - } - break; - case GL_ADD: - if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) { - alphaComb.SourceA = locala; - alphaComb.ModeA = GR_FUNC_MODE_X; - alphaComb.SourceB = GR_CMBX_ZERO; - alphaComb.ModeB = GR_FUNC_MODE_X; - alphaComb.SourceC = GR_CMBX_ZERO; - alphaComb.InvertC = FXTRUE; - alphaComb.SourceD = GR_CMBX_ZERO; - } else if (ifmt == GL_INTENSITY) { - alphaComb.SourceA = locala; - alphaComb.ModeA = GR_FUNC_MODE_X; - alphaComb.SourceB = GR_CMBX_LOCAL_TEXTURE_ALPHA; - alphaComb.ModeB = GR_FUNC_MODE_X; - alphaComb.SourceC = GR_CMBX_ZERO; - alphaComb.InvertC = FXTRUE; - alphaComb.SourceD = GR_CMBX_ZERO; - } else { - alphaComb.SourceA = locala; - alphaComb.ModeA = GR_FUNC_MODE_X; - alphaComb.SourceB = GR_CMBX_ZERO; - alphaComb.ModeB = GR_FUNC_MODE_X; - alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA; - alphaComb.InvertC = FXFALSE; - alphaComb.SourceD = GR_CMBX_ZERO; - } - - if (ifmt == GL_ALPHA) { - colorComb.SourceA = localc; - colorComb.ModeA = GR_FUNC_MODE_X; - colorComb.SourceB = GR_CMBX_ZERO; - colorComb.ModeB = GR_FUNC_MODE_X; - colorComb.SourceC = GR_CMBX_ZERO; - colorComb.InvertC = FXTRUE; - colorComb.SourceD = GR_CMBX_ZERO; - } else { - colorComb.SourceA = localc; - colorComb.ModeA = GR_FUNC_MODE_X; - colorComb.SourceB = GR_CMBX_LOCAL_TEXTURE_RGB; - colorComb.ModeB = GR_FUNC_MODE_X; - colorComb.SourceC = GR_CMBX_ZERO; - colorComb.InvertC = FXTRUE; - colorComb.SourceD = GR_CMBX_ZERO; - } - break; - /* COMBINE_EXT */ - case GL_COMBINE_EXT: - /* XXX todo - INCOMPLETE!!! */ - if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) { -#if 1 - fprintf(stderr, "COMBINE_EXT: %s + %s\n", - _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB), - _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); -#else - fprintf(stderr, "Texture Unit %d\n", textureset); - fprintf(stderr, " GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode)); - fprintf(stderr, " GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB)); - fprintf(stderr, " GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); - fprintf(stderr, " GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0])); - fprintf(stderr, " GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1])); - fprintf(stderr, " GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2])); - fprintf(stderr, " GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0])); - fprintf(stderr, " GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1])); - fprintf(stderr, " GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2])); - fprintf(stderr, " GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0])); - fprintf(stderr, " GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1])); - fprintf(stderr, " GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2])); - fprintf(stderr, " GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0])); - fprintf(stderr, " GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1])); - fprintf(stderr, " GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2])); - fprintf(stderr, " GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB); - fprintf(stderr, " GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA); - fprintf(stderr, " GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", envColor[0], envColor[1], envColor[2], envColor[3]); -#endif - } - - alphaComb.Shift = texUnit->Combine.ScaleShiftA; - colorComb.Shift = texUnit->Combine.ScaleShiftRGB; - - switch (texUnit->Combine.ModeRGB) { - case GL_MODULATE: - /* Arg0 * Arg1 == (A + 0) * C + 0 */ - TEXENV_SETUP_ARG_RGB(colorComb.SourceA, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - localc, locala); - TEXENV_SETUP_MODE_RGB(colorComb.ModeA, - texUnit->Combine.OperandRGB[0]); - colorComb.SourceB = GR_CMBX_ZERO; - colorComb.ModeB = GR_FUNC_MODE_ZERO; - TEXENV_SETUP_ARG_RGB(colorComb.SourceC, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - localc, locala); - colorComb.InvertC = TEXENV_OPERAND_INVERTED( - texUnit->Combine.OperandRGB[1]); - colorComb.SourceD = GR_CMBX_ZERO; - break; - case GL_REPLACE: - /* Arg0 == (A + 0) * 1 + 0 */ - TEXENV_SETUP_ARG_RGB(colorComb.SourceA, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - localc, locala); - TEXENV_SETUP_MODE_RGB(colorComb.ModeA, - texUnit->Combine.OperandRGB[0]); - colorComb.SourceB = GR_CMBX_ZERO; - colorComb.ModeB = GR_FUNC_MODE_ZERO; - colorComb.SourceC = GR_CMBX_ZERO; - colorComb.InvertC = FXTRUE; - colorComb.SourceD = GR_CMBX_ZERO; - break; - case GL_ADD: - /* Arg0 + Arg1 = (A + B) * 1 + 0 */ - TEXENV_SETUP_ARG_RGB(colorComb.SourceA, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - localc, locala); - TEXENV_SETUP_MODE_RGB(colorComb.ModeA, - texUnit->Combine.OperandRGB[0]); - TEXENV_SETUP_ARG_RGB(colorComb.SourceB, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - localc, locala); - TEXENV_SETUP_MODE_RGB(colorComb.ModeB, - texUnit->Combine.OperandRGB[1]); - colorComb.SourceC = GR_CMBX_ZERO; - colorComb.InvertC = FXTRUE; - colorComb.SourceD = GR_CMBX_ZERO; - break; - case GL_INTERPOLATE_EXT: - /* Arg0 * Arg2 + Arg1 * (1 - Arg2) == - * (Arg0 - Arg1) * Arg2 + Arg1 == (A - B) * C + D - */ - TEXENV_SETUP_ARG_RGB(colorComb.SourceA, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - localc, locala); - TEXENV_SETUP_MODE_RGB(colorComb.ModeA, - texUnit->Combine.OperandRGB[0]); - TEXENV_SETUP_ARG_RGB(colorComb.SourceB, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - localc, locala); - if (TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandRGB[1])) { - /* Hack alert!!! This case is wrong!!! */ - fprintf(stderr, "COMBINE_EXT_color: WRONG!!!\n"); - colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X; - } else { - colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X; - } - /* - * The Source/Operand for the C value must - * specify some kind of alpha value. - */ - TEXENV_SETUP_ARG_A(colorComb.SourceC, - texUnit->Combine.SourceRGB[2], - texUnit->Combine.OperandRGB[2], - locala); - colorComb.InvertC = FXFALSE; - colorComb.SourceD = GR_CMBX_B; - break; - default: - fprintf(stderr, "COMBINE_EXT_color: %s\n", - _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB)); - } - - switch (texUnit->Combine.ModeA) { - case GL_MODULATE: - /* Arg0 * Arg1 == (A + 0) * C + 0 */ - TEXENV_SETUP_ARG_A(alphaComb.SourceA, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - locala); - TEXENV_SETUP_MODE_A(alphaComb.ModeA, - texUnit->Combine.OperandA[0]); - alphaComb.SourceB = GR_CMBX_ZERO; - alphaComb.ModeB = GR_FUNC_MODE_ZERO; - TEXENV_SETUP_ARG_A(alphaComb.SourceC, - texUnit->Combine.SourceA[1], - texUnit->Combine.OperandA[1], - locala); - alphaComb.InvertC = TEXENV_OPERAND_INVERTED( - texUnit->Combine.OperandA[1]); - alphaComb.SourceD = GR_CMBX_ZERO; - break; - case GL_REPLACE: - /* Arg0 == (A + 0) * 1 + 0 */ - TEXENV_SETUP_ARG_A(alphaComb.SourceA, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - locala); - TEXENV_SETUP_MODE_A(alphaComb.ModeA, - texUnit->Combine.OperandA[0]); - alphaComb.SourceB = GR_CMBX_ZERO; - alphaComb.ModeB = GR_FUNC_MODE_ZERO; - alphaComb.SourceC = GR_CMBX_ZERO; - alphaComb.InvertC = FXTRUE; - alphaComb.SourceD = GR_CMBX_ZERO; - break; - case GL_ADD: - /* Arg0 + Arg1 = (A + B) * 1 + 0 */ - TEXENV_SETUP_ARG_A(alphaComb.SourceA, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - locala); - TEXENV_SETUP_MODE_A(alphaComb.ModeA, - texUnit->Combine.OperandA[0]); - TEXENV_SETUP_ARG_A(alphaComb.SourceB, - texUnit->Combine.SourceA[1], - texUnit->Combine.OperandA[1], - locala); - TEXENV_SETUP_MODE_A(alphaComb.ModeB, - texUnit->Combine.OperandA[1]); - alphaComb.SourceC = GR_CMBX_ZERO; - alphaComb.InvertC = FXTRUE; - alphaComb.SourceD = GR_CMBX_ZERO; - break; - default: - fprintf(stderr, "COMBINE_EXT_alpha: %s\n", - _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); - } - - fxMesa->Glide.grConstantColorValueExt(tmu, - (((GLuint)(envColor[0] * 255.0f)) ) | - (((GLuint)(envColor[1] * 255.0f)) << 8) | - (((GLuint)(envColor[2] * 255.0f)) << 16) | - (((GLuint)(envColor[3] * 255.0f)) << 24)); - break; - - default: - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupTextureEnvNapalm_NoLock: %x Texture.EnvMode not yet supported\n", - texUnit->EnvMode); - } - return; - } - - /* On Napalm we simply put the color combine unit into passthrough mode - * and do everything we need with the texture combine units. */ - fxMesa->Glide.grColorCombineExt(GR_CMBX_TEXTURE_RGB, - GR_FUNC_MODE_X, - GR_CMBX_ZERO, - GR_FUNC_MODE_X, - GR_CMBX_ZERO, - FXTRUE, - GR_CMBX_ZERO, - FXFALSE, - 0, - FXFALSE); - fxMesa->Glide.grAlphaCombineExt(GR_CMBX_TEXTURE_ALPHA, - GR_FUNC_MODE_X, - GR_CMBX_ZERO, - GR_FUNC_MODE_X, - GR_CMBX_ZERO, - FXTRUE, - GR_CMBX_ZERO, - FXFALSE, - 0, - FXFALSE); - - fxMesa->Glide.grTexAlphaCombineExt(tmu, - alphaComb.SourceA, - alphaComb.ModeA, - alphaComb.SourceB, - alphaComb.ModeB, - alphaComb.SourceC, - alphaComb.InvertC, - alphaComb.SourceD, - alphaComb.InvertD, - alphaComb.Shift, - alphaComb.Invert); - fxMesa->Glide.grTexColorCombineExt(tmu, - colorComb.SourceA, - colorComb.ModeA, - colorComb.SourceB, - colorComb.ModeB, - colorComb.SourceC, - colorComb.InvertC, - colorComb.SourceD, - colorComb.InvertD, - colorComb.Shift, - colorComb.Invert); -} - - -/************************* Single Texture Set ***************************/ - -static void -fxSelectSingleTMUSrcNapalm_NoLock(fxMesaContext fxMesa, GLint tmu, FxBool LODblend) -{ - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSelectSingleTMUSrcNapalm_NoLock(%d, %d)\n", tmu, LODblend); - } - - if (LODblend) { - /* XXX todo - GR_CMBX_LOD_FRAC? */ - fxMesa->tmuSrc = FX_TMU_SPLIT; - } - else { - if (tmu != FX_TMU1) { - /* disable tex1 */ - if (fxMesa->haveTwoTMUs) { - fxMesa->Glide.grTexAlphaCombineExt(FX_TMU1, - GR_CMBX_ZERO, - GR_FUNC_MODE_ZERO, - GR_CMBX_ZERO, - GR_FUNC_MODE_ZERO, - GR_CMBX_ZERO, - FXTRUE, - GR_CMBX_ZERO, - FXFALSE, - 0, - FXFALSE); - fxMesa->Glide.grTexColorCombineExt(FX_TMU1, - GR_CMBX_ZERO, - GR_FUNC_MODE_ZERO, - GR_CMBX_ZERO, - GR_FUNC_MODE_ZERO, - GR_CMBX_ZERO, - FXTRUE, - GR_CMBX_ZERO, - FXFALSE, - 0, - FXFALSE); - } - - fxMesa->tmuSrc = FX_TMU0; - } - else { -#if 1 - grTexCombine(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_FUNCTION_BLEND, - GR_COMBINE_FACTOR_ONE, - FXFALSE, - FXFALSE); -#else - /* [dBorca] why, oh why? doesn't work! stupid Glide? */ - fxMesa->Glide.grTexAlphaCombineExt(FX_TMU0, - GR_CMBX_OTHER_TEXTURE_ALPHA, - GR_FUNC_MODE_X, - GR_CMBX_ZERO, - GR_FUNC_MODE_X, - GR_CMBX_ZERO, - FXTRUE, - GR_CMBX_ZERO, - FXFALSE, - 0, - FXFALSE); - fxMesa->Glide.grTexColorCombineExt(FX_TMU0, - GR_CMBX_OTHER_TEXTURE_RGB, - GR_FUNC_MODE_X, - GR_CMBX_ZERO, - GR_FUNC_MODE_X, - GR_CMBX_ZERO, - FXTRUE, - GR_CMBX_ZERO, - FXFALSE, - 0, - FXFALSE); -#endif - - fxMesa->tmuSrc = FX_TMU1; - } - } -} - -static void -fxSetupTextureSingleTMUNapalm_NoLock(GLcontext * ctx, GLuint textureset) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLuint unitsmode; - tfxTexInfo *ti; - struct gl_texture_object *tObj = ctx->Texture.Unit[textureset]._Current; - int tmu; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupTextureSingleTMUNapalm_NoLock(%d)\n", textureset); - } - - ti = fxTMGetTexInfo(tObj); - - fxTexValidate(ctx, tObj); - - fxSetupSingleTMU_NoLock(fxMesa, tObj); - - if (ti->whichTMU == FX_TMU_BOTH) - tmu = FX_TMU0; - else - tmu = ti->whichTMU; - if (fxMesa->tmuSrc != tmu) - fxSelectSingleTMUSrcNapalm_NoLock(fxMesa, tmu, ti->LODblend); - - if (textureset == 0 || !fxMesa->haveTwoTMUs) - unitsmode = fxGetTexSetConfiguration(ctx, tObj, NULL); - else - unitsmode = fxGetTexSetConfiguration(ctx, NULL, tObj); - -/* if(fxMesa->lastUnitsMode==unitsmode) */ -/* return; */ - - fxMesa->lastUnitsMode = unitsmode; - - fxMesa->stw_hint_state = 0; - FX_grHints_NoLock(GR_HINT_STWHINT, 0); - - if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) - fprintf(stderr, "fxSetupTextureSingleTMUNapalm_NoLock: envmode is %s\n", - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode)); - - /* [dBorca] Hack alert: - * what if we're in split mode? (LODBlend) - * also should we update BOTH TMUs in FX_TMU_BOTH mode? - */ - fxSetupTextureEnvNapalm_NoLock(ctx, textureset, tmu, GL_TRUE); -} - - -/************************* Double Texture Set ***************************/ - -static void -fxSetupTextureDoubleTMUNapalm_NoLock(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxTexInfo *ti0, *ti1; - struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current; - struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current; - GLuint unitsmode; - int tmu0 = 0, tmu1 = 1; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupTextureDoubleTMUNapalm_NoLock(...)\n"); - } - - ti0 = fxTMGetTexInfo(tObj0); - fxTexValidate(ctx, tObj0); - - ti1 = fxTMGetTexInfo(tObj1); - fxTexValidate(ctx, tObj1); - - fxSetupDoubleTMU_NoLock(fxMesa, tObj0, tObj1); - - unitsmode = fxGetTexSetConfiguration(ctx, tObj0, tObj1); - -/* if(fxMesa->lastUnitsMode==unitsmode) */ -/* return; */ - - fxMesa->lastUnitsMode = unitsmode; - - fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1; - FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state); - - if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) - fprintf(stderr, "fxSetupTextureDoubleTMUNapalm_NoLock: envmode is %s/%s\n", - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode), - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode)); - - - if ((ti0->whichTMU == FX_TMU1) || (ti1->whichTMU == FX_TMU0)) { - tmu0 = 1; - tmu1 = 0; - } - fxMesa->tmuSrc = FX_TMU_BOTH; - - /* OpenGL vs Glide texture pipeline */ - fxSetupTextureEnvNapalm_NoLock(ctx, 0, 1, GL_TRUE); - fxSetupTextureEnvNapalm_NoLock(ctx, 1, 0, GL_FALSE); -} - -/************************* No Texture ***************************/ - -static void -fxSetupTextureNoneNapalm_NoLock(GLcontext * ctx) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxSetupTextureNoneNapalm_NoLock(...)\n"); - } - - /* the combiner formula is: (A + B) * C + D - ** - ** a = tc_otherselect - ** a_mode = tc_invert_other - ** b = tc_localselect - ** b_mode = tc_invert_local - ** c = (tc_mselect, tc_mselect_7) - ** d = (tc_add_clocal, tc_add_alocal) - ** shift = tc_outshift - ** invert = tc_invert_output - */ - - fxMesa->Glide.grColorCombineExt(GR_CMBX_ITRGB, - GR_FUNC_MODE_X, - GR_CMBX_ZERO, - GR_FUNC_MODE_ZERO, - GR_CMBX_ZERO, - FXTRUE, - GR_CMBX_ZERO, - FXFALSE, - 0, - FXFALSE); - fxMesa->Glide.grAlphaCombineExt(GR_CMBX_ITALPHA, - GR_FUNC_MODE_X, - GR_CMBX_ZERO, - GR_FUNC_MODE_ZERO, - GR_CMBX_ZERO, - FXTRUE, - GR_CMBX_ZERO, - FXFALSE, - 0, - FXFALSE); - - fxMesa->lastUnitsMode = FX_UM_NONE; -} diff --git a/src/mesa/drivers/glide/fxtexman.c b/src/mesa/drivers/glide/fxtexman.c deleted file mode 100644 index 940c8fd0b9..0000000000 --- a/src/mesa/drivers/glide/fxtexman.c +++ /dev/null @@ -1,874 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * Copyright (C) 1999-2001 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. - */ - -/* Authors: - * David Bucciarelli - * Brian Paul - * Daryll Strauss - * Keith Whitwell - * Daniel Borca - * Hiroshi Morii - */ - -/* fxtexman.c - 3Dfx VooDoo texture memory functions */ - - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#if defined(FX) - -#include "hash.h" -#include "fxdrv.h" - -int texSwaps = 0; -static FxU32 texBoundMask; - -#define FX_2MB_SPLIT 0x200000 - -static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa, - int tmu); - - -#ifdef TEXSANITY -static void -fubar() -{ -} - - /* Sanity Check */ -static void -sanity(fxMesaContext fxMesa) -{ - MemRange *tmp, *prev, *pos; - - prev = 0; - tmp = fxMesa->tmFree[0]; - while (tmp) { - if (!tmp->startAddr && !tmp->endAddr) { - fprintf(stderr, "Textures fubar\n"); - fubar(); - } - if (tmp->startAddr >= tmp->endAddr) { - fprintf(stderr, "Node fubar\n"); - fubar(); - } - if (prev && (prev->startAddr >= tmp->startAddr || - prev->endAddr > tmp->startAddr)) { - fprintf(stderr, "Sorting fubar\n"); - fubar(); - } - prev = tmp; - tmp = tmp->next; - } - prev = 0; - tmp = fxMesa->tmFree[1]; - while (tmp) { - if (!tmp->startAddr && !tmp->endAddr) { - fprintf(stderr, "Textures fubar\n"); - fubar(); - } - if (tmp->startAddr >= tmp->endAddr) { - fprintf(stderr, "Node fubar\n"); - fubar(); - } - if (prev && (prev->startAddr >= tmp->startAddr || - prev->endAddr > tmp->startAddr)) { - fprintf(stderr, "Sorting fubar\n"); - fubar(); - } - prev = tmp; - tmp = tmp->next; - } -} -#endif - -static MemRange * -fxTMNewRangeNode(fxMesaContext fxMesa, FxU32 start, FxU32 end) -{ - MemRange *result = 0; - - if (fxMesa->tmPool) { - result = fxMesa->tmPool; - fxMesa->tmPool = fxMesa->tmPool->next; - } - else { - if (!(result = MALLOC(sizeof(MemRange)))) { - fprintf(stderr, "fxTMNewRangeNode: ERROR: out of memory!\n"); - fxCloseHardware(); - exit(-1); - } - } - result->startAddr = start; - result->endAddr = end; - return result; -} - -#if 1 -#define fxTMDeleteRangeNode(fxMesa, range) \ - do { \ - range->next = fxMesa->tmPool; \ - fxMesa->tmPool = range; \ - } while (0); -#else -static void -fxTMDeleteRangeNode(fxMesaContext fxMesa, MemRange * range) -{ - range->next = fxMesa->tmPool; - fxMesa->tmPool = range; -} -#endif - -static void -fxTMUInit(fxMesaContext fxMesa, int tmu) -{ - MemRange *tmn, *last; - FxU32 start, end, blockstart, blockend, chunk; - - start = grTexMinAddress(tmu); - end = grTexMaxAddress(tmu); - - chunk = (fxMesa->type >= GR_SSTTYPE_Banshee) ? (end - start) : FX_2MB_SPLIT; - - if (fxMesa->verbose) { - fprintf(stderr, "Voodoo TMU%d configuration:\n", tmu); - } - - fxMesa->freeTexMem[tmu] = end - start; - fxMesa->tmFree[tmu] = NULL; - - last = 0; - blockstart = start; - while (blockstart < end) { - if (blockstart + chunk > end) - blockend = end; - else - blockend = blockstart + chunk; - - if (fxMesa->verbose) - fprintf(stderr, "Voodoo %08u-%08u\n", - (unsigned int) blockstart, (unsigned int) blockend); - - tmn = fxTMNewRangeNode(fxMesa, blockstart, blockend); - tmn->next = NULL; - - - if (last) - last->next = tmn; - else - fxMesa->tmFree[tmu] = tmn; - last = tmn; - - blockstart += chunk; - } -} - -static int -fxTMFindStartAddr(fxMesaContext fxMesa, GLint tmu, int size) -{ - MemRange *prev, *tmp; - int result; - struct gl_texture_object *obj; - - if (fxMesa->HaveTexUma) { - tmu = FX_TMU0; - } - - while (1) { - prev = 0; - tmp = fxMesa->tmFree[tmu]; - while (tmp) { - if (tmp->endAddr - tmp->startAddr >= size) { /* Fits here */ - result = tmp->startAddr; - tmp->startAddr += size; - if (tmp->startAddr == tmp->endAddr) { /* Empty */ - if (prev) { - prev->next = tmp->next; - } - else { - fxMesa->tmFree[tmu] = tmp->next; - } - fxTMDeleteRangeNode(fxMesa, tmp); - } - fxMesa->freeTexMem[tmu] -= size; - return result; - } - prev = tmp; - tmp = tmp->next; - } - /* No free space. Discard oldest */ - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxTMFindStartAddr: No free space. Discard oldest\n"); - } - obj = fxTMFindOldestObject(fxMesa, tmu); - if (!obj) { - fprintf(stderr, "fxTMFindStartAddr: ERROR: No space for texture\n"); - return -1; - } - fxTMMoveOutTM(fxMesa, obj); - texSwaps++; - } -} - -int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti) -{ - MemRange *tmp; - int size; - - if (fxMesa->HaveTexUma) { - return FXTRUE; - } - - size = grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); - - tmp = fxMesa->tmFree[tmu]; - while (tmp) { - if (tmp->endAddr - tmp->startAddr >= size) { /* Fits here */ - return FXTRUE; - } - tmp = tmp->next; - } - - return FXFALSE; -} - -static void -fxTMRemoveRange(fxMesaContext fxMesa, GLint tmu, MemRange * range) -{ - MemRange *tmp, *prev; - - if (fxMesa->HaveTexUma) { - tmu = FX_TMU0; - } - - if (range->startAddr == range->endAddr) { - fxTMDeleteRangeNode(fxMesa, range); - return; - } - fxMesa->freeTexMem[tmu] += range->endAddr - range->startAddr; - prev = 0; - tmp = fxMesa->tmFree[tmu]; - while (tmp) { - if (range->startAddr > tmp->startAddr) { - prev = tmp; - tmp = tmp->next; - } - else - break; - } - /* When we create the regions, we make a split at the 2MB boundary. - Now we have to make sure we don't join those 2MB boundary regions - back together again. */ - range->next = tmp; - if (tmp) { - if (range->endAddr == tmp->startAddr - && tmp->startAddr & texBoundMask) { - /* Combine */ - tmp->startAddr = range->startAddr; - fxTMDeleteRangeNode(fxMesa, range); - range = tmp; - } - } - if (prev) { - if (prev->endAddr == range->startAddr - && range->startAddr & texBoundMask) { - /* Combine */ - prev->endAddr = range->endAddr; - prev->next = range->next; - fxTMDeleteRangeNode(fxMesa, range); - } - else - prev->next = range; - } - else { - fxMesa->tmFree[tmu] = range; - } -} - -static struct gl_texture_object * -fxTMFindOldestObject(fxMesaContext fxMesa, int tmu) -{ - GLuint age, old, lasttime, bindnumber; - GLfloat lowestPriority; - struct gl_texture_object *obj, *lowestPriorityObj; - struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - GLuint id; - - if (!_mesa_HashFirstEntry(textures)) - return 0; - - obj = NULL; - old = 0; - - lowestPriorityObj = NULL; - lowestPriority = 1.0F; - - bindnumber = fxMesa->texBindNumber; - - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *tmp - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); - tfxTexInfo *info = fxTMGetTexInfo(tmp); - - if (info && info->isInTM && - ((info->whichTMU == tmu) || - (info->whichTMU == FX_TMU_BOTH) || - (info->whichTMU == FX_TMU_SPLIT) || - fxMesa->HaveTexUma - ) - ) { - lasttime = info->lastTimeUsed; - - if (lasttime > bindnumber) - age = bindnumber + (UINT_MAX - lasttime + 1); /* TO DO: check wrap around */ - else - age = bindnumber - lasttime; - - if (age >= old) { - old = age; - obj = tmp; - } - - /* examine priority */ - if (tmp->Priority < lowestPriority) { - lowestPriority = tmp->Priority; - lowestPriorityObj = tmp; - } - } - } - - if (lowestPriorityObj != NULL) { - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxTMFindOldestObject: %d pri=%f\n", lowestPriorityObj->Name, lowestPriority); - } - return lowestPriorityObj; - } - else { - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - if (obj != NULL) { - fprintf(stderr, "fxTMFindOldestObject: %d age=%d\n", obj->Name, old); - } - } - return obj; - } -} - -static MemRange * -fxTMAddObj(fxMesaContext fxMesa, - struct gl_texture_object *tObj, GLint tmu, int texmemsize) -{ - FxI32 startAddr; - MemRange *range; - - startAddr = fxTMFindStartAddr(fxMesa, tmu, texmemsize); - if (startAddr < 0) - return 0; - range = fxTMNewRangeNode(fxMesa, startAddr, startAddr + texmemsize); - return range; -} - -/* External Functions */ - -void -fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj, - GLint where) -{ - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - int i, l; - int texmemsize; - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxTMMoveInTM_NoLock(%d)\n", tObj->Name); - } - - fxMesa->stats.reqTexUpload++; - - if (!ti->validated) { - fprintf(stderr, "fxTMMoveInTM_NoLock: INTERNAL ERROR: not validated\n"); - fxCloseHardware(); - exit(-1); - } - - if (ti->isInTM) { - if (ti->whichTMU == where) - return; - if (where == FX_TMU_SPLIT || ti->whichTMU == FX_TMU_SPLIT) - fxTMMoveOutTM_NoLock(fxMesa, tObj); - else { - if (ti->whichTMU == FX_TMU_BOTH) - return; - where = FX_TMU_BOTH; - } - } - - if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) { - fprintf(stderr, "fxTMMoveInTM_NoLock: downloading %p (%d) in texture memory in %d\n", - (void *)tObj, tObj->Name, where); - } - - ti->whichTMU = (FxU32) where; - - switch (where) { - case FX_TMU0: - case FX_TMU1: - texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); - ti->tm[where] = fxTMAddObj(fxMesa, tObj, where, texmemsize); - fxMesa->stats.memTexUpload += texmemsize; - - for (i = FX_largeLodValue(ti->info), l = ti->minLevel; - i <= FX_smallLodValue(ti->info); i++, l++) { - struct gl_texture_image *texImage = tObj->Image[0][l]; - grTexDownloadMipMapLevel(where, - ti->tm[where]->startAddr, - FX_valueToLod(i), - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, - texImage->Data); - } - break; - case FX_TMU_SPLIT: - texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_ODD, &(ti->info)); - ti->tm[FX_TMU0] = fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize); - fxMesa->stats.memTexUpload += texmemsize; - - texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_EVEN, &(ti->info)); - ti->tm[FX_TMU1] = fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize); - fxMesa->stats.memTexUpload += texmemsize; - - for (i = FX_largeLodValue(ti->info), l = ti->minLevel; - i <= FX_smallLodValue(ti->info); i++, l++) { - struct gl_texture_image *texImage = tObj->Image[0][l]; - - grTexDownloadMipMapLevel(GR_TMU0, - ti->tm[FX_TMU0]->startAddr, - FX_valueToLod(i), - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_ODD, - texImage->Data); - - grTexDownloadMipMapLevel(GR_TMU1, - ti->tm[FX_TMU1]->startAddr, - FX_valueToLod(i), - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_EVEN, - texImage->Data); - } - break; - case FX_TMU_BOTH: - texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); - ti->tm[FX_TMU0] = fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize); - fxMesa->stats.memTexUpload += texmemsize; - - /*texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));*/ - ti->tm[FX_TMU1] = fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize); - fxMesa->stats.memTexUpload += texmemsize; - - for (i = FX_largeLodValue(ti->info), l = ti->minLevel; - i <= FX_smallLodValue(ti->info); i++, l++) { - struct gl_texture_image *texImage = tObj->Image[0][l]; - grTexDownloadMipMapLevel(GR_TMU0, - ti->tm[FX_TMU0]->startAddr, - FX_valueToLod(i), - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, - texImage->Data); - - grTexDownloadMipMapLevel(GR_TMU1, - ti->tm[FX_TMU1]->startAddr, - FX_valueToLod(i), - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, - texImage->Data); - } - break; - default: - fprintf(stderr, "fxTMMoveInTM_NoLock: INTERNAL ERROR: wrong tmu (%d)\n", where); - fxCloseHardware(); - exit(-1); - } - - fxMesa->stats.texUpload++; - - ti->isInTM = GL_TRUE; -} - - -void -fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj, - GLint where) -{ - BEGIN_BOARD_LOCK(); - fxTMMoveInTM_NoLock(fxMesa, tObj, where); - END_BOARD_LOCK(); -} - - -void -fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj, - GLint level) -{ - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - GrLOD_t lodlevel; - GLint tmu; - struct gl_texture_image *texImage = tObj->Image[0][level]; - tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxTMReloadMipMapLevel(%p (%d), %d)\n", (void *)tObj, tObj->Name, level); - } - - assert(mml); - assert(mml->width > 0); - assert(mml->height > 0); - assert(mml->glideFormat > 0); - assert(ti->isInTM); - - if (!ti->validated) { - fprintf(stderr, "fxTMReloadMipMapLevel: INTERNAL ERROR: not validated\n"); - fxCloseHardware(); - exit(-1); - } - - tmu = (int) ti->whichTMU; - fxMesa->stats.reqTexUpload++; - fxMesa->stats.texUpload++; - - lodlevel = ti->info.largeLodLog2 - (level - ti->minLevel); - - switch (tmu) { - case FX_TMU0: - case FX_TMU1: - grTexDownloadMipMapLevel(tmu, - ti->tm[tmu]->startAddr, - lodlevel, - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, texImage->Data); - break; - case FX_TMU_SPLIT: - grTexDownloadMipMapLevel(GR_TMU0, - ti->tm[GR_TMU0]->startAddr, - lodlevel, - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_ODD, texImage->Data); - - grTexDownloadMipMapLevel(GR_TMU1, - ti->tm[GR_TMU1]->startAddr, - lodlevel, - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_EVEN, texImage->Data); - break; - case FX_TMU_BOTH: - grTexDownloadMipMapLevel(GR_TMU0, - ti->tm[GR_TMU0]->startAddr, - lodlevel, - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, texImage->Data); - - grTexDownloadMipMapLevel(GR_TMU1, - ti->tm[GR_TMU1]->startAddr, - lodlevel, - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, texImage->Data); - break; - - default: - fprintf(stderr, "fxTMReloadMipMapLevel: INTERNAL ERROR: wrong tmu (%d)\n", tmu); - fxCloseHardware(); - exit(-1); - } -} - -void -fxTMReloadSubMipMapLevel(fxMesaContext fxMesa, - struct gl_texture_object *tObj, - GLint level, GLint yoffset, GLint height) -{ - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - GrLOD_t lodlevel; - unsigned short *data; - GLint tmu; - struct gl_texture_image *texImage = tObj->Image[0][level]; - tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); - - assert(mml); - - if (!ti->validated) { - fprintf(stderr, "fxTMReloadSubMipMapLevel: INTERNAL ERROR: not validated\n"); - fxCloseHardware(); - exit(-1); - } - - tmu = (int) ti->whichTMU; - fxTMMoveInTM(fxMesa, tObj, tmu); - - fxTexGetInfo(mml->width, mml->height, - &lodlevel, NULL, NULL, NULL, NULL, NULL); - - if ((ti->info.format == GR_TEXFMT_INTENSITY_8) || - (ti->info.format == GR_TEXFMT_P_8) || - (ti->info.format == GR_TEXFMT_ALPHA_8)) - data = (GLushort *) texImage->Data + ((yoffset * mml->width) >> 1); - else - data = (GLushort *) texImage->Data + yoffset * mml->width; - - switch (tmu) { - case FX_TMU0: - case FX_TMU1: - grTexDownloadMipMapLevelPartial(tmu, - ti->tm[tmu]->startAddr, - FX_valueToLod(FX_lodToValue(lodlevel) - + level), - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, data, - yoffset, yoffset + height - 1); - break; - case FX_TMU_SPLIT: - grTexDownloadMipMapLevelPartial(GR_TMU0, - ti->tm[FX_TMU0]->startAddr, - FX_valueToLod(FX_lodToValue(lodlevel) - + level), - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_ODD, data, - yoffset, yoffset + height - 1); - - grTexDownloadMipMapLevelPartial(GR_TMU1, - ti->tm[FX_TMU1]->startAddr, - FX_valueToLod(FX_lodToValue(lodlevel) - + level), - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_EVEN, data, - yoffset, yoffset + height - 1); - break; - case FX_TMU_BOTH: - grTexDownloadMipMapLevelPartial(GR_TMU0, - ti->tm[FX_TMU0]->startAddr, - FX_valueToLod(FX_lodToValue(lodlevel) - + level), - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, data, - yoffset, yoffset + height - 1); - - grTexDownloadMipMapLevelPartial(GR_TMU1, - ti->tm[FX_TMU1]->startAddr, - FX_valueToLod(FX_lodToValue(lodlevel) - + level), - FX_largeLodLog2(ti->info), - FX_aspectRatioLog2(ti->info), - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, data, - yoffset, yoffset + height - 1); - break; - default: - fprintf(stderr, "fxTMReloadSubMipMapLevel: INTERNAL ERROR: wrong tmu (%d)\n", tmu); - fxCloseHardware(); - exit(-1); - } -} - -void -fxTMMoveOutTM(fxMesaContext fxMesa, struct gl_texture_object *tObj) -{ - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - - if (TDFX_DEBUG & VERBOSE_DRIVER) { - fprintf(stderr, "fxTMMoveOutTM(%p (%d))\n", (void *)tObj, tObj->Name); - } - - if (!ti->isInTM) - return; - - switch (ti->whichTMU) { - case FX_TMU0: - case FX_TMU1: - fxTMRemoveRange(fxMesa, (int) ti->whichTMU, ti->tm[ti->whichTMU]); - break; - case FX_TMU_SPLIT: - case FX_TMU_BOTH: - fxTMRemoveRange(fxMesa, FX_TMU0, ti->tm[FX_TMU0]); - fxTMRemoveRange(fxMesa, FX_TMU1, ti->tm[FX_TMU1]); - break; - default: - fprintf(stderr, "fxTMMoveOutTM: INTERNAL ERROR: bad TMU (%ld)\n", ti->whichTMU); - fxCloseHardware(); - exit(-1); - } - - ti->isInTM = GL_FALSE; - ti->whichTMU = FX_TMU_NONE; -} - -void -fxTMFreeTexture(fxMesaContext fxMesa, struct gl_texture_object *tObj) -{ - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - int i; - - if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxTMFreeTexture(%p (%d))\n", (void *)tObj, tObj->Name); - } - - fxTMMoveOutTM(fxMesa, tObj); - - for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { - struct gl_texture_image *texImage = tObj->Image[0][i]; - if (texImage) { - if (texImage->DriverData) { - FREE(texImage->DriverData); - texImage->DriverData = NULL; - } - } - } - switch (ti->whichTMU) { - case FX_TMU0: - case FX_TMU1: - fxTMDeleteRangeNode(fxMesa, ti->tm[ti->whichTMU]); - break; - case FX_TMU_SPLIT: - case FX_TMU_BOTH: - fxTMDeleteRangeNode(fxMesa, ti->tm[FX_TMU0]); - fxTMDeleteRangeNode(fxMesa, ti->tm[FX_TMU1]); - break; - } -} - -void -fxTMInit(fxMesaContext fxMesa) -{ - fxMesa->texBindNumber = 0; - fxMesa->tmPool = 0; - - if (fxMesa->HaveTexUma) { - grEnable(GR_TEXTURE_UMA_EXT); - } - - fxTMUInit(fxMesa, FX_TMU0); - - if (!fxMesa->HaveTexUma && fxMesa->haveTwoTMUs) - fxTMUInit(fxMesa, FX_TMU1); - - texBoundMask = (fxMesa->type >= GR_SSTTYPE_Banshee) ? -1 : (FX_2MB_SPLIT - 1); -} - -void -fxTMClose(fxMesaContext fxMesa) -{ - MemRange *tmp, *next; - - tmp = fxMesa->tmPool; - while (tmp) { - next = tmp->next; - FREE(tmp); - tmp = next; - } - tmp = fxMesa->tmFree[FX_TMU0]; - while (tmp) { - next = tmp->next; - FREE(tmp); - tmp = next; - } - if (fxMesa->haveTwoTMUs) { - tmp = fxMesa->tmFree[FX_TMU1]; - while (tmp) { - next = tmp->next; - FREE(tmp); - tmp = next; - } - } -} - -void -fxTMRestoreTextures_NoLock(fxMesaContext ctx) -{ - struct _mesa_HashTable *textures = ctx->glCtx->Shared->TexObjects; - GLuint id; - - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *tObj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - if (ti && ti->isInTM) { - int i; - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { - if (ctx->glCtx->Texture.Unit[i]._Current == tObj) { - /* Force the texture onto the board, as it could be in use */ - int where = ti->whichTMU; - fxTMMoveOutTM_NoLock(ctx, tObj); - fxTMMoveInTM_NoLock(ctx, tObj, where); - break; - } - } - if (i == MAX_TEXTURE_UNITS) /* Mark the texture as off the board */ - fxTMMoveOutTM_NoLock(ctx, tObj); - } - } -} - -#else - - -/* - * Need this to provide at least one external definition. - */ - -extern int gl_fx_dummy_function_texman(void); -int -gl_fx_dummy_function_texman(void) -{ - return 0; -} - -#endif /* FX */ diff --git a/src/mesa/drivers/glide/fxtris.c b/src/mesa/drivers/glide/fxtris.c deleted file mode 100644 index aff91fe7d4..0000000000 --- a/src/mesa/drivers/glide/fxtris.c +++ /dev/null @@ -1,1832 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * Copyright (C) 1999-2001 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. - */ - -/* Authors: - * Keith Whitwell - * Daniel Borca - */ - -#include "glheader.h" - -#ifdef FX - -#include "main/imports.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/colormac.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - -#include "fxdrv.h" - - -static GLboolean fxMultipass_ColorSum (GLcontext *ctx, GLuint pass); - - -/* - * Subpixel offsets to adjust Mesa's (true) window coordinates to - * Glide coordinates. We need these to ensure precise rasterization. - * Otherwise, we'll fail a bunch of conformance tests. - */ -#define TRI_X_OFFSET ( 0.0F) -#define TRI_Y_OFFSET ( 0.0F) -#define LINE_X_OFFSET ( 0.0F) -#define LINE_Y_OFFSET ( 0.125F) -#define PNT_X_OFFSET ( 0.375F) -#define PNT_Y_OFFSET ( 0.375F) - -static void fxRasterPrimitive( GLcontext *ctx, GLenum prim ); -static void fxRenderPrimitive( GLcontext *ctx, GLenum prim ); - -static GLenum reduced_prim[GL_POLYGON+1] = { - GL_POINTS, - GL_LINES, - GL_LINES, - GL_LINES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES -}; - -/*********************************************************************** - * Macros for t_dd_tritmp.h to draw basic primitives * - ***********************************************************************/ - -#define TRI( a, b, c ) \ -do { \ - if (DO_FALLBACK) \ - fxMesa->draw_tri( fxMesa, a, b, c ); \ - else \ - grDrawTriangle( a, b, c ); \ -} while (0) \ - -#define QUAD( a, b, c, d ) \ -do { \ - if (DO_FALLBACK) { \ - fxMesa->draw_tri( fxMesa, a, b, d ); \ - fxMesa->draw_tri( fxMesa, b, c, d ); \ - } else { \ - GrVertex *_v_[4]; \ - _v_[0] = d; \ - _v_[1] = a; \ - _v_[2] = b; \ - _v_[3] = c; \ - grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\ - /*grDrawTriangle( a, b, d );*/ \ - /*grDrawTriangle( b, c, d );*/ \ - } \ -} while (0) - -#define LINE( v0, v1 ) \ -do { \ - if (DO_FALLBACK) \ - fxMesa->draw_line( fxMesa, v0, v1 ); \ - else { \ - v0->x += LINE_X_OFFSET - TRI_X_OFFSET; \ - v0->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \ - v1->x += LINE_X_OFFSET - TRI_X_OFFSET; \ - v1->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \ - grDrawLine( v0, v1 ); \ - v0->x -= LINE_X_OFFSET - TRI_X_OFFSET; \ - v0->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \ - v1->x -= LINE_X_OFFSET - TRI_X_OFFSET; \ - v1->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \ - } \ -} while (0) - -#define POINT( v0 ) \ -do { \ - if (DO_FALLBACK) \ - fxMesa->draw_point( fxMesa, v0 ); \ - else { \ - v0->x += PNT_X_OFFSET - TRI_X_OFFSET; \ - v0->y += PNT_Y_OFFSET - TRI_Y_OFFSET; \ - grDrawPoint( v0 ); \ - v0->x -= PNT_X_OFFSET - TRI_X_OFFSET; \ - v0->y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \ - } \ -} while (0) - - -/*********************************************************************** - * Fallback to swrast for basic primitives * - ***********************************************************************/ - -/* Build an SWvertex from a hardware vertex. - * - * This code is hit only when a mix of accelerated and unaccelerated - * primitives are being drawn, and only for the unaccelerated - * primitives. - */ -static void -fx_translate_vertex( GLcontext *ctx, const GrVertex *src, SWvertex *dst) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLuint ts0 = fxMesa->tmu_source[0]; - GLuint ts1 = fxMesa->tmu_source[1]; - GLfloat w = 1.0F / src->oow; - - dst->win[0] = src->x; - dst->win[1] = src->y; - dst->win[2] = src->ooz; - dst->win[3] = src->oow; - -#if FX_PACKEDCOLOR - dst->color[0] = src->pargb[2]; - dst->color[1] = src->pargb[1]; - dst->color[2] = src->pargb[0]; - dst->color[3] = src->pargb[3]; - - dst->specular[0] = src->pspec[2]; - dst->specular[1] = src->pspec[1]; - dst->specular[2] = src->pspec[0]; -#else /* !FX_PACKEDCOLOR */ - dst->color[0] = src->r; - dst->color[1] = src->g; - dst->color[2] = src->b; - dst->color[3] = src->a; - - dst->specular[0] = src->r1; - dst->specular[1] = src->g1; - dst->specular[2] = src->g1; -#endif /* !FX_PACKEDCOLOR */ - - dst->texcoord[ts0][0] = fxMesa->inv_s0scale * src->tmuvtx[0].sow * w; - dst->texcoord[ts0][1] = fxMesa->inv_t0scale * src->tmuvtx[0].tow * w; - - if (fxMesa->stw_hint_state & GR_STWHINT_W_DIFF_TMU0) - dst->texcoord[ts0][3] = src->tmuvtx[0].oow * w; - else - dst->texcoord[ts0][3] = 1.0F; - - if (fxMesa->SetupIndex & SETUP_TMU1) { - dst->texcoord[ts1][0] = fxMesa->inv_s1scale * src->tmuvtx[1].sow * w; - dst->texcoord[ts1][1] = fxMesa->inv_t1scale * src->tmuvtx[1].tow * w; - - if (fxMesa->stw_hint_state & GR_STWHINT_W_DIFF_TMU1) - dst->texcoord[ts1][3] = src->tmuvtx[1].oow * w; - else - dst->texcoord[ts1][3] = 1.0F; - } - - dst->pointSize = src->psize; -} - - -static void -fx_fallback_tri( fxMesaContext fxMesa, - GrVertex *v0, - GrVertex *v1, - GrVertex *v2 ) -{ - GLcontext *ctx = fxMesa->glCtx; - SWvertex v[3]; - - fx_translate_vertex( ctx, v0, &v[0] ); - fx_translate_vertex( ctx, v1, &v[1] ); - fx_translate_vertex( ctx, v2, &v[2] ); - _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); -} - - -static void -fx_fallback_line( fxMesaContext fxMesa, - GrVertex *v0, - GrVertex *v1 ) -{ - GLcontext *ctx = fxMesa->glCtx; - SWvertex v[2]; - fx_translate_vertex( ctx, v0, &v[0] ); - fx_translate_vertex( ctx, v1, &v[1] ); - _swrast_Line( ctx, &v[0], &v[1] ); -} - - -static void -fx_fallback_point( fxMesaContext fxMesa, - GrVertex *v0 ) -{ - GLcontext *ctx = fxMesa->glCtx; - SWvertex v[1]; - fx_translate_vertex( ctx, v0, &v[0] ); - _swrast_Point( ctx, &v[0] ); -} - -/*********************************************************************** - * Functions to draw basic primitives * - ***********************************************************************/ - -static void fx_print_vertex( GLcontext *ctx, const GrVertex *v ) -{ - fprintf(stderr, "fx_print_vertex:\n"); - - fprintf(stderr, "\tvertex at %p\n", (void *) v); - - fprintf(stderr, "\tx %f y %f z %f oow %f\n", v->x, v->y, v->ooz, v->oow); -#if FX_PACKEDCOLOR - fprintf(stderr, "\tr %d g %d b %d a %d\n", v->pargb[2], v->pargb[1], v->pargb[0], v->pargb[3]); -#else /* !FX_PACKEDCOLOR */ - fprintf(stderr, "\tr %f g %f b %f a %f\n", v->r, v->g, v->b, v->a); -#endif /* !FX_PACKEDCOLOR */ - - fprintf(stderr, "\n"); -} - -#define DO_FALLBACK 0 - -/* Need to do clip loop at each triangle when mixing swrast and hw - * rendering. These functions are only used when mixed-mode rendering - * is occurring. - */ -static void fx_draw_triangle( fxMesaContext fxMesa, - GrVertex *v0, - GrVertex *v1, - GrVertex *v2 ) -{ - BEGIN_CLIP_LOOP(); - TRI( v0, v1, v2 ); - END_CLIP_LOOP(); -} - -static void fx_draw_line( fxMesaContext fxMesa, - GrVertex *v0, - GrVertex *v1 ) -{ - /* No support for wide lines (avoid wide/aa line fallback). - */ - BEGIN_CLIP_LOOP(); - LINE(v0, v1); - END_CLIP_LOOP(); -} - -static void fx_draw_point( fxMesaContext fxMesa, - GrVertex *v0 ) -{ - /* No support for wide points. - */ - BEGIN_CLIP_LOOP(); - POINT( v0 ); - END_CLIP_LOOP(); -} - -#ifndef M_2PI -#define M_2PI 6.28318530717958647692528676655901 -#endif -#define __GL_COSF cos -#define __GL_SINF sin -static void fx_draw_point_sprite ( fxMesaContext fxMesa, - GrVertex *v0, GLfloat psize ) -{ - const GLcontext *ctx = fxMesa->glCtx; - - GLfloat radius; - GrVertex _v_[4]; - GLuint ts0 = fxMesa->tmu_source[0]; - GLuint ts1 = fxMesa->tmu_source[1]; - GLfloat w = v0->oow; - GLfloat u0scale = fxMesa->s0scale * w; - GLfloat v0scale = fxMesa->t0scale * w; - GLfloat u1scale = fxMesa->s1scale * w; - GLfloat v1scale = fxMesa->t1scale * w; - - radius = psize / 2.0F; - _v_[0] = *v0; - _v_[1] = *v0; - _v_[2] = *v0; - _v_[3] = *v0; - /* CLIP_LOOP ?!? */ - /* point coverage? */ - /* we don't care about culling here (see fxSetupCull) */ - - if (ctx->Point.SpriteOrigin == GL_UPPER_LEFT) { - _v_[0].x -= radius; - _v_[0].y += radius; - _v_[1].x += radius; - _v_[1].y += radius; - _v_[2].x += radius; - _v_[2].y -= radius; - _v_[3].x -= radius; - _v_[3].y -= radius; - } else { - _v_[0].x -= radius; - _v_[0].y -= radius; - _v_[1].x += radius; - _v_[1].y -= radius; - _v_[2].x += radius; - _v_[2].y += radius; - _v_[3].x -= radius; - _v_[3].y += radius; - } - - if (ctx->Point.CoordReplace[ts0]) { - _v_[0].tmuvtx[0].sow = 0; - _v_[0].tmuvtx[0].tow = 0; - _v_[1].tmuvtx[0].sow = u0scale; - _v_[1].tmuvtx[0].tow = 0; - _v_[2].tmuvtx[0].sow = u0scale; - _v_[2].tmuvtx[0].tow = v0scale; - _v_[3].tmuvtx[0].sow = 0; - _v_[3].tmuvtx[0].tow = v0scale; - } - if (ctx->Point.CoordReplace[ts1]) { - _v_[0].tmuvtx[1].sow = 0; - _v_[0].tmuvtx[1].tow = 0; - _v_[1].tmuvtx[1].sow = u1scale; - _v_[1].tmuvtx[1].tow = 0; - _v_[2].tmuvtx[1].sow = u1scale; - _v_[2].tmuvtx[1].tow = v1scale; - _v_[3].tmuvtx[1].sow = 0; - _v_[3].tmuvtx[1].tow = v1scale; - } - - grDrawVertexArrayContiguous(GR_TRIANGLE_FAN, 4, _v_, sizeof(GrVertex)); -} - -static void fx_draw_point_wide ( fxMesaContext fxMesa, - GrVertex *v0 ) -{ - GLint i, n; - GLfloat ang, radius, oon; - GrVertex vtxB, vtxC; - GrVertex *_v_[3]; - - const GLcontext *ctx = fxMesa->glCtx; - const GLfloat psize = (ctx->_TriangleCaps & DD_POINT_ATTEN) - ? CLAMP(v0->psize, ctx->Point.MinSize, ctx->Point.MaxSize) - : ctx->Point._Size; /* clamped */ - - if (ctx->Point.PointSprite) { - fx_draw_point_sprite(fxMesa, v0, psize); - return; - } - - _v_[0] = v0; - _v_[1] = &vtxB; - _v_[2] = &vtxC; - - radius = psize / 2.0F; - n = IROUND(psize * 2); /* radius x 4 */ - if (n < 4) n = 4; - oon = 1.0F / (GLfloat)n; - - /* CLIP_LOOP ?!? */ - /* point coverage? */ - /* we don't care about culling here (see fxSetupCull) */ - - vtxB = *v0; - vtxC = *v0; - - vtxB.x += radius; - ang = M_2PI * oon; - vtxC.x += radius * __GL_COSF(ang); - vtxC.y += radius * __GL_SINF(ang); - grDrawVertexArray(GR_TRIANGLE_FAN, 3, _v_); - for (i = 2; i <= n; i++) { - ang = M_2PI * i * oon; - vtxC.x = v0->x + radius * __GL_COSF(ang); - vtxC.y = v0->y + radius * __GL_SINF(ang); - grDrawVertexArray(GR_TRIANGLE_FAN_CONTINUE, 1, &_v_[2]); - } -} - -static void fx_render_pw_verts( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - (void) flags; - - fxRenderPrimitive( ctx, GL_POINTS ); - - for ( ; start < count ; start++) - fx_draw_point_wide(fxMesa, fxVB + start); -} - -static void fx_render_pw_elts ( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; - (void) flags; - - fxRenderPrimitive( ctx, GL_POINTS ); - - for ( ; start < count ; start++) - fx_draw_point_wide(fxMesa, fxVB + elt[start]); -} - -static void fx_draw_point_wide_aa ( fxMesaContext fxMesa, - GrVertex *v0 ) -{ - GLint i, n; - GLfloat ang, radius, oon; - GrVertex vtxB, vtxC; - - const GLcontext *ctx = fxMesa->glCtx; - const GLfloat psize = (ctx->_TriangleCaps & DD_POINT_ATTEN) - ? CLAMP(v0->psize, ctx->Point.MinSize, ctx->Point.MaxSize) - : ctx->Point._Size; /* clamped */ - - if (ctx->Point.PointSprite) { - fx_draw_point_sprite(fxMesa, v0, psize); - return; - } - - radius = psize / 2.0F; - n = IROUND(psize * 2); /* radius x 4 */ - if (n < 4) n = 4; - oon = 1.0F / (GLfloat)n; - - /* CLIP_LOOP ?!? */ - /* point coverage? */ - /* we don't care about culling here (see fxSetupCull) */ - - vtxB = *v0; - vtxC = *v0; - - vtxB.x += radius; - for (i = 1; i <= n; i++) { - ang = M_2PI * i * oon; - vtxC.x = v0->x + radius * __GL_COSF(ang); - vtxC.y = v0->y + radius * __GL_SINF(ang); - grAADrawTriangle( v0, &vtxB, &vtxC, FXFALSE, FXTRUE, FXFALSE); - /*grDrawTriangle( v0, &vtxB, &vtxC);*/ - vtxB.x = vtxC.x; - vtxB.y = vtxC.y; - } -} -#undef __GLCOSF -#undef __GLSINF -#undef M_2PI - -#undef DO_FALLBACK - - -#define FX_UNFILLED_BIT 0x1 -#define FX_OFFSET_BIT 0x2 -#define FX_TWOSIDE_BIT 0x4 -#define FX_FLAT_BIT 0x8 -#define FX_TWOSTENCIL_BIT 0x10 -#define FX_FALLBACK_BIT 0x20 -#define FX_MAX_TRIFUNC 0x40 - -static struct { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[FX_MAX_TRIFUNC]; - -#define DO_FALLBACK (IND & FX_FALLBACK_BIT) -#define DO_OFFSET (IND & FX_OFFSET_BIT) -#define DO_UNFILLED (IND & FX_UNFILLED_BIT) -#define DO_TWOSIDE (IND & FX_TWOSIDE_BIT) -#define DO_FLAT (IND & FX_FLAT_BIT) -#define DO_TWOSTENCIL (IND & FX_TWOSTENCIL_BIT) -#define DO_TRI 1 -#define DO_QUAD 1 -#define DO_LINE 1 -#define DO_POINTS 1 -#define DO_FULL_QUAD 1 - -#define HAVE_RGBA 1 -#define HAVE_SPEC 1 -#define HAVE_HW_FLATSHADE 0 -#define HAVE_BACK_COLORS 0 -#define VERTEX GrVertex -#define TAB rast_tab - -#define DEPTH_SCALE 1.0 -#define UNFILLED_TRI unfilled_tri -#define UNFILLED_QUAD unfilled_quad -#define VERT_X(_v) _v->x -#define VERT_Y(_v) _v->y -#define VERT_Z(_v) _v->ooz -#define AREA_IS_CCW( a ) IS_NEGATIVE( a ) -#define GET_VERTEX(e) (fxMesa->verts + e) - - -#if FX_PACKEDCOLOR -#define VERT_SET_RGBA( dst, f ) \ -do { \ - UNCLAMPED_FLOAT_TO_UBYTE(dst->pargb[2], f[0]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->pargb[1], f[1]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->pargb[0], f[2]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->pargb[3], f[3]);\ -} while (0) - -#define VERT_COPY_RGBA( v0, v1 ) \ - *(GLuint *)&v0->pargb = *(GLuint *)&v1->pargb - -#define VERT_SAVE_RGBA( idx ) \ - *(GLuint *)&color[idx] = *(GLuint *)&v[idx]->pargb - -#define VERT_RESTORE_RGBA( idx ) \ - *(GLuint *)&v[idx]->pargb = *(GLuint *)&color[idx] - - -#define VERT_SET_SPEC( dst, f ) \ -do { \ - UNCLAMPED_FLOAT_TO_UBYTE(dst->pspec[2], f[0]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->pspec[1], f[1]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->pspec[0], f[2]);\ -} while (0) - -#define VERT_COPY_SPEC( v0, v1 ) \ - *(GLuint *)&v0->pspec = *(GLuint *)&v1->pspec - -#define VERT_SAVE_SPEC( idx ) \ - *(GLuint *)&spec[idx] = *(GLuint *)&v[idx]->pspec - -#define VERT_RESTORE_SPEC( idx ) \ - *(GLuint *)&v[idx]->pspec = *(GLuint *)&spec[idx] - - -#define LOCAL_VARS(n) \ - fxMesaContext fxMesa = FX_CONTEXT(ctx); \ - GLubyte color[n][4], spec[n][4]; \ - (void) color; (void) spec; -#else /* !FX_PACKEDCOLOR */ -#define VERT_SET_RGBA( dst, f ) \ -do { \ - CNORM(dst->r, f[0]); \ - CNORM(dst->g, f[1]); \ - CNORM(dst->b, f[2]); \ - CNORM(dst->a, f[3]); \ -} while (0) - -#define VERT_COPY_RGBA( v0, v1 ) \ -do { \ - COPY_FLOAT(v0->r, v1->r); \ - COPY_FLOAT(v0->g, v1->g); \ - COPY_FLOAT(v0->b, v1->b); \ - COPY_FLOAT(v0->a, v1->a); \ -} while (0) - -#define VERT_SAVE_RGBA( idx ) \ -do { \ - COPY_FLOAT(color[idx][0], v[idx]->r); \ - COPY_FLOAT(color[idx][1], v[idx]->g); \ - COPY_FLOAT(color[idx][2], v[idx]->b); \ - COPY_FLOAT(color[idx][3], v[idx]->a); \ -} while (0) - -#define VERT_RESTORE_RGBA( idx ) \ -do { \ - COPY_FLOAT(v[idx]->r, color[idx][0]); \ - COPY_FLOAT(v[idx]->g, color[idx][1]); \ - COPY_FLOAT(v[idx]->b, color[idx][2]); \ - COPY_FLOAT(v[idx]->a, color[idx][3]); \ -} while (0) - - -#define VERT_SET_SPEC( dst, f ) \ -do { \ - CNORM(dst->r1, f[0]); \ - CNORM(dst->g1, f[1]); \ - CNORM(dst->b1, f[2]); \ -} while (0) - -#define VERT_COPY_SPEC( v0, v1 ) \ -do { \ - COPY_FLOAT(v0->r1, v1->r1); \ - COPY_FLOAT(v0->g1, v1->g1); \ - COPY_FLOAT(v0->b1, v1->b1); \ -} while (0) - -#define VERT_SAVE_SPEC( idx ) \ -do { \ - COPY_FLOAT(spec[idx][0], v[idx]->r1); \ - COPY_FLOAT(spec[idx][1], v[idx]->g1); \ - COPY_FLOAT(spec[idx][2], v[idx]->b1); \ -} while (0) - -#define VERT_RESTORE_SPEC( idx ) \ -do { \ - COPY_FLOAT(v[idx]->r1, spec[idx][0]); \ - COPY_FLOAT(v[idx]->g1, spec[idx][1]); \ - COPY_FLOAT(v[idx]->b1, spec[idx][2]); \ -} while (0) - - -#define LOCAL_VARS(n) \ - fxMesaContext fxMesa = FX_CONTEXT(ctx); \ - GLfloat color[n][4], spec[n][4]; \ - (void) color; (void) spec; -#endif /* !FX_PACKEDCOLOR */ - - -/*********************************************************************** - * Twoside stencil * - ***********************************************************************/ -#define SETUP_STENCIL(f) if (f) fxSetupStencilFace(ctx, f) -#define UNSET_STENCIL(f) if (f) fxSetupStencil(ctx) - - -/*********************************************************************** - * Functions to draw basic unfilled primitives * - ***********************************************************************/ - -#define RASTERIZE(x) if (fxMesa->raster_primitive != reduced_prim[x]) \ - fxRasterPrimitive( ctx, reduced_prim[x] ) -#define RENDER_PRIMITIVE fxMesa->render_primitive -#define IND FX_FALLBACK_BIT -#define TAG(x) x -#include "tnl_dd/t_dd_unfilled.h" -#undef IND - -/*********************************************************************** - * Functions to draw GL primitives * - ***********************************************************************/ - -#define IND (0) -#define TAG(x) x -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_UNFILLED_BIT) -#define TAG(x) x##_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT) -#define TAG(x) x##_twoside_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_FALLBACK_BIT) -#define TAG(x) x##_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT) -#define TAG(x) x##_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT) -#define TAG(x) x##_twoside_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT) -#define TAG(x) x##_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT) -#define TAG(x) x##_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT) -#define TAG(x) x##_twoside_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \ - FX_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - - -/* Fx doesn't support provoking-vertex flat-shading? - */ -#define IND (FX_FLAT_BIT) -#define TAG(x) x##_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_FLAT_BIT) -#define TAG(x) x##_offset_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_FLAT_BIT) -#define TAG(x) x##_twoside_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FLAT_BIT) -#define TAG(x) x##_twoside_offset_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_UNFILLED_BIT|FX_FLAT_BIT) -#define TAG(x) x##_unfilled_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT) -#define TAG(x) x##_offset_unfilled_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT) -#define TAG(x) x##_twoside_unfilled_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT) -#define TAG(x) x##_twoside_offset_unfilled_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_FALLBACK_BIT|FX_FLAT_BIT) -#define TAG(x) x##_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT) -#define TAG(x) x##_offset_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT) -#define TAG(x) x##_twoside_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT) -#define TAG(x) x##_twoside_offset_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT) -#define TAG(x) x##_unfilled_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT) -#define TAG(x) x##_offset_unfilled_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT) -#define TAG(x) x##_twoside_unfilled_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \ - FX_FALLBACK_BIT|FX_FLAT_BIT) -#define TAG(x) x##_twoside_offset_unfilled_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - - -/* 2-sided stencil begin */ -#define IND (FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_offset_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_offset_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_UNFILLED_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_unfilled_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_offset_unfilled_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_unfilled_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_offset_unfilled_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_fallback_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_offset_fallback_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_fallback_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_offset_fallback_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_unfilled_fallback_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_offset_unfilled_fallback_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_unfilled_fallback_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \ - FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_offset_unfilled_fallback_twostencil -#include "tnl_dd/t_dd_tritmp.h" - - -/* Fx doesn't support provoking-vertex flat-shading? - */ -#define IND (FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_offset_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_offset_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_UNFILLED_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_unfilled_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_offset_unfilled_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_unfilled_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_offset_unfilled_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_fallback_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_offset_fallback_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_fallback_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_offset_fallback_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_unfilled_fallback_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_offset_unfilled_fallback_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_unfilled_fallback_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \ - FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT) -#define TAG(x) x##_twoside_offset_unfilled_fallback_flat_twostencil -#include "tnl_dd/t_dd_tritmp.h" -/* 2-sided stencil end */ - - -static void init_rast_tab( void ) -{ - init(); - init_offset(); - init_twoside(); - init_twoside_offset(); - init_unfilled(); - init_offset_unfilled(); - init_twoside_unfilled(); - init_twoside_offset_unfilled(); - init_fallback(); - init_offset_fallback(); - init_twoside_fallback(); - init_twoside_offset_fallback(); - init_unfilled_fallback(); - init_offset_unfilled_fallback(); - init_twoside_unfilled_fallback(); - init_twoside_offset_unfilled_fallback(); - - init_flat(); - init_offset_flat(); - init_twoside_flat(); - init_twoside_offset_flat(); - init_unfilled_flat(); - init_offset_unfilled_flat(); - init_twoside_unfilled_flat(); - init_twoside_offset_unfilled_flat(); - init_fallback_flat(); - init_offset_fallback_flat(); - init_twoside_fallback_flat(); - init_twoside_offset_fallback_flat(); - init_unfilled_fallback_flat(); - init_offset_unfilled_fallback_flat(); - init_twoside_unfilled_fallback_flat(); - init_twoside_offset_unfilled_fallback_flat(); - - /* 2-sided stencil begin */ - init_twostencil(); - init_offset_twostencil(); - init_twoside_twostencil(); - init_twoside_offset_twostencil(); - init_unfilled_twostencil(); - init_offset_unfilled_twostencil(); - init_twoside_unfilled_twostencil(); - init_twoside_offset_unfilled_twostencil(); - init_fallback_twostencil(); - init_offset_fallback_twostencil(); - init_twoside_fallback_twostencil(); - init_twoside_offset_fallback_twostencil(); - init_unfilled_fallback_twostencil(); - init_offset_unfilled_fallback_twostencil(); - init_twoside_unfilled_fallback_twostencil(); - init_twoside_offset_unfilled_fallback_twostencil(); - - init_flat_twostencil(); - init_offset_flat_twostencil(); - init_twoside_flat_twostencil(); - init_twoside_offset_flat_twostencil(); - init_unfilled_flat_twostencil(); - init_offset_unfilled_flat_twostencil(); - init_twoside_unfilled_flat_twostencil(); - init_twoside_offset_unfilled_flat_twostencil(); - init_fallback_flat_twostencil(); - init_offset_fallback_flat_twostencil(); - init_twoside_fallback_flat_twostencil(); - init_twoside_offset_fallback_flat_twostencil(); - init_unfilled_fallback_flat_twostencil(); - init_offset_unfilled_fallback_flat_twostencil(); - init_twoside_unfilled_fallback_flat_twostencil(); - init_twoside_offset_unfilled_fallback_flat_twostencil(); - /* 2-sided stencil end */ -} - - -/**********************************************************************/ -/* Render whole begin/end objects */ -/**********************************************************************/ - - -/* Accelerate vertex buffer rendering when renderindex == 0 and - * there is no clipping. - */ -#define INIT(x) fxRenderPrimitive( ctx, x ) - -static void fx_render_vb_points( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - GLint i; - (void) flags; - - if (TDFX_DEBUG & VERBOSE_VARRAY) { - fprintf(stderr, "fx_render_vb_points\n"); - } - - INIT(GL_POINTS); - - /* Adjust point coords */ - for (i = start; i < count; i++) { - fxVB[i].x += PNT_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += PNT_Y_OFFSET - TRI_Y_OFFSET; - } - - grDrawVertexArrayContiguous( GR_POINTS, count-start, - fxVB + start, sizeof(GrVertex)); - /* restore point coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= PNT_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= PNT_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void fx_render_vb_line_strip( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - GLint i; - (void) flags; - - if (TDFX_DEBUG & VERBOSE_VARRAY) { - fprintf(stderr, "fx_render_vb_line_strip\n"); - } - - INIT(GL_LINE_STRIP); - - /* adjust line coords */ - for (i = start; i < count; i++) { - fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; - } - - grDrawVertexArrayContiguous( GR_LINE_STRIP, count-start, - fxVB + start, sizeof(GrVertex)); - - /* restore line coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void fx_render_vb_line_loop( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - GLint i; - GLint j = start; - (void) flags; - - if (TDFX_DEBUG & VERBOSE_VARRAY) { - fprintf(stderr, "fx_render_vb_line_loop\n"); - } - - INIT(GL_LINE_LOOP); - - if (!(flags & PRIM_BEGIN)) { - j++; - } - - /* adjust line coords */ - for (i = start; i < count; i++) { - fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; - } - - grDrawVertexArrayContiguous( GR_LINE_STRIP, count-j, - fxVB + j, sizeof(GrVertex)); - - if (flags & PRIM_END) - grDrawLine( fxVB + (count - 1), - fxVB + start ); - - /* restore line coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void fx_render_vb_lines( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - GLint i; - (void) flags; - - if (TDFX_DEBUG & VERBOSE_VARRAY) { - fprintf(stderr, "fx_render_vb_lines\n"); - } - - INIT(GL_LINES); - - /* adjust line coords */ - for (i = start; i < count; i++) { - fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; - } - - grDrawVertexArrayContiguous( GR_LINES, count-start, - fxVB + start, sizeof(GrVertex)); - - /* restore line coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void fx_render_vb_triangles( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - GLuint j; - (void) flags; - - if (TDFX_DEBUG & VERBOSE_VARRAY) { - fprintf(stderr, "fx_render_vb_triangles\n"); - } - - INIT(GL_TRIANGLES); - - for (j=start+2; jverts; - (void) flags; - - if (TDFX_DEBUG & VERBOSE_VARRAY) { - fprintf(stderr, "fx_render_vb_tri_strip\n"); - } - - INIT(GL_TRIANGLE_STRIP); - - /* no GR_TRIANGLE_STRIP_CONTINUE?!? */ - - grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP, count-start, - fxVB + start, sizeof(GrVertex)); -} - - -static void fx_render_vb_tri_fan( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - (void) flags; - - if (TDFX_DEBUG & VERBOSE_VARRAY) { - fprintf(stderr, "fx_render_vb_tri_fan\n"); - } - - INIT(GL_TRIANGLE_FAN); - - grDrawVertexArrayContiguous( GR_TRIANGLE_FAN, count-start, - fxVB + start, sizeof(GrVertex) ); -} - -static void fx_render_vb_quads( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - GLuint i; - (void) flags; - - if (TDFX_DEBUG & VERBOSE_VARRAY) { - fprintf(stderr, "fx_render_vb_quads\n"); - } - - INIT(GL_QUADS); - - for (i = start + 3 ; i < count ; i += 4 ) { -#define VERT(x) (fxVB + (x)) - GrVertex *_v_[4]; - _v_[0] = VERT(i); - _v_[1] = VERT(i-3); - _v_[2] = VERT(i-2); - _v_[3] = VERT(i-1); - grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_); - /*grDrawTriangle( VERT(i-3), VERT(i-2), VERT(i) );*/ - /*grDrawTriangle( VERT(i-2), VERT(i-1), VERT(i) );*/ -#undef VERT - } -} - -static void fx_render_vb_quad_strip( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - (void) flags; - - if (TDFX_DEBUG & VERBOSE_VARRAY) { - fprintf(stderr, "fx_render_vb_quad_strip\n"); - } - - INIT(GL_QUAD_STRIP); - - count -= (count-start)&1; - - grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP, - count-start, fxVB + start, sizeof(GrVertex)); -} - -static void fx_render_vb_poly( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GrVertex *fxVB = fxMesa->verts; - (void) flags; - - if (TDFX_DEBUG & VERBOSE_VARRAY) { - fprintf(stderr, "fx_render_vb_poly\n"); - } - - INIT(GL_POLYGON); - - grDrawVertexArrayContiguous( GR_POLYGON, count-start, - fxVB + start, sizeof(GrVertex)); -} - -static void fx_render_vb_noop( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - (void) (ctx && start && count && flags); -} - -static void (*fx_render_tab_verts[GL_POLYGON+2])(GLcontext *, - GLuint, - GLuint, - GLuint) = -{ - fx_render_vb_points, - fx_render_vb_lines, - fx_render_vb_line_loop, - fx_render_vb_line_strip, - fx_render_vb_triangles, - fx_render_vb_tri_strip, - fx_render_vb_tri_fan, - fx_render_vb_quads, - fx_render_vb_quad_strip, - fx_render_vb_poly, - fx_render_vb_noop, -}; -#undef INIT - - -/**********************************************************************/ -/* Render whole (indexed) begin/end objects */ -/**********************************************************************/ - - -#define VERT(x) (vertptr + x) - -#define RENDER_POINTS( start, count ) \ - for ( ; start < count ; start++) \ - grDrawPoint( VERT(ELT(start)) ); - -#define RENDER_LINE( v0, v1 ) \ - grDrawLine( VERT(v0), VERT(v1) ) - -#define RENDER_TRI( v0, v1, v2 ) \ - grDrawTriangle( VERT(v0), VERT(v1), VERT(v2) ) - -#define RENDER_QUAD( v0, v1, v2, v3 ) \ - do { \ - GrVertex *_v_[4]; \ - _v_[0] = VERT(v3);\ - _v_[1] = VERT(v0);\ - _v_[2] = VERT(v1);\ - _v_[3] = VERT(v2);\ - grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\ - /*grDrawTriangle( VERT(v0), VERT(v1), VERT(v3) );*/\ - /*grDrawTriangle( VERT(v1), VERT(v2), VERT(v3) );*/\ - } while (0) - -#define INIT(x) fxRenderPrimitive( ctx, x ) - -#undef LOCAL_VARS -#define LOCAL_VARS \ - fxMesaContext fxMesa = FX_CONTEXT(ctx); \ - GrVertex *vertptr = fxMesa->verts; \ - const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ - (void) elt; - -#define RESET_STIPPLE -#define RESET_OCCLUSION -#define PRESERVE_VB_DEFS - -/* Elts, no clipping. - */ -#undef ELT -#undef TAG -#define TAG(x) fx_##x##_elts -#define ELT(x) elt[x] -#include "tnl_dd/t_dd_rendertmp.h" - -/* Verts, no clipping. - */ -#undef ELT -#undef TAG -#define TAG(x) fx_##x##_verts -#define ELT(x) x -/*#include "tnl_dd/t_dd_rendertmp.h"*/ /* we have fx_render_vb_* now */ - - - -/**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - - - -static void fxRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint prim = fxMesa->render_primitive; - - /* Render the new vertices as an unclipped polygon. - */ - { - GLuint *tmp = VB->Elts; - VB->Elts = (GLuint *)elts; - tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, - PRIM_BEGIN|PRIM_END ); - VB->Elts = tmp; - } - - /* Restore the render primitive - */ - if (prim != GL_POLYGON) - tnl->Driver.Render.PrimitiveNotify( ctx, prim ); -} - - -static void fxFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) -{ - int i; - fxMesaContext fxMesa = FX_CONTEXT( ctx ); - GrVertex *vertptr = fxMesa->verts; - if (n == 3) { - grDrawTriangle( VERT(elts[0]), VERT(elts[1]), VERT(elts[2]) ); - } else if (n <= 32) { - GrVertex *newvptr[32]; - for (i = 0 ; i < n ; i++) { - newvptr[i] = VERT(elts[i]); - } - grDrawVertexArray(GR_TRIANGLE_FAN, n, newvptr); - } else { - const GrVertex *start = VERT(elts[0]); - for (i = 2 ; i < n ; i++) { - grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) ); - } - } -} - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - - -#define POINT_FALLBACK (DD_POINT_SMOOTH) -#define LINE_FALLBACK (DD_LINE_STIPPLE) -#define TRI_FALLBACK (DD_TRI_SMOOTH | DD_TRI_STIPPLE) -#define ANY_FALLBACK_FLAGS (POINT_FALLBACK | LINE_FALLBACK | TRI_FALLBACK) -#define ANY_RASTER_FLAGS (DD_FLATSHADE | DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET \ - | DD_TRI_UNFILLED | DD_TRI_TWOSTENCIL) - - - -void fxDDChooseRenderState(GLcontext *ctx) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint index = 0; - - if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) { - if (flags & ANY_RASTER_FLAGS) { - if (flags & DD_TRI_TWOSTENCIL) index |= FX_TWOSTENCIL_BIT; - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= FX_TWOSIDE_BIT; - if (flags & DD_TRI_OFFSET) index |= FX_OFFSET_BIT; - if (flags & DD_TRI_UNFILLED) index |= FX_UNFILLED_BIT; - if (flags & DD_FLATSHADE) index |= FX_FLAT_BIT; - } - - fxMesa->draw_point = fx_draw_point; - fxMesa->draw_line = fx_draw_line; - fxMesa->draw_tri = fx_draw_triangle; - - /* Hook in fallbacks for specific primitives. */ - if (flags & (POINT_FALLBACK| - LINE_FALLBACK| - TRI_FALLBACK)) - { - if (fxMesa->verbose) { - fprintf(stderr, "Voodoo ! fallback (%x), raster (%x)\n", - flags & ANY_FALLBACK_FLAGS, flags & ANY_RASTER_FLAGS); - } - - if (flags & POINT_FALLBACK) - fxMesa->draw_point = fx_fallback_point; - - if (flags & LINE_FALLBACK) - fxMesa->draw_line = fx_fallback_line; - - if (flags & TRI_FALLBACK) - fxMesa->draw_tri = fx_fallback_tri; - - index |= FX_FALLBACK_BIT; - } - } - - tnl->Driver.Render.Points = rast_tab[index].points; - tnl->Driver.Render.Line = rast_tab[index].line; - tnl->Driver.Render.ClippedLine = rast_tab[index].line; - tnl->Driver.Render.Triangle = rast_tab[index].triangle; - tnl->Driver.Render.Quad = rast_tab[index].quad; - - if (index == 0) { - tnl->Driver.Render.PrimTabVerts = fx_render_tab_verts; - tnl->Driver.Render.PrimTabElts = fx_render_tab_elts; - tnl->Driver.Render.ClippedPolygon = fxFastRenderClippedPoly; - } else { - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedPolygon = fxRenderClippedPoly; - } - - fxMesa->render_index = index; - - /* [dBorca] Hack alert: more a trick than a real plug-in!!! */ - if (flags & (DD_POINT_SIZE | DD_POINT_ATTEN)) { - /* We need to set the point primitive to go through "rast_tab", - * to make sure "POINT" calls "fxMesa->draw_point" instead of - * "grDrawPoint". We can achieve this by using FX_FALLBACK_BIT - * (not really a total rasterization fallback, so we don't alter - * "fxMesa->render_index"). If we get here with DD_POINT_SMOOTH, - * we're done, cos we've already set _tnl_render_tab_{verts|elts} - * above. Otherwise, the T&L engine can optimize point rendering - * by using fx_render_tab_{verts|elts} hence the extra work. - */ - if (flags & DD_POINT_SMOOTH) { - fxMesa->draw_point = fx_draw_point_wide_aa; - } else { - fxMesa->draw_point = fx_draw_point_wide; - fx_render_tab_verts[0] = fx_render_pw_verts; - fx_render_tab_elts[0] = fx_render_pw_elts; - } - tnl->Driver.Render.Points = rast_tab[index|FX_FALLBACK_BIT].points; - } else { - fx_render_tab_verts[0] = fx_render_vb_points; - fx_render_tab_elts[0] = fx_render_points_elts; - } -} - - -/**********************************************************************/ -/* Runtime render state and callbacks */ -/**********************************************************************/ - -static void fxRunPipeline( GLcontext *ctx ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLuint new_gl_state = fxMesa->new_gl_state; - - if (TDFX_DEBUG & VERBOSE_PIPELINE) { - fprintf(stderr, "fxRunPipeline()\n"); - } - -#if 0 - /* Recalculate fog table on projection matrix changes. This used to - * be triggered by the NearFar callback. - */ - if (new_gl_state & _NEW_PROJECTION) - fxMesa->new_state |= FX_NEW_FOG; -#endif - - if (new_gl_state & _FX_NEW_IS_IN_HARDWARE) - fxCheckIsInHardware(ctx); - - if (fxMesa->new_state) - fxSetupFXUnits(ctx); - - if (!fxMesa->fallback) { - if (new_gl_state & _FX_NEW_RENDERSTATE) - fxDDChooseRenderState(ctx); - - if (new_gl_state & _FX_NEW_SETUP_FUNCTION) - fxChooseVertexState(ctx); - } - - if (new_gl_state & _NEW_TEXTURE) { - struct gl_texture_unit *t0 = &ctx->Texture.Unit[fxMesa->tmu_source[0]]; - struct gl_texture_unit *t1 = &ctx->Texture.Unit[fxMesa->tmu_source[1]]; - - if (t0->_Current && FX_TEXTURE_DATA(t0)) { - fxMesa->s0scale = FX_TEXTURE_DATA(t0)->sScale; - fxMesa->t0scale = FX_TEXTURE_DATA(t0)->tScale; - fxMesa->inv_s0scale = 1.0F / fxMesa->s0scale; - fxMesa->inv_t0scale = 1.0F / fxMesa->t0scale; - } - - if (t1->_Current && FX_TEXTURE_DATA(t1)) { - fxMesa->s1scale = FX_TEXTURE_DATA(t1)->sScale; - fxMesa->t1scale = FX_TEXTURE_DATA(t1)->tScale; - fxMesa->inv_s1scale = 1.0F / fxMesa->s1scale; - fxMesa->inv_t1scale = 1.0F / fxMesa->t1scale; - } - } - - fxMesa->new_gl_state = 0; - - _tnl_run_pipeline( ctx ); -} - - - -/* Always called between RenderStart and RenderFinish --> We already - * hold the lock. - */ -static void fxRasterPrimitive( GLcontext *ctx, GLenum prim ) -{ - fxMesaContext fxMesa = FX_CONTEXT( ctx ); - - fxMesa->raster_primitive = prim; - - fxSetupCull(ctx); -} - - - -/* Determine the rasterized primitive when not drawing unfilled - * polygons. - */ -static void fxRenderPrimitive( GLcontext *ctx, GLenum prim ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLuint rprim = reduced_prim[prim]; - - fxMesa->render_primitive = prim; - - if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) - return; - - if (fxMesa->raster_primitive != rprim) { - fxRasterPrimitive( ctx, rprim ); - } -} - -static void fxRenderFinish( GLcontext *ctx ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (fxMesa->render_index & FX_FALLBACK_BIT) - _swrast_flush( ctx ); -} - - - -/**********************************************************************/ -/* Manage total rasterization fallbacks */ -/**********************************************************************/ - -static char *fallbackStrings[] = { - "3D/Rect/Cube Texture map", - "glDrawBuffer(GL_FRONT_AND_BACK)", - "Separate specular color", - "glEnable/Disable(GL_STENCIL_TEST)", - "glRenderMode(selection or feedback)", - "glLogicOp()", - "Texture env mode", - "Texture border", - "glColorMask", - "blend mode", - "multitex" -}; - - -static char *getFallbackString(GLuint bit) -{ - int i = 0; - while (bit > 1) { - i++; - bit >>= 1; - } - return fallbackStrings[i]; -} - - -void fxCheckIsInHardware( GLcontext *ctx ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint oldfallback = fxMesa->fallback; - GLuint newfallback = fxMesa->fallback = fx_check_IsInHardware( ctx ); - - if (newfallback) { - if (oldfallback == 0) { - if (fxMesa->verbose) { - fprintf(stderr, "Voodoo ! enter SW 0x%08x %s\n", newfallback, getFallbackString(newfallback)); - } - _swsetup_Wakeup( ctx ); - } - } - else { - if (oldfallback) { - _swrast_flush( ctx ); - tnl->Driver.Render.Start = fxCheckTexSizes; - tnl->Driver.Render.Finish = fxRenderFinish; - tnl->Driver.Render.PrimitiveNotify = fxRenderPrimitive; - tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; - tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine; - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; - tnl->Driver.Render.BuildVertices = fxBuildVertices; - fxChooseVertexState(ctx); - fxDDChooseRenderState(ctx); - if (fxMesa->verbose) { - fprintf(stderr, "Voodoo ! leave SW 0x%08x %s\n", oldfallback, getFallbackString(oldfallback)); - } - } - tnl->Driver.Render.Multipass = NULL; - if (HAVE_SPEC && NEED_SECONDARY_COLOR(ctx)) { - tnl->Driver.Render.Multipass = fxMultipass_ColorSum; - /* obey stencil, but do not change it */ - fxMesa->multipass = GL_TRUE; - if (fxMesa->unitsState.stencilEnabled) { - fxMesa->new_state |= FX_NEW_STENCIL; - } - } - } -} - -void fxDDInitTriFuncs( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - static int firsttime = 1; - - if (firsttime) { - init_rast_tab(); - firsttime = 0; - } - - tnl->Driver.RunPipeline = fxRunPipeline; - tnl->Driver.Render.Start = fxCheckTexSizes; - tnl->Driver.Render.Finish = fxRenderFinish; - tnl->Driver.Render.PrimitiveNotify = fxRenderPrimitive; - tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; - tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine; - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; - tnl->Driver.Render.BuildVertices = fxBuildVertices; - tnl->Driver.Render.Multipass = NULL; - - (void) fx_print_vertex; -} - - -/* [dBorca] Hack alert: - * doesn't work with blending. - */ -static GLboolean -fxMultipass_ColorSum (GLcontext *ctx, GLuint pass) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxUnitsState *us = &fxMesa->unitsState; - - static int t0 = 0; - static int t1 = 0; - - switch (pass) { - case 1: /* first pass: the TEXTURED triangles are drawn */ - /* set stencil's real values */ - fxMesa->multipass = GL_FALSE; - if (us->stencilEnabled) { - fxSetupStencil(ctx); - } - /* save per-pass data */ - fxMesa->restoreUnitsState = *us; - /* turn off texturing */ - t0 = ctx->Texture.Unit[0]._ReallyEnabled; - t1 = ctx->Texture.Unit[1]._ReallyEnabled; - ctx->Texture.Unit[0]._ReallyEnabled = 0; - ctx->Texture.Unit[1]._ReallyEnabled = 0; - /* SUM the colors */ - fxDDBlendEquationSeparate(ctx, GL_FUNC_ADD, GL_FUNC_ADD); - fxDDBlendFuncSeparate(ctx, GL_ONE, GL_ONE, GL_ZERO, GL_ONE); - fxDDEnable(ctx, GL_BLEND, GL_TRUE); - /* make sure we draw only where we want to */ - if (us->depthTestEnabled) { - switch (us->depthTestFunc) { - default: - fxDDDepthFunc(ctx, GL_EQUAL); - case GL_NEVER: - case GL_ALWAYS: - ; - } - fxDDDepthMask(ctx, GL_FALSE); - } - /* switch to secondary colors */ -#if FX_PACKEDCOLOR - grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PSPEC_OFFSET << 2, GR_PARAM_ENABLE); -#else /* !FX_PACKEDCOLOR */ - grVertexLayout(GR_PARAM_RGB, GR_VERTEX_SPEC_OFFSET << 2, GR_PARAM_ENABLE); -#endif /* !FX_PACKEDCOLOR */ - /* don't advertise new state */ - fxMesa->new_state = 0; - break; - case 2: /* 2nd pass (last): the secondary color is summed over texture */ - /* restore original state */ - *us = fxMesa->restoreUnitsState; - /* restore texturing */ - ctx->Texture.Unit[0]._ReallyEnabled = t0; - ctx->Texture.Unit[1]._ReallyEnabled = t1; - /* revert to primary colors */ -#if FX_PACKEDCOLOR - grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE); -#else /* !FX_PACKEDCOLOR */ - grVertexLayout(GR_PARAM_RGB, GR_VERTEX_RGB_OFFSET << 2, GR_PARAM_ENABLE); -#endif /* !FX_PACKEDCOLOR */ - break; - default: - assert(0); /* NOTREACHED */ - } - - /* update HW state */ - fxSetupBlend(ctx); - fxSetupDepthTest(ctx); - fxSetupTexture(ctx); - - return (pass == 1); -} - - -#else - - -/* - * Need this to provide at least one external definition. - */ - -extern int gl_fx_dummy_function_tris(void); -int -gl_fx_dummy_function_tris(void) -{ - return 0; -} - -#endif /* FX */ diff --git a/src/mesa/drivers/glide/fxvb.c b/src/mesa/drivers/glide/fxvb.c deleted file mode 100644 index 64453cbe4b..0000000000 --- a/src/mesa/drivers/glide/fxvb.c +++ /dev/null @@ -1,838 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 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 - * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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. - */ - -/* Authors: - * Keith Whitwell - * Daniel Borca - */ - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#ifdef FX - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/colormac.h" - -#include "math/m_translate.h" -#include "swrast_setup/swrast_setup.h" - -#include "tnl/tnl.h" -#include "tnl/t_context.h" - -#include "fxdrv.h" - - -static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc ) -{ - fxMesaContext fxMesa = FX_CONTEXT( ctx ); - GrVertex *dst = fxMesa->verts + edst; - GrVertex *src = fxMesa->verts + esrc; - -#if FX_PACKEDCOLOR - *(GLuint *)&dst->pargb = *(GLuint *)&src->pargb; -#else /* !FX_PACKEDCOLOR */ - COPY_FLOAT(dst->r, src->r); - COPY_FLOAT(dst->g, src->g); - COPY_FLOAT(dst->b, src->b); - COPY_FLOAT(dst->a, src->a); -#endif /* !FX_PACKEDCOLOR */ -} - -static void copy_pv2( GLcontext *ctx, GLuint edst, GLuint esrc ) -{ - fxMesaContext fxMesa = FX_CONTEXT( ctx ); - GrVertex *dst = fxMesa->verts + edst; - GrVertex *src = fxMesa->verts + esrc; - -#if FX_PACKEDCOLOR - *(GLuint *)&dst->pargb = *(GLuint *)&src->pargb; - *(GLuint *)&dst->pspec = *(GLuint *)&src->pspec; -#else /* !FX_PACKEDCOLOR */ - COPY_FLOAT(dst->r, src->r); - COPY_FLOAT(dst->g, src->g); - COPY_FLOAT(dst->b, src->b); - COPY_FLOAT(dst->a, src->a); - COPY_FLOAT(dst->r1, src->r1); - COPY_FLOAT(dst->g1, src->g1); - COPY_FLOAT(dst->b1, src->b1); -#endif /* !FX_PACKEDCOLOR */ -} - -static struct { - void (*emit) (GLcontext *ctx, GLuint start, GLuint end, void *dest); - tnl_copy_pv_func copy_pv; - tnl_interp_func interp; - GLboolean (*check_tex_sizes) (GLcontext *ctx); - GLuint vertex_format; -} setup_tab[MAX_SETUP]; - - -#define GET_COLOR(ptr, idx) ((ptr)->data[idx]) - - -static void interp_extras( GLcontext *ctx, - GLfloat t, - GLuint dst, GLuint out, GLuint in, - GLboolean force_boundary ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (VB->BackfaceColorPtr) { - /* If stride is zero, BackfaceColorPtr is constant across the VB, so - * there is no point interpolating between two values as they will - * be identical. This case is handled in t_dd_tritmp.h - */ - if (VB->BackfaceColorPtr->stride) { - assert(VB->BackfaceColorPtr->stride == 4 * sizeof(GLfloat)); - INTERP_4F( t, - GET_COLOR(VB->BackfaceColorPtr, dst), - GET_COLOR(VB->BackfaceColorPtr, out), - GET_COLOR(VB->BackfaceColorPtr, in) ); - } - - if (VB->BackfaceSecondaryColorPtr) { - INTERP_3F( t, - GET_COLOR(VB->BackfaceSecondaryColorPtr, dst), - GET_COLOR(VB->BackfaceSecondaryColorPtr, out), - GET_COLOR(VB->BackfaceSecondaryColorPtr, in) ); - } - } - - if (VB->EdgeFlag) { - VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary; - } - - setup_tab[FX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in, - force_boundary); -} - -static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (VB->BackfaceColorPtr) { - COPY_4FV( GET_COLOR(VB->BackfaceColorPtr, dst), - GET_COLOR(VB->BackfaceColorPtr, src) ); - - if (VB->BackfaceSecondaryColorPtr) { - COPY_3FV( GET_COLOR(VB->BackfaceSecondaryColorPtr, dst), - GET_COLOR(VB->BackfaceSecondaryColorPtr, src) ); - } - } - - setup_tab[FX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src); -} - - -#define IND (SETUP_XYZW|SETUP_RGBA) -#define TAG(x) x##_wg -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0) -#define TAG(x) x##_wgt0 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1) -#define TAG(x) x##_wgt0t1 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX) -#define TAG(x) x##_wgpt0 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\ - SETUP_PTEX) -#define TAG(x) x##_wgpt0t1 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ) -#define TAG(x) x##_wga -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ) -#define TAG(x) x##_wgt0a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ) -#define TAG(x) x##_wgt0t1a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ) -#define TAG(x) x##_wgpt0a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\ - SETUP_PTEX|SETUP_PSIZ) -#define TAG(x) x##_wgpt0t1a -#include "fxvbtmp.h" - - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC) -#define TAG(x) x##_2wg -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0) -#define TAG(x) x##_2wgt0 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1) -#define TAG(x) x##_2wgt0t1 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX) -#define TAG(x) x##_2wgpt0 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\ - SETUP_PTEX) -#define TAG(x) x##_2wgpt0t1 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ) -#define TAG(x) x##_2wga -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ) -#define TAG(x) x##_2wgt0a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ) -#define TAG(x) x##_2wgt0t1a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ) -#define TAG(x) x##_2wgpt0a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\ - SETUP_PTEX|SETUP_PSIZ) -#define TAG(x) x##_2wgpt0t1a -#include "fxvbtmp.h" - -/* fog { */ -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_FOGC) -#define TAG(x) x##_wgf -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC) -#define TAG(x) x##_wgt0f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC) -#define TAG(x) x##_wgt0t1f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC) -#define TAG(x) x##_wgpt0f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\ - SETUP_PTEX|SETUP_FOGC) -#define TAG(x) x##_wgpt0t1f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_wgaf -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_wgt0af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_wgt0t1af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_wgpt0af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\ - SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_wgpt0t1af -#include "fxvbtmp.h" - - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC) -#define TAG(x) x##_2wgf -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC) -#define TAG(x) x##_2wgt0f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC) -#define TAG(x) x##_2wgt0t1f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC) -#define TAG(x) x##_2wgpt0f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\ - SETUP_PTEX|SETUP_FOGC) -#define TAG(x) x##_2wgpt0t1f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_2wgaf -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_2wgt0af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_2wgt0t1af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_2wgpt0af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\ - SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_2wgpt0t1af -#include "fxvbtmp.h" -/* fog } */ - - -/* Snapping for voodoo-1 - */ -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA) -#define TAG(x) x##_wsg -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0) -#define TAG(x) x##_wsgt0 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_TMU1) -#define TAG(x) x##_wsgt0t1 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_PTEX) -#define TAG(x) x##_wsgpt0 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PTEX) -#define TAG(x) x##_wsgpt0t1 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ) -#define TAG(x) x##_wsga -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ) -#define TAG(x) x##_wsgt0a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PSIZ) -#define TAG(x) x##_wsgt0t1a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_PTEX|SETUP_PSIZ) -#define TAG(x) x##_wsgpt0a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ) -#define TAG(x) x##_wsgpt0t1a -#include "fxvbtmp.h" - - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC) -#define TAG(x) x##_2wsg -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0) -#define TAG(x) x##_2wsgt0 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_TMU1) -#define TAG(x) x##_2wsgt0t1 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_PTEX) -#define TAG(x) x##_2wsgpt0 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PTEX) -#define TAG(x) x##_2wsgpt0t1 -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ) -#define TAG(x) x##_2wsga -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ) -#define TAG(x) x##_2wsgt0a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PSIZ) -#define TAG(x) x##_2wsgt0t1a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_PTEX|SETUP_PSIZ) -#define TAG(x) x##_2wsgpt0a -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ) -#define TAG(x) x##_2wsgpt0t1a -#include "fxvbtmp.h" - -/* fog { */ -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_FOGC) -#define TAG(x) x##_wsgf -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC) -#define TAG(x) x##_wsgt0f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_TMU1|SETUP_FOGC) -#define TAG(x) x##_wsgt0t1f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_PTEX|SETUP_FOGC) -#define TAG(x) x##_wsgpt0f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PTEX|SETUP_FOGC) -#define TAG(x) x##_wsgpt0t1f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_wsgaf -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_wsgt0af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_wsgt0t1af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_wsgpt0af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_wsgpt0t1af -#include "fxvbtmp.h" - - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC) -#define TAG(x) x##_2wsgf -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC) -#define TAG(x) x##_2wsgt0f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_TMU1|SETUP_FOGC) -#define TAG(x) x##_2wsgt0t1f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_PTEX|SETUP_FOGC) -#define TAG(x) x##_2wsgpt0f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PTEX|SETUP_FOGC) -#define TAG(x) x##_2wsgpt0t1f -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_2wsgaf -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_2wsgt0af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_2wsgt0t1af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_2wsgpt0af -#include "fxvbtmp.h" - -#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\ - SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC) -#define TAG(x) x##_2wsgpt0t1af -#include "fxvbtmp.h" -/* fog } */ - - -/* Vertex repair (multipass rendering) - */ -#define IND (SETUP_RGBA) -#define TAG(x) x##_g -#include "fxvbtmp.h" - -#define IND (SETUP_TMU0) -#define TAG(x) x##_t0 -#include "fxvbtmp.h" - -#define IND (SETUP_TMU0|SETUP_TMU1) -#define TAG(x) x##_t0t1 -#include "fxvbtmp.h" - -#define IND (SETUP_RGBA|SETUP_TMU0) -#define TAG(x) x##_gt0 -#include "fxvbtmp.h" - -#define IND (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1) -#define TAG(x) x##_gt0t1 -#include "fxvbtmp.h" - - -#define IND (SETUP_RGBA|SETUP_SPEC) -#define TAG(x) x##_2g -#include "fxvbtmp.h" - -#define IND (SETUP_TMU0|SETUP_SPEC) -#define TAG(x) x##_2t0 -#include "fxvbtmp.h" - -#define IND (SETUP_TMU0|SETUP_SPEC|SETUP_TMU1) -#define TAG(x) x##_2t0t1 -#include "fxvbtmp.h" - -#define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0) -#define TAG(x) x##_2gt0 -#include "fxvbtmp.h" - -#define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1) -#define TAG(x) x##_2gt0t1 -#include "fxvbtmp.h" - - - -static void init_setup_tab( void ) -{ - init_wg(); - init_wgt0(); - init_wgt0t1(); - init_wgpt0(); - init_wgpt0t1(); - init_wga(); - init_wgt0a(); - init_wgt0t1a(); - init_wgpt0a(); - init_wgpt0t1a(); - init_2wg(); - init_2wgt0(); - init_2wgt0t1(); - init_2wgpt0(); - init_2wgpt0t1(); - init_2wga(); - init_2wgt0a(); - init_2wgt0t1a(); - init_2wgpt0a(); - init_2wgpt0t1a(); - init_wgf(); - init_wgt0f(); - init_wgt0t1f(); - init_wgpt0f(); - init_wgpt0t1f(); - init_wgaf(); - init_wgt0af(); - init_wgt0t1af(); - init_wgpt0af(); - init_wgpt0t1af(); - init_2wgf(); - init_2wgt0f(); - init_2wgt0t1f(); - init_2wgpt0f(); - init_2wgpt0t1f(); - init_2wgaf(); - init_2wgt0af(); - init_2wgt0t1af(); - init_2wgpt0af(); - init_2wgpt0t1af(); - - init_wsg(); - init_wsgt0(); - init_wsgt0t1(); - init_wsgpt0(); - init_wsgpt0t1(); - init_wsga(); - init_wsgt0a(); - init_wsgt0t1a(); - init_wsgpt0a(); - init_wsgpt0t1a(); - init_2wsg(); - init_2wsgt0(); - init_2wsgt0t1(); - init_2wsgpt0(); - init_2wsgpt0t1(); - init_2wsga(); - init_2wsgt0a(); - init_2wsgt0t1a(); - init_2wsgpt0a(); - init_2wsgpt0t1a(); - init_wsgf(); - init_wsgt0f(); - init_wsgt0t1f(); - init_wsgpt0f(); - init_wsgpt0t1f(); - init_wsgaf(); - init_wsgt0af(); - init_wsgt0t1af(); - init_wsgpt0af(); - init_wsgpt0t1af(); - init_2wsgf(); - init_2wsgt0f(); - init_2wsgt0t1f(); - init_2wsgpt0f(); - init_2wsgpt0t1f(); - init_2wsgaf(); - init_2wsgt0af(); - init_2wsgt0t1af(); - init_2wsgpt0af(); - init_2wsgpt0t1af(); - - init_g(); - init_t0(); - init_t0t1(); - init_gt0(); - init_gt0t1(); - init_2g(); - init_2t0(); - init_2t0t1(); - init_2gt0(); - init_2gt0t1(); -} - - -void fxPrintSetupFlags(char *msg, GLuint flags ) -{ - fprintf(stderr, "%s(%x): %s%s%s%s%s%s%s%s\n", - msg, - (int)flags, - (flags & SETUP_XYZW) ? " xyzw," : "", - (flags & SETUP_SNAP) ? " snap," : "", - (flags & SETUP_RGBA) ? " rgba," : "", - (flags & SETUP_TMU0) ? " tex-0," : "", - (flags & SETUP_TMU1) ? " tex-1," : "", - (flags & SETUP_PSIZ) ? " psiz," : "", - (flags & SETUP_SPEC) ? " spec," : "", - (flags & SETUP_FOGC) ? " fog," : ""); -} - - - -void fxCheckTexSizes( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - fxMesaContext fxMesa = FX_CONTEXT( ctx ); - - if (!setup_tab[fxMesa->SetupIndex].check_tex_sizes(ctx)) { - GLuint ind = fxMesa->SetupIndex |= (SETUP_PTEX|SETUP_RGBA); - - /* Tdfx handles projective textures nicely; just have to change - * up to the new vertex format. - */ - if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) { - - fxMesa->stw_hint_state = setup_tab[ind].vertex_format; - FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state); - - /* This is required as we have just changed the vertex - * format, so the interp routines must also change. - * In the unfilled and twosided cases we are using the - * Extras ones anyway, so leave them in place. - */ - if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { - tnl->Driver.Render.Interp = setup_tab[fxMesa->SetupIndex].interp; - } - } - } -} - - -void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint end, - GLuint newinputs ) -{ - fxMesaContext fxMesa = FX_CONTEXT( ctx ); - GrVertex *v = (fxMesa->verts + start); - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[fxMesa->SetupIndex].emit( ctx, start, end, v ); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= SETUP_RGBA; - - if (newinputs & VERT_BIT_COLOR1) - ind |= SETUP_SPEC; - - if (newinputs & VERT_BIT_FOG) - ind |= SETUP_FOGC; - - if (newinputs & VERT_BIT_TEX0) - ind |= SETUP_TMU0; - - if (newinputs & VERT_BIT_TEX1) - ind |= SETUP_TMU0|SETUP_TMU1; - - if (fxMesa->SetupIndex & SETUP_PTEX) - ind = ~0; - - ind &= fxMesa->SetupIndex; - - if (ind) { - setup_tab[ind].emit( ctx, start, end, v ); - } - } -} - - -void fxChooseVertexState( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - fxMesaContext fxMesa = FX_CONTEXT( ctx ); - GLuint ind = SETUP_XYZW|SETUP_RGBA; - - if (fxMesa->snapVertices) - ind |= SETUP_SNAP; - - fxMesa->tmu_source[0] = 0; - fxMesa->tmu_source[1] = 1; - - if (ctx->Texture._EnabledUnits & 0x2) { - if (ctx->Texture._EnabledUnits & 0x1) { - ind |= SETUP_TMU1; - } - ind |= SETUP_TMU0; - fxMesa->tmu_source[0] = 1; - fxMesa->tmu_source[1] = 0; - } - else if (ctx->Texture._EnabledUnits & 0x1) { - ind |= SETUP_TMU0; - } - - if (ctx->_TriangleCaps & DD_POINT_ATTEN) { - ind |= SETUP_PSIZ; - } - - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) { - ind |= SETUP_SPEC; - } - - if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) { - ind |= SETUP_FOGC; - } - - fxMesa->SetupIndex = ind; - - if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) { - tnl->Driver.Render.Interp = interp_extras; - tnl->Driver.Render.CopyPV = copy_pv_extras; - } else { - tnl->Driver.Render.Interp = setup_tab[ind].interp; - tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv; - } - - if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) { - fxMesa->stw_hint_state = setup_tab[ind].vertex_format; - FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state); - } -} - - - -void fxAllocVB( GLcontext *ctx ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - } - - fxMesa->verts = (GrVertex *)_mesa_align_malloc(size * sizeof(GrVertex), 32); - fxMesa->SetupIndex = SETUP_XYZW|SETUP_RGBA; -} - - -void fxFreeVB( GLcontext *ctx ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - if (fxMesa->verts) { - _mesa_align_free(fxMesa->verts); - fxMesa->verts = 0; - } -} -#else - - -/* - * Need this to provide at least one external definition. - */ - -extern int gl_fx_dummy_function_vb(void); -int -gl_fx_dummy_function_vb(void) -{ - return 0; -} - -#endif /* FX */ diff --git a/src/mesa/drivers/glide/fxvbtmp.h b/src/mesa/drivers/glide/fxvbtmp.h deleted file mode 100644 index f7893c1573..0000000000 --- a/src/mesa/drivers/glide/fxvbtmp.h +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 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. - */ - -/* Authors: - * Keith Whitwell - * Daniel Borca - */ - - -#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12] -#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13] -#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14] - -static void TAG(emit)( GLcontext *ctx, - GLuint start, GLuint end, - void *dest ) -{ - fxMesaContext fxMesa = FX_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLuint tmu0_source = fxMesa->tmu_source[0]; - GLuint tmu1_source = fxMesa->tmu_source[1]; - GLfloat (*tc0)[4], (*tc1)[4]; - GLfloat (*col)[4], (*spec)[4]; - GLuint tc0_stride, tc1_stride, col_stride, spec_stride; - GLuint tc0_size, tc1_size, col_size; - GLfloat (*proj)[4] = VB->NdcPtr->data; - GLuint proj_stride = VB->NdcPtr->stride; - GLfloat (*psize)[4]; - GLuint psize_stride; - GLfloat (*fog)[4]; - GLuint fog_stride; - GrVertex *v = (GrVertex *)dest; - GLfloat u0scale,v0scale,u1scale,v1scale; - const GLubyte *mask = VB->ClipMask; - const GLfloat *const s = ctx->Viewport._WindowMap.m; - int i; - - if (IND & SETUP_PSIZ) { - psize = VB->PointSizePtr->data; - psize_stride = VB->PointSizePtr->stride; - } - - if (IND & SETUP_TMU0) { - tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->data; - tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->stride; - u0scale = fxMesa->s0scale; - v0scale = fxMesa->t0scale; - if (IND & SETUP_PTEX) - tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->size; - } - - if (IND & SETUP_TMU1) { - tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->data; - tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->stride; - u1scale = fxMesa->s1scale; /* wrong if tmu1_source == 0, possible? */ - v1scale = fxMesa->t1scale; - if (IND & SETUP_PTEX) - tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->size; - } - - if (IND & SETUP_RGBA) { - col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data; - col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride; - col_size = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size; - } - - if (IND & SETUP_SPEC) { - spec = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data; - spec_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride; - } - - if (IND & SETUP_FOGC) { - fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data; - fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride; - } - - if (start) { - proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride); - if (IND & SETUP_PSIZ) - psize = (GLfloat (*)[4])((GLubyte *)psize + start * psize_stride); - if (IND & SETUP_TMU0) - tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride); - if (IND & SETUP_TMU1) - tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride); - if (IND & SETUP_RGBA) - STRIDE_4F(col, start * col_stride); - if (IND & SETUP_SPEC) - STRIDE_4F(spec, start * spec_stride); - if (IND & SETUP_FOGC) - fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride); - } - - for (i=start; i < end; i++, v++) { - if (IND & SETUP_PSIZ) { - v->psize = psize[0][0]; - psize = (GLfloat (*)[4])((GLubyte *)psize + psize_stride); - } - - if (IND & SETUP_XYZW) { - if (mask[i] == 0) { - /* unclipped */ - VIEWPORT_X(v->x, proj[0][0]); - VIEWPORT_Y(v->y, proj[0][1]); - VIEWPORT_Z(v->ooz, proj[0][2]); - v->oow = proj[0][3]; - - if (IND & SETUP_SNAP) { -#if defined(USE_IEEE) - const float snapper = (3L << 18); - v->x += snapper; - v->x -= snapper; - v->y += snapper; - v->y -= snapper; -#else - v->x = ((int) (v->x * 16.0f)) * (1.0f / 16.0f); - v->y = ((int) (v->y * 16.0f)) * (1.0f / 16.0f); -#endif - } - } else { - /* clipped */ - v->oow = 1.0; - } - - proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride); - } - if (IND & SETUP_RGBA) { -#if FX_PACKEDCOLOR - UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[2], col[0][0]); - UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[1], col[0][1]); - UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[0], col[0][2]); - if (col_size == 4) { - UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[3], col[0][3]); - } else { - v->pargb[3] = 255; - } -#else /* !FX_PACKEDCOLOR */ - CNORM(v->r, col[0][0]); - CNORM(v->g, col[0][1]); - CNORM(v->b, col[0][2]); - if (col_size == 4) { - CNORM(v->a, col[0][3]); - } else { - v->a = 255.0f; - } -#endif /* !FX_PACKEDCOLOR */ - STRIDE_4F(col, col_stride); - } - if (IND & SETUP_SPEC) { -#if FX_PACKEDCOLOR - UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[2], spec[0][0]); - UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[1], spec[0][1]); - UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[0], spec[0][2]); -#else /* !FX_PACKEDCOLOR */ - CNORM(v->r1, spec[0][0]); - CNORM(v->g1, spec[0][1]); - CNORM(v->b1, spec[0][2]); -#endif /* !FX_PACKEDCOLOR */ - STRIDE_4F(spec, spec_stride); - } - if (IND & SETUP_FOGC) { - v->fog = CLAMP(fog[0][0], 0.0f, 1.0f); - fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride); - } - if (IND & SETUP_TMU0) { - GLfloat w = v->oow; - v->tmuvtx[0].sow = tc0[0][0] * u0scale * w; - v->tmuvtx[0].tow = tc0[0][1] * v0scale * w; - if (IND & SETUP_PTEX) { - v->tmuvtx[0].oow = w; - if (tc0_size == 4) - v->tmuvtx[0].oow *= tc0[0][3]; - } - tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride); - } - if (IND & SETUP_TMU1) { - GLfloat w = v->oow; - v->tmuvtx[1].sow = tc1[0][0] * u1scale * w; - v->tmuvtx[1].tow = tc1[0][1] * v1scale * w; - if (IND & SETUP_PTEX) { - v->tmuvtx[1].oow = w; - if (tc1_size == 4) - v->tmuvtx[1].oow *= tc1[0][3]; - } - tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride); - } - } -} - -#if (IND & SETUP_XYZW) && (IND & SETUP_RGBA) - -static GLboolean TAG(check_tex_sizes)( GLcontext *ctx ) -{ -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - - if (IND & SETUP_PTEX) - return GL_TRUE; - - if (IND & SETUP_TMU0) { - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (IND & SETUP_TMU1) { - if (VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0) - VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1]; - - if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4) - return GL_FALSE; - } - - if (VB->AttribPtr[_TNL_ATTRIB_TEX0] && - VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4) - return GL_FALSE; - } - - return GL_TRUE; -} - -static void TAG(interp)( GLcontext *ctx, - GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary ) -{ - fxMesaContext fxMesa = FX_CONTEXT( ctx ); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - const GLfloat *dstclip = VB->ClipPtr->data[edst]; - const GLfloat oow = (dstclip[3] == 0.0F) ? 1.0F : (1.0F / dstclip[3]); - const GLfloat *const s = ctx->Viewport._WindowMap.m; - GrVertex *fxverts = fxMesa->verts; - GrVertex *dst = (GrVertex *) (fxverts + edst); - const GrVertex *out = (const GrVertex *) (fxverts + eout); - const GrVertex *in = (const GrVertex *) (fxverts + ein); - const GLfloat wout = oow / out->oow; - const GLfloat win = oow / in->oow; - - VIEWPORT_X(dst->x, dstclip[0] * oow); - VIEWPORT_Y(dst->y, dstclip[1] * oow); - VIEWPORT_Z(dst->ooz, dstclip[2] * oow); - dst->oow = oow; - - if (IND & SETUP_SNAP) { -#if defined(USE_IEEE) - const float snapper = (3L << 18); - dst->x += snapper; - dst->x -= snapper; - dst->y += snapper; - dst->y -= snapper; -#else - dst->x = ((int) (dst->x * 16.0f)) * (1.0f / 16.0f); - dst->y = ((int) (dst->y * 16.0f)) * (1.0f / 16.0f); -#endif - } - - -#if FX_PACKEDCOLOR - INTERP_UB( t, dst->pargb[0], out->pargb[0], in->pargb[0] ); - INTERP_UB( t, dst->pargb[1], out->pargb[1], in->pargb[1] ); - INTERP_UB( t, dst->pargb[2], out->pargb[2], in->pargb[2] ); - INTERP_UB( t, dst->pargb[3], out->pargb[3], in->pargb[3] ); -#else /* !FX_PACKEDCOLOR */ - INTERP_F( t, dst->r, out->r, in->r ); - INTERP_F( t, dst->g, out->g, in->g ); - INTERP_F( t, dst->b, out->b, in->b ); - INTERP_F( t, dst->a, out->a, in->a ); -#endif /* !FX_PACKEDCOLOR */ - - if (IND & SETUP_SPEC) { -#if FX_PACKEDCOLOR - INTERP_UB( t, dst->pspec[0], out->pspec[0], in->pspec[0] ); - INTERP_UB( t, dst->pspec[1], out->pspec[1], in->pspec[1] ); - INTERP_UB( t, dst->pspec[2], out->pspec[2], in->pspec[2] ); -#else /* !FX_PACKEDCOLOR */ - INTERP_F( t, dst->r1, out->r1, in->r1 ); - INTERP_F( t, dst->g1, out->g1, in->g1 ); - INTERP_F( t, dst->b1, out->b1, in->b1 ); -#endif /* !FX_PACKEDCOLOR */ - } - - if (IND & SETUP_FOGC) { - INTERP_F( t, dst->fog, out->fog, in->fog ); - } - - if (IND & SETUP_TMU0) { - INTERP_F( t, - dst->tmuvtx[0].sow, - out->tmuvtx[0].sow * wout, - in->tmuvtx[0].sow * win ); - INTERP_F( t, - dst->tmuvtx[0].tow, - out->tmuvtx[0].tow * wout, - in->tmuvtx[0].tow * win ); - if (IND & SETUP_PTEX) { - INTERP_F( t, - dst->tmuvtx[0].oow, - out->tmuvtx[0].oow * wout, - in->tmuvtx[0].oow * win ); - } - } - - if (IND & SETUP_TMU1) { - INTERP_F( t, - dst->tmuvtx[1].sow, - out->tmuvtx[1].sow * wout, - in->tmuvtx[1].sow * win ); - INTERP_F( t, - dst->tmuvtx[1].tow, - out->tmuvtx[1].tow * wout, - in->tmuvtx[1].tow * win ); - if (IND & SETUP_PTEX) { - INTERP_F( t, - dst->tmuvtx[1].oow, - out->tmuvtx[1].oow * wout, - in->tmuvtx[1].oow * win ); - } - } -} -#endif - - -static void TAG(init)( void ) -{ - setup_tab[IND].emit = TAG(emit); - - if (IND & SETUP_SPEC) { - setup_tab[IND].copy_pv = copy_pv2; - } else { - setup_tab[IND].copy_pv = copy_pv; - } - -#if ((IND & SETUP_XYZW) && (IND & SETUP_RGBA)) - setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes); - setup_tab[IND].interp = TAG(interp); - - setup_tab[IND].vertex_format = 0; - if (IND & SETUP_PTEX) { - setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU0; - } - -#if (IND & SETUP_TMU1) - setup_tab[IND].vertex_format |= GR_STWHINT_ST_DIFF_TMU1; - if (IND & SETUP_PTEX) { - setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU1; - } -#endif - -#endif -} - - -#undef IND -#undef TAG -- cgit v1.2.3 From 40c6bb58be4bc2be3c4901fe8b945d2a12983af6 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 25 Feb 2010 16:10:09 -0500 Subject: Drop classic mesa svga driver --- Makefile | 2 - include/GL/svgamesa.h | 97 ------- src/mesa/drivers/svga/svgamesa.c | 516 ------------------------------------- src/mesa/drivers/svga/svgamesa15.c | 220 ---------------- src/mesa/drivers/svga/svgamesa15.h | 42 --- src/mesa/drivers/svga/svgamesa16.c | 218 ---------------- src/mesa/drivers/svga/svgamesa16.h | 43 ---- src/mesa/drivers/svga/svgamesa24.c | 242 ----------------- src/mesa/drivers/svga/svgamesa24.h | 43 ---- src/mesa/drivers/svga/svgamesa32.c | 223 ---------------- src/mesa/drivers/svga/svgamesa32.h | 43 ---- src/mesa/drivers/svga/svgamesa8.c | 196 -------------- src/mesa/drivers/svga/svgamesa8.h | 43 ---- src/mesa/drivers/svga/svgapix.h | 70 ----- 14 files changed, 1998 deletions(-) delete mode 100644 include/GL/svgamesa.h delete mode 100644 src/mesa/drivers/svga/svgamesa.c delete mode 100644 src/mesa/drivers/svga/svgamesa15.c delete mode 100644 src/mesa/drivers/svga/svgamesa15.h delete mode 100644 src/mesa/drivers/svga/svgamesa16.c delete mode 100644 src/mesa/drivers/svga/svgamesa16.h delete mode 100644 src/mesa/drivers/svga/svgamesa24.c delete mode 100644 src/mesa/drivers/svga/svgamesa24.h delete mode 100644 src/mesa/drivers/svga/svgamesa32.c delete mode 100644 src/mesa/drivers/svga/svgamesa32.h delete mode 100644 src/mesa/drivers/svga/svgamesa8.c delete mode 100644 src/mesa/drivers/svga/svgamesa8.h delete mode 100644 src/mesa/drivers/svga/svgapix.h (limited to 'Makefile') diff --git a/Makefile b/Makefile index f2ec3bf20f..0e70ef5d97 100644 --- a/Makefile +++ b/Makefile @@ -221,7 +221,6 @@ MAIN_FILES = \ $(DIRECTORY)/include/GL/mesa_wgl.h \ $(DIRECTORY)/include/GL/mglmesa.h \ $(DIRECTORY)/include/GL/osmesa.h \ - $(DIRECTORY)/include/GL/svgamesa.h \ $(DIRECTORY)/include/GL/vms_x_fix.h \ $(DIRECTORY)/include/GL/wglext.h \ $(DIRECTORY)/include/GL/wmesa.h \ @@ -274,7 +273,6 @@ MAIN_FILES = \ $(DIRECTORY)/src/mesa/drivers/osmesa/descrip.mms \ $(DIRECTORY)/src/mesa/drivers/osmesa/osmesa.def \ $(DIRECTORY)/src/mesa/drivers/osmesa/*.[ch] \ - $(DIRECTORY)/src/mesa/drivers/svga/*.[ch] \ $(DIRECTORY)/src/mesa/drivers/windows/*/*.[ch] \ $(DIRECTORY)/src/mesa/drivers/windows/*/*.def \ $(DIRECTORY)/src/mesa/drivers/x11/Makefile \ diff --git a/include/GL/svgamesa.h b/include/GL/svgamesa.h deleted file mode 100644 index 67c0e4c5c6..0000000000 --- a/include/GL/svgamesa.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.0 - * Copyright (C) 1995-2001 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * SVGA/Mesa interface for Linux. - */ - - -/* - * Intro to using the VGA/Mesa interface - * - * 1. #include the file - * 2. Call vga_init() to initialize the SVGA library. - * 3. Call vga_setmode() to specify the screen size and color depth. - * 4. Call SVGAMesaCreateContext() to setup a Mesa context. If using 8-bit - * color Mesa assumes color index mode, if using 16-bit or deeper color - * Mesa assumes RGB mode. - * 5. Call SVGAMesaMakeCurrent() to activate the Mesa context. - * 6. You can now use the Mesa API functions. - * 7. Before exiting, call SVGAMesaDestroyContext() then vga_setmode(TEXT) - * to restore the original text screen. - * - * Notes - * 1. You must run your executable as root (or use the set UID-bit) because - * the SVGA library requires it. - * 2. The SVGA driver is not fully implemented yet. See svgamesa.c for what - * has to be done yet. - */ - - -#ifndef SVGAMESA_H -#define SVGAMESA_H - - -#define SVGAMESA_MAJOR_VERSION 4 -#define SVGAMESA_MINOR_VERSION 0 - - -#ifdef __cplusplus -extern "C" { -#endif - - -#include "GL/gl.h" - - - -/* - * This is the SVGAMesa context 'handle': - */ -typedef struct svgamesa_context *SVGAMesaContext; - - - -/* - * doubleBuffer flag new in version 2.4 - */ -extern int SVGAMesaInit( int GraphMode ); - -extern int SVGAMesaClose( void ); - -extern SVGAMesaContext SVGAMesaCreateContext( GLboolean doubleBuffer ); - -extern void SVGAMesaDestroyContext( SVGAMesaContext ctx ); - -extern void SVGAMesaMakeCurrent( SVGAMesaContext ctx ); - -extern void SVGAMesaSwapBuffers( void ); - -extern void SVGAMesaSetCI(int ndx, GLubyte red, GLubyte green, GLubyte blue); - -extern SVGAMesaContext SVGAMesaGetCurrentContext( void ); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/src/mesa/drivers/svga/svgamesa.c b/src/mesa/drivers/svga/svgamesa.c deleted file mode 100644 index 5afa8e188b..0000000000 --- a/src/mesa/drivers/svga/svgamesa.c +++ /dev/null @@ -1,516 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.0 - * Copyright (C) 1995-2002 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * SVGA driver for Mesa. - * Original author: Brian Paul - * Additional authors: Slawomir Szczyrba (Mesa 3.2) - */ - - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#ifdef SVGA - -#include -#include -#include -#include -#include "GL/svgamesa.h" -#include "main/buffers.h" -#include "main/context.h" -#include "main/extensions.h" -#include "main/imports.h" -#include "main/matrix.h" -#include "main/mtypes.h" -#include "swrast/swrast.h" -#include "svgapix.h" -#include "svgamesa8.h" -#include "svgamesa15.h" -#include "svgamesa16.h" -#include "svgamesa24.h" -#include "svgamesa32.h" - -struct svga_buffer SVGABuffer; -vga_modeinfo * SVGAInfo; -SVGAMesaContext SVGAMesa; /* the current context */ - -#ifdef SVGA_DEBUG - -#include -#include - -FILE * logfile; -char cbuf[1024]={0}; - -void SVGAlog(char * what) -{ - logfile=fopen("svgamesa.log","a"); - if (!logfile) return; - fprintf(logfile,"%s\n",what); - fclose(logfile); -} -#endif - -/**********************************************************************/ -/***** Init stuff... *****/ -/**********************************************************************/ - -int SVGAMesaInit( int GraphMode ) -{ - vga_init(); - if (!vga_hasmode(GraphMode)) - { - fprintf(stderr,"GraphMode %d unavailable...",GraphMode); -#ifdef SVGA_DEBUG - SVGAlog("SVGAMesaInit: invalid GraphMode (doesn't exist)"); -#endif - return(1); - } - SVGAInfo=vga_getmodeinfo(GraphMode); - if (SVGAInfo->flags & IS_MODEX) - { - fprintf(stderr,"ModeX not implemented..."); -#ifdef SVGA_DEBUG - SVGAlog("SVGAMesaInit: invalid GraphMode (ModeX)"); -#endif - return(2); - } - if (!SVGAInfo->bytesperpixel) - { - fprintf(stderr,"1 / 4 bit color not implemented..."); -#ifdef SVGA_DEBUG - SVGAlog("SVGAMesaInit: invalid GraphMode (1 or 4 bit)"); -#endif - return(3); - } - switch (SVGAInfo->colors) { - case 256: SVGABuffer.Depth = 8; break; - case 32768: SVGABuffer.Depth = 15; break; - case 65536: SVGABuffer.Depth = 16; break; - default: SVGABuffer.Depth = SVGAInfo->bytesperpixel<<3; break; - } - SVGABuffer.BufferSize=SVGAInfo->linewidth*SVGAInfo->height; -#ifdef SVGA_DEBUG - sprintf(cbuf,"SVGAMesaInit: double buffer info.\n" \ - " depth : %d\n" \ - " mode : %d\n" \ - " width : %d\n" \ - " height : %d\n" \ - " bufsize: %d\n", \ - SVGABuffer.Depth,GraphMode,SVGAInfo->linewidth, \ - SVGAInfo->height,SVGABuffer.BufferSize); - SVGAlog(cbuf); -#endif - SVGABuffer.FrontBuffer=(void*)malloc(SVGABuffer.BufferSize + 4); - if (!SVGABuffer.FrontBuffer) { - { - fprintf(stderr,"Not enough RAM for FRONT_LEFT_BUFFER..."); -#ifdef SVGA_DEBUG - SVGAlog("SVGAMesaInit: Not enough RAM (front buffer)"); -#endif - return(4); - } - } -#ifdef SVGA_DEBUG - sprintf(cbuf,"SVGAMesaInit: FrontBuffer - %p",SVGABuffer.FrontBuffer); - SVGAlog(cbuf); -#endif - SVGABuffer.BackBuffer=(void*)malloc(SVGABuffer.BufferSize + 4); - if (!SVGABuffer.BackBuffer) { - { - free(SVGABuffer.FrontBuffer); - fprintf(stderr,"Not enough RAM for BACK_LEFT_BUFFER..."); -#ifdef SVGA_DEBUG - SVGAlog("SVGAMesaInit: Not enough RAM (back buffer)"); -#endif - return(5); - } - } -#ifdef SVGA_DEBUG - sprintf(cbuf,"SVGAMesaInit: BackBuffer - %p",SVGABuffer.BackBuffer); - SVGAlog(cbuf); -#endif - - vga_setmode(GraphMode); - SVGABuffer.VideoRam=vga_getgraphmem(); -#ifdef SVGA_DEBUG - sprintf(cbuf,"SVGAMesaInit: VRAM - %p",SVGABuffer.VideoRam); - SVGAlog(cbuf); - sprintf(cbuf,"SVGAMesaInit: done. (Mode %d)",GraphMode); - SVGAlog(cbuf); -#endif - - SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer; - SVGABuffer.ReadBuffer = SVGABuffer.BackBuffer; - - return 0; -} - -int SVGAMesaClose( void ) -{ - vga_setmode(TEXT); - free(SVGABuffer.FrontBuffer); - free(SVGABuffer.BackBuffer); - return 0; -} - -void SVGAMesaSetCI(int ndx, GLubyte red, GLubyte green, GLubyte blue) -{ - if (ndx<256) - vga_setpalette(ndx, red>>2, green>>2, blue>>2); -} - -/**********************************************************************/ -/***** Miscellaneous functions *****/ -/**********************************************************************/ - -static void copy_buffer( const GLubyte * buffer) { - int size = SVGABuffer.BufferSize, page = 0; - -#ifdef SVGA_DEBUG - sprintf(cbuf,"copy_buffer: copy %p to %p",buffer,SVGABuffer.VideoRam); - SVGAlog(cbuf); -#endif - - while(size>0) { - vga_setpage(page++); - if (size>>16) { - memcpy(SVGABuffer.VideoRam,buffer,0x10000); - buffer+=0x10000; - }else{ - memcpy(SVGABuffer.VideoRam,buffer,size & 0xffff); - } - size-=0xffff; - } -} - -static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) -{ - *width = SVGAMesa->width = vga_getxdim(); - *height = SVGAMesa->height = vga_getydim(); -} - -/** - * We only implement this function as a mechanism to check if the - * framebuffer size has changed (and update corresponding state). - */ -static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ - GLuint newWidth, newHeight; - GLframebuffer *buffer = ctx->WinSysDrawBuffer; - get_buffer_size( buffer, &newWidth, &newHeight ); - if (buffer->Width != newWidth || buffer->Height != newHeight) { - _mesa_resize_framebuffer(ctx, buffer, newWidth, newHeight ); - } -} - -static void set_buffer( GLcontext *ctx, GLframebuffer *colorBuffer, - GLenum buffer ) -{ - /* We can ignore colorBuffer since we don't support a MakeCurrentRead() - * function. - */ - (void) colorBuffer; - - if (buffer == GL_FRONT_LEFT) { - SVGABuffer.ReadBuffer = SVGABuffer.FrontBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer; -#if 0 - void * tmpptr; - /* vga_waitretrace(); */ - copy_buffer(SVGABuffer.FrontBuffer); - tmpptr=SVGABuffer.BackBuffer; - SVGABuffer.BackBuffer=SVGABuffer.FrontBuffer; - SVGABuffer.FrontBuffer=tmpptr; -#endif - } - else if (buffer == GL_BACK_LEFT) { - SVGABuffer.ReadBuffer = SVGABuffer.BackBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer; -#if 0 - /* vga_waitretrace(); */ - copy_buffer(SVGABuffer.BackBuffer); -#endif - } -} - -/**********************************************************************/ -/***** *****/ -/**********************************************************************/ - -static void svgamesa_update_state( GLcontext *ctx, GLuint new_state ) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx ); - - /* Initialize all the pointers in the DD struct. Do this whenever */ - /* a new context is made current or we change buffers via set_buffer! */ - - ctx->Driver.UpdateState = svgamesa_update_state; - - ctx->Driver.GetBufferSize = get_buffer_size; - ctx->Driver.Viewport = viewport; - - /* Fill in the swrast driver interface: - */ - swdd->SetBuffer = set_buffer; - - switch (SVGABuffer.Depth) { - case 8: ctx->Driver.ClearIndex = __clear_index8; - ctx->Driver.Clear = __clear8; - - swdd->ReadCI32Span = __read_ci32_span8; - swdd->ReadCI32Pixels = __read_ci32_pixels8; - swdd->WriteCI8Span = __write_ci8_span8; - swdd->WriteCI32Span = __write_ci32_span8; - swdd->WriteCI32Pixels = __write_ci32_pixels8; - swdd->WriteMonoCISpan = __write_mono_ci_span8; - swdd->WriteMonoCIPixels = __write_mono_ci_pixels8; -#ifdef SVGA_DEBUG - SVGAlog("SVGAUpdateState: 8 bit mode."); -#endif - - break; - case 15: ctx->Driver.ClearColor = __clear_color15; - ctx->Driver.Clear = __clear15; - - swdd->ReadRGBASpan = __read_rgba_span15; - swdd->ReadRGBAPixels = __read_rgba_pixels15; - swdd->WriteRGBASpan = __write_rgba_span15; - swdd->WriteRGBAPixels = __write_rgba_pixels15; - swdd->WriteMonoRGBASpan = __write_mono_rgba_span15; - swdd->WriteMonoRGBAPixels = __write_mono_rgba_pixels15; -#ifdef SVGA_DEBUG - SVGAlog("SVGAUpdateState: 15 bit mode."); -#endif - break; - case 16: ctx->Driver.ClearColor = __clear_color16; - ctx->Driver.Clear = __clear16; - - swdd->ReadRGBASpan = __read_rgba_span16; - swdd->ReadRGBAPixels = __read_rgba_pixels16; - swdd->WriteRGBASpan = __write_rgba_span16; - swdd->WriteRGBAPixels = __write_rgba_pixels16; - swdd->WriteMonoRGBASpan = __write_mono_rgba_span16; - swdd->WriteMonoRGBAPixels = __write_mono_rgba_pixels16; - break; -#ifdef SVGA_DEBUG - SVGAlog("SVGAUpdateState: 16 bit mode."); -#endif - case 24: ctx->Driver.ClearColor = __clear_color24; - ctx->Driver.Clear = __clear24; - - swdd->ReadRGBASpan = __read_rgba_span24; - swdd->ReadRGBAPixels = __read_rgba_pixels24; - swdd->WriteRGBASpan = __write_rgba_span24; - swdd->WriteRGBAPixels = __write_rgba_pixels24; - swdd->WriteMonoRGBASpan = __write_mono_rgba_span24; - swdd->WriteMonoRGBAPixels = __write_mono_rgba_pixels24; - break; -#ifdef SVGA_DEBUG - SVGAlog("SVGAUpdateState: 32 bit mode."); -#endif - case 32: ctx->Driver.ClearColor = __clear_color32; - ctx->Driver.Clear = __clear32; - - swdd->ReadRGBASpan = __read_rgba_span32; - swdd->ReadRGBAPixels = __read_rgba_pixels32; - swdd->WriteRGBASpan = __write_rgba_span32; - swdd->WriteRGBAPixels = __write_rgba_pixels32; - swdd->WriteMonoRGBASpan = __write_mono_rgba_span32; - swdd->WriteMonoRGBAPixels = __write_mono_rgba_pixels32; - } -} - -/* - * Create a new VGA/Mesa context and return a handle to it. - */ -SVGAMesaContext SVGAMesaCreateContext( GLboolean doubleBuffer ) -{ - SVGAMesaContext ctx; -#ifndef DEV - GLboolean rgb_flag; - GLfloat redscale, greenscale, bluescale, alphascale; - GLint index_bits; - GLint redbits, greenbits, bluebits, alphabits; - - /* determine if we're in RGB or color index mode */ - if ((SVGABuffer.Depth==32) || (SVGABuffer.Depth==24)) { - rgb_flag = GL_TRUE; - redscale = greenscale = bluescale = alphascale = 255.0; - redbits = greenbits = bluebits = 8; - alphabits = 0; - index_bits = 0; - } - else if (SVGABuffer.Depth==8) { - rgb_flag = GL_FALSE; - redscale = greenscale = bluescale = alphascale = 0.0; - redbits = greenbits = bluebits = alphabits = 0; - index_bits = 8; - } - else if (SVGABuffer.Depth==15) { - rgb_flag = GL_TRUE; - redscale = greenscale = bluescale = alphascale = 31.0; - redbits = greenbits = bluebits = 5; - alphabits = 0; - index_bits = 0; - } - else if (SVGABuffer.Depth==16) { - rgb_flag = GL_TRUE; - redscale = bluescale = alphascale = 31.0; - greenscale = 63.0; - redbits = bluebits = 5; - greenbits = 6; - alphabits = 0; - index_bits = 0; - } - - ctx = (SVGAMesaContext) calloc( 1, sizeof(struct svgamesa_context) ); - if (!ctx) { - return NULL; - } - - ctx->gl_vis = _mesa_create_visual( rgb_flag, - doubleBuffer, - GL_FALSE, /* stereo */ - redbits, greenbits, - bluebits, alphabits, - index_bits, - 16, /* depth_size */ - 8, /* stencil_size */ - 16, 16, 16, 16, /* accum_size */ - 1 /* samples */ - ); - - ctx->gl_ctx = _mesa_create_context( ctx->gl_vis, - NULL, /* share list context */ - (void *) ctx, GL_FALSE ); - - _mesa_enable_sw_extensions(ctx->gl_ctx); - _mesa_enable_1_3_extensions(ctx->gl_ctx); - - _mesa_init_driver_functions(&ctx->Driver); - - ctx->gl_buffer = _mesa_create_framebuffer( ctx->gl_vis, - ctx->gl_vis->depthBits > 0, - ctx->gl_vis->stencilBits > 0, - ctx->gl_vis->accumRedBits > 0, - ctx->gl_vis->alphaBits > 0 ); - - ctx->width = ctx->height = 0; /* temporary until first "make-current" */ -#endif - return ctx; -} - -/* - * Destroy the given VGA/Mesa context. - */ -void SVGAMesaDestroyContext( SVGAMesaContext ctx ) -{ -#ifndef DEV - if (ctx) { - _mesa_destroy_visual( ctx->gl_vis ); - _mesa_destroy_context( ctx->gl_ctx ); - free( ctx ); - if (ctx==SVGAMesa) { - SVGAMesa = NULL; - } - } -#endif -} - -/* - * Make the specified VGA/Mesa context the current one. - */ -void SVGAMesaMakeCurrent( SVGAMesaContext ctx ) -{ -#ifndef DEV - SVGAMesa = ctx; - svgamesa_update_state( ctx->gl_ctx, ~0 ); - _mesa_make_current( ctx->gl_ctx, ctx->gl_buffer ); - - if (ctx->width==0 || ctx->height==0) { - ctx->width = vga_getxdim(); - ctx->height = vga_getydim(); - } -#endif -} - -/* - * Return a handle to the current VGA/Mesa context. - */ -SVGAMesaContext SVGAMesaGetCurrentContext( void ) -{ - return SVGAMesa; -} - -/* - * Swap front/back buffers for current context if double buffered. - */ -void SVGAMesaSwapBuffers( void ) -{ -#if 000 - void * tmpptr; -#endif - - /* vga_waitretrace(); */ - copy_buffer(SVGABuffer.BackBuffer); - -#ifndef DEV - _mesa_notifySwapBuffers( SVGAMesa->gl_ctx ); - if (SVGAMesa->gl_vis->doubleBufferMode) -#endif /* DEV */ - { -#ifdef SVGA_DEBUG - sprintf(cbuf,"SVGAMesaSwapBuffers : Swapping..."); - SVGAlog(cbuf); -#endif /* SVGA_DEBUG */ -#if 000 - tmpptr=SVGABuffer.BackBuffer; - SVGABuffer.BackBuffer=SVGABuffer.FrontBuffer; - SVGABuffer.FrontBuffer=tmpptr; -#endif -#ifdef SVGA_DEBUG - sprintf(cbuf,"SVGAMesaSwapBuffers : WriteBuffer : %p\n" - " Readbuffer : %p", \ - SVGABuffer.BackBuffer, SVGABuffer.FrontBuffer ); - SVGAlog(cbuf); -#endif /* SVGA_DEBUG */ - } -} - -#else /*SVGA*/ - -/* - * Need this to provide at least one external definition when SVGA is - * not defined on the compiler command line. - */ -extern int gl_svga_dummy_function(void); -int gl_svga_dummy_function(void) -{ - return 0; -} - -#endif /*SVGA*/ - diff --git a/src/mesa/drivers/svga/svgamesa15.c b/src/mesa/drivers/svga/svgamesa15.c deleted file mode 100644 index 934aaa33fb..0000000000 --- a/src/mesa/drivers/svga/svgamesa15.c +++ /dev/null @@ -1,220 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.0 - * Copyright (C) 1995-2002 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * SVGA driver for Mesa. - * Original author: Brian Paul - * Additional authors: Slawomir Szczyrba (Mesa 3.2) - */ - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#ifdef SVGA - -#include "svgapix.h" -#include "svgamesa15.h" -#include "swrast/swrast.h" - - -static void __svga_drawpixel15(int x, int y, unsigned long c) -{ - unsigned long offset; - GLshort *shortBuffer=(void *)SVGABuffer.DrawBuffer; - y = SVGAInfo->height-y-1; - offset = y * SVGAInfo->width + x; - shortBuffer[offset]=c; -} - -static unsigned long __svga_getpixel15(int x, int y) -{ - unsigned long offset; - GLshort *shortBuffer=(void *)SVGABuffer.ReadBuffer; - y = SVGAInfo->height-y-1; - offset = y * SVGAInfo->width + x; - return shortBuffer[offset]; -} - -void __clear_color15( GLcontext *ctx, const GLfloat color[4] ) -{ - GLubyte col[3]; - CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]); - SVGAMesa->clear_hicolor=(col[0]>>3)<<10 | (col[1]>>3)<<5 | (col[2]>>3); -/* SVGAMesa->clear_hicolor=(red)<<10 | (green)<<5 | (blue);*/ -} - -void __clear15( GLcontext *ctx, GLbitfield mask ) -{ - int i, j; - int x = ctx->DrawBuffer->_Xmin; - int y = ctx->DrawBuffer->_Ymin; - int width = ctx->DrawBuffer->_Xmax - x; - int height = ctx->DrawBuffer->_Ymax - y; - GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->height) - - if (mask & DD_FRONT_LEFT_BIT) { - GLshort *shortBuffer=(void *)SVGABuffer.FrontBuffer; - if (all) { - for (i=0;iclear_hicolor; - } - else { - GLubyte *tmp = SVGABuffer.DrawBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer; - for (i=x;iclear_hicolor); - SVGABuffer.DrawBuffer = tmp; - } - mask &= ~DD_FRONT_LEFT_BIT; - } - if (mask & DD_BACK_LEFT_BIT) { - GLshort *shortBuffer=(void *)SVGABuffer.BackBuffer; - if (all) { - for (i=0;iclear_hicolor; - } - else { - GLubyte *tmp = SVGABuffer.DrawBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer; - for (i=x;iclear_hicolor); - SVGABuffer.DrawBuffer = tmp; - } - mask &= ~DD_BACK_LEFT_BIT; - } - - if (mask) - _swrast_Clear( ctx, mask ); -} - -void __write_rgba_span15( const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLubyte rgba[][4], const GLubyte mask[] ) -{ - int i; - if (mask) { - /* draw some pixels */ - for (i=0; i>3)<<10 | \ - (rgba[i][GCOMP]>>3)<<5 | \ - (rgba[i][BCOMP]>>3)); - } - } - } - else { - /* draw all pixels */ - for (i=0; i>3)<<10 | \ - (rgba[i][GCOMP]>>3)<<5 | \ - (rgba[i][BCOMP]>>3)); - } - } -} - -void __write_mono_rgba_span15( const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLchan color[4], const GLubyte mask[]) -{ - GLushort hicolor = (color[RCOMP] >> 3) << 10 | - (color[GCOMP] >> 3) << 5 | - (color[BCOMP] >> 3); - int i; - for (i=0; i>10)<<3) & 0xff; - rgba[i][GCOMP] = ((pix>> 5)<<3) & 0xff; - rgba[i][BCOMP] = ((pix )<<3) & 0xff; - } -} - -void __write_rgba_pixels15( const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLubyte rgba[][4], const GLubyte mask[] ) -{ - int i; - for (i=0; i>3)<<10 | \ - (rgba[i][GCOMP]>>3)<<5 | \ - (rgba[i][BCOMP]>>3)); - } - } -} - - -void __write_mono_rgba_pixels15( const GLcontext *ctx, - GLuint n, - const GLint x[], const GLint y[], - const GLchan color[4], const GLubyte mask[] ) -{ - GLushort hicolor = (color[RCOMP] >> 3) << 10 | - (color[GCOMP] >> 3) << 5 | - (color[BCOMP] >> 3); - int i; - /* use current rgb color */ - for (i=0; i>10)<<3) & 0xff; - rgba[i][GCOMP] = ((pix>> 5)<<3) & 0xff; - rgba[i][BCOMP] = ((pix )<<3) & 0xff; - } -} - -#else - - -/* silence compiler warning */ -extern void _mesa_svga15_dummy_function(void); -void _mesa_svga15_dummy_function(void) -{ -} - - -#endif diff --git a/src/mesa/drivers/svga/svgamesa15.h b/src/mesa/drivers/svga/svgamesa15.h deleted file mode 100644 index d453fb8d35..0000000000 --- a/src/mesa/drivers/svga/svgamesa15.h +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.0 - * Copyright (C) 1995-2002 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * SVGA driver for Mesa. - * Original author: Brian Paul - * Additional authors: Slawomir Szczyrba (Mesa 3.2) - */ - - -#ifndef SVGA_MESA_15_H -#define SVGA_MESA_15_H - -extern void __clear_color15( GLcontext *ctx, const GLfloat color[4] ); -extern void __clear15( GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height ); -extern void __write_rgba_span15( const GLcontext *ctx, GLuint n, GLint x, GLint y, const GLubyte rgba[][4], const GLubyte mask[] ); -extern void __write_mono_rgba_span15( const GLcontext *ctx, GLuint n, GLint x, GLint y, const GLchan color[4], const GLubyte mask[]); -extern void __read_rgba_span15( const GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte rgba[][4] ); -extern void __write_rgba_pixels15( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte rgba[][4], const GLubyte mask[] ); -extern void __write_mono_rgba_pixels15( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLchan color[4], const GLubyte mask[] ); -extern void __read_rgba_pixels15( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLubyte rgba[][4], const GLubyte mask[] ); - -#endif /* SVGA_MESA_15_H */ diff --git a/src/mesa/drivers/svga/svgamesa16.c b/src/mesa/drivers/svga/svgamesa16.c deleted file mode 100644 index 9fc8c786e8..0000000000 --- a/src/mesa/drivers/svga/svgamesa16.c +++ /dev/null @@ -1,218 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.0 - * Copyright (C) 1995-2002 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * SVGA driver for Mesa. - * Original author: Brian Paul - * Additional authors: Slawomir Szczyrba (Mesa 3.2) - */ - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#ifdef SVGA - -#include "svgapix.h" -#include "svgamesa16.h" -#include "swrast/swrast.h" - - -static void __svga_drawpixel16(int x, int y, unsigned long c) -{ - unsigned long offset; - GLshort *shortBuffer=(void *)SVGABuffer.DrawBuffer; - y = SVGAInfo->height-y-1; - offset = y * SVGAInfo->width + x; - shortBuffer[offset]=c; -} - -static unsigned long __svga_getpixel16(int x, int y) -{ - unsigned long offset; - - GLshort *shortBuffer=(void *)SVGABuffer.ReadBuffer; - y = SVGAInfo->height-y-1; - offset = y * SVGAInfo->width + x; - return shortBuffer[offset]; -} - -void __clear_color16( GLcontext *ctx, const GLfloat color[4] ) -{ - GLubyte col[3]; - CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]); - SVGAMesa->clear_hicolor = (col[0] >> 3) << 11 | - (col[1] >> 2) << 5 | - (col[2] >> 3); -/* SVGAMesa->clear_hicolor=(red)<<11 | (green)<<5 | (blue); */ -} - -void __clear16( GLcontext *ctx, GLbitfield mask ) -{ - int i,j; - int x = ctx->DrawBuffer->_Xmin; - int y = ctx->DrawBuffer->_Ymin; - int width = ctx->DrawBuffer->_Xmax - x; - int height = ctx->DrawBuffer->_Ymax - y; - GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->height) - - if (mask & DD_FRONT_LEFT_BIT) { - if (all) { - GLshort *shortBuffer=(void *)SVGABuffer.FrontBuffer; - for (i=0;iclear_hicolor; - } - else { - GLubyte *tmp = SVGABuffer.DrawBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer; - for (i=x;iclear_hicolor); - SVGABuffer.DrawBuffer = tmp; - } - mask &= ~DD_FRONT_LEFT_BIT; - } - if (mask & DD_BACK_LEFT_BIT) { - if (all) { - GLshort *shortBuffer=(void *)SVGABuffer.BackBuffer; - for (i=0;iclear_hicolor; - } - else { - GLubyte *tmp = SVGABuffer.DrawBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer; - for (i=x;iclear_hicolor); - SVGABuffer.DrawBuffer = tmp; - } - mask &= ~DD_BACK_LEFT_BIT; - } - - if (mask) - _swrast_Clear( ctx, mask ); -} - -void __write_rgba_span16( const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLubyte rgba[][4], const GLubyte mask[] ) -{ - int i; - if (mask) { - /* draw some pixels */ - for (i=0; i>3)<<11 | \ - (rgba[i][GCOMP]>>2)<<5 | \ - (rgba[i][BCOMP]>>3)); - } - } - } - else { - /* draw all pixels */ - for (i=0; i>3)<<11 | \ - (rgba[i][GCOMP]>>2)<<5 | \ - (rgba[i][BCOMP]>>3)); - } - } -} - -void __write_mono_rgba_span16( const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLchan color[4], const GLubyte mask[]) -{ - GLushort hicolor=(color[RCOMP]>>3)<<11 | (color[GCOMP]>>2)<<5 | (color[BCOMP]>>3); - int i; - for (i=0; i>11)<<3) & 0xff; - rgba[i][GCOMP] = ((pix>> 5)<<2) & 0xff; - rgba[i][BCOMP] = ((pix )<<3) & 0xff; - } -} - -void __write_rgba_pixels16( const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLubyte rgba[][4], const GLubyte mask[] ) -{ - int i; - for (i=0; i>3)<<11 | \ - (rgba[i][GCOMP]>>2)<<5 | \ - (rgba[i][BCOMP]>>3)); - } - } -} - - -void __write_mono_rgba_pixels16( const GLcontext *ctx, - GLuint n, - const GLint x[], const GLint y[], - const GLchan color[4], const GLubyte mask[] ) -{ - GLushort hicolor=(color[RCOMP]>>3)<<11 | (color[GCOMP]>>2)<<5 | (color[BCOMP]>>3); - int i; - for (i=0; i>11)<<3) & 0xff; - rgba[i][GCOMP] = ((pix>> 5)<<2) & 0xff; - rgba[i][BCOMP] = ((pix )<<3) & 0xff; - } -} - -#else - - -/* silence compiler warning */ -extern void _mesa_svga16_dummy_function(void); -void _mesa_svga16_dummy_function(void) -{ -} - - -#endif diff --git a/src/mesa/drivers/svga/svgamesa16.h b/src/mesa/drivers/svga/svgamesa16.h deleted file mode 100644 index b80cd3dd7e..0000000000 --- a/src/mesa/drivers/svga/svgamesa16.h +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.0 - * Copyright (C) 1995-2002 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * SVGA driver for Mesa. - * Original author: Brian Paul - * Additional authors: Slawomir Szczyrba (Mesa 3.2) - */ - - -#ifndef SVGA_MESA_16_H -#define SVGA_MESA_16_H - -extern void __clear_color16( GLcontext *ctx, const GLfloat color[4] ); -extern void __clear16( GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height ); -extern void __write_rgba_span16( const GLcontext *ctx, GLuint n, GLint x, GLint y, const GLubyte rgba[][4], const GLubyte mask[] ); -extern void __write_mono_rgba_span16( const GLcontext *ctx, GLuint n, GLint x, GLint y, const GLchan color[4], const GLubyte mask[]); -extern void __read_rgba_span16( const GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte rgba[][4] ); -extern void __write_rgba_pixels16( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte rgba[][4], const GLubyte mask[] ); -extern void __write_mono_rgba_pixels16( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLchan color[4], const GLubyte mask[] ); -extern void __read_rgba_pixels16( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLubyte rgba[][4], const GLubyte mask[] ); - -#endif /* SVGA_MESA_16_H */ - diff --git a/src/mesa/drivers/svga/svgamesa24.c b/src/mesa/drivers/svga/svgamesa24.c deleted file mode 100644 index f2ec9c0364..0000000000 --- a/src/mesa/drivers/svga/svgamesa24.c +++ /dev/null @@ -1,242 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.0 - * Copyright (C) 1995-2002 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * SVGA driver for Mesa. - * Original author: Brian Paul - * Additional authors: Slawomir Szczyrba (Mesa 3.2) - */ - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#ifdef SVGA - -#include "svgapix.h" -#include "svgamesa24.h" -#include "swrast/swrast.h" - - -#if 0 -/* this doesn't compile with GCC on RedHat 6.1 */ -static INLINE int RGB2BGR24(int c) -{ - asm("rorw $8, %0\n" - "rorl $16, %0\n" - "rorw $8, %0\n" - "shrl $8, %0\n" - : "=q"(c):"0"(c)); - return c; -} -#else -static unsigned long RGB2BGR24(unsigned long color) -{ - return (color & 0xff00)|(color>>16)|((color & 0xff)<<16); -} -#endif - -static void __svga_drawpixel24(int x, int y, GLubyte r, GLubyte g, GLubyte b) -{ - unsigned long offset; - - _RGB *rgbBuffer=(void *)SVGABuffer.DrawBuffer; - y = SVGAInfo->height-y-1; - offset = y * SVGAInfo->width + x; - - rgbBuffer[offset].r=r; - rgbBuffer[offset].g=g; - rgbBuffer[offset].b=b; -} - -static unsigned long __svga_getpixel24(int x, int y) -{ - unsigned long offset; - - _RGB *rgbBuffer=(void *)SVGABuffer.ReadBuffer; - y = SVGAInfo->height-y-1; - offset = y * SVGAInfo->width + x; - return rgbBuffer[offset].r<<16 | rgbBuffer[offset].g<<8 | rgbBuffer[offset].b; -} - -void __clear_color24( GLcontext *ctx, const GLfloat color[4] ) -{ - GLubyte col[3]; - CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]); - SVGAMesa->clear_red = col[0]; - SVGAMesa->clear_green = col[1]; - SVGAMesa->clear_blue = col[2]; -/* SVGAMesa->clear_truecolor = red<<16 | green<<8 | blue; */ -} - -void __clear24( GLcontext *ctx, GLbitfield mask ) -{ - int i,j; - int x = ctx->DrawBuffer->_Xmin; - int y = ctx->DrawBuffer->_Ymin; - int width = ctx->DrawBuffer->_Xmax - x; - int height = ctx->DrawBuffer->_Ymax - y; - GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->height) - - if (mask & DD_FRONT_LEFT_BIT) { - if (all) { - _RGB *rgbBuffer=(void *)SVGABuffer.FrontBuffer; - for (i=0;iclear_red; - rgbBuffer[i].g=SVGAMesa->clear_green; - rgbBuffer[i].b=SVGAMesa->clear_blue; - } - } - else { - GLubyte *tmp = SVGABuffer.DrawBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer; - for (i=x;iclear_red, - SVGAMesa->clear_green, - SVGAMesa->clear_blue); - SVGABuffer.DrawBuffer = tmp; - } - mask &= ~DD_FRONT_LEFT_BIT; - } - if (mask & DD_BACK_LEFT_BIT) { - if (all) { - _RGB *rgbBuffer=(void *)SVGABuffer.BackBuffer; - for (i=0;iclear_red; - rgbBuffer[i].g=SVGAMesa->clear_green; - rgbBuffer[i].b=SVGAMesa->clear_blue; - } - } - else { - GLubyte *tmp = SVGABuffer.DrawBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer; - for (i=x;iclear_red, - SVGAMesa->clear_green, - SVGAMesa->clear_blue); - SVGABuffer.DrawBuffer = tmp; - } - mask &= ~DD_BACK_LEFT_BIT; - } - - if (mask) - _swrast_Clear( ctx, mask ); -} - -void __write_rgba_span24( const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLubyte rgba[][4], const GLubyte mask[] ) -{ - int i; - if (mask) { - /* draw some pixels */ - for (i=0; i (Mesa 3.2) - */ - - -#ifndef SVGA_MESA_24_H -#define SVGA_MESA_24_H - -extern void __clear_color24( GLcontext *ctx, const GLfloat color[4] ); -extern void __clear24( GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height ); -extern void __write_rgba_span24( const GLcontext *ctx, GLuint n, GLint x, GLint y, const GLubyte rgba[][4], const GLubyte mask[] ); -extern void __write_mono_rgba_span24( const GLcontext *ctx, GLuint n, GLint x, GLint y, const GLchan color[4], const GLubyte mask[]); -extern void __read_rgba_span24( const GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte rgba[][4] ); -extern void __write_rgba_pixels24( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte rgba[][4], const GLubyte mask[] ); -extern void __write_mono_rgba_pixels24( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLchan color[4], const GLubyte mask[] ); -extern void __read_rgba_pixels24( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLubyte rgba[][4], const GLubyte mask[] ); - -#endif /* SVGA_MESA_24_H */ - diff --git a/src/mesa/drivers/svga/svgamesa32.c b/src/mesa/drivers/svga/svgamesa32.c deleted file mode 100644 index 8eea3cbe64..0000000000 --- a/src/mesa/drivers/svga/svgamesa32.c +++ /dev/null @@ -1,223 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.0 - * Copyright (C) 1995-2002 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * SVGA driver for Mesa. - * Original author: Brian Paul - * Additional authors: Slawomir Szczyrba (Mesa 3.2) - */ - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#ifdef SVGA - -#include "svgapix.h" -#include "svgamesa32.h" -#include "swrast/swrast.h" - - -#if 0 -/* this doesn't compile with GCC on RedHat 6.1 */ -static INLINE int RGB2BGR32(int c) -{ - asm("rorw $8, %0\n" - "rorl $16, %0\n" - "rorw $8, %0\n" - "shrl $8, %0\n" - : "=q"(c):"0"(c)); - return c; -} -#else -static unsigned long RGB2BGR32(unsigned long color) -{ - return (color & 0xff00)|(color>>16)|((color & 0xff)<<16); -} -#endif - -static void __svga_drawpixel32(int x, int y, unsigned long c) -{ - unsigned long offset; - - GLint *intBuffer=(void *)SVGABuffer.DrawBuffer; - y = SVGAInfo->height-y-1; - offset = y * SVGAInfo->width + x; - intBuffer[offset]=c; -} - -static unsigned long __svga_getpixel32(int x, int y) -{ - unsigned long offset; - - const GLint *intBuffer=(void *)SVGABuffer.ReadBuffer; - y = SVGAInfo->height-y-1; - offset = y * SVGAInfo->width + x; - return intBuffer[offset]; -} - -void __clear_color32( GLcontext *ctx, const GLfloat color[4] ) -{ - GLubyte col[3]; - CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]); - SVGAMesa->clear_truecolor = (col[0] << 16) | (col[1] << 8) | col[2]; -} - -void __clear32( GLcontext *ctx, GLbitfield mask ) -{ - int i,j; - int x = ctx->DrawBuffer->_Xmin; - int y = ctx->DrawBuffer->_Ymin; - int width = ctx->DrawBuffer->_Xmax - x; - int height = ctx->DrawBuffer->_Ymax - y; - GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->height) - - if (mask & DD_FRONT_LEFT_BIT) { - if (all) { - GLint *intBuffer=(void *)SVGABuffer.FrontBuffer; - for (i=0;iclear_truecolor; - } - else { - GLubyte *tmp = SVGABuffer.DrawBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer; - for (i=x;iclear_truecolor); - SVGABuffer.DrawBuffer = tmp; - } - mask &= ~DD_FRONT_LEFT_BIT; - } - if (mask & DD_BACK_LEFT_BIT) { - if (all) { - GLint *intBuffer=(void *)SVGABuffer.BackBuffer; - for (i=0;iclear_truecolor; - } - else { - GLubyte *tmp = SVGABuffer.DrawBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer; - for (i=x;iclear_truecolor); - SVGABuffer.DrawBuffer = tmp; - } - mask &= ~DD_BACK_LEFT_BIT; - } - - if (mask) - _swrast_Clear( ctx, mask ); -} - -void __write_rgba_span32( const GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLubyte rgba[][4], const GLubyte mask[] ) -{ - int i; - if (mask) { - /* draw some pixels */ - for (i=0; i (Mesa 3.2) - */ - - -#ifndef SVGA_MESA_32_H -#define SVGA_MESA_32_H - -extern void __clear_color32( GLcontext *ctx, const GLfloat color[4] ); -extern void __clear32( GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height ); -extern void __write_rgba_span32( const GLcontext *ctx, GLuint n, GLint x, GLint y, const GLubyte rgba[][4], const GLubyte mask[] ); -extern void __write_mono_rgba_span32( const GLcontext *ctx, GLuint n, GLint x, GLint y, const GLchan color[4], const GLubyte mask[]); -extern void __read_rgba_span32( const GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte rgba[][4] ); -extern void __write_rgba_pixels32( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte rgba[][4], const GLubyte mask[] ); -extern void __write_mono_rgba_pixels32( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLchan color[4], const GLubyte mask[] ); -extern void __read_rgba_pixels32( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLubyte rgba[][4], const GLubyte mask[] ); - -#endif /* SVGA_MESA_32_H */ - diff --git a/src/mesa/drivers/svga/svgamesa8.c b/src/mesa/drivers/svga/svgamesa8.c deleted file mode 100644 index 2f7048a930..0000000000 --- a/src/mesa/drivers/svga/svgamesa8.c +++ /dev/null @@ -1,196 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.3 - * Copyright (C) 1995-2000 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * SVGA driver for Mesa. - * Original author: Brian Paul - * Additional authors: Slawomir Szczyrba (Mesa 3.2) - */ - -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif - -#ifdef SVGA - - -#include "svgapix.h" -#include "svgamesa8.h" -#include "swrast/swrast.h" - - -static void __svga_drawpixel8(int x, int y, unsigned long c) -{ - unsigned long offset; - y = SVGAInfo->height-y-1; - offset = y * SVGAInfo->linewidth + x; - SVGABuffer.DrawBuffer[offset]=c; -} - -static unsigned long __svga_getpixel8(int x, int y) -{ - unsigned long offset; - y = SVGAInfo->height-y-1; - offset = y * SVGAInfo->linewidth + x; - return SVGABuffer.ReadBuffer[offset]; -} - -void __clear_index8( GLcontext *ctx, GLuint index ) -{ - SVGAMesa->clear_index = index; -} - -void __clear8( GLcontext *ctx, GLbitfield mask ) -{ - int i,j; - int x = ctx->DrawBuffer->_Xmin; - int y = ctx->DrawBuffer->_Ymin; - int width = ctx->DrawBuffer->_Xmax - x; - int height = ctx->DrawBuffer->_Ymax - y; - GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->height) - - if (mask & DD_FRONT_LEFT_BIT) { - if (all) { - memset(SVGABuffer.FrontBuffer, SVGAMesa->clear_index, SVGABuffer.BufferSize); - } - else { - GLubyte *tmp = SVGABuffer.DrawBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer; - for (i=x;iclear_index); - SVGABuffer.DrawBuffer = tmp; - } - mask &= ~DD_FRONT_LEFT_BIT; - } - if (mask & DD_BACK_LEFT_BIT) { - if (all) { - memset(SVGABuffer.BackBuffer, SVGAMesa->clear_index, SVGABuffer.BufferSize); - } - else { - GLubyte *tmp = SVGABuffer.DrawBuffer; - SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer; - for (i=x;iclear_index); - SVGABuffer.DrawBuffer = tmp; - } - mask &= ~DD_BACK_LEFT_BIT; - } - - if (mask) - _swrast_Clear( ctx, mask ); -} - -void __write_ci32_span8( const GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const GLuint index[], const GLubyte mask[] ) -{ - int i; - for (i=0;i (Mesa 3.2) - */ - - -#ifndef SVGA_MESA_8_H -#define SVGA_MESA_8_H - -extern void __clear_index8( GLcontext *ctx, GLuint index ); -extern void __clear8( GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height ); -extern void __write_ci32_span8( const GLcontext *ctx, GLuint n, GLint x, GLint y, const GLuint index[], const GLubyte mask[] ); -extern void __write_ci8_span8( const GLcontext *ctx, GLuint n, GLint x, GLint y, const GLubyte index[], const GLubyte mask[] ); -extern void __write_mono_ci_span8( const GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint colorIndex, const GLubyte mask[] ); -extern void __read_ci32_span8( const GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint index[]); -extern void __write_ci32_pixels8( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLuint index[], const GLubyte mask[] ); -extern void __write_mono_ci_pixels8( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLuint colorIndex, const GLubyte mask[] ); -extern void __read_ci32_pixels8( const GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLuint index[], const GLubyte mask[] ); - -#endif /* SVGA_MESA_15_H */ diff --git a/src/mesa/drivers/svga/svgapix.h b/src/mesa/drivers/svga/svgapix.h deleted file mode 100644 index c8cee37ca6..0000000000 --- a/src/mesa/drivers/svga/svgapix.h +++ /dev/null @@ -1,70 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.0 - * Copyright (C) 1995-2002 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * SVGA driver for Mesa. - * Original author: Brian Paul - * Additional authors: Slawomir Szczyrba (Mesa 3.2) - */ - - -#ifndef SVGAPIX_H -#define SVGAPIX_H - -#include "GL/gl.h" -#include "GL/svgamesa.h" -#include "main/context.h" -#include "main/colormac.h" -#include "vga.h" - -struct svgamesa_context { - GLcontext *gl_ctx; /* the core Mesa context */ - GLvisual *gl_vis; /* describes the color buffer */ - GLframebuffer *gl_buffer; /* the ancillary buffers */ - GLuint clear_index; /* current clear index */ - GLint clear_red, - clear_green, - clear_blue; /* current clear rgb color */ - GLuint clear_truecolor; /* current clear rgb color */ - GLushort hicolor; /* current hicolor */ - GLushort clear_hicolor; /* current clear hicolor */ - GLint width, height; /* size of color buffer */ - GLint depth; /* bits per pixel (8,16,24 or 32) */ -}; - -typedef struct { GLubyte b,g,r; } _RGB; - -struct svga_buffer { - GLint Depth; - GLint BufferSize; - GLubyte * FrontBuffer; - GLubyte * BackBuffer; - GLubyte * VideoRam; - GLubyte * DrawBuffer; /* == FrontBuffer or BackBuffer */ - GLubyte * ReadBuffer; /* == FrontBuffer or BackBuffer */ -}; - -extern struct svga_buffer SVGABuffer; -extern vga_modeinfo * SVGAInfo; -extern SVGAMesaContext SVGAMesa; /* the current context */ - -#endif /* SVGAPIX_H */ -- cgit v1.2.3 From ddecefbb82bf30845fed5788fa72751f44aec4e8 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Feb 2010 04:02:41 +0200 Subject: drop linux-solo configs --- Makefile | 3 --- configs/linux-solo-ia64 | 7 ------- configs/linux-solo-x86 | 10 ---------- 3 files changed, 20 deletions(-) delete mode 100644 configs/linux-solo-ia64 delete mode 100644 configs/linux-solo-x86 (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0e70ef5d97..fae20c09c8 100644 --- a/Makefile +++ b/Makefile @@ -133,9 +133,6 @@ linux-osmesa32 \ linux-ppc \ linux-ppc-static \ linux-profile \ -linux-solo \ -linux-solo-x86 \ -linux-solo-ia64 \ linux-sparc \ linux-sparc5 \ linux-static \ diff --git a/configs/linux-solo-ia64 b/configs/linux-solo-ia64 deleted file mode 100644 index b2051fac85..0000000000 --- a/configs/linux-solo-ia64 +++ /dev/null @@ -1,7 +0,0 @@ -# Configuration for linux-solo-ia64: Linux DRI hardware drivers for fbdev - -include $(TOP)/configs/linux-solo - -CONFIG_NAME = linux-solo-ia64 - -DRI_DIRS = fb mach64 mga r128 r200 radeon sis tdfx unichrome diff --git a/configs/linux-solo-x86 b/configs/linux-solo-x86 deleted file mode 100644 index a9bf388260..0000000000 --- a/configs/linux-solo-x86 +++ /dev/null @@ -1,10 +0,0 @@ -# -*-makefile-*- -# Configuration for linux-solo-x86: Linux hardware drivers for fbdev for x86 - -include $(TOP)/configs/linux-solo - -CONFIG_NAME = linux-solo-x86 - -ASM_FLAGS = -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -MESA_ASM_SOURCES = $(X86_SOURCES) -GLAPI_ASM_SOURCES = $(X86_API) -- cgit v1.2.3 From 9a4a219d20127378793217da4c10ab865b96e477 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Feb 2010 04:02:41 +0200 Subject: drop header files and demos for dropped window systems --- Makefile | 1 - include/GL/Makefile.am | 38 ------- include/GL/dmesa.h | 160 ---------------------------- include/GL/ggimesa.h | 85 --------------- progs/xdemos/vgears.c | 281 ------------------------------------------------- progs/xdemos/vindex.c | 65 ------------ progs/xdemos/vtest.c | 82 --------------- 7 files changed, 712 deletions(-) delete mode 100644 include/GL/Makefile.am delete mode 100644 include/GL/dmesa.h delete mode 100644 include/GL/ggimesa.h delete mode 100644 progs/xdemos/vgears.c delete mode 100644 progs/xdemos/vindex.c delete mode 100644 progs/xdemos/vtest.c (limited to 'Makefile') diff --git a/Makefile b/Makefile index fae20c09c8..f6c99efc12 100644 --- a/Makefile +++ b/Makefile @@ -205,7 +205,6 @@ MAIN_FILES = \ $(DIRECTORY)/docs/RELNOTES* \ $(DIRECTORY)/docs/*.spec \ $(DIRECTORY)/include/GL/internal/glcore.h \ - $(DIRECTORY)/include/GL/dmesa.h \ $(DIRECTORY)/include/GL/gl.h \ $(DIRECTORY)/include/GL/glext.h \ $(DIRECTORY)/include/GL/gl_mangle.h \ diff --git a/include/GL/Makefile.am b/include/GL/Makefile.am deleted file mode 100644 index a62495766c..0000000000 --- a/include/GL/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -## Process this file with automake to produce Makefile.in - -GLincludedir = $(includedir)/GL - -INC_GGI = ggimesa.h -INC_OSMESA = osmesa.h -INC_SVGA = svgamesa.h -INC_X11 = glx.h glxext.h glx_mangle.h -INC_GLUT = glut.h glutf90.h - -if HAVE_GGI -sel_inc_ggi = $(INC_GGI) -endif - -if HAVE_OSMESA -sel_inc_osmesa = $(INC_OSMESA) -endif - -if HAVE_SVGA -sel_inc_svga = $(INC_SVGA) -endif - -if HAVE_X11 -sel_inc_x11 = $(INC_X11) -endif - -if NEED_GLUT -sel_inc_glut = $(INC_GLUT) -endif - -EXTRA_HEADERS = amesa.h foomesa.h glut_h.dja mesa_wgl.h mglmesa.h \ - vms_x_fix.h wmesa.h \ - $(INC_GGI) $(INC_OSMESA) $(INC_SVGA) $(INC_X11) $(INC_GLUT) - -GLinclude_HEADERS = gl.h glext.h gl_mangle.h glu.h glu_mangle.h \ - $(sel_inc_ggi) $(sel_inc_osmesa) $(sel_inc_svga) \ - $(sel_inc_x11) $(sel_inc_glut) -include $(top_srcdir)/common_rules.make diff --git a/include/GL/dmesa.h b/include/GL/dmesa.h deleted file mode 100644 index 358082e3ea..0000000000 --- a/include/GL/dmesa.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2004 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 for Mesa - * - * Author: Daniel Borca - * Email : dborca@users.sourceforge.net - * Web : http://www.geocities.com/dborca - */ - - -#ifndef DMESA_H_included -#define DMESA_H_included - -#define DMESA_MAJOR_VERSION 6 -#define DMESA_MINOR_VERSION 5 - -/* Sample Usage: - * - * 1. Call DMesaCreateVisual() to initialize graphics. - * 2. Call DMesaCreateContext() to create a DMesa rendering context. - * 3. Call DMesaCreateBuffer() to define the window. - * 4. Call DMesaMakeCurrent() to bind the DMesaBuffer to a DMesaContext. - * 5. Make gl* calls to render your graphics. - * 6. Use DMesaSwapBuffers() when double buffering to swap front/back buffers. - * 7. Before exiting, destroy DMesaBuffer, DMesaContext and DMesaVisual. - */ - -typedef struct dmesa_context *DMesaContext; -typedef struct dmesa_visual *DMesaVisual; -typedef struct dmesa_buffer *DMesaBuffer; - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Create a new Visual and set graphics mode. - */ -DMesaVisual DMesaCreateVisual (GLint width, /* X res */ - GLint height, /* Y res */ - GLint colDepth, /* BPP */ - GLint refresh, /* refresh rate: 0=default */ - GLboolean dbFlag, /* double-buffered */ - GLboolean rgbFlag, /* RGB mode */ - GLint alphaSize, /* requested bits/alpha */ - GLint depthSize, /* requested bits/depth */ - GLint stencilSize, /* requested bits/stencil */ - GLint accumSize); /* requested bits/accum */ - -/* - * Destroy Visual and restore screen. - */ -void DMesaDestroyVisual (DMesaVisual v); - - - -/* - * Create a new Context for rendering. - */ -DMesaContext DMesaCreateContext (DMesaVisual visual, DMesaContext share); - -/* - * Destroy Context. - */ -void DMesaDestroyContext (DMesaContext c); - -/* - * Return a handle to the current context. - */ -DMesaContext DMesaGetCurrentContext (void); - - - -/* - * Create a new Buffer (window). - */ -DMesaBuffer DMesaCreateBuffer (DMesaVisual visual, - GLint xpos, GLint ypos, - GLint width, GLint height); - -/* - * Destroy Buffer. - */ -void DMesaDestroyBuffer (DMesaBuffer b); - -/* - * Return a handle to the current buffer. - */ -DMesaBuffer DMesaGetCurrentBuffer (void); - -/* - * Swap the front and back buffers for the given Buffer. - * No action is taken if the buffer is not double buffered. - */ -void DMesaSwapBuffers (DMesaBuffer b); - -/* - * Bind Buffer to Context and make the Context the current one. - */ -GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b); - - - -/* - * Move/Resize current Buffer. - */ -GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos); -GLboolean DMesaResizeBuffer (GLint width, GLint height); - -/* - * Set palette index, using normalized values. - */ -void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue); - -/* - * DMesa functions - */ -typedef void (*DMesaProc) (); -DMesaProc DMesaGetProcAddress (const char *name); - -/* - * DMesa state retrieval. - */ -#define DMESA_GET_SCREEN_SIZE 0x0100 -#define DMESA_GET_DRIVER_CAPS 0x0200 -#define DMESA_GET_VIDEO_MODES 0x0300 -#define DMESA_GET_BUFFER_ADDR 0x0400 - -#define DMESA_DRIVER_DBL_BIT 0x1 /* double-buffered */ -#define DMESA_DRIVER_YUP_BIT 0x2 /* lower-left window origin */ -int DMesaGetIntegerv (GLenum pname, GLint *params); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/GL/ggimesa.h b/include/GL/ggimesa.h deleted file mode 100644 index 90e0b42222..0000000000 --- a/include/GL/ggimesa.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Mesa 3-D graphics library GGI bindings (GGIGL [giggle]) - * Version: 4.0 - * Copyright (C) 1995-2000 Brian Paul - * Copyright (C) 1998 Uwe Maurer - * Copyrigth (C) 2001 Filip Spacek - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -#ifndef GGIMESA_H -#define GGIMESA_H - -#define GGIMESA_MAJOR_VERSION 4 -#define GGIMESA_MINOR_VERSION 0 - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "GL/gl.h" - -typedef struct ggi_mesa_context *ggi_mesa_context_t; - -/* - * Initialize Mesa GGI extension - */ -int ggiMesaInit(void); -/* - * Clean up Mesa GGI exension - */ -int ggiMesaExit(void); - -/* - * Attach Mesa GGI extension to the visual 'vis' - */ -int ggiMesaAttach(ggi_visual_t vis); -/* - * Detach Mesa GGI extension from the visual 'vis' - */ -int ggiMesaDetach(ggi_visual_t vis); - -int ggiMesaExtendVisual(ggi_visual_t vis, GLboolean alpha_flag, - GLboolean stereo_flag, GLint depth_size, - GLint stencil_size, GLint accum_red_size, - GLint accum_green_size, GLint accum_blue_size, - GLint accum_alpha_size, GLint num_samples); - -/* - * Create a new context capable of displaying on the visual vis. - */ -ggi_mesa_context_t ggiMesaCreateContext(ggi_visual_t vis); -/* - * Destroy the context 'ctx' - */ -void ggiMesaDestroyContext(ggi_mesa_context_t ctx); - -/* - * Make context 'ctx' the current context and bind it to visual 'vis'. - * Note that the context must have been created with respect to that visual. - */ -void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis); - -void ggiMesaSwapBuffers(void); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/progs/xdemos/vgears.c b/progs/xdemos/vgears.c deleted file mode 100644 index f579e8b421..0000000000 --- a/progs/xdemos/vgears.c +++ /dev/null @@ -1,281 +0,0 @@ - -/* - * Spinning gears demo for Linux SVGA/Mesa interface in 32K color mode. - * - * Compile with: gcc vgears.c -I../include -L../lib -lMesaGL -lX11 -lXext - * -lvga -lm -o vgears - * - * This program is in the public domain. - * Brian Paul, January 1996 - */ - - -#include -#include -#include "GL/svgamesa.h" -#include "GL/gl.h" - - -int width = 800, height = 600; - -SVGAMesaContext vmc; - - - -/* - * Draw a gear wheel. You'll probably want to call this function when - * building a display list since we do a lot of trig here. - * - * Input: inner_radius - radius of hole at center - * outer_radius - radius at center of teeth - * width - width of gear - * teeth - number of teeth - * tooth_depth - depth of tooth - */ -static void gear( GLfloat inner_radius, GLfloat outer_radius, GLfloat width, - GLint teeth, GLfloat tooth_depth ) -{ - GLint i; - GLfloat r0, r1, r2; - GLfloat angle, da; - GLfloat u, v, len; - - r0 = inner_radius; - r1 = outer_radius - tooth_depth/2.0; - r2 = outer_radius + tooth_depth/2.0; - - da = 2.0*M_PI / teeth / 4.0; - - glShadeModel( GL_FLAT ); - - glNormal3f( 0.0, 0.0, 1.0 ); - - /* draw front face */ - glBegin( GL_QUAD_STRIP ); - for (i=0;i<=teeth;i++) { - angle = i * 2.0*M_PI / teeth; - glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 ); - glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 ); - glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 ); - glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 ); - } - glEnd(); - - /* draw front sides of teeth */ - glBegin( GL_QUADS ); - da = 2.0*M_PI / teeth / 4.0; - for (i=0;iheight) { - GLfloat w = (GLfloat) width / (GLfloat) height; - glFrustum( -w, w, -1.0, 1.0, 5.0, 60.0 ); - } - else { - GLfloat h = (GLfloat) height / (GLfloat) width; - glFrustum( -1.0, 1.0, -h, h, 5.0, 60.0 ); - } - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef( 0.0, 0.0, -40.0 ); -} - -void setup( void ) -{ - vga_init(); - - vga_setmode(G800x600x32K); -/* gl_setcontextvga(G800x600x32K);*/ - - vmc = SVGAMesaCreateContext(GL_TRUE); - SVGAMesaMakeCurrent( vmc ); -} - - -void end( void ) -{ - SVGAMesaDestroyContext( vmc ); - - vga_setmode( TEXT ); -} - - -int main( int argc, char *argv[] ) -{ - int i; - - setup(); - init(); - for (i=0;i<4;i++) { - draw(); /*SVGAMesaSwapBuffers();*/ - } - end(); - return 0; -} diff --git a/progs/xdemos/vindex.c b/progs/xdemos/vindex.c deleted file mode 100644 index 991fce2a59..0000000000 --- a/progs/xdemos/vindex.c +++ /dev/null @@ -1,65 +0,0 @@ - -/* - * Test Linux 8-bit SVGA/Mesa color index mode - * - * Compile with: gcc vindex.c -I../include -L../lib -lMesaGL -lX11 -lXext - * -lvga -lm -o vindex - * - * This program is in the public domain. - * Brian Paul, January 1996 - */ - - - -#include -#include "GL/svgamesa.h" -#include "GL/gl.h" - - - -static GLint width = 640, height = 480; - - - -static void display( void ) -{ - int i, j; - int w, h; - - glViewport( 0, 0, width, height ); - glMatrixMode( GL_PROJECTION ); - glLoadIdentity(); - glOrtho( 0.0, (GLfloat) width, 0.0, (GLfloat) height, -1.0, 1.0 ); - - glClear( GL_COLOR_BUFFER_BIT ); - - w = width / 16; - h = height / 16; - for (i=0;i<16;i++) { - for (j=0;j<16;j++) { - glIndexi( i*16+j ); - glRecti( i*w, j*h, i*w+w, j*h+h ); - } - } -} - - - -int main( int argc, char *argv[] ) -{ - SVGAMesaContext vmc; - int i; - - vga_init(); - vga_setmode( G640x480x256 ); - - vmc = SVGAMesaCreateContext( GL_FALSE ); - SVGAMesaMakeCurrent( vmc ); - - display(); - sleep(3); - - SVGAMesaDestroyContext( vmc ); - vga_setmode( TEXT ); - return 0; -} diff --git a/progs/xdemos/vtest.c b/progs/xdemos/vtest.c deleted file mode 100644 index e322fbc5c8..0000000000 --- a/progs/xdemos/vtest.c +++ /dev/null @@ -1,82 +0,0 @@ - -/* - * Test SVGA/Mesa interface in 32K color mode. - * - * Compile with: gcc vtest.c -I../include -L../lib -lMesaGL -lX11 -lXext - * -lvga -lm -o vtest - * - * This program is in the public domain. - * Brian Paul, January 1996 - */ - - - -#include -#include "GL/svgamesa.h" -#include "GL/gl.h" - - -SVGAMesaContext vmc; - - - -void setup( void ) -{ - vga_init(); - - vga_setmode(G800x600x32K); -/* gl_setcontextvga(G800x600x32K);*/ - - vmc = SVGAMesaCreateContext( GL_FALSE ); /* single buffered */ - SVGAMesaMakeCurrent( vmc ); -} - - -void test( void ) -{ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); - glMatrixMode(GL_MODELVIEW); - - glClear( GL_COLOR_BUFFER_BIT ); - - glBegin( GL_LINES ); - glColor3f( 1.0, 0.0, 0.0 ); - glVertex2f( -0.5, 0.5 ); - glVertex2f( 0.5, 0.5 ); - glColor3f( 0.0, 1.0, 0.0 ); - glVertex2f( -0.5, 0.25 ); - glVertex2f( 0.5, 0.25 ); - glColor3f( 0.0, 0.0, 1.0 ); - glVertex2f( -0.5, 0.0 ); - glVertex2f( 0.5, 0.0 ); - glEnd(); - - glBegin( GL_POLYGON ); - glColor3f( 1.0, 0.0, 0.0 ); - glVertex2f( 0.0, 0.7 ); - glColor3f( 0.0, 1.0, 0.0 ); - glVertex2f( -0.5, -0.5 ); - glColor3f( 0.0, 0.0, 1.0 ); - glVertex2f( 0.5, -0.5 ); - glEnd(); - - sleep(3); -} - -void end( void ) -{ - SVGAMesaDestroyContext( vmc ); - - vga_setmode( TEXT ); -} - - -int main( int argc, char *argv[] ) -{ - setup(); - test(); - end(); - return 0; -} -- cgit v1.2.3 From e215830c38be8ba00257937f5abbb17ec50ae3dc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Feb 2010 08:21:44 -0700 Subject: mesa: update tarball file list, bump version string --- Makefile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f6c99efc12..c4ee9e583c 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ ultrix-gcc: # Rules for making release tarballs -VERSION=7.7 +VERSION=7.8-devel DIRECTORY = Mesa-$(VERSION) LIB_NAME = MesaLib-$(VERSION) DEMO_NAME = MesaDemos-$(VERSION) @@ -220,10 +220,12 @@ MAIN_FILES = \ $(DIRECTORY)/include/GL/vms_x_fix.h \ $(DIRECTORY)/include/GL/wglext.h \ $(DIRECTORY)/include/GL/wmesa.h \ + $(DIRECTORY)/include/VG/*.h \ + $(DIRECTORY)/include/KHR/*.h \ $(DIRECTORY)/src/glsl/Makefile \ $(DIRECTORY)/src/glsl/Makefile.template \ + $(DIRECTORY)/src/glsl/SConscript \ $(DIRECTORY)/src/glsl/*/Makefile \ - $(DIRECTORY)/src/glsl/*/SConscript \ $(DIRECTORY)/src/glsl/*/*.[ch] \ $(DIRECTORY)/src/Makefile \ $(DIRECTORY)/src/mesa/Makefile* \ @@ -244,7 +246,6 @@ MAIN_FILES = \ $(DIRECTORY)/src/mesa/shader/slang/descrip.mms \ $(DIRECTORY)/src/mesa/shader/slang/library/*.[ch] \ $(DIRECTORY)/src/mesa/shader/slang/library/*.gc \ - $(DIRECTORY)/src/mesa/shader/slang/library/*.syn \ $(DIRECTORY)/src/mesa/shader/slang/library/Makefile \ $(DIRECTORY)/src/mesa/swrast/*.[ch] \ $(DIRECTORY)/src/mesa/swrast/descrip.mms \ @@ -311,6 +312,7 @@ EGL_FILES = \ $(DIRECTORY)/include/EGL/*.h \ $(DIRECTORY)/src/egl/Makefile \ $(DIRECTORY)/src/egl/*/Makefile \ + $(DIRECTORY)/src/egl/*/Makefile.template \ $(DIRECTORY)/src/egl/*/*.[ch] \ $(DIRECTORY)/src/egl/*/*/Makefile \ $(DIRECTORY)/src/egl/*/*/*.[ch] \ @@ -437,10 +439,7 @@ DEMO_FILES = \ $(DIRECTORY)/progs/glsl/*.c \ $(DIRECTORY)/progs/glsl/*.frag \ $(DIRECTORY)/progs/glsl/*.vert \ - $(DIRECTORY)/progs/glsl/*.shtest \ - $(DIRECTORY)/progs/windml/Makefile.ugl \ - $(DIRECTORY)/progs/windml/*.c \ - $(DIRECTORY)/progs/windml/*.bmp \ + $(DIRECTORY)/progs/glsl/*.shtest GLUT_FILES = \ $(DIRECTORY)/include/GL/glut.h \ -- cgit v1.2.3 From 6ce4a85e0b1d6581d73c1b1cbc37525d7a9ed1ba Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 17:35:01 -0700 Subject: mesa: bump version to 7.9 Now that the 7.8 branch has been created Mesa/master will be version 7.9 --- Makefile | 2 +- configs/default | 2 +- src/mesa/main/version.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c4ee9e583c..92b227ca48 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ ultrix-gcc: # Rules for making release tarballs -VERSION=7.8-devel +VERSION=7.9-devel DIRECTORY = Mesa-$(VERSION) LIB_NAME = MesaLib-$(VERSION) DEMO_NAME = MesaDemos-$(VERSION) diff --git a/configs/default b/configs/default index ad6d93c92f..4fe64cc6c9 100644 --- a/configs/default +++ b/configs/default @@ -9,7 +9,7 @@ CONFIG_NAME = default # Version info MESA_MAJOR=7 -MESA_MINOR=8 +MESA_MINOR=9 MESA_TINY=0 MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY) diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h index d521569f8d..59f62ebd6c 100644 --- a/src/mesa/main/version.h +++ b/src/mesa/main/version.h @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.8 + * Version: 7.9 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. All Rights Reserved. @@ -33,9 +33,9 @@ /* Mesa version */ #define MESA_MAJOR 7 -#define MESA_MINOR 8 +#define MESA_MINOR 9 #define MESA_PATCH 0 -#define MESA_VERSION_STRING "7.8-devel" +#define MESA_VERSION_STRING "7.9-devel" /* To make version comparison easy */ #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -- cgit v1.2.3 From 323238864f5f94fa8140113265d5a5a25f1626e7 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 6 Mar 2010 07:05:06 +0200 Subject: include/GL: drop more deprecated headers --- Makefile | 1 - include/GL/glut_h.dja | 340 -------------------------------------------------- include/GL/mglmesa.h | 79 ------------ 3 files changed, 420 deletions(-) delete mode 100644 include/GL/glut_h.dja delete mode 100644 include/GL/mglmesa.h (limited to 'Makefile') diff --git a/Makefile b/Makefile index 92b227ca48..4a81312046 100644 --- a/Makefile +++ b/Makefile @@ -215,7 +215,6 @@ MAIN_FILES = \ $(DIRECTORY)/include/GL/glx_mangle.h \ $(DIRECTORY)/include/GL/glfbdev.h \ $(DIRECTORY)/include/GL/mesa_wgl.h \ - $(DIRECTORY)/include/GL/mglmesa.h \ $(DIRECTORY)/include/GL/osmesa.h \ $(DIRECTORY)/include/GL/vms_x_fix.h \ $(DIRECTORY)/include/GL/wglext.h \ diff --git a/include/GL/glut_h.dja b/include/GL/glut_h.dja deleted file mode 100644 index e76dcb985e..0000000000 --- a/include/GL/glut_h.dja +++ /dev/null @@ -1,340 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.1 - * Copyright (C) 1995-1998 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -/* - * This header file is based on the REAL glut.h by Mark J. Kilgard. - * - * The DJGPP/ALLEGRO (DJA) GLUT implementation was written by - * Bernhard Tschirren (bernie-t@geocities.com) for the sole purpose - * of compiling all the sample programs (which use GLUT). Therefore, - * is NOT AT ALL a complete version of GLUT! - */ - - -#ifndef __AGLUT_H__ -#define __AGLUT_H__ - -#include -#include - -#define GLUTCALLBACK -#define APIENTRY -#define GLUTAPI extern - -#define GLUT_RGB 0 -#define GLUT_RGBA GLUT_RGB -#define GLUT_INDEX 1 -#define GLUT_SINGLE 0 -#define GLUT_DOUBLE 2 -#define GLUT_ACCUM 4 -#define GLUT_ALPHA 8 -#define GLUT_DEPTH 16 -#define GLUT_STENCIL 32 - -/* Mouse buttons. */ -#define GLUT_LEFT_BUTTON 0 -#define GLUT_MIDDLE_BUTTON 1 -#define GLUT_RIGHT_BUTTON 2 - -/* Mouse button state. */ -#define GLUT_DOWN 0 -#define GLUT_UP 1 - -/* function keys */ -#define GLUT_KEY_F1 1 -#define GLUT_KEY_F2 2 -#define GLUT_KEY_F3 3 -#define GLUT_KEY_F4 4 -#define GLUT_KEY_F5 5 -#define GLUT_KEY_F6 6 -#define GLUT_KEY_F7 7 -#define GLUT_KEY_F8 8 -#define GLUT_KEY_F9 9 -#define GLUT_KEY_F10 10 -#define GLUT_KEY_F11 11 -#define GLUT_KEY_F12 12 - -/* directional keys */ -#define GLUT_KEY_LEFT 100 -#define GLUT_KEY_UP 101 -#define GLUT_KEY_RIGHT 102 -#define GLUT_KEY_DOWN 103 -#define GLUT_KEY_PAGE_UP 104 -#define GLUT_KEY_PAGE_DOWN 105 -#define GLUT_KEY_HOME 106 -#define GLUT_KEY_END 107 -#define GLUT_KEY_INSERT 108 - -/* Entry/exit state. */ -#define GLUT_LEFT 0 -#define GLUT_ENTERED 1 - -/* Visibility state. */ -#define GLUT_NOT_VISIBLE 0 -#define GLUT_VISIBLE 1 - -/* Color index component selection values. */ -#define GLUT_RED 0 -#define GLUT_GREEN 1 -#define GLUT_BLUE 2 - -/* Layers for use. */ -#define GLUT_NORMAL 0 -#define GLUT_OVERLAY 1 - -/* Stroke font constants (use these in GLUT program). */ -#define GLUT_STROKE_ROMAN ((void*)0) -#define GLUT_STROKE_MONO_ROMAN ((void*)1) - -/* Bitmap font constants (use these in GLUT program). */ -#define GLUT_BITMAP_9_BY_15 ((void*)2) -#define GLUT_BITMAP_8_BY_13 ((void*)3) -#define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4) -#define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5) -#define GLUT_BITMAP_HELVETICA_10 ((void*)6) -#define GLUT_BITMAP_HELVETICA_12 ((void*)7) -#define GLUT_BITMAP_HELVETICA_18 ((void*)8) - -/* glutGet parameters. */ -#define GLUT_WINDOW_X 100 -#define GLUT_WINDOW_Y 101 -#define GLUT_WINDOW_WIDTH 102 -#define GLUT_WINDOW_HEIGHT 103 -#define GLUT_WINDOW_BUFFER_SIZE 104 -#define GLUT_WINDOW_STENCIL_SIZE 105 -#define GLUT_WINDOW_DEPTH_SIZE 106 -#define GLUT_WINDOW_RED_SIZE 107 -#define GLUT_WINDOW_GREEN_SIZE 108 -#define GLUT_WINDOW_BLUE_SIZE 109 -#define GLUT_WINDOW_ALPHA_SIZE 110 -#define GLUT_WINDOW_ACCUM_RED_SIZE 111 -#define GLUT_WINDOW_ACCUM_GREEN_SIZE 112 -#define GLUT_WINDOW_ACCUM_BLUE_SIZE 113 -#define GLUT_WINDOW_ACCUM_ALPHA_SIZE 114 -#define GLUT_WINDOW_DOUBLEBUFFER 115 -#define GLUT_WINDOW_RGBA 116 -#define GLUT_WINDOW_PARENT 117 -#define GLUT_WINDOW_NUM_CHILDREN 118 -#define GLUT_WINDOW_COLORMAP_SIZE 119 -#define GLUT_WINDOW_NUM_SAMPLES 120 -#define GLUT_WINDOW_STEREO 121 -#define GLUT_WINDOW_CURSOR 122 -#define GLUT_SCREEN_WIDTH 200 -#define GLUT_SCREEN_HEIGHT 201 -#define GLUT_SCREEN_WIDTH_MM 202 -#define GLUT_SCREEN_HEIGHT_MM 203 -#define GLUT_MENU_NUM_ITEMS 300 -#define GLUT_DISPLAY_MODE_POSSIBLE 400 -#define GLUT_INIT_WINDOW_X 500 -#define GLUT_INIT_WINDOW_Y 501 -#define GLUT_INIT_WINDOW_WIDTH 502 -#define GLUT_INIT_WINDOW_HEIGHT 503 -#define GLUT_INIT_DISPLAY_MODE 504 -#define GLUT_ELAPSED_TIME 700 -#define GLUT_WINDOW_FORMAT_ID 123 - -/* glutDeviceGet parameters. */ -#define GLUT_HAS_KEYBOARD 600 -#define GLUT_HAS_MOUSE 601 -#define GLUT_HAS_SPACEBALL 602 -#define GLUT_HAS_DIAL_AND_BUTTON_BOX 603 -#define GLUT_HAS_TABLET 604 -#define GLUT_NUM_MOUSE_BUTTONS 605 -#define GLUT_NUM_SPACEBALL_BUTTONS 606 -#define GLUT_NUM_BUTTON_BOX_BUTTONS 607 -#define GLUT_NUM_DIALS 608 -#define GLUT_NUM_TABLET_BUTTONS 609 -#define GLUT_DEVICE_IGNORE_KEY_REPEAT 610 -#define GLUT_DEVICE_KEY_REPEAT 611 -#define GLUT_HAS_JOYSTICK 612 -#define GLUT_OWNS_JOYSTICK 613 -#define GLUT_JOYSTICK_BUTTONS 614 -#define GLUT_JOYSTICK_AXES 615 -#define GLUT_JOYSTICK_POLL_RATE 616 - -/* glutLayerGet parameters. */ -#define GLUT_OVERLAY_POSSIBLE 800 -#define GLUT_LAYER_IN_USE 801 -#define GLUT_HAS_OVERLAY 802 -#define GLUT_TRANSPARENT_INDEX 803 -#define GLUT_NORMAL_DAMAGED 804 -#define GLUT_OVERLAY_DAMAGED 805 - -/* glutVideoResizeGet parameters. */ -#define GLUT_VIDEO_RESIZE_POSSIBLE 900 -#define GLUT_VIDEO_RESIZE_IN_USE 901 -#define GLUT_VIDEO_RESIZE_X_DELTA 902 -#define GLUT_VIDEO_RESIZE_Y_DELTA 903 -#define GLUT_VIDEO_RESIZE_WIDTH_DELTA 904 -#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA 905 -#define GLUT_VIDEO_RESIZE_X 906 -#define GLUT_VIDEO_RESIZE_Y 907 -#define GLUT_VIDEO_RESIZE_WIDTH 908 -#define GLUT_VIDEO_RESIZE_HEIGHT 909 - -/* glutUseLayer parameters. */ -#define GLUT_NORMAL 0 -#define GLUT_OVERLAY 1 - -/* glutGetModifiers return mask. */ -#define GLUT_ACTIVE_SHIFT 1 -#define GLUT_ACTIVE_CTRL 2 -#define GLUT_ACTIVE_ALT 4 - -/* glutSetCursor parameters. */ -/* Basic arrows. */ -#define GLUT_CURSOR_RIGHT_ARROW 0 -#define GLUT_CURSOR_LEFT_ARROW 1 -/* Symbolic cursor shapes. */ -#define GLUT_CURSOR_INFO 2 -#define GLUT_CURSOR_DESTROY 3 -#define GLUT_CURSOR_HELP 4 -#define GLUT_CURSOR_CYCLE 5 -#define GLUT_CURSOR_SPRAY 6 -#define GLUT_CURSOR_WAIT 7 -#define GLUT_CURSOR_TEXT 8 -#define GLUT_CURSOR_CROSSHAIR 9 -/* Directional cursors. */ -#define GLUT_CURSOR_UP_DOWN 10 -#define GLUT_CURSOR_LEFT_RIGHT 11 -/* Sizing cursors. */ -#define GLUT_CURSOR_TOP_SIDE 12 -#define GLUT_CURSOR_BOTTOM_SIDE 13 -#define GLUT_CURSOR_LEFT_SIDE 14 -#define GLUT_CURSOR_RIGHT_SIDE 15 -#define GLUT_CURSOR_TOP_LEFT_CORNER 16 -#define GLUT_CURSOR_TOP_RIGHT_CORNER 17 -#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 18 -#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19 -/* Inherit from parent window. */ -#define GLUT_CURSOR_INHERIT 100 -/* Blank cursor. */ -#define GLUT_CURSOR_NONE 101 -/* Fullscreen crosshair (if available). */ -#define GLUT_CURSOR_FULL_CROSSHAIR 102 - -/* GLUT initialization sub-API. */ -GLUTAPI void APIENTRY glutInit(int *argcp, char **argv); -GLUTAPI void APIENTRY glutInitDisplayMode(unsigned int mode); -GLUTAPI void APIENTRY glutInitWindowPosition(int x, int y); -GLUTAPI void APIENTRY glutInitWindowSize(int width, int height); -GLUTAPI void APIENTRY glutMainLoop(void); - -/* GLUT window sub-API. */ -GLUTAPI int APIENTRY glutCreateWindow(const char *title); -GLUTAPI int APIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height); -GLUTAPI void APIENTRY glutDestroyWindow(int win); -GLUTAPI void APIENTRY glutPostRedisplay(void); -GLUTAPI void APIENTRY glutSwapBuffers(void); -GLUTAPI int APIENTRY glutGetWindow(void); -GLUTAPI void APIENTRY glutSetWindow(int win); -GLUTAPI void APIENTRY glutSetWindowTitle(const char *title); -GLUTAPI void APIENTRY glutSetIconTitle(const char *title); -GLUTAPI void APIENTRY glutPositionWindow(int x, int y); -GLUTAPI void APIENTRY glutReshapeWindow(int width, int height); -GLUTAPI void APIENTRY glutPopWindow(void); -GLUTAPI void APIENTRY glutPushWindow(void); -GLUTAPI void APIENTRY glutIconifyWindow(void); -GLUTAPI void APIENTRY glutShowWindow(void); -GLUTAPI void APIENTRY glutHideWindow(void); - -/* GLUT overlay sub-API. */ -GLUTAPI void APIENTRY glutEstablishOverlay(void); -GLUTAPI void APIENTRY glutRemoveOverlay(void); -GLUTAPI void APIENTRY glutUseLayer(GLenum layer); -GLUTAPI void APIENTRY glutPostOverlayRedisplay(void); -GLUTAPI void APIENTRY glutShowOverlay(void); -GLUTAPI void APIENTRY glutHideOverlay(void); - -/* GLUT menu sub-API. */ -GLUTAPI int APIENTRY glutCreateMenu(void (GLUTCALLBACK *)(int)); -GLUTAPI void APIENTRY glutDestroyMenu(int menu); -GLUTAPI int APIENTRY glutGetMenu(void); -GLUTAPI void APIENTRY glutSetMenu(int menu); -GLUTAPI void APIENTRY glutAddMenuEntry(const char *label, int value); -GLUTAPI void APIENTRY glutAddSubMenu(const char *label, int submenu); -GLUTAPI void APIENTRY glutChangeToMenuEntry(int item, const char *label, int value); -GLUTAPI void APIENTRY glutChangeToSubMenu(int item, const char *label, int submenu); -GLUTAPI void APIENTRY glutRemoveMenuItem(int item); -GLUTAPI void APIENTRY glutAttachMenu(int button); -GLUTAPI void APIENTRY glutDetachMenu(int button); - -/* GLUT window callback sub-API. */ -GLUTAPI void APIENTRY glutDisplayFunc(void (GLUTCALLBACK * func)(void)); -GLUTAPI void APIENTRY glutReshapeFunc(void (GLUTCALLBACK * func)(int width, int height)); -GLUTAPI void APIENTRY glutKeyboardFunc(void (GLUTCALLBACK * func)(unsigned char key, int x, int y)); -GLUTAPI void APIENTRY glutMouseFunc(void (GLUTCALLBACK * func)(int button, int state, int x, int y)); -GLUTAPI void APIENTRY glutMotionFunc(void (GLUTCALLBACK * func)(int x, int y)); -GLUTAPI void APIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK * func)(int x, int y)); -GLUTAPI void APIENTRY glutEntryFunc(void (GLUTCALLBACK * func)(int state)); -GLUTAPI void APIENTRY glutVisibilityFunc(void (GLUTCALLBACK * func)(int state)); -GLUTAPI void APIENTRY glutIdleFunc(void (GLUTCALLBACK * func)(void)); -GLUTAPI void APIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK * func)(int value), int value); -GLUTAPI void APIENTRY glutMenuStateFunc(void (GLUTCALLBACK * func)(int state)); -GLUTAPI void APIENTRY glutSpecialFunc(void (GLUTCALLBACK * func)(int key, int x, int y)); -GLUTAPI void APIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK * func)(int x, int y, int z)); -GLUTAPI void APIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK * func)(int x, int y, int z)); -GLUTAPI void APIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK * func)(int button, int state)); -GLUTAPI void APIENTRY glutButtonBoxFunc(void (GLUTCALLBACK * func)(int button, int state)); -GLUTAPI void APIENTRY glutDialsFunc(void (GLUTCALLBACK * func)(int dial, int value)); -GLUTAPI void APIENTRY glutTabletMotionFunc(void (GLUTCALLBACK * func)(int x, int y)); -GLUTAPI void APIENTRY glutTabletButtonFunc(void (GLUTCALLBACK * func)(int button, int state, int x, int y)); -GLUTAPI void APIENTRY glutMenuStatusFunc(void (GLUTCALLBACK * func)(int status, int x, int y)); -GLUTAPI void APIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK * func)(void)); -GLUTAPI void APIENTRY glutWindowStatusFunc(void (GLUTCALLBACK * func)(int state)); - -/* GLUT color index sub-API. */ -GLUTAPI void APIENTRY glutSetColor(int, GLfloat red, GLfloat green, GLfloat blue); -GLUTAPI GLfloat APIENTRY glutGetColor(int ndx, int component); -GLUTAPI void APIENTRY glutCopyColormap(int win); - -/* GLUT state retrieval sub-API. */ -GLUTAPI int APIENTRY glutGet(GLenum type); -GLUTAPI int APIENTRY glutDeviceGet(GLenum type); - -/* GLUT font sub-API */ -GLUTAPI void APIENTRY glutBitmapCharacter(void *font, int character); -GLUTAPI int APIENTRY glutBitmapWidth(void *font, int character); -GLUTAPI void APIENTRY glutStrokeCharacter(void *font, int character); -GLUTAPI int APIENTRY glutStrokeWidth(void *font, int character); - -/* GLUT pre-built models sub-API */ -GLUTAPI void APIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks); -GLUTAPI void APIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks); -GLUTAPI void APIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); -GLUTAPI void APIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); -GLUTAPI void APIENTRY glutWireCube(GLdouble size); -GLUTAPI void APIENTRY glutSolidCube(GLdouble size); -GLUTAPI void APIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings); -GLUTAPI void APIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings); -GLUTAPI void APIENTRY glutWireDodecahedron(void); -GLUTAPI void APIENTRY glutSolidDodecahedron(void); -GLUTAPI void APIENTRY glutWireTeapot(GLdouble size); -GLUTAPI void APIENTRY glutSolidTeapot(GLdouble size); -GLUTAPI void APIENTRY glutWireOctahedron(void); -GLUTAPI void APIENTRY glutSolidOctahedron(void); -GLUTAPI void APIENTRY glutWireTetrahedron(void); -GLUTAPI void APIENTRY glutSolidTetrahedron(void); -GLUTAPI void APIENTRY glutWireIcosahedron(void); -GLUTAPI void APIENTRY glutSolidIcosahedron(void); - -#endif /* __AGLUT_H__ */ diff --git a/include/GL/mglmesa.h b/include/GL/mglmesa.h deleted file mode 100644 index 0f9f789571..0000000000 --- a/include/GL/mglmesa.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -* -* Mesa bindings for SciTech MGL -* -* Copyright (C) 1996 SciTech Software. -* All rights reserved. -* -* Filename: mglmesa.h -* Version: Revision: 1.1.1.1 -* -* Language: ANSI C -* Environment: Any -* -* Description: Header file for the Mesa/OpenGL interface bindings for the -* SciTech MGL graphics library. Uses the MGL internal -* device context structures to get direct access to the -* high performance MGL rasterization functions for maximum -* performance. Utilizes the VESA VBE/AF Accelerator Functions -* via the MGL's accelerated device driver functions, as well -* as basic DirectDraw accelerated functions provided by the -* MGL. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Library General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Library General Public License for more details. -* -* You should have received a copy of the GNU Library General Public -* License along with this library; if not, write to the Free -* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -* -* -****************************************************************************/ - -#ifndef __MGLMESA_H -#define __MGLMESA_H - -#include "mgraph.h" - -/*------------------------- Function Prototypes ---------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -#ifndef __WINDOWS__ -#define GLAPIENTRY -#endif - -#ifdef __WINDOWS__ -bool GLAPIENTRY MGLMesaInitDLL(MGLCallbacks *cb,char *version); -#endif -void GLAPIENTRY MGLMesaChooseVisual(MGLDC *dc,MGLVisual *visual); -bool GLAPIENTRY MGLMesaSetVisual(MGLDC *dc,MGLVisual *visual); -bool GLAPIENTRY MGLMesaCreateContext(MGLDC *dc,bool forceMemDC); -void GLAPIENTRY MGLMesaDestroyContext(MGLDC *dc); -void GLAPIENTRY MGLMesaMakeCurrent(MGLDC *dc); -void GLAPIENTRY MGLMesaSwapBuffers(MGLDC *dc,bool waitVRT); - -/* Palette manipulation support. The reason we provide palette manipulation - * routines is so that when rendering in double buffered modes with a - * software backbuffer, the palette for the backbuffer is kept consistent - * with the hardware front buffer. - */ - -void GLAPIENTRY MGLMesaSetPaletteEntry(MGLDC *dc,int entry,uchar red,uchar green,uchar blue); -void GLAPIENTRY MGLMesaSetPalette(MGLDC *dc,palette_t *pal,int numColors,int startIndex); -void GLAPIENTRY MGLMesaRealizePalette(MGLDC *dc,int numColors,int startIndex,int waitVRT); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif /* __cplusplus */ - -#endif /* __MGLMESA_H */ -- cgit v1.2.3