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

Pages: [1]
1
DotNet / Using CurrentView
« on: November 13, 2010, 07:38:45 pm »
Unless I am missing something here, the following should update the view before each draw:

Code: [Select]
using System;
using SFML.Graphics;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var rw = new RenderWindow(new SFML.Window.VideoMode(800, 600), "Test"))
            {
                Shape sh = Shape.Rectangle(new FloatRect(8,8,32,32), Color.Green);

                while (rw.IsOpened())
                {
                    rw.DispatchEvents();
                    rw.CurrentView.Reset(new FloatRect(0, 0, rw.Width, rw.Height));
                    // rw.CurrentView = rw.CurrentView;
                    rw.Draw(sh);
                    rw.Display();
                }
            }
        }
    }
}


But the changes made to CurrentView don't actually take affect until you do a hack like I have above in the commented-out line. If you leave that line commented out, CurrentView.Reset() appears to have no affect. Adding the commented out line, the view is resized as expected.

2
DotNet / RenderImage woes
« on: November 13, 2010, 06:57:18 pm »
Here is a minimalist C# console app to recreate the problem:

Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML.Graphics;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var rw = new RenderWindow(new SFML.Window.VideoMode(800, 600), "Test"))
            {
                Shape sh = Shape.Rectangle(new FloatRect(8,8,32,32), Color.Green);

                RenderImage buffer = null;
                while (rw.IsOpened())
                {
                    rw.DispatchEvents();

                    buffer = CreateBuffer(rw, buffer);

                    buffer.Clear();
                    buffer.Draw(sh);
                    buffer.Display();

                    rw.Clear();
                    var s = new Sprite(buffer.Image);
                    rw.Draw(s);
                    rw.Display();
                }
            }
        }

        static RenderImage CreateBuffer(RenderWindow rw, RenderImage existingBuffer)
        {
            if (existingBuffer == null || existingBuffer.Width != rw.Width || existingBuffer.Height != rw.Height)
            {
                if (existingBuffer != null)
                    existingBuffer.Dispose();

                return new RenderImage(rw.Width, rw.Height);
            }

            return existingBuffer;
        }
    }
}


I have been having this issue for a while, but always assumed it was my fault up until now. RenderImage doesn't seem to want to dispose properly. In my game, I use a few RenderImages to draw to, then combine them all to the screen. If the RenderWindow changes in size, the RenderImages are disposed then created again with the new size. But when disposing them, that is when the problems seem to arise.

If you take out the Dispose in the program above, it also seems to make it work just fine.

3
DotNet / Call to invalid method: sfShader_Create
« on: November 07, 2010, 09:59:51 pm »
The default Shader() constructor calls sfShader_Create, which doesn't seem to exist in csfml.

4
DotNet / Missing CallingConvention.Cdecl
« on: November 07, 2010, 07:41:36 pm »
Seems the CallingConvention.Cdecl parameter is missing in the .NET bindings on:

Code: [Select]
static extern void sfText_SetString(IntPtr This, string Text);

5
General discussions / Alternative to SOIL
« on: November 05, 2010, 04:00:22 pm »
I'm not too familiar with SOIL and know almost nothing about its alternatives, but I did think this would still be worth mentioning. So far, my experiences with loading images in SFML (namely PNG) has been less than ideal. Most any PNG that has been optimized (optipng, pngcrush, etc) seems to completely fail to load. I have also had a few people using my engine mention that PNGs created by some applications also fail to load.

So, is there any better alternative to SOIL that could be used for SFML? Or is there a particular reason for SOIL being used? Or...?

6
Graphics / Skewing
« on: July 30, 2010, 08:22:55 pm »
In the past, I have added shadows by just skewing the sprite and drawing it black. That is, take the top two points of the rect, shift them over about 50%, halve the height, then draw it black with alpha. Though I just noticed that there is no native way to do this with SFML.

How would one go about accomplishing this in SFML?

7
DotNet / Missing StructLayout Sequential for some events
« on: May 26, 2010, 01:35:21 am »
I am not positive on this one, but it looks like the structs in Event.cs used inside of the Event struct (SizeEvent, JoyButtonEvent, etc) should have the StructLayout(LayoutKind.Sequential) attribute.

8
Window / Unsigned integers and negative cursor positions
« on: May 25, 2010, 05:26:23 am »
This is happening for me in .NET, but not sure if its from the SFML core. When the cursor is out of the screen to the left or top, the position relative to the window is negative. Normally, SFML won't even send these events since the cursor is out of the screen. However, when passing a manual handle and you click (and hold) on the form then move the cursor out of the form, these events will continue to be sent. Here is a minimalist example in C#:

Code: [Select]
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using SFML.Graphics;
using SFML.Window;
using Color = SFML.Graphics.Color;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            Application.Run(new Form1());
        }
    }

    public class Form1 : Form
    {
        readonly RenderWindow rw;

        string _displayText = string.Empty;

        public Form1()
        {
            InitializeComponent();

            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

            rw = new RenderWindow(Handle);

            rw.MouseMoved += rw_MouseMoved;

            Focus();
        }

        void InitializeComponent()
        {
            SuspendLayout();
            AutoScaleDimensions = new SizeF(6F, 13F);
            AutoScaleMode = AutoScaleMode.Font;
            ClientSize = new Size(284, 262);
            ResumeLayout(false);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            try
            {
                rw.DispatchEvents();
                rw.Clear();

                using (var text = new Text { Color = Color.White, Font = SFML.Graphics.Font.DefaultFont, Size = 16 })
                {
                    text.DisplayedString = _displayText;
                    rw.Draw(text);
                }

                rw.Display();
            }
            finally
            {
                Invalidate();
            }
        }

        void rw_MouseMoved(object sender, MouseMoveEventArgs e)
        {
            _displayText = e.X + "," + e.Y;
        }
    }
}

9
DotNet / Image.Copy copying nothing
« on: May 20, 2010, 12:33:41 am »
I recently upgraded all my code from SFML 1.5 to the latest 2.0 commit. Everything seems to be working for the most part except for Image.Copy. It simply just copies nothing. I threw together a little mock project to make sure it wasn't my code, and it does definitely seem to be SFML:

Code: [Select]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML.Graphics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var rw = new RenderWindow( new SFML.Window.VideoMode(800, 600), ":)"))
            {
                var a = new Image("a.bmp");
                var atlas = new Image(64, 64, new Color(255, 0, 255, 0));

                Copy(atlas, a, 0, 0, new IntRect(0, 0, 32, 32));
                Copy(atlas, a, 32, 0, new IntRect(0, 0, 32, 32));
                Copy(atlas, a, 0, 32, new IntRect(0, 0, 32, 32));
                Copy(atlas, a, 32, 32, new IntRect(0, 0, 32, 32));
     
                var s = new Sprite
                {
                    Position = new Vector2(0, 0),
                    SubRect = new IntRect(0, 0, 64, 64),
                    BlendMode = BlendMode.None,
                    Color = Color.White,
                    Image = atlas
                };

                rw.Show(true);
                rw.UseVerticalSync(true);

                while (rw.IsOpened())
                {
                    rw.DispatchEvents();
                    rw.Clear();
                    rw.Draw(s);
                    rw.Display();
                }
            }
        }

        static void Copy(Image dest, Image src, uint dx, uint dy, IntRect srcRect)
        {
            const bool useSFMLCopy = true;

            if (useSFMLCopy)
            {
                dest.Copy(src, dx, dy, srcRect);
            }
            else
            {
                for (uint x = 0; x < srcRect.Width; x++)
                {
                    for (uint y = 0; y < srcRect.Height; y++)
                    {
                        dest.SetPixel(dx + x, dy + y, src.GetPixel((uint)srcRect.Left + x, (uint)srcRect.Top + y));
                    }
                }
            }
        }
    }
}


If you set the const useSFMLCopy to false, it will do a pixel-by-pixel copy and work fine. But when true, nothing copies over at all.[/code]

Edit: Here is a copy of the project (for VS 2010).

10
DotNet / CallingConvention on DllImport
« on: April 24, 2010, 01:01:32 am »
When upgrading my project to use .NET 4.0, I started suddenly getting a PInvokeStackImbalance exception on just about every PInvoke call to the SFML DLLs. Adding the named parameter:

Code: [Select]
CallingConvention = CallingConvention.Cdecl

giving you:

Code: [Select]
[DllImport("csfml-window", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]

seems to fix it. Makes sense, since the default is StdCall. Other than getting rid of this annoying exception from the MDA (and the like 300x call overhead when MDA is enabled), everything else seems to behave just the same.

11
SFML projects / NetGore - C# open source MORPG engine
« on: April 08, 2010, 06:06:03 pm »
NetGore is a free, open-source 2D online RPG engine written in C#. It is cross-platform and supports both top-down and sidescroller games. NetGore comes with a large amount of the fundamental MMORPG components built in which allows you to focus more on designing your game.


(view more images)

Purpose: The idea behind NetGore is to provide a strong foundation to build a game off of, and to provide the implementation of all the fundamental components involved in 2D online games. That way, people can spend their time with what makes their game unique and stand apart from the rest. For the past few years, the focus has been on performance, flexibility, and advanced features. Recently, the focus has shifted to making it even easier and faster to create your own game with NetGore.

Target audience: NetGore is intended for online multiplayer 2D games only. Although the focus is mainly on real-time RPGs, most any kind of multiplayer 2D game is fine. Some users have already implemented shooters and turn-based combat. We also focus especially on indie developers in numerous ways, such as by including a lot of the features for you and providing a fully-functional base game to work off of.

Features: A detailed list of features can be found on the about page, but in short, most of the basic (and some more advanced) MMORPG features are built in to the engine. More features are always being added as well based on the demand for them.

Links:
Home page
Screenshots
Download page

Any feedback is appreciated, either here or through the NetGore forums.

Pages: [1]