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

Pages: [1]
1
General / Re: LNK2019 LNK1120 unresolved external symbol
« on: October 08, 2023, 01:38:51 pm »
Hi thanks! I discovered it yea, I had them commented out to test something and forgot to put them back in, then spent a long time trying to fix the wrong thing  :'(

2
General / delete
« on: October 08, 2023, 09:01:36 am »
I've setup my project in Visual Studio 2019 following this tutorial https://www.sfml-dev.org/tutorials/2.6/start-vc.php. When I ran the standard test code everything compiled, no link errors the window with the green circle rendered with no problems.

Since I've continued working on my project suddenly the link error returned and I do not understand why.

I've re-installed SFML multiple times, reconfigured the project following the guide step by step but have not managed to find my mistake.

Here is how I setup my project (I've attached images)

https://imgur.com/ilx633L

https://imgur.com/T5AIaXC

https://imgur.com/6BTUsrf

https://imgur.com/TPa7CWF

https://imgur.com/qJgvTrG

Additional dependencies : sfml-system-d.lib;sfml-window-d.lib;sfml-graphics-d.lib;sfml-network-d.lib;sfml-audio-d.lib;kernel32.lib

I have linked them via imgur.com since I have no idea how the img tag works

3
Network / LNK2019 unresolved external symbol [SOLVED]
« on: October 07, 2023, 02:44:09 pm »
I've been wanting to experiment with the SFML Network module. Unfortunately I'm running into some issues. I setup the Project with the Visual Studio guide on the SFML website. Everything worked fine, the green circle rendered and the standard "SFML works!" text got printed in the console. I followed the first networking guide step by step and ran into this issue.

Any help is greatly appreciated!

Both applications have the exact same issue so I believe that I setup something incorrectly. I checked if I had linked the .dll files and placed them in the correct directory and found no issues.

This is the Client application:
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <iostream>

int main()
{
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

                window.clear();
                window.draw(shape);
                window.display();
        }

        sf::UdpSocket socket;

        if (socket.bind(54000) != sf::Socket::Done)
        {
                std::cout << "Could not bind socket on port 54000";
        }

        char data[100] = "test";

        sf::IpAddress recipient = "127.0.0.1";
        unsigned short port = 54000;

        if (socket.send(data, 100, recipient, port) != sf::Socket::Done)
        {
                std::cout << "Failed to send data";
        }

        return 0;
}
 

This is the server application:
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <iostream>

int main()
{
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

                window.clear();
                window.draw(shape);
                window.display();
        }

        sf::UdpSocket socket;

        if (socket.bind(54000) != sf::Socket::Done)
        {
                std::cout << "Could not bind socket on port 54000!";
        }

        char data[100];
        std::size_t received;

        //UDP socket
        sf::IpAddress sender;
        unsigned short port;
        if (socket.receive(data, 100, received, sender, port) != sf::Socket::Done)
        {
                std::cout << "Failed to receive data!";
        }

        std::cout << "Received " << received << " bytes from " << sender << " on port " << port << std::endl;

        return 0;
}
 

EDIT: literally seconds after posting this I discovered that I had linked all .DLL files except the network one, oops!  ::)

4
Graphics / Vertex array with a texture is invisible
« on: November 28, 2022, 08:47:13 pm »
I want to draw a single vertex array with a texture. The texture is a 34x34 pixel .png file

I have the following function :

void drawMap(sf::RenderWindow& renderWindow)
{
        // create a quad
        sf::VertexArray quad(sf::Quads, 4);

        // define it as a square, located at (0, 0) and with size 34x34
        quad[0].position = sf::Vector2f(0.f, 0.f);
        quad[1].position = sf::Vector2f(34.f, 0.f);
        quad[2].position = sf::Vector2f(34.f, 34.f);
        quad[3].position = sf::Vector2f(0.f, 34.f);

        // define its texture area to be a 34x34 square starting at (0, 0)
        quad[0].position = sf::Vector2f(0.f, 0.f);
        quad[1].position = sf::Vector2f(34.f, 0.f);
        quad[2].position = sf::Vector2f(34.f, 34.f);
        quad[3].position = sf::Vector2f(0.f, 34.f);

        renderWindow.draw(quad, &grass_block);

}
 

This is how I initialize & load the texture


//initialize grassblock
sf::Texture grass_block;



        if (!grass_block.loadFromFile("grass_block.png"))
        {
                std::cout << "Could not load grass_block!";
        }
 

When my texture does not load, a white square gets drawn with right size & position. When my texture does load properly nothing shows up.

5
Graphics / Re: Need help with reducing draw calls to increase performance
« on: February 10, 2019, 12:39:26 pm »
Thanks for your reply! I found & read the tutorial and managed to draw my tile using a vertex array. But I still need to make a lot of draw calls to draw the entire tilemap.

for (int x = 0; x < 50; x++) {
                for (int y = 0; y < 50; y++) {
                        //Check if tile should be drawn
                        if (mapdata[x][y] == 1) {
                                sf::Texture tile;
                                if (!tile.loadFromFile("floor_tile_1.png"))
                                {
                                        std::cout << "Error could not load floor tile!";
                                }
                                //sf::Sprite tilesprite;
                                //tilesprite.setTexture(tile);
                                int px = (x - y) * 20;
                                int py = (x + y) * 20 / 2;
                                //tilesprite.setPosition(px + 800, py);
                                //window.draw(tilesprite);
                                //sf::VertexArray vertices;
                                //window.draw(vertices, &tile);
                                sf::VertexArray quad(sf::Quads, 4);

                                //this serves as some kind of wrapper for the texture?
                                //tiles; width:42px height: 21px;
                                //TODO draw with px & py coordinate input
                                quad[0].position = sf::Vector2f(10.f, 10.f); //top left
                                quad[1].position = sf::Vector2f(52.f, 10.f); //top right
                                quad[2].position = sf::Vector2f(52.f, 31.f); //bottom right
                                quad[3].position = sf::Vector2f(10.f, 31.f); //bottom left

                                //texture itself is 42x21px
                                quad[0].texCoords = sf::Vector2f(0.f, 0.f);
                                quad[1].texCoords = sf::Vector2f(42.f, 0.f);
                                quad[2].texCoords = sf::Vector2f(42.f, 21.f);
                                quad[3].texCoords = sf::Vector2f(0.f, 21.f);

                                window.draw(quad, &tile);
                        }
                }
        }

        window.display();
 

6
Graphics / Need help with reducing draw calls to increase performance
« on: February 09, 2019, 08:29:11 pm »
Hi!

Right now I'm rendering my tilemap like this :

for (int x = 0; x < 50; x++) {
      for (int y = 0; y < 50; y++) {
         if (mapdata
  • [y] == 1) {

            sf::Texture tile;
            if (!tile.loadFromFile("floor_tile_1.png"))
            {
               std::cout << "Error could not load floor tile!";
            }
            sf::Sprite tilesprite;
            tilesprite.setTexture(tile);
            int px = (x - y) * 20;
            int py = (x + y) * 20 / 2;
            tilesprite.setPosition(px + 800, py);
                                window.draw(tilesprite);
         }
      }
   }

   window.display();
}

I did some research and found out that you can use vertex arrays to reduce the draw calls. But I have no idea how I would implement a system like this.

7
General / Problem with y out put in console
« on: February 08, 2019, 03:12:25 pm »
Hi! If have a really weird problem
The y output is not a number but is :

Jeleki
eleki
leki
eki
ki
i










:AM:am:PM:pm
AM:am:PM:pm

Jeleki is the title of the window.

void display_game(sf::RenderWindow& window, float interpolation)
{
        window.clear();

        for (int x = 0; x < 50; x++) {
                for (int y = 0; y < 50; y++) {
                        //Check if tile should be drawn
                        if (mapdata[x][y] == 1) {
                                sf::Texture tile;
                                if (!tile.loadFromFile("floor_tile_1.png"))
                                {
                                        std::cout << "Error could not load floor tile!";
                                }
                                sf::Sprite tilesprite;
                                tilesprite.setTexture(tile);
                                //int px = x * 40 + 1;
                                //int py = y * 20 + 1;
                                int px = (x - y) * 20;
                                int py = (y - x) * 10;
                                tilesprite.setPosition(px + 500, py + 300);
                                window.draw(tilesprite);
                                //std::cout << "x:" + x << std::endl;
                                std::cout << "y:" + y << std::endl;
                        }
                }
        }

        window.display();
}

If anyone has a clue what is causing this please let me know.

8
General / SFML Window not responding & can't close it.
« on: January 27, 2019, 05:38:46 pm »
Hi guys, I'm just started working on a new project of mine. I just finished the game loop and everything seemed fine but the window rendered by SFML is not responding and when I hover my mouse over it the cursor will change to a loading symbol. I added some console messages and the loop is still running.

void update_game(sf::RenderWindow& window)
{
        std::cout << "update";
        window.clear();
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);
        window.draw(shape);
}

void display_game(sf::RenderWindow& window, float interpolation)
{
        std::cout << "display";
        window.display();
}

int main()
{
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");

        const int TICKS_PER_SECOND = 25;
    const int SKIP_TICKS = 1000 / TICKS_PER_SECOND;
    const int MAX_FRAMESKIP = 5;

    DWORD next_game_tick = GetTickCount();
    int loops;
    float interpolation;

    //bool game_is_running = true;
    while(window.isOpen())
        {
        loops = 0;
        while( GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP)
                {
                        std::cout << "tickloop";
                        update_game(window);
            next_game_tick += SKIP_TICKS;
            loops++;
        }

        interpolation = float( GetTickCount() + SKIP_TICKS - next_game_tick )
                        / float( SKIP_TICKS );
        display_game(window, interpolation);
    }

        return 0;

}

9
General / removed
« on: April 02, 2018, 10:55:31 am »
removed

Pages: [1]
anything