├── lib └── empty ├── doc ├── conform │ ├── v.bat │ ├── tex.txt │ ├── util.h │ ├── extgl.h │ ├── texenv.h │ ├── Makefile.mgw │ ├── blend.h │ ├── base.h │ ├── util.c │ └── extgl.c ├── texenv │ ├── parser.h │ ├── util.h │ ├── napalm │ │ ├── REPLACE │ │ ├── tmu.txt │ │ ├── ADD │ │ ├── MODULATE │ │ ├── SUBTRACT_ARB │ │ ├── ADD_SIGNED_ARB │ │ └── INTERPOLATE_ARB │ ├── voodoo │ │ ├── REPLACE │ │ ├── ADD │ │ ├── MODULATE │ │ ├── DECAL │ │ ├── BLEND │ │ ├── tmu.txt │ │ ├── DECAL_MODULATE │ │ ├── MODULATE_DECAL │ │ ├── MODULATE_REPLACE │ │ ├── REPLACE_ADD │ │ ├── REPLACE_MODULATE │ │ ├── MODULATE_MODULATE │ │ └── MODULATE_BLEND │ ├── lexer.h │ ├── util.c │ ├── Makefile │ ├── tree.h │ ├── parser.c │ ├── tree.c │ └── lexer.c ├── bugs.txt ├── clip.txt ├── tools │ ├── defi │ └── glapit.pl ├── prim.txt └── apps.txt ├── g3sdk ├── lib │ ├── glide3x.lib │ ├── libglide3x.dll.a │ └── glide3x.def └── include │ ├── 3dfx.h │ └── glideutl.h ├── main ├── texture.h ├── raster.c ├── glapic.c ├── depth.c ├── texdef.h ├── texstore.h ├── glapi.h ├── stencil.c ├── dlist.h ├── buffer.c ├── matrix.h ├── glapi.c ├── legacy.c ├── alias.h ├── color.c ├── fog.c ├── cull.c ├── pixel.c ├── texdef.c └── ext.c ├── util ├── alloc.h ├── cfg.h ├── pow.h ├── alloc.c ├── macros.h ├── cfg.c ├── pow.c └── list.h ├── drivers ├── foo │ ├── config │ ├── drv.h │ ├── drv_setup.c │ ├── drv_cb.c │ ├── opengl.rc │ ├── drv_tex.c │ ├── drv_vb.c │ └── drv_api.c └── glide │ ├── opengl.rc │ ├── config │ ├── wgl_tab.c │ └── x86 │ └── k3d_emit.asm ├── log.h ├── x86 ├── cpu.h ├── glapia.asm ├── x86.h ├── cpusoft.asm ├── k3d_clip.asm ├── sse_clip.asm ├── xos.inc ├── sse_vertex.asm ├── x86_vertex.asm ├── sse_mat.asm ├── cpuhard.c └── x86.c ├── tnl ├── template │ ├── tcoord.h │ ├── reflect.h │ ├── texgen.h │ ├── normals.h │ └── clipmask.h ├── sav_api.c └── imm_api.c ├── README ├── include └── GL │ └── sage.h ├── glinternal.h ├── Makefile ├── Makefile.icc ├── Makefile.DJ ├── Makefile.mgw └── sage.ini /lib/empty: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/conform/v.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | del testgl.exe 3 | make FX=1 4 | -------------------------------------------------------------------------------- /g3sdk/lib/glide3x.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dborca/sage/HEAD/g3sdk/lib/glide3x.lib -------------------------------------------------------------------------------- /g3sdk/lib/libglide3x.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dborca/sage/HEAD/g3sdk/lib/libglide3x.dll.a -------------------------------------------------------------------------------- /doc/texenv/parser.h: -------------------------------------------------------------------------------- 1 | #ifndef PARSER_H_included 2 | #define PARSER_H_included 3 | 4 | NODE *parse (const char *input); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /doc/texenv/util.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_H_included 2 | #define UTIL_H_included 3 | 4 | char *str_dup (const char *source); 5 | 6 | void next_token (void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /main/texture.h: -------------------------------------------------------------------------------- 1 | #ifndef TEXTURE_H_included 2 | #define TEXTURE_H_included 3 | 4 | TEX_OBJ *tex_fill_object (TEX_OBJ *obj); 5 | void tex_delete_all (void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /util/alloc.h: -------------------------------------------------------------------------------- 1 | #ifndef ALLOC_H_included 2 | #define ALLOC_H_included 3 | 4 | void *malloc_a (size_t size, int p2align); 5 | void *calloc_a (size_t size, int p2align); 6 | void free_a (void *ptr); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /drivers/foo/config: -------------------------------------------------------------------------------- 1 | DRIVER_SOURCES = \ 2 | drivers/$(DRIVER)/drv_api.c \ 3 | drivers/$(DRIVER)/drv_cb.c \ 4 | drivers/$(DRIVER)/drv_setup.c \ 5 | drivers/$(DRIVER)/drv_tex.c \ 6 | drivers/$(DRIVER)/drv_tri.c \ 7 | drivers/$(DRIVER)/drv_vb.c 8 | -------------------------------------------------------------------------------- /log.h: -------------------------------------------------------------------------------- 1 | #ifndef LOG_H_included 2 | #define LOG_H_included 3 | 4 | #undef LOG 5 | 6 | #ifndef LOGGING 7 | #define LOGGING 0 8 | #endif 9 | 10 | #if LOGGING 11 | #include 12 | #define LOG(x) printf x 13 | #else 14 | #define LOG(x) 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /doc/conform/tex.txt: -------------------------------------------------------------------------------- 1 | GL_RGBA -> RGBA -> A, R, G, B 2 | GL_RGB -> RGB -> 1, R, G, B 3 | GL_INTENSITY -> ALPHA -> I, I, I, I 4 | GL_LUMINANCE_ALPHA -> ALPHA_INTENSITY -> A, L, L, L 5 | GL_LUMINANCE -> INTENSITY -> 1, L, L, L 6 | GL_ALPHA -> ALPHA -> A, A, A, A (A, 0, 0, 0) 7 | -------------------------------------------------------------------------------- /util/cfg.h: -------------------------------------------------------------------------------- 1 | #ifndef CFG_H_included 2 | #define CFG_H_included 3 | 4 | int cfg_load (const char *filename); 5 | const char *cfg_get (const char *var, const char *def); 6 | int cfg_browse (int (*fn) (const char *var, const char *val)); 7 | void cfg_kill (void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /main/raster.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "context.h" 5 | #include "glapi.h" 6 | 7 | 8 | typedef struct { 9 | GLfloat4 position; 10 | GLfloat distance; 11 | GLboolean valid; 12 | GLfloat4 color0; 13 | GLfloat4 color1; 14 | GLfloat4 texture[MAX_TEXTURE_UNITS]; 15 | } RASTER; 16 | -------------------------------------------------------------------------------- /doc/bugs.txt: -------------------------------------------------------------------------------- 1 | 1. unfilled clipped triangle is not ok (edgeflag?!?) 2 | 2. glCullFace(GL_FRONT_AND_BACK) is not 100% correct 3 | 3. secondarycolor: 4 | fragment -> alphatest -> stenciltest -> depthtest -> blending 5 | OpenGL: 6 | primitive -> texturing -> colorsum -> fog -> fragments (blending) 7 | SAGE: 8 | primitive -> texturing -> fog -> fragments (blending) -> colorsum 9 | -------------------------------------------------------------------------------- /doc/texenv/napalm/REPLACE: -------------------------------------------------------------------------------- 1 | Arg0 2 | 3 | ( Arg0 + 0) * 1 + 0 4 | [(1 - Arg0) + 0] * 1 + 0 5 | 6 | invert = 0 7 | a_mode = TEXENV_SETUP_MODE(Arg0, 0) 8 | b_mode = 0 9 | c_mode = 0 10 | c_invt = 1 11 | d_mode = 0 12 | d_invt = 0 13 | 14 | A_OK: 15 | (Arg0 + 0) * 1 + 0 = Arg0 16 | A_INVERT: 17 | (1_Arg0 + 0) * 1 + 0 = 1_Arg0 18 | -------------------------------------------------------------------------------- /x86/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef CPU_H_included 2 | #define CPU_H_included 3 | 4 | #define _CPU_HAS_CPUID 0x8000 5 | #define _CPU_FEATURE_MMX 0x0001 6 | #define _CPU_FEATURE_SSE 0x0002 7 | #define _CPU_FEATURE_SSE2 0x0004 8 | #define _CPU_FEATURE_3DNOW 0x0008 9 | #define _CPU_FEATURE_3DNOWPLUS 0x0010 10 | #define _CPU_FEATURE_MMXPLUS 0x0020 11 | 12 | int cpuhard (void); 13 | int cpusoft (char *name); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /main/glapic.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glapi.h" 4 | 5 | 6 | #ifndef X86 7 | #define ENTRY_NR(z, x, y, w, k) \ 8 | GLAPI z GLAPIENTRY gl##x y \ 9 | { \ 10 | GLCALL(x) w; \ 11 | } 12 | #define ENTRY_RV(z, x, y, w, k) \ 13 | GLAPI z GLAPIENTRY gl##x y \ 14 | { \ 15 | return GLCALL(x) w; \ 16 | } 17 | 18 | 19 | #include "glapit.h" 20 | #undef ENTRY_NR 21 | #undef ENTRY_RV 22 | #endif /* X86 */ 23 | -------------------------------------------------------------------------------- /doc/clip.txt: -------------------------------------------------------------------------------- 1 | d -d pd - d - pd pd 2 | t1 = ------ = ------ = ----------- = 1 - ------ = 1 - t2 3 | d - pd pd - d pd - d pd - d 4 | 5 | INTERP(d/(d-pd), A, B) = INTERP(t1, A, B) = 6 | = A + t1 * (B - A) = 7 | = A + (1 - t2) * (B - A) = 8 | = A + B - A - t2 * B + t2 * A = 9 | = B + t2 * A - t2 * B = 10 | = B + t2 * (A - B) = 11 | INTERP(t2, B, A) = INTERP(pd/(pd-d), B, A) 12 | -------------------------------------------------------------------------------- /doc/texenv/napalm/tmu.txt: -------------------------------------------------------------------------------- 1 | if (scale == 1) { 2 | use normal combiners 3 | } else if (singletexturing) { 4 | move scaling from TexCombine to ColorCombine 5 | } else if (GL_COMBINE requires Napalm texCombineInvert) { 6 | fix SUBTRACT 7 | fix ADD_SIGNED (w/o A_INVERT, B_INVERT) 8 | fix INTERPOLATE (w/o A_OK, B_INVERT) 9 | 10 | not fixed: ADD_SIGNED (A_INVERT, B_INVERT) 11 | not fixed: INTERPOLATE (A_OK, B_INVERT) 12 | } 13 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/REPLACE: -------------------------------------------------------------------------------- 1 | REPLACE 2 | 3 | ALPHA f A0 4 | LUMINANCE C0 f 5 | LUMINANCE_ALPHA C0 A0 6 | INTENSITY C0 A0 7 | RGB C0 f 8 | RGBA C0 A0 9 | -------------------------------------------------------------------------------- /doc/texenv/lexer.h: -------------------------------------------------------------------------------- 1 | #ifndef LEXER_H_included 2 | #define LEXER_H_included 3 | 4 | typedef enum { 5 | T_ID, 6 | T_ADD, 7 | T_SUB, 8 | T_MUL, 9 | T_DIV, 10 | T_OB, 11 | T_CB, 12 | T_EOI 13 | } TOKTYPE; 14 | 15 | typedef struct { 16 | TOKTYPE type; 17 | int len, max; 18 | char *sym; 19 | } TOKEN; 20 | 21 | extern TOKEN token; 22 | 23 | void set_input (const char *i); 24 | void get_token (void); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/ADD: -------------------------------------------------------------------------------- 1 | ADD 2 | 3 | ALPHA f f * A0 4 | LUMINANCE f + C0 f 5 | LUMINANCE_ALPHA f + C0 f * A0 6 | INTENSITY f + C0 f + A0 7 | RGB f + C0 f 8 | RGBA f + C0 f * A0 9 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/MODULATE: -------------------------------------------------------------------------------- 1 | MODULATE 2 | 3 | ALPHA f f * A0 4 | LUMINANCE f * C0 f 5 | LUMINANCE_ALPHA f * C0 f * A0 6 | INTENSITY f * C0 f * A0 7 | RGB f * C0 f 8 | RGBA f * C0 f * A0 9 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/DECAL: -------------------------------------------------------------------------------- 1 | DECAL 2 | 3 | ALPHA undefined undefined 4 | LUMINANCE undefined undefined 5 | LUMINANCE_ALPHA undefined undefined 6 | INTENSITY undefined undefined 7 | RGB C0 f 8 | RGBA f * (1 - A0) + C0 * A0 f 9 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/BLEND: -------------------------------------------------------------------------------- 1 | BLEND 2 | 3 | ALPHA f f * A0 4 | LUMINANCE f * (1 - C0) + Cc * C0 f 5 | LUMINANCE_ALPHA f * (1 - C0) + Cc * C0 f * A0 6 | INTENSITY f * (1 - C0) + Cc * C0 f * (1 - A0) + Ac * A0 7 | RGB f * (1 - C0) + Cc * C0 f 8 | RGBA f * (1 - C0) + Cc * C0 f * A0 9 | -------------------------------------------------------------------------------- /doc/texenv/util.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "lexer.h" 6 | #include "util.h" 7 | 8 | 9 | char * 10 | str_dup (const char *source) 11 | { 12 | char *p = malloc(strlen(source) + 1); 13 | if (p != NULL) { 14 | strcpy(p, source); 15 | } 16 | return p; 17 | } 18 | 19 | 20 | void 21 | next_token (void) 22 | { 23 | get_token(); 24 | 25 | #if 0 26 | if (token.type != T_EOI) { 27 | printf("token = %s\n", token.sym); 28 | } 29 | #endif 30 | } 31 | -------------------------------------------------------------------------------- /drivers/foo/drv.h: -------------------------------------------------------------------------------- 1 | #ifndef DRV_H_included 2 | #define DRV_H_included 3 | 4 | typedef struct { 5 | GLfloat s, t, r, q; 6 | } TexCoord; 7 | 8 | typedef struct { 9 | GLfloat r, g, b, a; 10 | GLfloat x, y, z, oow; 11 | TexCoord texcoord[TNL_MAX_TEXCOORD]; 12 | } SWvertex; 13 | 14 | 15 | extern SWvertex *vb; 16 | 17 | int drv_multipass_none (int pass); 18 | 19 | void setup_tri_pointers (void); 20 | 21 | 22 | struct sageContext { 23 | void *drawable; /**< Current drawable */ 24 | }; 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /doc/texenv/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean realclean 2 | 3 | CC = gcc 4 | CFLAGS += -Wall -W -pedantic -ansi 5 | CFLAGS += -O2 6 | 7 | LD = $(CC) 8 | LDFLAGS = -s 9 | LDLIBS = 10 | 11 | SOURCES = \ 12 | lexer.c \ 13 | parser.c \ 14 | tree.c \ 15 | util.c \ 16 | main.c 17 | 18 | OBJECTS = $(SOURCES:.c=.o) 19 | 20 | .c.o: 21 | $(CC) -o $@ $(CFLAGS) -c $< 22 | 23 | all: exu 24 | 25 | exu: $(OBJECTS) 26 | $(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS) 27 | 28 | clean: 29 | -$(RM) $(OBJECTS) 30 | 31 | realclean: clean 32 | -$(RM) exu 33 | -------------------------------------------------------------------------------- /x86/glapia.asm: -------------------------------------------------------------------------------- 1 | %include "xos.inc" 2 | 3 | 4 | extern ctx_gl_table 5 | 6 | 7 | struc glapi 8 | %define ENTRY_NR(z, x, y, w, k) x resd 1 9 | %define ENTRY_RV(z, x, y, w, k) x resd 1 10 | %include "glapit.h" 11 | %undef ENTRY_NR 12 | %undef ENTRY_RV 13 | endstruc 14 | 15 | %macro JUMP 2 16 | align 16 17 | proc gl%1, %2 18 | mov eax, [ctx_gl_table] 19 | jmp [eax + %1] 20 | endp 21 | dllexp gl%1 22 | %endmacro 23 | 24 | 25 | %define ENTRY_NR(z, x, y, w, k) JUMP x, k 26 | %define ENTRY_RV(z, x, y, w, k) JUMP x, k 27 | %include "glapit.h" 28 | %undef ENTRY_NR 29 | %undef ENTRY_RV 30 | -------------------------------------------------------------------------------- /main/depth.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "glapi.h" 5 | #include "context.h" 6 | 7 | 8 | void GLAPIENTRY 9 | imm_DepthFunc (GLenum func) 10 | { 11 | FLUSH_VERTICES(); 12 | 13 | ctx_depth_func = func; 14 | 15 | ctx_gl_state |= NEW_DEPTH; 16 | } 17 | 18 | 19 | void GLAPIENTRY 20 | imm_DepthMask (GLboolean flag) 21 | { 22 | FLUSH_VERTICES(); 23 | 24 | ctx_depth_mask = flag; 25 | 26 | ctx_gl_state |= NEW_DEPTH; 27 | } 28 | 29 | 30 | void GLAPIENTRY 31 | imm_ClearDepth (GLclampd depth) 32 | { 33 | ctx_clear_depth = depth; 34 | } 35 | -------------------------------------------------------------------------------- /doc/texenv/tree.h: -------------------------------------------------------------------------------- 1 | #ifndef TREE_H_included 2 | #define TREE_H_included 3 | 4 | typedef enum { 5 | N_OP, 6 | N_VAR 7 | } N_TYPE; 8 | 9 | typedef struct NODE { 10 | struct NODE *left, *right; 11 | N_TYPE type; 12 | union { 13 | int ch; 14 | const char *name; 15 | } val; 16 | } NODE; 17 | 18 | NODE *tree_node_op (int op); 19 | NODE *tree_node_var (const char *var); 20 | void tree_display (NODE *node); 21 | void tree_destroy (NODE *node); 22 | int tree_check_var (NODE *node, const char *var); 23 | NODE **tree_find_var (NODE *node, const char *var); 24 | const char *tree_string (NODE *node, int init); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /util/pow.h: -------------------------------------------------------------------------------- 1 | #ifndef POW_H_included 2 | #define POW_H_included 3 | 4 | #define POW_LUT_SIZE 256 5 | 6 | typedef struct POW_LUT { 7 | struct POW_LUT *next, *prev; 8 | GLint refcount; 9 | GLfloat threshold, scale, exp; 10 | GLfloat table[POW_LUT_SIZE + 1]; 11 | } POW_LUT; 12 | 13 | int pow_init (void); 14 | POW_LUT *pow_make (POW_LUT *table, GLfloat exp); 15 | POW_LUT *pow_scan (GLfloat exp); 16 | void pow_fini (void); 17 | 18 | GLfloat pow_sf (GLfloat dp, GLfloat exp); 19 | GLfloat pow_sl (GLfloat dp, GLfloat exp); 20 | GLfloat pow_tf (GLfloat dp, GLfloat exp, POW_LUT *tab); 21 | GLfloat pow_tl (GLfloat dp, GLfloat exp, POW_LUT *tab); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /doc/texenv/napalm/ADD: -------------------------------------------------------------------------------- 1 | Arg0 + Arg1 2 | 3 | ( Arg0 + Arg1) * 1 + 0 4 | [(1 - Arg0) + Arg1] * 1 + 0 5 | [ Arg0 + (1 - Arg1)] * 1 + 0 6 | [(1 - Arg0) + (1 - Arg1)] * 1 + 0 7 | 8 | invert = 0 9 | a_mode = TEXENV_SETUP_MODE(Arg0, 0) 10 | b_mode = TEXENV_SETUP_MODE(Arg1, 0) 11 | c_mode = 0 12 | c_invt = 1 13 | d_mode = 0 14 | d_invt = 0 15 | 16 | A_OK, B_OK 17 | (Arg0 + Arg1) * 1 + 0 = Arg0 + Arg1 18 | A_INVERT, B_OK 19 | (1_Arg0 + Arg1) * 1 + 0 = 1_Arg0 + Arg1 20 | A_INVERT, B_INVERT 21 | (1_Arg0 + 1_Arg1) * 1 + 0 = 1_Arg0 + 1_Arg1 22 | A_OK, B_INVERT 23 | (Arg0 + 1_Arg1) * 1 + 0 = Arg0 + 1_Arg1 24 | -------------------------------------------------------------------------------- /doc/texenv/napalm/MODULATE: -------------------------------------------------------------------------------- 1 | Arg0 * Arg1 2 | 3 | ( Arg0 + 0) * Arg1 + 0 4 | [(1 - Arg0) + 0] * Arg1 + 0 5 | ( Arg0 + 0) * (1 - Arg1) + 0 6 | [(1 - Arg0) + 0] * (1 - Arg1) + 0 7 | 8 | invert = 0 9 | a_mode = TEXENV_SETUP_MODE(Arg0, 0) 10 | b_mode = 0 11 | c_mode = x 12 | c_invt = TEXENV_OPERAND_INVERTED(Arg1) 13 | d_mode = 0 14 | d_invt = 0 15 | 16 | A_OK, B_OK 17 | (Arg0 + 0) * Arg1 + 0 = Arg0 * Arg1 18 | A_INVERT, B_OK 19 | (1_Arg0 + 0) * Arg1 + 0 = 1_Arg0 * Arg1 20 | A_INVERT, B_INVERT 21 | (1_Arg0 + 0) * 1_Arg1 + 0 = 1_Arg0 * 1_Arg1 22 | A_OK, B_INVERT 23 | (Arg0 + 0) * 1_Arg1 + 0 = Arg0 * 1_Arg1 24 | -------------------------------------------------------------------------------- /drivers/foo/drv_setup.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "main/context.h" 5 | #include "tnl/tnl.h" 6 | #include "driver.h" 7 | #include "drv.h" 8 | 9 | 10 | void 11 | drv_setupTexture (void) 12 | { 13 | } 14 | 15 | 16 | void 17 | drv_setupBlend (void) 18 | { 19 | } 20 | 21 | 22 | void 23 | drv_setupDepth (void) 24 | { 25 | } 26 | 27 | 28 | void 29 | drv_setupAlpha (void) 30 | { 31 | } 32 | 33 | 34 | void 35 | drv_setupColor (void) 36 | { 37 | } 38 | 39 | 40 | void 41 | drv_setupCull (void) 42 | { 43 | } 44 | 45 | 46 | void 47 | drv_setupFog (void) 48 | { 49 | } 50 | 51 | 52 | void 53 | drv_setupScissor (void) 54 | { 55 | } 56 | 57 | 58 | void 59 | drv_setupStencil (void) 60 | { 61 | } 62 | -------------------------------------------------------------------------------- /main/texdef.h: -------------------------------------------------------------------------------- 1 | #ifndef TEXDEF_H_included 2 | #define TEXDEF_H_included 3 | 4 | extern const TEXDEF texdef_rgb_565[]; 5 | 6 | extern const TEXDEF texdef_bgra_4444_rev[]; 7 | 8 | extern const TEXDEF texdef_l_ubyte[]; 9 | 10 | extern const TEXDEF texdef_a_ubyte[]; 11 | 12 | extern const TEXDEF texdef_i_ubyte[]; 13 | 14 | extern const TEXDEF texdef_la_ubyte[]; 15 | 16 | extern const TEXDEF texdef_bgra_1555_rev[]; 17 | 18 | extern const TEXDEF texdef_bgra_8888_rev[]; 19 | 20 | extern const TEXDEF texdef_bgr1_8888_rev[]; 21 | 22 | extern const TEXDEF texdef_rgb_fxt1[]; 23 | 24 | extern const TEXDEF texdef_rgba_fxt1[]; 25 | 26 | extern const TEXDEF texdef_rgb_dxt1[]; 27 | 28 | extern const TEXDEF texdef_rgba_dxt1[]; 29 | 30 | extern const TEXDEF texdef_rgba_dxt3[]; 31 | 32 | extern const TEXDEF texdef_rgba_dxt5[]; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /drivers/foo/drv_cb.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "GL/gl.h" 4 | 5 | #include "glinternal.h" 6 | #include "main/context.h" 7 | #include "tnl/tnl.h" 8 | #include "driver.h" 9 | #include "drv.h" 10 | 11 | 12 | void 13 | drv_Clear (GLbitfield mask) 14 | { 15 | } 16 | 17 | 18 | void 19 | drv_ClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) 20 | { 21 | } 22 | 23 | 24 | void 25 | drv_ClearDepth (GLclampd depth) 26 | { 27 | } 28 | 29 | 30 | const char * 31 | drv_GetString (int name) 32 | { 33 | if (name == GL_RENDERER) { 34 | return "SAGE foo"; 35 | } 36 | return NULL; 37 | } 38 | 39 | 40 | void 41 | drv_DrawBuffer (GLenum mode) 42 | { 43 | } 44 | 45 | 46 | void 47 | drv_ReadPixels (GLint x, GLint y, 48 | GLsizei width, GLsizei height, 49 | GLenum format, GLenum type, 50 | GLvoid *pixels) 51 | { 52 | } 53 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/tmu.txt: -------------------------------------------------------------------------------- 1 | unit = 0 tmu = 0 tmu0_source = 0 N/A 2 | tmu1_source = 1 3 | 4 | OpenGL[tmu0_source] active, Glide[0] active 5 | we have to send [tmu0_source] data to Glide[0] 6 | 7 | tmu = 1 tmu0_source = 1 switch 8 | tmu1_source = 0 9 | 10 | OpenGL[tmu1_source] active, Glide[1] active 11 | we have to send [tmu1_source] data to Glide[1] 12 | or we can send [tmu0_source:=tmu1_source] data to Glide[0] in passthrough mode 13 | 14 | 15 | unit = 1 tmu = 1 tmu0_source = 0 switch 16 | tmu1_source = 1 17 | 18 | OpenGL[tmu1_source] active, Glide[1] active 19 | we have to send [tmu1_source] data to Glide[1] 20 | or we can send [tmu0_source:=tmu1_source] data to Glide[0] in passthrough mode 21 | 22 | tmu = 0 tmu0_source = 1 N/A 23 | tmu1_source = 0 24 | 25 | OpenGL[tmu0_source] active, Glide[0] active 26 | we have to send [tmu0_source] data to Glide[0] 27 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/DECAL_MODULATE: -------------------------------------------------------------------------------- 1 | DECAL -> MODULATE 2 | 3 | RGB/ALPHA C1 f * A0 4 | RGB/LUMINANCE C1 * C0 f 5 | RGB/LUMINANCE_ALPHA C1 * C0 f * A0 6 | RGB/INTENSITY C1 * C0 f * A0 7 | RGB/RGB C1 * C0 f 8 | RGB/RGBA C1 * C0 f * A0 9 | RGBA/ALPHA f * (1 - A1) + C1 * A1 f * A0 10 | RGBA/LUMINANCE (f * (1 - A1) + C1 * A1) * C0 f 11 | RGBA/LUMINANCE_ALPHA (f * (1 - A1) + C1 * A1) * C0 f * A0 12 | RGBA/INTENSITY (f * (1 - A1) + C1 * A1) * C0 f * A0 13 | RGBA/RGB (f * (1 - A1) + C1 * A1) * C0 f 14 | RGBA/RGBA (f * (1 - A1) + C1 * A1) * C0 f * A0 15 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/MODULATE_DECAL: -------------------------------------------------------------------------------- 1 | MODULATE -> DECAL 2 | 3 | ALPHA/RGB C0 f * A1 4 | ALPHA/RGBA f * (1 - A0) + C0 * A0 f * A1 5 | LUMINANCE/RGB C0 f 6 | LUMINANCE/RGBA f * C1 * (1 - A0) + C0 * A0 f 7 | LUMINANCE_ALPHA/RGB C0 f * A1 8 | LUMINANCE_ALPHA/RGBA f * C1 * (1 - A0) + C0 * A0 f * A1 9 | INTENSITY/RGB C0 f * A1 10 | INTENSITY/RGBA f * C1 * (1 - A0) + C0 * A0 f * A1 11 | RGB/RGB C0 f 12 | RGB/RGBA f * C1 * (1 - A0) + C0 * A0 f 13 | RGBA/RGB C0 f * A1 14 | RGBA/RGBA f * C1 * (1 - A0) + C0 * A0 f * A1 15 | -------------------------------------------------------------------------------- /doc/tools/defi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Generate enum.c from GL/gl.h 4 | # 5 | 6 | IFILE="gl.h" 7 | 8 | for i in $*; do 9 | TMP=${i#-I}/GL/gl.h 10 | if [ -f $TMP ]; then 11 | IFILE=$TMP 12 | break 13 | fi 14 | done 15 | 16 | if [ ! -f $IFILE ]; then 17 | echo "Cannot find $IFILE" 18 | exit -1 19 | fi 20 | 21 | cat < 23 | 24 | #include "GL/gl.h" 25 | 26 | 27 | static const struct { 28 | GLenum e; 29 | const char *n; 30 | } enum_tab[] = { 31 | EOF 32 | 33 | awk '/define GL_/ {print " { " $2 ", \"" $2 "\" },"}' $IFILE | grep -v included | sed '$ s/},/}/' 34 | 35 | cat <x 5 | 6 | 7 | #define ENTRY_NR(z, x, y, w, k) \ 8 | z GLAPIENTRY imm_##x y; 9 | #define ENTRY_RV(z, x, y, w, k) \ 10 | z GLAPIENTRY imm_##x y; 11 | #include "glapit.h" 12 | #undef ENTRY_NR 13 | #undef ENTRY_RV 14 | 15 | #define ENTRY_NR(z, x, y, w, k) \ 16 | z GLAPIENTRY sav_##x y; 17 | #define ENTRY_RV(z, x, y, w, k) \ 18 | z GLAPIENTRY sav_##x y; 19 | #include "glapit.h" 20 | #undef ENTRY_NR 21 | #undef ENTRY_RV 22 | 23 | 24 | typedef struct { 25 | #define ENTRY_NR(z, x, y, w, k) \ 26 | z (GLAPIENTRY *x) y; 27 | #define ENTRY_RV(z, x, y, w, k) \ 28 | z (GLAPIENTRY *x) y; 29 | #include "glapit.h" 30 | #undef ENTRY_NR 31 | #undef ENTRY_RV 32 | } GLAPITABLE; 33 | 34 | 35 | extern GLAPITABLE *ctx_gl_table; 36 | extern GLAPITABLE ctx_imm_table; 37 | 38 | 39 | void gl_switch_nop (void); 40 | void gl_switch_imm (void); 41 | void gl_switch_sav (void); 42 | void gl_init (void); 43 | void gl_fini (void); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /tnl/template/reflect.h: -------------------------------------------------------------------------------- 1 | /* reflection vector 2 | * r = u - 2 * n * n~ * u 3 | * 4 | * x nx*nx nx*ny nx*nz x 5 | * r = y - 2 * ny*nx ny*ny ny*nz * y 6 | * z nz*nx nz*ny nz*nz z 7 | * 8 | * x nx*nx*x + nx*ny*y + nx*nz*z 9 | * r = y - 2 * ny*nx*x + ny*ny*y + ny*nz*z 10 | * z nz*nx*x + nz*ny*y + nz*nz*z 11 | * 12 | * x - nx * 2.0F * (nx*x + ny*y + nz*z) 13 | * r = y - ny * 2.0F * (nx*x + ny*y + nz*z) 14 | * z - nz * 2.0F * (nx*x + ny*y + nz*z) 15 | */ 16 | void 17 | TAG(tnl_reflect) (void) 18 | { 19 | int i; 20 | 21 | for (i = 0; i < tnl_vb.len; i++) { 22 | GLfloat dp = 2.0F * DOT3(tnl_vb.neye[i], tnl_vb.veyn[i]); 23 | 24 | tnl_vb.refl[i][0] = tnl_vb.veyn[i][0] - tnl_vb.neye[i][0] * dp; 25 | tnl_vb.refl[i][1] = tnl_vb.veyn[i][1] - tnl_vb.neye[i][1] * dp; 26 | tnl_vb.refl[i][2] = tnl_vb.veyn[i][2] - tnl_vb.neye[i][2] * dp + 1.0F; 27 | #if (IND & D_NEED_MVEC) 28 | tnl_vb.refl[i][3] = 0.5F / SQRT(SQLEN3(tnl_vb.refl[i])); 29 | #endif 30 | } 31 | } 32 | 33 | 34 | #undef TAG 35 | #undef IND 36 | -------------------------------------------------------------------------------- /doc/prim.txt: -------------------------------------------------------------------------------- 1 | primitive 2 | | 3 | unclipped +-------------------+-------------------+ clipped 4 | | | 5 | drv_prim_tab tnl_prim_tab 6 | | | 7 | direct +-------+-------+ mixed drv_point 8 | | | drv_line 9 | fv_prim_tab mv_prim_tab drv_triangle <----------+ 10 | | | drv_quad | 11 | v drv_point drv_clippedPolygon | 12 | 1 drv_line | | 13 | drv_triangle direct +-------+-------+ mixed | 14 | drv_quad | | | 15 | | full_point full_point | 16 | full_point full_line mix_line* | 17 | mix_line* full_triangle mix_triangle* | 18 | mix_triangle* full_quad mix_quad* | 19 | mix_quad* full_clippedPolygon mix_clippedPolygon 20 | | | | | 21 | v | v v 22 | DRV_POINT | DRV_POINT DRV_POINT 23 | DRV_LINE | DRV_LINE DRV_LINE 24 | DRV_TRIANGLE | DRV_TRIANGLE DRV_TRIANGLE 25 | DRV_QUAD | DRV_QUAD DRV_QUAD 26 | | +-------+ | 27 | v v v 28 | 2 3 4 29 | -------------------------------------------------------------------------------- /x86/x86.h: -------------------------------------------------------------------------------- 1 | #ifndef X86_H_included 2 | #define X86_H_included 3 | 4 | #ifdef FAST_MATH 5 | #define DEFAULT_X86_FPU 0x037f /* exc masked, extdbl prec, nearest */ 6 | #define FAST_X86_FPU 0x003f /* exc masked, single prec, nearest */ 7 | 8 | #ifdef __GNUC__ 9 | #define START_FAST_MATH(x) \ 10 | do { \ 11 | static GLuint mask = FAST_X86_FPU; \ 12 | __asm__("fnstcw %0" : "=m" (*&(x))); \ 13 | __asm__("fldcw %0" : : "m" (mask)); \ 14 | } while (0) 15 | #define END_FAST_MATH(x) \ 16 | do { \ 17 | __asm__("fnclex ; fldcw %0" : : "m" (*&(x))); \ 18 | } while (0) 19 | #else /* !__GNUC__ */ 20 | #define START_FAST_MATH(x) (void)(x) 21 | #define END_FAST_MATH(x) (void)(x) 22 | #warning FAST_MATH disabled for this compiler 23 | #endif /* !__GNUC__ */ 24 | #else /* !FAST_MATH */ 25 | #define START_FAST_MATH(x) (void)(x) 26 | #define END_FAST_MATH(x) (void)(x) 27 | #endif /* !FAST_MATH */ 28 | 29 | extern int x86_cpu_bits; 30 | extern char x86_cpu_name[]; 31 | 32 | extern int x86_enable_sse; 33 | extern int x86_enable_3dnow; 34 | 35 | int x86_init (void); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /main/stencil.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "glapi.h" 5 | #include "context.h" 6 | 7 | 8 | void GLAPIENTRY 9 | imm_StencilFunc (GLenum func, GLint ref, GLuint mask) 10 | { 11 | if (ref < 0) { 12 | ref = 0; 13 | } else if ((GLuint)ref > ctx_stencilmaxi) { 14 | ref = ctx_stencilmaxi; 15 | } 16 | 17 | FLUSH_VERTICES(); 18 | 19 | ctx_stencil.func = func; 20 | ctx_stencil.ref = ref; 21 | ctx_stencil.valMask = mask & ctx_stencilmaxi; 22 | 23 | ctx_gl_state |= NEW_STENCIL; 24 | } 25 | 26 | 27 | void GLAPIENTRY 28 | imm_StencilMask (GLuint mask) 29 | { 30 | FLUSH_VERTICES(); 31 | 32 | ctx_stencil.writeMask = mask & ctx_stencilmaxi; 33 | 34 | ctx_gl_state |= NEW_STENCIL; 35 | } 36 | 37 | 38 | void GLAPIENTRY 39 | imm_StencilOp (GLenum fail, GLenum zfail, GLenum zpass) 40 | { 41 | FLUSH_VERTICES(); 42 | 43 | ctx_stencil.fail = fail; 44 | ctx_stencil.zfail = zfail; 45 | ctx_stencil.zpass = zpass; 46 | 47 | ctx_gl_state |= NEW_STENCIL; 48 | } 49 | 50 | 51 | void GLAPIENTRY 52 | imm_ClearStencil (GLint s) 53 | { 54 | ctx_stencil.clear = s & ctx_stencilmaxi; 55 | } 56 | -------------------------------------------------------------------------------- /tnl/template/texgen.h: -------------------------------------------------------------------------------- 1 | static void 2 | TAG(_tnl_texgen) (int unit) 3 | { 4 | int i; 5 | 6 | GLfloat4 *output = tnl_vb.texgen[unit]; 7 | GLfloat4 *texcoord = tnl_vb.attr[unit + TNL_TEXCOORD0].data; 8 | const GLuint texcoord_stride = tnl_vb.attr[unit + TNL_TEXCOORD0].stride; 9 | for (i = 0; i < tnl_vb.len; i++) { 10 | #if (IND & TNL_GEN_S_BIT) 11 | output[0][0] = _tnl_gen_tab_0[ctx_texture[unit].genmode[0]](unit, i); 12 | #else 13 | output[0][0] = texcoord[0][0]; 14 | #endif 15 | #if (IND & TNL_GEN_T_BIT) 16 | output[0][1] = _tnl_gen_tab_1[ctx_texture[unit].genmode[1]](unit, i); 17 | #else 18 | output[0][1] = texcoord[0][1]; 19 | #endif 20 | #if (IND & TNL_GEN_R_BIT) 21 | output[0][2] = _tnl_gen_tab_2[ctx_texture[unit].genmode[2]](unit, i); 22 | #else 23 | output[0][2] = texcoord[0][2]; 24 | #endif 25 | #if (IND & TNL_GEN_Q_BIT) 26 | output[0][3] = _tnl_gen_tab_3[ctx_texture[unit].genmode[3]](unit, i); 27 | #else 28 | output[0][3] = texcoord[0][3]; 29 | #endif 30 | output++; 31 | texcoord += texcoord_stride; 32 | } 33 | } 34 | 35 | 36 | static void 37 | TAG(_tnl_texgen_init) (void) 38 | { 39 | tnl_texgen_tab[IND] = TAG(_tnl_texgen); 40 | } 41 | 42 | 43 | #undef TAG 44 | #undef IND 45 | -------------------------------------------------------------------------------- /doc/texenv/napalm/SUBTRACT_ARB: -------------------------------------------------------------------------------- 1 | Arg0 - Arg1 2 | 3 | ( Arg0 + -Arg1) * 1 + 0 4 | [(1 - Arg0) + -Arg1] * 1 + 0 5 | 1 - {[ Arg0 + (1 - Arg1)] * 1 + 0} 6 | 1 - {[(1 - Arg0) + (1 - Arg1)] * 1 + 0} 7 | 8 | invert = TEXENV_OPERAND_INVERTED(Arg1) 9 | a_mode = TEXENV_SETUP_MODE(Arg0, invert) 10 | b_mode = invert ? (1 - x) : (-x) 11 | c_mode = 0 12 | c_invt = 1 13 | d_mode = 0 14 | d_invt = 0 15 | 16 | A_OK, B_OK 17 | ( Arg0 + _Arg1) * 1 + 0 = Arg0 - Arg1 18 | A_INVERT, B_OK 19 | [(1_Arg0) + _Arg1] * 1 + 0 = 1_Arg0 - Arg1 20 | A_INVERT, B_INVERT 21 | 1 - {[ Arg0 + (1_Arg1)] * 1 + 0} = 1_Arg0 - 1_Arg1 22 | A_OK, B_INVERT 23 | 1 - {[(1_Arg0) + (1_Arg1)] * 1 + 0} = Arg0 - 1_Arg1 24 | 25 | B_OK 26 | invert = 0 27 | a_mode = TEXENV_SETUP_MODE(Arg0, invert) 28 | b_mode = -x 29 | c_mode = 0 30 | c_invt = 1 31 | d_mode = 0 32 | d_invt = 0 33 | A_INVERT, B_INVERT 34 | invert = 0 35 | a_mode = -x 36 | b_mode = x 37 | c_mode = 0 38 | c_invt = 1 39 | d_mode = 0 40 | d_invt = 0 41 | A_OK, B_INVERT 42 | invert = 0 43 | a_mode = x - 0.5 44 | b_mode = x - 0.5 45 | c_mode = 0 46 | c_invt = 1 47 | d_mode = 0 48 | d_invt = 0 49 | -------------------------------------------------------------------------------- /drivers/foo/opengl.rc: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | 4 | #define PRODNAME "SAGE 0.9" 5 | #define CONTACTSTR "http://www.geocities.com/dborca/" 6 | #define HWSTR "any" 7 | #define COPYRIGHTSTR "Copyright \251 Daniel Borca" 8 | 9 | #define VERSIONSTR "0.9.0.1" 10 | #define MANVERSION 0 11 | #define MANREVISION 9 12 | #define BUILD_NUMBER 1 13 | 14 | VS_VERSION_INFO VERSIONINFO 15 | FILEVERSION MANVERSION, MANREVISION, 0, BUILD_NUMBER 16 | PRODUCTVERSION MANVERSION, MANREVISION, 0, BUILD_NUMBER 17 | FILEFLAGSMASK 0x0030003FL 18 | 19 | FILEOS VOS_DOS_WINDOWS32 20 | FILETYPE VFT_DRV 21 | FILESUBTYPE VFT2_DRV_INSTALLABLE 22 | BEGIN 23 | BLOCK "StringFileInfo" 24 | BEGIN 25 | BLOCK "040904E4" 26 | BEGIN 27 | VALUE "FileDescription", PRODNAME 28 | VALUE "FileVersion", VERSIONSTR 29 | VALUE "LegalCopyright", COPYRIGHTSTR 30 | VALUE "ProductName", PRODNAME 31 | VALUE "Graphics Subsystem", HWSTR 32 | VALUE "Contact", CONTACTSTR 33 | END 34 | END 35 | BLOCK "VarFileInfo" 36 | BEGIN 37 | /* the following line should be extended for localized versions */ 38 | VALUE "Translation", 0x409, 1252 39 | END 40 | END 41 | -------------------------------------------------------------------------------- /drivers/glide/opengl.rc: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | 4 | #define PRODNAME "SAGE 0.9" 5 | #define CONTACTSTR "http://www.geocities.com/dborca/" 6 | #define HWSTR "3dfx Voodoo" 7 | #define COPYRIGHTSTR "Copyright \251 Daniel Borca" 8 | 9 | #define VERSIONSTR "0.9.0.4" 10 | #define MANVERSION 0 11 | #define MANREVISION 9 12 | #define BUILD_NUMBER 4 13 | 14 | VS_VERSION_INFO VERSIONINFO 15 | FILEVERSION MANVERSION, MANREVISION, 0, BUILD_NUMBER 16 | PRODUCTVERSION MANVERSION, MANREVISION, 0, BUILD_NUMBER 17 | FILEFLAGSMASK 0x0030003FL 18 | 19 | FILEOS VOS_DOS_WINDOWS32 20 | FILETYPE VFT_DRV 21 | FILESUBTYPE VFT2_DRV_INSTALLABLE 22 | BEGIN 23 | BLOCK "StringFileInfo" 24 | BEGIN 25 | BLOCK "040904E4" 26 | BEGIN 27 | VALUE "FileDescription", PRODNAME 28 | VALUE "FileVersion", VERSIONSTR 29 | VALUE "LegalCopyright", COPYRIGHTSTR 30 | VALUE "ProductName", PRODNAME 31 | VALUE "Graphics Subsystem", HWSTR 32 | VALUE "Contact", CONTACTSTR 33 | END 34 | END 35 | BLOCK "VarFileInfo" 36 | BEGIN 37 | /* the following line should be extended for localized versions */ 38 | VALUE "Translation", 0x409, 1252 39 | END 40 | END 41 | -------------------------------------------------------------------------------- /doc/texenv/napalm/ADD_SIGNED_ARB: -------------------------------------------------------------------------------- 1 | Arg0 + Arg1 - 0.5 2 | 3 | [ Arg0 + (Arg1 - 0.5)] * 1 + 0 4 | [(1 - Arg0) + (Arg1 - 0.5)] * 1 + 0 5 | 1 - {[ Arg0 + (Arg1 - 0.5)] * 1 + 0} 6 | 1 - {[(1 - Arg0) + (Arg1 - 0.5)] * 1 + 0} 7 | 8 | invert = TEXENV_OPERAND_INVERTED(Arg1) 9 | a_mode = TEXENV_SETUP_MODE(Arg0, invert) 10 | b_mode = x - 0.5 11 | c_mode = 0 12 | c_invt = 1 13 | d_mode = 0 14 | d_invt = 0 15 | 16 | A_OK, B_OK 17 | [(Arg0) + (Arg1 - 0.5)] * 1 + 0 = Arg0 + Arg1 - 0.5 18 | A_INVERT, B_OK 19 | [(1_Arg0) + (Arg1 - 0.5)] * 1 + 0 = 1_Arg0 + Arg1 - 0.5 20 | A_INVERT, B_INVERT 21 | 1 - {[(Arg0) + (Arg1 - 0.5)] * 1 + 0} = 1_Arg0 + 1_Arg1 - 0.5 22 | A_OK, B_INVERT 23 | 1 - {[(1_Arg0) + (Arg1 - 0.5)] * 1 + 0} = Arg0 + 1_Arg1 - 0.5 24 | 25 | B_OK 26 | invert = 0 27 | a_mode = TEXENV_SETUP_MODE(Arg0, 0) 28 | b_mode = x - 0.5 29 | c_mode = 0 30 | c_invt = 1 31 | d_mode = 0 32 | d_invt = 0 33 | A_INVERT, B_INVERT 34 | ??? 35 | A_OK, B_INVERT 36 | invert = 0 37 | a_mode = x - 0.5 38 | b_mode = 1 - x 39 | c_mode = 0 40 | c_invt = 1 41 | d_mode = 0 42 | d_invt = 0 43 | 44 | --- 45 | A_INVERT, B_INVERT 46 | (1 - Arg0) + (1 - Arg1) - 0.5 47 | 1.5 - Arg0 - Arg1 48 | 49 | 1 - Arg0 - Arg1 + 0.5 50 | 51 | [(Arg0) + (Arg1 - 0.5)] * -1 + (1 - 0) 52 | -------------------------------------------------------------------------------- /drivers/foo/drv_tex.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "main/context.h" 5 | #include "tnl/tnl.h" 6 | #include "driver.h" 7 | #include "drv.h" 8 | 9 | 10 | void 11 | drv_TexImage2D (TEX_OBJ *texObj, GLint level, GLint internalFormat, 12 | GLsizei width, GLsizei height, GLenum format, GLenum type, 13 | const GLvoid *pixels, const PACKING *unpack) 14 | { 15 | } 16 | 17 | 18 | void 19 | drv_TexSubImage2D (TEX_OBJ *texObj, GLint level, GLint xoffset, GLint yoffset, 20 | GLsizei width, GLsizei height, GLenum format, GLenum type, 21 | const GLvoid *pixels, const PACKING *unpack) 22 | { 23 | } 24 | 25 | 26 | void 27 | drv_CompressedTexImage2D (TEX_OBJ *texObj, GLint level, GLenum internalformat, 28 | GLsizei width, GLsizei height, GLsizei imageSize, 29 | const GLvoid *data) 30 | { 31 | } 32 | 33 | 34 | void 35 | drv_CompressedTexSubImage2D (TEX_OBJ *texObj, GLint level, 36 | GLint xoffset, GLint yoffset, 37 | GLsizei width, GLsizei height, 38 | GLenum format, GLsizei imageSize, 39 | const GLvoid *data) 40 | { 41 | } 42 | 43 | 44 | void 45 | drv_GetTexImage (TEX_OBJ *texObj, GLint level, GLenum format, GLenum type, GLvoid *pixels) 46 | { 47 | } 48 | 49 | 50 | void 51 | drv_GetCompressedTexImage (TEX_OBJ *texObj, GLint lod, GLvoid *img) 52 | { 53 | } 54 | 55 | 56 | void 57 | drv_DeleteTexture (TEX_OBJ *texObj) 58 | { 59 | } 60 | -------------------------------------------------------------------------------- /main/dlist.h: -------------------------------------------------------------------------------- 1 | #ifndef DLIST_H_included 2 | #define DLIST_H_included 3 | 4 | typedef enum { 5 | OP_INVALID = -1, 6 | OP_CONTINUE, 7 | 8 | OP_BEGIN, 9 | OP_END, 10 | OP_VERTEX2F, 11 | OP_VERTEX3F, 12 | OP_VERTEX4F, 13 | OP_COLOR3F, 14 | OP_COLOR4F, 15 | OP_SECONDARYCOLOR3F, 16 | OP_NORMAL3F, 17 | OP_TEXCOORD1F, 18 | OP_TEXCOORD2F, 19 | OP_TEXCOORD3F, 20 | OP_TEXCOORD4F, 21 | OP_MULTITEXCOORD1F, 22 | OP_MULTITEXCOORD2F, 23 | OP_MULTITEXCOORD3F, 24 | OP_MULTITEXCOORD4F, 25 | OP_MATERIALF, /* kept as 1F */ 26 | OP_MATERIALFV, /* kept as 4F */ 27 | OP_FOGCOORDF, 28 | OP_EDGEFLAG, 29 | OP_RECTF, 30 | 31 | OP_PUSHMATRIX, 32 | OP_POPMATRIX, 33 | OP_TRANSLATEF, 34 | OP_ROTATEF, 35 | OP_SCALEF, 36 | OP_LOADIDENTITY, 37 | OP_MATRIXMODE, 38 | 39 | OP_ENABLE, 40 | OP_DISABLE, 41 | OP_FRONTFACE, 42 | OP_SHADEMODEL, 43 | OP_CULLFACE, 44 | 45 | OP_BLENDFUNC, 46 | OP_DEPTHMASK, 47 | OP_DEPTHFUNC, 48 | OP_ALPHAFUNC, 49 | 50 | OP_BINDTEX, 51 | OP_ACTIVETEX, 52 | OP_TEXENV, 53 | OP_TEXGEN, 54 | OP_TEXPARAM, 55 | 56 | OP_CALLLIST, 57 | 58 | OP_EOL 59 | } DL_OPCODE; 60 | 61 | typedef union { 62 | DL_OPCODE op; 63 | GLint i; 64 | GLfloat f; 65 | void *p; 66 | void *next; 67 | } DL_NODE; 68 | 69 | DL_NODE *dlist_new_operation (DL_OPCODE op); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Warning: this project halted about 9 years ago (in 2006) and I do not intend 2 | to ever bring it back. The name Sage was a tribute to the stillborn Sage 3 | geometrical processor intended to accompany the never-released 3dfx Rampage. 4 | 5 | This is an open-source implementation of the OpenGL specification, a system 6 | for rendering interactive 3D graphics. Its semblance to Mesa in design (and 7 | possibly some parts of code) is due to my involvement with Mesa at that time. 8 | 9 | I can't remember if it ever outperformed Mesa, as this project was primarily 10 | a sandbox for my experiments to overcome shortcomings of the then-already-aged 11 | 3dfx cards: npot/large/compressed textures, fake/skipping some tcl stages, 12 | unsupported blending modes, etc. 13 | 14 | So here you go, without any support: 15 | 16 | * This program is free software; you can redistribute it and/or modify 17 | * it under the terms of the GNU General Public License as published by 18 | * the Free Software Foundation; either version 2 of the License, or 19 | * (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program. If not, see . 28 | -------------------------------------------------------------------------------- /util/alloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Allocate aligned memory. 3 | * The aligned block MUST be freed with functions provided here. 4 | */ 5 | 6 | 7 | #include 8 | #include 9 | 10 | #include "alloc.h" 11 | 12 | 13 | void * 14 | malloc_a (size_t size, int p2align) 15 | { 16 | void *ptr, **block; 17 | size_t align = (1 << p2align) - 1; 18 | size_t len = size + sizeof(void *) + align; 19 | ptr = malloc(len); 20 | if (ptr == NULL) { 21 | return NULL; 22 | } 23 | block = (void **)(((long)ptr + sizeof(void *) + align) & ~align); 24 | #if 1 25 | assert((long)block - (long)ptr >= (long)sizeof(void *)); 26 | assert(((long)block + size) <= ((long)ptr + len)); 27 | assert(((long)block & align) == 0); 28 | #endif 29 | block[-1] = ptr; 30 | return block; 31 | } 32 | 33 | 34 | void * 35 | calloc_a (size_t size, int p2align) 36 | { 37 | void *ptr, **block; 38 | size_t align = (1 << p2align) - 1; 39 | size_t len = size + sizeof(void *) + align; 40 | ptr = calloc(1, len); 41 | if (ptr == NULL) { 42 | return NULL; 43 | } 44 | block = (void **)(((long)ptr + sizeof(void *) + align) & ~align); 45 | #if 1 46 | assert((long)block - (long)ptr >= (long)sizeof(void *)); 47 | assert(((long)block + size) <= ((long)ptr + len)); 48 | assert(((long)block & align) == 0); 49 | #endif 50 | block[-1] = ptr; 51 | return block; 52 | } 53 | 54 | 55 | void 56 | free_a (void *ptr) 57 | { 58 | if (ptr != NULL) { 59 | free(((void **)ptr)[-1]); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /doc/texenv/napalm/INTERPOLATE_ARB: -------------------------------------------------------------------------------- 1 | Arg0 * (Arg2) + Arg1 * (1-Arg2) = (Arg0 - Arg1) * Arg2 + Arg1 2 | 3 | ( Arg0 + -Arg1) * Arg2 + Arg1 4 | [(1 - Arg0) + -Arg1] * Arg2 + Arg1 5 | 1 - [( Arg0 + -Arg1) * Arg2 + Arg1] 6 | 1 - {[(1 - Arg0) + -Arg1] * Arg2 + Arg1} 7 | 8 | invert = TEXENV_OPERAND_INVERTED(Arg1) 9 | a_mode = TEXENV_SETUP_MODE(Arg0, invert) 10 | b_mode = -x 11 | c_mode = x 12 | c_invt = TEXENV_OPERAND_INVERTED(Arg2) 13 | d_mode = b 14 | d_invt = 0 15 | 16 | A_OK, B_OK 17 | [(Arg0) + -Arg1] * Arg2 + Arg1 = Arg0 * Arg2 + Arg1 * (1 - Arg2) 18 | A_INVERT, B_OK 19 | [(1 - Arg0) + -Arg1] * Arg2 + Arg1 = 1_Arg0 * Arg2 + Arg1 * (1 - Arg2) 20 | A_INVERT, B_INVERT 21 | 1 - [( Arg0 + -Arg1) * Arg2 + Arg1] = 1_Arg0 * Arg2 + 1_Arg1 * (1 - Arg2) 22 | A_OK, B_INVERT 23 | 1 - {[(1 - Arg0) + -Arg1] * Arg2 + Arg1} = Arg0 * Arg2 + 1_Arg1 * (1 - Arg2) 24 | 25 | B_OK 26 | invert = 0 27 | a_mode = TEXENV_SETUP_MODE(Arg0, 0) 28 | b_mode = -x 29 | c_mode = x 30 | c_invt = TEXENV_OPERAND_INVERTED(Arg2) 31 | d_mode = b 32 | d_invt = 0 33 | A_INVERT, B_INVERT 34 | invert = 0 35 | a_mode = -x 36 | b_mode = x 37 | c_mode = x 38 | c_invt = TEXENV_OPERAND_INVERTED(Arg2) 39 | d_mode = b 40 | d_invt = 1 41 | A_OK, B_INVERT 42 | ??? 43 | 44 | --- 45 | A_OK, B_INVERT 46 | Arg0 * (Arg2) + (1-Arg1) * (1-Arg2) = (Arg0 - (1-Arg1)) * Arg2 + 1-Arg1 47 | (Arg0 - (1-Arg1)) * Arg2 + 1-Arg1 48 | {(Arg0 + Arg1) * Arg2 + 1 - Arg1} - Arg2 49 | -------------------------------------------------------------------------------- /main/buffer.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "glapi.h" 5 | #include "context.h" 6 | #include "tnl/tnl.h" 7 | #include "driver.h" 8 | 9 | 10 | void GLAPIENTRY 11 | imm_Clear (GLbitfield mask) 12 | { 13 | if (!ctx_depth_mask) { 14 | mask &= ~GL_DEPTH_BUFFER_BIT; 15 | } 16 | if (!ctx_stencil.writeMask) { 17 | mask &= ~GL_STENCIL_BUFFER_BIT; 18 | } 19 | if (!mask) { 20 | return; 21 | } 22 | 23 | FLUSH_VERTICES(); 24 | 25 | drv_Clear(mask); 26 | } 27 | 28 | 29 | void GLAPIENTRY 30 | imm_Scissor (GLint x, GLint y, GLsizei width, GLsizei height) 31 | { 32 | FLUSH_VERTICES(); 33 | 34 | ctx_scissor_x1 = x; 35 | ctx_scissor_y1 = y; 36 | ctx_scissor_x2 = x + width; 37 | ctx_scissor_y2 = y + height; 38 | 39 | ctx_gl_state |= NEW_SCISSOR; 40 | } 41 | 42 | 43 | void GLAPIENTRY 44 | imm_ReadPixels (GLint x, GLint y, 45 | GLsizei width, GLsizei height, 46 | GLenum format, GLenum type, 47 | GLvoid *pixels) 48 | { 49 | FLUSH_VERTICES(); 50 | 51 | drv_ReadPixels(x, y, width, height, format, type, pixels); 52 | } 53 | 54 | 55 | void GLAPIENTRY 56 | imm_ReadBuffer (GLenum mode) 57 | { 58 | if (mode == GL_FRONT || mode == GL_LEFT) { 59 | mode = GL_FRONT_LEFT; 60 | } 61 | if (mode == GL_BACK) { 62 | mode = GL_BACK_LEFT; 63 | } 64 | if (mode == GL_RIGHT) { 65 | mode = GL_FRONT_RIGHT; 66 | } 67 | 68 | ctx_read_buffer = mode; 69 | /* XXX should probably have a callback here */ 70 | /* XXX should we keep the value here, or just pass it down to the driver? */ 71 | } 72 | -------------------------------------------------------------------------------- /main/matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef MATRIX_H_included 2 | #define MATRIX_H_included 3 | 4 | #define MATRIX_IDENTITY 0 5 | #define MATRIX_ROTATE (1<<0) 6 | #define MATRIX_SCALE (1<<1) 7 | #define MATRIX_TRANSLATE (1<<2) 8 | #define MATRIX_GENERAL (1<<3) 9 | 10 | 11 | #define MAT_IDENTITY(M) ((M)->type == MATRIX_IDENTITY) 12 | #define MAT_GENERAL(M) ((M)->type & MATRIX_GENERAL) 13 | 14 | 15 | #define MAX_MODELVIEW 32 16 | #define MAX_PROJECTION 8 17 | #define MAX_TEXTURE 8 18 | #define MAX_COLOR 2 19 | 20 | 21 | typedef struct { 22 | GLfloat mat[16]; 23 | GLbitfield type; 24 | } MATRIX; 25 | 26 | 27 | extern MATRIX ctx_mx_viewport; 28 | extern MATRIX *ctx_mx_modelview_top; 29 | extern MATRIX *ctx_mx_projection_top; 30 | extern MATRIX *ctx_mx_texture_top[MAX_TEXTURE_UNITS]; 31 | extern GLenum ctx_mx_mode; 32 | 33 | 34 | void matrix_init (void); 35 | 36 | void matrix_mul (GLfloat *dst, const GLfloat *a, const GLfloat *b); 37 | 38 | 39 | void matrix_mul_vec2 (GLfloat4 dst, const GLfloat *m, const GLfloat4 src); 40 | 41 | void matrix_transpose (GLfloat *transpose, const GLfloat *src); 42 | GLboolean matrix_invt (GLfloat *inv, const MATRIX *src); 43 | 44 | 45 | typedef void (*XFORM) (GLfloat4 dst, const GLfloat *m, const GLfloat4 src); 46 | typedef void (*XFORM_BATCH) (GLfloat4 dst[], const GLfloat *m, const GLfloat4 src[], int n); 47 | 48 | extern XFORM matrix_mul_vec4; 49 | extern XFORM_BATCH matrix_mul_vec4_batch; 50 | extern XFORM matrix_mul_vec3; 51 | extern XFORM_BATCH matrix_mul_vec3_batch; 52 | extern XFORM matrix_mul_vec_rot; 53 | 54 | 55 | const GLfloat *get_mvp (void); 56 | const GLfloat *get_imv (void); 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /tnl/template/normals.h: -------------------------------------------------------------------------------- 1 | /* The normals can be transformed in two ways: 2 | * 3 | * 1) [nx', ny', nz', q'] = [nx, ny, nz, q] * inv(M) 4 | * if w = 0 5 | * q = 0 6 | * else 7 | * q = -[nx, ny, nz] * t([x, y, z]) / w 8 | * 9 | * 2) [nx', ny', nz'] = [nx, ny, nz] * inv(up(M)) 10 | * where up(M) is upper 3x3 of matrix 11 | * 12 | * We are transforming with: 13 | * [nx', ny', nz'] = [nx, ny, nz] * up(inv(M)) 14 | */ 15 | static void 16 | TAG(_tnl_calc_neye) (void) 17 | { 18 | int i; 19 | GLbitfield mask; 20 | const GLfloat *imv = get_imv(); 21 | GLfloat4 *n = NULL; 22 | GLfloat4 *normal = tnl_vb.attr[TNL_NORMAL].data; 23 | const GLuint normal_stride = tnl_vb.attr[TNL_NORMAL].stride; 24 | #if (IND & NORM_RESCALE) 25 | const GLfloat f = 1.0F / SQRT(imv[8] * imv[8] + imv[9] * imv[9] + imv[10] * imv[10]); 26 | #endif 27 | 28 | for (mask = TNL_NORMAL_BIT, i = 0; i < tnl_vb.len; i++, mask = tnl_vb.flags[i]) { 29 | if (mask & TNL_NORMAL_BIT) { 30 | /* new normal, redo the transformation */ 31 | n = &tnl_vb.neye[i]; 32 | matrix_mul_vec_rot(n[0], imv, normal[0]); 33 | #if (IND & NORM_RESCALE) 34 | n[0][0] *= f; 35 | n[0][1] *= f; 36 | n[0][2] *= f; 37 | #endif 38 | #if (IND & NORM_NORMALIZE) 39 | NORM3(n[0], +, n[0]); 40 | #endif 41 | } else { 42 | tnl_vb.neye[i][0] = n[0][0]; 43 | tnl_vb.neye[i][1] = n[0][1]; 44 | tnl_vb.neye[i][2] = n[0][2]; 45 | } 46 | 47 | normal += normal_stride; 48 | } 49 | } 50 | 51 | 52 | static void 53 | TAG(_tnl_init_neye) (void) 54 | { 55 | tnl_calc_neye_tab[IND] = TAG(_tnl_calc_neye); 56 | } 57 | 58 | 59 | #undef TAG 60 | #undef IND 61 | -------------------------------------------------------------------------------- /doc/conform/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OpenGL testsuite 3 | * Version: 0.1 4 | * 5 | * Copyright (C) 2005 Daniel Borca All Rights Reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /* 27 | * Miscellaneous functions. 28 | */ 29 | 30 | 31 | #ifndef UTIL_H_included 32 | #define UTIL_H_included 33 | 34 | #define CASE_STRING(x) case x: return #x 35 | #define NODEFAULT default: assert(0) 36 | 37 | const char *blend_src_name (GLenum factor); 38 | const char *blend_dst_name (GLenum factor); 39 | const char *blend_eq_name (GLenum eq); 40 | 41 | const char *tex_env_name (GLenum e); 42 | const char *tex_fmt_name (GLenum t); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /x86/cpusoft.asm: -------------------------------------------------------------------------------- 1 | %include "xos.inc" 2 | 3 | %include "x86.inc" 4 | 5 | 6 | segment TEXT 7 | 8 | 9 | align 16 10 | proc cpusoft 11 | push ebx 12 | push ebp 13 | ; Initialize 14 | xor ebp, ebp 15 | ; Check for CPUID instruction 16 | pushfd 17 | pop edx 18 | mov ecx, edx 19 | xor edx, 0x00200000 20 | push edx 21 | popfd 22 | pushfd 23 | pop edx 24 | push ecx 25 | popfd 26 | xor edx, ecx 27 | jz .done 28 | ; OK, we have CPUID 29 | mov ebp, _CPU_HAS_CPUID 30 | ; Try CPUID(0) to get signature and max standard level 31 | xor eax, eax 32 | cpuid 33 | test eax, eax 34 | jz .done 35 | ; Save signature 36 | mov eax, [esp + 12] 37 | test eax, eax 38 | jz .noSave 39 | mov [eax], ebx 40 | mov [eax + 4], edx 41 | mov [eax + 8], ecx 42 | mov byte [eax + 12], 0 43 | .noSave: 44 | ; Check if we have extended info 45 | cmp ebx, 'Auth' 46 | jne .noAMD 47 | cmp edx, 'enti' 48 | jne .noAMD 49 | cmp ecx, 'cAMD' 50 | jne .noAMD 51 | ; Query extended info 52 | mov eax, 0x80000000 53 | cpuid 54 | cmp eax, 0x80000001 55 | jb .noAMD 56 | mov eax, 0x80000001 57 | cpuid 58 | test edx, 0x80000000 59 | jz .no3DNow 60 | or ebp, _CPU_FEATURE_3DNOW 61 | .no3DNow: 62 | test edx, 0x40000000 63 | jz .no3DNowPlus 64 | or ebp, _CPU_FEATURE_3DNOWPLUS 65 | .no3DNowPlus: 66 | test edx, 0x00400000 67 | jz .noMMXPlus 68 | or ebp, _CPU_FEATURE_MMXPLUS 69 | .noMMXPlus: 70 | .noAMD: 71 | ; Query standard info 72 | mov eax, 1 73 | cpuid 74 | 75 | test edx, 0x00800000 76 | jz .noMMX 77 | or ebp, _CPU_FEATURE_MMX 78 | .noMMX: 79 | test edx, 0x02000000 80 | jz .noSSE 81 | or ebp, _CPU_FEATURE_SSE 82 | .noSSE: 83 | test edx, 0x04000000 84 | jz .noSSE2 85 | or ebp, _CPU_FEATURE_SSE2 86 | .noSSE2: 87 | .done: 88 | mov eax, ebp 89 | pop ebp 90 | pop ebx 91 | ret 92 | endp 93 | -------------------------------------------------------------------------------- /main/glapi.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glapi.h" 4 | 5 | 6 | #define ENTRY_NR(z, x, y, w, k) \ 7 | static z GLAPIENTRY nop_##x y \ 8 | { \ 9 | } 10 | #define ENTRY_RV(z, x, y, w, k) \ 11 | static z GLAPIENTRY nop_##x y \ 12 | { \ 13 | return 0; \ 14 | } 15 | #include "glapit.h" 16 | #undef ENTRY_NR 17 | #undef ENTRY_RV 18 | 19 | 20 | static GLAPITABLE ctx_nop_table = { 21 | #define ENTRY_NR(z, x, y, w, k) \ 22 | nop_##x, 23 | #define ENTRY_RV(z, x, y, w, k) \ 24 | nop_##x, 25 | #include "glapit.h" 26 | #undef ENTRY_NR 27 | #undef ENTRY_RV 28 | }; 29 | 30 | GLAPITABLE ctx_imm_table = { 31 | #define ENTRY_NR(z, x, y, w, k) \ 32 | imm_##x, 33 | #define ENTRY_RV(z, x, y, w, k) \ 34 | imm_##x, 35 | #include "glapit.h" 36 | #undef ENTRY_NR 37 | #undef ENTRY_RV 38 | }; 39 | 40 | static GLAPITABLE ctx_sav_table = { 41 | #define ENTRY_NR(z, x, y, w, k) \ 42 | sav_##x, 43 | #define ENTRY_RV(z, x, y, w, k) \ 44 | sav_##x, 45 | #include "glapit.h" 46 | #undef ENTRY_NR 47 | #undef ENTRY_RV 48 | }; 49 | 50 | GLAPITABLE *ctx_gl_table = &ctx_nop_table; 51 | 52 | 53 | void 54 | gl_switch_nop (void) 55 | { 56 | ctx_gl_table = &ctx_nop_table; 57 | } 58 | 59 | 60 | void 61 | gl_switch_imm (void) 62 | { 63 | ctx_gl_table = &ctx_imm_table; 64 | } 65 | 66 | 67 | void 68 | gl_switch_sav (void) 69 | { 70 | ctx_gl_table = &ctx_sav_table; 71 | } 72 | 73 | 74 | static void 75 | gl_init_imm (void) 76 | { 77 | /* XXX necessary? */ 78 | } 79 | 80 | 81 | static void 82 | gl_init_sav (void) 83 | { 84 | /* XXX necessary? */ 85 | } 86 | 87 | 88 | void 89 | gl_init (void) 90 | { 91 | gl_init_imm(); 92 | gl_init_sav(); 93 | gl_switch_imm(); 94 | } 95 | 96 | 97 | void 98 | gl_fini (void) 99 | { 100 | gl_switch_nop(); 101 | } 102 | -------------------------------------------------------------------------------- /main/legacy.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glapi.h" 4 | 5 | 6 | GLAPI void GLAPIENTRY 7 | glActiveTextureARB (GLenum texture) 8 | { 9 | GLCALL(ActiveTexture)(texture); 10 | } 11 | 12 | 13 | GLAPI void GLAPIENTRY 14 | glMultiTexCoord1fARB (GLenum texture, GLfloat s) 15 | { 16 | GLCALL(MultiTexCoord1f)(texture, s); 17 | } 18 | 19 | 20 | GLAPI void GLAPIENTRY 21 | glMultiTexCoord1fvARB (GLenum texture, const GLfloat *v) 22 | { 23 | GLCALL(MultiTexCoord1fv)(texture, v); 24 | } 25 | 26 | 27 | GLAPI void GLAPIENTRY 28 | glMultiTexCoord2fARB (GLenum texture, GLfloat s, GLfloat t) 29 | { 30 | GLCALL(MultiTexCoord2f)(texture, s, t); 31 | } 32 | 33 | 34 | GLAPI void GLAPIENTRY 35 | glMultiTexCoord2fvARB (GLenum texture, const GLfloat *v) 36 | { 37 | GLCALL(MultiTexCoord2fv)(texture, v); 38 | } 39 | 40 | 41 | GLAPI void GLAPIENTRY 42 | glMultiTexCoord3fARB (GLenum texture, GLfloat s, GLfloat t, GLfloat r) 43 | { 44 | GLCALL(MultiTexCoord3f)(texture, s, t, r); 45 | } 46 | 47 | 48 | GLAPI void GLAPIENTRY 49 | glMultiTexCoord3fvARB (GLenum texture, const GLfloat *v) 50 | { 51 | GLCALL(MultiTexCoord3fv)(texture, v); 52 | } 53 | 54 | 55 | GLAPI void GLAPIENTRY 56 | glMultiTexCoord4fARB (GLenum texture, GLfloat s, GLfloat t, GLfloat r, GLfloat q) 57 | { 58 | GLCALL(MultiTexCoord4f)(texture, s, t, r, q); 59 | } 60 | 61 | 62 | GLAPI void GLAPIENTRY 63 | glMultiTexCoord4fvARB (GLenum texture, const GLfloat *v) 64 | { 65 | GLCALL(MultiTexCoord4fv)(texture, v); 66 | } 67 | 68 | 69 | GLAPI void GLAPIENTRY 70 | glClientActiveTextureARB (GLenum texture) 71 | { 72 | GLCALL(ClientActiveTexture)(texture); 73 | } 74 | 75 | 76 | GLAPI void GLAPIENTRY 77 | glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, 78 | GLenum sfactorAlpha, GLenum dfactorAlpha) 79 | { 80 | GLCALL(BlendFuncSeparate)(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); 81 | } 82 | -------------------------------------------------------------------------------- /doc/conform/extgl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OpenGL testsuite 3 | * Version: 0.1 4 | * 5 | * Copyright (C) 2005 Daniel Borca All Rights Reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /* 27 | * Extension wrappers. 28 | */ 29 | 30 | 31 | #ifndef EXTGL_H_included 32 | #define EXTGL_H_included 33 | 34 | GLAPI void GLAPIENTRY myBlendColorEXT (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); 35 | GLAPI void GLAPIENTRY myBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); 36 | GLAPI void GLAPIENTRY myBlendEquationEXT (GLenum mode); 37 | GLAPI void GLAPIENTRY myBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); 38 | GLAPI void GLAPIENTRY myActiveTextureARB (GLenum texture); 39 | GLAPI void GLAPIENTRY myMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /doc/conform/texenv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OpenGL testsuite 3 | * Version: 0.1 4 | * 5 | * Copyright (C) 2005 Daniel Borca All Rights Reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /* 27 | * Test OpenGL texture environment. This demo uses 28 | * destination alpha 29 | * GL_ARB_texture_env_add 30 | * GL_ARB_multitexture 31 | * 32 | * In order to test output ALPHA without ALPHABUFFER, 33 | * we blend with GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA 34 | * over a known color. But we must have BLEND test ok! 35 | */ 36 | 37 | 38 | #ifndef TEXENV_H_included 39 | #define TEXENV_H_included 40 | 41 | DrawProc texenvInit (void); 42 | 43 | extern GLboolean 44 | texEval (GLint stride, GLfloat *previous, GLfloat envcolor[], 45 | GLfloat *texture, GLenum type, GLenum e, GLint size, 46 | GLfloat *eval); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /doc/conform/Makefile.mgw: -------------------------------------------------------------------------------- 1 | # OpenGL testsuite 2 | # Version: 0.1 3 | # 4 | # Copyright (C) 2005 Daniel Borca All Rights Reserved. 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a 7 | # copy of this software and associated documentation files (the "Software"), 8 | # to deal in the Software without restriction, including without limitation 9 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | # and/or sell copies of the Software, and to permit persons to whom the 11 | # Software is furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included 14 | # in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | # DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | 24 | # DJGPP Makefile 25 | 26 | 27 | .PHONY: all clean realclean 28 | 29 | CC = mingw32-gcc 30 | CFLAGS = -Wall -W -pedantic 31 | CFLAGS += -O2 -ffast-math 32 | CFLAGS += -I. -I../include 33 | LD = $(CC) 34 | LDFLAGS = -s 35 | LDFLAGS = -L../lib 36 | LDLIBS = -lglut32 -lglu32 -lopengl32 -lglide3x 37 | RM = del 38 | 39 | CORE_SOURCES = \ 40 | base.c \ 41 | util.c \ 42 | extgl.c 43 | 44 | TEST_SOURCES = \ 45 | blend.c \ 46 | texenv.c 47 | 48 | SOURCES = $(CORE_SOURCES) $(TEST_SOURCES) 49 | 50 | OBJECTS = $(SOURCES:.c=.o) 51 | 52 | .c.o: 53 | $(CC) -o $@ $(CFLAGS) -c $< 54 | 55 | all: testgl.exe 56 | 57 | testgl.exe: $(OBJECTS) 58 | $(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS) 59 | 60 | clean: 61 | $(RM) *.o 62 | 63 | realclean: clean 64 | $(RM) testgl.exe 65 | -------------------------------------------------------------------------------- /doc/apps.txt: -------------------------------------------------------------------------------- 1 | 1) I've Found Her: Danger and Opportunity Demo Version 1.0 2 | - needs MAX_TEXTURE_SIZE >= 512 (preferably 1024) 3 | - Aaaaaarrrgggh! Fatal exception in CWorld::mfShowOrtho! 4 | 2) NeverWinter Nights Demo 5 | - needs dxtn.dll? 6 | - needs stencil? 7 | 3) Call of Duty Burnville Demo 8 | - needs MAX_TEXTURE_SIZE >= 512 9 | - needs GL_ARB_texture_compression and GL_EXT_texture_compression_s3tc 10 | - needs dxtn.dll 11 | 4) BloodRayne Demo 12 | - needs tweaked trigl.dll and heavy changes in wgl.c 13 | 5) Unreal Tournament 2003 DEMO 14 | - needs some TexCombine modes not available on Voodoo2 15 | 6) Unreal Tournament 2004 DEMO 16 | - needs some TexCombine modes not available on Voodoo2 17 | 7) Vulpine GLmark v1.1p 18 | - some lighting problems 19 | 8) Doom3 1.0.1262 20 | - some serious artifacts 21 | - needs heavy changes in wgl.c 22 | 9) SWKotor2 23 | - needs dxtn.dll 24 | - needs stencil? 25 | - needs alpha? 26 | - needs NV_register_combiner? 27 | 10) Savage - The Battle for Newerth DEMO 28 | - needs OpenGL 1.2 29 | 11) Savage - The Battle for Newerth DEMO 2.0 30 | - needs OpenGL 1.2 31 | 12) Homeworld2 Demo Version 1.0 32 | - needs OpenGL 1.2 33 | 13) Hitman 2: Silent Assassin Demo 34 | 14) Medal of Honor Allied Assault(tm) Demo Version 1.0 35 | 15) Oni Demo 1.0 36 | 16) Return to Castle Wolfenstein Single Player Demo 37 | 17) Serious Sam: The First Encounter Demo Release 1.00 38 | 18) Serious Sam: The Second Encounter DEMO Release 1.05 39 | 19) Star Wars(r) Jedi Knight(r) II: Jedi Outcast(tm) Demo Version 1.0 40 | 20) Star Wars(TM) Jedi Knight(TM): Jedi Academy(TM) Demo Version 1.0 41 | 21) Warcraft III 42 | 22) glQuake 1.30 43 | 23) Quake II 3.20 44 | 24) Quake III Arena Point Release 1.32 45 | 25) UnrealTournament 46 | 26) Wolfenstein: Enemy Territory 1.02 Update 47 | 27) wTorcs 1.2.2 48 | 28) FooBillard Version 3.0 Win32 Release 1 49 | 29) GL-Excess v1.2v 50 | 30) DroneZMark 51 | 31) The OpenGL Geometry Benchmark 52 | 32) Minidemo by Neoztar 53 | 33) GLViewer 54 | -------------------------------------------------------------------------------- /drivers/glide/config: -------------------------------------------------------------------------------- 1 | .INTERMEDIATE: drivers/$(DRIVER)/x86/drvgen.exe glide3x.dxe 2 | 3 | GLIDESDK ?= g3sdk 4 | 5 | CFLAGS += -I$(GLIDESDK)/include 6 | LDFLAGS += -L$(GLIDESDK)/lib 7 | LDLIBS += -lglide3x 8 | ASFLAGS += -Idrivers/$(DRIVER)/x86/ 9 | 10 | DRIVER_SOURCES += \ 11 | drivers/$(DRIVER)/drv_api.c \ 12 | drivers/$(DRIVER)/drv_cb.c \ 13 | drivers/$(DRIVER)/drv_setup.c \ 14 | drivers/$(DRIVER)/drv_tex.c \ 15 | drivers/$(DRIVER)/drv_texman.c \ 16 | drivers/$(DRIVER)/drv_tri.c \ 17 | drivers/$(DRIVER)/drv_vb.c 18 | 19 | ifeq ($(X86),1) 20 | DRIVER_SOURCES += \ 21 | drivers/$(DRIVER)/x86/k3d_emit.asm \ 22 | drivers/$(DRIVER)/x86/sse_emit.asm 23 | 24 | drivers/$(DRIVER)/drv_api.o: drivers/$(DRIVER)/drvchk.h 25 | endif 26 | 27 | drivers/$(DRIVER)/x86/k3d_emit.o: drivers/$(DRIVER)/x86/k3d_emit.asm drivers/$(DRIVER)/x86/k3d_vbtmp.asm drivers/$(DRIVER)/x86/drv.inc 28 | $(AS) -o $@ $(ASFLAGS) $< 29 | 30 | drivers/$(DRIVER)/x86/sse_emit.o: drivers/$(DRIVER)/x86/sse_emit.asm drivers/$(DRIVER)/x86/sse_vbtmp.asm drivers/$(DRIVER)/x86/drv.inc 31 | $(AS) -o $@ $(ASFLAGS) $< 32 | 33 | drivers/$(DRIVER)/x86/drv.inc: drivers/$(DRIVER)/x86/drvgen.exe 34 | $< -o $@ 35 | drivers/$(DRIVER)/drvchk.h: drivers/$(DRIVER)/x86/drvgen.exe 36 | $< -c -o $@ 37 | 38 | drivers/$(DRIVER)/x86/drvgen.exe: drivers/$(DRIVER)/x86/drvgen.c glinternal.h main/context.h drivers/$(DRIVER)/drv.h 39 | $(HOST_CC) -o $@ $(CFLAGS) $< 40 | 41 | # dxe3gen needs glide3x.dxe when generating the import lib libigl.a. 42 | # so we generate a dummy glide3x.dxe to cover common glide3x exports 43 | # and all possible libc dependencies: 44 | lib/gl.dxe: glide3x.dxe 45 | drivers/$(DRIVER)/glide3x_dxe.o: drivers/$(DRIVER)/glide3x_dxe.c 46 | $(CC) -O0 -Wall -o $@ -c $< 47 | glide3x.dxe: drivers/$(DRIVER)/glide3x_dxe.o 48 | -$(DXE3GEN) -o glide3x.dxe -E _gr -E _gu -U $< 49 | 50 | clean:: 51 | -$(RM) drivers/$(DRIVER)/x86/k3d_emit.o 52 | -$(RM) drivers/$(DRIVER)/x86/sse_emit.o 53 | -$(RM) drivers/$(DRIVER)/glide3x_dxe.o 54 | -$(RM) drivers/$(DRIVER)/drvchk.h 55 | -$(RM) drivers/$(DRIVER)/x86/drv.inc 56 | 57 | -------------------------------------------------------------------------------- /main/alias.h: -------------------------------------------------------------------------------- 1 | ALIAS(ActiveTexture, ARB) 2 | ALIAS(BlendFuncSeparate, EXT) 3 | ALIAS(ClientActiveTexture, ARB) 4 | ALIAS(CompressedTexImage1D, ARB) 5 | ALIAS(CompressedTexImage2D, ARB) 6 | ALIAS(CompressedTexImage3D, ARB) 7 | ALIAS(CompressedTexSubImage1D, ARB) 8 | ALIAS(CompressedTexSubImage2D, ARB) 9 | ALIAS(CompressedTexSubImage3D, ARB) 10 | ALIAS(DrawRangeElements, EXT) 11 | ALIAS(FogCoordPointer, EXT) 12 | ALIAS(FogCoordf, EXT) 13 | ALIAS(GetCompressedTexImage, ARB) 14 | ALIAS(MultiTexCoord1d, ARB) 15 | ALIAS(MultiTexCoord1dv, ARB) 16 | ALIAS(MultiTexCoord1f, ARB) 17 | ALIAS(MultiTexCoord1fv, ARB) 18 | ALIAS(MultiTexCoord1i, ARB) 19 | ALIAS(MultiTexCoord1iv, ARB) 20 | ALIAS(MultiTexCoord1s, ARB) 21 | ALIAS(MultiTexCoord1sv, ARB) 22 | ALIAS(MultiTexCoord2d, ARB) 23 | ALIAS(MultiTexCoord2dv, ARB) 24 | ALIAS(MultiTexCoord2f, ARB) 25 | ALIAS(MultiTexCoord2fv, ARB) 26 | ALIAS(MultiTexCoord2i, ARB) 27 | ALIAS(MultiTexCoord2iv, ARB) 28 | ALIAS(MultiTexCoord2s, ARB) 29 | ALIAS(MultiTexCoord2sv, ARB) 30 | ALIAS(MultiTexCoord3d, ARB) 31 | ALIAS(MultiTexCoord3dv, ARB) 32 | ALIAS(MultiTexCoord3f, ARB) 33 | ALIAS(MultiTexCoord3fv, ARB) 34 | ALIAS(MultiTexCoord3i, ARB) 35 | ALIAS(MultiTexCoord3iv, ARB) 36 | ALIAS(MultiTexCoord3s, ARB) 37 | ALIAS(MultiTexCoord3sv, ARB) 38 | ALIAS(MultiTexCoord4d, ARB) 39 | ALIAS(MultiTexCoord4dv, ARB) 40 | ALIAS(MultiTexCoord4f, ARB) 41 | ALIAS(MultiTexCoord4fv, ARB) 42 | ALIAS(MultiTexCoord4i, ARB) 43 | ALIAS(MultiTexCoord4iv, ARB) 44 | ALIAS(MultiTexCoord4s, ARB) 45 | ALIAS(MultiTexCoord4sv, ARB) 46 | ALIAS(SecondaryColor3b, EXT) 47 | ALIAS(SecondaryColor3bv, EXT) 48 | ALIAS(SecondaryColor3d, EXT) 49 | ALIAS(SecondaryColor3dv, EXT) 50 | ALIAS(SecondaryColor3f, EXT) 51 | ALIAS(SecondaryColor3fv, EXT) 52 | ALIAS(SecondaryColor3i, EXT) 53 | ALIAS(SecondaryColor3iv, EXT) 54 | ALIAS(SecondaryColor3s, EXT) 55 | ALIAS(SecondaryColor3sv, EXT) 56 | ALIAS(SecondaryColor3ub, EXT) 57 | ALIAS(SecondaryColor3ubv, EXT) 58 | ALIAS(SecondaryColor3ui, EXT) 59 | ALIAS(SecondaryColor3uiv, EXT) 60 | ALIAS(SecondaryColor3us, EXT) 61 | ALIAS(SecondaryColor3usv, EXT) 62 | ALIAS(SecondaryColorPointer, EXT) 63 | 64 | #undef ALIAS 65 | -------------------------------------------------------------------------------- /main/color.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "glapi.h" 5 | #include "context.h" 6 | #include "util/macros.h" 7 | #include "tnl/tnl.h" 8 | #include "driver.h" 9 | 10 | 11 | void GLAPIENTRY 12 | imm_ColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) 13 | { 14 | FLUSH_VERTICES(); 15 | 16 | ctx_color.color_mask_r = red; 17 | ctx_color.color_mask_g = green; 18 | ctx_color.color_mask_b = blue; 19 | ctx_color.color_mask_a = alpha; 20 | 21 | ctx_gl_state |= NEW_COLOR; 22 | } 23 | 24 | 25 | void GLAPIENTRY 26 | imm_AlphaFunc (GLenum func, GLclampf ref) 27 | { 28 | FLUSH_VERTICES(); 29 | 30 | ctx_color.alpha_func = func; 31 | ctx_color.alpha_ref = ref; 32 | 33 | ctx_gl_state |= NEW_ALPHA; 34 | } 35 | 36 | 37 | void GLAPIENTRY 38 | imm_BlendFunc (GLenum sfactor, GLenum dfactor) 39 | { 40 | FLUSH_VERTICES(); 41 | 42 | ctx_color.blend_src_rgb = 43 | ctx_color.blend_src_alpha = sfactor; 44 | 45 | ctx_color.blend_dst_rgb = 46 | ctx_color.blend_dst_alpha = dfactor; 47 | 48 | ctx_gl_state |= NEW_BLEND; 49 | } 50 | 51 | 52 | void GLAPIENTRY 53 | imm_BlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, 54 | GLenum sfactorAlpha, GLenum dfactorAlpha) 55 | { 56 | FLUSH_VERTICES(); 57 | 58 | ctx_color.blend_src_rgb = sfactorRGB; 59 | ctx_color.blend_src_alpha = sfactorAlpha; 60 | 61 | ctx_color.blend_dst_rgb = dfactorRGB; 62 | ctx_color.blend_dst_alpha = dfactorAlpha; 63 | 64 | ctx_gl_state |= NEW_BLEND; 65 | } 66 | 67 | 68 | void GLAPIENTRY 69 | imm_ClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) 70 | { 71 | ctx_color.clear_color[0] = CLAMPF(red); 72 | ctx_color.clear_color[1] = CLAMPF(green); 73 | ctx_color.clear_color[2] = CLAMPF(blue); 74 | ctx_color.clear_color[3] = CLAMPF(alpha); 75 | } 76 | 77 | 78 | void GLAPIENTRY 79 | imm_DrawBuffer (GLenum mode) 80 | { 81 | FLUSH_VERTICES(); 82 | 83 | ctx_color.draw_buffer = mode; 84 | 85 | /* XXX maybe not in immediate mode (batch with |= NEW_...)? */ 86 | drv_DrawBuffer(mode); 87 | } 88 | -------------------------------------------------------------------------------- /doc/conform/blend.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OpenGL testsuite 3 | * Version: 0.1 4 | * 5 | * Copyright (C) 2005 Daniel Borca All Rights Reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /* 27 | * Test OpenGL blending accuracy. This demo uses 28 | * destination alpha 29 | * GL_NV_blend_square 30 | * GL_EXT_blend_color 31 | * GL_EXT_blend_equation_separate 32 | * GL_EXT_blend_func_separate 33 | * GL_EXT_blend_minmax 34 | * GL_EXT_blend_subtract 35 | * for maximum number of combinations: 36 | * sfactor = 15 dfactor = 14 mode = 5 37 | * When all the above extensions are present, 38 | * we have 15 * 15 * 14 * 14 * 5 * 5 = 1,102,500 tries 39 | */ 40 | 41 | 42 | #ifndef BLEND_H_included 43 | #define BLEND_H_included 44 | 45 | DrawProc blendInit (void); 46 | 47 | extern void 48 | blendEval (GLfloat color0[], GLfloat color1[], GLfloat color2[], 49 | GLenum sfactorRGB, GLenum dfactorRGB, 50 | GLenum sfactorAlpha, GLenum dfactorAlpha, 51 | GLenum modeRGB, GLenum modeAlpha, 52 | GLfloat result[]); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /main/fog.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "GL/gl.h" 4 | 5 | #include "glinternal.h" 6 | #include "glapi.h" 7 | #include "context.h" 8 | #include "util/macros.h" 9 | 10 | 11 | void GLAPIENTRY 12 | imm_Fogfv (GLenum pname, const GLfloat *params) 13 | { 14 | FLUSH_VERTICES(); 15 | 16 | switch (pname) { 17 | case GL_FOG_MODE: 18 | ctx_fog.mode = params[0]; 19 | break; 20 | case GL_FOG_DENSITY: 21 | ctx_fog.density = params[0]; 22 | break; 23 | case GL_FOG_START: 24 | ctx_fog.start = params[0]; 25 | break; 26 | case GL_FOG_END: 27 | ctx_fog.end = params[0]; 28 | break; 29 | case GL_FOG_COORDINATE_SOURCE: 30 | ctx_fog.source = params[0]; 31 | break; 32 | case GL_FOG_COLOR: 33 | ctx_fog.color[0] = params[0]; 34 | ctx_fog.color[1] = params[1]; 35 | ctx_fog.color[2] = params[2]; 36 | ctx_fog.color[3] = params[3]; 37 | break; 38 | default: 39 | gl_assert(0); 40 | return; 41 | } 42 | 43 | ctx_gl_state |= NEW_FOG; 44 | } 45 | 46 | 47 | void GLAPIENTRY 48 | imm_Fogf (GLenum pname, GLfloat param) 49 | { 50 | imm_Fogfv(pname, ¶m); 51 | } 52 | 53 | 54 | /* variations */ 55 | 56 | 57 | void GLAPIENTRY 58 | imm_Fogiv (GLenum pname, const GLint *params) 59 | { 60 | FLUSH_VERTICES(); 61 | 62 | switch (pname) { 63 | case GL_FOG_MODE: 64 | ctx_fog.mode = params[0]; 65 | break; 66 | case GL_FOG_DENSITY: 67 | ctx_fog.density = params[0]; 68 | break; 69 | case GL_FOG_START: 70 | ctx_fog.start = params[0]; 71 | break; 72 | case GL_FOG_END: 73 | ctx_fog.end = params[0]; 74 | break; 75 | case GL_FOG_COORDINATE_SOURCE: 76 | ctx_fog.source = params[0]; 77 | break; 78 | case GL_FOG_COLOR: 79 | ctx_fog.color[0] = I_TO_FLOAT(params[0]); 80 | ctx_fog.color[1] = I_TO_FLOAT(params[1]); 81 | ctx_fog.color[2] = I_TO_FLOAT(params[2]); 82 | ctx_fog.color[3] = I_TO_FLOAT(params[3]); 83 | break; 84 | default: 85 | gl_assert(0); 86 | return; 87 | } 88 | 89 | ctx_gl_state |= NEW_FOG; 90 | } 91 | 92 | 93 | void GLAPIENTRY 94 | imm_Fogi (GLenum pname, GLint param) 95 | { 96 | imm_Fogiv(pname, ¶m); 97 | } 98 | -------------------------------------------------------------------------------- /doc/conform/base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OpenGL testsuite 3 | * Version: 0.1 4 | * 5 | * Copyright (C) 2005 Daniel Borca All Rights Reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /* 27 | * GLUT-based mini-framework. 28 | */ 29 | 30 | 31 | #ifndef BASE_H_included 32 | #define BASE_H_included 33 | 34 | #define MIN(x,y) (((x) < (y)) ? (x) : (y)) 35 | #define MAX(x,y) (((x) > (y)) ? (x) : (y)) 36 | #define MID(x,y,z) MAX((x), MIN((y), (z))) 37 | 38 | #define VERBOSE(n) if (verbose >= (n)) 39 | extern GLint verbose; 40 | 41 | extern GLuint WIDTH, HEIGHT; 42 | 43 | #define R_COMP 0/*(GL_RED - GL_RED)*/ 44 | #define G_COMP 1/*(GL_GREEN - GL_RED)*/ 45 | #define B_COMP 2/*(GL_BLUE - GL_RED)*/ 46 | #define A_COMP 3/*(GL_ALPHA - GL_RED)*/ 47 | extern GLint colorBits[4]; 48 | extern GLfloat epsZero, epsColor[4]; 49 | 50 | extern GLuint flatTri; 51 | 52 | void readPixel (GLfloat color[], GLint x, GLint y); 53 | void readPixels (GLfloat *buff, GLint x, GLint y, GLuint width, GLuint height); 54 | void pickColor (GLfloat color[]); 55 | 56 | typedef GLboolean (*DrawProc) (void); 57 | typedef DrawProc (*InitProc) (void); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /g3sdk/lib/glide3x.def: -------------------------------------------------------------------------------- 1 | LIBRARY glide3x.dll 2 | EXPORTS 3 | grAADrawTriangle@24 4 | grAlphaBlendFunction@16 5 | grAlphaCombine@20 6 | grAlphaControlsITRGBLighting@4 7 | grAlphaTestFunction@4 8 | grAlphaTestReferenceValue@4 9 | grBufferClear@12 10 | grBufferSwap@4 11 | grCheckForRoom@4 12 | grChromakeyMode@4 13 | grChromakeyValue@4 14 | grClipWindow@16 15 | grColorCombine@20 16 | grColorMask@8 17 | grConstantColorValue@4 18 | grCoordinateSpace@4 19 | grCullMode@4 20 | grDepthBiasLevel@4 21 | grDepthBufferFunction@4 22 | grDepthBufferMode@4 23 | grDepthMask@4 24 | grDepthRange@8 25 | grDisable@4 26 | grDisableAllEffects@0 27 | grDitherMode@4 28 | grDrawLine@8 29 | grDrawPoint@4 30 | grDrawTriangle@12 31 | grDrawVertexArray@12 32 | grDrawVertexArrayContiguous@16 33 | grEnable@4 34 | grErrorSetCallback@4 35 | grFinish@0 36 | grFlush@0 37 | grFogColorValue@4 38 | grFogMode@4 39 | grFogTable@4 40 | grGet@12 41 | grGetProcAddress@4 42 | grGetString@4 43 | grGlideGetState@4 44 | grGlideGetVertexLayout@4 45 | grGlideInit@0 46 | grGlideSetState@4 47 | grGlideSetVertexLayout@4 48 | grGlideShutdown@0 49 | grLfbConstantAlpha@4 50 | grLfbConstantDepth@4 51 | grLfbLock@24 52 | grLfbReadRegion@28 53 | grLfbUnlock@8 54 | grLfbWriteColorFormat@4 55 | grLfbWriteColorSwizzle@8 56 | grLfbWriteRegion@36 57 | grLoadGammaTable@16 58 | grQueryResolutions@8 59 | grRenderBuffer@4 60 | grReset@4 61 | grSelectContext@4 62 | grSetNumPendingBuffers@4 63 | grSplash@20 64 | grSstConfigPipeline@12 65 | grSstOrigin@4 66 | grSstSelect@4 67 | grSstVidMode@8 68 | grSstWinClose@4 69 | grSstWinOpen@28 70 | grTexCalcMemRequired@16 71 | grTexClampMode@12 72 | grTexCombine@28 73 | grTexDetailControl@16 74 | grTexDownloadMipMap@16 75 | grTexDownloadMipMapLevel@32 76 | grTexDownloadMipMapLevelPartial@40 77 | grTexDownloadTable@8 78 | grTexDownloadTablePartial@16 79 | grTexFilterMode@12 80 | grTexLodBiasValue@8 81 | grTexMaxAddress@4 82 | grTexMinAddress@4 83 | grTexMipMapMode@12 84 | grTexMultibase@8 85 | grTexMultibaseAddress@20 86 | grTexNCCTable@4 87 | grTexSource@16 88 | grTexTextureMemRequired@8 89 | grVertexLayout@12 90 | grViewport@16 91 | gu3dfGetInfo@8 92 | gu3dfLoad@8 93 | guEncodeRLE16@16 94 | guFogGenerateExp2@8 95 | guFogGenerateExp@8 96 | guFogGenerateLinear@12 97 | guFogTableIndexToW@4 98 | guGammaCorrectionRGB@12 99 | -------------------------------------------------------------------------------- /doc/tools/glapit.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Generate glapit.h from api.h 4 | # 5 | 6 | 7 | sub makeGLAPItable 8 | { 9 | my ( $infile, $outfile ) = @_; 10 | open API, $infile or die "ERROR: cannot open $infile\n"; 11 | @data = ; 12 | close API; 13 | open GLAPIT, "> $outfile" or die "ERROR: cannot open $outfile\n"; 14 | foreach $line (@data) { 15 | # $line = [const GLubyte *glGetString (GLenum name);\n] 16 | # $line = [void glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer);\n] 17 | $line =~ m/[a-zA-Z \*]+gl/; 18 | # $& = [const GLubyte *gl] 19 | # $& = [void gl] 20 | if (substr($&, -3) eq " gl") { 21 | $rv = substr($&, 0, -3); 22 | } else { 23 | $rv = substr($&, 0, -2); 24 | } 25 | # $rv = [const GLubyte *] 26 | # $rv = [void] 27 | if ($rv eq "void") { 28 | print GLAPIT "ENTRY_NR"; 29 | } else { 30 | print GLAPIT "ENTRY_RV"; 31 | } 32 | # $' = [GetString (GLenum name);\n] 33 | # $' = [InterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer);\n] 34 | $tmp = $'; 35 | $tmp =~ m/[a-zA-Z0-9]+/; 36 | # $& = [GetString] 37 | # $& = [InterleavedArrays] 38 | $name = $&; 39 | # $' = [ (GLenum name);\n] 40 | # $' = [ (GLenum format, GLsizei stride, const GLvoid *pointer);\n] 41 | $para = $'; 42 | $para =~ s/;/\n/; 43 | chomp($para); 44 | chomp($para); 45 | # $para = [ (GLenum name)] 46 | # $para = [ (GLenum format, GLsizei stride, const GLvoid *pointer)] 47 | $para =~ m/\(/; 48 | # $' = [GLenum name)] 49 | # $' = [GLenum format, GLsizei stride, const GLvoid *pointer)] 50 | print GLAPIT "($rv, $name, ($', ("; 51 | $tmp = $'; 52 | $tmp =~ s/\)/,/; 53 | # $tmp = [GLenum name,] 54 | # $tmp = [GLenum format, GLsizei stride, const GLvoid *pointer,] 55 | $l = 0; 56 | while ($tmp =~ m/[a-zA-Z_0-9]+,/g) { 57 | $type = $`; 58 | if ($l != 0) { 59 | print GLAPIT ", "; 60 | } 61 | $p = substr($&, 0, -1); 62 | if ($p ne "void") { 63 | if ($type =~ m/\*/) { 64 | $l = $l + 4; 65 | } elsif ($type =~ m/GLdouble/) { 66 | $l = $l + 8; 67 | } elsif ($type =~ m/GLclampd/) { 68 | $l = $l + 8; 69 | } else { 70 | $l = $l + 4; 71 | } 72 | print GLAPIT "$p"; 73 | } 74 | } 75 | print GLAPIT "), $l)\n"; 76 | } 77 | close GLAPIT; 78 | } 79 | 80 | &makeGLAPItable("api.h", "glapit.h"); 81 | -------------------------------------------------------------------------------- /x86/k3d_clip.asm: -------------------------------------------------------------------------------- 1 | %include "xos.inc" 2 | 3 | %include "x86.inc" 4 | 5 | 6 | extrn tnl_vb 7 | extrn tnl_prim 8 | extrn tnl_prim_num 9 | extrn x86_clip_lut 10 | 11 | 12 | segment TEXT 13 | 14 | 15 | align 16 16 | proc k3d_clipmask 17 | push ebx 18 | push esi 19 | push edi 20 | push ebp 21 | mov ebx, [tnl_vb + TNL_VB_CLIPMASK] 22 | mov ecx, [tnl_prim_num] 23 | mov esi, [tnl_vb + TNL_VB_CLIP] 24 | mov edi, [tnl_prim] 25 | mov ebp, [tnl_vb + TNL_VB_NDC] 26 | test ecx, ecx 27 | jz .done 28 | align 16 29 | .k_loop: 30 | push ecx 31 | push edi 32 | mov edi, [edi + PRIM_COUNT] 33 | xor eax, eax 34 | test edi, edi 35 | jz .next_k 36 | align 16 37 | .j_loop: 38 | movd mm0, [esi + 12] 39 | pfrcp mm1, mm0 40 | push ebp 41 | 42 | xor ecx, ecx ; ecx = < > 43 | mov ebp, [esi + 12] ; ebp = w 44 | add ebp, ebp ; ebp = 2*|w|, carry = (w < 0) 45 | adc ecx, ecx ; ecx = < q> 46 | mov edx, [esi + 8] ; edx = z 47 | add edx, edx ; edx = 2*|z|, carry = (z < 0) 48 | adc ecx, ecx ; ecx = < qf> 49 | cmp ebp, edx ; carry = 2*|w| < 2*|z| 50 | adc ecx, ecx ; ecx = < qfe> 51 | mov edx, [esi + 4] ; edx = y 52 | add edx, edx ; edx = 2*|y|, carry = (y < 0) 53 | adc ecx, ecx ; ecx = < qfed> 54 | cmp ebp, edx ; carry = 2*|w| < 2*|y| 55 | adc ecx, ecx ; ecx = < qfedc> 56 | mov edx, [esi] ; edx = x 57 | add edx, edx ; edx = 2*|x|, carry = (x < 0) 58 | adc ecx, ecx ; ecx = < qfedcb> 59 | cmp ebp, edx ; carry = 2*|w| < 2*|x| 60 | adc ecx, ecx ; ecx = 61 | mov cl, [x86_clip_lut + ecx] 62 | 63 | pop ebp 64 | punpckldq mm0, mm0 65 | mov [ebx], cl 66 | or eax, ecx 67 | test ecx, ecx 68 | jnz .next_j 69 | pfrcpit1 mm0, mm1 70 | movq mm3, [esi + 8] 71 | pfrcpit2 mm0, mm1 72 | movq mm2, [esi] 73 | pfmul mm3, mm0 74 | pfmul mm2, mm0 75 | punpckldq mm3, mm0 76 | movq [ebp], mm2 77 | movq [ebp + 8], mm3 78 | align 16 79 | .next_j: 80 | add esi, 16 81 | add ebp, 16 82 | inc ebx 83 | dec edi 84 | jnz .j_loop 85 | align 16 86 | .next_k: 87 | pop edi 88 | pop ecx 89 | mov [edi + PRIM_ORMASK], eax 90 | add edi, sizeof_TNL_PRIMITIVE 91 | dec ecx 92 | jnz .k_loop 93 | femms 94 | align 16 95 | .done: 96 | pop ebp 97 | pop edi 98 | pop esi 99 | pop ebx 100 | ret 101 | endp 102 | -------------------------------------------------------------------------------- /drivers/glide/wgl_tab.c: -------------------------------------------------------------------------------- 1 | /* YYY SWKotOR2 */ 2 | /* YYY Homeworld2 */ 3 | /* YYY Bloodrayne */ 4 | { "glTexImage3D", (PROC)glTexImage3D }, 5 | { "glTexSubImage3D", (PROC)glTexSubImage3D }, 6 | { "glCombinerInputNV", (PROC)g_CombinerInputNV }, 7 | { "glCombinerOutputNV", (PROC)g_CombinerOutputNV }, 8 | { "glCombinerParameterfNV", (PROC)g_CombinerParameterfNV }, 9 | { "glCombinerParameterfvNV", (PROC)g_CombinerParameterfvNV }, 10 | { "glCombinerParameteriNV", (PROC)g_CombinerParameteriNV }, 11 | { "glCombinerParameterivNV", (PROC)g_CombinerParameterivNV }, 12 | { "glCombinerStageParameterfvNV", (PROC)g_CombinerStageParameterfvNV }, 13 | { "glFinalCombinerInputNV", (PROC)g_FinalCombinerInputNV }, 14 | { "glGetCombinerInputParameterfvNV", (PROC)g_GetCombinerInputParameterfvNV }, 15 | { "glGetCombinerInputParameterivNV", (PROC)g_GetCombinerInputParameterivNV }, 16 | { "glGetCombinerOutputParameterfvNV", (PROC)g_GetCombinerOutputParameterfvNV }, 17 | { "glGetCombinerOutputParameterivNV", (PROC)g_GetCombinerOutputParameterivNV }, 18 | { "glGetCombinerStageParameterfvNV", (PROC)g_GetCombinerStageParameterfvNV }, 19 | { "glGetFinalCombinerInputParameterfvNV", (PROC)g_GetFinalCombinerInputParameterfvNV }, 20 | { "glGetFinalCombinerInputParameterivNV", (PROC)g_GetFinalCombinerInputParameterivNV }, 21 | { "wglGetPixelFormatAttribivARB", (PROC)wg_GetPixelFormatAttribivARB }, 22 | { "wglGetPixelFormatAttribfvARB", (PROC)wg_GetPixelFormatAttribfvARB }, 23 | { "wglChoosePixelFormatARB", (PROC)wg_ChoosePixelFormatARB }, 24 | { "wglBindTexImageARB", (PROC)wg_BindTexImageARB }, 25 | { "wglReleaseTexImageARB", (PROC)wg_ReleaseTexImageARB }, 26 | { "wglSetPbufferAttribARB", (PROC)wg_SetPbufferAttribARB }, 27 | { "wglCreatePbufferARB", (PROC)wg_CreatePbufferARB }, 28 | { "wglGetPbufferDCARB", (PROC)wg_GetPbufferDCARB }, 29 | { "wglReleasePbufferDCARB", (PROC)wg_ReleasePbufferDCARB }, 30 | { "wglDestroyPbufferARB", (PROC)wg_DestroyPbufferARB }, 31 | { "wglQueryPbufferARB", (PROC)wg_QueryPbufferARB }, 32 | -------------------------------------------------------------------------------- /main/cull.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "glapi.h" 5 | #include "context.h" 6 | #include "matrix.h" 7 | 8 | 9 | void GLAPIENTRY 10 | imm_CullFace (GLenum mode) 11 | { 12 | FLUSH_VERTICES(); 13 | 14 | ctx_cull_face = mode; 15 | 16 | ctx_gl_state |= NEW_CULL; 17 | } 18 | 19 | 20 | void GLAPIENTRY 21 | imm_FrontFace (GLenum mode) 22 | { 23 | FLUSH_VERTICES(); 24 | 25 | ctx_front_face = mode; 26 | 27 | ctx_gl_state |= NEW_CULL; 28 | } 29 | 30 | 31 | void GLAPIENTRY 32 | imm_PolygonMode (GLenum face, GLenum mode) 33 | { 34 | FLUSH_VERTICES(); 35 | 36 | /* face: GL_FRONT, GL_BACK, GL_FRONT_AND_BACK */ 37 | /* mode: GL_FILL, GL_LINE, GL_POINT */ 38 | if (face != GL_BACK) { /* front */ 39 | switch (mode) { 40 | case GL_FILL: 41 | ctx_polygon_mode[0] = POLYGON_FILL; 42 | break; 43 | case GL_LINE: 44 | ctx_polygon_mode[0] = POLYGON_LINE; 45 | break; 46 | case GL_POINT: 47 | ctx_polygon_mode[0] = POLYGON_POINT; 48 | break; 49 | } 50 | } 51 | if (face != GL_FRONT) { /* back */ 52 | switch (mode) { 53 | case GL_FILL: 54 | ctx_polygon_mode[1] = POLYGON_FILL; 55 | break; 56 | case GL_LINE: 57 | ctx_polygon_mode[1] = POLYGON_LINE; 58 | break; 59 | case GL_POINT: 60 | ctx_polygon_mode[1] = POLYGON_POINT; 61 | break; 62 | } 63 | } 64 | } 65 | 66 | 67 | void GLAPIENTRY 68 | imm_ClipPlane (GLenum plane, const GLdouble *equation) 69 | { 70 | GLfloat4 tmp; 71 | 72 | FLUSH_VERTICES(); 73 | 74 | tmp[0] = equation[0]; 75 | tmp[1] = equation[1]; 76 | tmp[2] = equation[2]; 77 | tmp[3] = equation[3]; 78 | matrix_mul_vec4(ctx_userplanes[0][plane - GL_CLIP_PLANE0], get_imv(), tmp); 79 | 80 | ctx_gl_state |= NEW_USERCLIP; 81 | } 82 | 83 | 84 | void GLAPIENTRY 85 | imm_PolygonOffset (GLfloat factor, GLfloat units) 86 | { 87 | FLUSH_VERTICES(); 88 | 89 | ctx_polygon_offset_factor = factor; 90 | ctx_polygon_offset_bias = units * ctx_const_depth_resolution; 91 | ctx_gl_state |= 0; /* XXX GULP!?! */ 92 | } 93 | 94 | 95 | void GLAPIENTRY 96 | imm_PolygonOffsetEXT (GLfloat factor, GLfloat bias) 97 | { 98 | FLUSH_VERTICES(); 99 | 100 | ctx_polygon_offset_factor = factor; 101 | ctx_polygon_offset_bias = bias; 102 | ctx_gl_state |= 0; /* XXX GULP!?! */ 103 | } 104 | -------------------------------------------------------------------------------- /main/pixel.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "context.h" 5 | 6 | 7 | void GLAPIENTRY 8 | imm_PixelStoref (GLenum pname, GLfloat param) 9 | { 10 | switch (pname) { 11 | case GL_UNPACK_SWAP_BYTES: 12 | ctx_unpack.swap_bytes = param; 13 | break; 14 | case GL_UNPACK_LSB_FIRST: 15 | ctx_unpack.lsb_first = param; 16 | break; 17 | case GL_UNPACK_ROW_LENGTH: 18 | ctx_unpack.row_length = param; 19 | break; 20 | case GL_UNPACK_SKIP_ROWS: 21 | ctx_unpack.skip_rows = param; 22 | break; 23 | case GL_UNPACK_SKIP_PIXELS: 24 | ctx_unpack.skip_pixels = param; 25 | break; 26 | case GL_UNPACK_ALIGNMENT: 27 | ctx_unpack.alignment = param; 28 | break; 29 | case GL_PACK_SWAP_BYTES: 30 | ctx_pack.swap_bytes = param; 31 | break; 32 | case GL_PACK_LSB_FIRST: 33 | ctx_pack.lsb_first = param; 34 | break; 35 | case GL_PACK_ROW_LENGTH: 36 | ctx_pack.row_length = param; 37 | break; 38 | case GL_PACK_SKIP_ROWS: 39 | ctx_pack.skip_rows = param; 40 | break; 41 | case GL_PACK_SKIP_PIXELS: 42 | ctx_pack.skip_pixels = param; 43 | break; 44 | case GL_PACK_ALIGNMENT: 45 | ctx_pack.alignment = param; 46 | break; 47 | } 48 | } 49 | 50 | 51 | /* variations */ 52 | 53 | 54 | void GLAPIENTRY 55 | imm_PixelStorei (GLenum pname, GLint param) 56 | { 57 | switch (pname) { 58 | case GL_UNPACK_SWAP_BYTES: 59 | ctx_unpack.swap_bytes = param; 60 | break; 61 | case GL_UNPACK_LSB_FIRST: 62 | ctx_unpack.lsb_first = param; 63 | break; 64 | case GL_UNPACK_ROW_LENGTH: 65 | ctx_unpack.row_length = param; 66 | break; 67 | case GL_UNPACK_SKIP_ROWS: 68 | ctx_unpack.skip_rows = param; 69 | break; 70 | case GL_UNPACK_SKIP_PIXELS: 71 | ctx_unpack.skip_pixels = param; 72 | break; 73 | case GL_UNPACK_ALIGNMENT: 74 | ctx_unpack.alignment = param; 75 | break; 76 | case GL_PACK_SWAP_BYTES: 77 | ctx_pack.swap_bytes = param; 78 | break; 79 | case GL_PACK_LSB_FIRST: 80 | ctx_pack.lsb_first = param; 81 | break; 82 | case GL_PACK_ROW_LENGTH: 83 | ctx_pack.row_length = param; 84 | break; 85 | case GL_PACK_SKIP_ROWS: 86 | ctx_pack.skip_rows = param; 87 | break; 88 | case GL_PACK_SKIP_PIXELS: 89 | ctx_pack.skip_pixels = param; 90 | break; 91 | case GL_PACK_ALIGNMENT: 92 | ctx_pack.alignment = param; 93 | break; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /tnl/sav_api.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "main/glapi.h" 5 | #include "util/macros.h" 6 | #include "main/dlist.h" 7 | #include "tnl.h" 8 | 9 | 10 | void GLAPIENTRY 11 | sav_Begin (GLenum mode) 12 | { 13 | DL_NODE *node = dlist_new_operation(OP_BEGIN); 14 | (node + 1)->i = mode | TNL_PRIM_WEAK; 15 | } 16 | 17 | 18 | void GLAPIENTRY 19 | sav_End (void) 20 | { 21 | DL_NODE *node = dlist_new_operation(OP_END); 22 | } 23 | 24 | 25 | void GLAPIENTRY 26 | sav_Finish (void) 27 | { 28 | /* block until all GL execution is complete */ 29 | imm_Finish(); 30 | } 31 | 32 | 33 | void GLAPIENTRY 34 | sav_Flush (void) 35 | { 36 | /* force execution of GL commands in finite time */ 37 | imm_Flush(); 38 | } 39 | 40 | 41 | #define RECT_F(x1, y1, x2, y2) \ 42 | do { \ 43 | DL_NODE *node = dlist_new_operation(OP_RECTF); \ 44 | (node + 1)->f = x1; \ 45 | (node + 2)->f = y1; \ 46 | (node + 3)->f = x2; \ 47 | (node + 4)->f = y2; \ 48 | } while (0) 49 | 50 | 51 | void GLAPIENTRY 52 | sav_Rectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) 53 | { 54 | RECT_F(x1, y1, x2, y2); 55 | } 56 | 57 | 58 | void GLAPIENTRY 59 | sav_Rectfv (const GLfloat *v1, const GLfloat *v2) 60 | { 61 | RECT_F(v1[0], v1[1], v2[0], v2[1]); 62 | } 63 | 64 | 65 | /* variations */ 66 | 67 | 68 | void GLAPIENTRY 69 | sav_Rectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) 70 | { 71 | RECT_F(x1, y1, x2, y2); 72 | } 73 | 74 | 75 | void GLAPIENTRY 76 | sav_Rectdv (const GLdouble *v1, const GLdouble *v2) 77 | { 78 | RECT_F(v1[0], v1[1], v2[0], v2[1]); 79 | } 80 | 81 | 82 | void GLAPIENTRY 83 | sav_Recti (GLint x1, GLint y1, GLint x2, GLint y2) 84 | { 85 | RECT_F(I_TO_FLOAT(x1), I_TO_FLOAT(y1), I_TO_FLOAT(x2), I_TO_FLOAT(y2)); 86 | } 87 | 88 | 89 | void GLAPIENTRY 90 | sav_Rectiv (const GLint *v1, const GLint *v2) 91 | { 92 | RECT_F(I_TO_FLOAT(v1[0]), I_TO_FLOAT(v1[1]), I_TO_FLOAT(v2[0]), I_TO_FLOAT(v2[1])); 93 | } 94 | 95 | 96 | void GLAPIENTRY 97 | sav_Rects (GLshort x1, GLshort y1, GLshort x2, GLshort y2) 98 | { 99 | RECT_F(S_TO_FLOAT(x1), S_TO_FLOAT(y1), S_TO_FLOAT(x2), S_TO_FLOAT(y2)); 100 | } 101 | 102 | 103 | void GLAPIENTRY 104 | sav_Rectsv (const GLshort *v1, const GLshort *v2) 105 | { 106 | RECT_F(S_TO_FLOAT(v1[0]), S_TO_FLOAT(v1[1]), S_TO_FLOAT(v2[0]), S_TO_FLOAT(v2[1])); 107 | } 108 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/MODULATE_REPLACE: -------------------------------------------------------------------------------- 1 | MODULATE -> REPLACE 2 | 3 | ALPHA/ALPHA f A0 4 | ALPHA/LUMINANCE C0 f * A1 5 | ALPHA/LUMINANCE_ALPHA C0 A0 6 | ALPHA/INTENSITY C0 A0 7 | ALPHA/RGB C0 f * A1 8 | ALPHA/RGBA C0 A0 9 | LUMINANCE/ALPHA f * C1 A0 10 | LUMINANCE/LUMINANCE C0 f 11 | LUMINANCE/LUMINANCE_ALPHA C0 A0 12 | LUMINANCE/INTENSITY C0 A0 13 | LUMINANCE/RGB C0 f 14 | LUMINANCE/RGBA C0 A0 15 | LUMINANCE_ALPHA/ALPHA f * C1 A0 16 | LUMINANCE_ALPHA/LUMINANCE C0 f * A1 17 | LUMINANCE_ALPHA/LUMINANCE_ALPHA C0 A0 18 | LUMINANCE_ALPHA/INTENSITY C0 A0 19 | LUMINANCE_ALPHA/RGB C0 f * A1 20 | LUMINANCE_ALPHA/RGBA C0 A0 21 | INTENSITY/ALPHA f * C1 A0 22 | INTENSITY/LUMINANCE C0 f * A1 23 | INTENSITY/LUMINANCE_ALPHA C0 A0 24 | INTENSITY/INTENSITY C0 A0 25 | INTENSITY/RGB C0 f * A1 26 | INTENSITY/RGBA C0 A0 27 | RGB/ALPHA f * C1 A0 28 | RGB/LUMINANCE C0 f 29 | RGB/LUMINANCE_ALPHA C0 A0 30 | RGB/INTENSITY C0 A0 31 | RGB/RGB C0 f 32 | RGB/RGBA C0 A0 33 | RGBA/ALPHA f * C1 A0 34 | RGBA/LUMINANCE C0 f * A1 35 | RGBA/LUMINANCE_ALPHA C0 A0 36 | RGBA/INTENSITY C0 A0 37 | RGBA/RGB C0 f * A1 38 | RGBA/RGBA C0 A0 39 | -------------------------------------------------------------------------------- /x86/sse_clip.asm: -------------------------------------------------------------------------------- 1 | %include "xos.inc" 2 | 3 | %include "x86.inc" 4 | 5 | 6 | %macro rcppsit 2 7 | ; same operands as rcpps 8 | ; result = a * (2 - x * a) 9 | mulps %2, %1 10 | mulps %2, %1 11 | addps %1, %1 12 | subps %1, %2 13 | %endmacro 14 | 15 | 16 | %macro movt 2 17 | ; dst[3] = src[0] 18 | shufps %2, %1, SHUF(X, Y, Z, W) 19 | shufps %1, %2, SHUF(X, Y, Z, X) 20 | %endmacro 21 | 22 | 23 | extrn tnl_vb 24 | extrn tnl_prim 25 | extrn tnl_prim_num 26 | extrn x86_clip_lut 27 | 28 | 29 | segment TEXT 30 | 31 | 32 | align 16 33 | proc sse_clipmask 34 | push ebx 35 | push esi 36 | push edi 37 | push ebp 38 | mov ebx, [tnl_vb + TNL_VB_CLIPMASK] 39 | mov ecx, [tnl_prim_num] 40 | mov esi, [tnl_vb + TNL_VB_CLIP] 41 | mov edi, [tnl_prim] 42 | mov ebp, [tnl_vb + TNL_VB_NDC] 43 | test ecx, ecx 44 | jz .done 45 | align 16 46 | .k_loop: 47 | push ecx 48 | push edi 49 | mov edi, [edi + PRIM_COUNT] 50 | xor eax, eax 51 | test edi, edi 52 | jz .next_k 53 | align 16 54 | .j_loop: 55 | MOVUAPS xmm2, [esi] 56 | rcpps xmm0, xmm2 57 | push ebp 58 | 59 | xor ecx, ecx ; ecx = < > 60 | mov ebp, [esi + 12] ; ebp = w 61 | add ebp, ebp ; ebp = 2*|w|, carry = (w < 0) 62 | adc ecx, ecx ; ecx = < q> 63 | mov edx, [esi + 8] ; edx = z 64 | add edx, edx ; edx = 2*|z|, carry = (z < 0) 65 | adc ecx, ecx ; ecx = < qf> 66 | cmp ebp, edx ; carry = 2*|w| < 2*|z| 67 | adc ecx, ecx ; ecx = < qfe> 68 | mov edx, [esi + 4] ; edx = y 69 | add edx, edx ; edx = 2*|y|, carry = (y < 0) 70 | adc ecx, ecx ; ecx = < qfed> 71 | cmp ebp, edx ; carry = 2*|w| < 2*|y| 72 | adc ecx, ecx ; ecx = < qfedc> 73 | mov edx, [esi] ; edx = x 74 | add edx, edx ; edx = 2*|x|, carry = (x < 0) 75 | adc ecx, ecx ; ecx = < qfedcb> 76 | cmp ebp, edx ; carry = 2*|w| < 2*|x| 77 | adc ecx, ecx ; ecx = 78 | mov cl, [x86_clip_lut + ecx] 79 | 80 | pop ebp 81 | MOVUAPS xmm1, xmm2 82 | mov [ebx], cl 83 | or eax, ecx 84 | test ecx, ecx 85 | jnz .next_j 86 | rcppsit xmm0, xmm1 87 | shufps xmm0, xmm0, SHUF(W, W, W, W) 88 | mulps xmm2, xmm0 89 | movt xmm2, xmm0 90 | MOVUAPS [ebp], xmm2 91 | align 16 92 | .next_j: 93 | add esi, 16 94 | add ebp, 16 95 | inc ebx 96 | dec edi 97 | jnz .j_loop 98 | align 16 99 | .next_k: 100 | pop edi 101 | pop ecx 102 | mov [edi + PRIM_ORMASK], eax 103 | add edi, sizeof_TNL_PRIMITIVE 104 | dec ecx 105 | jnz .k_loop 106 | align 16 107 | .done: 108 | pop ebp 109 | pop edi 110 | pop esi 111 | pop ebx 112 | ret 113 | endp 114 | -------------------------------------------------------------------------------- /include/GL/sage.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file sage.h 3 | * SAGE public API. 4 | * 5 | * Typical usage: 6 | * \code 7 | * if (sage_init() > 0) { 8 | * sageContext *ctx = sage_open(TRUE, 5, 6, 5, 0, 16, 0); 9 | * if (ctx != NULL) { 10 | * if (sage_bind(ctx, win, 640, 480) == 0) { 11 | * // OpenGL commands 12 | * sage_swap(1); 13 | * sage_bind(NULL, NULL, 0, 0); 14 | * } 15 | * sage_shut(ctx); 16 | * } 17 | * sage_fini(); 18 | * } 19 | * \endcode 20 | */ 21 | 22 | 23 | #ifndef SAGE_H_included 24 | #define SAGE_H_included 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** 31 | * Opaque definition for graphic context 32 | */ 33 | typedef struct sageContext sageContext; 34 | 35 | /** 36 | * Initialize hardware. 37 | * 38 | * \return maximum color depth 39 | * 40 | * \note It is safe to call multiple times, but there is no reference count. 41 | */ 42 | int sage_init (void); 43 | 44 | /** 45 | * Open graphic context. 46 | * 47 | * \param db_flag doublebuffer requested 48 | * \param red_size desired red channel bits 49 | * \param green_size desired green channel bits 50 | * \param blue_size desired blue channel bits 51 | * \param alpha_size desired alpha channel bits 52 | * \param depth_size desired depth channel bits 53 | * \param stencil_size desired stencil channel bits 54 | * 55 | * \return graphic context 56 | */ 57 | sageContext *sage_open (int db_flag, 58 | int red_size, int green_size, int blue_size, 59 | int alpha_size, int depth_size, int stencil_size); 60 | 61 | /** 62 | * Bind context to drawable and make the context the current one. 63 | * 64 | * \param win window handle 65 | * \param width width in pixels 66 | * \param height height in pixels 67 | * 68 | * \return 0 if success 69 | */ 70 | int sage_bind (sageContext *ctx, void *win, int width, int height); 71 | 72 | /** 73 | * Close graphic context. 74 | * 75 | * \param ctx graphic context 76 | */ 77 | void sage_shut (sageContext *ctx); 78 | 79 | /** 80 | * Shutdown hardware. 81 | * 82 | * \note It is safe to call multiple times, but there is no reference count. 83 | */ 84 | void sage_fini (void); 85 | 86 | /** 87 | * Swap buffers. 88 | * 89 | * \param interval number of retraces to wait 90 | */ 91 | void sage_swap (int interval); 92 | 93 | #ifdef __MSDOS__ 94 | typedef void (*SageProc) (); 95 | SageProc sage_GetProcAddress (const char *procname); 96 | #endif 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /doc/texenv/parser.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "lexer.h" 4 | #include "tree.h" 5 | #include "util.h" 6 | 7 | 8 | #define IS(x) (token.type == (x)) 9 | 10 | 11 | static NODE *do_expr (void); 12 | static NODE *do_term (void); 13 | static NODE *do_fact (void); 14 | 15 | 16 | /* RULE 17 | * ::= 18 | * | + 19 | * | - 20 | * 21 | * where: 22 | * 23 | * FIRST 24 | * (, +, -, ID 25 | */ 26 | static NODE * 27 | do_expr (void) 28 | { 29 | NODE *n = do_term(); 30 | if (IS(T_ADD)) { 31 | NODE *top = tree_node_op('+'); 32 | top->left = n; 33 | next_token(); /* eat `+' */ 34 | top->right = do_term(); 35 | n = top; 36 | } else if (IS(T_SUB)) { 37 | NODE *top = tree_node_op('-'); 38 | top->left = n; 39 | next_token(); /* eat `-' */ 40 | top->right = do_term(); 41 | n = top; 42 | } 43 | return n; 44 | } 45 | 46 | 47 | /* RULE 48 | * ::= 49 | * | * 50 | * | / 51 | * 52 | * where: 53 | * 54 | * FIRST 55 | * (, +, -, ID 56 | */ 57 | static NODE * 58 | do_term (void) 59 | { 60 | NODE *n = do_fact(); 61 | if (IS(T_MUL)) { 62 | NODE *top = tree_node_op('*'); 63 | top->left = n; 64 | next_token(); /* eat `*' */ 65 | top->right = do_fact(); 66 | n = top; 67 | } else if (IS(T_DIV)) { 68 | NODE *top = tree_node_op('/'); 69 | top->left = n; 70 | next_token(); /* eat `/' */ 71 | top->right = do_fact(); 72 | n = top; 73 | } 74 | return n; 75 | } 76 | 77 | 78 | /* RULE 79 | * ::= `(' ')' 80 | * | `+' 81 | * | `-' 82 | * | ID 83 | * 84 | * where: 85 | * 86 | * FIRST 87 | * (, +, -, ID 88 | */ 89 | static NODE * 90 | do_fact (void) 91 | { 92 | NODE *n; 93 | if (IS(T_OB)) { 94 | next_token(); /* eat `(' */ 95 | n = do_expr(); 96 | if (!IS(T_CB)) { 97 | assert(0); 98 | } 99 | next_token(); /* eat `)' */ 100 | } else if (IS(T_ADD)) { 101 | next_token(); /* eat `+' */ 102 | n = do_fact(); 103 | } else if (IS(T_SUB)) { 104 | NODE *top = tree_node_op('-'); 105 | top->left = 0; 106 | next_token(); /* eat `-' */ 107 | top->right = do_fact(); 108 | n = top; 109 | } else if (IS(T_ID)) { 110 | n = tree_node_var(token.sym); 111 | next_token(); /* eat ID */ 112 | } else { 113 | assert(0); 114 | } 115 | 116 | return n; 117 | } 118 | 119 | 120 | NODE * 121 | parse (const char *input) 122 | { 123 | set_input(input); 124 | next_token(); 125 | return do_expr(); 126 | } 127 | -------------------------------------------------------------------------------- /tnl/template/clipmask.h: -------------------------------------------------------------------------------- 1 | static void 2 | TAG(_tnl_clipmask) (void) 3 | { 4 | int i = 0, j; 5 | GLuint k; 6 | GLfloat oow; 7 | 8 | for (k = 0; k < tnl_prim_num; k++) { 9 | tnl_prim[k].ormask = 0; 10 | for (j = 0; j < tnl_prim[k].count; j++) { 11 | GLbitfield mask = 0; 12 | #if (!(IND & V_NOCLIP)) 13 | /* set up clipmask */ 14 | const GLfloat cx = tnl_vb.clip[i][0]; 15 | const GLfloat cy = tnl_vb.clip[i][1]; 16 | const GLfloat cz = tnl_vb.clip[i][2]; 17 | const GLfloat cw = tnl_vb.clip[i][3]; 18 | #if 0 19 | if (-cx + cw < 0) mask |= TNL_CLIP_RIGHT; 20 | if ( cx + cw < 0) mask |= TNL_CLIP_LEFT; 21 | if (-cy + cw < 0) mask |= TNL_CLIP_TOP; 22 | if ( cy + cw < 0) mask |= TNL_CLIP_BOTTOM; 23 | if (-cz + cw < 0) mask |= TNL_CLIP_FAR; 24 | if ( cz + cw < 0) mask |= TNL_CLIP_NEAR; 25 | #else 26 | #define TNL_CLIP_NEAR_SHIFT (0) 27 | #define TNL_CLIP_FAR_SHIFT (1) 28 | #define TNL_CLIP_TOP_SHIFT (2) 29 | #define TNL_CLIP_BOTTOM_SHIFT (3) 30 | #define TNL_CLIP_LEFT_SHIFT (4) 31 | #define TNL_CLIP_RIGHT_SHIFT (5) 32 | #define TNL_CLIP_USER_SHIFT (6) 33 | mask |= IS_NEGATIVE(cw - cx) << TNL_CLIP_RIGHT_SHIFT; 34 | mask |= IS_NEGATIVE(cw + cx) << TNL_CLIP_LEFT_SHIFT; 35 | mask |= IS_NEGATIVE(cw - cy) << TNL_CLIP_TOP_SHIFT; 36 | mask |= IS_NEGATIVE(cw + cy) << TNL_CLIP_BOTTOM_SHIFT; 37 | mask |= IS_NEGATIVE(cw - cz) << TNL_CLIP_FAR_SHIFT; 38 | mask |= IS_NEGATIVE(cw + cz) << TNL_CLIP_NEAR_SHIFT; 39 | #endif 40 | #if (IND & V_USERCLIP) 41 | { 42 | int u, planes = ctx_userclip; 43 | for (u = 0; u < TNL_USERCLIP_PLANES; u++) { 44 | if (planes & 1) { 45 | GLfloat dp = cx * ctx_userplanes[1][u][0] + 46 | cy * ctx_userplanes[1][u][1] + 47 | cz * ctx_userplanes[1][u][2] + 48 | cw * ctx_userplanes[1][u][3]; 49 | if (IS_NEGATIVE(dp)) { 50 | mask |= TNL_CLIP_USER; 51 | break; 52 | } 53 | } 54 | planes >>= 1; 55 | } 56 | } 57 | #endif 58 | #endif 59 | tnl_vb.clipmask[i] = mask; 60 | tnl_prim[k].ormask |= mask; 61 | if (!mask) { 62 | /* ndc (normalized device coords) */ 63 | oow = (tnl_vb.clip[i][3] == 0.0F) ? 1.0F : (1.0F / tnl_vb.clip[i][3]); 64 | tnl_vb.ndc[i][0] = tnl_vb.clip[i][0] * oow; 65 | tnl_vb.ndc[i][1] = tnl_vb.clip[i][1] * oow; 66 | tnl_vb.ndc[i][2] = tnl_vb.clip[i][2] * oow; 67 | tnl_vb.ndc[i][3] = oow; /* essentially 1.0, but we keep oow */ 68 | } 69 | i++; 70 | } 71 | } 72 | } 73 | 74 | 75 | static void 76 | TAG(_tnl_init_clipmask) (void) 77 | { 78 | tnl_clipmask_tab[IND] = TAG(_tnl_clipmask); 79 | } 80 | 81 | 82 | #undef TAG 83 | #undef IND 84 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/REPLACE_ADD: -------------------------------------------------------------------------------- 1 | REPLACE -> ADD 2 | 3 | ALPHA/ALPHA f A1 * A0 4 | ALPHA/LUMINANCE f + C0 A1 5 | ALPHA/LUMINANCE_ALPHA f + C0 A1 * A0 6 | ALPHA/INTENSITY f + C0 A1 + A0 7 | ALPHA/RGB f + C0 A1 8 | ALPHA/RGBA f + C0 A1 * A0 9 | LUMINANCE/ALPHA C1 f * A0 10 | LUMINANCE/LUMINANCE C1 + C0 f 11 | LUMINANCE/LUMINANCE_ALPHA C1 + C0 f * A0 12 | LUMINANCE/INTENSITY C1 + C0 f + A0 13 | LUMINANCE/RGB C1 + C0 f 14 | LUMINANCE/RGBA C1 + C0 f * A0 15 | LUMINANCE_ALPHA/ALPHA C1 A1 * A0 16 | LUMINANCE_ALPHA/LUMINANCE C1 + C0 A1 17 | LUMINANCE_ALPHA/LUMINANCE_ALPHA C1 + C0 A1 * A0 18 | LUMINANCE_ALPHA/INTENSITY C1 + C0 A1 + A0 19 | LUMINANCE_ALPHA/RGB C1 + C0 A1 20 | LUMINANCE_ALPHA/RGBA C1 + C0 A1 * A0 21 | INTENSITY/ALPHA C1 A1 * A0 22 | INTENSITY/LUMINANCE C1 + C0 A1 23 | INTENSITY/LUMINANCE_ALPHA C1 + C0 A1 * A0 24 | INTENSITY/INTENSITY C1 + C0 A1 + A0 25 | INTENSITY/RGB C1 + C0 A1 26 | INTENSITY/RGBA C1 + C0 A1 * A0 27 | RGB/ALPHA C1 f * A0 28 | RGB/LUMINANCE C1 + C0 f 29 | RGB/LUMINANCE_ALPHA C1 + C0 f * A0 30 | RGB/INTENSITY C1 + C0 f + A0 31 | RGB/RGB C1 + C0 f 32 | RGB/RGBA C1 + C0 f * A0 33 | RGBA/ALPHA C1 A1 * A0 34 | RGBA/LUMINANCE C1 + C0 A1 35 | RGBA/LUMINANCE_ALPHA C1 + C0 A1 * A0 36 | RGBA/INTENSITY C1 + C0 A1 + A0 37 | RGBA/RGB C1 + C0 A1 38 | RGBA/RGBA C1 + C0 A1 * A0 39 | -------------------------------------------------------------------------------- /x86/xos.inc: -------------------------------------------------------------------------------- 1 | ;--------------------------------------- 2 | ; platform defines 3 | ;--------------------------------------- 4 | %define XOS_DJGPP 1 5 | %define XOS_LINUX 2 6 | %define XOS_WIN32 4 7 | 8 | %define STDCALL 0 9 | %define ELFTYPE 0 10 | 11 | ;--------------------------------------- 12 | ; pick up the right OS 13 | ;--------------------------------------- 14 | %ifdef __DJGPP__ 15 | %define XOS XOS_DJGPP 16 | %elifdef __linux__ 17 | %define XOS XOS_LINUX 18 | %define ELFTYPE 1 19 | %elifdef __WIN32__ 20 | %define XOS XOS_WIN32 21 | %define STDCALL 1 22 | %else 23 | %error Unknown OS 24 | %endif 25 | 26 | ;--------------------------------------- 27 | ; general purpose macros 28 | ;--------------------------------------- 29 | %macro extrn 1-2 30 | %if STDCALL && (%0 > 1) 31 | %define %1 %1@%2 32 | %endif 33 | extern %1 34 | %endmacro 35 | 36 | %macro proc 1-2 37 | %push proc 38 | %define %$ret RET 39 | %define %$end %1_end 40 | %if STDCALL && (%0 > 1) 41 | %if (%2 > 0) 42 | %define %$ret RET %2 43 | %endif 44 | %define %1 %1@%2 45 | %endif 46 | %if ELFTYPE 47 | global %1:function (%$end - %1) 48 | %else 49 | global %1 50 | %endif 51 | %1: 52 | %endmacro 53 | 54 | %macro endp 0 55 | %ifnctx proc 56 | %error Mismatched ENDP/PROC 57 | %else 58 | %$end: 59 | %pop 60 | %endif 61 | %endmacro 62 | 63 | %macro ret 0 64 | %ifnctx proc 65 | RET 66 | %else 67 | %$ret 68 | %endif 69 | %endmacro 70 | 71 | ;--------------------------------------- 72 | ; Windows 73 | ;--------------------------------------- 74 | %if XOS == XOS_WIN32 75 | 76 | %define TEXT .text 77 | %define DATA .data 78 | %define CONST .rdata 79 | 80 | %macro dllexp 1 81 | export %1 82 | %endmacro 83 | 84 | %endif 85 | 86 | ;--------------------------------------- 87 | ; DJGPP 88 | ;--------------------------------------- 89 | %if XOS == XOS_DJGPP 90 | 91 | %define TEXT .text 92 | %define DATA .data 93 | %define CONST .rodata 94 | 95 | %macro dllexp 1 96 | %endmacro 97 | 98 | %endif 99 | 100 | ;--------------------------------------- 101 | ; Linux 102 | ;--------------------------------------- 103 | %if XOS == XOS_LINUX 104 | 105 | %define TEXT .text 106 | %define DATA .data 107 | %define CONST .rodata 108 | 109 | %macro dllexp 1 110 | %endmacro 111 | 112 | %endif 113 | 114 | ;--------------------------------------- 115 | ; movaps is broken in DJGPP DXE builds - 116 | ; possibly an issue in the dxe3gen tool. 117 | ;--------------------------------------- 118 | %ifdef BROKEN_MOVAPS 119 | %define MOVUAPS movups 120 | %else 121 | %define MOVUAPS movaps 122 | %endif 123 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/REPLACE_MODULATE: -------------------------------------------------------------------------------- 1 | REPLACE -> MODULATE 2 | 3 | ALPHA/ALPHA f A1 * A0 4 | ALPHA/LUMINANCE f * C0 A1 5 | ALPHA/LUMINANCE_ALPHA f * C0 A1 * A0 6 | ALPHA/INTENSITY f * C0 A1 * A0 7 | ALPHA/RGB f * C0 A1 8 | ALPHA/RGBA f * C0 A1 * A0 9 | LUMINANCE/ALPHA C1 f * A0 10 | LUMINANCE/LUMINANCE C1 * C0 f 11 | LUMINANCE/LUMINANCE_ALPHA C1 * C0 f * A0 12 | LUMINANCE/INTENSITY C1 * C0 f * A0 13 | LUMINANCE/RGB C1 * C0 f 14 | LUMINANCE/RGBA C1 * C0 f * A0 15 | LUMINANCE_ALPHA/ALPHA C1 A1 * A0 16 | LUMINANCE_ALPHA/LUMINANCE C1 * C0 A1 17 | LUMINANCE_ALPHA/LUMINANCE_ALPHA C1 * C0 A1 * A0 18 | LUMINANCE_ALPHA/INTENSITY C1 * C0 A1 * A0 19 | LUMINANCE_ALPHA/RGB C1 * C0 A1 20 | LUMINANCE_ALPHA/RGBA C1 * C0 A1 * A0 21 | INTENSITY/ALPHA C1 A1 * A0 22 | INTENSITY/LUMINANCE C1 * C0 A1 23 | INTENSITY/LUMINANCE_ALPHA C1 * C0 A1 * A0 24 | INTENSITY/INTENSITY C1 * C0 A1 * A0 25 | INTENSITY/RGB C1 * C0 A1 26 | INTENSITY/RGBA C1 * C0 A1 * A0 27 | RGB/ALPHA C1 f * A0 28 | RGB/LUMINANCE C1 * C0 f 29 | RGB/LUMINANCE_ALPHA C1 * C0 f * A0 30 | RGB/INTENSITY C1 * C0 f * A0 31 | RGB/RGB C1 * C0 f 32 | RGB/RGBA C1 * C0 f * A0 33 | RGBA/ALPHA C1 A1 * A0 34 | RGBA/LUMINANCE C1 * C0 A1 35 | RGBA/LUMINANCE_ALPHA C1 * C0 A1 * A0 36 | RGBA/INTENSITY C1 * C0 A1 * A0 37 | RGBA/RGB C1 * C0 A1 38 | RGBA/RGBA C1 * C0 A1 * A0 39 | -------------------------------------------------------------------------------- /main/texdef.c: -------------------------------------------------------------------------------- 1 | #include "GL/gl.h" 2 | 3 | #include "glinternal.h" 4 | #include "context.h" 5 | #include "texdef.h" 6 | 7 | 8 | const TEXDEF texdef_rgb_565[1] = {{ 9 | GL_RGB, 10 | GL_UNSIGNED_SHORT_5_6_5, 11 | 2, 12 | GL_FALSE, 13 | 5, 6, 5, 0 14 | }}; 15 | 16 | const TEXDEF texdef_bgra_4444_rev[1] = {{ 17 | GL_BGRA, 18 | GL_UNSIGNED_SHORT_4_4_4_4_REV, 19 | 2, 20 | GL_FALSE, 21 | 4, 4, 4, 4 22 | }}; 23 | 24 | const TEXDEF texdef_l_ubyte[1] = {{ 25 | GL_LUMINANCE, 26 | GL_UNSIGNED_BYTE, 27 | 1, 28 | GL_FALSE, 29 | 8, 8, 8, 0 30 | }}; 31 | 32 | const TEXDEF texdef_a_ubyte[1] = {{ 33 | GL_ALPHA, 34 | GL_UNSIGNED_BYTE, 35 | 1, 36 | GL_FALSE, 37 | 0, 0, 0, 8 38 | }}; 39 | 40 | const TEXDEF texdef_i_ubyte[1] = {{ 41 | GL_INTENSITY, 42 | GL_UNSIGNED_BYTE, 43 | 1, 44 | GL_FALSE, 45 | 8, 8, 8, 8 46 | }}; 47 | 48 | const TEXDEF texdef_la_ubyte[1] = {{ 49 | GL_LUMINANCE_ALPHA, 50 | GL_UNSIGNED_BYTE, 51 | 2, 52 | GL_FALSE, 53 | 8, 8, 8, 8 54 | }}; 55 | 56 | const TEXDEF texdef_bgra_1555_rev[1] = {{ 57 | GL_BGRA, 58 | GL_UNSIGNED_SHORT_1_5_5_5_REV, 59 | 2, 60 | GL_FALSE, 61 | 5, 5, 5, 1 62 | }}; 63 | 64 | const TEXDEF texdef_bgra_8888_rev[1] = {{ 65 | GL_BGRA, 66 | GL_UNSIGNED_INT_8_8_8_8_REV, 67 | 4, 68 | GL_FALSE, 69 | 8, 8, 8, 8 70 | }}; 71 | 72 | const TEXDEF texdef_bgr1_8888_rev[1] = {{ 73 | GL_BGR, 74 | GL_UNSIGNED_INT_8_8_8_8_REV, 75 | 4, 76 | GL_FALSE, 77 | 8, 8, 8, 0 78 | }}; 79 | 80 | const TEXDEF texdef_rgb_fxt1[1] = {{ 81 | GL_COMPRESSED_RGB_FXT1_3DFX, 82 | GL_UNSIGNED_BYTE, 83 | 1, 84 | GL_TRUE, 85 | 4, 4, 4, 0 86 | }}; 87 | 88 | const TEXDEF texdef_rgba_fxt1[1] = {{ 89 | GL_COMPRESSED_RGBA_FXT1_3DFX, 90 | GL_UNSIGNED_BYTE, 91 | 1, 92 | GL_TRUE, 93 | 4, 4, 4, 4 94 | }}; 95 | 96 | const TEXDEF texdef_rgb_dxt1[1] = {{ 97 | GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 98 | GL_UNSIGNED_BYTE, 99 | 1, 100 | GL_TRUE, 101 | 4, 4, 4, 0 102 | }}; 103 | 104 | const TEXDEF texdef_rgba_dxt1[1] = {{ 105 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 106 | GL_UNSIGNED_BYTE, 107 | 1, 108 | GL_TRUE, 109 | 4, 4, 4, 4 110 | }}; 111 | 112 | const TEXDEF texdef_rgba_dxt3[1] = {{ 113 | GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 114 | GL_UNSIGNED_BYTE, 115 | 1, 116 | GL_TRUE, 117 | 4, 4, 4, 4 118 | }}; 119 | 120 | const TEXDEF texdef_rgba_dxt5[1] = {{ 121 | GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 122 | GL_UNSIGNED_BYTE, 123 | 1, 124 | GL_TRUE, 125 | 4, 4, 4, 4 126 | }}; 127 | -------------------------------------------------------------------------------- /glinternal.h: -------------------------------------------------------------------------------- 1 | #ifndef GLINTERNAL_H_included 2 | #define GLINTERNAL_H_included 3 | 4 | typedef GLfloat GLfloat4[4]; 5 | 6 | /* unapproved stuff (to be moved in gl.h when ready) */ 7 | 8 | #define GL_TEXTURE_BORDER_COLOR 0x1004 9 | 10 | #define GL_POINT_SMOOTH 0x0B10 11 | 12 | #define GL_TEXTURE_RECTANGLE_ARB 0x84F5 13 | 14 | #define GL_STENCIL_BITS 0x0D57 15 | #define GL_ALPHA_BITS 0x0D55 16 | #define GL_RED_BITS 0x0D52 17 | #define GL_GREEN_BITS 0x0D53 18 | #define GL_BLUE_BITS 0x0D54 19 | 20 | /* UT2003 woes */ 21 | #define GL_TEXTURE_WRAP_R 0x8072 22 | #define GL_TEXTURE_CUBE_MAP 0x8513 23 | #define GL_COMBINE_RGB 0x8571 24 | #define GL_COMBINE_ALPHA 0x8572 25 | #define GL_RGB_SCALE 0x8573 26 | #define GL_ALPHA_SCALE 0x0D1C 27 | #define GL_SOURCE0_RGB 0x8580 28 | #define GL_SOURCE1_RGB 0x8581 29 | #define GL_SOURCE2_RGB 0x8582 30 | #define GL_SOURCE0_ALPHA 0x8588 31 | #define GL_SOURCE1_ALPHA 0x8589 32 | #define GL_SOURCE2_ALPHA 0x858A 33 | #define GL_OPERAND0_RGB 0x8590 34 | #define GL_OPERAND1_RGB 0x8591 35 | #define GL_OPERAND2_RGB 0x8592 36 | #define GL_OPERAND0_ALPHA 0x8598 37 | #define GL_OPERAND1_ALPHA 0x8599 38 | #define GL_OPERAND2_ALPHA 0x859A 39 | #define GL_CONSTANT 0x8576 40 | #define GL_PRIMARY_COLOR 0x8577 41 | #define GL_PREVIOUS 0x8578 42 | #define GL_INTERPOLATE 0x8575 43 | 44 | /* texture compression */ 45 | #define GL_COMPRESSED_RGB 0x84ED 46 | #define GL_COMPRESSED_RGBA 0x84EE 47 | #define GL_RGB_S3TC 0x83A0 48 | #define GL_RGB4_S3TC 0x83A1 49 | #define GL_RGBA_S3TC 0x83A2 50 | #define GL_RGBA4_S3TC 0x83A3 51 | #define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 52 | #define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 53 | #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 54 | #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 55 | #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 56 | #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 57 | 58 | /* Buffers, Pixel Drawing/Reading */ 59 | #define GL_NONE 0x0 60 | #define GL_LEFT 0x0406 61 | #define GL_RIGHT 0x0407 62 | /*GL_FRONT 0x0404 */ 63 | /*GL_BACK 0x0405 */ 64 | /*GL_FRONT_AND_BACK 0x0408 */ 65 | #define GL_FRONT_LEFT 0x0400 66 | #define GL_FRONT_RIGHT 0x0401 67 | #define GL_BACK_LEFT 0x0402 68 | #define GL_BACK_RIGHT 0x0403 69 | 70 | #define GL_DEPTH_COMPONENT 0x1902 71 | 72 | #define GL_MAX_TEXTURE_COORDS_ARB 0x8871 73 | #define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 74 | 75 | /* SWKotOR2 */ 76 | #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE 77 | 78 | #define GL_COLOR_CLEAR_VALUE 0x0C22 79 | 80 | #define GL_ENABLE_BIT 0x00002000 81 | 82 | #define GL_DEPTH_WRITEMASK 0x0B72 83 | 84 | /* Homeworld2 */ 85 | #define GL_INDEX_ARRAY 0x8077 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/MODULATE_MODULATE: -------------------------------------------------------------------------------- 1 | MODULATE -> MODULATE 2 | 3 | ALPHA/ALPHA f f * A1 * A0 4 | ALPHA/LUMINANCE f * C0 f * A1 5 | ALPHA/LUMINANCE_ALPHA f * C0 f * A1 * A0 6 | ALPHA/INTENSITY f * C0 f * A1 * A0 7 | ALPHA/RGB f * C0 f * A1 8 | ALPHA/RGBA f * C0 f * A1 * A0 9 | LUMINANCE/ALPHA f * C1 f * A0 10 | LUMINANCE/LUMINANCE f * C1 * C0 f 11 | LUMINANCE/LUMINANCE_ALPHA f * C1 * C0 f * A0 12 | LUMINANCE/INTENSITY f * C1 * C0 f * A0 13 | LUMINANCE/RGB f * C1 * C0 f 14 | LUMINANCE/RGBA f * C1 * C0 f * A0 15 | LUMINANCE_ALPHA/ALPHA f * C1 f * A1 * A0 16 | LUMINANCE_ALPHA/LUMINANCE f * C1 * C0 f * A1 17 | LUMINANCE_ALPHA/LUMINANCE_ALPHA f * C1 * C0 f * A1 * A0 18 | LUMINANCE_ALPHA/INTENSITY f * C1 * C0 f * A1 * A0 19 | LUMINANCE_ALPHA/RGB f * C1 * C0 f * A1 20 | LUMINANCE_ALPHA/RGBA f * C1 * C0 f * A1 * A0 21 | INTENSITY/ALPHA f * C1 f * A1 * A0 22 | INTENSITY/LUMINANCE f * C1 * C0 f * A1 23 | INTENSITY/LUMINANCE_ALPHA f * C1 * C0 f * A1 * A0 24 | INTENSITY/INTENSITY f * C1 * C0 f * A1 * A0 25 | INTENSITY/RGB f * C1 * C0 f * A1 26 | INTENSITY/RGBA f * C1 * C0 f * A1 * A0 27 | RGB/ALPHA f * C1 f * A0 28 | RGB/LUMINANCE f * C1 * C0 f 29 | RGB/LUMINANCE_ALPHA f * C1 * C0 f * A0 30 | RGB/INTENSITY f * C1 * C0 f * A0 31 | RGB/RGB f * C1 * C0 f 32 | RGB/RGBA f * C1 * C0 f * A0 33 | RGBA/ALPHA f * C1 f * A1 * A0 34 | RGBA/LUMINANCE f * C1 * C0 f * A1 35 | RGBA/LUMINANCE_ALPHA f * C1 * C0 f * A1 * A0 36 | RGBA/INTENSITY f * C1 * C0 f * A1 * A0 37 | RGBA/RGB f * C1 * C0 f * A1 38 | RGBA/RGBA f * C1 * C0 f * A1 * A0 39 | -------------------------------------------------------------------------------- /doc/texenv/voodoo/MODULATE_BLEND: -------------------------------------------------------------------------------- 1 | MODULATE -> BLEND 2 | 3 | ALPHA/ALPHA f f * A1 * A0 4 | ALPHA/LUMINANCE f * (1 - C0) + Cc * C0 f * A1 5 | ALPHA/LUMINANCE_ALPHA f * (1 - C0) + Cc * C0 f * A1 * A0 6 | ALPHA/INTENSITY f * (1 - C0) + Cc * C0 f * A1 * (1 - A0) + Ac * A0 7 | ALPHA/RGB f * (1 - C0) + Cc * C0 f * A1 8 | ALPHA/RGBA f * (1 - C0) + Cc * C0 f * A1 * A0 9 | LUMINANCE/ALPHA f * C1 f * A0 10 | LUMINANCE/LUMINANCE f * C1 * (1 - C0) + Cc * C0 f 11 | LUMINANCE/LUMINANCE_ALPHA f * C1 * (1 - C0) + Cc * C0 f * A0 12 | LUMINANCE/INTENSITY f * C1 * (1 - C0) + Cc * C0 f * (1 - A0) + Ac * A0 13 | LUMINANCE/RGB f * C1 * (1 - C0) + Cc * C0 f 14 | LUMINANCE/RGBA f * C1 * (1 - C0) + Cc * C0 f * A0 15 | LUMINANCE_ALPHA/ALPHA f * C1 f * A1 * A0 16 | LUMINANCE_ALPHA/LUMINANCE f * C1 * (1 - C0) + Cc * C0 f * A1 17 | LUMINANCE_ALPHA/LUMINANCE_ALPHA f * C1 * (1 - C0) + Cc * C0 f * A1 * A0 18 | LUMINANCE_ALPHA/INTENSITY f * C1 * (1 - C0) + Cc * C0 f * A1 * (1 - A0) + Ac * A0 19 | LUMINANCE_ALPHA/RGB f * C1 * (1 - C0) + Cc * C0 f * A1 20 | LUMINANCE_ALPHA/RGBA f * C1 * (1 - C0) + Cc * C0 f * A1 * A0 21 | INTENSITY/ALPHA f * C1 f * A1 * A0 22 | INTENSITY/LUMINANCE f * C1 * (1 - C0) + Cc * C0 f * A1 23 | INTENSITY/LUMINANCE_ALPHA f * C1 * (1 - C0) + Cc * C0 f * A1 * A0 24 | INTENSITY/INTENSITY f * C1 * (1 - C0) + Cc * C0 f * A1 * (1 - A0) + Ac * A0 25 | INTENSITY/RGB f * C1 * (1 - C0) + Cc * C0 f * A1 26 | INTENSITY/RGBA f * C1 * (1 - C0) + Cc * C0 f * A1 * A0 27 | RGB/ALPHA f * C1 f * A0 28 | RGB/LUMINANCE f * C1 * (1 - C0) + Cc * C0 f 29 | RGB/LUMINANCE_ALPHA f * C1 * (1 - C0) + Cc * C0 f * A0 30 | RGB/INTENSITY f * C1 * (1 - C0) + Cc * C0 f * (1 - A0) + Ac * A0 31 | RGB/RGB f * C1 * (1 - C0) + Cc * C0 f 32 | RGB/RGBA f * C1 * (1 - C0) + Cc * C0 f * A0 33 | RGBA/ALPHA f * C1 f * A1 * A0 34 | RGBA/LUMINANCE f * C1 * (1 - C0) + Cc * C0 f * A1 35 | RGBA/LUMINANCE_ALPHA f * C1 * (1 - C0) + Cc * C0 f * A1 * A0 36 | RGBA/INTENSITY f * C1 * (1 - C0) + Cc * C0 f * A1 * (1 - A0) + Ac * A0 37 | RGBA/RGB f * C1 * (1 - C0) + Cc * C0 f * A1 38 | RGBA/RGBA f * C1 * (1 - C0) + Cc * C0 f * A1 * A0 39 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean realclean 2 | .SUFFIXES: .asm .o 3 | .INTERMEDIATE: x86/x86gen.exe 4 | 5 | DRIVER ?= glide 6 | 7 | all: lib/libGL.so.1.1 8 | 9 | CC = gcc 10 | HOST_CC = gcc 11 | CFLAGS = -Wall 12 | CFLAGS += -Wno-unused 13 | CFLAGS += -O2 14 | # in case of problems disable -DNDEBUG to enable assertions 15 | CFLAGS += -DNDEBUG 16 | #CFLAGS += -g 17 | #CFLAGS += -ffast-math -DFAST_MATH 18 | CFLAGS += -I. -Iinclude -Idrivers 19 | # disable software scaledown of hardware-unsupported large textures 20 | #CFLAGS += -DFX_RESCALEHACK=0 21 | LD = $(CC) 22 | LDFLAGS = 23 | LDLIBS = -lX11 -ldl -lm 24 | AS = nasm 25 | ASFLAGS = -O2 -felf -D__linux__ -Ix86/ -Imain/ 26 | 27 | CORE_SOURCES = \ 28 | util/cfg.c \ 29 | util/pow.c \ 30 | main/buffer.c \ 31 | main/color.c \ 32 | main/context.c \ 33 | main/cull.c \ 34 | main/depth.c \ 35 | main/stencil.c \ 36 | main/dlist.c \ 37 | main/enable.c \ 38 | main/get.c \ 39 | main/glapi.c \ 40 | main/glapic.c \ 41 | main/light.c \ 42 | main/matrix.c \ 43 | main/texture.c \ 44 | main/texstore.c \ 45 | main/texcodec.c \ 46 | main/texdef.c \ 47 | main/fog.c \ 48 | main/ext.c \ 49 | main/pixel.c \ 50 | main/raster.c \ 51 | main/attrib.c \ 52 | main/fake.c \ 53 | main/legacy.c \ 54 | util/alloc.c 55 | 56 | TNL_SOURCES = \ 57 | tnl/tnl.c \ 58 | tnl/tnl_prim.c \ 59 | tnl/tnl_pipeline.c \ 60 | tnl/tnl_setup.c \ 61 | tnl/imm_api.c \ 62 | tnl/imm_array.c \ 63 | tnl/imm_vertex.c \ 64 | tnl/sav_api.c \ 65 | tnl/sav_array.c \ 66 | tnl/sav_vertex.c 67 | 68 | ifeq ($(X86),1) 69 | CFLAGS += -DX86 70 | X86_SOURCES = \ 71 | x86/x86.c \ 72 | x86/cpuhard.c \ 73 | x86/cpusoft.asm \ 74 | x86/glapia.asm \ 75 | x86/x86_vertex.asm \ 76 | x86/x86_clip.asm \ 77 | x86/k3d_mat.asm \ 78 | x86/k3d_clip.asm \ 79 | x86/k3d_misc.asm \ 80 | x86/sse_vertex.asm \ 81 | x86/sse_mat.asm \ 82 | x86/sse_clip.asm \ 83 | x86/sse_misc.asm 84 | 85 | x86/x86.o: x86/x86chk.h 86 | endif 87 | 88 | include drivers/$(DRIVER)/config 89 | DRIVER_SOURCES += \ 90 | drivers/$(DRIVER)/glx.c 91 | 92 | SOURCES = $(CORE_SOURCES) $(TNL_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES) 93 | 94 | OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) 95 | 96 | .c.o: 97 | $(CC) -o $@ $(CFLAGS) -fPIC -DPIC -c $< 98 | .asm.o: 99 | $(AS) -o $@ $(ASFLAGS) $< 100 | 101 | lib/libGL.so.1.1: $(OBJECTS) 102 | $(LD) -o $@ -shared -Wl,-soname=libGL.so.1 $(LDFLAGS) $^ $(LDLIBS) 103 | 104 | $(X86_SOURCES:.asm=.o): x86/x86.inc 105 | 106 | x86/x86.inc: x86/x86gen.exe 107 | $< -o $@ 108 | 109 | x86/x86chk.h: x86/x86gen.exe 110 | $< -c -o $@ 111 | 112 | x86/x86gen.exe: x86/x86gen.c glinternal.h main/context.h main/matrix.h tnl/tnl.h x86/cpu.h 113 | $(HOST_CC) -o $@ $(CFLAGS) $< 114 | 115 | clean:: 116 | -$(RM) $(OBJECTS) 117 | -$(RM) x86/*.o 118 | -$(RM) x86/x86chk.h 119 | -$(RM) x86/x86.inc 120 | 121 | realclean:: clean 122 | -$(RM) lib/libGL.so.1.1 123 | -------------------------------------------------------------------------------- /Makefile.icc: -------------------------------------------------------------------------------- 1 | .PHONY: all clean realclean 2 | .SUFFIXES: .asm .o 3 | .INTERMEDIATE: x86/x86gen.exe 4 | 5 | DRIVER ?= glide 6 | 7 | all: lib/libGL.so.1.1 8 | 9 | #CC = /opt/intel/cc/9.0/bin/icc 10 | CC = icc 11 | HOST_CC = icc 12 | CFLAGS = -Wall 13 | CFLAGS += -O2 -ip 14 | # in case of problems disable -DNDEBUG to enable assertions 15 | CFLAGS += -DNDEBUG 16 | #CFLAGS += -g 17 | #CFLAGS += -rcd -xK -DFAST_MATH 18 | CFLAGS += -I. -Iinclude -Idrivers 19 | # disable software scaledown of hardware-unsupported large textures 20 | #CFLAGS += -DFX_RESCALEHACK=0 21 | LD = $(CC) 22 | LDFLAGS = -i-static 23 | LDLIBS = -lX11 -ldl -lm 24 | AS = nasm 25 | ASFLAGS = -O2 -felf -D__linux__ -Ix86/ -Imain/ 26 | 27 | CORE_SOURCES = \ 28 | util/cfg.c \ 29 | util/pow.c \ 30 | main/buffer.c \ 31 | main/color.c \ 32 | main/context.c \ 33 | main/cull.c \ 34 | main/depth.c \ 35 | main/stencil.c \ 36 | main/dlist.c \ 37 | main/enable.c \ 38 | main/get.c \ 39 | main/glapi.c \ 40 | main/glapic.c \ 41 | main/light.c \ 42 | main/matrix.c \ 43 | main/texture.c \ 44 | main/texstore.c \ 45 | main/texcodec.c \ 46 | main/texdef.c \ 47 | main/fog.c \ 48 | main/ext.c \ 49 | main/pixel.c \ 50 | main/raster.c \ 51 | main/attrib.c \ 52 | main/fake.c \ 53 | main/legacy.c \ 54 | util/alloc.c 55 | 56 | TNL_SOURCES = \ 57 | tnl/tnl.c \ 58 | tnl/tnl_prim.c \ 59 | tnl/tnl_pipeline.c \ 60 | tnl/tnl_setup.c \ 61 | tnl/imm_api.c \ 62 | tnl/imm_array.c \ 63 | tnl/imm_vertex.c \ 64 | tnl/sav_api.c \ 65 | tnl/sav_array.c \ 66 | tnl/sav_vertex.c 67 | 68 | ifeq ($(X86),1) 69 | CFLAGS += -DX86 70 | X86_SOURCES = \ 71 | x86/x86.c \ 72 | x86/cpuhard.c \ 73 | x86/cpusoft.asm \ 74 | x86/glapia.asm \ 75 | x86/x86_vertex.asm \ 76 | x86/x86_clip.asm \ 77 | x86/k3d_mat.asm \ 78 | x86/k3d_clip.asm \ 79 | x86/k3d_misc.asm \ 80 | x86/sse_vertex.asm \ 81 | x86/sse_mat.asm \ 82 | x86/sse_clip.asm \ 83 | x86/sse_misc.asm 84 | 85 | x86/x86.o: x86/x86chk.h 86 | endif 87 | 88 | include drivers/$(DRIVER)/config 89 | DRIVER_SOURCES += \ 90 | drivers/$(DRIVER)/glx.c 91 | 92 | SOURCES = $(CORE_SOURCES) $(TNL_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES) 93 | 94 | OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) 95 | 96 | .c.o: 97 | $(CC) -o $@ $(CFLAGS) -c $< 98 | .asm.o: 99 | $(AS) -o $@ $(ASFLAGS) $< 100 | 101 | lib/libGL.so.1.1: $(OBJECTS) 102 | $(LD) -o $@ -shared -Wl,-soname=libGL.so.1 $(LDFLAGS) $^ $(LDLIBS) 103 | 104 | $(X86_SOURCES:.asm=.o): x86/x86.inc 105 | 106 | x86/x86.inc: x86/x86gen.exe 107 | $< -o $@ 108 | 109 | x86/x86chk.h: x86/x86gen.exe 110 | $< -c -o $@ 111 | 112 | x86/x86gen.exe: x86/x86gen.c glinternal.h main/context.h main/matrix.h tnl/tnl.h x86/cpu.h 113 | $(HOST_CC) -o $@ $(CFLAGS) $< 114 | 115 | clean:: 116 | -$(RM) $(OBJECTS) 117 | -$(RM) x86/*.o 118 | -$(RM) x86/x86chk.h 119 | -$(RM) x86/x86.inc 120 | 121 | realclean:: clean 122 | -$(RM) lib/libGL.so.1.1 123 | -------------------------------------------------------------------------------- /x86/sse_vertex.asm: -------------------------------------------------------------------------------- 1 | %include "xos.inc" 2 | 3 | %include "x86.inc" 4 | 5 | 6 | extrn tnl_vb 7 | extrn tnl_general_flags 8 | ;extrn tnl_flush, 4 9 | 10 | 11 | segment TEXT 12 | 13 | 14 | align 16 15 | f_0001 dd 0.0, 0.0, 0.0, 1.0 16 | 17 | 18 | align 16 19 | proc sse_Vertex3fv, 4 20 | mov eax, [esp + 4] ; const GLfloat *v 21 | mov ecx, [tnl_vb + TNL_VB_NUM] 22 | mov edx, ecx 23 | sal edx, 4 24 | add edx, [tnl_vb + TNL_VB_VERTEX_PTR] 25 | inc ecx 26 | mov [tnl_vb + TNL_VB_NUM], ecx 27 | movss xmm0, [eax + 8] 28 | shufps xmm0, [f_0001], SHUF(X, Y, Z, W) 29 | shufps xmm0, xmm0, SHUF(Y, Z, X, W) 30 | movlps xmm0, [eax] 31 | MOVUAPS [edx], xmm0 32 | cmp ecx, [tnl_vb + TNL_VB_MAX] 33 | je .0 34 | ret 35 | align 16 36 | .0: 37 | ; mov dword [esp + 8], 0 ; XXX unused 38 | ; jmp tnl_flush 39 | endp 40 | 41 | 42 | align 16 43 | proc sse_Color3fv, 4 44 | mov edx, [esp + 4] ; const GLfloat *v 45 | mov ecx, [tnl_vb + TNL_VB_NUM] 46 | mov eax, ecx 47 | sal eax, 4 48 | add eax, [tnl_vb + TNL_VB_COLOR0_PTR] 49 | movss xmm0, [edx + 8] 50 | shufps xmm0, [f_0001], SHUF(X, Y, Z, W) 51 | shufps xmm0, xmm0, SHUF(Y, Z, X, W) 52 | movlps xmm0, [edx] 53 | MOVUAPS [eax], xmm0 54 | mov eax, [tnl_vb + TNL_VB_FLAGS] 55 | or dword [eax + ecx * 4], TNL_COLOR0_BIT 56 | or dword [tnl_general_flags], TNL_COLOR0_BIT 57 | ret 58 | endp 59 | 60 | 61 | align 16 62 | proc sse_Color4fv, 4 63 | mov edx, [esp + 4] ; const GLfloat *v 64 | mov ecx, [tnl_vb + TNL_VB_NUM] 65 | mov eax, ecx 66 | sal eax, 4 67 | add eax, [tnl_vb + TNL_VB_COLOR0_PTR] 68 | movups xmm0, [edx] 69 | MOVUAPS [eax], xmm0 70 | mov eax, [tnl_vb + TNL_VB_FLAGS] 71 | or dword [eax + ecx * 4], TNL_COLOR0_BIT 72 | or dword [tnl_general_flags], TNL_COLOR0_BIT 73 | ret 74 | endp 75 | 76 | 77 | align 16 78 | proc sse_TexCoord2fv, 4 79 | mov edx, [esp + 4] ; const GLfloat *v 80 | mov ecx, [tnl_vb + TNL_VB_NUM] 81 | mov eax, ecx 82 | sal eax, 4 83 | add eax, [tnl_vb + TNL_VB_TEXCOORD0_PTR] 84 | MOVUAPS xmm0, [f_0001] 85 | movlps xmm0, [edx] 86 | MOVUAPS [eax], xmm0 87 | mov eax, [tnl_vb + TNL_VB_FLAGS] 88 | or dword [eax + ecx * 4], TNL_TEXCOORD0_BIT 89 | or dword [tnl_general_flags], TNL_TEXCOORD0_BIT 90 | ret 91 | endp 92 | 93 | 94 | align 16 95 | proc sse_MultiTexCoord2fv, 8 96 | push esi 97 | push ebx 98 | mov ecx, [esp + 12] ; GLenum texture 99 | mov esi, [esp + 16] ; const GLfloat *v 100 | mov ebx, [tnl_vb + TNL_VB_NUM] 101 | lea edx, [ecx + ecx * 2] ; EDX = ECX * 3 102 | mov eax, ebx 103 | sal eax, 4 104 | add eax, [tnl_vb + edx * 4 - GL_TEXTURE0 * sizeof_TNL_ARRAY + TNL_VB_TEXCOORD0_PTR] 105 | MOVUAPS xmm0, [f_0001] 106 | movlps xmm0, [esi] 107 | MOVUAPS [eax], xmm0 108 | mov edx, [tnl_vb + TNL_VB_FLAGS] 109 | sub ecx, GL_TEXTURE0 110 | mov eax, TNL_TEXCOORD0_BIT 111 | sal eax, cl 112 | or [edx + ebx * 4], eax 113 | or [tnl_general_flags], eax 114 | pop ebx 115 | pop esi 116 | ret 117 | endp 118 | -------------------------------------------------------------------------------- /drivers/foo/drv_vb.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "GL/gl.h" 4 | 5 | #include "glinternal.h" 6 | #include "util/macros.h" 7 | #include "main/context.h" 8 | #include "tnl/tnl.h" 9 | #include "main/matrix.h" /* for get_mvp() */ 10 | #include "driver.h" 11 | #include "drv.h" 12 | 13 | 14 | static void d_emitvertices (int n); 15 | static void d_copypv (int vdst, int vsrc); 16 | static void d_interp (float t, int vdst, int vout, int vin); 17 | 18 | 19 | void 20 | drv_render_init (void) 21 | { 22 | drv_emitvertices = d_emitvertices; 23 | drv_copypv = d_copypv; 24 | drv_interp = d_interp; 25 | 26 | setup_tri_pointers(); 27 | } 28 | 29 | 30 | void 31 | drv_render_fini (void) 32 | { 33 | } 34 | 35 | 36 | static void 37 | d_emitvertices (int n) 38 | { 39 | int i; 40 | SWvertex *vertex = vb; 41 | const GLfloat *view = ctx_mx_viewport.mat; 42 | for (i = 0; i < n; i++) { 43 | if (tnl_vb.clipmask[i] == 0) { 44 | vertex->x = tnl_vb.ndc[i][0] * view[0] + view[12]; 45 | vertex->y = tnl_vb.ndc[i][1] * view[5] + view[13]; 46 | vertex->z = tnl_vb.ndc[i][2] * view[10] + view[14]; 47 | vertex->oow = tnl_vb.ndc[i][3]; 48 | } else { 49 | vertex->oow = 1.0F; 50 | } 51 | 52 | vertex->r = tnl_vb.attr[TNL_COLOR0].data[i][0]; 53 | vertex->g = tnl_vb.attr[TNL_COLOR0].data[i][1]; 54 | vertex->b = tnl_vb.attr[TNL_COLOR0].data[i][2]; 55 | vertex->a = tnl_vb.attr[TNL_COLOR0].data[i][3]; 56 | printf("Color0: %f, %f, %f, %f\n", 57 | vertex->r, vertex->g, vertex->b, vertex->a); 58 | printf("Vertex: %f, %f, %f, %f\n", 59 | tnl_vb.attr[TNL_VERTEX].data[i][0], 60 | tnl_vb.attr[TNL_VERTEX].data[i][1], 61 | tnl_vb.attr[TNL_VERTEX].data[i][2], 62 | tnl_vb.attr[TNL_VERTEX].data[i][3]); 63 | printf("\n"); 64 | vertex++; 65 | } 66 | } 67 | 68 | 69 | static void 70 | d_copypv (int vdst, int vsrc) 71 | { 72 | const SWvertex *src = &vb[vsrc]; 73 | SWvertex *dst = &vb[vdst]; 74 | dst->r = src->r; 75 | dst->g = src->g; 76 | dst->b = src->b; 77 | dst->a = src->a; 78 | } 79 | 80 | 81 | static void 82 | d_interp (float t, int vdst, int vout, int vin) 83 | { 84 | const GLfloat *view = ctx_mx_viewport.mat; 85 | GLfloat4 *clip = &tnl_vb.clip[vdst]; 86 | SWvertex *dst = &vb[vdst]; 87 | SWvertex *in = &vb[vin]; 88 | SWvertex *out = &vb[vout]; 89 | const GLfloat oow = (clip[0][3] == 0.0F) ? 1.0F : (1.0F / clip[0][3]); 90 | const GLfloat wout = oow / out->oow; 91 | const GLfloat win = oow / in->oow; 92 | 93 | dst->x = clip[0][0] * oow * view[0] + view[12]; 94 | dst->y = clip[0][1] * oow * view[5] + view[13]; 95 | dst->z = clip[0][2] * oow * view[10] + view[14]; 96 | dst->oow = oow; 97 | 98 | INTERP_F(t, dst->r, out->r, in->r); 99 | INTERP_F(t, dst->g, out->g, in->g); 100 | INTERP_F(t, dst->b, out->b, in->b); 101 | INTERP_F(t, dst->a, out->a, in->a); 102 | } 103 | 104 | 105 | int 106 | drv_multipass_none (int pass) 107 | { 108 | return 0; 109 | } 110 | -------------------------------------------------------------------------------- /Makefile.DJ: -------------------------------------------------------------------------------- 1 | .PHONY: all clean realclean 2 | .SUFFIXES: .asm .o 3 | .INTERMEDIATE: x86/x86gen.exe 4 | 5 | DRIVER ?= glide 6 | 7 | all: lib/libgl.a lib/gl.dxe 8 | 9 | CC = gcc 10 | HOST_CC = gcc 11 | CFLAGS = -Wall 12 | CFLAGS += -Wno-unused 13 | CFLAGS += -O2 14 | # in case of problems disable -DNDEBUG to enable assertions 15 | CFLAGS += -DNDEBUG 16 | #CFLAGS += -g 17 | #CFLAGS += -ffast-math -DFAST_MATH 18 | CFLAGS += -I. -Iinclude -Idrivers 19 | CFLAGS += -D__DOS__ 20 | # disable software scaledown of hardware-unsupported large textures 21 | CFLAGS += -DFX_RESCALEHACK=0 22 | #CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=1 23 | LD = $(CC) 24 | LDFLAGS = 25 | AS = nasm 26 | ASFLAGS = -O2 -fcoff -D__DJGPP__ -Ix86/ -Imain/ --prefix _ 27 | # workaround the sse issue in DXE builds: note that this 28 | # is only needed for DXE, but not for the static library. 29 | ASFLAGS+= -DBROKEN_MOVAPS 30 | AR = ar 31 | ARFLAGS = crus 32 | DXE3GEN = dxe3gen 33 | DXE3FLAGS = -E _sage_ -E _gl -X _gl_ 34 | ifeq ($(DRIVER),glide) 35 | DXE3FLAGS+= -P glide3x.dxe 36 | endif 37 | 38 | CORE_SOURCES = \ 39 | util/cfg.c \ 40 | util/pow.c \ 41 | main/buffer.c \ 42 | main/color.c \ 43 | main/context.c \ 44 | main/cull.c \ 45 | main/depth.c \ 46 | main/stencil.c \ 47 | main/dlist.c \ 48 | main/enable.c \ 49 | main/get.c \ 50 | main/glapi.c \ 51 | main/glapic.c \ 52 | main/light.c \ 53 | main/matrix.c \ 54 | main/texture.c \ 55 | main/texstore.c \ 56 | main/texcodec.c \ 57 | main/texdef.c \ 58 | main/fog.c \ 59 | main/ext.c \ 60 | main/pixel.c \ 61 | main/raster.c \ 62 | main/attrib.c \ 63 | main/fake.c \ 64 | main/legacy.c \ 65 | util/alloc.c 66 | 67 | TNL_SOURCES = \ 68 | tnl/tnl.c \ 69 | tnl/tnl_prim.c \ 70 | tnl/tnl_pipeline.c \ 71 | tnl/tnl_setup.c \ 72 | tnl/imm_api.c \ 73 | tnl/imm_array.c \ 74 | tnl/imm_vertex.c \ 75 | tnl/sav_api.c \ 76 | tnl/sav_array.c \ 77 | tnl/sav_vertex.c 78 | 79 | ifeq ($(X86),1) 80 | CFLAGS += -DX86 81 | X86_SOURCES = \ 82 | x86/x86.c \ 83 | x86/cpuhard.c \ 84 | x86/cpusoft.asm \ 85 | x86/glapia.asm \ 86 | x86/x86_vertex.asm \ 87 | x86/x86_clip.asm \ 88 | x86/k3d_mat.asm \ 89 | x86/k3d_clip.asm \ 90 | x86/k3d_misc.asm \ 91 | x86/sse_vertex.asm \ 92 | x86/sse_mat.asm \ 93 | x86/sse_clip.asm \ 94 | x86/sse_misc.asm 95 | 96 | x86/x86.o: x86/x86chk.h 97 | endif 98 | 99 | include drivers/$(DRIVER)/config 100 | 101 | SOURCES = $(CORE_SOURCES) $(TNL_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES) 102 | 103 | OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) 104 | 105 | .c.o: 106 | $(CC) -o $@ $(CFLAGS) -c $< 107 | .asm.o: 108 | $(AS) -o $@ $(ASFLAGS) $< 109 | 110 | lib/libgl.a: $(OBJECTS) 111 | $(AR) $(ARFLAGS) $@ $^ 112 | 113 | lib/gl.dxe: $(OBJECTS) 114 | -$(DXE3GEN) -o $@ -Y lib/libigl.a $(DXE3FLAGS) -U $(OBJECTS) 115 | 116 | $(X86_SOURCES:.asm=.o): x86/x86.inc 117 | 118 | x86/x86.inc: x86/x86gen.exe 119 | $< -o $@ 120 | 121 | x86/x86chk.h: x86/x86gen.exe 122 | $< -c -o $@ 123 | 124 | x86/x86gen.exe: x86/x86gen.c glinternal.h main/context.h main/matrix.h tnl/tnl.h x86/cpu.h 125 | $(HOST_CC) -o $@ $(CFLAGS) $< 126 | 127 | clean:: 128 | -$(RM) $(OBJECTS) 129 | -$(RM) x86/*.o 130 | -$(RM) x86/x86chk.h 131 | -$(RM) x86/x86.inc 132 | 133 | realclean:: clean 134 | -$(RM) lib/libgl.a 135 | -$(RM) lib/gl.dxe 136 | -$(RM) lib/libigl.a 137 | -------------------------------------------------------------------------------- /Makefile.mgw: -------------------------------------------------------------------------------- 1 | .PHONY: all clean realclean 2 | .SUFFIXES: .asm .o .rc .res 3 | .INTERMEDIATE: x86/x86gen.exe 4 | 5 | DRIVER ?= glide 6 | 7 | all: lib/opengl32.dll lib/libopengl32.a 8 | 9 | CC = gcc 10 | HOST_CC = gcc 11 | CFLAGS = -m32 -Wall 12 | CFLAGS += -Wno-unused 13 | CFLAGS += -O2 14 | # in case of problems disable -DNDEBUG to enable assertions 15 | CFLAGS += -DNDEBUG 16 | #CFLAGS += -g 17 | CFLAGS += -ffast-math -DFAST_MATH 18 | CFLAGS += -I. -Iinclude -Idrivers 19 | # disable software scaledown of hardware-unsupported large textures 20 | #CFLAGS += -DFX_RESCALEHACK=0 21 | LD = $(CC) 22 | LDFLAGS = -m32 -Wl,--enable-auto-image-base -Wl,--no-undefined -Wl,-k 23 | LDLIBS = 24 | AS = nasm 25 | ASFLAGS = -O2 -fwin32 -D__WIN32__ -Ix86/ -Imain/ --prefix _ 26 | RC = windres 27 | RCFLAGS = --output-format=coff --target=pe-i386 28 | DLLTOOL = dlltool 29 | 30 | CORE_SOURCES = \ 31 | util/cfg.c \ 32 | util/pow.c \ 33 | main/buffer.c \ 34 | main/color.c \ 35 | main/context.c \ 36 | main/cull.c \ 37 | main/depth.c \ 38 | main/stencil.c \ 39 | main/dlist.c \ 40 | main/enable.c \ 41 | main/get.c \ 42 | main/glapi.c \ 43 | main/glapic.c \ 44 | main/light.c \ 45 | main/matrix.c \ 46 | main/texture.c \ 47 | main/texstore.c \ 48 | main/texcodec.c \ 49 | main/texdef.c \ 50 | main/fog.c \ 51 | main/ext.c \ 52 | main/pixel.c \ 53 | main/raster.c \ 54 | main/attrib.c \ 55 | main/fake.c \ 56 | main/legacy.c \ 57 | util/alloc.c 58 | 59 | TNL_SOURCES = \ 60 | tnl/tnl.c \ 61 | tnl/tnl_prim.c \ 62 | tnl/tnl_pipeline.c \ 63 | tnl/tnl_setup.c \ 64 | tnl/imm_api.c \ 65 | tnl/imm_array.c \ 66 | tnl/imm_vertex.c \ 67 | tnl/sav_api.c \ 68 | tnl/sav_array.c \ 69 | tnl/sav_vertex.c 70 | 71 | ifeq ($(X86),1) 72 | CFLAGS += -DX86 73 | X86_SOURCES = \ 74 | x86/x86.c \ 75 | x86/cpuhard.c \ 76 | x86/cpusoft.asm \ 77 | x86/glapia.asm \ 78 | x86/x86_vertex.asm \ 79 | x86/x86_clip.asm \ 80 | x86/k3d_mat.asm \ 81 | x86/k3d_clip.asm \ 82 | x86/k3d_misc.asm \ 83 | x86/sse_vertex.asm \ 84 | x86/sse_mat.asm \ 85 | x86/sse_clip.asm \ 86 | x86/sse_misc.asm 87 | 88 | x86/x86.o: x86/x86chk.h 89 | endif 90 | 91 | include drivers/$(DRIVER)/config 92 | DRIVER_SOURCES += \ 93 | drivers/$(DRIVER)/wgl.c 94 | 95 | SOURCES = $(CORE_SOURCES) $(TNL_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES) 96 | 97 | OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) 98 | 99 | .c.o: 100 | $(CC) -o $@ $(CFLAGS) -c $< 101 | .asm.o: 102 | $(AS) -o $@ $(ASFLAGS) $< 103 | .rc.res: 104 | $(RC) -o $@ $(RCFLAGS) $< 105 | 106 | lib/libopengl32.a: 107 | $(DLLTOOL) --as-flags=--32 -m i386 --dllname opengl32.dll --input-def drivers/opengl32.def --output-lib $@ -k 108 | 109 | lib/opengl32.dll: $(OBJECTS) drivers/$(DRIVER)/opengl.res drivers/opengl32.def 110 | $(LD) -shared -o $@ $^ $(LDFLAGS) $(LDLIBS) 111 | 112 | $(X86_SOURCES:.asm=.o): x86/x86.inc 113 | 114 | x86/x86.inc: x86/x86gen.exe 115 | $< -o $@ 116 | 117 | x86/x86chk.h: x86/x86gen.exe 118 | $< -c -o $@ 119 | 120 | x86/x86gen.exe: x86/x86gen.c glinternal.h main/context.h main/matrix.h tnl/tnl.h x86/cpu.h 121 | $(HOST_CC) -o $@ $(CFLAGS) $< 122 | 123 | clean:: 124 | -$(RM) $(OBJECTS) 125 | -$(RM) drivers/$(DRIVER)/opengl.res 126 | -$(RM) x86/*.o 127 | -$(RM) x86/x86chk.h 128 | -$(RM) x86/x86.inc 129 | 130 | realclean:: clean 131 | -$(RM) lib/opengl32.dll 132 | -$(RM) lib/libopengl32.a 133 | -------------------------------------------------------------------------------- /tnl/imm_api.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "GL/gl.h" 4 | 5 | #include "glinternal.h" 6 | #include "main/glapi.h" 7 | #include "main/context.h" 8 | #include "util/macros.h" 9 | #include "tnl.h" 10 | 11 | 12 | void GLAPIENTRY 13 | imm_Begin (GLenum mode) 14 | { 15 | if (tnl_primitive != TNL_OUTSIDE_BE) { 16 | gl_assert(0); 17 | return; 18 | } 19 | if (tnl_prim_num >= TNL_PRIM_MAX) { 20 | gl_assert(0); 21 | return; 22 | } 23 | 24 | /* start building a new primitive */ 25 | tnl_prim[tnl_prim_num].start = tnl_vb.num; 26 | tnl_prim[tnl_prim_num].count = -tnl_vb.num; 27 | tnl_prim[tnl_prim_num].name = mode | TNL_PRIM_BEGIN; 28 | tnl_prim_num++; 29 | 30 | /* track the current primitive name */ 31 | tnl_primitive = mode; 32 | } 33 | 34 | 35 | void GLAPIENTRY 36 | imm_End (void) 37 | { 38 | if (tnl_primitive == TNL_OUTSIDE_BE) { 39 | gl_assert(0); 40 | return; 41 | } 42 | 43 | /* close the primitive */ 44 | tnl_prim[tnl_prim_num - 1].name |= TNL_PRIM_END; 45 | tnl_prim[tnl_prim_num - 1].count += tnl_vb.num; 46 | 47 | /* see if we can handle more primitives */ 48 | if (tnl_prim_num == TNL_PRIM_MAX) { 49 | /* flush the vertices */ 50 | tnl_flush(); 51 | } 52 | 53 | /* track the current primitive name: we're outside Begin/End */ 54 | tnl_primitive = TNL_OUTSIDE_BE; 55 | } 56 | 57 | 58 | void GLAPIENTRY 59 | imm_Finish (void) 60 | { 61 | /* block until all GL execution is complete */ 62 | tnl_flush(); 63 | } 64 | 65 | 66 | void GLAPIENTRY 67 | imm_Flush (void) 68 | { 69 | /* force execution of GL commands in finite time */ 70 | tnl_flush(); 71 | } 72 | 73 | 74 | #define RECT_F(x1, y1, x2, y2) \ 75 | do { \ 76 | imm_Begin(GL_POLYGON); \ 77 | imm_Vertex2f(x1, y1); \ 78 | imm_Vertex2f(x2, y1); \ 79 | imm_Vertex2f(x2, y2); \ 80 | imm_Vertex2f(x1, y2); \ 81 | imm_End(); \ 82 | } while (0) 83 | 84 | 85 | void GLAPIENTRY 86 | imm_Rectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) 87 | { 88 | RECT_F(x1, y1, x2, y2); 89 | } 90 | 91 | 92 | void GLAPIENTRY 93 | imm_Rectfv (const GLfloat *v1, const GLfloat *v2) 94 | { 95 | RECT_F(v1[0], v1[1], v2[0], v2[1]); 96 | } 97 | 98 | 99 | /* variations */ 100 | 101 | 102 | void GLAPIENTRY 103 | imm_Rectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) 104 | { 105 | RECT_F(x1, y1, x2, y2); 106 | } 107 | 108 | 109 | void GLAPIENTRY 110 | imm_Rectdv (const GLdouble *v1, const GLdouble *v2) 111 | { 112 | RECT_F(v1[0], v1[1], v2[0], v2[1]); 113 | } 114 | 115 | 116 | void GLAPIENTRY 117 | imm_Recti (GLint x1, GLint y1, GLint x2, GLint y2) 118 | { 119 | RECT_F(I_TO_FLOAT(x1), I_TO_FLOAT(y1), I_TO_FLOAT(x2), I_TO_FLOAT(y2)); 120 | } 121 | 122 | 123 | void GLAPIENTRY 124 | imm_Rectiv (const GLint *v1, const GLint *v2) 125 | { 126 | RECT_F(I_TO_FLOAT(v1[0]), I_TO_FLOAT(v1[1]), I_TO_FLOAT(v2[0]), I_TO_FLOAT(v2[1])); 127 | } 128 | 129 | 130 | void GLAPIENTRY 131 | imm_Rects (GLshort x1, GLshort y1, GLshort x2, GLshort y2) 132 | { 133 | RECT_F(S_TO_FLOAT(x1), S_TO_FLOAT(y1), S_TO_FLOAT(x2), S_TO_FLOAT(y2)); 134 | } 135 | 136 | 137 | void GLAPIENTRY 138 | imm_Rectsv (const GLshort *v1, const GLshort *v2) 139 | { 140 | RECT_F(S_TO_FLOAT(v1[0]), S_TO_FLOAT(v1[1]), S_TO_FLOAT(v2[0]), S_TO_FLOAT(v2[1])); 141 | } 142 | -------------------------------------------------------------------------------- /x86/x86_vertex.asm: -------------------------------------------------------------------------------- 1 | %include "xos.inc" 2 | 3 | %include "x86.inc" 4 | 5 | 6 | extrn tnl_vb 7 | extrn tnl_general_flags 8 | ;extrn tnl_flush, 4 9 | 10 | 11 | segment TEXT 12 | 13 | 14 | align 16 15 | proc x86_Vertex3fv, 4 16 | push ebx 17 | mov ebx, [esp + 8] ; const GLfloat *v 18 | mov ecx, [tnl_vb + TNL_VB_NUM] 19 | mov edx, ecx 20 | sal edx, 4 21 | add edx, [tnl_vb + TNL_VB_VERTEX_PTR] 22 | inc ecx 23 | mov [tnl_vb + TNL_VB_NUM], ecx 24 | mov eax, [ebx] 25 | mov [edx], eax 26 | mov eax, [ebx + 4] 27 | mov [edx + 4], eax 28 | mov eax, [ebx + 8] 29 | mov [edx + 8], eax 30 | mov dword [edx + 12], 0x3f800000 31 | cmp ecx, [tnl_vb + TNL_VB_MAX] 32 | je .0 33 | pop ebx 34 | ret 35 | align 16 36 | .0: 37 | ; mov dword [esp + 8], 0 ; XXX unused 38 | pop ebx 39 | ; jmp tnl_flush 40 | endp 41 | 42 | 43 | align 16 44 | proc x86_Color3fv, 4 45 | push ebx 46 | mov ecx, [esp + 8] ; const GLfloat *v 47 | mov ebx, [tnl_vb + TNL_VB_NUM] 48 | mov edx, ebx 49 | sal edx, 4 50 | add edx, [tnl_vb + TNL_VB_COLOR0_PTR] 51 | mov eax, [ecx] 52 | mov [edx], eax 53 | mov eax, [ecx + 4] 54 | mov [edx + 4], eax 55 | mov eax, [ecx + 8] 56 | mov [edx + 8], eax 57 | mov dword [edx + 12], 0x3f800000 58 | mov eax, [tnl_vb + TNL_VB_FLAGS] 59 | or dword [eax + ebx * 4], TNL_COLOR0_BIT 60 | or dword [tnl_general_flags], TNL_COLOR0_BIT 61 | pop ebx 62 | ret 63 | endp 64 | 65 | 66 | align 16 67 | proc x86_Color4fv, 4 68 | push ebx 69 | mov ecx, [esp + 8] ; const GLfloat *v 70 | mov ebx, [tnl_vb + TNL_VB_NUM] 71 | mov edx, ebx 72 | sal edx, 4 73 | add edx, [tnl_vb + TNL_VB_COLOR0_PTR] 74 | mov eax, [ecx] 75 | mov [edx], eax 76 | mov eax, [ecx + 4] 77 | mov [edx + 4], eax 78 | mov eax, [ecx + 8] 79 | mov [edx + 8], eax 80 | mov eax, [ecx + 12] 81 | mov [edx + 12], eax 82 | mov eax, [tnl_vb + TNL_VB_FLAGS] 83 | or dword [eax + ebx * 4], TNL_COLOR0_BIT 84 | or dword [tnl_general_flags], TNL_COLOR0_BIT 85 | pop ebx 86 | ret 87 | endp 88 | 89 | 90 | align 16 91 | proc x86_TexCoord2fv, 4 92 | push ebx 93 | mov ebx, [esp + 8] ; const GLfloat *v 94 | mov ecx, [tnl_vb + TNL_VB_NUM] 95 | mov eax, ecx 96 | sal eax, 4 97 | add eax, [tnl_vb + TNL_VB_TEXCOORD0_PTR] 98 | mov edx, [ebx] 99 | mov [eax], edx 100 | mov edx, [ebx + 4] 101 | mov [eax + 4], edx 102 | mov dword [eax + 8], 0x00000000 103 | mov dword [eax + 12], 0x3f800000 104 | mov eax, [tnl_vb + TNL_VB_FLAGS] 105 | or dword [eax + ecx * 4], TNL_TEXCOORD0_BIT 106 | or dword [tnl_general_flags], TNL_TEXCOORD0_BIT 107 | pop ebx 108 | ret 109 | endp 110 | 111 | 112 | align 16 113 | proc x86_MultiTexCoord2fv, 8 114 | push esi 115 | push ebx 116 | mov ecx, [esp + 12] ; GLenum texture 117 | mov esi, [esp + 16] ; const GLfloat *v 118 | mov ebx, [tnl_vb + TNL_VB_NUM] 119 | lea edx, [ecx + ecx * 2] ; EDX = ECX * 3 120 | mov eax, ebx 121 | sal eax, 4 122 | add eax, [tnl_vb + edx * 4 - GL_TEXTURE0 * sizeof_TNL_ARRAY + TNL_VB_TEXCOORD0_PTR] 123 | mov edx, [esi] 124 | mov [eax], edx 125 | mov edx, [esi + 4] 126 | mov [eax + 4], edx 127 | mov dword [eax + 8], 0x00000000 128 | mov dword [eax + 12], 0x3f800000 129 | mov edx, [tnl_vb + TNL_VB_FLAGS] 130 | sub ecx, GL_TEXTURE0 131 | mov eax, TNL_TEXCOORD0_BIT 132 | sal eax, cl 133 | or [edx + ebx * 4], eax 134 | or [tnl_general_flags], eax 135 | pop ebx 136 | pop esi 137 | ret 138 | endp 139 | -------------------------------------------------------------------------------- /util/macros.h: -------------------------------------------------------------------------------- 1 | #ifndef MACROS_H_included 2 | #define MACROS_H_included 3 | 4 | 5 | #ifdef __DJGPP__ 6 | #define SQRT(x) sqrt(x) 7 | #define COS(x) cos(x) 8 | #define SIN(x) sin(x) 9 | #define FABS(x) fabs(x) 10 | #define EXP(x) exp(x) 11 | #define POW(x, y) pow(x, y) 12 | #else 13 | #define SQRT(x) sqrtf(x) 14 | #define COS(x) cosf(x) 15 | #define SIN(x) sinf(x) 16 | #define FABS(x) fabsf(x) 17 | #define EXP(x) expf(x) 18 | #define POW(x, y) powf(x, y) 19 | #endif 20 | 21 | 22 | #define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT))) 23 | 24 | 25 | #define INTERP_UB( t, dstub, outub, inub ) \ 26 | do { \ 27 | GLfloat inf = inub; \ 28 | GLfloat outf = outub; \ 29 | GLfloat dstf = LINTERP( t, outf, inf ); \ 30 | dstub = dstf; \ 31 | } while (0) 32 | 33 | 34 | #define INTERP_F( t, dstf, outf, inf ) \ 35 | dstf = LINTERP( t, outf, inf ) 36 | 37 | 38 | #define INTERP_4F( t, dst, out, in ) \ 39 | do { \ 40 | dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \ 41 | dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \ 42 | dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \ 43 | dst[3] = LINTERP( (t), (out)[3], (in)[3] ); \ 44 | } while (0) 45 | 46 | 47 | #define MAX2(x, y) (((x) < (y)) ? (y) : (x)) 48 | #define MIN2(x, y) (((x) > (y)) ? (y) : (x)) 49 | 50 | 51 | typedef union { 52 | GLint i; 53 | GLfloat f; 54 | } fi_type; 55 | 56 | 57 | static __inline int 58 | IS_NEGATIVE (GLfloat f) 59 | { 60 | fi_type fi; 61 | fi.f = f; 62 | return (fi.i < 0); 63 | } 64 | 65 | 66 | static __inline int 67 | DIFFERENT_SIGNS (GLfloat f1, GLfloat f2) 68 | { 69 | fi_type fi1, fi2; 70 | fi1.f = f1; 71 | fi2.f = f2; 72 | return ((fi1.i < 0) ^ (fi2.i < 0)); 73 | } 74 | 75 | 76 | static __inline GLfloat 77 | CLAMPF (GLfloat f) 78 | { 79 | #define IEEE_0996 0x3f7f0000 /* 0.996 or so */ 80 | fi_type fi; 81 | fi.f = f; 82 | if (fi.i < 0) { 83 | return 0.0F; 84 | } else if (fi.i > IEEE_0996) { 85 | return 1.0F; 86 | } else { 87 | return f; 88 | } 89 | } 90 | 91 | 92 | extern GLfloat ub_to_float[]; 93 | 94 | 95 | #define B_TO_FLOAT(b) ((2.0F * (b) + 1.0F) * (1.0F/255.0F)) 96 | #define UB_TO_FLOAT(u) ub_to_float[(GLuint)u]/*((GLfloat)(u) / 255.0F)*/ 97 | #define S_TO_FLOAT(s) ((2.0F * (s) + 1.0F) * (1.0F/65535.0F)) 98 | #define US_TO_FLOAT(u) ((GLfloat)(u) / 65535.0F) 99 | #define I_TO_FLOAT(i) ((2.0F * (i) + 1.0F) * (1.0F/4294967295.0F)) 100 | #define UI_TO_FLOAT(u) ((GLfloat)(u) / 4294967295.0F) 101 | 102 | 103 | #define when(x) if (x) 104 | 105 | 106 | #define DOT3(x, y) ((x)[0] * (y)[0] + (x)[1] * (y)[1] + (x)[2] * (y)[2]) 107 | #define DOT4(x, y) ((x)[0] * (y)[0] + (x)[1] * (y)[1] + (x)[2] * (y)[2] + (x)[3] * (y)[3]) 108 | #define SQLEN3(x) DOT3(x, x) 109 | 110 | #define NORM3(u, S, v) \ 111 | do { \ 112 | GLfloat dp = SQLEN3(v); \ 113 | dp = S 1.0F / SQRT(dp); \ 114 | (u)[0] = (v)[0] * dp; \ 115 | (u)[1] = (v)[1] * dp; \ 116 | (u)[2] = (v)[2] * dp; \ 117 | } while (0) 118 | 119 | 120 | static __inline GLushort 121 | SWAP_SHORT (GLushort s) 122 | { 123 | return (s >> 8) | (s << 8); 124 | } 125 | 126 | 127 | #define PTR_ADD_STRIDE(type, ptr, stride) ptr = (type *)((GLubyte *)ptr + stride) 128 | 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /doc/texenv/tree.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "util.h" 7 | #include "tree.h" 8 | 9 | 10 | #define PRECEDENCE(f, s) \ 11 | ( \ 12 | (((f)->val.ch == '*' || (f)->val.ch == '/') && \ 13 | (s)->type == N_OP && ((s)->val.ch == '+' || (s)->val.ch == '-')) \ 14 | || \ 15 | ((f)->val.ch == '-' && \ 16 | (s)->type == N_OP && (s)->val.ch != '*' && (s)->val.ch != '/') \ 17 | ) 18 | 19 | 20 | NODE * 21 | tree_node_op (int op) 22 | { 23 | NODE *n = malloc(sizeof(NODE)); 24 | assert(n); 25 | n->type = N_OP; 26 | n->val.ch = op; 27 | return n; 28 | } 29 | 30 | 31 | NODE * 32 | tree_node_var (const char *var) 33 | { 34 | NODE *n = malloc(sizeof(NODE)); 35 | assert(n); 36 | n->type = N_VAR; 37 | n->val.name = str_dup(var); 38 | assert(n->val.name); 39 | return n; 40 | } 41 | 42 | 43 | void 44 | tree_display (NODE *node) 45 | { 46 | if (node->type == N_OP) { 47 | if (node->left) { 48 | if (PRECEDENCE(node, node->left)) { 49 | printf("("); 50 | } 51 | tree_display(node->left); 52 | if (PRECEDENCE(node, node->left)) { 53 | printf(")"); 54 | } 55 | printf(" %c ", node->val.ch); 56 | } else { 57 | printf("%c", node->val.ch); 58 | } 59 | if (PRECEDENCE(node, node->right)) { 60 | printf("("); 61 | } 62 | tree_display(node->right); 63 | if (PRECEDENCE(node, node->right)) { 64 | printf(")"); 65 | } 66 | } else { 67 | printf("%s", node->val.name); 68 | } 69 | } 70 | 71 | 72 | void 73 | tree_destroy (NODE *node) 74 | { 75 | if (node->type == N_OP) { 76 | if (node->left) { 77 | tree_destroy(node->left); 78 | } 79 | tree_destroy(node->right); 80 | } else { 81 | free((char *)node->val.name); 82 | } 83 | free(node); 84 | } 85 | 86 | 87 | int 88 | tree_check_var (NODE *node, const char *var) 89 | { 90 | return (node->type == N_VAR && !strcmp(node->val.name, var)); 91 | } 92 | 93 | 94 | NODE ** 95 | tree_find_var (NODE *node, const char *var) 96 | { 97 | NODE **rv; 98 | if (node->type == N_OP) { 99 | if (node->left != NULL) { 100 | if (tree_check_var(node->left, var)) { 101 | return &node->left; 102 | } 103 | rv = tree_find_var(node->left, var); 104 | if (rv != NULL) { 105 | return rv; 106 | } 107 | } 108 | if (tree_check_var(node->right, var)) { 109 | return &node->right; 110 | } 111 | rv = tree_find_var(node->right, var); 112 | if (rv != NULL) { 113 | return rv; 114 | } 115 | } 116 | return NULL; 117 | } 118 | 119 | 120 | const char * 121 | tree_string (NODE *node, int init) 122 | { 123 | static char buf[1024]; 124 | static int len; 125 | 126 | if (init) { 127 | len = 0; 128 | } 129 | 130 | if (node->type == N_OP) { 131 | if (node->left) { 132 | if (PRECEDENCE(node, node->left)) { 133 | len += sprintf(&buf[len], "("); 134 | } 135 | tree_string(node->left, 0); 136 | if (PRECEDENCE(node, node->left)) { 137 | len += sprintf(&buf[len], ")"); 138 | } 139 | len += sprintf(&buf[len], " %c ", node->val.ch); 140 | } else { 141 | len += sprintf(&buf[len], "%c", node->val.ch); 142 | } 143 | if (PRECEDENCE(node, node->right)) { 144 | len += sprintf(&buf[len], "("); 145 | } 146 | tree_string(node->right, 0); 147 | if (PRECEDENCE(node, node->right)) { 148 | len += sprintf(&buf[len], ")"); 149 | } 150 | } else { 151 | len += sprintf(&buf[len], "%s", node->val.name); 152 | } 153 | return buf; 154 | } 155 | -------------------------------------------------------------------------------- /x86/sse_mat.asm: -------------------------------------------------------------------------------- 1 | %include "xos.inc" 2 | 3 | %include "x86.inc" 4 | 5 | 6 | segment TEXT 7 | 8 | 9 | align 16 10 | proc matrix_mul_vec4_sse 11 | mov edx, [esp+4] 12 | mov ecx, [esp+8] 13 | mov eax, [esp+12] 14 | movups xmm4, [ecx] 15 | movups xmm5, [ecx+0x10] 16 | movups xmm6, [ecx+0x20] 17 | movups xmm7, [ecx+0x30] 18 | movups xmm0, [eax] 19 | movups xmm1, xmm0 20 | movups xmm2, xmm0 21 | movups xmm3, xmm0 22 | shufps xmm0, xmm0, SHUF(X, X, X, X) 23 | shufps xmm1, xmm1, SHUF(Y, Y, Y, Y) 24 | shufps xmm2, xmm2, SHUF(Z, Z, Z, Z) 25 | shufps xmm3, xmm3, SHUF(W, W, W, W) 26 | mulps xmm0, xmm4 27 | mulps xmm1, xmm5 28 | mulps xmm2, xmm6 29 | mulps xmm3, xmm7 30 | addps xmm1, xmm0 31 | addps xmm2, xmm3 32 | addps xmm1, xmm2 33 | movups [edx], xmm1 34 | ret 35 | endp 36 | 37 | 38 | align 16 39 | proc matrix_mul_vec3_sse 40 | mov edx, [esp+4] 41 | mov ecx, [esp+8] 42 | mov eax, [esp+12] 43 | movups xmm4, [ecx] 44 | movups xmm5, [ecx+0x10] 45 | movups xmm6, [ecx+0x20] 46 | movups xmm7, [ecx+0x30] 47 | movups xmm0, [eax] 48 | movups xmm1, xmm0 49 | movups xmm2, xmm0 50 | shufps xmm0, xmm0, SHUF(X, X, X, X) 51 | shufps xmm1, xmm1, SHUF(Y, Y, Y, Y) 52 | shufps xmm2, xmm2, SHUF(Z, Z, Z, Z) 53 | mulps xmm0, xmm4 54 | mulps xmm1, xmm5 55 | mulps xmm2, xmm6 56 | addps xmm1, xmm0 57 | addps xmm2, xmm7 58 | addps xmm1, xmm2 59 | movups [edx], xmm1 60 | ret 61 | endp 62 | 63 | 64 | align 16 65 | proc matrix_mul_vec4_batch_sse 66 | mov edx, [esp+4] 67 | mov ecx, [esp+8] 68 | mov eax, [esp+12] 69 | movups xmm4, [ecx] 70 | movups xmm5, [ecx+0x10] 71 | movups xmm6, [ecx+0x20] 72 | movups xmm7, [ecx+0x30] 73 | mov ecx, [esp+16] 74 | align 16 75 | .0: 76 | MOVUAPS xmm0, [eax] 77 | prefetchnta [eax+0x30] 78 | MOVUAPS xmm1, xmm0 79 | add eax, 16 80 | MOVUAPS xmm2, xmm0 81 | add edx, 16 82 | MOVUAPS xmm3, xmm0 83 | prefetchnta [edx+0x20] 84 | shufps xmm0, xmm0, SHUF(X, X, X, X) 85 | shufps xmm1, xmm1, SHUF(Y, Y, Y, Y) 86 | shufps xmm2, xmm2, SHUF(Z, Z, Z, Z) 87 | shufps xmm3, xmm3, SHUF(W, W, W, W) 88 | mulps xmm0, xmm4 89 | mulps xmm1, xmm5 90 | mulps xmm2, xmm6 91 | mulps xmm3, xmm7 92 | addps xmm1, xmm0 93 | addps xmm2, xmm3 94 | addps xmm1, xmm2 95 | MOVUAPS [edx-16], xmm1 96 | dec ecx 97 | jnz .0 98 | ret 99 | endp 100 | 101 | 102 | align 16 103 | proc matrix_mul_vec3_batch_sse 104 | mov edx, [esp+4] 105 | mov ecx, [esp+8] 106 | mov eax, [esp+12] 107 | movups xmm4, [ecx] 108 | movups xmm5, [ecx+0x10] 109 | movups xmm6, [ecx+0x20] 110 | movups xmm7, [ecx+0x30] 111 | mov ecx, [esp+16] 112 | align 16 113 | .0: 114 | MOVUAPS xmm0, [eax] 115 | prefetchnta [eax+0x30] 116 | MOVUAPS xmm1, xmm0 117 | add eax, 16 118 | MOVUAPS xmm2, xmm0 119 | add edx, 16 120 | prefetchnta [edx+0x20] 121 | shufps xmm0, xmm0, SHUF(X, X, X, X) 122 | shufps xmm1, xmm1, SHUF(Y, Y, Y, Y) 123 | shufps xmm2, xmm2, SHUF(Z, Z, Z, Z) 124 | mulps xmm0, xmm4 125 | mulps xmm1, xmm5 126 | mulps xmm2, xmm6 127 | addps xmm1, xmm0 128 | addps xmm2, xmm7 129 | addps xmm1, xmm2 130 | MOVUAPS [edx-16], xmm1 131 | dec ecx 132 | jnz .0 133 | ret 134 | endp 135 | 136 | 137 | align 16 138 | proc matrix_mul_vec_rot_sse 139 | mov edx, [esp+4] 140 | mov ecx, [esp+8] 141 | mov eax, [esp+12] 142 | movups xmm4, [ecx] 143 | movups xmm5, [ecx+0x10] 144 | movups xmm6, [ecx+0x20] 145 | movups xmm0, [eax] 146 | movups xmm1, xmm0 147 | movups xmm2, xmm0 148 | shufps xmm0, xmm0, SHUF(X, X, X, X) 149 | shufps xmm1, xmm1, SHUF(Y, Y, Y, Y) 150 | shufps xmm2, xmm2, SHUF(Z, Z, Z, Z) 151 | mulps xmm0, xmm4 152 | mulps xmm1, xmm5 153 | mulps xmm2, xmm6 154 | addps xmm1, xmm0 155 | addps xmm1, xmm2 156 | movups [edx], xmm1 157 | ret 158 | endp 159 | -------------------------------------------------------------------------------- /doc/conform/util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * OpenGL testsuite 3 | * Version: 0.1 4 | * 5 | * Copyright (C) 2005 Daniel Borca All Rights Reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /* 27 | * Miscellaneous functions. 28 | */ 29 | 30 | 31 | #include 32 | #include 33 | 34 | #include "util.h" 35 | 36 | 37 | const char * 38 | blend_src_name (GLenum factor) 39 | { 40 | switch (factor) { 41 | CASE_STRING(GL_ZERO); 42 | CASE_STRING(GL_ONE); 43 | CASE_STRING(GL_SRC_COLOR); 44 | CASE_STRING(GL_ONE_MINUS_SRC_COLOR); 45 | CASE_STRING(GL_DST_COLOR); 46 | CASE_STRING(GL_ONE_MINUS_DST_COLOR); 47 | CASE_STRING(GL_SRC_ALPHA); 48 | CASE_STRING(GL_ONE_MINUS_SRC_ALPHA); 49 | CASE_STRING(GL_DST_ALPHA); 50 | CASE_STRING(GL_ONE_MINUS_DST_ALPHA); 51 | CASE_STRING(GL_CONSTANT_COLOR); 52 | CASE_STRING(GL_ONE_MINUS_CONSTANT_COLOR); 53 | CASE_STRING(GL_CONSTANT_ALPHA); 54 | CASE_STRING(GL_ONE_MINUS_CONSTANT_ALPHA); 55 | CASE_STRING(GL_SRC_ALPHA_SATURATE); 56 | NODEFAULT; 57 | } 58 | } 59 | 60 | 61 | const char * 62 | blend_dst_name (GLenum factor) 63 | { 64 | switch (factor) { 65 | CASE_STRING(GL_ZERO); 66 | CASE_STRING(GL_ONE); 67 | CASE_STRING(GL_SRC_COLOR); 68 | CASE_STRING(GL_ONE_MINUS_SRC_COLOR); 69 | CASE_STRING(GL_DST_COLOR); 70 | CASE_STRING(GL_ONE_MINUS_DST_COLOR); 71 | CASE_STRING(GL_SRC_ALPHA); 72 | CASE_STRING(GL_ONE_MINUS_SRC_ALPHA); 73 | CASE_STRING(GL_DST_ALPHA); 74 | CASE_STRING(GL_ONE_MINUS_DST_ALPHA); 75 | CASE_STRING(GL_CONSTANT_COLOR); 76 | CASE_STRING(GL_ONE_MINUS_CONSTANT_COLOR); 77 | CASE_STRING(GL_CONSTANT_ALPHA); 78 | CASE_STRING(GL_ONE_MINUS_CONSTANT_ALPHA); 79 | NODEFAULT; 80 | } 81 | } 82 | 83 | 84 | const char * 85 | blend_eq_name (GLenum eq) 86 | { 87 | switch (eq) { 88 | CASE_STRING(GL_FUNC_ADD); 89 | CASE_STRING(GL_FUNC_SUBTRACT); 90 | CASE_STRING(GL_FUNC_REVERSE_SUBTRACT); 91 | CASE_STRING(GL_MIN); 92 | CASE_STRING(GL_MAX); 93 | NODEFAULT; 94 | } 95 | } 96 | 97 | 98 | const char * 99 | tex_env_name (GLenum e) 100 | { 101 | switch (e) { 102 | CASE_STRING(GL_REPLACE); 103 | CASE_STRING(GL_MODULATE); 104 | CASE_STRING(GL_DECAL); 105 | CASE_STRING(GL_BLEND); 106 | CASE_STRING(GL_ADD); 107 | NODEFAULT; 108 | } 109 | } 110 | 111 | 112 | const char * 113 | tex_fmt_name (GLenum t) 114 | { 115 | switch (t) { 116 | CASE_STRING(GL_RGBA); 117 | CASE_STRING(GL_RGB); 118 | CASE_STRING(GL_LUMINANCE_ALPHA); 119 | CASE_STRING(GL_LUMINANCE); 120 | CASE_STRING(GL_ALPHA); 121 | NODEFAULT; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /x86/cpuhard.c: -------------------------------------------------------------------------------- 1 | #include "cpu.h" 2 | 3 | /* Testing code: 4 | * TEST_SSE = xorps xmm0, xmm0 5 | * TEST_SSE2 = xorpd xmm0, xmm0 6 | * TEST_3DNOW = femms 7 | * TEST_MMX = emms 8 | * TEST_3DNOWPLUS = femms | pswapd mm0, mm0 | femms 9 | * TEST_MMXPLUS = emms | pminsw mm0, mm0 | emms 10 | */ 11 | #ifdef __GNUC__ 12 | 13 | #define USE_SIGNALS 1 14 | 15 | #define TEST_CPUID(f) __asm __volatile ("pushl %%ebx; cpuid; popl %%ebx"::"a"(f):"%ecx", "%edx") 16 | #define TEST_SSE() __asm __volatile (".byte 0x0f, 0x57, 0xc0") 17 | #define TEST_SSE2() __asm __volatile (".byte 0x66, 0x0f, 0x57, 0xc0") 18 | #define TEST_3DNOW() __asm __volatile (".byte 0x0f, 0x0e") 19 | #define TEST_MMX() __asm __volatile (".byte 0x0f, 0x77") 20 | #define TEST_3DNOWPLUS() __asm __volatile (".byte 0x0f, 0x0e, 0x0f, 0x0f, 0xc0, 0xbb, 0x0f, 0x0e") 21 | #define TEST_MMXPLUS() __asm __volatile (".byte 0x0f, 0x77, 0x0f, 0xea, 0xc0, 0x0f, 0x77") 22 | 23 | #else /* !__GNUC__ */ 24 | 25 | #define USE_SIGNALS 0 26 | 27 | #define TEST_CPUID(f) __asm { _asm mov eax, f _asm cpuid } 28 | #define TEST_SSE() __asm { _asm _emit 0x0f _asm _emit 0x57 _asm _emit 0xc0 } 29 | #define TEST_SSE2() __asm { _asm _emit 0x66 _asm _emit 0x0f _asm _emit 0x57 _asm _emit 0xc0 } 30 | #define TEST_3DNOW() __asm { _asm _emit 0x0f _asm _emit 0x0e } 31 | #define TEST_MMX() __asm { _asm _emit 0x0f _asm _emit 0x77 } 32 | #define TEST_3DNOWPLUS() __asm { _asm _emit 0x0f _asm _emit 0x0e _asm _emit 0x0f _asm _emit 0x0f _asm _emit 0xc0 _asm _emit 0xbb _asm _emit 0x0f _asm _emit 0x0e } 33 | #define TEST_MMXPLUS() __asm { _asm _emit 0x0f _asm _emit 0x77 _asm _emit 0x0f _asm _emit 0xea _asm _emit 0xc0 _asm _emit 0x0f _asm _emit 0x77 } 34 | 35 | #endif /* !__GNUC__ */ 36 | 37 | 38 | #if USE_SIGNALS 39 | 40 | #include 41 | #include 42 | 43 | #define __try if (!setjmp(j)) 44 | #define __except(x) else 45 | 46 | #define EXC_INIT() ((old_sigill = signal(SIGILL, handler)) != SIG_ERR) 47 | #define EXC_FINI() signal(SIGILL, old_sigill) 48 | 49 | static jmp_buf j; 50 | static void (*old_sigill) (int); 51 | 52 | 53 | static void 54 | handler (int signal) 55 | { 56 | longjmp(j, signal + 1); /* so we can tell... also ensure we don't pass 0 */ 57 | } 58 | 59 | #else /* !USE_SIGNALS */ 60 | 61 | #include 62 | 63 | #define EXC_INIT() !0 64 | #define EXC_FINI() 65 | 66 | #endif /* !USE_SIGNALS */ 67 | 68 | 69 | static int 70 | check_feature (int feature) 71 | { 72 | __try { 73 | /* we have signals and jump buffer set */ 74 | switch (feature) { 75 | case _CPU_HAS_CPUID: 76 | TEST_CPUID(0); 77 | break; 78 | case _CPU_FEATURE_SSE: 79 | TEST_SSE(); 80 | break; 81 | case _CPU_FEATURE_SSE2: 82 | TEST_SSE2(); 83 | break; 84 | case _CPU_FEATURE_3DNOW: 85 | TEST_3DNOW(); 86 | break; 87 | case _CPU_FEATURE_MMX: 88 | TEST_MMX(); 89 | break; 90 | case _CPU_FEATURE_3DNOWPLUS: 91 | TEST_3DNOWPLUS(); 92 | break; 93 | case _CPU_FEATURE_MMXPLUS: 94 | TEST_MMXPLUS(); 95 | break; 96 | default: 97 | return 0; 98 | } 99 | return feature; 100 | } __except (EXCEPTION_EXECUTE_HANDLER) { 101 | /* we got here only when `longjmp'ed by signal handlers */ 102 | return 0; 103 | } 104 | } 105 | 106 | 107 | static int 108 | has_feature (int feature) 109 | { 110 | int rv; 111 | 112 | if (!EXC_INIT()) { 113 | return 0; 114 | } 115 | 116 | rv = check_feature(feature); 117 | 118 | EXC_FINI(); 119 | return rv; 120 | } 121 | 122 | 123 | int 124 | cpuhard (void) 125 | { 126 | int rv = has_feature(_CPU_HAS_CPUID); 127 | if (rv) { 128 | rv |= has_feature(_CPU_FEATURE_MMX); 129 | rv |= has_feature(_CPU_FEATURE_SSE); 130 | rv |= has_feature(_CPU_FEATURE_SSE2); 131 | rv |= has_feature(_CPU_FEATURE_3DNOW); 132 | rv |= has_feature(_CPU_FEATURE_3DNOWPLUS); 133 | rv |= has_feature(_CPU_FEATURE_MMXPLUS); 134 | } 135 | return rv; 136 | } 137 | -------------------------------------------------------------------------------- /g3sdk/include/3dfx.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY 3 | ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 4 | ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 5 | ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 6 | ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 7 | ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 8 | ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 9 | ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 10 | ** 11 | ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 12 | ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN 13 | ** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013, 14 | ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 15 | ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 16 | ** THE UNITED STATES. 17 | ** 18 | ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 19 | */ 20 | #ifndef __3DFX_H__ 21 | #define __3DFX_H__ 22 | 23 | /* 24 | ** basic data types 25 | */ 26 | typedef unsigned char FxU8; 27 | typedef signed char FxI8; 28 | typedef unsigned short FxU16; 29 | typedef signed short FxI16; 30 | #if defined(__DOS__) || defined(__MSDOS__) || defined(_WIN32) || defined(macintosh) 31 | typedef signed long FxI32; 32 | typedef unsigned long FxU32; 33 | #else 34 | typedef signed int FxI32; 35 | typedef unsigned int FxU32; 36 | #endif 37 | typedef unsigned long AnyPtr; 38 | typedef int FxBool; 39 | typedef float FxFloat; 40 | typedef double FxDouble; 41 | 42 | /* 43 | ** color types 44 | */ 45 | typedef unsigned long FxColor_t; 46 | typedef struct { float r, g, b, a; } FxColor4; 47 | 48 | /* 49 | ** fundamental types 50 | */ 51 | #define FXTRUE 1 52 | #define FXFALSE 0 53 | 54 | /* 55 | ** helper macros 56 | */ 57 | #define FXUNUSED( a ) ((void)(a)) 58 | #define FXBIT( i ) ( 1 << (i) ) 59 | 60 | /* 61 | ** export macros 62 | */ 63 | 64 | #if defined(__MSC__) || defined(_MSC_VER) 65 | # if defined (MSVC16) 66 | # define FX_ENTRY 67 | # define FX_CALL 68 | # else 69 | # define FX_ENTRY extern 70 | # define FX_CALL __stdcall 71 | # endif 72 | #elif defined(__WATCOMC__) 73 | # define FX_ENTRY extern 74 | # define FX_CALL __stdcall 75 | #elif defined (__IBMC__) || defined (__IBMCPP__) 76 | /* IBM Visual Age C/C++: */ 77 | # define FX_ENTRY extern 78 | # define FX_CALL __stdcall 79 | #elif defined(__DJGPP__) 80 | # define FX_ENTRY extern 81 | # define FX_CALL 82 | #elif defined(__MINGW32__) 83 | # define FX_ENTRY extern 84 | # define FX_CALL __stdcall 85 | #elif defined(__unix__) 86 | # define FX_ENTRY extern 87 | # define FX_CALL 88 | #elif defined(__MWERKS__) 89 | # if macintosh 90 | # define FX_ENTRY extern 91 | # define FX_CALL 92 | # else /* !macintosh */ 93 | # error "Unknown MetroWerks target platform" 94 | # endif /* !macintosh */ 95 | #else 96 | # warning define FX_ENTRY & FX_CALL for your compiler 97 | # define FX_ENTRY extern 98 | # define FX_CALL 99 | #endif 100 | 101 | /* 102 | ** x86 compiler specific stuff 103 | */ 104 | #if defined(__BORLANDC_) 105 | # define REALMODE 106 | 107 | # define REGW( a, b ) ((a).x.b) 108 | # define REGB( a, b ) ((a).h.b) 109 | # define INT86( a, b, c ) int86(a,b,c) 110 | # define INT86X( a, b, c, d ) int86x(a,b,c,d) 111 | 112 | # define RM_SEG( a ) FP_SEG( a ) 113 | # define RM_OFF( a ) FP_OFF( a ) 114 | #elif defined(__WATCOMC__) 115 | # undef FP_SEG 116 | # undef FP_OFF 117 | 118 | # define REGW( a, b ) ((a).w.b) 119 | # define REGB( a, b ) ((a).h.b) 120 | # define INT86( a, b, c ) int386(a,b,c) 121 | # define INT86X( a, b, c, d ) int386x(a,b,c,d) 122 | 123 | # define RM_SEG( a ) ( ( ( ( FxU32 ) (a) ) & 0x000F0000 ) >> 4 ) 124 | # define RM_OFF( a ) ( ( FxU16 ) (a) ) 125 | #endif 126 | 127 | #endif /* !__3DFX_H__ */ 128 | -------------------------------------------------------------------------------- /util/cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Read configuration files variable/value pairs into a linked list. 3 | * The linked list is cumulative (variables from new files are appended 4 | * to the list), but variables with the same name overwrite the old ones. 5 | * This file does not need explicit initialization. 6 | * Destruction is registered with atexit(). 7 | */ 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "list.h" 16 | #include "cfg.h" 17 | 18 | 19 | /** 20 | * VAR = VAL pair 21 | */ 22 | typedef struct ENTRY { 23 | struct ENTRY *next, *prev; 24 | char *val; /**< value */ 25 | char var[1]; /**< variable */ 26 | } ENTRY; 27 | 28 | 29 | /** configuration setting list */ 30 | static ENTRY cfg_list = { &cfg_list, &cfg_list, NULL, {0} }; 31 | 32 | 33 | static int 34 | cfg_isspace (int c) 35 | { 36 | switch(c) { 37 | case ' ': case '\t': 38 | case '\n': case '\r': 39 | case '\f': case '\v': return 1; 40 | } 41 | return 0; 42 | } 43 | 44 | 45 | /** 46 | * Load configuration file. 47 | * 48 | * \param filename config file 49 | * 50 | * \return 0 if success 51 | */ 52 | int 53 | cfg_load (const char *filename) 54 | { 55 | FILE *f; 56 | char line[BUFSIZ]; 57 | 58 | f = fopen(filename, "rb"); 59 | if (f == NULL) { 60 | return -1; 61 | } 62 | 63 | while (fgets(line, BUFSIZ, f)) { 64 | char *beg, *end, *mid; 65 | int len; 66 | ENTRY *e; 67 | 68 | beg = line; 69 | while (cfg_isspace(*beg)) { 70 | beg++; 71 | } 72 | 73 | end = beg + strcspn(beg, "#;"); 74 | if (end == beg) { 75 | continue; 76 | } 77 | while (cfg_isspace(*(end - 1))) { 78 | end--; 79 | } 80 | *end = '\0'; 81 | 82 | mid = strchr(beg, '='); 83 | if (mid == NULL) { 84 | continue; /* no `=' */ 85 | } 86 | 87 | if (mid == beg) { 88 | continue; /* `=abc' */ 89 | } 90 | 91 | end = mid; 92 | *mid++ = '\0'; 93 | if (*mid == '\0') { 94 | continue; /* `abc=' */ 95 | } 96 | while (cfg_isspace(*mid)) { 97 | mid++; 98 | } 99 | 100 | while (cfg_isspace(*(end - 1))) { 101 | end--; 102 | } 103 | *end = '\0'; 104 | 105 | len = strlen(beg); 106 | list_foreach (e, &cfg_list) { 107 | if (!strcmp(e->var, beg)) { 108 | break; 109 | } 110 | } 111 | if (!list_at_end(&cfg_list, e)) { 112 | if (!strcmp(e->val, mid)) { 113 | continue; 114 | } 115 | list_remove(e); 116 | free(e); 117 | } 118 | e = malloc(offsetof(ENTRY, var) + len + 1 + strlen(mid) + 1); 119 | if (e != NULL) { 120 | e->val = e->var + len + 1; 121 | strcpy(e->var, beg); 122 | strcpy(e->val, mid); 123 | list_append(&cfg_list, e); 124 | } 125 | } 126 | 127 | fclose(f); 128 | #ifndef __MSDOS__ 129 | atexit(cfg_kill); 130 | #endif 131 | 132 | return 0; 133 | } 134 | 135 | 136 | /** 137 | * Free configuration list. May be called multiple times. 138 | */ 139 | void 140 | cfg_kill (void) 141 | { 142 | ENTRY *c, *tmp; 143 | list_foreach_s (c, tmp, &cfg_list) { 144 | list_remove(c); 145 | free(c); 146 | } 147 | } 148 | 149 | 150 | /** 151 | * Get string value for given variable. 152 | * 153 | * \param var variable name 154 | * \param def default value if variable not found 155 | * 156 | * \return variable 157 | */ 158 | const char * 159 | cfg_get (const char *var, const char *def) 160 | { 161 | ENTRY *c; 162 | list_foreach (c, &cfg_list) { 163 | if (!strcmp(c->var, var)) { 164 | return c->val; 165 | } 166 | } 167 | return def; 168 | } 169 | 170 | 171 | /** 172 | * Browse all variables. 173 | * 174 | * \param fn callback function to be called for each variable 175 | * 176 | * \return 0 if the callback returns 0 for all variables 177 | * otherwise the value returned by the callback (and the browsing stops) 178 | */ 179 | int 180 | cfg_browse (int (*fn) (const char *var, const char *val)) 181 | { 182 | ENTRY *c; 183 | list_foreach (c, &cfg_list) { 184 | int rv = fn(c->var, c->val); 185 | if (rv) { 186 | return rv; 187 | } 188 | } 189 | return 0; 190 | } 191 | -------------------------------------------------------------------------------- /drivers/foo/drv_api.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "GL/gl.h" 5 | #include "GL/sage.h" 6 | 7 | #include "glinternal.h" 8 | #include "main/context.h" 9 | #include "tnl/tnl.h" 10 | #include "main/glapi.h" 11 | #include "util/cfg.h" 12 | #include "driver.h" 13 | #include "drv.h" 14 | 15 | 16 | static sageContext *current; /**< Current context */ 17 | 18 | static int hardware = -1; /**< Hardware type */ 19 | 20 | SWvertex *vb; 21 | int (*drv_multipass) (int pass); 22 | void (*drv_emitvertices) (int n); 23 | void (*drv_copypv) (int vdst, int vsrc); 24 | void (*drv_interp) (float t, int vdst, int vout, int vin); 25 | 26 | 27 | int 28 | sage_init (void) 29 | { 30 | if (hardware >= 0) { 31 | return 32; 32 | } 33 | 34 | #if defined(__MSDOS__)||defined(_WIN32) 35 | cfg_load("sage.ini"); 36 | #else 37 | if (cfg_load("sage.ini") != 0) { 38 | cfg_load("/etc/sage.ini"); 39 | } 40 | #endif 41 | 42 | hardware = 0; 43 | 44 | current = NULL; 45 | 46 | return 32; 47 | } 48 | 49 | 50 | sageContext * 51 | sage_open (int db_flag, 52 | int red_size, int green_size, int blue_size, 53 | int alpha_size, int depth_size, int stencil_size) 54 | { 55 | sageContext *ctx; 56 | 57 | if (hardware < 0) { 58 | goto exit_error; 59 | } 60 | 61 | /* Create context */ 62 | ctx = malloc(sizeof(sageContext)); 63 | if (ctx == NULL) { 64 | goto exit_error; 65 | } 66 | 67 | /* Initialize the core */ 68 | if (ctx_init(db_flag, 69 | red_size, green_size, blue_size, 70 | alpha_size, depth_size, stencil_size) != 0) { 71 | goto exit_error1; 72 | } 73 | 74 | /* Finish driver setup */ 75 | vb = malloc((tnl_vb.max + TNL_CLIPPED_VERTS) * sizeof(SWvertex)); 76 | if (vb == NULL) { 77 | goto exit_error3; 78 | } 79 | 80 | drv_multipass = drv_multipass_none; 81 | 82 | return ctx; 83 | 84 | exit_error3: 85 | ctx_fini(); 86 | exit_error1: 87 | free(ctx); 88 | exit_error: 89 | return NULL; 90 | } 91 | 92 | 93 | int 94 | sage_bind (sageContext *ctx, void *win, int width, int height) 95 | { 96 | if (hardware < 0) { 97 | return -1; 98 | } 99 | 100 | if (ctx == NULL || win == NULL) { 101 | if (current != NULL) { 102 | /* unbind */ 103 | current = NULL; 104 | } 105 | return 0; 106 | } 107 | #ifdef __MSDOS__ 108 | win = NULL; /* DOS: no window handle. */ 109 | #endif 110 | if (ctx == current) { 111 | if (win == current->drawable) { 112 | /* nop */ 113 | return 0; 114 | } 115 | /* rebind */ 116 | } 117 | 118 | ctx->drawable = win; 119 | current = ctx; 120 | 121 | GLCALL(Viewport)(0, 0, width, height); 122 | 123 | return 0; 124 | } 125 | 126 | 127 | void 128 | sage_shut (sageContext *ctx) 129 | { 130 | if (hardware < 0) { 131 | return; 132 | } 133 | if (ctx == NULL) { 134 | return; 135 | } 136 | 137 | sage_bind(NULL, NULL, 0, 0); 138 | 139 | free(vb); 140 | ctx_fini(); 141 | free(ctx); 142 | } 143 | 144 | 145 | void 146 | sage_fini (void) 147 | { 148 | if (hardware < 0) { 149 | return; 150 | } 151 | 152 | if (current != NULL) { 153 | sage_shut(current); 154 | } 155 | 156 | cfg_kill(); 157 | 158 | hardware = -1; 159 | } 160 | 161 | 162 | void 163 | sage_swap (int interval) 164 | { 165 | (void)interval; 166 | GLCALL(Flush)(); 167 | } 168 | 169 | 170 | #ifdef __MSDOS__ 171 | static struct { 172 | const char *name; 173 | SageProc proc; 174 | } functab[] = { 175 | #define ALIAS(x, y) \ 176 | { "gl" #x #y, (SageProc)gl##x }, 177 | #include "../../main/alias.h" 178 | { "glLockArraysEXT", (SageProc)glLockArraysEXT }, 179 | { "glUnlockArraysEXT", (SageProc)glUnlockArraysEXT }, 180 | { "glPolygonOffsetEXT", (SageProc)glPolygonOffsetEXT } 181 | }; 182 | 183 | SageProc 184 | sage_GetProcAddress (const char *procname) 185 | { 186 | const int n = sizeof(functab) / sizeof(functab[0]); 187 | int i; 188 | for (i = 0; i < n; i++) { 189 | if (!strcmp(procname, functab[i].name)) { 190 | return functab[i].proc; 191 | } 192 | } 193 | return NULL; 194 | } 195 | #endif 196 | -------------------------------------------------------------------------------- /util/pow.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "GL/gl.h" 5 | 6 | #include "macros.h" 7 | #include "list.h" 8 | #include "pow.h" 9 | 10 | 11 | #define MAX_LUT_ENTRIES 32 12 | 13 | 14 | static POW_LUT *pow_list; 15 | static GLuint pow_size; 16 | 17 | 18 | /* 19 | * In Euclidean space, the dot product of two unit 20 | * vectors is simply the cosine of the angle between them. 21 | * 22 | * Hence, our tables are [0..1] ^ [0..128] 23 | */ 24 | POW_LUT * 25 | pow_make (POW_LUT *table, GLfloat exp) 26 | { 27 | int i; 28 | GLfloat x, dx, scale, threshold, *tableEntry; 29 | 30 | if (table == NULL) { 31 | table = malloc(sizeof(POW_LUT)); 32 | } 33 | if (table == NULL) { 34 | return NULL; 35 | } 36 | 37 | /* Compute threshold */ 38 | if (exp == 0.0F) { 39 | threshold = 0.0F; 40 | } else { 41 | threshold = POW(0.0007F, 1.0F / exp); 42 | } 43 | 44 | scale = (POW_LUT_SIZE - 1) / (1.0F - threshold); 45 | dx = 1.0F / scale; 46 | x = threshold; 47 | tableEntry = table->table; 48 | for (i = POW_LUT_SIZE; --i >= 0; ) { 49 | *tableEntry++ = POW(x, exp); 50 | x += dx; 51 | } 52 | *tableEntry = 1.0F; 53 | table->threshold = threshold; 54 | table->scale = scale; 55 | table->refcount = 2; /* both cache and calling code refer to table */ 56 | table->exp = exp; 57 | return table; 58 | } 59 | 60 | 61 | int 62 | pow_init (void) 63 | { 64 | pow_size = 0; 65 | pow_list = malloc(2 * sizeof(void *)); 66 | if (pow_list == NULL) { 67 | return -1; 68 | } 69 | list_create(pow_list); 70 | return 0; 71 | } 72 | 73 | 74 | POW_LUT * 75 | pow_scan (GLfloat exp) 76 | { 77 | POW_LUT *ptr; 78 | list_foreach (ptr, pow_list) { 79 | if (ptr->exp == exp) { 80 | return ptr; 81 | } 82 | } 83 | if (pow_size >= MAX_LUT_ENTRIES) { 84 | /* too many tables already. start reusing them */ 85 | ptr = list_last(pow_list); 86 | list_remove(ptr); 87 | pow_size--; 88 | ptr = pow_make(ptr, exp); 89 | } else { 90 | /* really create a new table */ 91 | ptr = pow_make(NULL, exp); 92 | } 93 | if (ptr != NULL) { 94 | /* move the table to front */ 95 | list_prepend(pow_list, ptr); 96 | pow_size++; 97 | } 98 | return ptr; 99 | } 100 | 101 | 102 | void 103 | pow_fini (void) 104 | { 105 | POW_LUT *ptr, *tmp; 106 | list_foreach_s (ptr, tmp, pow_list) { 107 | list_remove(ptr); 108 | free(ptr); 109 | } 110 | if (pow_list != NULL) { 111 | free(pow_list); 112 | pow_list = NULL; 113 | } 114 | pow_size = 0; 115 | } 116 | 117 | 118 | #define FAST_POW(dp, exp, tab) \ 119 | do { \ 120 | GLfloat f; \ 121 | GLuint k; \ 122 | if (tab == NULL) { \ 123 | return POW(dp, exp); \ 124 | } \ 125 | f = dp - tab->threshold; \ 126 | if (IS_NEGATIVE(f)) { \ 127 | return 0.0F; \ 128 | } \ 129 | f = f * tab->scale + 0.5F; \ 130 | k = (GLuint)f; \ 131 | if (k >= POW_LUT_SIZE) { \ 132 | return 1.0F; \ 133 | } \ 134 | return tab->table[k]; \ 135 | } while (0) 136 | 137 | 138 | #define LERP_POW(dp, exp, tab) \ 139 | do { \ 140 | GLfloat f; \ 141 | GLuint k; \ 142 | GLfloat v; \ 143 | if (tab == NULL) { \ 144 | return POW(dp, exp); \ 145 | } \ 146 | f = dp - tab->threshold; \ 147 | if (IS_NEGATIVE(f)) { \ 148 | return 0.0F; \ 149 | } \ 150 | f = f * tab->scale; \ 151 | k = (GLuint)f; \ 152 | if (k >= POW_LUT_SIZE) { \ 153 | return 1.0F; \ 154 | } \ 155 | v = tab->table[k]; \ 156 | return v + (f - k) * (tab->table[k + 1] - v);\ 157 | } while (0) 158 | 159 | 160 | GLfloat 161 | pow_sf (GLfloat dp, GLfloat exp) 162 | { 163 | POW_LUT *tab = pow_scan(exp); 164 | FAST_POW(dp, exp, tab); 165 | } 166 | 167 | 168 | GLfloat 169 | pow_sl (GLfloat dp, GLfloat exp) 170 | { 171 | POW_LUT *tab = pow_scan(exp); 172 | LERP_POW(dp, exp, tab); 173 | } 174 | 175 | 176 | GLfloat 177 | pow_tf (GLfloat dp, GLfloat exp, POW_LUT *tab) 178 | { 179 | FAST_POW(dp, exp, tab); 180 | } 181 | 182 | 183 | GLfloat 184 | pow_tl (GLfloat dp, GLfloat exp, POW_LUT *tab) 185 | { 186 | LERP_POW(dp, exp, tab); 187 | } 188 | -------------------------------------------------------------------------------- /x86/x86.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "GL/gl.h" 5 | 6 | #include "glinternal.h" 7 | #include "main/glapi.h" 8 | #include "main/context.h" 9 | #include "main/matrix.h" 10 | #include "tnl/tnl.h" 11 | #include "util/cfg.h" 12 | #include "cpu.h" 13 | #include "x86.h" 14 | 15 | 16 | void x86_clipmask (void); 17 | void GLAPIENTRY x86_Vertex3fv (const GLfloat *v); 18 | void GLAPIENTRY x86_TexCoord2fv (const GLfloat *v); 19 | void GLAPIENTRY x86_MultiTexCoord2fv (GLenum texture, const GLfloat *v); 20 | 21 | void k3d_clipmask (void); 22 | void k3d_calc_neye (void); 23 | void k3d_calc_veyn3 (const GLfloat *mv); 24 | void k3d_calc_veyn4 (const GLfloat *mv); 25 | void k3d_reflect (void); 26 | void k3d_reflect_mvec (void); 27 | void matrix_mul_vec4_k3d (GLfloat4 dst, const GLfloat *m, const GLfloat4 src); 28 | void matrix_mul_vec4_batch_k3d (GLfloat4 dst[], const GLfloat *m, const GLfloat4 src[], int n); 29 | void matrix_mul_vec3_k3d (GLfloat4 dst, const GLfloat *m, const GLfloat4 src); 30 | void matrix_mul_vec3_batch_k3d (GLfloat4 dst[], const GLfloat *m, const GLfloat4 src[], int n); 31 | void matrix_mul_vec_rot_k3d (GLfloat4 dst, const GLfloat *m, const GLfloat4 src); 32 | 33 | void sse_clipmask (void); 34 | void sse_calc_neye (void); 35 | void sse_calc_veyn3 (const GLfloat *mv); 36 | void sse_calc_veyn4 (const GLfloat *mv); 37 | void sse_reflect (void); 38 | void sse_reflect_mvec (void); 39 | void matrix_mul_vec4_sse (GLfloat4 dst, const GLfloat *m, const GLfloat4 src); 40 | void matrix_mul_vec4_batch_sse (GLfloat4 dst[], const GLfloat *m, const GLfloat4 src[], int n); 41 | void matrix_mul_vec3_sse (GLfloat4 dst, const GLfloat *m, const GLfloat4 src); 42 | void matrix_mul_vec3_batch_sse (GLfloat4 dst[], const GLfloat *m, const GLfloat4 src[], int n); 43 | void matrix_mul_vec_rot_sse (GLfloat4 dst, const GLfloat *m, const GLfloat4 src); 44 | void GLAPIENTRY sse_Vertex3fv (const GLfloat *v); 45 | void GLAPIENTRY sse_TexCoord2fv (const GLfloat *v); 46 | void GLAPIENTRY sse_MultiTexCoord2fv (GLenum texture, const GLfloat *v); 47 | 48 | 49 | int x86_cpu_bits; 50 | char x86_cpu_name[13]; 51 | 52 | int x86_enable_sse; 53 | int x86_enable_3dnow; 54 | 55 | 56 | static int 57 | sse_init (void) 58 | { 59 | tnl_clipmask_tab[0] = sse_clipmask; 60 | tnl_calc_neye_tab[0] = sse_calc_neye; 61 | tnl_veyn_func[0] = sse_calc_veyn3; 62 | tnl_veyn_func[1] = sse_calc_veyn4; 63 | tnl_refl_func[0] = sse_reflect; 64 | tnl_refl_func[1] = sse_reflect_mvec; 65 | matrix_mul_vec4 = matrix_mul_vec4_sse; 66 | matrix_mul_vec4_batch = matrix_mul_vec4_batch_sse; 67 | matrix_mul_vec3 = matrix_mul_vec3_sse; 68 | matrix_mul_vec3_batch = matrix_mul_vec3_batch_sse; 69 | matrix_mul_vec_rot = matrix_mul_vec_rot_sse; 70 | /*ctx_imm_table.Vertex3fv = sse_Vertex3fv;*/ 71 | ctx_imm_table.TexCoord2fv = sse_TexCoord2fv; 72 | ctx_imm_table.MultiTexCoord2fv = sse_MultiTexCoord2fv; 73 | return 0; 74 | } 75 | 76 | 77 | static int 78 | k3d_init (void) 79 | { 80 | tnl_clipmask_tab[0] = k3d_clipmask; 81 | tnl_calc_neye_tab[0] = k3d_calc_neye; 82 | tnl_veyn_func[0] = k3d_calc_veyn3; 83 | tnl_veyn_func[1] = k3d_calc_veyn4; 84 | tnl_refl_func[0] = k3d_reflect; 85 | tnl_refl_func[1] = k3d_reflect_mvec; 86 | matrix_mul_vec4 = matrix_mul_vec4_k3d; 87 | matrix_mul_vec4_batch = matrix_mul_vec4_batch_k3d; 88 | matrix_mul_vec3 = matrix_mul_vec3_k3d; 89 | matrix_mul_vec3_batch = matrix_mul_vec3_batch_k3d; 90 | matrix_mul_vec_rot = matrix_mul_vec_rot_k3d; 91 | return 0; 92 | } 93 | 94 | 95 | #define YES(v) !strcmp(cfg_get(v, "n"), "y") 96 | 97 | int 98 | x86_init (void) 99 | { 100 | x86_cpu_bits = cpusoft(x86_cpu_name); 101 | 102 | x86_enable_3dnow = YES("x86.enable.3dnow"); 103 | x86_enable_sse = YES("x86.enable.sse"); 104 | 105 | tnl_clipmask_tab[0] = x86_clipmask; 106 | /*ctx_imm_table.Vertex3fv = x86_Vertex3fv;*/ 107 | ctx_imm_table.TexCoord2fv = x86_TexCoord2fv; 108 | ctx_imm_table.MultiTexCoord2fv = x86_MultiTexCoord2fv; 109 | 110 | if ((x86_cpu_bits & _CPU_FEATURE_SSE) && x86_enable_sse) { 111 | sse_init(); 112 | } 113 | else if ((x86_cpu_bits & _CPU_FEATURE_3DNOW) && x86_enable_3dnow) { 114 | k3d_init(); 115 | } 116 | return 0; 117 | } 118 | 119 | /* validate structure sizes and member offsets in x86.inc: */ 120 | #include "x86chk.h" 121 | -------------------------------------------------------------------------------- /doc/texenv/lexer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "lexer.h" 6 | 7 | 8 | #define FALSE 0 9 | #define TRUE !FALSE 10 | 11 | typedef enum { 12 | S_INIT, 13 | S_ID, 14 | S_OP, /* operator: +, -, *, / */ 15 | S_OB, /* openbrace */ 16 | S_CB, /* closebrace */ 17 | S_ERROR, 18 | S_RESET, 19 | S_QUIT 20 | } S_STATE; 21 | 22 | 23 | static int ch; 24 | static const char *input; 25 | static int pos; 26 | static S_STATE state; 27 | TOKEN token; 28 | 29 | 30 | void 31 | set_input (const char *i) 32 | { 33 | input = i; 34 | pos = 0; 35 | state = S_INIT; 36 | } 37 | 38 | 39 | static int 40 | get_char (void) 41 | { 42 | ch = input[pos]; 43 | if (ch) { 44 | pos++; 45 | } 46 | return ch; 47 | } 48 | 49 | 50 | static int 51 | get_nextchar (void) 52 | { 53 | return input[pos]; 54 | } 55 | 56 | 57 | static int 58 | tok_append (void) 59 | { 60 | if (token.len == token.max) { 61 | char *p = realloc(token.sym, token.max + 256 + 1); 62 | if (p == NULL) { 63 | return FALSE; 64 | } 65 | token.sym = p; 66 | token.max += 256; 67 | } 68 | token.sym[token.len++] = ch; 69 | return TRUE; 70 | } 71 | 72 | 73 | static void 74 | cleanup (void) 75 | { 76 | if (token.sym != NULL) { 77 | free(token.sym); 78 | token.sym = NULL; 79 | token.max = 0; 80 | } 81 | token.type = T_EOI; 82 | state = S_QUIT; 83 | } 84 | 85 | 86 | static void 87 | fix_token (void) 88 | { 89 | token.sym[token.len] = '\0'; 90 | if (state == S_OP) { 91 | switch (token.sym[0]) { 92 | case '+': 93 | token.type = T_ADD; 94 | break; 95 | case '-': 96 | token.type = T_SUB; 97 | break; 98 | case '*': 99 | token.type = T_MUL; 100 | break; 101 | case '/': 102 | token.type = T_DIV; 103 | break; 104 | } 105 | } else if (state == S_OB) { 106 | token.type = T_OB; 107 | } else if (state == S_CB) { 108 | token.type = T_CB; 109 | } else if (state == S_ID) { 110 | token.type = T_ID; 111 | } else { 112 | assert(0); 113 | } 114 | } 115 | 116 | 117 | static S_STATE 118 | next_state (int nch, S_STATE current) 119 | { 120 | static const S_STATE scantab[][5] = { 121 | /*INIT ID OP OB CB*/ 122 | /*Nul*/{S_QUIT, S_QUIT, S_QUIT, S_QUIT, S_QUIT }, 123 | /* */{S_INIT, S_RESET,S_RESET,S_RESET,S_RESET}, 124 | /* A */{S_ID, S_ID, S_RESET,S_RESET,S_RESET}, 125 | /* + */{S_OP, S_RESET,S_RESET,S_RESET,S_RESET}, 126 | /* - */{S_OP, S_RESET,S_RESET,S_RESET,S_RESET}, 127 | /* * */{S_OP, S_RESET,S_RESET,S_RESET,S_RESET}, 128 | /* / */{S_OP, S_RESET,S_RESET,S_RESET,S_RESET}, 129 | /* ( */{S_OB, S_RESET,S_RESET,S_RESET,S_RESET}, 130 | /* ) */{S_CB, S_RESET,S_RESET,S_RESET,S_RESET}, 131 | /*Oth*/{S_ERROR,S_ERROR,S_ERROR,S_ERROR,S_ERROR} 132 | }; 133 | 134 | if (isspace(nch)) { 135 | nch = 1; 136 | } else if (isalnum(nch)) { 137 | nch = 2; 138 | } else if (nch == '+') { 139 | nch = 3; 140 | } else if (nch == '-') { 141 | nch = 4; 142 | } else if (nch == '*') { 143 | nch = 5; 144 | } else if (nch == '/') { 145 | nch = 6; 146 | } else if (nch == '(') { 147 | nch = 7; 148 | } else if (nch == ')') { 149 | nch = 8; 150 | } else if (nch != '\0') { 151 | nch = 9; 152 | } 153 | return scantab[nch][current]; 154 | } 155 | 156 | 157 | void 158 | get_token (void) 159 | { 160 | token.len = 0; 161 | 162 | if (state == S_QUIT) { 163 | cleanup(); 164 | return; 165 | } 166 | 167 | do { 168 | int nch = get_nextchar(); /* the new character */ 169 | S_STATE nstate = next_state(nch, state); /* new state */ 170 | 171 | if (nstate == S_RESET) { 172 | fix_token(); 173 | state = S_INIT; 174 | return; 175 | } else if (nstate == S_ERROR) { 176 | assert(0); 177 | } else if (nstate == S_QUIT) { 178 | /* return the token here */ 179 | if (token.len) { 180 | fix_token(); 181 | state = S_QUIT; 182 | return; 183 | } else { 184 | cleanup(); 185 | return; 186 | } 187 | } else { 188 | ch = get_char(); 189 | if (!isspace(ch)) { 190 | if (!tok_append()) { 191 | assert(0); 192 | } 193 | } 194 | } 195 | 196 | if (nstate == S_INIT) { 197 | /* return the token here */ 198 | if (token.len) { 199 | fix_token(); 200 | state = S_INIT; 201 | return; 202 | } 203 | } 204 | state = nstate; 205 | } while (TRUE); 206 | } 207 | -------------------------------------------------------------------------------- /util/list.h: -------------------------------------------------------------------------------- 1 | #ifndef LIST_H_included 2 | #define LIST_H_included 3 | 4 | /** 5 | * Remove an element from list. 6 | * 7 | * \param elem element to remove. 8 | */ 9 | #define list_remove(elem) \ 10 | do { \ 11 | (elem)->next->prev = (elem)->prev; \ 12 | (elem)->prev->next = (elem)->next; \ 13 | } while (0) 14 | 15 | /** 16 | * Insert an element to the list head. 17 | * 18 | * \param list list. 19 | * \param elem element to insert. 20 | */ 21 | #define list_prepend(list, elem) \ 22 | do { \ 23 | (elem)->prev = list; \ 24 | (elem)->next = (list)->next; \ 25 | (list)->next->prev = elem; \ 26 | (list)->next = elem; \ 27 | } while(0) 28 | 29 | /** 30 | * Insert an element to the list tail. 31 | * 32 | * \param list list. 33 | * \param elem element to insert. 34 | */ 35 | #define list_append(list, elem) \ 36 | do { \ 37 | (elem)->next = list; \ 38 | (elem)->prev = (list)->prev; \ 39 | (list)->prev->next = elem; \ 40 | (list)->prev = elem; \ 41 | } while(0) 42 | 43 | /** 44 | * Make a empty list empty. 45 | * 46 | * \param sentinal list (sentinal element). 47 | */ 48 | #define list_create(sentinal) \ 49 | do { \ 50 | (sentinal)->next = sentinal; \ 51 | (sentinal)->prev = sentinal; \ 52 | } while (0) 53 | 54 | /** 55 | * Get list first element. 56 | * 57 | * \param list list. 58 | * 59 | * \return pointer to first element. 60 | */ 61 | #define list_first(list) ((list)->next) 62 | 63 | /** 64 | * Get list last element. 65 | * 66 | * \param list list. 67 | * 68 | * \return pointer to last element. 69 | */ 70 | #define list_last(list) ((list)->prev) 71 | 72 | /** 73 | * Get next element. 74 | * 75 | * \param elem element. 76 | * 77 | * \return pointer to next element. 78 | */ 79 | #define list_next(elem) ((elem)->next) 80 | 81 | /** 82 | * Get previous element. 83 | * 84 | * \param elem element. 85 | * 86 | * \return pointer to previous element. 87 | */ 88 | #define list_prev(elem) ((elem)->prev) 89 | 90 | /** 91 | * Test whether element is at end of the list. 92 | * 93 | * \param list list. 94 | * \param elem element. 95 | * 96 | * \return non-zero if element is at end of list, or zero otherwise. 97 | */ 98 | #define list_at_end(list, elem) ((elem) == (list)) 99 | 100 | /** 101 | * Test if a list is empty. 102 | * 103 | * \param list list. 104 | * 105 | * \return non-zero if list empty, or zero otherwise. 106 | */ 107 | #define list_is_empty(list) ((list)->next == (list)) 108 | 109 | /** 110 | * Walk through the elements of a list. 111 | * 112 | * \param ptr pointer to the current element. 113 | * \param list list. 114 | * 115 | * \note It should be followed by a { } block or a single statement, as in a \c 116 | * for loop. 117 | */ 118 | #define list_foreach(ptr, list)\ 119 | for (ptr=(list)->next; ptr!=list; ptr=(ptr)->next) 120 | 121 | /** 122 | * Walk through the elements of a list. 123 | * 124 | * Same as #foreach but lets you unlink the current value during a list 125 | * traversal. Useful for freeing a list, element by element. 126 | * 127 | * \param ptr pointer to the current element. 128 | * \param t temporary pointer. 129 | * \param list list. 130 | * 131 | * \note It should be followed by a { } block or a single statement, as in a \c 132 | * for loop. 133 | */ 134 | #define list_foreach_s(ptr, t, list)\ 135 | for (ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) 136 | 137 | /** 138 | * Walk backwards through the elements of a list. 139 | * 140 | * \param ptr pointer to the current element. 141 | * \param list list. 142 | * 143 | * \note It should be followed by a { } block or a single statement, as in a \c 144 | * for loop. 145 | */ 146 | #define list_forback(ptr, list)\ 147 | for (ptr=(list)->prev; ptr!=list; ptr=(ptr)->prev) 148 | 149 | /** 150 | * Walk backwards through the elements of a list. 151 | * 152 | * Same as #forback but lets you unlink the current value during a list 153 | * traversal. Useful for freeing a list, element by element. 154 | * 155 | * \param ptr pointer to the current element. 156 | * \param t temporary pointer. 157 | * \param list list. 158 | * 159 | * \note It should be followed by a { } block or a single statement, as in a \c 160 | * for loop. 161 | */ 162 | #define list_forback_s(ptr, t, list)\ 163 | for (ptr=(list)->prev,t=(ptr)->prev; list != ptr; ptr=t, t=(t)->prev) 164 | 165 | #endif 166 | -------------------------------------------------------------------------------- /main/ext.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "GL/gl.h" 5 | 6 | #include "glinternal.h" 7 | #include "context.h" 8 | 9 | 10 | typedef struct { 11 | GLboolean enabled; 12 | const char *name; 13 | } gl_ext; 14 | 15 | 16 | typedef struct { 17 | gl_ext EXT_texture; /* 1.1 */ 18 | gl_ext EXT_subtexture; /* 1.1 */ 19 | gl_ext EXT_texture_object; /* 1.1 */ 20 | gl_ext EXT_vertex_array; /* 1.1 */ 21 | gl_ext EXT_rescale_normal; /* 1.2 */ 22 | gl_ext EXT_draw_range_elements; /* 1.2 */ 23 | gl_ext EXT_bgra; /* 1.2 */ 24 | gl_ext EXT_separate_specular_color; /* 1.2 */ 25 | gl_ext EXT_texture_env_combine; /* 1.3 */ 26 | gl_ext EXT_texture_env_add; /* 1.3 */ 27 | gl_ext ARB_multitexture; /* 1.3 (1.2.1 as SGIS) */ 28 | gl_ext EXT_fog_coord; /* 1.4 */ 29 | gl_ext ARB_texture_mirrored_repeat; /* 1.4 */ 30 | gl_ext EXT_blend_func_separate; /* 1.4 */ 31 | gl_ext EXT_secondary_color; /* 1.4 */ 32 | gl_ext EXT_texture_lod_bias; /* 1.4 (1.2 as SGIS) */ 33 | gl_ext EXT_texture_edge_clamp; /* (1.2 as SGIS) */ 34 | gl_ext EXT_compiled_vertex_array; 35 | gl_ext EXT_polygon_offset; 36 | gl_ext NV_texgen_reflection; 37 | gl_ext EXT_clip_volume_hint; 38 | gl_ext ARB_texture_compression; 39 | gl_ext EXT_texture_compression_s3tc; 40 | gl_ext TDFX_texture_compression_FXT1; 41 | gl_ext S3_s3tc; 42 | gl_ext ARB_texture_env_combine; 43 | gl_ext ARB_texture_cube_map; 44 | gl_ext ARB_texture_env_dot3; 45 | gl_ext EXT_stencil_wrap; 46 | gl_ext NV_blend_square; 47 | } gl_extensions; 48 | 49 | 50 | gl_extensions ctx_extensions = { 51 | { GL_TRUE, "GL_EXT_texture" }, /* XXX no proxies */ 52 | { GL_TRUE, "GL_EXT_subtexture" }, /* XXX no proxies */ 53 | { GL_TRUE, "GL_EXT_texture_object" }, 54 | { GL_TRUE, "GL_EXT_vertex_array" }, 55 | { GL_TRUE, "GL_EXT_rescale_normal" }, 56 | { GL_TRUE, "GL_EXT_draw_range_elements" }, 57 | { GL_TRUE, "GL_EXT_bgra" }, 58 | { GL_FALSE, "GL_EXT_separate_specular_color" }, 59 | { GL_FALSE, "GL_EXT_texture_env_combine" }, /* XXX not all modes */ 60 | { GL_FALSE, "GL_EXT_texture_env_add" }, 61 | { GL_FALSE, "GL_ARB_multitexture" }, 62 | { GL_FALSE, "GL_EXT_fog_coord" }, 63 | { GL_FALSE, "GL_ARB_texture_mirrored_repeat" }, 64 | { GL_FALSE, "GL_EXT_blend_func_separate" }, 65 | { GL_FALSE, "GL_EXT_secondary_color" }, 66 | { GL_FALSE, "GL_EXT_texture_lod_bias" }, 67 | { GL_FALSE, "GL_EXT_texture_edge_clamp" }, 68 | { GL_FALSE, "GL_EXT_compiled_vertex_array" }, 69 | { GL_TRUE, "GL_EXT_polygon_offset" }, 70 | { GL_TRUE, "GL_NV_texgen_reflection" }, 71 | { GL_TRUE, "GL_EXT_clip_volume_hint" }, 72 | 73 | { GL_FALSE, "GL_ARB_texture_compression" }, 74 | { GL_FALSE, "GL_EXT_texture_compression_s3tc" }, 75 | { GL_FALSE, "GL_3DFX_texture_compression_FXT1" }, 76 | { GL_FALSE, "GL_S3_s3tc" }, 77 | 78 | { GL_FALSE, "GL_ARB_texture_env_combine" }, 79 | { GL_FALSE, "GL_ARB_texture_cube_map" }, /* YYY Doom3 */ 80 | { GL_FALSE, "GL_ARB_texture_env_dot3" }, /* YYY Doom3 */ 81 | { GL_FALSE, "GL_EXT_stencil_wrap" }, 82 | { GL_FALSE, "GL_NV_blend_square" } 83 | }; 84 | 85 | 86 | char * 87 | ext_create_string (void) 88 | { 89 | char *ptr; 90 | int i, n, len; 91 | gl_ext *array; 92 | 93 | if (ctx_ext_string != NULL) { 94 | return ctx_ext_string; 95 | } 96 | 97 | len = 0; 98 | array = (gl_ext *)&ctx_extensions; 99 | n = sizeof(gl_extensions) / sizeof(gl_ext); 100 | 101 | for (i = 0; i < n; i++) { 102 | if (array[i].enabled) { 103 | len += strlen(array[i].name) + 1; 104 | } 105 | } 106 | 107 | ptr = malloc(len * sizeof(char)); 108 | if (ptr == NULL) { 109 | return NULL; 110 | } 111 | 112 | strcpy(ptr, array[0].name); 113 | for (i = 1; i < n; i++) { 114 | if (array[i].enabled) { 115 | strcat(ptr, " "); 116 | strcat(ptr, array[i].name); 117 | } 118 | } 119 | 120 | ctx_ext_string = ptr; 121 | return ptr; 122 | } 123 | 124 | 125 | void 126 | ext_set (const char *name, int flag) 127 | { 128 | int i, n; 129 | gl_ext *array; 130 | 131 | if (ctx_ext_string != NULL) { 132 | return; 133 | } 134 | 135 | array = (gl_ext *)&ctx_extensions; 136 | n = sizeof(gl_extensions) / sizeof(gl_ext); 137 | 138 | for (i = 0; i < n; i++) { 139 | if (!strcmp(array[i].name, name)) { 140 | array[i].enabled = flag; 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /sage.ini: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # All drivers TCL configuration 3 | ############################################################################### 4 | 5 | # The TCL vertexbuffer size. 6 | #tnl.vb.size = 64 7 | 8 | ############################################################################### 9 | # All drivers WGL configuration 10 | ############################################################################### 11 | 12 | # Ignore stereo requests in wglChoosePixelFormat. 13 | # Not recommended, unless you want to force certain games to boot 14 | # eg: Doom3 15 | #wgl.ignore.stereo = y 16 | 17 | # Ignore alphabuffer requests in wglChoosePixelFormat 18 | # Not recommended, unless you want to force certain games to boot 19 | # eg: Doom3, Kotor1/2 20 | #wgl.ignore.alphabuffer = y 21 | 22 | # Ignore stencilbuffer requests in wglChoosePixelFormat 23 | # Not recommended, unless you want to force certain games to boot 24 | # eg: Doom3, Kotor1/2, NeverwinterNights 25 | #wgl.ignore.stencilbuffer = y 26 | 27 | ############################################################################### 28 | # x86 configuration 29 | ############################################################################### 30 | 31 | # enable use of 3dnow features: 32 | x86.enable.3dnow = y 33 | 34 | # enable use of SSE features: 35 | # SSE is buggy and can cause black screens with segfaults on startup. 36 | x86.enable.sse = y 37 | 38 | ############################################################################### 39 | # 3dfx configuration 40 | ############################################################################### 41 | 42 | # OpenGL version, as returned by glGetString(GL_VERSION). It is really 1.1, 43 | # but some games (Savage, Homeworld2) refuse to run unless >= 1.2. 44 | #3dfx.opengl.version = 1.2 45 | 46 | # Texture compression. Allowed values are 0, 1, 2, 3. The driver performs 47 | # the following safety checks: 48 | # if Voodoo1, Rush, Voodoo2, Banshee, Voodoo3 and this is greater than 1 49 | # subtract 2 50 | # if external codec not available and this is odd value 51 | # subtract 1 52 | # The resulting value is processed as follows: 53 | # 0 disable texture compression API 54 | # 1 decompress precompressed textures 55 | # 2 no compression within the driver, but use precompressed textures 56 | # 3 allow compression within the driver and use precompressed textures 57 | 3dfx.texture.compression = 3 58 | 59 | # Maximum texture size, as returned by glGet(GL_MAX_TEXTURE_SIZE). By default, 60 | # it returns the hardware limit, but some games (CallOfDuty, IFoundHer) refuse 61 | # to run unless >= 9. Do not increase this just for fun, because textures 62 | # larger that hardware can support are automatically rescaled, anyway. 63 | # Has no effect on Voodoo4, Voodoo5. 64 | #3dfx.maxlod = 9 65 | 66 | # Disable GL_{ARB|EXT}_texture_env_combine. On Voodoo4, Voodoo5 cards, 67 | # texture combine is fully supported, but you still can disable it just in case 68 | # combine code is buggy (also, texture combine and trilinear filtering are 69 | # mutually exclusive). On other cards, texture combine is partially emulated. 70 | # You can disable emulation if you experience texture mapping corruption. 71 | #3dfx.disable.combine = y 72 | 73 | # Voodoo4, Voodoo5 can display 32bit textures on 16bit visuals. Disabling this 74 | # can speed up the application at the expense of very small loss in quality. 75 | # Has no effect on Voodoo1, Rush, Voodoo2, Banshee, Voodoo3. 76 | #3dfx.disable.32bpt = y 77 | 78 | # Multitexturing can greatly improve texture mapping. Disabling multitex will 79 | # slow down the application, but you still can do it just in case multitex code 80 | # is buggy (also, multitexture and trilinear filtering are mutually exclusive). 81 | # Has no effect on Voodoo1, Rush, Banshee. 82 | #3dfx.disable.multitex = y 83 | 84 | # UMA can greatly improve texture caching. Disabling UMA will slow down 85 | # the application. This option exists just in case UMA code is buggy. 86 | # Has no effect on Voodoo1, Rush, Voodoo2. 87 | #3dfx.disable.texuma = y 88 | 89 | # Disable Fog coordinate, just in case my fogcoord code is buggy. 90 | # Has no effect on Voodoo1, Rush. 91 | #3dfx.disable.fogcoord = y 92 | 93 | # Disable Texture mirror, just in case my texmirror code is buggy. 94 | # Has no effect on Voodoo1, Rush. 95 | #3dfx.disable.texmirror = y 96 | 97 | # Disable GL_NV_blend_square, just in case my blendsquare code is buggy. 98 | # Has no effect on Voodoo1, Rush, Voodoo2, Banshee, Voodoo3. 99 | #3dfx.disable.blendsquare = y 100 | -------------------------------------------------------------------------------- /drivers/glide/x86/k3d_emit.asm: -------------------------------------------------------------------------------- 1 | %include "xos.inc" 2 | 3 | %include "x86.inc" 4 | %include "drv.inc" 5 | 6 | 7 | extrn tnl_vb 8 | extrn ctx_mx_viewport 9 | extrn ctx_texture 10 | 11 | extrn vb 12 | extrn tmu0_source 13 | extrn tmu1_source 14 | 15 | 16 | segment TEXT 17 | 18 | 19 | align 16 20 | f_bbbb dd 255.0, 255.0, 255.0, 255.0 21 | 22 | 23 | %define TAG(x) x %+ _g 24 | %define IND 0 25 | %include "k3d_vbtmp.asm" 26 | 27 | %define TAG(x) x %+ _t0 28 | %define IND SETUP_TEX0 29 | %include "k3d_vbtmp.asm" 30 | 31 | %define TAG(x) x %+ _q0 32 | %define IND (SETUP_TEX0|SETUP_PTX0) 33 | %include "k3d_vbtmp.asm" 34 | 35 | %define TAG(x) x %+ _t1 36 | %define IND SETUP_TEX1 37 | %include "k3d_vbtmp.asm" 38 | 39 | %define TAG(x) x %+ _q1 40 | %define IND (SETUP_TEX1|SETUP_PTX1) 41 | %include "k3d_vbtmp.asm" 42 | 43 | %define TAG(x) x %+ _t0t1 44 | %define IND (SETUP_TEX0|SETUP_TEX1) 45 | %include "k3d_vbtmp.asm" 46 | 47 | %define TAG(x) x %+ _q0t1 48 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_TEX1) 49 | %include "k3d_vbtmp.asm" 50 | 51 | %define TAG(x) x %+ _t0q1 52 | %define IND (SETUP_TEX0|SETUP_TEX1|SETUP_PTX1) 53 | %include "k3d_vbtmp.asm" 54 | 55 | %define TAG(x) x %+ _q0q1 56 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_TEX1|SETUP_PTX1) 57 | %include "k3d_vbtmp.asm" 58 | 59 | %define TAG(x) x %+ _f 60 | %define IND (SETUP_FOGC) 61 | %include "k3d_vbtmp.asm" 62 | 63 | %define TAG(x) x %+ _t0f 64 | %define IND (SETUP_TEX0|SETUP_FOGC) 65 | %include "k3d_vbtmp.asm" 66 | 67 | %define TAG(x) x %+ _q0f 68 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_FOGC) 69 | %include "k3d_vbtmp.asm" 70 | 71 | %define TAG(x) x %+ _t1f 72 | %define IND (SETUP_TEX1|SETUP_FOGC) 73 | %include "k3d_vbtmp.asm" 74 | 75 | %define TAG(x) x %+ _q1f 76 | %define IND (SETUP_TEX1|SETUP_PTX1|SETUP_FOGC) 77 | %include "k3d_vbtmp.asm" 78 | 79 | %define TAG(x) x %+ _t0t1f 80 | %define IND (SETUP_TEX0|SETUP_TEX1|SETUP_FOGC) 81 | %include "k3d_vbtmp.asm" 82 | 83 | %define TAG(x) x %+ _q0t1f 84 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_TEX1|SETUP_FOGC) 85 | %include "k3d_vbtmp.asm" 86 | 87 | %define TAG(x) x %+ _t0q1f 88 | %define IND (SETUP_TEX0|SETUP_TEX1|SETUP_PTX1|SETUP_FOGC) 89 | %include "k3d_vbtmp.asm" 90 | 91 | %define TAG(x) x %+ _q0q1f 92 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_TEX1|SETUP_PTX1|SETUP_FOGC) 93 | %include "k3d_vbtmp.asm" 94 | 95 | 96 | %define TAG(x) x %+ _s 97 | %define IND (SETUP_SPEC) 98 | %include "k3d_vbtmp.asm" 99 | 100 | %define TAG(x) x %+ _t0s 101 | %define IND (SETUP_TEX0|SETUP_SPEC) 102 | %include "k3d_vbtmp.asm" 103 | 104 | %define TAG(x) x %+ _q0s 105 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_SPEC) 106 | %include "k3d_vbtmp.asm" 107 | 108 | %define TAG(x) x %+ _t1s 109 | %define IND (SETUP_TEX1|SETUP_SPEC) 110 | %include "k3d_vbtmp.asm" 111 | 112 | %define TAG(x) x %+ _q1s 113 | %define IND (SETUP_TEX1|SETUP_PTX1|SETUP_SPEC) 114 | %include "k3d_vbtmp.asm" 115 | 116 | %define TAG(x) x %+ _t0t1s 117 | %define IND (SETUP_TEX0|SETUP_TEX1|SETUP_SPEC) 118 | %include "k3d_vbtmp.asm" 119 | 120 | %define TAG(x) x %+ _q0t1s 121 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_TEX1|SETUP_SPEC) 122 | %include "k3d_vbtmp.asm" 123 | 124 | %define TAG(x) x %+ _t0q1s 125 | %define IND (SETUP_TEX0|SETUP_TEX1|SETUP_PTX1|SETUP_SPEC) 126 | %include "k3d_vbtmp.asm" 127 | 128 | %define TAG(x) x %+ _q0q1s 129 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_TEX1|SETUP_PTX1|SETUP_SPEC) 130 | %include "k3d_vbtmp.asm" 131 | 132 | %define TAG(x) x %+ _fs 133 | %define IND (SETUP_FOGC|SETUP_SPEC) 134 | %include "k3d_vbtmp.asm" 135 | 136 | %define TAG(x) x %+ _t0fs 137 | %define IND (SETUP_TEX0|SETUP_FOGC|SETUP_SPEC) 138 | %include "k3d_vbtmp.asm" 139 | 140 | %define TAG(x) x %+ _q0fs 141 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_FOGC|SETUP_SPEC) 142 | %include "k3d_vbtmp.asm" 143 | 144 | %define TAG(x) x %+ _t1fs 145 | %define IND (SETUP_TEX1|SETUP_FOGC|SETUP_SPEC) 146 | %include "k3d_vbtmp.asm" 147 | 148 | %define TAG(x) x %+ _q1fs 149 | %define IND (SETUP_TEX1|SETUP_PTX1|SETUP_FOGC|SETUP_SPEC) 150 | %include "k3d_vbtmp.asm" 151 | 152 | %define TAG(x) x %+ _t0t1fs 153 | %define IND (SETUP_TEX0|SETUP_TEX1|SETUP_FOGC|SETUP_SPEC) 154 | %include "k3d_vbtmp.asm" 155 | 156 | %define TAG(x) x %+ _q0t1fs 157 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_TEX1|SETUP_FOGC|SETUP_SPEC) 158 | %include "k3d_vbtmp.asm" 159 | 160 | %define TAG(x) x %+ _t0q1fs 161 | %define IND (SETUP_TEX0|SETUP_TEX1|SETUP_PTX1|SETUP_FOGC|SETUP_SPEC) 162 | %include "k3d_vbtmp.asm" 163 | 164 | %define TAG(x) x %+ _q0q1fs 165 | %define IND (SETUP_TEX0|SETUP_PTX0|SETUP_TEX1|SETUP_PTX1|SETUP_FOGC|SETUP_SPEC) 166 | %include "k3d_vbtmp.asm" 167 | -------------------------------------------------------------------------------- /g3sdk/include/glideutl.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY 3 | ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 4 | ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 5 | ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 6 | ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 7 | ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 8 | ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 9 | ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 10 | ** 11 | ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 12 | ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN 13 | ** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013, 14 | ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 15 | ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 16 | ** THE UNITED STATES. 17 | ** 18 | ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 19 | ** 20 | ** $Header: /cvsroot/glide/glide3x/h5/glide3/src/glideutl.h,v 1.3.4.2 2003/06/05 08:23:53 koolsmoky Exp $ 21 | ** $Log: 22 | ** 3 3dfx 1.0.1.0.1.0 10/11/00 Brent Forced check in to enforce 23 | ** branching. 24 | ** 2 3dfx 1.0.1.0 06/20/00 Joseph Kain Changes to support the 25 | ** Napalm Glide open source release. Changes include cleaned up offensive 26 | ** comments and new legal headers. 27 | ** 1 3dfx 1.0 09/11/99 StarTeam VTS Administrator 28 | ** $ 29 | ** 30 | ** 4 7/24/98 1:41p Hohn 31 | ** 32 | ** 3 1/30/98 4:27p Atai 33 | ** gufog* prototype 34 | ** 35 | ** 1 1/29/98 4:00p Atai 36 | * 37 | * 1 1/16/98 4:29p Atai 38 | * create glide 3 src 39 | * 40 | * 11 1/07/98 11:18a Atai 41 | * remove GrMipMapInfo and GrGC.mm_table in glide3 42 | * 43 | * 10 1/06/98 6:47p Atai 44 | * undo grSplash and remove gu routines 45 | * 46 | * 9 1/05/98 6:04p Atai 47 | * move 3df gu related data structure from glide.h to glideutl.h 48 | * 49 | * 8 12/18/97 2:13p Peter 50 | * fogTable cataclysm 51 | * 52 | * 7 12/15/97 5:52p Atai 53 | * disable obsolete glide2 api for glide3 54 | * 55 | * 6 8/14/97 5:32p Pgj 56 | * remove dead code per GMT 57 | * 58 | * 5 6/12/97 5:19p Pgj 59 | * Fix bug 578 60 | * 61 | * 4 3/05/97 9:36p Jdt 62 | * Removed guFbWriteRegion added guEncodeRLE16 63 | * 64 | * 3 1/16/97 3:45p Dow 65 | * Embedded fn protos in ifndef FX_GLIDE_NO_FUNC_PROTO 66 | */ 67 | 68 | /* Glide Utility routines */ 69 | 70 | #ifndef __GLIDEUTL_H__ 71 | #define __GLIDEUTL_H__ 72 | 73 | #ifdef __cplusplus 74 | extern "C" { 75 | #endif 76 | 77 | /* 78 | ** 3DF texture file structs 79 | */ 80 | 81 | typedef struct 82 | { 83 | FxU32 width, height; 84 | int small_lod, large_lod; 85 | GrAspectRatio_t aspect_ratio; 86 | GrTextureFormat_t format; 87 | } Gu3dfHeader; 88 | 89 | typedef struct 90 | { 91 | FxU8 yRGB[16]; 92 | FxI16 iRGB[4][3]; 93 | FxI16 qRGB[4][3]; 94 | FxU32 packed_data[12]; 95 | } GuNccTable; 96 | 97 | typedef struct { 98 | FxU32 data[256]; 99 | } GuTexPalette; 100 | 101 | typedef union { 102 | GuNccTable nccTable; 103 | GuTexPalette palette; 104 | } GuTexTable; 105 | 106 | typedef struct 107 | { 108 | Gu3dfHeader header; 109 | GuTexTable table; 110 | void *data; 111 | FxU32 mem_required; /* memory required for mip map in bytes. */ 112 | } Gu3dfInfo; 113 | 114 | #ifndef FX_GLIDE_NO_FUNC_PROTO 115 | /* 116 | ** Gamma functions 117 | */ 118 | 119 | FX_ENTRY void FX_CALL 120 | guGammaCorrectionRGB( FxFloat red, FxFloat green, FxFloat blue ); 121 | 122 | /* 123 | ** fog stuff 124 | */ 125 | FX_ENTRY float FX_CALL 126 | guFogTableIndexToW( int i ); 127 | 128 | FX_ENTRY void FX_CALL 129 | guFogGenerateExp( GrFog_t *fogtable, float density ); 130 | 131 | FX_ENTRY void FX_CALL 132 | guFogGenerateExp2( GrFog_t *fogtable, float density ); 133 | 134 | FX_ENTRY void FX_CALL 135 | guFogGenerateLinear(GrFog_t *fogtable, 136 | float nearZ, float farZ ); 137 | 138 | /* 139 | ** hi-level texture manipulation tools. 140 | */ 141 | FX_ENTRY FxBool FX_CALL 142 | gu3dfGetInfo( const char *filename, Gu3dfInfo *info ); 143 | 144 | FX_ENTRY FxBool FX_CALL 145 | gu3dfLoad( const char *filename, Gu3dfInfo *data ); 146 | 147 | #endif /* FX_GLIDE_NO_FUNC_PROTO */ 148 | 149 | #ifdef __cplusplus 150 | } 151 | #endif 152 | 153 | #endif /* __GLIDEUTL_H__ */ 154 | -------------------------------------------------------------------------------- /doc/conform/extgl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * OpenGL testsuite 3 | * Version: 0.1 4 | * 5 | * Copyright (C) 2005 Daniel Borca All Rights Reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /* 27 | * Extension wrappers. 28 | */ 29 | 30 | 31 | #include 32 | #include 33 | 34 | #include "extgl.h" 35 | 36 | 37 | GLAPI void GLAPIENTRY 38 | myBlendColorEXT (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) 39 | { 40 | #ifdef _WIN32 41 | static PFNGLBLENDCOLOREXTPROC BlendColorEXT = NULL; 42 | if (BlendColorEXT == NULL) { 43 | BlendColorEXT = (PFNGLBLENDCOLOREXTPROC)wglGetProcAddress("glBlendColorEXT"); 44 | } 45 | if (BlendColorEXT != NULL) { 46 | BlendColorEXT(red, green, blue, alpha); 47 | } 48 | #else 49 | glBlendColorEXT(red, green, blue, alpha); 50 | #endif 51 | } 52 | 53 | 54 | GLAPI void GLAPIENTRY 55 | myBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) 56 | { 57 | #ifdef _WIN32 58 | static PFNGLBLENDFUNCSEPARATEEXTPROC BlendFuncSeparateEXT = NULL; 59 | if (BlendFuncSeparateEXT == NULL) { 60 | BlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)wglGetProcAddress("glBlendFuncSeparateEXT"); 61 | } 62 | if (BlendFuncSeparateEXT != NULL) { 63 | BlendFuncSeparateEXT(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); 64 | } 65 | #else 66 | glBlendFuncSeparateEXT(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); 67 | #endif 68 | } 69 | 70 | 71 | GLAPI void GLAPIENTRY 72 | myBlendEquationEXT (GLenum mode) 73 | { 74 | #ifdef _WIN32 75 | static PFNGLBLENDEQUATIONEXTPROC BlendEquationEXT = NULL; 76 | if (BlendEquationEXT == NULL) { 77 | BlendEquationEXT = (PFNGLBLENDEQUATIONEXTPROC)wglGetProcAddress("glBlendEquationEXT"); 78 | } 79 | if (BlendEquationEXT != NULL) { 80 | BlendEquationEXT(mode); 81 | } 82 | #else 83 | glBlendEquationEXT(mode); 84 | #endif 85 | } 86 | 87 | 88 | GLAPI void GLAPIENTRY 89 | myBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha) 90 | { 91 | #ifdef _WIN32 92 | static PFNGLBLENDEQUATIONSEPARATEEXTPROC BlendEquationSeparateEXT; 93 | if (BlendEquationSeparateEXT == NULL) { 94 | BlendEquationSeparateEXT = (PFNGLBLENDEQUATIONSEPARATEEXTPROC)wglGetProcAddress("glBlendEquationSeparateEXT"); 95 | } 96 | if (BlendEquationSeparateEXT != NULL) { 97 | BlendEquationSeparateEXT(modeRGB, modeAlpha); 98 | } 99 | #else 100 | /*glBlendEquationSeparateEXT(modeRGB, modeAlpha);*/ 101 | #endif 102 | } 103 | 104 | 105 | GLAPI void APIENTRY 106 | myActiveTextureARB (GLenum texture) 107 | { 108 | #ifdef _WIN32 109 | static PFNGLACTIVETEXTUREARBPROC ActiveTextureARB; 110 | if (ActiveTextureARB == NULL) { 111 | ActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB"); 112 | } 113 | if (ActiveTextureARB != NULL) { 114 | ActiveTextureARB(texture); 115 | } 116 | #else 117 | glActiveTextureARB(texture); 118 | #endif 119 | } 120 | 121 | 122 | GLAPI void APIENTRY 123 | myMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t) 124 | { 125 | #ifdef _WIN32 126 | static PFNGLMULTITEXCOORD2FARBPROC MultiTexCoord2fARB = NULL; 127 | if (MultiTexCoord2fARB == NULL) { 128 | MultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)wglGetProcAddress("glMultiTexCoord2fARB"); 129 | } 130 | if (MultiTexCoord2fARB != NULL) { 131 | MultiTexCoord2fARB(target, s, t); 132 | } 133 | #else 134 | glMultiTexCoord2fARB(target, s, t); 135 | #endif 136 | } 137 | 138 | --------------------------------------------------------------------------------