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

Pages: [1]
1
General / Re: New here, and a simple question
« on: August 04, 2024, 08:42:57 pm »
Hi person999,

Heh heh just looked at your code. Strangely before I looked back at it I implimented deltaTime. I like the way you get the screen dimensions and stuff.

Going to go through your code slowly and see if I can improve my simple code.

Asimov

2
General / Re: Compiling GCC into the exe
« on: August 03, 2024, 01:11:12 pm »
Hi Texus,

Thanks I think you have solved my problem. Because I didn't want to complicate it, I removed audio-s and network-s seeing as I didn't need them for this project, which is basically the standard circle which I am using for testing. So this is what libraries I used.

sfml-graphics-s
sfml-window-s
sfml-system-s
opengl32
winmm
gdi32

I did add freetype, but when I tried to compile it said that it couldn't find freetype. Is this something I have to install? Anyway I removed freetype and it compiled ok.
So I tried it on my test pc in virtualbox and a black window came up complaining about hardware rendering, but other than that it worked. I wonder if there is a way to surpress that black console window from opening.

For my debug I am sticking with shared libraries. I only need static libraries for Release.
How do I mark this as solved?

Asimov

3
General / Re: Compiling GCC into the exe
« on: August 02, 2024, 10:07:09 pm »
Ok I have read a bit more of the documentation and it said if i want to make a static exe i have to add the static version of the libraries eg.
sfml-graphics-s
sfml-window-s
sfml-audio-s
sfml-network-s
sfml-system-s

Seeing as I compile these as static from source it should work, however when I do this I get a pile of errors.
Lots of undefined reference errors. See attachment.

Asimov

4
General / Re: Compiling GCC into the exe
« on: August 02, 2024, 04:23:03 pm »
I have had another go at compiling from source. This time I unticked BUILD_SHAREd_LIBS and ticked SFML_USE_STATIC_STD_LIBS. I copied them to the libs folder and compiled my program. However after copying the exe to another computer it still complains that the libgcc_s_dw2-1.dll is missing.

I am pulling my hair out over this. Can anyone help. I am attaching a screenshot of my cmake settings.

Asimov

5
General / Re: How to statically link sfml with codeblocks
« on: August 02, 2024, 03:21:59 pm »
I have also made it from source code using cmake. It works on my computer but won't work on my friends computer. Can you go through exactly what you set in cmake?

6
General / Compiling GCC into the exe
« on: August 01, 2024, 01:23:36 pm »
Hi all,
I am having a problem. Basically if I try to run the exe on another computer I get the libgcc_s_dw2-1.dll not found error. Which is strange because I am running hte 64 bit version of SFML and I am sure that should be the seh lib. I am using code::blocks.

 I compiled SFML from source. I compiled it 4 times. For debug and release, and the I compiled it with the Build Shared libs unticked, so I could link SFML statically.

In Code::blocks I am setting the flags
-static-libstdc++
-static-libgcc
-static

In other compiler options. I have even gone into global compiler settings and ticked the static libraries there too. I have done my research before posting. I read a pile of posts on this forum, and on stackoverflow and tried everything I have found, to no avail.


I even tried adding SFML_STATIC to #defines as well.

I have been trying to get this to work for 3 days without getting it to work, and now I thought I would ask the question.

Asimov

7
Graphics / Re: LoadFromMemory Sprites
« on: July 29, 2024, 08:22:58 pm »
It's ok. I have now successfully converted my loaded image from my resource in the other code. Then all I had to do was this
 sf::Image scotty_png = LoadImageFromResource("SCOTT_PNG");
    sf::Texture scottTexture;
   scottTexture.loadFromImage(scotty_png);

Thanks for your help anyway.
I hope this helps someone else with the same problem.

8
Graphics / Re: LoadFromMemory Sprites
« on: July 29, 2024, 07:32:24 pm »
Hi,

I found some code which does load the image from my resource. I know it works because was able to save the image out, but I am having trouble getting it into a Sprite. Ok so the following function works, but it isn't one i wrote. I found it on stackoverflow.
sf::Image LoadImageFromResource(const std::string& name)
{
    HRSRC rsrcData = FindResource(NULL, name.c_str(), RT_RCDATA);
    if (!rsrcData)
        throw std::runtime_error("Failed to find resource.");

    DWORD rsrcDataSize = SizeofResource(NULL, rsrcData);
    if (rsrcDataSize <= 0)
        throw std::runtime_error("Size of resource is 0.");

    HGLOBAL grsrcData = LoadResource(NULL, rsrcData);
    if (!grsrcData)
        throw std::runtime_error("Failed to load resource.");

    LPVOID firstByte = LockResource(grsrcData);
    if (!firstByte)
        throw std::runtime_error("Failed to lock resource.");

    sf::Image image;
    if (!image.loadFromMemory(firstByte, rsrcDataSize))
        throw std::runtime_error("Failed to load image from memory.");
    return image;
}
 


So in my main I put this to test if it worked.
sf::Image scotty_png = LoadImageFromResource("SCOTT_PNG");
scotty_png.saveToFile("pp.png");
 

Good news is that it loaded the png from the resource and actually saved out the Png to a file. So I know the resource is working. The problem is that I don't know how to turn this into a sprite. I think it is already a texture when it comes in. Or have I got that wrong?

I tried this, but it says I am doing a redeclaratoin
 sf::Sprite ScottSprite;
    ScottSprite.setTexture(scotty_png);

PS. It is actually image. So I am just trying to work out how to convert the image to a Sprite now LOL.


I think with a little help I can get this working.

Asimov


9
Graphics / Re: LoadFromMemory Sprites
« on: July 29, 2024, 04:04:12 pm »
Hi eXpl0it3r,

Thanks I will look into GDI. I think I used it on the irrlicht engine a while ago, but I have been out of practice for a while, and trying to get back into programming.

If it is only a small game I prefer to load sprites from a resource file, and then they only need the exe, and I don't have to rely on people having to make sure that the folder structure stays in tact.

Asimov

10
General / Re: New here, and a simple question
« on: July 29, 2024, 01:24:28 pm »
Hi Person999,

Removing my framerate line and adding  window.setVerticalSyncEnabled(true);
Solved my tearing problem, after reading the documentation.

I should probably investigate using deltatime at some point too..

I will have a look at the code you posted and see how it differs from mine, after I have had some food.

Asimov

11
I am also trying to load from a resource file.
Could you give me your full resource code so I can work out how to do it.

12
Graphics / LoadFromMemory Sprites
« on: July 26, 2024, 01:31:27 pm »
Hi,
I am on a windows machine using Code::Blocks. i have added my resource file to my project with so far one PNG sprite in there. I have made a resource.rc file and taken in the sprite as RCDATA which I have successfully done in other game engines. I just don't know how to turn the RCDATA png into a texture by using LoadFromMemory. I will be wanting to use this as a sprite.
Here is my resource file
SCOTT RCDATA "rc/SCOTT.bin"
 
I have also included a header file resource.h
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif

#define SCOTT 101

Now I want to know how to get my image which is a PNG into LoadFromMemory.

Bare in mind I am on windows and I am using Code::Blocks.
Also I have only been using SFML for a few days, so I am very new to it.


13
General / New here, and a simple question
« on: July 25, 2024, 01:07:04 pm »
Hi all,

I have only been messing with SFML for about a day. I made a little bouncing ball thing, but for some reason the animation is choppy. It is like scissoring or going out of phase when it is moving. I am on windows 10, so I am not sure if it is a windows thing. The program is not very long and bare in mind I am still learning how SFML works. I am wondering if it is something to do with the screen buffering.
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(1280, 720), "Screensaver",sf::Style::Fullscreen);

    window.setFramerateLimit(60);
    sf::CircleShape shape(50.f);
    shape.setFillColor(sf::Color::Green);

    sf::Vector2f circlePosition(600,350);
    shape.setPosition(circlePosition);

    float xVelocity =5;
    float yVelocity =5;

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) window.close();
        }
        //Physics
        if (circlePosition.x < 0 || circlePosition.x > 1200 -30) xVelocity *= -1;
        if (circlePosition.y < 0 || circlePosition.y > 720 - 100) yVelocity *= -1;

        circlePosition.x += xVelocity;
        circlePosition.y += yVelocity;
        shape.setPosition(circlePosition);

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

    return 0;
}
 

Pages: [1]
anything