36 lines
854 B
C++
36 lines
854 B
C++
#pragma once
|
|
|
|
#include "opengl.hpp"
|
|
|
|
class TriangleWindow : public endofthejedi::GLWindow {
|
|
private:
|
|
protected:
|
|
void init() override {
|
|
glClearColor(0.5f, 0.6f, 0.7f, 1.0f);
|
|
resize();
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
}
|
|
void render(double time) override {
|
|
(void) time;
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
glColor3f(1.0f, 0.0f, 0.0f);
|
|
glVertex3f(0.0f, -1.0f, 0.0f);
|
|
glColor3f(0.0f, 1.0f, 0.0f);
|
|
glVertex3f(-1.0f, 1.0f, 0.0f);
|
|
glColor3f(0.0f, 0.0f, 1.0f);
|
|
glVertex3f(1.0f, 1.0f, 0.0f);
|
|
glEnd();
|
|
}
|
|
void resize() override { glViewport(0, 0, getwidth(), getheight()); }
|
|
|
|
public:
|
|
TriangleWindow(unsigned int width, unsigned int height)
|
|
: endofthejedi::GLWindow(width, height)
|
|
{
|
|
}
|
|
};
|
|
|