Basic rectangle drawing

This commit is contained in:
2022-04-30 20:20:07 +02:00
parent ddf7e14682
commit f547ff1b8f
8 changed files with 93 additions and 40 deletions

View File

@ -38,6 +38,19 @@ Shader::Shader(const std::string vertexShaderPath, const std::string fragmentSha
return;
}
id = glCreateProgram();
glAttachShader(id, vertId);
glAttachShader(id, fragId);
glLinkProgram(id);
int success;
glGetProgramiv(id, GL_LINK_STATUS, &success);
if(!success) {
glGetProgramInfoLog(id, 512, NULL, infoLog);
printf("ERROR::SHADER_PROGRAM::LINKING_FAILED\n %s", infoLog);
}
delete[] vertexCode;
@ -90,5 +103,5 @@ char* Shader::readFile (const char* filePath){
void Shader::Use()
{
// glUseProgam(id);
glUseProgram(id);
}

View File

@ -1,4 +1,5 @@
#pragma once
#include <glad/glad.h>
#include <GLFW/glfw3.h>
@ -9,7 +10,7 @@ class BarinkWindow{
bool VulkanSupported;
int Width, Height;
bool InitGLFW();
static bool InitGLFW();
public:

View File

@ -8,12 +8,15 @@ bool BarinkWindow::InitGLFW(){
spdlog::error("Failed to initialise GLFW!");
return false;
}
return true;
}
BarinkWindow::BarinkWindow(const int width, const int height) :
Width(width), Height(height), FullScreen(false){
InitGLFW();
if (InitGLFW()==false) {
exit(-1);
}
window = glfwCreateWindow(Width, Height, "BarinkEngine", NULL, NULL);
@ -25,6 +28,10 @@ Width(width), Height(height), FullScreen(false){
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
printf("Failed to initialize GLAD!\n");
exit(-1);
}
VulkanSupported = glfwVulkanSupported();
@ -33,6 +40,9 @@ Width(width), Height(height), FullScreen(false){
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
}