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:
parent
938bcb59bb
commit
eb3934d8f6
@ -26,6 +26,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
#import "Entity.h"
|
#import "Entity.h"
|
||||||
#import "OOOpenGLExtensionManager.h"
|
#import "OOOpenGLExtensionManager.h"
|
||||||
|
#import "OOTexture.h"
|
||||||
|
|
||||||
#define DUST_SCALE 2000
|
#define DUST_SCALE 2000
|
||||||
#define DUST_N_PARTICLES 600
|
#define DUST_N_PARTICLES 600
|
||||||
@ -40,6 +41,7 @@ MA 02110-1301, USA.
|
|||||||
Vector vertices[DUST_N_PARTICLES * 2];
|
Vector vertices[DUST_N_PARTICLES * 2];
|
||||||
GLushort indices[DUST_N_PARTICLES * 2];
|
GLushort indices[DUST_N_PARTICLES * 2];
|
||||||
GLfloat color_fv[4];
|
GLfloat color_fv[4];
|
||||||
|
OOTexture *texture;
|
||||||
|
|
||||||
#if OO_SHADERS
|
#if OO_SHADERS
|
||||||
GLfloat warpinessAttr[DUST_N_PARTICLES * 2];
|
GLfloat warpinessAttr[DUST_N_PARTICLES * 2];
|
||||||
|
@ -31,6 +31,7 @@ MA 02110-1301, USA.
|
|||||||
#import "OODebugFlags.h"
|
#import "OODebugFlags.h"
|
||||||
#import "OOMacroOpenGL.h"
|
#import "OOMacroOpenGL.h"
|
||||||
|
|
||||||
|
|
||||||
#if OO_SHADERS
|
#if OO_SHADERS
|
||||||
#import "OOMaterial.h" // For kTangentAttributeIndex
|
#import "OOMaterial.h" // For kTangentAttributeIndex
|
||||||
#import "OOShaderProgram.h"
|
#import "OOShaderProgram.h"
|
||||||
@ -95,6 +96,12 @@ enum
|
|||||||
|
|
||||||
dust_color = [[OOColor colorWithRed:0.5 green:1.0 blue:1.0 alpha:1.0] retain];
|
dust_color = [[OOColor colorWithRed:0.5 green:1.0 blue:1.0 alpha:1.0] retain];
|
||||||
[self setStatus:STATUS_ACTIVE];
|
[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];
|
[[OOGraphicsResetManager sharedManager] registerClient:self];
|
||||||
|
|
||||||
@ -106,7 +113,8 @@ enum
|
|||||||
{
|
{
|
||||||
DESTROY(dust_color);
|
DESTROY(dust_color);
|
||||||
[[OOGraphicsResetManager sharedManager] unregisterClient:self];
|
[[OOGraphicsResetManager sharedManager] unregisterClient:self];
|
||||||
|
|
||||||
|
DESTROY(texture);
|
||||||
#if OO_SHADERS
|
#if OO_SHADERS
|
||||||
DESTROY(shader);
|
DESTROY(shader);
|
||||||
DESTROY(uniforms);
|
DESTROY(uniforms);
|
||||||
@ -308,12 +316,12 @@ enum
|
|||||||
OOGL(glFogf(GL_FOG_END, FAR_PLANE));
|
OOGL(glFogf(GL_FOG_END, FAR_PLANE));
|
||||||
}
|
}
|
||||||
|
|
||||||
OOGL(glDisable(GL_TEXTURE_2D));
|
|
||||||
OOGL(glEnable(GL_BLEND));
|
OOGL(glEnable(GL_BLEND));
|
||||||
OOGL(glDepthMask(GL_FALSE));
|
OOGL(glDepthMask(GL_FALSE));
|
||||||
|
|
||||||
if (warp_stars)
|
if (warp_stars)
|
||||||
{
|
{
|
||||||
|
OOGL(glDisable(GL_TEXTURE_2D));
|
||||||
#if OO_SHADERS
|
#if OO_SHADERS
|
||||||
if (useShader)
|
if (useShader)
|
||||||
{
|
{
|
||||||
@ -340,11 +348,16 @@ enum
|
|||||||
OOGL(glDisableVertexAttribArrayARB(kTangentAttributeIndex));
|
OOGL(glDisableVertexAttribArrayARB(kTangentAttributeIndex));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
OOGL(glEnable(GL_TEXTURE_2D));
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
OOGL(glEnable(GL_POINT_SPRITE_ARB));
|
||||||
|
[texture apply];
|
||||||
OOGL(glVertexPointer(3, GL_FLOAT, 0, vertices));
|
OOGL(glVertexPointer(3, GL_FLOAT, 0, vertices));
|
||||||
OOGL(glDrawArrays(GL_POINTS, 0, DUST_N_PARTICLES));
|
OOGL(glDrawArrays(GL_POINTS, 0, DUST_N_PARTICLES));
|
||||||
|
OOGL(glDisable(GL_POINT_SPRITE_ARB));
|
||||||
}
|
}
|
||||||
|
|
||||||
// reapply normal conditions
|
// reapply normal conditions
|
||||||
@ -361,7 +374,6 @@ enum
|
|||||||
|
|
||||||
OOGL(glDisable(GL_BLEND));
|
OOGL(glDisable(GL_BLEND));
|
||||||
OOGL(glDepthMask(GL_TRUE));
|
OOGL(glDepthMask(GL_TRUE));
|
||||||
OOGL(glEnable(GL_TEXTURE_2D));
|
|
||||||
OOGL(glEnableClientState(GL_NORMAL_ARRAY));
|
OOGL(glEnableClientState(GL_NORMAL_ARRAY));
|
||||||
|
|
||||||
OOVerifyOpenGLState();
|
OOVerifyOpenGLState();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user