Compare commits

..

156 Commits

Author SHA1 Message Date
Brian Paul
4266ec91fe removed extra right-paren 2002-06-25 15:23:51 +00:00
Brian Paul
8a5bdd826a added glCullFace bug fix 2002-06-25 15:22:12 +00:00
Keith Whitwell
20cbbf8459 Check for GL_FRONT_AND_BACK culling before installing optimized tri
funcs.
2002-06-25 08:41:06 +00:00
Keith Whitwell
2847895a03 Check for FRONT_AND_BACK culling before installing an optimized tri func 2002-06-25 08:38:33 +00:00
Brian Paul
79d05b5649 version updates 2002-06-24 20:44:58 +00:00
Karl Schultz
a0ad8d5a8a Remove -Zi from CFLAGS. I probably left it in there during a debug
session.
2002-06-24 20:19:16 +00:00
Karl Schultz
1a9198f118 Set global "Current" context in WMesaMakeCurrent before calling
GetBufferSize, since GetBufferSize needs Current to be set.
2002-06-24 20:18:04 +00:00
Brian Paul
dd8fbed413 compilation fixes 2002-06-24 17:37:53 +00:00
Brian Paul
972cc7827f put XSync in get_buffer_size(), plus clean-up 2002-06-19 21:50:14 +00:00
Brian Paul
263d8ff8e3 new fix for initial window size problem 2002-06-17 23:32:43 +00:00
Brian Paul
363c8b9048 Fix glXCopyContext bug 2002-06-16 03:55:27 +00:00
Brian Paul
eb7b122807 added glXCopyContext bug fix 2002-06-16 03:33:33 +00:00
Brian Paul
6306085c69 Fixed a few bugs in _mesa_copy_context() related to pointer corruption.
Added _mesa_copy_texture_state() to texstate.c
Added _meas_copy_texture_object() to texobj.c, use it in attrib.c
2002-06-16 03:19:57 +00:00
Brian Paul
7e20f99f81 fixed window size initialization bug 2002-06-16 01:11:03 +00:00
Brian Paul
a79f7f8838 added updated GGI driver info 2002-06-15 03:17:28 +00:00
Brian Paul
d1d4f6bd34 Sync with Mesa changes in DRI trunk.
Updated device drivers since Driver->SetDrawBuffer() no longer returns bool.
2002-06-14 03:49:09 +00:00
Brian Paul
640f61ba13 Moved big/little endian code to glheader.h.
Define either MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
2002-06-12 00:28:55 +00:00
Brian Paul
07e3f72bf8 Added CPLUSPLUS for sunos5 entries 2002-06-10 17:01:30 +00:00
Brian Paul
d06d24f497 GGI driver updates (Filip Spacek) 2002-06-10 15:16:16 +00:00
Brian Paul
3fa786c175 fixed two texture target error checking conditions 2002-06-08 13:05:07 +00:00
Brian Paul
984bb590df tweaked a comment 2002-06-08 12:43:40 +00:00
Brian Paul
67c5effe5c added GL_TEXTURE_FILTER_CONTROL_EXT query to glGetTexEnv[if]v() 2002-06-08 12:43:05 +00:00
Brian Paul
fbe488cb76 glext.h version 15 2002-06-08 12:40:47 +00:00
Brian Paul
dbd36a0ca0 added missing texture cube map targets 2002-06-08 12:39:39 +00:00
Brian Paul
076870f384 version 15 of glext.h 2002-06-07 20:21:29 +00:00
Brian Paul
c1fba8241b added glext.h GL_MAX_RECTANGLE_TEXTURE_SIZE_NV fix 2002-06-07 19:38:06 +00:00
Brian Paul
690798ae3b s/GL_MAX_TEXTURE_RECTANGLE_SIZE_NV/GL_MAX_RECTANGLE_TEXTURE_SIZE_NV/ 2002-06-07 19:29:09 +00:00
Brian Paul
89e91fcc9a replaced hard-coded 4 with NUM_TEXTURE_TARGETS 2002-06-06 16:25:07 +00:00
Brian Paul
d5a8eeaeeb replaced 0xf and 0xf0 with TEXTURE0_ANY and TEXTURE1_ANY 2002-06-06 16:15:12 +00:00
Brian Paul
b118f433e1 NASM fix for *_CONTENT() macros (Josh Vanderhoof) 2002-06-06 15:33:15 +00:00
Brian Paul
fbbb780e1f more big-endian tweaks 2002-06-05 16:40:21 +00:00
Brian Paul
9429860763 use CONTENT() macro on line 205 (Josh Vanderhoof) 2002-06-04 21:29:01 +00:00
Brian Paul
531af3f17f bring over Michel Daenzer's DRI changes 2002-06-03 16:02:04 +00:00
Keith Whitwell
054f415f45 Fix FETCH(argb1555) mask values 2002-05-09 20:51:32 +00:00
Brian Paul
b1b4382283 remove -xK flag from linux-icc 2002-05-06 15:46:17 +00:00
Brian Paul
3aef708b56 added linux-icc config (Marc.Dietrich) 2002-05-05 15:57:09 +00:00
Alan Hourihane
d63730d087 glutSwapBuffers implicitly does a glFinish when swapping back to the front
buffer. We now issue a glFinish when not issuing SwapBuffers to ensure
the pipeline is complete.

(Problem found with Chromium).
2002-05-01 14:53:52 +00:00
Brian Paul
2469fc9672 bump version to 4.0.3 2002-04-26 13:57:15 +00:00
Brian Paul
86ab257a46 Mesa 4.0.3 updates 2002-04-26 13:54:47 +00:00
Brian Paul
d7e7d8ec74 bump version numbers to 4.0.3 2002-04-26 13:51:53 +00:00
Brian Paul
fe4edce605 added GL_TEXTURE_MAX_ANISOTROPY_EXT to glGetTexParameteriv() 2002-04-26 13:39:38 +00:00
Brian Paul
b0f477e5dd added GL_TEXTURE_MAX_ANISOTROPY_EXT to glGetTexParameter (bug 548812) 2002-04-25 22:11:24 +00:00
Brian Paul
ce4c38fe2e backport array bound checking in glPixelMap() from Mesa 4.1 2002-04-24 20:41:51 +00:00
Brian Paul
09760a9563 test mapsize against 1, not 0 in glPixelMap() 2002-04-24 20:11:56 +00:00
Brian Paul
d7abab5c67 added GL_EDGE_FLAG_ARRAY_COUNT_EXT to glGetBooleanv() (Bug 548277) 2002-04-24 20:06:28 +00:00
Karl Schultz
e900da049b Apply alpha buffer control fix to accum buffer too. 2002-04-23 18:38:00 +00:00
Karl Schultz
9def08ad3d Fix up alpha buffer handling for Windows.
- add two new Pixel Format Descriptors that do not have alpha bits to
mirror the two that do.
- add logic to wglChoosePixelFormat to match PFD's with respect to alpha.
- Create/clear software alpha buffer as required.
Now a wgl or GLUT program can control the creation of a software alpha
buffer via the PFD or GLUT parms, respectively.
2002-04-23 18:24:41 +00:00
Brian Paul
978731595d call _mesa_sizeof_packed_type() in _mesa_GetTexImage() (bug 547203) 2002-04-23 16:45:16 +00:00
Alan Hourihane
00e5cb4120 same NULL checks for 4_0 branch 2002-04-22 20:04:52 +00:00
Brian Paul
b338ee265a fixed Width/Height cut&paste typo 2002-04-20 17:59:43 +00:00
Alan Hourihane
8d3f06a565 Correct check for noop array state change (Raystonn) 2002-04-19 08:37:10 +00:00
Brian Paul
0d1785c6db back-port new casts and C++ fixes from trunk 2002-04-19 01:10:48 +00:00
Brian Paul
79474dc528 fixed problem with swap() function and GCC3 (patch 414404) 2002-04-17 19:30:19 +00:00
Brian Paul
43e90c0053 Disabled SPARC cliptest functions for now. See bug report 544665. 2002-04-17 19:08:37 +00:00
Karl Schultz
c748b6c3d8 Build demos/samples correctly on Windows (Robert Bergkvist) to sync up
with the main branch.  (I should have done this for 4.0.2)
2002-04-15 22:13:00 +00:00
Karl Schultz
2c109c15e0 update to match branch - performance measuring additions. 2002-04-15 21:22:36 +00:00
Brian Paul
22fcb86432 Jose's latest patch (GMBT_GEOMETRIC_CORRECTION) 2002-04-12 21:57:46 +00:00
Brian Paul
70c5d68365 fixes for corrected GL_DOT3_RGB[A]_EXT token values 2002-04-12 21:17:53 +00:00
Brian Paul
1b0fcb2124 version 13 of glext.h - fixes GL_EXT_texture_env_dot3 token values 2002-04-12 21:09:24 +00:00
Brian Paul
6668d2fcb1 new MMX blend code (Jose Fonseca) 2002-04-10 16:32:50 +00:00
Brian Paul
e3c2d6bd0c removed stray 'n' character at top of file 2002-04-09 13:33:34 +00:00
Keith Whitwell
655e0ad0c1 bring in changes from dri tcl branch 2002-04-09 12:13:06 +00:00
Brian Paul
d99fa29b94 tranforming display list normals by non-uniform scale didn't work (Carlos Pereira) 2002-04-08 15:36:03 +00:00
Brian Paul
7229861a46 Pass context pointer to _tnl_free_immediate() and don't rely on backref
pointer (fixes Allen Barnett's display list sharing problem).
2002-04-06 16:35:17 +00:00
Karl Schultz
f5130e3473 export another symbol for recent osmesa changes. 2002-04-05 17:13:10 +00:00
Brian Paul
a5ed2460e9 repair Array.NewState flags (Michael Fitzpatrick) 2002-04-04 23:57:58 +00:00
Brian Paul
e2130abf8f call _mesa_ResizeBuffersMESA() in OSMesaMakeCurrent() to reconcile buffer size changes 2002-04-04 17:12:47 +00:00
Brian Paul
bf6a6f1d59 fixed some 3D texture image stride bugs when using 16-bit channels 2002-04-04 17:05:59 +00:00
Brian Paul
abd10c99e5 fixed 16/32-bit channel problems in CopyColor[Sub]Table() 2002-04-04 17:04:56 +00:00
Brian Paul
c3bc8a9c1e Texture combine alpha subtraction was wrong. Fixed 16-bit channel glitches 2002-04-04 17:04:50 +00:00
Brian Paul
aa5698e8ed DJGPP fixes 2002-04-01 17:09:25 +00:00
Brian Paul
cf4c9ada0d another DOS driver update 2002-04-01 16:54:11 +00:00
Brian Paul
13c751a1c2 Use invert_matrix_general() instead of invert_matrix_perspective() because
the former fails for some projection matrices (ala Vis5D with Chromium).
2002-03-29 17:15:01 +00:00
Brian Paul
2af71a9acf added dmesadxe.h to tar file list 2002-03-29 14:42:29 +00:00
Brian Paul
5e0316f1a8 decrement Transform._AnyClip when clip planes are disabled 2002-03-28 22:45:50 +00:00
Brian Paul
2366fb3b89 popping of user-defined clip planes was broken 2002-03-28 22:42:34 +00:00
Karl Schultz
4ad3511865 (WIN32)Use _glapi_get_context to get the context in buffer_size() instead
of the GET_CURRENT_CONTEXT macro.  The macro tries to use the glapi_Context
variable which needs to be imported from the MesaGL DLL, which is too
problematic to do at the moment.
2002-03-25 23:52:34 +00:00
Karl Schultz
44f6191507 export _glapi_get_context for osmesa. 2002-03-25 23:41:49 +00:00
Brian Paul
aaf89c1cc7 re-adding a lost file 2002-03-23 02:36:52 +00:00
Brian Paul
7350dd7395 DOS/Mesa driver updates (Daniel Borca) 2002-03-23 02:23:06 +00:00
Brian Paul
972815c414 final? updates 2002-03-23 02:22:01 +00:00
Brian Paul
0bb0b4df73 latest extension headers from SGI 2002-03-23 01:49:09 +00:00
Brian Paul
e07b4252ad removed glSamplePass() 2002-03-20 22:06:57 +00:00
Brian Paul
b8855675ca latest bug fixes 2002-03-19 16:49:07 +00:00
Brian Paul
6bf823ac2d don't set plane mask for xm_buffer->gc, it causes an accum buffer conformance problem 2002-03-19 16:47:56 +00:00
Brian Paul
af3f3080f9 Use MESA_PBUFFER_ALLOC/FREE macros to allocate all framebuffer and texture
memory.  These can be overridden by applications which need to manage this
memory specially.  Contributed by Gerk Huisma.
2002-03-19 16:42:41 +00:00
Brian Paul
bb47715320 fix Intel C compiler warnings (Gerk Huisma) 2002-03-19 15:22:41 +00:00
Brian Paul
cef9cdf3bb undo previous check-in 2002-03-16 01:00:43 +00:00
Brian Paul
4493f41577 added XMesaResizeBuffers() 2002-03-16 00:50:36 +00:00
Brian Paul
a4f3130a7f Lots of changes related to framebuffer/window buffer resizing. Basically,
instead of passing a GLcontext* to ResizeBuffers(), pass a GLframebuffer*.
The idea is that a window can be resized without it being bound to a rendering
context.  This makes for a nice clean-up in the XFree86 server-side GLX code.
Renamed ctx->Driver.ResizeBuffersMESA() to ctx->Driver.ResizeBuffers().
2002-03-16 00:50:11 +00:00
Brian Paul
b2c3daa875 protect currentReadable reference with #ifndef GLX_BUILT_IN_XMESA 2002-03-15 19:11:37 +00:00
Brian Paul
3d6951c097 updated comments. removed dead code. 2002-03-15 18:32:54 +00:00
Brian Paul
db0ed6252b remove a debug printf 2002-03-15 18:24:34 +00:00
Brian Paul
e6c59e8d0c fixed typo in CONVERT_TEXEL_DWORD for convert_abgr8888_to_ai88 textures (Michael Fitzpatrick) 2002-03-15 17:57:42 +00:00
Brian Paul
378fcdb818 fixed pointer arithmetic error in glCopyPixels 2002-03-14 22:09:05 +00:00
Brian Paul
cd3f5d807a put lodbias loop inside test for non-NULL lambda array 2002-03-13 04:45:35 +00:00
Brian Paul
c3e908891c added thread rendering bug fix 2002-03-12 21:57:27 +00:00
Brian Paul
fdbaf407a7 Removed the xm_context field from XMesaBuffer. It was preventing N threads
from rendering into one window in parallel and wasn't really needed anyway.
2002-03-12 21:54:03 +00:00
Brian Paul
5a86d3852c tweak file list for tarballs 2002-03-11 14:59:12 +00:00
Brian Paul
96d0be5cf2 obsolete 2002-03-11 14:56:42 +00:00
Brian Paul
0bd26c3c55 fix some minor warnings 2002-03-08 19:43:36 +00:00
Brian Paul
9f7053e913 updates for 4.0.2 2002-03-08 19:28:57 +00:00
Brian Paul
9fa55ac457 DOS driver updates from Daniel Borca 2002-03-08 19:27:28 +00:00
Brian Paul
101092ea11 new DOS driver files from Daniel Borca 2002-03-08 19:24:36 +00:00
Brian Paul
da648d9afd minor patches from David Dawes 2002-03-07 21:50:53 +00:00
Brian Paul
7a3b7c9687 syntax fixes for Solaris (David Dawes) 2002-03-07 21:39:09 +00:00
Brian Paul
55f8fcba10 use -O3 for osmesa16/32 builds, disable FX and SVGA in debug builds 2002-03-01 19:38:53 +00:00
Brian Paul
7419597f2f return 'Mesa Offscreen16' or 'Mesa Offscreen32' if using deep color channels 2002-03-01 19:37:28 +00:00
Brian Paul
e784671997 silence gcc warnings (Marc La France) 2002-03-01 04:25:42 +00:00
Brian Paul
c2165e799c updated comments for CHAN_BITS=16 or 32 2002-03-01 04:23:16 +00:00
Brian Paul
40519b3eb3 DOS driver updates from Daniel Borca 2002-02-23 17:07:21 +00:00
Brian Paul
dcda68de33 Fixed out-of-bounds memory write problem (CONVERT_TEXEL_DWORD macro).
Renamed 'packing' to 'unpacking' since we're moving data from client -> GL.
Rnamed DST_ROW_WIDTH to DST_ROW_BYTES.
2002-02-21 15:11:15 +00:00
Brian Paul
8308199e5d added XMesaGarbageCollect item 2002-02-21 00:00:25 +00:00
Brian Paul
3b029b0c7d check for initialized XMesaBuffer in XMesaGarbageCollect() 2002-02-20 23:59:40 +00:00
Brian Paul
bff7677bd9 undo some debug changes mistakenly checked in earlier 2002-02-17 17:38:44 +00:00
Brian Paul
41796ecc25 added two latest bug fixes 2002-02-15 19:15:59 +00:00
Brian Paul
94865a95b1 use separate GC for SwapBuffers to avoid colormask problem 2002-02-15 19:15:08 +00:00
Karl Schultz
b8b23d4552 fix casts to quiet compiler warnings. 2002-02-15 18:50:48 +00:00
Brian Paul
3245cfdf41 obsolete 2002-02-15 14:04:57 +00:00
Brian Paul
69e043158a fixed float->int conversion. Fix conditional for 16-bit Z buffer path 2002-02-15 03:38:29 +00:00
Keith Whitwell
3ce17ffb84 Remove debug 2002-02-13 23:52:48 +00:00
Keith Whitwell
33b483f882 remove debug prints 2002-02-12 21:07:59 +00:00
Keith Whitwell
308a036114 More support for t&l drivers.
Fix reset_stipple calls.
Fix unsigned compare bugs.
2002-02-12 17:37:26 +00:00
Karl Schultz
4c97c84f7e silence compiler warning (windows) 2002-02-12 16:36:36 +00:00
Brian Paul
d7bde06097 silence compiler warnings 2002-02-12 16:07:15 +00:00
Brian Paul
a00292bcfe silence compiler warning 2002-02-12 16:06:16 +00:00
Brian Paul
7d729ffb58 release notes for 4.0.2 2002-02-12 15:54:47 +00:00
Brian Paul
aeb6c0af5e replace assertion with a test (avoid div by zero error) 2002-02-12 03:14:58 +00:00
Brian Paul
41110917d7 Prep for Mesa 4.0.2 release. 2002-02-12 03:13:41 +00:00
Brian Paul
a58b1ed0a3 Daniel Borca's GLUT for DOS/DJGPP. 2002-02-12 02:59:24 +00:00
Brian Paul
27b503cab8 Daniel Borca's new DOS/DJGPP driver. 2002-02-12 02:58:56 +00:00
Brian Paul
d38cdd33d0 removed GLUT reference 2002-01-30 21:54:47 +00:00
Brian Paul
851acc6ea7 added some handy debug code 2002-01-30 16:47:04 +00:00
Brian Paul
6115d784a7 don't use affine/persp_textured_triangle funcs when CHAN_BITS > 8 2002-01-30 16:45:29 +00:00
Brian Paul
fcca385bec replace GLushort w/ GLubyte in DEST_4US template (fixes 16-bit GLchan problem 2002-01-30 16:42:23 +00:00
Brian Paul
06743cf365 updated gl_mangle.h (Ray Tice) 2002-01-18 14:55:50 +00:00
Brian Paul
b372b40bd1 set PB->haveSpec in line functions that emit specular color 2002-01-16 18:24:31 +00:00
Karl Schultz
3e3bd40614 Fixes for 24-bit Windows devices. The old code was trying to do 3-byte
stores with a full DWORD store (yuk).  (Jeff Lewis)
2002-01-16 15:37:49 +00:00
Brian Paul
3fb6d0bfde added some missing error checks 2002-01-15 21:50:15 +00:00
Brian Paul
b36acc0423 removed API compat stuff 2002-01-15 20:17:59 +00:00
Karl Schultz
287d6127d2 Fixed pixel color component problem and clear code for 24-bit Windows
devices.  (Jeff Lewis)
2002-01-15 16:47:37 +00:00
Karl Schultz
a8290d3a95 Remove trailing CR's from most of the lines. No logical changes. 2002-01-15 16:12:15 +00:00
Brian Paul
b26f972618 don't apply scissor box in read_fast_rgba_pixels() 2002-01-12 16:12:42 +00:00
Brian Paul
5bd6bad38d fixed int->float conversion bug in _mesa_TexEnviv() 2002-01-09 02:14:50 +00:00
Brian Paul
1ae3437156 fixed GL_REPLACE / GL_RGB bug 2002-01-09 00:28:53 +00:00
Brian Paul
93665403aa texture env color wasn't used correctly in GL_BLEND mode 2002-01-09 00:12:37 +00:00
Brian Paul
04613cb0bc compile with -DNDEBUG 2002-01-08 15:58:11 +00:00
Brian Paul
e0a30e9d2d work-around for QNX compiler problem 2002-01-08 14:56:33 +00:00
Brian Paul
fd3da01ec3 fix typo (d'oh) 2002-01-04 14:36:58 +00:00
Brian Paul
40bbb8b7f3 fix bug 498555 - test for __GNUC__ 2002-01-04 14:35:34 +00:00
Brian Paul
00b7772bda fixes from Albert Chin 2002-01-03 16:29:07 +00:00
Karl Schultz
0fc4d7e46d Define finite as _finite for Windows. 2001-12-20 18:58:24 +00:00
Keith Whitwell
1261fed2c3 Further help with libGL version skew in dri drivers. 2001-12-20 15:29:15 +00:00
Keith Whitwell
4f4f542bd7 Fix clipping problem on mga 2001-12-20 09:53:57 +00:00
Brian Paul
550169ab62 added separate specular bug fix 2001-12-19 01:20:40 +00:00
Brian Paul
ad83c33a4d have to clamp color+specular in _swrast_add_spec_terms_triangle()! (fixes Chimera bug) 2001-12-19 01:13:12 +00:00
205 changed files with 16090 additions and 8603 deletions

View File

@@ -1,13 +1,13 @@
# $Id: Make-config,v 1.50.2.4 2001/12/14 17:46:20 kschultz Exp $
# $Id: Make-config,v 1.50.2.10 2002/06/10 17:01:30 brianp Exp $
MESA_MAJOR=4
MESA_MINOR=0
MESA_TINY=0
MESA_TINY=3
VERSION=$(MESA_MAJOR).$(MESA_MINOR)
# Mesa 3-D graphics library
#
# Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
# Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -606,6 +606,32 @@ linux-x86:
X86/sse_xform3.S X86/sse_xform4.S \
X86/sse_normal.S X86/sse_vertex.S"
linux-icc:
$(MAKE) $(MFLAGS) -f Makefile.X11 targets \
"GL_LIB = libGL.so" \
"GLU_LIB = libGLU.so" \
"GLUT_LIB = libglut.so" \
"GLW_LIB = libGLw.so" \
"OSMESA_LIB = libOSMesa.so" \
"CC = icc" \
"CPLUSPLUS = g++" \
"CFLAGS = -O3 -tpp6 -KPIC -D_GCC_LIMITS_H_ -D__GNUC__ -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -I/usr/X11R6/include" \
"MAKELIB = ../bin/mklib.linux" \
"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lm -lpthread" \
"GLU_LIB_DEPS = -L../lib -lGL -lm" \
"GLUT_LIB_DEPS = -L../lib -lGLU -lGL -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm" \
"APP_LIB_DEPS = -lm" \
"ASM_SOURCES = X86/common_x86_asm.S X86/glapi_x86.S \
X86/x86_xform2.S X86/x86_xform3.S X86/x86_xform4.S \
X86/x86_cliptest.S X86/x86_vertex.S \
X86/mmx_blend.S \
X86/3dnow_xform1.S X86/3dnow_xform2.S \
X86/3dnow_xform3.S X86/3dnow_xform4.S \
X86/3dnow_normal.S X86/3dnow_vertex.S \
X86/sse_xform1.S X86/sse_xform2.S \
X86/sse_xform3.S X86/sse_xform4.S \
X86/sse_normal.S X86/sse_vertex.S"
linux-x86-static:
$(MAKE) $(MFLAGS) -f Makefile.X11 targets \
"GL_LIB = libGL.a" \
@@ -697,7 +723,7 @@ linux-386-glide:
"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -L/usr/local/glide/lib -lglide2x -lm -lpthread" \
"GLU_LIB_DEPS = -L../lib -lGL -lm" \
"GLUT_LIB_DEPS = -L../lib -lGLU -lGL -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm" \
"APP_LIB_DEPS = -L/usr/local/glide/lib -lglide2x -lglut -lGLU -lGL"
"APP_LIB_DEPS = -L/usr/local/glide/lib -lglide2x -lglut -lGLU -lGL -lm" \
"ASM_SOURCES = X86/common_x86_asm.S X86/glapi_x86.S \
X86/x86_xform2.S X86/x86_xform3.S X86/x86_xform4.S \
X86/x86_cliptest.S X86/x86_vertex.S"
@@ -717,7 +743,7 @@ linux-386-opt-glide:
"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -L/usr/local/glide/lib -lglide2x -lm -lpthread" \
"GLU_LIB_DEPS = -L../lib -lGL -lm" \
"GLUT_LIB_DEPS = -L../lib -lGLU -lGL -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm" \
"APP_LIB_DEPS = -lm" \
"APP_LIB_DEPS = -L/usr/local/glide/lib -lglide2x -lglut -lGLU -lGL -lm" \
"ASM_SOURCES = X86/common_x86_asm.S X86/glapi_x86.S \
X86/x86_xform2.S X86/x86_xform3.S X86/x86_xform4.S \
X86/x86_cliptest.S X86/x86_vertex.S"
@@ -736,7 +762,7 @@ linux-x86-glide:
"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -L/usr/local/glide/lib -lglide2x -lm -lpthread" \
"GLU_LIB_DEPS = -L../lib -lGL -lm" \
"GLUT_LIB_DEPS = -L../lib -lGLU -lGL -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm" \
"APP_LIB_DEPS = -lm" \
"APP_LIB_DEPS = -L/usr/local/glide/lib -lglide2x -lglut -lGLU -lGL -lm" \
"ASM_SOURCES = X86/common_x86_asm.S X86/glapi_x86.S \
X86/x86_xform2.S X86/x86_xform3.S X86/x86_xform4.S \
X86/x86_cliptest.S X86/x86_vertex.S \
@@ -867,7 +893,7 @@ linux-osmesa16:
"OSMESA16_LIB = libOSMesa16.so" \
"CC = gcc" \
"CPLUSPLUS = g++" \
"CFLAGS = -g -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG -DMESA_DEBUG -DCHAN_BITS=16 -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \
"CFLAGS = -O3 -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG -DMESA_DEBUG -DCHAN_BITS=16 -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \
"CCFLAGS = $(CFLAGS)" \
"MAKELIB = ../bin/mklib.linux" \
"GL_LIB_DEPS = -lm -lpthread" \
@@ -879,7 +905,7 @@ linux-osmesa32:
"OSMESA16_LIB = libOSMesa32.so" \
"CC = gcc" \
"CPLUSPLUS = g++" \
"CFLAGS = -g -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG -DMESA_DEBUG -DCHAN_BITS=32 -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \
"CFLAGS = -O3 -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG -DMESA_DEBUG -DCHAN_BITS=32 -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \
"CCFLAGS = $(CFLAGS)" \
"MAKELIB = ../bin/mklib.linux" \
"GL_LIB_DEPS = -lm -lpthread" \
@@ -1212,6 +1238,7 @@ sunos5:
"GLW_LIB = libGLw.a" \
"OSMESA_LIB = libOSMesa.a" \
"CC = cc" \
"CPLUSPLUS = CC" \
"CFLAGS = -Xa -fast -xO4 -native -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DSOLARIS_2_4_BUG" \
"MAKELIB = ../bin/mklib.ar-ruv" \
"APP_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -R/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm"
@@ -1224,6 +1251,7 @@ sunos5-sl:
"GLW_LIB = libGLw.so" \
"OSMESA_LIB = libOSMesa.so" \
"CC = cc" \
"CPLUSPLUS = CC" \
"CFLAGS = -KPIC -Xa -O -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DSOLARIS_2_4_BUG" \
"MAKELIB = ../bin/mklib.sunos5" \
"APP_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -R/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm"
@@ -1236,6 +1264,7 @@ sunos5-ultra:
"GLW_LIB = libGLw.a" \
"OSMESA_LIB = libOSMesa.a" \
"CC = cc" \
"CPLUSPLUS = CC" \
"CFLAGS = -Xa -fast -xO5 -xtarget=ultra -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DSOLARIS_2_4_BUG" \
"MAKELIB = ../bin/mklib.ar-ruv" \
"APP_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -R/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm"
@@ -1248,6 +1277,7 @@ sunos5-ultra-sl:
"GLW_LIB = libGLw.so" \
"OSMESA_LIB = libOSMesa.so" \
"CC = cc" \
"CPLUSPLUS = CC" \
"CFLAGS = -KPIC -Xa -fast -xO5 -xtarget=ultra -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DSOLARIS_2_4_BUG" \
"MAKELIB = ../bin/mklib.sunos5" \
"APP_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -R/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm"
@@ -1487,13 +1517,13 @@ linux-debug:
"OSMESA_LIB = libOSMesa.so" \
"CC = gcc" \
"CPLUSPLUS = g++" \
"CFLAGS = -g -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG -DMESA_DEBUG -DSVGA -I/usr/include/glide -DFX -DMESA_TRACE" \
"CFLAGS = -g -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG -DMESA_DEBUG -DSVGA_foo -I/usr/include/glide -DFX_foo -DMESA_TRACE" \
"CCFLAGS = $(CFLAGS)" \
"MAKELIB = ../bin/mklib.linux" \
"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread -L/usr/local/glide/lib -lglide2x -lvga" \
"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread" \
"GLU_LIB_DEPS = -L../lib -lGL -lm" \
"GLUT_LIB_DEPS = -L../lib -lGLU -lGL -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm" \
"APP_LIB_DEPS = -lglut -lGLU -lGL -L/usr/local/glide/lib -lglide2x"
"APP_LIB_DEPS = -lglut -lGLU -lGL"
linux-x11-debug:
$(MAKE) $(MFLAGS) -f Makefile.X11 targets \

View File

@@ -1,9 +1,9 @@
# $Id: Makefile.X11,v 1.56.2.3 2001/12/14 17:11:46 kschultz Exp $
# $Id: Makefile.X11,v 1.56.2.10 2002/06/24 20:44:58 brianp Exp $
# Mesa 3-D graphics library
# Version: 4.0
# Version: 4.0.3
#
# Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
# Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -87,6 +87,7 @@ default:
@echo " make linux-sparc-ultra for UltraSparc systems, make ELF shared libs"
@echo " make linux-osmesa16 for 16-bit/channel OSMesa"
@echo " make linux-osmesa32 for 32-bit/channel OSMesa"
@echo " make linux-icc for Linux with the Intel C/C++ compiler"
@echo " make lynxos for LynxOS systems with GCC"
@echo " make macintosh for Macintosh"
@echo " make machten-2.2 for Macs w/ MachTen 2.2 (68k w/ FPU)"
@@ -143,7 +144,7 @@ hpux9 hpux9-sl hpux9-gcc hpux9-gcc-sl \
hpux10 hpux10-sl hpux10-gcc hpux10-gcc-sl \
irix4 irix5 irix5-gcc irix5-dso \
linux linux-static linux-debug linux-x11-debug linux-static-debug linux-prof \
linux-x86 linux-x86-static linux-x86-debug \
linux-x86 linux-icc linux-x86-static linux-x86-debug \
linux-glide linux-386-glide linux-386-opt-glide \
linux-x86-glide linux-glide-debug linux-glide-prof \
linux-alpha-static linux-alpha \
@@ -329,10 +330,10 @@ realclean: clean
DIRECTORY = Mesa-4.0
LIB_NAME = MesaLib-4.0
DEMO_NAME = MesaDemos-4.0
GLU_NAME = MesaGLU-4.0
DIRECTORY = Mesa-4.0.3
LIB_NAME = MesaLib-4.0.3
DEMO_NAME = MesaDemos-4.0.3
GLU_NAME = MesaGLU-4.0.3
GLUT_NAME = GLUT-3.7
@@ -377,7 +378,7 @@ LIB_FILES = \
$(DIRECTORY)/include/GL/internal/glcore.h \
$(DIRECTORY)/include/GL/Makefile.in \
$(DIRECTORY)/include/GL/Makefile.am \
$(DIRECTORY)/include/GL/dosmesa.h \
$(DIRECTORY)/include/GL/dmesa.h \
$(DIRECTORY)/include/GL/amesa.h \
$(DIRECTORY)/include/GL/fxmesa.h \
$(DIRECTORY)/include/GL/ggimesa.h \
@@ -400,6 +401,7 @@ LIB_FILES = \
$(DIRECTORY)/include/GL/xmesa_x.h \
$(DIRECTORY)/include/GL/xmesa_xf86.h \
$(DIRECTORY)/include/GLView.h \
$(DIRECTORY)/include/dmesadxe.h \
$(DIRECTORY)/include/Makefile.in \
$(DIRECTORY)/include/Makefile.am \
$(DIRECTORY)/src/Makefile* \
@@ -430,6 +432,7 @@ LIB_FILES = \
$(DIRECTORY)/src/windml/tornado/*.cdf \
$(DIRECTORY)/src/windml/man3/*.3 \
$(DIRECTORY)/src/windml/man3/*.html \
$(DIRECTORY)/src/DOS/*.[ch] \
$(DIRECTORY)/src/BeOS/*.cpp \
$(DIRECTORY)/src/FX/Makefile.am \
$(DIRECTORY)/src/FX/Makefile.in \
@@ -578,7 +581,6 @@ OBSOLETE_LIB_FILES = \
$(DIRECTORY)/src/D3D/*bat \
$(DIRECTORY)/src/D3D/*DEF \
$(DIRECTORY)/src/DOS/DEPEND.DOS \
$(DIRECTORY)/src/DOS/*.c \
$(DIRECTORY)/src/S3/*.[ch] \
$(DIRECTORY)/src/S3/*.def \
$(DIRECTORY)/src/S3/*.mak \
@@ -611,6 +613,9 @@ DEMO_FILES = \
$(DIRECTORY)/src-glut/descrip.mms \
$(DIRECTORY)/src-glut/mms_depend \
$(DIRECTORY)/src-glut/*.[ch] \
$(DIRECTORY)/src-glut.dos/*.[ch] \
$(DIRECTORY)/src-glut.dos/Makefile.DJ \
$(DIRECTORY)/src-glut.dos/PC_HW/*.[chS] \
$(DIRECTORY)/images/* \
$(DIRECTORY)/demos/Makefile* \
$(DIRECTORY)/demos/descrip.mms \

132
docs/README.DJ Normal file
View File

@@ -0,0 +1,132 @@
Mesa 4.0 DOS/DJGPP Port v1.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Description:
~~~~~~~~~~~~
Well, guess what... this is the DOS port of MESA 4.0, for DJGPP fans... Whoa!
Legal:
~~~~~~
MESA copyright applies.
Installation:
~~~~~~~~~~~~~
Type "make -f Makefile.DJ" to compile the libraries. Make accepts some options
which are passed to compiler: the target cpu (CPU=..., default=`pentium') and
X86 specific options (HAVE_X86=1, HAVE_MMX=1, HAVE_SSE=1, HAVE_3DNOW=1). The
core library (libGL) requires LFN support during compilation. Also, you must
have the DXE2 package (available on SimTel.Net, courtesy of Andrew Zabolotny)
installed in order to build the dynamic modules; if you encounter errors, you
can fetch a patched version from my web page.
The demos are not built automagically (see Pitfalls below). To make them, use
one of the following rules:
Static:
gcc -o OUT.exe IN.c -lglut -lglu -lgl
Dynamic:
gcc -o OUT.exe -include dmesadxe.h IN.c -ligl -liglu -liglut -ldl
Usage of the dynamic modules requires three things:
- include DMESADXE.H in one of the sources, so references inside
dynamic modules will get resolved (or use `-include' directive)
- link against import libraries (libIgl*.a) and LIBDL.A, which will do
the dynamic linkage job for you
- put the DXEs somewhere along the library path (LD_LIBRARY_PATH) or
in the current directory
Tested on:
CPU: Intel Pentium w/ MMX @166 MHz
Mainboard: ViA Apollo VP2 w/ 128 MB SDRAM
Video card: Matrox Millenium 2064W w/ 2048 kB WRAM, BIOS v3.0
DJGPP: djdev 2.03 + gcc v3.0.3 + make v3.79
libGL (the core):
~~~~~~~~~~~~~~~~~
Of course, MESA 4.0 core sources are required. It will probably work with
MESA 3.5, but not a chance with earlier versions due to major changes to the
MESA driver interface and the directory tree. All should compile succesfully.
The driver has its origins in ddsample.c, written by Brian Paul and found by
me in MESA 3.4.2. I touched almost all the functions, changing the coding
style :-( Sorry!
Pitfalls:
1. The current version supports only RGB[A] modes, for it made no sense to me
to endorse color-index (aka palette) modes.
2. Single-buffered is not allowed at all. Until I can find a way to use *REAL*
hardware acceleration, it won't get implemented.
3. Another weird "feature" is that buffer width must be multiple of 4 (I'm a
lazy programmer and I found that the easiest way to keep buffer handling at
peak performance ;-).
libGLU:
~~~~~~~
Mesa GLU sources are required.
libGLUT (the toolkit):
~~~~~~~~~~~~~~~~~~~~~~
Well, this "skeletal" GLUT implementation is not mine. Thanks should go to
Bernhard Tschirren, Mark Kilgard, Brian Paul and probably others (or probably
not ;-). I only changed it to be self-standing (Allegro-free). The keyboard,
mouse and timer drivers were inspired from an old project of mine (D3Xl) and
fixed with some Allegro "infusions"; I deeply thank to Shawn Hargreaves et co.
My keyboard driver used only scancodes, but since GLUT requires ASCII values
for keys, I borrowed the translation tables (and maybe more) from Allegro.
Ctrl-Alt-Del (plus Ctrl-Alt-End, for Windows users) will shut down the GLUT
engine unconditionally: it will raise SIGINT, which in turn will call the
destructors (let's hope), thus cleaning up your/my mess ;-) NB: since the
DJGPP guys ensured signal handlers won't go beyond program's space (and since
dynamic modules shall) the SIGINT can't be hooked (well, it can, but it is
useless), therefore you must live with the 'Exiting due to signal SIGINT'
message...
The mouse driver is far from complete (lack of positioning, drawing, etc),
but is enough to make almost all the demos work.
The timer is pretty versatile for it supports multiple timers with different
frequencies. It may not be the most accurate timer in the known universe, but
I think it's OK. Take this example: you have timer A with a very high rate,
and then you have timer B with very low rate compared to A; now, A ticks OK,
but timer B will probably loose precision!
As an addition, stdout and stderr are redirected and dumped upon exit. This
means that printf can be safely called during graphics, but all messages come
in bulk! A bit of a hack, I know, but I think it's better than to miss them
at all. "Borrowed" from RHIDE (Robert Hoehne) or SETEDIT (Salvador Eduardo
Tropea)... I'm not sure.
Window creating defaults: 640x480x16 at (0,0), 8-bit stencil, 16-bit accum.
However, the video mode is chosen in such a way that first window will fit.
History:
~~~~~~~~
v1.0 mar-2002 initial release
Contact:
~~~~~~~~
Name: Borca Daniel
E-mail: dborca@yahoo.com
WWW: http://www.geocities.com/dborca/

View File

@@ -1,5 +1,5 @@
Mesa 4.0.1 Unix/X11 Information
Mesa 4.0.3 Unix/X11 Information
@@ -25,7 +25,7 @@ There are two ways to compile Mesa on Unix/X11 systems:
The top-level makefile will execute the makefiles in a number of sub-
directories. When finished, the Mesa libraries will be in the Mesa-4.0.1/lib/
directories. When finished, the Mesa libraries will be in the Mesa-4.0.3/lib/
directory. A few GLUT demos in the demos/ directory should be ready to run.
If you also downloaded and unpacked the demos there should be executables
@@ -323,4 +323,4 @@ Summary of X-related environment variables:
----------------------------------------------------------------------
$Id: README.X11,v 3.8.2.1 2001/11/23 20:47:25 brianp Exp $
$Id: README.X11,v 3.8.2.3 2002/04/26 13:54:47 brianp Exp $

22
docs/RELNOTES-3.4 Normal file
View File

@@ -0,0 +1,22 @@
Mesa 3.4 release notes
November 3, 2000
PLEASE READ!!!!
Introduction
------------
Mesa uses an even/odd version number scheme like the Linux kernel.
Odd numbered versions (such as 3.3) designate new developmental releases.
Even numbered versions (such as 3.4) designate stable releases.
Mesa 3.4 simply fixes bugs found in the Mesa 3.3 release. For details,
see the VERSIONS file.
----------------------------------------------------------------------
$Id: RELNOTES-3.4,v 1.1.4.1 2002/03/23 02:36:52 brianp Exp $

50
docs/RELNOTES-4.0.2 Normal file
View File

@@ -0,0 +1,50 @@
Mesa 4.0.2 release notes
April 2, 2002
PLEASE READ!!!!
Introduction
------------
Mesa uses an even/odd version number scheme like the Linux kernel.
Odd numbered versions (such as 3.3) designate new developmental releases.
Even numbered versions (such as 3.4) designate stable releases.
Mesa 4.0.2 only contains bug fixes and a new DOS driver since version 4.0.1.
See the docs/VERSIONS file for the list of bug fixes.
Device Drivers
--------------
Mesa advertises itself as either OpenGL 1.2 or OpenGL 1.3 depending on the
device driver. If the driver enables all the ARB extensions which are part
of OpenGL 1.3 then glGetString(GL_VERSION) will return "1.3". Otherwise,
it'll return "1.2".
A number of Mesa's software drivers haven't been actively maintained for
some time. We rely on volunteers to maintain many of the drivers.
Here's the current status of all included drivers:
Driver Status
---------------------- ---------------------
XMesa (Xlib) implements OpenGL 1.3
OSMesa (off-screen) implements OpenGL 1.3
FX (3dfx Voodoo1/2) implements OpenGL 1.3
SVGA implements OpenGL 1.3
Wind River UGL implements OpenGL 1.3
Windows/Win32 implements OpenGL 1.3
DOS/DJGPP implements OpenGL 1.3 (new in Mesa 4.0.2)
GGI needs updating
BeOS needs updating
Allegro needs updating
D3D needs updating
----------------------------------------------------------------------
$Id: RELNOTES-4.0.2,v 1.1.2.3 2002/04/01 16:54:11 brianp Exp $

52
docs/RELNOTES-4.0.3 Normal file
View File

@@ -0,0 +1,52 @@
Mesa 4.0.3 release notes
June 25, 2002
PLEASE READ!!!!
Introduction
------------
Mesa uses an even/odd version number scheme like the Linux kernel.
Odd numbered versions (such as 3.3) designate new developmental releases.
Even numbered versions (such as 3.4) designate stable releases.
Mesa 4.0.3 basically just contains bug fixes version 4.0.2.
See the docs/VERSIONS file for the list of bug fixes.
The GGI driver has been updated, thanks to Filip Spacek.
Device Drivers
--------------
Mesa advertises itself as either OpenGL 1.2 or OpenGL 1.3 depending on the
device driver. If the driver enables all the ARB extensions which are part
of OpenGL 1.3 then glGetString(GL_VERSION) will return "1.3". Otherwise,
it'll return "1.2".
A number of Mesa's software drivers haven't been actively maintained for
some time. We rely on volunteers to maintain many of the drivers.
Here's the current status of all included drivers:
Driver Status
---------------------- ---------------------
XMesa (Xlib) implements OpenGL 1.3
OSMesa (off-screen) implements OpenGL 1.3
FX (3dfx Voodoo1/2) implements OpenGL 1.3
SVGA implements OpenGL 1.3
Wind River UGL implements OpenGL 1.3
Windows/Win32 implements OpenGL 1.3
DOS/DJGPP implements OpenGL 1.3 (new in Mesa 4.0.2)
GGI implements OpenGL 1.3
BeOS needs updating
Allegro needs updating
D3D needs updating
----------------------------------------------------------------------
$Id: RELNOTES-4.0.3,v 1.1.2.3 2002/06/24 20:44:58 brianp Exp $

View File

@@ -1,4 +1,4 @@
$Id: VERSIONS,v 1.73.2.14 2001/12/15 00:50:55 brianp Exp $
$Id: VERSIONS,v 1.73.2.29 2002/06/25 15:22:12 brianp Exp $
Mesa Version History
@@ -898,7 +898,8 @@ Mesa Version History
- lighting didn't always produce the correct alpha value
- fixed 3DNow! code to not read past end of arrays (Andrew Lewycky)
4.0.1 December 17, 2001
4.0.1 December 17, 2001
New:
- better sub-pixel sample positions for AA triangles (Ray Tice)
- slightly faster blending for (GL_ZERO, GL_ONE) and (GL_ONE, GL_ZERO)
@@ -924,3 +925,59 @@ Mesa Version History
- glTexParameter didn't flush the vertex buffer (Ray Tice)
- feedback attributes for glDraw/CopyPixels and glBitmap were wrong
- fixed bug in normal length caching (ParaView lighting bug)
- fixed separate_specular color bug found in Chimera (18 Dec 2001)
4.0.2 April 2, 2002
New:
- New DOS (DJGPP) driver written by Daniel Borca
- New driver interface functions for TCL drivers (such as Radeon DRI)
- GL_RENDERER string returns "Mesa Offscreen16" or "Mesa Offscreen32"
if using deep color channels
- latest GL/glext.h and GL/glxext.h headers from SGI
Bug fixes:
- GL_BLEND with non-black texture env color wasn't always correct
- GL_REPLACE with GL_RGB texture format wasn't always correct (alpha)
- glTexEnviv( pname != GL_TEXTURE_ENV_COLOR ) was broken
- glReadPixels was sometimes mistakenly clipped by the scissor box
- glDraw/ReadPixels didn't catch all the errors that they should have
- Fixed 24bpp rendering problem in Windows driver (Karl Schultz)
- 16-bit GLchan mode fixes (m_trans_tmp.h, s_triangle.c)
- Fixed 1-bit float->int conversion bug in glDrawPixels(GL_DEPTH_COMP)
- glColorMask as sometimes effecting glXSwapBuffers()
- fixed a potential bug in XMesaGarbageCollect()
- N threads rendering into one window didn't work reliably
- glCopyPixels didn't work for deep color channels
- improved 8 -> 16bit/channel texture image conversion (Gerk Huisma)
- glPopAttrib() didn't correctly restore user clip planes
- user clip planes failed for some perspective projections (Chromium)
Known bugs:
- mipmap LOD computation
4.0.3 June 25, 2002
New:
- updated GL/glext.h file (version 15)
- corrected MMX blend code (Jose Fonseca)
- support for software-based alpha planes in Windows driver
- updated GGI driver (Filip Spacek)
Bug fixes:
- glext.h had wrong values for GL_DOT3_RGB[A]_EXT tokens
- OSMesaMakeCurrent() didn't recognize buffer size changes
- assorted conformance fixes for 16-bit/channel rendering
- texcombine alpha subtraction mode was broken
- fixed lighting bug with non-uniform scaling and display lists
- fixed bug when deleting shared display lists
- disabled SPARC cliptest assembly code (Mesa bug 544665)
- fixed a couple Solaris compilation/link problems
- blending clipped glDrawPixels didn't always work
- glGetTexImage() didn't accept packed pixel types
- glPixelMapu[is]v() could explode given too large of pixelmap
- glGetTexParameter[if]v() didn't accept GL_TEXTURE_MAX_ANISOTROPY_EXT
- glXCopyContext() could lead to segfaults
- glCullFace(GL_FRONT_AND_BACK) didn't work (bug 572665)
Changes:
- lots of C++ (g++) code clean-ups
- lots of T&L updates for the Radeon DRI driver
Known bugs:
- mipmap LOD computation (fixed for Mesa 4.1)

77
include/GL/dmesa.h Normal file
View File

@@ -0,0 +1,77 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* DOS/DJGPP device driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef DMESA_included
#define DMESA_included
#define DMESA_MAJOR_VERSION 4
#define DMESA_MINOR_VERSION 0
typedef struct dmesa_context *DMesaContext;
typedef struct dmesa_visual *DMesaVisual;
typedef struct dmesa_buffer *DMesaBuffer;
#ifdef __cplusplus
extern "C" {
#endif
DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
GLboolean dbFlag, GLint depthSize,
GLint stencilSize,
GLint accumSize);
void DMesaDestroyVisual (DMesaVisual v);
DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
GLint xpos, GLint ypos,
GLint width, GLint height);
void DMesaDestroyBuffer (DMesaBuffer b);
DMesaContext DMesaCreateContext (DMesaVisual visual, DMesaContext share);
void DMesaDestroyContext (DMesaContext c);
GLboolean DMesaViewport (DMesaBuffer b,
GLint xpos, GLint ypos,
GLint width, GLint height);
GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b);
void DMesaSwapBuffers (DMesaBuffer b);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,10 +1,11 @@
/* $Id: ggimesa.h,v 1.3 2000/02/09 19:03:28 brianp Exp $ */
/* $Id: ggimesa.h,v 1.3.6.1 2002/06/10 15:16:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
* Mesa 3-D graphics library GGI bindings (GGIGL [giggle])
* Version: 4.0
* Copyright (C) 1995-2000 Brian Paul
* Copyright (C) 1998 Uwe Maurer
* Copyrigth (C) 2001 Filip Spacek
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,34 +26,59 @@
#ifndef GGIMESA_H
#define GGIMESA_H
#define GGIMESA_MAJOR_VERSION 3
#define GGIMESA_MINOR_VERSION 3
#define GGIMESA_MAJOR_VERSION 4
#define GGIMESA_MINOR_VERSION 0
#ifdef __cplusplus
extern "C" {
#endif
#include "GL/gl.h"
typedef struct ggi_mesa_context *GGIMesaContext;
#include <ggi/ggi.h>
#include "GL/gl.h"
typedef struct ggi_mesa_context *ggi_mesa_context_t;
extern GGIMesaContext GGIMesaCreateContext(void);
/*
* Initialize Mesa GGI extension
*/
int ggiMesaInit(void);
/*
* Clean up Mesa GGI exension
*/
int ggiMesaExit(void);
extern void GGIMesaDestroyContext(GGIMesaContext ctx);
/*
* Attach Mesa GGI extension to the visual 'vis'
*/
int ggiMesaAttach(ggi_visual_t vis);
/*
* Detach Mesa GGI extension from the visual 'vis'
*/
int ggiMesaDetach(ggi_visual_t vis);
extern void GGIMesaMakeCurrent(GGIMesaContext ctx);
int ggiMesaExtendVisual(ggi_visual_t vis, GLboolean alpha_flag,
GLboolean stereo_flag, GLint depth_size,
GLint stencil_size, GLint accum_red_size,
GLint accum_green_size, GLint accum_blue_size,
GLint accum_alpha_size, GLint num_samples);
extern GGIMesaContext GGIMesaGetCurrentContext(void);
/*
* Create a new context capable of displaying on the visual vis.
*/
ggi_mesa_context_t ggiMesaCreateContext(ggi_visual_t vis);
/*
* Destroy the context 'ctx'
*/
void ggiMesaDestroyContext(ggi_mesa_context_t ctx);
extern void GGIMesaSwapBuffers(void);
/*
* Make context 'ctx' the current context and bind it to visual 'vis'.
* Note that the context must have been created with respect to that visual.
*/
void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis);
void ggiMesaSwapBuffers(void);
extern int GGIMesaSetVisual(GGIMesaContext ctx, ggi_visual_t vis,
GLboolean rgb_flag, GLboolean db_flag);
#ifdef __cplusplus
}

View File

@@ -1,10 +1,10 @@
/* $Id: gl.h,v 1.59.2.1 2001/11/09 21:54:05 brianp Exp $ */
/* $Id: gl.h,v 1.59.2.3 2002/04/26 13:53:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 4.0
* Version: 4.0.3
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -1912,8 +1912,6 @@ GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] );
GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert );
GLAPI void GLAPIENTRY glSamplePass( GLenum pass );
/*
* GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
/* $Id: glx.h,v 1.33.2.1 2001/12/14 03:20:57 brianp Exp $ */
/* $Id: glx.h,v 1.33.2.2 2002/04/26 13:53:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 4.0
* Version: 4.0.3
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@@ -42,12 +42,16 @@ extern "C" {
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef GLAPI
#define GLAPI extern
#endif
/*************************************************************/
/* Header file version number, required by OpenGL ABI for Linux */
/* glxext.h last updated 2001/09/26 */
#define GLX_GLXEXT_VERSION 3
/* glxext.h last updated 2002/03/22 */
/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */
#define GLX_GLXEXT_VERSION 5
#ifndef GLX_VERSION_1_3
#define GLX_WINDOW_BIT 0x00000001
@@ -113,6 +117,9 @@ extern "C" {
#define GLX_SAMPLES 100001
#endif
#ifndef GLX_ARB_get_proc_address
#endif
#ifndef GLX_ARB_multisample
#define GLX_SAMPLE_BUFFERS_ARB 100000
#define GLX_SAMPLES_ARB 100001
@@ -276,7 +283,6 @@ extern "C" {
/*************************************************************/
#ifndef GLX_ARB_get_proc_address
/* XXX Added void parameter to silence many, many warnings (BrianP) */
typedef void (*__GLXextFuncPtr)(void);
#endif
@@ -348,6 +354,14 @@ typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigne
typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
#endif
#ifndef GLX_VERSION_1_4
#define GLX_VERSION_1_4 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
#endif
#ifndef GLX_ARB_get_proc_address
#define GLX_ARB_get_proc_address 1
#ifdef GLX_GLXEXT_PROTOTYPES
@@ -356,6 +370,10 @@ extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *);
typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName);
#endif
#ifndef GLX_ARB_multisample
#define GLX_ARB_multisample 1
#endif
#ifndef GLX_SGIS_multisample
#define GLX_SGIS_multisample 1
#endif
@@ -419,7 +437,7 @@ extern void glXFreeContextEXT (Display *, GLXContext);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void);
typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value);
typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (GLXContext context);
typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context);
typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID);
typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context);
#endif
@@ -554,14 +572,33 @@ typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode);
#define GLX_SGIX_visual_select_group 1
#endif
#ifndef GLX_GLX_OML_swap_method
#define GLX_GLX_OML_swap_method 1
#ifndef GLX_OML_swap_method
#define GLX_OML_swap_method 1
#endif
#ifndef GLX_GLX_OML_sync_control
#define GLX_GLX_OML_sync_control 1
#if defined(__STDC_VERSION__)
#if __STDC_VERSION__ >= 199901L
/* Include ISO C99 integer types for OML_sync_control; need a better test */
#include <inttypes.h>
#ifndef GLX_OML_sync_control
#define GLX_OML_sync_control 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern Bool glXGetSyncValuesOML (Display *, GLXDrawable, int64_t *, int64_t *, int64_t *);
extern Bool glXGetMscRateOML (Display *, GLXDrawable, int32_t *, int32_t *);
extern int64_t glXSwapBuffersMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t);
extern Bool glXWaitForMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t, int64_t *, int64_t *, int64_t *);
extern Bool glXWaitForSbcOML (Display *, GLXDrawable, int64_t, int64_t *, int64_t *, int64_t *);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);
typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);
typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);
typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);
typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);
#endif
#endif /* C99 version test */
#endif /* STDC test */
#ifdef __cplusplus
}

View File

@@ -1,10 +1,10 @@
/* $Id: osmesa.h,v 1.9 2001/09/23 16:06:13 brianp Exp $ */
/* $Id: osmesa.h,v 1.9.2.1 2002/04/26 13:53:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 4.0
* Version: 4.0.3
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -64,7 +64,7 @@ extern "C" {
#define OSMESA_MAJOR_VERSION 4
#define OSMESA_MINOR_VERSION 0
#define OSMESA_PATCH_VERSION 0
#define OSMESA_PATCH_VERSION 3

View File

@@ -1,4 +1,4 @@
/* $Id: wmesa.h,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/* $Id: wmesa.h,v 1.1.1.1.8.1 2002/04/23 18:24:41 kschultz Exp $ */
/*
* Mesa 3-D graphics library
@@ -24,8 +24,17 @@
/*
* $Log: wmesa.h,v $
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
* Revision 1.1.1.1.8.1 2002/04/23 18:24:41 kschultz
* Fix up alpha buffer handling for Windows.
* - add two new Pixel Format Descriptors that do not have alpha bits to
* mirror the two that do.
* - add logic to wglChoosePixelFormat to match PFD's with respect to alpha.
* - Create/clear software alpha buffer as required.
* Now a wgl or GLUT program can control the creation of a software alpha
* buffer via the PFD or GLUT parms, respectively.
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
*
* Revision 3.2 1999/01/03 02:54:45 brianp
* updated per Ted Jump
@@ -101,13 +110,17 @@ typedef struct wmesa_context *WMesaContext;
* GL_FALSE = color index mode
* db_flag - GL_TRUE = double-buffered,
* GL_FALSE = single buffered
* alpha_flag - GL_TRUE = create software alpha buffer,
* GL_FALSE = no software alpha buffer
*
* Note: Indexed mode requires double buffering under Windows.
*
* Return: a WMesa_context or NULL if error.
*/
extern WMesaContext WMesaCreateContext(HWND hWnd,HPALETTE* pPal,
GLboolean rgb_flag,GLboolean db_flag);
GLboolean rgb_flag,
GLboolean db_flag,
GLboolean alpha_flag);
/*

View File

@@ -1,10 +1,10 @@
/* $Id: xmesa.h,v 1.12 2001/09/23 16:06:13 brianp Exp $ */
/* $Id: xmesa.h,v 1.12.2.2 2002/04/26 13:53:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 4.0
* Version: 4.0.3
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -365,6 +365,15 @@ extern GLboolean XMesaSetFXmode( GLint mode );
/*
* Reallocate the back/depth/stencil/accum/etc/ buffers associated with
* buffer <b> if its size has changed.
*
* New in Mesa 4.0.2
*/
extern void XMesaResizeBuffers( XMesaBuffer b );
#ifdef __cplusplus
}
#endif

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.win,v 1.5.2.1 2001/10/26 21:03:15 kschultz Exp $
# $Id: Makefile.win,v 1.5.2.2 2002/04/15 22:14:09 kschultz Exp $
# Mesa 3-D graphics library
# Version: 3.5
@@ -67,12 +67,41 @@ SRCS = \
geartrain.c \
glinfo.c \
gloss.c \
gltestperf.c \
glutfx.c \
isosurf.c \
lodbias.c \
morph3d.c \
teapot.c
multiarb.c \
occlude.c \
paltex.c \
pixeltex.c \
pointblast.c \
ray.c \
readpix.c \
reflect.c \
renormal.c \
shadowtex.c \
spectex.c \
stex3d.c \
teapot.c \
terrain.c \
tessdemo.c \
texcyl.c \
texdown.c \
texenv.c \
texobj.c \
trispd.c \
tunnel.c \
tunnel2.c \
winpos.c
CXXSRCS = \
rain.cxx
OSMESASRCS = osdemo.c
IPERSSRCS = ipers.c
IPERSEXES = $(IPERSSRCS:.c=.exe)
!include "../mesawin32.mak"
##### TARGETS #####
@@ -90,9 +119,12 @@ $(OSMESAEXES) : $*.obj
@echo $@
$(link) $(lcommon) -out:$@ $* /LIBPATH:$(LIBDIR) $(LIBS) $(EXTRALIBS)
$(IPERSEXES) : $*.obj
@echo $@
$(link) -out:$@ $* /LIBPATH:$(LIBDIR) $(LIBS) winmm.lib
readtex.c:
-copy ..\util\readtex.c .
readtex.h:
-copy ..\util\readtex.h .
-copy ..\util\readtex.h .

View File

@@ -11,7 +11,7 @@
#include <math.h>
#include <time.h>
#ifdef WIN32
#if defined (WIN32)|| defined(_WIN32)
#include <windows.h>
#include <mmsystem.h>
#endif

View File

@@ -1,4 +1,4 @@
/* $Id: osdemo.c,v 1.7 2001/09/24 15:29:27 kschultz Exp $ */
/* $Id: osdemo.c,v 1.7.2.1 2002/04/15 21:22:36 kschultz Exp $ */
/*
* Demo of off-screen Mesa rendering
@@ -14,6 +14,11 @@
*
* PPM output provided by Joerg Schmalzl.
* ASCII PPM output added by Brian Paul.
*
* Usage: osdemo [-perf] [filename]
*
* -perf: Redraws the image 1000 times, displaying the FPS every 5 secs.
* filename: file to store the TGA or PPM output
*/
@@ -29,7 +34,9 @@
#define WIDTH 400
#define HEIGHT 400
static GLint T0 = 0;
static GLint Frames = 0;
static int perf = 0;
static void render_image( void )
{
@@ -76,7 +83,7 @@ static void render_image( void )
glPopMatrix();
#ifdef GL_HP_occlusion_test
{
if (perf == 0) {
GLboolean bRet;
glDepthMask(GL_FALSE);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
@@ -105,7 +112,7 @@ static void render_image( void )
glPopMatrix();
#ifdef GL_HP_occlusion_test
{
if (perf == 0){
GLboolean bRet;
glDepthMask(GL_FALSE);
@@ -130,6 +137,18 @@ static void render_image( void )
#endif
glPopMatrix();
Frames++;
if (perf) {
GLint t = glutGet(GLUT_ELAPSED_TIME);
if (t - T0 >= 5000) {
GLfloat seconds = (t - T0) / 1000.0;
GLfloat fps = Frames / seconds;
printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
T0 = t;
Frames = 0;
}
}
}
@@ -224,6 +243,8 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height)
int main( int argc, char *argv[] )
{
void *buffer;
int i;
char *filename = NULL;
/* Create an RGBA-mode context */
#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305
@@ -237,6 +258,11 @@ int main( int argc, char *argv[] )
return 0;
}
for ( i=1; i<argc; i++ ) {
if (argv[i][0] != '-') filename = argv[i];
if (strcmp(argv[i], "-perf")==0) perf = 1;
}
/* Allocate the image buffer */
buffer = malloc( WIDTH * HEIGHT * 4 * sizeof(GLubyte) );
if (!buffer) {
@@ -256,16 +282,19 @@ int main( int argc, char *argv[] )
glGetIntegerv(GL_DEPTH_BITS, &z);
glGetIntegerv(GL_STENCIL_BITS, &s);
glGetIntegerv(GL_ACCUM_RED_BITS, &a);
printf("%d %d %d\n", z, s, a);
printf("Depth=%d Stencil=%d Accum=%d\n", z, s, a);
}
render_image();
if (perf)
for(i=0; i< 1000; i++)
render_image();
if (argc>1) {
if (filename != NULL) {
#ifdef SAVE_TARGA
write_targa(argv[1], buffer, WIDTH, HEIGHT);
write_targa(filename, buffer, WIDTH, HEIGHT);
#else
write_ppm(argv[1], buffer, WIDTH, HEIGHT);
write_ppm(filename, buffer, WIDTH, HEIGHT);
#endif
}
else {

View File

@@ -1,4 +1,4 @@
/* $Id: paltex.c,v 1.6 2000/10/05 07:17:43 joukj Exp $ */
/* $Id: paltex.c,v 1.6.2.1 2002/04/15 22:14:09 kschultz Exp $ */
/*
* Paletted texture demo. Written by Brian Paul.
@@ -9,6 +9,9 @@
#include <stdlib.h>
#include <math.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_LEGACY
#include <GL/glut.h>

View File

@@ -13,6 +13,13 @@
/*
* $Log: pointblast.c,v $
* Revision 1.2.6.1 2002/04/15 22:14:09 kschultz
* Build demos/samples correctly on Windows (Robert Bergkvist) to sync up
* with the main branch. (I should have done this for 4.0.2)
*
* Revision 1.3 2002/01/16 00:48:43 kschultz
* Demo updates for Windows (Robert Bergkvist)
*
* Revision 1.2 2000/06/27 17:04:43 brianp
* fixed compiler warnings
*
@@ -38,6 +45,9 @@
#include <stdlib.h>
#include <string.h>
#include <math.h> /* for cos(), sin(), and sqrt() */
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_LEGACY
#include <GL/glut.h>

View File

@@ -11,15 +11,20 @@
#include <math.h>
#include <time.h>
#include <GL/glut.h>
#ifndef M_PI
#define M_PI 3.14159265
#endif
#include "particles.h"
extern "C" {
#include "image.h"
#include "readtex.h"
}
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#include <mmsystem.h>
#include "particles.cxx"
#include "readtex.c"
#endif
#ifdef XMESA
@@ -297,20 +302,21 @@ static void key(unsigned char key, int x, int y)
static void inittextures(void)
{
IMAGE *img;
GLubyte *img;
GLint width,height;
GLenum format;
GLenum gluerr;
glGenTextures(1,&groundid);
glBindTexture(GL_TEXTURE_2D,groundid);
if(!(img=ImageLoad("s128.rgb"))) {
fprintf(stderr,"Error reading a texture.\n");
exit(-1);
if(!(img=LoadRGBImage("../images/s128.rgb",&width,&height,&format))){
fprintf(stderr,"Error reading a texture.\n");
exit(-1);
}
glPixelStorei(GL_UNPACK_ALIGNMENT,4);
if((gluerr=(GLenum)gluBuild2DMipmaps(GL_TEXTURE_2D, 3, img->sizeX, img->sizeY, GL_RGB,
GL_UNSIGNED_BYTE, (GLvoid *)(img->data)))) {
if((gluerr=(GLenum)gluBuild2DMipmaps(GL_TEXTURE_2D, 3, width, height,GL_RGB,
GL_UNSIGNED_BYTE, (GLvoid *)(img)))) {
fprintf(stderr,"GLULib%s\n",gluErrorString(gluerr));
exit(-1);
}

View File

@@ -1,4 +1,4 @@
/* $Id: readpix.c,v 1.4 2000/10/16 21:24:39 brianp Exp $ */
/* $Id: readpix.c,v 1.4.2.1 2002/05/01 14:53:52 alanh Exp $ */
/*
* glReadPixels and glCopyPixels test
@@ -8,6 +8,13 @@
/*
* $Log: readpix.c,v $
* Revision 1.4.2.1 2002/05/01 14:53:52 alanh
* glutSwapBuffers implicitly does a glFinish when swapping back to the front
* buffer. We now issue a glFinish when not issuing SwapBuffers to ensure
* the pipeline is complete.
*
* (Problem found with Chromium).
*
* Revision 1.4 2000/10/16 21:24:39 brianp
* use gray background, memset TempImage to white to help with debugging
*
@@ -173,6 +180,8 @@ Display( void )
if (!DrawFront)
glutSwapBuffers();
else
glFinish();
}

View File

@@ -1,4 +1,4 @@
/* $Id: winpos.c,v 1.3 2000/12/24 22:53:54 pesco Exp $ */
/* $Id: winpos.c,v 1.3.2.1 2002/04/15 22:14:09 kschultz Exp $ */
/*
* Example of how to use the GL_MESA_window_pos extension.
@@ -8,6 +8,13 @@
/*
* $Log: winpos.c,v $
* Revision 1.3.2.1 2002/04/15 22:14:09 kschultz
* Build demos/samples correctly on Windows (Robert Bergkvist) to sync up
* with the main branch. (I should have done this for 4.0.2)
*
* Revision 1.4 2002/01/16 00:48:43 kschultz
* Demo updates for Windows (Robert Bergkvist)
*
* Revision 1.3 2000/12/24 22:53:54 pesco
* * demos/Makefile.am (INCLUDES): Added -I$(top_srcdir)/util.
* * demos/Makefile.X11, demos/Makefile.BeOS-R4, demos/Makefile.cygnus:
@@ -59,6 +66,9 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_LEGACY
#include "GL/glut.h"

View File

@@ -19,6 +19,7 @@
ggi_visual_t vis;
char text[100];
int db_flag,vis_x, vis_y, vir_x, vir_y, gt;
/*
* Draw a gear wheel. You'll probably want to call this function when
@@ -157,6 +158,7 @@ static GLuint count = 1;
static void draw( void )
{
static int n = 0;
glClearColor(0,0,0,0);
glClearIndex(0);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
@@ -197,12 +199,25 @@ static void draw( void )
ggiPuts(vis,0,ggiGetInfo(vis)->mode->visible.y+16,text);
#endif
GGIMesaSwapBuffers();
if(db_flag)
ggiMesaSwapBuffers();
count++;
if (count==limit) {
exit(1);
}
++n;
/*
if (!(n%10)){
ggi_color rgb = { 10000, 10000, 10000 };
ggiSetSimpleMode(vis,vis_x+(n/10),vis_y+(n/10),db_flag?2:1, gt);
glViewport(0, 0,vis_x+(n/10),vis_y+(n/10));
ggiSetGCForeground(vis, ggiMapColor(vis, &rgb));
ggiDrawBox(vis, 20, 20, 100, 100);
if(db_flag)
ggiSetWriteFrame(vis, 1);
}
*/
}
static void idle( void )
@@ -216,6 +231,10 @@ static void reshape( int width, int height )
{
GLfloat h = (GLfloat) height / (GLfloat) width;
if(db_flag)
glDrawBuffer(GL_BACK);
else
glDrawBuffer(GL_FRONT);
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -231,8 +250,8 @@ static void reshape( int width, int height )
static void init( void )
{
static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0 };
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0 };
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0 };
static GLfloat red[4] = {0.9, 0.9, 0.9, 1.0 };
static GLfloat green[4] = {0.0, 0.8, 0.9, 1.0 };
static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0 };
glLightfv( GL_LIGHT0, GL_POSITION, pos );
@@ -276,9 +295,9 @@ static void usage(char *s)
int main( int argc, char *argv[] )
{
GGIMesaContext ctx;
int vis_x,vis_y,vir_x,vir_y,bpp,db_flag,gt;
ggi_mesa_context_t ctx;
ggi_mode mode;
int bpp;
limit=0;
@@ -313,13 +332,12 @@ int main( int argc, char *argv[] )
exit(1);
}
ctx=GGIMesaCreateContext();
if (ctx==NULL)
if (ggiMesaInit() < 0)
{
printf("GGIMesaCreateContext() failed\n");
printf("ggiMesaInit failed\n");
exit(1);
}
vis=ggiOpen(NULL);
if (vis==NULL)
{
@@ -327,29 +345,42 @@ int main( int argc, char *argv[] )
exit(1);
}
if (ggiSetGraphMode(vis,vis_x,vis_y,vir_x,vir_y,gt)<0)
if (ggiSetSimpleMode(vis,vis_x,vis_y,db_flag ? 2 : 1,gt)<0)
{
printf("%s: can't set graphmode (%i %i %i %i) %i BPP\n",
argv[0],vis_x,vis_y,vir_x,vir_y,bpp);
exit(1);
}
if (GGIMesaSetVisual(ctx,vis,GL_TRUE,db_flag)<0)
if (ggiMesaAttach(vis) < 0)
{
printf("ggiMesaAttach failed\n");
exit(1);
}
if (ggiMesaExtendVisual(vis, GL_FALSE, GL_FALSE, 16,
0, 0, 0, 0, 0, 1) < 0)
{
printf ("GGIMesaSetVisual() failed\n");
exit(1);
}
GGIMesaMakeCurrent(ctx);
ctx = ggiMesaCreateContext(vis);
if (ctx==NULL)
{
printf("GGIMesaCreateContext() failed\n");
exit(1);
}
ggiMesaMakeCurrent(ctx, vis);
ggiGetMode(vis,&mode);
reshape(mode.visible.x,mode.visible.y);
init();
while (!ggiKbhit(vis)) idle();
while (!ggiKbhit(vis)) { /*sleep(1);*/ idle(); }
GGIMesaDestroyContext(ctx);
ggiMesaDestroyContext(ctx);
ggiClose(vis);
printf("%s\n",text);

View File

@@ -1,62 +1,51 @@
# Makefile for Win32
TOP = ..
!include "$(TOP)/names.win"
TOP = ..
INCDIR = ..\include
LIBDIR = ..\lib
!include <win32.mak>
SRCS= \
aaindex.c \
aapoly.c \
aargb.c \
accanti.c \
accnot.c \
accum.c \
aim.c \
accpersp.c \
alpha.c \
alpha3D.c \
anti.c \
antiindex.c \
antipindex.c \
antipoint.c \
antipoly.c \
bezcurve.c \
bezmesh.c \
bezsurf.c \
checker.c \
checker2.c \
chess.c \
clip.c \
colormat.c \
cone.c \
cube.c \
curve.c \
depthcue.c \
disk.c \
dof.c \
dofnot.c \
double.c \
drawf.c \
feedback.c \
fog.c \
fogindex.c \
font.c \
hello.c \
image.c \
light.c \
linelist.c \
lines.c \
list.c \
list2.c \
maplight.c \
material.c \
mipmap.c \
model.c \
movelight.c \
nurbs.c \
pickdepth.c \
pickline.c \
picksquare.c \
plane.c \
planet.c \
planetup.c \
polyoff.c \
polys.c \
quadric.c \
robot.c \
sccolorlight.c \
scene.c \
@@ -64,18 +53,26 @@ SRCS= \
sceneflat.c \
select.c \
smooth.c \
sphere.c \
stencil.c \
stroke.c \
surface.c \
tea.c \
teaambient.c \
teapots.c \
tess.c \
tesswind.c \
texbind.c \
texgen.c \
texprox.c \
texsub.c \
texturesurf.c \
trim.c
EXTRALIBS = $(MESAGL).lib $(MESAGLU).lib $(MESATK).lib $(MESAAUX).lib
torus.c \
trim.c \
unproject.c \
varray.c \
wrap.c
!include "$(TOP)/mesawin32.mak"
$(EXES) : $*.obj
@echo $@
$(link) -out:$@ $* /LIBPATH:$(LIBDIR) $(LIBS)

View File

@@ -42,6 +42,7 @@
* two rectangles. This program clamps the texture, if
* the texture coordinates fall outside 0.0 and 1.0.
*/
#include <stdlib.h>
#include <GL/glut.h>
/* Create checkerboard texture */

View File

@@ -62,7 +62,7 @@ selectFog(int mode)
/* falls through */
case GL_EXP2:
case GL_EXP:
glFogi(GL_FOG_MODE, mode);
glFogiv(GL_FOG_MODE, (int *) &mode);
glutPostRedisplay();
break;
case 0:
@@ -190,7 +190,7 @@ main(int argc, char **argv)
glutDisplayFunc(display);
glutCreateMenu(selectFog);
glutAddMenuEntry("Fog EXP", GL_EXP);
glutAddMenuEntry("Fog EXP2", GL_EXP2);
glutAddMenuEntry("Fog EXP2", /*GL_EXP2*/ 0xffff);
glutAddMenuEntry("Fog LINEAR", GL_LINEAR);
glutAddMenuEntry("Quit", 0);
glutAttachMenu(GLUT_RIGHT_BUTTON);

View File

@@ -39,6 +39,7 @@
* hello.c
* This is a simple, introductory OpenGL program.
*/
#include <stdlib.h>
#include <GL/glut.h>
void display(void)

View File

@@ -44,6 +44,7 @@
#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef GL_VERSION_1_1
GLuint list;
@@ -149,7 +150,7 @@ static void Benchmark( float xdiff, float ydiff )
{
int startTime, endTime;
int draws;
double seconds, fps, triPerSecond;
double seconds, fps;
printf("Benchmarking...\n");

View File

@@ -41,6 +41,7 @@
* This program draws a NURBS surface in the shape of a
* symmetrical hill.
*/
#include <stdlib.h>
#include <GL/glut.h>
GLfloat ctlpoints[4][4][3];

View File

@@ -0,0 +1,42 @@
# $Id: Makefile.win,v 1.1.2.1 2002/04/15 22:13:31 kschultz Exp $
# Mesa 3-D graphics library
# Version: 3.5
# Copyright (C) 1995-2001 Brian Paul
# Makefile for GLUT-based demo programs for Windows
!include <win32.mak>
##### MACROS #####
TOP = ..
INCDIR = ..\include
LIBDIR = ..\lib
PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
font line logo nurb oglinfo olympic overlay point prim quad select \
shape sphere star stencil stretch texture tri wave
SRCS = \
accum.c \
bitmap1.c \
bitmap2.c \
blendeq.c \
blendxor.c \
copy.c \
cursor.c depth.c eval.c fog.c \
font.c line.c logo.c nurb.c olympic.c overlay.c point.c prim.c quad.c select.c \
shape.c sphere.c star.c stencil.c stretch.c texture.c tri.c wave.c
!include "../mesawin32.mak"
##### TARGETS #####
clean::
clobber::
$(EXES) : $*.obj
@echo $@
$(link) -out:$@ $* /LIBPATH:$(LIBDIR) $(LIBS)

View File

@@ -11,6 +11,10 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_LEGACY
#include <GL/glut.h>

View File

@@ -10,6 +10,10 @@
#include <unistd.h>
#endif
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_LEGACY
#include <GL/glut.h>

View File

@@ -174,7 +174,7 @@ static void DeleteTri(GLint h)
static void GrowTri(GLint h)
{
float v[2];
float *oldV;
float *oldV = NULL;
GLint i;
v[0] = objects[h].v1[0] + objects[h].v2[0] + objects[h].v3[0];

39
progs/tests/Makefile.win Normal file
View File

@@ -0,0 +1,39 @@
# $Id: Makefile.win,v 1.1.2.1 2002/04/15 22:13:00 kschultz Exp $
# Mesa 3-D graphics library
# Version: 3.5
# Copyright (C) 1995-2001 Brian Paul
# Makefile for GLUT-based demo programs for Windows
!include <win32.mak>
##### MACROS #####
TOP = ..
INCDIR = ..\include
LIBDIR = ..\lib
SRCS = cva.c \
dinoshade.c \
fogcoord.c \
manytex.c \
multipal.c \
projtex.c \
seccolor.c \
# sharedtex.c \
texline.c \
texwrap.c
!include "../mesawin32.mak"
##### TARGETS #####
clean::
clobber::
@del readtex.c readtex.h
$(EXES) :$*.obj
@echo $@
$(link) -out:$@ $* /LIBPATH:$(LIBDIR) $(LIBS)

View File

@@ -1,4 +1,4 @@
/* $Id: cva.c,v 1.3 2000/11/30 03:06:56 gareth Exp $ */
/* $Id: cva.c,v 1.3.2.1 2002/04/15 22:13:00 kschultz Exp $ */
/*
* Trivial CVA test, good for testing driver fastpaths (especially
@@ -11,6 +11,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_LEGACY
#include <GL/glut.h>
@@ -130,7 +133,7 @@ int main( int argc, char **argv )
*/
string = (char *) glGetString( GL_VERSION );
if ( !strstr( string, "1.2" ) ) {
if ( (!strstr( string, "1.2" ))&&(!strstr(string,"1.3"))) {
fprintf( stderr, "This program requires OpenGL 1.2 vertex arrays.\n" );
exit( -1 );
}

View File

@@ -38,6 +38,10 @@
#include <stdlib.h>
#include <string.h>
#include <math.h> /* for cos(), sin(), and sqrt() */
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_LEGACY
#include <GL/glut.h> /* OpenGL Utility Toolkit header */
/* Some <math.h> files do not define M_PI... */

View File

@@ -1,4 +1,4 @@
/* $Id: multipal.c,v 1.1 2000/11/18 17:12:33 brianp Exp $ */
/* $Id: multipal.c,v 1.1.2.1 2002/04/15 22:13:00 kschultz Exp $ */
/*
* GL_ARB_multitexture demo
@@ -12,6 +12,13 @@
/*
* $Log: multipal.c,v $
* Revision 1.1.2.1 2002/04/15 22:13:00 kschultz
* Build demos/samples correctly on Windows (Robert Bergkvist) to sync up
* with the main branch. (I should have done this for 4.0.2)
*
* Revision 1.2 2002/01/16 01:03:25 kschultz
* get tests working on windows (Robert Bergkvist)
*
* Revision 1.1 2000/11/18 17:12:33 brianp
* test texture palettes with multitexture
*
@@ -52,6 +59,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_LEGACY
#include <GL/glut.h>
#include "../util/readtex.c" /* I know, this is a hack. */

View File

@@ -1,7 +1,7 @@
# $Id: Makefile.X11,v 1.11 2001/03/23 22:48:35 brianp Exp $
# $Id: Makefile.X11,v 1.11.2.1 2002/01/30 21:54:47 brianp Exp $
# Mesa 3-D graphics library
# Version: 3.5
# Version: 4.0.2
# Copyright (C) 1995-2001 Brian Paul
# Makefile for non-GLUT (X11, SVGA, etc) demo programs
@@ -12,9 +12,9 @@
INCDIR = ../include
LIBDIR = ../lib
GL_LIBS = -L$(LIBDIR) -lglut -lGLU -lGL $(APP_LIB_DEPS)
GL_LIBS = -L$(LIBDIR) -lGLU -lGL $(APP_LIB_DEPS)
LIB_DEP = $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLUT_LIB)
LIB_DEP = $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GLU_LIB)
PROGS = glthreads \
glxdemo \
@@ -43,7 +43,7 @@ PROGS = glthreads \
##### TARGETS #####
default:
@echo "Specify a target configuration"
@echo "Specify a target configuration (i.e. make -f Makefile.X11 linux)"
clean:
-rm *.o *~

View File

@@ -1,4 +1,4 @@
/* $Id: glthreads.c,v 1.1 2000/07/20 20:12:17 brianp Exp $ */
/* $Id: glthreads.c,v 1.1.4.1 2002/03/08 19:43:36 brianp Exp $ */
/*
* Copyright (C) 2000 Brian Paul All Rights Reserved.
@@ -38,6 +38,7 @@
#include <GL/glx.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>

View File

@@ -1,4 +1,4 @@
/* $Id: glxheads.c,v 1.2 2000/11/10 17:23:07 brianp Exp $ */
/* $Id: glxheads.c,v 1.2.2.1 2002/03/08 19:43:36 brianp Exp $ */
/*
* Exercise multiple GLX connections on multiple X displays.
@@ -30,6 +30,7 @@
#include <GL/glx.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -247,9 +248,9 @@ static void
PrintInfo(const struct head *h)
{
printf("Name: %s\n", h->DisplayName);
printf(" Display: 0x%x\n", h->Dpy);
printf(" Window: 0x%x\n", h->Win);
printf(" Context: 0x%x\n", h->Context);
printf(" Display: 0x%x\n", (int) h->Dpy);
printf(" Window: 0x%x\n", (int) h->Win);
printf(" Context: 0x%x\n", (int) h->Context);
printf(" GL_VERSION: %s\n", h->Version);
printf(" GL_VENDOR: %s\n", h->Vendor);
printf(" GL_RENDERER: %s\n", h->Renderer);

View File

@@ -1,4 +1,4 @@
/* $Id: glxinfo.c,v 1.14 2001/04/24 20:57:36 brianp Exp $ */
/* $Id: glxinfo.c,v 1.14.2.1 2002/03/08 19:43:36 brianp Exp $ */
/*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
@@ -408,7 +408,7 @@ print_visual_attribs_short_header(void)
static void
print_visual_attribs_short(const struct visual_attribs *attribs)
{
char *caveat;
char *caveat = NULL;
#ifdef GLX_EXT_visual_rating
if (attribs->visualCaveat == GLX_NONE_EXT || attribs->visualCaveat == 0)
caveat = "None";

85
src/glu/mesa/Makefile.DJ Normal file
View File

@@ -0,0 +1,85 @@
# Mesa 3-D graphics library
# Version: 4.0
#
# Copyright (C) 1999 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# DOS/DJGPP glu makefile v1.0 for Mesa 4.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
.PHONY: all clean
TOP = ..
CC = gcc
CFLAGS = -I$(TOP)/include -Wall -W -Wno-unused -mcpu=$(CPU) -ffast-math -O2
AR = ar
ARFLAGS = ruv
LIBDIR = $(TOP)/lib
ifeq ($(wildcard $(DJDIR)/lib/dxe2.ld),)
DXE2GEN =
else
DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH))))
endif
GLU_LIB = libglu.a
GLU_DXE = glu.dxe
GLU_IMP = libiglu.a
CORE_SOURCES = \
glu.c \
mipmap.c \
nurbs.c \
nurbscrv.c \
nurbssrf.c \
nurbsutl.c \
polytest.c \
project.c \
quadric.c \
tess.c \
tesselat.c
SOURCES = $(CORE_SOURCES)
OBJECTS = $(SOURCES:.c=.o)
.c.o:
gcc -o $@ -c $(CFLAGS) $<
all: $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP)
$(LIBDIR)/$(GLU_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLU_LIB) $(OBJECTS)
$(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP): $(OBJECTS)
ifeq ($(DXE2GEN),)
$(warning Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN)
$(warning somewhere in PATH, and DXE2.LD in DJGPP/LIB directory.)
else
dxe2gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) $(OBJECTS) -D "Mesa DOS GLU" -U
endif
clean:
-$(RM) *.o
include depend

View File

@@ -1,9 +1,9 @@
/* $Id: glu.c,v 1.24 2001/03/20 17:56:10 brianp Exp $ */
/* $Id: glu.c,v 1.24.2.1 2002/02/12 03:13:42 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Copyright (C) 1995-2001 Brian Paul
* Version: 4.0.2
* Copyright (C) 1995-2002 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -330,7 +330,7 @@ const GLubyte *GLAPIENTRY
gluGetString(GLenum name)
{
static char *extensions = "GL_EXT_abgr";
static char *version = "1.1 Mesa 3.5";
static char *version = "1.1 Mesa 4.0.2";
switch (name) {
case GLU_EXTENSIONS:

View File

@@ -1,7 +1,7 @@
# $Id: Makefile.X11,v 1.5.2.1 2001/12/14 17:18:08 kschultz Exp $
# $Id: Makefile.X11,v 1.5.2.2 2002/01/08 15:58:11 brianp Exp $
# Mesa 3-D graphics library
# Version: 3.5
# Version: 4.0.1
# Copyright (C) 1995-2001 Brian Paul
# Makefile for SGI SI GLU library
@@ -122,10 +122,10 @@ OBJECTS = $(C_OBJECTS) $(CC_OBJECTS)
##### RULES #####
.c.o:
$(CC) -c $(INCDIRS) $(CFLAGS) -DLIBRARYBUILD $< -o $@
$(CC) -c $(INCDIRS) $(CFLAGS) -DNDEBUG -DLIBRARYBUILD $< -o $@
.cc.o:
$(CPLUSPLUS) -c $(INCDIRS) $(CCFLAGS) -DLIBRARYBUILD $< -o $@
$(CPLUSPLUS) -c $(INCDIRS) $(CCFLAGS) -DNDEBUG -DLIBRARYBUILD $< -o $@
##### TARGETS #####

View File

@@ -31,10 +31,10 @@
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
**
** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
** $Date: 2002/02/12 03:14:58 $ $Revision: 1.1.2.1 $
*/
/*
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/insurfeval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/insurfeval.cc,v 1.1.2.1 2002/02/12 03:14:58 brianp Exp $
*/
#include "gluos.h"
@@ -528,11 +528,11 @@ void OpenGLSurfaceEvaluator::inComputeNormal2(REAL *pu, REAL *pv, REAL *n)
mag = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]);
assert(mag > 0.0); /*better be some threshold*/
n[0] /= mag;
n[1] /= mag;
n[2] /= mag;
if (mag > 0.0) {
n[0] /= mag;
n[1] /= mag;
n[2] /= mag;
}
}

View File

@@ -31,16 +31,23 @@
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
**
** $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
** $Date: 2002/04/17 19:30:19 $ $Revision: 1.1.2.1 $
*/
/*
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/nurbtess/quicksort.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/nurbtess/quicksort.cc,v 1.1.2.1 2002/04/17 19:30:19 brianp Exp $
*/
#include <stdlib.h>
#include <stdio.h>
static void swap(void *v[], int i, int j);
static void swap(void *v[], int i, int j)
{
void *temp;
temp = v[i];
v[i] = v[j];
v[j] = temp;
}
/*as an example to use this function to
*sort integers, you need to supply the function
@@ -58,7 +65,6 @@ void quicksort(void *v[], int left, int right,
int (*comp) (void *, void *))
{
int i, last;
void swap(void *v[], int , int);
if(left >= right) /*do nothing if array contains */
return; /*fewer than two elements*/
@@ -71,12 +77,3 @@ void quicksort(void *v[], int left, int right,
quicksort(v, left, last-1, comp);
quicksort(v, last+1, right, comp);
}
void swap(void *v[], int i, int j)
{
void *temp;
temp = v[i];
v[i] = v[j];
v[j] = temp;
}

114
src/glut/dos/Makefile.DJ Normal file
View File

@@ -0,0 +1,114 @@
# Mesa 3-D graphics library
# Version: 4.0
#
# Copyright (C) 1999 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# DOS/DJGPP glut makefile v1.0 for Mesa 4.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
.PHONY: all clean
TOP = ..
CC = gcc
CFLAGS = -I$(TOP)/include -Wall -W -Wno-unused -mcpu=$(CPU) -ffast-math -O2
AR = ar
ARFLAGS = ruv
LIBDIR = $(TOP)/lib
ifeq ($(wildcard $(DJDIR)/lib/dxe2.ld),)
DXE2GEN =
else
DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH))))
endif
GLUT_LIB = libglut.a
GLUT_DXE = glut.dxe
GLUT_IMP = libiglut.a
CORE_SOURCES = \
callback.c \
color.c \
font.c \
globals.c \
init.c \
menu.c \
models.c \
overlay.c \
state.c \
teapot.c \
window.c
PC_HW_SOURCES = \
PC_HW/pc_hw.c \
PC_HW/pc_keyb.c \
PC_HW/pc_mouse.c \
PC_HW/pc_timer.c \
PC_HW/pc_irq.S
SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
.c.o:
gcc -o $@ -c $(CFLAGS) $<
.S.o:
gcc -o $@ -c $(CFLAGS) $<
.s.o:
gcc -o $@ -c $(CFLAGS) $(<:.s=.S)
all: $(LIBDIR)/$(GLUT_LIB) $(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP)
$(LIBDIR)/$(GLUT_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLUT_LIB) $(OBJECTS)
$(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS)
ifeq ($(DXE2GEN),)
$(warning Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN)
$(warning somewhere in PATH, and DXE2.LD in DJGPP/LIB directory.)
else
dxe2gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) $(OBJECTS) -D "Mesa DOS GLUT" -U
endif
clean:
-$(RM) *.o
-$(RM) PC_HW\*.o
callback.o: callback.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
color.o: color.c ../include/GL/glut.h
font.o: font.c ../include/GL/glut.h
globals.o: globals.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
init.o: init.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
menu.o: menu.c ../include/GL/glut.h
models.o: models.c ../include/GL/glut.h
overlay.o: overlay.c ../include/GL/glut.h
state.o: state.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
teapot.o: teapot.c ../include/GL/glut.h
window.o: window.c ../include/GL/glut.h ../include/GL/dmesa.h internal.h \
PC_HW/pc_hw.h
PC_HW/pc_hw.o: PC_HW/pc_hw.c PC_HW/pc_hw.h
PC_HW/pc_keyb.o: PC_HW/pc_keyb.c PC_HW/pc_hw.h
PC_HW/pc_mouse.o: PC_HW/pc_mouse.c PC_HW/pc_hw.h
PC_HW/pc_timer.o: PC_HW/pc_timer.c PC_HW/pc_hw.h
PC_HW/pc_irq.o: PC_HW/pc_irq.S

141
src/glut/dos/PC_HW/pc_hw.c Normal file
View File

@@ -0,0 +1,141 @@
/*
* PC/HW routine collection v1.0 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <dpmi.h>
#include <fcntl.h>
#include <sys/stat.h> /* for mode definitions */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "pc_hw.h"
/*
* atexit
*/
#define MAX_ATEXIT 32
static volatile int atexitcnt;
static VFUNC atexittbl[MAX_ATEXIT];
static void __attribute__((destructor)) doexit (void)
{
while (atexitcnt) atexittbl[--atexitcnt]();
}
int pc_clexit (VFUNC f)
{
int i;
for (i=0;i<atexitcnt;i++) {
if (atexittbl[i]==f) {
for (atexitcnt--;i<atexitcnt;i++) atexittbl[i] = atexittbl[i+1];
atexittbl[i] = 0;
return 0;
}
}
return -1;
}
int pc_atexit (VFUNC f)
{
pc_clexit(f);
if (atexitcnt<MAX_ATEXIT) {
atexittbl[atexitcnt++] = f;
return 0;
}
return -1;
}
/*
* locked memory allocation
*/
void *pc_malloc (size_t size)
{
void *p = malloc(size);
if (p) {
if (_go32_dpmi_lock_data(p, size)) {
free(p);
return NULL;
}
}
return p;
}
/*
* standard redirection
*/
static char errname[L_tmpnam];
static char outname[L_tmpnam];
static int h_out, h_outbak;
static int h_err, h_errbak;
void pc_open_stderr (void)
{
if (tmpnam(errname)) {
h_err = open(errname, O_WRONLY |/* O_BINARY |*/ O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE);
h_errbak = dup(2);
fflush(stderr);
dup2(h_err, 2);
}
}
void pc_close_stderr (void)
{
FILE *f;
char *line = alloca(512);
dup2(h_errbak, 2);
close(h_err);
close(h_errbak);
if ((f=fopen(errname, "r"))!=NULL) {
while (fgets(line, 512, f)) {
fputs(line, stderr);
}
fclose(f);
}
remove(errname);
}
void pc_open_stdout (void)
{
if (tmpnam(outname)) {
h_out = open(outname, O_WRONLY |/* O_BINARY |*/ O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE);
h_outbak = dup(1);
fflush(stdout);
dup2(h_out, 1);
}
}
void pc_close_stdout (void)
{
FILE *f;
char *line = alloca(512);
dup2(h_outbak, 1);
close(h_out);
close(h_outbak);
if ((f=fopen(outname, "r"))!=NULL) {
while (fgets(line, 512, f)) {
fputs(line, stdout);
}
fclose(f);
}
remove(outname);
}

225
src/glut/dos/PC_HW/pc_hw.h Normal file
View File

@@ -0,0 +1,225 @@
/*
* PC/HW routine collection v1.0 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef PC_HW_H_included
#define PC_HW_H_included
#include <dpmi.h>
#include <stdlib.h>
/*
* misc C definitions
*/
#define FALSE 0
#define TRUE !FALSE
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
#define MID(x,y,z) MAX((x), MIN((y), (z)))
typedef void (*VFUNC) (void);
typedef void (*PFUNC) (void *);
typedef void (*MFUNC) (int x, int y, int b);
/*
* atexit
*/
int pc_atexit (VFUNC f);
int pc_clexit (VFUNC f);
/*
* locked memory
*/
#define ENDOFUNC(x) static void x##_end() { }
#define LOCKFUNC(x) _go32_dpmi_lock_code((void *)x, (long)x##_end - (long)x)
#define LOCKDATA(x) _go32_dpmi_lock_data((void *)&x, sizeof(x))
void *pc_malloc (size_t size);
/*
* IRQ
*/
#define ENABLE() __asm__ __volatile__ ("sti")
#define DISABLE() __asm__ __volatile__ ("cli")
extern int pc_install_irq (int i, int (*handler) ());
extern int pc_remove_irq (int i);
/*
* keyboard
*/
#define KB_SHIFT_FLAG 0x0001
#define KB_CTRL_FLAG 0x0002
#define KB_ALT_FLAG 0x0004
#define KB_LWIN_FLAG 0x0008
#define KB_RWIN_FLAG 0x0010
#define KB_MENU_FLAG 0x0020
#define KB_SCROLOCK_FLAG 0x0100
#define KB_NUMLOCK_FLAG 0x0200
#define KB_CAPSLOCK_FLAG 0x0400
#define KB_INALTSEQ_FLAG 0x0800
#define KB_ACCENT1_FLAG 0x1000
#define KB_ACCENT2_FLAG 0x2000
#define KB_ACCENT3_FLAG 0x4000
#define KB_ACCENT4_FLAG 0x8000
#define KEY_A 1
#define KEY_B 2
#define KEY_C 3
#define KEY_D 4
#define KEY_E 5
#define KEY_F 6
#define KEY_G 7
#define KEY_H 8
#define KEY_I 9
#define KEY_J 10
#define KEY_K 11
#define KEY_L 12
#define KEY_M 13
#define KEY_N 14
#define KEY_O 15
#define KEY_P 16
#define KEY_Q 17
#define KEY_R 18
#define KEY_S 19
#define KEY_T 20
#define KEY_U 21
#define KEY_V 22
#define KEY_W 23
#define KEY_X 24
#define KEY_Y 25
#define KEY_Z 26
#define KEY_0 27
#define KEY_1 28
#define KEY_2 29
#define KEY_3 30
#define KEY_4 31
#define KEY_5 32
#define KEY_6 33
#define KEY_7 34
#define KEY_8 35
#define KEY_9 36
#define KEY_0_PAD 37
#define KEY_1_PAD 38
#define KEY_2_PAD 39
#define KEY_3_PAD 40
#define KEY_4_PAD 41
#define KEY_5_PAD 42
#define KEY_6_PAD 43
#define KEY_7_PAD 44
#define KEY_8_PAD 45
#define KEY_9_PAD 46
#define KEY_F1 47
#define KEY_F2 48
#define KEY_F3 49
#define KEY_F4 50
#define KEY_F5 51
#define KEY_F6 52
#define KEY_F7 53
#define KEY_F8 54
#define KEY_F9 55
#define KEY_F10 56
#define KEY_F11 57
#define KEY_F12 58
#define KEY_ESC 59
#define KEY_TILDE 60
#define KEY_MINUS 61
#define KEY_EQUALS 62
#define KEY_BACKSPACE 63
#define KEY_TAB 64
#define KEY_OPENBRACE 65
#define KEY_CLOSEBRACE 66
#define KEY_ENTER 67
#define KEY_COLON 68
#define KEY_QUOTE 69
#define KEY_BACKSLASH 70
#define KEY_BACKSLASH2 71
#define KEY_COMMA 72
#define KEY_STOP 73
#define KEY_SLASH 74
#define KEY_SPACE 75
#define KEY_INSERT 76
#define KEY_DEL 77
#define KEY_HOME 78
#define KEY_END 79
#define KEY_PGUP 80
#define KEY_PGDN 81
#define KEY_LEFT 82
#define KEY_RIGHT 83
#define KEY_UP 84
#define KEY_DOWN 85
#define KEY_SLASH_PAD 86
#define KEY_ASTERISK 87
#define KEY_MINUS_PAD 88
#define KEY_PLUS_PAD 89
#define KEY_DEL_PAD 90
#define KEY_ENTER_PAD 91
#define KEY_PRTSCR 92
#define KEY_PAUSE 93
#define KEY_ABNT_C1 94
#define KEY_YEN 95
#define KEY_KANA 96
#define KEY_CONVERT 97
#define KEY_NOCONVERT 98
#define KEY_AT 99
#define KEY_CIRCUMFLEX 100
#define KEY_COLON2 101
#define KEY_KANJI 102
#define KEY_MODIFIERS 103
#define KEY_LSHIFT 103
#define KEY_RSHIFT 104
#define KEY_LCONTROL 105
#define KEY_RCONTROL 106
#define KEY_ALT 107
#define KEY_ALTGR 108
#define KEY_LWIN 109
#define KEY_RWIN 110
#define KEY_MENU 111
#define KEY_SCRLOCK 112
#define KEY_NUMLOCK 113
#define KEY_CAPSLOCK 114
#define KEY_MAX 115
int pc_install_keyb (void);
void pc_remove_keyb (void);
int pc_keypressed (void);
int pc_readkey (void);
int pc_keydown (int code);
/*
* timer
*/
int pc_install_int (PFUNC func, void *parm, unsigned int freq);
void pc_remove_timer (void);
/*
* mouse
*/
int pc_install_mouse (void);
void pc_remove_mouse (void);
MFUNC pc_install_mouse_handler (MFUNC handler);
void pc_mouse_area (int x1, int y1, int x2, int y2);
void pc_mouse_speed (int xspeed, int yspeed);
int pc_query_mouse (int *x, int *y);
void pc_show_mouse (void);
void pc_scare_mouse (void);
void pc_unscare_mouse (void);
/*
* standard redirection
*/
void pc_open_stdout (void);
void pc_open_stderr (void);
void pc_close_stdout (void);
void pc_close_stderr (void);
#endif

180
src/glut/dos/PC_HW/pc_irq.S Normal file
View File

@@ -0,0 +1,180 @@
/*
* PC/HW routine collection v1.0 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
.file "pc_irq.S"
.text
#define IRQ_STACK_SIZE 16384
#define IRQ_WRAPPER_LEN (__irq_wrapper_1-__irq_wrapper_0)
#define IRQ_OLD (__irq_old_0-__irq_wrapper_0)
#define IRQ_HOOK (__irq_hook_0-__irq_wrapper_0)
#define IRQ_STACK (__irq_stack_0-__irq_wrapper_0)
.balign 4
common:
movw $0x0400, %ax
int $0x31
movl %ss:8(%ebp), %ebx
cmpl $15, %ebx
jbe 0f
fail:
orl $-1, %eax
popl %edi
popl %ebx
leave
ret
0:
movl %ebx, %edi
imull $IRQ_WRAPPER_LEN, %edi
addl $__irq_wrapper_0, %edi
cmpb $7, %bl
jbe 1f
movb %dl, %dh
subb $8, %dh
1:
addb %dh, %bl
ret
.balign 4
.global _pc_install_irq
_pc_install_irq:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi
call common
cmpl $0, IRQ_HOOK(%edi)
jne fail
pushl $IRQ_WRAPPER_LEN
pushl %edi
call __go32_dpmi_lock_code
addl $8, %esp
testl %eax, %eax
jnz fail
pushl $IRQ_STACK_SIZE
call _pc_malloc
popl %edx
testl %eax, %eax
jz fail
addl %edx, %eax
movl %eax, IRQ_STACK(%edi)
movl %ss:12(%ebp), %eax
movl %eax, IRQ_HOOK(%edi)
movw $0x0204, %ax
int $0x31
movl %edx, IRQ_OLD(%edi)
movw %cx, IRQ_OLD+4(%edi)
movw $0x0205, %ax
movl %edi, %edx
movl %cs, %ecx
int $0x31
done:
xorl %eax, %eax
popl %edi
popl %ebx
leave
ret
.balign 4
.global _pc_remove_irq
_pc_remove_irq:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi
call common
cmpl $0, IRQ_HOOK(%edi)
je fail
movl $0, IRQ_HOOK(%edi)
movw $0x0205, %ax
movl IRQ_OLD(%edi), %edx
movl IRQ_OLD+4(%edi), %ecx
int $0x31
movl IRQ_STACK(%edi), %eax
subl $IRQ_STACK_SIZE, %eax
pushl %eax
call _free
popl %eax
jmp done
#define WRAPPER(x) ; \
.balign 4 ; \
__irq_wrapper_##x: ; \
pushal ; \
pushl %ds ; \
pushl %es ; \
pushl %fs ; \
pushl %gs ; \
movl %ss, %ebx ; \
movl %esp, %esi ; \
movl %cs:___djgpp_ds_alias, %ss ; \
movl %cs:__irq_stack_##x, %esp ; \
pushl %ss ; \
pushl %ss ; \
popl %es ; \
popl %ds ; \
movl ___djgpp_dos_sel, %fs ; \
pushl %fs ; \
popl %gs ; \
call *__irq_hook_##x ; \
movl %ebx, %ss ; \
movl %esi, %esp ; \
testl %eax, %eax ; \
popl %gs ; \
popl %fs ; \
popl %es ; \
popl %ds ; \
popal ; \
jz __irq_ignore_##x ; \
__irq_bypass_##x: ; \
ljmp *%cs:__irq_old_##x ; \
__irq_ignore_##x: ; \
iret ; \
.balign 4 ; \
__irq_old_##x: ; \
.long 0, 0 ; \
__irq_hook_##x: ; \
.long 0 ; \
__irq_stack_##x: ; \
.long 0
WRAPPER(0);
WRAPPER(1);
WRAPPER(2);
WRAPPER(3);
WRAPPER(4);
WRAPPER(5);
WRAPPER(6);
WRAPPER(7);
WRAPPER(8);
WRAPPER(9);
WRAPPER(10);
WRAPPER(11);
WRAPPER(12);
WRAPPER(13);
WRAPPER(14);
WRAPPER(15);

View File

@@ -0,0 +1,541 @@
/*
* PC/HW routine collection v1.0 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <pc.h>
#include <sys/exceptn.h>
#include <sys/farptr.h>
#include "pc_hw.h"
#define KEYB_IRQ 1
#define KEY_BUFFER_SIZE 64
#define KB_MODIFIERS (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG | KB_LWIN_FLAG | KB_RWIN_FLAG | KB_MENU_FLAG)
#define KB_LED_FLAGS (KB_SCROLOCK_FLAG | KB_NUMLOCK_FLAG | KB_CAPSLOCK_FLAG)
static int keyboard_installed;
static volatile struct {
volatile int start, end;
volatile int key[KEY_BUFFER_SIZE];
} key_buffer;
static volatile int key_enhanced, key_pause_loop, key_shifts;
static int leds_ok = TRUE;
static int in_a_terrupt = FALSE;
static volatile char pc_key[KEY_MAX];
/* convert Allegro format scancodes into key_shifts flag bits */
static unsigned short modifier_table[KEY_MAX - KEY_MODIFIERS] =
{
KB_SHIFT_FLAG, KB_SHIFT_FLAG, KB_CTRL_FLAG,
KB_CTRL_FLAG, KB_ALT_FLAG, KB_ALT_FLAG,
KB_LWIN_FLAG, KB_RWIN_FLAG, KB_MENU_FLAG,
KB_SCROLOCK_FLAG, KB_NUMLOCK_FLAG, KB_CAPSLOCK_FLAG
};
/* lookup table for converting hardware scancodes into Allegro format */
static unsigned char hw_to_mycode[128] =
{
/* 0x00 */ 0, KEY_ESC, KEY_1, KEY_2,
/* 0x04 */ KEY_3, KEY_4, KEY_5, KEY_6,
/* 0x08 */ KEY_7, KEY_8, KEY_9, KEY_0,
/* 0x0C */ KEY_MINUS, KEY_EQUALS, KEY_BACKSPACE, KEY_TAB,
/* 0x10 */ KEY_Q, KEY_W, KEY_E, KEY_R,
/* 0x14 */ KEY_T, KEY_Y, KEY_U, KEY_I,
/* 0x18 */ KEY_O, KEY_P, KEY_OPENBRACE, KEY_CLOSEBRACE,
/* 0x1C */ KEY_ENTER, KEY_LCONTROL, KEY_A, KEY_S,
/* 0x20 */ KEY_D, KEY_F, KEY_G, KEY_H,
/* 0x24 */ KEY_J, KEY_K, KEY_L, KEY_COLON,
/* 0x28 */ KEY_QUOTE, KEY_TILDE, KEY_LSHIFT, KEY_BACKSLASH,
/* 0x2C */ KEY_Z, KEY_X, KEY_C, KEY_V,
/* 0x30 */ KEY_B, KEY_N, KEY_M, KEY_COMMA,
/* 0x34 */ KEY_STOP, KEY_SLASH, KEY_RSHIFT, KEY_ASTERISK,
/* 0x38 */ KEY_ALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1,
/* 0x3C */ KEY_F2, KEY_F3, KEY_F4, KEY_F5,
/* 0x40 */ KEY_F6, KEY_F7, KEY_F8, KEY_F9,
/* 0x44 */ KEY_F10, KEY_NUMLOCK, KEY_SCRLOCK, KEY_7_PAD,
/* 0x48 */ KEY_8_PAD, KEY_9_PAD, KEY_MINUS_PAD, KEY_4_PAD,
/* 0x4C */ KEY_5_PAD, KEY_6_PAD, KEY_PLUS_PAD, KEY_1_PAD,
/* 0x50 */ KEY_2_PAD, KEY_3_PAD, KEY_0_PAD, KEY_DEL_PAD,
/* 0x54 */ KEY_PRTSCR, 0, KEY_BACKSLASH2, KEY_F11,
/* 0x58 */ KEY_F12, 0, 0, KEY_LWIN,
/* 0x5C */ KEY_RWIN, KEY_MENU, 0, 0,
/* 0x60 */ 0, 0, 0, 0,
/* 0x64 */ 0, 0, 0, 0,
/* 0x68 */ 0, 0, 0, 0,
/* 0x6C */ 0, 0, 0, 0,
/* 0x70 */ KEY_KANA, 0, 0, KEY_ABNT_C1,
/* 0x74 */ 0, 0, 0, 0,
/* 0x78 */ 0, KEY_CONVERT, 0, KEY_NOCONVERT,
/* 0x7C */ 0, KEY_YEN, 0, 0
};
/* lookup table for converting extended hardware codes into Allegro format */
static unsigned char hw_to_mycode_ex[128] =
{
/* 0x00 */ 0, KEY_ESC, KEY_1, KEY_2,
/* 0x04 */ KEY_3, KEY_4, KEY_5, KEY_6,
/* 0x08 */ KEY_7, KEY_8, KEY_9, KEY_0,
/* 0x0C */ KEY_MINUS, KEY_EQUALS, KEY_BACKSPACE, KEY_TAB,
/* 0x10 */ KEY_CIRCUMFLEX, KEY_AT, KEY_COLON2, KEY_R,
/* 0x14 */ KEY_KANJI, KEY_Y, KEY_U, KEY_I,
/* 0x18 */ KEY_O, KEY_P, KEY_OPENBRACE, KEY_CLOSEBRACE,
/* 0x1C */ KEY_ENTER_PAD, KEY_RCONTROL, KEY_A, KEY_S,
/* 0x20 */ KEY_D, KEY_F, KEY_G, KEY_H,
/* 0x24 */ KEY_J, KEY_K, KEY_L, KEY_COLON,
/* 0x28 */ KEY_QUOTE, KEY_TILDE, 0, KEY_BACKSLASH,
/* 0x2C */ KEY_Z, KEY_X, KEY_C, KEY_V,
/* 0x30 */ KEY_B, KEY_N, KEY_M, KEY_COMMA,
/* 0x34 */ KEY_STOP, KEY_SLASH_PAD, 0, KEY_PRTSCR,
/* 0x38 */ KEY_ALTGR, KEY_SPACE, KEY_CAPSLOCK, KEY_F1,
/* 0x3C */ KEY_F2, KEY_F3, KEY_F4, KEY_F5,
/* 0x40 */ KEY_F6, KEY_F7, KEY_F8, KEY_F9,
/* 0x44 */ KEY_F10, KEY_NUMLOCK, KEY_PAUSE, KEY_HOME,
/* 0x48 */ KEY_UP, KEY_PGUP, KEY_MINUS_PAD, KEY_LEFT,
/* 0x4C */ KEY_5_PAD, KEY_RIGHT, KEY_PLUS_PAD, KEY_END,
/* 0x50 */ KEY_DOWN, KEY_PGDN, KEY_INSERT, KEY_DEL,
/* 0x54 */ KEY_PRTSCR, 0, KEY_BACKSLASH2, KEY_F11,
/* 0x58 */ KEY_F12, 0, 0, KEY_LWIN,
/* 0x5C */ KEY_RWIN, KEY_MENU, 0, 0,
/* 0x60 */ 0, 0, 0, 0,
/* 0x64 */ 0, 0, 0, 0,
/* 0x68 */ 0, 0, 0, 0,
/* 0x6C */ 0, 0, 0, 0,
/* 0x70 */ 0, 0, 0, 0,
/* 0x74 */ 0, 0, 0, 0,
/* 0x78 */ 0, 0, 0, 0,
/* 0x7C */ 0, 0, 0, 0
};
/* default mapping table for the US keyboard layout */
static unsigned short standard_key_ascii_table[KEY_MAX] =
{
/* start */ 0,
/* alphabet */ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
/* numbers */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* misc chars */ 27, '`', '-', '=', 8, 9, '[', ']', 13, ';', '\'', '\\', '\\', ',', '.', '/', ' ',
/* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* numpad */ '/', '*', '-', '+', '.', 13,
/* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* capslock mapping table for the US keyboard layout */
static unsigned short standard_key_capslock_table[KEY_MAX] =
{
/* start */ 0,
/* alphabet */ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
/* numbers */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* misc chars */ 27, '`', '-', '=', 8, 9, '[', ']', 13, ';', '\'', '\\', '\\', ',', '.', '/', ' ',
/* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* numpad */ '/', '*', '-', '+', '.', 13,
/* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* shifted mapping table for the US keyboard layout */
static unsigned short standard_key_shift_table[KEY_MAX] =
{
/* start */ 0,
/* alphabet */ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
/* numbers */ ')', '!', '@', '#', '$', '%', '^', '&', '*', '(',
/* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* misc chars */ 27, '~', '_', '+', 8, 9, '{', '}', 13, ':', '"', '|', '|', '<', '>', '?', ' ',
/* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* numpad */ '/', '*', '-', '+', '.', 13,
/* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* ctrl+key mapping table for the US keyboard layout */
static unsigned short standard_key_control_table[KEY_MAX] =
{
/* start */ 0,
/* alphabet */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
/* numbers */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
/* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
/* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* misc chars */ 27, 2, 2, 2, 127, 127, 2, 2, 10, 2, 2, 2, 2, 2, 2, 2, 2,
/* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
/* numpad */ 2, 2, 2, 2, 2, 10,
/* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* convert numeric pad scancodes into arrow codes */
static unsigned char numlock_table[10] =
{
KEY_INSERT, KEY_END, KEY_DOWN, KEY_PGDN, KEY_LEFT,
KEY_5_PAD, KEY_RIGHT, KEY_HOME, KEY_UP, KEY_PGUP
};
/* kb_wait_for_write_ready:
* Wait for the keyboard controller to set the ready-for-write bit.
*/
static __inline__ int kb_wait_for_write_ready (void)
{
int timeout = 4096;
while ((timeout>0) && (inportb(0x64)&2)) timeout--;
return (timeout>0);
}
/* kb_wait_for_read_ready:
* Wait for the keyboard controller to set the ready-for-read bit.
*/
static __inline__ int kb_wait_for_read_ready (void)
{
int timeout = 16384;
while ((timeout>0) && (!(inportb(0x64)&1))) timeout--;
return (timeout>0);
}
/* kb_send_data:
* Sends a byte to the keyboard controller. Returns 1 if all OK.
*/
static __inline__ int kb_send_data (unsigned char data)
{
int resends = 4;
int timeout, temp;
do {
if (!kb_wait_for_write_ready())
return 0;
outportb(0x60, data);
timeout = 4096;
while (--timeout>0) {
if (!kb_wait_for_read_ready())
return 0;
temp = inportb(0x60);
if (temp == 0xFA)
return 1;
if (temp == 0xFE)
break;
}
} while ((resends-- > 0) && (timeout > 0));
return 0;
}
static void update_leds (int leds)
{
if (leds_ok) {
if (!in_a_terrupt)
DISABLE();
if (!kb_send_data(0xED)) {
kb_send_data(0xF4);
leds_ok = FALSE;
} else if (!kb_send_data((leds>>8)&7)) {
kb_send_data(0xF4);
leds_ok = FALSE;
}
if (!in_a_terrupt)
ENABLE();
}
} ENDOFUNC(update_leds)
static void inject_key (int scancode)
{
unsigned short *table;
if ((scancode >= KEY_0_PAD) && (scancode <= KEY_9_PAD)) {
if (((key_shifts & KB_NUMLOCK_FLAG) != 0) == ((key_shifts & KB_SHIFT_FLAG) != 0)) {
scancode = numlock_table[scancode - KEY_0_PAD];
}
table = standard_key_ascii_table;
} else if (key_shifts & KB_CTRL_FLAG) {
table = standard_key_control_table;
} else if (key_shifts & KB_SHIFT_FLAG) {
if (key_shifts & KB_CAPSLOCK_FLAG) {
if (standard_key_ascii_table[scancode]==standard_key_capslock_table[scancode]) {
table = standard_key_shift_table;
} else {
table = standard_key_ascii_table;
}
} else {
table = standard_key_shift_table;
}
} else if (key_shifts & KB_CAPSLOCK_FLAG) {
table = standard_key_capslock_table;
} else {
table = standard_key_ascii_table;
}
key_buffer.key[key_buffer.end++] = (scancode<<16)|table[scancode];
if (key_buffer.end>=KEY_BUFFER_SIZE)
key_buffer.end = 0;
if (key_buffer.end==key_buffer.start) {
key_buffer.start++;
if (key_buffer.start>=KEY_BUFFER_SIZE)
key_buffer.start = 0;
}
} ENDOFUNC(inject_key)
static void handle_code (int scancode, int keycode)
{
in_a_terrupt++;
if (keycode==0) { /* pause */
inject_key(scancode);
pc_key[KEY_PAUSE] ^= TRUE;
} else if (scancode) {
int flag;
if (scancode>=KEY_MODIFIERS) {
flag = modifier_table[scancode - KEY_MODIFIERS];
} else {
flag = 0;
}
if ((char)keycode<0) { /* release */
pc_key[scancode] = FALSE;
if (flag&KB_MODIFIERS) {
key_shifts &= ~flag;
}
} else { /* keypress */
pc_key[scancode] = TRUE;
if (flag&KB_MODIFIERS) {
key_shifts |= flag;
}
if (flag&KB_LED_FLAGS) {
key_shifts ^= flag;
update_leds(key_shifts);
}
if (scancode<KEY_MODIFIERS) {
inject_key(scancode);
}
}
}
in_a_terrupt--;
} ENDOFUNC(handle_code)
static __inline__ void satisfy (void)
{
__asm__("\n\
inb $0x61, %%al \n\
movb %%al, %%ah \n\
orb $0x80, %%al \n\
outb %%al, $0x61 \n\
xchgb %%al, %%ah \n\
outb %%al, $0x61 \n\
movb $0x20, %%al \n\
outb %%al, $0x20 \n\
":::"%eax");
}
static int keyboard ()
{
unsigned char temp, scancode;
temp = inportb(0x60);
if (temp<=0xe1) {
if (key_pause_loop) {
if (!--key_pause_loop) handle_code(KEY_PAUSE, 0);
} else
switch (temp) {
case 0xe0:
key_enhanced = TRUE;
break;
case 0xe1:
key_pause_loop = 5;
break;
default:
if (key_enhanced) {
key_enhanced = FALSE;
scancode = hw_to_mycode_ex[temp&0x7f];
} else {
scancode = hw_to_mycode[temp&0x7f];
}
handle_code(scancode, temp);
}
}
if (((temp==0x4F)||(temp==0x53))&&(key_shifts&KB_CTRL_FLAG)&&(key_shifts&KB_ALT_FLAG)) {
/* Hack alert:
only SIGINT (but not Ctrl-Break)
calls the destructors and will safely clean up
*/
__asm__("\n\
movb $0x79, %%al \n\
call ___djgpp_hw_exception \n\
":::"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
}
satisfy();
return 0;
} ENDOFUNC(keyboard)
int pc_keypressed (void)
{
return (key_buffer.start!=key_buffer.end);
}
int pc_readkey (void)
{
if (keyboard_installed) {
int key;
do {
} while (key_buffer.start==key_buffer.end);
DISABLE();
key = key_buffer.key[key_buffer.start++];
if (key_buffer.start>=KEY_BUFFER_SIZE)
key_buffer.start = 0;
ENABLE();
return key;
} else {
return 0;
}
}
int pc_keydown (int code)
{
return pc_key[code];
}
void pc_remove_keyb (void)
{
if (keyboard_installed) {
int s1, s2, s3;
keyboard_installed = FALSE;
pc_clexit(pc_remove_keyb);
DISABLE();
_farsetsel(__djgpp_dos_sel);
_farnspokew(0x41c, _farnspeekw(0x41a));
s1 = _farnspeekb(0x417) & 0x80;
s2 = _farnspeekb(0x418) & 0xFC;
s3 = _farnspeekb(0x496) & 0xF3;
if (pc_key[KEY_RSHIFT]) { s1 |= 1; }
if (pc_key[KEY_LSHIFT]) { s1 |= 2; }
if (pc_key[KEY_LCONTROL]) { s2 |= 1; s1 |= 4; }
if (pc_key[KEY_ALT]) { s1 |= 8; s2 |= 2; }
if (pc_key[KEY_RCONTROL]) { s1 |= 4; s3 |= 4; }
if (pc_key[KEY_ALTGR]) { s1 |= 8; s3 |= 8; }
if (key_shifts&KB_SCROLOCK_FLAG) s1 |= 16;
if (key_shifts&KB_NUMLOCK_FLAG) s1 |= 32;
if (key_shifts&KB_CAPSLOCK_FLAG) s1 |= 64;
_farnspokeb(0x417, s1);
_farnspokeb(0x418, s2);
_farnspokeb(0x496, s3);
update_leds(key_shifts);
ENABLE();
pc_remove_irq(KEYB_IRQ);
}
}
int pc_install_keyb (void)
{
if (keyboard_installed||pc_install_irq(KEYB_IRQ, keyboard)) {
return -1;
} else {
int s1, s2, s3;
LOCKDATA(key_buffer);
LOCKDATA(key_enhanced);
LOCKDATA(key_pause_loop);
LOCKDATA(key_shifts);
LOCKDATA(leds_ok);
LOCKDATA(in_a_terrupt);
LOCKDATA(pc_key);
LOCKDATA(modifier_table);
LOCKDATA(hw_to_mycode);
LOCKDATA(hw_to_mycode_ex);
LOCKDATA(standard_key_ascii_table);
LOCKDATA(standard_key_capslock_table);
LOCKDATA(standard_key_shift_table);
LOCKDATA(standard_key_control_table);
LOCKDATA(numlock_table);
LOCKFUNC(update_leds);
LOCKFUNC(inject_key);
LOCKFUNC(handle_code);
LOCKFUNC(keyboard);
DISABLE();
_farsetsel(__djgpp_dos_sel);
_farnspokew(0x41c, _farnspeekw(0x41a));
key_shifts = 0;
s1 = _farnspeekb(0x417);
s2 = _farnspeekb(0x418);
s3 = _farnspeekb(0x496);
if (s1&1) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_RSHIFT] = TRUE; }
if (s1&2) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_LSHIFT] = TRUE; }
if (s2&1) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_LCONTROL] = TRUE; }
if (s2&2) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALT] = TRUE; }
if (s3&4) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_RCONTROL] = TRUE; }
if (s3&8) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALTGR] = TRUE; }
if (s1&16) key_shifts |= KB_SCROLOCK_FLAG;
if (s1&32) key_shifts |= KB_NUMLOCK_FLAG;
if (s1&64) key_shifts |= KB_CAPSLOCK_FLAG;
update_leds(key_shifts);
key_enhanced = key_pause_loop = 0;
key_buffer.start = key_buffer.end = 0;
ENABLE();
pc_atexit(pc_remove_keyb);
keyboard_installed = TRUE;
return 0;
}
}

View File

@@ -0,0 +1,258 @@
/*
* PC/HW routine collection v1.0 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <dpmi.h>
#include "pc_hw.h"
#define MOUSE_STACK_SIZE 16384
#define CLEAR_MICKEYS() \
do { \
__asm__ __volatile__ ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \
ox = oy = 0; \
} while (0)
extern void mouse_wrapper (void);
extern void mouse_wrapper_end (void);
static MFUNC mouse_func;
static void *mouse_stack;
static long mouse_callback;
static __dpmi_regs mouse_regs;
static volatile int pc_mouse_x, pc_mouse_y, pc_mouse_b;
static int minx = 0;
static int maxx = 319;
static int miny = 0;
static int maxy = 199;
static int sx = 2;
static int sy = 2;
static int emulat3 = FALSE;
static int ox, oy;
static void mouse (__dpmi_regs *r)
{
int nx = (signed short)r->x.si / sx;
int ny = (signed short)r->x.di / sy;
int dx = nx - ox;
int dy = ny - oy;
ox = nx;
oy = ny;
pc_mouse_b = r->x.bx;
pc_mouse_x = MID(minx, pc_mouse_x + dx, maxx);
pc_mouse_y = MID(miny, pc_mouse_y + dy, maxy);
if (emulat3) {
if ((pc_mouse_b&3)==3) {
pc_mouse_b = 4;
}
}
if (mouse_func) {
mouse_func(pc_mouse_x, pc_mouse_y, pc_mouse_b);
}
} ENDOFUNC(mouse)
void pc_remove_mouse (void)
{
if (mouse_callback) {
pc_clexit(pc_remove_mouse);
__asm__("\n\
movl %%edx, %%ecx \n\
shrl $16, %%ecx \n\
movw $0x0304, %%ax \n\
int $0x31 \n\
movw $0x000c, %%ax \n\
xorl %%ecx, %%ecx \n\
int $0x33 \n\
"::"d"(mouse_callback):"%eax", "%ecx");
mouse_callback = 0;
free((void *)((unsigned long)mouse_stack-MOUSE_STACK_SIZE));
}
}
int pc_install_mouse (void)
{
int buttons;
/* fail if already call-backed */
if (mouse_callback) {
return 0;
}
/* reset mouse and get status */
__asm__("\n\
xorl %%eax, %%eax \n\
int $0x33 \n\
andl %%ebx, %%eax \n\
movl %%eax, %0 \n\
":"=g" (buttons)::"%eax", "%ebx");
if (!buttons) {
return 0;
}
/* lock wrapper */
LOCKDATA(mouse_func);
LOCKDATA(mouse_stack);
LOCKDATA(mouse_callback);
LOCKDATA(mouse_regs);
LOCKDATA(pc_mouse_x);
LOCKDATA(pc_mouse_y);
LOCKDATA(pc_mouse_b);
LOCKDATA(minx);
LOCKDATA(maxx);
LOCKDATA(miny);
LOCKDATA(maxy);
LOCKDATA(sx);
LOCKDATA(sy);
LOCKDATA(emulat3);
LOCKDATA(ox);
LOCKDATA(oy);
LOCKFUNC(mouse);
LOCKFUNC(mouse_wrapper);
/* grab a locked stack */
if ((mouse_stack=pc_malloc(MOUSE_STACK_SIZE))==NULL) {
return 0;
}
/* try to hook a call-back */
__asm__("\n\
pushl %%ds \n\
pushl %%es \n\
movw $0x0303, %%ax \n\
pushl %%ds \n\
pushl %%cs \n\
popl %%ds \n\
popl %%es \n\
int $0x31 \n\
popl %%es \n\
popl %%ds \n\
jc 0f \n\
shll $16, %%ecx \n\
movw %%dx, %%cx \n\
movl %%ecx, %0 \n\
0: \n\
":"=g"(mouse_callback)
:"S" (mouse_wrapper), "D"(&mouse_regs)
:"%eax", "%ecx", "%edx");
if (!mouse_callback) {
free(mouse_stack);
return 0;
}
/* adjust stack */
mouse_stack = (void *)((unsigned long)mouse_stack + MOUSE_STACK_SIZE);
/* install the handler */
mouse_regs.x.ax = 0x000c;
mouse_regs.x.cx = 0x007f;
mouse_regs.x.dx = mouse_callback&0xffff;
mouse_regs.x.es = mouse_callback>>16;
__dpmi_int(0x33, &mouse_regs);
CLEAR_MICKEYS();
emulat3 = buttons<3;
pc_atexit(pc_remove_mouse);
return buttons;
}
MFUNC pc_install_mouse_handler (MFUNC handler)
{
MFUNC old;
if (!mouse_callback && !pc_install_mouse()) {
return NULL;
}
old = mouse_func;
mouse_func = handler;
return old;
}
void pc_mouse_area (int x1, int y1, int x2, int y2)
{
minx = x1;
maxx = x2;
miny = y1;
maxy = y2;
}
void pc_mouse_speed (int xspeed, int yspeed)
{
DISABLE();
sx = MAX(1, xspeed);
sy = MAX(1, yspeed);
ENABLE();
}
int pc_query_mouse (int *x, int *y)
{
*x = pc_mouse_x;
*y = pc_mouse_y;
return pc_mouse_b;
}
void pc_show_mouse (void)
{
/* not implemented */
}
void pc_scare_mouse (void)
{
/* not implemented */
}
void pc_unscare_mouse (void)
{
/* not implemented */
}
__asm__("\n\
.balign 4 \n\
.global _mouse_wrapper \n\
_mouse_wrapper: \n\
cld \n\
lodsl \n\
movl %eax, %es:42(%edi) \n\
addw $4, %es:46(%edi) \n\
pushl %es \n\
movl %ss, %ebx \n\
movl %esp, %esi \n\
movl %cs:___djgpp_ds_alias, %ss \n\
movl %cs:_mouse_stack, %esp \n\
pushl %ss \n\
pushl %ss \n\
popl %es \n\
popl %ds \n\
movl ___djgpp_dos_sel, %fs \n\
pushl %fs \n\
popl %gs \n\
pushl %edi \n\
call _mouse \n\
popl %edi \n\
movl %ebx, %ss \n\
movl %esi, %esp \n\
popl %es \n\
iret \n\
\n\
.balign 4 \n\
.global _mouse_wrapper_end \n\
_mouse_wrapper_end:");

View File

@@ -0,0 +1,158 @@
/*
* PC/HW routine collection v1.0 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <pc.h>
#include "pc_hw.h"
#define TIMER_IRQ 0
#define MAX_TIMERS 8
#define PIT_FREQ 0x1234DD
#define unvolatile(__v, __t) __extension__ ({union { volatile __t __cp; __t __p; } __q; __q.__cp = __v; __q.__p;})
static int timer_installed;
typedef struct {
volatile unsigned int counter, clock_ticks, freq;
volatile PFUNC func;
volatile void *parm;
} TIMER;
TIMER timer_main, timer_func[MAX_TIMERS];
static int timer ()
{
int i;
for (i=0;i<MAX_TIMERS;i++) {
TIMER *t = &timer_func[i];
if (t->func) {
t->clock_ticks += t->counter;
if (t->clock_ticks>=timer_main.counter) {
t->clock_ticks -= timer_main.counter;
t->func(unvolatile(t->parm, void *));
}
}
}
timer_main.clock_ticks += timer_main.counter;
if (timer_main.clock_ticks>=0x10000) {
timer_main.clock_ticks -= 0x10000;
return 1;
} else {
outportb(0x20, 0x20);
return 0;
}
} ENDOFUNC(timer)
void pc_remove_timer (void)
{
if (timer_installed) {
timer_installed = FALSE;
pc_clexit(pc_remove_timer);
DISABLE();
outportb(0x43, 0x34);
outportb(0x40, 0);
outportb(0x40, 0);
ENABLE();
pc_remove_irq(TIMER_IRQ);
}
}
static int install_timer (void)
{
if (timer_installed||pc_install_irq(TIMER_IRQ, timer)) {
return -1;
} else {
LOCKDATA(timer_func);
LOCKDATA(timer_main);
LOCKFUNC(timer);
timer_main.counter = 0x10000;
DISABLE();
outportb(0x43, 0x34);
outportb(0x40, 0);
outportb(0x40, 0);
timer_main.clock_ticks = 0;
ENABLE();
pc_atexit(pc_remove_timer);
timer_installed = TRUE;
return 0;
}
}
static TIMER *find_slot (PFUNC func)
{
int i;
for (i=0;i<MAX_TIMERS;i++) {
if (timer_func[i].func==func) {
return &timer_func[i];
}
}
for (i=0;i<MAX_TIMERS;i++) {
if (!timer_func[i].func) {
return &timer_func[i];
}
}
return NULL;
}
int pc_install_int (PFUNC func, void *parm, unsigned int freq)
{
int i;
TIMER *t;
if (!timer_installed) {
if (install_timer()) {
return -1;
}
}
if ((t=find_slot(func))!=NULL) {
unsigned int new_counter = PIT_FREQ / freq;
DISABLE();
t->func = func;
t->parm = parm;
t->freq = freq;
t->clock_ticks = 0;
if (new_counter < timer_main.counter) {
for (i=0;i<MAX_TIMERS;i++) {
if (timer_func[i].func) {
timer_func[i].counter = new_counter * timer_func[i].freq / freq;
}
}
outportb(0x43, 0x34);
outportb(0x40, (unsigned char)new_counter);
outportb(0x40, (unsigned char)(new_counter>>8));
timer_main.clock_ticks = 0;
timer_main.counter = new_counter;
timer_main.freq = freq;
} else {
t->counter = PIT_FREQ * freq / (timer_main.freq * timer_main.freq);
}
ENABLE();
return 0;
}
return -1;
}

152
src/glut/dos/callback.c Normal file
View File

@@ -0,0 +1,152 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
#include "internal.h"
void APIENTRY glutDisplayFunc (void (GLUTCALLBACK *func) (void))
{
display_func = func;
}
void APIENTRY glutReshapeFunc (void (GLUTCALLBACK *func) (int width, int height))
{
reshape_func = func;
}
void APIENTRY glutKeyboardFunc (void (GLUTCALLBACK *func) (unsigned char key, int x, int y))
{
keyboard_func = func;
}
void APIENTRY glutMouseFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))
{
mouse_func = func;
}
void APIENTRY glutMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
{
motion_func = func;
}
void APIENTRY glutPassiveMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
{
passive_motion_func = func;
}
void APIENTRY glutEntryFunc (void (GLUTCALLBACK *func) (int state))
{
entry_func = func;
}
void APIENTRY glutVisibilityFunc (void (GLUTCALLBACK *func) (int state))
{
visibility_func = func;
}
void APIENTRY glutIdleFunc (void (GLUTCALLBACK *func) (void))
{
idle_func = func;
}
void APIENTRY glutTimerFunc (unsigned int millis, void (GLUTCALLBACK *func) (int value), int value)
{
}
void APIENTRY glutMenuStateFunc (void (GLUTCALLBACK *func) (int state))
{
menu_state_func = func;
}
void APIENTRY glutSpecialFunc (void (GLUTCALLBACK *func) (int key, int x, int y))
{
special_func = func;
}
void APIENTRY glutSpaceballMotionFunc (void (GLUTCALLBACK *func) (int x, int y, int z))
{
}
void APIENTRY glutSpaceballRotateFunc (void (GLUTCALLBACK *func) (int x, int y, int z))
{
}
void APIENTRY glutSpaceballButtonFunc (void (GLUTCALLBACK *func) (int button, int state))
{
}
void APIENTRY glutButtonBoxFunc (void (GLUTCALLBACK *func) (int button, int state))
{
}
void APIENTRY glutDialsFunc (void (GLUTCALLBACK *func) (int dial, int value))
{
}
void APIENTRY glutTabletMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
{
}
void APIENTRY glutTabletButtonFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))
{
}
void APIENTRY glutMenuStatusFunc (void (GLUTCALLBACK *func) (int status, int x, int y))
{
}
void APIENTRY glutOverlayDisplayFunc (void (GLUTCALLBACK *func) (void))
{
}
void APIENTRY glutWindowStatusFunc (void (GLUTCALLBACK *func) (int state))
{
}

46
src/glut/dos/color.c Normal file
View File

@@ -0,0 +1,46 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
void APIENTRY glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue)
{
}
GLfloat APIENTRY glutGetColor (int ndx, int component)
{
return 0.0;
}
void APIENTRY glutCopyColormap (int win)
{
}

52
src/glut/dos/font.c Normal file
View File

@@ -0,0 +1,52 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
void APIENTRY glutBitmapCharacter (void *font, int character)
{
}
int APIENTRY glutBitmapWidth (void *font, int character)
{
return 0;
}
void APIENTRY glutStrokeCharacter (void *font, int character)
{
}
int APIENTRY glutStrokeWidth (void *font, int character)
{
return 0;
}

61
src/glut/dos/globals.c Normal file
View File

@@ -0,0 +1,61 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
#include "internal.h"
GLenum g_display_mode = 0;
GLuint g_width = DEFAULT_WIDTH;
GLuint g_height = DEFAULT_HEIGHT;
GLint g_mouse = GL_FALSE;
GLboolean g_redisplay = GL_FALSE;
GLint g_xpos = 0;
GLint g_ypos = 0;
void (GLUTCALLBACK *display_func) (void) = NULL;
void (GLUTCALLBACK *reshape_func) (int width, int height) = NULL;
void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y) = NULL;
void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y) = NULL;
void (GLUTCALLBACK *motion_func) (int x, int y) = NULL;
void (GLUTCALLBACK *passive_motion_func) (int x, int y) = NULL;
void (GLUTCALLBACK *entry_func) (int state) = NULL;
void (GLUTCALLBACK *visibility_func) (int state) = NULL;
void (GLUTCALLBACK *idle_func) (void) = NULL;
void (GLUTCALLBACK *menu_state_func) (int state) = NULL;
void (GLUTCALLBACK *special_func) (int key, int x, int y) = NULL;
void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z) = NULL;
void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z) = NULL;
void (GLUTCALLBACK *spaceball_button_func) (int button, int state) = NULL;
void (GLUTCALLBACK *button_box_func) (int button, int state) = NULL;
void (GLUTCALLBACK *dials_func) (int dial, int value) = NULL;
void (GLUTCALLBACK *tablet_motion_func) (int x, int y) = NULL;
void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y) = NULL;
void (GLUTCALLBACK *menu_status_func) (int status, int x, int y) = NULL;
void (GLUTCALLBACK *overlay_display_func) (void) = NULL;
void (GLUTCALLBACK *window_status_func) (int state) = NULL;

160
src/glut/dos/init.c Normal file
View File

@@ -0,0 +1,160 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
#include "internal.h"
void APIENTRY glutInit (int *argcp, char **argv)
{
glutGet(GLUT_ELAPSED_TIME);
}
void APIENTRY glutInitDisplayMode (unsigned int mode)
{
g_display_mode = mode;
pc_install_keyb();
g_mouse = pc_install_mouse();
}
void APIENTRY glutInitWindowPosition (int x, int y)
{
g_xpos = x;
g_ypos = y;
}
void APIENTRY glutInitWindowSize (int width, int height)
{
g_width = width;
g_height = height;
}
void APIENTRY glutMainLoop (void)
{
GLboolean idle;
static int old_mouse_x = 0;
static int old_mouse_y = 0;
static int old_mouse_b = 0;
glutPostRedisplay();
if (reshape_func) reshape_func(g_width, g_height);
if (visibility_func) visibility_func(GLUT_VISIBLE);
if (g_mouse) pc_show_mouse();
while (GL_TRUE) {
idle = GL_TRUE;
if (g_redisplay && display_func) {
idle = GL_FALSE;
g_redisplay = GL_FALSE;
if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_scare_mouse();
display_func();
if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_unscare_mouse();
}
if (pc_keypressed()) {
int key;
idle = GL_FALSE;
key = pc_readkey();
switch (key>>16) {
case KEY_F1: if (special_func) special_func(GLUT_KEY_F1, 0, 0); break;
case KEY_F2: if (special_func) special_func(GLUT_KEY_F2, 0, 0); break;
case KEY_F3: if (special_func) special_func(GLUT_KEY_F3, 0, 0); break;
case KEY_F4: if (special_func) special_func(GLUT_KEY_F4, 0, 0); break;
case KEY_F5: if (special_func) special_func(GLUT_KEY_F5, 0, 0); break;
case KEY_F6: if (special_func) special_func(GLUT_KEY_F6, 0, 0); break;
case KEY_F7: if (special_func) special_func(GLUT_KEY_F7, 0, 0); break;
case KEY_F8: if (special_func) special_func(GLUT_KEY_F8, 0, 0); break;
case KEY_F9: if (special_func) special_func(GLUT_KEY_F9, 0, 0); break;
case KEY_F10: if (special_func) special_func(GLUT_KEY_F10, 0, 0); break;
case KEY_F11: if (special_func) special_func(GLUT_KEY_F11, 0, 0); break;
case KEY_F12: if (special_func) special_func(GLUT_KEY_F12, 0, 0); break;
case KEY_LEFT: if (special_func) special_func(GLUT_KEY_LEFT, 0, 0); break;
case KEY_UP: if (special_func) special_func(GLUT_KEY_UP, 0, 0); break;
case KEY_RIGHT: if (special_func) special_func(GLUT_KEY_RIGHT, 0, 0); break;
case KEY_DOWN: if (special_func) special_func(GLUT_KEY_DOWN, 0, 0); break;
case KEY_PGUP: if (special_func) special_func(GLUT_KEY_PAGE_UP, 0, 0); break;
case KEY_PGDN: if (special_func) special_func(GLUT_KEY_PAGE_DOWN, 0, 0); break;
case KEY_HOME: if (special_func) special_func(GLUT_KEY_HOME, 0, 0); break;
case KEY_END: if (special_func) special_func(GLUT_KEY_END, 0, 0); break;
case KEY_INSERT: if (special_func) special_func(GLUT_KEY_INSERT, 0, 0); break;
default: if (keyboard_func) keyboard_func(key & 0xFF, 0, 0);
}
}
if (g_mouse) {
int mouse_x;
int mouse_y;
int mouse_b;
mouse_b = pc_query_mouse(&mouse_x, &mouse_y);
if (motion_func && ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y))) {
idle = GL_FALSE;
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
motion_func(old_mouse_x, old_mouse_y);
}
if (mouse_func && (mouse_b != old_mouse_b)) {
int new_mouse_b = mouse_b;
if ((old_mouse_b & 1) && !(new_mouse_b & 1))
mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, mouse_x, mouse_y);
else if (!(old_mouse_b & 1) && (new_mouse_b & 1))
mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
if ((old_mouse_b & 2) && !(new_mouse_b & 2))
mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, mouse_x, mouse_y);
else if (!(old_mouse_b & 2) && (new_mouse_b & 2))
mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
if ((old_mouse_b & 4) && !(new_mouse_b & 4))
mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, mouse_x, mouse_y);
else if (!(old_mouse_b & 3) && (new_mouse_b & 4))
mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
idle = GL_FALSE;
old_mouse_b = new_mouse_b;
}
}
if (idle && idle_func)
idle_func();
}
}

78
src/glut/dos/internal.h Normal file
View File

@@ -0,0 +1,78 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef INTERNAL_H_included
#define INTERNAL_H_included
#include "GL/glut.h"
#include "pc_hw/pc_hw.h"
#define MAX_WINDOWS 4
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
#define DEFAULT_BPP 16
#define DEPTH_SIZE 16
#define STENCIL_SIZE 8
#define ACCUM_SIZE 16
extern GLenum g_display_mode;
extern GLuint g_width;
extern GLuint g_height;
extern GLint g_mouse;
extern GLboolean g_redisplay;
extern GLint g_xpos;
extern GLint g_ypos;
extern void (GLUTCALLBACK *display_func) (void);
extern void (GLUTCALLBACK *reshape_func) (int width, int height);
extern void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y);
extern void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y);
extern void (GLUTCALLBACK *motion_func) (int x, int y);
extern void (GLUTCALLBACK *passive_motion_func) (int x, int y);
extern void (GLUTCALLBACK *entry_func) (int state);
extern void (GLUTCALLBACK *visibility_func) (int state);
extern void (GLUTCALLBACK *idle_func) (void);
extern void (GLUTCALLBACK *menu_state_func) (int state);
extern void (GLUTCALLBACK *special_func) (int key, int x, int y);
extern void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z);
extern void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z);
extern void (GLUTCALLBACK *spaceball_button_func) (int button, int state);
extern void (GLUTCALLBACK *button_box_func) (int button, int state);
extern void (GLUTCALLBACK *dials_func) (int dial, int value);
extern void (GLUTCALLBACK *tablet_motion_func) (int x, int y);
extern void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y);
extern void (GLUTCALLBACK *menu_status_func) (int status, int x, int y);
extern void (GLUTCALLBACK *overlay_display_func) (void);
extern void (GLUTCALLBACK *window_status_func) (int state);
#endif

86
src/glut/dos/menu.c Normal file
View File

@@ -0,0 +1,86 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
int APIENTRY glutCreateMenu (void (GLUTCALLBACK *func) (int))
{
return 0;
}
void APIENTRY glutDestroyMenu (int menu)
{
}
int APIENTRY glutGetMenu (void)
{
return 0;
}
void APIENTRY glutSetMenu (int menu)
{
}
void APIENTRY glutAddMenuEntry (const char *label, int value)
{
}
void APIENTRY glutAddSubMenu (const char *label, int submenu)
{
}
void APIENTRY glutChangeToMenuEntry (int item, const char *label, int value)
{
}
void APIENTRY glutChangeToSubMenu (int item, const char *label, int submenu)
{
}
void APIENTRY glutRemoveMenuItem (int item)
{
}
void APIENTRY glutAttachMenu (int button)
{
}
void APIENTRY glutDetachMenu (int button)
{
}

598
src/glut/dos/models.c Normal file
View File

@@ -0,0 +1,598 @@
/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
/**
(c) Copyright 1993, Silicon Graphics, Inc.
ALL RIGHTS RESERVED
Permission to use, copy, modify, and distribute this software
for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that
both the copyright notice and this permission notice appear in
supporting documentation, and that the name of Silicon
Graphics, Inc. not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission.
THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
PERFORMANCE OF THIS SOFTWARE.
US Government Users Restricted Rights
Use, duplication, or disclosure by the Government is subject to
restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
(c)(1)(ii) of the Rights in Technical Data and Computer
Software clause at DFARS 252.227-7013 and/or in similar or
successor clauses in the FAR or the DOD or NASA FAR
Supplement. Unpublished-- rights reserved under the copyright
laws of the United States. Contractor/manufacturer is Silicon
Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
94039-7311.
OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
#include <math.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "GL/glut.h"
/* Some <math.h> files do not define M_PI... */
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
static GLUquadricObj *quadObj;
#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); }
static void
initQuadObj(void)
{
quadObj = gluNewQuadric();
/* if (!quadObj)
__glutFatalError("out of memory."); */
}
/* CENTRY */
void APIENTRY
glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_LINE);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}
void APIENTRY
glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}
void APIENTRY
glutWireCone(GLdouble base, GLdouble height,
GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_LINE);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
}
void APIENTRY
glutSolidCone(GLdouble base, GLdouble height,
GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
}
/* ENDCENTRY */
static void
drawBox(GLfloat size, GLenum type)
{
static GLfloat n[6][3] =
{
{-1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{1.0, 0.0, 0.0},
{0.0, -1.0, 0.0},
{0.0, 0.0, 1.0},
{0.0, 0.0, -1.0}
};
static GLint faces[6][4] =
{
{0, 1, 2, 3},
{3, 2, 6, 7},
{7, 6, 5, 4},
{4, 5, 1, 0},
{5, 6, 2, 1},
{7, 4, 0, 3}
};
GLfloat v[8][3];
GLint i;
v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
for (i = 5; i >= 0; i--) {
glBegin(type);
glNormal3fv(&n[i][0]);
glVertex3fv(&v[faces[i][0]][0]);
glVertex3fv(&v[faces[i][1]][0]);
glVertex3fv(&v[faces[i][2]][0]);
glVertex3fv(&v[faces[i][3]][0]);
glEnd();
}
}
/* CENTRY */
void APIENTRY
glutWireCube(GLdouble size)
{
drawBox(size, GL_LINE_LOOP);
}
void APIENTRY
glutSolidCube(GLdouble size)
{
drawBox(size, GL_QUADS);
}
/* ENDCENTRY */
static void
doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings)
{
int i, j;
GLfloat theta, phi, theta1;
GLfloat cosTheta, sinTheta;
GLfloat cosTheta1, sinTheta1;
GLfloat ringDelta, sideDelta;
ringDelta = 2.0 * M_PI / rings;
sideDelta = 2.0 * M_PI / nsides;
theta = 0.0;
cosTheta = 1.0;
sinTheta = 0.0;
for (i = rings - 1; i >= 0; i--) {
theta1 = theta + ringDelta;
cosTheta1 = cos(theta1);
sinTheta1 = sin(theta1);
glBegin(GL_QUAD_STRIP);
phi = 0.0;
for (j = nsides; j >= 0; j--) {
GLfloat cosPhi, sinPhi, dist;
phi += sideDelta;
cosPhi = cos(phi);
sinPhi = sin(phi);
dist = R + r * cosPhi;
glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
}
glEnd();
theta = theta1;
cosTheta = cosTheta1;
sinTheta = sinTheta1;
}
}
/* CENTRY */
void APIENTRY
glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,
GLint nsides, GLint rings)
{
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
doughnut(innerRadius, outerRadius, nsides, rings);
glPopAttrib();
}
void APIENTRY
glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius,
GLint nsides, GLint rings)
{
doughnut(innerRadius, outerRadius, nsides, rings);
}
/* ENDCENTRY */
static GLfloat dodec[20][3];
static void
initDodecahedron(void)
{
GLfloat alpha, beta;
alpha = sqrt(2.0 / (3.0 + sqrt(5.0)));
beta = 1.0 + sqrt(6.0 / (3.0 + sqrt(5.0)) -
2.0 + 2.0 * sqrt(2.0 / (3.0 + sqrt(5.0))));
/* *INDENT-OFF* */
dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta;
dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta;
dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1;
dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1;
dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1;
dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1;
dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1;
dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1;
dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1;
dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1;
dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0;
dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0;
dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0;
dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0;
dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta;
dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta;
dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha;
dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha;
dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha;
dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha;
/* *INDENT-ON* */
}
#define DIFF3(_a,_b,_c) { \
(_c)[0] = (_a)[0] - (_b)[0]; \
(_c)[1] = (_a)[1] - (_b)[1]; \
(_c)[2] = (_a)[2] - (_b)[2]; \
}
static void
crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3])
{
GLfloat p[3]; /* in case prod == v1 or v2 */
p[0] = v1[1] * v2[2] - v2[1] * v1[2];
p[1] = v1[2] * v2[0] - v2[2] * v1[0];
p[2] = v1[0] * v2[1] - v2[0] * v1[1];
prod[0] = p[0];
prod[1] = p[1];
prod[2] = p[2];
}
static void
normalize(GLfloat v[3])
{
GLfloat d;
d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
if (d == 0.0) {
// __glutWarning("normalize: zero length vector");
v[0] = d = 1.0;
}
d = 1 / d;
v[0] *= d;
v[1] *= d;
v[2] *= d;
}
static void
pentagon(int a, int b, int c, int d, int e, GLenum shadeType)
{
GLfloat n0[3], d1[3], d2[3];
DIFF3(dodec[a], dodec[b], d1);
DIFF3(dodec[b], dodec[c], d2);
crossprod(d1, d2, n0);
normalize(n0);
glBegin(shadeType);
glNormal3fv(n0);
glVertex3fv(&dodec[a][0]);
glVertex3fv(&dodec[b][0]);
glVertex3fv(&dodec[c][0]);
glVertex3fv(&dodec[d][0]);
glVertex3fv(&dodec[e][0]);
glEnd();
}
static void
dodecahedron(GLenum type)
{
static int inited = 0;
if (inited == 0) {
inited = 1;
initDodecahedron();
}
pentagon(0, 1, 9, 16, 5, type);
pentagon(1, 0, 3, 18, 7, type);
pentagon(1, 7, 11, 10, 9, type);
pentagon(11, 7, 18, 19, 6, type);
pentagon(8, 17, 16, 9, 10, type);
pentagon(2, 14, 15, 6, 19, type);
pentagon(2, 13, 12, 4, 14, type);
pentagon(2, 19, 18, 3, 13, type);
pentagon(3, 0, 5, 12, 13, type);
pentagon(6, 15, 8, 10, 11, type);
pentagon(4, 17, 8, 15, 14, type);
pentagon(4, 12, 5, 16, 17, type);
}
/* CENTRY */
void APIENTRY
glutWireDodecahedron(void)
{
dodecahedron(GL_LINE_LOOP);
}
void APIENTRY
glutSolidDodecahedron(void)
{
dodecahedron(GL_TRIANGLE_FAN);
}
/* ENDCENTRY */
static void
recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3,
GLenum shadeType)
{
GLfloat q0[3], q1[3];
DIFF3(n1, n2, q0);
DIFF3(n2, n3, q1);
crossprod(q0, q1, q1);
normalize(q1);
glBegin(shadeType);
glNormal3fv(q1);
glVertex3fv(n1);
glVertex3fv(n2);
glVertex3fv(n3);
glEnd();
}
static void
subdivide(GLfloat * v0, GLfloat * v1, GLfloat * v2,
GLenum shadeType)
{
int depth;
GLfloat w0[3], w1[3], w2[3];
GLfloat l;
int i, j, k, n;
depth = 1;
for (i = 0; i < depth; i++) {
for (j = 0; i + j < depth; j++) {
k = depth - i - j;
for (n = 0; n < 3; n++) {
w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth;
w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n])
/ depth;
w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n])
/ depth;
}
l = sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]);
w0[0] /= l;
w0[1] /= l;
w0[2] /= l;
l = sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]);
w1[0] /= l;
w1[1] /= l;
w1[2] /= l;
l = sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]);
w2[0] /= l;
w2[1] /= l;
w2[2] /= l;
recorditem(w1, w0, w2, shadeType);
}
}
}
static void
drawtriangle(int i, GLfloat data[][3], int ndx[][3],
GLenum shadeType)
{
GLfloat *x0, *x1, *x2;
x0 = data[ndx[i][0]];
x1 = data[ndx[i][1]];
x2 = data[ndx[i][2]];
subdivide(x0, x1, x2, shadeType);
}
/* octahedron data: The octahedron produced is centered at the
origin and has radius 1.0 */
static GLfloat odata[6][3] =
{
{1.0, 0.0, 0.0},
{-1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, -1.0, 0.0},
{0.0, 0.0, 1.0},
{0.0, 0.0, -1.0}
};
static int ondex[8][3] =
{
{0, 4, 2},
{1, 2, 4},
{0, 3, 4},
{1, 4, 3},
{0, 2, 5},
{1, 5, 2},
{0, 5, 3},
{1, 3, 5}
};
static void
octahedron(GLenum shadeType)
{
int i;
for (i = 7; i >= 0; i--) {
drawtriangle(i, odata, ondex, shadeType);
}
}
/* CENTRY */
void APIENTRY
glutWireOctahedron(void)
{
octahedron(GL_LINE_LOOP);
}
void APIENTRY
glutSolidOctahedron(void)
{
octahedron(GL_TRIANGLES);
}
/* ENDCENTRY */
/* icosahedron data: These numbers are rigged to make an
icosahedron of radius 1.0 */
#define X .525731112119133606
#define Z .850650808352039932
static GLfloat idata[12][3] =
{
{-X, 0, Z},
{X, 0, Z},
{-X, 0, -Z},
{X, 0, -Z},
{0, Z, X},
{0, Z, -X},
{0, -Z, X},
{0, -Z, -X},
{Z, X, 0},
{-Z, X, 0},
{Z, -X, 0},
{-Z, -X, 0}
};
static int index[20][3] =
{
{0, 4, 1},
{0, 9, 4},
{9, 5, 4},
{4, 5, 8},
{4, 8, 1},
{8, 10, 1},
{8, 3, 10},
{5, 3, 8},
{5, 2, 3},
{2, 7, 3},
{7, 10, 3},
{7, 6, 10},
{7, 11, 6},
{11, 0, 6},
{0, 1, 6},
{6, 1, 10},
{9, 0, 11},
{9, 11, 2},
{9, 2, 5},
{7, 2, 11},
};
static void
icosahedron(GLenum shadeType)
{
int i;
for (i = 19; i >= 0; i--) {
drawtriangle(i, idata, index, shadeType);
}
}
/* CENTRY */
void APIENTRY
glutWireIcosahedron(void)
{
icosahedron(GL_LINE_LOOP);
}
void APIENTRY
glutSolidIcosahedron(void)
{
icosahedron(GL_TRIANGLES);
}
/* ENDCENTRY */
/* tetrahedron data: */
#define T 1.73205080756887729
static GLfloat tdata[4][3] =
{
{T, T, T},
{T, -T, -T},
{-T, T, -T},
{-T, -T, T}
};
static int tndex[4][3] =
{
{0, 1, 3},
{2, 1, 0},
{3, 2, 0},
{1, 2, 3}
};
static void
tetrahedron(GLenum shadeType)
{
int i;
for (i = 3; i >= 0; i--)
drawtriangle(i, tdata, tndex, shadeType);
}
/* CENTRY */
void APIENTRY
glutWireTetrahedron(void)
{
tetrahedron(GL_LINE_LOOP);
}
void APIENTRY
glutSolidTetrahedron(void)
{
tetrahedron(GL_TRIANGLES);
}
/* ENDCENTRY */

60
src/glut/dos/overlay.c Normal file
View File

@@ -0,0 +1,60 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
void APIENTRY glutEstablishOverlay (void)
{
}
void APIENTRY glutRemoveOverlay (void)
{
}
void APIENTRY glutUseLayer (GLenum layer)
{
}
void APIENTRY glutPostOverlayRedisplay (void)
{
}
void APIENTRY glutShowOverlay (void)
{
}
void APIENTRY glutHideOverlay (void)
{
}

70
src/glut/dos/state.c Normal file
View File

@@ -0,0 +1,70 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
#include "internal.h"
#define FREQUENCY 100
static int timer_installed;
static volatile int ticks;
static void ticks_timer (void *p)
{
(void)p;
ticks++;
} ENDOFUNC(ticks_timer)
int APIENTRY glutGet (GLenum type)
{
switch (type) {
case GLUT_WINDOW_RGBA:
return 1;
case GLUT_ELAPSED_TIME:
if (!timer_installed) {
timer_installed = !timer_installed;
LOCKDATA(ticks);
LOCKFUNC(ticks_timer);
pc_install_int(ticks_timer, NULL, FREQUENCY);
}
return ticks*1000/FREQUENCY;
default:
return 0;
}
}
int APIENTRY glutDeviceGet (GLenum type)
{
return 0;
}

212
src/glut/dos/teapot.c Normal file
View File

@@ -0,0 +1,212 @@
/* Copyright (c) Mark J. Kilgard, 1994. */
/**
(c) Copyright 1993, Silicon Graphics, Inc.
ALL RIGHTS RESERVED
Permission to use, copy, modify, and distribute this software
for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that
both the copyright notice and this permission notice appear in
supporting documentation, and that the name of Silicon
Graphics, Inc. not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission.
THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
PERFORMANCE OF THIS SOFTWARE.
US Government Users Restricted Rights
Use, duplication, or disclosure by the Government is subject to
restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
(c)(1)(ii) of the Rights in Technical Data and Computer
Software clause at DFARS 252.227-7013 and/or in similar or
successor clauses in the FAR or the DOD or NASA FAR
Supplement. Unpublished-- rights reserved under the copyright
laws of the United States. Contractor/manufacturer is Silicon
Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
94039-7311.
OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
#include <GL/gl.h>
#include <GL/glu.h>
#include "GL/glut.h"
/* Rim, body, lid, and bottom data must be reflected in x and
y; handle and spout data across the y axis only. */
static int patchdata[][16] =
{
/* rim */
{102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15},
/* body */
{12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27},
{24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40},
/* lid */
{96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
101, 0, 1, 2, 3,},
{0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117},
/* bottom */
{118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
125, 120, 40, 39, 38, 37},
/* handle */
{41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
53, 54, 55, 56},
{53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
28, 65, 66, 67},
/* spout */
{68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83},
{80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95}
};
/* *INDENT-OFF* */
static float cpdata[][3] =
{
{0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0,
-0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125},
{0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375,
0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375,
2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84,
2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875},
{1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75,
1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35},
{0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2,
0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12,
0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225},
{1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225},
{1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0,
-1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5,
-0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3,
2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0,
2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0,
2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8},
{-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3,
-0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3,
1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2,
-0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0,
1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0,
0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66,
0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1},
{2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7,
-0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0,
2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375},
{3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},
{3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},
{2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0,
3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8,
3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4,
-0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0,
2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4,
2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3,
2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4},
{0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425,
-0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425,
0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075},
{0.84, -1.5, 0.075}
};
static float tex[2][2][2] =
{
{ {0, 0},
{1, 0}},
{ {0, 1},
{1, 1}}
};
/* *INDENT-ON* */
static void
teapot(GLint grid, GLdouble scale, GLenum type)
{
float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
long i, j, k, l;
glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_MAP2_TEXTURE_COORD_2);
glPushMatrix();
glRotatef(270.0, 1.0, 0.0, 0.0);
glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
glTranslatef(0.0, 0.0, -1.5);
for (i = 0; i < 10; i++) {
for (j = 0; j < 4; j++) {
for (k = 0; k < 4; k++) {
for (l = 0; l < 3; l++) {
p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
if (l == 1)
q[j][k][l] *= -1.0;
if (i < 6) {
r[j][k][l] =
cpdata[patchdata[i][j * 4 + (3 - k)]][l];
if (l == 0)
r[j][k][l] *= -1.0;
s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
if (l == 0)
s[j][k][l] *= -1.0;
if (l == 1)
s[j][k][l] *= -1.0;
}
}
}
}
glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,
&tex[0][0][0]);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&p[0][0][0]);
glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
glEvalMesh2(type, 0, grid, 0, grid);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&q[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
if (i < 6) {
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&r[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&s[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
}
}
glPopMatrix();
glPopAttrib();
}
/* CENTRY */
void APIENTRY
glutSolidTeapot(GLdouble scale)
{
teapot(7, scale, GL_FILL);
}
void APIENTRY
glutWireTeapot(GLdouble scale)
{
teapot(10, scale, GL_LINE);
}
/* ENDCENTRY */

217
src/glut/dos/window.c Normal file
View File

@@ -0,0 +1,217 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
#include "GL/dmesa.h"
#include "internal.h"
static int window;
static DMesaVisual visual = NULL;
static DMesaContext context = NULL;
static DMesaBuffer buffer[MAX_WINDOWS];
static void clean (void)
{
int i;
for (i=0; i<MAX_WINDOWS; i++) {
glutDestroyWindow(i+1);
}
if (context) DMesaDestroyContext(context);
if (visual) DMesaDestroyVisual(visual);
pc_close_stdout();
pc_close_stderr();
}
int APIENTRY glutCreateWindow (const char *title)
{
int i;
if (!visual) {
int screen_w = DEFAULT_WIDTH;
int screen_h = DEFAULT_HEIGHT;
if ((g_width<=640) && (g_height<=480)) {
screen_w = 640;
screen_h = 480;
} else if ((g_width<=800) && (g_height<=600)) {
screen_w = 800;
screen_h = 600;
} else if ((g_width<=1024) && (g_height<=768)) {
screen_w = 1024;
screen_h = 768;
}
if ((visual=DMesaCreateVisual(screen_w, screen_h, DEFAULT_BPP,
g_display_mode & GLUT_DOUBLE,
g_display_mode & GLUT_DEPTH ?DEPTH_SIZE :0,
g_display_mode & GLUT_STENCIL?STENCIL_SIZE:0,
g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {
return 0;
}
if ((context=DMesaCreateContext(visual, NULL))==NULL) {
DMesaDestroyVisual(visual);
return 0;
}
pc_open_stdout();
pc_open_stderr();
pc_atexit(clean);
}
for (i=0; i<MAX_WINDOWS; i++) {
if (!buffer[i]) {
DMesaBuffer b;
if ((b=DMesaCreateBuffer(visual, g_xpos, g_ypos, g_width, g_height))==NULL) {
return 0;
}
if (!DMesaMakeCurrent(context, b)) {
DMesaDestroyBuffer(b);
return 0;
}
if (g_mouse) {
pc_mouse_area(g_xpos, g_ypos, g_xpos + g_width - 1, g_ypos + g_height - 1);
}
buffer[window = i] = b;
return i+1;
}
}
return 0;
}
int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
{
return GL_FALSE;
}
void APIENTRY glutDestroyWindow (int win)
{
if (buffer[win-1]) {
DMesaDestroyBuffer(buffer[win-1]);
buffer[win-1] = NULL;
}
}
void APIENTRY glutPostRedisplay (void)
{
g_redisplay = GL_TRUE;
}
void APIENTRY glutSwapBuffers (void)
{
if (g_mouse) pc_scare_mouse();
DMesaSwapBuffers(buffer[window]);
if (g_mouse) pc_unscare_mouse();
}
int APIENTRY glutGetWindow (void)
{
return window + 1;
}
void APIENTRY glutSetWindow (int win)
{
window = win - 1;
}
void APIENTRY glutSetWindowTitle (const char *title)
{
}
void APIENTRY glutSetIconTitle (const char *title)
{
}
void APIENTRY glutPositionWindow (int x, int y)
{
if (DMesaViewport(buffer[window], x, y, g_width, g_height)) {
g_xpos = x;
g_ypos = y;
}
}
void APIENTRY glutReshapeWindow (int width, int height)
{
if (DMesaViewport(buffer[window], g_xpos, g_ypos, width, height)) {
g_width = width;
g_height = height;
if (reshape_func) {
reshape_func(width, height);
} else {
glViewport(0, 0, width, height);
}
}
}
void APIENTRY glutPopWindow (void)
{
}
void APIENTRY glutPushWindow (void)
{
}
void APIENTRY glutIconifyWindow (void)
{
}
void APIENTRY glutShowWindow (void)
{
}
void APIENTRY glutHideWindow (void)
{
}

View File

@@ -238,11 +238,6 @@ int glutCreateWindow(const char *title)
gt = (rgb) ? __glut_gt_rgb : __glut_gt_index;
__glut_ctx = GGIMesaCreateContext();
if (__glut_ctx == NULL)
ggiPanic("Can't create mesa-context\n");
__glut_vis = ggiOpen(NULL);
if (__glut_vis == NULL)
{
@@ -261,20 +256,27 @@ int glutCreateWindow(const char *title)
/* return GL_FALSE; */
}
ggiGetMode(__glut_vis, &mode);
if (GGIMesaSetVisual(__glut_ctx, __glut_vis, rgb, frames > 1) < 0)
if (ggiMesaExtendVisual(__glut_vis, GL_FALSE, GL_FALSE,
16, 0, 0, 0, 0, 0, 1) < 0)
{
ggiPanic("GGIMesaSetVisual failed!\n");
}
__glut_ctx = ggiMesaCreateContext(__glut_vis);
if (__glut_ctx == NULL)
ggiPanic("Can't create mesa-context\n");
ggiGetMode(__glut_vis, &mode);
__glut_width = mode.visible.x;
__glut_height = mode.visible.y;
mousex = mode.visible.x / 2;
mousey = mode.visible.y / 2;
GGIMesaMakeCurrent(__glut_ctx);
ggiMesaMakeCurrent(__glut_ctx, __glut_vis);
if (__glut_reshape)
__glut_reshape(__glut_width, __glut_height);

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.X11,v 1.58.2.2 2001/12/14 16:33:06 kschultz Exp $
# $Id: Makefile.X11,v 1.58.2.4 2002/01/15 20:17:59 brianp Exp $
# Mesa 3-D graphics library
# Version: 4.0.1

View File

@@ -1,4 +1,4 @@
/* $Id: t_dd_dmatmp.h,v 1.10.2.2 2001/12/11 15:12:57 keithw Exp $ */
/* $Id: t_dd_dmatmp.h,v 1.10.2.3 2002/02/12 17:37:27 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -202,7 +202,7 @@ static void TAG(render_line_strip_verts)( GLcontext *ctx,
if (currentsz < 8)
currentsz = dmasz;
for (j = start; j < count - 1; j += nr - 1 ) {
for (j = start; j + 1 < count; j += nr - 1 ) {
nr = MIN2( currentsz, count - j );
EMIT_VERTS( ctx, j, nr );
currentsz = dmasz;
@@ -243,7 +243,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx,
if (currentsz < 8)
currentsz = dmasz;
for ( ; j < count - 1; j += nr - 1 ) {
for ( ; j + 1 < count; j += nr - 1 ) {
nr = MIN2( currentsz, count - j );
EMIT_VERTS( ctx, j, nr );
currentsz = dmasz;
@@ -307,7 +307,7 @@ static void TAG(render_tri_strip_verts)( GLcontext *ctx,
currentsz = GET_CURRENT_VB_MAX_VERTS();
if (currentsz < 8) {
FIRE_VERTICES();
NEW_BUFFER();
currentsz = dmasz;
}
@@ -324,7 +324,7 @@ static void TAG(render_tri_strip_verts)( GLcontext *ctx,
dmasz -= (dmasz & 1);
currentsz -= (currentsz & 1);
for (j = start ; j < count - 2; j += nr - 2 ) {
for (j = start ; j + 2 < count; j += nr - 2 ) {
nr = MIN2( currentsz, count - j );
EMIT_VERTS( ctx, j, nr );
currentsz = dmasz;
@@ -352,11 +352,11 @@ static void TAG(render_tri_fan_verts)( GLcontext *ctx,
INIT(GL_TRIANGLE_FAN);
if (currentsz < 8) {
FIRE_VERTICES();
NEW_BUFFER();
currentsz = dmasz;
}
for (j = start + 1 ; j < count - 1; j += nr - 1 ) {
for (j = start + 1 ; j + 1 < count; j += nr - 1 ) {
nr = MIN2( currentsz, count - j + 1 );
EMIT_VERTS( ctx, start, 1 );
EMIT_VERTS( ctx, j, nr - 1 );
@@ -390,11 +390,11 @@ static void TAG(render_poly_verts)( GLcontext *ctx,
INIT(GL_POLYGON);
if (currentsz < 8) {
FIRE_VERTICES();
NEW_BUFFER();
currentsz = dmasz;
}
for (j = start + 1 ; j < count - 1 ; j += nr - 1 ) {
for (j = start + 1 ; j + 1 < count ; j += nr - 1 ) {
nr = MIN2( currentsz, count - j + 1 );
EMIT_VERTS( ctx, start, 1 );
EMIT_VERTS( ctx, j, nr - 1 );
@@ -430,14 +430,14 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx,
currentsz = GET_CURRENT_VB_MAX_VERTS();
if (currentsz < 8) {
FIRE_VERTICES();
NEW_BUFFER();
currentsz = dmasz;
}
dmasz -= (dmasz & 2);
currentsz -= (currentsz & 2);
for (j = start ; j < count - 3; j += nr - 2 ) {
for (j = start ; j + 3 < count; j += nr - 2 ) {
nr = MIN2( currentsz, count - j );
EMIT_VERTS( ctx, j, nr );
currentsz = dmasz;
@@ -445,7 +445,7 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx,
FINISH;
} else if (HAVE_TRI_STRIPS && ctx->_TriangleCaps & DD_FLATSHADE) {
} else if (HAVE_TRI_STRIPS && (ctx->_TriangleCaps & DD_FLATSHADE)) {
if (TAG(emit_elt_verts)( ctx, start, count )) {
LOCAL_VARS;
int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
@@ -471,7 +471,7 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx,
currentsz = currentsz/6*2;
dmasz = dmasz/6*2;
for (j = start; j < count - 3; j += nr - 2 ) {
for (j = start; j + 3 < count; j += nr - 2 ) {
nr = MIN2( currentsz, count - j );
if (nr >= 4) {
GLint quads = (nr/2)-1;
@@ -519,11 +519,11 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx,
count -= (count-start) & 1;
if (currentsz < 8) {
FIRE_VERTICES();
NEW_BUFFER();
currentsz = dmasz;
}
for (j = start; j < count - 3; j += nr - 2 ) {
for (j = start; j + 3 < count; j += nr - 2 ) {
nr = MIN2( currentsz, count - j );
EMIT_VERTS( ctx, j, nr );
currentsz = dmasz;
@@ -740,7 +740,7 @@ static void TAG(render_line_strip_elts)( GLcontext *ctx,
if (currentsz < 8)
currentsz = dmasz;
for (j = start; j < count - 1; j += nr - 1 ) {
for (j = start; j + 1 < count; j += nr - 1 ) {
nr = MIN2( currentsz, count - j );
TAG(emit_elts)( ctx, elts+j, nr );
NEW_PRIMITIVE();
@@ -776,7 +776,7 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx,
currentsz = GET_CURRENT_VB_MAX_ELTS();
if (currentsz < 8) {
FIRE_VERTICES();
NEW_BUFFER();
currentsz = dmasz;
}
@@ -785,7 +785,7 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx,
currentsz--;
dmasz--;
for ( ; j < count - 1; j += nr - 1 ) {
for ( ; j + 1 < count; j += nr - 1 ) {
nr = MIN2( currentsz, count - j );
/* NEW_PRIMITIVE(); */
TAG(emit_elts)( ctx, elts+j, nr );
@@ -858,7 +858,7 @@ static void TAG(render_tri_strip_elts)( GLcontext *ctx,
currentsz = GET_CURRENT_VB_MAX_ELTS();
if (currentsz < 8) {
FIRE_VERTICES();
NEW_BUFFER();
currentsz = dmasz;
}
@@ -871,7 +871,7 @@ static void TAG(render_tri_strip_elts)( GLcontext *ctx,
dmasz -= (dmasz & 1);
currentsz -= (currentsz & 1);
for (j = start ; j < count - 2; j += nr - 2 ) {
for (j = start ; j + 2 < count; j += nr - 2 ) {
nr = MIN2( currentsz, count - j );
TAG(emit_elts)( ctx, elts+j, nr );
NEW_PRIMITIVE();
@@ -900,11 +900,11 @@ static void TAG(render_tri_fan_elts)( GLcontext *ctx,
currentsz = GET_CURRENT_VB_MAX_ELTS();
if (currentsz < 8) {
FIRE_VERTICES();
NEW_BUFFER();
currentsz = dmasz;
}
for (j = start + 1 ; j < count - 1; j += nr - 1 ) {
for (j = start + 1 ; j + 1 < count; j += nr - 1 ) {
nr = MIN2( currentsz, count - j + 1 );
TAG(emit_elts)( ctx, elts+start, 1 );
TAG(emit_elts)( ctx, elts+j, nr - 1 );
@@ -936,11 +936,11 @@ static void TAG(render_poly_elts)( GLcontext *ctx,
currentsz = GET_CURRENT_VB_MAX_ELTS();
if (currentsz < 8) {
FIRE_VERTICES();
NEW_BUFFER();
currentsz = dmasz;
}
for (j = start + 1 ; j < count - 1 ; j += nr - 1 ) {
for (j = start + 1 ; j + 1 < count ; j += nr - 1 ) {
nr = MIN2( currentsz, count - j + 1 );
TAG(emit_elts)( ctx, elts+start, 1 );
TAG(emit_elts)( ctx, elts+j, nr - 1 );
@@ -984,7 +984,7 @@ static void TAG(render_quad_strip_elts)( GLcontext *ctx,
currentsz = currentsz/6*2;
dmasz = dmasz/6*2;
for (j = start; j < count - 3; j += nr - 2 ) {
for (j = start; j + 3 < count; j += nr - 2 ) {
nr = MIN2( currentsz, count - j );
if (nr >= 4)
@@ -1013,7 +1013,7 @@ static void TAG(render_quad_strip_elts)( GLcontext *ctx,
else {
ELT_INIT( GL_TRIANGLE_STRIP );
for (j = start; j < count - 3; j += nr - 2 ) {
for (j = start; j + 3 < count; j += nr - 2 ) {
nr = MIN2( currentsz, count - j );
TAG(emit_elts)( ctx, elts+j, nr );
NEW_PRIMITIVE();
@@ -1054,7 +1054,7 @@ static void TAG(render_quads_elts)( GLcontext *ctx,
if (currentsz < 8)
currentsz = dmasz;
for (j = start; j < count - 3; j += nr - 2 ) {
for (j = start; j + 3 < count; j += nr - 2 ) {
nr = MIN2( currentsz, count - j );
if (nr >= 4)

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
/* $Id: t_dd_vbtmp.h,v 1.14 2001/05/03 16:49:28 keithw Exp $ */
/* $Id: t_dd_vbtmp.h,v 1.14.2.4 2002/06/14 03:49:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.0.3
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -136,6 +136,9 @@ static void TAG(emit)( GLcontext *ctx,
const GLubyte *mask = VB->ClipMask;
int i;
/* fprintf(stderr, "%s(big) importable %d %d..%d\n", */
/* __FUNCTION__, VB->importable_data, start, end); */
if (HAVE_HW_VIEWPORT && HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
(void) s;
coord = VB->ClipPtr->data;
@@ -186,15 +189,28 @@ static void TAG(emit)( GLcontext *ctx,
}
if (DO_SPEC) {
if (VB->SecondaryColorPtr[0]->Type != GL_UNSIGNED_BYTE)
IMPORT_FLOAT_SPEC_COLORS( ctx );
spec = (GLubyte (*)[4])VB->SecondaryColorPtr[0]->Ptr;
spec_stride = VB->SecondaryColorPtr[0]->StrideB;
if (VB->SecondaryColorPtr[0]) {
if (VB->SecondaryColorPtr[0]->Type != GL_UNSIGNED_BYTE)
IMPORT_FLOAT_SPEC_COLORS( ctx );
spec = (GLubyte (*)[4])VB->SecondaryColorPtr[0]->Ptr;
spec_stride = VB->SecondaryColorPtr[0]->StrideB;
} else {
GLubyte tmp[4];
spec = &tmp;
spec_stride = 0;
}
}
if (DO_FOG) {
fog = VB->FogCoordPtr->data;
fog_stride = VB->FogCoordPtr->stride;
if (VB->FogCoordPtr) {
fog = VB->FogCoordPtr->data;
fog_stride = VB->FogCoordPtr->stride;
}
else {
GLfloat tmp = 0;
fog = &tmp;
fog_stride = 0;
}
}
if (VB->importable_data) {
@@ -226,11 +242,13 @@ static void TAG(emit)( GLcontext *ctx,
VIEWPORT_Z(v->v.z, coord[0][2]);
v->v.w = coord[0][3];
}
/* fprintf(stderr, "vert %d: %.2f %.2f %.2f %.2f\n", */
/* i, v->v.x, v->v.y, v->v.z, v->v.w); */
coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
}
if (DO_RGBA) {
if (HAVE_RGBA_COLOR) {
*(GLuint *)&v->v.color = *(GLuint *)&col[0];
*(GLuint *)&v->v.color = LE32_TO_CPU(*(GLuint *)&col[0]);
STRIDE_4UB(col, col_stride);
} else {
v->v.color.blue = col[0][2];
@@ -331,7 +349,7 @@ static void TAG(emit)( GLcontext *ctx,
}
if (DO_RGBA) {
if (HAVE_RGBA_COLOR) {
*(GLuint *)&v->v.color = *(GLuint *)&col[i];
*(GLuint *)&v->v.color = LE32_TO_CPU(*(GLuint *)&col[i]);
}
else {
v->v.color.blue = col[i][2];
@@ -417,8 +435,8 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
col_stride = VB->ColorPtr[0]->StrideB;
ASSERT(VB->ColorPtr[0]->Type == GL_UNSIGNED_BYTE);
/* fprintf(stderr, "%s stride %d importable %d\n", */
/* __FUNCTION__, col_stride, VB->importable_data); */
/* fprintf(stderr, "%s(small) importable %x\n", */
/* __FUNCTION__, VB->importable_data); */
/* Pack what's left into a 4-dword vertex. Color is in a different
* place, and there is no 'w' coordinate.
@@ -438,7 +456,7 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
if (DO_RGBA) {
if (HAVE_RGBA_COLOR) {
*(GLuint *)&v[3] = *(GLuint *)col;
*(GLuint *)&v[3] = LE32_TO_CPU(*(GLuint *)col);
}
else {
GLubyte *b = (GLubyte *)&v[3];
@@ -449,6 +467,8 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
}
STRIDE_4UB( col, col_stride );
}
/* fprintf(stderr, "vert %d: %.2f %.2f %.2f %x\n", */
/* i, v[0], v[1], v[2], *(int *)&v[3]); */
}
}
else {
@@ -460,7 +480,7 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
}
if (DO_RGBA) {
if (HAVE_RGBA_COLOR) {
*(GLuint *)&v[3] = *(GLuint *)&col[i];
*(GLuint *)&v[3] = LE32_TO_CPU(*(GLuint *)&col[i]);
}
else {
GLubyte *b = (GLubyte *)&v[3];
@@ -470,6 +490,9 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
b[3] = col[i][3];
}
}
/* fprintf(stderr, "vert %d: %.2f %.2f %.2f %x\n", */
/* i, v[0], v[1], v[2], *(int *)&v[3]); */
}
}
}
@@ -502,7 +525,7 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
for (i=start; i < end; i++, STRIDE_F(v, stride)) {
if (HAVE_RGBA_COLOR) {
*(GLuint *)v = *(GLuint *)col[0];
*(GLuint *)v = LE32_TO_CPU(*(GLuint *)col[0]);
}
else {
GLubyte *b = (GLubyte *)v;
@@ -624,7 +647,7 @@ static void TAG(interp)( GLcontext *ctx,
if ((HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) ||
DO_FOG || DO_SPEC || DO_TEX0 || DO_TEX1 ||
DO_TEX2 || DO_TEX3) {
DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES) {
dst->v.w = w;
@@ -634,12 +657,12 @@ static void TAG(interp)( GLcontext *ctx,
INTERP_UB( t, dst->ub4[4][3], out->ub4[4][3], in->ub4[4][3] );
if (DO_SPEC) {
INTERP_UB( t, dst->ub4[5][0], out->ub4[5][0], in->ub4[5][0] );
INTERP_UB( t, dst->ub4[5][1], out->ub4[5][1], in->ub4[5][1] );
INTERP_UB( t, dst->ub4[5][2], out->ub4[5][2], in->ub4[5][2] );
INTERP_UB( t, dst->v.specular.red, out->v.specular.red, in->v.specular.red );
INTERP_UB( t, dst->v.specular.green, out->v.specular.green, in->v.specular.green );
INTERP_UB( t, dst->v.specular.blue, out->v.specular.blue, in->v.specular.blue );
}
if (DO_FOG) {
INTERP_UB( t, dst->ub4[5][3], out->ub4[5][3], in->ub4[5][3] );
INTERP_UB( t, dst->v.specular.alpha, out->v.specular.alpha, in->v.specular.alpha );
}
if (DO_TEX0) {
if (DO_PTEX) {
@@ -729,7 +752,7 @@ static void TAG(init)( void )
if (DO_SPEC)
setup_tab[IND].copy_pv = copy_pv_rgba4_spec5;
else if (HAVE_HW_DIVIDE || DO_SPEC || DO_FOG || DO_TEX0 || DO_TEX1 ||
DO_TEX2 || DO_TEX3)
DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES)
setup_tab[IND].copy_pv = copy_pv_rgba4;
else
setup_tab[IND].copy_pv = copy_pv_rgba3;

View File

@@ -1,10 +1,10 @@
/* $Id: t_dd_vertex.h,v 1.9 2001/09/23 15:19:16 keithw Exp $ */
/* $Id: t_dd_vertex.h,v 1.9.2.3 2002/06/14 03:49:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.0.3
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -33,17 +33,19 @@ typedef struct {
#ifdef COLOR_IS_RGBA
typedef struct {
GLubyte red;
GLubyte green;
GLubyte blue;
GLubyte alpha;
#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
GLubyte alpha, blue, green, red;
#else
GLubyte red, green, blue, alpha;
#endif
} TAG(_color_t);
#else
typedef struct {
GLubyte blue;
GLubyte green;
GLubyte red;
GLubyte alpha;
#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
GLubyte alpha, red, green, blue;
#else
GLubyte blue, green, red, alpha;
#endif
} TAG(_color_t);
#endif
@@ -75,9 +77,3 @@ typedef union {
GLubyte ub4[24][4];
} TAG(Vertex), *TAG(VertexPtr);
typedef struct {
GLfloat clip[4];
GLuint mask;
GLuint pad; /* alignment */
TAG(Vertex) v;
} TAG(TnlVertex), *TAG(TnlVertexPtr);

View File

@@ -1,119 +0,0 @@
# DO NOT DELETE
accum.obj: accum.h types.h ..\include\GL\gl.h config.h fixed.h dd.h context.h
accum.obj: dlist.h macros.h
alpha.obj: alpha.h types.h ..\include\GL\gl.h config.h fixed.h dd.h context.h
alpha.obj: dlist.h macros.h
alphabuf.obj: alphabuf.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
alphabuf.obj: context.h macros.h
api1.obj: api.h bitmap.h types.h ..\include\GL\gl.h config.h fixed.h dd.h context.h
api1.obj: eval.h image.h macros.h matrix.h teximage.h
api2.obj: api.h bitmap.h types.h ..\include\GL\gl.h config.h fixed.h dd.h context.h
api2.obj: eval.h image.h macros.h matrix.h teximage.h
attrib.obj: attrib.h types.h ..\include\GL\gl.h config.h fixed.h dd.h context.h
attrib.obj: draw.h dlist.h macros.h
bitmap.obj: bitmap.h types.h ..\include\GL\gl.h config.h fixed.h dd.h context.h
bitmap.obj: feedback.h image.h macros.h pb.h
blend.obj: alphabuf.h types.h ..\include\GL\gl.h config.h fixed.h dd.h blend.h
blend.obj: context.h dlist.h macros.h pb.h span.h
bresenhm.obj: bresenhm.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
clip.obj: clip.h types.h ..\include\GL\gl.h config.h fixed.h dd.h context.h
clip.obj: dlist.h macros.h matrix.h vb.h xform.h
context.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h depth.h
context.obj: draw.h eval.h light.h lines.h dlist.h macros.h pb.h points.h
context.obj: pointers.h triangle.h teximage.h texobj.h texture.h vb.h vertex.h
copypix.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
copypix.obj: copypix.h depth.h feedback.h dlist.h macros.h pixel.h span.h
copypix.obj: stencil.h
depth.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h depth.h
depth.obj: dlist.h macros.h
dlist.obj: accum.h types.h ..\include\GL\gl.h config.h fixed.h dd.h alpha.h
dlist.obj: attrib.h bitmap.h blend.h clip.h context.h copypix.h depth.h draw.h
dlist.obj: drawpix.h enable.h eval.h feedback.h fog.h image.h light.h lines.h
dlist.obj: dlist.h logic.h macros.h masking.h matrix.h misc.h pixel.h points.h
dlist.obj: polygon.h scissor.h stencil.h texobj.h teximage.h texture.h vb.h
dlist.obj: vertex.h winpos.h
draw.obj: clip.h types.h ..\include\GL\gl.h config.h fixed.h dd.h context.h
draw.obj: draw.h feedback.h fog.h light.h lines.h dlist.h macros.h matrix.h
draw.obj: pb.h points.h texture.h vb.h xform.h
drawpix.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
drawpix.obj: drawpix.h feedback.h dlist.h macros.h pixel.h span.h stencil.h
enable.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h depth.h
enable.obj: draw.h enable.h light.h dlist.h macros.h stencil.h
eval.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h draw.h
eval.obj: eval.h dlist.h macros.h
feedback.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
feedback.obj: feedback.h dlist.h macros.h
fog.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h fog.h
fog.obj: dlist.h macros.h
get.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h get.h
get.obj: dlist.h macros.h
hash.obj: hash.h
interp.obj: interp.h types.h ..\include\GL\gl.h config.h fixed.h dd.h macros.h
image.obj: image.h types.h ..\include\GL\gl.h config.h fixed.h dd.h macros.h
image.obj: pixel.h
light.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h light.h
light.obj: dlist.h macros.h matrix.h vb.h xform.h
lines.obj: bresenhm.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
lines.obj: context.h feedback.h interp.h lines.h dlist.h macros.h pb.h vb.h
logic.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h dlist.h
logic.obj: logic.h macros.h pb.h
masking.obj: alphabuf.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
masking.obj: context.h macros.h masking.h pb.h
matrix.obj: accum.h types.h ..\include\GL\gl.h config.h fixed.h dd.h alphabuf.h
matrix.obj: context.h depth.h dlist.h macros.h matrix.h stencil.h
misc.obj: accum.h types.h ..\include\GL\gl.h config.h fixed.h dd.h alphabuf.h
misc.obj: context.h depth.h macros.h masking.h misc.h stencil.h
pb.obj: alpha.h types.h ..\include\GL\gl.h config.h fixed.h dd.h alphabuf.h
pb.obj: blend.h depth.h fog.h logic.h macros.h masking.h pb.h scissor.h
pb.obj: stencil.h texture.h
pixel.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h dlist.h
pixel.obj: macros.h pixel.h image.h span.h stencil.h
points.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
points.obj: feedback.h dlist.h macros.h pb.h span.h vb.h
pointers.obj: accum.h types.h ..\include\GL\gl.h config.h fixed.h dd.h alpha.h
pointers.obj: attrib.h bitmap.h blend.h clip.h context.h copypix.h depth.h
pointers.obj: draw.h drawpix.h enable.h eval.h feedback.h fog.h get.h light.h
pointers.obj: lines.h dlist.h logic.h macros.h masking.h matrix.h misc.h
pointers.obj: pixel.h points.h polygon.h readpix.h scissor.h stencil.h
pointers.obj: teximage.h texobj.h texture.h varray.h vb.h vertex.h winpos.h
polygon.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
polygon.obj: macros.h polygon.h
readpix.obj: alphabuf.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
readpix.obj: context.h depth.h feedback.h dlist.h macros.h image.h readpix.h
readpix.obj: span.h stencil.h
scissor.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
scissor.obj: macros.h dlist.h scissor.h
span.obj: alpha.h types.h ..\include\GL\gl.h config.h fixed.h dd.h alphabuf.h
span.obj: blend.h depth.h fog.h logic.h macros.h masking.h scissor.h span.h
span.obj: stencil.h texture.h
stencil.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h dlist.h
stencil.obj: macros.h pb.h stencil.h
teximage.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
teximage.obj: image.h macros.h pixel.h span.h teximage.h
texobj.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h macros.h
texobj.obj: teximage.h texobj.h
texture.obj: context.h types.h ..\include\GL\gl.h config.h fixed.h dd.h dlist.h
texture.obj: macros.h pb.h teximage.h texture.h
triangle.obj: depth.h types.h ..\include\GL\gl.h config.h fixed.h dd.h
triangle.obj: feedback.h macros.h span.h triangle.h vb.h tritemp.h
varray.obj: draw.h types.h ..\include\GL\gl.h config.h fixed.h dd.h context.h
varray.obj: enable.h dlist.h macros.h varray.h vb.h xform.h
vb.obj: types.h ..\include\GL\gl.h config.h fixed.h dd.h vb.h
vertex.obj: draw.h types.h ..\include\GL\gl.h config.h fixed.h dd.h light.h
vertex.obj: dlist.h macros.h vb.h vertex.h
winpos.obj: ..\include\GL\gl.h draw.h types.h config.h fixed.h dd.h dlist.h
winpos.obj: macros.h winpos.h
xform.obj: types.h ..\include\GL\gl.h config.h fixed.h dd.h xform.h
glx.obj: ..\include\GL\gl.h ..\include\GL\glx.h ..\include\GL\xmesa.h context.h
glx.obj: types.h config.h fixed.h dd.h macros.h xmesaP.h
osmesa.obj: ..\include\GL\osmesa.h ..\include\GL\gl.h context.h types.h
osmesa.obj: config.h fixed.h dd.h depth.h macros.h matrix.h vb.h tritemp.h
xfonts.obj: ..\include\GL\gl.h ..\include\GL\xmesa.h macros.h xmesaP.h types.h
xfonts.obj: config.h fixed.h dd.h context.h
xmesa1.obj: ..\include\GL\xmesa.h ..\include\GL\gl.h xmesaP.h types.h config.h
xmesa1.obj: fixed.h dd.h context.h macros.h matrix.h
xmesa2.obj: ..\include\GL\xmesa.h ..\include\GL\gl.h macros.h types.h config.h
xmesa2.obj: fixed.h dd.h xmesaP.h
xmesa3.obj: bresenhm.h types.h ..\include\GL\gl.h config.h fixed.h dd.h depth.h
xmesa3.obj: interp.h macros.h vb.h xmesaP.h ..\include\GL\xmesa.h tritemp.h

View File

@@ -0,0 +1,927 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* DOS/DJGPP device driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include "glheader.h"
#include "context.h"
#include "GL/dmesa.h"
#include "extensions.h"
#include "macros.h"
#include "matrix.h"
#include "mmath.h"
#include "texformat.h"
#include "texstore.h"
#include "array_cache/acache.h"
#include "swrast/s_context.h"
#include "swrast/s_depth.h"
#include "swrast/s_lines.h"
#include "swrast/s_triangle.h"
#include "swrast/s_trispan.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
#endif
#include "video.h"
/*
* In C++ terms, this class derives from the GLvisual class.
* Add system-specific fields to it.
*/
struct dmesa_visual {
GLvisual *gl_visual;
GLboolean db_flag; /* double buffered? */
GLboolean rgb_flag; /* RGB mode? */
GLuint depth; /* bits per pixel (1, 8, 24, etc) */
};
/*
* In C++ terms, this class derives from the GLframebuffer class.
* Add system-specific fields to it.
*/
struct dmesa_buffer {
GLframebuffer gl_buffer; /* The depth, stencil, accum, etc buffers */
void *the_window; /* your window handle, etc */
int bypp; /* bytes per pixel */
int xpos, ypos; /* position */
int width, height; /* size in pixels */
int bwidth, len; /* bytes in a line, then total */
};
/*
* In C++ terms, this class derives from the GLcontext class.
* Add system-specific fields to it.
*/
struct dmesa_context {
GLcontext *gl_ctx; /* the core library context */
DMesaVisual visual;
DMesaBuffer Buffer;
GLuint ClearColor;
/* etc... */
};
static void dmesa_update_state (GLcontext *ctx, GLuint new_state);
/**********************************************************************/
/***** Read/Write pixels *****/
/**********************************************************************/
#define FLIP(y) (c->Buffer->height - (y) - 1)
#define FLIP2(y) (h - (y) - 1)
static void write_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLubyte rgba[][4], const GLubyte mask[])
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint i, offset;
offset = c->Buffer->width * FLIP(y) + x;
if (mask) {
/* draw some pixels */
for (i=0; i<n; i++, offset++) {
if (mask[i]) {
vl_putpixel(b, offset, vl_mixrgba(rgba[i]));
}
}
} else {
/* draw all pixels */
for (i=0; i<n; i++, offset++) {
vl_putpixel(b, offset, vl_mixrgba(rgba[i]));
}
}
}
static void write_rgb_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLubyte rgb[][3], const GLubyte mask[])
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint i, offset;
offset = c->Buffer->width * FLIP(y) + x;
if (mask) {
/* draw some pixels */
for (i=0; i<n; i++, offset++) {
if (mask[i]) {
vl_putpixel(b, offset, vl_mixrgb(rgb[i]));
}
}
} else {
/* draw all pixels */
for (i=0; i<n; i++, offset++) {
vl_putpixel(b, offset, vl_mixrgb(rgb[i]));
}
}
}
static void write_mono_rgba_span (const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLchan color[4], const GLubyte mask[])
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint i, offset, rgba = vl_mixrgba(color);
offset = c->Buffer->width * FLIP(y) + x;
if (mask) {
/* draw some pixels */
for (i=0; i<n; i++, offset++) {
if (mask[i]) {
vl_putpixel(b, offset, rgba);
}
}
} else {
/* draw all pixels */
for (i=0; i<n; i++, offset++) {
vl_putpixel(b, offset, rgba);
}
}
}
static void read_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
GLubyte rgba[][4])
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint i, offset;
offset = c->Buffer->width * FLIP(y) + x;
/* read all pixels */
for (i=0; i<n; i++, offset++) {
vl_getrgba(b, offset, rgba[i]);
}
}
static void write_rgba_pixels (const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLubyte rgba[][4], const GLubyte mask[])
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint i, w = c->Buffer->width, h = c->Buffer->height;
if (mask) {
/* draw some pixels */
for (i=0; i<n; i++) {
if (mask[i]) {
vl_putpixel(b, FLIP2(y[i])*w + x[i], vl_mixrgba(rgba[i]));
}
}
} else {
/* draw all pixels */
for (i=0; i<n; i++) {
vl_putpixel(b, FLIP2(y[i])*w + x[i], vl_mixrgba(rgba[i]));
}
}
}
static void write_mono_rgba_pixels (const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLchan color[4], const GLubyte mask[])
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint i, w = c->Buffer->width, h = c->Buffer->height, rgba = vl_mixrgba(color);
if (mask) {
/* draw some pixels */
for (i=0; i<n; i++) {
if (mask[i]) {
vl_putpixel(b, FLIP2(y[i])*w + x[i], rgba);
}
}
} else {
/* draw all pixels */
for (i=0; i<n; i++) {
vl_putpixel(b, FLIP2(y[i])*w + x[i], rgba);
}
}
}
static void read_rgba_pixels (const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4], const GLubyte mask[])
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint i, w = c->Buffer->width, h = c->Buffer->height;
if (mask) {
/* read some pixels */
for (i=0; i<n; i++) {
if (mask[i]) {
vl_getrgba(b, FLIP2(y[i])*w + x[i], rgba[i]);
}
}
} else {
/* read all pixels */
for (i=0; i<n; i++) {
vl_getrgba(b, FLIP2(y[i])*w + x[i], rgba[i]);
}
}
}
/**********************************************************************/
/***** Optimized triangle rendering *****/
/**********************************************************************/
/*
* flat, NON-depth-buffered, triangle.
*/
static void tri_rgb_flat (GLcontext *ctx,
const SWvertex *v0,
const SWvertex *v1,
const SWvertex *v2)
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint w = c->Buffer->width, h = c->Buffer->height;
#define SETUP_CODE GLuint rgb = vl_mixrgb(v2->color);
#define RENDER_SPAN(span) \
GLuint i, offset = FLIP2(span.y)*w + span.x; \
for (i = 0; i < span.count; i++, offset++) { \
vl_putpixel(b, offset, rgb); \
}
#include "swrast/s_tritemp.h"
}
/*
* flat, depth-buffered, triangle.
*/
static void tri_rgb_flat_z (GLcontext *ctx,
const SWvertex *v0,
const SWvertex *v1,
const SWvertex *v2)
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint w = c->Buffer->width, h = c->Buffer->height;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE GLuint rgb = vl_mixrgb(v2->color);
#define RENDER_SPAN(span) \
GLuint i, offset = FLIP2(span.y)*w + span.x; \
for (i = 0; i < span.count; i++, offset++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
vl_putpixel(b, offset, rgb); \
zRow[i] = z; \
} \
span.z += span.zStep; \
}
#include "swrast/s_tritemp.h"
}
/*
* smooth, NON-depth-buffered, triangle.
*/
static void tri_rgb_smooth (GLcontext *ctx,
const SWvertex *v0,
const SWvertex *v1,
const SWvertex *v2)
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint w = c->Buffer->width, h = c->Buffer->height;
#define INTERP_RGB 1
#define RENDER_SPAN(span) \
GLuint i, offset = FLIP2(span.y)*w + span.x; \
for (i = 0; i < span.count; i++, offset++) { \
unsigned char rgb[3]; \
rgb[0] = FixedToInt(span.red); \
rgb[1] = FixedToInt(span.green); \
rgb[2] = FixedToInt(span.blue); \
vl_putpixel(b, offset, vl_mixrgb(rgb)); \
span.red += span.redStep; \
span.green += span.greenStep; \
span.blue += span.blueStep; \
}
#include "swrast/s_tritemp.h"
}
/*
* smooth, depth-buffered, triangle.
*/
static void tri_rgb_smooth_z (GLcontext *ctx,
const SWvertex *v0,
const SWvertex *v1,
const SWvertex *v2)
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
void *b = c->Buffer->the_window;
GLuint w = c->Buffer->width, h = c->Buffer->height;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define RENDER_SPAN(span) \
GLuint i, offset = FLIP2(span.y)*w + span.x; \
for (i = 0; i < span.count; i++, offset++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
unsigned char rgb[3]; \
rgb[0] = FixedToInt(span.red); \
rgb[1] = FixedToInt(span.green); \
rgb[2] = FixedToInt(span.blue); \
vl_putpixel(b, offset, vl_mixrgb(rgb)); \
zRow[i] = z; \
} \
span.red += span.redStep; \
span.green += span.greenStep; \
span.blue += span.blueStep; \
span.z += span.zStep; \
}
#include "swrast/s_tritemp.h"
}
/*
* Analyze context state to see if we can provide a fast triangle function
* Otherwise, return NULL.
*/
static swrast_tri_func dmesa_choose_tri_function (GLcontext *ctx)
{
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;
if (ctx->Light.ShadeModel==GL_SMOOTH
&& swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
&& ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
&& ctx->Polygon.StippleFlag==GL_FALSE) {
return tri_rgb_smooth_z;
}
if (ctx->Light.ShadeModel==GL_FLAT
&& swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
&& ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
&& ctx->Polygon.StippleFlag==GL_FALSE) {
return tri_rgb_flat_z;
}
if (swrast->_RasterMask==0 /* no depth test */
&& ctx->Light.ShadeModel==GL_SMOOTH
&& ctx->Polygon.StippleFlag==GL_FALSE) {
return tri_rgb_smooth;
}
if (swrast->_RasterMask==0 /* no depth test */
&& ctx->Light.ShadeModel==GL_FLAT
&& ctx->Polygon.StippleFlag==GL_FALSE) {
return tri_rgb_flat;
}
return (swrast_tri_func)NULL;
}
/* Override for the swrast triangle-selection function. Try to use one
* of our internal line functions, otherwise fall back to the
* standard swrast functions.
*/
static void dmesa_choose_tri (GLcontext *ctx)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (!(swrast->Triangle=dmesa_choose_tri_function(ctx)))
_swrast_choose_triangle(ctx);
}
/**********************************************************************/
/***** Miscellaneous device driver funcs *****/
/**********************************************************************/
static void clear_color (GLcontext *ctx, const GLchan color[4])
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
c->ClearColor = vl_mixrgba(color);
}
static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint x, GLint y, GLint width, GLint height)
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
const GLuint *colorMask = (GLuint *)&ctx->Color.ColorMask;
DMesaBuffer b = c->Buffer;
/*
* Clear the specified region of the buffers indicated by 'mask'
* using the clear color or index as specified by one of the two
* functions above.
* If all==GL_TRUE, clear whole buffer, else just clear region defined
* by x,y,width,height
*/
/* we can't handle color or index masking */
if (*colorMask==0xffffffff) {
if (mask & DD_BACK_LEFT_BIT) {
if (all) {
vl_clear(b->the_window, b->len, c->ClearColor);
} else {
vl_rect(b->the_window, x, y, width, height, c->ClearColor);
}
mask &= ~DD_BACK_LEFT_BIT;
}
}
if (mask) {
_swrast_Clear(ctx, mask, all, x, y, width, height);
}
}
/*
* Set the current reading buffer.
*/
static void set_read_buffer (GLcontext *ctx, GLframebuffer *buffer,
GLenum mode)
{
/*
DMesaContext c = (DMesaContext)ctx->DriverCtx;
dmesa_update_state(ctx);
*/
}
/*
* Set the destination/draw buffer.
*/
static void set_draw_buffer (GLcontext *ctx, GLenum mode)
{
/*
XXX this has to be fixed
*/
}
/*
* Return the width and height of the current buffer.
* If anything special has to been done when the buffer/window is
* resized, do it now.
*/
static void get_buffer_size (GLframebuffer *buffer, GLuint *width, GLuint *height)
{
DMesaBuffer b = (DMesaBuffer)buffer;
*width = b->width;
*height = b->height;
}
static const GLubyte* get_string (GLcontext *ctx, GLenum name)
{
switch (name) {
case GL_RENDERER:
return (const GLubyte *)"Mesa DOS\0DJGPP port (c) Borca Daniel 31-mar-2002";
default:
return NULL;
}
}
/**********************************************************************/
/***** Miscellaneous device driver funcs *****/
/***** Note that these functions are mandatory *****/
/**********************************************************************/
/* OPTIONAL FUNCTION: implements glFinish if possible */
static void finish (GLcontext *ctx)
{
/*
DMesaContext c = (DMesaContext)ctx->DriverCtx;
*/
}
/* OPTIONAL FUNCTION: implements glFlush if possible */
static void flush (GLcontext *ctx)
{
/*
DMesaContext c = (DMesaContext)ctx->DriverCtx;
*/
}
/**********************************************************************/
/**********************************************************************/
#define DMESA_NEW_TRIANGLE (_NEW_POLYGON | \
_NEW_TEXTURE | \
_NEW_LIGHT | \
_NEW_DEPTH | \
_NEW_RENDERMODE | \
_SWRAST_NEW_RASTERMASK)
/* Extend the software rasterizer with our line and triangle
* functions.
*/
static void dmesa_register_swrast_functions (GLcontext *ctx)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
swrast->choose_triangle = dmesa_choose_tri;
swrast->invalidate_triangle |= DMESA_NEW_TRIANGLE;
}
/* Setup pointers and other driver state that is constant for the life
* of a context.
*/
void dmesa_init_pointers (GLcontext *ctx)
{
TNLcontext *tnl;
ctx->Driver.UpdateState = dmesa_update_state;
ctx->Driver.GetString = get_string;
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.Flush = flush;
ctx->Driver.Finish = finish;
/* Software rasterizer pixel paths:
*/
ctx->Driver.Accum = _swrast_Accum;
ctx->Driver.Bitmap = _swrast_Bitmap;
ctx->Driver.Clear = clear;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
/* Software texture functions:
*/
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
ctx->Driver.TexImage2D = _mesa_store_teximage2d;
ctx->Driver.TexImage3D = _mesa_store_teximage3d;
ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
/* Swrast hooks for imaging extensions:
*/
ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
/* Statechange callbacks:
*/
ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ClearColor = clear_color;
/* Initialize the TNL driver interface:
*/
tnl = TNL_CONTEXT(ctx);
tnl->Driver.RunPipeline = _tnl_run_pipeline;
/* Install swsetup for tnl->Driver.Render.*:
*/
_swsetup_Wakeup(ctx);
}
static void dmesa_update_state (GLcontext *ctx, GLuint new_state)
{
DMesaContext c = (DMesaContext)ctx->DriverCtx;
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
/* Initialize all the pointers in the DD struct. Do this whenever */
/* a new context is made current or we change buffers via set_buffer! */
_swrast_InvalidateState(ctx, new_state);
_swsetup_InvalidateState(ctx, new_state);
_ac_InvalidateState(ctx, new_state);
_tnl_InvalidateState(ctx, new_state);
swdd->SetReadBuffer = set_read_buffer;
/* RGB(A) span/pixel functions */
swdd->WriteRGBASpan = write_rgba_span;
swdd->WriteRGBSpan = write_rgb_span;
swdd->WriteMonoRGBASpan = write_mono_rgba_span;
swdd->WriteRGBAPixels = write_rgba_pixels;
swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels;
swdd->ReadRGBASpan = read_rgba_span;
swdd->ReadRGBAPixels = read_rgba_pixels;
}
/**********************************************************************/
/***** DMesa Public API Functions *****/
/**********************************************************************/
/*
* The exact arguments to this function will depend on your window system
*/
DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
GLboolean dbFlag, GLint depthSize,
GLint stencilSize,
GLint accumSize)
{
DMesaVisual v;
GLint redBits, greenBits, blueBits, alphaBits;
if (!dbFlag) {
return NULL;
}
alphaBits = 0;
switch (colDepth) {
case 15:
redBits = 5;
greenBits = 5;
blueBits = 5;
break;
case 16:
redBits = 5;
greenBits = 6;
blueBits = 5;
break;
case 32:
alphaBits = 8;
case 24:
redBits = 8;
greenBits = 8;
blueBits = 8;
break;
default:
return NULL;
}
if (vl_video_init(width, height, colDepth)!=0) {
return NULL;
}
if ((v=(DMesaVisual)calloc(1, sizeof(struct dmesa_visual)))!=NULL) {
/* Create core visual */
v->gl_visual = _mesa_create_visual(colDepth>8, /* rgb */
dbFlag,
GL_FALSE, /* stereo */
redBits,
greenBits,
blueBits,
alphaBits,
0, /* indexBits */
depthSize,
stencilSize,
accumSize, /* accumRed */
accumSize, /* accumGreen */
accumSize, /* accumBlue */
alphaBits?accumSize:0, /* accumAlpha */
1); /* numSamples */
v->depth = colDepth;
v->db_flag = dbFlag;
}
return v;
}
void DMesaDestroyVisual (DMesaVisual v)
{
vl_video_exit(!0);
_mesa_destroy_visual(v->gl_visual);
free(v);
}
DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
GLint xpos, GLint ypos,
GLint width, GLint height)
{
DMesaBuffer b;
if ((b=(DMesaBuffer)calloc(1, sizeof(struct dmesa_buffer)))!=NULL) {
_mesa_initialize_framebuffer(&b->gl_buffer,
visual->gl_visual,
visual->gl_visual->depthBits > 0,
visual->gl_visual->stencilBits > 0,
visual->gl_visual->accumRedBits > 0,
visual->gl_visual->alphaBits > 0);
b->xpos = xpos;
b->ypos = ypos;
b->width = width;
b->height = height;
b->bypp = (visual->depth+7)/8;
}
return b;
}
void DMesaDestroyBuffer (DMesaBuffer b)
{
free(b->the_window);
_mesa_free_framebuffer_data(&b->gl_buffer);
free(b);
}
DMesaContext DMesaCreateContext (DMesaVisual visual,
DMesaContext share)
{
DMesaContext c;
GLboolean direct = GL_FALSE;
if ((c=(DMesaContext)calloc(1, sizeof(struct dmesa_context)))!=NULL) {
c->gl_ctx = _mesa_create_context(visual->gl_visual,
share ? share->gl_ctx : NULL,
(void *)c, direct);
_mesa_enable_sw_extensions(c->gl_ctx);
_mesa_enable_1_3_extensions(c->gl_ctx);
/* you probably have to do a bunch of other initializations here. */
c->visual = visual;
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext(c->gl_ctx);
_ac_CreateContext(c->gl_ctx);
_tnl_CreateContext(c->gl_ctx);
_swsetup_CreateContext(c->gl_ctx);
dmesa_init_pointers(c->gl_ctx);
dmesa_register_swrast_functions(c->gl_ctx);
}
return c;
}
void DMesaDestroyContext (DMesaContext c)
{
_mesa_destroy_context(c->gl_ctx);
free(c);
}
GLboolean DMesaViewport (DMesaBuffer b,
GLint xpos, GLint ypos,
GLint width, GLint height)
{
void *new_window;
if ((new_window=vl_sync_buffer(b->the_window, xpos, ypos, width, height))==NULL) {
return GL_FALSE;
} else {
b->the_window = new_window;
b->xpos = xpos;
b->ypos = ypos;
b->width = width;
b->height = height;
b->bwidth = width * b->bypp;
b->len = b->bwidth * height;
return GL_TRUE;
}
}
/*
* Make the specified context and buffer the current one.
*/
GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
{
if (c&&b) {
if (!DMesaViewport(b, b->xpos, b->ypos, b->width, b->height)) {
return GL_FALSE;
}
c->Buffer = b;
dmesa_update_state(c->gl_ctx, 0);
_mesa_make_current(c->gl_ctx, &b->gl_buffer);
if (c->gl_ctx->Viewport.Width==0) {
/* initialize viewport to window size */
_mesa_Viewport(0, 0, b->width, b->height);
}
} else {
/* Detach */
_mesa_make_current(NULL, NULL);
}
return GL_TRUE;
}
void DMesaSwapBuffers (DMesaBuffer b)
{
/* copy/swap back buffer to front if applicable */
vl_flip(b->the_window, b->bwidth, b->height);
}

File diff suppressed because it is too large Load Diff

123
src/mesa/drivers/dos/dpmi.c Normal file
View File

@@ -0,0 +1,123 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* DOS/DJGPP device driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <dpmi.h>
#include "dpmiint.h"
/* _create_linear_mapping:
* Maps a physical address range into linear memory.
*/
static int _create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size)
{
__dpmi_meminfo meminfo;
if (physaddr >= 0x100000) {
/* map into linear memory */
meminfo.address = physaddr;
meminfo.size = size;
if (__dpmi_physical_address_mapping(&meminfo) != 0)
return -1;
*linear = meminfo.address;
} else {
/* exploit 1 -> 1 physical to linear mapping in low megabyte */
*linear = physaddr;
}
return 0;
}
/* _remove_linear_mapping:
* Frees the DPMI resources being used to map a linear address range.
*/
static void _remove_linear_mapping (unsigned long *linear)
{
__dpmi_meminfo meminfo;
if (*linear) {
if (*linear >= 0x100000) {
meminfo.address = *linear;
__dpmi_free_physical_address_mapping(&meminfo);
}
*linear = 0;
}
}
/* _create_selector:
* Allocates a selector to access a region of linear memory.
*/
int _create_selector (int *segment, unsigned long base, int size)
{
/* allocate an ldt descriptor */
if ((*segment=__dpmi_allocate_ldt_descriptors(1)) < 0) {
*segment = 0;
return -1;
}
/* create the linear mapping */
if (_create_linear_mapping(&base, base, size)) {
__dpmi_free_ldt_descriptor(*segment);
*segment = 0;
return -1;
}
/* set the descriptor base and limit */
__dpmi_set_segment_base_address(*segment, base);
__dpmi_set_segment_limit(*segment, MAX(size-1, 0xFFFF));
return 0;
}
/* _remove_selector:
* Frees a DPMI segment selector.
*/
void _remove_selector (int *segment)
{
if (*segment) {
unsigned long base;
__dpmi_get_segment_base_address(*segment, &base);
_remove_linear_mapping(&base);
__dpmi_free_ldt_descriptor(*segment);
*segment = 0;
}
}

View File

@@ -0,0 +1,48 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* DOS/DJGPP device driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef DPMIINT_H_included
#define DPMIINT_H_included
#ifndef NULL
#define NULL 0
#endif
#ifndef MAX
#define MAX(x, y) (((x)<(y))?(y):(x))
#endif
int _create_selector (int *segment, unsigned long base, int size);
void _remove_selector (int *segment);
#endif

View File

@@ -0,0 +1,623 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* DOS/DJGPP device driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <dpmi.h>
#include <stdlib.h>
#include <string.h>
#include <stubinfo.h>
#include <sys/exceptn.h>
#include <sys/segments.h>
#include <sys/farptr.h>
#include "video.h"
#include "dpmiint.h"
typedef unsigned char word8;
typedef unsigned short word16;
typedef unsigned long word32;
typedef struct vl_mode {
int mode;
int xres, yres;
int scanlen;
int bpp;
} vl_mode;
#define _16_ *(word16 *)&
#define _32_ *(word32 *)&
static int init;
static vl_mode modes[64];
/* card specific: valid forever */
static word16 vesa_ver;
static word32 hw_granularity, hw_linearfb;
static unsigned int gran_shift, gran_mask;
/* based upon mode specific data: valid entire session */
static int video_selector, banked_selector, linear_selector;
static int video_scanlen, video_bypp;
/* valid until next buffer */
static int current_offset, current_delta, current_width;
/* lookup table for scaling 5 bit colors up to 8 bits */
static int _rgb_scale_5[32] =
{
0, 8, 16, 24, 32, 41, 49, 57,
65, 74, 82, 90, 98, 106, 115, 123,
131, 139, 148, 156, 164, 172, 180, 189,
197, 205, 213, 222, 230, 238, 246, 255
};
/* lookup table for scaling 6 bit colors up to 8 bits */
static int _rgb_scale_6[64] =
{
0, 4, 8, 12, 16, 20, 24, 28,
32, 36, 40, 44, 48, 52, 56, 60,
64, 68, 72, 76, 80, 85, 89, 93,
97, 101, 105, 109, 113, 117, 121, 125,
129, 133, 137, 141, 145, 149, 153, 157,
161, 165, 170, 174, 178, 182, 186, 190,
194, 198, 202, 206, 210, 214, 218, 222,
226, 230, 234, 238, 242, 246, 250, 255
};
/*
* virtual clearing
*/
void (*vl_clear) (void *buffer, int len, int color);
#define v_clear15 v_clear16
extern void v_clear16 (void *buffer, int len, int color);
extern void v_clear32 (void *buffer, int len, int color);
__asm__("\n\
.text \n\
.balign 4 \n\
.global _v_clear16 \n\
_v_clear16: \n\
movl 12(%esp), %eax \n\
pushw %ax \n\
pushw %ax \n\
popl %eax \n\
jmp _v_clear_common \n\
.balign 4 \n\
.global _v_clear32 \n\
_v_clear32: \n\
movl 12(%esp), %eax \n\
.balign 4 \n\
_v_clear_common: \n\
movl 8(%esp), %ecx \n\
movl 4(%esp), %edx \n\
shrl $2, %ecx \n\
0: \n\
.balign 4 \n\
movl %eax, (%edx) \n\
addl $4, %edx \n\
decl %ecx \n\
jnz 0b \n\
ret");
extern void v_clear24 (void *buffer, int len, int color);
__asm__("\n\
.text \n\
.balign 4 \n\
.global _v_clear24 \n\
_v_clear24: \n\
movl 8(%esp), %edx \n\
movl $0xaaaaaaab, %eax \n\
mull %edx \n\
movl 12(%esp), %eax \n\
movl %edx, %ecx \n\
movl 4(%esp), %edx \n\
pushl %ebx \n\
shrl %ecx \n\
movb 18(%esp), %bl \n\
.balign 4 \n\
0: \n\
movw %ax, (%edx) \n\
movb %bl, 2(%edx) \n\
addl $3, %edx \n\
decl %ecx \n\
jnz 0b \n\
popl %ebx \n\
ret");
/*
* virtual rectangle clearing
*/
void vl_rect (void *buffer, int x, int y, int width, int height, int color)
{
int offset = y*current_width + x;
int delta = current_width - width;
for (y=0; y<height; y++) {
for (x=0; x<width; x++, offset++) {
vl_putpixel(buffer, offset, color);
}
offset += delta;
}
}
/*
* virtual dumping:
*/
void (*vl_flip) (void *buffer, int width, int height);
extern void b_dump_virtual (void *buffer, int width, int height);
__asm__("\n\
.text \n\
.balign 4 \n\
.global _b_dump_virtual \n\
_b_dump_virtual: \n\
pushl %ebx \n\
pushl %esi \n\
pushl %edi \n\
pushl %ebp \n\
movl _video_selector, %fs \n\
movl 4*4+4+0(%esp), %esi \n\
movl _hw_granularity, %ebp \n\
xorl %edx, %edx \n\
movl _current_offset, %eax \n\
divl %ebp \n\
movl %edx, %edi \n\
pushl %eax \n\
movl %eax, %edx \n\
xorl %ebx, %ebx \n\
movw $0x4f05, %ax \n\
int $0x10 \n\
movl _current_delta, %ebx \n\
movl 5*4+4+4(%esp), %ecx \n\
movl 5*4+4+8(%esp), %edx \n\
shrl $2, %ecx \n\
.balign 4 \n\
0: \n\
pushl %ecx \n\
.balign 4 \n\
1: \n\
cmpl %ebp, %edi \n\
jb 2f \n\
pushl %ebx \n\
pushl %edx \n\
incl 12(%esp) \n\
movw $0x4f05, %ax \n\
movl 12(%esp), %edx \n\
xorl %ebx, %ebx \n\
int $0x10 \n\
popl %edx \n\
popl %ebx \n\
subl %ebp, %edi \n\
2: \n\
movl (%esi), %eax \n\
addl $4, %esi \n\
movl %eax, %fs:(%edi) \n\
addl $4, %edi \n\
decl %ecx \n\
jnz 1b \n\
popl %ecx \n\
addl %ebx, %edi \n\
decl %edx \n\
jnz 0b \n\
popl %eax \n\
popl %ebp \n\
popl %edi \n\
popl %esi \n\
popl %ebx \n\
ret");
extern void l_dump_virtual (void *buffer, int width, int height);
__asm__("\n\
.text \n\
.balign 4 \n\
.global _l_dump_virtual \n\
_l_dump_virtual: \n\
pushl %ebx \n\
pushl %esi \n\
pushl %edi \n\
movl _video_selector, %fs \n\
movl 3*4+4+0(%esp), %esi \n\
movl _current_offset, %edi \n\
movl 3*4+4+4(%esp), %ecx \n\
movl 3*4+4+8(%esp), %edx \n\
movl _current_delta, %ebx \n\
shrl $2, %ecx \n\
.balign 4 \n\
0: \n\
pushl %ecx \n\
.balign 4 \n\
1: \n\
movl (%esi), %eax \n\
addl $4, %esi \n\
movl %eax, %fs:(%edi) \n\
addl $4, %edi \n\
decl %ecx \n\
jnz 1b \n\
popl %ecx \n\
addl %ebx, %edi \n\
decl %edx \n\
jnz 0b \n\
popl %edi \n\
popl %esi \n\
popl %ebx \n\
ret");
/*
* mix RGBA components
*/
int (*vl_mixrgba) (const unsigned char rgba[]);
#define vl_mixrgba15 vl_mixrgb15
#define vl_mixrgba16 vl_mixrgb16
#define vl_mixrgba24 vl_mixrgb24
static int vl_mixrgba32 (const unsigned char rgba[])
{
return (rgba[3]<<24)|(rgba[0]<<16)|(rgba[1]<<8)|(rgba[2]);
}
/*
* mix RGB components
*/
int (*vl_mixrgb) (const unsigned char rgb[]);
static int vl_mixrgb15 (const unsigned char rgb[])
{
return ((rgb[0]>>3)<<10)|((rgb[1]>>3)<<5)|(rgb[2]>>3);
}
static int vl_mixrgb16 (const unsigned char rgb[])
{
return ((rgb[0]>>3)<<11)|((rgb[1]>>2)<<5)|(rgb[2]>>3);
}
#define vl_mixrgb24 vl_mixrgb32
static int vl_mixrgb32 (const unsigned char rgb[])
{
return (rgb[0]<<16)|(rgb[1]<<8)|(rgb[2]);
}
/*
* vl_putpixel*
*/
void (*vl_putpixel) (void *buffer, int offset, int color);
#define v_putpixel15 v_putpixel16
extern void v_putpixel16 (void *buffer, int offset, int color);
__asm__("\n\
.text \n\
.balign 4 \n\
.global _v_putpixel16 \n\
_v_putpixel16: \n\
movl 8(%esp), %edx \n\
shll %edx \n\
movl 12(%esp), %eax \n\
addl 4(%esp), %edx \n\
movw %ax, (%edx) \n\
ret");
extern void v_putpixel24 (void *buffer, int offset, int color);
__asm__("\n\
.text \n\
.balign 4 \n\
.global _v_putpixel24 \n\
_v_putpixel24: \n\
movl 8(%esp), %edx \n\
leal (%edx, %edx, 2), %edx \n\
movl 12(%esp), %eax \n\
addl 4(%esp), %edx \n\
movw %ax, (%edx) \n\
shrl $16, %eax \n\
movb %al, 2(%edx) \n\
ret");
extern void v_putpixel32 (void *buffer, int offset, int color);
__asm__("\n\
.text \n\
.balign 4 \n\
.global _v_putpixel32 \n\
_v_putpixel32: \n\
movl 8(%esp), %edx \n\
shll $2, %edx \n\
movl 12(%esp), %eax \n\
addl 4(%esp), %edx \n\
movl %eax, (%edx) \n\
ret");
/*
* get pixel and decompose R, G, B, A
*/
void (*vl_getrgba) (void *buffer, int offset, unsigned char rgba[4]);
/*
* v_getrgba*
*/
static void v_getrgba15 (void *buffer, int offset, unsigned char rgba[4])
{
int c = ((word16 *)buffer)[offset];
rgba[0] = _rgb_scale_5[(c >> 10) & 0x1F];
rgba[1] = _rgb_scale_5[(c >> 5) & 0x1F];
rgba[2] = _rgb_scale_5[c & 0x1F];
rgba[3] = 255;
}
static void v_getrgba16 (void *buffer, int offset, unsigned char rgba[4])
{
int c = ((word16 *)buffer)[offset];
rgba[0] = _rgb_scale_5[(c >> 11) & 0x1F];
rgba[1] = _rgb_scale_6[(c >> 5) & 0x3F];
rgba[2] = _rgb_scale_5[c & 0x1F];
rgba[3] = 255;
}
static void v_getrgba24 (void *buffer, int offset, unsigned char rgba[4])
{
int c = *(word32 *)((long)buffer+offset*3);
rgba[0] = c >> 16;
rgba[1] = c >> 8;
rgba[2] = c;
rgba[3] = 255;
}
static void v_getrgba32 (void *buffer, int offset, unsigned char rgba[4])
{
int c = ((word32 *)buffer)[offset];
rgba[0] = c >> 16;
rgba[1] = c >> 8;
rgba[2] = c;
rgba[3] = c >> 24;
}
/*
* sync buffer with video hardware
*/
void *vl_sync_buffer (void *buffer, int x, int y, int width, int height)
{
void *newbuf;
if (width&3) {
return NULL;
} else {
if ((newbuf=realloc(buffer, width*height*video_bypp))!=NULL) {
current_offset = video_scanlen * y + video_bypp * x;
current_width = width;
current_delta = video_scanlen - video_bypp * width;
}
return newbuf;
}
}
/*
* attempts to detect VESA and video modes
*/
static word16 vl_vesa_init (void)
{
__dpmi_regs r;
unsigned short *p;
vl_mode *q;
char vesa_info[512], tmp[512];
int maxsize = 0;
_farpokel(_stubinfo->ds_selector, 0, 0x32454256);
r.x.ax = 0x4f00;
r.x.di = 0;
r.x.es = _stubinfo->ds_segment;
__dpmi_int(0x10, &r);
if (r.x.ax==0x004f) {
movedata(_stubinfo->ds_selector, 0, _my_ds(), (unsigned)vesa_info, 512);
if ((_32_ vesa_info[0])==0x41534556) {
p = (unsigned short *)(((_16_ vesa_info[0x10])<<4) + (_16_ vesa_info[0x0e]));
q = modes;
do {
if ((q->mode=_farpeekw(__djgpp_dos_sel, (unsigned long)(p++)))==0xffff) {
break;
}
r.x.ax = 0x4f01;
r.x.cx = q->mode;
r.x.di = 512;
r.x.es = _stubinfo->ds_segment;
__dpmi_int(0x10, &r);
movedata(_stubinfo->ds_selector, 512, _my_ds(), (unsigned)tmp, 256);
switch (tmp[0x19]) {
case 16:
q->bpp = tmp[0x1f] + tmp[0x21] + tmp[0x23];
break;
case 15:
case 24:
case 32:
q->bpp = tmp[0x19];
break;
default:
q->bpp = 0;
}
if ((r.x.ax==0x004f)&&((tmp[0]&0x11)==0x11)&&q->bpp) {
q->xres = _16_ tmp[0x12];
q->yres = _16_ tmp[0x14];
q->scanlen = _16_ tmp[0x10];
hw_granularity = (_16_ tmp[4])<<10;
if (tmp[0]&0x80) {
*(q+1) = *q++;
hw_linearfb = _32_ tmp[0x28];
q->mode |= 0x4000;
}
if (maxsize<(q->scanlen*q->yres)) {
maxsize = q->scanlen*q->yres;
}
q++;
}
} while (!0);
if (hw_linearfb) {
maxsize = ((maxsize+0xfffUL)&~0xfffUL);
if (_create_selector(&linear_selector, hw_linearfb, maxsize)) {
return 0;
}
}
if (_create_selector(&banked_selector, 0xa0000, hw_granularity)) {
_remove_selector(&linear_selector);
return 0;
}
return _16_ vesa_info[4];
}
}
return 0;
}
/*
* setup mode
*/
static int vl_setup_mode (vl_mode *p)
{
if (p->mode&0x4000) {
video_selector = linear_selector;
vl_flip = l_dump_virtual;
} else {
{ int n; for (gran_shift=0, n=hw_granularity; n; gran_shift++, n>>=1) ; }
gran_mask = (1<<(--gran_shift)) - 1;
if (hw_granularity!=(gran_mask+1)) {
return -1;
}
video_selector = banked_selector;
vl_flip = b_dump_virtual;
}
#define INITPTR(bpp) \
vl_putpixel = v_putpixel##bpp; \
vl_getrgba = v_getrgba##bpp; \
vl_clear = v_clear##bpp; \
vl_mixrgb = vl_mixrgb##bpp; \
vl_mixrgba = vl_mixrgba##bpp;
switch (p->bpp) {
case 15:
INITPTR(15);
break;
case 16:
INITPTR(16);
break;
case 24:
INITPTR(24);
break;
case 32:
INITPTR(32);
break;
default:
return -1;
}
#undef INITPTR
video_bypp = (p->bpp+7)/8;
video_scanlen = p->scanlen;
return 0;
}
/*
* shutdown the video engine
*/
void vl_video_exit (int textmode)
{
if (init) {
if (textmode) {
__asm__("movw $0x3, %%ax; int $0x10":::"%eax");
}
_remove_selector(&linear_selector);
_remove_selector(&banked_selector);
init = !init;
}
}
/*
* initialize video engine
*
* success: 0
* failure: -1
*/
int vl_video_init (int width, int height, int bpp)
{
vl_mode *p, *q;
unsigned int min;
/* check for prior initialization */
if (init) {
return 0;
}
/* initialize hardware */
if (!(vesa_ver=vl_vesa_init())) {
return -1;
}
init = !init;
/* search for a mode that fits our request */
for (min=-1, p=NULL, q=modes; q->mode!=0xffff; q++) {
if ((q->xres>=width)&&(q->yres>=height)&&(q->bpp==bpp)) {
if (min>=(unsigned)(q->xres*q->yres)) {
min = q->xres*q->yres;
p = q;
}
}
}
if (p) {
vl_setup_mode(p);
__asm__("movw $0x4f02, %%ax; int $0x10"::"b"(p->mode):"%eax");
return 0;
} else {
/* no suitable mode found, abort */
vl_video_exit(0);
return -1;
}
}

View File

@@ -0,0 +1,52 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* DOS/DJGPP device driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef VIDEO_H_included
#define VIDEO_H_included
int vl_video_init (int width, int height, int bpp);
void vl_video_exit (int textmode);
void *vl_sync_buffer (void *buffer, int x, int y, int width, int height);
extern void (*vl_clear) (void *buffer, int len, int color);
void vl_rect (void *buffer, int x, int y, int width, int height, int color);
void (*vl_flip) (void *buffer, int width, int height);
extern int (*vl_mixrgba) (const unsigned char rgba[]);
extern int (*vl_mixrgb) (const unsigned char rgb[]);
extern void (*vl_putpixel) (void *buffer, int offset, int color);
extern void (*vl_getrgba) (void *buffer, int offset, unsigned char rgba[4]);
#endif

View File

@@ -24,6 +24,8 @@
#include <ggi/mesa/ggimesa.h>
#include <ggi/mesa/ggimesa_int.h>
#include <ggi/mesa/debug.h>
#include "swrast/swrast.h"
#define RMASK ((1<<R)-1)
#define GMASK ((1<<G)-1)
@@ -33,21 +35,30 @@
#define GS (8-G)
#define BS (8-B)
#define PACK(color) (((color[RCOMP]>>RS) << (G+B)) | \
((color[GCOMP]>>GS) << B) | \
((color[BCOMP]>>BS)))
#define FLIP(coord) (LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y-(coord) - 1)
/**********************************************************************/
/***** Write spans of pixels *****/
/**********************************************************************/
void GGIwrite_ci32_span(const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLuint ci[],
const GLubyte mask[])
void GGIwrite_ci32_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLuint ci[], const GLubyte mask[])
{
FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y));
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
FB_TYPE *fb;
fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) +
FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x;
if (mask)
{
while (n--) {
if (*mask++) *fb=*ci;
if (*mask++)
*fb = *ci;
fb++;
ci++;
}
@@ -58,17 +69,19 @@ void GGIwrite_ci32_span(const GLcontext *ctx,
}
}
void GGIwrite_ci8_span(const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte ci[],
const GLubyte mask[] )
void GGIwrite_ci8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLubyte ci[], const GLubyte mask[])
{
FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y));
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
FB_TYPE *fb;
fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) +
FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x;
if (mask)
{
while (n--) {
if (*mask++) *fb=*ci;
if (*mask++)
*fb = *ci;
fb++;
ci++;
}
@@ -80,87 +93,108 @@ void GGIwrite_ci8_span(const GLcontext *ctx,
}
void GGIwrite_rgba_span(const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte rgba[][4],
const GLubyte mask[])
{
FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y));
if (mask)
{
while (n--) {
if (*mask++) {
*fb= ((rgba[0][RCOMP]>>RS) << (G+B)) |
((rgba[0][GCOMP]>>GS) << B) |
((rgba[0][BCOMP]>>BS));
}
fb++;
rgba++;
}
}
else
{
while (n--) {
*fb++= ((rgba[0][RCOMP]>>RS) << (G+B)) |
((rgba[0][GCOMP]>>GS) << B)|
((rgba[0][BCOMP]>>BS));
rgba++;
}
}
}
void GGIwrite_rgb_span( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte rgba[][3],
const GLubyte mask[] )
{
FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y));
if (mask)
{
while (n--) {
if (*mask++) {
*fb= ((rgba[0][RCOMP]>>RS) << (G+B)) |
((rgba[0][GCOMP]>>GS) << B) |
((rgba[0][BCOMP]>>BS));
}
fb++;
rgba++;
}
}
else
{
while (n--) {
*fb++= ((rgba[0][RCOMP]>>RS) << (G+B)) |
((rgba[0][GCOMP]>>GS) << B) |
((rgba[0][BCOMP]>>BS));
rgba++;
}
}
}
void GGIwrite_mono_span( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte mask[])
void GGIwrite_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLchan rgba[][4], const GLubyte mask[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
FB_TYPE *fb;
FB_TYPE color;
fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) +
FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x;
if (mask)
{
fb=LFB(FB_TYPE,x,FLIP(y));
color=(FB_TYPE) GGICTX->color;
while (n--)
{
if (*mask++) *fb=color;
while (n--) {
if (*mask++)
*fb = PACK(rgba[0]);
fb++;
rgba++;
}
}
else
{
ggiDrawHLine(VIS,x,FLIP(y),n);
while (n--) {
*fb++ = PACK(rgba[0]);
rgba++;
}
}
}
void GGIwrite_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLchan rgba[][3], const GLubyte mask[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
FB_TYPE *fb;
fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) +
FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x;
if (mask)
{
while (n--) {
if (*mask++)
*fb = PACK(rgba[0]);
fb++;
rgba++;
}
}
else
{
while (n--) {
*fb++ = PACK(rgba[0]);
rgba++;
}
}
}
void GGIwrite_mono_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLchan color[4], const GLubyte mask[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
FB_TYPE *fb;
fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) +
FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x;
if (mask){
while (n--){
if (*mask++)
*fb = PACK(color);
++fb;
}
}
else {
while (n--)
*fb++ = PACK(color);
/* Alternatively we could write a potentialy faster HLine
ggiSetGCForeground(ggi_ctx->ggi_visual, color);
ggiDrawHLine(ggi_ctx->ggi_visual,x,FLIP(y),n);
*/
}
}
void GGIwrite_mono_ci_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLuint ci, const GLubyte mask[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
FB_TYPE *fb;
fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) +
FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x;
if (mask){
while (n--){
if (*mask++)
*fb = ci;
++fb;
}
}
else {
while (n--)
*fb++ = ci;
/* Alternatively we could write a potentialy faster HLine
ggiSetGCForeground(ggi_ctx->ggi_visual, ci);
ggiDrawHLine(ggi_ctx->ggi_visual, x, FLIP(y), n);
*/
}
}
@@ -171,27 +205,33 @@ void GGIwrite_mono_span( const GLcontext *ctx,
void GGIread_ci32_span(const GLcontext *ctx,
GLuint n, GLint x, GLint y, GLuint ci[])
GLuint n, GLint x, GLint y, GLuint ci[])
{
FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y));
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
FB_TYPE *fb;
fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) +
FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x;
while (n--)
*ci++=(GLuint)*fb++;
*ci++ = (GLuint)*fb++;
}
void GGIread_rgba_span(const GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLubyte rgba[][4])
GLuint n, GLint x, GLint y, GLchan rgba[][4])
{
FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y));
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
FB_TYPE color;
FB_TYPE *fb;
fb = (FB_TYPE *)(LIBGGI_CURWRITE(ggi_ctx->ggi_visual) +
FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x;
while (n--)
{
color=*fb++;
color = *fb++;
rgba[0][RCOMP] = (GLubyte) (color>>(G+B))<<RS;
rgba[0][GCOMP] = (GLubyte) ((color>>B)& ((1<<G)-1))<<GS;
rgba[0][BCOMP] = (GLubyte) (color & ((1<<B)-1))<<BS;
rgba[0][ACOMP] =0;
rgba[0][ACOMP] = 0;
rgba++;
}
}
@@ -201,68 +241,97 @@ void GGIread_rgba_span(const GLcontext *ctx,
/**********************************************************************/
void GGIwrite_ci32_pixels(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLuint ci[], const GLubyte mask[] )
GLuint n, const GLint x[], const GLint y[],
const GLuint ci[], const GLubyte mask[])
{
FB_TYPE *fb=LFB(FB_TYPE,0,0);
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual);
void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual);
while (n--) {
if (*mask++) *(fb+ *x + FLIP(*y)*GGICTX->width)=*ci;
if (*mask++){
FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x;
*dst = *ci;
}
ci++;
x++;
y++;
}
}
void GGIwrite_mono_pixels(const GLcontext *ctx,
GLuint n,
const GLint x[], const GLint y[],
const GLubyte mask[] )
void GGIwrite_mono_ci_pixels(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint ci, const GLubyte mask[])
{
FB_TYPE *fb=LFB(FB_TYPE,0,0);
FB_TYPE color=(FB_TYPE) GGICTX->color;
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual);
void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual);
while (n--) {
if (*mask++) *(fb+ *x + FLIP(*y)*GGICTX->width)=color;
if (*mask++){
FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x;
*dst = ci;
}
x++;
y++;
}
}
void GGIwrite_rgba_pixels(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLubyte rgba[][4],
const GLubyte mask[] )
GLuint n, const GLint x[], const GLint y[],
const GLchan rgba[][4], const GLubyte mask[])
{
FB_TYPE *fb=LFB(FB_TYPE,0,0);
FB_TYPE color;
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual);
void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual);
while (n--) {
if (*mask++) {
color= ((rgba[0][RCOMP]>>RS) << (G+B)) |
((rgba[0][GCOMP]>>GS) << B) |
((rgba[0][BCOMP]>>BS));
*(fb+ *x + FLIP(*y)*GGICTX->width)=color;
if (*mask++){
FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x;
*dst = PACK(rgba[0]);
}
x++;y++;
x++;
y++;
rgba++;
}
}
void GGIwrite_mono_rgba_pixels(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLchan rgba[4], const GLubyte mask[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual);
void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual);
while (n--) {
if (*mask++){
FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x;
*dst = PACK(rgba);
}
x++;
y++;
}
}
/**********************************************************************/
/***** Read arrays of pixels *****/
/**********************************************************************/
void GGIread_ci32_pixels(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint ci[], const GLubyte mask[])
GLuint n, const GLint x[], const GLint y[],
GLuint ci[], const GLubyte mask[])
{
FB_TYPE *fb=LFB(FB_TYPE,0,0);
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual);
void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual);
while (n--) {
if (*mask++)
*ci=*(fb+ *x + FLIP(*y)*GGICTX->width);
if (*mask++){
FB_TYPE *src = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x;
*ci = *src;
}
ci++;
x++;
y++;
@@ -270,60 +339,70 @@ void GGIread_ci32_pixels(const GLcontext *ctx,
}
void GGIread_rgba_pixels(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4],
const GLubyte mask[] )
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4], const GLubyte mask[])
{
FB_TYPE *fb=LFB(FB_TYPE,0,0);
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual);
void *fb = LIBGGI_CURWRITE(ggi_ctx->ggi_visual);
FB_TYPE color;
while (n--)
{
if (*mask++)
{
color=*(fb+ *x + FLIP(*y)*GGICTX->width);
rgba[0][RCOMP] =(GLubyte)(color>>(G+B))<<RS;
rgba[0][GCOMP] =(GLubyte)((color>>B)& ((1<<G)-1))<<GS;
rgba[0][BCOMP] =(GLubyte) (color & ((1<<B)-1))<<BS;
rgba[0][ACOMP] =0;
{
FB_TYPE *src = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x;
color = *src;
rgba[0][RCOMP] = (GLubyte)(color>>(G+B))<<RS;
rgba[0][GCOMP] = (GLubyte)((color>>B)& ((1<<G)-1))<<GS;
rgba[0][BCOMP] = (GLubyte) (color & ((1<<B)-1))<<BS;
rgba[0][ACOMP] = 0;
}
x++; y++;
x++;
y++;
rgba++;
}
}
int GGIsetup_driver(GGIMesaContext ggictx, struct ggi_mesa_info *info)
void GGIset_read_buffer(GLcontext *ctx, GLframebuffer *buffer, GLenum mode)
{
GLcontext *ctx = ggictx->gl_ctx;
#if 0
ctx->Driver.WriteRGBASpan = GGIwrite_rgba_span;
ctx->Driver.WriteRGBSpan = GGIwrite_rgb_span;
// ctx->Driver.WriteMonoRGBASpan = GGIwrite_mono_span;
ctx->Driver.WriteRGBAPixels = GGIwrite_rgba_pixels;
// ctx->Driver.WriteMonoRGBAPixels = GGIwrite_mono_pixels;
}
ctx->Driver.WriteCI32Span = GGIwrite_ci32_span;
ctx->Driver.WriteCI8Span = GGIwrite_ci8_span;
// ctx->Driver.WriteMonoCISpan = GGIwrite_mono_span;
ctx->Driver.WriteCI32Pixels = GGIwrite_ci32_pixels;
// ctx->Driver.WriteMonoCIPixels = GGIwrite_mono_pixels;
int GGIsetup_driver(ggi_mesa_context_t ggi_ctx)
{
struct swrast_device_driver *swdd =
_swrast_GetDeviceDriverReference(ggi_ctx->gl_ctx);
ctx->Driver.ReadCI32Span = GGIread_ci32_span;
ctx->Driver.ReadRGBASpan = GGIread_rgba_span;
ctx->Driver.ReadCI32Pixels = GGIread_ci32_pixels;
ctx->Driver.ReadRGBAPixels = GGIread_rgba_pixels;
#endif
info->red_bits = R;
info->green_bits =G;
info->blue_bits = B;
GGIMESADPRINT_LIBS("linear_%d: GGIsetup_driver\n", sizeof(FB_TYPE)*8);
swdd->WriteRGBASpan = GGIwrite_rgba_span;
swdd->WriteRGBSpan = GGIwrite_rgb_span;
swdd->WriteMonoRGBASpan = GGIwrite_mono_rgba_span;
swdd->WriteRGBAPixels = GGIwrite_rgba_pixels;
swdd->WriteMonoRGBAPixels = GGIwrite_mono_rgba_pixels;
swdd->WriteCI32Span = GGIwrite_ci32_span;
swdd->WriteCI8Span = GGIwrite_ci8_span;
swdd->WriteMonoCISpan = GGIwrite_mono_ci_span;
swdd->WriteCI32Pixels = GGIwrite_ci32_pixels;
swdd->WriteMonoCIPixels = GGIwrite_mono_ci_pixels;
swdd->ReadCI32Span = GGIread_ci32_span;
swdd->ReadRGBASpan = GGIread_rgba_span;
swdd->ReadCI32Pixels = GGIread_ci32_pixels;
swdd->ReadRGBAPixels = GGIread_rgba_pixels;
swdd->SetReadBuffer = GGIset_read_buffer;
return 0;
}
static int GGIopen(ggi_visual_t vis,struct ggi_dlhandle *dlh,
const char *args,void *argptr, uint32 *dlret)
{
LIBGGI_MESAEXT(vis)->setup_driver=GGIsetup_driver;
const char *args,void *argptr, uint32 *dlret)
{
GGIMESADPRINT_CORE("linear_%d: GGIOpen\n", sizeof(FB_TYPE)*8);
LIBGGI_MESAEXT(vis)->setup_driver = GGIsetup_driver;
*dlret = GGI_DL_OPDRAW;
return 0;
@@ -332,15 +411,15 @@ static int GGIopen(ggi_visual_t vis,struct ggi_dlhandle *dlh,
int DLOPENFUNC(int func, void **funcptr)
{
switch (func) {
case GGIFUNC_open:
*funcptr = GGIopen;
return 0;
case GGIFUNC_exit:
case GGIFUNC_close:
*funcptr = NULL;
return 0;
default:
*funcptr = NULL;
case GGIFUNC_open:
*funcptr = GGIopen;
return 0;
case GGIFUNC_exit:
case GGIFUNC_close:
*funcptr = NULL;
return 0;
default:
*funcptr = NULL;
}
return GGI_ENOTFOUND;
}

View File

@@ -26,14 +26,16 @@
#include <ggi/internal/ggi-dl.h>
#include <ggi/mesa/ggimesa_int.h>
#include <ggi/mesa/debug.h>
#include "mmath.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "swrast/s_context.h"
#include "swrast/s_depth.h"
#include "swrast/s_triangle.h"
#include "swrast/s_trispan.h"
//#include "swrast_setup/swrast_setup.h"
//#include "swrast/s_context.h"
//#include "swrast/s_depth.h"
//#include "swrast/s_triangle.h"
#define FLIP(coord) (LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y-(coord)-1)
/**********************************************************************/
/***** Write spans of pixels *****/
@@ -44,18 +46,21 @@ void GGIwrite_ci32_span(const GLcontext *ctx,
const GLuint ci[],
const GLubyte mask[] )
{
y=FLIP(y);
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
y = FLIP(y);
if (mask)
{
while (n--) {
if (*mask++) ggiPutPixel(VIS,x,y,*ci);
if (*mask++)
ggiPutPixel(ggi_ctx->ggi_visual, x, y, *ci);
x++;
ci++;
}
}
else
{
while (n--) ggiPutPixel(VIS,x++,y,*ci++);
while (n--)
ggiPutPixel(ggi_ctx->ggi_visual, x++, y, *ci++);
}
}
@@ -64,36 +69,69 @@ void GGIwrite_ci8_span(const GLcontext *ctx,
const GLubyte ci[],
const GLubyte mask[] )
{
y=FLIP(y);
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
y = FLIP(y);
if (mask)
{
while (n--) {
if (*mask++) ggiPutPixel(VIS,x,y,*ci);
if (*mask++)
ggiPutPixel(ggi_ctx->ggi_visual, x, y, *ci);
x++;
ci++;
}
}
else
{
while (n--) ggiPutPixel(VIS,x++,y,*ci++);
while (n--)
ggiPutPixel(ggi_ctx->ggi_visual, x++, y, *ci++);
}
}
void GGIwrite_mono_span( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte mask[] )
void GGIwrite_mono_ci_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLuint ci, const GLubyte mask[])
{
y=FLIP(y);
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
y = FLIP(y);
if (mask)
{
while (n--) {
if (*mask++) ggiDrawPixel(VIS,x,y);
if (*mask++)
ggiPutPixel(ggi_ctx->ggi_visual, x, y, ci);
x++;
}
}
else
{
ggiDrawHLine(VIS,x,y,n);
while (n--)
ggiPutPixel(ggi_ctx->ggi_visual, x++, y, ci);
}
}
void GGIwrite_mono_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLchan rgba[4], const GLubyte mask[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
y = FLIP(y);
rgb.r = (uint16)(rgba[RCOMP]) << SHIFT;
rgb.g = (uint16)(rgba[GCOMP]) << SHIFT;
rgb.b = (uint16)(rgba[BCOMP]) << SHIFT;
col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
if (mask)
{
while (n--) {
if (*mask++)
ggiPutPixel(ggi_ctx->ggi_visual, x, y, col);
x++;
}
}
else
{
ggiDrawHLine(ggi_ctx->ggi_visual, x, y, n);
}
}
@@ -102,20 +140,21 @@ void GGIwrite_rgba_span( const GLcontext *ctx,
const GLubyte rgba[][4],
const GLubyte mask[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
y=FLIP(y);
y = FLIP(y);
if (mask)
{
while (n--) {
if (*mask++)
{
rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT;
rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT;
rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT;
col=ggiMapColor(VIS,&rgb);
ggiPutPixel(VIS,x,y,col);
rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT;
rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT;
rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT;
col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
ggiPutPixel(ggi_ctx->ggi_visual, x, y, col);
}
x++;
rgba++;
@@ -125,34 +164,36 @@ void GGIwrite_rgba_span( const GLcontext *ctx,
{
while (n--)
{
rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT;
rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT;
rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT;
col=ggiMapColor(VIS,&rgb);
ggiPutPixel(VIS,x++,y,col);
rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT;
rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT;
rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT;
col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
ggiPutPixel(ggi_ctx->ggi_visual, x++, y, col);
rgba++;
}
}
}
void GGIwrite_rgb_span( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte rgba[][3],
const GLubyte mask[] )
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
y=FLIP(y);
y = FLIP(y);
if (mask)
{
while (n--) {
if (*mask++)
{
rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT;
rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT;
rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT;
col=ggiMapColor(VIS,&rgb);
ggiPutPixel(VIS,x,y,col);
rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT;
rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT;
rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT;
col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
ggiPutPixel(ggi_ctx->ggi_visual, x, y, col);
}
x++;
rgba++;
@@ -162,11 +203,11 @@ void GGIwrite_rgb_span( const GLcontext *ctx,
{
while (n--)
{
rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT;
rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT;
rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT;
col=ggiMapColor(VIS,&rgb);
ggiPutPixel(VIS,x++,y,col);
rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT;
rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT;
rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT;
col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
ggiPutPixel(ggi_ctx->ggi_visual, x++, y, col);
rgba++;
}
}
@@ -182,24 +223,26 @@ void GGIwrite_rgb_span( const GLcontext *ctx,
void GGIread_ci32_span( const GLcontext *ctx,
GLuint n, GLint x, GLint y, GLuint ci[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
y = FLIP(y);
while (n--)
ggiGetPixel(VIS, x++, y,ci++);
ggiGetPixel(ggi_ctx->ggi_visual, x++, y, ci++);
}
void GGIread_rgba_span( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLubyte rgba[][4])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
y=FLIP(y);
y = FLIP(y);
while (n--)
{
ggiGetPixel(VIS,x++,y,&col);
ggiUnmapPixel(VIS,col,&rgb);
ggiGetPixel(ggi_ctx->ggi_visual, x++, y, &col);
ggiUnmapPixel(ggi_ctx->ggi_visual, col, &rgb);
rgba[0][RCOMP] = (GLubyte) (rgb.r >> SHIFT);
rgba[0][GCOMP] = (GLubyte) (rgb.g >> SHIFT);
rgba[0][BCOMP] = (GLubyte) (rgb.b >> SHIFT);
@@ -216,21 +259,24 @@ void GGIwrite_ci32_pixels( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLuint ci[], const GLubyte mask[] )
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
while (n--) {
if (*mask++) ggiPutPixel(VIS,*x, FLIP(*y),*ci);
if (*mask++)
ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), *ci);
ci++;
x++;
y++;
}
}
void GGIwrite_mono_pixels( const GLcontext *ctx,
GLuint n,
const GLint x[], const GLint y[],
const GLubyte mask[] )
void GGIwrite_mono_ci_pixels(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint ci, const GLubyte mask[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
while (n--) {
if (*mask++) ggiDrawPixel(VIS,*x,FLIP(*y));
if (*mask++)
ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), ci);
x++;
y++;
}
@@ -241,21 +287,43 @@ void GGIwrite_rgba_pixels( const GLcontext *ctx,
const GLubyte rgba[][4],
const GLubyte mask[] )
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_pixel col;
ggi_color rgb;
while (n--) {
if (*mask++) {
rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT;
rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT;
rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT;
col=ggiMapColor(VIS,&rgb);
ggiPutPixel(VIS,*x,FLIP(*y),col);
rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT;
rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT;
rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT;
col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), col);
}
x++;y++;
x++;
y++;
rgba++;
}
}
void GGIwrite_mono_rgba_pixels(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLchan rgba[4], const GLubyte mask[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
rgb.r = (uint16)(rgba[RCOMP]) << SHIFT;
rgb.g = (uint16)(rgba[GCOMP]) << SHIFT;
rgb.b = (uint16)(rgba[BCOMP]) << SHIFT;
col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
while (n--) {
if (*mask++)
ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), col);
x++;
y++;
}
}
/**********************************************************************/
/***** Read arrays of pixels *****/
@@ -265,9 +333,10 @@ void GGIread_ci32_pixels( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint ci[], const GLubyte mask[])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
while (n--) {
if (*mask++)
ggiGetPixel(VIS, *x, FLIP(*y) ,ci);
ggiGetPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), ci);
ci++;
x++;
y++;
@@ -279,6 +348,7 @@ void GGIread_rgba_pixels( const GLcontext *ctx,
GLubyte rgba[][4],
const GLubyte mask[] )
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
@@ -286,49 +356,59 @@ void GGIread_rgba_pixels( const GLcontext *ctx,
{
if (*mask++)
{
ggiGetPixel(VIS,*x,FLIP(*y),&col);
ggiUnmapPixel(VIS,col,&rgb);
rgba[0][RCOMP]= rgb.r >> SHIFT;
rgba[0][GCOMP]= rgb.g >> SHIFT;
rgba[0][BCOMP]= rgb.b >> SHIFT;
rgba[0][ACOMP]=0;
ggiGetPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), &col);
ggiUnmapPixel(ggi_ctx->ggi_visual, col, &rgb);
rgba[0][RCOMP] = rgb.r >> SHIFT;
rgba[0][GCOMP] = rgb.g >> SHIFT;
rgba[0][BCOMP] = rgb.b >> SHIFT;
rgba[0][ACOMP] = 0;
}
x++; y++;
x++;
y++;
rgba++;
}
}
static swrast_tri_func ggimesa_stubs_get_triangle_func(GLcontext *ctx);
int GGIsetup_driver(GGIMesaContext ggictx, struct ggi_mesa_info *info)
int GGIextend_visual(ggi_visual_t vis)
{
GLcontext *ctx = ggictx->gl_ctx;
#if 0
ctx->Driver.WriteRGBASpan = GGIwrite_rgba_span;
ctx->Driver.WriteRGBSpan = GGIwrite_rgb_span;
ctx->Driver.WriteRGBAPixels = GGIwrite_rgba_pixels;
ctx->Driver.WriteCI32Span = GGIwrite_ci32_span;
ctx->Driver.WriteCI8Span = GGIwrite_ci8_span;
ctx->Driver.WriteCI32Pixels = GGIwrite_ci32_pixels;
ctx->Driver.ReadCI32Span = GGIread_ci32_span;
ctx->Driver.ReadRGBASpan = GGIread_rgba_span;
ctx->Driver.ReadCI32Pixels = GGIread_ci32_pixels;
ctx->Driver.ReadRGBAPixels = GGIread_rgba_pixels;
#endif
return 0;
}
void GGIupdate_state(GLcontext *ctx)
//static swrast_tri_func ggimesa_stubs_get_triangle_func(GLcontext *ctx);
int GGIsetup_driver(ggi_mesa_context_t ggi_ctx)
{
#if 0
ctx->Driver.TriangleFunc = _swsetup_Triangle;
#endif
struct swrast_device_driver *swdd =
_swrast_GetDeviceDriverReference(ggi_ctx->gl_ctx);
GGIMESADPRINT_CORE("stubs: setup_driver\n");
swdd->WriteRGBASpan = GGIwrite_rgba_span;
swdd->WriteRGBSpan = GGIwrite_rgb_span;
swdd->WriteMonoRGBASpan = GGIwrite_mono_rgba_span;
swdd->WriteRGBAPixels = GGIwrite_rgba_pixels;
swdd->WriteMonoRGBAPixels = GGIwrite_mono_rgba_pixels;
swdd->WriteCI32Span = GGIwrite_ci32_span;
swdd->WriteCI8Span = GGIwrite_ci8_span;
swdd->WriteMonoCISpan = GGIwrite_mono_ci_span;
swdd->WriteCI32Pixels = GGIwrite_ci32_pixels;
swdd->WriteMonoCIPixels = GGIwrite_mono_ci_pixels;
swdd->ReadCI32Span = GGIread_ci32_span;
swdd->ReadRGBASpan = GGIread_rgba_span;
swdd->ReadCI32Pixels = GGIread_ci32_pixels;
swdd->ReadRGBAPixels = GGIread_rgba_pixels;
return 0;
}
void GGIupdate_state(ggi_mesa_context_t *ctx)
{
//ctx->Driver.TriangleFunc = _swsetup_Triangle;
}
/*
void GGItriangle_flat(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1, const SWvertex *v2)
{
//#define INTERP_Z 1
@@ -405,10 +485,10 @@ static swrast_tri_func ggimesa_stubs_get_triangle_func(GLcontext *ctx)
return GGItriangle_flat;
}
*/
static int GGIopen(ggi_visual_t vis, struct ggi_dlhandle *dlh,
const char *args, void *argptr, uint32 *dlret)
{
{
LIBGGI_MESAEXT(vis)->update_state = GGIupdate_state;
LIBGGI_MESAEXT(vis)->setup_driver = GGIsetup_driver;
@@ -419,15 +499,15 @@ static int GGIopen(ggi_visual_t vis, struct ggi_dlhandle *dlh,
int MesaGGIdl_stubs(int func, void **funcptr)
{
switch (func) {
case GGIFUNC_open:
*funcptr = GGIopen;
return 0;
case GGIFUNC_exit:
case GGIFUNC_close:
*funcptr = NULL;
return 0;
default:
*funcptr = NULL;
case GGIFUNC_open:
*funcptr = GGIopen;
return 0;
case GGIFUNC_exit:
case GGIFUNC_close:
*funcptr = NULL;
return 0;
default:
*funcptr = NULL;
}
return GGI_ENOTFOUND;
}

View File

@@ -1,6 +1,7 @@
/* GGI-Driver for MESA
*
* Copyright (C) 1997-1998 Uwe Maurer - uwe_maurer@t-online.de
* 2002 Filip Spacek
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -33,23 +34,17 @@
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#undef VIS
#undef FLIP
#define VIS (GGIMesa->ggi_vis)
#define FLIP(y) (GGIMesa->flip_y-(y))
GGIMesaContext GGIMesa = NULL; /* the current context */
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
#include "array_cache/acache.h"
#include "texformat.h"
#include "texstore.h"
ggi_extid ggiMesaID = -1;
static int _ggimesaLibIsUp = 0;
static void *_ggimesaConfigHandle;
/* FIXME: These should really be defined in the make system using -Dxxx */
#define GGIMESACONFFILE "/usr/local/etc/ggi/ggimesa.conf"
#define GGIMESATAGLEN 0
static char ggimesaconfstub[512] = GGIMESACONFFILE;
static char *ggimesaconffile = ggimesaconfstub + GGIMESATAGLEN;
static char ggimesaconffile[] = GGIMESACONFFILE;
int _ggimesaDebugSync = 0;
uint32 _ggimesaDebugState = 0;
@@ -57,48 +52,52 @@ uint32 _ggimesaDebugState = 0;
static void gl_ggiUpdateState(GLcontext *ctx, GLuint new_state);
static int changed(ggi_visual_t vis, int whatchanged);
static void gl_ggiGetSize(GLcontext *ctx, GLuint *width, GLuint *height)
static int _ggi_error(void)
{
GGIMESADPRINT_CORE("_ggi_error() called\n");
return -1;
}
static void gl_ggiGetSize(GLframebuffer *fb, GLuint *width, GLuint *height)
{
/* FIXME: this is a hack to work around the new interface */
GLcontext *ctx;
ggi_mesa_context_t ggi_ctx;
ctx = _mesa_get_current_context();
ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
GGIMESADPRINT_CORE("gl_ggiGetSize() called\n");
*width = GGIMesa->width;
*height = GGIMesa->height;
*width = LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.x;
*height = LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y;
printf("returning %d, %d\n", *width, *height);
}
static void gl_ggiSetIndex(GLcontext *ctx, GLuint ci)
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
GGIMESADPRINT_CORE("gl_ggiSetIndex() called\n");
ggiSetGCForeground(VIS, ci);
GGICTX->color = (ggi_pixel)ci;
ggiSetGCForeground(ggi_ctx->ggi_visual, ci);
ggi_ctx->color = (ggi_pixel)ci;
}
static void gl_ggiSetClearIndex(GLcontext *ctx, GLuint ci)
{
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
GGIMESADPRINT_CORE("gl_ggiSetClearIndex() called\n");
ggiSetGCForeground(VIS, ci);
GGICTX->clearcolor = (ggi_pixel)ci;
}
static void gl_ggiSetColor(GLcontext *ctx, GLubyte red, GLubyte green,
GLubyte blue, GLubyte alpha)
{
ggi_color rgb;
ggi_pixel col;
GGIMESADPRINT_CORE("gl_ggiSetColor() called\n");
rgb.r = (uint16)red << SHIFT;
rgb.g = (uint16)green << SHIFT;
rgb.b = (uint16)blue << SHIFT;
col = ggiMapColor(VIS, &rgb);
ggiSetGCForeground(VIS, col);
GGICTX->color = col;
ggiSetGCForeground(ggi_ctx->ggi_visual, ci);
ggi_ctx->clearcolor = (ggi_pixel)ci;
}
static void gl_ggiSetClearColor(GLcontext *ctx, const GLchan color[4])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
@@ -107,71 +106,90 @@ static void gl_ggiSetClearColor(GLcontext *ctx, const GLchan color[4])
rgb.r = (uint16)color[0] << SHIFT;
rgb.g = (uint16)color[1] << SHIFT;
rgb.b = (uint16)color[2] << SHIFT;
col = ggiMapColor(VIS, &rgb);
ggiSetGCForeground(VIS, col);
GGICTX->clearcolor = col;
col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
ggiSetGCForeground(ggi_ctx->ggi_visual, col);
ggi_ctx->clearcolor = col;
}
static GLbitfield gl_ggiClear(GLcontext *ctx,GLbitfield mask, GLboolean all,
GLint x, GLint y, GLint width, GLint height)
static void gl_ggiClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint x, GLint y, GLint width, GLint height)
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
GGIMESADPRINT_CORE("gl_ggiClear() called\n");
if (mask & GL_COLOR_BUFFER_BIT)
if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT))
{
ggiSetGCForeground(VIS, GGICTX->clearcolor);
ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->clearcolor);
if (all)
{
ggiDrawBox(VIS, 0, GGIMesa->origin.y,
GGIMesa->width, GGIMesa->height);
int w, h;
w = LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.x;
h = LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y;
ggiDrawBox(ggi_ctx->ggi_visual, 0, 0, w, h);
}
else
{
ggiDrawBox(VIS, x, FLIP(y), width, height);
ggiDrawBox(ggi_ctx->ggi_visual, x, y, //FLIP(y),
width, height);
}
ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->color);
ggiSetGCForeground(VIS, GGICTX->color);
mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
}
return mask & (~GL_COLOR_BUFFER_BIT);
_swrast_Clear(ctx, mask, all, x, y, width, height);
}
/* Set the buffer used for drawing */
static GLboolean gl_ggiSetDrawBuffer(GLcontext *ctx, GLenum mode)
static void gl_ggiSetDrawBuffer(GLcontext *ctx, GLenum mode)
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
printf("set draw %d\n", mode);
GGIMESADPRINT_CORE("gl_ggiSetDrawBuffer() called\n");
if (mode == GL_FRONT_LEFT)
{
GGICTX->active_buffer = 1;
return GL_TRUE;
ggiSetWriteFrame(ggi_ctx->ggi_visual,
ggiGetDisplayFrame(ggi_ctx->ggi_visual));
}
else if (mode == GL_BACK_LEFT)
{
GGICTX->active_buffer = 0;
return GL_TRUE;
ggiSetWriteFrame(ggi_ctx->ggi_visual,
ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1);
}
else
{
return GL_FALSE;
/* nothing since we don't have any point/line/triangle functions. */
}
}
/* Set the buffer used for reading */
/* XXX support for separate read/draw buffers hasn't been tested */
static void gl_ggiSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer, GLenum mode)
static GLboolean gl_ggiSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer, GLenum mode)
{
GGIMESADPRINT_CORE("gl_ggiSetReadBuffer() called\n");
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
printf("set read %d\n", mode);
GGIMESADPRINT_CORE("gl_ggiSetReadBuffer() called\n");
if (mode == GL_FRONT_LEFT)
{
GGICTX->active_buffer = 1;
ggiSetReadFrame(ggi_ctx->ggi_visual,
ggiGetDisplayFrame(ggi_ctx->ggi_visual));
return GL_TRUE;
}
else if (mode == GL_BACK_LEFT)
{
GGICTX->active_buffer = 0;
ggiSetReadFrame(ggi_ctx->ggi_visual,
ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1);
return GL_TRUE;
}
else
return GL_FALSE;
}
@@ -187,9 +205,11 @@ static const GLubyte * gl_ggiGetString(GLcontext *ctx, GLenum name)
static void gl_ggiFlush(GLcontext *ctx)
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
GGIMESADPRINT_CORE("gl_ggiFlush() called\n");
ggiFlush(VIS);
ggiFlush(ggi_ctx->ggi_visual);
}
static void gl_ggiIndexMask(GLcontext *ctx, GLuint mask)
@@ -197,7 +217,8 @@ static void gl_ggiIndexMask(GLcontext *ctx, GLuint mask)
GGIMESADPRINT_CORE("gl_ggiIndexMask() called\n");
}
static void gl_ggiColorMask(GLcontext *ctx, GLboolean rmask, GLboolean gmask, GLboolean bmask, GLboolean amask)
static void gl_ggiColorMask(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
GLboolean bmask, GLboolean amask)
{
GGIMESADPRINT_CORE("gl_ggiColorMask() called\n");
}
@@ -209,76 +230,95 @@ static void gl_ggiEnable(GLcontext *ctx, GLenum pname, GLboolean state)
static void gl_ggiSetupPointers(GLcontext *ctx)
{
TNLcontext *tnl;
GGIMESADPRINT_CORE("gl_ggiSetupPointers() called\n");
/* Initialize all the pointers in the DD struct. Do this whenever */
/* a new context is made current or we change buffers via set_buffer! */
/* General information */
ctx->Driver.GetString = gl_ggiGetString;
ctx->Driver.UpdateState = gl_ggiUpdateState;
ctx->Driver.GetBufferSize = gl_ggiGetSize;
ctx->Driver.Finish = gl_ggiFlush;
ctx->Driver.Flush = gl_ggiFlush;
/* Software rasterizer pixel paths */
ctx->Driver.Accum = _swrast_Accum;
ctx->Driver.Bitmap = _swrast_Bitmap;
ctx->Driver.Clear = gl_ggiClear;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
/* Software texturing */
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
ctx->Driver.TexImage2D = _mesa_store_teximage2d;
ctx->Driver.TexImage3D = _mesa_store_teximage3d;
ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
/* Imaging extensions */
ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
/* State change callbacks */
ctx->Driver.SetDrawBuffer = gl_ggiSetDrawBuffer;
ctx->Driver.ClearIndex = gl_ggiSetClearIndex;
ctx->Driver.ClearColor = gl_ggiSetClearColor;
// ctx->Driver.Clear = gl_ggiClear;
ctx->Driver.IndexMask = gl_ggiIndexMask;
ctx->Driver.ColorMask = gl_ggiColorMask;
ctx->Driver.Enable = gl_ggiEnable;
#if 0
ctx->Driver.SetDrawBuffer = gl_ggiSetDrawBuffer;
ctx->Driver.SetReadBuffer = gl_ggiSetReadBuffer;
ctx->Driver.GetBufferSize = gl_ggiGetSize;
ctx->Driver.Finish = gl_ggiFlush;
ctx->Driver.Flush = gl_ggiFlush;
ctx->Driver.UpdateState = gl_ggiUpdateState;
ctx->Driver.RenderStart = 0;
ctx->Driver.RenderFinish = _swrast_flush;
/* Initialize TNL driver interface */
tnl = TNL_CONTEXT(ctx);
tnl->Driver.RunPipeline = _tnl_run_pipeline;
ctx->Driver.PointsFunc = _swsetup_Points;
ctx->Driver.LineFunc = _swsetup_Line;
ctx->Driver.TriangleFunc = _swsetup_Triangle;
ctx->Driver.QuadFunc = _swsetup_Quad;
#endif
/* Install setup for tnl */
_swsetup_Wakeup(ctx);
}
static int gl_ggiInitInfo(GGIMesaContext ctx, struct ggi_mesa_info *info)
static void get_mode_info(ggi_visual_t vis, int *r, int *g, int *b,
GLboolean *rgb, GLboolean *db, int *ci)
{
ggi_mode mode;
GGIMESADPRINT_CORE("gl_ggiInitInfo() called\n");
int i;
ggiGetMode(ctx->ggi_vis, &mode);
info->depth_bits = DEFAULT_SOFTWARE_DEPTH_BITS;
info->stencil_bits = STENCIL_BITS;
info->accum_bits = ACCUM_BITS;
*r = 0;
*g = 0;
*b = 0;
if (info->rgb_flag)
{
info->rgb_flag = GL_TRUE;
info->alpha_flag = GL_FALSE;
info->index_bits = 0;
info->red_bits = 8;
info->green_bits = 8;
info->blue_bits = 8;
info->alpha_bits = 0;
for(i = 0; i < sizeof(ggi_pixel)*8; ++i){
int mask = 1 << i;
if(LIBGGI_PIXFMT(vis)->red_mask & mask)
++(*r);
if(LIBGGI_PIXFMT(vis)->green_mask & mask)
++(*g);
if(LIBGGI_PIXFMT(vis)->blue_mask & mask)
++(*b);
}
else
{
info->alpha_flag = GL_FALSE;
info->index_bits = GT_SIZE(mode.graphtype);
info->red_bits = info->green_bits =
info->blue_bits = info->alpha_bits = 0;
}
return 0;
*rgb = GT_SCHEME(LIBGGI_MODE(vis)->graphtype) == GT_TRUECOLOR;
*db = LIBGGI_MODE(vis)->frames > 1;
*ci = GT_SIZE(LIBGGI_MODE(vis)->graphtype);
printf("rgb (%d, %d, %d) db %d, rgb %d ci %d\n",*r,*g,*b,*db,*rgb,*ci);
}
int ggiMesaInit()
{
int err;
@@ -301,17 +341,19 @@ int ggiMesaInit()
_ggimesaLibIsUp++;
if (_ggimesaLibIsUp > 1)
return 0; /* Initialize only at first call */
return 0; /* Initialize only at first call */
err = ggLoadConfig(ggimesaconffile, &_ggimesaConfigHandle);
if (err != GGI_OK)
{
GGIMESADPRINT_CORE("GGIMesa: Couldn't open %s\n", ggimesaconffile);
GGIMESADPRINT_CORE("GGIMesa: Couldn't open %s\n",
ggimesaconffile);
_ggimesaLibIsUp--;
return err;
}
ggiMesaID = ggiExtensionRegister("GGIMesa", sizeof(struct mesa_ext), changed);
ggiMesaID = ggiExtensionRegister("GGIMesa",
sizeof(struct ggi_mesa_ext), changed);
if (ggiMesaID < 0)
{
@@ -324,306 +366,6 @@ int ggiMesaInit()
return 0;
}
GGIMesaContext GGIMesaCreateContext(void)
{
GGIMesaContext ctx;
char *str;
GGIMESADPRINT_CORE("ggiMesaCreateContext() called\n");
if (ggiMesaInit() < 0) /* register extensions*/
{
return NULL;
}
ctx = (GGIMesaContext)calloc(1, sizeof(struct ggi_mesa_context));
if (!ctx)
return NULL;
ctx->gl_vis = (GLvisual *)calloc(1, sizeof(GLvisual));
if (!ctx->gl_vis)
return NULL;
ctx->viewport_init = GL_FALSE;
// ctx->gl_vis->DBflag = GL_FALSE;
ctx->gl_ctx = _mesa_create_context(ctx->gl_vis, NULL, (void *)ctx, GL_TRUE);
if (!ctx->gl_ctx)
return NULL;
_mesa_enable_sw_extensions(ctx->gl_ctx);
_swrast_CreateContext(ctx->gl_ctx);
_swsetup_CreateContext(ctx->gl_ctx);
_tnl_CreateContext(ctx->gl_ctx);
return ctx;
}
void GGIMesaDestroyContext(GGIMesaContext ctx)
{
GGIMESADPRINT_CORE("ggiMesaDestroyContext() called\n");
if (ctx)
{
_mesa_destroy_visual(ctx->gl_vis);
_mesa_destroy_context(ctx->gl_ctx);
_mesa_destroy_framebuffer(ctx->gl_buffer);
if (ctx == GGIMesa)
GGIMesa = NULL;
if (ctx->ggi_vis)
ggiExtensionDetach(ctx->ggi_vis, ggiMesaID);
ggiExtensionUnregister(ggiMesaID);
free(ctx);
}
}
int GGIMesaSetVisual(GGIMesaContext ctx, ggi_visual_t vis,
GLboolean rgb_flag, GLboolean db_flag)
{
struct ggi_mesa_info info;
int err;
uint16 r,g,b;
ggi_color pal[256];
int i;
void *func;
ggi_mode mode;
int num_buf;
GGIMESADPRINT_CORE("ggiMesaSetVisual() called\n");
if (!ctx) return -1;
if (!vis) return -1;
if (ctx->ggi_vis)
ggiExtensionDetach(ctx->ggi_vis, ggiMesaID);
ctx->ggi_vis=vis;
err = ggiExtensionAttach(vis, ggiMesaID);
if (err < 0)
return -1;
if (err == 0)
changed(vis, GGI_CHG_APILIST);
if (ctx->gl_vis)
_mesa_destroy_visual(ctx->gl_vis);
if (ctx->gl_buffer)
_mesa_destroy_framebuffer(ctx->gl_buffer);
info.rgb_flag = rgb_flag;
info.db_flag = db_flag;
err = gl_ggiInitInfo(ctx, &info);
if (err)
return -1;
gl_ggiSetupPointers(ctx->gl_ctx);
func = (void *)LIBGGI_MESAEXT(ctx->ggi_vis)->setup_driver;
if (!func)
{
GGIMESADPRINT_CORE("setup_driver==NULL!\n");
GGIMESADPRINT_CORE("Please check your config files!\n");
return -1;
}
err = LIBGGI_MESAEXT(ctx->ggi_vis)->setup_driver(ctx, &info);
if (err)
return -1;
ctx->gl_vis = _mesa_create_visual(info.rgb_flag,
info.db_flag,
GL_FALSE, /*stereo*/
info.red_bits, info.green_bits,
info.blue_bits, info.alpha_bits,
info.index_bits,
info.depth_bits,
info.stencil_bits,
info.accum_bits,
info.accum_bits,
info.accum_bits,
info.accum_bits,
1);
if (!ctx->gl_vis)
{
GGIMESADPRINT_CORE("Can't create gl_visual!\n");
return -1;
}
ctx->gl_buffer = _mesa_create_framebuffer(ctx->gl_vis,
// ctx->gl_vis->DepthBits > 0,
// ctx->gl_vis->StencilBits > 0,
// ctx->gl_vis->AccumRedBits > 0,
// ctx->gl_vis->AlphaBits > 0);
info.depth_bits > 0,
info.stencil_bits > 0,
info.accum_bits > 0,
info.alpha_bits > 0);
if (!ctx->gl_buffer)
{
GGIMESADPRINT_CORE("Can't create gl_buffer!\n");
return -1;
}
ggiGetMode(ctx->ggi_vis, &mode);
ctx->width = mode.visible.x;
ctx->height = mode.visible.y;
ctx->stride = mode.virt.x;
ctx->origin.x = 0;
ctx->origin.y = 0;
ctx->flip_y = ctx->origin.y + ctx->height - 1;
ctx->color = 0;
ctx->lfb[0] = ctx->lfb[1] = NULL;
num_buf = ggiDBGetNumBuffers(ctx->ggi_vis);
for (i = 0; i < num_buf; i++)
{
if (ggiDBGetBuffer(ctx->ggi_vis,i)->layout == blPixelLinearBuffer)
{
ctx->stride = ggiDBGetBuffer(ctx->ggi_vis, i)->buffer.plb.stride /
(ggiDBGetBuffer(ctx->ggi_vis, i)->buffer.plb.pixelformat->size / 8);
ctx->lfb[0] = ggiDBGetBuffer(ctx->ggi_vis, i)->write;
}
}
if (ctx->lfb[0] == NULL)
{
GGIMESADPRINT_CORE("No linear frame buffer!\n");
return -1;
}
/* FIXME: Use separate buffers */
ctx->lfb[1] = malloc(ctx->stride * ctx->height);
ctx->bufsize = (ctx->stride * ctx->height);
ctx->gl_ctx->Visual = *ctx->gl_vis;
ctx->gl_ctx->Pixel.ReadBuffer =
ctx->gl_ctx->Color.DrawBuffer = (db_flag) ? GL_BACK : GL_FRONT;
if (GGIMesa == ctx)
_mesa_make_current(ctx->gl_ctx, ctx->gl_buffer);
if (rgb_flag && mode.graphtype==GT_8BIT)
{
for (i = r = 0; r < 8; r++)
for (g = 0; g < 8; g++)
for (b = 0; b < 4; b++, i++)
{
pal[i].r = r << (GGI_COLOR_PRECISION - 3);
pal[i].g = g << (GGI_COLOR_PRECISION - 3);
pal[i].b = b << (GGI_COLOR_PRECISION - 2);
}
ggiSetPalette(ctx->ggi_vis, 0, 256, pal);
}
return 0;
}
void GGIMesaMakeCurrent(GGIMesaContext ctx)
{
GGIMESADPRINT_CORE("ggiMesaMakeCurrent(ctx = %p) called\n", ctx);
if (!ctx->ggi_vis)
return;
GGIMesa = ctx;
_mesa_make_current(ctx->gl_ctx, ctx->gl_buffer);
if (!ctx->viewport_init)
{
_mesa_set_viewport(ctx->gl_ctx, 0, 0, ctx->width, ctx->height);
ctx->viewport_init = GL_TRUE;
}
}
GGIMesaContext GGIMesaGetCurrentContext(void)
{
GGIMESADPRINT_CORE("ggiMesaGetCurrentContext() called\n");
return GGIMesa;
}
/*
* Swap front/back buffers for current context if double buffered.
*/
void GGIMesaSwapBuffers(void)
{
GGIMESADPRINT_CORE("ggiMesaSwapBuffers() called\n");
_mesa_swapbuffers( GGIMesa->gl_ctx );
gl_ggiFlush(GGIMesa->gl_ctx);
// if (GGIMesa->gl_vis->DBflag)
// {
memcpy(GGIMesa->lfb[0], GGIMesa->lfb[1], GGIMesa->bufsize);
// }
}
static void gl_ggiUpdateState(GLcontext *ctx, GLuint new_state)
{
void *func;
GGIMESADPRINT_CORE("gl_ggiUpdateState() called\n");
/* Propogate statechange information to swrast and swrast_setup
* modules. The GGI driver has no internal GL-dependent state.
*/
_swrast_InvalidateState(ctx, new_state);
_swsetup_InvalidateState(ctx, new_state);
_tnl_InvalidateState(ctx, new_state);
func = (void *)CTX_OPMESA(ctx)->update_state;
if (!func) {
GGIMESADPRINT_CORE("update_state == NULL!\n");
GGIMESADPRINT_CORE("Please check your config files!\n");
ggiPanic("");
}
CTX_OPMESA(ctx)->update_state(ctx);
}
static int changed(ggi_visual_t vis, int whatchanged)
{
GGIMESADPRINT_CORE("changed() called\n");
switch (whatchanged)
{
case GGI_CHG_APILIST:
{
char api[256];
char args[256];
int i;
const char *fname;
ggi_dlhandle *lib;
for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++)
{
strcat(api, "-mesa");
fname = ggMatchConfig(_ggimesaConfigHandle, api, NULL);
if (fname == NULL)
{
/* No special implementation for this sublib */
continue;
}
lib = ggiExtensionLoadDL(vis, fname, args, NULL, GGI_SYMNAME_PREFIX);
}
}
break;
}
return 0;
}
int ggiMesaExit(void)
{
int rc;
@@ -631,7 +373,7 @@ int ggiMesaExit(void)
GGIMESADPRINT_CORE("ggiMesaExit() called\n");
if (!_ggimesaLibIsUp)
return -1;
return -1;
if (_ggimesaLibIsUp > 1)
{
@@ -648,13 +390,6 @@ int ggiMesaExit(void)
return rc;
}
static int _ggi_error(void)
{
GGIMESADPRINT_CORE("_ggi_error() called\n");
return -1;
}
int ggiMesaAttach(ggi_visual_t vis)
{
int rc;
@@ -664,10 +399,24 @@ int ggiMesaAttach(ggi_visual_t vis)
rc = ggiExtensionAttach(vis, ggiMesaID);
if (rc == 0)
{
int r, g, b, ci;
GLboolean rgb, db;
GLvisual *gl_visual;
GLframebuffer *gl_fb;
/* We are creating the primary instance */
memset(LIBGGI_MESAEXT(vis), 0, sizeof(mesaext));
memset(LIBGGI_MESAEXT(vis), 0, sizeof(struct ggi_mesa_ext));
LIBGGI_MESAEXT(vis)->update_state = (void *)_ggi_error;
LIBGGI_MESAEXT(vis)->setup_driver = (void *)_ggi_error;
/* Initialize default mesa visual */
get_mode_info(vis, &r, &g, &b, &rgb, &db, &ci);
gl_visual = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual);
_mesa_initialize_visual(gl_visual,
rgb, db, 0 /* No stereo */,
r, g, b, 0 /* No alpha */, ci,
0 /* No depth */, 0 /* No stencil */,
0, 0, 0, 0 /* No accum */, 0);
/* Now fake an "API change" so the right libs get loaded */
changed(vis, GGI_CHG_APILIST);
@@ -682,3 +431,230 @@ int ggiMesaDetach(ggi_visual_t vis)
return ggiExtensionDetach(vis, ggiMesaID);
}
int ggiMesaExtendVisual(ggi_visual_t vis, GLboolean alpha_flag,
GLboolean stereo_flag, GLint depth_size,
GLint stencil_size, GLint accum_red_size,
GLint accum_green_size, GLint accum_blue_size,
GLint accum_alpha_size, GLint num_samples)
{
GLvisual *gl_vis = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual);
int r, g, b, ci;
GLboolean db, rgb;
get_mode_info(vis, &r, &g, &b, &rgb, &db, &ci);
/* Initialize the visual with the provided information */
_mesa_initialize_visual(&(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual),
rgb, db, stereo_flag,
r, g, b, 0 /* FIXME */, ci,
depth_size, stencil_size,
accum_red_size, accum_green_size,
accum_blue_size, accum_alpha_size, 0);
/* Now fake an "API change" so the right libs get loaded. After all,
extending the visual by all these new buffers could be considered
a "mode change" which requires an "API change".
*/
changed(vis, GGI_CHG_APILIST);
return 0;
}
ggi_mesa_context_t ggiMesaCreateContext(ggi_visual_t vis)
{
ggi_mesa_context_t ctx;
int err;
ggi_color pal[256];
int i;
GGIMESADPRINT_CORE("ggiMesaCreateContext() called\n");
ctx = (ggi_mesa_context_t)malloc(sizeof(struct ggi_mesa_context));
if (!ctx)
return NULL;
ctx->ggi_visual = vis;
ctx->color = 0;
ctx->gl_ctx =
_mesa_create_context(&(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual),
NULL, (void *)ctx, GL_TRUE);
if (!ctx->gl_ctx)
goto free_context;
_mesa_enable_sw_extensions(ctx->gl_ctx);
_swrast_CreateContext(ctx->gl_ctx);
_ac_CreateContext(ctx->gl_ctx);
_tnl_CreateContext(ctx->gl_ctx);
_swsetup_CreateContext(ctx->gl_ctx);
gl_ggiSetupPointers(ctx->gl_ctx);
/* Make sure that an appropriate sublib has been loaded */
if (!LIBGGI_MESAEXT(ctx->ggi_visual)->setup_driver){
GGIMESADPRINT_CORE("setup_driver==NULL!\n");
GGIMESADPRINT_CORE("Please check your config files!\n");
goto free_context;
}
/* Set up the sublib driver */
err = LIBGGI_MESAEXT(ctx->ggi_visual)->setup_driver(ctx);
if (err){
GGIMESADPRINT_CORE("setup_driver failed (err = %d)", err);
goto free_gl_context;
}
_mesa_read_config_file(ctx->gl_ctx);
return ctx;
free_gl_context:
_mesa_destroy_context(ctx->gl_ctx);
free_context:
free(ctx);
return NULL;
}
void ggiMesaDestroyContext(ggi_mesa_context_t ctx)
{
GGIMESADPRINT_CORE("ggiMesaDestroyContext() called\n");
if(!ctx)
return;
_mesa_destroy_context(ctx->gl_ctx);
free(ctx);
}
void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis)
{
GGIMESADPRINT_CORE("ggiMesaMakeCurrent(ctx = %p) called\n", ctx);
/* FIXME: clean up where are ggi_vis */
if (ctx->ggi_visual != vis) {
GGIMESADPRINT_CORE("Cannot migrate GL contexts\n");
return;
}
_mesa_make_current(ctx->gl_ctx, &LIBGGI_MESAEXT(vis)->mesa_buffer);
if (ctx->gl_ctx->Viewport.Width == 0)
{
_mesa_Viewport(0, 0,
LIBGGI_MODE(vis)->visible.x,
LIBGGI_MODE(vis)->visible.y);
ctx->gl_ctx->Scissor.Width = LIBGGI_MODE(vis)->visible.x;
ctx->gl_ctx->Scissor.Height = LIBGGI_MODE(vis)->visible.y;
}
}
/*
* Swap front/back buffers for current context if double buffered.
*/
void ggiMesaSwapBuffers(void)
{
GLcontext *ctx;
ggi_mesa_context_t ggi_ctx;
ctx = _mesa_get_current_context();
ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
GGIMESADPRINT_CORE("ggiMesaSwapBuffers() called\n");
_mesa_swapbuffers(ctx);
gl_ggiFlush(ctx);
ggiSetDisplayFrame(ggi_ctx->ggi_visual,
!ggiGetDisplayFrame(ggi_ctx->ggi_visual));
ggiSetWriteFrame(ggi_ctx->ggi_visual,
!ggiGetWriteFrame(ggi_ctx->ggi_visual));
ggiSetReadFrame(ggi_ctx->ggi_visual,
!ggiGetReadFrame(ggi_ctx->ggi_visual));
GGIMESADPRINT_CORE("swap disp: %d, write %d\n",
ggiGetDisplayFrame(ggi_ctx->ggi_visual),
ggiGetWriteFrame(ggi_ctx->ggi_visual));
}
static void gl_ggiUpdateState(GLcontext *ctx, GLuint new_state)
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
GGIMESADPRINT_CORE("gl_ggiUpdateState() called\n");
/* Propogate statechange information to swrast and swrast_setup
* modules. The GGI driver has no internal GL-dependent state.
*/
_swrast_InvalidateState(ctx, new_state);
_swsetup_InvalidateState(ctx, new_state);
_tnl_InvalidateState(ctx, new_state);
if (!LIBGGI_MESAEXT(ggi_ctx->ggi_visual)->update_state) {
GGIMESADPRINT_CORE("update_state == NULL!\n");
GGIMESADPRINT_CORE("Please check your config files!\n");
ggiPanic("");
}
LIBGGI_MESAEXT(ggi_ctx->ggi_visual)->update_state(ggi_ctx);
}
static int changed(ggi_visual_t vis, int whatchanged)
{
GLcontext *ctx;
ctx = _mesa_get_current_context();
GGIMESADPRINT_CORE("changed() called\n");
switch (whatchanged)
{
case GGI_CHG_APILIST:
{
char api[256];
char args[256];
int i;
const char *fname;
ggi_dlhandle *lib;
GLvisual *gl_vis=&(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual);
GLframebuffer *gl_fb = &(LIBGGI_MESAEXT(vis)->mesa_buffer);
/* Initialize the framebuffer to provide all necessary
buffers in software. The target libraries that are loaded
next are free to modify this according to their
capabilities.
*/
/* FIXME: if the target changes capabilities we'll leak
swrast's memory !!! Need to deallocate first */
_mesa_initialize_framebuffer(gl_fb, gl_vis,
gl_vis->depthBits > 0,
gl_vis->stencilBits > 0,
gl_vis->accumRedBits > 0,
gl_vis->alphaBits > 0);
for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++)
{
strcat(api, "-mesa");
fname = ggMatchConfig(_ggimesaConfigHandle, api, NULL);
if (fname == NULL)
{
/* No special implementation for this sublib */
continue;
}
lib = ggiExtensionLoadDL(vis, fname, args, NULL,
GGI_SYMNAME_PREFIX);
}
/* The targets have cleared everything they can do from
the framebuffer structure so we provide the rest in sw
*/
_swrast_alloc_buffers(gl_fb);
break;
}
}
return 0;
}

View File

@@ -45,50 +45,40 @@
#include <ggi/ggi.h>
#include "GL/ggimesa.h"
struct ggi_mesa_info;
/*
* GGIMesa visual configuration.
*
* This structure "derives" from Mesa's GLvisual and extends it by
* GGI's visual. Combination of these two structures is enough to fully
* describe the mode the application is currently running in. GGI
* visual provides information about color configuration and buffering
* method, GLvisual fills the rest.
*/
struct ggi_mesa_visual {
GLvisual gl_visual;
ggi_visual_t ggi_visual;
};
/*
* GGIMesa context.
*
* GGIMesa context expands the Mesa's context (it doesn't actualy derive
* from it, but this ability isn't needed, and it is best if GL context
* creation is left up to Mesa). It also contains a reference to the GGI
* visual it is attached to, which is very useful for all Mesa callbacks.
*/
struct ggi_mesa_context
{
GLcontext *gl_ctx;
GLvisual *gl_vis;
GLframebuffer *gl_buffer;
ggi_visual_t ggi_visual;
ggi_visual_t ggi_vis;
ggi_coord origin;
int flip_y;
int width, height, stride; /* Stride is in pixels */
ggi_pixel color; /* Current color or index*/
ggi_pixel clearcolor;
void *lfb[2]; /* Linear frame buffers */
int active_buffer;
int bufsize;
int viewport_init;
void *private;
};
struct ggi_mesa_info
{
GLboolean rgb_flag;
GLboolean db_flag;
GLboolean alpha_flag;
GLint index_bits;
GLint red_bits, green_bits, blue_bits, alpha_bits;
GLint depth_bits, stencil_bits, accum_bits;
};
extern GGIMesaContext GGIMesa; /* The current context */
#define SHIFT (GGI_COLOR_PRECISION - 8)
#define GGICTX ((GGIMesaContext)ctx->DriverCtx)
#define VIS (GGICTX->ggi_vis)
#define FLIP(y) (GGICTX->flip_y-(y))
#define LFB(type,x,y) ((type *)GGICTX->lfb[0] + (x) + (y) * GGICTX->stride)
#define CTX_OPMESA(ctx) \
((struct mesa_ext *)LIBGGI_EXT(((GGIMesaContext)ctx->DriverCtx)->ggi_vis, \
ggiMesaID))
#endif

View File

@@ -11,14 +11,35 @@ extern ggi_extid ggiMesaID;
ggifunc_setmode GGIMesa_setmode;
ggifunc_getapi GGIMesa_getapi;
typedef struct mesa_ext
typedef struct ggi_mesa_ext
{
void (*update_state)(GLcontext *ctx);
int (*setup_driver)(GGIMesaContext ctx, struct ggi_mesa_info *info);
void *private;
} mesaext;
/*
* How mesa extends this visual; i.e., size of the depth buffer etc.
*
* By default (upon attaching) this structure is initialized to what
* libggi is guaranteed to handle without any help: single buffered
* visual without any ancilary buffers.
*/
struct ggi_mesa_visual mesa_visual;
#define LIBGGI_MESAEXT(vis) ((mesaext *)LIBGGI_EXT(vis,ggiMesaID))
/*
* Mesa framebuffer is a collection of all ancilary buffers required.
*
* This structure contains the ancilary buffers provided in in
* software. On each mode change it is loaded with the list of
* required buffers and the target is expected to clear the ones
* it can provide in hw. The remaining ones are then provided in sw.
*
*/
GLframebuffer mesa_buffer;
void (*update_state)(ggi_mesa_context_t ctx);
int (*setup_driver)(ggi_mesa_context_t ctx);
void *private;
} ggi_mesa_ext_t;
#define LIBGGI_MESAEXT(vis) ((ggi_mesa_ext_t *)LIBGGI_EXT(vis,ggiMesaID))
#define GGIMESA_PRIVATE(vis) ((LIBGGI_MESAEXT(vis)->private))
#endif /* _GGI_MISC_INT_H */

View File

@@ -1,10 +1,10 @@
/* $Id: fxdd.c,v 1.84 2001/09/23 16:50:01 brianp Exp $ */
/* $Id: fxdd.c,v 1.84.2.3 2002/06/24 17:37:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 4.0
* Version: 4.0.3
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -47,6 +47,7 @@
#include "extensions.h"
#include "texstore.h"
#include "swrast/swrast.h"
#include "swrast/s_context.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
@@ -103,19 +104,22 @@ fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder)
/* Return buffer size information */
static void
fxDDBufferSize(GLcontext * ctx, GLuint * width, GLuint * height)
fxDDBufferSize(GLframebuffer *buffer, GLuint * width, GLuint * height)
{
fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
GET_CURRENT_CONTEXT(ctx);
if (ctx && ctx->DriverCtx) {
fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr, "fxmesa: fxDDBufferSize(...) Start\n");
}
if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr, "fxmesa: fxDDBufferSize(...) Start\n");
}
*width = fxMesa->width;
*height = fxMesa->height;
*width = fxMesa->width;
*height = fxMesa->height;
if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr, "fxmesa: fxDDBufferSize(...) End\n");
if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr, "fxmesa: fxDDBufferSize(...) End\n");
}
}
}
@@ -261,7 +265,7 @@ fxDDClear(GLcontext * ctx, GLbitfield mask, GLboolean all,
/* Set the buffer used for drawing */
/* XXX support for separate read/draw buffers hasn't been tested */
static GLboolean
static void
fxDDSetDrawBuffer(GLcontext * ctx, GLenum mode)
{
fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
@@ -273,26 +277,22 @@ fxDDSetDrawBuffer(GLcontext * ctx, GLenum mode)
if (mode == GL_FRONT_LEFT) {
fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
FX_grRenderBuffer(fxMesa->currentFB);
return GL_TRUE;
}
else if (mode == GL_BACK_LEFT) {
fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
FX_grRenderBuffer(fxMesa->currentFB);
return GL_TRUE;
}
else if (mode == GL_NONE) {
FX_grColorMask(FXFALSE, FXFALSE);
return GL_TRUE;
}
else {
return GL_FALSE;
/* we'll need a software fallback */
/* XXX not implemented */
}
}
static void
fxDDDrawBitmap(GLcontext * ctx, GLint px, GLint py,
GLsizei width, GLsizei height,
@@ -304,6 +304,7 @@ fxDDDrawBitmap(GLcontext * ctx, GLint px, GLint py,
FxU16 color;
const struct gl_pixelstore_attrib *finalUnpack;
struct gl_pixelstore_attrib scissoredUnpack;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* check if there's any raster operations enabled which we can't handle */
if (ctx->Color.AlphaEnabled ||
@@ -314,12 +315,11 @@ fxDDDrawBitmap(GLcontext * ctx, GLint px, GLint py,
ctx->Stencil.Enabled ||
ctx->Scissor.Enabled ||
(ctx->DrawBuffer->UseSoftwareAlphaBuffers &&
ctx->Color.ColorMask[ACOMP]) || ctx->Color.MultiDrawBuffer) {
ctx->Color.ColorMask[ACOMP]) || (swrast->_RasterMask & MULTI_DRAW_BIT)) {
_swrast_Bitmap(ctx, px, py, width, height, unpack, bitmap);
return;
}
if (ctx->Scissor.Enabled) {
/* This is a bit tricky, but by carefully adjusting the px, py,
* width, height, skipPixels and skipRows values we can do
@@ -821,12 +821,13 @@ GLboolean
fx_check_IsInHardware(GLcontext * ctx)
{
fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (ctx->RenderMode != GL_RENDER)
return GL_FALSE;
if (ctx->Stencil.Enabled ||
ctx->Color.MultiDrawBuffer ||
(swrast->_RasterMask & MULTI_DRAW_BIT) ||
((ctx->Color.BlendEnabled)
&& (ctx->Color.BlendEquation != GL_FUNC_ADD_EXT))
|| ((ctx->Color.ColorLogicOpEnabled)
@@ -1002,7 +1003,7 @@ fxSetupDDPointers(GLcontext * ctx)
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = fxDDReadPixels;
ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.Finish = fxDDFinish;
ctx->Driver.Flush = NULL;
ctx->Driver.ChooseTextureFormat = fxDDChooseTextureFormat;

View File

@@ -1,4 +1,4 @@
/* $Id: fxvb.c,v 1.11 2001/09/23 16:50:01 brianp Exp $ */
/* $Id: fxvb.c,v 1.11.2.1 2002/06/06 16:15:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -342,8 +342,8 @@ void fxChooseVertexState( GLcontext *ctx )
fxMesa->tmu_source[0] = 0;
fxMesa->tmu_source[1] = 1;
if (ctx->Texture._ReallyEnabled & 0xf0) {
if (ctx->Texture._ReallyEnabled & 0xf) {
if (ctx->Texture._ReallyEnabled & TEXTURE1_ANY) {
if (ctx->Texture._ReallyEnabled & TEXTURE0_ANY) {
ind |= SETUP_TMU1|SETUP_TMU0;
}
else {
@@ -352,7 +352,7 @@ void fxChooseVertexState( GLcontext *ctx )
ind |= SETUP_TMU0;
}
}
else if (ctx->Texture._ReallyEnabled & 0xf) {
else if (ctx->Texture._ReallyEnabled & TEXTURE0_ANY) {
ind |= SETUP_TMU0;
}

View File

@@ -1,10 +1,10 @@
/* $Id: osmesa.c,v 1.71 2001/09/25 17:38:11 keithw Exp $ */
/* $Id: osmesa.c,v 1.71.2.8 2002/06/25 15:23:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.0.3
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -37,6 +37,7 @@
#include "glheader.h"
#include "GL/osmesa.h"
#include "buffers.h"
#include "context.h"
#include "colormac.h"
#include "depth.h"
@@ -427,21 +428,19 @@ static void compute_row_addresses( OSMesaContext ctx )
* with the lower-left image pixel stored in the first array position
* (ie. bottom-to-top).
*
* Since the only type initially supported is GL_UNSIGNED_BYTE, if the
* context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
* value. If the context is in color indexed mode, each pixel will be
* stored as a 1-byte value.
*
* If the context's viewport hasn't been initialized yet, it will now be
* initialized to (0,0,width,height).
*
* Input: ctx - the rendering context
* buffer - the image buffer memory
* type - data type for pixel components, only GL_UNSIGNED_BYTE
* and GL_UNSIGNED_SHORT_5_6_5 supported now.
* type - data type for pixel components
* Normally, only GL_UNSIGNED_BYTE and GL_UNSIGNED_SHORT_5_6_5
* are supported. But if Mesa's been compiled with CHAN_BITS==16
* then type must be GL_UNSIGNED_SHORT. And if Mesa's been build
* with CHAN_BITS==32 then type must be GL_FLOAT.
* width, height - size of image buffer in pixels, at least 1
* Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
* invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
* invalid buffer address, invalid type, width<1, height<1,
* width>internal limit or height>internal limit.
*/
GLAPI GLboolean GLAPIENTRY
@@ -482,6 +481,10 @@ OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
ctx->gl_ctx.Scissor.Width = width;
ctx->gl_ctx.Scissor.Height = height;
}
else {
/* this will make ensure we recognize the new buffer size */
_mesa_ResizeBuffersMESA();
}
return GL_TRUE;
}
@@ -669,15 +672,11 @@ do { \
static GLboolean set_draw_buffer( GLcontext *ctx, GLenum mode )
static void set_draw_buffer( GLcontext *ctx, GLenum mode )
{
/* A no-op since there's only one color buffer! */
(void) ctx;
if (mode==GL_FRONT_LEFT) {
return GL_TRUE;
}
else {
return GL_FALSE;
}
(void) mode;
}
@@ -878,11 +877,21 @@ static void clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
static void buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
static void buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
*width = osmesa->width;
*height = osmesa->height;
#ifdef WIN32
/* Hack to get around problems with exporting glapi_Context from MesaGL
and importing into OSMesa. */
GLcontext *ctx = (GLcontext *) _glapi_get_context();
#else
GET_CURRENT_CONTEXT(ctx);
#endif
(void) buffer;
if (ctx) {
OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
*width = osmesa->width;
*height = osmesa->height;
}
}
@@ -1773,6 +1782,7 @@ osmesa_choose_line_function( GLcontext *ctx )
osmesa->format != OSMESA_BGRA &&
osmesa->format != OSMESA_ARGB) return NULL;
if (swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
@@ -1922,6 +1932,9 @@ osmesa_choose_triangle_function( GLcontext *ctx )
if (osmesa->format != OSMESA_RGBA &&
osmesa->format != OSMESA_BGRA &&
osmesa->format != OSMESA_ARGB) return (swrast_tri_func) NULL;
if (ctx->Polygon.CullFlag &&
ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
return (swrast_tri_func) NULL;
if (swrast->_RasterMask == DEPTH_BIT &&
ctx->Depth.Func == GL_LESS &&
@@ -1997,7 +2010,13 @@ static const GLubyte *get_string( GLcontext *ctx, GLenum name )
(void) ctx;
switch (name) {
case GL_RENDERER:
#if CHAN_BITS == 32
return (const GLubyte *) "Mesa OffScreen32";
#elif CHAN_BITS == 16
return (const GLubyte *) "Mesa OffScreen16";
#else
return (const GLubyte *) "Mesa OffScreen";
#endif
default:
return NULL;
}
@@ -2020,8 +2039,8 @@ static void osmesa_update_state( GLcontext *ctx, GLuint new_state )
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = osmesa_update_state;
ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
ctx->Driver.GetBufferSize = buffer_size;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.Accum = _swrast_Accum;
ctx->Driver.Bitmap = _swrast_Bitmap;

View File

@@ -1,4 +1,4 @@
/* $Id: svgamesa.c,v 1.16 2001/09/23 16:11:27 brianp Exp $ */
/* $Id: svgamesa.c,v 1.16.2.2 2002/06/14 03:49:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -210,13 +210,13 @@ static void copy_buffer( const GLubyte * buffer) {
}
}
static void get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
*width = SVGAMesa->width = vga_getxdim();
*height = SVGAMesa->height = vga_getydim();
}
static GLboolean set_draw_buffer( GLcontext *ctx, GLenum buffer )
static void set_draw_buffer( GLcontext *ctx, GLenum buffer )
{
if (buffer == GL_FRONT_LEFT) {
SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
@@ -228,7 +228,6 @@ static GLboolean set_draw_buffer( GLcontext *ctx, GLenum buffer )
SVGABuffer.BackBuffer=SVGABuffer.FrontBuffer;
SVGABuffer.FrontBuffer=tmpptr;
#endif
return GL_TRUE;
}
else if (buffer == GL_BACK_LEFT) {
SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
@@ -236,10 +235,10 @@ static GLboolean set_draw_buffer( GLcontext *ctx, GLenum buffer )
/* vga_waitretrace(); */
copy_buffer(SVGABuffer.BackBuffer);
#endif
return GL_TRUE;
}
else
return GL_FALSE;
else {
/* nothing since we don't have any point/line/triangle functions. */
}
}
@@ -286,6 +285,7 @@ static void svgamesa_update_state( GLcontext *ctx, GLuint new_state )
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
/* Software rasterizer pixel paths:
*/

View File

@@ -1,499 +1,521 @@
/* File name : colors.h
* Version : 2.3
*
* Header file for display driver for Mesa 2.3 under
* Windows95 and WindowsNT
* This file defines macros and global variables needed
* for converting color format
*
* Copyright (C) 1996- Li Wei
* Address : Institute of Artificial Intelligence
* : & Robotics
* : Xi'an Jiaotong University
* Email : liwei@aiar.xjtu.edu.cn
* Web page : http://sun.aiar.xjtu.edu.cn
*
* This file and its associations are partially based on the
* Windows NT driver for Mesa, written by Mark Leaming
* (mark@rsinc.com).
*/
/* $Log: ddcolors.h 1997/6/14 by Li Wei(liwei@aiar.xjtu.edu.cn)
* Macros for pixel format defined
*/
/*
/* File name : colors.h
* Version : 2.3
*
* Header file for display driver for Mesa 2.3 under
* Windows95 and WindowsNT
* This file defines macros and global variables needed
* for converting color format
*
* Copyright (C) 1996- Li Wei
* Address : Institute of Artificial Intelligence
* : & Robotics
* : Xi'an Jiaotong University
* Email : liwei@aiar.xjtu.edu.cn
* Web page : http://sun.aiar.xjtu.edu.cn
*
* This file and its associations are partially based on the
* Windows NT driver for Mesa, written by Mark Leaming
* (mark@rsinc.com).
*/
/* $Log: ddcolors.h 1997/6/14 by Li Wei(liwei@aiar.xjtu.edu.cn)
* Macros for pixel format defined
*/
/*
* $Log: colors.h,v $
* Revision 1.1 1999/08/19 00:55:42 jtg
* Initial revision
* Revision 1.1.1.1.8.2 2002/01/15 16:47:37 kschultz
* Fixed pixel color component problem and clear code for 24-bit Windows
* devices. (Jeff Lewis)
*
* Revision 1.1.1.1.8.1 2002/01/15 16:12:15 kschultz
* Remove trailing CR's from most of the lines. No logical changes.
*
* Revision 1.1.1.1 1999/08/19 00:55:42 jtg
* Imported sources
*
* Revision 1.2 1999/01/03 03:08:57 brianp
* Ted Jump's changes
*
* Revision 1.1 1999/01/03 03:08:12 brianp
* Initial revision
*
* Revision 2.0.2 1997/4/30 15:58:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
* Add LUTs need for dithering
*/
/*
*
* Revision 2.0.2 1997/4/30 15:58:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
* Add LUTs need for dithering
*/
/*
* $Log: colors.h,v $
* Revision 1.1 1999/08/19 00:55:42 jtg
* Initial revision
* Revision 1.1.1.1.8.2 2002/01/15 16:47:37 kschultz
* Fixed pixel color component problem and clear code for 24-bit Windows
* devices. (Jeff Lewis)
*
* Revision 1.1.1.1.8.1 2002/01/15 16:12:15 kschultz
* Remove trailing CR's from most of the lines. No logical changes.
*
* Revision 1.1.1.1 1999/08/19 00:55:42 jtg
* Imported sources
*
* Revision 1.2 1999/01/03 03:08:57 brianp
* Ted Jump's changes
*
* Revision 1.1 1999/01/03 03:08:12 brianp
* Initial revision
*
* Revision 2.0.1 1997/4/29 15:52:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
* Add BGR8 Macro
*/
/*
*
* Revision 2.0.1 1997/4/29 15:52:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
* Add BGR8 Macro
*/
/*
* $Log: colors.h,v $
* Revision 1.1 1999/08/19 00:55:42 jtg
* Initial revision
* Revision 1.1.1.1.8.2 2002/01/15 16:47:37 kschultz
* Fixed pixel color component problem and clear code for 24-bit Windows
* devices. (Jeff Lewis)
*
* Revision 1.1.1.1.8.1 2002/01/15 16:12:15 kschultz
* Remove trailing CR's from most of the lines. No logical changes.
*
* Revision 1.1.1.1 1999/08/19 00:55:42 jtg
* Imported sources
*
* Revision 1.2 1999/01/03 03:08:57 brianp
* Ted Jump's changes
*
* Revision 1.1 1999/01/03 03:08:12 brianp
* Initial revision
*
* Revision 2.0 1996/11/15 10:55:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
* Initial revision
*/
/* Values for wmesa->pixelformat: */
#define PF_8A8B8G8R 3 /* 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */
#define PF_8R8G8B 4 /* 32-bit TrueColor: 8-R, 8-G, 8-B */
#define PF_5R6G5B 5 /* 16-bit TrueColor: 5-R, 6-G, 5-B bits */
#define PF_DITHER8 6 /* Dithered RGB using a lookup table */
#define PF_LOOKUP 7 /* Undithered RGB using a lookup table */
#define PF_GRAYSCALE 10 /* Grayscale or StaticGray */
#define PF_BADFORMAT 11
#define PF_INDEX8 12
char ColorMap16[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,
0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,
0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,
0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,
0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,
0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,
0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};
#define BGR8(r,g,b) (unsigned)(((BYTE)(b & 0xc0 | (g & 0xe0)>>2 | (r & 0xe0)>>5)))
#ifdef DDRAW
#define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(g&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[r])) << 11)))
#else
#define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(ColorMap16[g]) << 5)) | (((WORD)(BYTE)(ColorMap16[r])) << 10)))
#endif
#define BGR24(r,g,b) (unsigned long)(((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16))) << 8)
#define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
/*
* If pixelformat==PF_8A8B8G8R:
*/
#define PACK_8A8B8G8R( R, G, B, A ) \
( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
/*
* If pixelformat==PF_8R8G8B:
*/
#define PACK_8R8G8B( R, G, B) ( ((R) << 16) | ((G) << 8) | (B) )
/*
* If pixelformat==PF_5R6G5B:
*/
#ifdef DDRAW
#define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(G&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[R])) << 11)))
#else
#define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(ColorMap16[G]) << 5)) | (((WORD)(BYTE)(ColorMap16[R])) << 10)))
#endif
/*----------------------------------------------------------------------------
Division lookup tables. These tables compute 0-255 divided by 51 and
modulo 51. These tables could approximate gamma correction.
*/
char unsigned const aDividedBy51Rounded[256] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
};
char unsigned const aDividedBy51[256] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
};
char unsigned const aModulo51[256] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0,
};
/*----------------------------------------------------------------------------
Multiplication LUTs. These compute 0-5 times 6 and 36.
*/
char unsigned const aTimes6[6] =
{
0, 6, 12, 18, 24, 30
};
char unsigned const aTimes36[6] =
{
0, 36, 72, 108, 144, 180
};
/*----------------------------------------------------------------------------
Dither matrices for 8 bit to 2.6 bit halftones.
*/
char unsigned const aHalftone16x16[256] =
{
0, 44, 9, 41, 3, 46, 12, 43, 1, 44, 10, 41, 3, 46, 12, 43,
34, 16, 25, 19, 37, 18, 28, 21, 35, 16, 26, 19, 37, 18, 28, 21,
38, 6, 47, 3, 40, 9, 50, 6, 38, 7, 47, 4, 40, 9, 49, 6,
22, 28, 13, 31, 25, 31, 15, 34, 22, 29, 13, 32, 24, 31, 15, 34,
2, 46, 12, 43, 1, 45, 10, 42, 2, 45, 11, 42, 1, 45, 11, 42,
37, 18, 27, 21, 35, 17, 26, 20, 36, 17, 27, 20, 36, 17, 26, 20,
40, 8, 49, 5, 38, 7, 48, 4, 39, 8, 48, 5, 39, 7, 48, 4,
24, 30, 15, 33, 23, 29, 13, 32, 23, 30, 14, 33, 23, 29, 14, 32,
2, 46, 12, 43, 0, 44, 10, 41, 3, 47, 12, 44, 0, 44, 10, 41,
37, 18, 27, 21, 35, 16, 25, 19, 37, 19, 28, 22, 35, 16, 25, 19,
40, 9, 49, 5, 38, 7, 47, 4, 40, 9, 50, 6, 38, 6, 47, 3,
24, 30, 15, 34, 22, 29, 13, 32, 25, 31, 15, 34, 22, 28, 13, 31,
1, 45, 11, 42, 2, 46, 11, 42, 1, 45, 10, 41, 2, 46, 11, 43,
36, 17, 26, 20, 36, 17, 27, 21, 35, 16, 26, 20, 36, 18, 27, 21,
39, 8, 48, 4, 39, 8, 49, 5, 38, 7, 48, 4, 39, 8, 49, 5,
23, 29, 14, 33, 24, 30, 14, 33, 23, 29, 13, 32, 24, 30, 14, 33,
};
char unsigned const aHalftone8x8[64] =
{
0, 38, 9, 47, 2, 40, 11, 50,
25, 12, 35, 22, 27, 15, 37, 24,
6, 44, 3, 41, 8, 47, 5, 43,
31, 19, 28, 15, 34, 21, 31, 18,
1, 39, 11, 49, 0, 39, 10, 48,
27, 14, 36, 23, 26, 13, 35, 23,
7, 46, 4, 43, 7, 45, 3, 42,
33, 20, 30, 17, 32, 19, 29, 16,
};
char unsigned const aHalftone4x4_1[16] =
{
0, 25, 6, 31,
38, 12, 44, 19,
9, 35, 3, 28,
47, 22, 41, 15
};
char unsigned const aHalftone4x4_2[16] =
{
41, 3, 9, 28,
35, 15, 22, 47,
6, 25, 38, 0,
19, 44, 31, 12
};
/***************************************************************************
aWinGHalftoneTranslation
Translates a 2.6 bit-per-pixel halftoned representation into the
slightly rearranged WinG Halftone Palette.
*/
char unsigned const aWinGHalftoneTranslation[216] =
{
0,
29,
30,
31,
32,
249,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
250,
250,
57,
58,
59,
251,
60,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
250,
90,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
110,
111,
227,
112,
113,
114,
115,
116,
117,
118,
119,
151,
120,
121,
122,
123,
124,
228,
125,
126,
229,
133,
162,
135,
131,
132,
137,
166,
134,
140,
130,
136,
143,
138,
139,
174,
141,
142,
177,
129,
144,
145,
146,
147,
148,
149,
150,
157,
152,
153,
154,
155,
156,
192,
158,
159,
160,
161,
196,
163,
164,
165,
127,
199,
167,
168,
169,
170,
171,
172,
173,
207,
175,
176,
210,
178,
179,
180,
181,
182,
183,
184,
185,
186,
187,
188,
189,
190,
191,
224,
193,
194,
195,
252,
252,
197,
198,
128,
253,
252,
200,
201,
202,
203,
204,
205,
206,
230,
208,
209,
231,
211,
212,
213,
214,
215,
216,
217,
218,
219,
220,
221,
222,
254,
223,
232,
225,
226,
255,
};
*
* Revision 2.0 1996/11/15 10:55:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
* Initial revision
*/
/* Values for wmesa->pixelformat: */
#define PF_8A8B8G8R 3 /* 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */
#define PF_8R8G8B 4 /* 32-bit TrueColor: 8-R, 8-G, 8-B */
#define PF_5R6G5B 5 /* 16-bit TrueColor: 5-R, 6-G, 5-B bits */
#define PF_DITHER8 6 /* Dithered RGB using a lookup table */
#define PF_LOOKUP 7 /* Undithered RGB using a lookup table */
#define PF_GRAYSCALE 10 /* Grayscale or StaticGray */
#define PF_BADFORMAT 11
#define PF_INDEX8 12
char ColorMap16[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,
0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,
0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,
0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,
0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,
0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,
0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};
#define BGR8(r,g,b) (unsigned)(((BYTE)(b & 0xc0 | (g & 0xe0)>>2 | (r & 0xe0)>>5)))
#ifdef DDRAW
#define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(g&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[r])) << 11)))
#else
#define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(ColorMap16[g]) << 5)) | (((WORD)(BYTE)(ColorMap16[r])) << 10)))
#endif
#define BGR24(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
#define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
/*
* If pixelformat==PF_8A8B8G8R:
*/
#define PACK_8A8B8G8R( R, G, B, A ) \
( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
/*
* If pixelformat==PF_8R8G8B:
*/
#define PACK_8R8G8B( R, G, B) ( ((R) << 16) | ((G) << 8) | (B) )
/*
* If pixelformat==PF_5R6G5B:
*/
#ifdef DDRAW
#define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(G&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[R])) << 11)))
#else
#define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(ColorMap16[G]) << 5)) | (((WORD)(BYTE)(ColorMap16[R])) << 10)))
#endif
/*----------------------------------------------------------------------------
Division lookup tables. These tables compute 0-255 divided by 51 and
modulo 51. These tables could approximate gamma correction.
*/
char unsigned const aDividedBy51Rounded[256] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
};
char unsigned const aDividedBy51[256] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
};
char unsigned const aModulo51[256] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0,
};
/*----------------------------------------------------------------------------
Multiplication LUTs. These compute 0-5 times 6 and 36.
*/
char unsigned const aTimes6[6] =
{
0, 6, 12, 18, 24, 30
};
char unsigned const aTimes36[6] =
{
0, 36, 72, 108, 144, 180
};
/*----------------------------------------------------------------------------
Dither matrices for 8 bit to 2.6 bit halftones.
*/
char unsigned const aHalftone16x16[256] =
{
0, 44, 9, 41, 3, 46, 12, 43, 1, 44, 10, 41, 3, 46, 12, 43,
34, 16, 25, 19, 37, 18, 28, 21, 35, 16, 26, 19, 37, 18, 28, 21,
38, 6, 47, 3, 40, 9, 50, 6, 38, 7, 47, 4, 40, 9, 49, 6,
22, 28, 13, 31, 25, 31, 15, 34, 22, 29, 13, 32, 24, 31, 15, 34,
2, 46, 12, 43, 1, 45, 10, 42, 2, 45, 11, 42, 1, 45, 11, 42,
37, 18, 27, 21, 35, 17, 26, 20, 36, 17, 27, 20, 36, 17, 26, 20,
40, 8, 49, 5, 38, 7, 48, 4, 39, 8, 48, 5, 39, 7, 48, 4,
24, 30, 15, 33, 23, 29, 13, 32, 23, 30, 14, 33, 23, 29, 14, 32,
2, 46, 12, 43, 0, 44, 10, 41, 3, 47, 12, 44, 0, 44, 10, 41,
37, 18, 27, 21, 35, 16, 25, 19, 37, 19, 28, 22, 35, 16, 25, 19,
40, 9, 49, 5, 38, 7, 47, 4, 40, 9, 50, 6, 38, 6, 47, 3,
24, 30, 15, 34, 22, 29, 13, 32, 25, 31, 15, 34, 22, 28, 13, 31,
1, 45, 11, 42, 2, 46, 11, 42, 1, 45, 10, 41, 2, 46, 11, 43,
36, 17, 26, 20, 36, 17, 27, 21, 35, 16, 26, 20, 36, 18, 27, 21,
39, 8, 48, 4, 39, 8, 49, 5, 38, 7, 48, 4, 39, 8, 49, 5,
23, 29, 14, 33, 24, 30, 14, 33, 23, 29, 13, 32, 24, 30, 14, 33,
};
char unsigned const aHalftone8x8[64] =
{
0, 38, 9, 47, 2, 40, 11, 50,
25, 12, 35, 22, 27, 15, 37, 24,
6, 44, 3, 41, 8, 47, 5, 43,
31, 19, 28, 15, 34, 21, 31, 18,
1, 39, 11, 49, 0, 39, 10, 48,
27, 14, 36, 23, 26, 13, 35, 23,
7, 46, 4, 43, 7, 45, 3, 42,
33, 20, 30, 17, 32, 19, 29, 16,
};
char unsigned const aHalftone4x4_1[16] =
{
0, 25, 6, 31,
38, 12, 44, 19,
9, 35, 3, 28,
47, 22, 41, 15
};
char unsigned const aHalftone4x4_2[16] =
{
41, 3, 9, 28,
35, 15, 22, 47,
6, 25, 38, 0,
19, 44, 31, 12
};
/***************************************************************************
aWinGHalftoneTranslation
Translates a 2.6 bit-per-pixel halftoned representation into the
slightly rearranged WinG Halftone Palette.
*/
char unsigned const aWinGHalftoneTranslation[216] =
{
0,
29,
30,
31,
32,
249,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
250,
250,
57,
58,
59,
251,
60,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
250,
90,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
110,
111,
227,
112,
113,
114,
115,
116,
117,
118,
119,
151,
120,
121,
122,
123,
124,
228,
125,
126,
229,
133,
162,
135,
131,
132,
137,
166,
134,
140,
130,
136,
143,
138,
139,
174,
141,
142,
177,
129,
144,
145,
146,
147,
148,
149,
150,
157,
152,
153,
154,
155,
156,
192,
158,
159,
160,
161,
196,
163,
164,
165,
127,
199,
167,
168,
169,
170,
171,
172,
173,
207,
175,
176,
210,
178,
179,
180,
181,
182,
183,
184,
185,
186,
187,
188,
189,
190,
191,
224,
193,
194,
195,
252,
252,
197,
198,
128,
253,
252,
200,
201,
202,
203,
204,
205,
206,
230,
208,
209,
231,
211,
212,
213,
214,
215,
216,
217,
218,
219,
220,
221,
222,
254,
223,
232,
225,
226,
255,
};

View File

@@ -1,4 +1,4 @@
/* $Id: wgl.c,v 1.9 2001/09/18 16:39:38 kschultz Exp $ */
/* $Id: wgl.c,v 1.9.2.1 2002/04/23 18:24:41 kschultz Exp $ */
/*
* This library is free software; you can redistribute it and/or
@@ -100,6 +100,7 @@ int qt_ext = sizeof(ext) / sizeof(ext[0]);
struct __pixelformat__ pix[] =
{
/* Double Buffer, alpha */
{ { sizeof(PIXELFORMATDESCRIPTOR), 1,
PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
PFD_TYPE_RGBA,
@@ -107,6 +108,7 @@ struct __pixelformat__ pix[] =
0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
GL_TRUE
},
/* Single Buffer, alpha */
{ { sizeof(PIXELFORMATDESCRIPTOR), 1,
PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT,
PFD_TYPE_RGBA,
@@ -114,6 +116,22 @@ struct __pixelformat__ pix[] =
0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
GL_FALSE
},
/* Double Buffer, no alpha */
{ { sizeof(PIXELFORMATDESCRIPTOR), 1,
PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
PFD_TYPE_RGBA,
24, 8, 0, 8, 8, 8, 16, 0, 0,
0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
GL_TRUE
},
/* Single Buffer, no alpha */
{ { sizeof(PIXELFORMATDESCRIPTOR), 1,
PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT,
PFD_TYPE_RGBA,
24, 8, 0, 8, 8, 8, 16, 0, 0,
0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
GL_FALSE
},
};
int qt_pix = sizeof(pix) / sizeof(pix[0]);
@@ -158,7 +176,8 @@ WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
if ( wgl_ctx[i].ctx == NULL )
{
wgl_ctx[i].ctx = WMesaCreateContext( hWnd, NULL, GL_TRUE,
pix[curPFD-1].doubleBuffered );
pix[curPFD-1].doubleBuffered,
pix[curPFD-1].pfd.cAlphaBits ? GL_TRUE : GL_FALSE);
if (wgl_ctx[i].ctx == NULL)
break;
wgl_ctx[i].hdc = hdc;
@@ -559,6 +578,8 @@ WGLAPI int GLAPIENTRY wglChoosePixelFormat(HDC hdc,
continue;
if(ppfd->iPixelType != pix[i].pfd.iPixelType)
delta++;
if(ppfd->cAlphaBits != pix[i].pfd.cAlphaBits)
delta++;
if(delta < bestdelta)
{
best = i + 1;

View File

@@ -1,4 +1,4 @@
/* $Id: wmesa.c,v 1.22.2.1 2001/11/01 22:52:18 kschultz Exp $ */
/* $Id: wmesa.c,v 1.22.2.8 2002/06/24 20:18:04 kschultz Exp $ */
/*
* Windows (Win32) device driver for Mesa 3.4
@@ -370,166 +370,180 @@ static void clear_color( GLcontext* ctx, const GLchan color[4] )
}
/*
* Clear the specified region of the color buffer using the clear color
* or index as specified by one of the two functions above.
*
* This procedure clears either the front and/or the back COLOR buffers.
* Only the "left" buffer is cleared since we are not stereo.
* Clearing of the other non-color buffers is left to the swrast.
* We also only clear the color buffers if the color masks are all 1's.
* Otherwise, we let swrast do it.
*/
/*
* Clear the specified region of the color buffer using the clear color
* or index as specified by one of the two functions above.
*
* This procedure clears either the front and/or the back COLOR buffers.
* Only the "left" buffer is cleared since we are not stereo.
* Clearing of the other non-color buffers is left to the swrast.
* We also only clear the color buffers if the color masks are all 1's.
* Otherwise, we let swrast do it.
*/
static clear(GLcontext* ctx, GLbitfield mask,
GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
static clear(GLcontext* ctx, GLbitfield mask,
GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
if (all){
x=y=0;
width=Current->width;
height=Current->height;
if (all){
x=y=0;
width=Current->width;
height=Current->height;
}
/* sanity check - can't have right(stereo) buffers */
assert((mask & (DD_FRONT_RIGHT_BIT | DD_BACK_RIGHT_BIT)) == 0);
/* clear alpha */
if ((mask & (DD_FRONT_LEFT_BIT | DD_BACK_RIGHT_BIT)) &&
ctx->DrawBuffer->UseSoftwareAlphaBuffers &&
ctx->Color.ColorMask[ACOMP]) {
_mesa_clear_alpha_buffers( ctx );
}
/* sanity check - can't have right(stereo) buffers */
assert((mask & (DD_FRONT_RIGHT_BIT | DD_BACK_RIGHT_BIT)) == 0);
if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
if (mask & DD_BACK_LEFT_BIT) {
#if defined(USE_GDI_TO_CLEAR)
#if defined(DDRAW)
// D.R.S. 10/29/01 on my system (Pentium 4 with nvidia GeForce2 MX card,
// this is almose 100 times faster that the code below
HDC DC=NULL;
HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel);
HBRUSH Brush=CreateSolidBrush(Current->clearpixel);
HPEN Old_Pen=NULL;
HBRUSH Old_Brush=NULL;
Current->lpDDSOffScreen->lpVtbl->Unlock(Current->lpDDSOffScreen,NULL);
Current->lpDDSOffScreen->lpVtbl->GetDC(Current->lpDDSOffScreen,&DC);
Old_Pen=SelectObject(DC,Pen);
Old_Brush=SelectObject(DC,Brush);
Rectangle(DC,x,y,x+width,y+height);
SelectObject(DC,Old_Pen);
SelectObject(DC,Old_Brush);
DeleteObject(Pen);
DeleteObject(Brush);
Current->lpDDSOffScreen->lpVtbl->ReleaseDC(Current->lpDDSOffScreen,DC);
while (Current->lpDDSOffScreen->lpVtbl->Lock(Current->lpDDSOffScreen,NULL, &(Current->ddsd), 0, NULL) == DDERR_WASSTILLDRAWING);
mask &= ~DD_BACK_LEFT_BIT;
#else
/* single-buffer */
HDC DC=DD_GETDC;
HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel);
HBRUSH Brush=CreateSolidBrush(Current->clearpixel);
HPEN Old_Pen=SelectObject(DC,Pen);
HBRUSH Old_Brush=SelectObject(DC,Brush);
Rectangle(DC,x+Current->rectSurface.left,Current->rectSurface.top+y,x+width+Current->rectSurface.left,y+height+Current->rectSurface.top);
SelectObject(DC,Old_Pen);
SelectObject(DC,Old_Brush);
DeleteObject(Pen);
DeleteObject(Brush);
DD_RELEASEDC;
mask &= ~DD_BACK_LEFT_BIT;
#endif // DDRAW
#else
DWORD dwColor;
WORD wColor;
BYTE bColor;
LPDWORD lpdw = (LPDWORD)Current->pbPixels;
LPWORD lpw = (LPWORD)Current->pbPixels;
LPBYTE lpb = Current->pbPixels;
int lines;
/* Double-buffering - clear back buffer */
UINT nBypp = Current->cColorBits / 8;
int i = 0;
int iSize = 0;
assert(Current->db_flag==GL_TRUE); /* we'd better be double buffer */
if(nBypp ==1 ){
iSize = Current->width/4;
bColor = BGR8(GetRValue(Current->clearpixel),
GetGValue(Current->clearpixel),
GetBValue(Current->clearpixel));
wColor = MAKEWORD(bColor,bColor);
dwColor = MAKELONG(wColor, wColor);
}
if(nBypp == 2){
iSize = Current->width / 2;
wColor = BGR16(GetRValue(Current->clearpixel),
GetGValue(Current->clearpixel),
GetBValue(Current->clearpixel));
dwColor = MAKELONG(wColor, wColor);
}
else if(nBypp == 4){
iSize = Current->width;
dwColor = BGR32(GetRValue(Current->clearpixel),
GetGValue(Current->clearpixel),
GetBValue(Current->clearpixel));
}
/* clear a line */
while(i < iSize){
*lpdw = dwColor;
lpdw++;
i++;
}
/* This is the 24bit case */
if (nBypp == 3) {
iSize = Current->width *3/4;
dwColor = BGR24(GetRValue(Current->clearpixel),
GetGValue(Current->clearpixel),
GetBValue(Current->clearpixel));
while(i < iSize){
*lpdw = dwColor;
lpb += nBypp;
lpdw = (LPDWORD)lpb;
i++;
}
}
i = 0;
if (stereo_flag)
lines = height /2;
else
lines = height;
/* copy cleared line to other lines in buffer */
do {
memcpy(lpb, Current->pbPixels, iSize*4);
lpb += Current->ScanWidth;
i++;
}
while (i<lines-1);
mask &= ~DD_BACK_LEFT_BIT;
#endif // defined(USE_GDI_TO_CLEAR)
} /* double-buffer */
if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
if (mask & DD_BACK_LEFT_BIT) {
#if defined(USE_GDI_TO_CLEAR)
#if defined(DDRAW)
// D.R.S. 10/29/01 on my system (Pentium 4 with nvidia GeForce2 MX card,
// this is almose 100 times faster that the code below
HDC DC=NULL;
HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel);
HBRUSH Brush=CreateSolidBrush(Current->clearpixel);
HPEN Old_Pen=NULL;
HBRUSH Old_Brush=NULL;
Current->lpDDSOffScreen->lpVtbl->Unlock(Current->lpDDSOffScreen,NULL);
Current->lpDDSOffScreen->lpVtbl->GetDC(Current->lpDDSOffScreen,&DC);
Old_Pen=SelectObject(DC,Pen);
Old_Brush=SelectObject(DC,Brush);
Rectangle(DC,x,y,x+width,y+height);
SelectObject(DC,Old_Pen);
SelectObject(DC,Old_Brush);
DeleteObject(Pen);
DeleteObject(Brush);
Current->lpDDSOffScreen->lpVtbl->ReleaseDC(Current->lpDDSOffScreen,DC);
while (Current->lpDDSOffScreen->lpVtbl->Lock(Current->lpDDSOffScreen,NULL, &(Current->ddsd), 0, NULL) == DDERR_WASSTILLDRAWING);
mask &= ~DD_BACK_LEFT_BIT;
#else
/* single-buffer */
HDC DC=DD_GETDC;
HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel);
HBRUSH Brush=CreateSolidBrush(Current->clearpixel);
HPEN Old_Pen=SelectObject(DC,Pen);
HBRUSH Old_Brush=SelectObject(DC,Brush);
Rectangle(DC,x+Current->rectSurface.left,Current->rectSurface.top+y,x+width+Current->rectSurface.left,y+height+Current->rectSurface.top);
SelectObject(DC,Old_Pen);
SelectObject(DC,Old_Brush);
DeleteObject(Pen);
DeleteObject(Brush);
DD_RELEASEDC;
mask &= ~DD_BACK_LEFT_BIT;
#endif // DDRAW
#else
DWORD dwColor;
WORD wColor;
BYTE bColor;
LPDWORD lpdw = (LPDWORD)Current->pbPixels;
LPWORD lpw = (LPWORD)Current->pbPixels;
LPBYTE lpb = Current->pbPixels;
int lines;
/* Double-buffering - clear back buffer */
UINT nBypp = Current->cColorBits / 8;
int i = 0;
int iSize = 0;
int mult = 4;
assert(Current->db_flag==GL_TRUE); /* we'd better be double buffer */
if(nBypp ==1 ){
iSize = Current->width/4;
bColor = BGR8(GetRValue(Current->clearpixel),
GetGValue(Current->clearpixel),
GetBValue(Current->clearpixel));
wColor = MAKEWORD(bColor,bColor);
dwColor = MAKELONG(wColor, wColor);
}
else if(nBypp == 2){
iSize = Current->width / 2;
wColor = BGR16(GetRValue(Current->clearpixel),
GetGValue(Current->clearpixel),
GetBValue(Current->clearpixel));
dwColor = MAKELONG(wColor, wColor);
}
else if(nBypp == 3){
BYTE r, g, b;
r = GetRValue(Current->clearpixel);
g = GetGValue(Current->clearpixel);
b = GetBValue(Current->clearpixel);
iSize = Current->width;
while (i < iSize) {
*lpb++ = b;
*lpb++ = g;
*lpb++ = r;
i++;
}
lpb = Current->pbPixels + Current->ScanWidth;
mult = 3;
}
else if(nBypp == 4){
iSize = Current->width;
dwColor = BGR32(GetRValue(Current->clearpixel),
GetGValue(Current->clearpixel),
GetBValue(Current->clearpixel));
}
if (nBypp != 3)
{
/* clear a line */
while(i < iSize){
*lpdw = dwColor;
lpdw++;
i++;
}
}
i = 0;
if (stereo_flag)
lines = height /2;
else
lines = height;
/* copy cleared line to other lines in buffer */
do {
memcpy(lpb, Current->pbPixels, iSize*mult);
lpb += Current->ScanWidth;
i++;
}
while (i<lines-1);
mask &= ~DD_BACK_LEFT_BIT;
#endif // defined(USE_GDI_TO_CLEAR)
} /* double-buffer */
if (mask & DD_FRONT_LEFT_BIT) {
/* single-buffer */
HDC DC=DD_GETDC;
HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel);
HBRUSH Brush=CreateSolidBrush(Current->clearpixel);
HPEN Old_Pen=SelectObject(DC,Pen);
HBRUSH Old_Brush=SelectObject(DC,Brush);
Rectangle(DC,x+Current->rectSurface.left,Current->rectSurface.top+y,x+width+Current->rectSurface.left,y+height+Current->rectSurface.top);
SelectObject(DC,Old_Pen);
SelectObject(DC,Old_Brush);
DeleteObject(Pen);
DeleteObject(Brush);
DD_RELEASEDC;
mask &= ~DD_FRONT_LEFT_BIT;
} /* single-buffer */
} /* if masks are all 1's */
if (mask & DD_FRONT_LEFT_BIT) {
/* single-buffer */
HDC DC=DD_GETDC;
HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel);
HBRUSH Brush=CreateSolidBrush(Current->clearpixel);
HPEN Old_Pen=SelectObject(DC,Pen);
HBRUSH Old_Brush=SelectObject(DC,Brush);
Rectangle(DC,x+Current->rectSurface.left,Current->rectSurface.top+y,x+width+Current->rectSurface.left,y+height+Current->rectSurface.top);
SelectObject(DC,Old_Pen);
SelectObject(DC,Old_Brush);
DeleteObject(Pen);
DeleteObject(Brush);
DD_RELEASEDC;
mask &= ~DD_FRONT_LEFT_BIT;
} /* single-buffer */
} /* if masks are all 1's */
/* Call swrast if there is anything left to clear (like DEPTH) */
if (mask)
_swrast_Clear( ctx, mask, all, x, y, width, height );
}
/* Call swrast if there is anything left to clear (like DEPTH) */
if (mask)
_swrast_Clear( ctx, mask, all, x, y, width, height );
}
static void enable( GLcontext* ctx, GLenum pname, GLboolean enable )
@@ -554,15 +568,13 @@ static void enable( GLcontext* ctx, GLenum pname, GLboolean enable )
}
}
static GLboolean set_draw_buffer( GLcontext* ctx, GLenum mode )
static void set_draw_buffer( GLcontext* ctx, GLenum mode )
{
/* TODO: this could be better */
if (mode==GL_FRONT_LEFT || mode==GL_BACK_LEFT) {
return GL_TRUE;
}
else {
return GL_FALSE;
}
/* XXX doing nothing for now */
/* if front buffer, fine */
/* if back buffer, fine */
/* else, check swrast->_RasterMask & MULTI_DRAW_BIT, if true, */
/* use a swrast fallback function */
}
@@ -576,8 +588,9 @@ static void set_read_buffer(GLcontext *ctx, GLframebuffer *colorBuffer,
/* Return characteristics of the output buffer. */
static void buffer_size( GLcontext* ctx, GLuint *width, GLuint *height )
static void buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
GET_CURRENT_CONTEXT(ctx);
int New_Size;
RECT CR;
@@ -1014,7 +1027,7 @@ static void SetFunctionPointers(GLcontext *ctx)
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = wmesa_update_state;
ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.GetBufferSize = buffer_size;
ctx->Driver.Accum = _swrast_Accum;
@@ -1093,7 +1106,7 @@ static void wmesa_update_state( GLcontext *ctx, GLuint new_state )
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = wmesa_update_state;
ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.GetBufferSize = buffer_size;
ctx->Driver.Accum = _swrast_Accum;
@@ -1232,7 +1245,8 @@ static void GetPalette(HPALETTE Pal,RGBQUAD *aRGB)
WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal,
GLboolean rgb_flag,
GLboolean db_flag )
GLboolean db_flag,
GLboolean alpha_flag )
{
RECT CR;
WMesaContext c;
@@ -1310,11 +1324,13 @@ WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal,
c->gl_visual = _mesa_create_visual(rgb_flag,
db_flag, /* db_flag */
GL_FALSE, /* stereo */
8,8,8,8, /* r, g, b, a bits */
8,8,8, /* r, g, b bits */
alpha_flag ? 8 : 0, /* alpha bits */
0, /* index bits */
16, /* depth_bits */
8, /* stencil_bits */
16,16,16,16,/* accum_bits */
16,16,16,/* accum_bits */
alpha_flag ? 16 : 0, /* alpha accum */
1);
if (!c->gl_visual) {
@@ -1347,7 +1363,7 @@ WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal,
c->gl_visual->depthBits > 0,
c->gl_visual->stencilBits > 0,
c->gl_visual->accumRedBits > 0,
GL_FALSE /* s/w alpha */ );
alpha_flag /* s/w alpha */ );
if (!c->gl_buffer) {
_mesa_destroy_visual( c->gl_visual );
_mesa_free_context_data( c->gl_ctx );
@@ -1416,9 +1432,9 @@ void WMesaMakeCurrent( WMesaContext c )
if(Current == c)
return;
Current = c;
wmesa_update_state(c->gl_ctx, 0);
_mesa_make_current(c->gl_ctx, c->gl_buffer);
Current = c;
if (Current->gl_ctx->Viewport.Width==0) {
/* initialize viewport to window size */
_mesa_Viewport( 0, 0, Current->width, Current->height );
@@ -1609,7 +1625,11 @@ wmSetPixel(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
else if(nBypp == 2)
*((LPWORD)lpb) = BGR16(r,g,b);
else if (nBypp == 3)
*((LPDWORD)lpb) = BGR24(r,g,b);
{
*lpb++ = b;
*lpb++ = g;
*lpb = r;
}
else if (nBypp == 4)
*((LPDWORD)lpb) = BGR32(r,g,b);
}
@@ -1631,7 +1651,9 @@ void wmSetPixel4(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
void wmSetPixel3(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
{
LPBYTE lpb = pwc->pbPixels + pwc->ScanWidth * iScanLine + iPixel + iPixel + iPixel;
*((LPDWORD)lpb) = BGR24(r,g,b);
*lpb++ = b;
*lpb++ = g;
*lpb = r;
}
void wmSetPixel2(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
@@ -3176,6 +3198,8 @@ static triangle_func choose_triangle_function( GLcontext *ctx )
if (ctx->Polygon.SmoothFlag) return NULL;
if (ctx->Texture._ReallyEnabled) return NULL;
if (!wmesa->db_flag) return NULL;
if (ctx->swrast->_RasterMask & MULTI_DRAW_BIT) return NULL;
/*if (wmesa->xm_buffer->buffer==XIMAGE)*/ {
if ( ctx->Light.ShadeModel==GL_SMOOTH
&& ctx->_RasterMask==DEPTH_BIT

View File

@@ -1,10 +1,9 @@
/* $Id: fakeglx.c,v 1.58.2.1 2001/11/25 18:50:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 4.0.1
* Version: 4.0.3
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -66,7 +65,7 @@
#define SERVER_MINOR_VERSION 4
/* This is appended onto the glXGetClient/ServerString version strings. */
#define MESA_GLX_VERSION "Mesa 4.0.1"
#define MESA_GLX_VERSION "Mesa 4.0.3"
/* Who implemented this GLX? */
#define VENDOR "Brian Paul"
@@ -1233,9 +1232,9 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
((__GLXcontext *) ctx)->currentDpy = dpy;
((__GLXcontext *) ctx)->currentDrawable = draw;
#ifndef GLX_BUILT_IN_XMESA
((__GLXcontext *) ctx)->currentReadable = read;
#ifdef GLX_BUILT_IN_XMESA
printf("Set fake context ctx %p\n", ctx);
#else
__glXSetCurrentContext(ctx);
#endif
return True;
@@ -1342,8 +1341,10 @@ static void
Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
unsigned long mask )
{
XMesaContext xm_src = (XMesaContext) src;
XMesaContext xm_dst = (XMesaContext) dst;
struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src;
struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst;
XMesaContext xm_src = fakeSrc->xmesaContext;
XMesaContext xm_dst = fakeDst->xmesaContext;
(void) dpy;
_mesa_copy_context( xm_src->gl_ctx, xm_dst->gl_ctx, (GLuint) mask );
}
@@ -1791,7 +1792,11 @@ Fake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
*value = False; /* XXX ??? */
break;
case GLX_X_VISUAL_TYPE:
#if defined(__cplusplus) || defined(c_plusplus)
switch (v->vishandle->c_class) {
#else
switch (v->vishandle->class) {
#endif
case GrayScale:
*value = GLX_GRAY_SCALE;
break;

View File

@@ -1,8 +1,8 @@
/* $Id: glxapi.c,v 1.28 2001/09/14 02:43:03 brianp Exp $ */
/* $Id: glxapi.c,v 1.28.2.1 2002/03/15 18:32:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.0.2
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
@@ -28,6 +28,7 @@
/*
* This is the GLX API dispatcher. Calls to the glX* functions are
* either routed to the real GLX encoders or to Mesa's pseudo-GLX functions.
* See the glxapi.h file for more details.
*/
@@ -35,7 +36,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/*#include <dlfcn.h>*/ /* XXX not portable? */
#include "glapi.h"
#include "glxapi.h"
@@ -1064,143 +1064,6 @@ _glxapi_set_no_op_table(struct _glxapi_table *t)
}
#if 00
/*
* Open the named library and use dlsym() to populate the given dispatch
* table with GLX function pointers.
* Return: true = all OK
* false = can't open libName or can't get required GLX function
*/
GLboolean
_glxapi_load_library_table(const char *libName, struct _glxapi_table *t)
{
void *libHandle;
void **entry; /* used to avoid a lot of cast/type warnings */
libHandle = dlopen(libName, 0);
if (!libHandle) {
return GL_FALSE;
}
#define GET_REQ_FUNCTION(ENTRY, NAME) \
entry = (void **) &(t->ENTRY); \
*entry = dlsym(libHandle, NAME); \
if (!*entry) { \
fprintf(stderr, "libGL Error: couldn't load %s from %s\n", \
NAME, libName); \
dlclose(libHandle); \
return GL_FALSE; \
}
/* 1.0 and 1.1 functions */
GET_REQ_FUNCTION(ChooseVisual, "glXChooseVisual");
GET_REQ_FUNCTION(CopyContext, "glXCopyContext");
GET_REQ_FUNCTION(CreateContext, "glXCreateContext");
GET_REQ_FUNCTION(CreateGLXPixmap, "glXCreateGLXPixmap");
GET_REQ_FUNCTION(DestroyContext, "glXDestroyContext");
GET_REQ_FUNCTION(GetConfig, "glXGetConfig");
GET_REQ_FUNCTION(IsDirect, "glXIsDirect");
GET_REQ_FUNCTION(MakeCurrent, "glXMakeCurrent");
GET_REQ_FUNCTION(QueryExtension, "glXQueryExtension");
GET_REQ_FUNCTION(QueryVersion, "glXQueryVersion");
GET_REQ_FUNCTION(SwapBuffers, "glXSwapBuffers");
GET_REQ_FUNCTION(UseXFont, "glXUseXFont");
GET_REQ_FUNCTION(WaitGL, "glXWaitGL");
GET_REQ_FUNCTION(WaitX, "glXWaitX");
GET_REQ_FUNCTION(GetClientString, "glXGetClientString");
GET_REQ_FUNCTION(QueryExtensionsString, "glXQueryExtensionsString");
GET_REQ_FUNCTION(QueryServerString, "glXQueryServerString");
#define GET_OPT_FUNCTION(ENTRY, NAME) \
entry = (void **) &(t->ENTRY); \
*entry = dlsym(libHandle, NAME); \
if (!*entry) { \
*entry = (void *) generic_no_op_func; \
}
/* 1.2, 1.3 and extensions */
GET_OPT_FUNCTION(ChooseFBConfig, "glXChooseFBConfig");
GET_OPT_FUNCTION(CreateNewContext, "glXCreateNewContext");
GET_OPT_FUNCTION(CreatePbuffer, "glXCreatePbuffer");
GET_OPT_FUNCTION(CreatePixmap, "glXCreatePixmap");
GET_OPT_FUNCTION(CreateWindow, "glXCreateWindow");
GET_OPT_FUNCTION(DestroyPbuffer, "glXDestroyPbuffer");
GET_OPT_FUNCTION(DestroyPixmap, "glXDestroyPixmap");
GET_OPT_FUNCTION(DestroyWindow, "glXDestroyWindow");
GET_OPT_FUNCTION(GetFBConfigAttrib, "glXGetFBConfigAttrib");
GET_OPT_FUNCTION(GetFBConfigs, "glXGetFBConfigs");
GET_OPT_FUNCTION(GetSelectedEvent, "glXGetSelectedEvent");
GET_OPT_FUNCTION(GetVisualFromFBConfig, "glXGetVisualFromFBConfig");
GET_OPT_FUNCTION(MakeContextCurrent, "glXMakeContextCurrent");
GET_OPT_FUNCTION(QueryContext, "glXQueryContext");
GET_OPT_FUNCTION(QueryDrawable, "glXQueryDrawable");
GET_OPT_FUNCTION(SelectEvent, "glXSelectEvent");
/*** GLX_SGI_swap_control ***/
GET_OPT_FUNCTION(SwapIntervalSGI, "glXSwapIntervalSGI");
/*** GLX_SGI_video_sync ***/
GET_OPT_FUNCTION(GetVideoSyncSGI, "glXGetVideoSyncSGI");
GET_OPT_FUNCTION(WaitVideoSyncSGI, "glXWaitVideoSyncSGI");
/*** GLX_SGI_make_current_read ***/
GET_OPT_FUNCTION(MakeCurrentReadSGI, "glXMakeCurrentReadSGI");
GET_OPT_FUNCTION(GetCurrentReadDrawableSGI, "glXGetCurrentReadDrawableSGI");
/*** GLX_SGIX_video_source ***/
#if defined(_VL_H)
GET_OPT_FUNCTION(CreateGLXVideoSourceSGIX, "glXCreateGLXVideoSourceSGIX");
GET_OPT_FUNCTION(DestroyGLXVideoSourceSGIX, "glXDestroyGLXVideoSourceSGIX");
#endif
/*** GLX_EXT_import_context ***/
GET_OPT_FUNCTION(FreeContextEXT, "glXFreeContextEXT");
GET_OPT_FUNCTION(GetContextIDEXT, "glXGetContextIDEXT");
GET_OPT_FUNCTION(GetCurrentDisplayEXT, "glXGetCurrentDisplayEXT");
GET_OPT_FUNCTION(ImportContextEXT, "glXImportContextEXT");
GET_OPT_FUNCTION(QueryContextInfoEXT, "glXQueryContextInfoEXT");
/*** GLX_SGIX_fbconfig ***/
GET_OPT_FUNCTION(GetFBConfigAttribSGIX, "glXGetFBConfigAttribSGIX");
GET_OPT_FUNCTION(ChooseFBConfigSGIX, "glXChooseFBConfigSGIX");
GET_OPT_FUNCTION(CreateGLXPixmapWithConfigSGIX, "glXCreateGLXPixmapWithConfigSGIX");
GET_OPT_FUNCTION(CreateContextWithConfigSGIX, "glXCreateContextWithConfigSGIX");
GET_OPT_FUNCTION(GetVisualFromFBConfigSGIX, "glXGetVisualFromFBConfigSGIX");
GET_OPT_FUNCTION(GetFBConfigFromVisualSGIX, "glXGetFBConfigFromVisualSGIX");
/*** GLX_SGIX_pbuffer ***/
GET_OPT_FUNCTION(CreateGLXPbufferSGIX, "glXCreateGLXPbufferSGIX");
GET_OPT_FUNCTION(DestroyGLXPbufferSGIX, "glXDestroyGLXPbufferSGIX");
GET_OPT_FUNCTION(QueryGLXPbufferSGIX, "glXQueryGLXPbufferSGIX");
GET_OPT_FUNCTION(SelectEventSGIX, "glXSelectEventSGIX");
GET_OPT_FUNCTION(GetSelectedEventSGIX, "glXGetSelectedEventSGIX");
/*** GLX_SGI_cushion ***/
GET_OPT_FUNCTION(CushionSGI, "glXCushionSGI");
/*** GLX_SGIX_video_resize ***/
GET_OPT_FUNCTION(BindChannelToWindowSGIX, "glXBindChannelToWindowSGIX");
GET_OPT_FUNCTION(ChannelRectSGIX, "glXChannelRectSGIX");
GET_OPT_FUNCTION(QueryChannelRectSGIX, "glXQueryChannelRectSGIX");
GET_OPT_FUNCTION(QueryChannelDeltasSGIX, "glXQueryChannelDeltasSGIX");
GET_OPT_FUNCTION(ChannelRectSyncSGIX, "glXChannelRectSyncSGIX");
/*** GLX_SGIX_dmbuffer ***/
#if defined (_DM_BUFFER_H_)
GET_OPT_FUNCTION(AssociateDMPbufferSGIX, "glXAssociateDMPbufferSGIX");
#endif
/*** GLX_SGIX_swap_group ***/
GET_OPT_FUNCTION(JoinSwapGroupSGIX, "glXJoinSwapGroupSGIX");
/*** GLX_SGIX_swap_barrier ***/
GET_OPT_FUNCTION(BindSwapBarrierSGIX, "glXBindSwapBarrierSGIX");
GET_OPT_FUNCTION(QueryMaxSwapBarriersSGIX, "glXQueryMaxSwapBarriersSGIX");
/*** GLX_SUN_get_transparent_index ***/
GET_OPT_FUNCTION(GetTransparentIndexSUN, "glXGetTransparentIndexSUN");
/*** GLX_MESA_copy_sub_buffer ***/
GET_OPT_FUNCTION(CopySubBufferMESA, "glXCopySubBufferMESA");
/*** GLX_MESA_release_buffers ***/
GET_OPT_FUNCTION(ReleaseBuffersMESA, "glXReleaseBuffersMESA");
/*** GLX_MESA_pixmap_colormap ***/
GET_OPT_FUNCTION(CreateGLXPixmapMESA, "glXCreateGLXPixmapMESA");
/*** GLX_MESA_set_3dfx_mode ***/
GET_OPT_FUNCTION(Set3DfxModeMESA, "glXSet3DfxModeMESA");
return GL_TRUE;
}
#endif
struct name_address_pair {
const char *Name;
GLvoid *Address;

View File

@@ -1,8 +1,8 @@
/* $Id: glxapi.h,v 1.11 2001/05/29 23:15:07 brianp Exp $ */
/* $Id: glxapi.h,v 1.11.2.1 2002/03/15 18:32:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.0.2
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
@@ -34,10 +34,16 @@
#ifdef GLX_BUILT_IN_XMESA
/* The GLX API dispatcher is being built into XFree86's libGL */
/* The GLX API dispatcher (i.e. this code) is being built into XFree86's
* libGL so we'll use the __GLXContextRec defined in xc/lib/GL/glx/glxclient.h
*/
#include "glxclient.h"
#else
/* The GLX API dispatcher is being built into stand-alone Mesa */
/* The GLX API dispatcher (i.e. this code) is being built into stand-alone
* Mesa. We don't know anything about XFree86 or real GLX so we define a
* minimal __GLXContextRec here so some of the functions in this file can
* work properly.
*/
typedef struct __GLXcontextRec {
Display *currentDpy;
GLboolean isDirect;
@@ -57,8 +63,10 @@ typedef struct __GLXcontextRec {
* pseudo-GLX can be present at the same time. The former being used on
* GLX-enabled X servers and the later on non-GLX X servers.
*
* XXX Note that this hasn't actually been fully used yet in either Mesa or
* the DRI. Red Hat, however, has used it for their custom libGL.
* Red Hat has been using this since Red Hat Linux 7.0 (I think).
* This'll be a standard feature in XFree86 4.3. It basically allows one
* libGL to do both DRI-rendering and "fake GLX" rendering to X displays
* that lack the GLX extension.
*/
struct _glxapi_table {
/*** GLX_VERSION_1_0 ***/

View File

@@ -1,10 +1,10 @@
/* $Id: xm_api.c,v 1.29.2.1 2001/11/06 16:00:58 brianp Exp $ */
/* $Id: xm_api.c,v 1.29.2.9 2002/06/17 23:32:43 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.0.3
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -23,7 +23,7 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* $XFree86: xc/extras/Mesa/src/X/xm_api.c,v 1.2 2002/02/26 23:37:31 tsi Exp $ */
/*
* This file contains the implementations of all the XMesa* functions.
@@ -168,6 +168,8 @@ static short hpcr_rgbTbl[3][256] = {
*/
static void error( const char *msg )
{
(void)DitherValues; /* Muffle compiler */
if (getenv("MESA_DEBUG"))
fprintf( stderr, "X/Mesa error: %s\n", msg );
}
@@ -1306,23 +1308,31 @@ static GLboolean initialize_visual_and_buffer( int client,
#endif
XMesaSetFunction( v->display, b->gc, GXcopy );
/* cleargc - for glClear() */
#ifdef XFree86Server
b->cleargc = CreateScratchGC(v->display, window->depth);
#else
b->cleargc = XCreateGC( v->display, window, 0, NULL );
#endif
XMesaSetFunction( v->display, b->cleargc, GXcopy );
/*
* Don't generate Graphics Expose/NoExpose events in swapbuffers().
* Patch contributed by Michael Pichler May 15, 1995.
*/
#ifdef XFree86Server
b->cleargc = CreateScratchGC(v->display, window->depth);
b->swapgc = CreateScratchGC(v->display, window->depth);
{
CARD32 v[1];
v[0] = FALSE;
dixChangeGC(NullClient, b->cleargc, GCGraphicsExposures, v, NULL);
dixChangeGC(NullClient, b->swapgc, GCGraphicsExposures, v, NULL);
}
#else
gcvalues.graphics_exposures = False;
b->cleargc = XCreateGC( v->display, window,
b->swapgc = XCreateGC( v->display, window,
GCGraphicsExposures, &gcvalues);
#endif
XMesaSetFunction( v->display, b->cleargc, GXcopy );
XMesaSetFunction( v->display, b->swapgc, GXcopy );
/*
* Set fill style and tile pixmap once for all for HPCR stuff
* (instead of doing it each time in clear_color_HPCR_pixmap())
@@ -1690,35 +1700,6 @@ void XMesaDestroyContext( XMesaContext c )
_mesa_destroy_context( c->gl_ctx );
}
/*
* XXX This code should really go away because the ancilliary data
* associated with a window/pixmap should not go away just because
* a context is destroyed.
*/
#if 0
/* Destroy any buffers which are using this context. If we don't
* we may have dangling references. Hmm, maybe we should just
* set the buffer's context pointer to NULL instead of deleting it?
* Let's see if we get any bug reports...
* This contributed by Doug Rabson <dfr@calcaphon.com>
*/
{
XMesaBuffer b, next;
for (b = XMesaBufferList; b; b = next) {
next = b->Next;
if (!b->pixmap_flag) {
#ifndef XFree86Server
XSync(b->display, False);
#endif
if (b->xm_context == c) {
/* found a context created for this context */
XMesaDestroyBuffer( b );
}
}
}
}
#endif
FREE( c );
}
@@ -1769,8 +1750,6 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
return NULL;
}
b->xm_context = NULL; /* Associate no context with this buffer */
b->xm_visual = v;
b->pixmap_flag = GL_FALSE;
b->display = v->display;
@@ -1917,8 +1896,6 @@ XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
assert(v);
b->xm_context = NULL; /* Associate no context with this buffer */
b->xm_visual = v;
b->pixmap_flag = GL_TRUE;
b->display = v->display;
@@ -1967,8 +1944,6 @@ XMesaBuffer XMesaCreatePBuffer( XMesaVisual v, XMesaColormap cmap,
return NULL;
}
b->xm_context = NULL; /* Associate no context with this buffer */
b->xm_visual = v;
b->pbuffer_flag = GL_TRUE;
b->display = v->display;
@@ -2022,6 +1997,7 @@ void XMesaDestroyBuffer( XMesaBuffer b )
if (b->gc) XMesaFreeGC( b->xm_visual->display, b->gc );
if (b->cleargc) XMesaFreeGC( b->xm_visual->display, b->cleargc );
if (b->swapgc) XMesaFreeGC( b->xm_visual->display, b->swapgc );
if (b->backimage) {
#if defined(USE_XSHM) && !defined(XFree86Server)
@@ -2048,9 +2024,6 @@ void XMesaDestroyBuffer( XMesaBuffer b )
XMesaDestroyImage( b->rowimage );
}
if (b->xm_context)
b->xm_context->xm_buffer = NULL;
free_xmesa_buffer(client, b);
}
@@ -2079,17 +2052,6 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
if (drawBuffer->FXctx) {
fxMesaMakeCurrent(drawBuffer->FXctx);
/* Disassociate drawBuffer's current context from drawBuffer */
if (drawBuffer->xm_context)
drawBuffer->xm_context->xm_buffer = NULL;
/* Disassociate old buffer from this context */
if (c->xm_buffer)
c->xm_buffer->xm_context = NULL;
/* Associate the context with this buffer */
drawBuffer->xm_context = c;
c->xm_buffer = drawBuffer;
c->xm_read_buffer = readBuffer;
c->use_read_buffer = (drawBuffer != readBuffer);
@@ -2105,16 +2067,6 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
return GL_TRUE;
}
/* Disassociate drawBuffer's current context from drawBuffer */
if (drawBuffer->xm_context)
drawBuffer->xm_context->xm_buffer = NULL;
/* Disassociate old buffer with this context */
if (c->xm_buffer)
c->xm_buffer->xm_context = NULL;
drawBuffer->xm_context = c; /* Associate the context with this buffer */
c->xm_buffer = drawBuffer;
c->xm_read_buffer = readBuffer;
c->use_read_buffer = (drawBuffer != readBuffer);
@@ -2279,12 +2231,13 @@ GLboolean XMesaSetFXmode( GLint mode )
*/
static void FXgetImage( XMesaBuffer b )
{
GET_CURRENT_CONTEXT(ctx);
static unsigned short pixbuf[MAX_WIDTH];
GLuint x, y;
int xpos, ypos;
XMesaWindow root;
unsigned int bw, depth, width, height;
XMesaContext xmesa = (XMesaContext) b->xm_context->gl_ctx->DriverCtx;
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
assert(xmesa->xm_buffer->FXctx);
@@ -2376,7 +2329,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
/* If we're swapping the buffer associated with the current context
* we have to flush any pending rendering commands first.
*/
if (b->xm_context && b->xm_context->gl_ctx == ctx)
if (ctx && ctx->DrawBuffer == &(b->mesa_buffer))
_mesa_swapbuffers(ctx);
if (b->db_state) {
@@ -2396,7 +2349,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
if (b->shm) {
/*_glthread_LOCK_MUTEX(_xmesa_lock);*/
XShmPutImage( b->xm_visual->display, b->frontbuffer,
b->cleargc,
b->swapgc,
b->backimage, 0, 0,
0, 0, b->width, b->height, False );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
@@ -2406,7 +2359,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
{
/*_glthread_LOCK_MUTEX(_xmesa_lock);*/
XMesaPutImage( b->xm_visual->display, b->frontbuffer,
b->cleargc,
b->swapgc,
b->backimage, 0, 0,
0, 0, b->width, b->height );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
@@ -2418,7 +2371,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
XMesaCopyArea( b->xm_visual->display,
b->backpixmap, /* source drawable */
b->frontbuffer, /* dest. drawable */
b->cleargc,
b->swapgc,
0, 0, b->width, b->height, /* source region */
0, 0 /* dest region */
);
@@ -2442,7 +2395,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
/* If we're swapping the buffer associated with the current context
* we have to flush any pending rendering commands first.
*/
if (b->xm_context->gl_ctx == ctx)
if (ctx && ctx->DrawBuffer == &(b->mesa_buffer))
_mesa_swapbuffers(ctx);
if (b->db_state) {
@@ -2462,7 +2415,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
if (b->shm) {
/* XXX assuming width and height aren't too large! */
XShmPutImage( b->xm_visual->display, b->frontbuffer,
b->cleargc,
b->swapgc,
b->backimage, x, yTop,
x, yTop, width, height, False );
/* wait for finished event??? */
@@ -2472,7 +2425,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
{
/* XXX assuming width and height aren't too large! */
XMesaPutImage( b->xm_visual->display, b->frontbuffer,
b->cleargc,
b->swapgc,
b->backimage, x, yTop,
x, yTop, width, height );
}
@@ -2482,7 +2435,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
XMesaCopyArea( b->xm_visual->display,
b->backpixmap, /* source drawable */
b->frontbuffer, /* dest. drawable */
b->cleargc,
b->swapgc,
x, yTop, width, height, /* source region */
x, yTop /* dest region */
);
@@ -2562,7 +2515,7 @@ const char *XMesaGetString( XMesaContext c, int name )
{
(void) c;
if (name==XMESA_VERSION) {
return "3.5";
return "4.0.3";
}
else if (name==XMESA_EXTENSIONS) {
return "";
@@ -2596,7 +2549,7 @@ void XMesaGarbageCollect( void )
XMesaBuffer b, next;
for (b=XMesaBufferList; b; b=next) {
next = b->Next;
if (!b->pixmap_flag) {
if (b->display && b->frontbuffer && !b->pixmap_flag) {
#ifdef XFree86Server
/* NOT_NEEDED */
#else
@@ -2676,3 +2629,13 @@ unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
}
/*
* This is typically called when the window size changes and we need
* to reallocate the buffer's back/depth/stencil/accum buffers.
*/
void XMesaResizeBuffers( XMesaBuffer b )
{
xmesa_resize_buffers( &(b->mesa_buffer) );
}

View File

@@ -1,10 +1,10 @@
/* $Id: xm_dd.c,v 1.26.2.1 2001/11/28 11:54:45 keithw Exp $ */
/* $Id: xm_dd.c,v 1.26.2.7 2002/06/19 21:50:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.0.3
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -23,7 +23,7 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* $XFree86: xc/extras/Mesa/src/X/xm_dd.c,v 1.2 2002/02/26 23:37:31 tsi Exp $ */
#include "glxheader.h"
#include "context.h"
@@ -48,74 +48,39 @@
/*
* Return the size (width,height of the current color buffer.
* This function should be called by the glViewport function because
* glViewport is often called when the window gets resized. We need to
* update some X/Mesa stuff when that happens.
* Return the size (width, height) of the X window for the given GLframebuffer.
* Output: width - width of buffer in pixels.
* height - height of buffer in pixels.
*/
static void
get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
/* We can do this cast because the first field in the XMesaBuffer
* struct is a GLframebuffer struct. If this weren't true, we'd
* need a pointer from the GLframebuffer to the XMesaBuffer.
*/
const XMesaBuffer xmBuffer = (XMesaBuffer) buffer;
unsigned int winwidth, winheight;
#ifndef XFree86Server
#ifdef XFree86Server
/* XFree86 GLX renderer */
winwidth = xmBuffer->frontbuffer->width;
winheight = xmBuffer->frontbuffer->height;
#else
Window root;
int winx, winy;
unsigned int bw, d;
_glthread_LOCK_MUTEX(_xmesa_lock);
XGetGeometry( xmesa->display, xmesa->xm_buffer->frontbuffer, &root,
XSync(xmBuffer->xm_visual->display, 0); /* added for Chromium */
XGetGeometry( xmBuffer->xm_visual->display, xmBuffer->frontbuffer, &root,
&winx, &winy, &winwidth, &winheight, &bw, &d );
_glthread_UNLOCK_MUTEX(_xmesa_lock);
#else
winwidth = xmesa->xm_buffer->frontbuffer->width;
winheight = xmesa->xm_buffer->frontbuffer->height;
#endif
(void)kernel8; /* Muffle compiler */
*width = winwidth;
*height = winheight;
if ( winwidth!=xmesa->xm_buffer->width
|| winheight!=xmesa->xm_buffer->height) {
xmesa->xm_buffer->width = winwidth;
xmesa->xm_buffer->height = winheight;
xmesa_alloc_back_buffer( xmesa->xm_buffer );
}
/* Needed by FLIP macro */
xmesa->xm_buffer->bottom = (int) winheight - 1;
if (xmesa->xm_buffer->backimage) {
/* Needed by PIXELADDR1 macro */
xmesa->xm_buffer->ximage_width1
= xmesa->xm_buffer->backimage->bytes_per_line;
xmesa->xm_buffer->ximage_origin1
= (GLubyte *) xmesa->xm_buffer->backimage->data
+ xmesa->xm_buffer->ximage_width1 * (winheight-1);
/* Needed by PIXELADDR2 macro */
xmesa->xm_buffer->ximage_width2
= xmesa->xm_buffer->backimage->bytes_per_line / 2;
xmesa->xm_buffer->ximage_origin2
= (GLushort *) xmesa->xm_buffer->backimage->data
+ xmesa->xm_buffer->ximage_width2 * (winheight-1);
/* Needed by PIXELADDR3 macro */
xmesa->xm_buffer->ximage_width3
= xmesa->xm_buffer->backimage->bytes_per_line;
xmesa->xm_buffer->ximage_origin3
= (GLubyte *) xmesa->xm_buffer->backimage->data
+ xmesa->xm_buffer->ximage_width3 * (winheight-1);
/* Needed by PIXELADDR4 macro */
xmesa->xm_buffer->ximage_width4 = xmesa->xm_buffer->backimage->width;
xmesa->xm_buffer->ximage_origin4
= (GLuint *) xmesa->xm_buffer->backimage->data
+ xmesa->xm_buffer->ximage_width4 * (winheight-1);
}
}
@@ -151,9 +116,7 @@ flush( GLcontext *ctx )
}
static GLboolean
static void
set_draw_buffer( GLcontext *ctx, GLenum mode )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
@@ -161,7 +124,6 @@ set_draw_buffer( GLcontext *ctx, GLenum mode )
/* write to front buffer */
xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer;
xmesa_update_span_funcs(ctx);
return GL_TRUE;
}
else if (mode==GL_BACK_LEFT && xmesa->xm_buffer->db_state) {
/* write to back buffer */
@@ -177,10 +139,11 @@ set_draw_buffer( GLcontext *ctx, GLenum mode )
xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer;
}
xmesa_update_span_funcs(ctx);
return GL_TRUE;
}
else {
return GL_FALSE;
/* the swrast->_RasterMask MULTI_DRAW_BIT will be set and
* we'll fall back to swrast to draw points/lines/triangles.
*/
}
}
@@ -281,8 +244,7 @@ color_mask(GLcontext *ctx,
int xclass = GET_VISUAL_CLASS(xmesa->xm_visual);
(void) amask;
if (xmesa->xm_buffer->buffer != XIMAGE
&& (xclass == TrueColor || xclass == DirectColor)) {
if (xclass == TrueColor || xclass == DirectColor) {
unsigned long m;
if (rmask && gmask && bmask) {
m = ((unsigned long)~0L);
@@ -777,10 +739,51 @@ clear_buffers( GLcontext *ctx, GLbitfield mask,
}
static void
resize_buffers( GLcontext *ctx )
/*
* When we detect that the user has resized the window this function will
* get called. Here we'll reallocate the back buffer, depth buffer,
* stencil buffer etc. to match the new window size.
*/
void
xmesa_resize_buffers( GLframebuffer *buffer )
{
_swrast_alloc_buffers( ctx );
int height = (int) buffer->Height;
/* We can do this cast because the first field in the XMesaBuffer
* struct is a GLframebuffer struct. If this weren't true, we'd
* need a pointer from the GLframebuffer to the XMesaBuffer.
*/
XMesaBuffer xmBuffer = (XMesaBuffer) buffer;
xmBuffer->width = buffer->Width;
xmBuffer->height = buffer->Height;
xmesa_alloc_back_buffer( xmBuffer );
/* Needed by FLIP macro */
xmBuffer->bottom = height - 1;
if (xmBuffer->backimage) {
/* Needed by PIXELADDR1 macro */
xmBuffer->ximage_width1 = xmBuffer->backimage->bytes_per_line;
xmBuffer->ximage_origin1 = (GLubyte *) xmBuffer->backimage->data
+ xmBuffer->ximage_width1 * (height-1);
/* Needed by PIXELADDR2 macro */
xmBuffer->ximage_width2 = xmBuffer->backimage->bytes_per_line / 2;
xmBuffer->ximage_origin2 = (GLushort *) xmBuffer->backimage->data
+ xmBuffer->ximage_width2 * (height-1);
/* Needed by PIXELADDR3 macro */
xmBuffer->ximage_width3 = xmBuffer->backimage->bytes_per_line;
xmBuffer->ximage_origin3 = (GLubyte *) xmBuffer->backimage->data
+ xmBuffer->ximage_width3 * (height-1);
/* Needed by PIXELADDR4 macro */
xmBuffer->ximage_width4 = xmBuffer->backimage->width;
xmBuffer->ximage_origin4 = (GLuint *) xmBuffer->backimage->data
+ xmBuffer->ximage_width4 * (height-1);
}
_swrast_alloc_buffers( buffer );
}
#if 0
@@ -948,7 +951,7 @@ void xmesa_init_pointers( GLcontext *ctx )
ctx->Driver.Accum = _swrast_Accum;
ctx->Driver.Bitmap = _swrast_Bitmap;
ctx->Driver.Clear = clear_buffers;
ctx->Driver.ResizeBuffersMESA = resize_buffers;
ctx->Driver.ResizeBuffers = xmesa_resize_buffers;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;

View File

@@ -1,10 +1,10 @@
/* $Id: xm_line.c,v 1.18 2001/09/12 03:32:29 brianp Exp $ */
/* $Id: xm_line.c,v 1.18.2.1 2002/06/14 03:49:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.0.3
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -560,6 +560,7 @@ static swrast_line_func get_line_func( GLcontext *ctx )
if (ctx->Texture._ReallyEnabled) return (swrast_line_func) NULL;
if (ctx->Light.ShadeModel != GL_FLAT) return (swrast_line_func) NULL;
if (ctx->Line.StippleFlag) return (swrast_line_func) NULL;
if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
if (xmesa->xm_buffer->buffer==XIMAGE
&& swrast->_RasterMask==DEPTH_BIT

Some files were not shown because too many files have changed in this diff Show More