Compare commits

..

No commits in common. "430b1fb36411163f846ddd3ecc2460ec160c2350" and "3f0224ac2da82c4f0f8913e873e896a763c6ee38" have entirely different histories.

13 changed files with 23 additions and 43907 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +0,0 @@
# Vertices
v -0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.500000 -0.500000
v -0.500000 0.500000 -0.500000
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
v 0.500000 0.500000 0.500000
v -0.500000 0.500000 0.500000
# Texture Coordinates
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
# Faces
f 1/1 2/2 3/3
f 3/3 4/4 1/1
f 5/1 6/2 7/3
f 7/3 8/4 5/1
f 8/2 4/3 1/4
f 1/4 5/1 8/2
f 7/2 6/3 2/4
f 2/4 3/1 7/2
f 1/4 2/3 6/2
f 6/2 5/1 1/4
f 4/4 3/3 7/2
f 7/2 8/1 4/4

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,6 @@ uniform sampler2D ourTexture;
void main()
{
FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);
//FragColor = texture(ourTexture, TexCoord);
//FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);
FragColor = texture(ourTexture, TexCoord);
}

View File

@ -1,7 +1,6 @@
#ifndef _MESH3D
#define _MESH3D
#include "Texture2D.h"
#include <vector>
#include <string>
@ -9,14 +8,10 @@ namespace djalim {
class Mesh3D {
public:
Mesh3D();
// Constructor
Mesh3D(const std::string& filepath);
std::vector<float> meshVertices;
int numMeshVertices = 0;
void loadOBJFile(const std::string& filepath);
Texture2D texture;
GLuint VBO;
GLuint VAO;
};
}

View File

@ -6,10 +6,8 @@
#include "ShaderProgram.h"
#include "Texture2D.h"
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include "Mesh3D.h"
#define NBCALLBACKS 1
@ -21,7 +19,7 @@ struct Object3D {
GLuint VAO;
};
typedef std::map<std::string,djalim::Mesh3D> Objects3D;
typedef std::map<std::string,Object3D> Objects3D;
static bool gWireframe = false;
@ -39,6 +37,7 @@ namespace djalim {
double previousSeconds = 0.0;
double elapsedSeconds;
int frameCount = 0;
std::map<std::string,Texture2D> textures;
ShaderProgram shaderProgram;
Objects3D objects;
@ -50,7 +49,7 @@ namespace djalim {
void onUpdate();
void loadHints();
void createObject(std::string name, std::string textures, std::string filepath);
void createObject(std::string name, std::string textures, std::vector<float>& vertices);
void loadCallbacks();
void showFps();
void onCreate();

View File

@ -25,8 +25,6 @@ struct objFace {
djalim::Mesh3D::Mesh3D(){}
djalim::Mesh3D::Mesh3D(const std::string& filepath) {
loadOBJFile(filepath);
}
@ -56,7 +54,6 @@ void djalim::Mesh3D::loadOBJFile(const std::string& filepath){
//std::cout << "found vertice: (" << x << ", " << y << ", " << z << ")" << std::endl;
objVertex v = {x, y, z};
vertices.push_back(v);
numMeshVertices++;
}
else if (type == "vn"){
float x, y, z;
@ -73,8 +70,8 @@ void djalim::Mesh3D::loadOBJFile(const std::string& filepath){
vertexTexture.push_back(vt);
}
else if (type == "f"){
// std::cout << "found face" << std::endl;
// std::cout << ss.str() << std::endl;
std::cout << "found face" << std::endl;
std::cout << ss.str() << std::endl;
objFace face;
// TODO Find a more elegant way to do this
for (int i = 0; i < 3; i++){

View File

@ -21,8 +21,8 @@ bool Texture2D::loadTexture(const std::string& filename, bool generateMipmaps) {
return false;
}
//std::cout << "Texture loaded successfully: " << filename << std::endl;
//std::cout << "Width: " << width << ", Height: " << height << ", Components: " << components << std::endl;
std::cout << "Texture loaded successfully: " << filename << std::endl;
std::cout << "Width: " << width << ", Height: " << height << ", Components: " << components << std::endl;
glGenTextures(1, &mTexture);
glBindTexture(GL_TEXTURE_2D, mTexture);

View File

@ -1,5 +1,4 @@
#include "engine.h"
#include "Mesh3D.h"
#include <cstdlib>
#include <iostream>
#include <vector>
@ -42,14 +41,11 @@ djalim::OpenGlEngine::OpenGlEngine(const char* title, int width, int height) {
}
void djalim::OpenGlEngine::createObject(std::string name, std::string textures, std::string filepath){
void djalim::OpenGlEngine::createObject(std::string name, std::string textures, std::vector<float>& vertices){
Mesh3D obj = Mesh3D(filepath);
objects[name] = obj;
objects[name];
bool textureLoaded = obj.texture.loadTexture(textures);
bool textureLoaded = objects[name].texture.loadTexture(textures);
if (!textureLoaded) {
std::cerr << "Failed to load " << name << " texture!" << std::endl;
@ -68,8 +64,10 @@ void djalim::OpenGlEngine::createObject(std::string name, std::string textures,
//glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBindBuffer(GL_ARRAY_BUFFER, objects[name].VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*obj.meshVertices.size(), obj.meshVertices.data(), GL_STATIC_DRAW);
std::cout << "Loading 3D objects with "<< vertices.size() << " vertices"<< std::endl;
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*vertices.size(), vertices.data(), GL_STATIC_DRAW);
// Attribut de position
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);

View File

@ -49,7 +49,7 @@ void djalim::cube(GLFWwindow* window, djalim::ShaderProgram shader, Objects3D& o
shader.setUniform("projection", projection); // Assurez-vous que setUniform pour mat4 est implémenté
// Matrice de Vue
glm::mat4 view = glm::lookAt(glm::vec3(0.0f, 0.0f, 9.0f), // Position caméra
glm::mat4 view = glm::lookAt(glm::vec3(0.0f, 0.0f, 3.0f), // Position caméra
glm::vec3(0.0f, 0.0f, 0.0f), // Cible
glm::vec3(0.0f, 1.0f, 0.0f)); // Axe Haut
shader.setUniform("view", view);
@ -61,7 +61,7 @@ void djalim::cube(GLFWwindow* window, djalim::ShaderProgram shader, Objects3D& o
// Dessiner le cube
glBindVertexArray(objects["cube"].VAO);
glDrawArrays(GL_TRIANGLES, 0, objects["cube"].numMeshVertices*3);
glDrawArrays(GL_TRIANGLES, 0, 36);
//std::cout << objects["cube"].VAO << std::endl;

View File

@ -4,7 +4,8 @@
#include "Mesh3D.h"
int main() {
djalim::OpenGlEngine engine = djalim::OpenGlEngine("Mon app", 800, 600);
engine.start();
//djalim::OpenGlEngine engine = djalim::OpenGlEngine("Mon app", 800, 600);
//engine.start();
djalim::Mesh3D mesh = djalim::Mesh3D("../assets/models/UTAH_BLEND.obj");
return 0;
}

View File

@ -48,7 +48,7 @@ void djalim::OpenGlEngine::onCreate(){
};
stbi_set_flip_vertically_on_load(true);
createObject("cube", "../assets/textures/prof.png", "../assets/models/UTAH_BLEND.obj");
createObject("cube", "../assets/textures/prof.png", vertices);
// textures["cube"] = Texture2D();
// bool textureLoaded = textures["cube"].loadTexture("../assets/textures/prof.png");