Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

OpenGL Programming for Windows

Name: Anonymous 2012-06-16 23:13

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: Anonymous 2012-06-16 23:30

halp

Name: Anonymous 2012-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: Anonymous 2012-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: Anonymous 2012-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: Anonymous 2012-06-17 0:02

>>5
You should read SICP, and disavow yourself of these impure thoughts.

Name: Anonymous 2012-06-17 0:05

>>6
I have read it actually. There's nothing wrong with some good documentation and examples.

Name: Anonymous 2012-06-17 1:00

One word, RTFMSDN, thread over.

Also win32.hlp is your friend.

Name: Anonymous 2012-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: Anonymous 2012-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: Anonymous 2012-06-17 3:38

the very last lazyfoo tutorial shows how to get a simple OpenGL window up with SDL

Name: Anonymous 2012-06-17 4:16

>>8
Have you read your MSDN today?

Name: Anonymous 2012-06-17 4:54

VENDOR LOCK-IN MY ANUS

Name: Anonymous 2012-06-18 18:15

OpenGL a shit. Just use DirectX. If you like C, Win32 and DirectX APIs are both very C-ish (the former is actually pure C89).

I uploaded Petzold's book (Programming Windows 5th) right here:
http://www.mediafire.com/?sbpch0wr5ff5i66

Here's the content of a "DirectX books" torrent in case you don't want to torrent:
http://www.mediafire.com/#zxg9p9akl7g1z

This is also a helpful site:
http://directxtutorial.com/

Name: Anonymous 2012-06-18 18:28

>>14
OpenGL a shit.
Just use DirectX.
Contradictions
2012

Name: Anonymous 2012-06-18 18:50

>>15
replace a with is

Name: Anonymous 2012-06-18 20:53

>>14
I wouldn't recommend DirectX even to my worst enemies. You are truly an awful person.

Name: Anonymous 2012-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.

Name: Anonymous 2012-06-18 23:58

>>18
SDL, faggot.

Name: Anonymous 2012-06-19 0:06

Allegro. Allegro. Allegro.

If it's good enough for Xarn it's good enough for you.

Name: Anonymous 2012-06-19 0:07

>>18
You cannot deny that DirectX is a much more pleasant experience for game programming.
You're so funny.

Name: Anonymous 2012-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: Anonymous 2012-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: Anonymous 2012-06-19 1:05

>>23
Keep telling yourself that if it makes you feel better.

Name: Anonymous 2012-06-19 1:23

>>24
YHBT.

Name: Anonymous 2012-06-19 2:22

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.

Name: Anonymous 2012-06-19 2:47

Why not just use GLUT?

Name: Anonymous 2012-06-19 4:12

>>27
GLUT a shit.

Name: Anonymous 2012-06-19 4:20

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?

_____________
1. Jason L. McKesson (2012). http://www.arcsynthesis.org/gltut/.

Name: Anonymous 2012-06-19 5:31

>>29
I ate C++, I ate GLUT, and I ate SHAYDERZ!

Name: Anonymous 2012-06-19 5:47

>>30
You can learn with shaders and then program with the fixed-function pipeline for compatibility.

Name: Anonymous 2012-06-19 6:26

error: unrecognized layout identifier `location'

>>31
Apparently my drivers don't even support them. =D

Name: Anonymous 2012-06-19 11:54

إ唹捣蜉㖗㝢葕ʆ昇ᚆ牓䕇瑅枓ህ䑗芀⚑瀨興砒䒇匴㜑吖荳҂昱鐶䍡䑨父抐㌘舰牔皑᜴物摘疐Ɛ䚉ė南䜡杙偲ʗĥ喘ᠷ蜣܃饩つ䕩袀〦̩垑楀ځ疁⁗硩恷圂㈔蕲荓扷蜃䘅ᠰ戅螅虥⁸獑ᄠ冘鞄馒脐祂䢃煙夐ᦇݩᔒ蘙聣ⅆ憐အᠨᠦ杔儩䠠㐲夐᎗䔖䙇∸ᖉ劀敡䈦࢈㖕ⅳ蘣炆⢖蕲ᤒ㥰割単榐≕鐙邉⤇挨蠰ᔖ㉱慀ⅱ逃ፓ阸Բ墈艳ԓ玐㒓᥉蜡睕犀⤲䘣荰慥኉⤇吧夣呁楶霡ច頓ᡷባ阤㙢ॸ㢅̓捴ဆ䉅犉⍑ᄆ䁁钃剸畃ѥ硐ረ儰‑礑ɷ阰⊘焐㉹皉Ň厐皙䉦鉄鍇ᅗ䔵炉昒0舂甕䉳ᐦ卦䝃̲ቨᖇ恐ន瘆睩܂鉒敧✓䥒醅傒皐璕ȉ冉ࡒ材蔂猇卨㙑䜁ㅖ剁⎅虲荵⥉ら〴獣Ή睅榔Ч碇捠瀢眸鈖襡倈畣蘘④蕂ㄈᙇ戄ㄦ唣薓⒒≕⍰邗扐ゃޙ餖䠣錙♇䉆┲戁蔈祷慀ᅄ奶Ƃ偧艒呓֔䠖儩ᚃ莂г饆♷䢔券酂⎘然頶ᥣ

Name: Anonymous 2012-06-19 11:57

>>26
I fucking agree.

Don't change these.
Name: Email:
Entire Thread Thread List