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

Pages: [1]
1
DotNet / SFML and event management (solved)
« on: March 14, 2017, 12:11:36 am »
Consider the following (very simple) SFML app.
It creates a render window, poll events and print to console each mouse move position:

public static void Main()
{                      
        RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML window");
       
        window.MouseMoved += (sender, e) => {
                Console.WriteLine(e.X + " " + e.Y);
        };
                       
        // Start the game loop
        while (window.IsOpen())
        {
                window.DispatchEvents();                                               
                window.Clear();                        
                window.Display();
                //System.Threading.Thread.Sleep(1000);
        }
}

Imagine we remove the line in comment (Thread.Sleep(...)).
Now the display in the console is very laggy (which is expected).

However it only prints one mouse position per second. I would rather expect that it would wait one second, then print a bunch of mouse positions (actually all the ones send to the window while sleeping), then wait one second , then print some messages and so on.

I have taken a look at source code (both C++ and C# github repos) and AFAIK SFML behavior is to pump all messages from the window (using PeekMessageW()) then store in it's own queue (a C++ vector) and dispatch them one by one. So I don't understand behavior that I got. I expect Console.WriteLine() to be called several times between two Thread.Sleep().

2
I have a perfectly working application made with SFML.Net 2.1. I have decided to migrate to 2.2.

However, after the migration I have noticed the following : ALL sprites are now displayed as white rectangles (no more textures)

I have reduce program to the bare minimum and problem still occurs :

public static void Main()
{
        RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML window");
       
        window.Closed += OnClosed;
        Sprite spr = new Sprite(new Texture(@"test.png"));     
                       
        while (window.IsOpen)
        {
                window.DispatchEvents();                                                       
                window.Clear();                                
                window.Draw(spr);
                window.Display();
        }
}
   

Issue is not related to test.png file : if it was not there it would throw an exception.

Compiling the exact same program under SFML 2.1 (expect minor changes like window.Open vs window.Open()) => it works perfectly (sprites are displayed as they should).

At runtime, the following errors are sometimes shown when using SFML 2.2 :

Code: [Select]
OpenGL Warning: SHCRGL_GUEST_FN_WRITE_READ (36) failed with ffffffdb ffffffea   

Code: [Select]
Unhandled Exception: System.AccessViolationException: Attempted to read or write
 protected memory. This is often an indication that other memory is corrupt.
   at SFML.Graphics.Sprite.sfRenderWindow_drawSprite(IntPtr CPointer, IntPtr Spr
ite, MarshalData& states)
   at SFML.Graphics.Sprite.Draw(RenderTarget target, RenderStates states)
   at SFML.Graphics.RenderWindow.Draw(Drawable drawable)
   at Test.Program.Main() in Program.cs:line 22
   

I use SFML.Net 2.2 32-bit version from here : http://www.sfml-dev.org/download/sfml.net/ + CSFML 2.2 from here : http://www.sfml-dev.org/download/csfml/



3
Graphics / How to draw a line strip that has some thickness
« on: March 04, 2017, 11:19:42 am »
I would like to draw a line made of several points (more than 2) and that have some thickness (aka width).

How can I do that in SFML ?

Here is my actual code (C#) :
Vertex[] line =
{
        new Vertex(new Vector2f(10.0f, 10.0f)),
        new Vertex(new Vector2f(150.0f, 150.0f)),
        new Vertex(new Vector2f(300.0f, 60.0f))
};

window.Draw(line, PrimitiveType.LinesStrip);

4
General / Which SFML package to install from NuGet ?
« on: February 17, 2017, 02:48:56 pm »
When I search "SFML" on NuGet I got the following packages :

- "SFML.Net" (2.1.5) By Laurent G

However there is also the following ones :

sfml-system
sfml-window
sfml-graphics
sfml-audio
sfml-network

They are also by Laurent G. but version is 2.4.0

Should I install "SFML.Net" package (which is outdated) or the individual (more recent) packages (only the one I need) ?
If it's better to install the individual packages, what is the purpose of "SFML.Net" package ?


5
Graphics / How to check if a sprite is visible within a view ?
« on: February 17, 2017, 11:30:07 am »
Hi all,
I am a beginner with SFML and have a question.

Let's say I have a game with a scrollable view.

Is there a simple way using SFML to check if a given sprite (eg : an enemy) is visible within a view ? By visible I mean the sprite can be seen with the current scroll values, not that it is occluded by another sprite.

I have same problem with mouse : how to check that a the mouse cursor is inside a view ?

Pages: [1]
anything