Jump to content
  • Advertisement
Sign in to follow this  
DarkBalls

Creating a window in windows using only int main()

This topic is 3395 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

I'm creating a game engine right now with my team but I want to dump SDL now. Our engine is quite good because we can now create some simple games on it. So I created a window using the usual int WINAPI WinMain(). But because I want our engine to be like those other outside that is OS independent, I've created a class that will check what OS the developer is using then use the necessary function to load/create a window. Now my problem is, I don't know how to create a window in windows, for now because I'm going to study linux also maybe after this, using only the int main() function. Thanks DarkBalls

Share this post


Link to post
Share on other sites
Advertisement
You can't.
You must have an OS-specific file, or a #define that says the OS, and let the entry-point be the correct main function. Then from that call your own function, GameMain or something, in which the OS-independent stuff takes place.


#ifdef WINDOWS
int WINAPI WinMain(..) {
GameMain();
}
#elif LINUX
int ...() {
GameMain();
}
#endif

void GameMain() {
}

Share this post


Link to post
Share on other sites
CreateWindow

http://msdn.microsoft.com/en-us/library/ms632679(VS.85).aspx

Maybe that's what you are looking for? MSDN can be very helpful at times...

Share this post


Link to post
Share on other sites
@Erik Rufelt
How can SDL do those thing? Does it have any libraries that define everything what to do. I don't want to use sdl on our engine really. I want to have our own. If only we know the steps how to do it, we will do it really.

@scottrick49
Still I need to set the subsytem to windows. But thanks for the help.

@Antheus
Thanks for the help but I don't want to use any libraries out there.

Share this post


Link to post
Share on other sites
Quote:

Thanks for the help but I don't want to use any libraries out there.

That is the kind of mentality that makes mediocre engines.

All the big companies use libraries. Who wants to pay programmers to write physics code when you could license Havok and concentrate on the stuff that makes your game unique.

Write games, not engines.

Quote:

How can SDL do those thing? Does it have any libraries that define everything what to do. I don't want to use sdl on our engine really. I want to have our own. If only we know the steps how to do it, we will do it really.

SDL has a huge number of code paths for many different platforms. SDL_SetVideoMode() is a work of art, hiding an immense complexity from you.

Take a look at the SDL source to see how they did it.

I believe it has been used in some quite serious software, IIRC Unreal 2004 and Doom3 both use SDL for the Linux ports. What do you think you will gain by dumping SDL? You spend god knows how long writing code that essentially sets up a window for you, and meanwhile your game is no closer to being finished than when you were using SDL.

Share this post


Link to post
Share on other sites
Quote:
Original post by Erik Rufelt
You can't.
You must have an OS-specific file, or a #define that says the OS, and let the entry-point be the correct main function. Then from that call your own function, GameMain or something, in which the OS-independent stuff takes place.

*** Source Snippet Removed ***

Rubbish you can use main as the entry point in windows and still create a window, WinMain does not create a window it is just an OS specific entry point which by default does not have a console window.

Quote:
I want to dump SDL now

Why do you want to discontinue using that library?
Does it not fulfil your requirements? if so what are they, maybe another library for instance SFML as Antheus pointed out maybe better.

Quote:

Now my problem is, I don't know how to create a window in windows, for now because I'm going to study linux

So you neither know how to create a win32 or X11 window, well it does not take much knowledge to create them but this is not everything which SDL does for you.

Share this post


Link to post
Share on other sites
Quote:
Original post by DarkBalls
@Erik Rufelt
How can SDL do those thing?


I'm pretty sure SDL does as I wrote in the example, they probably have something like that in a header. At least that's how many libraries do it.

Share this post


Link to post
Share on other sites
Will you please stop saying "Write Games not engines". I'm here to ask for help on how to open a window using only int main() and not using any libraries at all and not about the engines!

So, if you are telling me to write games not engine, just keep it in yourself. That's what you want. So be it. Just shut the fuck up! But I'll never follow you. If you want to be just a game developer who code games or actually don't know how the graphics engines works. Ok, that's what you want to be. Go for it!

We are creating a 3D engine because we love it, we love graphics, we love algorithms, we love trees, we love shaders, and we love math. So only "Mediocre engines"? Why the hell are you comparing the physics engine on just windowing? Are you in drugs? You're insane really. We are focus only in 3D graphics not everything else. If we are going to create a game in the future, we might use Havok or PhysX.

And honestly, I think you didn't understand the article about "Write games not engine". I think the author should put "FOR NOW" in the end if you really understand his conclusions.

I'm really pissed off on those people who really think they are so smart. Ok, you're so smart now because you're not like me who is so stupid(for you because of what you believe) that creates a 3d engine, and you are using our engine. lmfao.

Share this post


Link to post
Share on other sites
Quote:
Original post by DarkBalls
Will you please stop saying "Write Games not engines". I'm here to ask for help on how to open a window using only int main() and not using any libraries at all and not about the engines!

Woot hardcore, why not use assembly! O wait what about the platform SDK's and ...?

Quote:
Original post by DarkBalls
Unadulterated drivel.
... and you are using our engine. lmfao.

Yes but you have to make it first.

Seriously take a step back, take in a deep breath and consider if this is what you really want to do. Please answer the question
Quote:

Why do you want to discontinue using that library?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!