GLUtil: Encapsulate functions in a namespace

This commit is contained in:
Stenzek
2018-03-10 14:52:48 +10:00
parent e31cc1f679
commit 51a586d11a
4 changed files with 11 additions and 12 deletions

View File

@ -11,12 +11,14 @@
std::unique_ptr<cInterfaceBase> GLInterface; std::unique_ptr<cInterfaceBase> GLInterface;
namespace GLUtil
{
void InitInterface() void InitInterface()
{ {
GLInterface = HostGL_CreateGLInterface(); GLInterface = HostGL_CreateGLInterface();
} }
GLuint OpenGL_CompileProgram(const std::string& vertexShader, const std::string& fragmentShader) GLuint CompileProgram(const std::string& vertexShader, const std::string& fragmentShader)
{ {
// generate objects // generate objects
GLuint vertexShaderID = glCreateShader(GL_VERTEX_SHADER); GLuint vertexShaderID = glCreateShader(GL_VERTEX_SHADER);
@ -100,3 +102,4 @@ GLuint OpenGL_CompileProgram(const std::string& vertexShader, const std::string&
return programID; return programID;
} }
}

View File

@ -8,12 +8,8 @@
#include "Common/GL/GLExtensions/GLExtensions.h" #include "Common/GL/GLExtensions/GLExtensions.h"
#ifndef _WIN32 namespace GLUtil
{
#include <sys/types.h>
#endif
void InitInterface(); void InitInterface();
GLuint CompileProgram(const std::string& vertexShader, const std::string& fragmentShader);
// Helpers }
GLuint OpenGL_CompileProgram(const std::string& vertexShader, const std::string& fragmentShader);

View File

@ -160,7 +160,7 @@ bool VideoBackend::Initialize(void* window_handle)
InitBackendInfo(); InitBackendInfo();
InitializeShared(); InitializeShared();
InitInterface(); GLUtil::InitInterface();
GLInterface->SetMode(GLInterfaceMode::MODE_DETECT); GLInterface->SetMode(GLInterfaceMode::MODE_DETECT);
if (!GLInterface->Create(window_handle, g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer)) if (!GLInterface->Create(window_handle, g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer))
return false; return false;

View File

@ -15,7 +15,7 @@ std::unique_ptr<SWOGLWindow> SWOGLWindow::s_instance;
void SWOGLWindow::Init(void* window_handle) void SWOGLWindow::Init(void* window_handle)
{ {
InitInterface(); GLUtil::InitInterface();
GLInterface->SetMode(GLInterfaceMode::MODE_DETECT); GLInterface->SetMode(GLInterfaceMode::MODE_DETECT);
if (!GLInterface->Create(window_handle)) if (!GLInterface->Create(window_handle))
{ {
@ -71,7 +71,7 @@ void SWOGLWindow::Prepare()
"#version 300 es\n" "#version 300 es\n"
"precision highp float;\n"; "precision highp float;\n";
m_image_program = OpenGL_CompileProgram(header + vertex_shader, header + frag_shader); m_image_program = GLUtil::CompileProgram(header + vertex_shader, header + frag_shader);
glUseProgram(m_image_program); glUseProgram(m_image_program);