GL/Program: Add IsBound() method

This commit is contained in:
Connor McLaughlin 2019-12-07 01:36:14 +10:00
parent 8d7b93766d
commit b53e32e84f
2 changed files with 7 additions and 4 deletions

View file

@ -5,11 +5,11 @@
#include <fstream> #include <fstream>
Log_SetChannel(GL); Log_SetChannel(GL);
static u32 s_next_bad_shader_id = 1;
static GLuint s_last_program_id = 0;
namespace GL { namespace GL {
GLuint Program::s_last_program_id = 0;
static GLuint s_next_bad_shader_id = 1;
Program::Program() = default; Program::Program() = default;
Program::~Program() Program::~Program()

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "glad.h"
#include "../types.h" #include "../types.h"
#include "glad.h"
#include <string_view> #include <string_view>
#include <vector> #include <vector>
@ -15,6 +15,7 @@ public:
static void ResetLastProgram(); static void ResetLastProgram();
bool IsVaild() const { return m_program_id != 0; } bool IsVaild() const { return m_program_id != 0; }
bool IsBound() const { return s_last_program_id == m_program_id; }
bool Compile(const std::string_view vertex_shader, const std::string_view fragment_shader); bool Compile(const std::string_view vertex_shader, const std::string_view fragment_shader);
@ -78,6 +79,8 @@ public:
void BindUniformBlock(const char* name, u32 index); void BindUniformBlock(const char* name, u32 index);
private: private:
static u32 s_last_program_id;
GLuint m_program_id = 0; GLuint m_program_id = 0;
GLuint m_vertex_shader_id = 0; GLuint m_vertex_shader_id = 0;
GLuint m_fragment_shader_id = 0; GLuint m_fragment_shader_id = 0;