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

Author Topic: Strange lines between tiles when rendered  (Read 3380 times)

0 Members and 1 Guest are viewing this topic.

chbrules

  • Newbie
  • *
  • Posts: 16
    • AOL Instant Messenger - Conrad1986
    • View Profile
Strange lines between tiles when rendered
« on: August 07, 2010, 02:20:54 pm »
So here's the visual problem I am having (lines between tiles):




And here's my map code:

Code: [Select]
#include "cMap.h"

cMap::cMap(RenderWindow& A){
App = &A;
mapDims.x = 32;
mapDims.y = 24;

loadTiles();
genMap();
}


cMap::~cMap(){
delete [] tiles;
delete [] imgs;

for(uint16 y=0; y < mapDims.y; y++)
delete [] map[y];
delete [] map;
}


//Load tile images
void cMap::loadTiles(){
imgs = new Image[1];
tiles = new Sprite[1];

//Load tiles
if(imgs[0].LoadFromFile("textures\\grass.png")){
cout << "*Loaded asset: \"grass.png\" (" << imgs[0].GetWidth() << " x " << imgs[0].GetHeight() << ")" << endl;

imgs[0].CreateMaskFromColor(Color(255,0,255,255));
tiles[0].SetImage(imgs[0]);
}else
cout << "*Could not load: \"grass.png\"" << endl;
}


//Generate temp map for dev purposes
void cMap::genMap(){
map = new mTile*[mapDims.y];

for(uint16 y=0; y < mapDims.y; y++){
map[y] = new mTile[mapDims.x];

//Fill data
for(uint16 x=0; x < mapDims.x; x++){
map[y][x].id = 0;
map[y][x].clip = 0;
}
}
}



//Draw the map
void cMap::draw(){
uint16 ymax = (App->GetHeight() / _UNIT_), xmax = (App->GetWidth() / _UNIT_);

for(uint16 y=0; y < ymax; y++){
for(uint16 x=0; x < xmax; x++){
tiles[map[y][x].id].SetPosition((float)(x * _UNIT_), (float)(y * _UNIT_));

App->Draw(tiles[map[y][x].id]);
}
}
}



I'm thinking SFML is setting OGL up to do something strange while rendering things. Unless I'm dumb or just don't understand something here, I checked my math to be correct and believe SFML is doing something to cause this.

Also, I setup my window as such:

Code: [Select]
App.Create(VideoMode(1024,768,32), "Neptune Alpha", Style::Close);

Any info on this? Thanks!  :D

chbrules

  • Newbie
  • *
  • Posts: 16
    • AOL Instant Messenger - Conrad1986
    • View Profile
Strange lines between tiles when rendered
« Reply #1 on: August 07, 2010, 02:49:30 pm »
Ughhhh

After a lot of research I figured it was OGL smoothing. Why is this on by default? Is there any way to globally turn it off?

4ian

  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Game Develop website
Strange lines between tiles when rendered
« Reply #2 on: August 07, 2010, 03:35:01 pm »
sf::Image::SetSmooth, but you'll have to do this on each sf::Image.

Luinechor

  • Guest
Strange lines between tiles when rendered
« Reply #3 on: August 07, 2010, 04:17:02 pm »
Well, he could use the SFML src, change it and recompile it. However, if you want SetSmooth to be true, you will have to set it manually after doing so.

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
Strange lines between tiles when rendered
« Reply #4 on: August 07, 2010, 04:41:58 pm »
You can try to create a custom class inheriting sf::Drawable, and in the Render function, after the renderer->SetTexture(), you add
Code: [Select]
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );


It will ensure the extremities of your drawable won't be transparent.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Strange lines between tiles when rendered
« Reply #5 on: August 07, 2010, 06:11:08 pm »
It's easier to call image.Bind() and do it once, there's no need to create a drawable class ;)

And he's probably not using SFML 2 (there's no renderer in SFML 1).

Anyway, just calling image.SetSmooth(false) will be much easier.
Laurent Gomila - SFML developer

 

anything