Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Alternative Civs > Stella Polaris > OpenGL tips
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!

bottom of page
  
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
Blake is offline Blake
King
Brainfallocatione
Oct 2000
time: 17:24
  Old Post 20-12-2002 01:37
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
OpenGL tips Support Apolyton, buy Alpha Centauri

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

Blake is offline Blake
King
Brainfallocatione
Oct 2000
time: 17:24
  Old Post 20-12-2002 08:14
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Support Apolyton

hehe, I really should attach the darn file.

Zipped so the board will accept it.

Note the header is distribued under the GNU LGPL, meaning you can do pretty much anything you want with it except claim you wrote it

Attachment: gl.zip
This has been downloaded 2 time(s).

Vultur is offline Vultur
Warlord
Milan
Jun 2000
time: 06:24
  Old Post 20-12-2002 17:08
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Avatar Enlargement: We've got the solution

I'm looking a way to convert a SDL_Surface into an OpenGL texture: this will allow to use .PNG file format. Is it possible? Thank you for help.

Kurilka is offline Kurilka
Chieftain
Arkhangelsk, by the White Sea
Dec 2002
time: 08:24
  Old Post 20-12-2002 17:47 Visit Kurilka's homepage!
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

Why do you need it at all?
SDL in conjunction with OpenGL is used not for graphics
but for program initialization, threads, timers etc.

Blake is offline Blake
King
Brainfallocatione
Oct 2000
time: 17:24
  Old Post 21-12-2002 01:38
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Support Apolyton, buy Civilization 2

Well, there are two ways:
Get an image loader designed to load OpenGL textures. (this really does seem like the better way...)

Take a SDL_Surface, and have some code to turn it into an OpenGL texture (this involves flipping the image, at the minimum). To find out how to do this, try looking at some of the tutorials - chances are the SDL versions will do something simialler.

DJ is offline DJ
Warlord

Jul 1999
time: 05:24
  Old Post 21-12-2002 04:30
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Full PM-box? Change here!

http://www.wotsit.org/

DJ is offline DJ
Warlord

Jul 1999
time: 05:24
  Old Post 21-12-2002 04:31
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Support Apolyton, buy Civilization 2

File Format Collection

Kurilka is offline Kurilka
Chieftain
Arkhangelsk, by the White Sea
Dec 2002
time: 08:24
  Old Post 21-12-2002 15:35 Visit Kurilka's homepage!
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Got spare money?

2 DJ - Was it a joke?
I think that it's not yet decided what graphic libraries we will use. SDL+OpenGL are too low-level. And if we use something like OSG then there could be image loaders already.

Vultur is offline Vultur
Warlord
Milan
Jun 2000
time: 06:24
  Old Post 21-12-2002 15:41
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Inflate your Upload Space

I've found the code at GameDev, and I've modified it to load .PNG/.JPEG files.... Thanks for the help!

DJ is offline DJ
Warlord

Jul 1999
time: 05:24
  Old Post 21-12-2002 16:04
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Support Apolyton, buy Call to Power 2

quote:
Originally posted by Kurilka
2 DJ - Was it a joke?
I think that it's not yet decided what graphic libraries we will use. SDL+OpenGL are too low-level. And if we use something like OSG then there could be image loaders already.


No, it wasn't a joke. I've found that site very useful for figuring out loading .3ds models, .X models and jpeg files for Quake3 BSP levels, i just thought it could be helpful in helping you guys figure out loading PNG files.

Vultur is offline Vultur
Warlord
Milan
Jun 2000
time: 06:24
  Old Post 21-12-2002 20:44
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

ehm... DJ... I have the code to load .PNG file (SDL_image.h)
My problem is to discover how to handle a texture once opened...
There are no books on the arguments and tutorials I've found won't explain how-commands-work...
SDL is not exactly easy to learn... and OpenGL is less clear!
I suggest to reduce coders craziness to attach part of code to implement simple things like 2D texture loading/showing...
In the meanwhile I'll learn as much as I can from GameDev tutorials...

DJ is offline DJ
Warlord

Jul 1999
time: 05:24
  Old Post 21-12-2002 21:39
Edit/Delete Message Reply w/Quote
#12 Report this post to a moderator
Support Apolyton buy from Amazon

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 is offline DJ
Warlord

Jul 1999
time: 05:24
  Old Post 21-12-2002 21:54
Edit/Delete Message Reply w/Quote
#13 Report this post to a moderator
Get a bigger avatar today!

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

Kurilka is offline Kurilka
Chieftain
Arkhangelsk, by the White Sea
Dec 2002
time: 08:24
  Old Post 22-12-2002 16:08 Visit Kurilka's homepage!
Edit/Delete Message Reply w/Quote
#14 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

2 Vultur:
there are excellent OpenGL tutorials from NeHe (http://nehe.gamedev.net), and samples for SDL (could be found on SDL website)

targon is offline targon
Prince
Dolgoprudny, Moscow region
Nov 2002
time: 08:24
  Old Post 23-12-2002 20:13
Edit/Delete Message Reply w/Quote
#15 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

Mmm... DJ, are you sure GL_MODULATE is right stuff? You prefer bother your head with vertex colors, are't you? They're surely more easy to handle dynamicaly, but it seems to be excessive for this situation.

DJ is offline DJ
Warlord

Jul 1999
time: 05:24
  Old Post 23-12-2002 21:08
Edit/Delete Message Reply w/Quote
#16 Report this post to a moderator
Inflate your Upload Space

I get impressive results...

targon is offline targon
Prince
Dolgoprudny, Moscow region
Nov 2002
time: 08:24
  Old Post 25-12-2002 13:04
Edit/Delete Message Reply w/Quote
#17 Report this post to a moderator
Got spare money?

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?

Kurilka is offline Kurilka
Chieftain
Arkhangelsk, by the White Sea
Dec 2002
time: 08:24
  Old Post 25-12-2002 16:58 Visit Kurilka's homepage!
Edit/Delete Message Reply w/Quote
#18 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

Phiew...
I'm not
My thoughts:
- looks cool but:
- i don't think that we could implement (of course we can but the question of time...) such a complex engine, so if we want All these features then we should use somthing like OSG;
- what is HW T&L (i'm already getting mad from all these abbreviations)?
- do you think that all these features will be really used by designers?

targon is offline targon
Prince
Dolgoprudny, Moscow region
Nov 2002
time: 08:24
  Old Post 25-12-2002 17:31
Edit/Delete Message Reply w/Quote
#19 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

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?).

Kurilka is offline Kurilka
Chieftain
Arkhangelsk, by the White Sea
Dec 2002
time: 08:24
  Old Post 25-12-2002 18:08 Visit Kurilka's homepage!
Edit/Delete Message Reply w/Quote
#20 Report this post to a moderator
Increase Your PM Length

What is HW T&L?

targon is offline targon
Prince
Dolgoprudny, Moscow region
Nov 2002
time: 08:24
  Old Post 25-12-2002 18:16
Edit/Delete Message Reply w/Quote
#21 Report this post to a moderator
Support Apolyton or Terrorists Win

HardWare Texturing and Lighting (though someone may call it HardWare Transformation and Lighting). This is that all modern 3D cards do unless you disturb them with obsolete rendering pipeline (ab)use (like glBegin/glEnd).

DJ is offline DJ
Warlord

Jul 1999
time: 05:24
  Old Post 25-12-2002 18:26
Edit/Delete Message Reply w/Quote
#22 Report this post to a moderator
Inflate your Upload Space

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 is offline targon
Prince
Dolgoprudny, Moscow region
Nov 2002
time: 08:24
  Old Post 25-12-2002 18:54
Edit/Delete Message Reply w/Quote
#23 Report this post to a moderator
Lose 30 kilos (of popups)

With arrays, 3D card (and its drivers ) may actualy upload vertex data into on-board memory (if you utilize it in clever way) and never bother about it (at lest on per-frame basis).
Vertex/fragment shaders are cool because all neat effects like refraction, grass, skinning, motion blur etc. may be disjointed from the mesh, so 3D card may stay in its rendering loop uninterupted. This is exactly the way of work all modern 3D chips were designed for. Vertex arrays (AKA "vertex buffers" in evil place far from here) plus vertex/fragment programs.

Blake is offline Blake
King
Brainfallocatione
Oct 2000
time: 17:24
  Old Post 26-12-2002 05:22
Edit/Delete Message Reply w/Quote
#24 Report this post to a moderator
Avatar Enlargement: We've got the solution

Well as far as I know, there is no-one on the team who has the skills to write such an engine. As such we are probably reliant on the work of other opensource projects for a decent 3D engine. Openscenegraph looks promising for sure.

The best strategy is probably to have it so the rendering can easily be changed, so initially we can use a quick 'n nasty 2D interface for testing stuff (prehaps written in straight SDL) and later change to a full featured 3D engine.

DJ is offline DJ
Warlord

Jul 1999
time: 05:24
  Old Post 26-12-2002 06:15
Edit/Delete Message Reply w/Quote
#25 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

Yea, all models in my engine (.3ds and .md3 models), are rendered with Vertex Arrays to provide the best performance. Unfortunantely my terrain isn't optimized yet, but it runs fine and i'm not sure if i'm gonna deal with it....

Vultur is offline Vultur
Warlord
Milan
Jun 2000
time: 06:24
  Old Post 27-12-2002 23:05
Edit/Delete Message Reply w/Quote
#26 Report this post to a moderator
Help yourself to an AD-FREE life

quote:
Originally posted by Blake
The best strategy is probably to have it so the rendering can easily be changed, so initially we can use a quick 'n nasty 2D interface for testing stuff (prehaps written in straight SDL) and later change to a full featured 3D engine.

I've tried to inizialize the screen surface with SDL_OPENGL flag, and won't accept normal blitting with SDL
The things don't fit together...

Blake is offline Blake
King
Brainfallocatione
Oct 2000
time: 17:24
  Old Post 28-12-2002 01:20
Edit/Delete Message Reply w/Quote
#27 Report this post to a moderator
Got spare money?

Yes... it says that in the documentation.

Try, instead of "SDL_OPENGL" use "SDL_OPENGLBLIT"


However the best way to do blits for small sprites (faster and better flexibility with stuff like coloring and rotation) is to convert the surface to a OpenGL texture then use it as a texture on a GL Quad.

Vultur is offline Vultur
Warlord
Milan
Jun 2000
time: 06:24
  Old Post 28-12-2002 16:09
Edit/Delete Message Reply w/Quote
#28 Report this post to a moderator
Support Apolyton buy from Amazon

SDL_OPENGLBLIT works fine...
But I've the impression that the program cannot blit together both a SDL surface, both a GL triangle...
Maybe I've forgot to write something, but I don't know what...
I think there is a simplier way...
Thanks for the suggestions

targon is offline targon
Prince
Dolgoprudny, Moscow region
Nov 2002
time: 08:24
  Old Post 30-12-2002 16:41
Edit/Delete Message Reply w/Quote
#29 Report this post to a moderator
Support Apolyton buy from Amazon

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.

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:24.
Apolyton Time is 00:24.
    top of page
Rate This Thread:
Forum Jump:
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
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0526 seconds (92.31% PHP - 7.69% MySQL) with 30 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net