ソースを参照

allow drivers to request fog coordinates

tags/mesa_3_1
Keith Whitwell 26年前
コミット
3e63be01d1
5個のファイルの変更195行の追加132行の削除
  1. 83
    27
      src/mesa/main/clip.c
  2. 10
    14
      src/mesa/main/context.c
  3. 80
    61
      src/mesa/main/fog.c
  4. 8
    17
      src/mesa/main/fog.h
  5. 14
    13
      src/mesa/main/lines.c

+ 83
- 27
src/mesa/main/clip.c ファイルの表示

@@ -1,8 +1,8 @@
/* $Id: clip.c,v 1.5 1999/11/11 01:22:25 brianp Exp $ */
/* $Id: clip.c,v 1.4.2.1 1999/11/25 16:51:24 keithw Exp $ */

/*
* Mesa 3-D graphics library
* Version: 3.3
* Version: 3.1
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -25,10 +25,19 @@
*/





#ifdef PC_HEADER
#include "all.h"
#else
#include "glheader.h"
#ifndef XFree86Server
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#else
#include "GL/xf86glx.h"
#endif
#include "clip.h"
#include "context.h"
#include "macros.h"
@@ -42,6 +51,15 @@



#define CLIP_RGBA0 0x1
#define CLIP_RGBA1 0x2
#define CLIP_TEX0 0x4
#define CLIP_TEX1 0x8
#define CLIP_INDEX0 0x10
#define CLIP_INDEX1 0x20
#define CLIP_FOG_COORD 0x40


/* Linear interpolation between A and B: */
#define LINTERP( T, A, B ) ( (A) + (T) * ( (B) - (A) ) )

@@ -58,16 +76,7 @@ do { \
} while(0)



#define CLIP_RGBA0 0x1
#define CLIP_RGBA1 0x2
#define CLIP_TEX0 0x4
#define CLIP_TEX1 0x8
#define CLIP_INDEX0 0x10
#define CLIP_INDEX1 0x20

static clip_interp_func clip_interp_tab[0x40];
static clip_interp_func clip_interp_tab[0x80];

#define IND 0
#define NAME clip_nil
@@ -113,6 +122,50 @@ static clip_interp_func clip_interp_tab[0x40];
#define NAME clipINDEX0_INDEX1
#include "interp_tmp.h"

#define IND (CLIP_FOG_COORD)
#define NAME clip_FOG
#include "interp_tmp.h"

#define IND (CLIP_RGBA0|CLIP_FOG_COORD)
#define NAME clipRGBA0_FOG
#include "interp_tmp.h"

#define IND (CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
#define NAME clipRGBA0_RGBA1_FOG
#include "interp_tmp.h"

#define IND (CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD)
#define NAME clipTEX0_RGBA0_FOG
#include "interp_tmp.h"

#define IND (CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
#define NAME clipTEX0_RGBA0_RGBA1_FOG
#include "interp_tmp.h"

#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD)
#define NAME clipTEX1_TEX0_RGBA0_FOG
#include "interp_tmp.h"

#define IND (CLIP_TEX0|CLIP_FOG_COORD)
#define NAME clipTEX0_FOG
#include "interp_tmp.h"

#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_FOG_COORD)
#define NAME clipTEX1_TEX0_FOG
#include "interp_tmp.h"

#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
#define NAME clipTEX1_TEX0_RGBA0_RGBA1_FOG
#include "interp_tmp.h"

#define IND (CLIP_INDEX0|CLIP_FOG_COORD)
#define NAME clipINDEX0_FOG
#include "interp_tmp.h"

#define IND (CLIP_INDEX0|CLIP_INDEX1|CLIP_FOG_COORD)
#define NAME clipINDEX0_INDEX1_FOG
#include "interp_tmp.h"




@@ -122,17 +175,9 @@ static clip_interp_func clip_interp_tab[0x40];



void
_mesa_ClipPlane( GLenum plane, const GLdouble *eq )
void gl_ClipPlane( GLcontext* ctx, GLenum plane, const GLfloat *equation )
{
GET_CURRENT_CONTEXT(ctx);
GLint p;
GLfloat equation[4];

equation[0] = eq[0];
equation[1] = eq[1];
equation[2] = eq[2];
equation[3] = eq[3];

ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glClipPlane");

@@ -183,10 +228,8 @@ void gl_update_userclip( GLcontext *ctx )
}
}

void
_mesa_GetClipPlane( GLenum plane, GLdouble *equation )
void gl_GetClipPlane( GLcontext* ctx, GLenum plane, GLdouble *equation )
{
GET_CURRENT_CONTEXT(ctx);
GLint p;

ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetClipPlane");
@@ -353,6 +396,8 @@ void gl_update_clipmask( GLcontext *ctx )
mask |= CLIP_INDEX1;
}

if (ctx->FogMode == FOG_FRAGMENT && (ctx->TriangleCaps & DD_CLIP_FOG_COORD))
mask |= CLIP_FOG_COORD;
ctx->ClipInterpFunc = clip_interp_tab[mask];
ctx->poly_clip_tab = gl_poly_clip_tab[0];
@@ -448,11 +493,22 @@ void gl_init_clip(void)
clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0] = clipTEX1_TEX0_RGBA0;
clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1] =
clipTEX1_TEX0_RGBA0_RGBA1;

clip_interp_tab[CLIP_TEX0] = clipTEX0;
clip_interp_tab[CLIP_TEX1|CLIP_TEX0] = clipTEX1_TEX0;

clip_interp_tab[CLIP_INDEX0] = clipINDEX0;
clip_interp_tab[CLIP_INDEX0|CLIP_INDEX1] = clipINDEX0_INDEX1;

clip_interp_tab[CLIP_FOG_COORD] = clip_FOG;
clip_interp_tab[CLIP_RGBA0|CLIP_FOG_COORD] = clipRGBA0_FOG;
clip_interp_tab[CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] = clipRGBA0_RGBA1_FOG;
clip_interp_tab[CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD] = clipTEX0_RGBA0_FOG;
clip_interp_tab[CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] = clipTEX0_RGBA0_RGBA1_FOG;
clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD] = clipTEX1_TEX0_RGBA0_FOG;
clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] =
clipTEX1_TEX0_RGBA0_RGBA1_FOG;
clip_interp_tab[CLIP_TEX0|CLIP_FOG_COORD] = clipTEX0_FOG;
clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_FOG_COORD] = clipTEX1_TEX0_FOG;
clip_interp_tab[CLIP_INDEX0|CLIP_FOG_COORD] = clipINDEX0_FOG;
clip_interp_tab[CLIP_INDEX0|CLIP_INDEX1|CLIP_FOG_COORD] = clipINDEX0_INDEX1_FOG;
}


+ 10
- 14
src/mesa/main/context.c ファイルの表示

@@ -1,4 +1,4 @@
/* $Id: context.c,v 1.18.2.2 1999/11/15 22:21:18 brianp Exp $ */
/* $Id: context.c,v 1.18.2.3 1999/11/25 16:51:24 keithw Exp $ */

/*
* Mesa 3-D graphics library
@@ -1977,21 +1977,17 @@ static void update_pixel_masking( GLcontext *ctx )
static void update_fog_mode( GLcontext *ctx )
{
int old_mode = ctx->FogMode;
ctx->FogMode = FOG_NONE;

if (ctx->Fog.Enabled) {
if (ctx->Texture.Enabled)
ctx->FogMode = FOG_FRAGMENT;
else if (ctx->Hint.Fog == GL_NICEST)
ctx->FogMode = FOG_FRAGMENT;
else
ctx->FogMode = FOG_VERTEX;
ctx->FogMode = FOG_VERTEX;

if (ctx->Driver.GetParameteri)
if ((ctx->Driver.GetParameteri)( ctx, DD_HAVE_HARDWARE_FOG ))
ctx->FogMode = FOG_FRAGMENT;
}
else {
ctx->FogMode = FOG_NONE;
if (ctx->Texture.Enabled || ctx->Hint.Fog == GL_NICEST)
ctx->FogMode = FOG_FRAGMENT;

if ( ctx->Driver.GetParameteri &&
ctx->Driver.GetParameteri( ctx, DD_HAVE_HARDWARE_FOG ) )
ctx->FogMode = FOG_FRAGMENT;
}
if (old_mode != ctx->FogMode)
@@ -2412,7 +2408,7 @@ void gl_update_state( GLcontext *ctx )
oldnorm = ctx->NeedEyeNormals;

ctx->NeedNormals = (ctx->Light.Enabled || ctx->Texture.NeedNormals);
ctx->NeedEyeCoords = ((ctx->Fog.Enabled && ctx->Hint.Fog != GL_NICEST) ||
ctx->NeedEyeCoords = (ctx->FogMode == FOG_VERTEX ||
ctx->Point.Attenuated);
ctx->NeedEyeNormals = GL_FALSE;


+ 80
- 61
src/mesa/main/fog.c ファイルの表示

@@ -1,8 +1,8 @@
/* $Id: fog.c,v 1.4 1999/11/11 01:22:26 brianp Exp $ */
/* $Id: fog.c,v 1.3.2.1 1999/11/25 16:51:24 keithw Exp $ */

/*
* Mesa 3-D graphics library
* Version: 3.3
* Version: 3.1
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -25,64 +25,29 @@
*/


/* $XFree86: xc/lib/GL/mesa/src/fog.c,v 1.4 1999/04/04 00:20:24 dawes Exp $ */

#ifdef PC_HEADER
#include "all.h"
#else
#include "glheader.h"
#ifndef XFree86Server
#include <math.h>
#include <stdlib.h>
#else
#include "GL/xf86glx.h"
#endif
#include "context.h"
#include "fog.h"
#include "macros.h"
#include "mmath.h"
#include "types.h"
#include "xform.h"
#endif



void
_mesa_Fogf(GLenum pname, GLfloat param)
{
_mesa_Fogfv(pname, &param);
}


void
_mesa_Fogi(GLenum pname, GLint param )
{
GLfloat fparam = (GLfloat) param;
_mesa_Fogfv(pname, &fparam);
}


void
_mesa_Fogiv(GLenum pname, const GLint *params )
{
GLfloat p[4];
switch (pname) {
case GL_FOG_MODE:
case GL_FOG_DENSITY:
case GL_FOG_START:
case GL_FOG_END:
case GL_FOG_INDEX:
p[0] = (GLfloat) *params;
break;
case GL_FOG_COLOR:
p[0] = INT_TO_FLOAT( params[0] );
p[1] = INT_TO_FLOAT( params[1] );
p[2] = INT_TO_FLOAT( params[2] );
p[3] = INT_TO_FLOAT( params[3] );
break;
default:
/* Error will be caught later in gl_Fogfv */
;
}
_mesa_Fogfv(pname, p);
}


void
_mesa_Fogfv( GLenum pname, const GLfloat *params )
void gl_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
{
GET_CURRENT_CONTEXT(ctx);
GLenum m;

switch (pname) {
@@ -106,23 +71,9 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
}
break;
case GL_FOG_START:
#if 0
/* Prior to OpenGL 1.1, this was an error */
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:
#if 0
/* Prior to OpenGL 1.1, this was an error */
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:
@@ -150,9 +101,13 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
typedef void (*fog_func)( struct vertex_buffer *VB, GLuint side,
GLubyte flag );

typedef void (*fog_coord_func)( struct vertex_buffer *VB,
const GLvector4f *from,
GLubyte flag );

static fog_func fog_ci_tab[2];
static fog_func fog_rgba_tab[2];
static fog_coord_func make_fog_coord_tab[2];

/*
* Compute the fogged color for an array of vertices.
@@ -206,6 +161,70 @@ void gl_fog_vertices( struct vertex_buffer *VB )
}
}


static void check_fog_coords( GLcontext *ctx, struct gl_pipeline_stage *d )
{
d->type = 0;

if (ctx->FogMode==FOG_FRAGMENT)
{
d->type = PIPE_IMMEDIATE|PIPE_PRECALC;
d->inputs = VERT_OBJ_ANY;
d->outputs = VERT_FOG_COORD;
}
}

void gl_make_fog_coords( struct vertex_buffer *VB )
{
GLcontext *ctx = VB->ctx;

/* If full eye coords weren't required, just calculate the eye Z
* values.
*/
if (!ctx->NeedEyeCoords) {
GLfloat *m = ctx->ModelView.m;
GLfloat plane[4];

plane[0] = m[2];
plane[1] = m[6];
plane[2] = m[10];
plane[3] = m[14];

gl_dotprod_tab[0][VB->ObjPtr->size](&VB->Eye,
2, /* fill z coordinates */
VB->ObjPtr,
plane,
0 );

make_fog_coord_tab[0]( VB, &VB->Eye, 0 );
}
else
{
make_fog_coord_tab[0]( VB, VB->EyePtr, 0 );
}
}


/* Drivers that want fog coordinates in VB->Spec[0] alpha, can substitute this
* stage for the default PIPE_OP_FOG pipeline stage.
*/
struct gl_pipeline_stage gl_fog_coord_stage = {
"build fog coordinates",
PIPE_OP_FOG,
PIPE_PRECALC|PIPE_IMMEDIATE,
0,
NEW_FOG,
NEW_LIGHTING|NEW_RASTER_OPS|NEW_FOG|NEW_MODELVIEW,
0, 0,
0, 0, 0,
check_fog_coords,
gl_make_fog_coords
};





/*
* Apply fog to an array of RGBA pixels.
* Input: n - number of pixels

+ 8
- 17
src/mesa/main/fog.h ファイルの表示

@@ -1,8 +1,8 @@
/* $Id: fog.h,v 1.2 1999/11/11 01:22:26 brianp Exp $ */
/* $Id: fog.h,v 1.1.1.1.2.1 1999/11/25 16:51:24 keithw Exp $ */

/*
* Mesa 3-D graphics library
* Version: 3.3
* Version: 3.1
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -25,6 +25,7 @@
*/



#ifndef FOG_H
#define FOG_H

@@ -32,21 +33,7 @@
#include "types.h"


extern void
_mesa_Fogf(GLenum pname, GLfloat param);


extern void
_mesa_Fogi(GLenum pname, GLint param );


extern void
_mesa_Fogfv(GLenum pname, const GLfloat *params );


extern void
_mesa_Fogiv(GLenum pname, const GLint *params );

extern void gl_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params );


extern void gl_fog_vertices( struct vertex_buffer *VB );
@@ -58,7 +45,11 @@ extern void gl_fog_rgba_pixels( const GLcontext *ctx,
extern void gl_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLdepth z[], GLuint indx[] );

extern void gl_make_fog_coords( struct vertex_buffer *VB );

extern struct gl_pipeline_stage gl_fog_coord_stage;

extern void gl_init_fog( void );


#endif

+ 14
- 13
src/mesa/main/lines.c ファイルの表示

@@ -1,8 +1,8 @@
/* $Id: lines.c,v 1.6 1999/11/11 01:22:27 brianp Exp $ */
/* $Id: lines.c,v 1.5.2.1 1999/11/25 16:51:24 keithw Exp $ */

/*
* Mesa 3-D graphics library
* Version: 3.3
* Version: 3.1
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -25,10 +25,17 @@
*/





#ifdef PC_HEADER
#include "all.h"
#else
#include "glheader.h"
#ifndef XFree86Server
#include <assert.h>
#else
#include "GL/xf86glx.h"
#endif
#include "context.h"
#include "depth.h"
#include "feedback.h"
@@ -43,10 +50,8 @@



void
_mesa_LineWidth( GLfloat width )
void gl_LineWidth( GLcontext *ctx, GLfloat width )
{
GET_CURRENT_CONTEXT(ctx);
if (width<=0.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLineWidth" );
return;
@@ -63,10 +68,8 @@ _mesa_LineWidth( GLfloat width )



void
_mesa_LineStipple( GLint factor, GLushort pattern )
void gl_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLineStipple");
ctx->Line.StippleFactor = CLAMP( factor, 1, 256 );
ctx->Line.StipplePattern = pattern;
@@ -1024,8 +1027,7 @@ void gl_set_line_function( GLcontext *ctx )
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 (ctx->Depth.Test || ctx->FogMode == FOG_FRAGMENT) {
if (rgbmode)
ctx->Driver.LineFunc = smooth_rgba_z_line;
else
@@ -1040,8 +1042,7 @@ void gl_set_line_function( GLcontext *ctx )
}
else {
/* Width==1, non-stippled, flat-shaded */
if (ctx->Depth.Test
|| (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) {
if (ctx->Depth.Test || ctx->FogMode == FOG_FRAGMENT) {
if (rgbmode)
ctx->Driver.LineFunc = flat_rgba_z_line;
else

読み込み中…
キャンセル
保存