OpenGL Book [Archive] - C Board

PDA

View Full Version : OpenGL Book


punkrockguy318
12-16-2003, 06:37 PM
I'm an intermediate C++ programmer, and know very little about programming in Windows. I want to learn OpenGL; what's a really good book that would suit me? Thanks

Silvercord
12-16-2003, 07:34 PM
OpenGL Game Programming

frenchfry164
12-16-2003, 08:52 PM
Look up the OpenGL Red and Blue books

glUser3f
12-17-2003, 07:25 AM
>OpenGL Game Programming
seconded

>Look up the OpenGL Red and Blue books
I think that both are better as references more than something to start with, and they are available online anyway...

punkrockguy318
12-17-2003, 09:55 AM
Okay, I think I'll go with OpenGL game programming, and I'm also purchasing "Tricks of the Trade of Windows Game Programming" by andres somethingorother. I'm going to learn a little 2D directX; that way I'll be more versitile. But learning openGL is more of a priority for me: I would like to code multiplatform; and stay away from microsoft specific!

Silvercord
12-17-2003, 02:57 PM
OpenGL is easier to learn too.

Mokkan
12-17-2003, 04:01 PM
*about to learn directX*

*pauses*

What? It is? :(

Silvercord
12-17-2003, 04:34 PM
yes OpenGL is easier to learn than DirectX, in my opinion. Rest assured, that'll be your opinion too :)

glUser3f
12-18-2003, 06:30 AM
if you like functions with 10 params, each is a struct with 20 members, and everything's name starts with 8 caps, then DirectX is for you :D

EvBladeRunnervE
12-18-2003, 08:26 AM
if you like functions with 10 params, each is a struct with 20 members, and everything's name starts with 8 caps, then DirectX is for you

well, I love Opengl as much as everyone here, but there are some reasons to use DirectX:

1) most commonly used graphics API in the prof. gaming market(I am speaking commercial titles, not indy-prof.)

2) Has full support by Windows, which is on ~92% of PCs

3) has most of the new features(shaders/etc.) built-in, instead of using encumbersome extensions.

Some reasons NOT to use DirectX:

1) doesn't run on those other ~8% of PCs, while OGL does

2) as mentioned in quote above, crappy naming scheme, overloaded(no, not the good kind) structs.

3) doesnt have a wide programmer base(while most commercial companies use DX, most hobbyists/programmers use OGL and you are more likely to get help if you have questions).

4) its M$(just had to include this :P).



now, back on topic..........

OpenGL Game Programming

third this^^.

glUser3f
12-18-2003, 08:50 AM
1) Isn't really a reason to use DirectX, I don't care what other programmers are using as long as the API I use does what I want it to do.
2) OpenGL does so too, it also runs on the remaining 8% you spoke of.
3) I think that using OpenGL extensions are much better than downloading the latest framework every time a new feature is out.
In OpenGL, the only latest driver and extensions header file are required to use new features.
4) OpenGL has a better community than DirectX.

punkrockguy318
12-18-2003, 02:20 PM
Wow, thanks a lot for all the replies! I'm going to get "OpenGL Game Programming" instead of "Tricks on the trade of Windows Programming". Those were just the answers I was looking for!

...
12-19-2003, 04:51 AM
"tricks of the windows game programming gurus" is a good book, as is "tricks of the 3d game programming gurus". neither focus on openGL though.

i personally use directx more than ogl, simply because its what ive gotten used to using. make a few wrapper classes and you dont have to worry about all the messes microsoft has created for your convenience.

punkrockguy318
12-19-2003, 06:40 AM
Originally posted by ...
make a few wrapper classes and you dont have to worry about all the messes microsoft has created for your convenience.

What is a wrapper? i'm still not sure

Silvercord
12-19-2003, 07:21 AM
well, it is a programmer thing, and it's hard to explain if you don't already know what it is. but basically it just means that he made his own functions that do the directx stuff for him, and so he doesn't always have to remember the cumbersome details of directx stuff.

and OpenGL doesn't seem to be fully supported by microsoft, because a lot of the extensions that are extensions on Windows are NOT extensions on other operating systems...the only reason they must be extensions on Windows is that they don't update their OpenGL accessors (the headers and libraries you need to be able to make OpenGL function calls).

In short, they're both really good, both fast, both have their ups and downs, but OpenGL is easier and you're more likely to get help on the internet from other peeps. Also, you can always go into DirectX later, so why not start with the easier one?

Kinasz
12-19-2003, 07:55 AM
While we're on the topic, I am also looking for advice on a book. I'm after a book that teaches more the theory of games programming than any particular API. Stuff like tiling and representing data, collision detection, etc. In fact a book that avoided API specific code all togethor. Does such a book exist and would it be helpful?

punkrockguy318
12-19-2003, 02:23 PM
So would this be a very simple example of a wrapper?


int setColor(unsigned short color)
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hOut,color);
return 1;
}

...
12-19-2003, 03:38 PM
in a way, yes...

this is my initialization function in my direct3d wrapper. i pass in the hWnd of my window, the size of it, and a bool for fullscreen. my wrapper then tells directx to do this:



BOOL CDisplay::Init( HWND hWnd, int iWidth, int iHeight, BOOL bFullScreen )
{
// create the main d3d obj
m_d3dObj = Direct3DCreate9( D3D_SDK_VERSION );

if ( !m_d3dObj )
{
MessageBox( NULL, "Failed to create d3d object", "error", MB_OK );
m_pEL->Log( "Failed to create d3d object" );
return false;
}

// setup device parameters
memset( &m_d3dPresent, 0, sizeof( m_d3dPresent ) );

m_d3dPresent.BackBufferWidth = iWidth;
m_d3dPresent.BackBufferHeight = iHeight;

// windowed = D3DFMT_UNKNOWN
// fullscreen = D3DFMT_R5G6B5
m_d3dPresent.BackBufferFormat = (bFullScreen ? D3DFMT_R5G6B5 : D3DFMT_UNKNOWN);

m_d3dPresent.BackBufferCount = 1;
m_d3dPresent.Windowed = !bFullScreen;
m_d3dPresent.hDeviceWindow = hWnd;
m_d3dPresent.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_d3dPresent.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;

HRESULT hr = 0;

hr = m_d3dObj->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&m_d3dPresent, &m_d3dDevice );

*m_pEL << DXGetErrorString9( hr ) << " - " << DXGetErrorDescription9( hr ) << "\n";

if ( FAILED( hr ) )
{
MessageBox( NULL, "Failed creating d3d device", "error", MB_OK );
m_pEL->Log( "Failed creating d3d device" );
m_d3dObj->Release();
m_d3dObj = NULL;
return false;
}

m_hWnd = hWnd;

return true;
}

punkrockguy318
12-30-2003, 11:34 AM
Thanks a lot everyone! I got the OpenGL Game Programming book - and the Tricks of the Trade of Windows Game Programming Book (directX). OpenGL Game Programming is great - It's works great when using it with NeHe tutorials. I'm going to skim through TOTWGP just for a basic idea of directX.

Also - the OpenGL Game programming uses DirectInput and DirectSound. That's great, but if I want to port to mac/linux, is there something platform independant i can use? Any ideas?

ps: look at my win32/tcp/ip book thread. i don't want to double post, and i have some questions

punkrockguy318
12-30-2003, 11:46 AM
Originally posted by Kinasz
While we're on the topic, I am also looking for advice on a book. I'm after a book that teaches more the theory of games programming than any particular API. Stuff like tiling and representing data, collision detection, etc. In fact a book that avoided API specific code all togethor. Does such a book exist and would it be helpful?

http://www.amazon.com/exec/obidos/ASIN/1556229119/ref%3Dnosim/gamedev/103-4633064-5829400

That is supposed to be pretty good - 5 stars on gameDev.net

frenchfry164
12-30-2003, 12:49 PM
You can use FreeGLUT for input and FMOD for sound. OpenAL is good for 3D sound too.

FreeGLUT
freeglut.sourceforge.net
FMOD
www.fmod.org
OpenAL
www.openal.org

FreeGLUT is not only an input library though. It also does all the work of creating a window and handling messages for you.

FMOD is an awesome sound and music library. It is free to use, and it is platform-independent. You can even use it on the PS2, Gamecube, and XBox if you want (I think you have to buy a license to use it for consoles though. The computer versions are free though).

OpenAL is library that resembles OpenGL, but is for audio. It works really nicely, and is platform-independent. It works really well with 3D audio. I prefer FMOD though.