Commit of work up to day 11 of learnopengl.com.

This commit is contained in:
Zed A. Shaw 2026-08-21 13:15:55 -04:00
commit 5ce5b4dda4
447 changed files with 126678 additions and 0 deletions

View file

@ -0,0 +1,10 @@
#version 330 core
layout (location = 0) in vec3 aPos; // the position variable has attribute position 0
out vec4 vertexColor; // specify a color output to the fragment shader
void main()
// syntax error here
gl_Position = vec4(aPos, 1.0); // see how we directly give a vec3 to vec4's constructor
vertexColor = vec4(0.5, 0.0, 0.0, 1.0); // set the output variable to a dark-red color
}

View file

@ -0,0 +1,38 @@
#include <fuc2/run.hpp>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include "dbc.hpp"
TEST_SET(shader_tests);
using namespace fuc2;
int main(int argc, char* argv[]) {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
if (window == NULL)
{
dbc::log("Failed to create GLFW window");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// glad: load all OpenGL function pointers
// ---------------------------------------
if(!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
dbc::log("Failed to initialize GLAD");
return -1;
}
std::vector<fuc2::Set> tests{
shader_tests::TESTS
};
return run_tests(tests, argc, argv);
}

View file

@ -0,0 +1,4 @@
fuc2_tests = files(
'main.cpp',
'shader_tests.cpp',
)

View file

@ -0,0 +1,33 @@
#include <deque>
#include <string>
#include <fuc2/testing.hpp>
#include "shader.hpp"
using namespace fuc2;
namespace shader_tests {
void test_load_shaders() {
Shader shader("shaders/3.3.shader.vs", "shaders/3.3.shader.fs");
shader.use();
CHECK(shader.ID != UINT_MAX, "Shader not initialized");
}
void test_compile_fail() {
auto runner = [&]() {
Shader shader("tests/bad_shader.vs", "shaders/3.3.shader.fs");
};
BLOWS_UP(runner, "compile fail should blow up");
}
fuc2::Set TESTS{
.name="shaders",
.options={ .fail_fast=false },
.tests={
TEST(test_load_shaders),
TEST(test_compile_fail),
}
};
}