mirror of
https://github.com/guezoloic/LearnOpenGL.git
synced 2026-01-25 03:34:15 +00:00
feat: triangle is perfectly draw
This commit is contained in:
@@ -76,10 +76,10 @@ constexpr const std::size_t P_CUBE_INDICE_LEN =
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern const unsigned char CUBE_VERT[];
|
||||
extern const unsigned int CUBE_VERT_LEN;
|
||||
extern const unsigned char CUBE_FRAG[];
|
||||
extern const unsigned int CUBE_FRAG_LEN;
|
||||
extern const unsigned char P_CUBE_VERT[];
|
||||
extern const unsigned int P_CUBE_VERT_LEN;
|
||||
extern const unsigned char P_CUBE_FRAG[];
|
||||
extern const unsigned int P_CUBE_FRAG_LEN;
|
||||
}
|
||||
} // namespace mesh
|
||||
|
||||
8
res/render/primitives/p_triangle.frag
Normal file
8
res/render/primitives/p_triangle.frag
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 330 core
|
||||
|
||||
out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = vec4(1.0f, 0.5f, 0.2f, 1.0f);
|
||||
}
|
||||
37
res/render/primitives/p_triangle.hpp
Normal file
37
res/render/primitives/p_triangle.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef P_TRIANGLE_HPP
|
||||
#define P_TRIANGLE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "GLFW/glfw3.h"
|
||||
|
||||
namespace mesh
|
||||
{
|
||||
// clang-format off
|
||||
constexpr GLfloat P_TRIANGLE_VERTICE[] = {
|
||||
-0.5f, -0.5f, 0.0f,
|
||||
0.5f, -0.5f, 0.0f,
|
||||
0.0f, 0.5f, 0.0f
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
constexpr const std::size_t P_TRIANGLE_VERTICE_LEN =
|
||||
sizeof(P_TRIANGLE_VERTICE) / sizeof(GLfloat);
|
||||
|
||||
constexpr unsigned int P_TRIANGLE_INDICE[] = {
|
||||
0, 1, 2, // 1
|
||||
};
|
||||
|
||||
constexpr const std::size_t P_TRIANGLE_INDICE_LEN =
|
||||
sizeof(P_TRIANGLE_VERTICE) / sizeof(unsigned int);
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern const unsigned char P_TRIANGLE_VERT[];
|
||||
extern const unsigned int P_TRIANGLE_VERT_LEN;
|
||||
extern const unsigned char P_TRIANGLE_FRAG[];
|
||||
extern const unsigned int P_TRIANGLE_FRAG_LEN;
|
||||
}
|
||||
} // namespace mesh
|
||||
|
||||
#endif
|
||||
7
res/render/primitives/p_triangle.vert
Normal file
7
res/render/primitives/p_triangle.vert
Normal file
@@ -0,0 +1,7 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec3 aPos;
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(aPos , 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user