541
Programming / Re: [Solved] Textures
« on: July 10, 2010, 08:02:58 pm »
I did that, because yeah... I completely forgot about that point, despite writing it in the top of the post
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
I couldn't make much sense of the code, but the result looks alright. If you're making a light calculation based on time, something you should remember:That's fine, I had accounted for that.
- Even though X-Com longitude goes from 0..360 (as opposed to -180..180), the GMT line is still at 0 longitude.
- Therefore, the "daylight" is centered at 0 at 12:00GMT, and the "nightlight" is centered at 0 at 0:00GMT (24-hour-format).
It's fine. As long as you keep working on the things I really don't feel like working on and would postpone for weeks (UGH GLOBES MATHS TRIGNOMETRIES THAT CAN WAIT), things get done faster.hehe, okay. I'll post a topic before I start looking at anything.
I'm sorry you still went to the trouble, but I said in my post that I had already took care of the marker slowdown and that wasn't what was slowing down textures. It's been with me from the beginning.Wasn't really much trouble, define a new function, copy and paste the code, make some minor alterations... Took longer to find out what the problem was than to fix it
Yeah, I must admit, when I saw all your surfaces being created as SDL_SWSURFACE, I was wondering if that was the bottleneck and switched them to SDL_HWSURFACE. It didn't work, so I moved on, where I noticed the SDL_RLEACCEL flag, I though, there's no RLE encoded images here, so I did a quick search and also saw several bug reports linked to it. That led me to remove it, and hey presto...Here you go... All working.Oh hey, thanks for that. Funny how things that are supposed to accelerate always end up backfiring.
The bottleneck was on SDL_SetColorKey() in your Surface constructor. I removed the SDL_RLEACCEL flag, and bingo...
if( !backFace )
texturedPolygon(_world->getSurface(), (Sint16*)&x, (Sint16*)&y, (*i)->getPoints(), _texture->getFrame((*i)->getTexture())->getSurface(), 0, 0);
SDL_BlitSurface( _world->getSurface(), ©Rct, this->getSurface(), ©Rct );
cout << "Globe:draw();";
to the top of the draw function, you'll find this is rendered every frame (which makes sense to animate the bases and craft). However, it also means you're rendering the globe using texturedPolygon 20+ times per frame, every frame. private:
Surface *_world;
void drawWorld();
void Globe::setTexture(SurfaceSet *texture)
{
_texture = texture;
_texture->setPalette( this->getPalette() );
draw();
}
texturedPolygon(getSurface(), (Sint16*)&x, (Sint16*)&y, (*i)->getPoints(), _texture->getFrame((*i)->getTexture())->getSurface(), 0, 0);
Enabling the poor texture rendering is an exercise in horror and shock and possibly frustration, but here goes:Actually, I did these instructions, it just left me with a blue globe (tho I might have forgot to change the surface lock). I'll have another look later
1. Go to the Globe::draw function in Globe.cpp.
2. Comment out the filledPolygonColor(...) line and uncomment the texturedPolygon(...) line.
(if you're having fun you can also uncomment the polygonColor(...) line instead and see the globe in wireframe-o-vision!)
This would be enough, but because of how SDL works, surfaces need to be locked for pixel-level access and unlocked for blitting. So you also need to:
3. Comment out the lock() and unlock() lines so the blitting works.
4. Comment out the whole "base markers" drawing since anything with getPixel/setPixel will probably crash now since the surface is unlocked.
5. Comment out everything in Globe::blit except the Surface::blit(...) line so it doesn't redraw itself every few ticks (I'll optimize this eventually).
Any attempt at rotation will take seconds and the textures don't even match the terrain and there's gaps in the polygons and oh gawd it's just so horrible that I just commented it out to never see the light of day while I cried in a corner for weeks and weeks (seriously though with the huge performance problem there's no point in fixing the rest so I just moved on).Hmmm, I might take a look at this, see if I can help out any, as I have a cunning plan how to perform this operation quickly...
Yeah palette wizardry is very common in X-Com, and since colors go from light to dark in the palette, you would just shift the palette a bit to the left for each polygon to make it darker. In OpenXcom you can achieve a similar effect with the Surface::offset function.Thanks for the heads up on that.
Yeah that would be the more sensible option today, but those were different times with only 32K of memory that you couldn't afford to waste or something who knows. Plus it makes the day/night effect look smoother over the ocean.Oh I knew why they didn't do it UFO, but I'm saying for OpenXcom you should. That said, TFTD had polygons for the seas, although I don't think they had as many for the land.
Well the real globe has actual textures (I haven't applied them because they cause terrible performance for some mysterious reason)Yeah, totally forgot about them. In fact, I've been having a bit of a look at textures tonight, I can't seem to render them. They either don't draw anything, or crashes in the Surface::getPixel with _surface->pixels = 0x00000000. Odd.
There are no ocean polygons (except in TFTD) stored in the game files. If I had to guess, the game might just generate a bunch of "ocean quads" itself that scroll horizontally along the flat map depending on the time, and get mapped as a "semi-sphere" on the globe. Or they use some wizardry involving circles or something, what do I know?If it were me, I'd probably create a hardcoded full sphere polygon list (landscape can draw over the top), but this way you could texture the sea too if you wanted.