Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Messages - Cloppy

Pages: [1]
1
Graphics / Concatenate tiles to an image
« on: December 16, 2010, 04:42:43 pm »
I tried that in all ways, but doesn't work.

Code: [Select]
i_map.Copy(vTiles[0], draw_x, draw_y, sf::IntRect(0, 0, 64, 32), true);

I want to copy the vTiles[0] image to i_map multiple times, so draw_x and draw_y are the current position, where the tile belongs to the map.

But i_map doesn't change.

By the way, it would be cool, if someone could have a look at my algorithm to create the map and tell if it's okay or total bullcrap.

Code: [Select]
void CMapManager::LoadMap(sf::View* pView, float time)
{
int add_x, draw_x, draw_y;

sf::FloatRect offset = pView->GetRect();

int start_x = offset.Left / TILE_W + 1;
int start_y = offset.Top / TILE_H + 1;

int end_x = (WINDOW_W / TILE_W) + start_x + 2;
int end_y = (WINDOW_H / (TILE_H / 2)) + start_y + 4;

if(start_x < 1) {
start_x = 1;
pView->Move(SCROLLSPEED * time, 0);
}
if(start_y < 1) {
start_y = 1;
pView->Move(0, SCROLLSPEED * time);
}
if(end_x > MAP_W - 1) {
end_x = MAP_W - 1;
pView->Move(-SCROLLSPEED * time, 0);
}
if(end_y > MAP_H - 1) {
end_y = MAP_H - 1;
pView->Move(0, -SCROLLSPEED * time);
}

int posY = -(static_cast<int>(offset.Top) % 16) - 16;
for(int y = start_y; y < end_y; y++) {

int posX = -(static_cast<int>(offset.Left) % 64) - 64;

for(int x = start_x; x < end_x; x++) {
if(y % 2 == 0)
add_x = TILE_W / 2;
else
add_x = 0;

draw_x = posX + add_x + offset.Left;
draw_y = posY + offset.Top;

posX += 64;

i_map.Copy(vTiles[0], draw_x, draw_y, sf::IntRect(0, 0, 64, 32), true);
}

posY += 16;
}

s_Tile.SetImage(i_map);
}


But main problem is the Copy function. It just does not want to work. I'm doing something wrong, but have no idea where the issue hides.

2
Graphics / sf::Image::LoadFromFile() pretty slow...
« on: December 13, 2010, 10:29:41 pm »
yeah saw that right after I posted the code and fixed it.
Old and noncommented code sucks :D

Okay, now it's pretty fast. Still 0.2 seconds per load, but that's okay, i guess.

But another problem appears right now, the App.Draw() kills the Framerate.

Code: [Select]
App.Draw(vUnits[i].s_Unit);

vUnits is a vector of instances of the unitclass, and s_Unit is a sf::Sprite.
Takes 0.3 seconds per call, so I got a Framerate around 2.
Appeared just a few minutes ago, didn't change something.

I have no idea where the problem is.

Edit: Performance Analyzer says, that nvoglv32.dll takes 82% of the samplings.

Edit2: Okay, seems to be done. Just needed to update nVidia driver.

3
Graphics / sf::Image::LoadFromFile() pretty slow...
« on: December 13, 2010, 10:11:15 pm »
Yes right guess.

Code: [Select]
for(int i = 1; i <= numOfFrames; i++) {
temp = i;

sf::Image* tempImage = new sf::Image;

file.append(path);
file.append(itoa(temp, buffer, 10));
file.append(".png");

if(!tempImage->LoadFromFile(file))
printf("Unable to load Frame\n");

vReturn.push_back(*tempImage);

printf("%f\n", clock.GetElapsedTime());
clock.Reset();

file.clear();
}


Reserve()? Where's that? Couldn't find it in sf::Image

4
Graphics / sf::Image::LoadFromFile() pretty slow...
« on: December 13, 2010, 09:57:43 pm »
Hi,
I animated a little 2D character via .png files as frames.
So at start of program, I load all Images for the Unit Class (14 frames right now) and then i animate it per elapsed frame time, which is no problem.
But the fourteen LoadFromFile() calls take ages. Something about 8 seconds (summed up), which is (at least in my opinion) much time for this amount of images.

Is there any way to speed things up?

5
Graphics / Concatenate tiles to an image
« on: December 06, 2010, 05:24:53 pm »
Hey Guys,
I programmed a little IsoMap for learning reasons.
However, I used one tile (64*32px), calculated the position and called App.Draw() every time, so something about 470 times per frame, which is pretty unperformant. So i wanted to add all the tiles to a sf::Image and draw it once per frame.

But I could not find a function to add a sf::Image to another.
Can anyone help me or has anyone an idea how to do that?

Pages: [1]