Properly fixed point sprite scaling.
parent
7dc351bef1
commit
72542b240d
|
@ -603,13 +603,24 @@ Mesh::transform(Vec3f translation, float scale)
|
|||
return;
|
||||
|
||||
char* vdata = reinterpret_cast<char*>(vertices) + vertexDesc.getAttribute(Position).offset;
|
||||
for (uint32 i = 0; i < nVertices; i++, vdata += vertexDesc.stride)
|
||||
uint32 i;
|
||||
|
||||
// Scale and translate the vertex positions
|
||||
for (i = 0; i < nVertices; i++, vdata += vertexDesc.stride)
|
||||
{
|
||||
Vec3f tv = (Vec3f(reinterpret_cast<float*>(vdata)) + translation) * scale;
|
||||
reinterpret_cast<float*>(vdata)[0] = tv.x;
|
||||
reinterpret_cast<float*>(vdata)[1] = tv.y;
|
||||
reinterpret_cast<float*>(vdata)[2] = tv.z;
|
||||
}
|
||||
|
||||
// Point sizes need to be scaled as well
|
||||
if (vertexDesc.getAttribute(PointSize).format == Float1)
|
||||
{
|
||||
vdata = reinterpret_cast<char*>(vertices) + vertexDesc.getAttribute(PointSize).offset;
|
||||
for (i = 0; i < nVertices; i++, vdata += vertexDesc.stride)
|
||||
reinterpret_cast<float*>(vdata)[0] *= scale;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ void Nebula::render(const GLContext& glcontext,
|
|||
if (glcontext.getRenderPath() == GLContext::GLPath_GLSL)
|
||||
{
|
||||
GLSLUnlit_RenderContext rc(getRadius());
|
||||
rc.setPointScale(0.5f * getRadius() / pixelSize);
|
||||
rc.setPointScale(2.0 * getRadius() / pixelSize);
|
||||
m->render(rc);
|
||||
glx::glUseProgramObjectARB(0);
|
||||
}
|
||||
|
|
|
@ -84,13 +84,6 @@ RenderContext::RenderContext(const Mesh::Material* _material)
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void setVertexArrays(const Mesh::VertexDescription& desc)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
const Mesh::Material*
|
||||
RenderContext::getMaterial() const
|
||||
{
|
||||
|
@ -157,6 +150,7 @@ RenderContext::drawGroup(const Mesh::PrimitiveGroup& group)
|
|||
glEnable(GL_POINT_SPRITE_ARB);
|
||||
glx::glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
|
||||
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
|
||||
}
|
||||
|
||||
glDrawElements(GLPrimitiveModes[(int) group.prim],
|
||||
|
@ -167,6 +161,7 @@ RenderContext::drawGroup(const Mesh::PrimitiveGroup& group)
|
|||
if (group.prim == Mesh::SpriteList)
|
||||
{
|
||||
glDisable(GL_POINT_SPRITE_ARB);
|
||||
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue