IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

GLUT Discussion :

Assimp, l'objet importé ne s'affiche pas. [OpenGL 4.x]


Sujet :

GLUT

  1. #1
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Septembre 2012
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2012
    Messages : 22
    Points : 18
    Points
    18
    Par défaut Assimp, l'objet importé ne s'affiche pas.
    Bonjour,
    Voila je n'arrive pas à afficher l'objet importé :/ voici mon code. Est ce que quelqu'un peut m'aider?
    Juste me dire si le code dans le fichier model.cpp est bon ou pas?

    Model.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
     
    #ifdef _WIN32
    	#include <Seed\Graphics\model.hpp>
    #else
    	#include <Seed/Graphics/model.hpp>
    #endif
     
    Model::~Model()
    {
    	//free VBO and VAO
    	glDeleteBuffers(1, &VBO_vertices);
    	glDeleteBuffers(1, &VBO_normals);
    	glDeleteBuffers(1, &VBO_tangents);
    	glDeleteBuffers(1, &VBO_coordText);
    	glDeleteBuffers(1, &VBO_faces);
    	glDeleteVertexArrays(1, &VAO);
    	glDisableVertexAttribArray(0);
    	glDisableVertexAttribArray(1);
    	glDisableVertexAttribArray(2);
    	glDisableVertexAttribArray(3);
    }
    Model::Model(const aiMesh *mesh)
    {
    	unsigned int i = 0;
    	this->m_numVertices = mesh->mNumVertices;
    	int size = 0;
    	//size of datas
    	if (mesh->HasPositions())
    	{
    		size = mesh->mNumVertices * sizeof(glm::vec3);
    	}
    	if (mesh->HasTangentsAndBitangents())
    	{
    		size += (mesh->mNumVertices * sizeof(glm::vec3));
    	}
    	if (mesh->HasTextureCoords(0))
    	{
    		size += (mesh->mNumVertices * sizeof(glm::vec2));
    	}
    	if (mesh->HasNormals())
    	{
    		size += (mesh->mNumVertices * sizeof(glm::vec3));
    	}
     
    	//copy datas
    	try
    	{
    		for (i = 0; i < this->m_numVertices; i++)
    		{
    			if (mesh->HasPositions())
    			{
    				//copy vertices
    				this->m_vertices.push_back(glm::vec3(mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z));
    			}
    			if (mesh->HasTangentsAndBitangents())
    			{
    				//copy tangents
    				this->m_tangents.push_back(glm::vec3(mesh->mTangents[i].x, mesh->mTangents[i].y, mesh->mTangents[i].z));
    			}
    			if (mesh->HasTextureCoords(0))
    			{
    				//copy texture coordinates
    				this->m_textCoords.push_back(glm::vec2(mesh->mTextureCoords[0][i].x, mesh->mTextureCoords[0][i].y));
    			}
    			if (mesh->HasNormals())
    			{
    				//copy normals
    				this->m_normals.push_back(glm::vec3(mesh->mNormals[i].x, mesh->mNormals[i].y, mesh->mNormals[i].z));
    			}
    		}
    		if (mesh->HasFaces())
    		{
    			for (i = 0; i < mesh->mNumFaces; i++)
    			{
    				//copy faces
    				this->m_faces.push_back(glm::ivec3(mesh->mFaces[i].mIndices[0], mesh->mFaces[i].mIndices[1], mesh->mFaces[i].mIndices[2]));
    			}
    		}
    	}
    	catch (std::out_of_range &)
    	{
    		printf("ERROR: Out of range of array in file model.cpp\n");
    		return;
    	}
    	catch (std::exception &)
    	{
    		printf("ERROR: error in model.cpp file\n");
    		return;
    	}
     
    	this->m_indexMaterial = mesh->mMaterialIndex;
     
    	if (mesh->HasFaces())
    	{
    		glGenBuffers(1, &VBO_faces);
    		//bind buffer for faces
    		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VBO_faces);
    		//allocate memoty for the faces
    		glBufferData(GL_ELEMENT_ARRAY_BUFFER, this->m_faces.size() * sizeof(glm::vec3), 0, GL_STATIC_DRAW);
    		//put the faces in the buffer
    		glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, this->m_faces.size() * sizeof(glm::vec3), &m_faces[0]);
    	}
     
    	//taille vertices in bytes
    	int verticesBytes = this->m_vertices.size() * sizeof(glm::vec3);
     
     
    	if (mesh->HasPositions())
    	{
    		//Put the datas' mesh in a VBOBuffer
    		glGenBuffers(1, &VBO_vertices);
    		//bind buffer VBO for datas
    		glBindBuffer(GL_ARRAY_BUFFER, VBO_vertices);
    		glBufferData(GL_ARRAY_BUFFER, verticesBytes, 0, GL_STATIC_DRAW);
    		//copy data in GPU memory
    		glBufferSubData(GL_ARRAY_BUFFER, 0, verticesBytes, &m_vertices[0]);
    	}
     
    	if (mesh->HasNormals())
    	{
    		//Put the datas' mesh in a VBOBuffer
    		glGenBuffers(1, &VBO_normals);
    		//bind buffer VBO for datas
    		glBindBuffer(GL_ARRAY_BUFFER, VBO_normals);
    		glBufferData(GL_ARRAY_BUFFER, verticesBytes, 0, GL_STATIC_DRAW);
    		//copy data in GPU memory
    		glBufferSubData(GL_ARRAY_BUFFER, 0, verticesBytes, &m_normals[0]);
    	}
    	if (mesh->HasTangentsAndBitangents())
    	{
    		//Put the datas' mesh in a VBOBuffer
    		glGenBuffers(1, &VBO_tangents);
    		//bind buffer VBO for datas
    		glBindBuffer(GL_ARRAY_BUFFER, VBO_tangents);
    		glBufferData(GL_ARRAY_BUFFER, verticesBytes, 0, GL_STATIC_DRAW);
    		//copy data in GPU memory
    		glBufferSubData(GL_ARRAY_BUFFER, 0, verticesBytes, &m_tangents[0]);
    	}
    	if (mesh->HasTextureCoords(0))
    	{
    		//Put the datas' mesh in a VBOBuffer
    		glGenBuffers(1, &VBO_coordText);
    		//bind buffer VBO for datas
    		glBindBuffer(GL_ARRAY_BUFFER, VBO_coordText);
    		glBufferData(GL_ARRAY_BUFFER, m_textCoords.size() * sizeof(glm::vec2), 0, GL_STATIC_DRAW);
    		//copy data in GPU memory
    		glBufferSubData(GL_ARRAY_BUFFER, 0, this->m_textCoords.size() * sizeof(glm::vec2), &m_textCoords[0]);
    	}
     
    	//generate a VAO buffer
    	glGenVertexArrays(1, &VAO);
    	//bind VAO
    	glBindVertexArray(VAO);
     
    	//specify to opengl where is the data
    	//the position
    	if (this->m_vertices.size())
    	{
    		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(glm::vec3), 0);
    		glEnableVertexAttribArray(0);
    	}
    	if (this->m_normals.size())
    	{
    		glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(glm::vec3), 0);
    		glEnableVertexAttribArray(1);
    	}
    	if (this->m_tangents.size())
    	{
    		glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(glm::vec3), 0);
    		glEnableVertexAttribArray(2);
    	}
    	if (this->m_textCoords.size())
    	{
    		glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(glm::vec2), 0);
    		glEnableVertexAttribArray(3);
    	}
    	//free VBO
    	glBindBuffer(GL_ARRAY_BUFFER, 0);
    	//free VAO
    	glBindVertexArray(0);
    }
     
    void Model::render()
    {
    	//bind VAO
    	glBindVertexArray(VAO);
    	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VBO_faces);
    	glDrawRangeElements(GL_TRIANGLES, 0, this->m_faces.size() * 3, this->m_faces.size() * 3, GL_UNSIGNED_INT, 0);
    	//glDrawElements(GL_TRIANGLES, this->m_faces.size(), GL_UNSIGNED_INT, 0);
    	//glDrawArrays(GL_TRIANGLES, 0, this->m_faces.size());
    	//free VAO
    	glBindVertexArray(0);
    	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    }
     
    void Model::afficher()
    {
    	std::cout << "Model : \n nb de vertices : " << this->m_vertices.size() << "\n nb de normales : " << this->m_normals.size() << "\n nb de tangents " << this->m_tangents.size() << "\n nb de text coord " << this->m_textCoords.size() << std::endl;
    }
    main.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
     
    #include <stdio.h>
    #include <stdlib.h>
    //*
    // Include GLEW. Always include it before gl.h and glfw.h
    #ifdef _WIN32
    	#include <GL\glew.h>
    #else
    	#include <GL/glew.h>
    #endif
     
    // Include GLFW
    #ifdef _WIN32
    	#include <GLFW\glfw3.h>
    #else
    	#include <GLFW/glfw3.h>
    #endif
     
    // Include GLM
    #ifdef _WIN32
    	#include <glm\glm.hpp>
    	#include <glm\gtx\transform.hpp>
    #else
    	#include <glm/glm.hpp>
    	#include <glm/gtx/transform.hpp>
    #endif
     
    #ifdef _WIN32
    	#include <Seed\Graphics\camera.hpp>
    	#include <Seed\Graphics\texture.hpp>
    	#include <Seed\Graphics\model.hpp>
    	#include <Seed\Graphics\shader.hpp>
    	#include <Seed\Graphics\control.hpp>
    	#include <Seed\Graphics\Constant.hpp>
    	#include <Seed\Graphics\Outils.hpp>
    	#include <Seed\Graphics\scene.hpp>
     
    #else
    	#include <Seed/Graphics/camera.hpp>
    	#include <Seed/Graphics/texture.hpp>
    	#include <Seed/Graphics/model.hpp>
    	#include <Seed/Graphics/shader.hpp>
    	#include <Seed/Graphics/control.hpp>
    	#include <Seed/Graphics/Constant.hpp>
    	#include <Seed/Graphics/Outils.hpp>
    	#include <Seed/Graphics/scene.hpp>
    #endif
    #include <time.h>
     
    // Open a window and create its OpenGL context 
    GLFWwindow* window; // (In the accompanying source code, this variable is global) 
     
    int Initialisation();
     
    int main()
    {
     
    	//position of the camera
    	glm::vec3 position = glm::vec3(0.0, 0.0, 5.0);
    	//horizontal and vertical angle
    	float WAngle = 3.14f;
    	float HAngle = 0.0f;
    	//field of view
    	const float initFoV = 45.0f;
    	float near = (float)0.1;
    	float far = (float)100.0;
    	//speed move direction (keyboard)
    	float speed = 3.0f;
    	//speed view direction (mouse)
    	float mouseSpeed = 0.05f;
    	//initialisation systeme
    	if (Initialisation() != 0)
    		return -1;
     
    	//captur keys
    	glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
     
    	//create scene
    	Scene scene;
    	//import model
    	scene.importModelFromFile(pathToModels + "UVsphere.obj");
     
    	//create camera
    	Camera camera(position, glm::vec3(0.0,0.0,0.0), glm::vec3(0.0,1.0,0.0), initFoV, WIDTH, HEIGHT, near, far);
    	// Create and compile our GLSL program from the shaders
    	GLuint programID = loadShaders(pathToShaders + "shader1\\VertexShader.hlsl",pathToShaders + "shader1\\FragmentShader.hlsl");//(pathToShaders + "\FragmentShader.hlsl").c_str());
    	//enable texturing
    	glEnable(GL_TEXTURE_2D);
     
    	// Dark blue background
    	glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
     
    	/*GLuint VertexArrayID;
    	glGenVertexArrays(1, &VertexArrayID);
    	glBindVertexArray(VertexArrayID);
     
    	// Our vertices. Tree consecutive floats give a 3D vertex; Three consecutive vertices give a triangle.
    	// A cube has 6 faces with 2 triangles each, so this makes 6*2=12 triangles, and 12*3 vertices
    	static const GLfloat vertex_buffer_data[] = {
    		-1.0f, -1.0f, -1.0f, // triangle 1 : begin
    		-1.0f, -1.0f, 1.0f,
    		-1.0f, 1.0f, 1.0f, // triangle 1 : end
    		1.0f, 1.0f, -1.0f, // triangle 2 : begin
    		-1.0f, -1.0f, -1.0f,
    		-1.0f, 1.0f, -1.0f, // triangle 2 : end
    		1.0f, -1.0f, 1.0f,
    		-1.0f, -1.0f, -1.0f,
    		1.0f, -1.0f, -1.0f,
    		1.0f, 1.0f, -1.0f,
    		1.0f, -1.0f, -1.0f,
    		-1.0f, -1.0f, -1.0f,
    		-1.0f, -1.0f, -1.0f,
    		-1.0f, 1.0f, 1.0f,
    		-1.0f, 1.0f, -1.0f,
    		1.0f, -1.0f, 1.0f,
    		-1.0f, -1.0f, 1.0f,
    		-1.0f, -1.0f, -1.0f,
    		-1.0f, 1.0f, 1.0f,
    		-1.0f, -1.0f, 1.0f,
    		1.0f, -1.0f, 1.0f,
    		1.0f, 1.0f, 1.0f,
    		1.0f, -1.0f, -1.0f,
    		1.0f, 1.0f, -1.0f,
    		1.0f, -1.0f, -1.0f,
    		1.0f, 1.0f, 1.0f,
    		1.0f, -1.0f, 1.0f,
    		1.0f, 1.0f, 1.0f,
    		1.0f, 1.0f, -1.0f,
    		-1.0f, 1.0f, -1.0f,
    		1.0f, 1.0f, 1.0f,
    		-1.0f, 1.0f, -1.0f,
    		-1.0f, 1.0f, 1.0f,
    		1.0f, 1.0f, 1.0f,
    		-1.0f, 1.0f, 1.0f,
    		1.0f, -1.0f, 1.0f
    	};
     
    	// Two UV coordinatesfor each vertex. They were created with Blender. You'll learn shortly how to do this yourself.
    	static const GLfloat uv_buffer_data[] = {
    		0.000059f, 1.0f - 0.000004f,
    		0.000103f, 1.0f - 0.336048f,
    		0.335973f, 1.0f - 0.335903f,
    		1.000023f, 1.0f - 0.000013f,
    		0.667979f, 1.0f - 0.335851f,
    		0.999958f, 1.0f - 0.336064f,
    		0.667979f, 1.0f - 0.335851f,
    		0.336024f, 1.0f - 0.671877f,
    		0.667969f, 1.0f - 0.671889f,
    		1.000023f, 1.0f - 0.000013f,
    		0.668104f, 1.0f - 0.000013f,
    		0.667979f, 1.0f - 0.335851f,
    		0.000059f, 1.0f - 0.000004f,
    		0.335973f, 1.0f - 0.335903f,
    		0.336098f, 1.0f - 0.000071f,
    		0.667979f, 1.0f - 0.335851f,
    		0.335973f, 1.0f - 0.335903f,
    		0.336024f, 1.0f - 0.671877f,
    		1.000004f, 1.0f - 0.671847f,
    		0.999958f, 1.0f - 0.336064f,
    		0.667979f, 1.0f - 0.335851f,
    		0.668104f, 1.0f - 0.000013f,
    		0.335973f, 1.0f - 0.335903f,
    		0.667979f, 1.0f - 0.335851f,
    		0.335973f, 1.0f - 0.335903f,
    		0.668104f, 1.0f - 0.000013f,
    		0.336098f, 1.0f - 0.000071f,
    		0.000103f, 1.0f - 0.336048f,
    		0.000004f, 1.0f - 0.671870f,
    		0.336024f, 1.0f - 0.671877f,
    		0.000103f, 1.0f - 0.336048f,
    		0.336024f, 1.0f - 0.671877f,
    		0.335973f, 1.0f - 0.335903f,
    		0.667969f, 1.0f - 0.671889f,
    		1.000004f, 1.0f - 0.671847f,
    		0.667979f, 1.0f - 0.335851f
    		};
     
    	srand(time(NULL));
    	static GLfloat color_buffer_data[12 * 3 * 3];
    	for (int i = 0; i < 12*3; i++)
    	{
    		color_buffer_data[i * 3] = (float)(rand() % 100) / 100.0;
    		color_buffer_data[i * 3 + 1] = (float)(rand() % 100) / 100.0;
    		color_buffer_data[i * 3 + 2] = (float)(rand() % 100) / 100.0;
    	}
     
    	//id vertex VertexArrayID
    	GLuint VertexBuffer;
    	//on génère une adresse pointant vers un emplacement dans la mémoire du GPU
    	//on génère 1 emplacement
    	glGenBuffers(1, &VertexBuffer);
    	//on bind l'emplacement
    	glBindBuffer(GL_ARRAY_BUFFER, VertexBuffer);
    	//on donne les vertex à openGL
    	glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_buffer_data), vertex_buffer_data, GL_STATIC_DRAW);
     
    	//id du color vertexArrayID
    	GLuint ColorBuffer;
    	glGenBuffers(1, &ColorBuffer);
    	glBindBuffer(GL_ARRAY_BUFFER, ColorBuffer);
    	glBufferData(GL_ARRAY_BUFFER, sizeof(color_buffer_data), color_buffer_data, GL_STATIC_DRAW);
     
    	//id UV vertexArrayID
    	GLuint UVBuffer;
    	glGenBuffers(1, &UVBuffer);
    	glBindBuffer(GL_ARRAY_BUFFER, UVBuffer);
    	glBufferData(GL_ARRAY_BUFFER, sizeof(uv_buffer_data), uv_buffer_data, GL_STATIC_DRAW);
    	*/
     
    	glm::mat4 M = glm::mat4(1.0);
    	//M = glm::translate(glm::mat4(1.0), glm::vec3(1.0, 0.0, 0.0));
    	glm::mat4 MVP = camera.getProjectionMatrix() * camera.getViewMatrix() * M;
     
    	// Get a handle for our "MVP" uniform.
    	// Only at initialisation time.
    	GLuint MatrixID = glGetUniformLocation(programID, "MVP");
    	GLuint TextureID = glGetUniformLocation(programID, "samplerTexture");
     
    	//chargement texture
    	Texture t(pathToTextures + "texture2.bmp");
     
    	//Model model("Models/axe.obj");
     
    	double currentTime = 0, lastTime = 0;
    	float deltaTime = 0;
    	float FoV = initFoV;
    	glm::vec3 direction;
    	glm::vec3 up;
     
    	//main loop to render
    	do
    	{
    		//get current time
    		currentTime = glfwGetTime();
    		//update mouse control and keyboard control
    		updateControl(window, WAngle, HAngle, mouseSpeed, deltaTime, speed, position ,  direction, up, initFoV, FoV);
    		//update ViewMatrix
    		camera.setViewMatrix(position, direction, up);
    		//update Projection Matrix
    		camera.setProjectionMatrix(FoV, WIDTH, HEIGHT, near, far);
    		//update MVP matrix
    		MVP = camera.getProjectionMatrix() * camera.getViewMatrix() * M;
     
    		// Clear the screen
    		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
    		if(programID)
    		{
    			// Use our shader
    			glUseProgram(programID);
    		}
     
    		// Send our transformation to the currently bound shader,
    		// in the "MVP" uniform
    		// For each model you render, since the MVP will be different (at least the M part)
    		glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
     
    		/*
    		//vertexs
    		//on se place sur les vertices
    		glEnableVertexAttribArray(0);
    		glBindBuffer(GL_ARRAY_BUFFER, VertexBuffer);
    		glVertexAttribPointer(
    			0,//canal 0
    			3,//la taille du vertex
    			GL_FLOAT,//le type de données
    			GL_FALSE,//est-ce que les données sont normalisée
    			0,//stride
    			(void*)0//offset du buffer
    			);
     
     
    		//couleurs
    		//on se place sur les couleurs
    		glEnableVertexAttribArray(1);
    		//on bind le buffer
    		glBindBuffer(GL_ARRAY_BUFFER, ColorBuffer);
     
    		//on attribue le buffer sur le canal 1
    		glVertexAttribPointer(
    			1,//canal 1
    			3,//la taille de la couleur
    			GL_FLOAT,//le type de données
    			GL_FALSE,//est-ce que les données sont normalisée
    			0,//stride
    			(void*)0//offset du buffer
    		);
     
    		//UV
    		//on se place sur le canal pour les UV
    		glEnableVertexAttribArray(2);
    		glBindBuffer(GL_ARRAY_BUFFER, UVBuffer);
    		glVertexAttribPointer(
    			2,//canal 0
    			2,//la taille du vertex
    			GL_FLOAT,//le type de données
    			GL_FALSE,//est-ce que les données sont normalisée
    			0,//stride
    			(void*)0//offset du buffer
    			);
    		*/
    		//Enable culling triangles which normal is not towards the camera
    		glEnable(GL_CULL_FACE);
    		// Enable depth test
    		glEnable(GL_DEPTH_TEST);
    		// Accept fragment if it closer to the camera than the former one
    		glDepthFunc(GL_LESS);
     
    		scene.getRootNode()->render();
     
    		//t.bind();
    		//glUniform1i(TextureID, 0);
    		//draw Arrays!
    		//glDrawArrays(GL_TRIANGLES, 0, 12*3);//on part du vertex0 et il y en a trois
    		//t.release();
    		/*glBindBuffer(GL_ARRAY_BUFFER, 0);
    		glDisableVertexAttribArray(0);
    		glDisableVertexAttribArray(1);
    		glDisableVertexAttribArray(2);*/
     
    		//on nettoie les buffers
    		glfwSwapBuffers(window);
    		glfwPollEvents();
     
    		//get current time
    		lastTime = glfwGetTime();
    		//time between 2 frames
    		deltaTime = float(lastTime - currentTime);
     
     
    	} while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && glfwWindowShouldClose(window) == 0);
     
    	// Cleanup VBO
    	/*glDeleteBuffers(1, &VertexBuffer);
    	glDeleteBuffers(1, &ColorBuffer);
    	glDeleteVertexArrays(1, &VertexArrayID);*/
    	glDeleteProgram(programID);
     
    	// Close OpenGL window and terminate GLFW
    	glfwTerminate();
    	return 0;
    }
     
    int Initialisation()
    {
    	// Initialise GLFW
    	if (!glfwInit())
    	{
    		fprintf(stderr, "Failed to initialize GLFW\n");
    		return -1;
    	}
    	glfwWindowHint(GLFW_SAMPLES, 4); // 4x antialiasing
    	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); // We want OpenGL 4.3
    	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    	glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
    	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL 
     
    	window = glfwCreateWindow(WIDTH, HEIGHT, "Moteur3d", NULL, NULL);
    	if (window == NULL){
    		fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n");
    		glfwTerminate();
    		return -1;
    	}
    	glfwMakeContextCurrent(window); // Initialize GLEW 
    	glewExperimental = true; // Needed in core profile 
    	if (glewInit() != GLEW_OK) {
    		fprintf(stderr, "Failed to initialize GLEW\n");
    		return -1;
    	}
    	return 0;
    }
    Je vous remercie d'avance

  2. #2
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    26 859
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 26 859
    Points : 218 580
    Points
    218 580
    Billets dans le blog
    120
    Par défaut
    Bonjour,

    Pour corriger votre souci, je serai de l'avis d'utiliser un traceur d'appel OpenGL (glTrace ou un truc similaire). Ou si vous voulez tout faire dans votre code, de rajouter des appels à glGetError() ou d'utiliser l'extension de débogage (KHR_debug).

    De plus :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    #ifdef _WIN32
    	#include <Seed\Graphics\model.hpp>
    #else
    	#include <Seed/Graphics/model.hpp>
    #endif
    Microsoft accepte normalement pleinement les '/' dans les chemins. Donc pas besoin d'avoir cette condition.
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  3. #3
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Septembre 2012
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2012
    Messages : 22
    Points : 18
    Points
    18
    Par défaut
    Merci pour votre réponse. Je vais essayer ce que vous dites. Je ne le savais pas pour windows pour les chemins relatifs. Je reposterai pour dire ce qui ne va pas.

  4. #4
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Septembre 2012
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2012
    Messages : 22
    Points : 18
    Points
    18
    Par défaut
    RE:
    Voici les buffers de points normals et faces. Ce sont les données représentant un cube.
    Nom : points.JPG
Affichages : 169
Taille : 17,1 KoNom : normals.JPG
Affichages : 126
Taille : 17,0 KoNom : faces.JPG
Affichages : 155
Taille : 23,7 Ko

    Est-ce normal pour les indices des faces??

  5. #5
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    26 859
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 26 859
    Points : 218 580
    Points
    218 580
    Billets dans le blog
    120
    Par défaut
    Je pense oui. Mais, il n'y a pas d'erreur OpenGL ?
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  6. #6
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Septembre 2012
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Septembre 2012
    Messages : 22
    Points : 18
    Points
    18
    Par défaut
    J'ai honte de le dire, mais le code est tout à fait correct finalement. C'était une erreur de mise à jour de la matrice MVP. Je vous remercie quand même pour votre aide, c'a m'a permis de connaitre le debugger gDebugger qui est très sympa pour voir ce qui se passe un peu dans le GPU.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Un objet qui ne s'affiche pas
    Par tonytrua dans le forum Débuter avec Java
    Réponses: 8
    Dernier message: 15/12/2011, 14h18
  2. [AC-2007] Objet OLE ne s'affiche PAS
    Par Jeenan dans le forum IHM
    Réponses: 2
    Dernier message: 24/04/2011, 00h15
  3. [CKEditor] les objets flash ne s'affichent pas sous IE7
    Par une_tite_question dans le forum Bibliothèques & Frameworks
    Réponses: 5
    Dernier message: 09/04/2009, 09h49
  4. un objet JPanel qui ne s'affiche pas
    Par dark_geek dans le forum Agents de placement/Fenêtres
    Réponses: 6
    Dernier message: 05/03/2009, 21h41
  5. Mes Objets JLabel ne s'affiche pas correctement
    Par michel18 dans le forum AWT/Swing
    Réponses: 1
    Dernier message: 03/11/2006, 20h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo