TestTriangle
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user