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

Pages: [1]
1
DotNet / System.DllNotFoundException on Mac OS
« on: August 19, 2019, 06:57:50 am »
I'm on Mac OS Mojave using Visual Studio Community 2019.

First I created a blank C# project. Then I installed the SFML.Net NuGet. After that, this is what my packages.config file looked like:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="CSFML" version="2.5.0" targetFramework="net47" />
  <package id="SFML.Audio" version="2.5.0" targetFramework="net47" />
  <package id="SFML.Graphics" version="2.5.0" targetFramework="net47" />
  <package id="SFML.Net" version="2.5.0" targetFramework="net47" />
  <package id="SFML.System" version="2.5.0" targetFramework="net47" />
  <package id="SFML.Window" version="2.5.0" targetFramework="net47" />
</packages>

I then create a simple main program:

using System;
using SFML;
using SFML.Graphics;
using SFML.Window;

namespace HelloSFML
{
    class MainClass
    {
        private static RenderWindow _window;

        public static void Main(string[] args)
        {
            _window = new RenderWindow(new VideoMode(640, 480), "Hello SFML!");
            _window.SetVisible(true);
            _window.Closed += new EventHandler(OnClosed);
            while (_window.IsOpen)
            {
                _window.DispatchEvents();
                _window.Clear(Color.Black);
                _window.Display();
            }
        }

        private static void OnClosed(object sender, EventArgs e)
        {
            _window.Close();
        }
    }
}

After building, I then copy the following files to my the Debug/bin folder of my project:

libcsfml-audio.2.5.0.dylib
libcsfml-graphics.2.5.0.dylib
libcsfml-network.2.5.0.dylib
libcsfml-system.2.5.0.dylib
libcsfml-window.2.5.0.dylib

I then also create a file called sfmlnet-graphics.dll.config in that same folder with the following contents:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
        <dllmap dll="csfml-graphics" target="libcsfml-graphics.2.5.0.dylib"/>
        <dllmap dll="csfml-audio" target="libcsfml-audio.2.5.0.dylib"/>
        <dllmap dll="csfml-window" target="libcsfml-window.2.5.0.dylib"/>
        <dllmap dll="csfml-system" target="libcsfml-system.2.5.0.dylib"/>
        <dllmap dll="csfml-network" target="libcsfml-network.2.5.0.dylib"/>
</configuration>

However, when I run the program, I get the following exception:

{System.DllNotFoundException: csfml-graphics
  at (wrapper managed-to-native) SFML.Graphics.RenderWindow.sfRenderWindow_createUnicode(SFML.Window.VideoMode,intptr,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Graphics.RenderWindow..ctor (SFML.Window.VideoMode mode, System.String title, SFML.Window.Styles style, SFML.Window.ContextSettings settings) [0x00040] in <e68fba52605f4eee88783890392bddfc>:0
  at SFML.Graphics.RenderWindow..ctor (SFML.Window.VideoMode mode, System.String title) [0x0000b] in <e68fba52605f4eee88783890392bddfc>:0
  at HelloSFML.MainClass.Main (System.String[] args) [0x00001] in /Users/rutvik/Desktop/hello-csharp/hello-csharp/MainClass.cs:14 }

I'm really not sure what other steps are required to get this to work. There are some other posts on this forum:

https://en.sfml-dev.org/forums/index.php?topic=24990.msg166468#msg166468

https://en.sfml-dev.org/forums/index.php?topic=25450.0


^ Both of those posts seem inconclusive and don't fix my problem (from what I can tell). Not sure what other steps are needed to get this to work...

2
Java / Re: Trouble setting the viewport
« on: September 16, 2013, 01:02:30 am »
Hi sorry to bother you, but have there been any developments?

3
Java / Trouble setting the viewport
« on: September 09, 2013, 02:28:16 am »
I made a very simple app to test JSFML and learn how to use views, but when I tried to set the viewport, nothing happened; the view still takes up the whole screen when it should take up half. I looked through my code a few times, but I was unable to catch the problem. I've tested similar code in the c++ version and it works, so I'm not sure if there's a difference in how I need to use the viewports in java or if I'm making a silly error...

If anyone could point me to the problem I'd really be grateful.

        RenderWindow window = new RenderWindow();
        ContextSettings ctxSettings = new ContextSettings(8);
        int screenWidth = 720;
        int screenHeight = 480;
        window.create(new VideoMode(screenWidth, screenHeight),
                              "JSFML Test",
                               RenderWindow.CLOSE | RenderWindow.TITLEBAR,
                               ctxSettings);

        window.setVerticalSyncEnabled(true);
       
        Texture bgTexture = new Texture();
       
        // load the bg picture with an InputStream
       
        Vector2i worldSize = bgTexture.getSize();
       
        RectangleShape bg = new RectangleShape();
        bg.setPosition(0,0);
        bg.setSize(new Vector2f(bgTexture.getSize()));
        bg.setTexture(bgTexture);
       
        View view = new View(window.getDefaultView().getCenter(), new Vector2f(screenWidth, screenHeight));
        view.setViewport(new FloatRect(0, 0, 0.5f, 1.f));
        window.setView(view);
       
        RectangleShape player1 = new RectangleShape();
        player1.setSize(new Vector2f(20, 20));
        player1.setPosition(0, 0);
        player1.setFillColor(Color.RED);
        int player1MoveSpeed = 200;
       
        Clock clock = new Clock();
        while (window.isOpen())
        {
            window.clear();
                   
            window.draw(bg);
            window.draw(player1);
                   
            window.display();

            float dt = clock.restart().asSeconds();        
           
            // move the player at `player1MoveSpeed`
           
            for (Event event : window.pollEvents())
            {
                switch (event.type)
                {
                    case CLOSED:
                        window.close();
                        break;
                }
            }
        }
 

4
General / SFML Empty Application Xcode template
« on: July 13, 2012, 02:54:25 am »
I downloaded SFML 2.0 using the wizard, and got everything up an running smoothly. However, the templates given aren't empty, they have some sample files and sample code. I know I could just delete the files and the sample code, but it gets annoying to do that every time I want to create an SFML project. Does anyone know how to edit the xctemplate files that control the given templates, or has anyone already made a blank project template themselves?

5
Graphics / Re: Animating a sprite independently from the main loop
« on: July 09, 2012, 09:04:59 pm »
That would work too! Thanks!

And one more thing, how do I restart the flash? If I simply reset m_accumulatedTime back to 0, it'll just keep flashing. Should I use a static bool in this case (for example called isFlashing)?

6
Graphics / Re: Animating a sprite independently from the main loop
« on: July 09, 2012, 08:35:04 pm »
m_accumulatedTime is most likely static correct?

7
Graphics / Animating a sprite independently from the main loop
« on: July 09, 2012, 08:23:53 pm »
So i have a sprite that needs to flash when it gets hit, and for convenience purposes, let's say (theoretically) I have a flash method in the spaceship object class like so

class Spaceship: public Object {
public:
   void flash()
   {
      if (t < 1.5) {
         float opacityRatio = cos(3t);
         sprite.setColor(sf::Color(255,255,255,255*opacityRatio));
      }
   }
};
 

The problem is that how do I get the "t" value? The game loop is repeated multiple times and relies on a clock, so if I use the clock value (which gets reset ever iteration) for "t" , the whole flash animation will mess up. So how do I get the "t" value? Should I use static variables (however I have a feeling that implementation isn't very graceful), or should I animate it in a separate thread (although I'm not sure it's possible)? Games use effects like this all the time, so I'm sure there's an easy way... Any suggestions/solutions would be extremely helpful.

8
Graphics / Best way to display sprites
« on: June 18, 2012, 03:38:52 am »
I have a window on which I'm going to display a ton of sprites for a game. I'm using SFML 2.0 which adds a view to windows automatically, which is good I hear because it converts measurements and locations for the window so it behaves the same, regardless of size. Problem is, when I resize the window, it stretches/shrinks all the sprites. Is there a way to resize the window but NOT the view? And what is the best way to set up views/windows to adjust to ALL resolutions? Because I want the game to look more or less the same on ALL screen sizes... thanks.

9
Window / Get the x/y coordinates of a window
« on: June 08, 2012, 08:11:30 pm »
I have a window that I'm using for a game, and I'm going to use the windows function ClipCursor()to confine the mouse to the window like make game do. However, I need to know how to get the coordinates of the window. I've looked through the documentation, but I can't seem to find it. Is there any way to do this? I plan on moving to mac later on, so cross-platform solutions would be best.

10
Graphics / Re: Rotating a sprite
« on: June 01, 2012, 06:43:35 am »
I've tried that before, but it doesn't work. Specifically I tried it like this before:

void CSprite::setRotation(float degrees)
{
   drawable.SetCenter(get_width()/2, get_height()/2);
   drawable.SetRotation(degrees);
   drawable.SetCenter(0, 0);
}

11
Graphics / Rotating a sprite
« on: June 01, 2012, 02:19:57 am »
I have this sprite I want to rotate, but when I call SetRotation() on it, it behaves weird, like the hinge is on the top left corner. I'm aware that I can use SetCenter() to place the hinge in the center of the sprite, but I like positioning elements using the top left corner. I wrote a wrapper class for sf::Sprite and wrote the setRotation() method like this:

void CSprite::setRotation(float degrees)
{
   float oldXCenter = drawable.GetCenter().x;
   float oldYCenter = drawable.GetCenter().y;
   drawable.SetRotation(degrees);
   drawable.SetPosition(oldXCenter, oldYCenter);
}

But it still doesn't do what I want... Does anyone have a solution?

12
Graphics / Re: Large text appears blurry
« on: May 22, 2012, 07:43:23 pm »
That's the default I think, and it still appears blurry.

13
Graphics / Large text appears blurry
« on: May 22, 2012, 07:21:19 pm »
I use the sf::String class to show text on the screen, and it looks okay at small sizes, but if I make the text 96pt, the it appears really blurry. I did SetSmooth(false) on the sf::Font object, but the it appears blurry and pixel-y! Is there any way  to have large, clean-looking text in SFML 1.6?

14
Graphics / Re: Help with rotating a sprite
« on: May 11, 2012, 08:32:18 pm »
Can it be done with SFML 2? And if so, how?

And the way I'm currently getting around the situation is by just center-positioning all the sprites internally, and using the wrapper class to make it behave like I'm positioning using the top left corner. Would you say this is bad design?

15
Graphics / Help with rotating a sprite
« on: May 10, 2012, 11:20:47 pm »
I have a character sprite that I need to rotate to face up, left, right, and down. The way I'm currently rotating it is like this:

(SpriteX is a wrapper class I made around an sf::Sprite, and these are some rotation methods)

void SpriteX::rotate(float degrees)
{
   sprite.SetCenter(get_width()/2, get_height()/2);
   sprite.Rotate(degrees);
   sprite.SetCenter(0, 0);
}

void SpriteX::set_rotation(float degrees)
{
   sprite.SetCenter(get_width()/2, get_height()/2);
   sprite.SetRotation(degrees);
   sprite.SetCenter(0, 0);
}
 

The sprite still rotates around its top left corner, how do I make it rotate around it's center just for the scope of the rotation method? I still want to position the sprite based on its top left corner.

Will I just have to make 4 separate image files?

Any help is appreciated!

Pages: [1]
anything