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

Pages: [1] 2
1
DotNet / Re: SFML on PictureBox with no render loop and GDI+
« on: November 16, 2013, 09:24:12 am »
Do you just want to draw inside a Form? Then try the following code.
After copying my code you just need to add a timer, set it's interval to 5ms and enable it.

Quote
   public partial class Form1 : Form
   {
      RenderWindow renderWnd;
      public Form1()
      {
         InitializeComponent();
         SetDoubleBuffered(panel1);
      }

      protected override void OnShown(EventArgs e)
      {
         base.OnShown(e);
         renderWnd = new RenderWindow(panel1.Handle, new ContextSettings(32, 0, 8));
      }

      public static void SetDoubleBuffered(Control c)
      {
         System.Reflection.PropertyInfo aProp =
              typeof(Control).GetProperty(
                  "DoubleBuffered",
                  System.Reflection.BindingFlags.NonPublic |
                  System.Reflection.BindingFlags.Instance);

         aProp.SetValue(c, true, null);
      }

      private void timer1_Tick(object sender, EventArgs e)
      {
         renderWnd.Clear(new SFML.Graphics.Color(0,0,0));

         var circle = new CircleShape(5);
         circle.FillColor = SFML.Graphics.Color.Red;
         var cursor = panel1.PointToClient(MousePosition);
         circle.Position = new Vector2f(cursor.X, cursor.Y);

         renderWnd.Draw(circle);

         renderWnd.Display();
      }
   }


2
Feature requests / Re: Textured text?
« on: December 19, 2012, 11:14:53 am »
Use a shader to directly merge the two textures (the glyphs and your custom texture) in a single drawcall.
or if that doesnt work draw the text with white color, then in a second pass, apply your texture on all white pixels.

3
Window / Re: Repeating keys when held down
« on: December 19, 2012, 11:10:32 am »
Oh, I'm sorry! I only used TextEntered and Keyboard.GetState() to get the keys.
KeyPressed does what I want! Feel free to delete the thread.

4
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.

5
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??

6
General / Networking (tutorial) using SFML and NodeJS
« on: March 15, 2012, 04:00:19 pm »
huh, wow this is really cool!

I'll read it in the next days and provide feedback.
Thanks!!

7
DotNet / Limit the amount of vertices drawn
« on: March 08, 2012, 11:29:28 am »
Yeah, now it works, thank you.

8
DotNet / Limit the amount of vertices drawn
« on: March 07, 2012, 11:41:45 pm »
By the way: RenderStates is somehow buggy.

When I use the following renderstates, the program crashes:

Code: [Select]

renderStates = new RenderStates(Texture);
renderStates.BlendMode = BlendMode.Add;

target.Draw(vertices, PrimitiveType.Quads, renderStates);


"Access Violation" inside this:
           
                     
Code: [Select]
  sfRenderWindow_DrawPrimitives(CPointer, vertexPtr, (uint)vertices.Length, type, states.Marshal());


EDITED:
But when I try it that way, it works without problems:
Code: [Select]

var va = new VertexArray(PrimitiveType.Quads);
for (int i = 0; i < particles.Count; i++)
{
va.Append(vertices[i * 4 + 0]);
va.Append(vertices[i * 4 + 1]);
va.Append(vertices[i * 4 + 2]);
va.Append(vertices[i * 4 + 3]);
}

va.Draw(target, renderState);


That would be very inefficient. But strangely it works.
Maybe only the vertexarray should draw vertices ? But why does RenderTarget.Draw() have an overload that allows drawing Vertex[] types directly ????

I'm using that method for now :/
I hope its only a small bug.

9
DotNet / Limit the amount of vertices drawn
« on: March 07, 2012, 11:07:30 pm »
The only possible way would be copying out the part of the array I want to render.
But since there is a (hidden) maximum variable, i'd rather use use that.

10
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?

11
DotNet / How to enable antialiasing for rendertexture?
« on: March 07, 2012, 11:52:29 am »
Oh sorry, I'll search next time.
Thanks :)

12
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?

13
Graphics / Tilemap: vertex array or prerendered texture?
« on: March 03, 2012, 05:43:55 pm »
Yes it would be faster. But you will still have to split the complete, huge, prerendered texture, into smaller textures.
Since the maximum "renderTexture" is dependant on your GPU,
i think 1024 would be ok for most gpus, but you will have to check it yourself.


Whatever, as I said you will still have to split it.
I will implement some kind of grouping into my tilemap so a 20x20 part of my levels tilemap will be rendered into one rendertexture.

14
DotNet / get window position?
« on: March 02, 2012, 09:52:57 pm »
Mouse.GetPosition(renderWindow);

Will retrieve the position relative to the renderwindow, you don't need its position.

15
DotNet / A few design questions
« on: March 02, 2012, 09:51:57 pm »
Ah ok, you are right,
I just  thought this one is the correct link
http://msdn.microsoft.com/en-us/library/ms229042.aspx
because it said:
"Design Guidelines for Developing Class Libraries"

It's not really a problem anyway :)

Pages: [1] 2
anything