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

Pages: 1 [2]
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:

#include <SFML/Graphics.hpp>

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();

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

class Pic
        Pic( int pathID );

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


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

                texture = nodeTexture;
//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.

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 [2]