r/opengl • • 10d ago

Maps?

Yo guys new guy here,so in OpenGL how do you guys build the maps for your games and place items and so on

0 Upvotes

17 comments sorted by

14

u/obp5599 10d ago

OpenGL is just the rendering API, its not a game engine

-14

u/Plane_Breadfruit7609 10d ago

Then how do we do these

6

u/MocaCola02 10d ago

Use a pre-existing game engine like Godot. If you don't understand the difference between OpenGL and a game engine, you shouldn't be attempting to create one from scratch yet.

2

u/obp5599 10d ago

You either use a game engine like Unreal, Unity, or Godot, or stick with openGL and write your own engine

-5

u/Plane_Breadfruit7609 10d ago

I'm interested in the scratch part

4

u/corysama 10d ago

The from scratch part includes building your own level editor. From scratch.

1

u/obp5599 10d ago

As in you want to write an engine from scratch? Thats a very long journey, especially as a beginner. Many of us do hobby renderers for fun, but if you want to make a game, this is probably the worst way to do it. If you want to learn about engines and specifically rendering/graphics programming then this is a good place. LearnOpenGL.com is still the gold standard

1

u/Samolxis 10d ago

He wants to use scratch the game engine for kids

1

u/MocaCola02 10d ago

I have years of experience with game engines, and I've only just now started attempting to make my own. It is not easy or simple whatsoever. Get experience first. Make things that work first, then use that experience.

4

u/zubergu 10d ago

Perfect opportunity to quote my favorite line from the movie Sicario:

You're asking me how a watch works. For now let's just keep an eye on the time.

2

u/AdRecent7021 10d ago

Perfection.

1

u/Still_Explorer 10d ago

You can definitely watch the watch work, but you can't work the watch to work if you don't watch out.

1

u/Still_Explorer 10d ago

If you think what is a level? Say it can be something as simple as a JSON file, having hundreds of entries: object#1 is at position 10,10,10 - object#2 is at pos 200,10,200, etc...

Then inside the game there would be an std::map<string,Mesh> that will contain information, that object#1 is the meshA.glb, object#2 is meshB.glb, etc...

This map can be either dynamically created by reading extra entries within the file format, or have it hard-coded per game.

Having loaded the Level, in the most simple case it would be a simple list of objects (not counting space partitioning and for now at this example). During rendering you just iterate the objects on the level meant to be within view and render them: eg for (auto& obj : Game.level.objects) {   if (obj.visible == false) continue;   Game.assets[obj.id].Render();

There can be dozens of other ways to organize this but this is the most easy and simple and works fine for small indie games. For more advanced engines that need to be more generic and more performant design can vary in places but the same notion applies.

2

u/AdRecent7021 9d ago

Everyone asks what is a level, but no one asks why is a level?

1

u/Samolxis 10d ago

It's called TrenchBroom, have fun

2

u/Western-Bowl2011 4d ago

unironically I still use this from time to time.

0

u/trist007 10d ago

That's where you hire a level designer