Skip to content

Commit

Permalink
Revise shader and material system
Browse files Browse the repository at this point in the history
  • Loading branch information
cjhoward committed Jan 18, 2018
1 parent a452354 commit ce417f4
Show file tree
Hide file tree
Showing 29 changed files with 2,292 additions and 965 deletions.
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ set(emergent_SOURCES
src/emergent/graphics/scene-object.cpp
src/emergent/graphics/scene.cpp
src/emergent/graphics/shader.cpp
src/emergent/graphics/shader-loader.cpp
src/emergent/graphics/shader-parameter.cpp
src/emergent/graphics/shader-parameter-set.cpp
src/emergent/graphics/shader-input.cpp
src/emergent/graphics/shader-variable.cpp
src/emergent/graphics/skeleton.cpp
src/emergent/graphics/texture.cpp
src/emergent/graphics/texture-2d.cpp
src/emergent/graphics/texture-cube.cpp
src/emergent/graphics/texture-loader.cpp
src/emergent/input/arcball.cpp
src/emergent/math/math.cpp
Expand Down Expand Up @@ -154,12 +154,12 @@ set(emergent_HEADERS
include/emergent/graphics/scene-object.hpp
include/emergent/graphics/scene.hpp
include/emergent/graphics/shader.hpp
include/emergent/graphics/shader-loader.hpp
include/emergent/graphics/shader-parameter.hpp
include/emergent/graphics/shader-parameter-set.hpp
include/emergent/graphics/shader-input.hpp
include/emergent/graphics/shader-variable.hpp
include/emergent/graphics/skeleton.hpp
include/emergent/graphics/stb-image.hpp
include/emergent/graphics/texture.hpp
include/emergent/graphics/texture-2d.hpp
include/emergent/graphics/texture-cube.hpp
include/emergent/graphics/texture-loader.hpp
include/emergent/graphics/vertex-format.hpp
include/emergent/input/arcball.hpp
Expand Down
8 changes: 4 additions & 4 deletions include/emergent/emergent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@
#include <emergent/graphics/scene-object.hpp>
#include <emergent/graphics/scene.hpp>
#include <emergent/graphics/shader.hpp>
#include <emergent/graphics/shader-loader.hpp>
#include <emergent/graphics/shader-parameter.hpp>
#include <emergent/graphics/shader-parameter-set.hpp>
#include <emergent/graphics/shader-input.hpp>
#include <emergent/graphics/shader-variable.hpp>
#include <emergent/graphics/skeleton.hpp>
#include <emergent/graphics/stb-image.hpp>
#include <emergent/graphics/texture.hpp>
#include <emergent/graphics/texture-2d.hpp>
#include <emergent/graphics/texture-cube.hpp>
#include <emergent/graphics/texture-loader.hpp>
#include <emergent/graphics/vertex-format.hpp>

Expand Down
12 changes: 6 additions & 6 deletions include/emergent/font/font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <emergent/font/font-metrics.hpp>
#include <emergent/font/glyph.hpp>
#include <emergent/font/kerning-table.hpp>
#include <emergent/graphics/texture.hpp>
#include <emergent/graphics/texture-2d.hpp>
#include <cstdlib>
#include <map>
#include <string>
Expand Down Expand Up @@ -126,17 +126,17 @@ class Font
/**
* Returns the texture containing the font glyphs.
*/
const Texture* getTexture() const;
const Texture2D* getTexture() const;

/// @copydoc Font::getTexture() const
Texture* getTexture();
Texture2D* getTexture();

private:
FontMetrics fontMetrics;
std::map<char32_t, Glyph> glyphs;
KerningTable kerningTable;
TextureAtlas* atlas;
Texture texture;
Texture2D texture;
};

inline void Font::setMetrics(const FontMetrics& metrics)
Expand Down Expand Up @@ -170,12 +170,12 @@ inline KerningTable* Font::getKerningTable()
return &kerningTable;
}

inline const Texture* Font::getTexture() const
inline const Texture2D* Font::getTexture() const
{
return &texture;
}

inline Texture* Font::getTexture()
inline Texture2D* Font::getTexture()
{
return &texture;
}
Expand Down
31 changes: 16 additions & 15 deletions include/emergent/graphics/ambient-light.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
#define EMERGENT_GRAPHICS_AMBIENT_LIGHT_HPP

#include <emergent/graphics/light.hpp>
#include <emergent/graphics/gl3w.hpp>

namespace Emergent
{

class TextureCube;

/**
* Abstract base class for ambient light sources.
*
Expand Down Expand Up @@ -62,51 +63,51 @@ class AmbientCube: public AmbientLight
/**
* Sets the diffuse cubemap texture.
*/
void setDiffuseTexture(GLuint textureID);
void setDiffuseTexture(const TextureCube* texture);

/**
* Sets the specular cubemap texture
*/
void setSpecularTexture(GLuint textureID);
void setSpecularTexture(const TextureCube* texture);

/**
* Returns the diffuse cubemap texture.
*/
GLuint getDiffuseTexture() const;
const TextureCube* getDiffuseTexture() const;

/**
* Returns the specular cubemap texture.
*/
GLuint getSpecularTexture() const;
const TextureCube* getSpecularTexture() const;

private:
GLuint diffuseTextureID;
GLuint specularTextureID;
const TextureCube* diffuseTexture;
const TextureCube* specularTexture;
};

inline void AmbientCube::setDiffuseTexture(GLuint textureID)
inline void AmbientCube::setDiffuseTexture(const TextureCube* texture)
{
this->diffuseTextureID = textureID;
this->diffuseTexture = texture;
}

inline void AmbientCube::setSpecularTexture(GLuint textureID)
inline void AmbientCube::setSpecularTexture(const TextureCube* texture)
{
this->specularTextureID = textureID;
this->specularTexture = texture;
}

inline LightType AmbientCube::getLightType() const
{
return LightType::AMBIENT_CUBE;
}

inline GLuint AmbientCube::getDiffuseTexture() const
inline const TextureCube* AmbientCube::getDiffuseTexture() const
{
return diffuseTextureID;
return diffuseTexture;
}

inline GLuint AmbientCube::getSpecularTexture() const
inline const TextureCube* AmbientCube::getSpecularTexture() const
{
return specularTextureID;
return specularTexture;
}

} // namespace Emergent
Expand Down
15 changes: 8 additions & 7 deletions include/emergent/graphics/billboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@

#include <emergent/graphics/gl3w.hpp>
#include <emergent/graphics/scene-object.hpp>
#include <emergent/graphics/material.hpp>
#include <emergent/graphics/camera.hpp>
#include <emergent/math/types.hpp>
#include <vector>

namespace Emergent
{

class Material;
class Camera;

/**
* Enumerates billboard alignment modes
*
Expand All @@ -55,21 +56,21 @@ class Billboard
Billboard();

void setTranslation(const Vector3& translation);
void setRotation(const glm::quat& rotation);
void setRotation(const Quaternion& rotation);
void setDimensions(const Vector2& dimensions);
void setTextureCoordinates(const Vector2& min, const Vector2& max);
void setTintColor(const Vector4& color);

const Vector3& getTranslation() const;
const glm::quat& getRotation() const;
const Quaternion& getRotation() const;
const Vector2& getDimensions() const;
const Vector2& getTextureCoordinatesMin() const;
const Vector2& getTextureCoordinatesMax() const;
const Vector4& getTintColor() const;

private:
Vector3 translation;
glm::quat rotation;
Quaternion rotation;
Vector2 dimensions;
Vector2 coordinatesMin;
Vector2 coordinatesMax;
Expand All @@ -81,7 +82,7 @@ inline void Billboard::setTranslation(const Vector3& translation)
this->translation = translation;
}

inline void Billboard::setRotation(const glm::quat& rotation)
inline void Billboard::setRotation(const Quaternion& rotation)
{
this->rotation = rotation;
}
Expand All @@ -107,7 +108,7 @@ inline const Vector3& Billboard::getTranslation() const
return translation;
}

inline const glm::quat& Billboard::getRotation() const
inline const Quaternion& Billboard::getRotation() const
{
return rotation;
}
Expand Down

0 comments on commit ce417f4

Please sign in to comment.