changes towards GL_ARB_point_sprite (two-zero)

This commit is contained in:
Daniel Borca 2004-09-13 08:47:01 +00:00
parent e54464e9d3
commit a9ea1628da
6 changed files with 109 additions and 5 deletions

View File

@ -56,7 +56,7 @@ static GLfloat pointTime[MAX_POINTS];
static GLfloat pointVelocity[MAX_POINTS][2]; static GLfloat pointVelocity[MAX_POINTS][2];
static GLfloat pointDirection[MAX_POINTS][2]; static GLfloat pointDirection[MAX_POINTS][2];
static int colorList[MAX_POINTS]; static int colorList[MAX_POINTS];
static int animate = 1, motion = 0; static int animate = 1, motion = 0, org = 0, sprite = 1, smooth = 1;
static GLfloat colorSet[][4] = { static GLfloat colorSet[][4] = {
/* Shades of red. */ /* Shades of red. */
@ -240,17 +240,19 @@ redraw(void)
if (blend) if (blend)
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D); if (sprite) {
glEnable(GL_TEXTURE_2D);
#ifdef GL_ARB_point_sprite #ifdef GL_ARB_point_sprite
glEnable(GL_POINT_SPRITE_ARB); glEnable(GL_POINT_SPRITE_ARB);
#endif #endif
}
glColor3f(1,1,1); glColor3f(1,1,1);
glBegin(GL_POINTS); glBegin(GL_POINTS);
for (i=0; i<numPoints; i++) { for (i=0; i<numPoints; i++) {
/* Draw alive particles. */ /* Draw alive particles. */
if (colorList[i] != DEAD) { if (colorList[i] != DEAD) {
/*glColor4fv(colorSet[colorList[i]]);*/ if (!sprite) glColor4fv(colorSet[colorList[i]]);
glVertex3fv(pointList[i]); glVertex3fv(pointList[i]);
} }
} }
@ -326,9 +328,11 @@ menu(int option)
#endif #endif
case 8: case 8:
glEnable(GL_POINT_SMOOTH); glEnable(GL_POINT_SMOOTH);
smooth = 1;
break; break;
case 9: case 9:
glDisable(GL_POINT_SMOOTH); glDisable(GL_POINT_SMOOTH);
smooth = 0;
break; break;
case 10: case 10:
glPointSize(4.0); glPointSize(4.0);
@ -383,6 +387,47 @@ key(unsigned char c, int x, int y)
makePointList(); makePointList();
glutIdleFunc(idle); glutIdleFunc(idle);
break; break;
case 'o':
case 'O':
org ^= 1;
#if GL_VERSION_2_0
#if GL_ARB_point_parameters
glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN,
org ? GL_LOWER_LEFT : GL_UPPER_LEFT);
#endif
#endif
glutPostRedisplay();
break;
case 't':
case 'T':
sprite ^= 1;
glutPostRedisplay();
break;
case 's':
case 'S':
(smooth ^= 1) ? glEnable(GL_POINT_SMOOTH) : glDisable(GL_POINT_SMOOTH);
glutPostRedisplay();
break;
case '0':
glPointSize(1.0);
glutPostRedisplay();
break;
case '1':
glPointSize(2.0);
glutPostRedisplay();
break;
case '2':
glPointSize(4.0);
glutPostRedisplay();
break;
case '3':
glPointSize(8.0);
glutPostRedisplay();
break;
case '4':
glPointSize(16.0);
glutPostRedisplay();
break;
case 27: case 27:
exit(0); exit(0);
} }

View File

@ -1017,6 +1017,10 @@ _mesa_PopAttrib(void)
_mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite); _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite);
_mesa_PointParameteriNV(GL_POINT_SPRITE_R_MODE_NV, _mesa_PointParameteriNV(GL_POINT_SPRITE_R_MODE_NV,
ctx->Point.SpriteRMode); ctx->Point.SpriteRMode);
#if GL_VERSION_2_0
_mesa_PointParameterfEXT(GL_POINT_SPRITE_COORD_ORIGIN,
(GLfloat)ctx->Point.SpriteOrigin);
#endif
} }
} }
break; break;

View File

@ -1390,6 +1390,12 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
CHECK_EXTENSION_B(NV_point_sprite, pname); CHECK_EXTENSION_B(NV_point_sprite, pname);
*params = ENUM_TO_BOOL(ctx->Point.SpriteRMode); *params = ENUM_TO_BOOL(ctx->Point.SpriteRMode);
break; break;
#if GL_VERSION_2_0
case GL_POINT_SPRITE_COORD_ORIGIN:
CHECK_EXTENSION_B(ARB_point_sprite, pname);
*params = ENUM_TO_BOOL(ctx->Point.SpriteOrigin);
break;
#endif
/* GL_SGIS_generate_mipmap */ /* GL_SGIS_generate_mipmap */
case GL_GENERATE_MIPMAP_HINT_SGIS: case GL_GENERATE_MIPMAP_HINT_SGIS:
@ -2942,6 +2948,12 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
CHECK_EXTENSION_D(NV_point_sprite, pname); CHECK_EXTENSION_D(NV_point_sprite, pname);
*params = (GLdouble) ctx->Point.SpriteRMode; *params = (GLdouble) ctx->Point.SpriteRMode;
break; break;
#if GL_VERSION_2_0
case GL_POINT_SPRITE_COORD_ORIGIN:
CHECK_EXTENSION_D(ARB_point_sprite, pname);
*params = (GLdouble) ctx->Point.SpriteOrigin;
break;
#endif
/* GL_SGIS_generate_mipmap */ /* GL_SGIS_generate_mipmap */
case GL_GENERATE_MIPMAP_HINT_SGIS: case GL_GENERATE_MIPMAP_HINT_SGIS:
@ -4468,6 +4480,12 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
CHECK_EXTENSION_F(NV_point_sprite, pname); CHECK_EXTENSION_F(NV_point_sprite, pname);
*params = (GLfloat) ctx->Point.SpriteRMode; *params = (GLfloat) ctx->Point.SpriteRMode;
break; break;
#if GL_VERSION_2_0
case GL_POINT_SPRITE_COORD_ORIGIN:
CHECK_EXTENSION_F(ARB_point_sprite, pname);
*params = (GLfloat) ctx->Point.SpriteOrigin;
break;
#endif
/* GL_SGIS_generate_mipmap */ /* GL_SGIS_generate_mipmap */
case GL_GENERATE_MIPMAP_HINT_SGIS: case GL_GENERATE_MIPMAP_HINT_SGIS:
@ -6032,6 +6050,12 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
CHECK_EXTENSION_I(NV_point_sprite, pname); CHECK_EXTENSION_I(NV_point_sprite, pname);
*params = (GLint) ctx->Point.SpriteRMode; *params = (GLint) ctx->Point.SpriteRMode;
break; break;
#if GL_VERSION_2_0
case GL_POINT_SPRITE_COORD_ORIGIN:
CHECK_EXTENSION_I(ARB_point_sprite, pname);
*params = (GLint) ctx->Point.SpriteOrigin;
break;
#endif
/* GL_SGIS_generate_mipmap */ /* GL_SGIS_generate_mipmap */
case GL_GENERATE_MIPMAP_HINT_SGIS: case GL_GENERATE_MIPMAP_HINT_SGIS:

View File

@ -890,6 +890,7 @@ struct gl_point_attrib {
GLboolean PointSprite; /**< GL_NV_point_sprite / GL_NV_point_sprite */ GLboolean PointSprite; /**< GL_NV_point_sprite / GL_NV_point_sprite */
GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_NV_point_sprite / GL_NV_point_sprite */ GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_NV_point_sprite / GL_NV_point_sprite */
GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */ GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
GLenum SpriteOrigin; /**< GL_ARB_point_sprite */
}; };

View File

@ -229,6 +229,27 @@ _mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params)
return; return;
} }
break; break;
#if GL_VERSION_2_0
case GL_POINT_SPRITE_COORD_ORIGIN:
if (ctx->Extensions.ARB_point_sprite) {
GLenum value = (GLenum) params[0];
if (value != GL_LOWER_LEFT && value != GL_UPPER_LEFT) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glPointParameterf[v]{EXT,ARB}(param)");
return;
}
if (ctx->Point.SpriteOrigin == value)
return;
FLUSH_VERTICES(ctx, _NEW_POINT);
ctx->Point.SpriteOrigin = value;
}
else {
_mesa_error(ctx, GL_INVALID_ENUM,
"glPointParameterf[v]{EXT,ARB}(pname)");
return;
}
break;
#endif
default: default:
_mesa_error( ctx, GL_INVALID_ENUM, _mesa_error( ctx, GL_INVALID_ENUM,
"glPointParameterf[v]{EXT,ARB}(pname)" ); "glPointParameterf[v]{EXT,ARB}(pname)" );
@ -266,6 +287,9 @@ void _mesa_init_point( GLcontext * ctx )
ctx->Point.Threshold = 1.0; ctx->Point.Threshold = 1.0;
ctx->Point.PointSprite = GL_FALSE; /* GL_ARB_point_sprite / GL_NV_point_sprite */ ctx->Point.PointSprite = GL_FALSE; /* GL_ARB_point_sprite / GL_NV_point_sprite */
ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */ ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */
#if GL_VERSION_2_0
ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */
#endif
for (i = 0; i < MAX_TEXTURE_UNITS; i++) { for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB_point_sprite / GL_NV_point_sprite */ ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB_point_sprite / GL_NV_point_sprite */
} }

View File

@ -292,7 +292,13 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
if (ctx->Texture.Unit[u]._ReallyEnabled) { if (ctx->Texture.Unit[u]._ReallyEnabled) {
if (ctx->Point.CoordReplace[u]) { if (ctx->Point.CoordReplace[u]) {
GLfloat s = 0.5F + (x + 0.5F - vert->win[0]) / size; GLfloat s = 0.5F + (x + 0.5F - vert->win[0]) / size;
GLfloat t = 0.5F - (y + 0.5F - vert->win[1]) / size; GLfloat t;
#if GL_VERSION_2_0
if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT)
t = 0.5F + (y + 0.5F - vert->win[1]) / size;
else /* GL_UPPER_LEFT */
#endif
t = 0.5F - (y + 0.5F - vert->win[1]) / size;
span->array->texcoords[u][count][0] = s; span->array->texcoords[u][count][0] = s;
span->array->texcoords[u][count][1] = t; span->array->texcoords[u][count][1] = t;
span->array->texcoords[u][count][3] = 1.0F; span->array->texcoords[u][count][3] = 1.0F;