TestTriangle

This commit is contained in:
2026-02-04 09:04:44 -06:00
parent 07b4518cb4
commit e67df40233
2 changed files with 26 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ namespace Archimedes {
void render(std::list<std::function<void()>> cmdList, int& w, int& h) { void render(std::list<std::function<void()>> cmdList, int& w, int& h) {
glViewport(0, 0, w, h); glViewport(0, 0, w, h);
glClearColor(0.2, 0.2, 0.4, 1);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
for(auto f : cmdList) for(auto f : cmdList)

View File

@@ -47,6 +47,7 @@ void TestTriangle::onLoad() {
glBindVertexArray(vao); glBindVertexArray(vao);
// 3. now draw the object // 3. now draw the object
glDrawArrays(GL_TRIANGLES, 0, 3); glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
}); });
rcmd_it = --wm->getRenderer()->getCmdList().end()++; rcmd_it = --wm->getRenderer()->getCmdList().end()++;
@@ -63,16 +64,40 @@ void TestTriangle::onLoad() {
glShaderSource(vs, 1, &vertexShaderSource, NULL); glShaderSource(vs, 1, &vertexShaderSource, NULL);
glCompileShader(vs); glCompileShader(vs);
glGetShaderiv(vs, GL_COMPILE_STATUS, &success);
if(!success) {
std::cout << "shader linking failed!" << std::endl;
std::abort();
};
fs = glCreateShader(GL_FRAGMENT_SHADER); fs = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fs, 1, &fragShaderSource, NULL); glShaderSource(fs, 1, &fragShaderSource, NULL);
glCompileShader(fs); glCompileShader(fs);
glGetShaderiv(fs, GL_COMPILE_STATUS, &success);
if(!success) {
std::cout << "shader linking failed!" << std::endl;
std::abort();
};
program = glCreateProgram(); program = glCreateProgram();
glAttachShader(program, vs); glAttachShader(program, vs);
glAttachShader(program, fs); glAttachShader(program, fs);
glLinkProgram(program); glLinkProgram(program);
glGetProgramiv(program, GL_LINK_STATUS, &success);
if(!success) {
std::cout << "shader linking failed!" << std::endl;
std::abort();
};
glDeleteShader(vs); glDeleteShader(vs);
glDeleteShader(fs); glDeleteShader(fs);