dodanie modelu lazik3.obj
This commit is contained in:
7678
lazik3.obj
Normal file
7678
lazik3.obj
Normal file
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,8 @@ bool loadOBJ(const char* path, std::vector <glm::vec3>& out_vertices, std::vecto
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int line = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
char lineHeader[128];
|
char lineHeader[128];
|
||||||
@@ -57,7 +59,7 @@ bool loadOBJ(const char* path, std::vector <glm::vec3>& out_vertices, std::vecto
|
|||||||
int matches = fscanf(file, "%d/%d/%d %d/%d/%d %d/%d/%d\n", &vertexIndex[0], &uvIndex[0], &normalIndex[0], &vertexIndex[1], &uvIndex[1], &normalIndex[1], &vertexIndex[2], &uvIndex[2], &normalIndex[2]);
|
int matches = fscanf(file, "%d/%d/%d %d/%d/%d %d/%d/%d\n", &vertexIndex[0], &uvIndex[0], &normalIndex[0], &vertexIndex[1], &uvIndex[1], &normalIndex[1], &vertexIndex[2], &uvIndex[2], &normalIndex[2]);
|
||||||
|
|
||||||
if (matches != 9){
|
if (matches != 9){
|
||||||
printf("File can't be read by our simple parser : ( Try exporting with other options\n");
|
printf("File can't be read by our simple parser. Try exporting with other options (%d matches on line %d)\n", matches, line);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +89,8 @@ bool loadOBJ(const char* path, std::vector <glm::vec3>& out_vertices, std::vecto
|
|||||||
out_normals .push_back(vertex3);
|
out_normals .push_back(vertex3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
line++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
13
main.cpp
13
main.cpp
@@ -263,7 +263,7 @@ void RenderScene(void) {
|
|||||||
/* */
|
/* */
|
||||||
// Read our .obj file
|
// Read our .obj file
|
||||||
|
|
||||||
bool res = loadOBJ("suzanne.obj", vertices, uvs, normals);
|
bool res = loadOBJ("lazik3.obj", vertices, uvs, normals);
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
glGenBuffers(1, &vertexbuffer);
|
glGenBuffers(1, &vertexbuffer);
|
||||||
@@ -329,10 +329,10 @@ void RenderScene(void) {
|
|||||||
//glUseProgram(programID);
|
//glUseProgram(programID);
|
||||||
|
|
||||||
// Bind our texture in Texture Unit 0
|
// Bind our texture in Texture Unit 0
|
||||||
//glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
//glBindTexture(GL_TEXTURE_2D, Texture);
|
glBindTexture(GL_TEXTURE_2D, Texture);
|
||||||
// Set our "myTextureSampler" sampler to use Texture Unit 0
|
// Set our "myTextureSampler" sampler to use Texture Unit 0
|
||||||
//glUniform1i(TextureID, 0);
|
glUniform1i(TextureID, 0);
|
||||||
|
|
||||||
// 1rst attribute buffer : vertices
|
// 1rst attribute buffer : vertices
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
@@ -346,7 +346,7 @@ void RenderScene(void) {
|
|||||||
(void*)0 // array buffer offset
|
(void*)0 // array buffer offset
|
||||||
);
|
);
|
||||||
|
|
||||||
// 2nd attribute buffer : UVs
|
// 2nd attribute buffer: UVs
|
||||||
glEnableVertexAttribArray(1);
|
glEnableVertexAttribArray(1);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
|
||||||
glVertexAttribPointer(
|
glVertexAttribPointer(
|
||||||
@@ -358,7 +358,7 @@ void RenderScene(void) {
|
|||||||
(void*)0 // array buffer offset
|
(void*)0 // array buffer offset
|
||||||
);
|
);
|
||||||
|
|
||||||
// Draw the triangle !
|
// Draw the triangle!
|
||||||
glDrawArrays(GL_TRIANGLES, 0, vertices.size() );
|
glDrawArrays(GL_TRIANGLES, 0, vertices.size() );
|
||||||
|
|
||||||
glDisableVertexAttribArray(0);
|
glDisableVertexAttribArray(0);
|
||||||
@@ -706,6 +706,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
case ' ': // 32
|
case ' ': // 32
|
||||||
polygonmode = !polygonmode;
|
polygonmode = !polygonmode;
|
||||||
|
if (polygonmode) std::cout << "debug: tryb wireframe jest niewydajny i powinien sluzyc tylko do debugowania!\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
BIN
output.exe
BIN
output.exe
Binary file not shown.
Reference in New Issue
Block a user