NIthiyaa M
NIthiyaa M

Reputation: 17

How to convert .obj file to openGL?

I am finding difficulty in converting .obj file into openGL. I have found my model and here i have attach the main.cpp file for your reference. I am unsure of how to run the files. Which file should I run when I called all these files in openGL. Initially when I open OpenGL in Visual studio I called main.cpp file and run the file. But it shows many errors. The error says that cant find PDB file. What is that?

Upvotes: -1

Views: 14096

Answers (4)

datenwolf
datenwolf

Reputation: 162164

I'm just throwing in my answer to clear up the misconception leading to a question like that one:

How to convert .obj file (human head) to openGL?

The answer is: You don't.

OpenGL is a drawing API called from a program. It there for a program to make calls to draw points, lines and triangles. OpenGL is not a file format.

.OBJ is actually not very well defined name for a file format (there are literally hundreds of file formats that end .OBJ). But I take it you mean Wavefront OBJ. Anyway, files contain data. And while a program is data as well, a Wavefront OBJ file is not a program and can not be executed. Hence it makes no sense to even try to formulate a OBJ to OpenGL conversion.

What you need to do is writing a program, that reads the data from the Wavefront OBJ file, and uses that data to make the right calls to OpenGL. The other answers you already got link to such tutorials.

Upvotes: 11

RamblingMad
RamblingMad

Reputation: 5518

You will need to parse the .obj file then (depending on OpenGL version) load the parsed data into array/element_array buffers then use glDraw[Elements/Arrays] to work with in glsl or draw all the vertices using fixed functions.

But I think the real answer here lies in more study and not jumping in the deep water when you can hardly doggy paddle. You should do more basic exercises and get an understanding of the API.

Oh, and a .pdb file is for debugging in visual studio; I think it stands for program database.

Upvotes: 3

jparimaa
jparimaa

Reputation: 2044

Yet another OBJ-loading tutorial http://www.opengl-tutorial.org/beginners-tutorials/tutorial-7-model-loading/

Upvotes: 2

Volodymyr B.
Volodymyr B.

Reputation: 3441

Here is good tiny parser for obj https://github.com/syoyo/tinyobjloader

You need:
1. parse data
2. create buffer object with data
3. draw buffer object

Upvotes: 2

Related Questions