mirror of
https://github.com/guezoloic/LearnOpenGL.git
synced 2026-01-25 04:34:14 +00:00
feat: add imgui library & primitive shapes
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -10,3 +10,6 @@
|
|||||||
[submodule "lib/glad"]
|
[submodule "lib/glad"]
|
||||||
path = lib/glad
|
path = lib/glad
|
||||||
url = https://github.com/DawidLokiec/glad.git
|
url = https://github.com/DawidLokiec/glad.git
|
||||||
|
[submodule "lib/imgui"]
|
||||||
|
path = lib/imgui
|
||||||
|
url = https://github.com/ocornut/imgui.git
|
||||||
|
|||||||
1
lib/imgui
Submodule
1
lib/imgui
Submodule
Submodule lib/imgui added at 922a11f084
31
res/render/primitives/cube.frag
Normal file
31
res/render/primitives/cube.frag
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#version 330 core
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
struct Material
|
||||||
|
{
|
||||||
|
sampler2D diffuse;
|
||||||
|
vec3 specular;
|
||||||
|
float shininess;
|
||||||
|
};
|
||||||
|
struct Light
|
||||||
|
{
|
||||||
|
vec3 position;
|
||||||
|
|
||||||
|
vec3 ambient;
|
||||||
|
vec3 diffuse;
|
||||||
|
vec3 specular;
|
||||||
|
};
|
||||||
|
|
||||||
|
in vec3 FragPos;
|
||||||
|
in vec3 Normal;
|
||||||
|
in vec2 TexCoords;
|
||||||
|
|
||||||
|
uniform vec3 viewPos;
|
||||||
|
uniform Material material;
|
||||||
|
uniform Light light;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 texColor = texture(material.diffuse , TexCoords);
|
||||||
|
FragColor = texColor;
|
||||||
|
}
|
||||||
60
res/render/primitives/cube.hpp
Normal file
60
res/render/primitives/cube.hpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#include "GLFW/glfw3.h"
|
||||||
|
|
||||||
|
// Positions // Normales // texture coordinate
|
||||||
|
constexpr GLfloat VERTICE[] = {
|
||||||
|
// front side
|
||||||
|
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
|
0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f,
|
||||||
|
0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
|
||||||
|
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f,
|
||||||
|
|
||||||
|
// back side
|
||||||
|
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f,
|
||||||
|
0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
|
||||||
|
0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f,
|
||||||
|
-0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f,
|
||||||
|
|
||||||
|
// left side
|
||||||
|
-0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
-0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
-0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
|
||||||
|
-0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
|
||||||
|
// right side
|
||||||
|
0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
|
||||||
|
|
||||||
|
// bottom side
|
||||||
|
-0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 1.0f, 1.0f,
|
||||||
|
0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
-0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
|
||||||
|
// up side
|
||||||
|
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,
|
||||||
|
0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr unsigned int INDICE[] = {
|
||||||
|
0, 1, 2, // 1
|
||||||
|
2, 3, 0, // 2
|
||||||
|
|
||||||
|
4, 5, 6, // 3
|
||||||
|
6, 7, 4, // 4
|
||||||
|
|
||||||
|
8, 9, 10, // 5
|
||||||
|
10, 11, 8, // 6
|
||||||
|
|
||||||
|
12, 13, 14, // 7
|
||||||
|
14, 15, 12, // 8
|
||||||
|
|
||||||
|
16, 17, 18, // 9
|
||||||
|
18, 19, 16, // 10
|
||||||
|
|
||||||
|
20, 21, 22, // 11
|
||||||
|
22, 23, 20 // 12
|
||||||
|
};
|
||||||
22
res/render/primitives/cube.vert
Normal file
22
res/render/primitives/cube.vert
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
layout (location = 0) in vec3 aPos;
|
||||||
|
layout (location = 1) in vec3 aNormal;
|
||||||
|
layout (location = 2) in vec2 aTexCoords;
|
||||||
|
|
||||||
|
uniform mat4 projection;
|
||||||
|
uniform mat4 model;
|
||||||
|
uniform mat4 view;
|
||||||
|
|
||||||
|
out vec3 Normal;
|
||||||
|
out vec3 FragPos;
|
||||||
|
out vec2 TexCoords;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragPos = vec3(model*vec4(aPos , 1.0));
|
||||||
|
gl_Position = projection*view*vec4(FragPos , 1.0);
|
||||||
|
|
||||||
|
Normal = mat3(transpose(inverse(model)))*aNormal;
|
||||||
|
TexCoords = aTexCoords;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user