[OPENGL32][MESA] Downgrade Mesa library to version 2.6

With this commit, we now use a forked version of MESA which only supports OpenGL 1.1, like the windows implementation does.
It exposes :
  - The same pixel formats
  - The same set of extensions
  - Nothing more
All of this without taking 10% of your build time.
If you need a more modern option, look at the MESA package from Rapps, which is (and must be) maintained outside of this code tree.
CORE-7499
This commit is contained in:
Jérôme Gardou
2018-12-10 18:04:20 +01:00
committed by Jérôme Gardou
parent 905bcf617f
commit 5f2bebf7a5
448 changed files with 56975 additions and 132249 deletions

View File

@@ -1,36 +1,71 @@
include_directories(.)
# our DBG definitions conflict with mesa source code
remove_definitions(-DDBG=1 -DDBG=0)
add_definitions(-DFAST_MATH -DTHREADS)
add_definitions(
-DWIN32
-D_WINDOWS
-D_DLL
-DFEATURE_GL=1
-D_GDI32_ # prevent gl* being declared __declspec(dllimport) in MS headers
-DBUILD_GL32 # declare gl* as __declspec(dllexport) in Mesa headers
-D_GLAPI_NO_EXPORTS # prevent _glapi_* from being declared __declspec(dllimport)
if(ARCH STREQUAL "i386")
list(APPEND ASM_SOURCE asm-386.S)
add_definitions(-DUSE_ASM)
endif()
add_asm_files(mesa_asm ${ASM_SOURCE})
list(APPEND SOURCE
accum.c
alpha.c
alphabuf.c
api.c
attrib.c
bitmap.c
blend.c
clip.c
colortab.c
context.c
copypix.c
depth.c
dlist.c
drawpix.c
enable.c
eval.c
feedback.c
fog.c
get.c
hash.c
image.c
light.c
lines.c
logic.c
masking.c
matrix.c
misc.c
mmath.c
pb.c
pixel.c
pointers.c
points.c
polygon.c
quads.c
rastpos.c
readpix.c
rect.c
scissor.c
shade.c
span.c
stencil.c
teximage.c
texobj.c
texstate.c
texture.c
triangle.c
varray.c
vb.c
vbfill.c
vbrender.c
vbxform.c
xform.c
)
if(OPENGL32_USE_TLS)
add_definitions(-DOPENGL32_USE_TLS)
endif()
add_library(mesa STATIC ${SOURCE} ${mesa_asm})
add_dependencies(mesa psdk)
if((ARCH STREQUAL "i386") AND (NOT MSVC))
add_definitions(
-DUSE_X86_ASM
-DUSE_MMX_ASM
-DUSE_3DNOW_ASM
-DUSE_SSE_ASM)
add_subdirectory(x86)
endif()
add_subdirectory(drivers/common)
add_subdirectory(main)
add_subdirectory(math)
add_subdirectory(swrast)
add_subdirectory(swrast_setup)
add_subdirectory(tnl)
add_subdirectory(vbo)

373
dll/opengl/mesa/accum.c Normal file
View File

@@ -0,0 +1,373 @@
/* $Id: accum.c,v 1.5 1997/07/24 01:24:28 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: accum.c,v $
* Revision 1.5 1997/07/24 01:24:28 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.4 1997/05/28 03:23:09 brianp
* added precompiled header (PCH) support
*
* Revision 1.3 1997/04/30 01:54:48 brianp
* call gl_warning() if calling gl_Accum w/out accum buffer
*
* Revision 1.2 1996/09/15 14:19:44 brianp
* now use GLframebuffer and GLvisual
* added gl_alloc_accum_buffer()
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "accum.h"
#include "context.h"
#include "dlist.h"
#include "macros.h"
#include "types.h"
#endif
void gl_alloc_accum_buffer( GLcontext *ctx )
{
GLint n;
if (ctx->Buffer->Accum) {
free( ctx->Buffer->Accum );
ctx->Buffer->Accum = NULL;
}
/* allocate accumulation buffer if not already present */
n = ctx->Buffer->Width * ctx->Buffer->Height * 4 * sizeof(GLaccum);
ctx->Buffer->Accum = (GLaccum *) malloc( n );
if (!ctx->Buffer->Accum) {
/* unable to setup accumulation buffer */
gl_error( ctx, GL_OUT_OF_MEMORY, "glAccum" );
}
}
void gl_ClearAccum( GLcontext *ctx,
GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glAccum" );
return;
}
ctx->Accum.ClearColor[0] = CLAMP( red, -1.0, 1.0 );
ctx->Accum.ClearColor[1] = CLAMP( green, -1.0, 1.0 );
ctx->Accum.ClearColor[2] = CLAMP( blue, -1.0, 1.0 );
ctx->Accum.ClearColor[3] = CLAMP( alpha, -1.0, 1.0 );
}
void gl_Accum( GLcontext *ctx, GLenum op, GLfloat value )
{
GLuint xpos, ypos, width, height;
GLfloat acc_scale;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glAccum" );
return;
}
if (ctx->Visual->AccumBits==0 || !ctx->Buffer->Accum) {
/* No accumulation buffer! */
gl_warning(ctx, "Calling glAccum() without an accumulation buffer");
return;
}
if (sizeof(GLaccum)==1) {
acc_scale = 127.0;
}
else if (sizeof(GLaccum)==2) {
acc_scale = 32767.0;
}
else {
/* sizeof(GLaccum) > 2 (Cray) */
acc_scale = (float) SHRT_MAX;
}
/* Determine region to operate upon. */
if (ctx->Scissor.Enabled) {
xpos = ctx->Scissor.X;
ypos = ctx->Scissor.Y;
width = ctx->Scissor.Width;
height = ctx->Scissor.Height;
}
else {
/* whole window */
xpos = 0;
ypos = 0;
width = ctx->Buffer->Width;
height = ctx->Buffer->Height;
}
switch (op) {
case GL_ADD:
{
GLaccum ival, *acc;
GLuint i, j;
ival = (GLaccum) (value * acc_scale);
for (j=0;j<height;j++) {
acc = ctx->Buffer->Accum
+ (ypos * ctx->Buffer->Width + xpos) * 4;
for (i=0;i<width;i++) {
*acc += ival; acc++; /* red */
*acc += ival; acc++; /* green */
*acc += ival; acc++; /* blue */
*acc += ival; acc++; /* alpha */
}
ypos++;
}
}
break;
case GL_MULT:
{
GLaccum *acc;
GLuint i, j;
for (j=0;j<height;j++) {
acc = ctx->Buffer->Accum
+ (ypos * ctx->Buffer->Width + xpos) * 4;
for (i=0;i<width;i++) {
*acc = (GLaccum) ( (GLfloat) *acc * value ); acc++; /*r*/
*acc = (GLaccum) ( (GLfloat) *acc * value ); acc++; /*g*/
*acc = (GLaccum) ( (GLfloat) *acc * value ); acc++; /*g*/
*acc = (GLaccum) ( (GLfloat) *acc * value ); acc++; /*a*/
}
ypos++;
}
}
break;
case GL_ACCUM:
{
GLaccum *acc;
GLubyte red[MAX_WIDTH], green[MAX_WIDTH];
GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH];
GLfloat rscale, gscale, bscale, ascale;
GLuint i, j;
(void) (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer );
/* Accumulate */
rscale = value * acc_scale * ctx->Visual->InvRedScale;
gscale = value * acc_scale * ctx->Visual->InvGreenScale;
bscale = value * acc_scale * ctx->Visual->InvBlueScale;
ascale = value * acc_scale * ctx->Visual->InvAlphaScale;
for (j=0;j<height;j++) {
(*ctx->Driver.ReadColorSpan)( ctx, width, xpos, ypos,
red, green, blue, alpha);
acc = ctx->Buffer->Accum
+ (ypos * ctx->Buffer->Width + xpos) * 4;
for (i=0;i<width;i++) {
*acc += (GLaccum) ( (GLfloat) red[i] * rscale ); acc++;
*acc += (GLaccum) ( (GLfloat) green[i] * gscale ); acc++;
*acc += (GLaccum) ( (GLfloat) blue[i] * bscale ); acc++;
*acc += (GLaccum) ( (GLfloat) alpha[i] * ascale ); acc++;
}
ypos++;
}
(void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DrawBuffer );
}
break;
case GL_LOAD:
{
GLaccum *acc;
GLubyte red[MAX_WIDTH], green[MAX_WIDTH];
GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH];
GLfloat rscale, gscale, bscale, ascale;
GLuint i, j;
(void) (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer );
/* Load accumulation buffer */
rscale = value * acc_scale * ctx->Visual->InvRedScale;
gscale = value * acc_scale * ctx->Visual->InvGreenScale;
bscale = value * acc_scale * ctx->Visual->InvBlueScale;
ascale = value * acc_scale * ctx->Visual->InvAlphaScale;
for (j=0;j<height;j++) {
(*ctx->Driver.ReadColorSpan)( ctx, width, xpos, ypos,
red, green, blue, alpha);
acc = ctx->Buffer->Accum
+ (ypos * ctx->Buffer->Width + xpos) * 4;
for (i=0;i<width;i++) {
*acc++ = (GLaccum) ( (GLfloat) red[i] * rscale );
*acc++ = (GLaccum) ( (GLfloat) green[i] * gscale );
*acc++ = (GLaccum) ( (GLfloat) blue[i] * bscale );
*acc++ = (GLaccum) ( (GLfloat) alpha[i] * ascale );
}
ypos++;
}
(void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DrawBuffer );
}
break;
case GL_RETURN:
{
GLubyte red[MAX_WIDTH], green[MAX_WIDTH];
GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH];
GLaccum *acc;
GLfloat rscale, gscale, bscale, ascale;
GLint rmax, gmax, bmax, amax;
GLuint i, j;
rscale = value / acc_scale * ctx->Visual->RedScale;
gscale = value / acc_scale * ctx->Visual->GreenScale;
bscale = value / acc_scale * ctx->Visual->BlueScale;
ascale = value / acc_scale * ctx->Visual->AlphaScale;
rmax = (GLint) ctx->Visual->RedScale;
gmax = (GLint) ctx->Visual->GreenScale;
bmax = (GLint) ctx->Visual->BlueScale;
amax = (GLint) ctx->Visual->AlphaScale;
for (j=0;j<height;j++) {
acc = ctx->Buffer->Accum
+ (ypos * ctx->Buffer->Width + xpos) * 4;
for (i=0;i<width;i++) {
GLint r, g, b, a;
r = (GLint) ( (GLfloat) (*acc++) * rscale + 0.5F );
g = (GLint) ( (GLfloat) (*acc++) * gscale + 0.5F );
b = (GLint) ( (GLfloat) (*acc++) * bscale + 0.5F );
a = (GLint) ( (GLfloat) (*acc++) * ascale + 0.5F );
red[i] = CLAMP( r, 0, rmax );
green[i] = CLAMP( g, 0, gmax );
blue[i] = CLAMP( b, 0, bmax );
alpha[i] = CLAMP( a, 0, amax );
}
(*ctx->Driver.WriteColorSpan)( ctx, width, xpos, ypos,
red, green, blue, alpha, NULL );
ypos++;
}
}
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glAccum" );
}
}
/*
* Clear the accumulation Buffer->
*/
void gl_clear_accum_buffer( GLcontext *ctx )
{
GLuint buffersize;
GLfloat acc_scale;
if (ctx->Visual->AccumBits==0) {
/* No accumulation buffer! */
return;
}
if (sizeof(GLaccum)==1) {
acc_scale = 127.0;
}
else if (sizeof(GLaccum)==2) {
acc_scale = 32767.0;
}
else {
/* sizeof(GLaccum) > 2 (Cray) */
acc_scale = (float) SHRT_MAX;
}
/* number of pixels */
buffersize = ctx->Buffer->Width * ctx->Buffer->Height;
if (!ctx->Buffer->Accum) {
/* try to alloc accumulation buffer */
ctx->Buffer->Accum = (GLaccum *)
malloc( buffersize * 4 * sizeof(GLaccum) );
}
if (ctx->Buffer->Accum) {
if (ctx->Scissor.Enabled) {
/* Limit clear to scissor box */
GLaccum r, g, b, a;
GLint i, j;
GLint width, height;
GLaccum *row;
r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
/* size of region to clear */
width = 4 * (ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1);
height = ctx->Buffer->Ymax - ctx->Buffer->Ymin + 1;
/* ptr to first element to clear */
row = ctx->Buffer->Accum
+ 4 * (ctx->Buffer->Ymin * ctx->Buffer->Width
+ ctx->Buffer->Xmin);
for (j=0;j<height;j++) {
for (i=0;i<width;i+=4) {
row[i+0] = r;
row[i+1] = g;
row[i+2] = b;
row[i+3] = a;
}
row += 4 * ctx->Buffer->Width;
}
}
else {
/* clear whole buffer */
if (ctx->Accum.ClearColor[0]==0.0 &&
ctx->Accum.ClearColor[1]==0.0 &&
ctx->Accum.ClearColor[2]==0.0 &&
ctx->Accum.ClearColor[3]==0.0) {
/* Black */
MEMSET( ctx->Buffer->Accum, 0, buffersize * 4 * sizeof(GLaccum) );
}
else {
/* Not black */
GLaccum *acc, r, g, b, a;
GLuint i;
acc = ctx->Buffer->Accum;
r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
for (i=0;i<buffersize;i++) {
*acc++ = r;
*acc++ = g;
*acc++ = b;
*acc++ = a;
}
}
}
}
}

55
dll/opengl/mesa/accum.h Normal file
View File

@@ -0,0 +1,55 @@
/* $Id: accum.h,v 1.2 1996/09/15 14:19:57 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: accum.h,v $
* Revision 1.2 1996/09/15 14:19:57 brianp
* added gl_alloc_accum_buffer()
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef ACCUM_H
#define ACCUM_H
#include "types.h"
extern void gl_alloc_accum_buffer( GLcontext *ctx );
extern void gl_Accum( GLcontext* ctx, GLenum op, GLfloat value );
extern void gl_ClearAccum( GLcontext* ctx, GLfloat red, GLfloat green,
GLfloat blue, GLfloat alpha );
extern void gl_clear_accum_buffer( GLcontext* ctx );
#endif

136
dll/opengl/mesa/all.h Normal file
View File

@@ -0,0 +1,136 @@
/* $Id: all.h,v 1.6 1997/12/15 03:40:05 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.6
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: all.h,v $
* Revision 1.6 1997/12/15 03:40:05 brianp
* added asm-386.h file
*
* Revision 1.5 1997/11/20 00:23:21 brianp
* added rect.h
*
* Revision 1.4 1997/09/27 00:16:04 brianp
* added colortab.h
*
* Revision 1.3 1997/08/22 01:42:48 brianp
* added api.h and hash.h
*
* Revision 1.2 1997/05/28 03:22:27 brianp
* added a few more headers
*
* Revision 1.1 1997/04/02 03:49:26 brianp
* Initial revision
*
*/
/* The purpose of this file is to collect all the header files that Mesa
* uses into a single header so that we can get new compilers that support
* pre-compiled headers to compile much faster.
* All we do is list all the internal headers used by Mesa in this one
* main header file, and most compilers will pre-compile all these headers
* and use them over and over again for each source module. This makes a
* big difference for Win32 support, because the <windows.h> headers take
* a *long* time to compile.
*/
#ifndef SRC_ALL_H
#define SRC_ALL_H
#ifndef PC_HEADER
This is an error. all.h should be included only if PC_HEADER is defined.
#endif
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include "GL/gl.h"
#include "GL/osmesa.h"
#include "accum.h"
#include "alpha.h"
#include "alphabuf.h"
#include "api.h"
#include "asm-386.h"
#include "attrib.h"
#include "bitmap.h"
#include "blend.h"
#include "clip.h"
#include "colortab.h"
#include "context.h"
#include "config.h"
#include "copypix.h"
#include "dd.h"
#include "depth.h"
#include "dlist.h"
#include "drawpix.h"
#include "enable.h"
#include "eval.h"
#include "feedback.h"
#include "fixed.h"
#include "fog.h"
#include "get.h"
#include "hash.h"
#include "image.h"
#include "light.h"
#include "lines.h"
#include "logic.h"
#include "macros.h"
#include "masking.h"
#include "matrix.h"
#include "misc.h"
#include "mmath.h"
#include "pb.h"
#include "pixel.h"
#include "pointers.h"
#include "points.h"
#include "polygon.h"
#include "rastpos.h"
#include "readpix.h"
#include "rect.h"
#include "scissor.h"
#include "shade.h"
#include "span.h"
#include "stencil.h"
#include "teximage.h"
#include "texobj.h"
#include "texstate.h"
#include "texture.h"
#include "triangle.h"
#include "types.h"
#include "varray.h"
#include "vb.h"
#include "vbfill.h"
#include "vbrender.h"
#include "vbxform.h"
#include "winpos.h"
#include "xform.h"
#endif /*SRC_ALL_H*/

142
dll/opengl/mesa/alpha.c Normal file
View File

@@ -0,0 +1,142 @@
/* $Id: alpha.c,v 1.5 1997/07/24 01:24:28 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: alpha.c,v $
* Revision 1.5 1997/07/24 01:24:28 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.4 1997/05/28 03:23:09 brianp
* added precompiled header (PCH) support
*
* Revision 1.3 1997/03/13 03:07:53 brianp
* optimized gl_alpha_test() by removing conditional from inside loops
*
* Revision 1.2 1996/09/15 14:15:54 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include "alpha.h"
#include "context.h"
#include "types.h"
#include "dlist.h"
#include "macros.h"
#endif
void gl_AlphaFunc( GLcontext* ctx, GLenum func, GLclampf ref )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glAlphaFunc" );
return;
}
switch (func) {
case GL_NEVER:
case GL_LESS:
case GL_EQUAL:
case GL_LEQUAL:
case GL_GREATER:
case GL_NOTEQUAL:
case GL_GEQUAL:
case GL_ALWAYS:
ctx->Color.AlphaFunc = func;
ctx->Color.AlphaRef = CLAMP( ref, 0.0F, 1.0F );
ctx->Color.AlphaRefUbyte = (GLubyte) (ctx->Color.AlphaRef
* ctx->Visual->AlphaScale);
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glAlphaFunc(func)" );
break;
}
}
/*
* Apply the alpha test to a span of pixels.
* In/Out: mask - current pixel mask. Pixels which fail the alpha test
* will set the corresponding mask flag to 0.
* Return: 0 = all pixels in the span failed the alpha test.
* 1 = one or more pixels passed the alpha test.
*/
GLint gl_alpha_test( GLcontext* ctx,
GLuint n, const GLubyte alpha[], GLubyte mask[] )
{
GLuint i;
GLubyte ref = ctx->Color.AlphaRefUbyte;
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Color.AlphaFunc) {
case GL_LESS:
for (i=0;i<n;i++) {
mask[i] &= (alpha[i] < ref);
}
return 1;
case GL_LEQUAL:
for (i=0;i<n;i++) {
mask[i] &= (alpha[i] <= ref);
}
return 1;
case GL_GEQUAL:
for (i=0;i<n;i++) {
mask[i] &= (alpha[i] >= ref);
}
return 1;
case GL_GREATER:
for (i=0;i<n;i++) {
mask[i] &= (alpha[i] > ref);
}
return 1;
case GL_NOTEQUAL:
for (i=0;i<n;i++) {
mask[i] &= (alpha[i] != ref);
}
return 1;
case GL_EQUAL:
for (i=0;i<n;i++) {
mask[i] &= (alpha[i] == ref);
}
return 1;
case GL_ALWAYS:
/* do nothing */
return 1;
case GL_NEVER:
/* caller should check for zero! */
return 0;
default:
gl_problem( ctx, "Invalid alpha test in gl_alpha_test" );
return 0;
}
/* Never get here */
return 1;
}

46
dll/opengl/mesa/alpha.h Normal file
View File

@@ -0,0 +1,46 @@
/* $Id: alpha.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: alpha.h,v $
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef ALPHA_H
#define ALPHA_H
#include "types.h"
extern GLint gl_alpha_test( GLcontext* ctx,
GLuint n, const GLubyte alpha[], GLubyte mask[] );
extern void gl_AlphaFunc( GLcontext* ctx, GLenum func, GLclampf ref );
#endif

271
dll/opengl/mesa/alphabuf.c Normal file
View File

@@ -0,0 +1,271 @@
/* $Id: alphabuf.c,v 1.5 1997/07/24 01:24:28 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: alphabuf.c,v $
* Revision 1.5 1997/07/24 01:24:28 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.4 1997/05/28 03:23:09 brianp
* added precompiled header (PCH) support
*
* Revision 1.3 1996/10/02 02:51:07 brianp
* in gl_clear_alpha_buffers() check for GL_FRONT_AND_BACK draw mode
*
* Revision 1.2 1996/09/15 14:15:54 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
/*
* Software alpha planes. Many frame buffers don't have alpha bits so
* we simulate them in software.
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <stdlib.h>
#include <string.h>
#include "alphabuf.h"
#include "context.h"
#include "macros.h"
#include "types.h"
#endif
#define ALPHA_ADDR(X,Y) (ctx->Buffer->Alpha + (Y) * ctx->Buffer->Width + (X))
/*
* Allocate a new front and back alpha buffer.
*/
void gl_alloc_alpha_buffers( GLcontext* ctx )
{
GLint bytes = ctx->Buffer->Width * ctx->Buffer->Height * sizeof(GLubyte);
if (ctx->Visual->FrontAlphaEnabled) {
if (ctx->Buffer->FrontAlpha) {
free( ctx->Buffer->FrontAlpha );
}
ctx->Buffer->FrontAlpha = (GLubyte *) malloc( bytes );
if (!ctx->Buffer->FrontAlpha) {
/* out of memory */
gl_error( ctx, GL_OUT_OF_MEMORY, "Couldn't allocate front alpha buffer" );
}
}
if (ctx->Visual->BackAlphaEnabled) {
if (ctx->Buffer->BackAlpha) {
free( ctx->Buffer->BackAlpha );
}
ctx->Buffer->BackAlpha = (GLubyte *) malloc( bytes );
if (!ctx->Buffer->BackAlpha) {
/* out of memory */
gl_error( ctx, GL_OUT_OF_MEMORY, "Couldn't allocate back alpha buffer" );
}
}
if (ctx->Color.DrawBuffer==GL_FRONT) {
ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha;
}
if (ctx->Color.DrawBuffer==GL_BACK) {
ctx->Buffer->Alpha = ctx->Buffer->BackAlpha;
}
}
/*
* Clear the front and/or back alpha planes.
*/
void gl_clear_alpha_buffers( GLcontext* ctx )
{
GLint buffer;
/* Loop over front and back buffers */
for (buffer=0;buffer<2;buffer++) {
/* Get pointer to front or back buffer */
GLubyte *abuffer = NULL;
if (buffer==0
&& ( ctx->Color.DrawBuffer==GL_FRONT
|| ctx->Color.DrawBuffer==GL_FRONT_AND_BACK)
&& ctx->Visual->FrontAlphaEnabled && ctx->Buffer->FrontAlpha) {
abuffer = ctx->Buffer->FrontAlpha;
}
else if (buffer==1
&& ( ctx->Color.DrawBuffer==GL_BACK
|| ctx->Color.DrawBuffer==GL_FRONT_AND_BACK)
&& ctx->Visual->BackAlphaEnabled && ctx->Buffer->BackAlpha) {
abuffer = ctx->Buffer->BackAlpha;
}
/* Clear the alpha buffer */
if (abuffer) {
GLubyte aclear = (GLint) (ctx->Color.ClearColor[3]
* ctx->Visual->AlphaScale);
if (ctx->Scissor.Enabled) {
/* clear scissor region */
GLint i, j;
for (j=0;j<ctx->Scissor.Height;j++) {
GLubyte *aptr = ALPHA_ADDR(ctx->Buffer->Xmin,
ctx->Buffer->Ymin+j);
for (i=0;i<ctx->Scissor.Width;i++) {
*aptr++ = aclear;
}
}
}
else {
/* clear whole buffer */
MEMSET( abuffer, aclear, ctx->Buffer->Width*ctx->Buffer->Height );
}
}
}
}
void gl_write_alpha_span( GLcontext* ctx, GLuint n, GLint x, GLint y,
GLubyte alpha[], GLubyte mask[] )
{
GLubyte *aptr = ALPHA_ADDR( x, y );
GLuint i;
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
*aptr = alpha[i];
}
aptr++;
}
}
else {
for (i=0;i<n;i++) {
*aptr++ = alpha[i];
}
}
}
void gl_write_mono_alpha_span( GLcontext* ctx, GLuint n, GLint x, GLint y,
GLubyte alpha, GLubyte mask[] )
{
GLubyte *aptr = ALPHA_ADDR( x, y );
GLuint i;
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
*aptr = alpha;
}
aptr++;
}
}
else {
for (i=0;i<n;i++) {
*aptr++ = alpha;
}
}
}
void gl_write_alpha_pixels( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
const GLubyte alpha[], const GLubyte mask[] )
{
GLuint i;
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
GLubyte *aptr = ALPHA_ADDR( x[i], y[i] );
*aptr = alpha[i];
}
}
}
else {
for (i=0;i<n;i++) {
GLubyte *aptr = ALPHA_ADDR( x[i], y[i] );
*aptr = alpha[i];
}
}
}
void gl_write_mono_alpha_pixels( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte alpha, const GLubyte mask[] )
{
GLuint i;
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
GLubyte *aptr = ALPHA_ADDR( x[i], y[i] );
*aptr = alpha;
}
}
}
else {
for (i=0;i<n;i++) {
GLubyte *aptr = ALPHA_ADDR( x[i], y[i] );
*aptr = alpha;
}
}
}
void gl_read_alpha_span( GLcontext* ctx,
GLuint n, GLint x, GLint y, GLubyte alpha[] )
{
GLubyte *aptr = ALPHA_ADDR( x, y );
GLuint i;
for (i=0;i<n;i++) {
alpha[i] = *aptr++;
}
}
void gl_read_alpha_pixels( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte alpha[], const GLubyte mask[] )
{
GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
GLubyte *aptr = ALPHA_ADDR( x[i], y[i] );
alpha[i] = *aptr;
}
}
}

View File

@@ -0,0 +1,78 @@
/* $Id: alphabuf.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: alphabuf.h,v $
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef ALPHABUF_H
#define ALPHABUF_H
#include "types.h"
extern void gl_alloc_alpha_buffers( GLcontext* ctx );
extern void gl_clear_alpha_buffers( GLcontext* ctx );
extern void gl_write_alpha_span( GLcontext* ctx, GLuint n, GLint x, GLint y,
GLubyte alpha[], GLubyte mask[] );
extern void gl_write_mono_alpha_span( GLcontext* ctx,
GLuint n, GLint x, GLint y,
GLubyte alpha, GLubyte mask[] );
extern void gl_write_alpha_pixels( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
const GLubyte alpha[],
const GLubyte mask[] );
extern void gl_write_mono_alpha_pixels( GLcontext* ctx,
GLuint n, const GLint x[],
const GLint y[], GLubyte alpha,
const GLubyte mask[] );
extern void gl_read_alpha_span( GLcontext* ctx,
GLuint n, GLint x, GLint y, GLubyte alpha[] );
extern void gl_read_alpha_pixels( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte alpha[], const GLubyte mask[] );
#endif

2874
dll/opengl/mesa/api.c Normal file

File diff suppressed because it is too large Load Diff

83
dll/opengl/mesa/api.h Normal file
View File

@@ -0,0 +1,83 @@
/* $Id: api.h,v 1.4 1998/02/04 00:38:24 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: api.h,v $
* Revision 1.4 1998/02/04 00:38:24 brianp
* WIN32 patch from Oleg Letsinsky
*
* Revision 1.3 1998/02/04 00:13:35 brianp
* updated for Cygnus (Stephane Rehel)
*
* Revision 1.2 1997/11/25 03:20:09 brianp
* simple clean-ups for multi-threading (John Stone)
*
* Revision 1.1 1997/08/22 01:42:26 brianp
* Initial revision
*
*/
/*
* The original api.c file has been split into two files: api1.c and api2.c
* because some compilers complained that api.c was too big.
*
* This header contains stuff only included by api1.c and api2.c
*/
#ifndef API_H
#define API_H
/*
* Single/multiple thread context selection.
*/
#ifdef THREADS
/* Get the context associated with the calling thread */
#define GET_CONTEXT GLcontext *CC = gl_get_thread_context()
#else
/* CC is a global pointer for all threads in the address space */
#define GET_CONTEXT
#endif /* THREADS */
/*
* An optimization in a few performance-critical functions.
*/
#define SHORTCUT
/*
* Windows 95/NT DLL stuff.
*/
#if !defined(WIN32) && !defined(WINDOWS_NT) && !defined(__CYGWIN32__)
#define APIENTRY
#endif
#endif

1644
dll/opengl/mesa/asm-386.S Normal file

File diff suppressed because it is too large Load Diff

99
dll/opengl/mesa/asm-386.h Normal file
View File

@@ -0,0 +1,99 @@
/* $Id: asm-386.h,v 1.1 1997/12/15 03:39:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.6
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: asm-386.h,v $
* Revision 1.1 1997/12/15 03:39:14 brianp
* Initial revision
*
*/
#ifndef ASM_386_H
#define ASM_386_H
#include "GL/gl.h"
/*
* Prototypes for assembly functions.
*/
extern void asm_transform_points3_general( GLuint n, GLfloat d[][4],
GLfloat m[16], GLfloat s[][4] );
extern void asm_transform_points3_identity( GLuint n, GLfloat d[][4],
GLfloat s[][4] );
extern void asm_transform_points3_2d( GLuint n, GLfloat d[][4],
GLfloat m[16], GLfloat s[][4] );
extern void asm_transform_points3_2d_no_rot( GLuint n, GLfloat d[][4],
GLfloat m[16], GLfloat s[][4] );
extern void asm_transform_points3_3d( GLuint n, GLfloat d[][4], GLfloat m[16],
GLfloat s[][4] );
extern void asm_transform_points4_general( GLuint n, GLfloat d[][4],
GLfloat m[16], GLfloat s[][4] );
extern void asm_transform_points4_identity( GLuint n, GLfloat d[][4],
GLfloat s[][4] );
extern void asm_transform_points4_2d( GLuint n, GLfloat d[][4], GLfloat m[16],
GLfloat s[][4] );
extern void asm_transform_points4_2d_no_rot( GLuint n, GLfloat d[][4],
GLfloat m[16], GLfloat s[][4] );
extern void asm_transform_points4_3d( GLuint n, GLfloat d[][4], GLfloat m[16],
GLfloat s[][4] );
extern void asm_transform_points4_ortho( GLuint n, GLfloat d[][4],
GLfloat m[16], GLfloat s[][4] );
extern void asm_transform_points4_perspective( GLuint n, GLfloat d[][4],
GLfloat m[16], GLfloat s[][4] );
extern void asm_project_and_cliptest_general( GLuint n, GLfloat d[][4],
GLfloat m[16],
GLfloat s[][4], GLubyte clipmask[],
GLubyte *ormask, GLubyte *andmask );
extern void asm_project_and_cliptest_identity( GLuint n, GLfloat d[][4],
GLfloat s[][4], GLubyte clipmask[],
GLubyte *ormask, GLubyte *andmask );
extern void asm_project_and_cliptest_ortho( GLuint n, GLfloat d[][4],
GLfloat m[16],
GLfloat s[][4], GLubyte clipmask[],
GLubyte *ormask, GLubyte *andmask );
extern void asm_project_and_cliptest_perspective( GLuint n, GLfloat d[][4],
GLfloat m[16],
GLfloat s[][4], GLubyte clipmask[],
GLubyte *ormask, GLubyte *andmask );
#endif

624
dll/opengl/mesa/attrib.c Normal file
View File

@@ -0,0 +1,624 @@
/* $Id: attrib.c,v 1.9 1997/07/24 01:24:28 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: attrib.c,v $
* Revision 1.9 1997/07/24 01:24:28 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.8 1997/05/28 03:23:09 brianp
* added precompiled header (PCH) support
*
* Revision 1.7 1997/04/20 19:49:57 brianp
* replaced abort() calls with gl_problem()
*
* Revision 1.6 1997/04/01 04:18:28 brianp
* removed #include "draw.h"
*
* Revision 1.5 1997/01/28 22:13:02 brianp
* now there's separate state for CI and RGBA logic op enabled
*
* Revision 1.4 1996/10/01 03:30:01 brianp
* added #include "misc.h"
*
* Revision 1.3 1996/09/30 23:55:06 brianp
* call gl_DrawBuffer() when glPopAttrib(GL_COLOR_BUFFER_BIT)
*
* Revision 1.2 1996/09/27 01:24:14 brianp
* removed unused variables
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <stdlib.h>
#include <string.h>
#include "attrib.h"
#include "context.h"
#include "dlist.h"
#include "macros.h"
#include "misc.h"
#include "types.h"
#endif
#define MALLOC_STRUCT(T) (struct T *) malloc( sizeof(struct T) )
static struct gl_attrib_node *new_attrib_node( GLbitfield kind )
{
struct gl_attrib_node *an;
an = (struct gl_attrib_node *) malloc( sizeof(struct gl_attrib_node) );
if (an) {
an->kind = kind;
}
return an;
}
void gl_PushAttrib( GLcontext* ctx, GLbitfield mask )
{
struct gl_attrib_node *newnode;
struct gl_attrib_node *head;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glPushAttrib" );
return;
}
if (ctx->AttribStackDepth>=MAX_ATTRIB_STACK_DEPTH) {
gl_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" );
return;
}
/* Build linked list of attribute nodes which save all attribute */
/* groups specified by the mask. */
head = NULL;
if (mask & GL_ACCUM_BUFFER_BIT) {
struct gl_accum_attrib *attr;
attr = MALLOC_STRUCT( gl_accum_attrib );
MEMCPY( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) );
newnode = new_attrib_node( GL_ACCUM_BUFFER_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_COLOR_BUFFER_BIT) {
struct gl_colorbuffer_attrib *attr;
attr = MALLOC_STRUCT( gl_colorbuffer_attrib );
MEMCPY( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) );
newnode = new_attrib_node( GL_COLOR_BUFFER_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_CURRENT_BIT) {
struct gl_current_attrib *attr;
attr = MALLOC_STRUCT( gl_current_attrib );
MEMCPY( attr, &ctx->Current, sizeof(struct gl_current_attrib) );
newnode = new_attrib_node( GL_CURRENT_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_DEPTH_BUFFER_BIT) {
struct gl_depthbuffer_attrib *attr;
attr = MALLOC_STRUCT( gl_depthbuffer_attrib );
MEMCPY( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) );
newnode = new_attrib_node( GL_DEPTH_BUFFER_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_ENABLE_BIT) {
struct gl_enable_attrib *attr;
GLuint i;
attr = MALLOC_STRUCT( gl_enable_attrib );
/* Copy enable flags from all other attributes into the enable struct. */
attr->AlphaTest = ctx->Color.AlphaEnabled;
attr->AutoNormal = ctx->Eval.AutoNormal;
attr->Blend = ctx->Color.BlendEnabled;
for (i=0;i<MAX_CLIP_PLANES;i++) {
attr->ClipPlane[i] = ctx->Transform.ClipEnabled[i];
}
attr->ColorMaterial = ctx->Light.ColorMaterialEnabled;
attr->CullFace = ctx->Polygon.CullFlag;
attr->DepthTest = ctx->Depth.Test;
attr->Dither = ctx->Color.DitherFlag;
attr->Fog = ctx->Fog.Enabled;
for (i=0;i<MAX_LIGHTS;i++) {
attr->Light[i] = ctx->Light.Light[i].Enabled;
}
attr->Lighting = ctx->Light.Enabled;
attr->LineSmooth = ctx->Line.SmoothFlag;
attr->LineStipple = ctx->Line.StippleFlag;
attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled;
attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled;
attr->Map1Color4 = ctx->Eval.Map1Color4;
attr->Map1Index = ctx->Eval.Map1Index;
attr->Map1Normal = ctx->Eval.Map1Normal;
attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1;
attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2;
attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3;
attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4;
attr->Map1Vertex3 = ctx->Eval.Map1Vertex3;
attr->Map1Vertex4 = ctx->Eval.Map1Vertex4;
attr->Map2Color4 = ctx->Eval.Map2Color4;
attr->Map2Index = ctx->Eval.Map2Index;
attr->Map2Normal = ctx->Eval.Map2Normal;
attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1;
attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2;
attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3;
attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4;
attr->Map2Vertex3 = ctx->Eval.Map2Vertex3;
attr->Map2Vertex4 = ctx->Eval.Map2Vertex4;
attr->Normalize = ctx->Transform.Normalize;
attr->PointSmooth = ctx->Point.SmoothFlag;
attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint;
attr->PolygonOffsetLine = ctx->Polygon.OffsetLine;
attr->PolygonOffsetFill = ctx->Polygon.OffsetFill;
attr->PolygonSmooth = ctx->Polygon.SmoothFlag;
attr->PolygonStipple = ctx->Polygon.StippleFlag;
attr->Scissor = ctx->Scissor.Enabled;
attr->Stencil = ctx->Stencil.Enabled;
attr->Texture = ctx->Texture.Enabled;
attr->TexGen = ctx->Texture.TexGenEnabled;
newnode = new_attrib_node( GL_ENABLE_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_EVAL_BIT) {
struct gl_eval_attrib *attr;
attr = MALLOC_STRUCT( gl_eval_attrib );
MEMCPY( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) );
newnode = new_attrib_node( GL_EVAL_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_FOG_BIT) {
struct gl_fog_attrib *attr;
attr = MALLOC_STRUCT( gl_fog_attrib );
MEMCPY( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) );
newnode = new_attrib_node( GL_FOG_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_HINT_BIT) {
struct gl_hint_attrib *attr;
attr = MALLOC_STRUCT( gl_hint_attrib );
MEMCPY( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) );
newnode = new_attrib_node( GL_HINT_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_LIGHTING_BIT) {
struct gl_light_attrib *attr;
attr = MALLOC_STRUCT( gl_light_attrib );
MEMCPY( attr, &ctx->Light, sizeof(struct gl_light_attrib) );
newnode = new_attrib_node( GL_LIGHTING_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_LINE_BIT) {
struct gl_line_attrib *attr;
attr = MALLOC_STRUCT( gl_line_attrib );
MEMCPY( attr, &ctx->Line, sizeof(struct gl_line_attrib) );
newnode = new_attrib_node( GL_LINE_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_LIST_BIT) {
struct gl_list_attrib *attr;
attr = MALLOC_STRUCT( gl_list_attrib );
MEMCPY( attr, &ctx->List, sizeof(struct gl_list_attrib) );
newnode = new_attrib_node( GL_LIST_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_PIXEL_MODE_BIT) {
struct gl_pixel_attrib *attr;
attr = MALLOC_STRUCT( gl_pixel_attrib );
MEMCPY( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) );
newnode = new_attrib_node( GL_PIXEL_MODE_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_POINT_BIT) {
struct gl_point_attrib *attr;
attr = MALLOC_STRUCT( gl_point_attrib );
MEMCPY( attr, &ctx->Point, sizeof(struct gl_point_attrib) );
newnode = new_attrib_node( GL_POINT_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_POLYGON_BIT) {
struct gl_polygon_attrib *attr;
attr = MALLOC_STRUCT( gl_polygon_attrib );
MEMCPY( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) );
newnode = new_attrib_node( GL_POLYGON_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_POLYGON_STIPPLE_BIT) {
GLuint *stipple;
stipple = (GLuint *) malloc( 32*sizeof(GLuint) );
MEMCPY( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) );
newnode = new_attrib_node( GL_POLYGON_STIPPLE_BIT );
newnode->data = stipple;
newnode->next = head;
head = newnode;
}
if (mask & GL_SCISSOR_BIT) {
struct gl_scissor_attrib *attr;
attr = MALLOC_STRUCT( gl_scissor_attrib );
MEMCPY( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) );
newnode = new_attrib_node( GL_SCISSOR_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_STENCIL_BUFFER_BIT) {
struct gl_stencil_attrib *attr;
attr = MALLOC_STRUCT( gl_stencil_attrib );
MEMCPY( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) );
newnode = new_attrib_node( GL_STENCIL_BUFFER_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_TEXTURE_BIT) {
struct gl_texture_attrib *attr;
attr = MALLOC_STRUCT( gl_texture_attrib );
MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) );
newnode = new_attrib_node( GL_TEXTURE_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_TRANSFORM_BIT) {
struct gl_transform_attrib *attr;
attr = MALLOC_STRUCT( gl_transform_attrib );
MEMCPY( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) );
newnode = new_attrib_node( GL_TRANSFORM_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_VIEWPORT_BIT) {
struct gl_viewport_attrib *attr;
attr = MALLOC_STRUCT( gl_viewport_attrib );
MEMCPY( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) );
newnode = new_attrib_node( GL_VIEWPORT_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
/* etc... */
ctx->AttribStack[ctx->AttribStackDepth] = head;
ctx->AttribStackDepth++;
}
void gl_PopAttrib( GLcontext* ctx )
{
struct gl_attrib_node *attr, *next;
struct gl_enable_attrib *enable;
GLuint i, oldDrawBuffer;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glPopAttrib" );
return;
}
if (ctx->AttribStackDepth==0) {
gl_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" );
return;
}
ctx->AttribStackDepth--;
attr = ctx->AttribStack[ctx->AttribStackDepth];
while (attr) {
switch (attr->kind) {
case GL_ACCUM_BUFFER_BIT:
MEMCPY( &ctx->Accum, attr->data, sizeof(struct gl_accum_attrib) );
break;
case GL_COLOR_BUFFER_BIT:
oldDrawBuffer = ctx->Color.DrawBuffer;
MEMCPY( &ctx->Color, attr->data,
sizeof(struct gl_colorbuffer_attrib) );
if (ctx->Color.DrawBuffer != oldDrawBuffer) {
gl_DrawBuffer(ctx, ctx->Color.DrawBuffer);
}
break;
case GL_CURRENT_BIT:
MEMCPY( &ctx->Current, attr->data,
sizeof(struct gl_current_attrib) );
break;
case GL_DEPTH_BUFFER_BIT:
MEMCPY( &ctx->Depth, attr->data,
sizeof(struct gl_depthbuffer_attrib) );
break;
case GL_ENABLE_BIT:
enable = (struct gl_enable_attrib *) attr->data;
ctx->Color.AlphaEnabled = enable->AlphaTest;
ctx->Transform.Normalize = enable->AutoNormal;
ctx->Color.BlendEnabled = enable->Blend;
for (i=0;i<MAX_CLIP_PLANES;i++) {
ctx->Transform.ClipEnabled[i] = enable->ClipPlane[i];
}
ctx->Light.ColorMaterialEnabled = enable->ColorMaterial;
ctx->Polygon.CullFlag = enable->CullFace;
ctx->Depth.Test = enable->DepthTest;
ctx->Color.DitherFlag = enable->Dither;
ctx->Fog.Enabled = enable->Fog;
ctx->Light.Enabled = enable->Lighting;
ctx->Line.SmoothFlag = enable->LineSmooth;
ctx->Line.StippleFlag = enable->LineStipple;
ctx->Color.IndexLogicOpEnabled = enable->IndexLogicOp;
ctx->Color.ColorLogicOpEnabled = enable->ColorLogicOp;
ctx->Eval.Map1Color4 = enable->Map1Color4;
ctx->Eval.Map1Index = enable->Map1Index;
ctx->Eval.Map1Normal = enable->Map1Normal;
ctx->Eval.Map1TextureCoord1 = enable->Map1TextureCoord1;
ctx->Eval.Map1TextureCoord2 = enable->Map1TextureCoord2;
ctx->Eval.Map1TextureCoord3 = enable->Map1TextureCoord3;
ctx->Eval.Map1TextureCoord4 = enable->Map1TextureCoord4;
ctx->Eval.Map1Vertex3 = enable->Map1Vertex3;
ctx->Eval.Map1Vertex4 = enable->Map1Vertex4;
ctx->Eval.Map2Color4 = enable->Map2Color4;
ctx->Eval.Map2Index = enable->Map2Index;
ctx->Eval.Map2Normal = enable->Map2Normal;
ctx->Eval.Map2TextureCoord1 = enable->Map2TextureCoord1;
ctx->Eval.Map2TextureCoord2 = enable->Map2TextureCoord2;
ctx->Eval.Map2TextureCoord3 = enable->Map2TextureCoord3;
ctx->Eval.Map2TextureCoord4 = enable->Map2TextureCoord4;
ctx->Eval.Map2Vertex3 = enable->Map2Vertex3;
ctx->Eval.Map2Vertex4 = enable->Map2Vertex4;
ctx->Transform.Normalize = enable->Normalize;
ctx->Point.SmoothFlag = enable->PointSmooth;
ctx->Polygon.OffsetPoint = enable->PolygonOffsetPoint;
ctx->Polygon.OffsetLine = enable->PolygonOffsetLine;
ctx->Polygon.OffsetFill = enable->PolygonOffsetFill;
ctx->Polygon.OffsetAny = ctx->Polygon.OffsetPoint ||
ctx->Polygon.OffsetLine ||
ctx->Polygon.OffsetFill;
ctx->Polygon.SmoothFlag = enable->PolygonSmooth;
ctx->Polygon.StippleFlag = enable->PolygonStipple;
ctx->Scissor.Enabled = enable->Scissor;
ctx->Stencil.Enabled = enable->Stencil;
ctx->Texture.Enabled = enable->Texture;
ctx->Texture.TexGenEnabled = enable->TexGen;
break;
case GL_EVAL_BIT:
MEMCPY( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) );
break;
case GL_FOG_BIT:
MEMCPY( &ctx->Fog, attr->data, sizeof(struct gl_fog_attrib) );
break;
case GL_HINT_BIT:
MEMCPY( &ctx->Hint, attr->data, sizeof(struct gl_hint_attrib) );
break;
case GL_LIGHTING_BIT:
MEMCPY( &ctx->Light, attr->data, sizeof(struct gl_light_attrib) );
break;
case GL_LINE_BIT:
MEMCPY( &ctx->Line, attr->data, sizeof(struct gl_line_attrib) );
break;
case GL_LIST_BIT:
MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) );
break;
case GL_PIXEL_MODE_BIT:
MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) );
break;
case GL_POINT_BIT:
MEMCPY( &ctx->Point, attr->data, sizeof(struct gl_point_attrib) );
break;
case GL_POLYGON_BIT:
MEMCPY( &ctx->Polygon, attr->data,
sizeof(struct gl_polygon_attrib) );
break;
case GL_POLYGON_STIPPLE_BIT:
MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) );
break;
case GL_SCISSOR_BIT:
MEMCPY( &ctx->Scissor, attr->data,
sizeof(struct gl_scissor_attrib) );
break;
case GL_STENCIL_BUFFER_BIT:
MEMCPY( &ctx->Stencil, attr->data,
sizeof(struct gl_stencil_attrib) );
break;
case GL_TRANSFORM_BIT:
MEMCPY( &ctx->Transform, attr->data,
sizeof(struct gl_transform_attrib) );
break;
case GL_TEXTURE_BIT:
MEMCPY( &ctx->Texture, attr->data,
sizeof(struct gl_texture_attrib) );
break;
case GL_VIEWPORT_BIT:
MEMCPY( &ctx->Viewport, attr->data,
sizeof(struct gl_viewport_attrib) );
break;
default:
gl_problem( ctx, "Bad attrib flag in PopAttrib");
break;
}
next = attr->next;
free( (void *) attr->data );
free( (void *) attr );
attr = next;
}
ctx->NewState = NEW_ALL;
}
#define GL_CLIENT_PACK_BIT (1<<20)
#define GL_CLIENT_UNPACK_BIT (1<<21)
void gl_PushClientAttrib( GLcontext *ctx, GLbitfield mask )
{
struct gl_attrib_node *newnode;
struct gl_attrib_node *head;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glPushClientAttrib" );
return;
}
if (ctx->ClientAttribStackDepth>=MAX_CLIENT_ATTRIB_STACK_DEPTH) {
gl_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" );
return;
}
/* Build linked list of attribute nodes which save all attribute */
/* groups specified by the mask. */
head = NULL;
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
struct gl_pixelstore_attrib *attr;
/* packing attribs */
attr = MALLOC_STRUCT( gl_pixelstore_attrib );
MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );
newnode = new_attrib_node( GL_CLIENT_PACK_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
/* unpacking attribs */
attr = MALLOC_STRUCT( gl_pixelstore_attrib );
MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) );
newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
struct gl_array_attrib *attr;
attr = MALLOC_STRUCT( gl_array_attrib );
MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) );
newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
/* etc... */
ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head;
ctx->ClientAttribStackDepth++;
}
void gl_PopClientAttrib( GLcontext *ctx )
{
struct gl_attrib_node *attr, *next;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glPopClientAttrib" );
return;
}
if (ctx->ClientAttribStackDepth==0) {
gl_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" );
return;
}
ctx->ClientAttribStackDepth--;
attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];
while (attr) {
switch (attr->kind) {
case GL_CLIENT_PACK_BIT:
MEMCPY( &ctx->Pack, attr->data,
sizeof(struct gl_pixelstore_attrib) );
break;
case GL_CLIENT_UNPACK_BIT:
MEMCPY( &ctx->Unpack, attr->data,
sizeof(struct gl_pixelstore_attrib) );
break;
case GL_CLIENT_VERTEX_ARRAY_BIT:
MEMCPY( &ctx->Array, attr->data,
sizeof(struct gl_array_attrib) );
break;
default:
gl_problem( ctx, "Bad attrib flag in PopClientAttrib");
break;
}
next = attr->next;
free( (void *) attr->data );
free( (void *) attr );
attr = next;
}
ctx->NewState = NEW_ALL;
}

48
dll/opengl/mesa/attrib.h Normal file
View File

@@ -0,0 +1,48 @@
/* $Id: attrib.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: attrib.h,v $
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef ATTRIB_H
#define ATTRIB_h
#include "types.h"
extern void gl_PushAttrib( GLcontext* ctx, GLbitfield mask );
extern void gl_PopAttrib( GLcontext* ctx );
extern void gl_PushClientAttrib( GLcontext *ctx, GLbitfield mask );
extern void gl_PopClientAttrib( GLcontext *ctx );
#endif

221
dll/opengl/mesa/bitmap.c Normal file
View File

@@ -0,0 +1,221 @@
/* $Id: bitmap.c,v 1.9 1998/02/03 23:45:02 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: bitmap.c,v $
* Revision 1.9 1998/02/03 23:45:02 brianp
* added casts to prevent warnings with Amiga StormC compiler
*
* Revision 1.8 1997/10/02 03:06:42 brianp
* added #include <assert.h>
*
* Revision 1.7 1997/09/27 00:15:39 brianp
* changed parameters to gl_unpack_image()
*
* Revision 1.6 1997/07/24 01:24:45 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.5 1997/06/20 02:18:09 brianp
* replaced Current.IntColor with Current.ByteColor
*
* Revision 1.4 1997/05/28 03:23:48 brianp
* added precompiled header (PCH) support
*
* Revision 1.3 1996/11/06 04:23:18 brianp
* replaced 0 with GL_COLOR_INDEX in gl_unpack_bitmap()
*
* Revision 1.2 1996/09/15 14:18:10 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "bitmap.h"
#include "context.h"
#include "feedback.h"
#include "image.h"
#include "macros.h"
#include "pb.h"
#include "types.h"
#endif
/*
* Unpack a bitmap image
*/
struct gl_image *gl_unpack_bitmap( GLcontext* ctx,
GLsizei width, GLsizei height,
const GLubyte *bitmap )
{
return gl_unpack_image( ctx, width, height,
GL_COLOR_INDEX, GL_BITMAP, bitmap );
}
/*
* Do actual rendering of a bitmap.
*/
void gl_render_bitmap( GLcontext* ctx,
GLsizei width, GLsizei height,
GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove,
const struct gl_image *bitmap )
{
struct pixel_buffer *PB = ctx->PB;
GLint bx, by; /* bitmap position */
GLint px, py, pz; /* pixel position */
GLubyte *ptr;
assert(bitmap);
assert(bitmap->Type == GL_BITMAP);
assert(bitmap->Format == GL_COLOR_INDEX);
if (ctx->NewState) {
gl_update_state(ctx);
PB_INIT( PB, GL_BITMAP );
}
if (ctx->Visual->RGBAflag) {
GLint r, g, b, a;
r = (GLint) (ctx->Current.RasterColor[0] * ctx->Visual->RedScale);
g = (GLint) (ctx->Current.RasterColor[1] * ctx->Visual->GreenScale);
b = (GLint) (ctx->Current.RasterColor[2] * ctx->Visual->BlueScale);
a = (GLint) (ctx->Current.RasterColor[3] * ctx->Visual->AlphaScale);
PB_SET_COLOR( ctx, PB, r, g, b, a );
}
else {
PB_SET_INDEX( ctx, PB, ctx->Current.RasterIndex );
}
px = (GLint) ( (ctx->Current.RasterPos[0] - xorig) + 0.0F );
py = (GLint) ( (ctx->Current.RasterPos[1] - yorig) + 0.0F );
pz = (GLint) ( ctx->Current.RasterPos[2] * DEPTH_SCALE );
ptr = (GLubyte *) bitmap->Data;
for (by=0;by<height;by++) {
GLubyte bitmask;
/* do a row */
bitmask = 128;
for (bx=0;bx<width;bx++) {
if (*ptr&bitmask) {
PB_WRITE_PIXEL( PB, px+bx, py+by, pz );
}
bitmask = bitmask >> 1;
if (bitmask==0) {
ptr++;
bitmask = 128;
}
}
PB_CHECK_FLUSH( ctx, PB )
/* get ready for next row */
if (bitmask!=128) ptr++;
}
gl_flush_pb(ctx);
}
/*
* Execute a glBitmap command:
* 1. check for errors
* 2. feedback/render/select
* 3. advance raster position
*/
void gl_Bitmap( GLcontext* ctx,
GLsizei width, GLsizei height,
GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove,
const struct gl_image *bitmap )
{
if (width<0 || height<0) {
gl_error( ctx, GL_INVALID_VALUE, "glBitmap" );
return;
}
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glBitmap" );
return;
}
if (ctx->Current.RasterPosValid==GL_FALSE) {
/* do nothing */
return;
}
if (ctx->RenderMode==GL_RENDER) {
GLboolean completed = GL_FALSE;
if (ctx->Driver.Bitmap) {
/* let device driver try to render the bitmap */
completed = (*ctx->Driver.Bitmap)( ctx, width, height, xorig, yorig,
xmove, ymove, bitmap );
}
if (!completed) {
/* use generic function */
gl_render_bitmap( ctx, width, height, xorig, yorig,
xmove, ymove, bitmap );
}
}
else if (ctx->RenderMode==GL_FEEDBACK) {
GLfloat color[4], texcoord[4], invq;
color[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale;
color[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale;
color[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale;
color[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale;
invq = 1.0F / ctx->Current.TexCoord[3];
texcoord[0] = ctx->Current.TexCoord[0] * invq;
texcoord[1] = ctx->Current.TexCoord[1] * invq;
texcoord[2] = ctx->Current.TexCoord[2] * invq;
texcoord[3] = ctx->Current.TexCoord[3];
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_BITMAP_TOKEN );
/* TODO: Verify XYZW values are correct: */
gl_feedback_vertex( ctx, ctx->Current.RasterPos[0] - xorig,
ctx->Current.RasterPos[1] - yorig,
ctx->Current.RasterPos[2],
ctx->Current.RasterPos[3],
color, ctx->Current.Index, texcoord );
}
else if (ctx->RenderMode==GL_SELECT) {
/* Bitmaps don't generate selection hits. See appendix B of 1.1 spec. */
}
/* update raster position */
ctx->Current.RasterPos[0] += xmove;
ctx->Current.RasterPos[1] += ymove;
}

59
dll/opengl/mesa/bitmap.h Normal file
View File

@@ -0,0 +1,59 @@
/* $Id: bitmap.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: bitmap.h,v $
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef BITMAP_H
#define BITMAP_H
#include "types.h"
extern struct gl_image *gl_unpack_bitmap( GLcontext* ctx,
GLsizei width, GLsizei height,
const GLubyte *bitmap );
extern void gl_render_bitmap( GLcontext* ctx,
GLsizei width, GLsizei height,
GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove,
const struct gl_image *bitmap );
extern void gl_Bitmap( GLcontext* ctx,
GLsizei width, GLsizei height,
GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove,
const struct gl_image *bitmap );
#endif

547
dll/opengl/mesa/blend.c Normal file
View File

@@ -0,0 +1,547 @@
/* $Id: blend.c,v 1.10 1998/01/27 03:42:40 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.6
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: blend.c,v $
* Revision 1.10 1998/01/27 03:42:40 brianp
* optimized more blending modes (Kai Schuetz)
*
* Revision 1.9 1997/07/24 01:24:45 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.8 1997/05/28 03:23:48 brianp
* added precompiled header (PCH) support
*
* Revision 1.7 1997/04/20 19:51:57 brianp
* replaced abort() with gl_problem()
*
* Revision 1.6 1997/02/15 18:27:56 brianp
* fixed a few error messages
*
* Revision 1.5 1997/01/28 22:17:19 brianp
* moved logic op blending into logic.c
*
* Revision 1.4 1997/01/04 00:13:11 brianp
* was using ! instead of ~ to invert pixel bits (ugh!)
*
* Revision 1.3 1996/09/19 00:53:31 brianp
* added missing returns after some gl_error() calls
*
* Revision 1.2 1996/09/15 14:18:10 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <assert.h>
#include <stdlib.h>
#include "alphabuf.h"
#include "blend.h"
#include "context.h"
#include "dlist.h"
#include "macros.h"
#include "pb.h"
#include "span.h"
#include "types.h"
#endif
void gl_BlendFunc( GLcontext* ctx, GLenum sfactor, GLenum dfactor )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glBlendFunc" );
return;
}
switch (sfactor) {
case GL_ZERO:
case GL_ONE:
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
case GL_SRC_ALPHA_SATURATE:
ctx->Color.BlendSrc = sfactor;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glBlendFunc(sfactor)" );
return;
}
switch (dfactor) {
case GL_ZERO:
case GL_ONE:
case GL_SRC_COLOR:
case GL_ONE_MINUS_SRC_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
ctx->Color.BlendDst = dfactor;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glBlendFunc(dfactor)" );
}
ctx->NewState |= NEW_RASTER_OPS;
}
/*
* Do the real work of gl_blend_span() and gl_blend_pixels().
* Input: n - number of pixels
* mask - the usual write mask
* In/Out: red, green, blue, alpha - the incoming and modified pixels
* Input: rdest, gdest, bdest, adest - the pixels from the dest color buffer
*/
static void do_blend( GLcontext* ctx, GLuint n, const GLubyte mask[],
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[],
const GLubyte rdest[], const GLubyte gdest[],
const GLubyte bdest[], const GLubyte adest[] )
{
GLuint i;
if (ctx->Color.BlendSrc==GL_SRC_ALPHA
&& ctx->Color.BlendDst==GL_ONE_MINUS_SRC_ALPHA) {
/* Alpha blending */
GLfloat ascale = 256.0f * ctx->Visual->InvAlphaScale;
GLint rmax = (GLint) ctx->Visual->RedScale;
GLint gmax = (GLint) ctx->Visual->GreenScale;
GLint bmax = (GLint) ctx->Visual->BlueScale;
GLint amax = (GLint) ctx->Visual->AlphaScale;
for (i=0;i<n;i++) {
if (mask[i]) {
GLint r, g, b, a;
GLint t = (GLint) ( alpha[i] * ascale ); /* t in [0,256] */
GLint s = 256 - t;
r = (red[i] * t + rdest[i] * s) >> 8;
g = (green[i] * t + gdest[i] * s) >> 8;
b = (blue[i] * t + bdest[i] * s) >> 8;
a = (alpha[i] * t + adest[i] * s) >> 8;
/* kai: I think the following clamping is not needed: */
red[i] = MIN2( r, rmax );
green[i] = MIN2( g, gmax );
blue[i] = MIN2( b, bmax );
alpha[i] = MIN2( a, amax );
}
}
}
else {
/* clipped sum */
if (ctx->Color.BlendSrc==GL_ONE
&& ctx->Color.BlendDst==GL_ONE) {
GLint rmax = (GLint) ctx->Visual->RedScale;
GLint gmax = (GLint) ctx->Visual->GreenScale;
GLint bmax = (GLint) ctx->Visual->BlueScale;
GLint amax = (GLint) ctx->Visual->AlphaScale;
for (i=0; i < n; i++) {
if (mask[i]) {
red[i] = MIN2(rmax, red[i] + rdest[i]);
green[i] = MIN2(gmax, green[i] + gdest[i]);
blue[i] = MIN2(bmax, blue[i] + bdest[i]);
alpha[i] = MIN2(amax, alpha[i] + adest[i]);
}
}
}
/* modulation */
else if ((ctx->Color.BlendSrc==GL_ZERO &&
ctx->Color.BlendDst==GL_SRC_COLOR)
||
(ctx->Color.BlendSrc==GL_DST_COLOR &&
ctx->Color.BlendDst==GL_ZERO)) {
if (ctx->Visual->EightBitColor) {
for (i=0; i < n; i++) {
if (mask[i]) {
red[i] = (red[i] * rdest[i]) / 255;
green[i] = (green[i] * gdest[i]) / 255;
blue[i] = (blue[i] * bdest[i]) / 255;
alpha[i] = (alpha[i] * adest[i]) / 255;
}
}
}
else {
GLint rmax = (GLint) ctx->Visual->RedScale;
GLint gmax = (GLint) ctx->Visual->GreenScale;
GLint bmax = (GLint) ctx->Visual->BlueScale;
GLint amax = (GLint) ctx->Visual->AlphaScale;
for (i=0; i < n; i++) {
if (mask[i]) {
red[i] = (red[i] * rdest[i]) / rmax;
green[i] = (green[i] * gdest[i]) / gmax;
blue[i] = (blue[i] * bdest[i]) / bmax;
alpha[i] = (alpha[i] * adest[i]) / amax;
}
}
}
}else{
/* General cases: */
if (ctx->Visual->EightBitColor) {
for (i=0;i<n;i++) {
if (mask[i]) {
GLint Rs, Gs, Bs, As; /* Source colors */
GLint Rd, Gd, Bd, Ad; /* Dest colors */
GLint Rss, Gss, Bss, Ass; /* Source colors scaled */
GLint Rds, Gds, Bds, Ads; /* Dest colors scaled */
/* Source Color */
Rs = red[i];
Gs = green[i];
Bs = blue[i];
As = alpha[i];
/* Frame buffer color */
Rd = rdest[i];
Gd = gdest[i];
Bd = bdest[i];
Ad = adest[i];
/* Source scaling */
switch (ctx->Color.BlendSrc) {
case GL_ZERO:
Rss = Gss = Bss = Ass = 0;
break;
case GL_ONE:
Rss = Rs * 255;
Gss = Gs * 255;
Bss = Bs * 255;
Ass = As * 255;
break;
case GL_DST_COLOR:
Rss = Rs * Rd;
Gss = Gs * Gd;
Bss = Bs * Bd;
Ass = As * Ad;
break;
case GL_ONE_MINUS_DST_COLOR:
Rss = Rs * (255 - Rd);
Gss = Gs * (255 - Gd);
Bss = Bs * (255 - Bd);
Ass = As * (255 - Ad);
break;
case GL_SRC_ALPHA:
Rss = Rs * As;
Gss = Gs * As;
Bss = Bs * As;
Ass = As * As;
break;
case GL_ONE_MINUS_SRC_ALPHA:
Rss = Rs * (255 - As);
Gss = Gs * (255 - As);
Bss = Bs * (255 - As);
Ass = As * (255 - As);
break;
case GL_DST_ALPHA:
Rss = Rs * Ad;
Gss = Gs * Ad;
Bss = Bs * Ad;
Ass = As * Ad;
break;
case GL_ONE_MINUS_DST_ALPHA:
Rss = Rs * (255 - Ad);
Gss = Gs * (255 - Ad);
Bss = Bs * (255 - Ad);
Ass = As * (255 - Ad);
break;
case GL_SRC_ALPHA_SATURATE:
{
GLint sA = MIN2(As, 255 - Ad);
Rss = Rs * sA;
Gss = Gs * sA;
Bss = Bs * sA;
Ass = As * 255;
break;
}
default:
/* this should never happen */
gl_problem(ctx, "Bad blend source factor in do_blend");
}
/* Dest scaling */
switch (ctx->Color.BlendDst) {
case GL_ZERO:
Rds = Gds = Bds = Ads = 0;
break;
case GL_ONE:
Rds = Rd * 255;
Gds = Gd * 255;
Bds = Bd * 255;
Ads = Ad * 255;
break;
case GL_SRC_COLOR:
Rds = Rd * Rs;
Gds = Gd * Gs;
Bds = Bd * Bs;
Ads = Ad * As;
break;
case GL_ONE_MINUS_SRC_COLOR:
Rds = Rs * (255 - Rs);
Gds = Gs * (255 - Gs);
Bds = Bs * (255 - Bs);
Ads = As * (255 - As);
break;
case GL_SRC_ALPHA:
Rds = Rd * As;
Gds = Gd * As;
Bds = Bd * As;
Ads = Ad * As;
break;
case GL_ONE_MINUS_SRC_ALPHA:
Rds = Rd * (255 - As);
Gds = Gd * (255 - As);
Bds = Bd * (255 - As);
Ads = Ad * (255 - As);
break;
case GL_DST_ALPHA:
Rds = Rd * Ad;
Gds = Gd * Ad;
Bds = Bd * Ad;
Ads = Ad * Ad;
break;
case GL_ONE_MINUS_DST_ALPHA:
Rds = Rd * (255 - Ad);
Gds = Gd * (255 - Ad);
Bds = Bd * (255 - Ad);
Ads = Ad * (255 - Ad);
break;
default:
/* this should never happen */
gl_problem(ctx, "Bad blend dest factor in do_blend");
}
/* compute blended color */
red[i] = MIN2((Rss + Rds) / 255, 255);
green[i] = MIN2((Gss + Gds) / 255, 255);
blue[i] = MIN2((Bss + Bds) / 255, 255);
alpha[i] = MIN2((Ass + Ads) / 255, 255);
}
}
}else{ /* !EightBitColor */
GLfloat rmax = ctx->Visual->RedScale;
GLfloat gmax = ctx->Visual->GreenScale;
GLfloat bmax = ctx->Visual->BlueScale;
GLfloat amax = ctx->Visual->AlphaScale;
GLfloat rscale = 1.0f / rmax;
GLfloat gscale = 1.0f / gmax;
GLfloat bscale = 1.0f / bmax;
GLfloat ascale = 1.0f / amax;
for (i=0;i<n;i++) {
if (mask[i]) {
GLint Rs, Gs, Bs, As; /* Source colors */
GLint Rd, Gd, Bd, Ad; /* Dest colors */
GLfloat sR, sG, sB, sA; /* Source scaling */
GLfloat dR, dG, dB, dA; /* Dest scaling */
GLfloat r, g, b, a;
/* Source Color */
Rs = red[i];
Gs = green[i];
Bs = blue[i];
As = alpha[i];
/* Frame buffer color */
Rd = rdest[i];
Gd = gdest[i];
Bd = bdest[i];
Ad = adest[i];
/* Source scaling */
switch (ctx->Color.BlendSrc) {
case GL_ZERO:
sR = sG = sB = sA = 0.0F;
break;
case GL_ONE:
sR = sG = sB = sA = 1.0F;
break;
case GL_DST_COLOR:
sR = (GLfloat) Rd * rscale;
sG = (GLfloat) Gd * gscale;
sB = (GLfloat) Bd * bscale;
sA = (GLfloat) Ad * ascale;
break;
case GL_ONE_MINUS_DST_COLOR:
sR = 1.0F - (GLfloat) Rd * rscale;
sG = 1.0F - (GLfloat) Gd * gscale;
sB = 1.0F - (GLfloat) Bd * bscale;
sA = 1.0F - (GLfloat) Ad * ascale;
break;
case GL_SRC_ALPHA:
sR = sG = sB = sA = (GLfloat) As * ascale;
break;
case GL_ONE_MINUS_SRC_ALPHA:
sR = sG = sB = sA = (GLfloat) 1.0F - (GLfloat) As * ascale;
break;
case GL_DST_ALPHA:
sR = sG = sB = sA =(GLfloat) Ad * ascale;
break;
case GL_ONE_MINUS_DST_ALPHA:
sR = sG = sB = sA = 1.0F - (GLfloat) Ad * ascale;
break;
case GL_SRC_ALPHA_SATURATE:
if (As < 1.0F - (GLfloat) Ad * ascale) {
sR = sG = sB = (GLfloat) As * ascale;
}
else {
sR = sG = sB = 1.0F - (GLfloat) Ad * ascale;
}
sA = 1.0;
break;
default:
/* this should never happen */
gl_problem(ctx, "Bad blend source factor in do_blend");
}
/* Dest scaling */
switch (ctx->Color.BlendDst) {
case GL_ZERO:
dR = dG = dB = dA = 0.0F;
break;
case GL_ONE:
dR = dG = dB = dA = 1.0F;
break;
case GL_SRC_COLOR:
dR = (GLfloat) Rs * rscale;
dG = (GLfloat) Gs * gscale;
dB = (GLfloat) Bs * bscale;
dA = (GLfloat) As * ascale;
break;
case GL_ONE_MINUS_SRC_COLOR:
dR = 1.0F - (GLfloat) Rs * rscale;
dG = 1.0F - (GLfloat) Gs * gscale;
dB = 1.0F - (GLfloat) Bs * bscale;
dA = 1.0F - (GLfloat) As * ascale;
break;
case GL_SRC_ALPHA:
dR = dG = dB = dA = (GLfloat) As * ascale;
break;
case GL_ONE_MINUS_SRC_ALPHA:
dR = dG = dB = dA = (GLfloat) 1.0F - (GLfloat) As * ascale;
break;
case GL_DST_ALPHA:
dR = dG = dB = dA = (GLfloat) Ad * ascale;
break;
case GL_ONE_MINUS_DST_ALPHA:
dR = dG = dB = dA = 1.0F - (GLfloat) Ad * ascale;
break;
default:
/* this should never happen */
gl_problem(ctx, "Bad blend dest factor in do_blend");
}
#ifdef DEBUG
assert( sR>= 0.0 && sR<=1.0 );
assert( sG>= 0.0 && sG<=1.0 );
assert( sB>= 0.0 && sB<=1.0 );
assert( sA>= 0.0 && sA<=1.0 );
assert( dR>= 0.0 && dR<=1.0 );
assert( dG>= 0.0 && dG<=1.0 );
assert( dB>= 0.0 && dB<=1.0 );
assert( dA>= 0.0 && dA<=1.0 );
#endif
/* compute blended color */
r = Rs * sR + Rd * dR;
g = Gs * sG + Gd * dG;
b = Bs * sB + Bd * dB;
a = As * sA + Ad * dA;
red[i] = (GLint) CLAMP( r, 0.0F, rmax );
green[i] = (GLint) CLAMP( g, 0.0F, gmax );
blue[i] = (GLint) CLAMP( b, 0.0F, bmax );
alpha[i] = (GLint) CLAMP( a, 0.0F, amax );
}
}
}
}
}
}
/*
* Apply the blending operator to a span of pixels.
* Input: n - number of pixels in span
* x, y - location of leftmost pixel in span in window coords.
* mask - boolean mask indicating which pixels to blend.
* In/Out: red, green, blue, alpha - pixel values
*/
void gl_blend_span( GLcontext* ctx, GLuint n, GLint x, GLint y,
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[],
GLubyte mask[] )
{
GLubyte rdest[MAX_WIDTH], gdest[MAX_WIDTH];
GLubyte bdest[MAX_WIDTH], adest[MAX_WIDTH];
/* Read span of current frame buffer pixels */
gl_read_color_span( ctx, n, x, y, rdest, gdest, bdest, adest );
do_blend( ctx, n, mask, red, green, blue, alpha, rdest, gdest, bdest, adest );
}
/*
* Apply the blending operator to an array of pixels.
* Input: n - number of pixels in span
* x, y - array of pixel locations
* mask - boolean mask indicating which pixels to blend.
* In/Out: red, green, blue, alpha - array of pixel values
*/
void gl_blend_pixels( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[],
GLubyte mask[] )
{
GLubyte rdest[PB_SIZE], gdest[PB_SIZE], bdest[PB_SIZE], adest[PB_SIZE];
/* Read pixels from current color buffer */
(*ctx->Driver.ReadColorPixels)( ctx, n, x, y, rdest, gdest, bdest, adest, mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
gl_read_alpha_pixels( ctx, n, x, y, adest, mask );
}
do_blend( ctx, n, mask, red, green, blue, alpha, rdest, gdest, bdest, adest );
}

54
dll/opengl/mesa/blend.h Normal file
View File

@@ -0,0 +1,54 @@
/* $Id: blend.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: blend.h,v $
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef BLEND_H
#define BLEND_H
#include "types.h"
extern void gl_blend_span( GLcontext* ctx, GLuint n, GLint x, GLint y,
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[],
GLubyte mask[] );
extern void gl_blend_pixels( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[],
GLubyte mask[] );
extern void gl_BlendFunc( GLcontext* ctx, GLenum sfactor, GLenum dfactor );
#endif

1055
dll/opengl/mesa/clip.c Normal file

File diff suppressed because it is too large Load Diff

98
dll/opengl/mesa/clip.h Normal file
View File

@@ -0,0 +1,98 @@
/* $Id: clip.h,v 1.3 1998/02/03 23:45:36 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.6
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: clip.h,v $
* Revision 1.3 1998/02/03 23:45:36 brianp
* added space parameter to clip interpolation functions
*
* Revision 1.2 1998/01/06 02:40:52 brianp
* added DavidB's clipping interpolation optimization
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef CLIP_H
#define CLIP_H
#include "types.h"
#ifdef DEBUG
# define GL_VIEWCLIP_POINT( V ) gl_viewclip_point( V )
#else
# define GL_VIEWCLIP_POINT( V ) \
( (V)[0] <= (V)[3] && (V)[0] >= -(V)[3] \
&& (V)[1] <= (V)[3] && (V)[1] >= -(V)[3] \
&& (V)[2] <= (V)[3] && (V)[2] >= -(V)[3] )
#endif
extern GLuint gl_viewclip_point( const GLfloat v[] );
extern GLuint gl_viewclip_line( GLcontext* ctx, GLuint *i, GLuint *j );
extern GLuint gl_viewclip_polygon( GLcontext* ctx, GLuint n, GLuint vlist[] );
extern GLuint gl_userclip_point( GLcontext* ctx, const GLfloat v[] );
extern GLuint gl_userclip_line( GLcontext* ctx, GLuint *i, GLuint *j );
extern GLuint gl_userclip_polygon( GLcontext* ctx, GLuint n, GLuint vlist[] );
extern void gl_ClipPlane( GLcontext* ctx,
GLenum plane, const GLfloat *equation );
extern void gl_GetClipPlane( GLcontext* ctx,
GLenum plane, GLdouble *equation );
/*
* Clipping interpolation functions
*/
extern void interpolate_aux( GLcontext *ctx, GLuint space,
GLuint dst, GLfloat t, GLuint in, GLuint out );
extern void interpolate_aux_color_tex2( GLcontext *ctx, GLuint space,
GLuint dst, GLfloat t, GLuint in, GLuint out );
extern void interpolate_aux_tex2( GLcontext *ctx, GLuint space,
GLuint dst, GLfloat t, GLuint in, GLuint out );
extern void interpolate_aux_color( GLcontext *ctx, GLuint space,
GLuint dst, GLfloat t, GLuint in, GLuint out );
#endif

287
dll/opengl/mesa/colortab.c Normal file
View File

@@ -0,0 +1,287 @@
/* $Id: colortab.c,v 1.6 1997/10/16 02:26:18 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: colortab.c,v $
* Revision 1.6 1997/10/16 02:26:18 brianp
* call Driver.UpdateTexturePalette(ctx,NULL) when shared palette changed
*
* Revision 1.5 1997/10/16 01:59:08 brianp
* added GL_EXT_shared_texture_palette extension
*
* Revision 1.4 1997/10/15 23:37:05 brianp
* removed dirty flag stuff
*
* Revision 1.3 1997/10/13 23:50:03 brianp
* added call to Driver.UpdateTexturePalette
*
* Revision 1.2 1997/09/29 23:27:44 brianp
* updated for new device driver texture functions
*
* Revision 1.1 1997/09/27 00:12:46 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include "colortab.h"
#include "context.h"
#include "macros.h"
#endif
/*
* Return GL_TRUE if k is a power of two, else return GL_FALSE.
*/
static GLboolean power_of_two( GLint k )
{
GLint i, m = 1;
for (i=0; i<32; i++) {
if (k == m)
return GL_TRUE;
m = m << 1;
}
return GL_FALSE;
}
static GLint decode_internal_format( GLint format )
{
switch (format) {
case GL_ALPHA:
case GL_ALPHA4:
case GL_ALPHA8:
case GL_ALPHA12:
case GL_ALPHA16:
return GL_ALPHA;
case 1:
case GL_LUMINANCE:
case GL_LUMINANCE4:
case GL_LUMINANCE8:
case GL_LUMINANCE12:
case GL_LUMINANCE16:
return GL_LUMINANCE;
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE4_ALPHA4:
case GL_LUMINANCE6_ALPHA2:
case GL_LUMINANCE8_ALPHA8:
case GL_LUMINANCE12_ALPHA4:
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
return GL_LUMINANCE_ALPHA;
case GL_INTENSITY:
case GL_INTENSITY4:
case GL_INTENSITY8:
case GL_INTENSITY12:
case GL_INTENSITY16:
return GL_INTENSITY;
case 3:
case GL_RGB:
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
return GL_RGB;
case 4:
case GL_RGBA:
case GL_RGBA2:
case GL_RGBA4:
case GL_RGB5_A1:
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
return GL_RGBA;
default:
return -1; /* error */
}
}
void gl_ColorTable( GLcontext *ctx, GLenum target,
GLenum internalFormat, struct gl_image *table )
{
struct gl_texture_object *texObj;
GLboolean proxy = GL_FALSE;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glGetBooleanv" );
return;
}
switch (target) {
case GL_TEXTURE_1D:
texObj = ctx->Texture.Current1D;
break;
case GL_TEXTURE_2D:
texObj = ctx->Texture.Current2D;
break;
case GL_PROXY_TEXTURE_1D:
texObj = ctx->Texture.Proxy1D;
proxy = GL_TRUE;
break;
case GL_PROXY_TEXTURE_2D:
texObj = ctx->Texture.Proxy2D;
proxy = GL_TRUE;
break;
default:
gl_error(ctx, GL_INVALID_ENUM, "glColorTableEXT(target)");
return;
}
/* internalformat = just like glTexImage */
if (table->Width < 1 || table->Width > MAX_TEXTURE_PALETTE_SIZE
|| !power_of_two(table->Width)) {
gl_error(ctx, GL_INVALID_VALUE, "glColorTableEXT(width)");
if (proxy) {
texObj->PaletteSize = 0;
texObj->PaletteIntFormat = 0;
texObj->PaletteFormat = 0;
}
return;
}
/* per-texture object palette */
texObj->PaletteSize = table->Width;
texObj->PaletteIntFormat = internalFormat;
texObj->PaletteFormat = decode_internal_format(internalFormat);
if (!proxy) {
MEMCPY(texObj->Palette, table->Data, table->Width*table->Components);
if (ctx->Driver.UpdateTexturePalette) {
(*ctx->Driver.UpdateTexturePalette)( ctx, texObj );
}
}
}
void gl_ColorSubTable( GLcontext *ctx, GLenum target,
GLsizei start, struct gl_image *data )
{
/* XXX TODO */
gl_problem(ctx, "glColorSubTableEXT not implemented");
}
void gl_GetColorTable( GLcontext *ctx, GLenum target, GLenum format,
GLenum type, GLvoid *table )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glGetBooleanv" );
return;
}
switch (target) {
case GL_TEXTURE_1D:
break;
case GL_TEXTURE_2D:
break;
case GL_TEXTURE_3D_EXT:
break;
default:
gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableEXT(target)");
return;
}
gl_problem(ctx, "glGetColorTableEXT not implemented!");
}
void gl_GetColorTableParameterfv( GLcontext *ctx, GLenum target,
GLenum pname, GLfloat *params )
{
GLint iparams[10];
gl_GetColorTableParameteriv( ctx, target, pname, iparams );
*params = (GLfloat) iparams[0];
}
void gl_GetColorTableParameteriv( GLcontext *ctx, GLenum target,
GLenum pname, GLint *params )
{
struct gl_texture_object *texObj;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glGetColorTableParameter" );
return;
}
switch (target) {
case GL_TEXTURE_1D:
texObj = ctx->Texture.Current1D;
break;
case GL_TEXTURE_2D:
texObj = ctx->Texture.Current2D;
break;
default:
gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
return;
}
switch (pname) {
case GL_COLOR_TABLE_FORMAT_EXT:
if (texObj)
*params = texObj->PaletteIntFormat;
break;
case GL_COLOR_TABLE_WIDTH_EXT:
if (texObj)
*params = texObj->PaletteSize;
break;
case GL_COLOR_TABLE_RED_SIZE_EXT:
*params = 8;
break;
case GL_COLOR_TABLE_GREEN_SIZE_EXT:
*params = 8;
break;
case GL_COLOR_TABLE_BLUE_SIZE_EXT:
*params = 8;
break;
case GL_COLOR_TABLE_ALPHA_SIZE_EXT:
*params = 8;
break;
case GL_COLOR_TABLE_LUMINANCE_SIZE_EXT:
*params = 8;
break;
case GL_COLOR_TABLE_INTENSITY_SIZE_EXT:
*params = 8;
break;
default:
gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter" );
return;
}
}

View File

@@ -0,0 +1,65 @@
/* $Id: colortab.h,v 1.1 1997/09/27 00:12:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: colortab.h,v $
* Revision 1.1 1997/09/27 00:12:46 brianp
* Initial revision
*
*/
#ifndef COLORTAB_H
#define COLORTAB_H
#include "types.h"
#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8
#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9
#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA
#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB
#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC
#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD
#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE
#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF
extern void gl_ColorTable( GLcontext *ctx, GLenum target,
GLenum internalformat,
struct gl_image *table );
extern void gl_ColorSubTable( GLcontext *ctx, GLenum target,
GLsizei start, struct gl_image *data );
extern void gl_GetColorTable( GLcontext *ctx, GLenum target, GLenum format,
GLenum type, GLvoid *table );
extern void gl_GetColorTableParameterfv( GLcontext *ctx, GLenum target,
GLenum pname, GLfloat *params );
extern void gl_GetColorTableParameteriv( GLcontext *ctx, GLenum target,
GLenum pname, GLint *params );
#endif

167
dll/opengl/mesa/config.h Normal file
View File

@@ -0,0 +1,167 @@
/* $Id: config.h,v 1.8 1997/09/27 00:13:44 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: config.h,v $
* Revision 1.8 1997/09/27 00:13:44 brianp
* added GL_EXT_paletted_texture extension
*
* Revision 1.7 1997/09/23 00:57:21 brianp
* removed MAX_DISPLAYLISTS
*
* Revision 1.6 1997/06/17 02:20:25 brianp
* changed MAX_WIDTH to 1600 and MAX_HEIGHT to 1200
*
* Revision 1.5 1997/05/28 03:27:19 brianp
* set MAX_TEXTURE_LEVELS to 9 if compiling for 3Dfx driver (FX)
*
* Revision 1.4 1997/01/08 20:54:02 brianp
* added DITHER666 option from Michael Pichler
*
* Revision 1.3 1996/10/01 03:30:18 brianp
* changed MAX_DEPTH to 0x00ffffff for 32-bit depth buffer
*
* Revision 1.2 1996/09/15 01:49:26 brianp
* removed some junk
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
/*
* Tunable configuration parameters.
*/
#ifndef CONFIG_H
#define CONFIG_H
/* Maximum modelview matrix stack depth: */
#define MAX_MODELVIEW_STACK_DEPTH 32
/* Maximum projection matrix stack depth: */
#define MAX_PROJECTION_STACK_DEPTH 32
/* Maximum texture matrix stack depth: */
#define MAX_TEXTURE_STACK_DEPTH 10
/* Maximum attribute stack depth: */
#define MAX_ATTRIB_STACK_DEPTH 16
/* Maximum client attribute stack depth: */
#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16
/* Maximum recursion depth of display list calls: */
#define MAX_LIST_NESTING 64
/* Maximum number of lights: */
#define MAX_LIGHTS 8
/* Maximum user-defined clipping planes: */
#define MAX_CLIP_PLANES 6
/* Number of texture levels */
#define MAX_TEXTURE_LEVELS 11
/* Max texture size */
#define MAX_TEXTURE_SIZE (1 << (MAX_TEXTURE_LEVELS-1))
/* Maximum pixel map lookup table size: */
#define MAX_PIXEL_MAP_TABLE 256
/* Number of auxillary color buffers: */
#define NUM_AUX_BUFFERS 0
/* Maximum order (degree) of curves: */
#ifdef AMIGA
# define MAX_EVAL_ORDER 12
#else
# define MAX_EVAL_ORDER 30
#endif
/* Maximum Name stack depth */
#define MAX_NAME_STACK_DEPTH 64
/* Min and Max point sizes and granularity */
#define MIN_POINT_SIZE 1.0
#define MAX_POINT_SIZE 10.0
#define POINT_SIZE_GRANULARITY 0.1
/* Min and Max line widths and granularity */
#define MIN_LINE_WIDTH 1.0
#define MAX_LINE_WIDTH 10.0
#define LINE_WIDTH_GRANULARITY 1.0
/* Max texture palette size */
#define MAX_TEXTURE_PALETTE_SIZE 256
/* Maximum viewport size: */
#ifdef AMIGA
# define MAX_WIDTH 640
# define MAX_HEIGHT 400
#else
# define MAX_WIDTH 1600
# define MAX_HEIGHT 1200
#endif
/*
* Bits per accumulation buffer color component: 8 or 16
*/
#define ACCUM_BITS 16
/*
* Bits per depth buffer value: 16 or 32
*/
#define MAX_DEPTH 0x00ffffff
#define DEPTH_SCALE ((GLfloat) 0x00ffffff)
/*
* Bits per stencil value: 8
*/
#define STENCIL_BITS 8
/***
*** For X11 driver only:
***/
/*
* When defined, use 6x6x6 dithering instead of 5x9x5.
* 5x9x5 better for general colors, 6x6x6 better for grayscale.
*/
/*#define DITHER666*/
#endif

1926
dll/opengl/mesa/context.c Normal file

File diff suppressed because it is too large Load Diff

179
dll/opengl/mesa/context.h Normal file
View File

@@ -0,0 +1,179 @@
/* $Id: context.h,v 1.9 1997/09/29 22:25:28 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: context.h,v $
* Revision 1.9 1997/09/29 22:25:28 brianp
* added const to a few function parameters
*
* Revision 1.8 1997/05/26 21:14:13 brianp
* gl_create_visual() now takes red/green/blue/alpha_bits arguments
*
* Revision 1.7 1997/04/16 23:55:06 brianp
* added gl_set_api_table()
*
* Revision 1.6 1997/04/12 17:12:43 brianp
* added gl_get_current_context()
*
* Revision 1.5 1997/02/27 19:57:38 brianp
* added gl_problem() function
*
* Revision 1.4 1997/02/10 19:49:50 brianp
* added gl_ResizeBuffersMESA()
*
* Revision 1.3 1996/09/19 03:14:49 brianp
* now just one parameter for gl_create_framebuffer()
*
* Revision 1.2 1996/09/15 14:20:22 brianp
* added new functions for GLframebuffer and GLvisual support
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef CONTEXT_H
#define CONTEXT_H
#include "types.h"
#ifdef THREADS
/*
* A seperate GLcontext for each thread
*/
extern GLcontext *gl_get_thread_context( void );
#else
/*
* All threads use same pointer to current context.
*/
extern GLcontext *CC;
#endif
/*
* There are three Mesa datatypes which are meant to be used by device
* drivers:
* GLcontext: this contains the Mesa rendering state
* GLvisual: this describes the color buffer (rgb vs. ci), whether
* or not there's a depth buffer, stencil buffer, etc.
* GLframebuffer: contains pointers to the depth buffer, stencil
* buffer, accum buffer and alpha buffers.
*
* These types should be encapsulated by corresponding device driver
* datatypes. See xmesa.h and xmesaP.h for an example.
*
* The following functions create and destroy these datatypes.
*/
/*
* Create/destroy a GLvisual. A GLvisual is like a GLX visual. It describes
* the colorbuffer, depth buffer, stencil buffer and accum buffer which will
* be used by the GL context and framebuffer.
*/
extern GLvisual *gl_create_visual( GLboolean rgb_flag,
GLboolean alpha_flag,
GLboolean db_flag,
GLint depth_bits,
GLint stencil_bits,
GLint accum_bits,
GLint index_bits,
GLfloat red_scale,
GLfloat green_scale,
GLfloat blue_scale,
GLfloat alpha_scale,
GLint red_bits,
GLint green_bits,
GLint blue_bits,
GLint alpha_bits );
extern void gl_destroy_visual( GLvisual *vis );
/*
* Create/destroy a GLcontext. A GLcontext is like a GLX context. It
* contains the rendering state.
*/
extern GLcontext *gl_create_context( GLvisual *visual,
GLcontext *share_list,
void *driver_ctx );
extern void gl_destroy_context( GLcontext *ctx );
/*
* Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable.
* It bundles up the depth buffer, stencil buffer and accum buffers into a
* single entity.
*/
extern GLframebuffer *gl_create_framebuffer( GLvisual *visual );
extern void gl_destroy_framebuffer( GLframebuffer *buffer );
extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer );
extern GLcontext *gl_get_current_context(void);
extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
extern void gl_set_api_table( GLcontext *ctx, const struct gl_api_table *api );
/*
* GL_MESA_resize_buffers extension
*/
extern void gl_ResizeBuffersMESA( GLcontext *ctx );
/*
* Miscellaneous
*/
extern void gl_problem( const GLcontext *ctx, const char *s );
extern void gl_warning( const GLcontext *ctx, const char *s );
extern void gl_error( GLcontext *ctx, GLenum error, const char *s );
extern GLenum gl_GetError( GLcontext *ctx );
extern void gl_update_state( GLcontext *ctx );
#ifdef PROFILE
extern GLdouble gl_time( void );
#endif
#endif

517
dll/opengl/mesa/copypix.c Normal file
View File

@@ -0,0 +1,517 @@
/* $Id: copypix.c,v 1.7 1998/02/03 23:45:02 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: copypix.c,v $
* Revision 1.7 1998/02/03 23:45:02 brianp
* added casts to prevent warnings with Amiga StormC compiler
*
* Revision 1.6 1997/07/24 01:24:45 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.5 1997/06/20 02:20:04 brianp
* replaced Current.IntColor with Current.ByteColor
*
* Revision 1.4 1997/05/28 03:23:48 brianp
* added precompiled header (PCH) support
*
* Revision 1.3 1996/09/15 14:18:10 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.2 1996/09/15 01:48:58 brianp
* removed #define NULL 0
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <string.h>
#include "context.h"
#include "copypix.h"
#include "depth.h"
#include "feedback.h"
#include "dlist.h"
#include "macros.h"
#include "pixel.h"
#include "span.h"
#include "stencil.h"
#include "types.h"
#endif
static void copy_rgb_pixels( GLcontext* ctx,
GLint srcx, GLint srcy, GLint width, GLint height,
GLint destx, GLint desty )
{
DEFARRAY( GLdepth, zspan, MAX_WIDTH );
DEFARRAY( GLubyte, red, MAX_WIDTH );
DEFARRAY( GLubyte, green, MAX_WIDTH );
DEFARRAY( GLubyte, blue, MAX_WIDTH );
DEFARRAY( GLubyte, alpha, MAX_WIDTH );
GLboolean scale_or_bias, quick_draw, zoom;
GLint sy, dy, stepy;
GLint i, j;
GLboolean setbuffer;
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
zoom = GL_FALSE;
}
else {
zoom = GL_TRUE;
}
/* Determine if copy should be done bottom-to-top or top-to-bottom */
if (srcy<desty) {
/* top-down max-to-min */
sy = srcy + height - 1;
dy = desty + height - 1;
stepy = -1;
}
else {
/* bottom-up min-to-max */
sy = srcy;
dy = desty;
stepy = 1;
}
scale_or_bias = ctx->Pixel.RedScale!=1.0 || ctx->Pixel.RedBias!=0.0
|| ctx->Pixel.GreenScale!=1.0 || ctx->Pixel.GreenBias!=0.0
|| ctx->Pixel.BlueScale!=1.0 || ctx->Pixel.BlueBias!=0.0
|| ctx->Pixel.AlphaScale!=1.0 || ctx->Pixel.AlphaBias!=0.0;
if (ctx->Depth.Test) {
/* fill in array of z values */
GLint z = (GLint) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
for (i=0;i<width;i++) {
zspan[i] = z;
}
}
if (ctx->RasterMask==0 && !zoom
&& destx>=0 && destx+width<=ctx->Buffer->Width) {
quick_draw = GL_TRUE;
}
else {
quick_draw = GL_FALSE;
}
/* If read and draw buffer are different we must do buffer switching */
setbuffer = ctx->Pixel.ReadBuffer!=ctx->Color.DrawBuffer;
for (j=0; j<height; j++, sy+=stepy, dy+=stepy) {
/* read */
if (setbuffer) {
(*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer );
}
gl_read_color_span( ctx, width, srcx, sy, red, green, blue, alpha );
if (scale_or_bias) {
GLfloat rbias = ctx->Pixel.RedBias * ctx->Visual->RedScale;
GLfloat gbias = ctx->Pixel.GreenBias * ctx->Visual->GreenScale;
GLfloat bbias = ctx->Pixel.BlueBias * ctx->Visual->BlueScale;
GLfloat abias = ctx->Pixel.AlphaBias * ctx->Visual->AlphaScale;
GLint rmax = (GLint) ctx->Visual->RedScale;
GLint gmax = (GLint) ctx->Visual->GreenScale;
GLint bmax = (GLint) ctx->Visual->BlueScale;
GLint amax = (GLint) ctx->Visual->AlphaScale;
for (i=0;i<width;i++) {
GLint r = red[i] * ctx->Pixel.RedScale + rbias;
GLint g = green[i] * ctx->Pixel.GreenScale + gbias;
GLint b = blue[i] * ctx->Pixel.BlueScale + bbias;
GLint a = alpha[i] * ctx->Pixel.AlphaScale + abias;
red[i] = CLAMP( r, 0, rmax );
green[i] = CLAMP( g, 0, gmax );
blue[i] = CLAMP( b, 0, bmax );
alpha[i] = CLAMP( a, 0, amax );
}
}
if (ctx->Pixel.MapColorFlag) {
GLfloat r = (ctx->Pixel.MapRtoRsize-1) * ctx->Visual->InvRedScale;
GLfloat g = (ctx->Pixel.MapGtoGsize-1) * ctx->Visual->InvGreenScale;
GLfloat b = (ctx->Pixel.MapBtoBsize-1) * ctx->Visual->InvBlueScale;
GLfloat a = (ctx->Pixel.MapAtoAsize-1) * ctx->Visual->InvAlphaScale;
for (i=0;i<width;i++) {
GLint ir = red[i] * r;
GLint ig = green[i] * g;
GLint ib = blue[i] * b;
GLint ia = alpha[i] * a;
red[i] = (GLint) (ctx->Pixel.MapRtoR[ir]*ctx->Visual->RedScale);
green[i] = (GLint) (ctx->Pixel.MapGtoG[ig]*ctx->Visual->GreenScale);
blue[i] = (GLint) (ctx->Pixel.MapBtoB[ib]*ctx->Visual->BlueScale);
alpha[i] = (GLint) (ctx->Pixel.MapAtoA[ia]*ctx->Visual->AlphaScale);
}
}
/* write */
if (setbuffer) {
(*ctx->Driver.SetBuffer)( ctx, ctx->Color.DrawBuffer );
}
if (quick_draw && dy>=0 && dy<ctx->Buffer->Height) {
(*ctx->Driver.WriteColorSpan)( ctx, width, destx, dy,
red, green, blue, alpha, NULL);
}
else if (zoom) {
gl_write_zoomed_color_span( ctx, width, destx, dy, zspan,
red, green, blue, alpha, desty );
}
else {
gl_write_color_span( ctx, width, destx, dy, zspan,
red, green, blue, alpha, GL_BITMAP );
}
}
UNDEFARRAY( zspan );
UNDEFARRAY( red );
UNDEFARRAY( green );
UNDEFARRAY( blue );
UNDEFARRAY( alpha );
}
static void copy_ci_pixels( GLcontext* ctx,
GLint srcx, GLint srcy, GLint width, GLint height,
GLint destx, GLint desty )
{
GLdepth zspan[MAX_WIDTH];
GLuint indx[MAX_WIDTH];
GLint sy, dy, stepy;
GLint i, j;
GLboolean setbuffer, zoom;
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
zoom = GL_FALSE;
}
else {
zoom = GL_TRUE;
}
/* Determine if copy should be bottom-to-top or top-to-bottom */
if (srcy<desty) {
/* top-down max-to-min */
sy = srcy + height - 1;
dy = desty + height - 1;
stepy = -1;
}
else {
/* bottom-up min-to-max */
sy = srcy;
dy = desty;
stepy = 1;
}
if (ctx->Depth.Test) {
/* fill in array of z values */
GLint z = (GLint) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
for (i=0;i<width;i++) {
zspan[i] = z;
}
}
/* If read and draw buffer are different we must do buffer switching */
setbuffer = ctx->Pixel.ReadBuffer!=ctx->Color.DrawBuffer;
for (j=0; j<height; j++, sy+=stepy, dy+=stepy) {
/* read */
if (setbuffer) {
(*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer );
}
gl_read_index_span( ctx, width, srcx, sy, indx );
/* shift, offset */
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
if (ctx->Pixel.IndexShift<0) {
for (i=0;i<width;i++) {
indx[i] = (indx[i] >> -ctx->Pixel.IndexShift)
+ ctx->Pixel.IndexOffset;
}
}
else {
for (i=0;i<width;i++) {
indx[i] = (indx[i] << ctx->Pixel.IndexShift)
+ ctx->Pixel.IndexOffset;
}
}
}
/* mapping */
if (ctx->Pixel.MapColorFlag) {
for (i=0;i<width;i++) {
if (indx[i] < ctx->Pixel.MapItoIsize) {
indx[i] = ctx->Pixel.MapItoI[ indx[i] ];
}
}
}
/* write */
if (setbuffer) {
(*ctx->Driver.SetBuffer)( ctx, ctx->Color.DrawBuffer );
}
if (zoom) {
gl_write_zoomed_index_span( ctx, width, destx, dy, zspan, indx, desty );
}
else {
gl_write_index_span( ctx, width, destx, dy, zspan, indx, GL_BITMAP );
}
}
}
/*
* TODO: Optimize!!!!
*/
static void copy_depth_pixels( GLcontext* ctx, GLint srcx, GLint srcy,
GLint width, GLint height,
GLint destx, GLint desty )
{
GLfloat depth[MAX_WIDTH];
GLdepth zspan[MAX_WIDTH];
GLuint indx[MAX_WIDTH];
GLubyte red[MAX_WIDTH], green[MAX_WIDTH];
GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH];
GLint sy, dy, stepy;
GLint i, j;
GLboolean zoom;
if (!ctx->Buffer->Depth) {
gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
return;
}
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
zoom = GL_FALSE;
}
else {
zoom = GL_TRUE;
}
/* Determine if copy should be bottom-to-top or top-to-bottom */
if (srcy<desty) {
/* top-down max-to-min */
sy = srcy + height - 1;
dy = desty + height - 1;
stepy = -1;
}
else {
/* bottom-up min-to-max */
sy = srcy;
dy = desty;
stepy = 1;
}
/* setup colors or indexes */
if (ctx->Visual->RGBAflag) {
GLubyte r, g, b, a;
r = ctx->Current.ByteColor[0];
g = ctx->Current.ByteColor[1];
b = ctx->Current.ByteColor[2];
a = ctx->Current.ByteColor[3];
MEMSET( red, (int) r, width );
MEMSET( green, (int) g, width );
MEMSET( blue, (int) b, width );
MEMSET( alpha, (int) a, width );
}
else {
for (i=0;i<width;i++) {
indx[i] = ctx->Current.Index;
}
}
for (j=0; j<height; j++, sy+=stepy, dy+=stepy) {
/* read */
(*ctx->Driver.ReadDepthSpanFloat)( ctx, width, srcx, sy, depth );
/* scale, bias, clamp */
for (i=0;i<width;i++) {
GLfloat d = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
zspan[i] = (GLint) (CLAMP( d, 0.0, 1.0 ) * DEPTH_SCALE);
}
/* write */
if (ctx->Visual->RGBAflag) {
if (zoom) {
gl_write_zoomed_color_span( ctx, width, destx, dy, zspan,
red, green, blue, alpha, desty );
}
else {
gl_write_color_span( ctx, width, destx, dy, zspan,
red, green, blue, alpha, GL_BITMAP );
}
}
else {
if (zoom) {
gl_write_zoomed_index_span( ctx, width, destx, dy,
zspan, indx, desty);
}
else {
gl_write_index_span( ctx, width, destx, dy,
zspan, indx, GL_BITMAP );
}
}
}
}
static void copy_stencil_pixels( GLcontext* ctx, GLint srcx, GLint srcy,
GLint width, GLint height,
GLint destx, GLint desty )
{
GLubyte stencil[MAX_WIDTH];
GLint sy, dy, stepy;
GLint i, j;
GLboolean zoom;
if (!ctx->Buffer->Stencil) {
gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
return;
}
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
zoom = GL_FALSE;
}
else {
zoom = GL_TRUE;
}
/* Determine if copy should be bottom-to-top or top-to-bottom */
if (srcy<desty) {
/* top-down max-to-min */
sy = srcy + height - 1;
dy = desty + height - 1;
stepy = -1;
}
else {
/* bottom-up min-to-max */
sy = srcy;
dy = desty;
stepy = 1;
}
for (j=0; j<height; j++, sy+=stepy, dy+=stepy) {
/* read */
gl_read_stencil_span( ctx, width, srcx, sy, stencil );
/* shift, offset */
if (ctx->Pixel.IndexShift<0) {
for (i=0;i<width;i++) {
stencil[i] = (stencil[i] >> -ctx->Pixel.IndexShift)
+ ctx->Pixel.IndexOffset;
}
}
else {
for (i=0;i<width;i++) {
stencil[i] = (stencil[i] << ctx->Pixel.IndexShift)
+ ctx->Pixel.IndexOffset;
}
}
/* mapping */
if (ctx->Pixel.MapStencilFlag) {
for (i=0;i<width;i++) {
if ((GLint) stencil[i] < ctx->Pixel.MapStoSsize) {
stencil[i] = ctx->Pixel.MapStoS[ stencil[i] ];
}
}
}
/* write */
if (zoom) {
gl_write_zoomed_stencil_span( ctx, width, destx, dy, stencil, desty );
}
else {
gl_write_stencil_span( ctx, width, destx, dy, stencil );
}
}
}
void gl_CopyPixels( GLcontext* ctx, GLint srcx, GLint srcy, GLsizei width, GLsizei height,
GLenum type )
{
GLint destx, desty;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
return;
}
if (width<0 || height<0) {
gl_error( ctx, GL_INVALID_VALUE, "glCopyPixels" );
return;
}
if (ctx->NewState) {
gl_update_state(ctx);
}
if (ctx->RenderMode==GL_RENDER) {
/* Destination of copy: */
if (!ctx->Current.RasterPosValid) {
return;
}
destx = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
desty = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
if (type==GL_COLOR && ctx->Visual->RGBAflag) {
copy_rgb_pixels( ctx, srcx, srcy, width, height, destx, desty );
}
else if (type==GL_COLOR && !ctx->Visual->RGBAflag) {
copy_ci_pixels( ctx, srcx, srcy, width, height, destx, desty );
}
else if (type==GL_DEPTH) {
copy_depth_pixels( ctx, srcx, srcy, width, height, destx, desty );
}
else if (type==GL_STENCIL) {
copy_stencil_pixels( ctx, srcx, srcy, width, height, destx, desty );
}
else {
gl_error( ctx, GL_INVALID_ENUM, "glCopyPixels" );
}
}
else if (ctx->RenderMode==GL_FEEDBACK) {
GLfloat color[4];
color[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale;
color[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale;
color[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale;
color[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale;
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN );
gl_feedback_vertex( ctx, ctx->Current.RasterPos[0],
ctx->Current.RasterPos[1],
ctx->Current.RasterPos[2],
ctx->Current.RasterPos[3],
color, ctx->Current.Index,
ctx->Current.TexCoord );
}
else if (ctx->RenderMode==GL_SELECT) {
gl_update_hitflag( ctx, ctx->Current.RasterPos[2] );
}
}

46
dll/opengl/mesa/copypix.h Normal file
View File

@@ -0,0 +1,46 @@
/* $Id: copypix.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: copypix.h,v $
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef COPYPIXELS_H
#define COPYPIXELS_H
#include "types.h"
extern void gl_CopyPixels( GLcontext* ctx,
GLint srcx, GLint srcy,
GLsizei width, GLsizei height,
GLenum type );
#endif

557
dll/opengl/mesa/dd.h Normal file
View File

@@ -0,0 +1,557 @@
/* $Id: dd.h,v 1.15 1997/12/05 04:38:28 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.6
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: dd.h,v $
* Revision 1.15 1997/12/05 04:38:28 brianp
* added ClearColorAndDepth() function pointer (David Bucciarelli)
*
* Revision 1.14 1997/11/25 03:39:41 brianp
* added TexSubImage() function pointer (David Bucciarelli)
*
* Revision 1.13 1997/10/29 02:23:54 brianp
* added UseGlobalTexturePalette() dd function (David Bucciarelli v20 3dfx)
*
* Revision 1.12 1997/10/16 02:27:53 brianp
* more comments
*
* Revision 1.11 1997/10/14 00:07:40 brianp
* added DavidB's fxmesa v19 changes
*
* Revision 1.10 1997/09/29 23:26:50 brianp
* new texture functions
*
* Revision 1.9 1997/04/29 01:31:07 brianp
* added RasterSetup() function to device driver
*
* Revision 1.8 1997/04/20 19:47:27 brianp
* added RenderVB to device driver
*
* Revision 1.7 1997/04/20 16:31:08 brianp
* added NearFar device driver function
*
* Revision 1.6 1997/04/12 12:27:31 brianp
* added QuadFunc and RectFunc
*
* Revision 1.5 1997/03/21 01:57:07 brianp
* added RendererString() function
*
* Revision 1.4 1997/02/10 19:22:47 brianp
* added device driver Error() function
*
* Revision 1.3 1997/01/16 03:34:33 brianp
* added preliminary texture mapping functions and cleaned up documentation
*
* Revision 1.2 1996/11/13 03:51:59 brianp
* updated comments
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef DD_INCLUDED
#define DD_INCLUDED
/* THIS FILE ONLY INCLUDED BY types.h !!!!! */
/*
* Device Driver (DD) interface
*
*
* All device driver functions are accessed through pointers in the
* dd_function_table struct (defined below) which is stored in the GLcontext
* struct. Since the device driver is strictly accessed trough a table of
* function pointers we can:
* 1. switch between a number of different device drivers at runtime.
* 2. use optimized functions dependant on current rendering state or
* frame buffer configuration.
*
* The function pointers in the dd_function_table struct are divided into
* two groups: mandatory and optional.
* Mandatory functions have to be implemented by every device driver.
* Optional functions may or may not be implemented by the device driver.
* The optional functions provide ways to take advantage of special hardware
* or optimized algorithms.
*
* The function pointers in the dd_function_table struct are first
* initialized in the "MakeCurrent" function. The "MakeCurrent" function
* is a little different in each device driver. See the X/Mesa, GLX, or
* OS/Mesa drivers for examples.
*
* Later, Mesa may call the dd_function_table's UpdateState() function.
* This function should initialize the dd_function_table's pointers again.
* The UpdateState() function is called whenever the core (GL) rendering
* state is changed in a way which may effect rasterization. For example,
* the TriangleFunc() pointer may have to point to different functions
* depending on whether smooth or flat shading is enabled.
*
* Note that the first argument to every device driver function is a
* GLcontext *. In turn, the GLcontext->DriverCtx pointer points to
* the driver-specific context struct. See the X/Mesa or OS/Mesa interface
* for an example.
*
* For more information about writing a device driver see the ddsample.c
* file and other device drivers (xmesa[123].c, osmesa.c, etc) for examples.
*
*
* Look below in the dd_function_table struct definition for descriptions
* of each device driver function.
*
*
* In the future more function pointers may be added for glReadPixels
* glCopyPixels, etc.
*
*
* Notes:
* ------
* RGBA = red/green/blue/alpha
* CI = color index (color mapped mode)
* mono = all pixels have the same color or index
*
* The write_ functions all take an array of mask flags which indicate
* whether or not the pixel should be written. One special case exists
* in the write_color_span function: if the mask array is NULL, then
* draw all pixels. This is an optimization used for glDrawPixels().
*
* IN ALL CASES:
* X coordinates start at 0 at the left and increase to the right
* Y coordinates start at 0 at the bottom and increase upward
*
*/
/*
* Device Driver function table.
*/
struct dd_function_table {
/**********************************************************************
*** Mandatory functions: these functions must be implemented by ***
*** every device driver. ***
**********************************************************************/
const char * (*RendererString)(void);
/*
* Return a string which uniquely identifies this device driver.
* The string should contain no whitespace. Examples: "X11" "OffScreen"
* "MSWindows" "SVGA".
*/
void (*UpdateState)( GLcontext *ctx );
/*
* UpdateState() is called whenver Mesa thinks the device driver should
* update its state and/or the other pointers (such as PointsFunc,
* LineFunc, or TriangleFunc).
*/
void (*ClearIndex)( GLcontext *ctx, GLuint index );
/*
* Called whenever glClearIndex() is called. Set the index for clearing
* the color buffer.
*/
void (*ClearColor)( GLcontext *ctx, GLubyte red, GLubyte green,
GLubyte blue, GLubyte alpha );
/*
* Called whenever glClearColor() is called. Set the color for clearing
* the color buffer.
*/
void (*Clear)( GLcontext *ctx,
GLboolean all, GLint x, GLint y, GLint width, GLint height );
/*
* Clear the current color buffer. If 'all' is set the clear the whole
* buffer, else clear the region defined by (x,y,width,height).
*/
void (*Index)( GLcontext *ctx, GLuint index );
/*
* Sets current color index for drawing flat-shaded primitives.
*/
void (*Color)( GLcontext *ctx,
GLubyte red, GLubyte green, GLubyte glue, GLubyte alpha );
/*
* Sets current color for drawing flat-shaded primitives.
*/
GLboolean (*SetBuffer)( GLcontext *ctx, GLenum mode );
/*
* Selects either the front or back color buffer for reading and writing.
* mode is either GL_FRONT or GL_BACK.
*/
void (*GetBufferSize)( GLcontext *ctx,
GLuint *width, GLuint *height );
/*
* Returns the width and height of the current color buffer.
*/
/***
*** Functions for writing pixels to the frame buffer:
***/
void (*WriteColorSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte red[], const GLubyte green[],
const GLubyte blue[], const GLubyte alpha[],
const GLubyte mask[] );
/*
* Write a horizontal run of RGBA pixels.
*/
void (*WriteMonocolorSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte mask[] );
/*
* Write a horizontal run of mono-RGBA pixels.
*/
void (*WriteColorPixels)( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLubyte red[], const GLubyte green[],
const GLubyte blue[], const GLubyte alpha[],
const GLubyte mask[] );
/*
* Write an array of RGBA pixels at random locations.
*/
void (*WriteMonocolorPixels)( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLubyte mask[] );
/*
* Write an array of mono-RGBA pixels at random locations.
*/
void (*WriteIndexSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y, const GLuint index[],
const GLubyte mask[] );
/*
* Write a horizontal run of CI pixels.
*/
void (*WriteMonoindexSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte mask[] );
/*
* Write a horizontal run of mono-CI pixels.
*/
void (*WriteIndexPixels)( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLuint index[], const GLubyte mask[] );
/*
* Write a random array of CI pixels.
*/
void (*WriteMonoindexPixels)( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLubyte mask[] );
/*
* Write a random array of mono-CI pixels.
*/
/***
*** Functions to read pixels from frame buffer:
***/
void (*ReadIndexSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y, GLuint index[] );
/*
* Read a horizontal run of color index pixels.
*/
void (*ReadColorSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[] );
/*
* Read a horizontal run of RGBA pixels.
*/
void (*ReadIndexPixels)( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint indx[], const GLubyte mask[] );
/*
* Read a random array of CI pixels.
*/
void (*ReadColorPixels)( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[],
const GLubyte mask[] );
/*
* Read a random array of RGBA pixels.
*/
/**********************************************************************
*** Optional functions: these functions may or may not be ***
*** implemented by the device driver. If the device driver ***
*** doesn't implement them it should never touch these pointers ***
*** since Mesa will either set them to NULL or point them at a ***
*** fall-back function. ***
**********************************************************************/
void (*Finish)( GLcontext *ctx );
/*
* Called whenever glFinish() is called.
*/
void (*Flush)( GLcontext *ctx );
/*
* Called whenever glFlush() is called.
*/
GLboolean (*IndexMask)( GLcontext *ctx, GLuint mask );
/*
* Implements glIndexMask() if possible, else return GL_FALSE.
*/
GLboolean (*ColorMask)( GLcontext *ctx,
GLboolean rmask, GLboolean gmask,
GLboolean bmask, GLboolean amask );
/*
* Implements glColorMask() if possible, else return GL_FALSE.
*/
GLboolean (*LogicOp)( GLcontext *ctx, GLenum op );
/*
* Implements glLogicOp() if possible, else return GL_FALSE.
*/
void (*Dither)( GLcontext *ctx, GLboolean enable );
/*
* Enable/disable dithering.
*/
void (*Error)( GLcontext *ctx );
/*
* Called whenever an error is generated. ctx->ErrorValue contains
* the error value.
*/
void (*NearFar)( GLcontext *ctx, GLfloat nearVal, GLfloat farVal );
/*
* Called from glFrustum and glOrtho to tell device driver the
* near and far clipping plane Z values. The 3Dfx driver, for example,
* uses this.
*/
/***
*** For supporting hardware Z buffers:
***/
void (*AllocDepthBuffer)( GLcontext *ctx );
/*
* Called when the depth buffer must be allocated or possibly resized.
*/
void (*ClearDepthBuffer)( GLcontext *ctx );
/*
* Clear the depth buffer to depth specified by CC.Depth.Clear value.
*/
GLuint (*DepthTestSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y, const GLdepth z[],
GLubyte mask[] );
void (*DepthTestPixels)( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] );
/*
* Apply the depth buffer test to an span/array of pixels and return
* an updated pixel mask. This function is not used when accelerated
* point, line, polygon functions are used.
*/
void (*ReadDepthSpanFloat)( GLcontext *ctx,
GLuint n, GLint x, GLint y, GLfloat depth[]);
void (*ReadDepthSpanInt)( GLcontext *ctx,
GLuint n, GLint x, GLint y, GLdepth depth[] );
/*
* Return depth values as integers for glReadPixels.
* Floats should be returned in the range [0,1].
* Ints (GLdepth) values should be in the range [0,MAXDEPTH].
*/
void (*ClearColorAndDepth)( GLcontext *ctx,
GLboolean all, GLint x, GLint y,
GLint width, GLint height );
/*
* If this function is implemented then it will be called when both the
* color and depth buffers are to be cleared.
*/
/***
*** Accelerated point, line, polygon, glDrawPixels and glBitmap functions:
***/
points_func PointsFunc;
/*
* Called to draw an array of points.
*/
line_func LineFunc;
/*
* Called to draw a line segment.
*/
triangle_func TriangleFunc;
/*
* Called to draw a filled triangle.
*/
quad_func QuadFunc;
/*
* Called to draw a filled quadrilateral.
*/
rect_func RectFunc;
/*
* Called to draw a filled, screen-aligned 2-D rectangle.
*/
GLboolean (*DrawPixels)( GLcontext *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLboolean packed,
const GLvoid *pixels );
/*
* Called from glDrawPixels().
*/
GLboolean (*Bitmap)( GLcontext *ctx, GLsizei width, GLsizei height,
GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove,
const struct gl_image *bitmap );
/*
* Called from glBitmap().
*/
void (*Begin)( GLcontext *ctx, GLenum mode );
void (*End)( GLcontext *ctx );
/*
* These are called whenever glBegin() or glEnd() are called.
* The device driver may do some sort of window locking/unlocking here.
*/
void (*RasterSetup)( GLcontext *ctx, GLuint start, GLuint end );
/*
* This function, if not NULL, is called whenever new window coordinates
* are put in the vertex buffer. The vertices in question are those n
* such that start <= n < end.
* The device driver can convert the window coords to its own specialized
* format. The 3Dfx driver uses this.
*/
GLboolean (*RenderVB)( GLcontext *ctx, GLboolean allDone );
/*
* This function allows the device driver to rasterize an entire
* buffer of primitives at once. See the gl_render_vb() function
* in vbrender.c for more details.
* Return GL_TRUE if vertex buffer successfully rendered.
* Return GL_FALSE if failure, let core Mesa render the vertex buffer.
*/
/***
*** Texture mapping functions:
***/
void (*TexEnv)( GLcontext *ctx, GLenum pname, const GLfloat *param );
/*
* Called whenever glTexEnv*() is called.
* Pname will be one of GL_TEXTURE_ENV_MODE or GL_TEXTURE_ENV_COLOR.
* If pname is GL_TEXTURE_ENV_MODE then param will be one
* of GL_MODULATE, GL_BLEND, GL_DECAL, or GL_REPLACE.
*/
void (*TexImage)( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj, GLint level,
GLint internalFormat,
const struct gl_texture_image *image );
/*
* Called whenever a texture object's image is changed.
* texObject is the number of the texture object being changed.
* level indicates the mipmap level.
* internalFormat is the format in which the texture is to be stored.
* image is a pointer to a gl_texture_image struct which contains
* the actual image data.
*/
void (*TexSubImage)( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLint internalFormat,
const struct gl_texture_image *image );
/*
* Called from glTexSubImage() to define a sub-region of a texture.
*/
void (*TexParameter)( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj,
GLenum pname, const GLfloat *params );
/*
* Called whenever glTexParameter*() is called.
* target is GL_TEXTURE_1D or GL_TEXTURE_2D
* texObject is the texture object to modify
* pname is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER,
* GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, or GL_TEXTURE_BORDER_COLOR.
* params is dependant on pname. See man glTexParameter.
*/
void (*BindTexture)( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj );
/*
* Called whenever glBindTexture() is called. This specifies which
* texture is to be the current one.
*/
void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
/*
* Called when a texture object can be deallocated.
*/
void (*UpdateTexturePalette)( GLcontext *ctx,
struct gl_texture_object *tObj );
/*
* Called when the texture's color lookup table is changed.
* If tObj is NULL then the shared texture palette ctx->Texture.Palette
* was changed.
*/
};
#endif

924
dll/opengl/mesa/depth.c Normal file
View File

@@ -0,0 +1,924 @@
/* $Id: depth.c,v 1.11 1997/07/24 01:24:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: depth.c,v $
* Revision 1.11 1997/07/24 01:24:45 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.10 1997/05/28 03:24:22 brianp
* added precompiled header (PCH) support
*
* Revision 1.9 1997/04/20 19:54:15 brianp
* replaced abort() with gl_problem()
*
* Revision 1.8 1997/02/27 19:58:52 brianp
* don't try to clear depth buffer if there isn't one
*
* Revision 1.7 1997/01/31 23:33:08 brianp
* replaced calloc with malloc in gl_alloc_depth_buffer()
*
* Revision 1.6 1996/11/04 01:42:07 brianp
* multiply Viewport.Sz and .Tz by DEPTH_SCALE
*
* Revision 1.5 1996/10/09 03:07:25 brianp
* replaced malloc with calloc in gl_alloc_depth_buffer()
*
* Revision 1.4 1996/09/27 01:24:58 brianp
* added missing default cases to switches
*
* Revision 1.3 1996/09/19 00:54:05 brianp
* added missing returns after some gl_error() calls
*
* Revision 1.2 1996/09/15 14:19:16 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
/*
* Depth buffer functions
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <stdlib.h>
#include <string.h>
#include "context.h"
#include "depth.h"
#include "dlist.h"
#include "macros.h"
#include "types.h"
#endif
/**********************************************************************/
/***** API Functions *****/
/**********************************************************************/
void gl_ClearDepth( GLcontext* ctx, GLclampd depth )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glClearDepth" );
return;
}
ctx->Depth.Clear = (GLfloat) CLAMP( depth, 0.0, 1.0 );
}
void gl_DepthFunc( GLcontext* ctx, GLenum func )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glDepthFunc" );
return;
}
switch (func) {
case GL_NEVER:
case GL_LESS: /* (default) pass if incoming z < stored z */
case GL_GEQUAL:
case GL_LEQUAL:
case GL_GREATER:
case GL_NOTEQUAL:
case GL_EQUAL:
case GL_ALWAYS:
ctx->Depth.Func = func;
ctx->NewState |= NEW_RASTER_OPS;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glDepth.Func" );
}
}
void gl_DepthMask( GLcontext* ctx, GLboolean flag )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glDepthMask" );
return;
}
/*
* GL_TRUE indicates depth buffer writing is enabled (default)
* GL_FALSE indicates depth buffer writing is disabled
*/
ctx->Depth.Mask = flag;
ctx->NewState |= NEW_RASTER_OPS;
}
void gl_DepthRange( GLcontext* ctx, GLclampd nearval, GLclampd farval )
{
/*
* nearval - specifies mapping of the near clipping plane to window
* coordinates, default is 0
* farval - specifies mapping of the far clipping plane to window
* coordinates, default is 1
*
* After clipping and div by w, z coords are in -1.0 to 1.0,
* corresponding to near and far clipping planes. glDepthRange
* specifies a linear mapping of the normalized z coords in
* this range to window z coords.
*/
GLfloat n, f;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glDepthRange" );
return;
}
n = (GLfloat) CLAMP( nearval, 0.0, 1.0 );
f = (GLfloat) CLAMP( farval, 0.0, 1.0 );
ctx->Viewport.Near = n;
ctx->Viewport.Far = f;
ctx->Viewport.Sz = DEPTH_SCALE * ((f - n) / 2.0);
ctx->Viewport.Tz = DEPTH_SCALE * ((f - n) / 2.0 + n);
}
/**********************************************************************/
/***** Depth Testing Functions *****/
/**********************************************************************/
/*
* Depth test horizontal spans of fragments. These functions are called
* via ctx->Driver.depth_test_span only.
*
* Input: n - number of pixels in the span
* x, y - location of leftmost pixel in span in window coords
* z - array [n] of integer depth values
* In/Out: mask - array [n] of flags (1=draw pixel, 0=don't draw)
* Return: number of pixels which passed depth test
*/
/*
* glDepthFunc( any ) and glDepthMask( GL_TRUE or GL_FALSE ).
*/
GLuint gl_depth_test_span_generic( GLcontext* ctx,
GLuint n, GLint x, GLint y,
const GLdepth z[],
GLubyte mask[] )
{
GLdepth *zptr = Z_ADDRESS( ctx, x, y );
GLubyte *m = mask;
GLuint i;
GLuint passed = 0;
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Depth.Func) {
case GL_LESS:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0; i<n; i++,zptr++,m++) {
if (*m) {
if (z[i] < *zptr) {
/* pass */
*zptr = z[i];
passed++;
}
else {
/* fail */
*m = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0; i<n; i++,zptr++,m++) {
if (*m) {
if (z[i] < *zptr) {
/* pass */
passed++;
}
else {
*m = 0;
}
}
}
}
break;
case GL_LEQUAL:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
if (z[i] <= *zptr) {
*zptr = z[i];
passed++;
}
else {
*m = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
if (z[i] <= *zptr) {
/* pass */
passed++;
}
else {
*m = 0;
}
}
}
}
break;
case GL_GEQUAL:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
if (z[i] >= *zptr) {
*zptr = z[i];
passed++;
}
else {
*m = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
if (z[i] >= *zptr) {
/* pass */
passed++;
}
else {
*m = 0;
}
}
}
}
break;
case GL_GREATER:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
if (z[i] > *zptr) {
*zptr = z[i];
passed++;
}
else {
*m = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
if (z[i] > *zptr) {
/* pass */
passed++;
}
else {
*m = 0;
}
}
}
}
break;
case GL_NOTEQUAL:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
if (z[i] != *zptr) {
*zptr = z[i];
passed++;
}
else {
*m = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
if (z[i] != *zptr) {
/* pass */
passed++;
}
else {
*m = 0;
}
}
}
}
break;
case GL_EQUAL:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
if (z[i] == *zptr) {
*zptr = z[i];
passed++;
}
else {
*m =0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
if (z[i] == *zptr) {
/* pass */
passed++;
}
else {
*m =0;
}
}
}
}
break;
case GL_ALWAYS:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0;i<n;i++,zptr++,m++) {
if (*m) {
*zptr = z[i];
passed++;
}
}
}
else {
/* Don't update Z buffer or mask */
passed = n;
}
break;
case GL_NEVER:
for (i=0;i<n;i++) {
mask[i] = 0;
}
break;
default:
gl_problem(ctx, "Bad depth func in gl_depth_test_span_generic");
} /*switch*/
return passed;
}
/*
* glDepthFunc(GL_LESS) and glDepthMask(GL_TRUE).
*/
GLuint gl_depth_test_span_less( GLcontext* ctx,
GLuint n, GLint x, GLint y, const GLdepth z[],
GLubyte mask[] )
{
GLdepth *zptr = Z_ADDRESS( ctx, x, y );
GLuint i;
GLuint passed = 0;
for (i=0; i<n; i++) {
if (mask[i]) {
if (z[i] < zptr[i]) {
/* pass */
zptr[i] = z[i];
passed++;
}
else {
/* fail */
mask[i] = 0;
}
}
}
return passed;
}
/*
* glDepthFunc(GL_GREATER) and glDepthMask(GL_TRUE).
*/
GLuint gl_depth_test_span_greater( GLcontext* ctx,
GLuint n, GLint x, GLint y,
const GLdepth z[],
GLubyte mask[] )
{
GLdepth *zptr = Z_ADDRESS( ctx, x, y );
GLuint i;
GLuint passed = 0;
for (i=0; i<n; i++) {
if (mask[i]) {
if (z[i] > zptr[i]) {
/* pass */
zptr[i] = z[i];
passed++;
}
else {
/* fail */
mask[i] = 0;
}
}
}
return passed;
}
/*
* Depth test an array of randomly positioned fragments.
*/
#define ZADDR_SETUP GLdepth *depthbuffer = ctx->Buffer->Depth; \
GLint width = ctx->Buffer->Width;
#define ZADDR( X, Y ) (depthbuffer + (Y) * width + (X) )
/*
* glDepthFunc( any ) and glDepthMask( GL_TRUE or GL_FALSE ).
*/
void gl_depth_test_pixels_generic( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] )
{
register GLdepth *zptr;
register GLuint i;
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Depth.Func) {
case GL_LESS:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] < *zptr) {
/* pass */
*zptr = z[i];
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] < *zptr) {
/* pass */
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
break;
case GL_LEQUAL:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] <= *zptr) {
/* pass */
*zptr = z[i];
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] <= *zptr) {
/* pass */
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
break;
case GL_GEQUAL:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] >= *zptr) {
/* pass */
*zptr = z[i];
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] >= *zptr) {
/* pass */
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
break;
case GL_GREATER:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] > *zptr) {
/* pass */
*zptr = z[i];
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] > *zptr) {
/* pass */
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
break;
case GL_NOTEQUAL:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] != *zptr) {
/* pass */
*zptr = z[i];
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] != *zptr) {
/* pass */
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
break;
case GL_EQUAL:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] == *zptr) {
/* pass */
*zptr = z[i];
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
else {
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] == *zptr) {
/* pass */
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
break;
case GL_ALWAYS:
if (ctx->Depth.Mask) {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
*zptr = z[i];
}
}
}
else {
/* Don't update Z buffer or mask */
}
break;
case GL_NEVER:
/* depth test never passes */
for (i=0;i<n;i++) {
mask[i] = 0;
}
break;
default:
gl_problem(ctx, "Bad depth func in gl_depth_test_pixels_generic");
} /*switch*/
}
/*
* glDepthFunc( GL_LESS ) and glDepthMask( GL_TRUE ).
*/
void gl_depth_test_pixels_less( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] )
{
GLdepth *zptr;
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] < *zptr) {
/* pass */
*zptr = z[i];
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
/*
* glDepthFunc( GL_GREATER ) and glDepthMask( GL_TRUE ).
*/
void gl_depth_test_pixels_greater( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] )
{
GLdepth *zptr;
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
zptr = Z_ADDRESS(ctx,x[i],y[i]);
if (z[i] > *zptr) {
/* pass */
*zptr = z[i];
}
else {
/* fail */
mask[i] = 0;
}
}
}
}
/**********************************************************************/
/***** Read Depth Buffer *****/
/**********************************************************************/
/*
* Return a span of depth values from the depth buffer as floats in [0,1].
* This function is only called through Driver.read_depth_span_float()
* Input: n - how many pixels
* x,y - location of first pixel
* Output: depth - the array of depth values
*/
void gl_read_depth_span_float( GLcontext* ctx,
GLuint n, GLint x, GLint y, GLfloat depth[] )
{
GLdepth *zptr;
GLfloat scale;
GLuint i;
scale = 1.0F / DEPTH_SCALE;
if (ctx->Buffer->Depth) {
zptr = Z_ADDRESS( ctx, x, y );
for (i=0;i<n;i++) {
depth[i] = (GLfloat) zptr[i] * scale;
}
}
else {
for (i=0;i<n;i++) {
depth[i] = 0.0F;
}
}
}
/*
* Return a span of depth values from the depth buffer as integers in
* [0,MAX_DEPTH].
* This function is only called through Driver.read_depth_span_int()
* Input: n - how many pixels
* x,y - location of first pixel
* Output: depth - the array of depth values
*/
void gl_read_depth_span_int( GLcontext* ctx,
GLuint n, GLint x, GLint y, GLdepth depth[] )
{
if (ctx->Buffer->Depth) {
GLdepth *zptr = Z_ADDRESS( ctx, x, y );
MEMCPY( depth, zptr, n * sizeof(GLdepth) );
}
else {
GLuint i;
for (i=0;i<n;i++) {
depth[i] = 0.0;
}
}
}
/**********************************************************************/
/***** Allocate and Clear Depth Buffer *****/
/**********************************************************************/
/*
* Allocate a new depth buffer. If there's already a depth buffer allocated
* it will be free()'d. The new depth buffer will be uniniitalized.
* This function is only called through Driver.alloc_depth_buffer.
*/
void gl_alloc_depth_buffer( GLcontext* ctx )
{
/* deallocate current depth buffer if present */
if (ctx->Buffer->Depth) {
free(ctx->Buffer->Depth);
ctx->Buffer->Depth = NULL;
}
/* allocate new depth buffer, but don't initialize it */
ctx->Buffer->Depth = (GLdepth *) malloc( ctx->Buffer->Width
* ctx->Buffer->Height
* sizeof(GLdepth) );
if (!ctx->Buffer->Depth) {
/* out of memory */
ctx->Depth.Test = GL_FALSE;
gl_error( ctx, GL_OUT_OF_MEMORY, "Couldn't allocate depth buffer" );
}
}
/*
* Clear the depth buffer. If the depth buffer doesn't exist yet we'll
* allocate it now.
* This function is only called through Driver.clear_depth_buffer.
*/
void gl_clear_depth_buffer( GLcontext* ctx )
{
GLdepth clear_value = (GLdepth) (ctx->Depth.Clear * DEPTH_SCALE);
if (ctx->Visual->DepthBits==0 || !ctx->Buffer->Depth) {
/* no depth buffer */
return;
}
/* The loops in this function have been written so the IRIX 5.3
* C compiler can unroll them. Hopefully other compilers can too!
*/
if (ctx->Scissor.Enabled) {
/* only clear scissor region */
GLint y;
for (y=ctx->Buffer->Ymin; y<=ctx->Buffer->Ymax; y++) {
GLdepth *d = Z_ADDRESS( ctx, ctx->Buffer->Xmin, y );
GLint n = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1;
do {
*d++ = clear_value;
n--;
} while (n);
}
}
else {
/* clear whole buffer */
GLdepth *d = ctx->Buffer->Depth;
GLint n = ctx->Buffer->Width * ctx->Buffer->Height;
while (n>=16) {
d[0] = clear_value; d[1] = clear_value;
d[2] = clear_value; d[3] = clear_value;
d[4] = clear_value; d[5] = clear_value;
d[6] = clear_value; d[7] = clear_value;
d[8] = clear_value; d[9] = clear_value;
d[10] = clear_value; d[11] = clear_value;
d[12] = clear_value; d[13] = clear_value;
d[14] = clear_value; d[15] = clear_value;
d += 16;
n -= 16;
}
while (n>0) {
*d++ = clear_value;
n--;
}
}
}

101
dll/opengl/mesa/depth.h Normal file
View File

@@ -0,0 +1,101 @@
/* $Id: depth.h,v 1.2 1996/09/15 14:19:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: depth.h,v $
* Revision 1.2 1996/09/15 14:19:16 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef DEPTH_H
#define DEPTH_H
#include "types.h"
/*
* Return the address of the Z-buffer value for window coordinate (x,y):
*/
#define Z_ADDRESS( CTX, X, Y ) \
((CTX)->Buffer->Depth + (CTX)->Buffer->Width * (Y) + (X))
extern GLuint
gl_depth_test_span_generic( GLcontext* ctx, GLuint n, GLint x, GLint y,
const GLdepth z[], GLubyte mask[] );
extern GLuint
gl_depth_test_span_less( GLcontext* ctx, GLuint n, GLint x, GLint y,
const GLdepth z[], GLubyte mask[] );
extern GLuint
gl_depth_test_span_greater( GLcontext* ctx, GLuint n, GLint x, GLint y,
const GLdepth z[], GLubyte mask[] );
extern void
gl_depth_test_pixels_generic( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] );
extern void
gl_depth_test_pixels_less( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] );
extern void
gl_depth_test_pixels_greater( GLcontext* ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] );
extern void gl_read_depth_span_float( GLcontext* ctx,
GLuint n, GLint x, GLint y,
GLfloat depth[] );
extern void gl_read_depth_span_int( GLcontext* ctx, GLuint n, GLint x, GLint y,
GLdepth depth[] );
extern void gl_alloc_depth_buffer( GLcontext* ctx );
extern void gl_clear_depth_buffer( GLcontext* ctx );
extern void gl_ClearDepth( GLcontext* ctx, GLclampd depth );
extern void gl_DepthFunc( GLcontext* ctx, GLenum func );
extern void gl_DepthMask( GLcontext* ctx, GLboolean flag );
extern void gl_DepthRange( GLcontext* ctx, GLclampd nearval, GLclampd farval );
#endif

3096
dll/opengl/mesa/dlist.c Normal file

File diff suppressed because it is too large Load Diff

432
dll/opengl/mesa/dlist.h Normal file
View File

@@ -0,0 +1,432 @@
/* $Id: dlist.h,v 1.15 1997/12/06 18:06:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: dlist.h,v $
* Revision 1.15 1997/12/06 18:06:50 brianp
* moved several static display list vars into GLcontext
*
* Revision 1.14 1997/10/29 01:29:09 brianp
* added GL_EXT_point_parameters extension from Daniel Barrero
*
* Revision 1.13 1997/09/27 00:13:44 brianp
* added GL_EXT_paletted_texture extension
*
* Revision 1.12 1997/06/20 01:57:57 brianp
* added gl_save_Color4ubv()
*
* Revision 1.11 1997/06/06 02:59:12 brianp
* added gl_destroy_list()
*
* Revision 1.10 1997/04/24 01:50:53 brianp
* optimized glColor3f, glColor3fv, glColor4fv
*
* Revision 1.9 1997/04/21 01:21:33 brianp
* added gl_save_Rectf()
*
* Revision 1.8 1997/04/20 16:18:15 brianp
* added glOrtho and glFrustum API pointers
*
* Revision 1.7 1997/04/16 23:55:33 brianp
* added optimized glTexCoord2f code
*
* Revision 1.6 1997/04/14 22:18:23 brianp
* added optimized glVertex3fv code
*
* Revision 1.5 1997/04/07 02:58:49 brianp
* added gl_save_Vertex[23]f() and related code
*
* Revision 1.4 1997/04/01 04:26:02 brianp
* added code for glLoadIdentity(), changed #include's
*
* Revision 1.3 1997/02/09 18:50:18 brianp
* added GL_EXT_texture3D support
*
* Revision 1.2 1996/11/07 04:12:45 brianp
* texture images are now gl_image structs, not gl_texture_image structs
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef DLIST_H
#define DLIST_H
#include "types.h"
extern void gl_init_lists( void );
extern void gl_destroy_list( GLcontext *ctx, GLuint list );
extern void gl_CallList( GLcontext *ctx, GLuint list );
extern void gl_CallLists( GLcontext *ctx,
GLsizei n, GLenum type, const GLvoid *lists );
extern void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range );
extern void gl_EndList( GLcontext *ctx );
extern GLuint gl_GenLists( GLcontext *ctx, GLsizei range );
extern GLboolean gl_IsList( GLcontext *ctx, GLuint list );
extern void gl_ListBase( GLcontext *ctx, GLuint base );
extern void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode );
extern void gl_save_Accum( GLcontext *ctx, GLenum op, GLfloat value );
extern void gl_save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref );
extern void gl_save_BlendFunc( GLcontext *ctx,
GLenum sfactor, GLenum dfactor );
extern void gl_save_Begin( GLcontext *ctx, GLenum mode );
extern void gl_save_BindTexture( GLcontext *ctx,
GLenum target, GLuint texture );
extern void gl_save_Bitmap( GLcontext *ctx, GLsizei width, GLsizei height,
GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove,
const struct gl_image *bitmap );
extern void gl_save_CallList( GLcontext *ctx, GLuint list );
extern void gl_save_CallLists( GLcontext *ctx,
GLsizei n, GLenum type, const GLvoid *lists );
extern void gl_save_Clear( GLcontext *ctx, GLbitfield mask );
extern void gl_save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green,
GLfloat blue, GLfloat alpha );
extern void gl_save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green,
GLclampf blue, GLclampf alpha );
extern void gl_save_ClearDepth( GLcontext *ctx, GLclampd depth );
extern void gl_save_ClearIndex( GLcontext *ctx, GLfloat c );
extern void gl_save_ClearStencil( GLcontext *ctx, GLint s );
extern void gl_save_ClipPlane( GLcontext *ctx,
GLenum plane, const GLfloat *equ );
extern void gl_save_Color3f( GLcontext *ctx, GLfloat r, GLfloat g, GLfloat b );
extern void gl_save_Color3fv( GLcontext *ctx, const GLfloat *c );
extern void gl_save_Color4f( GLcontext *ctx, GLfloat r, GLfloat g,
GLfloat b, GLfloat a );
extern void gl_save_Color4fv( GLcontext *ctx, const GLfloat *c );
extern void gl_save_Color4ub( GLcontext *ctx, GLubyte r, GLubyte g,
GLubyte b, GLubyte a );
extern void gl_save_Color4ubv( GLcontext *ctx, const GLubyte *c );
extern void gl_save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green,
GLboolean blue, GLboolean alpha );
extern void gl_save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode );
extern void gl_save_ColorTable( GLcontext *ctx, GLenum target,
GLenum internalFormat,
struct gl_image *table );
extern void gl_save_ColorSubTable( GLcontext *ctx, GLenum target,
GLsizei start, struct gl_image *data );
extern void gl_save_CopyPixels( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height, GLenum type );
extern void gl_save_CopyTexImage1D( GLcontext *ctx,
GLenum target, GLint level,
GLenum internalformat,
GLint x, GLint y, GLsizei width,
GLint border );
extern void gl_save_CopyTexImage2D( GLcontext *ctx,
GLenum target, GLint level,
GLenum internalformat,
GLint x, GLint y, GLsizei width,
GLsizei height, GLint border );
extern void gl_save_CopyTexSubImage1D( GLcontext *ctx,
GLenum target, GLint level,
GLint xoffset, GLint x, GLint y,
GLsizei width );
extern void gl_save_CopyTexSubImage2D( GLcontext *ctx,
GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLint x, GLint y,
GLsizei width, GLint height );
extern void gl_save_CullFace( GLcontext *ctx, GLenum mode );
extern void gl_save_DepthFunc( GLcontext *ctx, GLenum func );
extern void gl_save_DepthMask( GLcontext *ctx, GLboolean mask );
extern void gl_save_DepthRange( GLcontext *ctx,
GLclampd nearval, GLclampd farval );
extern void gl_save_Disable( GLcontext *ctx, GLenum cap );
extern void gl_save_DrawBuffer( GLcontext *ctx, GLenum mode );
extern void gl_save_DrawPixels( GLcontext *ctx,
GLsizei width, GLsizei height, GLenum format,
GLenum type, const GLvoid *pixels );
extern void gl_save_EdgeFlag( GLcontext *ctx, GLboolean flag );
extern void gl_save_Enable( GLcontext *ctx, GLenum cap );
extern void gl_save_End( GLcontext *ctx );
extern void gl_save_EvalCoord1f( GLcontext *ctx, GLfloat u );
extern void gl_save_EvalCoord2f( GLcontext *ctx, GLfloat u, GLfloat v );
extern void gl_save_EvalMesh1( GLcontext *ctx,
GLenum mode, GLint i1, GLint i2 );
extern void gl_save_EvalMesh2( GLcontext *ctx, GLenum mode, GLint i1, GLint i2,
GLint j1, GLint j2 );
extern void gl_save_EvalPoint1( GLcontext *ctx, GLint i );
extern void gl_save_EvalPoint2( GLcontext *ctx, GLint i, GLint j );
extern void gl_save_Fogfv( GLcontext *ctx,
GLenum pname, const GLfloat *params );
extern void gl_save_FrontFace( GLcontext *ctx, GLenum mode );
extern void gl_save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right,
GLdouble bottom, GLdouble top,
GLdouble nearval, GLdouble farval );
extern void gl_save_Hint( GLcontext *ctx, GLenum target, GLenum mode );
extern void gl_save_Indexf( GLcontext *ctx, GLfloat index );
extern void gl_save_Indexi( GLcontext *ctx, GLint index );
extern void gl_save_IndexMask( GLcontext *ctx, GLuint mask );
extern void gl_save_InitNames( GLcontext *ctx );
extern void gl_save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname,
const GLfloat *params, GLint numparams );
extern void gl_save_LightModelfv( GLcontext *ctx, GLenum pname,
const GLfloat *params );
extern void gl_save_LineWidth( GLcontext *ctx, GLfloat width );
extern void gl_save_LineStipple( GLcontext *ctx, GLint factor,
GLushort pattern );
extern void gl_save_ListBase( GLcontext *ctx, GLuint base );
extern void gl_save_LoadIdentity( GLcontext *ctx );
extern void gl_save_LoadMatrixf( GLcontext *ctx, const GLfloat *m );
extern void gl_save_LoadName( GLcontext *ctx, GLuint name );
extern void gl_save_LogicOp( GLcontext *ctx, GLenum opcode );
extern void gl_save_Map1f( GLcontext *ctx, GLenum target,
GLfloat u1, GLfloat u2, GLint stride,
GLint order, const GLfloat *points,
GLboolean retain );
extern void gl_save_Map2f( GLcontext *ctx, GLenum target,
GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
const GLfloat *points,
GLboolean retain );
extern void gl_save_MapGrid1f( GLcontext *ctx, GLint un,
GLfloat u1, GLfloat u2 );
extern void gl_save_MapGrid2f( GLcontext *ctx,
GLint un, GLfloat u1, GLfloat u2,
GLint vn, GLfloat v1, GLfloat v2 );
extern void gl_save_Materialfv( GLcontext *ctx, GLenum face, GLenum pname,
const GLfloat *params );
extern void gl_save_MatrixMode( GLcontext *ctx, GLenum mode );
extern void gl_save_MultMatrixf( GLcontext *ctx, const GLfloat *m );
extern void gl_save_NewList( GLcontext *ctx, GLuint list, GLenum mode );
extern void gl_save_Normal3fv( GLcontext *ctx, const GLfloat n[3] );
extern void gl_save_Normal3f( GLcontext *ctx,
GLfloat nx, GLfloat ny, GLfloat nz );
extern void gl_save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right,
GLdouble bottom, GLdouble top,
GLdouble nearval, GLdouble farval );
extern void gl_save_PassThrough( GLcontext *ctx, GLfloat token );
extern void gl_save_PixelMapfv( GLcontext *ctx, GLenum map, GLint mapsize,
const GLfloat *values );
extern void gl_save_PixelTransferf( GLcontext *ctx,
GLenum pname, GLfloat param );
extern void gl_save_PixelZoom( GLcontext *ctx,
GLfloat xfactor, GLfloat yfactor );
extern void gl_save_PointSize( GLcontext *ctx, GLfloat size );
extern void gl_save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode );
extern void gl_save_PolygonStipple( GLcontext *ctx, const GLubyte *mask );
extern void gl_save_PolygonOffset( GLcontext *ctx,
GLfloat factor, GLfloat units );
extern void gl_save_PopAttrib( GLcontext *ctx );
extern void gl_save_PopMatrix( GLcontext *ctx );
extern void gl_save_PopName( GLcontext *ctx );
extern void gl_save_PrioritizeTextures( GLcontext *ctx,
GLsizei n, const GLuint *textures,
const GLclampf *priorities );
extern void gl_save_PushAttrib( GLcontext *ctx, GLbitfield mask );
extern void gl_save_PushMatrix( GLcontext *ctx );
extern void gl_save_PushName( GLcontext *ctx, GLuint name );
extern void gl_save_RasterPos4f( GLcontext *ctx,
GLfloat x, GLfloat y, GLfloat z, GLfloat w );
extern void gl_save_ReadBuffer( GLcontext *ctx, GLenum mode );
extern void gl_save_Rectf( GLcontext *ctx,
GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 );
extern void gl_save_Rotatef( GLcontext *ctx, GLfloat angle,
GLfloat x, GLfloat y, GLfloat z );
extern void gl_save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z );
extern void gl_save_Scissor( GLcontext *ctx,
GLint x, GLint y, GLsizei width, GLsizei height );
extern void gl_save_ShadeModel( GLcontext *ctx, GLenum mode );
extern void gl_save_StencilFunc( GLcontext *ctx,
GLenum func, GLint ref, GLuint mask );
extern void gl_save_StencilMask( GLcontext *ctx, GLuint mask );
extern void gl_save_StencilOp( GLcontext *ctx,
GLenum fail, GLenum zfail, GLenum zpass );
extern void gl_save_TexCoord2f( GLcontext *ctx, GLfloat s, GLfloat t );
extern void gl_save_TexCoord4f( GLcontext *ctx, GLfloat s, GLfloat t,
GLfloat r, GLfloat q );
extern void gl_save_TexEnvfv( GLcontext *ctx, GLenum target, GLenum pname,
const GLfloat *params );
extern void gl_save_TexParameterfv( GLcontext *ctx, GLenum target,
GLenum pname, const GLfloat *params );
extern void gl_save_TexGenfv( GLcontext *ctx, GLenum coord, GLenum pname,
const GLfloat *params );
extern void gl_save_TexImage1D( GLcontext *ctx, GLenum target,
GLint level, GLint components,
GLsizei width, GLint border,
GLenum format, GLenum type,
struct gl_image *teximage );
extern void gl_save_TexImage2D( GLcontext *ctx, GLenum target,
GLint level, GLint components,
GLsizei width, GLsizei height, GLint border,
GLenum format, GLenum type,
struct gl_image *teximage );
extern void gl_save_TexSubImage1D( GLcontext *ctx,
GLenum target, GLint level,
GLint xoffset, GLsizei width,
GLenum format, GLenum type,
struct gl_image *image );
extern void gl_save_TexSubImage2D( GLcontext *ctx,
GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
struct gl_image *image );
extern void gl_save_Translatef( GLcontext *ctx,
GLfloat x, GLfloat y, GLfloat z );
extern void gl_save_Vertex2f( GLcontext *ctx,
GLfloat x, GLfloat y );
extern void gl_save_Vertex3f( GLcontext *ctx,
GLfloat x, GLfloat y, GLfloat z );
extern void gl_save_Vertex4f( GLcontext *ctx,
GLfloat x, GLfloat y, GLfloat z, GLfloat w );
extern void gl_save_Vertex3fv( GLcontext *ctx, const GLfloat *v );
extern void gl_save_Viewport( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height );
#endif

1207
dll/opengl/mesa/drawpix.c Normal file

File diff suppressed because it is too large Load Diff

46
dll/opengl/mesa/drawpix.h Normal file
View File

@@ -0,0 +1,46 @@
/* $Id: drawpix.h,v 1.2 1996/10/16 00:53:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: drawpix.h,v $
* Revision 1.2 1996/10/16 00:53:14 brianp
* removed gl_drawpixels() prototype
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef DRAWPIXELS_H
#define DRAWPIXELS_H
#include "types.h"
extern void gl_DrawPixels( GLcontext* ctx, GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid *pixels );
#endif

View File

@@ -1,7 +0,0 @@
list(APPEND SOURCE
driverfuncs.c
meta.c)
add_library(mesa_drv_common STATIC ${SOURCE})
add_dependencies(mesa_drv_common xdk)

View File

@@ -1,163 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2007 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.
*/
#include "main/glheader.h"
#include "main/imports.h"
#include "main/accum.h"
#include "main/context.h"
#include "main/framebuffer.h"
#include "main/readpix.h"
#include "main/renderbuffer.h"
#include "main/texformat.h"
#include "main/texgetimage.h"
#include "main/teximage.h"
#include "main/texobj.h"
#include "main/texstore.h"
#include "main/bufferobj.h"
#include "tnl/tnl.h"
#include "swrast/swrast.h"
#include "swrast/s_renderbuffer.h"
#include "driverfuncs.h"
#include "meta.h"
/**
* Plug in default functions for all pointers in the dd_function_table
* structure.
* Device drivers should call this function and then plug in any
* functions which it wants to override.
* Some functions (pointers) MUST be implemented by all drivers (REQUIRED).
*
* \param table the dd_function_table to initialize
*/
void
_mesa_init_driver_functions(struct dd_function_table *driver)
{
memset(driver, 0, sizeof(*driver));
driver->GetString = NULL; /* REQUIRED! */
driver->UpdateState = NULL; /* REQUIRED! */
driver->GetBufferSize = NULL; /* REQUIRED! */
driver->ResizeBuffers = _mesa_resize_framebuffer;
driver->Error = NULL;
driver->Finish = NULL;
driver->Flush = NULL;
/* framebuffer/image functions */
driver->Clear = _swrast_Clear;
driver->Accum = _mesa_accum;
driver->RasterPos = _tnl_RasterPos;
driver->DrawPixels = _swrast_DrawPixels;
driver->ReadPixels = _mesa_readpixels;
driver->CopyPixels = _swrast_CopyPixels;
driver->Bitmap = _swrast_Bitmap;
/* Texture functions */
driver->ChooseTextureFormat = _mesa_choose_tex_format;
driver->TexImage1D = _mesa_store_teximage1d;
driver->TexImage2D = _mesa_store_teximage2d;
driver->TexSubImage1D = _mesa_store_texsubimage1d;
driver->TexSubImage2D = _mesa_store_texsubimage2d;
driver->GetTexImage = _mesa_get_teximage;
driver->CopyTexSubImage1D = _mesa_meta_CopyTexSubImage1D;
driver->CopyTexSubImage2D = _mesa_meta_CopyTexSubImage2D;
driver->TestProxyTexImage = _mesa_test_proxy_teximage;
driver->BindTexture = NULL;
driver->NewTextureObject = _mesa_new_texture_object;
driver->DeleteTexture = _mesa_delete_texture_object;
driver->NewTextureImage = _swrast_new_texture_image;
driver->DeleteTextureImage = _swrast_delete_texture_image;
driver->AllocTextureImageBuffer = _swrast_alloc_texture_image_buffer;
driver->FreeTextureImageBuffer = _swrast_free_texture_image_buffer;
driver->MapTextureImage = _swrast_map_teximage;
driver->UnmapTextureImage = _swrast_unmap_teximage;
/* simple state commands */
driver->AlphaFunc = NULL;
driver->ClearColor = NULL;
driver->ClearDepth = NULL;
driver->ClearStencil = NULL;
driver->ClipPlane = NULL;
driver->ColorMask = NULL;
driver->ColorMaterial = NULL;
driver->CullFace = NULL;
driver->DrawBuffer = NULL;
driver->FrontFace = NULL;
driver->DepthFunc = NULL;
driver->DepthMask = NULL;
driver->DepthRange = NULL;
driver->Enable = NULL;
driver->Fogfv = NULL;
driver->Hint = NULL;
driver->Lightfv = NULL;
driver->LightModelfv = NULL;
driver->LineStipple = NULL;
driver->LineWidth = NULL;
driver->LogicOpcode = NULL;
driver->PointParameterfv = NULL;
driver->PointSize = NULL;
driver->PolygonMode = NULL;
driver->PolygonOffset = NULL;
driver->PolygonStipple = NULL;
driver->ReadBuffer = NULL;
driver->RenderMode = NULL;
driver->Scissor = NULL;
driver->ShadeModel = NULL;
driver->TexGen = NULL;
driver->TexEnv = NULL;
driver->TexParameter = NULL;
driver->Viewport = NULL;
/* buffer objects */
_mesa_init_buffer_object_functions(driver);
driver->MapRenderbuffer = _swrast_map_soft_renderbuffer;
driver->UnmapRenderbuffer = _swrast_unmap_soft_renderbuffer;
/* T&L stuff */
driver->CurrentExecPrimitive = 0;
driver->CurrentSavePrimitive = 0;
driver->NeedFlush = 0;
driver->SaveNeedFlush = 0;
driver->FlushVertices = NULL;
driver->SaveFlushVertices = NULL;
driver->PrepareExecBegin = NULL;
driver->NotifySaveBegin = NULL;
driver->LightingSpaceChange = NULL;
/* display list */
driver->NewList = NULL;
driver->EndList = NULL;
driver->BeginCallList = NULL;
driver->EndCallList = NULL;
/* GL_ARB_texture_storage */
driver->AllocTextureStorage = _swrast_AllocTextureStorage;
}

View File

@@ -1,33 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2007 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.
*/
#ifndef DRIVERFUNCS_H
#define DRIVERFUNCS_H
extern void
_mesa_init_driver_functions(struct dd_function_table *driver);
#endif

View File

@@ -1,756 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.6
*
* Copyright (C) 2009 VMware, Inc. 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.
*/
/**
* Meta operations. Some GL operations can be expressed in terms of
* other GL operations. For example, glBlitFramebuffer() can be done
* with texture mapping and glClear() can be done with polygon rendering.
*
* \author Brian Paul
*/
#include "main/glheader.h"
#include "main/mtypes.h"
#include "main/imports.h"
#include "main/blend.h"
#include "main/bufferobj.h"
#include "main/buffers.h"
#include "main/context.h"
#include "main/depth.h"
#include "main/enable.h"
#include "main/feedback.h"
#include "main/formats.h"
#include "main/image.h"
#include "main/macros.h"
#include "main/matrix.h"
#include "main/pixel.h"
#include "main/polygon.h"
#include "main/readpix.h"
#include "main/scissor.h"
#include "main/state.h"
#include "main/stencil.h"
#include "main/texobj.h"
#include "main/texenv.h"
#include "main/texgetimage.h"
#include "main/teximage.h"
#include "main/texparam.h"
#include "main/texstate.h"
#include "main/varray.h"
#include "main/viewport.h"
#include "swrast/swrast.h"
#include "drivers/common/meta.h"
/** Return offset in bytes of the field within a vertex struct */
#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
/**
* State which we may save/restore across meta ops.
* XXX this may be incomplete...
*/
struct save_state
{
GLbitfield SavedState; /**< bitmask of MESA_META_* flags */
/** MESA_META_ALPHA_TEST */
GLboolean AlphaEnabled;
GLenum AlphaFunc;
GLclampf AlphaRef;
/** MESA_META_BLEND */
GLbitfield BlendEnabled;
GLboolean ColorLogicOpEnabled;
/** MESA_META_COLOR_MASK */
GLubyte ColorMask[4];
/** MESA_META_DEPTH_TEST */
struct gl_depthbuffer_attrib Depth;
/** MESA_META_FOG */
GLboolean Fog;
/** MESA_META_PIXEL_STORE */
struct gl_pixelstore_attrib Pack, Unpack;
/** MESA_META_PIXEL_TRANSFER */
GLfloat RedBias, RedScale;
GLfloat GreenBias, GreenScale;
GLfloat BlueBias, BlueScale;
GLfloat AlphaBias, AlphaScale;
GLfloat DepthBias, DepthScale;
GLboolean MapColorFlag;
/** MESA_META_RASTERIZATION */
GLenum FrontPolygonMode, BackPolygonMode;
GLboolean PolygonOffset;
GLboolean PolygonSmooth;
GLboolean PolygonStipple;
GLboolean PolygonCull;
/** MESA_META_SCISSOR */
struct gl_scissor_attrib Scissor;
/** MESA_META_STENCIL_TEST */
struct gl_stencil_attrib Stencil;
/** MESA_META_TRANSFORM */
GLenum MatrixMode;
GLfloat ModelviewMatrix[16];
GLfloat ProjectionMatrix[16];
GLfloat TextureMatrix[16];
/** MESA_META_CLIP */
GLbitfield ClipPlanesEnabled;
/** MESA_META_TEXTURE */
struct gl_texture_object *CurrentTexture[NUM_TEXTURE_TARGETS];
/** mask of TEXTURE_2D_BIT, etc */
GLbitfield TexEnabled;
GLbitfield TexGenEnabled;
GLuint EnvMode; /* unit[0] only */
/** MESA_META_VIEWPORT */
GLint ViewportX, ViewportY, ViewportW, ViewportH;
GLclampd DepthNear, DepthFar;
/** MESA_META_SELECT_FEEDBACK */
GLenum RenderMode;
struct gl_selection Select;
struct gl_feedback Feedback;
/** Miscellaneous (always disabled) */
GLboolean Lighting;
GLboolean RasterDiscard;
};
/**
* State for glBlitFramebufer()
*/
struct blit_state
{
GLuint ArrayObj;
GLuint VBO;
GLuint DepthFP;
};
/**
* State for glClear()
*/
struct clear_state
{
GLuint ArrayObj;
GLuint VBO;
GLint ColorLocation;
GLint IntegerColorLocation;
};
/**
* State for glCopyPixels()
*/
struct copypix_state
{
GLuint ArrayObj;
GLuint VBO;
};
#define MAX_META_OPS_DEPTH 8
/**
* All per-context meta state.
*/
struct gl_meta_state
{
/** Stack of state saved during meta-ops */
struct save_state Save[MAX_META_OPS_DEPTH];
/** Save stack depth */
GLuint SaveStackDepth;
struct copypix_state CopyPix; /**< For _mesa_meta_CopyPixels() */
};
/**
* Initialize meta-ops for a context.
* To be called once during context creation.
*/
void
_mesa_meta_init(struct gl_context *ctx)
{
ASSERT(!ctx->Meta);
ctx->Meta = CALLOC_STRUCT(gl_meta_state);
}
/**
* Free context meta-op state.
* To be called once during context destruction.
*/
void
_mesa_meta_free(struct gl_context *ctx)
{
GET_CURRENT_CONTEXT(old_context);
_mesa_make_current(ctx, NULL, NULL);
if (old_context)
_mesa_make_current(old_context, old_context->WinSysDrawBuffer, old_context->WinSysReadBuffer);
else
_mesa_make_current(NULL, NULL, NULL);
free(ctx->Meta);
ctx->Meta = NULL;
}
/**
* Enter meta state. This is like a light-weight version of glPushAttrib
* but it also resets most GL state back to default values.
*
* \param state bitmask of MESA_META_* flags indicating which attribute groups
* to save and reset to their defaults
*/
void
_mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
{
struct save_state *save;
/* hope MAX_META_OPS_DEPTH is large enough */
assert(ctx->Meta->SaveStackDepth < MAX_META_OPS_DEPTH);
save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth++];
memset(save, 0, sizeof(*save));
save->SavedState = state;
if (state & MESA_META_ALPHA_TEST) {
save->AlphaEnabled = ctx->Color.AlphaEnabled;
save->AlphaFunc = ctx->Color.AlphaFunc;
save->AlphaRef = ctx->Color.AlphaRef;
if (ctx->Color.AlphaEnabled)
_mesa_set_enable(ctx, GL_ALPHA_TEST, GL_FALSE);
}
if (state & MESA_META_BLEND) {
save->BlendEnabled = ctx->Color.BlendEnabled;
if (ctx->Color.BlendEnabled) {
_mesa_set_enable(ctx, GL_BLEND, GL_FALSE);
}
save->ColorLogicOpEnabled = ctx->Color.ColorLogicOpEnabled;
if (ctx->Color.ColorLogicOpEnabled)
_mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, GL_FALSE);
}
if (state & MESA_META_COLOR_MASK) {
memcpy(save->ColorMask, ctx->Color.ColorMask,
sizeof(ctx->Color.ColorMask));
if (!ctx->Color.ColorMask[0] ||
!ctx->Color.ColorMask[1] ||
!ctx->Color.ColorMask[2] ||
!ctx->Color.ColorMask[3])
_mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
if (state & MESA_META_DEPTH_TEST) {
save->Depth = ctx->Depth; /* struct copy */
if (ctx->Depth.Test)
_mesa_set_enable(ctx, GL_DEPTH_TEST, GL_FALSE);
}
if (state & MESA_META_FOG) {
save->Fog = ctx->Fog.Enabled;
if (ctx->Fog.Enabled)
_mesa_set_enable(ctx, GL_FOG, GL_FALSE);
}
if (state & MESA_META_PIXEL_STORE) {
save->Pack = ctx->Pack;
save->Unpack = ctx->Unpack;
ctx->Pack = ctx->DefaultPacking;
ctx->Unpack = ctx->DefaultPacking;
}
if (state & MESA_META_PIXEL_TRANSFER) {
save->RedScale = ctx->Pixel.RedScale;
save->RedBias = ctx->Pixel.RedBias;
save->GreenScale = ctx->Pixel.GreenScale;
save->GreenBias = ctx->Pixel.GreenBias;
save->BlueScale = ctx->Pixel.BlueScale;
save->BlueBias = ctx->Pixel.BlueBias;
save->AlphaScale = ctx->Pixel.AlphaScale;
save->AlphaBias = ctx->Pixel.AlphaBias;
save->MapColorFlag = ctx->Pixel.MapColorFlag;
ctx->Pixel.RedScale = 1.0F;
ctx->Pixel.RedBias = 0.0F;
ctx->Pixel.GreenScale = 1.0F;
ctx->Pixel.GreenBias = 0.0F;
ctx->Pixel.BlueScale = 1.0F;
ctx->Pixel.BlueBias = 0.0F;
ctx->Pixel.AlphaScale = 1.0F;
ctx->Pixel.AlphaBias = 0.0F;
ctx->Pixel.MapColorFlag = GL_FALSE;
/* XXX more state */
ctx->NewState |=_NEW_PIXEL;
}
if (state & MESA_META_RASTERIZATION) {
save->FrontPolygonMode = ctx->Polygon.FrontMode;
save->BackPolygonMode = ctx->Polygon.BackMode;
save->PolygonOffset = ctx->Polygon.OffsetFill;
save->PolygonSmooth = ctx->Polygon.SmoothFlag;
save->PolygonStipple = ctx->Polygon.StippleFlag;
save->PolygonCull = ctx->Polygon.CullFlag;
_mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
_mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, GL_FALSE);
_mesa_set_enable(ctx, GL_POLYGON_SMOOTH, GL_FALSE);
_mesa_set_enable(ctx, GL_POLYGON_STIPPLE, GL_FALSE);
_mesa_set_enable(ctx, GL_CULL_FACE, GL_FALSE);
}
if (state & MESA_META_SCISSOR) {
save->Scissor = ctx->Scissor; /* struct copy */
_mesa_set_enable(ctx, GL_SCISSOR_TEST, GL_FALSE);
}
if (state & MESA_META_STENCIL_TEST) {
save->Stencil = ctx->Stencil; /* struct copy */
if (ctx->Stencil.Enabled)
_mesa_set_enable(ctx, GL_STENCIL_TEST, GL_FALSE);
/* NOTE: other stencil state not reset */
}
if (state & MESA_META_TEXTURE) {
GLuint tgt;
save->EnvMode = ctx->Texture.Unit.EnvMode;
/* Disable all texture units */
save->TexEnabled = ctx->Texture.Unit.Enabled;
save->TexGenEnabled = ctx->Texture.Unit.TexGenEnabled;
if (ctx->Texture.Unit.Enabled ||
ctx->Texture.Unit.TexGenEnabled) {
_mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE);
_mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE);
if (ctx->Extensions.ARB_texture_cube_map)
_mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE);
_mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_FALSE);
_mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_FALSE);
_mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_FALSE);
_mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_FALSE);
}
/* save current texture objects for unit[0] only */
for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
_mesa_reference_texobj(&save->CurrentTexture[tgt],
ctx->Texture.Unit.CurrentTex[tgt]);
}
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
if (state & MESA_META_TRANSFORM) {
memcpy(save->ModelviewMatrix, ctx->ModelviewMatrixStack.Top->m,
16 * sizeof(GLfloat));
memcpy(save->ProjectionMatrix, ctx->ProjectionMatrixStack.Top->m,
16 * sizeof(GLfloat));
memcpy(save->TextureMatrix, ctx->TextureMatrixStack.Top->m,
16 * sizeof(GLfloat));
save->MatrixMode = ctx->Transform.MatrixMode;
/* set 1:1 vertex:pixel coordinate transform */
_mesa_MatrixMode(GL_TEXTURE);
_mesa_LoadIdentity();
_mesa_MatrixMode(GL_MODELVIEW);
_mesa_LoadIdentity();
_mesa_MatrixMode(GL_PROJECTION);
_mesa_LoadIdentity();
_mesa_Ortho(0.0, ctx->DrawBuffer->Width,
0.0, ctx->DrawBuffer->Height,
-1.0, 1.0);
}
if (state & MESA_META_CLIP) {
save->ClipPlanesEnabled = ctx->Transform.ClipPlanesEnabled;
if (ctx->Transform.ClipPlanesEnabled) {
GLuint i;
for (i = 0; i < ctx->Const.MaxClipPlanes; i++) {
_mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE);
}
}
}
if (state & MESA_META_VIEWPORT) {
/* save viewport state */
save->ViewportX = ctx->Viewport.X;
save->ViewportY = ctx->Viewport.Y;
save->ViewportW = ctx->Viewport.Width;
save->ViewportH = ctx->Viewport.Height;
/* set viewport to match window size */
if (ctx->Viewport.X != 0 ||
ctx->Viewport.Y != 0 ||
ctx->Viewport.Width != ctx->DrawBuffer->Width ||
ctx->Viewport.Height != ctx->DrawBuffer->Height) {
_mesa_set_viewport(ctx, 0, 0,
ctx->DrawBuffer->Width, ctx->DrawBuffer->Height);
}
/* save depth range state */
save->DepthNear = ctx->Viewport.Near;
save->DepthFar = ctx->Viewport.Far;
/* set depth range to default */
_mesa_DepthRange(0.0, 1.0);
}
if (state & MESA_META_SELECT_FEEDBACK) {
save->RenderMode = ctx->RenderMode;
if (ctx->RenderMode == GL_SELECT) {
save->Select = ctx->Select; /* struct copy */
_mesa_RenderMode(GL_RENDER);
} else if (ctx->RenderMode == GL_FEEDBACK) {
save->Feedback = ctx->Feedback; /* struct copy */
_mesa_RenderMode(GL_RENDER);
}
}
/* misc */
{
save->Lighting = ctx->Light.Enabled;
if (ctx->Light.Enabled)
_mesa_set_enable(ctx, GL_LIGHTING, GL_FALSE);
save->RasterDiscard = ctx->RasterDiscard;
if (ctx->RasterDiscard)
_mesa_set_enable(ctx, GL_RASTERIZER_DISCARD, GL_FALSE);
}
}
/**
* Leave meta state. This is like a light-weight version of glPopAttrib().
*/
void
_mesa_meta_end(struct gl_context *ctx)
{
struct save_state *save = &ctx->Meta->Save[--ctx->Meta->SaveStackDepth];
const GLbitfield state = save->SavedState;
if (state & MESA_META_ALPHA_TEST) {
if (ctx->Color.AlphaEnabled != save->AlphaEnabled)
_mesa_set_enable(ctx, GL_ALPHA_TEST, save->AlphaEnabled);
_mesa_AlphaFunc(save->AlphaFunc, save->AlphaRef);
}
if (state & MESA_META_BLEND) {
if (ctx->Color.BlendEnabled != save->BlendEnabled) {
_mesa_set_enable(ctx, GL_BLEND, (save->BlendEnabled & 1));
}
if (ctx->Color.ColorLogicOpEnabled != save->ColorLogicOpEnabled)
_mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, save->ColorLogicOpEnabled);
}
if (state & MESA_META_COLOR_MASK) {
if (!TEST_EQ_4V(ctx->Color.ColorMask, save->ColorMask)) {
_mesa_ColorMask(save->ColorMask[0], save->ColorMask[1],
save->ColorMask[2], save->ColorMask[3]);
}
}
if (state & MESA_META_DEPTH_TEST) {
if (ctx->Depth.Test != save->Depth.Test)
_mesa_set_enable(ctx, GL_DEPTH_TEST, save->Depth.Test);
_mesa_DepthFunc(save->Depth.Func);
_mesa_DepthMask(save->Depth.Mask);
}
if (state & MESA_META_FOG) {
_mesa_set_enable(ctx, GL_FOG, save->Fog);
}
if (state & MESA_META_PIXEL_STORE) {
ctx->Pack = save->Pack;
ctx->Unpack = save->Unpack;
}
if (state & MESA_META_PIXEL_TRANSFER) {
ctx->Pixel.RedScale = save->RedScale;
ctx->Pixel.RedBias = save->RedBias;
ctx->Pixel.GreenScale = save->GreenScale;
ctx->Pixel.GreenBias = save->GreenBias;
ctx->Pixel.BlueScale = save->BlueScale;
ctx->Pixel.BlueBias = save->BlueBias;
ctx->Pixel.AlphaScale = save->AlphaScale;
ctx->Pixel.AlphaBias = save->AlphaBias;
ctx->Pixel.MapColorFlag = save->MapColorFlag;
/* XXX more state */
ctx->NewState |=_NEW_PIXEL;
}
if (state & MESA_META_RASTERIZATION) {
_mesa_PolygonMode(GL_FRONT, save->FrontPolygonMode);
_mesa_PolygonMode(GL_BACK, save->BackPolygonMode);
_mesa_set_enable(ctx, GL_POLYGON_STIPPLE, save->PolygonStipple);
_mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, save->PolygonOffset);
_mesa_set_enable(ctx, GL_POLYGON_SMOOTH, save->PolygonSmooth);
_mesa_set_enable(ctx, GL_CULL_FACE, save->PolygonCull);
}
if (state & MESA_META_SCISSOR) {
_mesa_set_enable(ctx, GL_SCISSOR_TEST, save->Scissor.Enabled);
_mesa_Scissor(save->Scissor.X, save->Scissor.Y,
save->Scissor.Width, save->Scissor.Height);
}
if (state & MESA_META_STENCIL_TEST) {
const struct gl_stencil_attrib *stencil = &save->Stencil;
_mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled);
_mesa_ClearStencil(stencil->Clear);
_mesa_StencilFunc(stencil->Function,
stencil->Ref,
stencil->ValueMask);
_mesa_StencilMask(stencil->WriteMask);
_mesa_StencilOp(stencil->FailFunc, stencil->ZFailFunc, stencil->ZPassFunc);
}
if (state & MESA_META_TEXTURE) {
GLuint tgt;
/* restore texenv for unit[0] */
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode);
/* restore texture objects for unit[0] only */
for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
if (ctx->Texture.Unit.CurrentTex[tgt] != save->CurrentTexture[tgt]) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
_mesa_reference_texobj(&ctx->Texture.Unit.CurrentTex[tgt],
save->CurrentTexture[tgt]);
}
_mesa_reference_texobj(&save->CurrentTexture[tgt], NULL);
}
/* Restore fixed function texture enables, texgen */
if (ctx->Texture.Unit.Enabled != save->TexEnabled) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
ctx->Texture.Unit.Enabled = save->TexEnabled;
}
if (ctx->Texture.Unit.TexGenEnabled != save->TexGenEnabled) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
ctx->Texture.Unit.TexGenEnabled = save->TexGenEnabled;
}
}
if (state & MESA_META_TRANSFORM) {
_mesa_MatrixMode(GL_TEXTURE);
_mesa_LoadMatrixf(save->TextureMatrix);
_mesa_MatrixMode(GL_MODELVIEW);
_mesa_LoadMatrixf(save->ModelviewMatrix);
_mesa_MatrixMode(GL_PROJECTION);
_mesa_LoadMatrixf(save->ProjectionMatrix);
_mesa_MatrixMode(save->MatrixMode);
}
if (state & MESA_META_CLIP) {
if (save->ClipPlanesEnabled) {
GLuint i;
for (i = 0; i < ctx->Const.MaxClipPlanes; i++) {
if (save->ClipPlanesEnabled & (1 << i)) {
_mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE);
}
}
}
}
if (state & MESA_META_VIEWPORT) {
if (save->ViewportX != ctx->Viewport.X ||
save->ViewportY != ctx->Viewport.Y ||
save->ViewportW != ctx->Viewport.Width ||
save->ViewportH != ctx->Viewport.Height) {
_mesa_set_viewport(ctx, save->ViewportX, save->ViewportY,
save->ViewportW, save->ViewportH);
}
_mesa_DepthRange(save->DepthNear, save->DepthFar);
}
/* misc */
if (save->Lighting) {
_mesa_set_enable(ctx, GL_LIGHTING, GL_TRUE);
}
if (save->RasterDiscard) {
_mesa_set_enable(ctx, GL_RASTERIZER_DISCARD, GL_TRUE);
}
}
/**
* Determine whether Mesa is currently in a meta state.
*/
GLboolean
_mesa_meta_in_progress(struct gl_context *ctx)
{
return ctx->Meta->SaveStackDepth != 0;
}
/**
* Determine the GL data type to use for the temporary image read with
* ReadPixels() and passed to Tex[Sub]Image().
*/
static GLenum
get_temp_image_type(struct gl_context *ctx, GLenum baseFormat)
{
switch (baseFormat) {
case GL_RGBA:
case GL_RGB:
case GL_RG:
case GL_RED:
case GL_ALPHA:
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
case GL_INTENSITY:
if (ctx->DrawBuffer->Visual.redBits <= 8)
return GL_UNSIGNED_BYTE;
else if (ctx->DrawBuffer->Visual.redBits <= 16)
return GL_UNSIGNED_SHORT;
else
return GL_FLOAT;
case GL_DEPTH_COMPONENT:
return GL_UNSIGNED_INT;
default:
_mesa_problem(ctx, "Unexpected format %d in get_temp_image_type()",
baseFormat);
return 0;
}
}
/**
* Helper for _mesa_meta_CopyTexSubImage1/2/3D() functions.
* Have to be careful with locking and meta state for pixel transfer.
*/
static void
copy_tex_sub_image(struct gl_context *ctx,
GLuint dims,
struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset, GLint zoffset,
struct gl_renderbuffer *rb,
GLint x, GLint y,
GLsizei width, GLsizei height)
{
struct gl_texture_object *texObj = texImage->TexObject;
const GLenum target = texObj->Target;
GLenum format, type;
GLint bpp;
void *buf;
/* Choose format/type for temporary image buffer */
format = _mesa_get_format_base_format(texImage->TexFormat);
if (format == GL_LUMINANCE ||
format == GL_LUMINANCE_ALPHA ||
format == GL_INTENSITY) {
/* We don't want to use GL_LUMINANCE, GL_INTENSITY, etc. for the
* temp image buffer because glReadPixels will do L=R+G+B which is
* not what we want (should be L=R).
*/
format = GL_RGBA;
}
if (_mesa_is_format_integer_color(texImage->TexFormat)) {
_mesa_problem(ctx, "unsupported integer color copyteximage");
return;
}
type = get_temp_image_type(ctx, format);
bpp = _mesa_bytes_per_pixel(format, type);
if (bpp <= 0) {
_mesa_problem(ctx, "Bad bpp in meta copy_tex_sub_image()");
return;
}
/*
* Alloc image buffer (XXX could use a PBO)
*/
buf = malloc(width * height * bpp);
if (!buf) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage%uD", dims);
return;
}
_mesa_unlock_texture(ctx, texObj); /* need to unlock first */
/*
* Read image from framebuffer (disable pixel transfer ops)
*/
_mesa_meta_begin(ctx, MESA_META_PIXEL_STORE | MESA_META_PIXEL_TRANSFER);
ctx->Driver.ReadPixels(ctx, x, y, width, height,
format, type, &ctx->Pack, buf);
_mesa_meta_end(ctx);
_mesa_update_state(ctx); /* to update pixel transfer state */
/*
* Store texture data (with pixel transfer ops)
*/
_mesa_meta_begin(ctx, MESA_META_PIXEL_STORE);
if (target == GL_TEXTURE_1D) {
ctx->Driver.TexSubImage1D(ctx, texImage,
xoffset, width,
format, type, buf, &ctx->Unpack);
}
else {
ctx->Driver.TexSubImage2D(ctx, texImage,
xoffset, yoffset, width, height,
format, type, buf, &ctx->Unpack);
}
_mesa_meta_end(ctx);
_mesa_lock_texture(ctx, texObj); /* re-lock */
free(buf);
}
void
_mesa_meta_CopyTexSubImage1D(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset,
struct gl_renderbuffer *rb,
GLint x, GLint y, GLsizei width)
{
copy_tex_sub_image(ctx, 1, texImage, xoffset, 0, 0,
rb, x, y, width, 1);
}
void
_mesa_meta_CopyTexSubImage2D(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
struct gl_renderbuffer *rb,
GLint x, GLint y,
GLsizei width, GLsizei height)
{
copy_tex_sub_image(ctx, 2, texImage, xoffset, yoffset, 0,
rb, x, y, width, height);
}

View File

@@ -1,90 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.6
*
* Copyright (C) 2009 VMware, Inc. 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.
*/
#ifndef META_H
#define META_H
#include "main/mtypes.h"
/**
* \name Flags for meta operations
* \{
*
* These flags are passed to _mesa_meta_begin().
*/
#define MESA_META_ALL ~0x0
#define MESA_META_ALPHA_TEST 0x1
#define MESA_META_BLEND 0x2 /**< includes logicop */
#define MESA_META_COLOR_MASK 0x4
#define MESA_META_DEPTH_TEST 0x8
#define MESA_META_FOG 0x10
#define MESA_META_PIXEL_STORE 0x20
#define MESA_META_PIXEL_TRANSFER 0x40
#define MESA_META_RASTERIZATION 0x80
#define MESA_META_SCISSOR 0x100
#define MESA_META_STENCIL_TEST 0x400
#define MESA_META_TRANSFORM 0x800 /**< modelview/projection matrix state */
#define MESA_META_TEXTURE 0x1000
#define MESA_META_VIEWPORT 0x4000
#define MESA_META_CLIP 0x8000
#define MESA_META_SELECT_FEEDBACK 0x10000
/**\}*/
extern void
_mesa_meta_init(struct gl_context *ctx);
extern void
_mesa_meta_free(struct gl_context *ctx);
extern void
_mesa_meta_begin(struct gl_context *ctx, GLbitfield state);
extern void
_mesa_meta_end(struct gl_context *ctx);
extern GLboolean
_mesa_meta_in_progress(struct gl_context *ctx);
extern void
_mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
GLsizei width, GLsizei height,
GLint dstx, GLint dsty, GLenum type);
extern void
_mesa_meta_CopyTexSubImage1D(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset,
struct gl_renderbuffer *rb,
GLint x, GLint y, GLsizei width);
extern void
_mesa_meta_CopyTexSubImage2D(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
struct gl_renderbuffer *rb,
GLint x, GLint y,
GLsizei width, GLsizei height);
#endif /* META_H */

652
dll/opengl/mesa/enable.c Normal file
View File

@@ -0,0 +1,652 @@
/* $Id: enable.c,v 1.23 1997/10/29 02:23:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: enable.c,v $
* Revision 1.23 1997/10/29 02:23:54 brianp
* added UseGlobalTexturePalette() dd function (David Bucciarelli v20 3dfx)
*
* Revision 1.22 1997/10/16 01:59:08 brianp
* added GL_EXT_shared_texture_palette extension
*
* Revision 1.21 1997/07/24 01:25:01 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.20 1997/06/20 02:20:32 brianp
* replaced Current.IntColor with Current.ByteColor
*
* Revision 1.19 1997/05/31 16:57:14 brianp
* added MESA_NO_RASTER env var support
*
* Revision 1.18 1997/05/28 03:24:22 brianp
* added precompiled header (PCH) support
*
* Revision 1.17 1997/04/24 01:49:30 brianp
* call gl_set_color_function() instead of directly setting pointers
*
* Revision 1.16 1997/04/12 16:54:05 brianp
* new NEW_POLYGON state flag
*
* Revision 1.15 1997/04/12 16:20:27 brianp
* removed call to Driver.Dither()
*
* Revision 1.14 1997/04/02 03:10:36 brianp
* changed some #include's
*
* Revision 1.13 1997/02/27 19:59:08 brianp
* issue a warning if enable depth or stencil test without such a buffer
*
* Revision 1.12 1997/02/09 19:53:43 brianp
* now use TEXTURE_xD enable constants
*
* Revision 1.11 1997/02/09 18:49:37 brianp
* added GL_EXT_texture3D support
*
* Revision 1.10 1997/01/28 22:13:42 brianp
* now there's separate state for CI and RGBA logic op enabled
*
* Revision 1.9 1996/12/18 20:00:57 brianp
* gl_set_material() now takes a bitmask instead of face and pname
*
* Revision 1.8 1996/12/11 20:16:49 brianp
* more work on the GL_COLOR_MATERIAL bug
*
* Revision 1.7 1996/12/09 22:51:51 brianp
* update API Color4f and Color4ub pointers for GL_COLOR_MATERIAL
*
* Revision 1.6 1996/12/07 10:21:07 brianp
* call gl_set_material() instead of gl_Materialfv()
*
* Revision 1.5 1996/11/09 03:11:18 brianp
* added missing GL_EXT_vertex_array caps to gl_enable()
*
* Revision 1.4 1996/10/11 03:44:09 brianp
* added comments for GL_POLYGON_OFFSET_EXT symbol
*
* Revision 1.3 1996/09/27 01:26:40 brianp
* removed unused variables
*
* Revision 1.2 1996/09/15 14:17:30 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <string.h>
#include "context.h"
#include "depth.h"
#include "enable.h"
#include "light.h"
#include "dlist.h"
#include "macros.h"
#include "stencil.h"
#include "types.h"
#include "vbfill.h"
#endif
/*
* Perform glEnable and glDisable calls.
*/
static void gl_enable( GLcontext* ctx, GLenum cap, GLboolean state )
{
GLuint p;
if (INSIDE_BEGIN_END(ctx)) {
if (state) {
gl_error( ctx, GL_INVALID_OPERATION, "glEnable" );
}
else {
gl_error( ctx, GL_INVALID_OPERATION, "glDisable" );
}
return;
}
switch (cap) {
case GL_ALPHA_TEST:
if (ctx->Color.AlphaEnabled!=state) {
ctx->Color.AlphaEnabled = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_AUTO_NORMAL:
ctx->Eval.AutoNormal = state;
break;
case GL_BLEND:
if (ctx->Color.BlendEnabled!=state) {
ctx->Color.BlendEnabled = state;
/* The following needed to accomodate 1.0 RGB logic op blending */
ctx->Color.ColorLogicOpEnabled = GL_FALSE;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_CLIP_PLANE0:
case GL_CLIP_PLANE1:
case GL_CLIP_PLANE2:
case GL_CLIP_PLANE3:
case GL_CLIP_PLANE4:
case GL_CLIP_PLANE5:
ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0] = state;
/* Check if any clip planes enabled */
ctx->Transform.AnyClip = GL_FALSE;
for (p=0;p<MAX_CLIP_PLANES;p++) {
if (ctx->Transform.ClipEnabled[p]) {
ctx->Transform.AnyClip = GL_TRUE;
break;
}
}
break;
case GL_COLOR_MATERIAL:
if (ctx->Light.ColorMaterialEnabled!=state) {
ctx->Light.ColorMaterialEnabled = state;
if (state) {
GLfloat color[4];
color[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale;
color[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale;
color[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale;
color[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale;
/* update material with current color */
gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color );
}
gl_set_color_function(ctx);
ctx->NewState |= NEW_LIGHTING;
}
break;
case GL_CULL_FACE:
if (ctx->Polygon.CullFlag!=state) {
ctx->Polygon.CullFlag = state;
ctx->NewState |= NEW_POLYGON;
}
break;
case GL_DEPTH_TEST:
if (state && ctx->Visual->DepthBits==0) {
gl_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
return;
}
if (ctx->Depth.Test!=state) {
ctx->Depth.Test = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_DITHER:
if (ctx->NoDither) {
/* MESA_NO_DITHER env var */
state = GL_FALSE;
}
if (ctx->Color.DitherFlag!=state) {
ctx->Color.DitherFlag = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_FOG:
if (ctx->Fog.Enabled!=state) {
ctx->Fog.Enabled = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_LIGHT0:
case GL_LIGHT1:
case GL_LIGHT2:
case GL_LIGHT3:
case GL_LIGHT4:
case GL_LIGHT5:
case GL_LIGHT6:
case GL_LIGHT7:
ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
ctx->NewState |= NEW_LIGHTING;
break;
case GL_LIGHTING:
if (ctx->Light.Enabled!=state) {
ctx->Light.Enabled = state;
ctx->NewState |= NEW_LIGHTING;
}
break;
case GL_LINE_SMOOTH:
if (ctx->Line.SmoothFlag!=state) {
ctx->Line.SmoothFlag = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_LINE_STIPPLE:
if (ctx->Line.StippleFlag!=state) {
ctx->Line.StippleFlag = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_INDEX_LOGIC_OP:
if (ctx->Color.IndexLogicOpEnabled!=state) {
ctx->NewState |= NEW_RASTER_OPS;
}
ctx->Color.IndexLogicOpEnabled = state;
break;
case GL_COLOR_LOGIC_OP:
if (ctx->Color.ColorLogicOpEnabled!=state) {
ctx->NewState |= NEW_RASTER_OPS;
}
ctx->Color.ColorLogicOpEnabled = state;
break;
case GL_MAP1_COLOR_4:
ctx->Eval.Map1Color4 = state;
break;
case GL_MAP1_INDEX:
ctx->Eval.Map1Index = state;
break;
case GL_MAP1_NORMAL:
ctx->Eval.Map1Normal = state;
break;
case GL_MAP1_TEXTURE_COORD_1:
ctx->Eval.Map1TextureCoord1 = state;
break;
case GL_MAP1_TEXTURE_COORD_2:
ctx->Eval.Map1TextureCoord2 = state;
break;
case GL_MAP1_TEXTURE_COORD_3:
ctx->Eval.Map1TextureCoord3 = state;
break;
case GL_MAP1_TEXTURE_COORD_4:
ctx->Eval.Map1TextureCoord4 = state;
break;
case GL_MAP1_VERTEX_3:
ctx->Eval.Map1Vertex3 = state;
break;
case GL_MAP1_VERTEX_4:
ctx->Eval.Map1Vertex4 = state;
break;
case GL_MAP2_COLOR_4:
ctx->Eval.Map2Color4 = state;
break;
case GL_MAP2_INDEX:
ctx->Eval.Map2Index = state;
break;
case GL_MAP2_NORMAL:
ctx->Eval.Map2Normal = state;
break;
case GL_MAP2_TEXTURE_COORD_1:
ctx->Eval.Map2TextureCoord1 = state;
break;
case GL_MAP2_TEXTURE_COORD_2:
ctx->Eval.Map2TextureCoord2 = state;
break;
case GL_MAP2_TEXTURE_COORD_3:
ctx->Eval.Map2TextureCoord3 = state;
break;
case GL_MAP2_TEXTURE_COORD_4:
ctx->Eval.Map2TextureCoord4 = state;
break;
case GL_MAP2_VERTEX_3:
ctx->Eval.Map2Vertex3 = state;
break;
case GL_MAP2_VERTEX_4:
ctx->Eval.Map2Vertex4 = state;
break;
case GL_NORMALIZE:
ctx->Transform.Normalize = state;
break;
case GL_POINT_SMOOTH:
if (ctx->Point.SmoothFlag!=state) {
ctx->Point.SmoothFlag = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_POLYGON_SMOOTH:
if (ctx->Polygon.SmoothFlag!=state) {
ctx->Polygon.SmoothFlag = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_POLYGON_STIPPLE:
if (ctx->Polygon.StippleFlag!=state) {
ctx->Polygon.StippleFlag = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_POLYGON_OFFSET_POINT:
if (ctx->Polygon.OffsetPoint!=state) {
ctx->Polygon.OffsetPoint = state;
ctx->NewState |= NEW_POLYGON;
}
break;
case GL_POLYGON_OFFSET_LINE:
if (ctx->Polygon.OffsetLine!=state) {
ctx->Polygon.OffsetLine = state;
ctx->NewState |= NEW_POLYGON;
}
break;
case GL_POLYGON_OFFSET_FILL:
/*case GL_POLYGON_OFFSET_EXT:*/
if (ctx->Polygon.OffsetFill!=state) {
ctx->Polygon.OffsetFill = state;
ctx->NewState |= NEW_POLYGON;
}
break;
case GL_SCISSOR_TEST:
if (ctx->Scissor.Enabled!=state) {
ctx->Scissor.Enabled = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_STENCIL_TEST:
if (state && ctx->Visual->StencilBits==0) {
gl_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
return;
}
if (ctx->Stencil.Enabled!=state) {
ctx->Stencil.Enabled = state;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
case GL_TEXTURE_1D:
if (ctx->Visual->RGBAflag) {
/* texturing only works in RGB mode */
if (state) {
ctx->Texture.Enabled |= TEXTURE_1D;
}
else {
ctx->Texture.Enabled &= (~TEXTURE_1D);
}
ctx->NewState |= (NEW_RASTER_OPS | NEW_TEXTURING);
}
break;
case GL_TEXTURE_2D:
if (ctx->Visual->RGBAflag) {
/* texturing only works in RGB mode */
if (state) {
ctx->Texture.Enabled |= TEXTURE_2D;
}
else {
ctx->Texture.Enabled &= (~TEXTURE_2D);
}
ctx->NewState |= (NEW_RASTER_OPS | NEW_TEXTURING);
}
break;
case GL_TEXTURE_GEN_Q:
if (state) {
ctx->Texture.TexGenEnabled |= Q_BIT;
}
else {
ctx->Texture.TexGenEnabled &= ~Q_BIT;
}
ctx->NewState |= NEW_TEXTURING;
break;
case GL_TEXTURE_GEN_R:
if (state) {
ctx->Texture.TexGenEnabled |= R_BIT;
}
else {
ctx->Texture.TexGenEnabled &= ~R_BIT;
}
ctx->NewState |= NEW_TEXTURING;
break;
case GL_TEXTURE_GEN_S:
if (state) {
ctx->Texture.TexGenEnabled |= S_BIT;
}
else {
ctx->Texture.TexGenEnabled &= ~S_BIT;
}
ctx->NewState |= NEW_TEXTURING;
break;
case GL_TEXTURE_GEN_T:
if (state) {
ctx->Texture.TexGenEnabled |= T_BIT;
}
else {
ctx->Texture.TexGenEnabled &= ~T_BIT;
}
ctx->NewState |= NEW_TEXTURING;
break;
/*
* CLIENT STATE!!!
*/
case GL_VERTEX_ARRAY:
ctx->Array.VertexEnabled = state;
break;
case GL_NORMAL_ARRAY:
ctx->Array.NormalEnabled = state;
break;
case GL_COLOR_ARRAY:
ctx->Array.ColorEnabled = state;
break;
case GL_INDEX_ARRAY:
ctx->Array.IndexEnabled = state;
break;
case GL_TEXTURE_COORD_ARRAY:
ctx->Array.TexCoordEnabled = state;
break;
case GL_EDGE_FLAG_ARRAY:
ctx->Array.EdgeFlagEnabled = state;
break;
default:
if (state) {
gl_error( ctx, GL_INVALID_ENUM, "glEnable" );
}
else {
gl_error( ctx, GL_INVALID_ENUM, "glDisable" );
}
break;
}
}
void gl_Enable( GLcontext* ctx, GLenum cap )
{
gl_enable( ctx, cap, GL_TRUE );
}
void gl_Disable( GLcontext* ctx, GLenum cap )
{
gl_enable( ctx, cap, GL_FALSE );
}
GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap )
{
switch (cap) {
case GL_ALPHA_TEST:
return ctx->Color.AlphaEnabled;
case GL_AUTO_NORMAL:
return ctx->Eval.AutoNormal;
case GL_BLEND:
return ctx->Color.BlendEnabled;
case GL_CLIP_PLANE0:
case GL_CLIP_PLANE1:
case GL_CLIP_PLANE2:
case GL_CLIP_PLANE3:
case GL_CLIP_PLANE4:
case GL_CLIP_PLANE5:
return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
case GL_COLOR_MATERIAL:
return ctx->Light.ColorMaterialEnabled;
case GL_CULL_FACE:
return ctx->Polygon.CullFlag;
case GL_DEPTH_TEST:
return ctx->Depth.Test;
case GL_DITHER:
return ctx->Color.DitherFlag;
case GL_FOG:
return ctx->Fog.Enabled;
case GL_LIGHTING:
return ctx->Light.Enabled;
case GL_LIGHT0:
case GL_LIGHT1:
case GL_LIGHT2:
case GL_LIGHT3:
case GL_LIGHT4:
case GL_LIGHT5:
case GL_LIGHT6:
case GL_LIGHT7:
return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
case GL_LINE_SMOOTH:
return ctx->Line.SmoothFlag;
case GL_LINE_STIPPLE:
return ctx->Line.StippleFlag;
case GL_INDEX_LOGIC_OP:
return ctx->Color.IndexLogicOpEnabled;
case GL_COLOR_LOGIC_OP:
return ctx->Color.ColorLogicOpEnabled;
case GL_MAP1_COLOR_4:
return ctx->Eval.Map1Color4;
case GL_MAP1_INDEX:
return ctx->Eval.Map1Index;
case GL_MAP1_NORMAL:
return ctx->Eval.Map1Normal;
case GL_MAP1_TEXTURE_COORD_1:
return ctx->Eval.Map1TextureCoord1;
case GL_MAP1_TEXTURE_COORD_2:
return ctx->Eval.Map1TextureCoord2;
case GL_MAP1_TEXTURE_COORD_3:
return ctx->Eval.Map1TextureCoord3;
case GL_MAP1_TEXTURE_COORD_4:
return ctx->Eval.Map1TextureCoord4;
case GL_MAP1_VERTEX_3:
return ctx->Eval.Map1Vertex3;
case GL_MAP1_VERTEX_4:
return ctx->Eval.Map1Vertex4;
case GL_MAP2_COLOR_4:
return ctx->Eval.Map2Color4;
case GL_MAP2_INDEX:
return ctx->Eval.Map2Index;
case GL_MAP2_NORMAL:
return ctx->Eval.Map2Normal;
case GL_MAP2_TEXTURE_COORD_1:
return ctx->Eval.Map2TextureCoord1;
case GL_MAP2_TEXTURE_COORD_2:
return ctx->Eval.Map2TextureCoord2;
case GL_MAP2_TEXTURE_COORD_3:
return ctx->Eval.Map2TextureCoord3;
case GL_MAP2_TEXTURE_COORD_4:
return ctx->Eval.Map2TextureCoord4;
case GL_MAP2_VERTEX_3:
return ctx->Eval.Map2Vertex3;
case GL_MAP2_VERTEX_4:
return ctx->Eval.Map2Vertex4;
case GL_NORMALIZE:
return ctx->Transform.Normalize;
case GL_POINT_SMOOTH:
return ctx->Point.SmoothFlag;
case GL_POLYGON_SMOOTH:
return ctx->Polygon.SmoothFlag;
case GL_POLYGON_STIPPLE:
return ctx->Polygon.StippleFlag;
case GL_POLYGON_OFFSET_POINT:
return ctx->Polygon.OffsetPoint;
case GL_POLYGON_OFFSET_LINE:
return ctx->Polygon.OffsetLine;
case GL_POLYGON_OFFSET_FILL:
/*case GL_POLYGON_OFFSET_EXT:*/
return ctx->Polygon.OffsetFill;
case GL_SCISSOR_TEST:
return ctx->Scissor.Enabled;
case GL_STENCIL_TEST:
return ctx->Stencil.Enabled;
case GL_TEXTURE_1D:
return (ctx->Texture.Enabled & TEXTURE_1D) ? GL_TRUE : GL_FALSE;
case GL_TEXTURE_2D:
return (ctx->Texture.Enabled & TEXTURE_2D) ? GL_TRUE : GL_FALSE;
case GL_TEXTURE_GEN_Q:
return (ctx->Texture.TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
case GL_TEXTURE_GEN_R:
return (ctx->Texture.TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
case GL_TEXTURE_GEN_S:
return (ctx->Texture.TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
case GL_TEXTURE_GEN_T:
return (ctx->Texture.TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
/*
* CLIENT STATE!!!
*/
case GL_VERTEX_ARRAY:
return ctx->Array.VertexEnabled;
case GL_NORMAL_ARRAY:
return ctx->Array.NormalEnabled;
case GL_COLOR_ARRAY:
return ctx->Array.ColorEnabled;
case GL_INDEX_ARRAY:
return ctx->Array.IndexEnabled;
case GL_TEXTURE_COORD_ARRAY:
return ctx->Array.TexCoordEnabled;
case GL_EDGE_FLAG_ARRAY:
return ctx->Array.EdgeFlagEnabled;
default:
gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
return GL_FALSE;
}
}
void gl_client_state( GLcontext *ctx, GLenum cap, GLboolean state )
{
switch (cap) {
case GL_VERTEX_ARRAY:
ctx->Array.VertexEnabled = state;
break;
case GL_NORMAL_ARRAY:
ctx->Array.NormalEnabled = state;
break;
case GL_COLOR_ARRAY:
ctx->Array.ColorEnabled = state;
break;
case GL_INDEX_ARRAY:
ctx->Array.IndexEnabled = state;
break;
case GL_TEXTURE_COORD_ARRAY:
ctx->Array.TexCoordEnabled = state;
break;
case GL_EDGE_FLAG_ARRAY:
ctx->Array.EdgeFlagEnabled = state;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
}
}
void gl_EnableClientState( GLcontext *ctx, GLenum cap )
{
gl_client_state( ctx, cap, GL_TRUE );
}
void gl_DisableClientState( GLcontext *ctx, GLenum cap )
{
gl_client_state( ctx, cap, GL_FALSE );
}

50
dll/opengl/mesa/enable.h Normal file
View File

@@ -0,0 +1,50 @@
/* $Id: enable.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: enable.h,v $
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef ENABLE_H
#define ENABLE_H
#include "types.h"
extern void gl_Disable( GLcontext* ctx, GLenum cap );
extern void gl_Enable( GLcontext* ctx, GLenum cap );
extern GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap );
extern void gl_EnableClientState( GLcontext *ctx, GLenum cap );
extern void gl_DisableClientState( GLcontext *ctx, GLenum cap );
#endif

2466
dll/opengl/mesa/eval.c Normal file

File diff suppressed because it is too large Load Diff

108
dll/opengl/mesa/eval.h Normal file
View File

@@ -0,0 +1,108 @@
/* $Id: eval.h,v 1.2 1997/05/14 03:27:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.3
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: eval.h,v $
* Revision 1.2 1997/05/14 03:27:04 brianp
* removed context argument from gl_init_eval()
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef EVAL_H
#define EVAL_H
#include "types.h"
extern void gl_init_eval( void );
extern void gl_free_control_points( GLcontext *ctx,
GLenum target, GLfloat *data );
extern GLfloat *gl_copy_map_points1f( GLenum target,
GLint ustride, GLint uorder,
const GLfloat *points );
extern GLfloat *gl_copy_map_points1d( GLenum target,
GLint ustride, GLint uorder,
const GLdouble *points );
extern GLfloat *gl_copy_map_points2f( GLenum target,
GLint ustride, GLint uorder,
GLint vstride, GLint vorder,
const GLfloat *points );
extern GLfloat *gl_copy_map_points2d(GLenum target,
GLint ustride, GLint uorder,
GLint vstride, GLint vorder,
const GLdouble *points );
extern void gl_Map1f( GLcontext* ctx,
GLenum target, GLfloat u1, GLfloat u2, GLint stride,
GLint order, const GLfloat *points, GLboolean retain );
extern void gl_Map2f( GLcontext* ctx, GLenum target,
GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
const GLfloat *points, GLboolean retain );
extern void gl_EvalCoord1f( GLcontext* ctx, GLfloat u );
extern void gl_EvalCoord2f( GLcontext* ctx, GLfloat u, GLfloat v );
extern void gl_MapGrid1f( GLcontext* ctx, GLint un, GLfloat u1, GLfloat u2 );
extern void gl_MapGrid2f( GLcontext* ctx,
GLint un, GLfloat u1, GLfloat u2,
GLint vn, GLfloat v1, GLfloat v2 );
extern void gl_GetMapdv( GLcontext* ctx,
GLenum target, GLenum query, GLdouble *v );
extern void gl_GetMapfv( GLcontext* ctx,
GLenum target, GLenum query, GLfloat *v );
extern void gl_GetMapiv( GLcontext* ctx,
GLenum target, GLenum query, GLint *v );
extern void gl_EvalPoint1( GLcontext* ctx, GLint i );
extern void gl_EvalPoint2( GLcontext* ctx, GLint i, GLint j );
extern void gl_EvalMesh1( GLcontext* ctx, GLenum mode, GLint i1, GLint i2 );
extern void gl_EvalMesh2( GLcontext* ctx, GLenum mode,
GLint i1, GLint i2, GLint j1, GLint j2 );
#endif

428
dll/opengl/mesa/feedback.c Normal file
View File

@@ -0,0 +1,428 @@
/* $Id: feedback.c,v 1.12 1998/02/03 23:45:02 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: feedback.c,v $
* Revision 1.12 1998/02/03 23:45:02 brianp
* added casts to prevent warnings with Amiga StormC compiler
*
* Revision 1.11 1997/11/07 03:38:07 brianp
* added stdio.h include for SunOS 4.x
*
* Revision 1.10 1997/07/24 01:25:01 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.9 1997/05/28 03:24:54 brianp
* added precompiled header (PCH) support
*
* Revision 1.8 1997/03/08 02:03:46 brianp
* better error checking
*
* Revision 1.7 1997/01/21 03:09:15 brianp
* fixed an error message in gl_RenderMode()
*
* Revision 1.6 1997/01/16 19:10:24 brianp
* kludged around a SunOS 5.x/GCC bug in write_hit_record()
*
* Revision 1.5 1996/12/13 21:03:19 brianp
* fixed feedback buffer overflow bug in write_hit_record()
*
* Revision 1.4 1996/10/22 22:58:25 brianp
* fixed bug in gl_update_hitflag() reported by Erich Eder
*
* Revision 1.3 1996/09/27 01:28:13 brianp
* added missing error check to gl_RenderMode()
*
* Revision 1.2 1996/09/15 14:17:30 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <assert.h>
#include <stdio.h>
#include "context.h"
#include "feedback.h"
#include "dlist.h"
#include "macros.h"
#include "types.h"
#endif
#define FB_3D 0x01
#define FB_4D 0x02
#define FB_INDEX 0x04
#define FB_COLOR 0x08
#define FB_TEXTURE 0X10
void
gl_FeedbackBuffer( GLcontext *ctx, GLsizei size, GLenum type, GLfloat *buffer )
{
if (ctx->RenderMode==GL_FEEDBACK || INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glFeedbackBuffer" );
return;
}
if (size<0) {
gl_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(size<0)" );
return;
}
if (!buffer) {
gl_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(buffer==NULL)" );
ctx->Feedback.BufferSize = 0;
return;
}
switch (type) {
case GL_2D:
ctx->Feedback.Mask = 0;
ctx->Feedback.Type = type;
break;
case GL_3D:
ctx->Feedback.Mask = FB_3D;
ctx->Feedback.Type = type;
break;
case GL_3D_COLOR:
ctx->Feedback.Mask = FB_3D
| (ctx->Visual->RGBAflag ? FB_COLOR : FB_INDEX);
ctx->Feedback.Type = type;
break;
case GL_3D_COLOR_TEXTURE:
ctx->Feedback.Mask = FB_3D
| (ctx->Visual->RGBAflag ? FB_COLOR : FB_INDEX)
| FB_TEXTURE;
ctx->Feedback.Type = type;
break;
case GL_4D_COLOR_TEXTURE:
ctx->Feedback.Mask = FB_3D | FB_4D
| (ctx->Visual->RGBAflag ? FB_COLOR : FB_INDEX)
| FB_TEXTURE;
ctx->Feedback.Type = type;
break;
default:
ctx->Feedback.Mask = 0;
gl_error( ctx, GL_INVALID_ENUM, "glFeedbackBuffer" );
}
ctx->Feedback.BufferSize = size;
ctx->Feedback.Buffer = buffer;
ctx->Feedback.Count = 0;
}
void gl_PassThrough( GLcontext *ctx, GLfloat token )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glPassThrough" );
return;
}
if (ctx->RenderMode==GL_FEEDBACK) {
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_PASS_THROUGH_TOKEN );
FEEDBACK_TOKEN( ctx, token );
}
}
/*
* Put a vertex into the feedback buffer.
*/
void gl_feedback_vertex( GLcontext *ctx,
GLfloat x, GLfloat y, GLfloat z, GLfloat w,
const GLfloat color[4], GLfloat index,
const GLfloat texcoord[4] )
{
FEEDBACK_TOKEN( ctx, x );
FEEDBACK_TOKEN( ctx, y );
if (ctx->Feedback.Mask & FB_3D) {
FEEDBACK_TOKEN( ctx, z );
}
if (ctx->Feedback.Mask & FB_4D) {
FEEDBACK_TOKEN( ctx, w );
}
if (ctx->Feedback.Mask & FB_INDEX) {
FEEDBACK_TOKEN( ctx, index );
}
if (ctx->Feedback.Mask & FB_COLOR) {
FEEDBACK_TOKEN( ctx, color[0] );
FEEDBACK_TOKEN( ctx, color[1] );
FEEDBACK_TOKEN( ctx, color[2] );
FEEDBACK_TOKEN( ctx, color[3] );
}
if (ctx->Feedback.Mask & FB_TEXTURE) {
FEEDBACK_TOKEN( ctx, texcoord[0] );
FEEDBACK_TOKEN( ctx, texcoord[1] );
FEEDBACK_TOKEN( ctx, texcoord[2] );
FEEDBACK_TOKEN( ctx, texcoord[3] );
}
}
/**********************************************************************/
/* Selection */
/**********************************************************************/
/*
* NOTE: this function can't be put in a display list.
*/
void gl_SelectBuffer( GLcontext *ctx, GLsizei size, GLuint *buffer )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" );
}
if (ctx->RenderMode==GL_SELECT) {
gl_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" );
}
ctx->Select.Buffer = buffer;
ctx->Select.BufferSize = size;
ctx->Select.BufferCount = 0;
ctx->Select.HitFlag = GL_FALSE;
ctx->Select.HitMinZ = 1.0;
ctx->Select.HitMaxZ = 0.0;
}
void gl_InitNames( GLcontext *ctx )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glInitNames" );
}
ctx->Select.NameStackDepth = 0;
ctx->Select.HitFlag = GL_FALSE;
ctx->Select.HitMinZ = 1.0;
ctx->Select.HitMaxZ = 0.0;
}
#define WRITE_RECORD( CTX, V ) \
if (CTX->Select.BufferCount < CTX->Select.BufferSize) { \
CTX->Select.Buffer[CTX->Select.BufferCount] = (V); \
} \
CTX->Select.BufferCount++;
void gl_update_hitflag( GLcontext *ctx, GLfloat z )
{
ctx->Select.HitFlag = GL_TRUE;
if (z < ctx->Select.HitMinZ) {
ctx->Select.HitMinZ = z;
}
if (z > ctx->Select.HitMaxZ) {
ctx->Select.HitMaxZ = z;
}
}
static void write_hit_record( GLcontext *ctx )
{
GLuint i;
GLuint zmin, zmax, zscale = (~0u);
/* HitMinZ and HitMaxZ are in [0,1]. Multiply these values by */
/* 2^32-1 and round to nearest unsigned integer. */
assert( ctx != NULL ); /* this line magically fixes a SunOS 5.x/gcc bug */
zmin = (GLuint) ((GLfloat) zscale * ctx->Select.HitMinZ);
zmax = (GLuint) ((GLfloat) zscale * ctx->Select.HitMaxZ);
WRITE_RECORD( ctx, ctx->Select.NameStackDepth );
WRITE_RECORD( ctx, zmin );
WRITE_RECORD( ctx, zmax );
for (i=0;i<ctx->Select.NameStackDepth;i++) {
WRITE_RECORD( ctx, ctx->Select.NameStack[i] );
}
ctx->Select.Hits++;
ctx->Select.HitFlag = GL_FALSE;
ctx->Select.HitMinZ = 1.0;
ctx->Select.HitMaxZ = -1.0;
}
void gl_LoadName( GLcontext *ctx, GLuint name )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glLoadName" );
return;
}
if (ctx->RenderMode!=GL_SELECT) {
return;
}
if (ctx->Select.NameStackDepth==0) {
gl_error( ctx, GL_INVALID_OPERATION, "glLoadName" );
return;
}
if (ctx->Select.HitFlag) {
write_hit_record( ctx );
}
if (ctx->Select.NameStackDepth<MAX_NAME_STACK_DEPTH) {
ctx->Select.NameStack[ctx->Select.NameStackDepth-1] = name;
}
else {
ctx->Select.NameStack[MAX_NAME_STACK_DEPTH-1] = name;
}
}
void gl_PushName( GLcontext *ctx, GLuint name )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glPushName" );
return;
}
if (ctx->RenderMode!=GL_SELECT) {
return;
}
if (ctx->Select.HitFlag) {
write_hit_record( ctx );
}
if (ctx->Select.NameStackDepth<MAX_NAME_STACK_DEPTH) {
ctx->Select.NameStack[ctx->Select.NameStackDepth++] = name;
}
else {
gl_error( ctx, GL_STACK_OVERFLOW, "glPushName" );
}
}
void gl_PopName( GLcontext *ctx )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glPopName" );
return;
}
if (ctx->RenderMode!=GL_SELECT) {
return;
}
if (ctx->Select.HitFlag) {
write_hit_record( ctx );
}
if (ctx->Select.NameStackDepth>0) {
ctx->Select.NameStackDepth--;
}
else {
gl_error( ctx, GL_STACK_UNDERFLOW, "glPopName" );
}
}
/**********************************************************************/
/* Render Mode */
/**********************************************************************/
/*
* NOTE: this function can't be put in a display list.
*/
GLint gl_RenderMode( GLcontext *ctx, GLenum mode )
{
GLint result;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" );
}
switch (ctx->RenderMode) {
case GL_RENDER:
result = 0;
break;
case GL_SELECT:
if (ctx->Select.HitFlag) {
write_hit_record( ctx );
}
if (ctx->Select.BufferCount > ctx->Select.BufferSize) {
/* overflow */
#ifdef DEBUG
gl_warning(ctx, "Feedback buffer overflow");
#endif
result = -1;
}
else {
result = ctx->Select.Hits;
}
ctx->Select.BufferCount = 0;
ctx->Select.Hits = 0;
ctx->Select.NameStackDepth = 0;
break;
case GL_FEEDBACK:
if (ctx->Feedback.Count > ctx->Feedback.BufferSize) {
/* overflow */
result = -1;
}
else {
result = ctx->Feedback.Count;
}
ctx->Feedback.Count = 0;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glRenderMode" );
return 0;
}
switch (mode) {
case GL_RENDER:
break;
case GL_SELECT:
if (ctx->Select.BufferSize==0) {
/* haven't called glSelectBuffer yet */
gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" );
}
break;
case GL_FEEDBACK:
if (ctx->Feedback.BufferSize==0) {
/* haven't called glFeedbackBuffer yet */
gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" );
}
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glRenderMode" );
return 0;
}
ctx->RenderMode = mode;
ctx->NewState |= NEW_ALL;
return result;
}

View File

@@ -0,0 +1,75 @@
/* $Id: feedback.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: feedback.h,v $
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef FEEDBACK_H
#define FEEDBACK_H
#include "types.h"
#define FEEDBACK_TOKEN( CTX, T ) \
if (CTX->Feedback.Count < CTX->Feedback.BufferSize) { \
CTX->Feedback.Buffer[CTX->Feedback.Count] = (T); \
} \
CTX->Feedback.Count++;
extern void gl_feedback_vertex( GLcontext *ctx,
GLfloat x, GLfloat y, GLfloat z, GLfloat w,
const GLfloat color[4], GLfloat index,
const GLfloat texcoord[4] );
extern void gl_update_hitflag( GLcontext *ctx, GLfloat z );
extern void gl_PassThrough( GLcontext *ctx, GLfloat token );
extern void gl_FeedbackBuffer( GLcontext *ctx, GLsizei size,
GLenum type, GLfloat *buffer );
extern void gl_SelectBuffer( GLcontext *ctx, GLsizei size, GLuint *buffer );
extern void gl_InitNames( GLcontext *ctx );
extern void gl_LoadName( GLcontext *ctx, GLuint name );
extern void gl_PushName( GLcontext *ctx, GLuint name );
extern void gl_PopName( GLcontext *ctx );
extern GLint gl_RenderMode( GLcontext *ctx, GLenum mode );
#endif

57
dll/opengl/mesa/fixed.h Normal file
View File

@@ -0,0 +1,57 @@
/* $Id: fixed.h,v 1.2 1996/10/01 03:31:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef FIXED_H
#define FIXED_H
typedef int GLfixed;
#define FIXED_ONE 0x00000800
#define FIXED_HALF 0x00000400
#define FIXED_FRAC_MASK 0x000007FF
#define FIXED_INT_MASK (~FIXED_FRAC_MASK)
#define FIXED_EPSILON 1
#define FIXED_SCALE 2048.0f
#define FIXED_SHIFT 11
#define FloatToFixed(X) ((GLfixed) ((X) * FIXED_SCALE))
#define IntToFixed(I) ((I) << FIXED_SHIFT)
#define FixedToInt(X) ((X) >> FIXED_SHIFT)
#define FixedToUns(X) (((unsigned int)(X)) >> 11)
#define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
#define FixedFloor(X) ((X) & FIXED_INT_MASK)
/* 0.00048828125 = 1/FIXED_SCALE */
#define FixedToFloat(X) ((X) * 0.00048828125f)
#define PosFloatToFixed(X) FloatToFixed(X)
#define SignedFloatToFixed(X) FloatToFixed(X)
#endif

389
dll/opengl/mesa/fog.c Normal file
View File

@@ -0,0 +1,389 @@
/* $Id: fog.c,v 1.9 1997/07/24 01:25:01 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: fog.c,v $
* Revision 1.9 1997/07/24 01:25:01 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.8 1997/06/20 04:14:47 brianp
* changed color components from GLfixed to GLubyte
*
* Revision 1.7 1997/05/28 03:24:54 brianp
* added precompiled header (PCH) support
*
* Revision 1.6 1997/05/22 03:03:47 brianp
* don't apply fog to alpha values
*
* Revision 1.5 1997/04/20 20:28:49 brianp
* replaced abort() with gl_problem()
*
* Revision 1.4 1996/11/04 02:30:15 brianp
* optimized gl_fog_color_pixels() and gl_fog_index_pixels()
*
* Revision 1.3 1996/09/27 01:26:52 brianp
* added missing default cases to switches
*
* Revision 1.2 1996/09/15 14:17:30 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <math.h>
#include <stdlib.h>
#include "context.h"
#include "fog.h"
#include "dlist.h"
#include "macros.h"
#include "types.h"
#endif
void gl_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
{
GLenum m;
switch (pname) {
case GL_FOG_MODE:
m = (GLenum) (GLint) *params;
if (m==GL_LINEAR || m==GL_EXP || m==GL_EXP2) {
ctx->Fog.Mode = m;
}
else {
gl_error( ctx, GL_INVALID_ENUM, "glFog" );
}
break;
case GL_FOG_DENSITY:
if (*params<0.0) {
gl_error( ctx, GL_INVALID_VALUE, "glFog" );
}
else {
ctx->Fog.Density = *params;
}
break;
case GL_FOG_START:
#ifndef GL_VERSION_1_1
if (*params<0.0F) {
gl_error( ctx, GL_INVALID_VALUE, "glFog(GL_FOG_START)" );
return;
}
#endif
ctx->Fog.Start = *params;
break;
case GL_FOG_END:
#ifndef GL_VERSION_1_1
if (*params<0.0F) {
gl_error( ctx, GL_INVALID_VALUE, "glFog(GL_FOG_END)" );
return;
}
#endif
ctx->Fog.End = *params;
break;
case GL_FOG_INDEX:
ctx->Fog.Index = *params;
break;
case GL_FOG_COLOR:
ctx->Fog.Color[0] = params[0];
ctx->Fog.Color[1] = params[1];
ctx->Fog.Color[2] = params[2];
ctx->Fog.Color[3] = params[3];
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glFog" );
}
}
/*
* Compute the fogged color for an array of vertices.
* Input: n - number of vertices
* v - array of vertices
* color - the original vertex colors
* Output: color - the fogged colors
*/
void gl_fog_color_vertices( GLcontext *ctx,
GLuint n, GLfloat v[][4], GLubyte color[][4] )
{
GLuint i;
GLfloat d;
GLfloat fogr = ctx->Fog.Color[0] * ctx->Visual->RedScale;
GLfloat fogg = ctx->Fog.Color[1] * ctx->Visual->GreenScale;
GLfloat fogb = ctx->Fog.Color[2] * ctx->Visual->BlueScale;
GLfloat end = ctx->Fog.End;
switch (ctx->Fog.Mode) {
case GL_LINEAR:
d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
for (i=0;i<n;i++) {
GLfloat f = (end - ABSF(v[i][2])) * d;
f = CLAMP( f, 0.0F, 1.0F );
color[i][0] = f * color[i][0] + (1.0F-f) * fogr;
color[i][1] = f * color[i][1] + (1.0F-f) * fogg;
color[i][2] = f * color[i][2] + (1.0F-f) * fogb;
}
break;
case GL_EXP:
d = -ctx->Fog.Density;
for (i=0;i<n;i++) {
GLfloat f = exp( d * ABSF(v[i][2]) );
f = CLAMP( f, 0.0F, 1.0F );
color[i][0] = f * color[i][0] + (1.0F-f) * fogr;
color[i][1] = f * color[i][1] + (1.0F-f) * fogg;
color[i][2] = f * color[i][2] + (1.0F-f) * fogb;
}
break;
case GL_EXP2:
d = -(ctx->Fog.Density*ctx->Fog.Density);
for (i=0;i<n;i++) {
GLfloat z = ABSF(v[i][2]);
GLfloat f = exp( d * z*z );
f = CLAMP( f, 0.0F, 1.0F );
color[i][0] = f * color[i][0] + (1.0F-f) * fogr;
color[i][1] = f * color[i][1] + (1.0F-f) * fogg;
color[i][2] = f * color[i][2] + (1.0F-f) * fogb;
}
break;
default:
gl_problem(ctx, "Bad fog mode in gl_fog_color_vertices");
return;
}
}
/*
* Compute the fogged color indexes for an array of vertices.
* Input: n - number of vertices
* v - array of vertices
* In/Out: indx - array of vertex color indexes
*/
void gl_fog_index_vertices( GLcontext *ctx,
GLuint n, GLfloat v[][4], GLuint indx[] )
{
/* NOTE: the extensive use of casts generates better/faster code for MIPS */
switch (ctx->Fog.Mode) {
case GL_LINEAR:
{
GLfloat d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
GLfloat fogindex = ctx->Fog.Index;
GLfloat fogend = ctx->Fog.End;
GLuint i;
for (i=0;i<n;i++) {
GLfloat f = (fogend - ABSF(v[i][2])) * d;
f = CLAMP( f, 0.0F, 1.0F );
indx[i] = (GLint)
((GLfloat) (GLint) indx[i] + (1.0F-f) * fogindex);
}
}
break;
case GL_EXP:
{
GLfloat d = -ctx->Fog.Density;
GLfloat fogindex = ctx->Fog.Index;
GLuint i;
for (i=0;i<n;i++) {
GLfloat f = exp( d * ABSF(v[i][2]) );
f = CLAMP( f, 0.0F, 1.0F );
indx[i] = (GLint)
((GLfloat) (GLint) indx[i] + (1.0F-f) * fogindex);
}
}
break;
case GL_EXP2:
{
GLfloat d = -(ctx->Fog.Density*ctx->Fog.Density);
GLfloat fogindex = ctx->Fog.Index;
GLuint i;
for (i=0;i<n;i++) {
GLfloat z = ABSF(v[i][2]);
GLfloat f = exp( -d * z*z );
f = CLAMP( f, 0.0F, 1.0F );
indx[i] = (GLint)
((GLfloat) (GLint) indx[i] + (1.0F-f) * fogindex);
}
}
break;
default:
gl_problem(ctx, "Bad fog mode in gl_fog_index_vertices");
return;
}
}
/*
* Apply fog to an array of RGBA pixels.
* Input: n - number of pixels
* z - array of integer depth values
* red, green, blue, alpha - pixel colors
* Output: red, green, blue, alpha - fogged pixel colors
*/
void gl_fog_color_pixels( GLcontext *ctx,
GLuint n, const GLdepth z[], GLubyte red[],
GLubyte green[], GLubyte blue[], GLubyte alpha[] )
{
GLfloat c = ctx->ProjectionMatrix[10];
GLfloat d = ctx->ProjectionMatrix[14];
GLuint i;
GLfloat fog_red = ctx->Fog.Color[0] * ctx->Visual->RedScale;
GLfloat fog_green = ctx->Fog.Color[1] * ctx->Visual->GreenScale;
GLfloat fog_blue = ctx->Fog.Color[2] * ctx->Visual->BlueScale;
GLfloat tz = ctx->Viewport.Tz;
GLfloat szInv = 1.0F / ctx->Viewport.Sz;
switch (ctx->Fog.Mode) {
case GL_LINEAR:
{
GLfloat fogEnd = ctx->Fog.End;
GLfloat fogScale = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
for (i=0;i<n;i++) {
GLfloat ndcz = ((GLfloat) z[i] - tz) * szInv;
GLfloat eyez = -d / (c+ndcz);
GLfloat f, g;
if (eyez < 0.0) eyez = -eyez;
f = (fogEnd - eyez) * fogScale;
f = CLAMP( f, 0.0F, 1.0F );
g = 1.0F - f;
red[i] = (GLint) (f * (GLfloat) red[i] + g * fog_red);
green[i] = (GLint) (f * (GLfloat) green[i] + g * fog_green);
blue[i] = (GLint) (f * (GLfloat) blue[i] + g * fog_blue);
}
}
break;
case GL_EXP:
for (i=0;i<n;i++) {
GLfloat ndcz = ((GLfloat) z[i] - tz) * szInv;
GLfloat eyez = -d / (c+ndcz);
GLfloat f, g;
if (eyez < 0.0) eyez = -eyez;
f = exp( -ctx->Fog.Density * eyez );
f = CLAMP( f, 0.0F, 1.0F );
g = 1.0F - f;
red[i] = (GLint) (f * (GLfloat) red[i] + g * fog_red);
green[i] = (GLint) (f * (GLfloat) green[i] + g * fog_green);
blue[i] = (GLint) (f * (GLfloat) blue[i] + g * fog_blue);
}
break;
case GL_EXP2:
{
GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density;
for (i=0;i<n;i++) {
GLfloat ndcz = ((GLfloat) z[i] - tz) * szInv;
GLfloat eyez = -d / (c+ndcz);
GLfloat f, g;
if (eyez < 0.0) eyez = -eyez;
f = exp( negDensitySquared * eyez*eyez );
f = CLAMP( f, 0.0F, 1.0F );
g = 1.0F - f;
red[i] = (GLint) (f * (GLfloat) red[i] + g * fog_red);
green[i] = (GLint) (f * (GLfloat) green[i] + g * fog_green);
blue[i] = (GLint) (f * (GLfloat) blue[i] + g * fog_blue);
}
}
break;
default:
gl_problem(ctx, "Bad fog mode in gl_fog_color_pixels");
return;
}
}
/*
* Apply fog to an array of color index pixels.
* Input: n - number of pixels
* z - array of integer depth values
* index - pixel color indexes
* Output: index - fogged pixel color indexes
*/
void gl_fog_index_pixels( GLcontext *ctx,
GLuint n, const GLdepth z[], GLuint index[] )
{
GLfloat c = ctx->ProjectionMatrix[10];
GLfloat d = ctx->ProjectionMatrix[14];
GLuint i;
GLfloat tz = ctx->Viewport.Tz;
GLfloat szInv = 1.0F / ctx->Viewport.Sz;
switch (ctx->Fog.Mode) {
case GL_LINEAR:
{
GLfloat fogEnd = ctx->Fog.End;
GLfloat fogScale = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
for (i=0;i<n;i++) {
GLfloat ndcz = ((GLfloat) z[i] - tz) * szInv;
GLfloat eyez = -d / (c+ndcz);
GLfloat f;
if (eyez < 0.0) eyez = -eyez;
f = (fogEnd - eyez) * fogScale;
f = CLAMP( f, 0.0F, 1.0F );
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F-f) * ctx->Fog.Index);
}
}
break;
case GL_EXP:
for (i=0;i<n;i++) {
GLfloat ndcz = ((GLfloat) z[i] - tz) * szInv;
GLfloat eyez = -d / (c+ndcz);
GLfloat f;
if (eyez < 0.0) eyez = -eyez;
f = exp( -ctx->Fog.Density * eyez );
f = CLAMP( f, 0.0F, 1.0F );
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F-f) * ctx->Fog.Index);
}
break;
case GL_EXP2:
{
GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density;
for (i=0;i<n;i++) {
GLfloat ndcz = ((GLfloat) z[i] - tz) * szInv;
GLfloat eyez = -d / (c+ndcz);
GLfloat f;
if (eyez < 0.0) eyez = -eyez;
f = exp( negDensitySquared * eyez*eyez );
f = CLAMP( f, 0.0F, 1.0F );
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F-f) * ctx->Fog.Index);
}
}
break;
default:
gl_problem(ctx, "Bad fog mode in gl_fog_index_pixels");
return;
}
}

62
dll/opengl/mesa/fog.h Normal file
View File

@@ -0,0 +1,62 @@
/* $Id: fog.h,v 1.2 1997/06/20 04:14:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.3
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: fog.h,v $
* Revision 1.2 1997/06/20 04:14:47 brianp
* changed color components from GLfixed to GLubyte
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef FOG_H
#define FOG_H
#include "types.h"
extern void gl_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params );
extern void gl_fog_color_vertices( GLcontext *ctx, GLuint n,
GLfloat v[][4], GLubyte color[][4] );
extern void gl_fog_index_vertices( GLcontext *ctx, GLuint n,
GLfloat v[][4], GLuint indx[] );
extern void gl_fog_color_pixels( GLcontext *ctx,
GLuint n, const GLdepth z[],
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[] );
extern void gl_fog_index_pixels( GLcontext *ctx,
GLuint n, const GLdepth z[], GLuint indx[] );
#endif

3198
dll/opengl/mesa/get.c Normal file

File diff suppressed because it is too large Load Diff

49
dll/opengl/mesa/get.h Normal file
View File

@@ -0,0 +1,49 @@
/* $Id: get.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: get.h,v $
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef GET_H
#define GET_H
#include "types.h"
extern void gl_GetBooleanv( GLcontext *ctx, GLenum pname, GLboolean *params );
extern void gl_GetDoublev( GLcontext *ctx, GLenum pname, GLdouble *params );
extern void gl_GetFloatv( GLcontext *ctx, GLenum pname, GLfloat *params );
extern void gl_GetIntegerv( GLcontext *ctx, GLenum pname, GLint *params );
#endif

302
dll/opengl/mesa/hash.c Normal file
View File

@@ -0,0 +1,302 @@
/* $Id: hash.c,v 1.4 1998/02/07 14:25:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: hash.c,v $
* Revision 1.4 1998/02/07 14:25:12 brianp
* fixed small Sun compiler warning (John Stone)
*
* Revision 1.3 1997/09/22 02:33:07 brianp
* added HashRemove() and HashFirstEntry()
*
* Revision 1.2 1997/09/03 13:13:45 brianp
* added a few pointer casts
*
* Revision 1.1 1997/08/22 01:15:10 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "hash.h"
#endif
/*
* Generic hash table. Only dependency is the GLuint datatype.
*
* This is used to implement display list and texture object lookup.
* NOTE: key=0 is illegal.
*/
#define TABLE_SIZE 1001
struct HashEntry {
GLuint Key;
void *Data;
struct HashEntry *Next;
};
struct HashTable {
struct HashEntry *Table[TABLE_SIZE];
GLuint MaxKey;
};
/*
* Return pointer to a new, empty hash table.
*/
struct HashTable *NewHashTable(void)
{
return (struct HashTable *) calloc(sizeof (struct HashTable), 1);
}
/*
* Delete a hash table.
*/
void DeleteHashTable(struct HashTable *table)
{
GLuint i;
assert(table);
for (i=0;i<TABLE_SIZE;i++) {
struct HashEntry *entry = table->Table[i];
while (entry) {
struct HashEntry *next = entry->Next;
free(entry);
entry = next;
}
}
free(table);
}
/*
* Lookup an entry in the hash table.
* Input: table - the hash table
* key - the key
* Return: user data pointer or NULL if key not in table
*/
void *HashLookup(const struct HashTable *table, GLuint key)
{
GLuint pos;
struct HashEntry *entry;
assert(table);
assert(key);
pos = key % TABLE_SIZE;
entry = table->Table[pos];
while (entry) {
if (entry->Key == key) {
return entry->Data;
}
entry = entry->Next;
}
return NULL;
}
/*
* Insert into the hash table. If an entry with this key already exists
* we'll replace the existing entry.
* Input: table - the hash table
* key - the key (not zero)
* data - pointer to user data
*/
void HashInsert(struct HashTable *table, GLuint key, void *data)
{
/* search for existing entry with this key */
GLuint pos;
struct HashEntry *entry;
assert(table);
assert(key);
if (key > table->MaxKey)
table->MaxKey = key;
pos = key % TABLE_SIZE;
entry = table->Table[pos];
while (entry) {
if (entry->Key == key) {
/* replace entry's data */
entry->Data = data;
return;
}
entry = entry->Next;
}
/* alloc and insert new table entry */
entry = (struct HashEntry *) calloc(sizeof(struct HashEntry), 1);
entry->Key = key;
entry->Data = data;
entry->Next = table->Table[pos];
table->Table[pos] = entry;
}
/*
* Remove an entry from the hash table.
* Input: table - the hash table
* key - key of entry to remove
*/
void HashRemove(struct HashTable *table, GLuint key)
{
GLuint pos;
struct HashEntry *entry, *prev;
assert(table);
assert(key);
pos = key % TABLE_SIZE;
prev = NULL;
entry = table->Table[pos];
while (entry) {
if (entry->Key == key) {
/* found it! */
if (prev) {
prev->Next = entry->Next;
}
else {
table->Table[pos] = entry->Next;
}
free(entry);
return;
}
prev = entry;
entry = entry->Next;
}
}
/*
* Return the key of the "first" entry in the hash table.
* By calling this function until zero is returned we can get
* the keys of all entries in the table.
*/
GLuint HashFirstEntry(const struct HashTable *table)
{
GLuint pos;
assert(table);
for (pos=0; pos < TABLE_SIZE; pos++) {
if (table->Table[pos])
return table->Table[pos]->Key;
}
return 0;
}
/*
* Dump contents of hash table for debugging.
*/
void HashPrint(const struct HashTable *table)
{
GLuint i;
assert(table);
for (i=0;i<TABLE_SIZE;i++) {
struct HashEntry *entry = table->Table[i];
while (entry) {
printf("%u %p\n", entry->Key, entry->Data);
entry = entry->Next;
}
}
}
/*
* Find a block of 'numKeys' adjacent unused hash keys.
* Input: table - the hash table
* numKeys - number of keys needed
* Return: startint key of free block or 0 if failure
*/
GLuint HashFindFreeKeyBlock(const struct HashTable *table, GLuint numKeys)
{
GLuint maxKey = ~((GLuint) 0);
if (maxKey - numKeys > table->MaxKey) {
/* the quick solution */
return table->MaxKey + 1;
}
else {
/* the slow solution */
GLuint freeCount = 0;
GLuint freeStart = 0;
GLuint key;
for (key=0; key!=maxKey; key++) {
if (HashLookup(table, key)) {
/* darn, this key is already in use */
freeCount = 0;
freeStart = key+1;
}
else {
/* this key not in use, check if we've found enough */
freeCount++;
if (freeCount == numKeys) {
return freeStart;
}
}
}
/* cannot allocate a block of numKeys consecutive keys */
return 0;
}
}
#ifdef HASH_TEST_HARNESS
int main(int argc, char *argv[])
{
int a, b, c;
struct HashTable *t;
printf("&a = %p\n", &a);
printf("&b = %p\n", &b);
t = NewHashTable();
HashInsert(t, 501, &a);
HashInsert(t, 10, &c);
HashInsert(t, 0xfffffff8, &b);
HashPrint(t);
printf("Find 501: %p\n", HashLookup(t,501));
printf("Find 1313: %p\n", HashLookup(t,1313));
printf("Find block of 100: %d\n", HashFindFreeKeyBlock(t, 100));
DeleteHashTable(t);
return 0;
}
#endif

63
dll/opengl/mesa/hash.h Normal file
View File

@@ -0,0 +1,63 @@
/* $Id: hash.h,v 1.2 1997/09/22 02:33:07 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: hash.h,v $
* Revision 1.2 1997/09/22 02:33:07 brianp
* added HashRemove() and HashFirstEntry()
*
* Revision 1.1 1997/08/22 01:15:10 brianp
* Initial revision
*
*/
#ifndef HASH_H
#define HASH_H
#include "GL/gl.h"
struct HashTable;
extern struct HashTable *NewHashTable(void);
extern void DeleteHashTable(struct HashTable *table);
extern void *HashLookup(const struct HashTable *table, GLuint key);
extern void HashInsert(struct HashTable *table, GLuint key, void *data);
extern void HashRemove(struct HashTable *table, GLuint key);
extern GLuint HashFirstEntry(const struct HashTable *table);
extern void HashPrint(const struct HashTable *table);
extern GLuint HashFindFreeKeyBlock(const struct HashTable *table, GLuint numKeys);
#endif

667
dll/opengl/mesa/image.c Normal file
View File

@@ -0,0 +1,667 @@
/* $Id: image.c,v 1.19 1997/11/07 03:49:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: image.c,v $
* Revision 1.19 1997/11/07 03:49:04 brianp
* more error checking work (but more to be done)
*
* Revision 1.18 1997/11/02 20:19:47 brianp
* added more error checking to gl_unpack_image3D()
*
* Revision 1.17 1997/10/16 01:04:51 brianp
* added code to normalize color, depth values in gl_unpack_image3d()
*
* Revision 1.16 1997/09/27 00:15:39 brianp
* changed parameters to gl_unpack_image()
*
* Revision 1.15 1997/08/11 01:23:10 brianp
* added a pointer cast
*
* Revision 1.14 1997/07/24 01:25:18 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.13 1997/05/28 03:25:26 brianp
* added precompiled header (PCH) support
*
* Revision 1.12 1997/04/29 01:26:25 brianp
* added #include "context.h"
*
* Revision 1.11 1997/04/20 20:28:49 brianp
* replaced abort() with gl_problem()
*
* Revision 1.10 1997/04/06 17:49:32 brianp
* image reference count wasn't always initialized to zero (Christopher Lloyd)
*
* Revision 1.9 1997/02/09 20:05:03 brianp
* new arguments for gl_pixel_addr_in_image()
*
* Revision 1.8 1997/02/09 18:52:53 brianp
* added GL_EXT_texture3D support
*
* Revision 1.7 1997/01/09 21:25:54 brianp
* initialize image reference count to zero
*
* Revision 1.6 1996/11/13 03:58:31 brianp
* fixed undefined "format" variable in gl_unpack_image()
*
* Revision 1.5 1996/11/10 17:48:03 brianp
* check if format is GL_DEPTH_COMPONENT or GL_STENCIL_COMPONENT
*
* Revision 1.4 1996/11/06 04:23:01 brianp
* changed gl_unpack_image() components argument to srcFormat
*
* Revision 1.3 1996/09/27 01:27:10 brianp
* removed unused variables
*
* Revision 1.2 1996/09/26 22:35:10 brianp
* fixed a few compiler warnings from IRIX 6 -n32 and -64 compiler
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "context.h"
#include "image.h"
#include "macros.h"
#include "pixel.h"
#include "types.h"
#endif
/*
* Flip the 8 bits in each byte of the given array.
*/
void gl_flip_bytes( GLubyte *p, GLuint n )
{
register GLuint i, a, b;
for (i=0;i<n;i++) {
b = (GLuint) p[i];
a = ((b & 0x01) << 7) |
((b & 0x02) << 5) |
((b & 0x04) << 3) |
((b & 0x08) << 1) |
((b & 0x10) >> 1) |
((b & 0x20) >> 3) |
((b & 0x40) >> 5) |
((b & 0x80) >> 7);
p[i] = (GLubyte) a;
}
}
/*
* Flip the order of the 2 bytes in each word in the given array.
*/
void gl_swap2( GLushort *p, GLuint n )
{
register GLuint i;
for (i=0;i<n;i++) {
p[i] = (p[i] >> 8) | ((p[i] << 8) & 0xff00);
}
}
/*
* Flip the order of the 4 bytes in each word in the given array.
*/
void gl_swap4( GLuint *p, GLuint n )
{
register GLuint i, a, b;
for (i=0;i<n;i++) {
b = p[i];
a = (b >> 24)
| ((b >> 8) & 0xff00)
| ((b << 8) & 0xff0000)
| ((b << 24) & 0xff000000);
p[i] = a;
}
}
/*
* Return the size, in bytes, of the given GL datatype.
* Return 0 if GL_BITMAP.
* Return -1 if invalid type enum.
*/
GLint gl_sizeof_type( GLenum type )
{
switch (type) {
case GL_BITMAP:
return 0;
case GL_UNSIGNED_BYTE:
return sizeof(GLubyte);
case GL_BYTE:
return sizeof(GLbyte);
case GL_UNSIGNED_SHORT:
return sizeof(GLushort);
case GL_SHORT:
return sizeof(GLshort);
case GL_UNSIGNED_INT:
return sizeof(GLuint);
case GL_INT:
return sizeof(GLint);
case GL_FLOAT:
return sizeof(GLfloat);
default:
return -1;
}
}
/*
* Return the number of components in a GL enum pixel type.
* Return -1 if bad format.
*/
GLint gl_components_in_format( GLenum format )
{
switch (format) {
case GL_COLOR_INDEX:
case GL_STENCIL_INDEX:
case GL_DEPTH_COMPONENT:
case GL_RED:
case GL_GREEN:
case GL_BLUE:
case GL_ALPHA:
case GL_LUMINANCE:
return 1;
case GL_LUMINANCE_ALPHA:
return 2;
case GL_RGB:
case GL_BGR_EXT:
return 3;
case GL_RGBA:
case GL_BGRA_EXT:
return 4;
default:
return -1;
}
}
/*
* Return the address of a pixel in an image (actually a volume).
* Pixel unpacking/packing parameters are observed according to 'packing'.
* Input: image - start of image data
* width, height - size of image
* format - image format
* type - pixel component type
* packing - GL_TRUE = use packing params
* GL_FALSE = use unpacking params.
* img - which image in the volume (0 for 2-D images)
* row, column - location of pixel in the image
* Return: address of pixel at (image,row,column) in image or NULL if error.
*/
GLvoid *gl_pixel_addr_in_image( struct gl_pixelstore_attrib *packing,
const GLvoid *image, GLsizei width,
GLsizei height, GLenum format, GLenum type,
GLint row)
{
GLint bytes_per_comp; /* bytes per component */
GLint comp_per_pixel; /* components per pixel */
GLint comps_per_row; /* components per row */
GLint pixels_per_row; /* pixels per row */
GLint alignment; /* 1, 2 or 4 */
GLint skiprows;
GLint skippixels;
GLubyte *pixel_addr;
/* Compute bytes per component */
bytes_per_comp = gl_sizeof_type( type );
if (bytes_per_comp<0) {
return NULL;
}
/* Compute number of components per pixel */
comp_per_pixel = gl_components_in_format( format );
if (comp_per_pixel<0) {
return NULL;
}
alignment = packing->Alignment;
if (packing->RowLength>0) {
pixels_per_row = packing->RowLength;
}
else {
pixels_per_row = width;
}
skiprows = packing->SkipRows;
skippixels = packing->SkipPixels;
if (type==GL_BITMAP) {
/* BITMAP data */
GLint bytes_per_row;
bytes_per_row = alignment
* CEILING( comp_per_pixel*pixels_per_row, 8*alignment );
pixel_addr = (GLubyte *) image
+ (skiprows + row) * bytes_per_row
+ (skippixels) / 8;
}
else {
/* Non-BITMAP data */
if (bytes_per_comp>=alignment) {
comps_per_row = comp_per_pixel * pixels_per_row;
}
else {
GLint bytes_per_row = bytes_per_comp * comp_per_pixel
* pixels_per_row;
comps_per_row = alignment / bytes_per_comp
* CEILING( bytes_per_row, alignment );
}
/* Copy/unpack pixel data to buffer */
pixel_addr = (GLubyte *) image
+ (skiprows + row) * bytes_per_comp * comps_per_row
+ (skippixels) * bytes_per_comp * comp_per_pixel;
}
return (GLvoid *) pixel_addr;
}
/*
* Unpack a 2-D image from user-supplied address, returning a pointer to
* a new gl_image struct.
*
* Input: width, height - size in pixels
* srcFormat - format of incoming pixel data, ignored if
* srcType BITMAP.
* srcType - GL_UNSIGNED_BYTE .. GL_FLOAT
* pixels - pointer to unpacked image in client memory space.
*/
struct gl_image *gl_unpack_image( GLcontext *ctx,
GLint width, GLint height,
GLenum srcFormat, GLenum srcType,
const GLvoid *pixels )
{
GLint components;
GLenum destType;
if (srcType==GL_UNSIGNED_BYTE) {
destType = GL_UNSIGNED_BYTE;
}
else if (srcType==GL_BITMAP) {
destType = GL_BITMAP;
}
else {
destType = GL_FLOAT;
}
components = gl_components_in_format( srcFormat );
if (components < 0)
return NULL;
if (srcType==GL_BITMAP || destType==GL_BITMAP) {
struct gl_image *image;
GLint bytes, i, width_in_bytes;
GLubyte *buffer, *dst;
assert( srcType==GL_BITMAP );
assert( destType==GL_BITMAP );
/* Alloc dest storage */
if (width > 0 && height > 0)
bytes = ((width+7)/8 * height);
else
bytes = 0;
if (bytes>0 && pixels!=NULL) {
buffer = (GLubyte *) malloc( bytes );
if (!buffer) {
return NULL;
}
/* Copy/unpack pixel data to buffer */
width_in_bytes = CEILING( width, 8 );
dst = buffer;
for (i=0; i<height; i++) {
GLvoid *src = gl_pixel_addr_in_image( &ctx->Unpack, pixels,
width, height,
GL_COLOR_INDEX, srcType,
i);
if (!src) {
free(buffer);
return NULL;
}
MEMCPY( dst, src, width_in_bytes );
dst += width_in_bytes;
}
/* Bit flipping */
if (ctx->Unpack.LsbFirst) {
gl_flip_bytes( buffer, bytes );
}
}
else {
/* a 'null' bitmap */
buffer = NULL;
}
image = (struct gl_image *) malloc( sizeof(struct gl_image) );
if (image) {
image->Width = width;
image->Height = height;
image->Components = 0;
image->Format = GL_COLOR_INDEX;
image->Type = GL_BITMAP;
image->Data = buffer;
image->RefCount = 0;
}
else {
if (buffer)
free( buffer );
return NULL;
}
return image;
}
else if (srcFormat==GL_DEPTH_COMPONENT) {
/* TODO: pack as GLdepth values (GLushort or GLuint) */
}
else if (srcFormat==GL_STENCIL_INDEX) {
/* TODO: pack as GLstencil (GLubyte or GLushort) */
}
else if (destType==GL_UNSIGNED_BYTE) {
struct gl_image *image;
GLint width_in_bytes;
GLubyte *buffer, *dst;
GLint i;
assert( srcType==GL_UNSIGNED_BYTE );
width_in_bytes = width * components * sizeof(GLubyte);
buffer = (GLubyte *) malloc( height * width_in_bytes );
if (!buffer) {
return NULL;
}
/* Copy/unpack pixel data to buffer */
dst = buffer;
for (i=0;i<height;i++) {
GLubyte *src = (GLubyte *) gl_pixel_addr_in_image( &ctx->Unpack,
pixels, width, height, srcFormat, srcType, i);
if (!src) {
free(buffer);
return NULL;
}
MEMCPY( dst, src, width_in_bytes );
dst += width_in_bytes;
}
if (ctx->Unpack.LsbFirst) {
gl_flip_bytes( buffer, height * width_in_bytes );
}
image = (struct gl_image *) malloc( sizeof(struct gl_image) );
if (image) {
image->Width = width;
image->Height = height;
image->Components = components;
image->Format = srcFormat;
image->Type = GL_UNSIGNED_BYTE;
image->Data = buffer;
image->RefCount = 0;
}
else {
free( buffer );
return NULL;
}
return image;
}
else if (destType==GL_FLOAT) {
struct gl_image *image;
GLfloat *buffer, *dst;
GLint elems_per_row;
GLint i, j;
GLboolean normalize;
elems_per_row = width * components;
buffer = (GLfloat *) malloc( height * elems_per_row * sizeof(GLfloat));
if (!buffer) {
return NULL;
}
normalize = (srcFormat != GL_COLOR_INDEX)
&& (srcFormat != GL_STENCIL_INDEX);
dst = buffer;
/** img_pixels= pixels;*/
for (i=0;i<height;i++) {
GLvoid *src = gl_pixel_addr_in_image( &ctx->Unpack, pixels,
width, height,
srcFormat, srcType,
i);
if (!src) {
free(buffer);
return NULL;
}
switch (srcType) {
case GL_UNSIGNED_BYTE:
if (normalize) {
for (j=0;j<elems_per_row;j++) {
*dst++ = UBYTE_TO_FLOAT(((GLubyte*)src)[j]);
}
}
else {
for (j=0;j<elems_per_row;j++) {
*dst++ = (GLfloat) ((GLubyte*)src)[j];
}
}
break;
case GL_BYTE:
if (normalize) {
for (j=0;j<elems_per_row;j++) {
*dst++ = BYTE_TO_FLOAT(((GLbyte*)src)[j]);
}
}
else {
for (j=0;j<elems_per_row;j++) {
*dst++ = (GLfloat) ((GLbyte*)src)[j];
}
}
break;
case GL_UNSIGNED_SHORT:
if (ctx->Unpack.SwapBytes) {
for (j=0;j<elems_per_row;j++) {
GLushort value = ((GLushort*)src)[j];
value = ((value >> 8) & 0xff) | ((value&0xff) << 8);
if (normalize) {
*dst++ = USHORT_TO_FLOAT(value);
}
else {
*dst++ = (GLfloat) value;
}
}
}
else {
if (normalize) {
for (j=0;j<elems_per_row;j++) {
*dst++ = USHORT_TO_FLOAT(((GLushort*)src)[j]);
}
}
else {
for (j=0;j<elems_per_row;j++) {
*dst++ = (GLfloat) ((GLushort*)src)[j];
}
}
}
break;
case GL_SHORT:
if (ctx->Unpack.SwapBytes) {
for (j=0;j<elems_per_row;j++) {
GLshort value = ((GLshort*)src)[j];
value = ((value >> 8) & 0xff) | ((value&0xff) << 8);
if (normalize) {
*dst++ = SHORT_TO_FLOAT(value);
}
else {
*dst++ = (GLfloat) value;
}
}
}
else {
if (normalize) {
for (j=0;j<elems_per_row;j++) {
*dst++ = SHORT_TO_FLOAT(((GLshort*)src)[j]);
}
}
else {
for (j=0;j<elems_per_row;j++) {
*dst++ = (GLfloat) ((GLshort*)src)[j];
}
}
}
break;
case GL_UNSIGNED_INT:
if (ctx->Unpack.SwapBytes) {
GLuint value;
for (j=0;j<elems_per_row;j++) {
value = ((GLuint*)src)[j];
value = ((value & 0xff000000) >> 24)
| ((value & 0x00ff0000) >> 8)
| ((value & 0x0000ff00) << 8)
| ((value & 0x000000ff) << 24);
if (normalize) {
*dst++ = UINT_TO_FLOAT(value);
}
else {
*dst++ = (GLfloat) value;
}
}
}
else {
if (normalize) {
for (j=0;j<elems_per_row;j++) {
*dst++ = UINT_TO_FLOAT(((GLuint*)src)[j]);
}
}
else {
for (j=0;j<elems_per_row;j++) {
*dst++ = (GLfloat) ((GLuint*)src)[j];
}
}
}
break;
case GL_INT:
if (ctx->Unpack.SwapBytes) {
GLint value;
for (j=0;j<elems_per_row;j++) {
value = ((GLint*)src)[j];
value = ((value & 0xff000000) >> 24)
| ((value & 0x00ff0000) >> 8)
| ((value & 0x0000ff00) << 8)
| ((value & 0x000000ff) << 24);
if (normalize) {
*dst++ = INT_TO_FLOAT(value);
}
else {
*dst++ = (GLfloat) value;
}
}
}
else {
if (normalize) {
for (j=0;j<elems_per_row;j++) {
*dst++ = INT_TO_FLOAT(((GLint*)src)[j]);
}
}
else {
for (j=0;j<elems_per_row;j++) {
*dst++ = (GLfloat) ((GLint*)src)[j];
}
}
}
break;
case GL_FLOAT:
if (ctx->Unpack.SwapBytes) {
GLint value;
for (j=0;j<elems_per_row;j++) {
value = ((GLuint*)src)[j];
value = ((value & 0xff000000) >> 24)
| ((value & 0x00ff0000) >> 8)
| ((value & 0x0000ff00) << 8)
| ((value & 0x000000ff) << 24);
*dst++ = *((GLfloat*) &value);
}
}
else {
MEMCPY( dst, src, elems_per_row*sizeof(GLfloat) );
dst += elems_per_row;
}
break;
default:
gl_problem(ctx, "Bad type in gl_unpack_image3D");
return NULL;
} /*switch*/
} /* for height */
image = (struct gl_image *) malloc( sizeof(struct gl_image) );
if (image) {
image->Width = width;
image->Height = height;
image->Components = components;
image->Format = srcFormat;
image->Type = GL_FLOAT;
image->Data = buffer;
image->RefCount = 0;
}
else {
free( buffer );
return NULL;
}
return image;
}
else {
gl_problem(ctx, "Bad dest type in gl_unpack_image3D");
return NULL;
}
return NULL; /* never get here */
}
void gl_free_image( struct gl_image *image )
{
if (image->Data) {
free(image->Data);
}
free(image);
}

80
dll/opengl/mesa/image.h Normal file
View File

@@ -0,0 +1,80 @@
/* $Id: image.h,v 1.5 1997/09/27 00:15:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.5
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: image.h,v $
* Revision 1.5 1997/09/27 00:15:39 brianp
* changed parameters to gl_unpack_image()
*
* Revision 1.4 1997/02/09 20:05:03 brianp
* new arguments for gl_pixel_addr_in_image()
*
* Revision 1.3 1997/02/09 18:52:53 brianp
* added GL_EXT_texture3D support
*
* Revision 1.2 1996/11/06 04:22:23 brianp
* changed gl_unpack_image() components argument to srcFormat
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef IMAGE_H
#define IMAGE_H
#include "types.h"
extern void gl_flip_bytes( GLubyte *p, GLuint n );
extern void gl_swap2( GLushort *p, GLuint n );
extern void gl_swap4( GLuint *p, GLuint n );
extern GLint gl_sizeof_type( GLenum type );
extern GLint gl_components_in_format( GLenum format );
extern GLvoid *gl_pixel_addr_in_image( struct gl_pixelstore_attrib *packing,
const GLvoid *image, GLsizei width,
GLsizei height, GLenum format, GLenum type,
GLint row);
extern struct gl_image *gl_unpack_image( GLcontext *ctx,
GLint width, GLint height,
GLenum srcFormat, GLenum srcType,
const GLvoid *pixels );
extern void gl_free_image( struct gl_image *image );
#endif

888
dll/opengl/mesa/light.c Normal file
View File

@@ -0,0 +1,888 @@
/* $Id: light.c,v 1.14 1997/07/24 01:24:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: light.c,v $
* Revision 1.14 1997/07/24 01:24:11 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.13 1997/06/20 04:15:43 brianp
* optimized changing of SHININESS (Henk Kok)
*
* Revision 1.12 1997/05/28 03:25:26 brianp
* added precompiled header (PCH) support
*
* Revision 1.11 1997/05/01 01:38:57 brianp
* now use NORMALIZE_3FV() macro from mmath.h
*
* Revision 1.10 1997/04/20 20:28:49 brianp
* replaced abort() with gl_problem()
*
* Revision 1.9 1997/04/07 02:59:17 brianp
* small optimization to setting of shininess and spot exponent
*
* Revision 1.8 1997/04/01 04:09:31 brianp
* misc code clean-ups. moved shading code to shade.c
*
* Revision 1.7 1997/03/11 00:37:39 brianp
* spotlight factor now effects ambient lighting
*
* Revision 1.6 1996/12/18 20:02:07 brianp
* glColorMaterial() and glMaterial() should finally work right!
*
* Revision 1.5 1996/12/07 10:22:41 brianp
* gl_Materialfv() now calls gl_set_material() if GL_COLOR_MATERIAL disabled
* implemented gl_GetLightiv()
*
* Revision 1.4 1996/11/08 04:39:23 brianp
* new gl_compute_spot_exp_table() contributed by Randy Frank
*
* Revision 1.3 1996/09/27 01:27:55 brianp
* removed unused variables
*
* Revision 1.2 1996/09/15 14:18:10 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <assert.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include "context.h"
#include "light.h"
#include "dlist.h"
#include "macros.h"
#include "matrix.h"
#include "mmath.h"
#include "types.h"
#include "vb.h"
#include "xform.h"
#endif
void gl_ShadeModel( GLcontext *ctx, GLenum mode )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glShadeModel" );
return;
}
switch (mode) {
case GL_FLAT:
case GL_SMOOTH:
if (ctx->Light.ShadeModel!=mode) {
ctx->Light.ShadeModel = mode;
ctx->NewState |= NEW_RASTER_OPS;
}
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glShadeModel" );
}
}
void gl_Lightfv( GLcontext *ctx,
GLenum light, GLenum pname, const GLfloat *params,
GLint nparams )
{
GLint l;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glShadeModel" );
return;
}
l = (GLint) (light - GL_LIGHT0);
if (l<0 || l>=MAX_LIGHTS) {
gl_error( ctx, GL_INVALID_ENUM, "glLight" );
return;
}
switch (pname) {
case GL_AMBIENT:
COPY_4V( ctx->Light.Light[l].Ambient, params );
break;
case GL_DIFFUSE:
COPY_4V( ctx->Light.Light[l].Diffuse, params );
break;
case GL_SPECULAR:
COPY_4V( ctx->Light.Light[l].Specular, params );
break;
case GL_POSITION:
/* transform position by ModelView matrix */
TRANSFORM_POINT( ctx->Light.Light[l].Position, ctx->ModelViewMatrix,
params );
break;
case GL_SPOT_DIRECTION:
/* transform direction by inverse modelview */
{
GLfloat direction[4];
direction[0] = params[0];
direction[1] = params[1];
direction[2] = params[2];
direction[3] = 0.0;
if (ctx->NewModelViewMatrix) {
gl_analyze_modelview_matrix( ctx );
}
gl_transform_vector( ctx->Light.Light[l].Direction,
direction, ctx->ModelViewInv);
}
break;
case GL_SPOT_EXPONENT:
if (params[0]<0.0 || params[0]>128.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLight" );
return;
}
if (ctx->Light.Light[l].SpotExponent != params[0]) {
ctx->Light.Light[l].SpotExponent = params[0];
gl_compute_spot_exp_table( &ctx->Light.Light[l] );
}
break;
case GL_SPOT_CUTOFF:
if ((params[0]<0.0 || params[0]>90.0) && params[0]!=180.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLight" );
return;
}
ctx->Light.Light[l].SpotCutoff = params[0];
ctx->Light.Light[l].CosCutoff = cos(params[0]*DEG2RAD);
break;
case GL_CONSTANT_ATTENUATION:
if (params[0]<0.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLight" );
return;
}
ctx->Light.Light[l].ConstantAttenuation = params[0];
break;
case GL_LINEAR_ATTENUATION:
if (params[0]<0.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLight" );
return;
}
ctx->Light.Light[l].LinearAttenuation = params[0];
break;
case GL_QUADRATIC_ATTENUATION:
if (params[0]<0.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLight" );
return;
}
ctx->Light.Light[l].QuadraticAttenuation = params[0];
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glLight" );
break;
}
ctx->NewState |= NEW_LIGHTING;
}
void gl_GetLightfv( GLcontext *ctx,
GLenum light, GLenum pname, GLfloat *params )
{
GLint l = (GLint) (light - GL_LIGHT0);
if (l<0 || l>=MAX_LIGHTS) {
gl_error( ctx, GL_INVALID_ENUM, "glGetLightfv" );
return;
}
switch (pname) {
case GL_AMBIENT:
COPY_4V( params, ctx->Light.Light[l].Ambient );
break;
case GL_DIFFUSE:
COPY_4V( params, ctx->Light.Light[l].Diffuse );
break;
case GL_SPECULAR:
COPY_4V( params, ctx->Light.Light[l].Specular );
break;
case GL_POSITION:
COPY_4V( params, ctx->Light.Light[l].Position );
break;
case GL_SPOT_DIRECTION:
COPY_3V( params, ctx->Light.Light[l].Direction );
break;
case GL_SPOT_EXPONENT:
params[0] = ctx->Light.Light[l].SpotExponent;
break;
case GL_SPOT_CUTOFF:
params[0] = ctx->Light.Light[l].SpotCutoff;
break;
case GL_CONSTANT_ATTENUATION:
params[0] = ctx->Light.Light[l].ConstantAttenuation;
break;
case GL_LINEAR_ATTENUATION:
params[0] = ctx->Light.Light[l].LinearAttenuation;
break;
case GL_QUADRATIC_ATTENUATION:
params[0] = ctx->Light.Light[l].QuadraticAttenuation;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glGetLightfv" );
break;
}
}
void gl_GetLightiv( GLcontext *ctx, GLenum light, GLenum pname, GLint *params )
{
GLint l = (GLint) (light - GL_LIGHT0);
if (l<0 || l>=MAX_LIGHTS) {
gl_error( ctx, GL_INVALID_ENUM, "glGetLightiv" );
return;
}
switch (pname) {
case GL_AMBIENT:
params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[0]);
params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[1]);
params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[2]);
params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[3]);
break;
case GL_DIFFUSE:
params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[0]);
params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[1]);
params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[2]);
params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[3]);
break;
case GL_SPECULAR:
params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[0]);
params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[1]);
params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[2]);
params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[3]);
break;
case GL_POSITION:
params[0] = ctx->Light.Light[l].Position[0];
params[1] = ctx->Light.Light[l].Position[1];
params[2] = ctx->Light.Light[l].Position[2];
params[3] = ctx->Light.Light[l].Position[3];
break;
case GL_SPOT_DIRECTION:
params[0] = ctx->Light.Light[l].Direction[0];
params[1] = ctx->Light.Light[l].Direction[1];
params[2] = ctx->Light.Light[l].Direction[2];
break;
case GL_SPOT_EXPONENT:
params[0] = ctx->Light.Light[l].SpotExponent;
break;
case GL_SPOT_CUTOFF:
params[0] = ctx->Light.Light[l].SpotCutoff;
break;
case GL_CONSTANT_ATTENUATION:
params[0] = ctx->Light.Light[l].ConstantAttenuation;
break;
case GL_LINEAR_ATTENUATION:
params[0] = ctx->Light.Light[l].LinearAttenuation;
break;
case GL_QUADRATIC_ATTENUATION:
params[0] = ctx->Light.Light[l].QuadraticAttenuation;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glGetLightiv" );
break;
}
}
/**********************************************************************/
/*** Light Model ***/
/**********************************************************************/
void gl_LightModelfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
{
switch (pname) {
case GL_LIGHT_MODEL_AMBIENT:
COPY_4V( ctx->Light.Model.Ambient, params );
break;
case GL_LIGHT_MODEL_LOCAL_VIEWER:
if (params[0]==0.0)
ctx->Light.Model.LocalViewer = GL_FALSE;
else
ctx->Light.Model.LocalViewer = GL_TRUE;
break;
case GL_LIGHT_MODEL_TWO_SIDE:
if (params[0]==0.0)
ctx->Light.Model.TwoSide = GL_FALSE;
else
ctx->Light.Model.TwoSide = GL_TRUE;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glLightModel" );
break;
}
ctx->NewState |= NEW_LIGHTING;
}
/********** MATERIAL **********/
/*
* Given a face and pname value (ala glColorMaterial), compute a bitmask
* of the targeted material values.
*/
GLuint gl_material_bitmask( GLenum face, GLenum pname )
{
GLuint bitmask = 0;
/* Make a bitmask indicating what material attribute(s) we're updating */
switch (pname) {
case GL_EMISSION:
bitmask |= FRONT_EMISSION_BIT | BACK_EMISSION_BIT;
break;
case GL_AMBIENT:
bitmask |= FRONT_AMBIENT_BIT | BACK_AMBIENT_BIT;
break;
case GL_DIFFUSE:
bitmask |= FRONT_DIFFUSE_BIT | BACK_DIFFUSE_BIT;
break;
case GL_SPECULAR:
bitmask |= FRONT_SPECULAR_BIT | BACK_SPECULAR_BIT;
break;
case GL_SHININESS:
bitmask |= FRONT_SHININESS_BIT | BACK_SHININESS_BIT;
break;
case GL_AMBIENT_AND_DIFFUSE:
bitmask |= FRONT_AMBIENT_BIT | BACK_AMBIENT_BIT;
bitmask |= FRONT_DIFFUSE_BIT | BACK_DIFFUSE_BIT;
break;
case GL_COLOR_INDEXES:
bitmask |= FRONT_INDEXES_BIT | BACK_INDEXES_BIT;
break;
default:
gl_problem(NULL, "Bad param in gl_material_bitmask");
return 0;
}
ASSERT( face==GL_FRONT || face==GL_BACK || face==GL_FRONT_AND_BACK );
if (face==GL_FRONT) {
bitmask &= FRONT_MATERIAL_BITS;
}
else if (face==GL_BACK) {
bitmask &= BACK_MATERIAL_BITS;
}
return bitmask;
}
/*
* This is called by glColor() when GL_COLOR_MATERIAL is enabled and
* called by glMaterial() when GL_COLOR_MATERIAL is disabled.
*/
void gl_set_material( GLcontext *ctx, GLuint bitmask, const GLfloat *params )
{
struct gl_material *mat;
if (INSIDE_BEGIN_END(ctx)) {
struct vertex_buffer *VB = ctx->VB;
/* Save per-vertex material changes in the Vertex Buffer.
* The update_material function will eventually update the global
* ctx->Light.Material values.
*/
mat = VB->Material[VB->Count];
VB->MaterialMask[VB->Count] |= bitmask;
VB->MonoMaterial = GL_FALSE;
}
else {
/* just update the global material property */
mat = ctx->Light.Material;
ctx->NewState |= NEW_LIGHTING;
}
if (bitmask & FRONT_AMBIENT_BIT) {
COPY_4V( mat[0].Ambient, params );
}
if (bitmask & BACK_AMBIENT_BIT) {
COPY_4V( mat[1].Ambient, params );
}
if (bitmask & FRONT_DIFFUSE_BIT) {
COPY_4V( mat[0].Diffuse, params );
}
if (bitmask & BACK_DIFFUSE_BIT) {
COPY_4V( mat[1].Diffuse, params );
}
if (bitmask & FRONT_SPECULAR_BIT) {
COPY_4V( mat[0].Specular, params );
}
if (bitmask & BACK_SPECULAR_BIT) {
COPY_4V( mat[1].Specular, params );
}
if (bitmask & FRONT_EMISSION_BIT) {
COPY_4V( mat[0].Emission, params );
}
if (bitmask & BACK_EMISSION_BIT) {
COPY_4V( mat[1].Emission, params );
}
if (bitmask & FRONT_SHININESS_BIT) {
GLfloat shininess = CLAMP( params[0], 0.0F, 128.0F );
if (mat[0].Shininess != shininess) {
mat[0].Shininess = shininess;
gl_compute_material_shine_table( &mat[0] );
}
}
if (bitmask & BACK_SHININESS_BIT) {
GLfloat shininess = CLAMP( params[0], 0.0F, 128.0F );
if (mat[1].Shininess != shininess) {
mat[1].Shininess = shininess;
gl_compute_material_shine_table( &mat[1] );
}
}
if (bitmask & FRONT_INDEXES_BIT) {
mat[0].AmbientIndex = params[0];
mat[0].DiffuseIndex = params[1];
mat[0].SpecularIndex = params[2];
}
if (bitmask & BACK_INDEXES_BIT) {
mat[1].AmbientIndex = params[0];
mat[1].DiffuseIndex = params[1];
mat[1].SpecularIndex = params[2];
}
}
void gl_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glColorMaterial" );
return;
}
switch (face) {
case GL_FRONT:
case GL_BACK:
case GL_FRONT_AND_BACK:
ctx->Light.ColorMaterialFace = face;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glColorMaterial(face)" );
return;
}
switch (mode) {
case GL_EMISSION:
case GL_AMBIENT:
case GL_DIFFUSE:
case GL_SPECULAR:
case GL_AMBIENT_AND_DIFFUSE:
ctx->Light.ColorMaterialMode = mode;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glColorMaterial(mode)" );
return;
}
ctx->Light.ColorMaterialBitmask = gl_material_bitmask( face, mode );
}
/*
* This is only called via the api_function_table struct or by the
* display list executor.
*/
void gl_Materialfv( GLcontext *ctx,
GLenum face, GLenum pname, const GLfloat *params )
{
GLuint bitmask;
/* error checking */
if (face!=GL_FRONT && face!=GL_BACK && face!=GL_FRONT_AND_BACK) {
gl_error( ctx, GL_INVALID_ENUM, "glMaterial(face)" );
return;
}
switch (pname) {
case GL_EMISSION:
case GL_AMBIENT:
case GL_DIFFUSE:
case GL_SPECULAR:
case GL_SHININESS:
case GL_AMBIENT_AND_DIFFUSE:
case GL_COLOR_INDEXES:
/* OK */
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glMaterial(pname)" );
return;
}
/* convert face and pname to a bitmask */
bitmask = gl_material_bitmask( face, pname );
if (ctx->Light.ColorMaterialEnabled) {
/* The material values specified by glColorMaterial() can't be */
/* updated by glMaterial() while GL_COLOR_MATERIAL is enabled! */
bitmask &= ~ctx->Light.ColorMaterialBitmask;
}
gl_set_material( ctx, bitmask, params );
}
void gl_GetMaterialfv( GLcontext *ctx,
GLenum face, GLenum pname, GLfloat *params )
{
GLuint f;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glGetMaterialfv" );
return;
}
if (face==GL_FRONT) {
f = 0;
}
else if (face==GL_BACK) {
f = 1;
}
else {
gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(face)" );
return;
}
switch (pname) {
case GL_AMBIENT:
COPY_4V( params, ctx->Light.Material[f].Ambient );
break;
case GL_DIFFUSE:
COPY_4V( params, ctx->Light.Material[f].Diffuse );
break;
case GL_SPECULAR:
COPY_4V( params, ctx->Light.Material[f].Specular );
break;
case GL_EMISSION:
COPY_4V( params, ctx->Light.Material[f].Emission );
break;
case GL_SHININESS:
*params = ctx->Light.Material[f].Shininess;
break;
case GL_COLOR_INDEXES:
params[0] = ctx->Light.Material[f].AmbientIndex;
params[1] = ctx->Light.Material[f].DiffuseIndex;
params[2] = ctx->Light.Material[f].SpecularIndex;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
}
}
void gl_GetMaterialiv( GLcontext *ctx,
GLenum face, GLenum pname, GLint *params )
{
GLuint f;
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glGetMaterialiv" );
return;
}
if (face==GL_FRONT) {
f = 0;
}
else if (face==GL_BACK) {
f = 1;
}
else {
gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialiv(face)" );
return;
}
switch (pname) {
case GL_AMBIENT:
params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[0] );
params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[1] );
params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[2] );
params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[3] );
break;
case GL_DIFFUSE:
params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[0] );
params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[1] );
params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[2] );
params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[3] );
break;
case GL_SPECULAR:
params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[0] );
params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[1] );
params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[2] );
params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[3] );
break;
case GL_EMISSION:
params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[0] );
params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[1] );
params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[2] );
params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[3] );
break;
case GL_SHININESS:
*params = ROUNDF( ctx->Light.Material[f].Shininess );
break;
case GL_COLOR_INDEXES:
params[0] = ROUNDF( ctx->Light.Material[f].AmbientIndex );
params[1] = ROUNDF( ctx->Light.Material[f].DiffuseIndex );
params[2] = ROUNDF( ctx->Light.Material[f].SpecularIndex );
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
}
}
/**********************************************************************/
/***** Lighting computation *****/
/**********************************************************************/
/*
* Notes:
* When two-sided lighting is enabled we compute the color (or index)
* for both the front and back side of the primitive. Then, when the
* orientation of the facet is later learned, we can determine which
* color (or index) to use for rendering.
*
* Variables:
* n = normal vector
* V = vertex position
* P = light source position
* Pe = (0,0,0,1)
*
* Precomputed:
* IF P[3]==0 THEN
* // light at infinity
* IF local_viewer THEN
* VP_inf_norm = unit vector from V to P // Precompute
* ELSE
* // eye at infinity
* h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute
* ENDIF
* ENDIF
*
* Functions:
* Normalize( v ) = normalized vector v
* Magnitude( v ) = length of vector v
*/
/*
* Whenever the spotlight exponent for a light changes we must call
* this function to recompute the exponent lookup table.
*/
void gl_compute_spot_exp_table( struct gl_light *l )
{
int i;
double exponent = l->SpotExponent;
double tmp;
int clamp = 0;
l->SpotExpTable[0][0] = 0.0;
for (i=EXP_TABLE_SIZE-1;i>0;i--) {
if (clamp == 0) {
tmp = pow(i/(double)(EXP_TABLE_SIZE-1), exponent);
if (tmp < FLT_MIN*100.0) {
tmp = 0.0;
clamp = 1;
}
}
l->SpotExpTable[i][0] = tmp;
}
for (i=0;i<EXP_TABLE_SIZE-1;i++) {
l->SpotExpTable[i][1] = l->SpotExpTable[i+1][0] - l->SpotExpTable[i][0];
}
l->SpotExpTable[EXP_TABLE_SIZE-1][1] = 0.0;
}
/*
* Whenever the shininess of a material changes we must call this
* function to recompute the exponential lookup table.
*/
void gl_compute_material_shine_table( struct gl_material *m )
{
int i;
m->ShineTable[0] = 0.0F;
for (i=1;i<SHINE_TABLE_SIZE;i++) {
#if 0
double x = pow( i/(double)(SHINE_TABLE_SIZE-1), exponent );
if (x<1.0e-10) {
m->ShineTable[i] = 0.0F;
}
else {
m->ShineTable[i] = x;
}
#else
/* just invalidate the table */
m->ShineTable[i] = -1.0;
#endif
}
}
/*
* Examine current lighting parameters to determine if the optimized lighting
* function can be used.
* Also, precompute some lighting values such as the products of light
* source and material ambient, diffuse and specular coefficients.
*/
void gl_update_lighting( GLcontext *ctx )
{
GLint i, side;
struct gl_light *prev_enabled, *light;
if (!ctx->Light.Enabled) {
/* If lighting is not enabled, we can skip all this. */
return;
}
/* Setup linked list of enabled light sources */
prev_enabled = NULL;
ctx->Light.FirstEnabled = NULL;
for (i=0;i<MAX_LIGHTS;i++) {
ctx->Light.Light[i].NextEnabled = NULL;
if (ctx->Light.Light[i].Enabled) {
if (prev_enabled) {
prev_enabled->NextEnabled = &ctx->Light.Light[i];
}
else {
ctx->Light.FirstEnabled = &ctx->Light.Light[i];
}
prev_enabled = &ctx->Light.Light[i];
}
}
/* base color = material_emission + global_ambient * material_ambient */
for (side=0; side<2; side++) {
ctx->Light.BaseColor[side][0] = ctx->Light.Material[side].Emission[0]
+ ctx->Light.Model.Ambient[0] * ctx->Light.Material[side].Ambient[0];
ctx->Light.BaseColor[side][1] = ctx->Light.Material[side].Emission[1]
+ ctx->Light.Model.Ambient[1] * ctx->Light.Material[side].Ambient[1];
ctx->Light.BaseColor[side][2] = ctx->Light.Material[side].Emission[2]
+ ctx->Light.Model.Ambient[2] * ctx->Light.Material[side].Ambient[2];
ctx->Light.BaseColor[side][3]
= MIN2( ctx->Light.Material[side].Diffuse[3], 1.0F );
}
/* Precompute some lighting stuff */
for (light = ctx->Light.FirstEnabled; light; light = light->NextEnabled) {
for (side=0; side<2; side++) {
struct gl_material *mat = &ctx->Light.Material[side];
/* Add each light's ambient component to base color */
ctx->Light.BaseColor[side][0] += light->Ambient[0] * mat->Ambient[0];
ctx->Light.BaseColor[side][1] += light->Ambient[1] * mat->Ambient[1];
ctx->Light.BaseColor[side][2] += light->Ambient[2] * mat->Ambient[2];
/* compute product of light's ambient with front material ambient */
light->MatAmbient[side][0] = light->Ambient[0] * mat->Ambient[0];
light->MatAmbient[side][1] = light->Ambient[1] * mat->Ambient[1];
light->MatAmbient[side][2] = light->Ambient[2] * mat->Ambient[2];
/* compute product of light's diffuse with front material diffuse */
light->MatDiffuse[side][0] = light->Diffuse[0] * mat->Diffuse[0];
light->MatDiffuse[side][1] = light->Diffuse[1] * mat->Diffuse[1];
light->MatDiffuse[side][2] = light->Diffuse[2] * mat->Diffuse[2];
/* compute product of light's specular with front material specular */
light->MatSpecular[side][0] = light->Specular[0] * mat->Specular[0];
light->MatSpecular[side][1] = light->Specular[1] * mat->Specular[1];
light->MatSpecular[side][2] = light->Specular[2] * mat->Specular[2];
/* VP (VP) = Normalize( Position ) */
COPY_3V( light->VP_inf_norm, light->Position );
NORMALIZE_3FV( light->VP_inf_norm );
/* h_inf_norm = Normalize( V_to_P + <0,0,1> ) */
COPY_3V( light->h_inf_norm, light->VP_inf_norm );
light->h_inf_norm[2] += 1.0F;
NORMALIZE_3FV( light->h_inf_norm );
COPY_3V( light->NormDirection, light->Direction );
NORMALIZE_3FV( light->NormDirection );
/* Compute color index diffuse and specular light intensities */
light->dli = 0.30F * light->Diffuse[0]
+ 0.59F * light->Diffuse[1]
+ 0.11F * light->Diffuse[2];
light->sli = 0.30F * light->Specular[0]
+ 0.59F * light->Specular[1]
+ 0.11F * light->Specular[2];
} /* loop over materials */
} /* loop over lights */
/* Determine if the fast lighting function can be used */
ctx->Light.Fast = GL_TRUE;
if ( ctx->Light.BaseColor[0][0]<0.0F
|| ctx->Light.BaseColor[0][1]<0.0F
|| ctx->Light.BaseColor[0][2]<0.0F
|| ctx->Light.BaseColor[0][3]<0.0F
|| ctx->Light.BaseColor[1][0]<0.0F
|| ctx->Light.BaseColor[1][1]<0.0F
|| ctx->Light.BaseColor[1][2]<0.0F
|| ctx->Light.BaseColor[1][3]<0.0F
|| ctx->Light.Model.LocalViewer
|| ctx->Light.ColorMaterialEnabled) {
ctx->Light.Fast = GL_FALSE;
}
else {
for (light=ctx->Light.FirstEnabled; light; light=light->NextEnabled) {
if ( light->Position[3]!=0.0F
|| light->SpotCutoff!=180.0F
|| light->MatDiffuse[0][0]<0.0F
|| light->MatDiffuse[0][1]<0.0F
|| light->MatDiffuse[0][2]<0.0F
|| light->MatSpecular[0][0]<0.0F
|| light->MatSpecular[0][1]<0.0F
|| light->MatSpecular[0][2]<0.0F
|| light->MatDiffuse[1][0]<0.0F
|| light->MatDiffuse[1][1]<0.0F
|| light->MatDiffuse[1][2]<0.0F
|| light->MatSpecular[1][0]<0.0F
|| light->MatSpecular[1][1]<0.0F
|| light->MatSpecular[1][2]<0.0F) {
ctx->Light.Fast = GL_FALSE;
break;
}
}
}
}

93
dll/opengl/mesa/light.h Normal file
View File

@@ -0,0 +1,93 @@
/* $Id: light.h,v 1.4 1997/04/01 04:09:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.3
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: light.h,v $
* Revision 1.4 1997/04/01 04:09:16 brianp
* removed shading functions
*
* Revision 1.3 1996/12/18 20:03:01 brianp
* gl_set_material() now takes a bitmask instead of face and pname
* added gl_material_bitmask()
*
* Revision 1.2 1996/12/07 10:21:58 brianp
* added gl_set_material()
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef LIGHT_H
#define LIGHT_H
#include "types.h"
extern void gl_ShadeModel( GLcontext *ctx, GLenum mode );
extern void gl_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode );
extern void gl_Lightfv( GLcontext *ctx,
GLenum light, GLenum pname, const GLfloat *params,
GLint nparams );
extern void gl_LightModelfv( GLcontext *ctx,
GLenum pname, const GLfloat *params );
extern GLuint gl_material_bitmask( GLenum face, GLenum pname );
extern void gl_set_material( GLcontext *ctx, GLuint bitmask,
const GLfloat *params);
extern void gl_Materialfv( GLcontext *ctx,
GLenum face, GLenum pname, const GLfloat *params );
extern void gl_GetLightfv( GLcontext *ctx,
GLenum light, GLenum pname, GLfloat *params );
extern void gl_GetLightiv( GLcontext *ctx,
GLenum light, GLenum pname, GLint *params );
extern void gl_GetMaterialfv( GLcontext *ctx,
GLenum face, GLenum pname, GLfloat *params );
extern void gl_GetMaterialiv( GLcontext *ctx,
GLenum face, GLenum pname, GLint *params );
extern void gl_compute_spot_exp_table( struct gl_light *l );
extern void gl_compute_material_shine_table( struct gl_material *m );
extern void gl_update_lighting( GLcontext *ctx );
#endif

978
dll/opengl/mesa/lines.c Normal file
View File

@@ -0,0 +1,978 @@
/* $Id: lines.c,v 1.19 1998/02/03 23:46:00 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: lines.c,v $
* Revision 1.19 1998/02/03 23:46:00 brianp
* fixed a few problems with condition expressions for Amiga StormC compiler
*
* Revision 1.18 1997/07/24 01:24:11 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.17 1997/07/05 16:03:51 brianp
* fixed PB overflow problem
*
* Revision 1.16 1997/06/20 02:01:49 brianp
* changed color components from GLfixed to GLubyte
*
* Revision 1.15 1997/06/03 01:38:22 brianp
* fixed divide by zero problem in feedback function (William Mitchell)
*
* Revision 1.14 1997/05/28 03:25:26 brianp
* added precompiled header (PCH) support
*
* Revision 1.13 1997/05/03 00:51:02 brianp
* removed calls to gl_texturing_enabled()
*
* Revision 1.12 1997/04/14 02:00:39 brianp
* #include "texstate.h" instead of "texture.h"
*
* Revision 1.11 1997/04/12 12:25:01 brianp
* replaced ctx->LineFunc with ctx->Driver.LineFunc, fixed PB->count bug
*
* Revision 1.10 1997/03/16 02:07:31 brianp
* now use linetemp.h in line drawing functions
*
* Revision 1.9 1997/03/08 02:04:27 brianp
* better implementation of feedback function
*
* Revision 1.8 1997/02/09 18:44:20 brianp
* added GL_EXT_texture3D support
*
* Revision 1.7 1997/01/09 19:48:00 brianp
* now call gl_texturing_enabled()
*
* Revision 1.6 1996/11/08 02:21:21 brianp
* added null drawing function for GL_NO_RASTER
*
* Revision 1.5 1996/09/27 01:28:56 brianp
* removed unused variables
*
* Revision 1.4 1996/09/25 02:01:54 brianp
* new texture coord interpolation
*
* Revision 1.3 1996/09/15 14:18:10 brianp
* now use GLframebuffer and GLvisual
*
* Revision 1.2 1996/09/15 01:48:58 brianp
* removed #define NULL 0
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include "context.h"
#include "depth.h"
#include "feedback.h"
#include "lines.h"
#include "dlist.h"
#include "macros.h"
#include "pb.h"
#include "texstate.h"
#include "types.h"
#include "vb.h"
#include <wine/debug.h>
#endif
WINE_DEFAULT_DEBUG_CHANNEL(opengl32);
void gl_LineWidth( GLcontext *ctx, GLfloat width )
{
if (width<=0.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLineWidth" );
return;
}
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glLineWidth" );
return;
}
ctx->Line.Width = width;
ctx->NewState |= NEW_RASTER_OPS;
}
void gl_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glLineStipple" );
return;
}
ctx->Line.StippleFactor = CLAMP( factor, 1, 256 );
ctx->Line.StipplePattern = pattern;
ctx->NewState |= NEW_RASTER_OPS;
}
/**********************************************************************/
/***** Rasterization *****/
/**********************************************************************/
/*
* There are 4 pairs (RGBA, CI) of line drawing functions:
* 1. simple: width=1 and no special rasterization functions (fastest)
* 2. flat: width=1, non-stippled, flat-shaded, any raster operations
* 3. smooth: width=1, non-stippled, smooth-shaded, any raster operations
* 4. general: any other kind of line (slowest)
*/
/*
* All line drawing functions have the same arguments:
* v1, v2 - indexes of first and second endpoints into vertex buffer arrays
* pv - provoking vertex: which vertex color/index to use for flat shading.
*/
static void feedback_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
{
struct vertex_buffer *VB = ctx->VB;
GLfloat x1, y1, z1, w1;
GLfloat x2, y2, z2, w2;
GLfloat tex1[4], tex2[4], invq;
GLfloat invRedScale = ctx->Visual->InvRedScale;
GLfloat invGreenScale = ctx->Visual->InvGreenScale;
GLfloat invBlueScale = ctx->Visual->InvBlueScale;
GLfloat invAlphaScale = ctx->Visual->InvAlphaScale;
x1 = VB->Win[v1][0];
y1 = VB->Win[v1][1];
z1 = VB->Win[v1][2] / DEPTH_SCALE;
w1 = VB->Clip[v1][3];
x2 = VB->Win[v2][0];
y2 = VB->Win[v2][1];
z2 = VB->Win[v2][2] / DEPTH_SCALE;
w2 = VB->Clip[v2][3];
invq = (VB->TexCoord[v1][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v1][3]);
tex1[0] = VB->TexCoord[v1][0] * invq;
tex1[1] = VB->TexCoord[v1][1] * invq;
tex1[2] = VB->TexCoord[v1][2] * invq;
tex1[3] = VB->TexCoord[v1][3];
invq = (VB->TexCoord[v2][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v2][3]);
tex2[0] = VB->TexCoord[v2][0] * invq;
tex2[1] = VB->TexCoord[v2][1] * invq;
tex2[2] = VB->TexCoord[v2][2] * invq;
tex2[3] = VB->TexCoord[v2][3];
if (ctx->StippleCounter==0) {
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_LINE_RESET_TOKEN );
}
else {
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_LINE_TOKEN );
}
{
GLfloat color[4];
/* convert color from integer to a float in [0,1] */
color[0] = (GLfloat) VB->Color[pv][0] * invRedScale;
color[1] = (GLfloat) VB->Color[pv][1] * invGreenScale;
color[2] = (GLfloat) VB->Color[pv][2] * invBlueScale;
color[3] = (GLfloat) VB->Color[pv][3] * invAlphaScale;
gl_feedback_vertex( ctx, x1,y1,z1,w1, color,
(GLfloat) VB->Index[pv], tex1 );
gl_feedback_vertex( ctx, x2,y2,z2,w2, color,
(GLfloat) VB->Index[pv], tex2 );
}
ctx->StippleCounter++;
}
static void select_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
{
gl_update_hitflag( ctx, ctx->VB->Win[v1][2] / DEPTH_SCALE );
gl_update_hitflag( ctx, ctx->VB->Win[v2][2] / DEPTH_SCALE );
}
#if MAX_WIDTH > MAX_HEIGHT
# define MAXPOINTS MAX_WIDTH
#else
# define MAXPOINTS MAX_HEIGHT
#endif
/* Flat, color index line */
static void flat_ci_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
PB_SET_INDEX( ctx, ctx->PB, ctx->VB->Index[pvert] );
count = ctx->PB->count;
#define INTERP_XY 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
count++;
#include "linetemp.h"
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/* Flat, color index line with Z interpolation/testing */
static void flat_ci_z_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
PB_SET_INDEX( ctx, ctx->PB, ctx->VB->Index[pvert] );
count = ctx->PB->count;
#define INTERP_XY 1
#define INTERP_Z 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
count++;
#include "linetemp.h"
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/* Flat-shaded, RGBA line */
static void flat_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLubyte *color = ctx->VB->Color[pvert];
PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] );
count = ctx->PB->count;
#define INTERP_XY 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
count++;
#include "linetemp.h"
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/* Flat-shaded, RGBA line with Z interpolation/testing */
static void flat_rgba_z_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLubyte *color = ctx->VB->Color[pvert];
PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] );
count = ctx->PB->count;
#define INTERP_XY 1
#define INTERP_Z 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
count++;
#include "linetemp.h"
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/* Smooth shaded, color index line */
static void smooth_ci_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLuint *pbi = ctx->PB->i;
#define INTERP_XY 1
#define INTERP_INDEX 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbi[count] = I; \
count++;
#include "linetemp.h"
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/* Smooth shaded, color index line with Z interpolation/testing */
static void smooth_ci_z_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLuint *pbi = ctx->PB->i;
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_INDEX 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
pbi[count] = I; \
count++;
#include "linetemp.h"
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/* Smooth-shaded, RGBA line */
static void smooth_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLubyte *pbr = ctx->PB->r;
GLubyte *pbg = ctx->PB->g;
GLubyte *pbb = ctx->PB->b;
GLubyte *pba = ctx->PB->a;
#define INTERP_XY 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbr[count] = FixedToInt(r0); \
pbg[count] = FixedToInt(g0); \
pbb[count] = FixedToInt(b0); \
pba[count] = FixedToInt(a0); \
count++;
#include "linetemp.h"
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/* Smooth-shaded, RGBA line with Z interpolation/testing */
static void smooth_rgba_z_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLubyte *pbr = ctx->PB->r;
GLubyte *pbg = ctx->PB->g;
GLubyte *pbb = ctx->PB->b;
GLubyte *pba = ctx->PB->a;
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
pbr[count] = FixedToInt(r0); \
pbg[count] = FixedToInt(g0); \
pbb[count] = FixedToInt(b0); \
pba[count] = FixedToInt(a0); \
count++;
#include "linetemp.h"
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
#define CHECK_FULL(count) \
if (count >= PB_SIZE-MAX_WIDTH) { \
ctx->PB->count = count; \
gl_flush_pb(ctx); \
count = ctx->PB->count; \
}
/* Smooth shaded, color index, any width, maybe stippled */
static void general_smooth_ci_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLuint *pbi = ctx->PB->i;
if (ctx->Line.StippleFlag) {
/* stippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_INDEX 1
#define WIDE 1
#define STIPPLE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
pbi[count] = I; \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
else {
/* unstippled */
if (ctx->Line.Width==2.0F) {
/* special case: unstippled and width=2 */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_INDEX 1
#define XMAJOR_PLOT(X,Y) \
pbx[count] = X; pbx[count+1] = X; \
pby[count] = Y; pby[count+1] = Y+1; \
pbz[count] = Z; pbz[count+1] = Z; \
pbi[count] = I; pbi[count+1] = I; \
count += 2;
#define YMAJOR_PLOT(X,Y) \
pbx[count] = X; pbx[count+1] = X+1; \
pby[count] = Y; pby[count+1] = Y; \
pbz[count] = Z; pbz[count+1] = Z; \
pbi[count] = I; pbi[count+1] = I; \
count += 2;
#include "linetemp.h"
}
else {
/* unstippled, any width */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_INDEX 1
#define WIDE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
pbi[count] = I; \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
}
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/* Flat shaded, color index, any width, maybe stippled */
static void general_flat_ci_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
PB_SET_INDEX( ctx, ctx->PB, ctx->VB->Index[pvert] );
count = ctx->PB->count;
if (ctx->Line.StippleFlag) {
/* stippled, any width */
#define INTERP_XY 1
#define INTERP_Z 1
#define WIDE 1
#define STIPPLE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
else {
/* unstippled */
if (ctx->Line.Width==2.0F) {
/* special case: unstippled and width=2 */
#define INTERP_XY 1
#define INTERP_Z 1
#define XMAJOR_PLOT(X,Y) \
pbx[count] = X; pbx[count+1] = X; \
pby[count] = Y; pby[count+1] = Y+1; \
pbz[count] = Z; pbz[count+1] = Z; \
count += 2;
#define YMAJOR_PLOT(X,Y) \
pbx[count] = X; pbx[count+1] = X+1; \
pby[count] = Y; pby[count+1] = Y; \
pbz[count] = Z; pbz[count+1] = Z; \
count += 2;
#include "linetemp.h"
}
else {
/* unstippled, any width */
#define INTERP_XY 1
#define INTERP_Z 1
#define WIDE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
}
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
static void general_smooth_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert)
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLubyte *pbr = ctx->PB->r;
GLubyte *pbg = ctx->PB->g;
GLubyte *pbb = ctx->PB->b;
GLubyte *pba = ctx->PB->a;
TRACE("Line %3.1f, %3.1f, %3.1f (r%u, g%u, b%u) --> %3.1f, %3.1f, %3.1f (r%u, g%u, b%u)\n",
ctx->VB->Win[vert0][0], ctx->VB->Win[vert0][1], ctx->VB->Win[vert0][2], ctx->VB->Color[vert0][0], ctx->VB->Color[vert0][1], ctx->VB->Color[vert0][2],
ctx->VB->Win[vert1][0], ctx->VB->Win[vert1][1], ctx->VB->Win[vert1][2], ctx->VB->Color[vert1][0], ctx->VB->Color[vert1][1], ctx->VB->Color[vert1][2]);
if (ctx->Line.StippleFlag) {
/* stippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define WIDE 1
#define STIPPLE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
pbr[count] = FixedToInt(r0); \
pbg[count] = FixedToInt(g0); \
pbb[count] = FixedToInt(b0); \
pba[count] = FixedToInt(a0); \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
else {
/* unstippled */
if (ctx->Line.Width==2.0F) {
/* special case: unstippled and width=2 */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define XMAJOR_PLOT(X,Y) \
pbx[count] = X; pbx[count+1] = X; \
pby[count] = Y; pby[count+1] = Y+1; \
pbz[count] = Z; pbz[count+1] = Z; \
pbr[count] = FixedToInt(r0); pbr[count+1] = FixedToInt(r0); \
pbg[count] = FixedToInt(g0); pbg[count+1] = FixedToInt(g0); \
pbb[count] = FixedToInt(b0); pbb[count+1] = FixedToInt(b0); \
pba[count] = FixedToInt(a0); pba[count+1] = FixedToInt(a0); \
count += 2;
#define YMAJOR_PLOT(X,Y) \
pbx[count] = X; pbx[count+1] = X+1; \
pby[count] = Y; pby[count+1] = Y; \
pbz[count] = Z; pbz[count+1] = Z; \
pbr[count] = FixedToInt(r0); pbr[count+1] = FixedToInt(r0); \
pbg[count] = FixedToInt(g0); pbg[count+1] = FixedToInt(g0); \
pbb[count] = FixedToInt(b0); pbb[count+1] = FixedToInt(b0); \
pba[count] = FixedToInt(a0); pba[count+1] = FixedToInt(a0); \
count += 2;
#include "linetemp.h"
}
else {
/* unstippled, any width */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define WIDE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
pbr[count] = FixedToInt(r0); \
pbg[count] = FixedToInt(g0); \
pbb[count] = FixedToInt(b0); \
pba[count] = FixedToInt(a0); \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
}
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
static void general_flat_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
GLint count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLubyte *color = ctx->VB->Color[pvert];
PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] );
count = ctx->PB->count;
if (ctx->Line.StippleFlag) {
/* stippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define WIDE 1
#define STIPPLE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
else {
/* unstippled */
if (ctx->Line.Width==2.0F) {
/* special case: unstippled and width=2 */
#define INTERP_XY 1
#define INTERP_Z 1
#define XMAJOR_PLOT(X,Y) \
pbx[count] = X; pbx[count+1] = X; \
pby[count] = Y; pby[count+1] = Y+1; \
pbz[count] = Z; pbz[count+1] = Z; \
count += 2;
#define YMAJOR_PLOT(X,Y) \
pbx[count] = X; pbx[count+1] = X+1; \
pby[count] = Y; pby[count+1] = Y; \
pbz[count] = Z; pbz[count+1] = Z; \
count += 2;
#include "linetemp.h"
}
else {
/* unstippled, any width */
#define INTERP_XY 1
#define INTERP_Z 1
#define WIDE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
}
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/* Flat-shaded, textured, any width, maybe stippled */
static void flat_textured_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pv )
{
GLint count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLfloat *pbs = ctx->PB->s;
GLfloat *pbt = ctx->PB->t;
GLfloat *pbu = ctx->PB->u;
GLubyte *color = ctx->VB->Color[pv];
PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] );
count = ctx->PB->count;
if (ctx->Line.StippleFlag) {
/* stippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_STW 1
#define INTERP_UV 1
#define WIDE 1
#define STIPPLE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
pbs[count] = s0 / w0; \
pbt[count] = t0 / w0; \
pbu[count] = u0 / w0; \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
else {
/* unstippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_STW 1
#define INTERP_UV 1
#define WIDE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
pbs[count] = s0 / w0; \
pbt[count] = t0 / w0; \
pbu[count] = u0 / w0; \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/* Smooth-shaded, textured, any width, maybe stippled */
static void smooth_textured_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pv )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLfloat *pbs = ctx->PB->s;
GLfloat *pbt = ctx->PB->t;
GLfloat *pbu = ctx->PB->u;
GLubyte *pbr = ctx->PB->r;
GLubyte *pbg = ctx->PB->g;
GLubyte *pbb = ctx->PB->b;
GLubyte *pba = ctx->PB->a;
if (ctx->Line.StippleFlag) {
/* stippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define INTERP_STW 1
#define INTERP_UV 1
#define WIDE 1
#define STIPPLE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
pbs[count] = s0 / w0; \
pbt[count] = t0 / w0; \
pbu[count] = u0 / w0; \
pbr[count] = FixedToInt(r0); \
pbg[count] = FixedToInt(g0); \
pbb[count] = FixedToInt(b0); \
pba[count] = FixedToInt(a0); \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
else {
/* unstippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define INTERP_STW 1
#define INTERP_UV 1
#define WIDE 1
#define PLOT(X,Y) \
pbx[count] = X; \
pby[count] = Y; \
pbz[count] = Z; \
pbs[count] = s0 / w0; \
pbt[count] = t0 / w0; \
pbu[count] = u0 / w0; \
pbr[count] = FixedToInt(r0); \
pbg[count] = FixedToInt(g0); \
pbb[count] = FixedToInt(b0); \
pba[count] = FixedToInt(a0); \
count++; \
CHECK_FULL(count);
#include "linetemp.h"
}
ctx->PB->count = count;
PB_CHECK_FLUSH( ctx, ctx->PB );
}
/*
* Null rasterizer for measuring transformation speed.
*/
static void null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
{
}
/*
* Determine which line drawing function to use given the current
* rendering context.
*/
void gl_set_line_function( GLcontext *ctx )
{
GLboolean rgbmode = ctx->Visual->RGBAflag;
/* TODO: antialiased lines */
if (ctx->RenderMode==GL_RENDER) {
if (ctx->NoRaster) {
ctx->Driver.LineFunc = null_line;
return;
}
if (ctx->Driver.LineFunc) {
/* Device driver will draw lines. */
ctx->Driver.LineFunc = ctx->Driver.LineFunc;
}
else if (ctx->Texture.Enabled) {
if (ctx->Light.ShadeModel==GL_SMOOTH) {
ctx->Driver.LineFunc = smooth_textured_line;
}
else {
ctx->Driver.LineFunc = flat_textured_line;
}
}
else if (ctx->Line.Width!=1.0 || ctx->Line.StippleFlag
|| ctx->Line.SmoothFlag || ctx->Texture.Enabled) {
if (ctx->Light.ShadeModel==GL_SMOOTH) {
if (rgbmode)
ctx->Driver.LineFunc = general_smooth_rgba_line;
else
ctx->Driver.LineFunc = general_smooth_ci_line;
}
else {
if (rgbmode)
ctx->Driver.LineFunc = general_flat_rgba_line;
else
ctx->Driver.LineFunc = general_flat_ci_line;
}
}
else {
if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* Width==1, non-stippled, smooth-shaded */
if (ctx->Depth.Test
|| (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) {
if (rgbmode)
ctx->Driver.LineFunc = smooth_rgba_z_line;
else
ctx->Driver.LineFunc = smooth_ci_z_line;
}
else {
if (rgbmode)
ctx->Driver.LineFunc = smooth_rgba_line;
else
ctx->Driver.LineFunc = smooth_ci_line;
}
}
else {
/* Width==1, non-stippled, flat-shaded */
if (ctx->Depth.Test
|| (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) {
if (rgbmode)
ctx->Driver.LineFunc = flat_rgba_z_line;
else
ctx->Driver.LineFunc = flat_ci_z_line;
}
else {
if (rgbmode)
ctx->Driver.LineFunc = flat_rgba_line;
else
ctx->Driver.LineFunc = flat_ci_line;
}
}
}
}
else if (ctx->RenderMode==GL_FEEDBACK) {
ctx->Driver.LineFunc = feedback_line;
}
else {
/* GL_SELECT mode */
ctx->Driver.LineFunc = select_line;
}
}

46
dll/opengl/mesa/lines.h Normal file
View File

@@ -0,0 +1,46 @@
/* $Id: lines.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.0
* Copyright (C) 1995-1996 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.
*/
/*
* $Log: lines.h,v $
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef LINES_H
#define LINES_H
#include "types.h"
extern void gl_LineWidth( GLcontext *ctx, GLfloat width );
extern void gl_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern );
extern void gl_set_line_function( GLcontext *ctx );
#endif

502
dll/opengl/mesa/linetemp.h Normal file
View File

@@ -0,0 +1,502 @@
/* $Id: linetemp.h,v 1.4 1998/01/16 03:46:07 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.6
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: linetemp.h,v $
* Revision 1.4 1998/01/16 03:46:07 brianp
* fixed a few Windows compilation warnings (Theodore Jump)
*
* Revision 1.3 1997/06/20 02:49:53 brianp
* changed color components from GLfixed to GLubyte
*
* Revision 1.2 1997/05/16 01:54:54 brianp
* zPtrYstep calculation was negated!
*
* Revision 1.1 1997/03/16 02:07:56 brianp
* Initial revision
*
*/
/*
* Line Rasterizer Template
*
* This file is #include'd to generate custom line rasterizers.
*
* The following macros may be defined to indicate what auxillary information
* must be interplated along the line:
* INTERP_Z - if defined, interpolate Z values
* INTERP_RGB - if defined, interpolate RGB values
* INTERP_ALPHA - if defined, interpolate Alpha values
* INTERP_INDEX - if defined, interpolate color index values
* INTERP_ST - if defined, interpolate integer ST texcoords
* (fast, simple 2-D texture mapping)
* INTERP_STW - if defined, interpolate float ST texcoords and W
* (2-D texture maps with perspective correction)
* INTERP_UV - if defined, interpolate float UV texcoords too
* (for 3-D, 4-D? texture maps)
*
* When one can directly address pixels in the color buffer the following
* macros can be defined and used to directly compute pixel addresses during
* rasterization (see pixelPtr):
* PIXEL_TYPE - the datatype of a pixel (GLubyte, GLushort, GLuint)
* BYTES_PER_ROW - number of bytes per row in the color buffer
* PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where
* Y==0 at bottom of screen and increases upward.
*
* Optionally, one may provide one-time setup code
* SETUP_CODE - code which is to be executed once per line
*
* To enable line stippling define STIPPLE = 1
* To enable wide lines define WIDE = 1
*
* To actually "plot" each pixel either the PLOT macro or
* (XMAJOR_PLOT and YMAJOR_PLOT macros) must be defined...
* PLOT(X,Y) - code to plot a pixel. Example:
* if (Z < *zPtr) {
* *zPtr = Z;
* color = pack_rgb( FixedToInt(r0), FixedToInt(g0),
* FixedToInt(b0) );
* put_pixel( X, Y, color );
* }
*
* This code was designed for the origin to be in the lower-left corner.
*
*/
/*void line( GLcontext *ctx, GLuint vert0, GLuint vert1, GLuint pvert )*/
{
struct vertex_buffer *VB = ctx->VB;
/*
GLint x0 = (GLint) VB->Win[vert0][0], dx = (GLint) VB->Win[vert1][0] - x0;
GLint y0 = (GLint) VB->Win[vert0][1], dy = (GLint) VB->Win[vert1][1] - y0;
*/
GLint x0 = (GLint) VB->Win[vert0][0], x1 = (GLint) VB->Win[vert1][0];
GLint y0 = (GLint) VB->Win[vert0][1], y1 = (GLint) VB->Win[vert1][1];
GLint dx, dy;
#if INTERP_XY
GLint xstep, ystep;
#endif
#if INTERP_Z
GLint z0, z1, dz, zPtrXstep, zPtrYstep;
GLdepth *zPtr;
#endif
#if INTERP_RGB
GLfixed r0 = IntToFixed(VB->Color[vert0][0]);
GLfixed dr = IntToFixed(VB->Color[vert1][0]) - r0;
GLfixed g0 = IntToFixed(VB->Color[vert0][1]);
GLfixed dg = IntToFixed(VB->Color[vert1][1]) - g0;
GLfixed b0 = IntToFixed(VB->Color[vert0][2]);
GLfixed db = IntToFixed(VB->Color[vert1][2]) - b0;
#endif
#if INTERP_ALPHA
GLfixed a0 = IntToFixed(VB->Color[vert0][3]);
GLfixed da = IntToFixed(VB->Color[vert1][3]) - a0;
#endif
#if INTERP_INDEX
GLint i0 = VB->Index[vert0] << 8, di = (GLint) (VB->Index[vert1] << 8)-i0;
#endif
#if INTERP_ST
GLfixed s0 = FloatToFixed(VB->TexCoord[vert0][0] * S_SCALE);
GLfixed ds = FloatToFixed(VB->TexCoord[vert1][0] * S_SCALE) - s0;
GLfixed t0 = FloatToFixed(VB->TexCoord[vert0][1] * T_SCALE);
GLfixed dt = FloatToFixed(VB->TexCoord[vert1][1] * T_SCALE) - t0;
#endif
#if INTERP_STW
GLfloat s0 = VB->TexCoord[vert0][0], ds = VB->TexCoord[vert1][0] - s0;
GLfloat t0 = VB->TexCoord[vert0][1], dt = VB->TexCoord[vert1][1] - t0;
GLfloat w0 = 1.0F / VB->Clip[vert0][3], dw = 1.0F / VB->Clip[vert1][3] - w0;
#endif
#if INTERP_UV
GLfloat u0 = VB->TexCoord[vert0][2], du = VB->TexCoord[vert1][2] - u0;
GLfloat v0 = VB->TexCoord[vert0][3], dv = VB->TexCoord[vert1][3] - v0;
#endif
#ifdef PIXEL_ADDRESS
PIXEL_TYPE *pixelPtr;
GLint pixelXstep, pixelYstep;
#endif
#if WIDE
GLint width, min, max;
width = (GLint) CLAMP( ctx->Line.Width, MIN_LINE_WIDTH, MAX_LINE_WIDTH );
min = -width / 2;
max = min + width - 1;
#endif
/*
* Despite being clipped to the view volume, the line's window coordinates
* may just lie outside the window bounds. That is, if the legal window
* coordinates are [0,W-1][0,H-1], it's possible for x==W and/or y==H.
* This quick and dirty code nudges the endpoints inside the window if
* necessary.
*/
#if CLIP_HACK
{
GLint w = ctx->Buffer->Width;
GLint h = ctx->Buffer->Height;
if ((x0==w) | (x1==w)) {
if ((x0==w) & (x1==w))
return;
x0 -= x0==w;
x1 -= x1==w;
}
if ((y0==h) | (y1==h)) {
if ((y0==h) & (y1==h))
return;
y0 -= y0==h;
y1 -= y1==h;
}
}
#endif
dx = x1 - x0;
dy = y1 - y0;
if (dx==0 && dy==0) {
return;
}
/*
* Setup
*/
#ifdef SETUP_CODE
SETUP_CODE
#endif
#if INTERP_Z
zPtr = Z_ADDRESS(ctx,x0,y0);
z0 = (int) VB->Win[vert0][2];
z1 = (int) VB->Win[vert1][2];
#endif
#ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE *) PIXEL_ADDRESS(x0,y0);
#endif
if (dx<0) {
dx = -dx; /* make positive */
#if INTERP_XY
xstep = -1;
#endif
#ifdef INTERP_Z
zPtrXstep = -((GLint)sizeof(GLdepth));
#endif
#ifdef PIXEL_ADDRESS
pixelXstep = -sizeof(PIXEL_TYPE);
#endif
}
else {
#if INTERP_XY
xstep = 1;
#endif
#if INTERP_Z
zPtrXstep = sizeof(GLdepth);
#endif
#ifdef PIXEL_ADDRESS
pixelXstep = sizeof(PIXEL_TYPE);
#endif
}
if (dy<0) {
dy = -dy; /* make positive */
#if INTERP_XY
ystep = -1;
#endif
#if INTERP_Z
zPtrYstep = -ctx->Buffer->Width * sizeof(GLdepth);
#endif
#ifdef PIXEL_ADDRESS
pixelYstep = BYTES_PER_ROW;
#endif
}
else {
#if INTERP_XY
ystep = 1;
#endif
#if INTERP_Z
zPtrYstep = ctx->Buffer->Width * sizeof(GLdepth);
#endif
#ifdef PIXEL_ADDRESS
pixelYstep = -(BYTES_PER_ROW);
#endif
}
/*
* Draw
*/
if (dx>dy) {
/*
* X-major line
*/
GLint i;
GLint errorInc = dy+dy;
GLint error = errorInc-dx;
GLint errorDec = error-dx;
#if INTERP_Z
dz = (z1-z0) / dx;
#endif
#if INTERP_RGB
dr /= dx; /* convert from whole line delta to per-pixel delta */
dg /= dx;
db /= dx;
#endif
#if INTERP_ALPHA
da /= dx;
#endif
#if INTERP_INDEX
di /= dx;
#endif
#if INTERP_ST
ds /= dx;
dt /= dx;
#endif
#if INTERP_STW
{
GLfloat fdxinv = 1.0F / (GLfloat) dx;
ds *= fdxinv;
dt *= fdxinv;
dw *= fdxinv;
#if INTERP_UV
du *= fdxinv;
dv *= fdxinv;
#endif
}
#endif
for (i=0;i<dx;i++) {
#if STIPPLE
GLushort m;
m = 1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf);
if (ctx->Line.StipplePattern & m) {
#endif
#if INTERP_Z
GLdepth Z = z0;
#endif
#if INTERP_INDEX
GLint I = i0 >> 8;
#endif
#if WIDE
GLint yy;
GLint ymin = y0 + min;
GLint ymax = y0 + max;
for (yy=ymin;yy<=ymax;yy++) {
PLOT( x0, yy );
}
#else
# ifdef XMAJOR_PLOT
XMAJOR_PLOT( x0, y0 );
# else
PLOT( x0, y0 );
# endif
#endif /*WIDE*/
#if STIPPLE
}
ctx->StippleCounter++;
#endif
#if INTERP_XY
x0 += xstep;
#endif
#if INTERP_Z
zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrXstep);
z0 += dz;
#endif
#if INTERP_RGB
r0 += dr;
g0 += dg;
b0 += db;
#endif
#if INTERP_ALPHA
a0 += da;
#endif
#if INTERP_INDEX
i0 += di;
#endif
#if INTERP_ST
s0 += ds;
t0 += dt;
#endif
#if INTERP_STW
s0 += ds;
t0 += dt;
w0 += dw;
#endif
#if INTERP_UV
u0 += du;
v0 += dv;
#endif
#ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep);
#endif
if (error<0) {
error += errorInc;
}
else {
error += errorDec;
#if INTERP_XY
y0 += ystep;
#endif
#if INTERP_Z
zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrYstep);
#endif
#ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelYstep);
#endif
}
}
}
else {
/*
* Y-major line
*/
GLint i;
GLint errorInc = dx+dx;
GLint error = errorInc-dy;
GLint errorDec = error-dy;
#if INTERP_Z
dz = (z1-z0) / dy;
#endif
#if INTERP_RGB
dr /= dy; /* convert from whole line delta to per-pixel delta */
dg /= dy;
db /= dy;
#endif
#if INTERP_ALPHA
da /= dy;
#endif
#if INTERP_INDEX
di /= dy;
#endif
#if INTERP_ST
ds /= dy;
dt /= dy;
#endif
#if INTERP_STW
{
GLfloat fdyinv = 1.0F / (GLfloat) dy;
ds *= fdyinv;
dt *= fdyinv;
dw *= fdyinv;
#if INTERP_UV
du *= fdyinv;
dv *= fdyinv;
#endif
}
#endif
for (i=0;i<dy;i++) {
#if STIPPLE
GLushort m;
m = 1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf);
if (ctx->Line.StipplePattern & m) {
#endif
#if INTERP_Z
GLdepth Z = z0;
#endif
#if INTERP_INDEX
GLint I = i0 >> 8;
#endif
#if WIDE
GLint xx;
GLint xmin = x0 + min;
GLint xmax = x0 + max;
for (xx=xmin;xx<=xmax;xx++) {
PLOT( xx, y0 );
}
#else
# ifdef YMAJOR_PLOT
YMAJOR_PLOT( x0, y0 );
# else
PLOT( x0, y0 );
# endif
#endif /*WIDE*/
#if STIPPLE
}
ctx->StippleCounter++;
#endif
#if INTERP_XY
y0 += ystep;
#endif
#if INTERP_Z
zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrYstep);
z0 += dz;
#endif
#if INTERP_RGB
r0 += dr;
g0 += dg;
b0 += db;
#endif
#if INTERP_ALPHA
a0 += da;
#endif
#if INTERP_INDEX
i0 += di;
#endif
#if INTERP_ST
s0 += ds;
t0 += dt;
#endif
#if INTERP_STW
s0 += ds;
t0 += dt;
w0 += dw;
#endif
#if INTERP_UV
u0 += du;
v0 += dv;
#endif
#ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelYstep);
#endif
if (error<0) {
error += errorInc;
}
else {
error += errorDec;
#if INTERP_XY
x0 += xstep;
#endif
#if INTERP_Z
zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrXstep);
#endif
#ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep);
#endif
}
}
}
}
#undef INTERP_XY
#undef INTERP_Z
#undef INTERP_RGB
#undef INTERP_ALPHA
#undef INTERP_INDEX
#undef PIXEL_ADDRESS
#undef PIXEL_TYPE
#undef BYTES_PER_ROW
#undef SETUP_CODE
#undef PLOT
#undef XMAJOR_PLOT
#undef YMAJOR_PLOT
#undef CLIP_HACK
#undef STIPPLE
#undef WIDE

726
dll/opengl/mesa/logic.c Normal file
View File

@@ -0,0 +1,726 @@
/* $Id: logic.c,v 1.7 1997/07/24 01:24:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.4
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: logic.c,v $
* Revision 1.7 1997/07/24 01:24:11 brianp
* changed precompiled header symbol from PCH to PC_HEADER
*
* Revision 1.6 1997/05/28 03:25:26 brianp
* added precompiled header (PCH) support
*
* Revision 1.5 1997/04/20 20:28:49 brianp
* replaced abort() with gl_problem()
*
* Revision 1.4 1997/03/04 18:56:57 brianp
* added #include <stdlib.h> for abort()
*
* Revision 1.3 1997/01/28 22:16:31 brianp
* added gl_logicop_rgba_span() and gl_logicop_rgba_pixels()
*
* Revision 1.2 1997/01/04 00:13:11 brianp
* was using ! instead of ~ to invert pixel bits (ugh!)
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifdef PC_HEADER
#include "all.h"
#else
#include <stdlib.h>
#include "alphabuf.h"
#include "context.h"
#include "dlist.h"
#include "logic.h"
#include "macros.h"
#include "pb.h"
#include "span.h"
#include "types.h"
#endif
void gl_LogicOp( GLcontext *ctx, GLenum opcode )
{
if (INSIDE_BEGIN_END(ctx)) {
gl_error( ctx, GL_INVALID_OPERATION, "glLogicOp" );
return;
}
switch (opcode) {
case GL_CLEAR:
case GL_SET:
case GL_COPY:
case GL_COPY_INVERTED:
case GL_NOOP:
case GL_INVERT:
case GL_AND:
case GL_NAND:
case GL_OR:
case GL_NOR:
case GL_XOR:
case GL_EQUIV:
case GL_AND_REVERSE:
case GL_AND_INVERTED:
case GL_OR_REVERSE:
case GL_OR_INVERTED:
ctx->Color.LogicOp = opcode;
ctx->NewState |= NEW_RASTER_OPS;
return;
default:
gl_error( ctx, GL_INVALID_ENUM, "glLogicOp" );
return;
}
}
/*
* Apply the current logic operator to a span of CI pixels. This is only
* used if the device driver can't do logic ops.
*/
void gl_logicop_ci_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
GLuint index[], GLubyte mask[] )
{
GLuint dest[MAX_WIDTH];
GLuint i;
/* Read dest values from frame buffer */
(*ctx->Driver.ReadIndexSpan)( ctx, n, x, y, dest );
switch (ctx->Color.LogicOp) {
case GL_CLEAR:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = 0;
}
}
break;
case GL_SET:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = 1;
}
}
break;
case GL_COPY:
/* do nothing */
break;
case GL_COPY_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~index[i];
}
}
break;
case GL_NOOP:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = dest[i];
}
}
break;
case GL_INVERT:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~dest[i];
}
}
break;
case GL_AND:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] &= dest[i];
}
}
break;
case GL_NAND:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~(index[i] & dest[i]);
}
}
break;
case GL_OR:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] |= dest[i];
}
}
break;
case GL_NOR:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~(index[i] | dest[i]);
}
}
break;
case GL_XOR:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] ^= dest[i];
}
}
break;
case GL_EQUIV:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~(index[i] ^ dest[i]);
}
}
break;
case GL_AND_REVERSE:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = index[i] & ~dest[i];
}
}
break;
case GL_AND_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~index[i] & dest[i];
}
}
break;
case GL_OR_REVERSE:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = index[i] | ~dest[i];
}
}
break;
case GL_OR_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~index[i] | dest[i];
}
}
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "gl_logic error" );
}
}
/*
* Apply the current logic operator to an array of CI pixels. This is only
* used if the device driver can't do logic ops.
*/
void gl_logicop_ci_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint index[], GLubyte mask[] )
{
GLuint dest[PB_SIZE];
GLuint i;
/* Read dest values from frame buffer */
(*ctx->Driver.ReadIndexPixels)( ctx, n, x, y, dest, mask );
switch (ctx->Color.LogicOp) {
case GL_CLEAR:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = 0;
}
}
break;
case GL_SET:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = 1;
}
}
break;
case GL_COPY:
/* do nothing */
break;
case GL_COPY_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~index[i];
}
}
break;
case GL_NOOP:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = dest[i];
}
}
break;
case GL_INVERT:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~dest[i];
}
}
break;
case GL_AND:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] &= dest[i];
}
}
break;
case GL_NAND:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~(index[i] & dest[i]);
}
}
break;
case GL_OR:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] |= dest[i];
}
}
break;
case GL_NOR:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~(index[i] | dest[i]);
}
}
break;
case GL_XOR:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] ^= dest[i];
}
}
break;
case GL_EQUIV:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~(index[i] ^ dest[i]);
}
}
break;
case GL_AND_REVERSE:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = index[i] & ~dest[i];
}
}
break;
case GL_AND_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~index[i] & dest[i];
}
}
break;
case GL_OR_REVERSE:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = index[i] | ~dest[i];
}
}
break;
case GL_OR_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
index[i] = ~index[i] | dest[i];
}
}
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "gl_logic_pixels error" );
}
}
/*
* Apply the current logic operator to a span of RGBA pixels. This is only
* used if the device driver can't do logic ops.
*/
void gl_logicop_rgba_span( GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[],
GLubyte mask[] )
{
GLubyte rdest[MAX_WIDTH], gdest[MAX_WIDTH];
GLubyte bdest[MAX_WIDTH], adest[MAX_WIDTH];
GLuint i;
/* Read span of current frame buffer pixels */
gl_read_color_span( ctx, n, x, y, rdest, gdest, bdest, adest );
/* apply logic op */
switch (ctx->Color.LogicOp) {
case GL_CLEAR:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = green[i] = blue[i] = alpha[i] = 0;
}
}
break;
case GL_SET:
{
GLubyte r = (GLint) ctx->Visual->RedScale;
GLubyte g = (GLint) ctx->Visual->GreenScale;
GLubyte b = (GLint) ctx->Visual->BlueScale;
GLubyte a = (GLint) ctx->Visual->AlphaScale;
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = r;
green[i] = g;
blue[i] = b;
alpha[i] = a;
}
}
}
break;
case GL_COPY:
/* do nothing */
break;
case GL_COPY_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~red[i];
green[i] = ~green[i];
blue[i] = ~blue[i];
alpha[i] = ~alpha[i];
}
}
break;
case GL_NOOP:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = rdest[i];
green[i] = gdest[i];
blue[i] = bdest[i];
alpha[i] = adest[i];
}
}
break;
case GL_INVERT:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~rdest[i];
green[i] = ~gdest[i];
blue[i] = ~bdest[i];
alpha[i] = ~adest[i];
}
}
break;
case GL_AND:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] &= rdest[i];
green[i] &= gdest[i];
blue[i] &= bdest[i];
alpha[i] &= adest[i];
}
}
break;
case GL_NAND:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~(red[i] & rdest[i]);
green[i] = ~(green[i] & gdest[i]);
blue[i] = ~(blue[i] & bdest[i]);
alpha[i] = ~(alpha[i] & adest[i]);
}
}
break;
case GL_OR:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] |= rdest[i];
green[i] |= gdest[i];
blue[i] |= bdest[i];
alpha[i] |= adest[i];
}
}
break;
case GL_NOR:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~(red[i] | rdest[i]);
green[i] = ~(green[i] | gdest[i]);
blue[i] = ~(blue[i] | bdest[i]);
alpha[i] = ~(alpha[i] | adest[i]);
}
}
break;
case GL_XOR:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] ^= rdest[i];
green[i] ^= gdest[i];
blue[i] ^= bdest[i];
alpha[i] ^= adest[i];
}
}
break;
case GL_EQUIV:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~(red[i] ^ rdest[i]);
green[i] = ~(green[i] ^ gdest[i]);
blue[i] = ~(blue[i] ^ bdest[i]);
alpha[i] = ~(alpha[i] ^ adest[i]);
}
}
break;
case GL_AND_REVERSE:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = red[i] & ~rdest[i];
green[i] = green[i] & ~gdest[i];
blue[i] = blue[i] & ~bdest[i];
alpha[i] = alpha[i] & ~adest[i];
}
}
break;
case GL_AND_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~red[i] & rdest[i];
green[i] = ~green[i] & gdest[i];
blue[i] = ~blue[i] & bdest[i];
alpha[i] = ~alpha[i] & adest[i];
}
}
break;
case GL_OR_REVERSE:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = red[i] | ~rdest[i];
green[i] = green[i] | ~gdest[i];
blue[i] = blue[i] | ~bdest[i];
alpha[i] = alpha[i] | ~adest[i];
}
}
break;
case GL_OR_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~red[i] | rdest[i];
green[i] = ~green[i] | gdest[i];
blue[i] = ~blue[i] | bdest[i];
alpha[i] = ~alpha[i] | adest[i];
}
}
break;
default:
/* should never happen */
gl_problem(ctx, "Bad function in gl_logicop_rgba_span");
return;
}
}
/*
* Apply the current logic operator to an array of RGBA pixels. This is only
* used if the device driver can't do logic ops.
*/
void gl_logicop_rgba_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[],
GLubyte mask[] )
{
GLubyte rdest[PB_SIZE], gdest[PB_SIZE], bdest[PB_SIZE], adest[PB_SIZE];
GLuint i;
/* Read pixels from current color buffer */
(*ctx->Driver.ReadColorPixels)( ctx, n, x, y, rdest, gdest, bdest, adest, mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
gl_read_alpha_pixels( ctx, n, x, y, adest, mask );
}
/* apply logic op */
switch (ctx->Color.LogicOp) {
case GL_CLEAR:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = green[i] = blue[i] = alpha[i] = 0;
}
}
break;
case GL_SET:
{
GLubyte r = (GLint) ctx->Visual->RedScale;
GLubyte g = (GLint) ctx->Visual->GreenScale;
GLubyte b = (GLint) ctx->Visual->BlueScale;
GLubyte a = (GLint) ctx->Visual->AlphaScale;
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = r;
green[i] = g;
blue[i] = b;
alpha[i] = a;
}
}
}
break;
case GL_COPY:
/* do nothing */
break;
case GL_COPY_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~red[i];
green[i] = ~green[i];
blue[i] = ~blue[i];
alpha[i] = ~alpha[i];
}
}
break;
case GL_NOOP:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = rdest[i];
green[i] = gdest[i];
blue[i] = bdest[i];
alpha[i] = adest[i];
}
}
break;
case GL_INVERT:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~rdest[i];
green[i] = ~gdest[i];
blue[i] = ~bdest[i];
alpha[i] = ~adest[i];
}
}
break;
case GL_AND:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] &= rdest[i];
green[i] &= gdest[i];
blue[i] &= bdest[i];
alpha[i] &= adest[i];
}
}
break;
case GL_NAND:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~(red[i] & rdest[i]);
green[i] = ~(green[i] & gdest[i]);
blue[i] = ~(blue[i] & bdest[i]);
alpha[i] = ~(alpha[i] & adest[i]);
}
}
break;
case GL_OR:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] |= rdest[i];
green[i] |= gdest[i];
blue[i] |= bdest[i];
alpha[i] |= adest[i];
}
}
break;
case GL_NOR:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~(red[i] | rdest[i]);
green[i] = ~(green[i] | gdest[i]);
blue[i] = ~(blue[i] | bdest[i]);
alpha[i] = ~(alpha[i] | adest[i]);
}
}
break;
case GL_XOR:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] ^= rdest[i];
green[i] ^= gdest[i];
blue[i] ^= bdest[i];
alpha[i] ^= adest[i];
}
}
break;
case GL_EQUIV:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~(red[i] ^ rdest[i]);
green[i] = ~(green[i] ^ gdest[i]);
blue[i] = ~(blue[i] ^ bdest[i]);
alpha[i] = ~(alpha[i] ^ adest[i]);
}
}
break;
case GL_AND_REVERSE:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = red[i] & ~rdest[i];
green[i] = green[i] & ~gdest[i];
blue[i] = blue[i] & ~bdest[i];
alpha[i] = alpha[i] & ~adest[i];
}
}
break;
case GL_AND_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~red[i] & rdest[i];
green[i] = ~green[i] & gdest[i];
blue[i] = ~blue[i] & bdest[i];
alpha[i] = ~alpha[i] & adest[i];
}
}
break;
case GL_OR_REVERSE:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = red[i] | ~rdest[i];
green[i] = green[i] | ~gdest[i];
blue[i] = blue[i] | ~bdest[i];
alpha[i] = alpha[i] | ~adest[i];
}
}
break;
case GL_OR_INVERTED:
for (i=0;i<n;i++) {
if (mask[i]) {
red[i] = ~red[i] | rdest[i];
green[i] = ~green[i] | gdest[i];
blue[i] = ~blue[i] | bdest[i];
alpha[i] = ~alpha[i] | adest[i];
}
}
break;
default:
/* should never happen */
gl_problem(ctx, "Bad function in gl_logicop_rgba_pixels");
return;
}
}

69
dll/opengl/mesa/logic.h Normal file
View File

@@ -0,0 +1,69 @@
/* $Id: logic.h,v 1.2 1997/01/28 22:16:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.2
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: logic.h,v $
* Revision 1.2 1997/01/28 22:16:31 brianp
* added gl_logicop_rgba_span() and gl_logicop_rgba_pixels()
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
#ifndef LOGIC_H
#define LOGIC_H
#include "types.h"
extern void gl_LogicOp( GLcontext *ctx, GLenum opcode );
extern void gl_logicop_ci_span( GLcontext *ctx,
GLuint n, GLint x, GLint y, GLuint index[],
GLubyte mask[] );
extern void gl_logicop_ci_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint index[], GLubyte mask[] );
extern void gl_logicop_rgba_span( GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[],
GLubyte mask[] );
extern void gl_logicop_rgba_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte red[], GLubyte green[],
GLubyte blue[], GLubyte alpha[],
GLubyte mask[] );
#endif

277
dll/opengl/mesa/macros.h Normal file
View File

@@ -0,0 +1,277 @@
/* $Id: macros.h,v 1.12 1998/01/06 01:42:29 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 2.6
* Copyright (C) 1995-1997 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.
*/
/*
* $Log: macros.h,v $
* Revision 1.12 1998/01/06 01:42:29 brianp
* small patch for BeOS
*
* Revision 1.11 1997/06/23 00:23:23 brianp
* changed preprocessor test for Macintosh
*
* Revision 1.10 1997/06/06 03:47:31 brianp
* added COPY_4UBV()
*
* Revision 1.9 1997/05/01 01:39:15 brianp
* moved NORMALIZE_3V macro to mmath.h and renamed NORMALIZE_3FV
*
* Revision 1.8 1997/04/24 00:28:45 brianp
* added COPY_2V macro
*
* Revision 1.7 1997/04/07 02:59:46 brianp
* added ASSIGN_2V macro
*
* Revision 1.6 1997/04/01 04:08:16 brianp
* changed DEFARRAY, UNDEFARRAY for Mac, per Miklos Fazekas
* added DEG2RAD macro
*
* Revision 1.5 1997/03/21 02:01:17 brianp
* added ASSERT() macro
*
* Revision 1.4 1997/02/03 20:31:26 brianp
* added DEFARRAY and UNDEFARRAY macros for BeOS
*
* Revision 1.3 1996/10/31 01:12:00 brianp
* removed (GLint) from FLOAT_TO_UINT() macro
*
* Revision 1.2 1996/09/15 01:49:44 brianp
* added #define NULL 0
*
* Revision 1.1 1996/09/13 01:38:16 brianp
* Initial revision
*
*/
/*
* A collection of useful macros.
*/
#ifndef MACROS_H
#define MACROS_H
#include <math.h>
#include <string.h>
#ifdef DEBUG
# include <assert.h>
# define ASSERT(X) assert(X)
#else
# define ASSERT(X)
#endif
/* Limits: */
#define MAX_GLUSHORT 0xffff
#define MAX_GLUINT 0xffffffff
/* Copy short vectors: */
#define COPY_2V( DST, SRC ) DST[0] = SRC[0]; \
DST[1] = SRC[1];
#define COPY_3V( DST, SRC ) DST[0] = SRC[0]; \
DST[1] = SRC[1]; \
DST[2] = SRC[2];
#define COPY_4V( DST, SRC ) DST[0] = SRC[0]; \
DST[1] = SRC[1]; \
DST[2] = SRC[2]; \
DST[3] = SRC[3];
/*
* Copy a vector of 4 GLubytes from SRC to DST.
*/
#define COPY_4UBV(DST, SRC) \
if (sizeof(GLuint)==4*sizeof(GLubyte)) { \
*((GLuint*)(DST)) = *((GLuint*)(SRC)); \
} \
else { \
(DST)[0] = (SRC)[0]; \
(DST)[1] = (SRC)[1]; \
(DST)[2] = (SRC)[2]; \
(DST)[3] = (SRC)[3]; \
}
/* Assign scalers to short vectors: */
#define ASSIGN_2V( V, V0, V1 ) V[0] = V0; V[1] = V1;
#define ASSIGN_3V( V, V0, V1, V2 ) V[0] = V0; V[1] = V1; V[2] = V2;
#define ASSIGN_4V( V, V0, V1, V2, V3 ) V[0] = V0; \
V[1] = V1; \
V[2] = V2; \
V[3] = V3;
/* Test if we're inside a glBegin / glEnd pair: */
#define INSIDE_BEGIN_END(CTX) ((CTX)->Primitive!=GL_BITMAP)
/* Absolute value (for Int, Float, Double): */
#define ABSI(X) ((X) < 0 ? -(X) : (X))
#define ABSF(X) ((X) < 0.0F ? -(X) : (X))
#define ABSD(X) ((X) < 0.0 ? -(X) : (X))
/* Round a floating-point value to the nearest integer: */
#define ROUNDF(X) ( (X)<0.0F ? ((GLint) ((X)-0.5F)) : ((GLint) ((X)+0.5F)) )
/* Compute ceiling of integer quotient of A divided by B: */
#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
/* Clamp X to [MIN,MAX]: */
#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
/* Min of two values: */
#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
/* MAX of two values: */
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
/* Dot product of two 3-element vectors */
#define DOT3( a, b ) ( a[0]*b[0] + a[1]*b[1] + a[2]*b[2] )
/* Dot product of two 4-element vectors */
#define DOT4( a, b ) ( a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3] )
/*
* Integer / float conversion for colors, normals, etc.
*/
/* Convert GLubyte in [0,255] to GLfloat in [0.0,1.0] */
#define UBYTE_TO_FLOAT(B) ((GLfloat) (B) * (1.0F / 255.0F))
/* Convert GLfloat in [0.0,1.0] to GLubyte in [0,255] */
#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) (((X)) * 255.0F))
/* Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0] */
#define BYTE_TO_FLOAT(B) ((2.0F * (B) + 1.0F) * (1.0F/255.0F))
/* Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127] */
#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 )
/* Convert GLushort in [0,65536] to GLfloat in [0.0,1.0] */
#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F))
/* Convert GLfloat in [0.0,1.0] to GLushort in [0,65536] */
#define FLOAT_TO_USHORT(X) ((GLushort) (GLint) ((X) * 65535.0F))
/* Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */
#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))
/* Convert GLfloat in [0.0,1.0] to GLshort in [-32768,32767] */
#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 )
/* Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */
#define UINT_TO_FLOAT(U) ((GLfloat) (U) * (1.0F / 4294967295.0F))
/* Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */
#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0))
/* Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */
#define INT_TO_FLOAT(I) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0F))
/* Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */
/* causes overflow:
#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0F * (X))) - 1) / 2 )
*/
/* a close approximation: */
#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) )
/* Memory copy: */
#ifdef SUNOS4
#define MEMCPY( DST, SRC, BYTES) \
memcpy( (char *) (DST), (char *) (SRC), (int) (BYTES) )
#else
#define MEMCPY( DST, SRC, BYTES) \
memcpy( (void *) (DST), (void *) (SRC), (size_t) (BYTES) )
#endif
/* Memory set: */
#ifdef SUNOS4
#define MEMSET( DST, VAL, N ) \
memset( (char *) (DST), (int) (VAL), (int) (N) )
#else
#define MEMSET( DST, VAL, N ) \
memset( (void *) (DST), (int) (VAL), (size_t) (N) )
#endif
/* MACs and BeOS don't support static larger than 32kb, so... */
#if defined(macintosh) && !defined(__MRC__)
extern char *AGLAlloc(int size);
extern void AGLFree(char* ptr);
# define DEFARRAY(TYPE,NAME,SIZE) TYPE *NAME = (TYPE*)AGLAlloc(sizeof(TYPE)*(SIZE))
# define UNDEFARRAY(NAME) AGLFree((char*)NAME)
#elif defined(__BEOS__)
# define DEFARRAY(TYPE,NAME,SIZE) TYPE *NAME = (TYPE*)malloc(sizeof(TYPE)*(SIZE))
# define UNDEFARRAY(NAME) free(NAME)
#else
# define DEFARRAY(TYPE,NAME,SIZE) TYPE NAME[SIZE]
# define UNDEFARRAY(NAME)
#endif
/* Pi */
#ifndef M_PI
#define M_PI (3.1415926)
#endif
/* Degrees to radians conversion: */
#define DEG2RAD (M_PI/180.0)
#ifndef NULL
#define NULL 0
#endif
#endif /*MACROS_H*/

View File

@@ -1,81 +0,0 @@
list(APPEND SOURCE
api_arrayelt.c
api_exec.c
api_loopback.c
api_validate.c
accum.c
attrib.c
blend.c
bufferobj.c
buffers.c
clear.c
clip.c
context.c
cpuinfo.c
depth.c
dlist.c
dlopen.c
drawpix.c
enable.c
enums.c
eval.c
execmem.c
extensions.c
feedback.c
fog.c
formats.c
format_pack.c
format_unpack.c
framebuffer.c
get.c
getstring.c
hash.c
hint.c
image.c
imports.c
light.c
lines.c
matrix.c
mm.c
multisample.c
pack.c
pixel.c
pixelstore.c
pixeltransfer.c
points.c
polygon.c
rastpos.c
readpix.c
renderbuffer.c
scissor.c
shared.c
state.c
stencil.c
texenv.c
texformat.c
texgen.c
texgetimage.c
teximage.c
texobj.c
#texpal.c
texparam.c
texstate.c
texstorage.c
texstore.c
varray.c
version.c
viewport.c
vtxfmt.c
precomp.h)
add_library(mesa_main STATIC ${SOURCE})
add_dependencies(mesa_main xdk)
add_pch(mesa_main precomp.h SOURCE)
if(NOT MSVC)
add_target_compile_flags(mesa_main "-Wno-type-limits")
elseif(USE_CLANG_CL)
add_target_compile_flags(mesa_main "-Wno-cast-calling-convention -Wno-unused-local-typedef")
add_target_compile_flags(mesa_main "-Wno-tautological-unsigned-zero-compare -Wno-constant-conversion")
endif()

View File

@@ -1,481 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 1999-2005 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.
*/
#include <precomp.h>
#if FEATURE_accum
void GLAPIENTRY
_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
{
GLfloat tmp[4];
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
tmp[0] = CLAMP( red, -1.0F, 1.0F );
tmp[1] = CLAMP( green, -1.0F, 1.0F );
tmp[2] = CLAMP( blue, -1.0F, 1.0F );
tmp[3] = CLAMP( alpha, -1.0F, 1.0F );
if (TEST_EQ_4V(tmp, ctx->Accum.ClearColor))
return;
COPY_4FV( ctx->Accum.ClearColor, tmp );
}
static void GLAPIENTRY
_mesa_Accum( GLenum op, GLfloat value )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
switch (op) {
case GL_ADD:
case GL_MULT:
case GL_ACCUM:
case GL_LOAD:
case GL_RETURN:
/* OK */
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)");
return;
}
if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum buffer)");
return;
}
if (ctx->DrawBuffer != ctx->ReadBuffer) {
/* See GLX_SGI_make_current_read or WGL_ARB_make_current_read,
* or GL_EXT_framebuffer_blit.
*/
_mesa_error(ctx, GL_INVALID_OPERATION,
"glAccum(different read/draw buffers)");
return;
}
if (ctx->NewState)
_mesa_update_state(ctx);
if (ctx->RasterDiscard)
return;
if (ctx->RenderMode == GL_RENDER) {
_mesa_accum(ctx, op, value);
}
}
void
_mesa_init_accum_dispatch(struct _glapi_table *disp)
{
SET_Accum(disp, _mesa_Accum);
SET_ClearAccum(disp, _mesa_ClearAccum);
}
/**
* Clear the accumulation buffer by mapping the renderbuffer and
* writing the clear color to it. Called by the driver's implementation
* of the glClear function.
*/
void
_mesa_clear_accum_buffer(struct gl_context *ctx)
{
GLuint x, y, width, height;
GLubyte *accMap;
GLint accRowStride;
struct gl_renderbuffer *accRb;
if (!ctx->DrawBuffer)
return;
accRb = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
if (!accRb)
return; /* missing accum buffer, not an error */
/* bounds, with scissor */
x = ctx->DrawBuffer->_Xmin;
y = ctx->DrawBuffer->_Ymin;
width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
ctx->Driver.MapRenderbuffer(ctx, accRb, x, y, width, height,
GL_MAP_WRITE_BIT, &accMap, &accRowStride);
if (!accMap) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
return;
}
if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
const GLshort clearR = FLOAT_TO_SHORT(ctx->Accum.ClearColor[0]);
const GLshort clearG = FLOAT_TO_SHORT(ctx->Accum.ClearColor[1]);
const GLshort clearB = FLOAT_TO_SHORT(ctx->Accum.ClearColor[2]);
const GLshort clearA = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]);
GLuint i, j;
for (j = 0; j < height; j++) {
GLshort *row = (GLshort *) accMap;
for (i = 0; i < width; i++) {
row[i * 4 + 0] = clearR;
row[i * 4 + 1] = clearG;
row[i * 4 + 2] = clearB;
row[i * 4 + 3] = clearA;
}
accMap += accRowStride;
}
}
else {
/* other types someday? */
_mesa_warning(ctx, "unexpected accum buffer type");
}
ctx->Driver.UnmapRenderbuffer(ctx, accRb);
}
/**
* if (bias)
* Accum += value
* else
* Accum *= value
*/
static void
accum_scale_or_bias(struct gl_context *ctx, GLfloat value,
GLint xpos, GLint ypos, GLint width, GLint height,
GLboolean bias)
{
struct gl_renderbuffer *accRb =
ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
GLubyte *accMap;
GLint accRowStride;
assert(accRb);
ctx->Driver.MapRenderbuffer(ctx, accRb, xpos, ypos, width, height,
GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
&accMap, &accRowStride);
if (!accMap) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
return;
}
if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
const GLshort incr = (GLshort) (value * 32767.0f);
GLuint i, j;
if (bias) {
for (j = 0; j < height; j++) {
GLshort *acc = (GLshort *) accMap;
for (i = 0; i < 4 * width; i++) {
acc[i] += incr;
}
accMap += accRowStride;
}
}
else {
/* scale */
for (j = 0; j < height; j++) {
GLshort *acc = (GLshort *) accMap;
for (i = 0; i < 4 * width; i++) {
acc[i] = (GLshort) (acc[i] * value);
}
accMap += accRowStride;
}
}
}
else {
/* other types someday? */
}
ctx->Driver.UnmapRenderbuffer(ctx, accRb);
}
/**
* if (load)
* Accum = ColorBuf * value
* else
* Accum += ColorBuf * value
*/
static void
accum_or_load(struct gl_context *ctx, GLfloat value,
GLint xpos, GLint ypos, GLint width, GLint height,
GLboolean load)
{
struct gl_renderbuffer *accRb =
ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
struct gl_renderbuffer *colorRb = ctx->ReadBuffer->_ColorReadBuffer;
GLubyte *accMap, *colorMap;
GLint accRowStride, colorRowStride;
GLbitfield mappingFlags;
if (!colorRb) {
/* no read buffer - OK */
return;
}
assert(accRb);
mappingFlags = GL_MAP_WRITE_BIT;
if (!load) /* if we're accumulating */
mappingFlags |= GL_MAP_READ_BIT;
/* Map accum buffer */
ctx->Driver.MapRenderbuffer(ctx, accRb, xpos, ypos, width, height,
mappingFlags, &accMap, &accRowStride);
if (!accMap) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
return;
}
/* Map color buffer */
ctx->Driver.MapRenderbuffer(ctx, colorRb, xpos, ypos, width, height,
GL_MAP_READ_BIT,
&colorMap, &colorRowStride);
if (!colorMap) {
ctx->Driver.UnmapRenderbuffer(ctx, accRb);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
return;
}
if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
const GLfloat scale = value * 32767.0f;
GLuint i, j;
GLfloat (*rgba)[4];
rgba = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat));
if (rgba) {
for (j = 0; j < height; j++) {
GLshort *acc = (GLshort *) accMap;
/* read colors from source color buffer */
_mesa_unpack_rgba_row(colorRb->Format, width, colorMap, rgba);
if (load) {
for (i = 0; i < width; i++) {
acc[i * 4 + 0] = (GLshort) (rgba[i][RCOMP] * scale);
acc[i * 4 + 1] = (GLshort) (rgba[i][GCOMP] * scale);
acc[i * 4 + 2] = (GLshort) (rgba[i][BCOMP] * scale);
acc[i * 4 + 3] = (GLshort) (rgba[i][ACOMP] * scale);
}
}
else {
/* accumulate */
for (i = 0; i < width; i++) {
acc[i * 4 + 0] += (GLshort) (rgba[i][RCOMP] * scale);
acc[i * 4 + 1] += (GLshort) (rgba[i][GCOMP] * scale);
acc[i * 4 + 2] += (GLshort) (rgba[i][BCOMP] * scale);
acc[i * 4 + 3] += (GLshort) (rgba[i][ACOMP] * scale);
}
}
colorMap += colorRowStride;
accMap += accRowStride;
}
free(rgba);
}
else {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
}
}
else {
/* other types someday? */
}
ctx->Driver.UnmapRenderbuffer(ctx, accRb);
ctx->Driver.UnmapRenderbuffer(ctx, colorRb);
}
/**
* ColorBuffer = Accum * value
*/
static void
accum_return(struct gl_context *ctx, GLfloat value,
GLint xpos, GLint ypos, GLint width, GLint height)
{
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct gl_renderbuffer *accRb = fb->Attachment[BUFFER_ACCUM].Renderbuffer;
GLubyte *accMap, *colorMap;
GLint accRowStride, colorRowStride;
struct gl_renderbuffer *colorRb = fb->_ColorDrawBuffer;
const GLboolean masking = (!ctx->Color.ColorMask[RCOMP] ||
!ctx->Color.ColorMask[GCOMP] ||
!ctx->Color.ColorMask[BCOMP] ||
!ctx->Color.ColorMask[ACOMP]);
GLbitfield mappingFlags = GL_MAP_WRITE_BIT;
/* Map accum buffer */
ctx->Driver.MapRenderbuffer(ctx, accRb, xpos, ypos, width, height,
GL_MAP_READ_BIT,
&accMap, &accRowStride);
if (!accMap) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
return;
}
if (masking)
mappingFlags |= GL_MAP_READ_BIT;
/* Map color buffer */
ctx->Driver.MapRenderbuffer(ctx, colorRb, xpos, ypos, width, height,
mappingFlags, &colorMap, &colorRowStride);
if (!colorMap) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
ctx->Driver.UnmapRenderbuffer(ctx, accRb);
return;
}
if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) {
const GLfloat scale = value / 32767.0f;
GLint i, j;
GLfloat (*rgba)[4], (*dest)[4];
rgba = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat));
dest = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat));
if (rgba && dest) {
for (j = 0; j < height; j++) {
GLshort *acc = (GLshort *) accMap;
for (i = 0; i < width; i++) {
rgba[i][0] = acc[i * 4 + 0] * scale;
rgba[i][1] = acc[i * 4 + 1] * scale;
rgba[i][2] = acc[i * 4 + 2] * scale;
rgba[i][3] = acc[i * 4 + 3] * scale;
}
if (masking) {
/* get existing colors from dest buffer */
_mesa_unpack_rgba_row(colorRb->Format, width, colorMap, dest);
/* use the dest colors where mask[channel] = 0 */
if (ctx->Color.ColorMask[RCOMP] == 0) {
for (i = 0; i < width; i++)
rgba[i][RCOMP] = dest[i][RCOMP];
}
if (ctx->Color.ColorMask[GCOMP] == 0) {
for (i = 0; i < width; i++)
rgba[i][GCOMP] = dest[i][GCOMP];
}
if (ctx->Color.ColorMask[BCOMP] == 0) {
for (i = 0; i < width; i++)
rgba[i][BCOMP] = dest[i][BCOMP];
}
if (ctx->Color.ColorMask[ACOMP] == 0) {
for (i = 0; i < width; i++)
rgba[i][ACOMP] = dest[i][ACOMP];
}
}
_mesa_pack_float_rgba_row(colorRb->Format, width,
(const GLfloat (*)[4]) rgba, colorMap);
accMap += accRowStride;
colorMap += colorRowStride;
}
}
else {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum");
}
free(rgba);
free(dest);
}
else {
/* other types someday? */
}
ctx->Driver.UnmapRenderbuffer(ctx, colorRb);
ctx->Driver.UnmapRenderbuffer(ctx, accRb);
}
/**
* Software fallback for glAccum. A hardware driver that supports
* signed 16-bit color channels could implement hardware accumulation
* operations, but no driver does so at this time.
*/
void
_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value)
{
GLint xpos, ypos, width, height;
if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) {
_mesa_warning(ctx, "Calling glAccum() without an accumulation buffer");
return;
}
xpos = ctx->DrawBuffer->_Xmin;
ypos = ctx->DrawBuffer->_Ymin;
width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
switch (op) {
case GL_ADD:
if (value != 0.0F) {
accum_scale_or_bias(ctx, value, xpos, ypos, width, height, GL_TRUE);
}
break;
case GL_MULT:
if (value != 1.0F) {
accum_scale_or_bias(ctx, value, xpos, ypos, width, height, GL_FALSE);
}
break;
case GL_ACCUM:
if (value != 0.0F) {
accum_or_load(ctx, value, xpos, ypos, width, height, GL_FALSE);
}
break;
case GL_LOAD:
accum_or_load(ctx, value, xpos, ypos, width, height, GL_TRUE);
break;
case GL_RETURN:
accum_return(ctx, value, xpos, ypos, width, height);
break;
default:
_mesa_problem(ctx, "invalid mode in _mesa_accum()");
break;
}
}
#endif /* FEATURE_accum */
void
_mesa_init_accum( struct gl_context *ctx )
{
/* Accumulate buffer group */
ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 );
}

View File

@@ -1,93 +0,0 @@
/**
* \file accum.h
* Accumulation buffer operations.
*
* \if subset
* (No-op)
*
* \endif
*/
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef ACCUM_H
#define ACCUM_H
#include "main/glheader.h"
#include "main/mfeatures.h"
struct _glapi_table;
struct gl_context;
struct gl_renderbuffer;
#if FEATURE_accum
extern void GLAPIENTRY
_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha );
extern void
_mesa_init_accum_dispatch(struct _glapi_table *disp);
extern void
_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value);
extern void
_mesa_clear_accum_buffer(struct gl_context *ctx);
#else /* FEATURE_accum */
#include "main/compiler.h"
static inline void
_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
{
/* this is used in _mesa_PopAttrib */
ASSERT_NO_FEATURE();
}
static inline void
_mesa_init_accum_dispatch(struct _glapi_table *disp)
{
}
static inline void
_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value)
{
}
static inline void
_mesa_clear_accum_buffer(struct gl_context *ctx)
{
}
#endif /* FEATURE_accum */
extern void
_mesa_init_accum( struct gl_context *ctx );
#endif /* ACCUM_H */

View File

@@ -1,910 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.1
*
* Copyright (C) 1999-2006 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.
*/
/**
* This file implements the glArrayElement() function.
* It involves looking at the format/type of all the enabled vertex arrays
* and emitting a list of pointers to functions which set the per-vertex
* state for the element/index.
*/
/* Author:
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include <precomp.h>
typedef void (GLAPIENTRY *array_func)( const void * );
typedef struct {
const struct gl_client_array *array;
int offset;
} AEarray;
typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data );
typedef struct {
const struct gl_client_array *array;
attrib_func func;
GLuint index;
} AEattrib;
typedef struct {
AEarray arrays[32];
AEattrib attribs[VERT_ATTRIB_MAX + 1];
GLuint NewState;
struct gl_buffer_object *vbo[VERT_ATTRIB_MAX];
GLuint nr_vbos;
GLboolean mapped_vbos;
} AEcontext;
#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
/*
* Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
* in the range [0, 7]. Luckily these type tokens are sequentially
* numbered in gl.h, except for GL_DOUBLE.
*/
#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
#define NUM_TYPES 8
#if FEATURE_arrayelt
static const int ColorFuncs[2][NUM_TYPES] = {
{
_gloffset_Color3bv,
_gloffset_Color3ubv,
_gloffset_Color3sv,
_gloffset_Color3usv,
_gloffset_Color3iv,
_gloffset_Color3uiv,
_gloffset_Color3fv,
_gloffset_Color3dv,
},
{
_gloffset_Color4bv,
_gloffset_Color4ubv,
_gloffset_Color4sv,
_gloffset_Color4usv,
_gloffset_Color4iv,
_gloffset_Color4uiv,
_gloffset_Color4fv,
_gloffset_Color4dv,
},
};
static const int VertexFuncs[3][NUM_TYPES] = {
{
-1,
-1,
_gloffset_Vertex2sv,
-1,
_gloffset_Vertex2iv,
-1,
_gloffset_Vertex2fv,
_gloffset_Vertex2dv,
},
{
-1,
-1,
_gloffset_Vertex3sv,
-1,
_gloffset_Vertex3iv,
-1,
_gloffset_Vertex3fv,
_gloffset_Vertex3dv,
},
{
-1,
-1,
_gloffset_Vertex4sv,
-1,
_gloffset_Vertex4iv,
-1,
_gloffset_Vertex4fv,
_gloffset_Vertex4dv,
},
};
static const int IndexFuncs[NUM_TYPES] = {
-1,
_gloffset_Indexubv,
_gloffset_Indexsv,
-1,
_gloffset_Indexiv,
-1,
_gloffset_Indexfv,
_gloffset_Indexdv,
};
static const int NormalFuncs[NUM_TYPES] = {
_gloffset_Normal3bv,
-1,
_gloffset_Normal3sv,
-1,
_gloffset_Normal3iv,
-1,
_gloffset_Normal3fv,
_gloffset_Normal3dv,
};
/* Note: _gloffset_* for these may not be a compile-time constant. */
static int FogCoordFuncs[NUM_TYPES];
/**
** GL_NV_vertex_program
**/
/* GL_BYTE attributes */
static void GLAPIENTRY
VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
}
static void GLAPIENTRY
VertexAttrib1bvNV(GLuint index, const GLbyte *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
}
static void GLAPIENTRY
VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
}
static void GLAPIENTRY
VertexAttrib2bvNV(GLuint index, const GLbyte *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
}
static void GLAPIENTRY
VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
BYTE_TO_FLOAT(v[1]),
BYTE_TO_FLOAT(v[2])));
}
static void GLAPIENTRY
VertexAttrib3bvNV(GLuint index, const GLbyte *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
}
static void GLAPIENTRY
VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
BYTE_TO_FLOAT(v[1]),
BYTE_TO_FLOAT(v[2]),
BYTE_TO_FLOAT(v[3])));
}
static void GLAPIENTRY
VertexAttrib4bvNV(GLuint index, const GLbyte *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
}
/* GL_UNSIGNED_BYTE attributes */
static void GLAPIENTRY
VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
}
static void GLAPIENTRY
VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
}
static void GLAPIENTRY
VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
UBYTE_TO_FLOAT(v[1])));
}
static void GLAPIENTRY
VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
}
static void GLAPIENTRY
VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
UBYTE_TO_FLOAT(v[1]),
UBYTE_TO_FLOAT(v[2])));
}
static void GLAPIENTRY
VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
(GLfloat)v[1], (GLfloat)v[2]));
}
static void GLAPIENTRY
VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
UBYTE_TO_FLOAT(v[1]),
UBYTE_TO_FLOAT(v[2]),
UBYTE_TO_FLOAT(v[3])));
}
static void GLAPIENTRY
VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
(GLfloat)v[1], (GLfloat)v[2],
(GLfloat)v[3]));
}
/* GL_SHORT attributes */
static void GLAPIENTRY
VertexAttrib1NsvNV(GLuint index, const GLshort *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
}
static void GLAPIENTRY
VertexAttrib1svNV(GLuint index, const GLshort *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
}
static void GLAPIENTRY
VertexAttrib2NsvNV(GLuint index, const GLshort *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
SHORT_TO_FLOAT(v[1])));
}
static void GLAPIENTRY
VertexAttrib2svNV(GLuint index, const GLshort *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
}
static void GLAPIENTRY
VertexAttrib3NsvNV(GLuint index, const GLshort *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
SHORT_TO_FLOAT(v[1]),
SHORT_TO_FLOAT(v[2])));
}
static void GLAPIENTRY
VertexAttrib3svNV(GLuint index, const GLshort *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
(GLfloat)v[2]));
}
static void GLAPIENTRY
VertexAttrib4NsvNV(GLuint index, const GLshort *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
SHORT_TO_FLOAT(v[1]),
SHORT_TO_FLOAT(v[2]),
SHORT_TO_FLOAT(v[3])));
}
static void GLAPIENTRY
VertexAttrib4svNV(GLuint index, const GLshort *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
(GLfloat)v[2], (GLfloat)v[3]));
}
/* GL_UNSIGNED_SHORT attributes */
static void GLAPIENTRY
VertexAttrib1NusvNV(GLuint index, const GLushort *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
}
static void GLAPIENTRY
VertexAttrib1usvNV(GLuint index, const GLushort *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
}
static void GLAPIENTRY
VertexAttrib2NusvNV(GLuint index, const GLushort *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
USHORT_TO_FLOAT(v[1])));
}
static void GLAPIENTRY
VertexAttrib2usvNV(GLuint index, const GLushort *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
(GLfloat)v[1]));
}
static void GLAPIENTRY
VertexAttrib3NusvNV(GLuint index, const GLushort *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
USHORT_TO_FLOAT(v[1]),
USHORT_TO_FLOAT(v[2])));
}
static void GLAPIENTRY
VertexAttrib3usvNV(GLuint index, const GLushort *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
(GLfloat)v[2]));
}
static void GLAPIENTRY
VertexAttrib4NusvNV(GLuint index, const GLushort *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
USHORT_TO_FLOAT(v[1]),
USHORT_TO_FLOAT(v[2]),
USHORT_TO_FLOAT(v[3])));
}
static void GLAPIENTRY
VertexAttrib4usvNV(GLuint index, const GLushort *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
(GLfloat)v[2], (GLfloat)v[3]));
}
/* GL_INT attributes */
static void GLAPIENTRY
VertexAttrib1NivNV(GLuint index, const GLint *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
}
static void GLAPIENTRY
VertexAttrib1ivNV(GLuint index, const GLint *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
}
static void GLAPIENTRY
VertexAttrib2NivNV(GLuint index, const GLint *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
INT_TO_FLOAT(v[1])));
}
static void GLAPIENTRY
VertexAttrib2ivNV(GLuint index, const GLint *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
}
static void GLAPIENTRY
VertexAttrib3NivNV(GLuint index, const GLint *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
INT_TO_FLOAT(v[1]),
INT_TO_FLOAT(v[2])));
}
static void GLAPIENTRY
VertexAttrib3ivNV(GLuint index, const GLint *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
(GLfloat)v[2]));
}
static void GLAPIENTRY
VertexAttrib4NivNV(GLuint index, const GLint *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
INT_TO_FLOAT(v[1]),
INT_TO_FLOAT(v[2]),
INT_TO_FLOAT(v[3])));
}
static void GLAPIENTRY
VertexAttrib4ivNV(GLuint index, const GLint *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
(GLfloat)v[2], (GLfloat)v[3]));
}
/* GL_UNSIGNED_INT attributes */
static void GLAPIENTRY
VertexAttrib1NuivNV(GLuint index, const GLuint *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
}
static void GLAPIENTRY
VertexAttrib1uivNV(GLuint index, const GLuint *v)
{
CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
}
static void GLAPIENTRY
VertexAttrib2NuivNV(GLuint index, const GLuint *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
UINT_TO_FLOAT(v[1])));
}
static void GLAPIENTRY
VertexAttrib2uivNV(GLuint index, const GLuint *v)
{
CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
(GLfloat)v[1]));
}
static void GLAPIENTRY
VertexAttrib3NuivNV(GLuint index, const GLuint *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
UINT_TO_FLOAT(v[1]),
UINT_TO_FLOAT(v[2])));
}
static void GLAPIENTRY
VertexAttrib3uivNV(GLuint index, const GLuint *v)
{
CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
(GLfloat)v[2]));
}
static void GLAPIENTRY
VertexAttrib4NuivNV(GLuint index, const GLuint *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
UINT_TO_FLOAT(v[1]),
UINT_TO_FLOAT(v[2]),
UINT_TO_FLOAT(v[3])));
}
static void GLAPIENTRY
VertexAttrib4uivNV(GLuint index, const GLuint *v)
{
CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
(GLfloat)v[2], (GLfloat)v[3]));
}
/* GL_FLOAT attributes */
static void GLAPIENTRY
VertexAttrib1fvNV(GLuint index, const GLfloat *v)
{
CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v));
}
static void GLAPIENTRY
VertexAttrib2fvNV(GLuint index, const GLfloat *v)
{
CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v));
}
static void GLAPIENTRY
VertexAttrib3fvNV(GLuint index, const GLfloat *v)
{
CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v));
}
static void GLAPIENTRY
VertexAttrib4fvNV(GLuint index, const GLfloat *v)
{
CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v));
}
/* GL_DOUBLE attributes */
static void GLAPIENTRY
VertexAttrib1dvNV(GLuint index, const GLdouble *v)
{
CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v));
}
static void GLAPIENTRY
VertexAttrib2dvNV(GLuint index, const GLdouble *v)
{
CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v));
}
static void GLAPIENTRY
VertexAttrib3dvNV(GLuint index, const GLdouble *v)
{
CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v));
}
static void GLAPIENTRY
VertexAttrib4dvNV(GLuint index, const GLdouble *v)
{
CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v));
}
/*
* Array [size][type] of VertexAttrib functions
*/
static attrib_func AttribFuncsNV[2][4][NUM_TYPES] = {
{
/* non-normalized */
{
/* size 1 */
(attrib_func) VertexAttrib1bvNV,
(attrib_func) VertexAttrib1ubvNV,
(attrib_func) VertexAttrib1svNV,
(attrib_func) VertexAttrib1usvNV,
(attrib_func) VertexAttrib1ivNV,
(attrib_func) VertexAttrib1uivNV,
(attrib_func) VertexAttrib1fvNV,
(attrib_func) VertexAttrib1dvNV
},
{
/* size 2 */
(attrib_func) VertexAttrib2bvNV,
(attrib_func) VertexAttrib2ubvNV,
(attrib_func) VertexAttrib2svNV,
(attrib_func) VertexAttrib2usvNV,
(attrib_func) VertexAttrib2ivNV,
(attrib_func) VertexAttrib2uivNV,
(attrib_func) VertexAttrib2fvNV,
(attrib_func) VertexAttrib2dvNV
},
{
/* size 3 */
(attrib_func) VertexAttrib3bvNV,
(attrib_func) VertexAttrib3ubvNV,
(attrib_func) VertexAttrib3svNV,
(attrib_func) VertexAttrib3usvNV,
(attrib_func) VertexAttrib3ivNV,
(attrib_func) VertexAttrib3uivNV,
(attrib_func) VertexAttrib3fvNV,
(attrib_func) VertexAttrib3dvNV
},
{
/* size 4 */
(attrib_func) VertexAttrib4bvNV,
(attrib_func) VertexAttrib4ubvNV,
(attrib_func) VertexAttrib4svNV,
(attrib_func) VertexAttrib4usvNV,
(attrib_func) VertexAttrib4ivNV,
(attrib_func) VertexAttrib4uivNV,
(attrib_func) VertexAttrib4fvNV,
(attrib_func) VertexAttrib4dvNV
}
},
{
/* normalized (except for float/double) */
{
/* size 1 */
(attrib_func) VertexAttrib1NbvNV,
(attrib_func) VertexAttrib1NubvNV,
(attrib_func) VertexAttrib1NsvNV,
(attrib_func) VertexAttrib1NusvNV,
(attrib_func) VertexAttrib1NivNV,
(attrib_func) VertexAttrib1NuivNV,
(attrib_func) VertexAttrib1fvNV,
(attrib_func) VertexAttrib1dvNV
},
{
/* size 2 */
(attrib_func) VertexAttrib2NbvNV,
(attrib_func) VertexAttrib2NubvNV,
(attrib_func) VertexAttrib2NsvNV,
(attrib_func) VertexAttrib2NusvNV,
(attrib_func) VertexAttrib2NivNV,
(attrib_func) VertexAttrib2NuivNV,
(attrib_func) VertexAttrib2fvNV,
(attrib_func) VertexAttrib2dvNV
},
{
/* size 3 */
(attrib_func) VertexAttrib3NbvNV,
(attrib_func) VertexAttrib3NubvNV,
(attrib_func) VertexAttrib3NsvNV,
(attrib_func) VertexAttrib3NusvNV,
(attrib_func) VertexAttrib3NivNV,
(attrib_func) VertexAttrib3NuivNV,
(attrib_func) VertexAttrib3fvNV,
(attrib_func) VertexAttrib3dvNV
},
{
/* size 4 */
(attrib_func) VertexAttrib4NbvNV,
(attrib_func) VertexAttrib4NubvNV,
(attrib_func) VertexAttrib4NsvNV,
(attrib_func) VertexAttrib4NusvNV,
(attrib_func) VertexAttrib4NivNV,
(attrib_func) VertexAttrib4NuivNV,
(attrib_func) VertexAttrib4fvNV,
(attrib_func) VertexAttrib4dvNV
}
}
};
/**********************************************************************/
GLboolean _ae_create_context( struct gl_context *ctx )
{
if (ctx->aelt_context)
return GL_TRUE;
FogCoordFuncs[0] = -1;
FogCoordFuncs[1] = -1;
FogCoordFuncs[2] = -1;
FogCoordFuncs[3] = -1;
FogCoordFuncs[4] = -1;
FogCoordFuncs[5] = -1;
FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
FogCoordFuncs[7] = _gloffset_FogCoorddvEXT;
ctx->aelt_context = CALLOC( sizeof(AEcontext) );
if (!ctx->aelt_context)
return GL_FALSE;
AE_CONTEXT(ctx)->NewState = ~0;
return GL_TRUE;
}
void _ae_destroy_context( struct gl_context *ctx )
{
if ( AE_CONTEXT( ctx ) ) {
FREE( ctx->aelt_context );
ctx->aelt_context = NULL;
}
}
static void check_vbo( AEcontext *actx,
struct gl_buffer_object *vbo )
{
if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) {
GLuint i;
for (i = 0; i < actx->nr_vbos; i++)
if (actx->vbo[i] == vbo)
return;
assert(actx->nr_vbos < VERT_ATTRIB_MAX);
actx->vbo[actx->nr_vbos++] = vbo;
}
}
/**
* Make a list of per-vertex functions to call for each glArrayElement call.
* These functions access the array data (i.e. glVertex, glColor, glNormal,
* etc).
* Note: this may be called during display list construction.
*/
static void _ae_update_state( struct gl_context *ctx )
{
AEcontext *actx = AE_CONTEXT(ctx);
AEarray *aa = actx->arrays;
AEattrib *at = actx->attribs;
actx->nr_vbos = 0;
/* conventional vertex arrays */
if (ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR_INDEX];
aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
if (ctx->Array.VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_EDGEFLAG];
aa->offset = _gloffset_EdgeFlagv;
check_vbo(actx, aa->array->BufferObj);
aa++;
}
if (ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL];
aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
if (ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR].Enabled) {
aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR];
aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
if (ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_FOG];
aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
{
struct gl_client_array *attribArray = &ctx->Array.VertexAttrib[VERT_ATTRIB_TEX];
if (attribArray->Enabled) {
/* NOTE: we use generic glVertexAttribNV functions here.
* If we ever remove GL_NV_vertex_program this will have to change.
*/
at->array = attribArray;
ASSERT(!at->array->Normalized);
at->func = AttribFuncsNV[at->array->Normalized]
[at->array->Size-1]
[TYPE_IDX(at->array->Type)];
at->index = VERT_ATTRIB_TEX;
check_vbo(actx, at->array->BufferObj);
at++;
}
}
/* finally, vertex position */
if (ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled) {
aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_POS];
aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
check_vbo(actx, ctx->Array.ElementArrayBufferObj);
ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
ASSERT(aa - actx->arrays < 32);
at->func = NULL; /* terminate the list */
aa->offset = -1; /* terminate the list */
actx->NewState = 0;
}
void _ae_map_vbos( struct gl_context *ctx )
{
AEcontext *actx = AE_CONTEXT(ctx);
GLuint i;
if (actx->mapped_vbos)
return;
if (actx->NewState)
_ae_update_state(ctx);
for (i = 0; i < actx->nr_vbos; i++)
ctx->Driver.MapBufferRange(ctx, 0,
actx->vbo[i]->Size,
GL_MAP_READ_BIT,
actx->vbo[i]);
if (actx->nr_vbos)
actx->mapped_vbos = GL_TRUE;
}
void _ae_unmap_vbos( struct gl_context *ctx )
{
AEcontext *actx = AE_CONTEXT(ctx);
GLuint i;
if (!actx->mapped_vbos)
return;
assert (!actx->NewState);
for (i = 0; i < actx->nr_vbos; i++)
ctx->Driver.UnmapBuffer(ctx, actx->vbo[i]);
actx->mapped_vbos = GL_FALSE;
}
/**
* Called via glArrayElement() and glDrawArrays().
* Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
* for all enabled vertex arrays (for elt-th element).
* Note: this may be called during display list construction.
*/
void GLAPIENTRY _ae_ArrayElement( GLint elt )
{
GET_CURRENT_CONTEXT(ctx);
const AEcontext *actx = AE_CONTEXT(ctx);
const AEarray *aa;
const AEattrib *at;
const struct _glapi_table * const disp = GET_DISPATCH();
GLboolean do_map;
if (actx->NewState) {
assert(!actx->mapped_vbos);
_ae_update_state( ctx );
}
/* Determine if we need to map/unmap VBOs */
do_map = actx->nr_vbos && !actx->mapped_vbos;
if (do_map)
_ae_map_vbos(ctx);
/* emit generic attribute elements */
for (at = actx->attribs; at->func; at++) {
const GLubyte *src
= ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr)
+ elt * at->array->StrideB;
at->func( at->index, src );
}
/* emit conventional arrays elements */
for (aa = actx->arrays; aa->offset != -1 ; aa++) {
const GLubyte *src
= ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr)
+ elt * aa->array->StrideB;
CALL_by_offset( disp, (array_func), aa->offset,
((const void *) src) );
}
if (do_map)
_ae_unmap_vbos(ctx);
}
void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state )
{
AEcontext *actx = AE_CONTEXT(ctx);
/* Only interested in this subset of mesa state. Need to prune
* this down as both tnl/ and the drivers can raise statechanges
* for arcane reasons in the middle of seemingly atomic operations
* like DrawElements, over which we'd like to keep a known set of
* arrays and vbo's mapped.
*
* Luckily, neither the drivers nor tnl muck with the state that
* concerns us here:
*/
new_state &= _NEW_ARRAY;
if (new_state) {
assert(!actx->mapped_vbos);
actx->NewState |= new_state;
}
}
void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
const GLvertexformat *vfmt)
{
SET_ArrayElement(disp, vfmt->ArrayElement);
}
#endif /* FEATURE_arrayelt */

View File

@@ -1,84 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef API_ARRAYELT_H
#define API_ARRAYELT_H
#include "main/mfeatures.h"
#include "main/mtypes.h"
#if FEATURE_arrayelt
#define _MESA_INIT_ARRAYELT_VTXFMT(vfmt, impl) \
do { \
(vfmt)->ArrayElement = impl ## ArrayElement; \
} while (0)
extern GLboolean _ae_create_context( struct gl_context *ctx );
extern void _ae_destroy_context( struct gl_context *ctx );
extern void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state );
extern void GLAPIENTRY _ae_ArrayElement( GLint elt );
/* May optionally be called before a batch of element calls:
*/
extern void _ae_map_vbos( struct gl_context *ctx );
extern void _ae_unmap_vbos( struct gl_context *ctx );
extern void
_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
const GLvertexformat *vfmt);
#else /* FEATURE_arrayelt */
#define _MESA_INIT_ARRAYELT_VTXFMT(vfmt, impl) do { } while (0)
static inline GLboolean
_ae_create_context( struct gl_context *ctx )
{
return GL_TRUE;
}
static inline void
_ae_destroy_context( struct gl_context *ctx )
{
}
static inline void
_ae_invalidate_state( struct gl_context *ctx, GLuint new_state )
{
}
static inline void
_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
const GLvertexformat *vfmt)
{
}
#endif /* FEATURE_arrayelt */
#endif /* API_ARRAYELT_H */

View File

@@ -1,306 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2008 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.
*/
/**
* \file api_exec.c
* Initialize dispatch table with the immidiate mode functions.
*/
#include <precomp.h>
#if FEATURE_GL
/**
* Initialize a dispatch table with pointers to Mesa's immediate-mode
* commands.
*
* Pointers to glBegin()/glEnd() object commands and a few others
* are provided via the GLvertexformat interface.
*
* \param ctx GL context to which \c exec belongs.
* \param exec dispatch table.
*/
struct _glapi_table *
_mesa_create_exec_table(void)
{
struct _glapi_table *exec;
exec = _mesa_alloc_dispatch_table(_gloffset_COUNT);
if (exec == NULL)
return NULL;
#if _HAVE_FULL_GL
_mesa_loopback_init_api_table( exec );
#endif
/* load the dispatch slots we understand */
SET_AlphaFunc(exec, _mesa_AlphaFunc);
SET_BlendFunc(exec, _mesa_BlendFunc);
SET_Clear(exec, _mesa_Clear);
SET_ClearColor(exec, _mesa_ClearColor);
SET_ClearStencil(exec, _mesa_ClearStencil);
SET_ColorMask(exec, _mesa_ColorMask);
SET_CullFace(exec, _mesa_CullFace);
SET_Disable(exec, _mesa_Disable);
#if FEATURE_draw_read_buffer
SET_DrawBuffer(exec, _mesa_DrawBuffer);
SET_ReadBuffer(exec, _mesa_ReadBuffer);
#endif
SET_Enable(exec, _mesa_Enable);
SET_Finish(exec, _mesa_Finish);
SET_Flush(exec, _mesa_Flush);
SET_FrontFace(exec, _mesa_FrontFace);
SET_Frustum(exec, _mesa_Frustum);
SET_GetError(exec, _mesa_GetError);
SET_GetFloatv(exec, _mesa_GetFloatv);
SET_GetString(exec, _mesa_GetString);
SET_LineStipple(exec, _mesa_LineStipple);
SET_LineWidth(exec, _mesa_LineWidth);
SET_LoadIdentity(exec, _mesa_LoadIdentity);
SET_LoadMatrixf(exec, _mesa_LoadMatrixf);
SET_LogicOp(exec, _mesa_LogicOp);
SET_MatrixMode(exec, _mesa_MatrixMode);
SET_MultMatrixf(exec, _mesa_MultMatrixf);
SET_Ortho(exec, _mesa_Ortho);
SET_PixelStorei(exec, _mesa_PixelStorei);
SET_PopMatrix(exec, _mesa_PopMatrix);
SET_PushMatrix(exec, _mesa_PushMatrix);
SET_Rotatef(exec, _mesa_Rotatef);
SET_Scalef(exec, _mesa_Scalef);
SET_Scissor(exec, _mesa_Scissor);
SET_ShadeModel(exec, _mesa_ShadeModel);
SET_StencilFunc(exec, _mesa_StencilFunc);
SET_StencilMask(exec, _mesa_StencilMask);
SET_StencilOp(exec, _mesa_StencilOp);
SET_TexEnvfv(exec, _mesa_TexEnvfv);
SET_TexEnvi(exec, _mesa_TexEnvi);
SET_TexImage2D(exec, _mesa_TexImage2D);
SET_TexParameteri(exec, _mesa_TexParameteri);
SET_Translatef(exec, _mesa_Translatef);
SET_Viewport(exec, _mesa_Viewport);
_mesa_init_accum_dispatch(exec);
_mesa_init_dlist_dispatch(exec);
SET_ClearDepth(exec, _mesa_ClearDepth);
SET_ClearIndex(exec, _mesa_ClearIndex);
SET_ClipPlane(exec, _mesa_ClipPlane);
SET_ColorMaterial(exec, _mesa_ColorMaterial);
SET_DepthFunc(exec, _mesa_DepthFunc);
SET_DepthMask(exec, _mesa_DepthMask);
SET_DepthRange(exec, _mesa_DepthRange);
_mesa_init_drawpix_dispatch(exec);
_mesa_init_feedback_dispatch(exec);
SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT);
SET_Fogf(exec, _mesa_Fogf);
SET_Fogfv(exec, _mesa_Fogfv);
SET_Fogi(exec, _mesa_Fogi);
SET_Fogiv(exec, _mesa_Fogiv);
SET_GetClipPlane(exec, _mesa_GetClipPlane);
SET_GetBooleanv(exec, _mesa_GetBooleanv);
SET_GetDoublev(exec, _mesa_GetDoublev);
SET_GetIntegerv(exec, _mesa_GetIntegerv);
SET_GetLightfv(exec, _mesa_GetLightfv);
SET_GetLightiv(exec, _mesa_GetLightiv);
SET_GetMaterialfv(exec, _mesa_GetMaterialfv);
SET_GetMaterialiv(exec, _mesa_GetMaterialiv);
SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple);
SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv);
SET_GetTexEnviv(exec, _mesa_GetTexEnviv);
SET_GetTexLevelParameterfv(exec, _mesa_GetTexLevelParameterfv);
SET_GetTexLevelParameteriv(exec, _mesa_GetTexLevelParameteriv);
SET_GetTexParameterfv(exec, _mesa_GetTexParameterfv);
SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv);
SET_GetTexImage(exec, _mesa_GetTexImage);
SET_Hint(exec, _mesa_Hint);
SET_IndexMask(exec, _mesa_IndexMask);
SET_IsEnabled(exec, _mesa_IsEnabled);
SET_LightModelf(exec, _mesa_LightModelf);
SET_LightModelfv(exec, _mesa_LightModelfv);
SET_LightModeli(exec, _mesa_LightModeli);
SET_LightModeliv(exec, _mesa_LightModeliv);
SET_Lightf(exec, _mesa_Lightf);
SET_Lightfv(exec, _mesa_Lightfv);
SET_Lighti(exec, _mesa_Lighti);
SET_Lightiv(exec, _mesa_Lightiv);
SET_LoadMatrixd(exec, _mesa_LoadMatrixd);
_mesa_init_eval_dispatch(exec);
SET_MultMatrixd(exec, _mesa_MultMatrixd);
_mesa_init_pixel_dispatch(exec);
SET_PixelStoref(exec, _mesa_PixelStoref);
SET_PointSize(exec, _mesa_PointSize);
SET_PolygonMode(exec, _mesa_PolygonMode);
SET_PolygonOffset(exec, _mesa_PolygonOffset);
SET_PolygonStipple(exec, _mesa_PolygonStipple);
_mesa_init_attrib_dispatch(exec);
_mesa_init_rastpos_dispatch(exec);
SET_ReadPixels(exec, _mesa_ReadPixels);
SET_Rotated(exec, _mesa_Rotated);
SET_Scaled(exec, _mesa_Scaled);
SET_TexEnvf(exec, _mesa_TexEnvf);
SET_TexEnviv(exec, _mesa_TexEnviv);
_mesa_init_texgen_dispatch(exec);
SET_TexImage1D(exec, _mesa_TexImage1D);
SET_TexParameterf(exec, _mesa_TexParameterf);
SET_TexParameterfv(exec, _mesa_TexParameterfv);
SET_TexParameteriv(exec, _mesa_TexParameteriv);
SET_Translated(exec, _mesa_Translated);
/* 1.1 */
SET_BindTexture(exec, _mesa_BindTexture);
SET_DeleteTextures(exec, _mesa_DeleteTextures);
SET_GenTextures(exec, _mesa_GenTextures);
#if _HAVE_FULL_GL
SET_AreTexturesResident(exec, _mesa_AreTexturesResident);
SET_ColorPointer(exec, _mesa_ColorPointer);
SET_CopyTexImage1D(exec, _mesa_CopyTexImage1D);
SET_CopyTexImage2D(exec, _mesa_CopyTexImage2D);
SET_CopyTexSubImage1D(exec, _mesa_CopyTexSubImage1D);
SET_CopyTexSubImage2D(exec, _mesa_CopyTexSubImage2D);
SET_DisableClientState(exec, _mesa_DisableClientState);
SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer);
SET_EnableClientState(exec, _mesa_EnableClientState);
SET_GetPointerv(exec, _mesa_GetPointerv);
SET_IndexPointer(exec, _mesa_IndexPointer);
SET_InterleavedArrays(exec, _mesa_InterleavedArrays);
SET_IsTexture(exec, _mesa_IsTexture);
SET_NormalPointer(exec, _mesa_NormalPointer);
SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures);
SET_TexCoordPointer(exec, _mesa_TexCoordPointer);
SET_TexSubImage1D(exec, _mesa_TexSubImage1D);
SET_TexSubImage2D(exec, _mesa_TexSubImage2D);
SET_VertexPointer(exec, _mesa_VertexPointer);
#endif
/* 3. GL_EXT_polygon_offset */
#if _HAVE_FULL_GL
SET_PolygonOffsetEXT(exec, _mesa_PolygonOffsetEXT);
#endif
/* 30. GL_EXT_vertex_array */
#if _HAVE_FULL_GL
SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT);
SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT);
SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT);
SET_NormalPointerEXT(exec, _mesa_NormalPointerEXT);
SET_TexCoordPointerEXT(exec, _mesa_TexCoordPointerEXT);
SET_VertexPointerEXT(exec, _mesa_VertexPointerEXT);
#endif
/* 54. GL_EXT_point_parameters */
#if _HAVE_FULL_GL
SET_PointParameterfEXT(exec, _mesa_PointParameterf);
SET_PointParameterfvEXT(exec, _mesa_PointParameterfv);
#endif
/* 97. GL_EXT_compiled_vertex_array */
#if _HAVE_FULL_GL
SET_LockArraysEXT(exec, _mesa_LockArraysEXT);
SET_UnlockArraysEXT(exec, _mesa_UnlockArraysEXT);
#endif
/* 197. GL_MESA_window_pos */
/* part of _mesa_init_rastpos_dispatch(exec); */
/* 200. GL_IBM_multimode_draw_arrays */
#if _HAVE_FULL_GL
SET_MultiModeDrawArraysIBM(exec, _mesa_MultiModeDrawArraysIBM);
SET_MultiModeDrawElementsIBM(exec, _mesa_MultiModeDrawElementsIBM);
#endif
/* 262. GL_NV_point_sprite */
#if _HAVE_FULL_GL
SET_PointParameteriNV(exec, _mesa_PointParameteri);
SET_PointParameterivNV(exec, _mesa_PointParameteriv);
#endif
/* ???. GL_EXT_depth_bounds_test */
SET_DepthBoundsEXT(exec, _mesa_DepthBoundsEXT);
/* ARB 3. GL_ARB_transpose_matrix */
#if _HAVE_FULL_GL
SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB);
SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB);
SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB);
SET_MultTransposeMatrixfARB(exec, _mesa_MultTransposeMatrixfARB);
#endif
/* ARB 5. GL_ARB_multisample */
#if _HAVE_FULL_GL
SET_SampleCoverageARB(exec, _mesa_SampleCoverageARB);
#endif
/* ARB 14. GL_ARB_point_parameters */
/* reuse EXT_point_parameters functions */
/* ARB 28. GL_ARB_vertex_buffer_object */
SET_BindBufferARB(exec, _mesa_BindBufferARB);
SET_BufferDataARB(exec, _mesa_BufferDataARB);
SET_BufferSubDataARB(exec, _mesa_BufferSubDataARB);
SET_DeleteBuffersARB(exec, _mesa_DeleteBuffersARB);
SET_GenBuffersARB(exec, _mesa_GenBuffersARB);
SET_GetBufferParameterivARB(exec, _mesa_GetBufferParameterivARB);
SET_GetBufferPointervARB(exec, _mesa_GetBufferPointervARB);
SET_GetBufferSubDataARB(exec, _mesa_GetBufferSubDataARB);
SET_IsBufferARB(exec, _mesa_IsBufferARB);
SET_MapBufferARB(exec, _mesa_MapBufferARB);
SET_UnmapBufferARB(exec, _mesa_UnmapBufferARB);
#if FEATURE_ARB_map_buffer_range
SET_MapBufferRange(exec, _mesa_MapBufferRange);
SET_FlushMappedBufferRange(exec, _mesa_FlushMappedBufferRange);
#endif
/* GL_EXT_texture_integer */
SET_ClearColorIiEXT(exec, _mesa_ClearColorIiEXT);
SET_ClearColorIuiEXT(exec, _mesa_ClearColorIuiEXT);
SET_GetTexParameterIivEXT(exec, _mesa_GetTexParameterIiv);
SET_GetTexParameterIuivEXT(exec, _mesa_GetTexParameterIuiv);
SET_TexParameterIivEXT(exec, _mesa_TexParameterIiv);
SET_TexParameterIuivEXT(exec, _mesa_TexParameterIuiv);
/* GL_ARB_texture_storage */
SET_TexStorage1D(exec, _mesa_TexStorage1D);
SET_TexStorage2D(exec, _mesa_TexStorage2D);
SET_TexStorage3D(exec, _mesa_TexStorage3D);
SET_TextureStorage1DEXT(exec, _mesa_TextureStorage1DEXT);
SET_TextureStorage2DEXT(exec, _mesa_TextureStorage2DEXT);
SET_TextureStorage3DEXT(exec, _mesa_TextureStorage3DEXT);
return exec;
}
#endif /* FEATURE_GL */

View File

@@ -1,45 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2008 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.
*/
#ifndef API_EXEC_H
#define API_EXEC_H
struct _glapi_table;
extern struct _glapi_table *
_mesa_alloc_dispatch_table(int size);
extern struct _glapi_table *
_mesa_create_exec_table(void);
extern struct _glapi_table *
_mesa_create_exec_table_es1(void);
extern struct _glapi_table *
_mesa_create_exec_table_es2(void);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,48 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef API_LOOPBACK_H
#define API_LOOPBACK_H
#include "main/compiler.h"
#include "main/mfeatures.h"
struct _glapi_table;
#if FEATURE_beginend
extern void _mesa_loopback_init_api_table( struct _glapi_table *dest );
#else /* FEATURE_beginend */
static inline void
_mesa_loopback_init_api_table( struct _glapi_table *dest )
{
}
#endif /* FEATURE_beginend */
#endif /* API_LOOPBACK_H */

View File

@@ -1,252 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2007 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.
*/
#include <precomp.h>
/**
* \return number of bytes in array [count] of type.
*/
static GLsizei
index_bytes(GLenum type, GLsizei count)
{
if (type == GL_UNSIGNED_INT) {
return count * sizeof(GLuint);
}
else if (type == GL_UNSIGNED_BYTE) {
return count * sizeof(GLubyte);
}
else {
ASSERT(type == GL_UNSIGNED_SHORT);
return count * sizeof(GLushort);
}
}
/**
* Find the max index in the given element/index buffer
*/
GLuint
_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type,
const void *indices,
struct gl_buffer_object *elementBuf)
{
const GLubyte *map = NULL;
GLuint max = 0;
GLuint i;
if (_mesa_is_bufferobj(elementBuf)) {
/* elements are in a user-defined buffer object. need to map it */
map = ctx->Driver.MapBufferRange(ctx, 0, elementBuf->Size,
GL_MAP_READ_BIT, elementBuf);
/* Actual address is the sum of pointers */
indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices);
}
if (type == GL_UNSIGNED_INT) {
for (i = 0; i < count; i++)
if (((GLuint *) indices)[i] > max)
max = ((GLuint *) indices)[i];
}
else if (type == GL_UNSIGNED_SHORT) {
for (i = 0; i < count; i++)
if (((GLushort *) indices)[i] > max)
max = ((GLushort *) indices)[i];
}
else {
ASSERT(type == GL_UNSIGNED_BYTE);
for (i = 0; i < count; i++)
if (((GLubyte *) indices)[i] > max)
max = ((GLubyte *) indices)[i];
}
if (map) {
ctx->Driver.UnmapBuffer(ctx, elementBuf);
}
return max;
}
/**
* Check if OK to draw arrays/elements.
*/
static GLboolean
check_valid_to_render(struct gl_context *ctx, const char *function)
{
if (!_mesa_valid_to_render(ctx, function)) {
return GL_FALSE;
}
/* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic
* array [0]).
*/
return ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled;
}
/**
* Do bounds checking on array element indexes. Check that the vertices
* pointed to by the indices don't lie outside buffer object bounds.
* \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds
*/
static GLboolean
check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type,
const GLvoid *indices)
{
struct _mesa_prim prim;
struct _mesa_index_buffer ib;
GLuint min, max;
/* Only the X Server needs to do this -- otherwise, accessing outside
* array/BO bounds allows application termination.
*/
if (!ctx->Const.CheckArrayBounds)
return GL_TRUE;
memset(&prim, 0, sizeof(prim));
prim.count = count;
memset(&ib, 0, sizeof(ib));
ib.type = type;
ib.ptr = indices;
ib.obj = ctx->Array.ElementArrayBufferObj;
vbo_get_minmax_index(ctx, &prim, &ib, &min, &max);
if (max >= ctx->Array._MaxElement) {
/* the max element is out of bounds of one or more enabled arrays */
_mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)",
max, ctx->Array._MaxElement);
return GL_FALSE;
}
return GL_TRUE;
}
/**
* Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
* etc? The set of legal values depends on whether geometry shaders/programs
* are supported.
*/
GLboolean
_mesa_valid_prim_mode(const struct gl_context *ctx, GLenum mode)
{
if (mode > GL_POLYGON) {
return GL_FALSE;
}
else {
return GL_TRUE;
}
}
/**
* Error checking for glDrawElements(). Includes parameter checking
* and VBO bounds checking.
* \return GL_TRUE if OK to render, GL_FALSE if error found
*/
GLboolean
_mesa_validate_DrawElements(struct gl_context *ctx,
GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices)
{
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
if (count <= 0) {
if (count < 0)
_mesa_error(ctx, GL_INVALID_VALUE, "glDrawElements(count)" );
return GL_FALSE;
}
if (!_mesa_valid_prim_mode(ctx, mode)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(mode)" );
return GL_FALSE;
}
if (type != GL_UNSIGNED_INT &&
type != GL_UNSIGNED_BYTE &&
type != GL_UNSIGNED_SHORT)
{
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
return GL_FALSE;
}
if (!check_valid_to_render(ctx, "glDrawElements"))
return GL_FALSE;
/* Vertex buffer object tests */
if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
/* use indices in the buffer object */
/* make sure count doesn't go outside buffer bounds */
if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) {
_mesa_warning(ctx, "glDrawElements index out of buffer bounds");
return GL_FALSE;
}
}
else {
/* not using a VBO */
if (!indices)
return GL_FALSE;
}
if (!check_index_bounds(ctx, count, type, indices))
return GL_FALSE;
return GL_TRUE;
}
/**
* Called from the tnl module to error check the function parameters and
* verify that we really can draw something.
* \return GL_TRUE if OK to render, GL_FALSE if error found
*/
GLboolean
_mesa_validate_DrawArrays(struct gl_context *ctx,
GLenum mode, GLint start, GLsizei count)
{
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
if (count <= 0) {
if (count < 0)
_mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" );
return GL_FALSE;
}
if (!_mesa_valid_prim_mode(ctx, mode)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" );
return GL_FALSE;
}
if (!check_valid_to_render(ctx, "glDrawArrays"))
return GL_FALSE;
if (ctx->Const.CheckArrayBounds) {
if (start + count > (GLint) ctx->Array._MaxElement)
return GL_FALSE;
}
return GL_TRUE;
}

View File

@@ -1,58 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef API_VALIDATE_H
#define API_VALIDATE_H
#include "glheader.h"
#include "mfeatures.h"
struct gl_buffer_object;
struct gl_context;
struct gl_transform_feedback_object;
extern GLuint
_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type,
const void *indices,
struct gl_buffer_object *elementBuf);
extern GLboolean
_mesa_valid_prim_mode(const struct gl_context *ctx, GLenum mode);
extern GLboolean
_mesa_validate_DrawArrays(struct gl_context *ctx,
GLenum mode, GLint start, GLsizei count);
extern GLboolean
_mesa_validate_DrawElements(struct gl_context *ctx,
GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,80 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2007 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.
*/
#ifndef ATTRIB_H
#define ATTRIB_H
#include "compiler.h"
#include "glheader.h"
#include "mfeatures.h"
struct _glapi_table;
struct gl_context;
#if FEATURE_attrib_stack
extern void GLAPIENTRY
_mesa_PushAttrib( GLbitfield mask );
extern void GLAPIENTRY
_mesa_PopAttrib( void );
extern void GLAPIENTRY
_mesa_PushClientAttrib( GLbitfield mask );
extern void GLAPIENTRY
_mesa_PopClientAttrib( void );
extern void
_mesa_init_attrib_dispatch(struct _glapi_table *disp);
#else /* FEATURE_attrib_stack */
static inline void
_mesa_PushClientAttrib( GLbitfield mask )
{
ASSERT_NO_FEATURE();
}
static inline void
_mesa_PopClientAttrib( void )
{
ASSERT_NO_FEATURE();
}
static inline void
_mesa_init_attrib_dispatch(struct _glapi_table *disp)
{
}
#endif /* FEATURE_attrib_stack */
extern void
_mesa_init_attrib( struct gl_context *ctx );
extern void
_mesa_free_attrib_data( struct gl_context *ctx );
#endif /* ATTRIB_H */

View File

@@ -1,160 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 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.
*/
/**
* \file bitset.h
* \brief Bitset of arbitrary size definitions.
* \author Michal Krol
*/
#ifndef BITSET_H
#define BITSET_H
#include "imports.h"
/****************************************************************************
* generic bitset implementation
*/
#define BITSET_WORD GLuint
#define BITSET_WORDBITS (sizeof (BITSET_WORD) * 8)
/* bitset declarations
*/
#define BITSET_DECLARE(name, size) \
BITSET_WORD name[((size) + BITSET_WORDBITS - 1) / BITSET_WORDBITS]
/* bitset operations
*/
#define BITSET_COPY(x, y) memcpy( (x), (y), sizeof (x) )
#define BITSET_EQUAL(x, y) (memcmp( (x), (y), sizeof (x) ) == 0)
#define BITSET_ZERO(x) memset( (x), 0, sizeof (x) )
#define BITSET_ONES(x) memset( (x), 0xff, sizeof (x) )
#define BITSET_BITWORD(b) ((b) / BITSET_WORDBITS)
#define BITSET_BIT(b) (1 << ((b) % BITSET_WORDBITS))
/* single bit operations
*/
#define BITSET_TEST(x, b) ((x)[BITSET_BITWORD(b)] & BITSET_BIT(b))
#define BITSET_SET(x, b) ((x)[BITSET_BITWORD(b)] |= BITSET_BIT(b))
#define BITSET_CLEAR(x, b) ((x)[BITSET_BITWORD(b)] &= ~BITSET_BIT(b))
#define BITSET_MASK(b) ((b) == BITSET_WORDBITS ? ~0 : BITSET_BIT(b) - 1)
#define BITSET_RANGE(b, e) (BITSET_MASK((e) + 1) & ~BITSET_MASK(b))
/* bit range operations
*/
#define BITSET_TEST_RANGE(x, b, e) \
(BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \
((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) : \
(assert (!"BITSET_TEST_RANGE: bit range crosses word boundary"), 0))
#define BITSET_SET_RANGE(x, b, e) \
(BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \
((x)[BITSET_BITWORD(b)] |= BITSET_RANGE(b, e)) : \
(assert (!"BITSET_SET_RANGE: bit range crosses word boundary"), 0))
#define BITSET_CLEAR_RANGE(x, b, e) \
(BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \
((x)[BITSET_BITWORD(b)] &= ~BITSET_RANGE(b, e)) : \
(assert (!"BITSET_CLEAR_RANGE: bit range crosses word boundary"), 0))
/* Get first bit set in a bitset.
*/
static inline int
__bitset_ffs(const BITSET_WORD *x, int n)
{
int i;
for (i = 0; i < n; i++) {
if (x[i])
return _mesa_ffs(x[i]) + BITSET_WORDBITS * i;
}
return 0;
}
#define BITSET_FFS(x) __bitset_ffs(x, Elements(x))
/****************************************************************************
* 64-bit bitset implementation
*/
#define BITSET64_WORD GLuint
#define BITSET64_WORDBITS (sizeof (BITSET64_WORD) * 8)
/* bitset declarations
*/
#define BITSET64_DECLARE(name, size) \
GLuint name[2]
/* bitset operations
*/
#define BITSET64_COPY(x, y) do { (x)[0] = (y)[0]; (x)[1] = (y)[1]; } while (0)
#define BITSET64_EQUAL(x, y) ( (x)[0] == (y)[0] && (x)[1] == (y)[1] )
#define BITSET64_ZERO(x) do { (x)[0] = 0; (x)[1] = 0; } while (0)
#define BITSET64_ONES(x) do { (x)[0] = 0xFF; (x)[1] = 0xFF; } while (0)
#define BITSET64_BITWORD(b) ((b) / BITSET64_WORDBITS)
#define BITSET64_BIT(b) (1 << ((b) % BITSET64_WORDBITS))
/* single bit operations
*/
#define BITSET64_TEST(x, b) ((x)[BITSET64_BITWORD(b)] & BITSET64_BIT(b))
#define BITSET64_SET(x, b) ((x)[BITSET64_BITWORD(b)] |= BITSET64_BIT(b))
#define BITSET64_CLEAR(x, b) ((x)[BITSET64_BITWORD(b)] &= ~BITSET64_BIT(b))
#define BITSET64_MASK(b) ((b) == BITSET64_WORDBITS ? ~0 : BITSET64_BIT(b) - 1)
#define BITSET64_RANGE(b, e) (BITSET64_MASK((e) + 1) & ~BITSET64_MASK(b))
/* bit range operations
*/
#define BITSET64_TEST_SUBRANGE(x, b, e) \
(BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
((x)[BITSET64_BITWORD(b)] & BITSET64_RANGE(b, e)) : \
(assert (!"BITSET64_TEST_RANGE: bit range crosses word boundary"), 0))
#define BITSET64_TEST_RANGE(x, b, e) \
(BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
(BITSET64_TEST_SUBRANGE(x, b, e)) : \
(BITSET64_TEST_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \
BITSET64_TEST_SUBRANGE(x, BITSET64_WORDBITS, e)))
#define BITSET64_SET_SUBRANGE(x, b, e) \
(BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
((x)[BITSET64_BITWORD(b)] |= BITSET64_RANGE(b, e)) : \
(assert (!"BITSET64_SET_RANGE: bit range crosses word boundary"), 0))
#define BITSET64_SET_RANGE(x, b, e) \
(BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
(BITSET64_SET_SUBRANGE(x, b, e)) : \
(BITSET64_SET_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \
BITSET64_SET_SUBRANGE(x, BITSET64_WORDBITS, e)))
#define BITSET64_CLEAR_SUBRANGE(x, b, e) \
(BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
((x)[BITSET64_BITWORD(b)] &= ~BITSET64_RANGE(b, e)) : \
(assert (!"BITSET64_CLEAR_RANGE: bit range crosses word boundary"), 0))
#define BITSET64_CLEAR_RANGE(x, b, e) \
(BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \
(BITSET64_CLEAR_SUBRANGE(x, b, e)) : \
(BITSET64_CLEAR_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \
BITSET64_CLEAR_SUBRANGE(x, BITSET64_WORDBITS, e)))
#endif

View File

@@ -1,352 +0,0 @@
/**
* \file blend.c
* Blending operations.
*/
/*
* Mesa 3-D graphics library
* Version: 6.5.1
*
* Copyright (C) 1999-2006 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.
*/
#include <precomp.h>
/**
* Check if given blend source factor is legal.
* \return GL_TRUE if legal, GL_FALSE otherwise.
*/
static GLboolean
legal_src_factor(const struct gl_context *ctx, GLenum factor)
{
switch (factor) {
case GL_SRC_COLOR:
case GL_ONE_MINUS_SRC_COLOR:
return ctx->Extensions.NV_blend_square;
case GL_ZERO:
case GL_ONE:
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
case GL_SRC_ALPHA_SATURATE:
case GL_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
case GL_ONE_MINUS_CONSTANT_ALPHA:
return GL_TRUE;
default:
return GL_FALSE;
}
}
/**
* Check if given blend destination factor is legal.
* \return GL_TRUE if legal, GL_FALSE otherwise.
*/
static GLboolean
legal_dst_factor(const struct gl_context *ctx, GLenum factor)
{
switch (factor) {
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
return ctx->Extensions.NV_blend_square;
case GL_ZERO:
case GL_ONE:
case GL_SRC_COLOR:
case GL_ONE_MINUS_SRC_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
case GL_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
case GL_ONE_MINUS_CONSTANT_ALPHA:
return GL_TRUE;
default:
return GL_FALSE;
}
}
/**
* Check if src/dest RGB/A blend factors are legal. If not generate
* a GL error.
* \return GL_TRUE if factors are legal, GL_FALSE otherwise.
*/
static GLboolean
validate_blend_factors(struct gl_context *ctx, const char *func,
GLenum srcfactor, GLenum dstfactor)
{
if (!legal_src_factor(ctx, srcfactor)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"%s(sfactorRGB = %s)", func,
_mesa_lookup_enum_by_nr(srcfactor));
return GL_FALSE;
}
if (!legal_dst_factor(ctx, dstfactor)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"%s(dfactorRGB = %s)", func,
_mesa_lookup_enum_by_nr(dstfactor));
return GL_FALSE;
}
return GL_TRUE;
}
/**
* Specify the blending operation.
*
* \param sfactor source factor operator.
* \param dfactor destination factor operator.
*
* \sa glBlendFunc
*/
void GLAPIENTRY
_mesa_BlendFunc( GLenum sfactor, GLenum dfactor )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glBlendFunc %s %s\n",
_mesa_lookup_enum_by_nr(sfactor),
_mesa_lookup_enum_by_nr(dfactor));
if (!validate_blend_factors(ctx, "glBlendFunc", sfactor, dfactor)) {
return;
}
if (ctx->Color.SrcFactor == sfactor &&
ctx->Color.DstFactor == dfactor) {
return;
}
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.SrcFactor = sfactor;
ctx->Color.DstFactor = dfactor;
}
/**
* Specify the alpha test function.
*
* \param func alpha comparison function.
* \param ref reference value.
*
* Verifies the parameters and updates gl_colorbuffer_attrib.
* On a change, flushes the vertices and notifies the driver via
* dd_function_table::AlphaFunc callback.
*/
void GLAPIENTRY
_mesa_AlphaFunc( GLenum func, GLclampf ref )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glAlphaFunc(%s, %f)\n",
_mesa_lookup_enum_by_nr(func), ref);
switch (func) {
case GL_NEVER:
case GL_LESS:
case GL_EQUAL:
case GL_LEQUAL:
case GL_GREATER:
case GL_NOTEQUAL:
case GL_GEQUAL:
case GL_ALWAYS:
if (ctx->Color.AlphaFunc == func && ctx->Color.AlphaRef == ref)
return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.AlphaFunc = func;
ctx->Color.AlphaRef = ref;
if (ctx->Driver.AlphaFunc)
ctx->Driver.AlphaFunc(ctx, func, ctx->Color.AlphaRef);
return;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glAlphaFunc(func)" );
return;
}
}
/**
* Specify a logic pixel operation for color index rendering.
*
* \param opcode operation.
*
* Verifies that \p opcode is a valid enum and updates
gl_colorbuffer_attrib::LogicOp.
* On a change, flushes the vertices and notifies the driver via the
* dd_function_table::LogicOpcode callback.
*/
void GLAPIENTRY
_mesa_LogicOp( GLenum opcode )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glLogicOp(%s)\n", _mesa_lookup_enum_by_nr(opcode));
switch (opcode) {
case GL_CLEAR:
case GL_SET:
case GL_COPY:
case GL_COPY_INVERTED:
case GL_NOOP:
case GL_INVERT:
case GL_AND:
case GL_NAND:
case GL_OR:
case GL_NOR:
case GL_XOR:
case GL_EQUIV:
case GL_AND_REVERSE:
case GL_AND_INVERTED:
case GL_OR_REVERSE:
case GL_OR_INVERTED:
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glLogicOp" );
return;
}
if (ctx->Color.LogicOp == opcode)
return;
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.LogicOp = opcode;
if (ctx->Driver.LogicOpcode)
ctx->Driver.LogicOpcode( ctx, opcode );
}
#if _HAVE_FULL_GL
void GLAPIENTRY
_mesa_IndexMask( GLuint mask )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (ctx->Color.IndexMask == mask)
return;
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.IndexMask = mask;
}
#endif
/**
* Enable or disable writing of frame buffer color components.
*
* \param red whether to mask writing of the red color component.
* \param green whether to mask writing of the green color component.
* \param blue whether to mask writing of the blue color component.
* \param alpha whether to mask writing of the alpha color component.
*
* \sa glColorMask().
*
* Sets the appropriate value of gl_colorbuffer_attrib::ColorMask. On a
* change, flushes the vertices and notifies the driver via the
* dd_function_table::ColorMask callback.
*/
void GLAPIENTRY
_mesa_ColorMask( GLboolean red, GLboolean green,
GLboolean blue, GLboolean alpha )
{
GET_CURRENT_CONTEXT(ctx);
GLubyte tmp[4];
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glColorMask(%d, %d, %d, %d)\n",
red, green, blue, alpha);
/* Shouldn't have any information about channel depth in core mesa
* -- should probably store these as the native booleans:
*/
tmp[RCOMP] = red ? 0xff : 0x0;
tmp[GCOMP] = green ? 0xff : 0x0;
tmp[BCOMP] = blue ? 0xff : 0x0;
tmp[ACOMP] = alpha ? 0xff : 0x0;
if (!TEST_EQ_4V(tmp, ctx->Color.ColorMask)) {
FLUSH_VERTICES(ctx, _NEW_COLOR);
COPY_4UBV(ctx->Color.ColorMask, tmp);
}
if (ctx->Driver.ColorMask)
ctx->Driver.ColorMask( ctx, red, green, blue, alpha );
}
/**********************************************************************/
/** \name Initialization */
/*@{*/
/**
* Initialization of the context's Color attribute group.
*
* \param ctx GL context.
*
* Initializes the related fields in the context color attribute group,
* __struct gl_contextRec::Color.
*/
void _mesa_init_color( struct gl_context * ctx )
{
/* Color buffer group */
ctx->Color.IndexMask = ~0u;
memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask));
ctx->Color.ClearIndex = 0;
ASSIGN_4V( ctx->Color.ClearColor.f, 0, 0, 0, 0 );
ctx->Color.AlphaEnabled = GL_FALSE;
ctx->Color.AlphaFunc = GL_ALWAYS;
ctx->Color.AlphaRef = 0;
ctx->Color.BlendEnabled = 0x0;
ctx->Color.SrcFactor = GL_ONE;
ctx->Color.DstFactor = GL_ZERO;
ctx->Color.IndexLogicOpEnabled = GL_FALSE;
ctx->Color.ColorLogicOpEnabled = GL_FALSE;
ctx->Color.LogicOp = GL_COPY;
ctx->Color.DitherFlag = GL_TRUE;
if (ctx->Visual.doubleBufferMode) {
ctx->Color.DrawBuffer = GL_BACK;
}
else {
ctx->Color.DrawBuffer = GL_FRONT;
}
}
/*@}*/

View File

@@ -1,64 +0,0 @@
/**
* \file blend.h
* Blending functions operations.
*/
/*
* Mesa 3-D graphics library
* Version: 6.5.2
*
* Copyright (C) 1999-2006 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.
*/
#ifndef BLEND_H
#define BLEND_H
#include "glheader.h"
struct gl_context;
extern void GLAPIENTRY
_mesa_BlendFunc( GLenum sfactor, GLenum dfactor );
extern void GLAPIENTRY
_mesa_AlphaFunc( GLenum func, GLclampf ref );
extern void GLAPIENTRY
_mesa_LogicOp( GLenum opcode );
extern void GLAPIENTRY
_mesa_IndexMask( GLuint mask );
extern void GLAPIENTRY
_mesa_ColorMask( GLboolean red, GLboolean green,
GLboolean blue, GLboolean alpha );
extern void
_mesa_init_color( struct gl_context * ctx );
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,155 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.6
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* Copyright (C) 2009 VMware, Inc. 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.
*/
#ifndef BUFFEROBJ_H
#define BUFFEROBJ_H
#include "mfeatures.h"
#include "mtypes.h"
/*
* Internal functions
*/
/** Is the given buffer object currently mapped? */
static inline GLboolean
_mesa_bufferobj_mapped(const struct gl_buffer_object *obj)
{
return obj->Pointer != NULL;
}
/**
* Is the given buffer object a user-created buffer object?
* Mesa uses default buffer objects in several places. Default buffers
* always have Name==0. User created buffers have Name!=0.
*/
static inline GLboolean
_mesa_is_bufferobj(const struct gl_buffer_object *obj)
{
return obj != NULL && obj->Name != 0;
}
extern void
_mesa_init_buffer_objects( struct gl_context *ctx );
extern void
_mesa_free_buffer_objects( struct gl_context *ctx );
extern void
_mesa_update_default_objects_buffer_objects(struct gl_context *ctx);
extern struct gl_buffer_object *
_mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer);
extern void
_mesa_initialize_buffer_object( struct gl_context *ctx,
struct gl_buffer_object *obj,
GLuint name, GLenum target );
extern void
_mesa_reference_buffer_object_(struct gl_context *ctx,
struct gl_buffer_object **ptr,
struct gl_buffer_object *bufObj);
static inline void
_mesa_reference_buffer_object(struct gl_context *ctx,
struct gl_buffer_object **ptr,
struct gl_buffer_object *bufObj)
{
if (*ptr != bufObj)
_mesa_reference_buffer_object_(ctx, ptr, bufObj);
}
extern void
_mesa_init_buffer_object_functions(struct dd_function_table *driver);
/*
* API functions
*/
extern void GLAPIENTRY
_mesa_BindBufferARB(GLenum target, GLuint buffer);
extern void GLAPIENTRY
_mesa_DeleteBuffersARB(GLsizei n, const GLuint * buffer);
extern void GLAPIENTRY
_mesa_GenBuffersARB(GLsizei n, GLuint * buffer);
extern GLboolean GLAPIENTRY
_mesa_IsBufferARB(GLuint buffer);
extern void GLAPIENTRY
_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage);
extern void GLAPIENTRY
_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data);
extern void GLAPIENTRY
_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data);
extern void * GLAPIENTRY
_mesa_MapBufferARB(GLenum target, GLenum access);
extern GLboolean GLAPIENTRY
_mesa_UnmapBufferARB(GLenum target);
extern void GLAPIENTRY
_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params);
extern void GLAPIENTRY
_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params);
extern void GLAPIENTRY
_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params);
extern void * GLAPIENTRY
_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
GLbitfield access);
extern void GLAPIENTRY
_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
#if FEATURE_APPLE_object_purgeable
extern GLenum GLAPIENTRY
_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
extern GLenum GLAPIENTRY
_mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
extern void GLAPIENTRY
_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname, GLint* params);
#endif
#endif

View File

@@ -1,347 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2007 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.
*/
/**
* \file buffers.c
* glReadBuffer, DrawBuffer functions.
*/
#include <precomp.h>
#define BAD_MASK ~0u
/**
* Return bitmask of BUFFER_BIT_* flags indicating which color buffers are
* available to the rendering context (for drawing or reading).
* This depends on the type of framebuffer. For window system framebuffers
* we look at the framebuffer's visual. But for user-create framebuffers we
* look at the number of supported color attachments.
* \param fb the framebuffer to draw to, or read from
* \return bitmask of BUFFER_BIT_* flags
*/
static GLbitfield
supported_buffer_bitmask(const struct gl_context *ctx, const struct gl_framebuffer *fb)
{
GLbitfield mask = 0x0;
/* A window system framebuffer */
GLint i;
mask = BUFFER_BIT_FRONT_LEFT; /* always have this */
if (fb->Visual.stereoMode) {
mask |= BUFFER_BIT_FRONT_RIGHT;
if (fb->Visual.doubleBufferMode) {
mask |= BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT;
}
}
else if (fb->Visual.doubleBufferMode) {
mask |= BUFFER_BIT_BACK_LEFT;
}
for (i = 0; i < fb->Visual.numAuxBuffers; i++) {
mask |= (BUFFER_BIT_AUX0 << i);
}
return mask;
}
/**
* Helper routine used by glDrawBuffer and glDrawBuffersARB.
* Given a GLenum naming one or more color buffers (such as
* GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
*/
static GLbitfield
draw_buffer_enum_to_bitmask(GLenum buffer)
{
switch (buffer) {
case GL_NONE:
return 0;
case GL_FRONT:
return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT;
case GL_BACK:
return BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT;
case GL_RIGHT:
return BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT;
case GL_FRONT_RIGHT:
return BUFFER_BIT_FRONT_RIGHT;
case GL_BACK_RIGHT:
return BUFFER_BIT_BACK_RIGHT;
case GL_BACK_LEFT:
return BUFFER_BIT_BACK_LEFT;
case GL_FRONT_AND_BACK:
return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT
| BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT;
case GL_LEFT:
return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT;
case GL_FRONT_LEFT:
return BUFFER_BIT_FRONT_LEFT;
case GL_AUX0:
return BUFFER_BIT_AUX0;
case GL_AUX1:
case GL_AUX2:
case GL_AUX3:
return 1 << BUFFER_COUNT; /* invalid, but not BAD_MASK */
default:
/* error */
return BAD_MASK;
}
}
/**
* Helper routine used by glReadBuffer.
* Given a GLenum naming a color buffer, return the index of the corresponding
* renderbuffer (a BUFFER_* value).
* return -1 for an invalid buffer.
*/
static GLint
read_buffer_enum_to_index(GLenum buffer)
{
switch (buffer) {
case GL_FRONT:
return BUFFER_FRONT_LEFT;
case GL_BACK:
return BUFFER_BACK_LEFT;
case GL_RIGHT:
return BUFFER_FRONT_RIGHT;
case GL_FRONT_RIGHT:
return BUFFER_FRONT_RIGHT;
case GL_BACK_RIGHT:
return BUFFER_BACK_RIGHT;
case GL_BACK_LEFT:
return BUFFER_BACK_LEFT;
case GL_LEFT:
return BUFFER_FRONT_LEFT;
case GL_FRONT_LEFT:
return BUFFER_FRONT_LEFT;
case GL_AUX0:
return BUFFER_AUX0;
case GL_AUX1:
case GL_AUX2:
case GL_AUX3:
return BUFFER_COUNT; /* invalid, but not -1 */
default:
/* error */
return -1;
}
}
/**
* Called by glDrawBuffer().
* Specify which renderbuffer(s) to draw into for the first color output.
* <buffer> can name zero, one, two or four renderbuffers!
* \sa _mesa_DrawBuffersARB
*
* \param buffer buffer token such as GL_LEFT or GL_FRONT_AND_BACK, etc.
*
* Note that the behaviour of this function depends on whether the
* current ctx->DrawBuffer is a window-system framebuffer (Name=0) or
* a user-created framebuffer object (Name!=0).
* In the former case, we update the per-context ctx->Color.DrawBuffer
* state var _and_ the FB's ColorDrawBuffer state.
* In the later case, we update the FB's ColorDrawBuffer state only.
*
* Furthermore, upon a MakeCurrent() or BindFramebuffer() call, if the
* new FB is a window system FB, we need to re-update the FB's
* ColorDrawBuffer state to match the context. This is handled in
* _mesa_update_framebuffer().
*
* See the GL_EXT_framebuffer_object spec for more info.
*/
void GLAPIENTRY
_mesa_DrawBuffer(GLenum buffer)
{
GLbitfield destMask;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex... */
if (MESA_VERBOSE & VERBOSE_API) {
_mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
}
if (buffer == GL_NONE) {
destMask = 0x0;
}
else {
const GLbitfield supportedMask
= supported_buffer_bitmask(ctx, ctx->DrawBuffer);
destMask = draw_buffer_enum_to_bitmask(buffer);
if (destMask == BAD_MASK) {
/* totally bogus buffer */
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(buffer=0x%x)", buffer);
return;
}
destMask &= supportedMask;
if (destMask == 0x0) {
/* none of the named color buffers exist! */
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawBuffer(buffer=0x%x)", buffer);
return;
}
}
/* if we get here, there's no error so set new state */
_mesa_drawbuffer(ctx, buffer, destMask);
/*
* Call device driver function.
*/
if (ctx->Driver.DrawBuffer)
ctx->Driver.DrawBuffer(ctx, buffer);
}
/**
* Performs necessary state updates when _mesa_drawbuffers makes an
* actual change.
*/
static void
updated_drawbuffers(struct gl_context *ctx)
{
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
}
/**
* Helper function to set the GL_DRAW_BUFFER state in the context and
* current FBO. Called via glDrawBuffer(), glDrawBuffersARB()
*
* All error checking will have been done prior to calling this function
* so nothing should go wrong at this point.
*
* \param ctx current context
* \param n number of color outputs to set
* \param buffers array[n] of colorbuffer names, like GL_LEFT.
* \param destMask array[n] of BUFFER_BIT_* bitmasks which correspond to the
* colorbuffer names. (i.e. GL_FRONT_AND_BACK =>
* BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
*/
void
_mesa_drawbuffer(struct gl_context *ctx, const GLenum buffers, GLbitfield destMask)
{
struct gl_framebuffer *fb = ctx->DrawBuffer;
GLint bufIndex;
if (!destMask) {
/* compute destMask values now */
const GLbitfield supportedMask = supported_buffer_bitmask(ctx, fb);
destMask = draw_buffer_enum_to_bitmask(buffers);
ASSERT(destmask != BAD_MASK);
destMask &= supportedMask;
}
bufIndex = _mesa_ffs(destMask) - 1;
if (fb->_ColorDrawBufferIndex != bufIndex) {
updated_drawbuffers(ctx);
fb->_ColorDrawBufferIndex = bufIndex;
}
fb->ColorDrawBuffer = buffers;
if (ctx->Color.DrawBuffer != fb->ColorDrawBuffer) {
updated_drawbuffers(ctx);
ctx->Color.DrawBuffer = fb->ColorDrawBuffer;
}
}
/**
* Update the current drawbuffer's _ColorDrawBufferIndex[] list, etc.
* from the context's Color.DrawBuffer[] state.
* Use when changing contexts.
*/
void
_mesa_update_draw_buffer(struct gl_context *ctx)
{
_mesa_drawbuffer(ctx, ctx->Color.DrawBuffer, 0);
}
/**
* Like \sa _mesa_drawbuffers(), this is a helper function for setting
* GL_READ_BUFFER state in the context and current FBO.
* \param ctx the rendering context
* \param buffer GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENT0, etc.
* \param bufferIndex the numerical index corresponding to 'buffer'
*/
void
_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex)
{
struct gl_framebuffer *fb = ctx->ReadBuffer;
ctx->Pixel.ReadBuffer = buffer;
fb->ColorReadBuffer = buffer;
fb->_ColorReadBufferIndex = bufferIndex;
ctx->NewState |= _NEW_BUFFERS;
}
/**
* Called by glReadBuffer to set the source renderbuffer for reading pixels.
* \param mode color buffer such as GL_FRONT, GL_BACK, etc.
*/
void GLAPIENTRY
_mesa_ReadBuffer(GLenum buffer)
{
struct gl_framebuffer *fb;
GLbitfield supportedMask;
GLint srcBuffer;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
fb = ctx->ReadBuffer;
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
/* general case / window-system framebuffer */
srcBuffer = read_buffer_enum_to_index(buffer);
if (srcBuffer == -1) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glReadBuffer(buffer=0x%x)", buffer);
return;
}
supportedMask = supported_buffer_bitmask(ctx, fb);
if (((1 << srcBuffer) & supportedMask) == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glReadBuffer(buffer=0x%x)", buffer);
return;
}
/* OK, all error checking has been completed now */
_mesa_readbuffer(ctx, buffer, srcBuffer);
ctx->NewState |= _NEW_BUFFERS;
/*
* Call device driver function.
*/
if (ctx->Driver.ReadBuffer)
(*ctx->Driver.ReadBuffer)(ctx, buffer);
}

View File

@@ -1,57 +0,0 @@
/**
* \file buffers.h
* Frame buffer management functions declarations.
*/
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2007 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.
*/
#ifndef BUFFERS_H
#define BUFFERS_H
#include "glheader.h"
struct gl_context;
extern void GLAPIENTRY
_mesa_DrawBuffer( GLenum mode );
extern void
_mesa_drawbuffer(struct gl_context *ctx, const GLenum buffers, GLbitfield destMask);
extern void
_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex);
extern void
_mesa_update_draw_buffer(struct gl_context *ctx);
extern void GLAPIENTRY
_mesa_ReadBuffer( GLenum mode );
#endif

View File

@@ -1,223 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2007 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.
*/
/**
* \file clear.c
* glClearColor, glClearIndex, glClear() functions.
*/
#include <precomp.h>
#if _HAVE_FULL_GL
void GLAPIENTRY
_mesa_ClearIndex( GLfloat c )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (ctx->Color.ClearIndex == (GLuint) c)
return;
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.ClearIndex = (GLuint) c;
}
#endif
/**
* Specify the clear values for the color buffers.
*
* \param red red color component.
* \param green green color component.
* \param blue blue color component.
* \param alpha alpha component.
*
* \sa glClearColor().
*
* Clamps the parameters and updates gl_colorbuffer_attrib::ClearColor. On a
* change, flushes the vertices and notifies the driver via the
* dd_function_table::ClearColor callback.
*/
void GLAPIENTRY
_mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
{
GLfloat tmp[4];
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
tmp[0] = red;
tmp[1] = green;
tmp[2] = blue;
tmp[3] = alpha;
if (TEST_EQ_4V(tmp, ctx->Color.ClearColor.f))
return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
COPY_4V(ctx->Color.ClearColor.f, tmp);
if (ctx->Driver.ClearColor) {
/* it's OK to call glClearColor in CI mode but it should be a NOP */
/* we pass the clamped color, since all drivers that need this don't
* support GL_ARB_color_buffer_float
*/
(*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor);
}
}
/**
* GL_EXT_texture_integer
*/
void GLAPIENTRY
_mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a)
{
GLint tmp[4];
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
tmp[0] = r;
tmp[1] = g;
tmp[2] = b;
tmp[3] = a;
if (TEST_EQ_4V(tmp, ctx->Color.ClearColor.i))
return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
COPY_4V(ctx->Color.ClearColor.i, tmp);
/* these should be NOP calls for drivers supporting EXT_texture_integer */
if (ctx->Driver.ClearColor) {
ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor);
}
}
/**
* GL_EXT_texture_integer
*/
void GLAPIENTRY
_mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a)
{
GLuint tmp[4];
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
tmp[0] = r;
tmp[1] = g;
tmp[2] = b;
tmp[3] = a;
if (TEST_EQ_4V(tmp, ctx->Color.ClearColor.ui))
return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
COPY_4V(ctx->Color.ClearColor.ui, tmp);
/* these should be NOP calls for drivers supporting EXT_texture_integer */
if (ctx->Driver.ClearColor) {
ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor);
}
}
/**
* Clear buffers.
*
* \param mask bit-mask indicating the buffers to be cleared.
*
* Flushes the vertices and verifies the parameter. If __struct gl_contextRec::NewState
* is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin,
* etc. If the rasterization mode is set to GL_RENDER then requests the driver
* to clear the buffers, via the dd_function_table::Clear callback.
*/
void GLAPIENTRY
_mesa_Clear( GLbitfield mask )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
FLUSH_CURRENT(ctx, 0);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glClear 0x%x\n", mask);
if (mask & ~(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT |
GL_ACCUM_BUFFER_BIT)) {
/* invalid bit set */
_mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask);
return;
}
if (ctx->NewState) {
_mesa_update_state( ctx ); /* update _Xmin, etc */
}
if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0 ||
ctx->DrawBuffer->_Xmin >= ctx->DrawBuffer->_Xmax ||
ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax)
return;
if (ctx->RasterDiscard)
return;
if (ctx->RenderMode == GL_RENDER) {
GLbitfield bufferMask;
/* don't clear depth buffer if depth writing disabled */
if (!ctx->Depth.Mask)
mask &= ~GL_DEPTH_BUFFER_BIT;
/* Build the bitmask to send to device driver's Clear function.
* Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4
* of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the
* BUFFER_BIT_COLORn flags.
*/
bufferMask = 0;
if (mask & GL_COLOR_BUFFER_BIT) {
bufferMask |= (1 << ctx->DrawBuffer->_ColorDrawBufferIndex);
}
if ((mask & GL_DEPTH_BUFFER_BIT)
&& ctx->DrawBuffer->Visual.haveDepthBuffer) {
bufferMask |= BUFFER_BIT_DEPTH;
}
if ((mask & GL_STENCIL_BUFFER_BIT)
&& ctx->DrawBuffer->Visual.haveStencilBuffer) {
bufferMask |= BUFFER_BIT_STENCIL;
}
if ((mask & GL_ACCUM_BUFFER_BIT)
&& ctx->DrawBuffer->Visual.haveAccumBuffer) {
bufferMask |= BUFFER_BIT_ACCUM;
}
ASSERT(ctx->Driver.Clear);
ctx->Driver.Clear(ctx, bufferMask);
}
}

View File

@@ -1,51 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2007 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.
*/
#ifndef CLEAR_H
#define CLEAR_H
#include "glheader.h"
extern void GLAPIENTRY
_mesa_ClearIndex( GLfloat c );
extern void GLAPIENTRY
_mesa_ClearColor( GLclampf red, GLclampf green,
GLclampf blue, GLclampf alpha );
extern void GLAPIENTRY
_mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a);
extern void GLAPIENTRY
_mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a);
extern void GLAPIENTRY
_mesa_Clear( GLbitfield mask );
#endif

View File

@@ -1,108 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 1999-2005 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.
*/
#include <precomp.h>
/**
* Update derived clip plane state.
*/
void
_mesa_update_clip_plane(struct gl_context *ctx, GLuint plane)
{
if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
_math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
/* Clip-Space Plane = Eye-Space Plane * Projection Matrix */
_mesa_transform_vector(ctx->Transform._ClipUserPlane[plane],
ctx->Transform.EyeUserPlane[plane],
ctx->ProjectionMatrixStack.Top->inv);
}
void GLAPIENTRY
_mesa_ClipPlane( GLenum plane, const GLdouble *eq )
{
GET_CURRENT_CONTEXT(ctx);
GLint p;
GLfloat equation[4];
ASSERT_OUTSIDE_BEGIN_END(ctx);
p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) {
_mesa_error( ctx, GL_INVALID_ENUM, "glClipPlane" );
return;
}
equation[0] = (GLfloat) eq[0];
equation[1] = (GLfloat) eq[1];
equation[2] = (GLfloat) eq[2];
equation[3] = (GLfloat) eq[3];
/*
* The equation is transformed by the transpose of the inverse of the
* current modelview matrix and stored in the resulting eye coordinates.
*
* KW: Eqn is then transformed to the current clip space, where user
* clipping now takes place. The clip-space equations are recalculated
* whenever the projection matrix changes.
*/
if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top))
_math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
_mesa_transform_vector( equation, equation,
ctx->ModelviewMatrixStack.Top->inv );
if (TEST_EQ_4V(ctx->Transform.EyeUserPlane[p], equation))
return;
FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
COPY_4FV(ctx->Transform.EyeUserPlane[p], equation);
if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
_mesa_update_clip_plane(ctx, p);
}
if (ctx->Driver.ClipPlane)
ctx->Driver.ClipPlane( ctx, plane, equation );
}
void GLAPIENTRY
_mesa_GetClipPlane( GLenum plane, GLdouble *equation )
{
GET_CURRENT_CONTEXT(ctx);
GLint p;
ASSERT_OUTSIDE_BEGIN_END(ctx);
p = (GLint) (plane - GL_CLIP_PLANE0);
if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) {
_mesa_error( ctx, GL_INVALID_ENUM, "glGetClipPlane" );
return;
}
equation[0] = (GLdouble) ctx->Transform.EyeUserPlane[p][0];
equation[1] = (GLdouble) ctx->Transform.EyeUserPlane[p][1];
equation[2] = (GLdouble) ctx->Transform.EyeUserPlane[p][2];
equation[3] = (GLdouble) ctx->Transform.EyeUserPlane[p][3];
}

View File

@@ -1,47 +0,0 @@
/**
* \file clip.h
*/
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef CLIP_H
#define CLIP_H
#include "glheader.h"
struct gl_context;
extern void
_mesa_update_clip_plane(struct gl_context *ctx, GLuint plane);
extern void GLAPIENTRY
_mesa_ClipPlane( GLenum plane, const GLdouble *equation );
extern void GLAPIENTRY
_mesa_GetClipPlane( GLenum plane, GLdouble *equation );
#endif

View File

@@ -1,125 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.3
*
* Copyright (C) 1999-2008 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.
*/
/**
* \file colormac.h
* Color-related macros
*/
#ifndef COLORMAC_H
#define COLORMAC_H
#include "config.h"
#include "macros.h"
#include "mtypes.h"
/**
* Convert four float values in [0,1] to ubytes in [0,255] with clamping.
*/
static inline void
_mesa_unclamped_float_rgba_to_ubyte(GLubyte dst[4], const GLfloat src[4])
{
int i;
for (i = 0; i < 4; i++)
UNCLAMPED_FLOAT_TO_UBYTE(dst[i], src[i]);
}
/**
* \name Generic color packing macros. All inputs should be GLubytes.
*
* \todo We may move these into texstore.h at some point.
*/
/*@{*/
#define PACK_COLOR_8888( X, Y, Z, W ) \
(((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W))
#define PACK_COLOR_8888_REV( X, Y, Z, W ) \
(((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X))
#define PACK_COLOR_888( X, Y, Z ) \
(((X) << 16) | ((Y) << 8) | (Z))
#define PACK_COLOR_565( X, Y, Z ) \
((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3))
#define PACK_COLOR_565_REV( X, Y, Z ) \
(((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5))
#define PACK_COLOR_5551( R, G, B, A ) \
((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) | \
((A) >> 7))
#define PACK_COLOR_1555( A, B, G, R ) \
((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \
(((A) & 0x80) << 8))
#define PACK_COLOR_1555_REV( A, B, G, R ) \
((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) | \
((A) ? 0x80 : 0))
#define PACK_COLOR_2101010_UB( A, B, G, R ) \
(((B) << 22) | ((G) << 12) | ((R) << 2) | \
(((A) & 0xc0) << 24))
#define PACK_COLOR_2101010_US( A, B, G, R ) \
((((B) >> 6) << 20) | (((G) >> 6) << 10) | ((R) >> 6) | \
(((A) >> 14) << 30))
#define PACK_COLOR_4444( R, G, B, A ) \
((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4))
#define PACK_COLOR_4444_REV( R, G, B, A ) \
((((B) & 0xf0) << 8) | (((A) & 0xf0) << 4) | ((R) & 0xf0) | ((G) >> 4))
#define PACK_COLOR_44( L, A ) \
(((L) & 0xf0) | (((A) & 0xf0) >> 4))
#define PACK_COLOR_88( L, A ) \
(((L) << 8) | (A))
#define PACK_COLOR_88_REV( L, A ) \
(((A) << 8) | (L))
#define PACK_COLOR_1616( L, A ) \
(((L) << 16) | (A))
#define PACK_COLOR_1616_REV( L, A ) \
(((A) << 16) | (L))
#define PACK_COLOR_332( R, G, B ) \
(((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6))
#define PACK_COLOR_233( B, G, R ) \
(((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5))
/*@}*/
#endif /* COLORMAC_H */

View File

@@ -1,506 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.5
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* Copyright (C) 2009 VMware, Inc. 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.
*/
/**
* \file compiler.h
* Compiler-related stuff.
*/
#ifndef COMPILER_H
#define COMPILER_H
#include <assert.h>
#include <ctype.h>
#if defined(__alpha__) && defined(CCPML)
#include <cpml.h> /* use Compaq's Fast Math Library on Alpha */
#else
#include <math.h>
#endif
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <float.h>
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Get standard integer types
*/
#include <stdint.h>
/**
* Sun compilers define __i386 instead of the gcc-style __i386__
*/
#ifdef __SUNPRO_C
# if !defined(__i386__) && defined(__i386)
# define __i386__
# elif !defined(__amd64__) && defined(__amd64)
# define __amd64__
# elif !defined(__sparc__) && defined(__sparc)
# define __sparc__
# endif
# if !defined(__volatile)
# define __volatile volatile
# endif
#endif
/**
* finite macro.
*/
#if defined(_MSC_VER)
# define finite _finite
#elif defined(__WATCOMC__)
# define finite _finite
#endif
/**
* Disable assorted warnings
*/
#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
# if !defined(__GNUC__) /* mingw environment */
# pragma warning( disable : 4068 ) /* unknown pragma */
# pragma warning( disable : 4710 ) /* function 'foo' not inlined */
# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
# pragma warning( disable : 4127 ) /* conditional expression is constant */
# if defined(MESA_MINWARN)
# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
# endif
# endif
#endif
#if defined(__WATCOMC__)
# pragma disable_message(201) /* Disable unreachable code warnings */
#endif
/**
* Function inlining
*/
#ifndef inline
# ifdef __cplusplus
/* C++ supports inline keyword */
# elif defined(__GNUC__)
# define inline __inline__
# elif defined(_MSC_VER)
# define inline __inline
# elif defined(__ICL)
# define inline __inline
# elif defined(__INTEL_COMPILER)
/* Intel compiler supports inline keyword */
# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
# define inline __inline
# elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
/* C99 supports inline keyword */
# elif (__STDC_VERSION__ >= 199901L)
/* C99 supports inline keyword */
# else
# define inline
# endif
#endif
#ifndef INLINE
# define INLINE inline
#endif
/**
* PUBLIC/USED macros
*
* If we build the library with gcc's -fvisibility=hidden flag, we'll
* use the PUBLIC macro to mark functions that are to be exported.
*
* We also need to define a USED attribute, so the optimizer doesn't
* inline a static function that we later use in an alias. - ajax
*/
#ifndef PUBLIC
# if (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
# define PUBLIC __attribute__((visibility("default")))
# define USED __attribute__((used))
# else
# define PUBLIC
# define USED
# endif
#endif
/**
* Some compilers don't like some of Mesa's const usage. In those places use
* CONST instead of const. Pass -DNO_CONST to compilers where this matters.
*/
#ifdef NO_CONST
# define CONST
#else
# define CONST const
#endif
/**
* __builtin_expect macros
*/
#if !defined(__GNUC__)
# define __builtin_expect(x, y) (x)
#endif
#ifndef likely
# ifdef __GNUC__
# define likely(x) __builtin_expect(!!(x), 1)
# define unlikely(x) __builtin_expect(!!(x), 0)
# else
# define likely(x) (x)
# define unlikely(x) (x)
# endif
#endif
/**
* The __FUNCTION__ gcc variable is generally only used for debugging.
* If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
* Don't define it if using a newer Windows compiler.
*/
#ifndef __FUNCTION__
# if defined(__VMS)
# define __FUNCTION__ "VMS$NL:"
# elif !defined(__GNUC__) && !defined(__xlC__) && \
(!defined(_MSC_VER) || _MSC_VER < 1300)
# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
(defined(__SUNPRO_C) && defined(__C99FEATURES__))
# define __FUNCTION__ __func__
# else
# define __FUNCTION__ "<unknown>"
# endif
# endif
#endif
#ifndef __func__
# if (__STDC_VERSION__ >= 199901L) || \
(defined(__SUNPRO_C) && defined(__C99FEATURES__))
/* __func__ is part of C99 */
# elif defined(_MSC_VER)
# if _MSC_VER >= 1300
# define __func__ __FUNCTION__
# else
# define __func__ "<unknown>"
# endif
# endif
#endif
/**
* Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32.
* Do not use these unless absolutely necessary!
* Try to use a runtime test instead.
* For now, only used by some DRI hardware drivers for color/texel packing.
*/
#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
#if defined(__linux__)
#include <byteswap.h>
#define CPU_TO_LE32( x ) bswap_32( x )
#elif defined(__APPLE__)
#include <CoreFoundation/CFByteOrder.h>
#define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x )
#elif (defined(_AIX) || defined(__blrts))
static INLINE GLuint CPU_TO_LE32(GLuint x)
{
return (((x & 0x000000ff) << 24) |
((x & 0x0000ff00) << 8) |
((x & 0x00ff0000) >> 8) |
((x & 0xff000000) >> 24));
}
#else /*__linux__ */
#include <sys/endian.h>
#define CPU_TO_LE32( x ) bswap32( x )
#endif /*__linux__*/
#define MESA_BIG_ENDIAN 1
#else
#define CPU_TO_LE32( x ) ( x )
#define MESA_LITTLE_ENDIAN 1
#endif
#define LE32_TO_CPU( x ) CPU_TO_LE32( x )
#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
#define CAPI _cdecl
#endif
/**
* Create a macro so that asm functions can be linked into compilers other
* than GNU C
*/
#ifndef _ASMAPI
#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
#define _ASMAPI __cdecl
#else
#define _ASMAPI
#endif
#ifdef PTR_DECL_IN_FRONT
#define _ASMAPIP * _ASMAPI
#else
#define _ASMAPIP _ASMAPI *
#endif
#endif
#ifdef USE_X86_ASM
#define _NORMAPI _ASMAPI
#define _NORMAPIP _ASMAPIP
#else
#define _NORMAPI
#define _NORMAPIP *
#endif
/* This is a macro on IRIX */
#ifdef _P
#undef _P
#endif
/* Turn off macro checking systems used by other libraries */
#ifdef CHECK
#undef CHECK
#endif
/**
* ASSERT macro
*/
#if !defined(_WIN32_WCE)
#if defined(BUILD_FOR_SNAP) && defined(CHECKED)
# define ASSERT(X) _CHECK(X)
#elif defined(DEBUG)
# define ASSERT(X) assert(X)
#else
# define ASSERT(X)
#endif
#endif
/**
* Static (compile-time) assertion.
* Basically, use COND to dimension an array. If COND is false/zero the
* array size will be -1 and we'll get a compilation error.
*/
#define STATIC_ASSERT(COND) \
do { \
typedef int static_assertion_failed[(!!(COND))*2-1]; \
} while (0)
#if (__GNUC__ >= 3)
#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
#else
#define PRINTFLIKE(f, a)
#endif
#ifndef NULL
#define NULL 0
#endif
/**
* LONGSTRING macro
* gcc -pedantic warns about long string literals, LONGSTRING silences that.
*/
#if !defined(__GNUC__)
# define LONGSTRING
#else
# define LONGSTRING __extension__
#endif
#ifndef M_PI
#define M_PI (3.14159265358979323846)
#endif
#ifndef M_E
#define M_E (2.7182818284590452354)
#endif
#ifndef M_LOG2E
#define M_LOG2E (1.4426950408889634074)
#endif
#ifndef ONE_DIV_SQRT_LN2
#define ONE_DIV_SQRT_LN2 (1.201122408786449815)
#endif
#ifndef FLT_MAX_EXP
#define FLT_MAX_EXP 128
#endif
/**
* USE_IEEE: Determine if we're using IEEE floating point
*/
#if defined(__i386__) || defined(__386__) || defined(__sparc__) || \
defined(__s390x__) || defined(__powerpc__) || \
defined(__x86_64__) || \
defined(ia64) || defined(__ia64__) || \
defined(__hppa__) || defined(hpux) || \
defined(__mips) || defined(_MIPS_ARCH) || \
defined(__arm__) || \
defined(__sh__) || defined(__m32r__) || \
(defined(__sun) && defined(_IEEE_754)) || \
(defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS)))
#define USE_IEEE
#define IEEE_ONE 0x3f800000
#endif
/**
* START/END_FAST_MATH macros:
*
* START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save
* original mode to a temporary).
* END_FAST_MATH: Restore x86 FPU to original mode.
*/
#if defined(__GNUC__) && defined(__i386__)
/*
* Set the x86 FPU control word to guarentee only 32 bits of precision
* are stored in registers. Allowing the FPU to store more introduces
* differences between situations where numbers are pulled out of memory
* vs. situations where the compiler is able to optimize register usage.
*
* In the worst case, we force the compiler to use a memory access to
* truncate the float, by specifying the 'volatile' keyword.
*/
/* Hardware default: All exceptions masked, extended double precision,
* round to nearest (IEEE compliant):
*/
#define DEFAULT_X86_FPU 0x037f
/* All exceptions masked, single precision, round to nearest:
*/
#define FAST_X86_FPU 0x003f
/* The fldcw instruction will cause any pending FP exceptions to be
* raised prior to entering the block, and we clear any pending
* exceptions before exiting the block. Hence, asm code has free
* reign over the FPU while in the fast math block.
*/
#if defined(NO_FAST_MATH)
#define START_FAST_MATH(x) \
do { \
static GLuint mask = DEFAULT_X86_FPU; \
__asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
__asm__ ( "fldcw %0" : : "m" (mask) ); \
} while (0)
#else
#define START_FAST_MATH(x) \
do { \
static GLuint mask = FAST_X86_FPU; \
__asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
__asm__ ( "fldcw %0" : : "m" (mask) ); \
} while (0)
#endif
/* Restore original FPU mode, and clear any exceptions that may have
* occurred in the FAST_MATH block.
*/
#define END_FAST_MATH(x) \
do { \
__asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \
} while (0)
#elif defined(__WATCOMC__) && defined(__386__)
#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */
#define FAST_X86_FPU 0x003f /* See GCC comments above */
void _watcom_start_fast_math(unsigned short *x,unsigned short *mask);
#pragma aux _watcom_start_fast_math = \
"fnstcw word ptr [eax]" \
"fldcw word ptr [ecx]" \
parm [eax] [ecx] \
modify exact [];
void _watcom_end_fast_math(unsigned short *x);
#pragma aux _watcom_end_fast_math = \
"fnclex" \
"fldcw word ptr [eax]" \
parm [eax] \
modify exact [];
#if defined(NO_FAST_MATH)
#define START_FAST_MATH(x) \
do { \
static GLushort mask = DEFAULT_X86_FPU; \
_watcom_start_fast_math(&x,&mask); \
} while (0)
#else
#define START_FAST_MATH(x) \
do { \
static GLushort mask = FAST_X86_FPU; \
_watcom_start_fast_math(&x,&mask); \
} while (0)
#endif
#define END_FAST_MATH(x) _watcom_end_fast_math(&x)
#elif defined(_MSC_VER) && defined(_M_IX86)
#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */
#define FAST_X86_FPU 0x003f /* See GCC comments above */
#if defined(NO_FAST_MATH)
#define START_FAST_MATH(x) do {\
static GLuint mask = DEFAULT_X86_FPU;\
__asm fnstcw word ptr [x]\
__asm fldcw word ptr [mask]\
} while(0)
#else
#define START_FAST_MATH(x) do {\
static GLuint mask = FAST_X86_FPU;\
__asm fnstcw word ptr [x]\
__asm fldcw word ptr [mask]\
} while(0)
#endif
#define END_FAST_MATH(x) do {\
__asm fnclex\
__asm fldcw word ptr [x]\
} while(0)
#else
#define START_FAST_MATH(x) x = 0
#define END_FAST_MATH(x) (void)(x)
#endif
#ifndef Elements
#define Elements(x) (sizeof(x)/sizeof(*(x)))
#endif
#ifdef __cplusplus
}
#endif
#endif /* COMPILER_H */

View File

@@ -1,228 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.5
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
* Copyright (C) 2008 VMware, Inc. 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.
*/
/**
* \file config.h
* Tunable configuration parameters.
*/
#ifndef MESA_CONFIG_H_INCLUDED
#define MESA_CONFIG_H_INCLUDED
/**
* \name OpenGL implementation limits
*/
/*@{*/
/** Maximum modelview matrix stack depth */
#define MAX_MODELVIEW_STACK_DEPTH 32
/** Maximum projection matrix stack depth */
#define MAX_PROJECTION_STACK_DEPTH 32
/** Maximum texture matrix stack depth */
#define MAX_TEXTURE_STACK_DEPTH 10
/** Maximum color matrix stack depth */
#define MAX_COLOR_STACK_DEPTH 4
/** Maximum attribute stack depth */
#define MAX_ATTRIB_STACK_DEPTH 16
/** Maximum client attribute stack depth */
#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16
/** Maximum recursion depth of display list calls */
#define MAX_LIST_NESTING 64
/** Maximum number of lights */
#define MAX_LIGHTS 8
/**
* Maximum number of user-defined clipping planes supported by any driver in
* Mesa. This is used to size arrays.
*/
#define MAX_CLIP_PLANES 8
/** Maximum pixel map lookup table size */
#define MAX_PIXEL_MAP_TABLE 256
/** Maximum number of auxillary color buffers */
#define MAX_AUX_BUFFERS 1
/** Maximum order (degree) of curves */
#ifdef AMIGA
# define MAX_EVAL_ORDER 12
#else
# define MAX_EVAL_ORDER 30
#endif
/** Maximum Name stack depth */
#define MAX_NAME_STACK_DEPTH 64
/** Minimum point size */
#define MIN_POINT_SIZE 1.0
/** Maximum point size */
#define MAX_POINT_SIZE 60.0
/** Point size granularity */
#define POINT_SIZE_GRANULARITY 0.1
/** Minimum line width */
#define MIN_LINE_WIDTH 1.0
/** Maximum line width */
#define MAX_LINE_WIDTH 10.0
/** Line width granularity */
#define LINE_WIDTH_GRANULARITY 0.1
/** Max memory to allow for a single texture image (in megabytes) */
#define MAX_TEXTURE_MBYTES 1024
/** Number of 1D/2D texture mipmap levels */
#define MAX_TEXTURE_LEVELS 15
/** Number of 3D texture mipmap levels */
#define MAX_3D_TEXTURE_LEVELS 15
/** Number of cube texture mipmap levels - GL_ARB_texture_cube_map */
#define MAX_CUBE_TEXTURE_LEVELS 15
/**
* Maximum viewport/image width. Must accomodate all texture sizes too.
*/
#ifndef MAX_WIDTH
# define MAX_WIDTH 16384
#endif
/** Maximum viewport/image height */
#ifndef MAX_HEIGHT
# define MAX_HEIGHT 16384
#endif
/* XXX: hack to prevent stack overflow on windows until all temporary arrays
* [MAX_WIDTH] are allocated from the heap */
#ifdef WIN32
#undef MAX_TEXTURE_LEVELS
#undef MAX_3D_TEXTURE_LEVELS
#undef MAX_CUBE_TEXTURE_LEVELS
#undef MAX_TEXTURE_RECT_SIZE
#undef MAX_WIDTH
#undef MAX_HEIGHT
#define MAX_TEXTURE_LEVELS 13
#define MAX_CUBE_TEXTURE_LEVELS 13
#define MAX_WIDTH 4096
#define MAX_HEIGHT 4096
#endif
/** Maxmimum size for CVA. May be overridden by the drivers. */
#define MAX_ARRAY_LOCK_SIZE 3000
/** Subpixel precision for antialiasing, window coordinate snapping */
#define SUB_PIXEL_BITS 4
/** Size of histogram tables */
#define HISTOGRAM_TABLE_SIZE 256
/** Max convolution filter width */
#define MAX_CONVOLUTION_WIDTH 9
/** Max convolution filter height */
#define MAX_CONVOLUTION_HEIGHT 9
/** For GL_EXT_texture_filter_anisotropic */
#define MAX_TEXTURE_MAX_ANISOTROPY 16.0
#define MAX_NV_VERTEX_PROGRAM_INPUTS 16
/** For GL_EXT_framebuffer_object */
/*@{*/
#define MAX_COLOR_ATTACHMENTS 8
/*@}*/
/** For GL_ATI_envmap_bump - support bump mapping on first 8 units */
#define SUPPORTED_ATI_BUMP_UNITS 0xff
/**
* \name Mesa-specific parameters
*/
/*@{*/
/**
* If non-zero use GLdouble for walking triangle edges, for better accuracy.
*/
#define TRIANGLE_WALK_DOUBLE 0
/**
* Bits per depth buffer value (max is 32).
*/
#ifndef DEFAULT_SOFTWARE_DEPTH_BITS
#define DEFAULT_SOFTWARE_DEPTH_BITS 16
#endif
/** Depth buffer data type */
#if DEFAULT_SOFTWARE_DEPTH_BITS <= 16
#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort
#else
#define DEFAULT_SOFTWARE_DEPTH_TYPE GLuint
#endif
/**
* Bits per stencil value: 8
*/
#define STENCIL_BITS 8
/**
* For swrast, bits per color channel: 8, 16 or 32
*/
#ifndef CHAN_BITS
#define CHAN_BITS 8
#endif
/*
* Color channel component order
*
* \note Changes will almost certainly cause problems at this time.
*/
#define RCOMP 0
#define GCOMP 1
#define BCOMP 2
#define ACOMP 3
/**
* Maximum number of temporary vertices required for clipping.
*
* Used in array_cache and tnl modules.
*/
#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
#endif /* MESA_CONFIG_H_INCLUDED */

File diff suppressed because it is too large Load Diff

View File

@@ -1,294 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.1
*
* Copyright (C) 1999-2006 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.
*/
/**
* \file context.h
* Mesa context and visual-related functions.
*
* There are three large Mesa data types/classes which are meant to be
* used by device drivers:
* - struct gl_context: this contains the Mesa rendering state
* - struct gl_config: this describes the color buffer (RGB vs. ci), whether
* or not there's a depth buffer, stencil buffer, etc.
* - struct gl_framebuffer: contains pointers to the depth buffer, stencil
* buffer, accum buffer and alpha buffers.
*
* These types should be encapsulated by corresponding device driver
* data types. See xmesa.h and xmesaP.h for an example.
*
* In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer
* are base classes which the device driver must derive from.
*
* The following functions create and destroy these data types.
*/
#ifndef CONTEXT_H
#define CONTEXT_H
#include "imports.h"
#include "mtypes.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _glapi_table;
/** \name Visual-related functions */
/*@{*/
extern struct gl_config *
_mesa_create_visual( GLboolean dbFlag,
GLboolean stereoFlag,
GLint redBits,
GLint greenBits,
GLint blueBits,
GLint alphaBits,
GLint depthBits,
GLint stencilBits,
GLint accumRedBits,
GLint accumGreenBits,
GLint accumBlueBits,
GLint accumAlphaBits);
extern GLboolean
_mesa_initialize_visual( struct gl_config *v,
GLboolean dbFlag,
GLboolean stereoFlag,
GLint redBits,
GLint greenBits,
GLint blueBits,
GLint alphaBits,
GLint depthBits,
GLint stencilBits,
GLint accumRedBits,
GLint accumGreenBits,
GLint accumBlueBits,
GLint accumAlphaBits);
extern void
_mesa_destroy_visual( struct gl_config *vis );
/*@}*/
/** \name Context-related functions */
/*@{*/
extern GLboolean
_mesa_initialize_context( struct gl_context *ctx,
const struct gl_config *visual,
struct gl_context *share_list,
const struct dd_function_table *driverFunctions,
void *driverContext );
extern struct gl_context *
_mesa_create_context(const struct gl_config *visual,
struct gl_context *share_list,
const struct dd_function_table *driverFunctions,
void *driverContext);
extern void
_mesa_free_context_data( struct gl_context *ctx );
extern void
_mesa_destroy_context( struct gl_context *ctx );
extern void
_mesa_copy_context(const struct gl_context *src, struct gl_context *dst, GLuint mask);
extern void
_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height);
extern GLboolean
_mesa_make_current( struct gl_context *ctx, struct gl_framebuffer *drawBuffer,
struct gl_framebuffer *readBuffer );
extern GLboolean
_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare);
extern struct gl_context *
_mesa_get_current_context(void);
/*@}*/
extern void
_mesa_init_get_hash(struct gl_context *ctx);
extern void
_mesa_notifySwapBuffers(struct gl_context *gc);
extern struct _glapi_table *
_mesa_get_dispatch(struct gl_context *ctx);
void
_mesa_set_mvp_with_dp4( struct gl_context *ctx,
GLboolean flag );
extern GLboolean
_mesa_valid_to_render(struct gl_context *ctx, const char *where);
/** \name Miscellaneous */
/*@{*/
extern void
_mesa_record_error( struct gl_context *ctx, GLenum error );
extern void
_mesa_finish(struct gl_context *ctx);
extern void
_mesa_flush(struct gl_context *ctx);
extern void GLAPIENTRY
_mesa_Finish( void );
extern void GLAPIENTRY
_mesa_Flush( void );
/*@}*/
/**
* \name Macros for flushing buffered rendering commands before state changes,
* checking if inside glBegin/glEnd, etc.
*/
/*@{*/
/**
* Flush vertices.
*
* \param ctx GL context.
* \param newstate new state.
*
* Checks if dd_function_table::NeedFlush is marked to flush stored vertices,
* and calls dd_function_table::FlushVertices if so. Marks
* __struct gl_contextRec::NewState with \p newstate.
*/
#define FLUSH_VERTICES(ctx, newstate) \
do { \
if (MESA_VERBOSE & VERBOSE_STATE) \
_mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\
if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
ctx->NewState |= newstate; \
} while (0)
/**
* Flush current state.
*
* \param ctx GL context.
* \param newstate new state.
*
* Checks if dd_function_table::NeedFlush is marked to flush current state,
* and calls dd_function_table::FlushVertices if so. Marks
* __struct gl_contextRec::NewState with \p newstate.
*/
#define FLUSH_CURRENT(ctx, newstate) \
do { \
if (MESA_VERBOSE & VERBOSE_STATE) \
_mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION); \
if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
ctx->NewState |= newstate; \
} while (0)
/**
* Macro to assert that the API call was made outside the
* glBegin()/glEnd() pair, with return value.
*
* \param ctx GL context.
* \param retval value to return in case the assertion fails.
*/
#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
do { \
if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
_mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \
return retval; \
} \
} while (0)
/**
* Macro to assert that the API call was made outside the
* glBegin()/glEnd() pair.
*
* \param ctx GL context.
*/
#define ASSERT_OUTSIDE_BEGIN_END(ctx) \
do { \
if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
_mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \
return; \
} \
} while (0)
/**
* Macro to assert that the API call was made outside the
* glBegin()/glEnd() pair and flush the vertices.
*
* \param ctx GL context.
*/
#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
do { \
ASSERT_OUTSIDE_BEGIN_END(ctx); \
FLUSH_VERTICES(ctx, 0); \
} while (0)
/**
* Macro to assert that the API call was made outside the
* glBegin()/glEnd() pair and flush the vertices, with return value.
*
* \param ctx GL context.
* \param retval value to return in case the assertion fails.
*/
#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
do { \
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
FLUSH_VERTICES(ctx, 0); \
} while (0)
/*@}*/
#ifdef __cplusplus
}
#endif
#endif /* CONTEXT_H */

View File

@@ -1,55 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.9
*
* Copyright (C) 2010 LunarG Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Chia-I Wu <olv@lunarg.com>
*/
/**
* \file core.h
* The public header of core mesa.
*
* This file is the (only) public header of core mesa. It is supposed to be
* used by GLX, WGL, and GLSL. It is important that headers directly or
* indirectly included here do not perform feature tests (#if FEATURE_xxx).
*/
#ifndef CORE_H
#define CORE_H
#include "main/glheader.h"
#include "main/compiler.h"
#include "main/imports.h"
#include "main/macros.h"
#include "main/mtypes.h"
/* for GLSL */
#include "program/prog_parameter.h"
#endif /* CORE_H */

View File

@@ -1,106 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.5
*
* Copyright (C) 2009 VMware, Inc. 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.
*/
#include <precomp.h>
/**
* This function should be called before the various "cpu_has_foo" macros
* are used.
*/
void
_mesa_get_cpu_features(void)
{
#ifdef USE_X86_ASM
_mesa_get_x86_features();
#endif
}
/**
* Return a string describing the CPU architexture and extensions that
* Mesa is using (such as SSE or Altivec).
* \return information string, free it with free()
*/
char *
_mesa_get_cpu_string(void)
{
#define MAX_STRING 50
char *buffer;
buffer = (char *) malloc(MAX_STRING);
if (!buffer)
return NULL;
buffer[0] = 0;
#ifdef USE_X86_ASM
if (_mesa_x86_cpu_features) {
strcat(buffer, "x86");
}
# ifdef USE_MMX_ASM
if (cpu_has_mmx) {
strcat(buffer, (cpu_has_mmxext) ? "/MMX+" : "/MMX");
}
# endif
# ifdef USE_3DNOW_ASM
if (cpu_has_3dnow) {
strcat(buffer, (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!");
}
# endif
# ifdef USE_SSE_ASM
if (cpu_has_xmm) {
strcat(buffer, (cpu_has_xmm2) ? "/SSE2" : "/SSE");
}
# endif
#elif defined(USE_SPARC_ASM)
strcat(buffer, "SPARC");
#elif defined(USE_PPC_ASM)
if (_mesa_ppc_cpu_features) {
strcat(buffer, (cpu_has_64) ? "PowerPC 64" : "PowerPC");
}
# ifdef USE_VMX_ASM
if (cpu_has_vmx) {
strcat(buffer, "/Altivec");
}
# endif
if (! cpu_has_fpu) {
strcat(buffer, "/No FPU");
}
#endif
assert(strlen(buffer) < MAX_STRING);
return buffer;
}

View File

@@ -1,47 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.5
*
* Copyright (C) 2009 VMware, Inc. 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.
*/
#ifndef CPUINFO_H
#define CPUINFO_H
#if defined(USE_X86_ASM)
#include "x86/common_x86_asm.h"
#endif
#if defined(USE_PPC_ASM)
#include "ppc/common_ppc_features.h"
#endif
extern void
_mesa_get_cpu_features(void);
extern char *
_mesa_get_cpu_string(void);
#endif /* CPUINFO_H */

View File

@@ -1,768 +0,0 @@
/**
* \file dd.h
* Device driver interfaces.
*/
/*
* Mesa 3-D graphics library
* Version: 6.5.2
*
* Copyright (C) 1999-2006 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.
*/
#ifndef DD_INCLUDED
#define DD_INCLUDED
/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */
#include "glheader.h"
struct gl_buffer_object;
struct gl_context;
struct gl_display_list;
struct gl_framebuffer;
struct gl_pixelstore_attrib;
struct gl_renderbuffer;
struct gl_renderbuffer_attachment;
struct gl_texture_image;
struct gl_texture_object;
/* GL_ARB_vertex_buffer_object */
/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return
* NULL) if buffer is unavailable for immediate mapping.
*
* Does GL_MAP_INVALIDATE_RANGE_BIT do this? It seems so, but it
* would require more book-keeping in the driver than seems necessary
* at this point.
*
* Does GL_MAP_INVALDIATE_BUFFER_BIT do this? Not really -- we don't
* want to provoke the driver to throw away the old storage, we will
* respect the contents of already referenced data.
*/
#define MESA_MAP_NOWAIT_BIT 0x0040
/**
* Device driver function table.
* Core Mesa uses these function pointers to call into device drivers.
* Most of these functions directly correspond to OpenGL state commands.
* Core Mesa will call these functions after error checking has been done
* so that the drivers don't have to worry about error testing.
*
* Vertex transformation/clipping/lighting is patched into the T&L module.
* Rasterization functions are patched into the swrast module.
*
* Note: when new functions are added here, the drivers/common/driverfuncs.c
* file should be updated too!!!
*/
struct dd_function_table {
/**
* Return a string as needed by glGetString().
* Only the GL_RENDERER query must be implemented. Otherwise, NULL can be
* returned.
*/
const GLubyte * (*GetString)( struct gl_context *ctx, GLenum name );
/**
* Notify the driver after Mesa has made some internal state changes.
*
* This is in addition to any state change callbacks Mesa may already have
* made.
*/
void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state );
/**
* Get the width and height of the named buffer/window.
*
* Mesa uses this to determine when the driver's window size has changed.
* XXX OBSOLETE: this function will be removed in the future.
*/
void (*GetBufferSize)( struct gl_framebuffer *buffer,
GLuint *width, GLuint *height );
/**
* Resize the given framebuffer to the given size.
* XXX OBSOLETE: this function will be removed in the future.
*/
void (*ResizeBuffers)( struct gl_context *ctx, struct gl_framebuffer *fb,
GLuint width, GLuint height);
/**
* Called whenever an error is generated.
* __struct gl_contextRec::ErrorValue contains the error value.
*/
void (*Error)( struct gl_context *ctx );
/**
* This is called whenever glFinish() is called.
*/
void (*Finish)( struct gl_context *ctx );
/**
* This is called whenever glFlush() is called.
*/
void (*Flush)( struct gl_context *ctx );
/**
* Clear the color/depth/stencil/accum buffer(s).
* \param buffers a bitmask of BUFFER_BIT_* flags indicating which
* renderbuffers need to be cleared.
*/
void (*Clear)( struct gl_context *ctx, GLbitfield buffers );
/**
* Execute glAccum command.
*/
void (*Accum)( struct gl_context *ctx, GLenum op, GLfloat value );
/**
* Execute glRasterPos, updating the ctx->Current.Raster fields
*/
void (*RasterPos)( struct gl_context *ctx, const GLfloat v[4] );
/**
* \name Image-related functions
*/
/*@{*/
/**
* Called by glDrawPixels().
* \p unpack describes how to unpack the source image data.
*/
void (*DrawPixels)( struct gl_context *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels );
/**
* Called by glReadPixels().
*/
void (*ReadPixels)( struct gl_context *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
GLvoid *dest );
/**
* Called by glCopyPixels().
*/
void (*CopyPixels)( struct gl_context *ctx, GLint srcx, GLint srcy,
GLsizei width, GLsizei height,
GLint dstx, GLint dsty, GLenum type );
/**
* Called by glBitmap().
*/
void (*Bitmap)( struct gl_context *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack,
const GLubyte *bitmap );
/*@}*/
/**
* \name Texture image functions
*/
/*@{*/
/**
* Choose actual hardware texture format given the user-provided source
* image format and type and the desired internal format. In some
* cases, srcFormat and srcType can be GL_NONE.
* Called by glTexImage(), etc.
*/
gl_format (*ChooseTextureFormat)( struct gl_context *ctx, GLint internalFormat,
GLenum srcFormat, GLenum srcType );
/**
* Called by glTexImage1D(). Simply copy the source texture data into the
* destination texture memory. The gl_texture_image fields, etc. will be
* fully initialized.
* The parameters are the same as glTexImage1D(), plus:
* \param packing describes how to unpack the source data.
* \param texImage is the destination texture image.
*/
void (*TexImage1D)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *packing);
/**
* Called by glTexImage2D().
*
* \sa dd_function_table::TexImage1D.
*/
void (*TexImage2D)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *packing);
/**
* Called by glTexSubImage1D(). Replace a subset of the target texture
* with new texel data.
* \sa dd_function_table::TexImage1D.
*/
void (*TexSubImage1D)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset, GLsizei width,
GLenum format, GLenum type,
const GLvoid *pixels,
const struct gl_pixelstore_attrib *packing);
/**
* Called by glTexSubImage2D().
*
* \sa dd_function_table::TexSubImage1D.
*/
void (*TexSubImage2D)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const GLvoid *pixels,
const struct gl_pixelstore_attrib *packing);
/**
* Called by glGetTexImage().
*/
void (*GetTexImage)( struct gl_context *ctx,
GLenum format, GLenum type, GLvoid *pixels,
struct gl_texture_image *texImage );
/**
* Called by glCopyTexSubImage1D() and glCopyTexImage1D().
*/
void (*CopyTexSubImage1D)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset,
struct gl_renderbuffer *rb,
GLint x, GLint y, GLsizei width);
/**
* Called by glCopyTexSubImage2D() and glCopyTexImage2D().
*/
void (*CopyTexSubImage2D)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
struct gl_renderbuffer *rb,
GLint x, GLint y,
GLsizei width, GLsizei height);
/**
* Called by glTexImage[123]D when user specifies a proxy texture
* target.
*
* \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails.
*/
GLboolean (*TestProxyTexImage)(struct gl_context *ctx, GLenum target,
GLint level, GLint internalFormat,
GLenum format, GLenum type,
GLint width, GLint height,
GLint depth, GLint border);
/*@}*/
/**
* \name Compressed texture functions
*/
/*@{*/
/**
* Called by glCompressedTexImage1D().
* The parameters are the same as for glCompressedTexImage1D(), plus a
* pointer to the destination texure image.
*/
void (*CompressedTexImage1D)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint internalFormat,
GLsizei width, GLint border,
GLsizei imageSize, const GLvoid *data);
/**
* Called by glCompressedTexImage2D().
*
* \sa dd_function_table::CompressedTexImage1D.
*/
void (*CompressedTexImage2D)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint internalFormat,
GLsizei width, GLsizei height, GLint border,
GLsizei imageSize, const GLvoid *data);
/**
* Called by glCompressedTexSubImage1D().
*/
void (*CompressedTexSubImage1D)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset, GLsizei width,
GLenum format,
GLsizei imageSize, const GLvoid *data);
/**
* Called by glCompressedTexSubImage2D().
*/
void (*CompressedTexSubImage2D)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
GLsizei width, GLint height,
GLenum format,
GLsizei imageSize, const GLvoid *data);
/*@}*/
/**
* \name Texture object / image functions
*/
/*@{*/
/**
* Called by glBindTexture().
*/
void (*BindTexture)( struct gl_context *ctx, GLenum target,
struct gl_texture_object *tObj );
/**
* Called to allocate a new texture object. Drivers will usually
* allocate/return a subclass of gl_texture_object.
*/
struct gl_texture_object * (*NewTextureObject)(struct gl_context *ctx,
GLuint name, GLenum target);
/**
* Called to delete/free a texture object. Drivers should free the
* object and any image data it contains.
*/
void (*DeleteTexture)(struct gl_context *ctx,
struct gl_texture_object *texObj);
/** Called to allocate a new texture image object. */
struct gl_texture_image * (*NewTextureImage)(struct gl_context *ctx);
/** Called to free a texture image object returned by NewTextureImage() */
void (*DeleteTextureImage)(struct gl_context *ctx,
struct gl_texture_image *);
/** Called to allocate memory for a single texture image */
GLboolean (*AllocTextureImageBuffer)(struct gl_context *ctx,
struct gl_texture_image *texImage,
gl_format format, GLsizei width,
GLsizei height, GLsizei depth);
/** Free the memory for a single texture image */
void (*FreeTextureImageBuffer)(struct gl_context *ctx,
struct gl_texture_image *texImage);
/** Map a slice of a texture image into user space.
* Note: for GL_TEXTURE_1D_ARRAY, height must be 1, y must be 0 and slice
* indicates the 1D array index.
* \param texImage the texture image
* \param slice the 3D image slice or array texture slice
* \param x, y, w, h region of interest
* \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and
* GL_MAP_INVALIDATE_RANGE_BIT (if writing)
* \param mapOut returns start of mapping of region of interest
* \param rowStrideOut returns row stride (in bytes)
*/
void (*MapTextureImage)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLuint slice,
GLuint x, GLuint y, GLuint w, GLuint h,
GLbitfield mode,
GLubyte **mapOut, GLint *rowStrideOut);
void (*UnmapTextureImage)(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLuint slice);
/** For GL_ARB_texture_storage. Allocate memory for whole mipmap stack.
* All the gl_texture_images in the texture object will have their
* dimensions, format, etc. initialized already.
*/
GLboolean (*AllocTextureStorage)(struct gl_context *ctx,
struct gl_texture_object *texObj,
GLsizei levels, GLsizei width,
GLsizei height, GLsizei depth);
/**
* Map a renderbuffer into user space.
* \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and
* GL_MAP_INVALIDATE_RANGE_BIT (if writing)
*/
void (*MapRenderbuffer)(struct gl_context *ctx,
struct gl_renderbuffer *rb,
GLuint x, GLuint y, GLuint w, GLuint h,
GLbitfield mode,
GLubyte **mapOut, GLint *rowStrideOut);
void (*UnmapRenderbuffer)(struct gl_context *ctx,
struct gl_renderbuffer *rb);
/*@}*/
/**
* \name State-changing functions.
*
* \note drawing functions are above.
*
* These functions are called by their corresponding OpenGL API functions.
* They are \e also called by the gl_PopAttrib() function!!!
* May add more functions like these to the device driver in the future.
*/
/*@{*/
/** Specify the alpha test function */
void (*AlphaFunc)(struct gl_context *ctx, GLenum func, GLfloat ref);
/** Specify clear values for the color buffers */
void (*ClearColor)(struct gl_context *ctx,
const union gl_color_union color);
/** Specify the clear value for the depth buffer */
void (*ClearDepth)(struct gl_context *ctx, GLclampd d);
/** Specify the clear value for the stencil buffer */
void (*ClearStencil)(struct gl_context *ctx, GLint s);
/** Specify a plane against which all geometry is clipped */
void (*ClipPlane)(struct gl_context *ctx, GLenum plane, const GLfloat *equation );
/** Enable and disable writing of frame buffer color components */
void (*ColorMask)(struct gl_context *ctx, GLboolean rmask, GLboolean gmask,
GLboolean bmask, GLboolean amask );
/** Cause a material color to track the current color */
void (*ColorMaterial)(struct gl_context *ctx, GLenum face, GLenum mode);
/** Specify whether front- or back-facing facets can be culled */
void (*CullFace)(struct gl_context *ctx, GLenum mode);
/** Define front- and back-facing polygons */
void (*FrontFace)(struct gl_context *ctx, GLenum mode);
/** Specify the value used for depth buffer comparisons */
void (*DepthFunc)(struct gl_context *ctx, GLenum func);
/** Enable or disable writing into the depth buffer */
void (*DepthMask)(struct gl_context *ctx, GLboolean flag);
/** Specify mapping of depth values from NDC to window coordinates */
void (*DepthRange)(struct gl_context *ctx, GLclampd nearval, GLclampd farval);
/** Specify the current buffer for writing */
void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer );
/** Enable or disable server-side gl capabilities */
void (*Enable)(struct gl_context *ctx, GLenum cap, GLboolean state);
/** Specify fog parameters */
void (*Fogfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params);
/** Specify implementation-specific hints */
void (*Hint)(struct gl_context *ctx, GLenum target, GLenum mode);
/** Set light source parameters.
* Note: for GL_POSITION and GL_SPOT_DIRECTION, params will have already
* been transformed to eye-space.
*/
void (*Lightfv)(struct gl_context *ctx, GLenum light,
GLenum pname, const GLfloat *params );
/** Set the lighting model parameters */
void (*LightModelfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params);
/** Specify the line stipple pattern */
void (*LineStipple)(struct gl_context *ctx, GLint factor, GLushort pattern );
/** Specify the width of rasterized lines */
void (*LineWidth)(struct gl_context *ctx, GLfloat width);
/** Specify a logical pixel operation for color index rendering */
void (*LogicOpcode)(struct gl_context *ctx, GLenum opcode);
void (*PointParameterfv)(struct gl_context *ctx, GLenum pname,
const GLfloat *params);
/** Specify the diameter of rasterized points */
void (*PointSize)(struct gl_context *ctx, GLfloat size);
/** Select a polygon rasterization mode */
void (*PolygonMode)(struct gl_context *ctx, GLenum face, GLenum mode);
/** Set the scale and units used to calculate depth values */
void (*PolygonOffset)(struct gl_context *ctx, GLfloat factor, GLfloat units);
/** Set the polygon stippling pattern */
void (*PolygonStipple)(struct gl_context *ctx, const GLubyte *mask );
/* Specifies the current buffer for reading */
void (*ReadBuffer)( struct gl_context *ctx, GLenum buffer );
/** Set rasterization mode */
void (*RenderMode)(struct gl_context *ctx, GLenum mode );
/** Define the scissor box */
void (*Scissor)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
/** Select flat or smooth shading */
void (*ShadeModel)(struct gl_context *ctx, GLenum mode);
/** Control the generation of texture coordinates */
void (*TexGen)(struct gl_context *ctx, GLenum coord, GLenum pname,
const GLfloat *params);
/** Set texture environment parameters */
void (*TexEnv)(struct gl_context *ctx, GLenum target, GLenum pname,
const GLfloat *param);
/** Set texture parameters */
void (*TexParameter)(struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj,
GLenum pname, const GLfloat *params);
/** Set the viewport */
void (*Viewport)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
/*@}*/
/**
* \name Vertex/pixel buffer object functions
*/
/*@{*/
void (*BindBuffer)( struct gl_context *ctx, GLenum target,
struct gl_buffer_object *obj );
struct gl_buffer_object * (*NewBufferObject)( struct gl_context *ctx, GLuint buffer,
GLenum target );
void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj );
GLboolean (*BufferData)( struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
const GLvoid *data, GLenum usage,
struct gl_buffer_object *obj );
void (*BufferSubData)( struct gl_context *ctx, GLintptrARB offset,
GLsizeiptrARB size, const GLvoid *data,
struct gl_buffer_object *obj );
void (*GetBufferSubData)( struct gl_context *ctx,
GLintptrARB offset, GLsizeiptrARB size,
GLvoid *data, struct gl_buffer_object *obj );
/* May return NULL if MESA_MAP_NOWAIT_BIT is set in access:
*/
void * (*MapBufferRange)( struct gl_context *ctx, GLintptr offset,
GLsizeiptr length, GLbitfield access,
struct gl_buffer_object *obj);
void (*FlushMappedBufferRange)(struct gl_context *ctx,
GLintptr offset, GLsizeiptr length,
struct gl_buffer_object *obj);
GLboolean (*UnmapBuffer)( struct gl_context *ctx,
struct gl_buffer_object *obj );
/*@}*/
/**
* \name Support for multiple T&L engines
*/
/*@{*/
/**
* Set by the driver-supplied T&L engine.
*
* Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd().
*/
GLuint CurrentExecPrimitive;
/**
* Current state of an in-progress compilation.
*
* May take on any of the additional values PRIM_OUTSIDE_BEGIN_END,
* PRIM_INSIDE_UNKNOWN_PRIM or PRIM_UNKNOWN defined above.
*/
GLuint CurrentSavePrimitive;
#define FLUSH_STORED_VERTICES 0x1
#define FLUSH_UPDATE_CURRENT 0x2
/**
* Set by the driver-supplied T&L engine whenever vertices are buffered
* between glBegin()/glEnd() objects or __struct gl_contextRec::Current is not
* updated.
*
* The dd_function_table::FlushVertices call below may be used to resolve
* these conditions.
*/
GLuint NeedFlush;
GLuint SaveNeedFlush;
/* Called prior to any of the GLvertexformat functions being
* called. Paired with Driver.FlushVertices().
*/
void (*BeginVertices)( struct gl_context *ctx );
/**
* If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if
* FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered
* vertices, if FLUSH_UPDATE_CURRENT bit is set updates
* __struct gl_contextRec::Current and gl_light_attrib::Material
*
* Note that the default T&L engine never clears the
* FLUSH_UPDATE_CURRENT bit, even after performing the update.
*/
void (*FlushVertices)( struct gl_context *ctx, GLuint flags );
void (*SaveFlushVertices)( struct gl_context *ctx );
/**
* \brief Hook for drivers to prepare for a glBegin/glEnd block
*
* This hook is called in vbo_exec_Begin() before any action, including
* state updates, occurs.
*/
void (*PrepareExecBegin)( struct gl_context *ctx );
/**
* Give the driver the opportunity to hook in its own vtxfmt for
* compiling optimized display lists. This is called on each valid
* glBegin() during list compilation.
*/
GLboolean (*NotifySaveBegin)( struct gl_context *ctx, GLenum mode );
/**
* Notify driver that the special derived value _NeedEyeCoords has
* changed.
*/
void (*LightingSpaceChange)( struct gl_context *ctx );
/**
* Called by glNewList().
*
* Let the T&L component know what is going on with display lists
* in time to make changes to dispatch tables, etc.
*/
void (*NewList)( struct gl_context *ctx, GLuint list, GLenum mode );
/**
* Called by glEndList().
*
* \sa dd_function_table::NewList.
*/
void (*EndList)( struct gl_context *ctx );
/**
* Called by glCallList(s).
*
* Notify the T&L component before and after calling a display list.
*/
void (*BeginCallList)( struct gl_context *ctx,
struct gl_display_list *dlist );
/**
* Called by glEndCallList().
*
* \sa dd_function_table::BeginCallList.
*/
void (*EndCallList)( struct gl_context *ctx );
/**@}*/
};
/**
* Transform/Clip/Lighting interface
*
* Drivers present a reduced set of the functions possible in
* glBegin()/glEnd() objects. Core mesa provides translation stubs for the
* remaining functions to map down to these entry points.
*
* These are the initial values to be installed into dispatch by
* mesa. If the T&L driver wants to modify the dispatch table
* while installed, it must do so itself. It would be possible for
* the vertexformat to install its own initial values for these
* functions, but this way there is an obvious list of what is
* expected of the driver.
*
* If the driver wants to hook in entry points other than those
* listed, it must restore them to their original values in
* the disable() callback, below.
*/
typedef struct {
/**
* \name Vertex
*/
/*@{*/
void (GLAPIENTRYP ArrayElement)( GLint );
void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat );
void (GLAPIENTRYP Color3fv)( const GLfloat * );
void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat );
void (GLAPIENTRYP Color4fv)( const GLfloat * );
void (GLAPIENTRYP EdgeFlag)( GLboolean );
void (GLAPIENTRYP EvalCoord1f)( GLfloat );
void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * );
void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat );
void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * );
void (GLAPIENTRYP EvalPoint1)( GLint );
void (GLAPIENTRYP EvalPoint2)( GLint, GLint );
void (GLAPIENTRYP FogCoordfEXT)( GLfloat );
void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * );
void (GLAPIENTRYP Indexf)( GLfloat );
void (GLAPIENTRYP Indexfv)( const GLfloat * );
void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * );
void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat );
void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * );
void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * );
void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat );
void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * );
void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat );
void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * );
void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat );
void (GLAPIENTRYP Normal3fv)( const GLfloat * );
void (GLAPIENTRYP TexCoord1f)( GLfloat );
void (GLAPIENTRYP TexCoord1fv)( const GLfloat * );
void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat );
void (GLAPIENTRYP TexCoord2fv)( const GLfloat * );
void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat );
void (GLAPIENTRYP TexCoord3fv)( const GLfloat * );
void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat );
void (GLAPIENTRYP TexCoord4fv)( const GLfloat * );
void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat );
void (GLAPIENTRYP Vertex2fv)( const GLfloat * );
void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat );
void (GLAPIENTRYP Vertex3fv)( const GLfloat * );
void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat );
void (GLAPIENTRYP Vertex4fv)( const GLfloat * );
void (GLAPIENTRYP CallList)( GLuint );
void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * );
void (GLAPIENTRYP Begin)( GLenum );
void (GLAPIENTRYP End)( void );
/* GL_NV_vertex_program */
void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x );
void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v );
void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y );
void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v );
void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z );
void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v );
void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v );
/*@}*/
void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
/**
* \name Array
*/
/*@{*/
void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count );
void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices );
/*@}*/
/**
* \name Eval
*
* If you don't support eval, fallback to the default vertex format
* on receiving an eval call and use the pipeline mechanism to
* provide partial T&L acceleration.
*
* Mesa will provide a set of helper functions to do eval within
* accelerated vertex formats, eventually...
*/
/*@{*/
void (GLAPIENTRYP EvalMesh1)( GLenum mode, GLint i1, GLint i2 );
void (GLAPIENTRYP EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
/*@}*/
} GLvertexformat;
#endif /* DD_INCLUDED */

View File

@@ -1,159 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2007 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.
*/
#include <precomp.h>
/**********************************************************************/
/***** API Functions *****/
/**********************************************************************/
void GLAPIENTRY
_mesa_ClearDepth( GLclampd depth )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glClearDepth(%f)\n", depth);
depth = CLAMP( depth, 0.0, 1.0 );
if (ctx->Depth.Clear == depth)
return;
FLUSH_VERTICES(ctx, _NEW_DEPTH);
ctx->Depth.Clear = depth;
if (ctx->Driver.ClearDepth)
(*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear );
}
void GLAPIENTRY
_mesa_DepthFunc( GLenum func )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func));
switch (func) {
case GL_LESS: /* (default) pass if incoming z < stored z */
case GL_GEQUAL:
case GL_LEQUAL:
case GL_GREATER:
case GL_NOTEQUAL:
case GL_EQUAL:
case GL_ALWAYS:
case GL_NEVER:
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glDepth.Func" );
return;
}
if (ctx->Depth.Func == func)
return;
FLUSH_VERTICES(ctx, _NEW_DEPTH);
ctx->Depth.Func = func;
if (ctx->Driver.DepthFunc)
ctx->Driver.DepthFunc( ctx, func );
}
void GLAPIENTRY
_mesa_DepthMask( GLboolean flag )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glDepthMask %d\n", flag);
/*
* GL_TRUE indicates depth buffer writing is enabled (default)
* GL_FALSE indicates depth buffer writing is disabled
*/
if (ctx->Depth.Mask == flag)
return;
FLUSH_VERTICES(ctx, _NEW_DEPTH);
ctx->Depth.Mask = flag;
if (ctx->Driver.DepthMask)
ctx->Driver.DepthMask( ctx, flag );
}
/**
* Specified by the GL_EXT_depth_bounds_test extension.
*/
void GLAPIENTRY
_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glDepthBounds(%f, %f)\n", zmin, zmax);
if (zmin > zmax) {
_mesa_error(ctx, GL_INVALID_VALUE, "glDepthBoundsEXT(zmin > zmax)");
return;
}
zmin = CLAMP(zmin, 0.0, 1.0);
zmax = CLAMP(zmax, 0.0, 1.0);
if (ctx->Depth.BoundsMin == zmin && ctx->Depth.BoundsMax == zmax)
return;
FLUSH_VERTICES(ctx, _NEW_DEPTH);
ctx->Depth.BoundsMin = (GLfloat) zmin;
ctx->Depth.BoundsMax = (GLfloat) zmax;
}
/**********************************************************************/
/***** Initialization *****/
/**********************************************************************/
/**
* Initialize the depth buffer attribute group in the given context.
*/
void
_mesa_init_depth(struct gl_context *ctx)
{
ctx->Depth.Test = GL_FALSE;
ctx->Depth.Clear = 1.0;
ctx->Depth.Func = GL_LESS;
ctx->Depth.Mask = GL_TRUE;
}

View File

@@ -1,65 +0,0 @@
/**
* \file depth.h
* Depth buffer operations.
*/
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 1999-2005 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.
*/
#ifndef DEPTH_H
#define DEPTH_H
#include "glheader.h"
#include "mfeatures.h"
struct gl_context;
#if _HAVE_FULL_GL
extern void GLAPIENTRY
_mesa_ClearDepth( GLclampd depth );
extern void GLAPIENTRY
_mesa_DepthFunc( GLenum func );
extern void GLAPIENTRY
_mesa_DepthMask( GLboolean flag );
extern void GLAPIENTRY
_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax );
extern void
_mesa_init_depth( struct gl_context * ctx );
#else
/** No-op */
#define _mesa_init_depth( c ) ((void)0)
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,104 +0,0 @@
/**
* \file dlist.h
* Display lists management.
*/
/*
* Mesa 3-D graphics library
* Version: 6.5.1
*
* Copyright (C) 1999-2006 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.
*/
#ifndef DLIST_H
#define DLIST_H
#include "main/mfeatures.h"
#include "main/mtypes.h"
#if FEATURE_dlist
#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) \
do { \
(vfmt)->CallList = impl ## CallList; \
(vfmt)->CallLists = impl ## CallLists; \
} while (0)
extern void GLAPIENTRY _mesa_CallList( GLuint list );
extern void GLAPIENTRY _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists );
extern void _mesa_compile_error( struct gl_context *ctx, GLenum error, const char *s );
extern void *_mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint sz);
extern GLint _mesa_dlist_alloc_opcode( struct gl_context *ctx, GLuint sz,
void (*execute)( struct gl_context *, void * ),
void (*destroy)( struct gl_context *, void * ),
void (*print)( struct gl_context *, void * ) );
extern void _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist);
extern void _mesa_save_vtxfmt_init( GLvertexformat *vfmt );
extern struct _glapi_table *_mesa_create_save_table(void);
extern void _mesa_install_dlist_vtxfmt(struct _glapi_table *disp,
const GLvertexformat *vfmt);
extern void _mesa_init_dlist_dispatch(struct _glapi_table *disp);
#else /* FEATURE_dlist */
#include "main/compiler.h"
#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) do { } while (0)
static inline void
_mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
{
/* there should be no list to delete */
ASSERT_NO_FEATURE();
}
static inline void
_mesa_install_dlist_vtxfmt(struct _glapi_table *disp,
const GLvertexformat *vfmt)
{
}
static inline void
_mesa_init_dlist_dispatch(struct _glapi_table *disp)
{
}
#endif /* FEATURE_dlist */
extern void _mesa_init_display_list( struct gl_context * ctx );
extern void _mesa_free_display_list_data(struct gl_context *ctx);
#endif /* DLIST_H */

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