ADD: Render first triangle
This commit is contained in:
parent
081a091f37
commit
2088dde6ca
@ -48,6 +48,7 @@ namespace engine {
|
|||||||
GLStateCache::init();
|
GLStateCache::init();
|
||||||
|
|
||||||
if (config.debugContext) {
|
if (config.debugContext) {
|
||||||
|
std::cout << "Debug Context should be enabled" << std::endl;
|
||||||
glEnable(GL_DEBUG_OUTPUT);
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||||
glDebugMessageCallback(DebugCallback, nullptr);
|
glDebugMessageCallback(DebugCallback, nullptr);
|
||||||
|
|||||||
@ -5,6 +5,9 @@
|
|||||||
#include "Vao.h"
|
#include "Vao.h"
|
||||||
#include "Vao.h"
|
#include "Vao.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
namespace engine {
|
namespace engine {
|
||||||
|
|
||||||
Vao::Vao(unsigned int id) : m_id(id) {
|
Vao::Vao(unsigned int id) : m_id(id) {
|
||||||
|
|||||||
@ -3,10 +3,33 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "ColorRaceApp.h"
|
#include "ColorRaceApp.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
void ColorRaceApp::initTriangle() {
|
||||||
|
float vertices[] = {
|
||||||
|
-0.5f, -0.5f, 0.0f,
|
||||||
|
0.5f, -0.5f, 0.0f,
|
||||||
|
0.0f, 0.5f, 0.0f,
|
||||||
|
};
|
||||||
|
|
||||||
|
m_triangleVao = engine::Vao::create();
|
||||||
|
|
||||||
|
std::vector<std::unique_ptr<engine::Attribute>> attributes;
|
||||||
|
attributes.push_back(std::make_unique<engine::Vec3Attribute>(0));
|
||||||
|
m_triangleVao->initDataFeed(vertices, sizeof(vertices), GL_STATIC_DRAW, std::move(attributes));
|
||||||
|
m_triangleVao->unbind();
|
||||||
|
}
|
||||||
|
|
||||||
void ColorRaceApp::onUpdate(float deltaTime) {
|
void ColorRaceApp::onUpdate(float deltaTime) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorRaceApp::onRender() {
|
void ColorRaceApp::onRender() {
|
||||||
|
m_renderState.apply();
|
||||||
|
m_triangleVao->bind();
|
||||||
|
m_shader->start();
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||||
|
m_shader->stop();
|
||||||
}
|
}
|
||||||
@ -5,6 +5,9 @@
|
|||||||
#ifndef COLORRACE_COLORRACEAPP_H
|
#ifndef COLORRACE_COLORRACEAPP_H
|
||||||
#define COLORRACE_COLORRACEAPP_H
|
#define COLORRACE_COLORRACEAPP_H
|
||||||
#include "core/Application.h"
|
#include "core/Application.h"
|
||||||
|
#include "utils/openglWrapper/GLRenderState.h"
|
||||||
|
#include "utils/openglWrapper/openglObjects/Vao.h"
|
||||||
|
#include "utils/openglWrapper/shader/ShaderProgram.h"
|
||||||
|
|
||||||
|
|
||||||
class ColorRaceApp : public engine::Application {
|
class ColorRaceApp : public engine::Application {
|
||||||
@ -17,9 +20,22 @@ public:
|
|||||||
config.windowTitle = "ColorRace";
|
config.windowTitle = "ColorRace";
|
||||||
config.clearColor = glm::vec4(0.1f, 0.1f, 0.15f, 1.0f);
|
config.clearColor = glm::vec4(0.1f, 0.1f, 0.15f, 1.0f);
|
||||||
config.vsync = true;
|
config.vsync = true;
|
||||||
|
config.debugContext = true;
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
ColorRaceApp() : Application(makeConfig()) {}
|
ColorRaceApp() : Application(makeConfig()) {
|
||||||
|
m_renderState.depthTesting = false;
|
||||||
|
m_renderState.backfaceCulling = false;
|
||||||
|
|
||||||
|
m_shader = std::make_unique<engine::ShaderProgram>("assets/shaders/basic.vert", "assets/shaders/basic.frag");
|
||||||
|
initTriangle();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
engine::GLRenderState m_renderState;
|
||||||
|
std::unique_ptr<engine::ShaderProgram> m_shader;
|
||||||
|
std::unique_ptr<engine::Vao> m_triangleVao;
|
||||||
|
|
||||||
|
void initTriangle();
|
||||||
protected:
|
protected:
|
||||||
void onUpdate(float deltaTime) override;
|
void onUpdate(float deltaTime) override;
|
||||||
void onRender() override;
|
void onRender() override;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user