I've written games for a lot of various different pieces of hardware, but I haven't done a whole lot on my PC, save the occasional Java2D game. However, I don't want to program in Java- I'd really like to use C, my language of choice (though C++ would be tolerable).
That being said, I would really like to learn OpenGL to write games for Windows. Is it necessary to learn the Win32
API to do this? I've searched for Petzold's book and I can't find it anywhere except online, and I'm too much of a poorfag to buy it. Also, any recommended sources for a complete newbie to OpenGL? Books preferred.
Name:
Anonymous2012-06-16 23:30
halp
Name:
Anonymous2012-06-16 23:34
>>1
You need to learn a small subset of the Win32 API, but not all of it. Just how to create a Window, get a handle to its draw context or HDC, and pass that to the WGL calls. Then you need to use Win32 to get user input events. It's no different than learning the stuff in X11 relevant to setting up a GL display via GLX. You'll also want to download and build the GLEW library to get access to all of the OpenGL 2.x/3.x/4.x features and extensions.
You could also just use SDL to bootstrap yourself, but no real game programmer uses SDL for Windows or XBox 360 development.
Name:
Anonymous2012-06-16 23:36
If you're programming for Windows in C past the standard library, then yes you need to use at least some of the Win32 API. If you're using C++, have a look at MFC or preferably WTL.
Name:
Anonymous2012-06-16 23:57
>>3
Thanks. And yeah, SDL looked interesting but always seemed a bit amateurish to me.
Are there any books I should read or just try to jump in?
Name:
Anonymous2012-06-17 0:02
>>5
You should read SICP, and disavow yourself of these impure thoughts.
Name:
Anonymous2012-06-17 0:05
>>6
I have read it actually. There's nothing wrong with some good documentation and examples.
Name:
Anonymous2012-06-17 1:00
One word, RTFMSDN, thread over.
Also win32.hlp is your friend.
Name:
Anonymous2012-06-17 1:55
>>5
SDL's documentation should be more than enough, the problem is learning OpenGL. It takes some searching to find a decent OpenGL tutorial (ideally, you want one that doesn't use immediate mode (the presence of glBegin(); ... glEnd(); indicates immediate mode; you want to find a tutorial which is based on version 3.3 core profile, if not 4.1 core profile)).
The only SDL code you need to get started with OpenGL is something like: #include <SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
SDL_Surface* screen;
int running = 0;
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
fprintf(stderr, "SDL_Init: %s (Jews did 9/11)\n", SDL_GetError());
exit(EXIT_FAILURE);
}
/* OpenGL attributes go here. */
if (!(screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL))) {
fprintf(stderr, "SDL_SetVideoMode: %s\n", SDL_GetError();
exit(EXIT_FAILURE);
}
running = 1;
while (running) {
SDL_Event event;
while (SDL_GetEvent(&event)) {
switch (event.Type) {
case SDL_QUIT:
running = 1;
break;
}
}
/* OpenGL code goes here. */
}
SDL_Quit();
return 0;
}
Name:
Anonymous2012-06-17 3:34
>>5
One of SDL's design goals is to be simple. If you try to compare it Direct X, it is undoubtedly simple.
Name:
Anonymous2012-06-17 3:38
the very last lazyfoo tutorial shows how to get a simple OpenGL window up with SDL
>>14
I wouldn't recommend DirectX even to my worst enemies. You are truly an awful person.
Name:
Anonymous2012-06-18 23:50
>>17
He wants to write games. OpenGL is just a graphics library. It can't handle I/O, sound, networking, etc., and you have to use various shitty libs to do those things (and in a similarly cross platform manner--the only reason you go this route anyway) whereas DirectX and Windows provides a cohesive collection of APIs for all of these. Enjoy your hacked together bloat. You cannot deny that DirectX is a much more pleasant experience for game programming.
>>18 You cannot deny that DirectX is a much more pleasant experience for game programming.
You're so funny.
Name:
Anonymous2012-06-19 0:20
It's so easy to troll /prog/. Just say that C++ is a good language or that Windows is better than Linux and there we go. Oh and check them.
Name:
Anonymous2012-06-19 0:48
>>22
On /prog/, "Trolling" is just a way for morons to back out of an argument. You make a stupid claim, somebody argues it, you say you were trolling because you can't respond to their argument in any other way.
Name:
Anonymous2012-06-19 1:05
>>23
Keep telling yourself that if it makes you feel better.
C++ is a good language. It is not a perfect language because it inherits from C. C is a flawed language where many things are left undefined. C is an ancient artifact that serves no purpose outside of the domain of kernel design. Because of the improvements made upon C to form C++, beginning programmers and veteran programmers alike may be led astray, thinking that modern C usage is a good idea. It is a mistake to believe the success of C++ justifies the continued use and popularity of C. Just because C++ is successful does not mean the language it has inherited from is of high quality.
Use the Win32 API like others have suggested.
By the way, I noticed a recent influx of OpenGL-related topics. Have You read your “Learning Modern 3D Graphics Programming”[1] today?