Compare commits
2 Commits
2a313fbc51
...
4ccf3b4b0d
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ccf3b4b0d | |||
| 8459ad562e |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
build/*
|
||||
.vscode
|
||||
13
fsq.vs
Normal file
13
fsq.vs
Normal file
@@ -0,0 +1,13 @@
|
||||
R"###(
|
||||
#version 330 core
|
||||
layout (location = 0) in vec2 aPos;
|
||||
layout (location = 1) in vec2 aTexCoords;
|
||||
|
||||
out vec2 TexCoords;
|
||||
|
||||
void main()
|
||||
{
|
||||
TexCoords = aTexCoords;
|
||||
gl_Position = vec4(aPos.x, aPos.y, 0.0, 1.0);
|
||||
}
|
||||
)###";
|
||||
51
main.cpp
51
main.cpp
@@ -3,26 +3,14 @@
|
||||
#include <cstdio>
|
||||
#include "FullScreenQuad.hpp"
|
||||
|
||||
float vertices[] = {
|
||||
-0.5f, -0.5f, 0.0f,
|
||||
0.5f, -0.5f, 0.0f,
|
||||
0.0f, 0.5f, 0.0f
|
||||
};
|
||||
|
||||
const char *vertexShaderSource =
|
||||
#include "fsq.vs"
|
||||
;
|
||||
|
||||
const char *vertexShaderSource = "#version 330 core\n"
|
||||
"layout (location = 0) in vec3 aPos;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
|
||||
"}\0";
|
||||
|
||||
const char *fragmentShaderSource = "#version 330 core\n"
|
||||
"out vec4 FragColor;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
|
||||
"}\n\0";
|
||||
const char *fragmentShaderSource =
|
||||
#include "sdf.fs"
|
||||
;
|
||||
|
||||
/*void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
{
|
||||
@@ -35,27 +23,6 @@ void processInput(GLFWwindow *window)
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
}
|
||||
|
||||
unsigned int initVBO() {
|
||||
unsigned int VBO;
|
||||
glGenBuffers(1, &VBO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||
return VBO;
|
||||
}
|
||||
|
||||
unsigned int initVAO() {
|
||||
unsigned int VAO;
|
||||
glGenVertexArrays(1, &VAO);
|
||||
glBindVertexArray(VAO);
|
||||
// 2. copy our vertices array in a buffer for OpenGL to use
|
||||
glBindBuffer(GL_ARRAY_BUFFER, initVBO());
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||
// 3. then set our vertex attributes pointers
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
|
||||
glEnableVertexAttribArray(0);
|
||||
return VAO;
|
||||
}
|
||||
|
||||
|
||||
unsigned int compVertexShader() {
|
||||
unsigned int vertexShader;
|
||||
@@ -88,10 +55,6 @@ unsigned int compShader() {
|
||||
return shaderProgram;
|
||||
}
|
||||
|
||||
void linkVBO() {
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
|
||||
glEnableVertexAttribArray(0);
|
||||
}
|
||||
|
||||
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
{
|
||||
@@ -128,7 +91,6 @@ int main(int argc, char** argv) {
|
||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||
|
||||
unsigned int shaderProgramm = compShader();
|
||||
unsigned int VAO = initVAO();
|
||||
|
||||
FullScreenQuad fsq{};
|
||||
|
||||
@@ -144,7 +106,6 @@ int main(int argc, char** argv) {
|
||||
|
||||
glUseProgram(shaderProgramm);
|
||||
|
||||
glBindVertexArray(VAO);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(fsq.getVAO());
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
Reference in New Issue
Block a user