So I got curious with OpenGL and I ended up having a copy of the "redbook", as people call it. Initially when I tried relying only on online sources like tutorials and whatnot they were all written using WinMain which was a drag so that sort of put me away but then I started skimming this book and I found that it was using main instead of WinMain.

If there any difference using one over the other? I tried googling these 3 keywords but got nothing since they were all in WinMain.

Also what is the point of WinMain anyway? Won't I be able to use windows.h without it? Will it deprive me of certain features when using OpenGL?

Oh and are all C libraries, standard or third party, written in assembly? Is that how they make APIs and the whole C library in general and that C itself is just merely a 'framework' that tells what the structure of the code should be? Merely grammar, in a way.

Recommended Answers

All 14 Replies

>>Also what is the point of WinMain anyway? Won't I be able to use windows.h without it?
Yes, windows.h is often used in console programs. I don't do OpenGL programming so I don't know the significance of using WinMain() vs main()

>> are all C libraries, standard or third party, written in assembly? I
No. They are written in C, although a few rare parts may be written in assembly.

>>C itself is just merely a 'framework' that tells what the structure of the code should be? Merely grammar, in a way.
I suppose you could think of a c compiler that way.But the language itself if much more as it contains header files and libraries of pre-compiled code as implemented by the writers of the compiler. The ANSI C language is specified by an international committee, and compiler writers such as GNU, Microsoft, Apple, and IBM each write their own implementation versions.

Generally speaking, I believe main is used when the application is compiled using the console subsystem and WinMain is used when compiled using the Windows subsystem.

I suggest searching for "WinMain vs. Main". That should pull up some results for you.

Generally speaking, I believe main is used when the application is compiled using the console subsystem and WinMain is used when compiled using the Windows subsystem.

I suggest searching for "WinMain vs. Main". That should pull up some results for you.

Although that is true in general, the question was: what is the significance of one over the over in OpenGL programming?

Oh god here we go again. lol So what is C since technically I've only been using libraries/functions written in C.

Oh and can assembly be compiled with C? Like if I felt like using assembly on a certain part of a C program I could?

>>Oh and can assembly be compiled with C? Like if I felt like using assembly on a certain part of a C program I could?

Depends on the C compiler. If your C compiler lets you do it then its an extension of C language. Different compilers have different ways of letting you embed assembly inside a c program. That's because assembly is totally non-portable, so if you use it then you will be unable to port the program from one processor type to another without rewriting the assembly code.

Oh god here we go again. lol So what is C since technically I've only been using libraries/functions written in C.

C is a programming language. :icon_rolleyes: It's a glorified text format which compilers use to convert conforming text files into the corresponding machine code for the targeted platform.

No I didn't mean it like that. I'm still lost there fueled by my inability to comprehend how C third party APIs can get those features and still be branded as C, since standard C doesn't supply those features.

Nontheless my original question on OpenGL still stands.

I'm still lost there fueled by my inability to comprehend how C third party APIs can get those features and still be branded as C, since standard C doesn't supply those features.

Obviously those features weren't implemented only with standard C. Any "branding" as probably means that the API is callable by C rather than being sold as written in C. Very few people care what a library is written in as long as it does the job sufficiently well.

>Any "branding" as probably means that the API is callable by C rather than being sold as written in C.
OHHH I think that did it...

Whoops. My bad on missing the actual question. To my knowledge and to the extent that I've worked with OGL, there's no difference at all. OpenGL only cares to have a window to draw to. Some game projects I worked on used main, where some used WinMain and I don't recall anyone ever complaining they couldn't do one thing or another because of the decision to use main or WinMain.

Hope that helps more than my last post =)

So it wouldn't matter? So it'll still be OpenGL, but using WinMain gives me the features of well... WinMain? But it makes no difference for OpenGL?

Oh and can I also make windows using OpenGL? Like leave the console-look?

OpenGL doesn't care as long as there's an application window to draw to, but I don't think the console is considered such. I could be wrong, though.

OpenGL itself isn't used to make windows, per se, as it just takes over a window that already exists. What do you consider the console look?

Well I'm hoping not to have to learn WinMain, at least not yet, since it has the capability to make a new window and resize it and whatnot. If OpenGL could do that then I'd stick to main for now until I can start WinMain for good. Not really any books around about that, and tutorials are very limited.

Console look would be what every beginner would first do, no?

Well, you need to create an OS specific window regardless, and that's OS level functionality. Some libs will take care of that for you, such as SDL or SFML, but if you want to do it from scratch, you'll have to manually create it somehow.

Check out nehe.gamedev.org and look at tutorial #1, which is how to setup OpenGL. You can use the code found there and modify it to work with main(). I'm sure there's a plethora of tutorials out there to show how to create a Windows window w/out WinMain.

The benefit of using WinMain is that it's already done for you when you create a win32 project and there's little you really have to understand about using it, besides changing the message loop, but setting that up is described in the tutorial on nehe.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.