Minor cleanup
parent
3b4c2f3049
commit
a1e4e4b97c
|
@ -192,17 +192,6 @@ enum FrustumPlane
|
||||||
FRUSTUM_PLANE_FRONT | FRUSTUM_PLANE_BACK
|
FRUSTUM_PLANE_FRONT | FRUSTUM_PLANE_BACK
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* \enum RenderTarget
|
|
||||||
* \brief Render targets for rendering to textures
|
|
||||||
*/
|
|
||||||
enum RenderTarget
|
|
||||||
{
|
|
||||||
RENDER_TARGET_COLOR,
|
|
||||||
RENDER_TARGET_DEPTH,
|
|
||||||
RENDER_TARGET_STENCIL
|
|
||||||
};
|
|
||||||
|
|
||||||
class CFrameBufferPixels
|
class CFrameBufferPixels
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -73,9 +73,6 @@ public:
|
||||||
//! Sets transparency mode
|
//! Sets transparency mode
|
||||||
virtual void SetTransparency(TransparencyMode mode) = 0;
|
virtual void SetTransparency(TransparencyMode mode) = 0;
|
||||||
|
|
||||||
//! Draws primitive
|
|
||||||
virtual void DrawPrimitive(PrimitiveType type, int count, const Vertex2D* vertices) = 0;
|
|
||||||
|
|
||||||
virtual Vertex2D* BeginPrimitive(PrimitiveType type, int count) = 0;
|
virtual Vertex2D* BeginPrimitive(PrimitiveType type, int count) = 0;
|
||||||
virtual Vertex2D* BeginPrimitives(PrimitiveType type, int drawCount, const int* counts) = 0;
|
virtual Vertex2D* BeginPrimitives(PrimitiveType type, int drawCount, const int* counts) = 0;
|
||||||
virtual bool EndPrimitive() = 0;
|
virtual bool EndPrimitive() = 0;
|
||||||
|
|
|
@ -44,19 +44,6 @@ namespace Gfx
|
||||||
enum class CullFace : unsigned char;
|
enum class CullFace : unsigned char;
|
||||||
enum class TransparencyMode : unsigned char;
|
enum class TransparencyMode : unsigned char;
|
||||||
|
|
||||||
//! Struct for dynamic buffers
|
|
||||||
struct DynamicBuffer
|
|
||||||
{
|
|
||||||
//! Auxiliary VAO for rendering primitives with DrawPrimitive*
|
|
||||||
GLuint vao = 0;
|
|
||||||
//! Dynamic buffer
|
|
||||||
GLuint vbo = 0;
|
|
||||||
//! Dynamic buffer size
|
|
||||||
unsigned int size = 0;
|
|
||||||
//! Dynamic buffer offset
|
|
||||||
unsigned int offset = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CGL33VertexBuffer : public CVertexBuffer
|
class CGL33VertexBuffer : public CVertexBuffer
|
||||||
{
|
{
|
||||||
GLuint m_vao = 0;
|
GLuint m_vao = 0;
|
||||||
|
|
|
@ -161,15 +161,6 @@ void CGL33UIRenderer::SetTransparency(TransparencyMode mode)
|
||||||
m_device->SetTransparency(mode);
|
m_device->SetTransparency(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGL33UIRenderer::DrawPrimitive(PrimitiveType type, int count, const Vertex2D* vertices)
|
|
||||||
{
|
|
||||||
auto ptr = BeginPrimitive(type, count);
|
|
||||||
|
|
||||||
std::copy_n(vertices, count, ptr);
|
|
||||||
|
|
||||||
EndPrimitive();
|
|
||||||
}
|
|
||||||
|
|
||||||
Vertex2D* CGL33UIRenderer::BeginPrimitive(PrimitiveType type, int count)
|
Vertex2D* CGL33UIRenderer::BeginPrimitive(PrimitiveType type, int count)
|
||||||
{
|
{
|
||||||
return BeginPrimitives(type, 1, &count);
|
return BeginPrimitives(type, 1, &count);
|
||||||
|
|
|
@ -48,8 +48,6 @@ public:
|
||||||
virtual void SetColor(const glm::vec4& color) override;
|
virtual void SetColor(const glm::vec4& color) override;
|
||||||
virtual void SetTransparency(TransparencyMode mode) override;
|
virtual void SetTransparency(TransparencyMode mode) override;
|
||||||
|
|
||||||
virtual void DrawPrimitive(PrimitiveType type, int count, const Vertex2D* vertices) override;
|
|
||||||
|
|
||||||
virtual Vertex2D* BeginPrimitive(PrimitiveType type, int count) override;
|
virtual Vertex2D* BeginPrimitive(PrimitiveType type, int count) override;
|
||||||
virtual Vertex2D* BeginPrimitives(PrimitiveType type, int drawCount, const int* counts) override;
|
virtual Vertex2D* BeginPrimitives(PrimitiveType type, int drawCount, const int* counts) override;
|
||||||
virtual bool EndPrimitive() override;
|
virtual bool EndPrimitive() override;
|
||||||
|
|
|
@ -35,9 +35,6 @@
|
||||||
namespace Gfx
|
namespace Gfx
|
||||||
{
|
{
|
||||||
|
|
||||||
GLuint textureCoordinates[] = { GL_S, GL_T, GL_R, GL_Q };
|
|
||||||
GLuint textureCoordGen[] = { GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R, GL_TEXTURE_GEN_Q };
|
|
||||||
|
|
||||||
bool InitializeGLEW()
|
bool InitializeGLEW()
|
||||||
{
|
{
|
||||||
static bool glewInited = false;
|
static bool glewInited = false;
|
||||||
|
@ -58,14 +55,6 @@ bool InitializeGLEW()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FramebufferSupport DetectFramebufferSupport()
|
|
||||||
{
|
|
||||||
if (GetOpenGLVersion() >= 30) return FBS_ARB;
|
|
||||||
if (glewIsSupported("GL_ARB_framebuffer_object")) return FBS_ARB;
|
|
||||||
if (glewIsSupported("GL_EXT_framebuffer_object")) return FBS_EXT;
|
|
||||||
return FBS_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<CDevice> CreateDevice(const DeviceConfig &config, const std::string& name)
|
std::unique_ptr<CDevice> CreateDevice(const DeviceConfig &config, const std::string& name)
|
||||||
{
|
{
|
||||||
if (name == "default") return std::make_unique<CGL33Device>(config);
|
if (name == "default") return std::make_unique<CGL33Device>(config);
|
||||||
|
@ -228,61 +217,22 @@ std::string GetHardwareInfo(bool full)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FBO support
|
// FBO support
|
||||||
FramebufferSupport framebuffer = DetectFramebufferSupport();
|
result << "Framebuffer Object:\t\tsupported\n";
|
||||||
|
result << " Type:\t\t\tCore/ARB\n";
|
||||||
|
|
||||||
if (framebuffer == FBS_ARB)
|
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value);
|
||||||
{
|
result << " Max Renderbuffer Size:\t" << value << '\n';
|
||||||
result << "Framebuffer Object:\t\tsupported\n";
|
|
||||||
result << " Type:\t\t\tCore/ARB\n";
|
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value);
|
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &value);
|
||||||
result << " Max Renderbuffer Size:\t" << value << '\n';
|
result << " Max Color Attachments:\t" << value << '\n';
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &value);
|
result << "Multisampling:\t\tsupported\n";
|
||||||
result << " Max Color Attachments:\t" << value << '\n';
|
|
||||||
|
|
||||||
result << "Multisampling:\t\tsupported\n";
|
glGetIntegerv(GL_MAX_SAMPLES, &value);
|
||||||
|
result << " Max Framebuffer Samples:\t" << value << '\n';
|
||||||
glGetIntegerv(GL_MAX_SAMPLES, &value);
|
|
||||||
result << " Max Framebuffer Samples:\t" << value << '\n';
|
|
||||||
}
|
|
||||||
else if (framebuffer == FBS_EXT)
|
|
||||||
{
|
|
||||||
result << "Framebuffer Object:\tsupported\n";
|
|
||||||
result << " Type:\tEXT\n";
|
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &value);
|
|
||||||
result << " Max Renderbuffer Size:\t" << value << '\n';
|
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &value);
|
|
||||||
result << " Max Color Attachments:\t" << value << '\n';
|
|
||||||
|
|
||||||
if (glewIsSupported("GL_EXT_framebuffer_multisample"))
|
|
||||||
{
|
|
||||||
result << "Multisampling:\tsupported\n";
|
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_SAMPLES_EXT, &value);
|
|
||||||
result << " Max Framebuffer Samples:\t" << value << '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result << "Framebuffer Object:\tunsupported\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// VBO support
|
// VBO support
|
||||||
if (glversion >= 15)
|
result << "VBO:\t\t\tsupported (core)\n";
|
||||||
{
|
|
||||||
result << "VBO:\t\t\tsupported (core)\n";
|
|
||||||
}
|
|
||||||
else if (glewIsSupported("GL_ARB_vertex_buffer_object"))
|
|
||||||
{
|
|
||||||
result << "VBO:\t\t\tsupported (ARB)\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result << "VBO:\t\t\tunsupported\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.str();
|
return result.str();
|
||||||
}
|
}
|
||||||
|
@ -381,20 +331,6 @@ bool InPlane(glm::vec3 normal, float originPlane, glm::vec3 center, float radius
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum TranslateTextureCoordinate(int index)
|
|
||||||
{
|
|
||||||
assert(index >= 0 && index < 4);
|
|
||||||
|
|
||||||
return textureCoordinates[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
GLenum TranslateTextureCoordinateGen(int index)
|
|
||||||
{
|
|
||||||
assert(index >= 0 && index < 4);
|
|
||||||
|
|
||||||
return textureCoordGen[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
GLenum TranslateType(Type type)
|
GLenum TranslateType(Type type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -424,9 +360,9 @@ std::string LoadSource(const std::string& path)
|
||||||
PHYSFS_file* file = PHYSFS_openRead(path.c_str());
|
PHYSFS_file* file = PHYSFS_openRead(path.c_str());
|
||||||
if (file == nullptr)
|
if (file == nullptr)
|
||||||
{
|
{
|
||||||
CLogger::GetInstance().Error("Cannot read shader source file\n");
|
GetLogger()->Error("Cannot read shader source file\n");
|
||||||
CLogger::GetInstance().Error("Missing file \"%s\"\n", path);
|
GetLogger()->Error("Missing file \"%s\"\n", path);
|
||||||
return 0;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len = PHYSFS_fileLength(file);
|
size_t len = PHYSFS_fileLength(file);
|
||||||
|
@ -479,8 +415,8 @@ GLint LoadShader(GLint type, const char* filename)
|
||||||
PHYSFS_file *file = PHYSFS_openRead(filename);
|
PHYSFS_file *file = PHYSFS_openRead(filename);
|
||||||
if (file == nullptr)
|
if (file == nullptr)
|
||||||
{
|
{
|
||||||
CLogger::GetInstance().Error("Cannot read shader source file\n");
|
GetLogger()->Error("Cannot read shader source file\n");
|
||||||
CLogger::GetInstance().Error("Missing file \"%s\"\n", filename);
|
GetLogger()->Error("Missing file \"%s\"\n", filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,17 +38,8 @@ struct SDL_Surface;
|
||||||
namespace Gfx
|
namespace Gfx
|
||||||
{
|
{
|
||||||
|
|
||||||
enum FramebufferSupport
|
|
||||||
{
|
|
||||||
FBS_NONE,
|
|
||||||
FBS_EXT,
|
|
||||||
FBS_ARB,
|
|
||||||
};
|
|
||||||
|
|
||||||
bool InitializeGLEW();
|
bool InitializeGLEW();
|
||||||
|
|
||||||
FramebufferSupport DetectFramebufferSupport();
|
|
||||||
|
|
||||||
//! Creates OpenGL device
|
//! Creates OpenGL device
|
||||||
std::unique_ptr<CDevice> CreateDevice(const DeviceConfig &config, const std::string& name);
|
std::unique_ptr<CDevice> CreateDevice(const DeviceConfig &config, const std::string& name);
|
||||||
|
|
||||||
|
@ -82,10 +73,6 @@ GLenum TranslateGfxCompFunc(CompFunc func);
|
||||||
|
|
||||||
bool InPlane(glm::vec3 normal, float originPlane, glm::vec3 center, float radius);
|
bool InPlane(glm::vec3 normal, float originPlane, glm::vec3 center, float radius);
|
||||||
|
|
||||||
GLenum TranslateTextureCoordinate(int index);
|
|
||||||
|
|
||||||
GLenum TranslateTextureCoordinateGen(int index);
|
|
||||||
|
|
||||||
GLenum TranslateType(Type type);
|
GLenum TranslateType(Type type);
|
||||||
|
|
||||||
std::string GetLastShaderError();
|
std::string GetLastShaderError();
|
||||||
|
@ -129,35 +116,4 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<CGLFrameBufferPixels> GetGLFrameBufferPixels(const glm::ivec2& size);
|
std::unique_ptr<CGLFrameBufferPixels> GetGLFrameBufferPixels(const glm::ivec2& size);
|
||||||
|
|
||||||
struct UniformLocations
|
|
||||||
{
|
|
||||||
// Uniforms
|
|
||||||
//! Projection matrix
|
|
||||||
GLint projectionMatrix = -1;
|
|
||||||
//! View matrix
|
|
||||||
GLint viewMatrix = -1;
|
|
||||||
//! Model matrix
|
|
||||||
GLint modelMatrix = -1;
|
|
||||||
//! Shadow matrix
|
|
||||||
GLint shadowMatrix = -1;
|
|
||||||
//! Normal matrix
|
|
||||||
GLint normalMatrix = -1;
|
|
||||||
//! Camera position
|
|
||||||
GLint cameraPosition = -1;
|
|
||||||
|
|
||||||
//! Primary texture sampler
|
|
||||||
GLint primaryTexture = -1;
|
|
||||||
//! Secondary texture sampler
|
|
||||||
GLint secondaryTexture = -1;
|
|
||||||
|
|
||||||
//! true enables texture
|
|
||||||
GLint textureEnabled[3] = {};
|
|
||||||
|
|
||||||
// Alpha test parameters
|
|
||||||
//! true enables alpha test
|
|
||||||
GLint alphaTestEnabled = -1;
|
|
||||||
//! Alpha test reference value
|
|
||||||
GLint alphaReference = -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Gfx
|
} // namespace Gfx
|
||||||
|
|
Loading…
Reference in New Issue