 |
|  |
 |
|
Blake
|
 |
Brainfallocatione
Oct 2000 time: 17:24
|
|
Compiling:
To make SDL+GL code compile under Dev-C++, use the following project options:
Compiler Options:
code: -I"\SDL" -Dmain=SDL_main
Linker Options:
code: -lmingw32 -lSDLmain -lSDL -liberty -lopengl32 -lglu32
If the code is advertised as "SDL/Linux" then it wont compile, it will bring up some weird error. You can either #include "windows.h" *before* including the GL headers, or you can do it how OpenSceneGraph does it, I'll attach the GL header to this post, you should be able to include this instead of "GL/GL.h" and it will do all the vodoo required to have GL.h included and working on all platforms
Note also that under Linux, a SDL app will compile with a main defined as either
int main(void) or int main(int argc, char **argv)
However, under windows, main MUST be
int main(int argc, char **argv)
Tutorials:
The two best resources are the NeHe OpenGL tutorials at www.gamdev.net and the OpenGL tutorials at www.gametutorials.com
NeHe
Gametutorials
Note that you WILL get compile errors for the SDL code for these tutorials, however 95% of the time the only required modifications will be the two things I pointed out above.
Last edited by Blake on 20-12-2002 at 04:12
|
|
|  |
 |
|  |
 |
|
DJ
|
|
Ok, well I'm not sure how SDL does there stuff, but if you have a texture loaded then all you should have to do is bind it.
glBindTexture(GL_TEXTURE_2D,(unsigned int)texID)
note that the second argument is a pointer, so if you don't have a pointer variable just assign the reference '&' memory address of that variable.
Also, if you haven't done this in your initialization do this before binding the texture
glEnable(GL_TEXTURE_2D);
This will allow for you to bind the textures, when you want to stop binding a certain texture use:
glDisable(GL_TEXTURE_2D);
One more thing, all texture must have attributes (size) of powers of 2. 
Last edited by DJ on 21-12-2002 at 21:57
|
|
|  |
 |
|
DJ
|
|
Ok, that was just the beginning basics, I'm posting this in a new post hoping this can clear what's really needed.
When you get a texture you should have read or extracted the bytes for it somehow and stored it in your byte pointer: unsigned char* imageData;
Ok, so now that you have that, through your library you can set it up for use in your OpenGL program like this:
code:
glGenTextures(1,&texID);
plBindTexture(GL_TEXTURE_2D,texID);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)minFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLint)maxFilter);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
int mode = GL_RGB;
if(ci.depth==4) mode = GL_RGBA;
gluBuild2DMipmaps(GL_TEXTURE_2D,mode ,ci.width,ci.height,mode ,GL_UNSIGNED_BYTE,ci.imageData);
for the minFilter and maxFilter variables you can use GL_LINEAR or GL_NEAREST... mix them up and use GL_LINEAR_MIPMAP_NEAREST, this is just to get the best results in rendering the texture. Now that this is done you can use glEnable(GL_TEXTURE_2D) and glBindTexture(GL_TEXTURE_2D,&texID) for your use in your program.
Last edited by DJ on 21-12-2002 at 22:04
|
|
|  |
 |
|
targon
|
|
Dolgoprudny, Moscow region
Nov 2002 time: 08:24
|
|
OK, if you guys really want to bother with own 3D engine I may show you list of things I'm as artist expecting from you code to do (at least, eventualy, but not _virtualy_, please!):
1) Portability.
2) Really good FPS for complex scenes.
3) HW T&L native support (in fact, it's second item), so forget about glBegin/glEnd and display lists, stick to arrays.
4) For even more complex scenes (I've seen "3000 units" somewhere), impositors or other rendering caching techniques.
5) Multitexturing support, including, but not limited to
6) Environmental cubic mapping,
7) Bump mapping,
8) Vertex/fragment shader support (for platforms really supporting it, that means any modern 3D accelerator).
9) Particle systems, with some basic "particle physics" like wind etc.
10) Some simple animation support. No need to bones, IK and other advanced features, but feel free to add some anim sequence/script/whatever you mean.
Are you ready?
|
|
|  |
 |
|
targon
|
|
Dolgoprudny, Moscow region
Nov 2002 time: 08:24
|
|
This features are't something pure eye-candy. Items 1..4 are vital for 3D strategy game (large landscapes/space scenes, lots of units etc.). 5..7 are in fact somewhat obsolete variants of 8th, but the later still is't widespread (legacy 3D cards). All bunch 5..8 is for any not-ordinary looking surface any nowdays gamer expects, why StP must be worse than commercial ones? 9th is obvious choise for dust/smoke/explosions/stars etc. 10th is nessesary even for simple mechanical units unless you want table toke look for them.
No way, you need't all these once from the beginning; but this stuff will surely very helpful in future (do you expect this game has some future?).
|
|
|  |
 |
|
DJ
|
|
you can still get good results if you use glBegin/glEnd, if you cull right..., although my engine does ultilize vertex arrays because that's the best way to go i think :-D
Here's the difference:
If i render, say 5,000 verts with glBegin/glEnd, on my GeForce 2 | 1.2 MHz Athlon my computer will begin slowing down at a VERY noticable speed.
If i render about 60,000 verts with vertex arrays I experience no lag at all... Big difference eh?
I tested this idea actually on my 3D Terrain Engine when implementing quadtrees.
|
|
|  |
 |
|
targon
|
|
Dolgoprudny, Moscow region
Nov 2002 time: 08:24
|
|
quote: Originally posted by Blake
Well as far as I know, there is no-one on the team who has the skills to write such an engine. |
Right. Common horror story is the Boson.
|
|
|  |
All times are GMT. The time now is 05:24. Apolyton Time is 00:24. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|