Creating a window in windows using only int main()

Started by
23 comments, last by phresnel 14 years, 11 months ago
What a reasonable response.

To be perfectly honest, if you are smart enough to write a fancy 3D graphics engine I would have imagined that you would be able to find out how to create a window without our help...

So which is it?

And remember, this question is still open:
Quote:
What do you think you will gain by dumping SDL?
Advertisement
@dmail

Quote:
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.


If I understand what you said correctly, I can create a window using only int main() and subsystem in console?

Quote:
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.


I'm just using SDL's windowing and input and using OpenGL to render 3d graphics. So I think making my own for that will not really a big job, I think.

Quote:
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.


I know how to create a win32 window but not yet in linux. But I have a linux installed on my virtual machine.

@Erik Rufelt
Quote:
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.


If I didn't find any way on how to create a window using int main() and subsystem console, I'll just leave to that for now.

@rip-off

I'm not having a problem with window really. I'm looking for a way on how to create a window using int main() and subsystem console just like SDL does.
I know its not exactly what you want to hear (Id get used to the feeling) but its true. Frustration in normal, but detrimental to the cause.

Sure, you can avoid libraries and still make your 3d engine, but you wont spend any time working on the 3d engine, you'll end up spending alot of time working with drivers and low level stuff, stuff which you wont be able to do as well as libraries provide, in addition to spending ALOT of time on it.

OpenGL and DirectX and SDL cover most of that for you. They know how to get the hardware info required, and use that to know how to send the right messages to the drivers in the correct fasion.

You use those libraries when you make an engine, you dont rewrite them and then make an engine with your driver handling code. You still need to learn an aweful lot about graphics programming to use them effectively.

You take this as shattering your dreams it seems, we're trying to tell you that taking the path you're on for too long is going to shatter them as well. If you really, really want to learn graphics stuff, learn DirectX and OpenGL. The pair will teach more then you could want on the subject.

Quote:Original post by DarkBalls
If I understand what you said correctly, I can create a window using only int main() and subsystem in console?

Just try it. If it doesn't work, then make a post about it.
If you want a console you can most definitely create it with only int main(), have you even tried it??
It _just works_, nothing to do, nothing to add, just type
int main() { CreateWindow(...)}

and you have your window, no problems, no nothing.

I assumed, since you posted a question like this, that you did not want a console or that you had already tried it and it didn't work without WinMain.
You'll never finish any engine if you need answers to small irrelevant questions like this before you even start.
@BreathOfLife

I'm using only SDL's windowing and input, so is it really reasonable to use it or write the code myself?
Quote:Original post by DarkBalls
@dmail
If I understand what you said correctly, I can create a window using only int main() and subsystem in console?

You have me confused now. Are you wanting to create a console window or win32 window? You can create a console window from WinMain using AllocConsole but this does not seem to be what you are asking. Yes you can create a win32 window using the entry point main. GetModuleHandle can give you the HINSTANCE to the process.

Quote:
I'm just using SDL's windowing and input and using OpenGL to render 3d graphics. So I think making my own for that will not really a big job, I think.

Ok lets quickly think this through, here is what you need
Cross platform window creation.
Cross platform window events.
Cross platform joystick handling.
Cross platform OpenGL and window binding.
Cross platform OpenGL extension loading.
This is only a very small fraction of what SDL provides.

Quote:
I know how to create a win32 window but not yet in linux. But I have a linux installed on my virtual machine.

This just confuses me more :) By the way you will not be able to have graphic acceleration in a virtual machine.

Quote:
Quote:
@Erik Rufelt
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.


If I didn't find any way on how to create a window using int main() and subsystem console, I'll just leave to that for now.

I do not know how helpful this will be but in a nutshell this is how SDL does it on windows.
*It uses the preprocessor to rename entry point
*Defines its own entry point
*Sets up global states
*Then calls your entry point which it renamed.
Quote:Original post by DarkBalls
@BreathOfLife

I'm using only SDL's windowing and input, so is it really reasonable to use it or write the code myself?


Have you a compelling reason not to use something that you already have working? Do you think using SDL will be a problem? Does it not support some feature you absolutely rely on having?

The whole point of SDL is to set up a rendering context for you, handle input and then get out of your way. It sounds like the perfect solution for someone in your position, with your (mostly assumed) requirements.
Oh now it works. Thanks to scottrick49 and Erik Rufelt. I just forget to change the subsystem to console. stupid me. Now it is working fine. Thanks guys.

Oh, what a tough forum really. I should just ask on a c++ forum or maybe tell that it is not for a 3d engine.

But anyway, thanks for the help.
Quote:Original post by DarkBalls
Oh, what a tough forum really. I should just ask on a c++ forum or maybe tell that it is not for a 3d engine.


Most forums will look down on childish tantrums like your explosion in the middle of this thread. Its an attitude thing simply. I expect you to be reasonable.

If you has said "I'm sorry, but I am really want to do this myself", then that is fine. But the profanity was unnecessary and inexcusable. Learn to restrain yourself, to not read too deeply into what other people type. This is a text only medium, without the subtle cues of body language to give you a hint about intent. I was trying to be helpful, as are the other members of this forums. Not trying to attack you or something, which is what you appeared to be responding to.

FWIW, I still think you are making a mistake by pursuing this path.
Quote:
What do you think you will gain by dumping SDL?

Quote:
Why do you want to discontinue using that library?

The fact that you cannot (or will not) answer the above two questions (which, IMHO, might well amount to the best help you got in this thread) indicates that this is some kind of "not invented here" tangent that you will only regret later.

Quote:
But anyway, thanks for the help.

You are most certainly welcome [smile]

This topic is closed to new replies.

Advertisement