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

Pages: [1]
1
DotNet / [SFML 2.0] App. crash when using Image and quitting the app?
« on: June 21, 2011, 09:09:46 pm »
So, as nobody answered I seem to be the only (testing) person to run into this problem.

Now, I tried everything:
x86 .Net and C
x64 .Net and C
as they were provided in the Snapshot. I even recompiled everything and tried again, still the same.

If it helps anything, there was this one time, when the console printed an error message: "Failed to share OpenGL context." (or something like that).

Now I switched back to Version 1.6 and everything works just fine.

2
DotNet / [SFML 2.0] App. crash when using Image and quitting the app?
« on: June 11, 2011, 07:50:38 pm »
Hello,

I recently restarted working on my current project using SFML.Net 2.0.

I encounted a crash, whenever loading some *.png files and then quitting the program. So I looked into it, and it seems, the crash always occurs when loading an Image (Image foo = new Image("file.png"); ) and then quitting the program.

Specifically, the following code results in an App. crash after the program ends:
Code: [Select]
   public static class Program
    {
        public static void Main() {
            SFML.Graphics.Image img = new SFML.Graphics.Image("img/enemy.png");
            Console.WriteLine("{0} x {1} px", img.Width, img.Height); // All fine, resulting text is as expected
        }
    }


I downloaded the latest SFML.Net 2.0 Snapshot, but still the same problem. Anyone else running into this problem?

3
DotNet / SFML.Net with Mono
« on: June 09, 2011, 12:22:27 am »
Hello,

quite some time has passed since I started this thread. Unfortunately, I did not reply, because of my laziness. I did manage to solve the problem myself a few days after I started this thread, though.

My main problem was infact the libraries not to be found by the executable, which I was not aware of. As a Windows user primarily, I simply assumed the Linux library behaviour was the same as on Windows. Little did I know...

Nevertheless your post is important to users, who encounter the same problems. I cannot recall for sure, but I guess this is what I did:

- Setting the environment variable to know the library search path (near the executable).
- Using CSFML Linux files.

So, no need for recompiling the SFML .Net or CSFML code. That should do the trick.

4
DotNet / Text get-DisplayedString Property results in a Crash
« on: March 31, 2011, 04:43:53 pm »
Hello,

after reporting a problem with String2D (SFML 1.6), I was told to check out SFML 2.0, whether the error occurs there also or not. Turns out: The originally problem was not only not solved, but made even worse! In the SFML 1.6 version, an exception was thrown, whenever the textlength of the contained string in String2D was longer than 15 characters and the get-part of the Text property was called (see http://www.sfml-dev.org/forum/viewtopic.php?t=4412). In the newer version 2.0, anytime one invokes the get-part of the DisplayedString property of the Text class, the program simply crashes even without throwing an exception:

Code: [Select]
Text text = new Text("Hello World");
Console.WrtieLine(text.DisplayedString); // Boom


Would be nice, if anyone could confirm this problem. I did not want to post an issue at github as I am not 100% sure the problem is a bug within the library.

5
DotNet / Problem with String2D in SFML 1.6?
« on: March 21, 2011, 03:41:02 pm »
Okay,

I guess (more or less) I found the problem.

After taking a look at the C SFML Code, I noticed sfString_GetText returns a const char*. On the C Code level, everything was fine. So the problem occurs, when .Net tries to convert the C const char* to the .Net String type. My guess is, .Net just "copies" the first 16 characters, which then results in the terminating \0 character of the const char* to be skipped, if the String2D.Text length is at least 16. Trying to determine the string length by looking for the terminating \0, .Net goes over its allowed limits and enters protected memory, which then results in an Exception being thrown.
Well, at least that is my guess.

To solve this, I modified the .Net code of String2D:
Code: [Select]

public string Text
{
    get
    {
        return Marshal.PtrToStringAnsi(sfString_GetText(This));
    }
    // ...
}
// ...
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfString_GetText(IntPtr This); // Replaced the return type from string to IntPtr


Now this seems to work, I tested it and got no more crashes.

Of course, this does still not solve your TODO comment with Unicode :P

6
DotNet / Problem with String2D in SFML 1.6?
« on: March 20, 2011, 07:39:03 pm »
Yeah, well. As much as I appreciate your answer... That does not help me at all :P

I just ran the same lines of code on my Linux machine and the outcome was the same: Crashing when invoking the get part of the Text attribute. So it does not seem to be a Windows-only problem.

Your reaction states, you did not know about it and it seems, this is not a local problem only I ran into. So I would be really happy if you happen you solve this "bug". If you cannot find it or you do not have enough time to look for it, I have to create a little work-around, which of course then would work. But it would not be the best solution :P

I have read in another thread that there seemed to be a problem with fonts. I did not read it completely, but I read the fact, there was (regarding the error message) a problem with the get-Text property, representing the same error I ran into.

Nevertheless thank you for reading this and providing us with a great library!

7
DotNet / Problem with String2D in SFML 1.6?
« on: March 20, 2011, 04:09:44 pm »
Hello,

it occurs to me that I have got a nasty problem with String2D.

Whenever the text length of the String2D object is greater than 15, the program crashes when reading the text from the Text property (the problem seems to lie in the layer between the .Net and C libraries). The proper error message would be
Quote
Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.
   bei SFML.Graphics.String2D.sfString_GetText(IntPtr This)
   bei SFML.Graphics.String2D.get_Text()

As one might see, this is German. The translation would be something like "It was tried to read or write protected memory. This often is caused by corrupted memory." More or less at least :P

Consider the following code:
Code: [Select]
String2D str = new String2D();
str.Text = "1234567890123456"; // str.Length == 16
string a = str.Text; // Crash


What makes me a bit surprised is the fact, there is no problem at all, unless the String2D.Text.Length is greater 15. Also, this only happens in the get Element of the Text property. The text can be set accurate and is also properly displayed, when invoked by a Draw command.

Now I am wondering whether this is a known bug or feature (?) or am I simply missing something to config? I even tried to change the standard font to something else, as I read there was a problem with the standard font (I image that had something to do with SFML 1.6 as I stumbled upon that problem, when I was programming in C++).

Note: I am currently using Windows Vista, Visual Studio 2008 Prof. with SFML.Net 1.6.

8
DotNet / SFML.Net with Mono
« on: March 01, 2011, 12:08:30 am »
Hello,

I want to start creating a game based on .Net. Because I like the design of SFML, this is my choice for the underlying library. Though .Net is commonly supposed to be MS Windows only, I've heard the .Net implementation of SFML should work very well with Mono on Linux.

Well, at least, that's what I've heard.

So, I downloaded MonoDevelop on Ubuntu and tried to add SFML.Net as references to my project. I failed miserably. "csfml-window" was not found. Okay, so I pop up the SFML forums and seek for wisdom. Hopefully, I open up a thread where the answer seems so near. Unfortunately, nothing worked, yet.

I tried:
- Add the "extlib" files of the .Net download into the directory of my *.exe file of my testapplication. Those are Windows-Only native DLLs I guess. Apperantly, they do not work.
- Added the CSFML Linux files into the directory of the *.exe file. Same result: "No csfml-window found".
- Added also the C++ SFML Linux files into that directory. Same result.
- Recompiled the SFML.Net Library as x86 and added above native files into the directory. Same result.

I am pretty much desperate right now. What exactly do I have to do to install SFML.Net on Linux to work with Mono? Maybe my order of execution was wrong. Or the filenames are not exactly correct (*.so.1.6 e.g.)

I would be very pleased if anyone is able to help me.

Best regards
- diRe

9
DotNet / Rendering in a Canvas in .NET
« on: September 18, 2009, 01:12:56 pm »
Thank you for your reply. The SetStyle method is really what I was looking for, now the annoying flickering has gone. But just to state it: The SetStyle method is protected, so one cannot modify the style of an already existing control (or I did not find out how). Therefore, I simply derived from Forms::Label and Re-Set the style in the constructor.

Also the Invalidate() in the event handling Paint() is very nice and makes the timer I used unnecessary. In fact, now this feels "right", the solution with the timer... well, I dislike them as already stated :)

10
DotNet / Rendering in a Canvas in .NET
« on: September 16, 2009, 06:02:36 pm »
"this" refers to the Form itself. That means, if something on the Form isn't valid in terms of "optic", the Form needs to redraw itself plus it's contents (at least, I think it works this way). So some child controls get the message "Hey, redraw yourself, please!", which is why the Label seems to redraw itself and overlay the renderView.

In my solution, only the Label itself is redrawn, if it needs to be. I came across this idea, when I thought about other controls like buttons etc. If I would have done a timer with the "this->Paint += ...", everything would be redrawn everytime, which... well, THAT would be massive flickering.

It has been a long time since I actually programmed with the native WinAPI, where this whole Invalidate, Redraw thing was clear to me, so I might be totally wrong. But this approach seems to work as intented.

With double buffering, I think it is more a problem of the Windows Form itself. The DB of SFML works fine, but the "Label" flickers. I had this problem in my native WinAPI days, too. AFAIK the problem is, that the content of the Label (the renderView) is first cleared and filled with the control's background color, when the Paint Event is fired. Then the content is drawn and shown.

11
DotNet / Rendering in a Canvas in .NET
« on: September 16, 2009, 03:31:44 pm »
OK, I fixed it.

Apparently you can disable the drawing of the Label with one easy change to my code above. Instead of
Code: [Select]
this->Paint += gcnew PaintEventHandler(...); one has to write
Code: [Select]
renderWindow->Paint += gcnew PaintEventHandler(...)This seems to override the Label's painting.
2nd: I implemented your suggestion, although I am not that happy with it, because I dislike working with timers :). But it works, there is a flickering sometimes, but I guess with double buffering I can get rid of that as well.

Thanks for your help.

12
DotNet / Rendering in a Canvas in .NET
« on: September 16, 2009, 02:43:52 pm »
Ok, I figured out, the Label can be used as a render target (infact, I can see a black box for a very short time). The problem now is, the label seems to redraw itself, so the sf::RenderWindow is not displaying anything.

That's my code (part of it):
Code: [Select]
// Constructor of my Form
Form1(void) : renderView(NULL)
{
InitializeComponent(); // Visual Studio Designer Stuff
HWND ptr = (HWND)renderWindow->Handle.ToPointer(); // Get the Label's handle (renderWindow is a Label)
renderView = new sf::RenderWindow(ptr); // Pass it to the sf::RenderWindow
this->Paint += gcnew PaintEventHandler(this, &Form1::Form1OnPaint); // Does not really work
}


So nothing that special about it. My main problem are two things:
1) The label redraws itself. Can I disable this behavior somehow?
2) Where to put renderView->Clear() and renderView->Display() (and of course the rest of rendering)? I put it into the method Form1OnPaint, which is called at the beginning of the program (if I place a Sleep() there, you can clearly see that the renderView displays it's content properly (a black void)), but after the method leaves, the label redraws itself - so the renderView's content is not shown.

PS.: If you are wondering: Yes, that is C++/CLI with .NET.

13
DotNet / Rendering in a Canvas in .NET
« on: September 16, 2009, 12:30:31 pm »
Hi,

I am currently working on a map editor (.NET) for my racing game. I encounted the problem of not being able to render something in the Windows Form (I want to have a canvas, where I render things, I do not want to be the Windows Form the sf::RenderWindow).
I tried the native approach: Create a "Label" (which is simply a "STATIC" with WinAPI), deactivate Autosizing, get the Handle of that label, pass it to the sf::RenderWindow and Clear() and Display() it's contents. While this works perfectly with the WinAPI, it will not do anything with Windows Forms.

My problem now is: I do not know, why this does not work, whether it is because of the "magic code" behind the scenes of the Visual Studio Designer or if the native approach simply does not go with Windows Forms.

If someone knows how to get this work, I would be very thankful.

Pages: [1]