Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Open GL OBJ Loader won't find file!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Coro   Members   -  Reputation: 112

Like
0Likes
Like

Posted 07 September 2012 - 01:56 PM

Hey Everyone

I recently decided that I would create a project based in Open GL to increase my knowledge of the API and create something that may be useful to me. So far I have followed some tutorials from a programmer on youtube called "TheCplusplusguy". Here's the begining tutorial for the "OpenGL (SDL,C++) tutorial 8 - Simple wavefront (.obj) model loader (part 1)" [ ].

So I followed the code along and made my adjustments where I saw fit in Visual Studio 2010. The program compiles correctly but for some reason will not load the "test.obj" file that is placed within the same folder as the compiled binary filles.

if(!in.is_open())	   //if not opened, exit with -1
		    {
				    std::cout << "File not found !" << std::endl;
				    return -1;
		    }

Is the algorithm used to tell the user in the console that the file was not opened/found.

int cube;
cube=loadObject("test.obj");    //load the test.obj file

Is the code that is used to tell Open GL what the filename is that I would like to use to render into the viewport. I have not mentioned that I have also tried creating two more separate projects in which I've used version 1 and 2 of the programmers obj loader code to see whether it not it was something I was missing. [ http://www.pastebin.com/6Q7zS7tC ] Was the place where he uploaded the code. Both projects compiled fine but I have the same problem.

I did exactly as he said with blender and even tried downloading and using the same version that he had in the tutorial. I can't seem to figure out why. May be there's something simple that I'm just forgetting.

Any help will be appreciated!
Thank you

Coro

Sponsor:

#2 Sponji   Members   -  Reputation: 1313

Like
0Likes
Like

Posted 07 September 2012 - 07:25 PM

The obj file isn't probably in the working directory which Visual Studio uses for your project. Try running the executable in the same directory as the obj file.
Derp

#3 Coro   Members   -  Reputation: 112

Like
0Likes
Like

Posted 08 September 2012 - 06:00 AM

Hey thanks for your reply. I have tried copying the obj file to the folder I compiled the application into and then tried running the program outside of Visual studio. I never create my projects in the default folder that VS selects. I've even tried pasting a copy of the obj file to my "D" drive and change the code to:

int cube;
cube=loadObject("D:	est.obj");    //load the test.obj file


#4 TheBlackDeath   Members   -  Reputation: 87

Like
0Likes
Like

Posted 08 September 2012 - 08:49 PM

Try using a forward slash instead.

cube=loadObject("D:/test.obj");	//load the test.obj file

If you are still having directory problems, try using the GetCurrentDirectory() function from the Windows SDK to verify you're in the correct directory.

Edited by Hydr0city, 08 September 2012 - 08:49 PM.


#5 Coro   Members   -  Reputation: 112

Like
0Likes
Like

Posted 10 September 2012 - 01:23 PM

Thanks for your reply, I've tried everything so far with no luck. I was thinking that it might be possibily due to the placement of my code? Since everything gets compiled in a linear fashion and the load parameter is near the end of the file. May be it's not locating the file because it isn't being loaded at the right time.
(Update: I was about to upload my code into I found out that somehow all of my .cpp files have been overwritten by the same texture loader I built a while ago, which has now angered me. I will try re-writting everything and hopefully may I might figure out my error along the way this time. If not I shall upload the code once I'm finished, Sorry about this and thank you everyone!)

Edited by Coro, 10 September 2012 - 01:56 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS