Switch dust from points to point sprites. Massive efficiency improvement on my graphics card. Will need testing to make sure it doesn't break things for others.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@5495 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Chris Morris 2012-11-13 19:09:01 +00:00
parent 938bcb59bb
commit eb3934d8f6
2 changed files with 17 additions and 3 deletions

View File

@ -26,6 +26,7 @@ MA 02110-1301, USA.
#import "Entity.h"
#import "OOOpenGLExtensionManager.h"
#import "OOTexture.h"
#define DUST_SCALE 2000
#define DUST_N_PARTICLES 600
@ -40,6 +41,7 @@ MA 02110-1301, USA.
Vector vertices[DUST_N_PARTICLES * 2];
GLushort indices[DUST_N_PARTICLES * 2];
GLfloat color_fv[4];
OOTexture *texture;
#if OO_SHADERS
GLfloat warpinessAttr[DUST_N_PARTICLES * 2];

View File

@ -31,6 +31,7 @@ MA 02110-1301, USA.
#import "OODebugFlags.h"
#import "OOMacroOpenGL.h"
#if OO_SHADERS
#import "OOMaterial.h" // For kTangentAttributeIndex
#import "OOShaderProgram.h"
@ -95,6 +96,12 @@ enum
dust_color = [[OOColor colorWithRed:0.5 green:1.0 blue:1.0 alpha:1.0] retain];
[self setStatus:STATUS_ACTIVE];
texture = [[OOTexture textureWithName:@"oolite-particle-dust.png"
inFolder:@"Textures"
options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask
anisotropy:kOOTextureDefaultAnisotropy / 2.0
lodBias:0.0] retain];
[[OOGraphicsResetManager sharedManager] registerClient:self];
@ -106,7 +113,8 @@ enum
{
DESTROY(dust_color);
[[OOGraphicsResetManager sharedManager] unregisterClient:self];
DESTROY(texture);
#if OO_SHADERS
DESTROY(shader);
DESTROY(uniforms);
@ -308,12 +316,12 @@ enum
OOGL(glFogf(GL_FOG_END, FAR_PLANE));
}
OOGL(glDisable(GL_TEXTURE_2D));
OOGL(glEnable(GL_BLEND));
OOGL(glDepthMask(GL_FALSE));
if (warp_stars)
{
OOGL(glDisable(GL_TEXTURE_2D));
#if OO_SHADERS
if (useShader)
{
@ -340,11 +348,16 @@ enum
OOGL(glDisableVertexAttribArrayARB(kTangentAttributeIndex));
}
#endif
OOGL(glEnable(GL_TEXTURE_2D));
}
else
{
OOGL(glEnable(GL_POINT_SPRITE_ARB));
[texture apply];
OOGL(glVertexPointer(3, GL_FLOAT, 0, vertices));
OOGL(glDrawArrays(GL_POINTS, 0, DUST_N_PARTICLES));
OOGL(glDisable(GL_POINT_SPRITE_ARB));
}
// reapply normal conditions
@ -361,7 +374,6 @@ enum
OOGL(glDisable(GL_BLEND));
OOGL(glDepthMask(GL_TRUE));
OOGL(glEnable(GL_TEXTURE_2D));
OOGL(glEnableClientState(GL_NORMAL_ARRAY));
OOVerifyOpenGLState();