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

Pages: [1] 2
1
Graphics / Text is blurred
« on: February 29, 2012, 04:49:12 pm »
Code: [Select]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML.Window;
using SFML.Graphics;
using System.IO;
using System.Diagnostics;

namespace SFML_Test3
{
static class Program
{
static RenderWindow renderWindow;

static void Main(string[] args)
{
renderWindow = new RenderWindow(new VideoMode(800, 500), "SFML 2", Styles.Default, new ContextSettings(32, 0, 16));
renderWindow.Show(true);
renderWindow.ShowMouseCursor(true);
renderWindow.SetFramerateLimit(60);

renderWindow.Closed += (s, e) => { Environment.Exit(0); };
renderWindow.Resized += (s, e) => { renderWindow.SetView(new View(new FloatRect(0, 0, e.Width, e.Height))); };


Font debugFont = new Font(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "visitor1.ttf"));
Text debugText1 = new Text("TEST1", debugFont, 10);
Text debugText2 = new Text("TEST2", debugFont, 20);

debugText2.Scale = new Vector2f(0.5f, 0.5f);

while (renderWindow.IsOpen())
{
renderWindow.DispatchEvents();

renderWindow.Clear();

//

debugText1.Position = new Vector2f(50, 50);
debugText2.Position = new Vector2f(50, 80);

renderWindow.Draw(debugText1);
renderWindow.Draw(debugText2);
//

renderWindow.Display();
}
}
}
}


Font used is this one:

http://www.dafont.com/visitor.font

there are 2 versions, obviously (from looking at the source) I am using visitor1

I'm getting similar results for all other fonts too.

EDIT:
I just noticed that changing: new ContextSettings(32, 0, 16);
to
new ContextSettings(32, 0, 8)); // 8 or lower
resolves the problem, the question remains... why ?

When I use (for example) Arial and antialiasing == 0, it's like you said, the first result looks better.
Does that mean that I shouldn't use antialiasing:16 or is it some kind of bug?

2
DotNet / How do I clear Pixels?
« on: February 29, 2012, 04:17:01 pm »
Yeah you're right (as always ;D)
Thanks for the answer, both work as intended.

3
Graphics / Text is blurred
« on: February 29, 2012, 04:10:54 pm »


In the bottom example I commented out the scaling and changed the font size from 20 to 10 to maintain the size.
So scaling the text down resolves the issue.

No changes to View or any other transformations have been made.

Is it advised to always scale down the text when rendering?
Is this intended? Is there some better way to fix this?

Using the .NET bindings in C# if that matters.

4
DotNet / How do I clear Pixels?
« on: February 29, 2012, 01:42:38 pm »
I use this renderTexture as a cache for a histogram.
I could also save the values to a array, but then I'd have to redraw the complete image of the histrogram every frame / everytime a value changes.

I'd prefer removing one histogram bar, and drawing a new line at that place.

Should I use something else then a rendertexture maybe?
Is there no "Replace pixel values" blend mode?
I can see Alpha, Add, Multiply and None. But no "replace" or "set".

Ill go with the convert to image solution for now, thanks

Would it be a good idea to have a "Vertex[]", that contains all the lines,
then drawing that in one big batch to the texture?
So I only have to modify the endpoint of the line that changes in order to change one bar of the histogram.

Would that be faster than modifying the pixels directly everytime?

Oh and another related question:
When and why should I use VertexArray instead of Vertex[] ?

5
DotNet / How do I clear Pixels?
« on: February 29, 2012, 01:06:58 pm »
Im using C# and I have a "RenderTexture".

Now I want to clear a line of pixels from the RenderTexture.
(So they should all have the argb value of 0,0,0,0)

Code: [Select]

vertices[0].Color = new Color(0, 0, 0, 0);
vertices[1].Color = new Color(0, 0, 0, 0);
vertices[0].Position = new Vector2f(x, 0);
vertices[1].Position = new Vector2f(x, 200);
myRenderTexture.Draw(vertices, PrimitiveType.Lines);


The problem is that its using alpha blending, so nothing is happening :(

I don't want that, I want to clear the pixels in that line.
What's the easiest way of doing that with the .NET bindings ?

6
DotNet / Is it possible to get a 2.x version of the .NET bindings?
« on: February 25, 2012, 05:05:45 am »
Awesome!!
I was waiting for this! Thanks a lot!

7
DotNet / Is it possible to get a 2.x version of the .NET bindings?
« on: February 24, 2012, 07:16:38 am »
Sounds awesome!
I'm really looking forward to the release of the sfml .net 2.0 bindings with the new stuff :D

8
DotNet / Performance questions
« on: November 14, 2011, 09:24:31 pm »
Quote from: "omeg"
Creating many objects every frame is a bad idea. Not because of SFML internals, but because .NET's garbage collector will need to collect them very often. Hence your performance drops.


Quote from: "Felheart"
I also have reduced allocations per frame to a minimum already.


The problem is simply the drawing a large amount of sprites.
But Laurent said it should get better when internal batching is ready.
I hope this will be finished soon :D

9
General / [SOLVED]Custom Icons in SFML?
« on: November 13, 2011, 03:26:42 am »
I suppose you mean the .exe file icon. not the icon thats displayed in the title bar. (in case you mean that, there is a sfml function for that).

you could either use reshacker or something like that.

or you could include one icon as a "resource" with the id IDI_ICON1 or something like that. (then you could also set it as the title-bar icon)

edit: i meant
http://www.sfml-dev.org/documentation/1.6/classsf_1_1Window.php#a36fa09e52af66878b8b826457b8f1dfa

10
DotNet / Performance questions
« on: November 12, 2011, 05:51:37 pm »
Quote from: "Laurent"
Quote
1) should I reuse "Shape.Line" objects?
2) Does it impact the performance negatively when I create a new Line object every frame?

Nop, there's nothing precomputed inside shapes objects.

Quote
3) Are Shape.Line, Shape.Circle, ... only proxys that are drawn with a shader?

No, they are simple geometric shapes, decomposed in triangles.

Quote
4) Are "Shapes" drawn in a batch?

Nothing is batched in SFML.

Quote
5) I've read that batching is not yet implemented.
When will it be ready? Will it be like batching in XNA or something like that?

It's not officially planned. If I implement it, it will most likely be an internal optimization and not appear in the public API.


So we will have no control about the batching process? :(
Why not something simple like the XNA spritebatch ?
We already have the "Drawable" class as base, so it shouldn't be a big problem?
Or is there a good reason why you want to implement batching without public access ?

Also, what are major performance pitfalls with SFML?
I use one soundbuffer per soundfile and assign it to multiple "Sound" instances already, the same with Texture and Sprite.
I also have reduced allocations per frame to a minimum already.
But are there any other things I should be aware of ?

My game draws (every frame) the map, consisting of ~2000 Sprites(already culling offscreen tiles with a grid, so its extremely efficient), the interface consisting of ~100 Rectangles/Sprites, and enemys + player.
The particle system adds another 2000-3000 particles(not culling offscreen particles)
With this setup the game runs with ~15-20fps
My computer: Q6600, nv8800gts, 4gb ram.

I think this should be faster.

Is there anything I can do to improve performance ?

edit: I made a small test.
I can draw 10000 Shape rectangles when I initialize them once.
When I'm using Sprite, 2800 is already the maximum. (until the game gets unplayable)
When I create new Sprites or Rectangles every frame, I can only draw one fifth!!

11
DotNet / Performance questions
« on: November 12, 2011, 02:57:18 am »
Hello,

1) should I reuse "Shape.Line" objects?

2) Does it impact the performance negatively when I create a new Line object every frame?

3) Are Shape.Line, Shape.Circle, ... only proxys that are drawn with a shader?

4) Are "Shapes" drawn in a batch?

5) I've read that batching is not yet implemented.
When will it be ready? Will it be like batching in XNA or something like that?

(using C# if it matters)

12
Window / Focus on Window?
« on: November 07, 2011, 12:40:24 am »
pumping the message queue?

In C# it's App.DispatchEvents();
There should be something similar in the original c++ version

13
Audio / Sounds stop playing after a while
« on: November 06, 2011, 08:17:51 pm »
Now that I have identified the problem, I thought about various ways to resolve it. But I really don't know what the best method is.
So I'm seeking advice here :)

The problem(as already said) is that sounds play too long and therefore get promoted to higher generations where they are not disposed in time to make place for new sound instances.
Thats why the internal Sound counter in SFML rises and doesn't decrease (fast enough) even though no more sounds are played.

Method 1:
Run the GC more often and on all generations.
But it takes time and introduces a bug and unnecessary overhead!

Method 2: (what I'm currently doing)
I have a static class that accepts "IDisposable" objects and a time.
When the time is up the class calls .Dispose(); on the object to free its resources (hence decreasing the sound counter).
The class has it's own low-priority background thread to carry out its task.

So everytime I need a explosion sound I do the following:
Sound s = new Sound(...);
ObjectDestroyer.RegisterDestruction(s, s.SoundBuffer.Duration);


Is there a better way that I'm overlooking?
I don't like the idea to have just another background thread besides the GC that only collects garbage...

Isn't there a "event" like OnSoundFinishedPlaying that I can register for?

How would you handle this situation Laurent ?

14
Audio / Sounds stop playing after a while
« on: November 05, 2011, 08:16:16 pm »
I found the problem. :D
I forced the GC to run every 10th frame, but only on the 0th collection.
But most of the sounds belonged to the 2nd or 3rd generation of objects!

In my game every rocket has its explosion sound. But a rocket often lives longer than 10frames, so it gets promoted to a higher object generation.

And it can take the GC quite a while to decide that it's now time for a generation2 or 3 cleanup.

I'm sorry to have wasted your time :(
But thanks for your help (and the fast replys!)

15
Audio / Sounds stop playing after a while
« on: November 05, 2011, 07:37:17 pm »
I was under the impression that once the garbage collector starts, it calls the Dispose method of every object it deletes.

I can confirm that the garbage collector runs at least every few seconds in my game

Do I have to call Dispose manually on every SFML-object ??

Pages: [1] 2
anything