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.


Topics - Notion

Pages: [1]
1
Graphics / Large tile maps with many non-tile-entities, Best Practice?
« on: April 21, 2021, 02:48:52 pm »
Hey everyone,

this is maybe rather a design problem than a "technical" problem, yet still, I think I lack some technical knowledge about how to deal with it:

Imagine a 200*200 tilemap with 100px*100px tiles. We can do that, probably in a single draw call (even though splitting it up might be helpful?). But that part is not the problem. Now assume that - in the worst case - each tile has an Entity occupying it with its own sprite (or maybe 2-3 Sprites, if they have additional icons displaying their status). Thats 200*200*2 = 80.000 Render Calls. That's a lot. Probably not gonna happen.

So, how to solve? Do I only use a sprite array of screenSize/100 sprites and panning over the map reloads the sprites of different entities into the array? So basically I dont move the view over the tiles, but instead move the index or range of entities for which the sprites should be shown right now.
Or should I just make it 2 giga-large vertex arrays, one for the map and one for all the entity sprites? They might be overlapping though, there's no useful way to quickly generate overlapping textures for tile maps, right?

Also: Given that there could be about 1000 different entity sprites each 80px by 150px, there's not way but to atlas them, is there?

2
Graphics / Using SFML should I care about texture binds?
« on: April 21, 2021, 02:38:40 pm »
Hey everyone,

there's this one thing I never really understood: In how far do I need to manage texture binds? I'm using SFML out of the box, mostly just window, sprite and texture classes (sometimes VertexArrays).

Are all textures bound that are loaded as texture? Or only those bound to a sprite? Or only those which have been drawn at least once? What if I bind 30 gb worth of texture data? Are they loaded and bound one after the other? Will it just crash? Will it miss rendercalls? Render only the textures that can be stored? Will it simply take 3 seconds to render a single frame?
Should I unload every texture that is not needed asap?
Should I build texture atlases even though I dont use tilesets?
Are there texture binds happening for off screen sprites? What for partial offscreen Sprites? (Imagine a 20.000*20.000 image, will it actually bind and render the whole thing or only the pixels inside the view?)

3
DotNet / Any newline characters for text class implemented right now?
« on: April 05, 2021, 12:04:25 pm »
Hey everyone,

for C++ the /n character inserts a line break into a text element. When I try it in C# its a "/n" in plain text and doesnt change the format. Any way to line break by inserting a character or do I have to use a second text object?

4
Hey everyone,

not sure if it's a help request, it's more like a "what do you think about" kind of thingy, so I hope the general category fits.

I try to develop for lower end machines and I use C#. Hate me, hunt me, but I got my reasons :) Most of my game ideas include about 5-15 small icons and bars and such for buffs, resistances etc of RPG like creatures or player characters. Given 10-30 units on screen at once that's kind of too many render calls and its a mess to manage all the offsets.

Many games do similar things though - how? What does best practice look like in those cases? Is each unit a vertexarray with the upper quads of the array being reserved for icons? Categorizing different vertexarray quads for different uses seems to be tedious as well. Is it just me being lazy and more of the RenPy/RPGMaker-Guy?

5
General / Is fading a single tile of a tilemap in and out efficient?
« on: November 09, 2020, 11:40:49 am »
Hey everyone,

this is kind of a broad question with probably no "100% accurate" way to answer "the right way". Yet I struggle a lot to find a solution for this problem:

I got a tilemap grid thingy. My game world is about 200*200 Tiles of Size 120*120 big. The efficient way to render those is by putting the relevant tiles in proximity to the camera in a vertex array as can be seen in the tutorial.
Yet I need things to move on top of those tiles. And while they are on top, they should keep fading in and out, and the tile should do the same as well, just "anti-synchronic" (sorry, I lack the english words to be more precise here). So while the Actor on Top is totally opaque, the tile is totally transparent, while the thing on top is transparent, the tile is opaque. Both alphas are changed with a sine function with an x-Offset of +1, their sum is always 1.

The actual problem: In order for this to work I need to check all the occupied tiles, change their color and therefore have to re-calculate the whole vertex array, right? This is probably less efficient, than going back to a sprite for each tile?
Sprite for each tile still seems really unpleasant performance wise. Can anyone give me advice on how to solve this issue? I would be really grateful!

6
Graphics / Setting Text origin driving me insane
« on: August 04, 2018, 07:36:21 pm »
Hey folks,

trying to set the origin of a text to its center in order to place it in the middle of a circle. Text tends to be quite off to the bottom right.

Read the thread https://en.sfml-dev.org/forums/index.php?topic=19447.0 , but that didn't work for me either.

Here's the code:

Code: [Select]
                //Some Circle Shape
lifeBackground = new sf::CircleShape();

lifeBackground->setFillColor(sf::Color::Red);
lifeBackground->setOutlineThickness(4);
lifeBackground->setOutlineColor(sf::Color::Black);
lifeBackground->setRadius(20);

lifeBackground->setOrigin(lifeBackground->getLocalBounds().width/2, lifeBackground->getLocalBounds().height / 2);

                //Text should go into center of circle shape
lifelabel = new sf::Text();
lifelabel->setFont(font);
lifelabel->setCharacterSize(25);
lifelabel->setOutlineThickness(3);
lifelabel->setString(std::to_string(life));
lifelabel->setFillColor(sf::Color::Yellow);
lifelabel->setOutlineColor(sf::Color::Black);

sf::FloatRect numRect = lifelabel->getLocalBounds();
sf::Vector2f numRectCenter(numRect.width / 2.0 - numRect.left, numRect.height / 2.0 + numRect.top);
lifelabel->setOrigin(numRectCenter);


See the RED circle in the attachment. The Text within the BLUE one is centered by hand and therefore not resolution-independent.

Would be glad for any help!

7
Graphics / Does sprite.setColor() use additional shaders internally?
« on: July 08, 2017, 01:04:17 pm »
This is a question of efficiency I guess. If I set the color of a single sprite to a new Color, does the rendering require the GPU to switch shaders? Does every colored object has its own shader? Would it be of any use, to pool Objects colored in the same color regarding their draw-calls?

Thanks in advance!

8
Hello everyone!

I know, that SFML is supposed to be a 2d engine, and basically I am totally fine with that. In fact: I really love how simplistic and intuitive SFML works: I love the input handling, the really basic Text and Sprite Classes and so on. But since I suck at 2d Animations, I really need my game to be 3d, in order to become finished any time in the future.

I tried UE, Irrlicht, Unity, Esenthel, ... and all of those are really annoying for the fact that they force you to include so ridiculously many crappy scene graphs and bloated input- and event handlers and whatsoever.

Therefore I am looking for an easy (by easy I mean: My math sucks) way, to get basic 3d models and skeletal animations up running in my SFML-Window, so that I can combine them with my selfmade SFML-UI-Components and my simplistic game loop and resource handling.

Does someone know of any library that fits those requirements?

9
Graphics / Texture Manager, how to make sprites take pointers?
« on: June 07, 2017, 08:55:24 pm »
Hey everyone,

What I try to do:
TextureManager.h holds a static pointer to a texture. I want my Sprites, which are basically stored in the class Pic, which are stored in the class Node, which are stored in a vector<Node> to use the texture, to which the texture pointer of my TextureManager points to. For some mysterious reasons its not working. Here are the relevant parts of the code:

//TEXTUREMANAGER.H
#include <SFML/Graphics.hpp>

//Textures
static sf::Texture* nodeTexture;

static void loadTextureSet(int i) {  //called from main method, works properly, can check the correct size after loading
        nodeTexture = new sf::Texture();
        nodeTexture->loadFromFile("Graphics/emptyNode.png");
}

//PIC.H
#pragma once
#include <SFML/Graphics.hpp>



class Pic
{
public:
        Pic( int pathID );
        ~Pic();

        sf::Texture* texture;
        sf::Sprite sprite;

};

//PIC.CPP
#include "Pic.h"
#include <SFML/Graphics.hpp>
#include "TextureManager.h"
Pic::Pic(int pathID)
{
       
        switch (pathID) {
       
        case 0:

                texture = nodeTexture;
                break;
        }
//can successfully call the size of texture until here
        sprite.setTexture(*(texture)); //<- ERROR HERE
//error will occur at the line above this one, cant give out any std::cout here.
}

Is there any way to fix this in an easy way? I know I could use some additional classes and something like the resource manager tutorial, but i would like to keep it really simple and readable.
Error Code is: Exception thrown at 0x00007FFA4C7B6F80 (sfml-graphics-2.dll) in Shattering.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

10
Hey everyone,

I am new to all the networking thing. I  did read the SFML-Tutorial about networking and watched some youtube videos, but none did answer my question:

Basically what I try to achieve: I have a server-side game loop, thats running like 30 times a second. In each of those Loops I want to poll and evaluate _every_ udp message that was send to me since the last polling. Messages can (but dont have to) be send from different clients/ips.

So I started by copy pasting the tutorial code:

void networkReceive() {

   char data[100];
   std::size_t received;
   sf::IpAddress sender;

   unsigned short port;
   if (socket.receive(data, 100, received, sender, port) != sf::Socket::Done)
   {
   }

}

So here does some kind of polling happen, right? (I disabled blocking). Does that mean, that there is some kind of hardware/OS buffer, which stores the messages until I poll them? How long do they remain, if I dont poll them? And do they get deleted from there, once i polled them?
How can I find out, how many messages are left in the buffer? Is there some kind of getMessageNumber() function, so I can loop for each message in the buffer?
If there is no buffer, my whole idea about networking is wrong, isnt it? So I would need a thread that doesnt poll, but push the messages in an array? Is that kinda "best practice"?

I would really appreciate your help!

Pages: [1]