Move duplicated setVertexArrays to RenderContext
parent
4d5f2d9c64
commit
f8d3815a70
|
@ -183,6 +183,37 @@ RenderContext::drawGroup(const Mesh::PrimitiveGroup& group)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
RenderContext::setVertexArrays(const Mesh::VertexDescription& desc,
|
||||||
|
const void* vertexData)
|
||||||
|
{
|
||||||
|
setStandardVertexArrays(desc, vertexData);
|
||||||
|
setExtendedVertexArrays(desc, vertexData);
|
||||||
|
|
||||||
|
// Normally, the shader that will be used depends only on the material.
|
||||||
|
// But the presence of point size and normals can also affect the
|
||||||
|
// shader, so force an update of the material if those attributes appear
|
||||||
|
// or disappear in the new set of vertex arrays.
|
||||||
|
bool usePointSizeNow = (desc.getAttribute(Mesh::PointSize).format == Mesh::Float1);
|
||||||
|
bool useNormalsNow = (desc.getAttribute(Mesh::Normal).format == Mesh::Float3);
|
||||||
|
bool useColorsNow = (desc.getAttribute(Mesh::Color0).format != Mesh::InvalidFormat);
|
||||||
|
bool useTexCoordsNow = (desc.getAttribute(Mesh::Texture0).format != Mesh::InvalidFormat);
|
||||||
|
|
||||||
|
if (usePointSizeNow != usePointSize ||
|
||||||
|
useNormalsNow != useNormals ||
|
||||||
|
useColorsNow != useColors ||
|
||||||
|
useTexCoordsNow != useTexCoords)
|
||||||
|
{
|
||||||
|
usePointSize = usePointSizeNow;
|
||||||
|
useNormals = useNormalsNow;
|
||||||
|
useColors = useColorsNow;
|
||||||
|
useTexCoords = useTexCoordsNow;
|
||||||
|
if (getMaterial() != nullptr)
|
||||||
|
makeCurrent(*getMaterial());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setStandardVertexArrays(const Mesh::VertexDescription& desc,
|
setStandardVertexArrays(const Mesh::VertexDescription& desc,
|
||||||
const void* vertexData)
|
const void* vertexData)
|
||||||
|
@ -602,37 +633,6 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
GLSL_RenderContext::setVertexArrays(const Mesh::VertexDescription& desc,
|
|
||||||
const void* vertexData)
|
|
||||||
{
|
|
||||||
setStandardVertexArrays(desc, vertexData);
|
|
||||||
setExtendedVertexArrays(desc, vertexData);
|
|
||||||
|
|
||||||
// Normally, the shader that will be used depends only on the material.
|
|
||||||
// But the presence of point size and normals can also affect the
|
|
||||||
// shader, so force an update of the material if those attributes appear
|
|
||||||
// or disappear in the new set of vertex arrays.
|
|
||||||
bool usePointSizeNow = (desc.getAttribute(Mesh::PointSize).format == Mesh::Float1);
|
|
||||||
bool useNormalsNow = (desc.getAttribute(Mesh::Normal).format == Mesh::Float3);
|
|
||||||
bool useColorsNow = (desc.getAttribute(Mesh::Color0).format != Mesh::InvalidFormat);
|
|
||||||
bool useTexCoordsNow = (desc.getAttribute(Mesh::Texture0).format != Mesh::InvalidFormat);
|
|
||||||
|
|
||||||
if (usePointSizeNow != usePointSize ||
|
|
||||||
useNormalsNow != useNormals ||
|
|
||||||
useColorsNow != useColors ||
|
|
||||||
useTexCoordsNow != useTexCoords)
|
|
||||||
{
|
|
||||||
usePointSize = usePointSizeNow;
|
|
||||||
useNormals = useNormalsNow;
|
|
||||||
useColors = useColorsNow;
|
|
||||||
useTexCoords = useTexCoordsNow;
|
|
||||||
if (getMaterial() != nullptr)
|
|
||||||
makeCurrent(*getMaterial());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GLSL_RenderContext::setAtmosphere(const Atmosphere* _atmosphere)
|
GLSL_RenderContext::setAtmosphere(const Atmosphere* _atmosphere)
|
||||||
{
|
{
|
||||||
|
@ -768,34 +768,3 @@ GLSLUnlit_RenderContext::makeCurrent(const Material& m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
GLSLUnlit_RenderContext::setVertexArrays(const Mesh::VertexDescription& desc,
|
|
||||||
const void* vertexData)
|
|
||||||
{
|
|
||||||
setStandardVertexArrays(desc, vertexData);
|
|
||||||
setExtendedVertexArrays(desc, vertexData);
|
|
||||||
|
|
||||||
// Normally, the shader that will be used depends only on the material.
|
|
||||||
// But the presence of point size and normals can also affect the
|
|
||||||
// shader, so force an update of the material if those attributes appear
|
|
||||||
// or disappear in the new set of vertex arrays.
|
|
||||||
bool usePointSizeNow = (desc.getAttribute(Mesh::PointSize).format == Mesh::Float1);
|
|
||||||
bool useNormalsNow = (desc.getAttribute(Mesh::Normal).format == Mesh::Float3);
|
|
||||||
bool useColorsNow = (desc.getAttribute(Mesh::Color0).format != Mesh::InvalidFormat);
|
|
||||||
bool useTexCoordsNow = (desc.getAttribute(Mesh::Texture0).format != Mesh::InvalidFormat);
|
|
||||||
|
|
||||||
if (usePointSizeNow != usePointSize ||
|
|
||||||
useNormalsNow != useNormals ||
|
|
||||||
useColorsNow != useColors ||
|
|
||||||
useTexCoordsNow != useTexCoords)
|
|
||||||
{
|
|
||||||
usePointSize = usePointSizeNow;
|
|
||||||
useNormals = useNormalsNow;
|
|
||||||
useColors = useColorsNow;
|
|
||||||
useTexCoords = useTexCoordsNow;
|
|
||||||
if (getMaterial() != nullptr)
|
|
||||||
makeCurrent(*getMaterial());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class RenderContext
|
||||||
|
|
||||||
virtual void makeCurrent(const cmod::Material&) = 0;
|
virtual void makeCurrent(const cmod::Material&) = 0;
|
||||||
virtual void setVertexArrays(const cmod::Mesh::VertexDescription& desc,
|
virtual void setVertexArrays(const cmod::Mesh::VertexDescription& desc,
|
||||||
const void* vertexData) = 0;
|
const void* vertexData);
|
||||||
virtual void drawGroup(const cmod::Mesh::PrimitiveGroup& group);
|
virtual void drawGroup(const cmod::Mesh::PrimitiveGroup& group);
|
||||||
|
|
||||||
const cmod::Material* getMaterial() const;
|
const cmod::Material* getMaterial() const;
|
||||||
|
@ -79,9 +79,6 @@ class GLSL_RenderContext : public RenderContext
|
||||||
~GLSL_RenderContext() override;
|
~GLSL_RenderContext() override;
|
||||||
|
|
||||||
void makeCurrent(const cmod::Material&) override;
|
void makeCurrent(const cmod::Material&) override;
|
||||||
void setVertexArrays(const cmod::Mesh::VertexDescription& desc,
|
|
||||||
const void* vertexData) override;
|
|
||||||
|
|
||||||
void setLunarLambert(float);
|
void setLunarLambert(float);
|
||||||
void setAtmosphere(const Atmosphere*);
|
void setAtmosphere(const Atmosphere*);
|
||||||
|
|
||||||
|
@ -112,8 +109,6 @@ class GLSLUnlit_RenderContext : public RenderContext
|
||||||
~GLSLUnlit_RenderContext() override;
|
~GLSLUnlit_RenderContext() override;
|
||||||
|
|
||||||
void makeCurrent(const cmod::Material&) override;
|
void makeCurrent(const cmod::Material&) override;
|
||||||
void setVertexArrays(const cmod::Mesh::VertexDescription& desc,
|
|
||||||
const void* vertexData) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initLightingEnvironment();
|
void initLightingEnvironment();
|
||||||
|
|
Loading…
Reference in New Issue