Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


How to create and load a map

This topic is 6190 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

You can''t open a file in OpenGL. However, using C''s f* functions (fopen, fclose, fread, fwrite, etc), you can create maps, and load them into your OpenGL programs. Your map may be as simple as a list of vertices, or a whole, well-thoughtout system, complete with vertex and normal arrays...

iNsAn1tY - the place where imagination and the real world merge...
Try http://uk.geocities.com/mentalmantle

Share this post

Link to post
Share on other sites
not opengl related but it depends on what u want personally i prefer ascii text files. eg for pacman ild do something light

X..XXX.....X...X etc


Share this post

Link to post
Share on other sites
OpenGL draws stuff. Period. What you tell it to draw each frame is up to your program.

You can use either the C file manipulation functions like iNsAn1tY said or the C++ fstream ones to read from files. Either way, all you''re doing is interpreting a file to be whatever you want, and then storing it in memory however you want, and then sending it off to OpenGL in the form of vertex arrays, glVertex3f() calls, or whatever other way you want.

A simple file format might be an ASCII text file, where it''s just a whole bunch of numbers. Each group of three could be a vertex, and each group of three verteces (or 9 numbers) could be a triangle.

I strongly recommend that you experiment with file IO functions using the console before trying to load models into OpenGL.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!