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

Pages: [1]
1
Window / Repeating keys when held down
« on: December 19, 2012, 11:00:45 am »
Hi,
I'm coding a textbox control with sfml.
When I hold down a letter button it begins to repeat it after a second like it should be.

My problem is that this only happens in the "TextEntered" event.
But I also need the arrow-keys to have the same functionality.

I know the arrow keys are not text, but there has to be a way to also get those keys to repeat.
After all, every text input control will move the cursor/caret when an arrow key is being held down.

2
DotNet / OpenTK and SFML
« on: November 11, 2012, 11:50:42 pm »
Hi there. Got SFML working with OpenTK.
I understand that me messing with the openGL context will disturb SFML in its functionality.
Thats why one should use PushGLStates / PopGLStates.
I read the tutorial and the documentation, but somehow it's still not 100% clear to me.

I have a few questions.

1.) Should I enclose my code with Push/PopGlStates, or should I enclode the SFML drawing code with it?
Is there even a difference?

2.) When should ResetGlStates be used? Can it replace the above functions?

3.) Is this the correct way to make openTK aware of SFML: ?

static void Main(string[] args)
                {
                        RenderWindow = new RenderWindow(new SFML.Window.VideoMode(800, 450), "Title", SFML.Window.Styles.Close);

                        var wi = OpenTK.Platform.Utilities.CreateWindowsWindowInfo(RenderWindow.SystemHandle);
                        var ctx = new OpenTK.Graphics.GraphicsContext(OpenTK.Graphics.GraphicsMode.Default, wi);
                        ctx.MakeCurrent(wi);
                        ctx.LoadAll();

                        ...
                }
 

Isn't there a way to get the GlContext from the "RenderWindow" class directly??

3
DotNet / Limit the amount of vertices drawn
« on: March 07, 2012, 09:49:58 pm »
Hi there,
I have a custom vertex array (not the VertexArray class).
And when drawing I sometimes only want to draw the first N quads, not all.

This is for a particle effect, if there are only 20 out of 2000 particles "alive", I don't want to draw all 2000.

Draw(vertices, PrimitiveType, renderStates) is missing something like a "count" parameter to specify this ?
Or how do I do this?

4
DotNet / How to enable antialiasing for rendertexture?
« on: March 07, 2012, 11:41:20 am »
Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML.Window;
using SFML.Graphics;

namespace SFML_MatrixTest2
{
class Program
{
public static void Main(string[] args)
{
RenderWindow renderWindow = new RenderWindow(new VideoMode(800, 500), "SFML!", Styles.Default, new ContextSettings(0, 0, 8));
renderWindow.Closed += (s, e) => Environment.Exit(0);
renderWindow.SetFramerateLimit(60);

RectangleShape rect = new RectangleShape(new Vector2f(100, 70));
rect.FillColor = Color.Red;
rect.OutlineThickness = 2f;
rect.OutlineColor = Color.Green;

RenderTexture renderTexture = new RenderTexture(100, 100);
Sprite renderSprite = new Sprite(renderTexture.Texture);

while (true)
{
renderWindow.DispatchEvents();
renderWindow.Clear();


renderTexture.Clear(Color.Blue);

rect.Position = new Vector2f(50, 50);
rect.CenterOrigin();
rect.Rotation += 0.2f;

renderTexture.Draw(rect);

renderTexture.Smooth = true;
renderSprite.CenterOrigin();
renderSprite.Rotation = rect.Rotation;
renderSprite.Position = new Vector2f(200, 200);
renderSprite.Scale = new Vector2f(3, 3);
renderWindow.Draw(renderSprite);
renderWindow.Display();
}
}
}
}


Center origin might be missing, its just:
Code: [Select]
internal static void CenterOrigin(this Sprite sprite)
{
sprite.Origin = new SFML.Window.Vector2f(sprite.TextureRect.Width * 0.5f, sprite.TextureRect.Height * 0.5f);
}

internal static void CenterOrigin(this RectangleShape rect)
{
var bounds = rect.GetLocalBounds();
rect.Origin = new Vector2f(bounds.Width * 0.5f, bounds.Height * 0.5f);
}



Anyway, the draw to the render texture doesnt seem to be anti aliased :(
How do I enable it when drawing to render textures?

5
DotNet / A few design questions
« on: March 02, 2012, 09:35:54 pm »
Why is renderWindow.Height and Width "uint" instead of "int" ?
Sure, they cant be negative, but the casts are unnecessary.
Size, Rectangle and other classes / structs in the DotNet environment are just int to make handling easier (no casts).
Is there any real reason to keep uint ?

The next thing is less a question, more like a bugreport.
The Events of "RenderWindow" shold begin with "OnX"
That means, OnResize, OnLostFocus, OnWhateverHappend.
See: http://msdn.microsoft.com/en-us/library/ms229045.aspx


Is CPointer of any use in the .NET environment ?
Of course it might be needed to have the pointer to the object ready in case its needed by the wrapper.
But that's and implementation detail, which should be "private".
Unless of course you can do something nice with it. (Please explain)

What do PushGLStates(), PopGLStates() and ResetGLStates() do?
When should they be used? What can they be used for?

What direction is "up" ?
Mouse coordinates are returned with +Y equals downwards, that also matches with how vertices are defined.
But shouldn't +Y be upwards in openGL ? Is this a SFML specific thing ?
I don't care what way is upwards as long as it is consistent over all the stuff that SFML provides.

Btw:
Is there any way to clip stuff ? Like a clip region ?
I've seen that in some other engines.
I think its drawing to the stencil buffer, then setting the stencil buffer as blend mode or something like that.
Or is the only available way for this using RenderTextures?
I don't have anything against them, but is there a limit on how many of those you can use ?

Thanks for the awesome libaray btw.
I really love it.

6
DotNet / Rotate images while batching
« on: March 02, 2012, 04:10:33 pm »
Hi,

im using the new vertexarray introduced in SFML2 to batch all the tiles from my tile map.
I add all the quads to the vertex array and set the texture coordinates accordingly.
This works good.

I can rotate the tiles in steps of 90°, or mirror them by swapping the texture coordinates.
But how can I rotate the image by an arbitrary value ? For example 15°

Do I have to rotate my vertices by the required value myself ?
Applying a series of trigonometric functions to every vertex doesnt seem to be the correct way, because its relatively expensive to do those calculations every frame.
Can I somehow utilize the GPU to do that work for me ?
If so, how ?

I know I can use Sprite and set its Rotation to the desired value, but will using "Sprite" still make use of batching ?? I think not, but correct me if I'm wrong

Pages: [1]