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 - kojack

Pages: 1 ... 10 11 [12] 13 14 ... 22
166
Graphics / Re: TextureRect sometimes rendered wrong
« on: June 06, 2022, 10:46:27 pm »
One method I've seen done is add padding around each sprite in a sprite sheet with a repeat of the edge pixels, so if they bleed over they have the same colour (or transparency) as what they bleed onto, so there's no effect.

Other engines (like Unity) can have this happen too.
https://answers.unity.com/questions/1566057/unity-2d-sprite-bleeding-glitch.html
https://stackoverflow.com/questions/15023158/how-to-prevent-pixel-bleeding-from-rendering-sprite-sheet-generated-with-zwoptex

Or a custom pixel shader should be able to force sampling from the texture rectangle.

167
Graphics / Re: TextureRect sometimes rendered wrong
« on: June 06, 2022, 04:37:42 pm »
This can happen if your sprite isn't placed at integer pixel coordinates, pixels outside of the texture rectangle can bleed over due to floating point errors.

There's other fun that can happen such as mip maps for non-power of 2 texture regions, but that's probably not happening here (you'd need to shrink the sprite for it to happen).



168
Graphics / Re: Rotating and moving a simple `CircleShape` object
« on: May 30, 2022, 06:37:19 pm »
//shape.setOrigin(x - radius / 2.0f, y - radius / 2.0f);

The origin is local to the shape, a value of 0,0 places the pivot/origin at the top left corner. So you don't want the circle's position in there.
Try this:
shape.setOrigin(radius,radius);

169
Window / Re: Do draw calls with same Texture affect performance?
« on: May 30, 2022, 03:50:47 pm »
From what I can see in the source, draw uses a state cache. If the texture you tell it to draw with is the same as the last draw call, it doesn't rebind the texture.

Although one condition is that FBO textures will always be rebound, and I think render textures are made as FBOs (but I'm not 100% sure), so it might not help your situation.

170
General / Re: Can this collision code be simplified?
« on: May 27, 2022, 01:47:40 pm »
One way to go would be to use an existing solution like Box2D. It will handle all of that for you. It works extremely well with SFML.
It takes a little bit more code to set up, but the entire general collision section would turn into 1 line (calling the box2d world's step function).

171
Graphics / Re: Flip Sprite setScale problem
« on: May 20, 2022, 11:12:50 am »
You could read back the current values and use them:
To make it flipped (regardless of whether it's already flipped or not):
sprite->setScale(-fabs(sprite->getScale().x), sprite->getScale().y);

To make it not flipped (also regardless of current flip):
sprite->setScale(fabs(sprite->getScale().x), sprite->getScale().y);

fabs is the floating point absolute, it makes numbers positive. So -fabs makes numbers negative.


172
General / Re: Random crashes while loading textures
« on: May 13, 2022, 04:47:54 pm »
Hmm, this is a very odd issue.

It seems opengl itself is dying (returning version 0 instead of version 4) after being called a few times.

173
General / Re: Random crashes while loading textures
« on: May 13, 2022, 02:00:15 pm »
A little progress: I've so far tracked it down to having the Linker setting: Link Library Dependencies enabled.
With it off, works fine. With it on, crashes.

Good texture setup pass:
   glGetIntegervFunc(GL_MAJOR_VERSION, &majorVersion) is 4.
   glGetError is valid
   glGetIntegerv is valid
   glGetString is valid
   glGetStringi is valid.

Crashing texture setup pass:
   glGetIntegervFunc(GL_MAJOR_VERSION, &majorVersion) is 0.
   glGetError is valid
   glGetIntegerv is valid
   glGetString is valid
   glGetStringi is null.  (makes sense, glGetStringi is for GL 3+. But the major version is 0)

174
General / Re: Random crashes while loading textures
« on: May 13, 2022, 01:23:46 pm »
Fascinating. I used Mbee's project file (but same source files, same sfml files) and I get the crash!
It must be some project file setting.
The detective work begins...

175
General / Re: Random crashes while loading textures
« on: May 13, 2022, 05:38:32 am »
How recently did you grab the repo? I'm using the latest master branch (pulled today) with VS2022, debug, 64bit and I'm not seeing the crash. I even expanded the texture list file to have over 500 entries.

Although I didn't use the supplied project file directly, just the code. Maybe there's a project setting that's different...

176
General / Re: Random crashes while loading textures
« on: May 11, 2022, 01:23:55 pm »
What graphics hardware do you have? It seems the crash is in code that checks for opengl extensions, so that might be a driver missing or low hardware.

177
Graphics / Re: Constructor problem, need help
« on: May 10, 2022, 02:07:45 am »
btnInit isn't making three buttons, it's setting the position of a single sprite 3 times in a row. The first 2 setPosition calls are overwritten.

Same with btnDraw, it's drawing the same sprite 3 times on top of itself.

You'll either need to make 3 sprites, or store the values passed to btnInit and do a setPosition before each draw.

178
General / Re: private member that is a texture isn't loading properly
« on: April 29, 2022, 10:24:55 am »
It looks like the pointers (tNext, tPrev and the 8 surrounding tiles) aren't being initialised. Uninitialised pointers have random values (whatever was in memory already) or special debug sequences (like 0xcccccccccccccccc), that could cause it to think there are tiles when there really isn't.

179
General / Re: private member that is a texture isn't loading properly
« on: April 28, 2022, 10:20:56 am »
On it's own that looks fine, assuming the working directory is correct when it's run.
But how are tiles being allocated and put in (what looks like) the linked list? Could you show an example of making a couple of tiles.

One semi-unrelated tip: textures only need to be loaded once for a whole program, you can reuse a texture for any number of sprites. If you have a texture in every tile, that texture has to be loaded and stored many times instead of just once.

180
Graphics / Re: Drawing text on an image and saving the image
« on: April 27, 2022, 10:31:53 am »
The Text object has a setPosition() that works just like for sprites. It controls where the top left corner of the text will be placed (default is 0,0).

Pages: 1 ... 10 11 [12] 13 14 ... 22