From 9142f8c8763fffcb266d020cb6e5def30fb82bf2 Mon Sep 17 00:00:00 2001 From: Yoz Grahame Date: Wed, 7 Nov 2012 14:09:53 -0800 Subject: [PATCH 1/3] Updated .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e43b0f9889..47042c2291 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +xcuserdata From 6e62e9ee3262a137574e81dadb129f9b295a5795 Mon Sep 17 00:00:00 2001 From: Yoz Grahame Date: Fri, 9 Nov 2012 15:41:19 -0800 Subject: [PATCH 2/3] Fixed 2D pointer particle display --- main.cpp | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/main.cpp b/main.cpp index 88f2feddf0..3836ca0a4c 100644 --- a/main.cpp +++ b/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); From c2c7f25a5346411cc2b01e26704ccac701c09bc7 Mon Sep 17 00:00:00 2001 From: Yoz Grahame Date: Wed, 7 Nov 2012 15:09:26 -0800 Subject: [PATCH 3/3] Documented load_png_as_texture() --- texture.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/texture.cpp b/texture.cpp index 6500b28e3f..475047a40d 100644 --- a/texture.cpp +++ b/texture.cpp @@ -19,6 +19,12 @@ #define TEXTURE_LOAD_ERROR 0 +/** + * Read a given filename as a PNG texture, and set + it as the current default OpenGL texture. + * @param[in] filename Relative path to PNG file + * @return Zero for success. + */ int load_png_as_texture(char* filename) {