SFML community forums
Help => General => Topic started by: chbrules on August 07, 2010, 02:20:54 pm
-
So here's the visual problem I am having (lines between tiles):
(http://o.uniteditc.com/pongles/neptune_glitch.jpg)
And here's my map code:
#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:
App.Create(VideoMode(1024,768,32), "Neptune Alpha", Style::Close);
Any info on this? Thanks! :D
-
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?
-
sf::Image::SetSmooth, but you'll have to do this on each sf::Image.
-
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.
-
You can try to create a custom class inheriting sf::Drawable, and in the Render function, after the renderer->SetTexture(), you add
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.
-
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.