mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-06 01:03:19 +02:00
Fixed 2D pointer particle display
This commit is contained in:
parent
9142f8c876
commit
6e62e9ee32
1 changed files with 16 additions and 24 deletions
40
main.cpp
40
main.cpp
|
@ -205,6 +205,7 @@ char texture_filename[] = "grayson-particle.png";
|
|||
//unsigned int texture_height = 256;
|
||||
|
||||
float particle_attenuation_quadratic[] = { 0.0f, 0.0f, 2.0f }; // larger Z = smaller particles
|
||||
float pointer_attenuation_quadratic[] = { 1.0f, 0.0f, 0.0f }; // for 2D view
|
||||
|
||||
|
||||
|
||||
|
@ -623,38 +624,27 @@ void display(void)
|
|||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
// Draw Point Sprites
|
||||
|
||||
/* assuming you have setup a 32-bit RGBA texture with a legal name */
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
/* Draw Point Sprites */
|
||||
|
||||
//glActiveTexture(GL_TEXTURE0);
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
|
||||
|
||||
//glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
|
||||
glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, particle_attenuation_quadratic );
|
||||
|
||||
float maxSize = 0.0f;
|
||||
glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize );
|
||||
glPointSize( maxSize );
|
||||
glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, maxSize );
|
||||
// glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 0.001f );
|
||||
glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 0.001f );
|
||||
glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
|
||||
|
||||
glEnable( GL_POINT_SPRITE_ARB );
|
||||
glBegin( GL_POINTS );
|
||||
{
|
||||
for (i = 0; i < NUM_TRIS; i++)
|
||||
{
|
||||
// glColor3f(tris.colors[i*3],
|
||||
// tris.colors[i*3+1],
|
||||
// tris.colors[i*3+2]);
|
||||
// for (j = 0; j < 3; j++)
|
||||
// {
|
||||
// glVertex3f(tris.vertices[i*9 + j*3],
|
||||
// tris.vertices[i*9 + j*3 + 1],
|
||||
// tris.vertices[i*9 + j*3 + 2]);
|
||||
// }
|
||||
// glNormal3f(tris.normals[i*3],
|
||||
// tris.normals[i*3 + 1],
|
||||
// tris.normals[i*3 + 2]);
|
||||
glVertex3f(tris.vertices[i*3],
|
||||
tris.vertices[i*3+1],
|
||||
tris.vertices[i*3+2]);
|
||||
|
@ -662,9 +652,11 @@ void display(void)
|
|||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
glDisable( GL_POINT_SPRITE_ARB );
|
||||
|
||||
|
||||
|
||||
// Show field vectors
|
||||
if (display_field) field_render();
|
||||
|
||||
|
@ -696,20 +688,20 @@ void display(void)
|
|||
|
||||
if (mouse_pressed == 1)
|
||||
{
|
||||
glPointSize(20.f);
|
||||
glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic );
|
||||
glPointSize( 10.0f );
|
||||
glColor3f(1,1,1);
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
//glEnable(GL_POINT_SMOOTH);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex2f(target_x, target_y);
|
||||
glEnd();
|
||||
char val[20];
|
||||
sprintf(val, "%d,%d", target_x, target_y);
|
||||
drawtext(target_x, target_y-20, 0.08, 0, 1.0, 0, val, 0, 1, 0);
|
||||
|
||||
}
|
||||
if (display_head_mouse)
|
||||
{
|
||||
glPointSize(20.f);
|
||||
glPointSize(10.0f);
|
||||
glColor4f(1.0, 1.0, 0.0, 0.8);
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
glBegin(GL_POINTS);
|
||||
|
|
Loading…
Reference in a new issue