Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Doc Block
Apr 15, 2003
Fun Shoe

vanjalolz posted:

I looked at the Nate Robbins tutorials, and although they are really funky, they clearly target a different crowd. NeHe teaches you OpenGL from the ground up, Nate Robbins shows you how the parameters of a function call come together. OpenGL colour books are equally sucky at walking you through step by step. Great reference, terrible point to start.

As for the BMP loading, code stealing is the best way, but if you're stealing code you may as well steal something that doesn't completely suck. PNG is cool, but libpng is a dependency that I really can't be bothered with.

Here is a TGA loader I found on the net somewhere:

http://pastebin.com/f7c2b44e2

http://rapidshare.com/files/73582942/tga.rar.html

Just call it with
GLuint tex = loadTGATexture(filename)
or set a texid your self loadTGATexture(filename,texid)

I tried learning from NeHe, and failed miserably. The problem I was having is that NeHe doesn't teach any of the reasons why the code does what it does. And the code itself is horrible, which just made it worse.

So I bought the Red Book and learned OpenGL from that. It starts you off at the basics, making sure you understand the pipeline and what's going on under the hood. NeHe does none of that, and is mostly a "copy-paste without really understanding what's going on" type of site IMHO.

Adbot
ADBOT LOVES YOU

cornmonger
Feb 15, 2007

Eat thy corn, fish mongers
I think the best way to learn game programming is to start with mod coding on something like one of the Quake engines or HL2 engines. You get all of the meat of game programing without all of the technical stuff. You can slowly become more technical as you move along. The important part is that you see results very quickly, which is important for motivation, I think.

tyrelhill
Jul 30, 2006

Kylratix posted:

I think the best way to learn game programming is to start with mod coding on something like one of the Quake engines or HL2 engines. You get all of the meat of game programing without all of the technical stuff. You can slowly become more technical as you move along. The important part is that you see results very quickly, which is important for motivation, I think.

I'd have to disagree and say you should start way down at the bottom with simple stuff like Pong and Frogger before you go look at binary search trees and crap like that.

haveblue
Aug 15, 2005



Toilet Rascal

tyrelhill posted:

I'd have to disagree and say you should start way down at the bottom with simple stuff like Pong and Frogger before you go look at binary search trees and crap like that.

I think you missed the point a little. Sure, modding a game won't teach you OpenGL or how a BSP tree works, but it lets you skip directly to the entities and world state - *game* programming, as opposed to just graphics and simulation programming (not to mention input, sound, I/O, etc). The foundation is already there.

I agree that examining a complete cutting-edge engine is a very bad way to learn the basics of graphics programming, if that's your objective.

vanjalolz
Oct 31, 2006

Ha Ha Ha HaHa Ha

tyrelhill posted:

I'd have to disagree and say you should start way down at the bottom with simple stuff like Pong and Frogger before you go look at binary search trees and crap like that.

Here's a question for you though. After making Pong, snake and tetris, what's next step to 3D Game Programming Mecca? Jump from the low level up to the top and work your way down again (ala pre-built game engine) or continue on the same path (build all the ground work on my own).

I can see the 'learning' benefit of option two, but seriously, if I started down that low, I'd code steal 80% of the stuff (like model loading code) to get to a clumsy version of a pre-built engine. Should I skip that pain and actually get to doing some serious game code before I work my way down when I start caring about the difference between different modelling programs?

gra
Feb 21, 2006

Ugg boots posted:

Just some simple vector math, really. Instead of moving the ship 1 unit in the Y direction, to move it forward just move it cos(angle) in the X direction and sin(angle) in the Y direction. If you're not keeping an angle, and your direction is in the form of a vector, just normalize that vector (let's call it V) and move Vx * speed in the X direction and Vy * speed in the Y direction.

That's great, thanks! I've almost got this working with vectors (it's OK when I'm at the origin, but not when I move about, so I think I'm forgetting to multiply something somewhere). My next question then is - is there any way to get the angle you've rotated from a rotation matrix?

more falafel please
Feb 26, 2005

forums poster

vanjalolz posted:

Oh poo poo, i ran into the same problem the other day, but on a bigger scale. Is there a generalisation I can make which ignores the angle the player is facing? At the moment, I have to use different math functions depending on the angle (eg 0-90, 90-180, 180-270, 270-360)

Vectors?

You should in general be trying to avoid angles and trig. Vectors are significantly more flexible and faster.

POKEMAN SAM
Jul 8, 2004

vanjalolz posted:

Here's a question for you though. After making Pong, snake and tetris, what's next step to 3D Game Programming Mecca? Jump from the low level up to the top and work your way down again (ala pre-built game engine) or continue on the same path (build all the ground work on my own).

What I would do, in retrospect, is grab something like XNA (2.0 beta is out ;-)) and make a game in it. It handles most of the model loading (though you can extend it pretty easily to add functionality to it) and a lot of the tedious stuff that goes into making a game engine (it handles all the DX stuff for you, for example.) Basically, it's a very extensible 3D engine that gives you a few bits and pieces of what a game engine needs. You'll still have to design all your classes, figure out what to draw when, figure out all of the camera code, matrices, etc.


gra posted:

That's great, thanks! I've almost got this working with vectors (it's OK when I'm at the origin, but not when I move about, so I think I'm forgetting to multiply something somewhere). My next question then is - is there any way to get the angle you've rotated from a rotation matrix?

For the vector, you want to keep an orientation vector, not just use your vector from your position to the origin. Every time you rotate the ship, do it by multiplying the orientation vector by a rotation matrix, then that vector is your new orientation vector. Use that orientation vector to determine how to rotate the actual sprite/model, and that orientation vector (should always be a unit vector) will be the one you move along.

Subotai
Jan 24, 2004

Ugg boots posted:

You'll want to use the inverse of your World-To-Screen Matrix to find a Screen-To-World Matrix to transform your points with. Then you can just draw your billboards there.

Do you have an example of how to get the Screen-To-World matrix? :confused:

*edit*
Ohh I think I just figured out how to get the inverse. Then I can just use that and I should be set?

Subotai fucked around with this message at 21:43 on Dec 2, 2007

heeen
May 14, 2005

CAT NEVER STOPS

gra posted:

I'm working in DirectX/C++ just now. At the moment, I move things along the x and y axis and rotate them around the z axis - but I want to move the object "forward" along the heading it's been rotated to (I'm thinking asteroids - where the ship moves along the direction it's heading). Any idea/tutorials on how to do this?

If you display the ship rotated on screen, you probably have a matrix for that object. Take the rotation part of that matrix (the top left 3x3 part) and rotate the forward vector of the ship with it and push the ship in this direction.
The forward vector is the vector in model space that points from the origin of the model space to the nose of the space ship.
In most cases the model is aligned along the axes of the model space in which case your forward vector will be something like (0,1,0). So instead of multiplying the vector with the rotation matrix, you can use the respective column directly, in the above case that would be the middle column.

heeen fucked around with this message at 22:20 on Dec 2, 2007

vanjalolz
Oct 31, 2006

Ha Ha Ha HaHa Ha
I tried XNA when it first came out, but it didn't really do it for me. I think I'll have another attempt these summer holidays.

As for the vector thing, I had the right idea but I had cos for x axis instead of z, and vice versa.

x = x - Speed*sin(roty)
z = z + Speed*cos(roty)

duck monster
Dec 15, 2004

Digital Spaghetti posted:

A little update on my game development adventure.

At the moment, I have been learning Python from scratch - so far I'm LOVING it - finding it much easier than C/C++

At the moment, I've not got much further that writing a OO Blackjack game, and some minor GUI stuff, but my next move is to look at PyGame (and possibly Soya3d) to start doing some 3D stuff.

Welcome to the cult :) We are all Guido's children :)

Pygame is an awesome little library, and its drat easy to bully around.

If you want a really basic 3D engine to play around with Panda3D is dead easy. Its very basic, and I wouldn't expect to be able to create anything remotely professional, but its a good little learning tool and its dead easy. Its a shame it doesn't seem so maintained however.

POKEMAN SAM
Jul 8, 2004

duck monster posted:

If you want a really basic 3D engine to play around with Panda3D is dead easy. Its very basic, and I wouldn't expect to be able to create anything remotely professional, but its a good little learning tool and its dead easy. Its a shame it doesn't seem so maintained however.

I don't see how it's so basic, I mean, it supports Cg shaders, has integrated Physics support, pretty solid model/animation support, and many other features.

duck monster
Dec 15, 2004

Ugg boots posted:

I don't see how it's so basic, I mean, it supports Cg shaders, has integrated Physics support, pretty solid model/animation support, and many other features.

You could be right. I haven't checked it in a while, and last time I looked there didn't seem a whole lot of advanced features, and didn't seem to have that active development.

Ferg
May 6, 2007

Lipstick Apathy

duck monster posted:

If you want a really basic 3D engine to play around with Panda3D is dead easy. Its very basic, and I wouldn't expect to be able to create anything remotely professional, but its a good little learning tool and its dead easy. Its a shame it doesn't seem so maintained however.
Irrlicht is another totally simple engine that's great for getting your feet wet with 3D engine programming. It's got great tutorials and a decent community.

Regarding XNA: why is it I need Visual C# Express? I have Visual Studio 2005 already, but no matter what XNA bitches at me for not having Express installed.

Ferg fucked around with this message at 15:52 on Dec 3, 2007

vanjalolz
Oct 31, 2006

Ha Ha Ha HaHa Ha
There were hacks to get it working in VS2005. Last I read, it had something to do with microsoft wanting to push a 'commercial' XNA product later which tied in with their commercial Visual Studio

Citizen Erased
Mar 20, 2004

Wash Me Away
I think this has been addressed twice now in this thread but I can't wrap my head around it in the context of my application:

I have a ring of verticies that are at an arbritrary position in local 3D space which I want to rotate to face an arbritrary direction and then translate in that direction by n units. I'm using the x,y and z coordinates of the verticies to do these transformations and am trying to work out how to get this to work. So far, I've got the rotation down with D3DXMatrixRotationYawPitchRoll to rotate a blank matrix and then taken the position from that matrix and transfered it to the verticies using D3DXVec3TransformCoordArray. What I can't work out how to do is translate the verticies in the direction they are now facing. What do I do to the x,y,z position coordinates to make them move in this abritrary direction?

Madox
Oct 25, 2004
Recedite, plebes!

Citizen Erased posted:

What I can't work out how to do is translate the verticies in the direction they are now facing. What do I do to the x,y,z position coordinates to make them move in this abritrary direction?

First, you should find out what is the forward direction of your vertex ring when it is unrotated. For this post, I will assume this is going to be the +z direction, so that vector would be (0,0,1). It sounds like you already have the rotation matrix for the given vertex ring. To translate it in the direction it is facing, transform the forward direction vector by your rotation matrix and use that.

newPosition = oldPosition + ((0,0,1) * distanceToMove * rotationMatrix)

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug

Twiggy794 posted:

Irrlicht is another totally simple engine that's great for getting your feet wet with 3D engine programming. It's got great tutorials and a decent community.

Regarding XNA: why is it I need Visual C# Express? I have Visual Studio 2005 already, but no matter what XNA bitches at me for not having Express installed.

Xna.com just posted that the Beta for XNA 2.0 has been released and it has support for VS2005.

Nyvinyd
Jun 2, 2005

"School! Ah, yes. Then you haven't heard of the easy road to success."
How would you guys suggest for someone to start from the absolute bottom? I know how programs work in theory, but in practice the most I have ever done is program my TI-83 to do my algebra homework for me. I am ok with learning the programs of other people when they have GUIs to make poo poo with, but I am still in the dark with the rest.

I have tried reading "Beginner's Guide"s on gamedev, but they all move way too fast. I have read a bunch and I still don't know how to alter existing code or even how to open up programs to be altered. I don't know how to actually get to the code, I guess, and I don't know how you go from bits of code to a program that runs from its own .exe.

I am assuming I need some kind of C++ book, but I don't know which one would be best to pick, or if there's a method that's better for learning game development than for writing other stuff.

So yeah guys, where do I start, and how should I move on from there?

magicalblender
Sep 29, 2007

Nyvinyd posted:

How would you guys suggest for someone to start from the absolute bottom?

Here's how I started:
Because it is free and moderately simple to install, I use the Borland C++ Compiler. It's seven years old, but if you're not doing anything super complex, it should suffice. Download it, run the exe, follow any pertinent readmes, and check to see if it's running correctly by compiling a simple program:

Open notepad, save this as test.cpp:

code:
#include <iostream>
int main(){
 std::cout << "Hello world! God, this is cliche.";
 return 0;
}
Go to the command line, "cd" to the directory where test.cpp is, and enter "bcc32 test.cpp". Now you have a ready-to-run .exe (Hopefully).

So, go do all that, then come back and tell us how it went.

t_rf
Nov 24, 2006
Hello world doesn't motivate any further subjects, which is what a learner should aim for. It's a "hay guys the compiler works."

My suggestion, which is very non-specific and expects you to do your own research, is to practice towards general programming knowledge. That means, don't worry about tutorials for graphics and 3d and stuff yet, don't worry about performance or commercial applicability or anything. Just choose any well-documented language to learn with, and try stuff that you'd see in introductory college courses: loading and manipulating files, text input loops, implementing simple data structures(linked lists, queues, stacks), and then maybe a text-based game to round out everything you've learned.

Once you've got the core background together, you can really go anywhere in programming. Game programming tutorials just implicitly assume that you already have it.

Madox
Oct 25, 2004
Recedite, plebes!

Nyvinyd posted:

How would you guys suggest for someone to start from the absolute bottom?

I started with the book 'The C Programming Language' by Kernighan and Ritchie to learn C. That book has exercises in it to boot, so I did all of those then moved on to writing my own text adventure games on *NIX (giving away my age). These days it wouldn't be so bad to start with the same book, desite everything being all C++ OOP. Most of the lanugage basics are still the same as C, and with game development you often want to squeeze out every tiny bit of performance, which often means resorting to some C code in your C++ app. I can't recomend a C++ book since all I read these days are reference books, but you'd definately want something to get you familiar with the C++ features, OOP and patterns etc.

Once you have the language down, you can move onto working with actual graphics simply using the Windows GDI library. Spend a bit of time learning how a basic window program / message pump works and get familiar with working with lines/colour/bmps/tiles etc. You can learn MFC but its not so important anymore. You do not want to use MFC for a game. Alternatively, you can learn C# if you plan to go the XNA route. I don't know a lot about XNA.

Following that you can start looking into DirectX and you should have enough footing to be able to take apart the sample code and other people's apps (Replace DirectX with OpenGL/3rd party engine if you like). The big challenge here is wrapping your head around shader programming. (Oh and maybe math).

That's basicly how I learned so that's all I can recommend really. I skipped the part about learning COM. Also, I'm not big on using engines because I'm more interested in figuring out how to render stuff than in making the game itself, so your goal may be different than mine.

Nyvinyd
Jun 2, 2005

"School! Ah, yes. Then you haven't heard of the easy road to success."

Madox posted:

I don't know a lot about XNA.

That's cool, I don't actually know what XNA is.

Ok so the basic idea I'm getting here is that before I learn graphics, I should learn text, and that a good book on C++ in general, along with the compiler, should get me there. I will do this. Thanks for the advice.

haveblue
Aug 15, 2005



Toilet Rascal

Nyvinyd posted:

That's cool, I don't actually know what XNA is.

Ok so the basic idea I'm getting here is that before I learn graphics, I should learn text, and that a good book on C++ in general, along with the compiler, should get me there. I will do this. Thanks for the advice.

Graphics is an application (in the original sense, not the computer sense); first you have to learn C++ itself. That learning process will likely not involve graphics, but at the end of it you'll be able to move on to that.

It's like how you have to learn Greek if you want to study classical philosophy.

zigb
Mar 21, 2007

Kylratix posted:

I think the best way to learn game programming is to start with mod coding on something like one of the Quake engines or HL2 engines. You get all of the meat of game programing without all of the technical stuff. You can slowly become more technical as you move along. The important part is that you see results very quickly, which is important for motivation, I think.

I've found the Source SDK code to be fascinating reading. Of course you don't get all of the good engine stuff, that's still proprietary. I also learned a nifty trick the first time I read it, not too long after HL2 came out.

code:
// Instead of defining flags like:
#define FLAG1 = 1 
#define FLAG2 = 2
#define FLAG3 = 4
#define FLAG4 = 8
... 
// They use left-shifts to do the same thing, in a much more readable (to me) manner: 
#define FLAG1 = 1<<0
#define FLAG2 = 1<<1
#define FLAG3 = 1<<2
...

6174
Dec 4, 2004

Nyvinyd posted:

Ok so the basic idea I'm getting here is that before I learn graphics, I should learn text, and that a good book on C++ in general, along with the compiler, should get me there. I will do this. Thanks for the advice.

The book Accelerated C++ by Koenig is a good place to start, assuming you want to go the C++ route. Start there and once you've got a handle on the basics you can start moving into something closer to game development.

PerOlus
Jan 26, 2003

We'r even, seņor!
Anyone have experience, comments, about XNA? I'm interested in using it. Do I have to use C# for it?

POKEMAN SAM
Jul 8, 2004

PerOlus posted:

Anyone have experience, comments, about XNA? I'm interested in using it. Do I have to use C# for it?

Pretty much. There are hackish ways of using it in other .NET languages, but you're pretty much stuck using C#.

If you have any other questions about XNA, I'd be glad to help.

Ferg
May 6, 2007

Lipstick Apathy

TAKE ME BACK posted:

Xna.com just posted that the Beta for XNA 2.0 has been released and it has support for VS2005.
I've been Googling around and perusing the Microsoft Connect website for this beta but I can't find anything. Is it closed?

Madox
Oct 25, 2004
Recedite, plebes!

Twiggy794 posted:

I've been Googling around and perusing the Microsoft Connect website for this beta but I can't find anything. Is it closed?

Looks like you should be able to get it from here.
http://creators.xna.com/beta/betahome.aspx

Ferg
May 6, 2007

Lipstick Apathy

Madox posted:

Looks like you should be able to get it from here.
http://creators.xna.com/beta/betahome.aspx
Thank you sir, somehow I wasn't able to find that.

vanjalolz
Oct 31, 2006

Ha Ha Ha HaHa Ha
When learning lighting in OpenGL, should I start by learning the fixed-function stuff, or should I skip ahead to implementing my own system in shaders? I'm not at all worried about not being able to program for video cards that do not support Pixel Shaders.

krysmopompas
Jan 17, 2004
hi
No reason you shouldn't just start with shaders - you'll get a better feel for what the hardware is actually doing behind the scenes. Fixed function is just a confusing mess of arbitrarily configured black boxes that result in *magic* on the other side.

Plus, while the syntax of the shader language may vary, the mechanics and logic of it are more consistent cross-platform/api than fixed function as well.

joe87653
Jul 9, 2002

joe87653 fucked around with this message at 07:54 on Mar 28, 2014

vanjalolz
Oct 31, 2006

Ha Ha Ha HaHa Ha
I'm starting with this tutorial - http://www.lighthouse3d.com/opengl/glsl/index.php?minimal

It's probably not the best, but its got me interested. After this I'll move on to more tutorials. I understand the basics of how lights work in opengl (glenable, light0-7, ambience, diffuse, specular) but nothing too in depth.

Vertex normals - Sounds like basic trig to me, just make sure I use Counter Clockwise vertices.

Just how difficult is shader loading? Naturally, I stole the loader for this tutorial which uses something called GLEW. Looks fairly basic.

tyrelhill
Jul 30, 2006

Citizen Erased posted:

D3DX stuff...

Use the view matrix. I'm a little rusty with DirectX since I've been using OpenGL a lot lately, but I'm pretty sure this is correct.

code:
D3DXMATRIX mat;
D3DXMatrixIdentity(&mat);
D3DXMatrixRotationAxis(&mat, &AxisToRotateAround, TheAngle);
D3DXMatrixTranslation(&mat, TranslationX, TranslationY, TranslationZ);
YourD3DDevicePointer->SetTransform(D3DTS_VIEW, &mat);
Then just draw your object at the origin. Make sure if you're drawing other objects to set the view matrix back to an identity.

This is my opinion but never use Euler Angles for stuff like this, they get really messy after you move them around a lot.

tyrelhill fucked around with this message at 08:52 on Dec 5, 2007

Sex Bumbo
Aug 14, 2004

PerOlus posted:

Anyone have experience, comments, about XNA? I'm interested in using it. Do I have to use C# for it?

I've used XNA Game Studio a lot, and I love it. It's not a game engine if that's what you're looking for. You can get a 3D model up a few minutes, but it doesn't provide any game logic, which is nice because it's meant to be a platform and there's no 'best' game engine.

C# is a much more enjoyable experience than using C++. C# has tons of really simple advantages like intellisense working, the debugger working better, edit and continue working, much much faster build times, and that's not even counting numerous language features that make it more enjoyable.

You can use any 2005 variant of Visual Studio with the 2.0 beta too. There are some fairly serious bugs in the beta right now but nothing that prevents general usage. Also, the final version should be coming out soon with the big bug fixes in most likely since they've been closed on their bug submission site (connect.microsoft.com). No 2008 support sadly.

Really, the biggest issues with XNA Game Studio are mostly related to difficulties if you ever try releasing a commercial game, especially on the Xbox 360 (which will be completely impossible for some time).

I definately recommend it over everything else. Questions get answered extremely quickly on their support forums too.

Sex Bumbo fucked around with this message at 10:31 on Dec 5, 2007

Ferg
May 6, 2007

Lipstick Apathy

Stanlo posted:

I've used XNA Game Studio a lot, and I love it. It's not a game engine if that's what you're looking for. You can get a 3D model up a few minutes, but it doesn't provide any game logic, which is nice because it's meant to be a platform and there's no 'best' game engine.
Then what would you describe it as? A 3D engine?

Adbot
ADBOT LOVES YOU

haveblue
Aug 15, 2005



Toilet Rascal

Twiggy794 posted:

Then what would you describe it as? A 3D engine?

It's a system architecture focused on game development. It's more comparable to something like SDL rather than a game engine.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply