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

Pages: [1] 2
1
I am using the latest SFML source and build it with Visual Studio 2017 and everything works fine. I once had a problem with msbuild because I had VS 2013 professional and VS 2017 community installed. I uninstalled everything but nothing worked...I resetted my windows 10 and reinstalled 2017. Problem solved (I work daily with VS and the way it's installed on a machine is just annoying).

What problem do you exactly have? What does CMake say? Or visual studio?!

2
General / Re: loadFromFile UNICODE path not working
« on: June 17, 2017, 06:10:07 pm »
Thanks for your reply Laurent!

Good to hear it will be supported sometime in the future (is there any current roadmap, couldn't find one)

3. It is an issue that will be fixed, but it's always better to use ASCII paths to avoid troubles anyway ;)

Yes, correct. The thing is, I don't know in which path the user will copy my game. Let's say I sell a game via Steam and Steam is installed in "C:\游戏\steamapps\", the game won't run.

I guess nowadays file operations must be done with Unicode if you plan to distribute your software worldwide  :-\

3
General / loadFromFile UNICODE path not working
« on: June 17, 2017, 05:27:34 pm »
I am trying to load a file from this path:

C:\Testи\\pic.jpg

using this code (not using code tag, since it destroy the Cyrillic char):

   std::string file = u8"C:\\Testи\\UnicodePathCheck\\pic.jpg"; //does not work

   sf::Texture tex;
   tex.loadFromFile(file) //returns false



It works fine without the Cyrillic character in the path.

Since SFML does not provide a std::wstring overload, I guess it's impossible to load files from paths with characters outside the ASCII range?!

I checked the sources and figured that underlying stb_image library also would need an update to make this work. std::ifstream refuses to load the file. using std::wifstream with std::wstring works

My questions:

4
General / SFML compatibility context
« on: October 02, 2016, 06:08:20 pm »
Hi,

I am trying to learn OpenGL and use SFML instead of GLFW. Since I want to combine it later on.
Everything is working fine with the Default attributeFlag (compatibility mode). Using the Core profile, gives me an error when calling

window.pushGLStates();
Error is: an internal opengl call failed in texture cpp pushGLStates...

AFAIK its because the OpenGL Core profile won't tolerate immediate calls made by SFML (I read, that SFML still uses the fixed function pipeline for compatibility with older hardware, that's okay)

My Question is:
When using VAOs to paint my nice triangles and semi professional models and then use sf::Text or Shape or Sprite to draw something, will pushGLStates do the trick or will things maybe get messed up at some point?!?!

                // Draw the triangle !
                glDrawArrays(GL_TRIANGLES, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle
                glDisableVertexAttribArray(0);

                window.pushGLStates();

                //---SFML STUFF

                window.popGLStates();
               
        //Maybe more OpenGL Stuff here...

                // Done => Display everything
                window.display();
 

This works fine, I just want to know if I will run into several problems later on, especially when drawing the GUI with SFML for example, using the compatibility mode. I am still learning. Maybe someone can give me a little head start here? :)

5
General discussions / Re: Learning OpenGL with SFML
« on: September 28, 2016, 06:39:24 pm »
Thank you very much Laurent,

these were the informations I was missing. My understanding of OpenGL was a little bit off, but now I get it.
And yeah, that's maybe because I thought SFML is an alternative to GLEW.

I will check out GLEW then and later on glbinding :)

Regards,
Wafthrudnir

6
General discussions / Re: Learning OpenGL with SFML
« on: September 28, 2016, 03:40:26 pm »
Thanks for the answer and the tutorial links :)

I guess my problem really is the SFML header. AFAIK Windows still only supports OpenGL 1.1. GLEW seems to communicate with the driver directly and thus supports the newer OpenGL functions (using this: GetAnyGLFuncAddress etc....

So I guess I also have to include GLEW to get it working with OpenGL 3+?! I thought SFML is an alternative to GLEW x_X

The SFML tutorials state, that it's possible to use SFML graphics module besides plain OpenGL (you have to save the GL states etc.. as stated in the tutorials).


7
General discussions / [SOLVED] Learning OpenGL with SFML
« on: September 27, 2016, 07:34:12 pm »
Hi,

I want to learn some basic OpenGL and use SFML for everything else, no GLUT/GLEW. I found this online tutorials: http://www.opengl-tutorial.org/.

My system supports OpenGL 4.5. And afaik glBegin()-tutorials are outdated. Is it possible to use "modern" openGL with SFML. I get compilation errors with these lines:
                GLuint VertexArrayID;
                glGenVertexArrays(1, &VertexArrayID);
                glBindVertexArray(VertexArrayID);
 

Error is: identifier "glGenVertexArrays" is undefined

So I have 3 questions:
1.) Does OpenGL 4.5 work with SFML? (I would like to use SFML 2D functionality with OpenGL 3D)
2.) glGenVertexXXX is GLEW/GLUT?! Maybe that's why I get the error?!
3.) Any good tutorial or book suggestions for a beginner?! :)
EDIT:
4.) Yeah, maybe I should keep in mind, that not all systems support the latest. Is there some info somewhere which OS supports which version of OpenGL?! .. Edit2.) http://store.steampowered.com/hwsurvey guess most users seem to have at least a OpenGL 3.0 compatible card (compared to DX10) ...

Regards,
Wafthrudnir

Edit: I just read, that under windows the default headers are OpenGL 1.1. Someone suggested to use Glew. urgh...really?! (http://stackoverflow.com/questions/37736829/glgenvertexarrays-not-available-in-c)

I am using Visual Studio 2015, the included GL.h doesn't contain the stated functions and the header says:
BUILD Version: 0004    // Increment this if a change has global effects

Copyright (c) 1985-96, Microsoft Corporation
 
Path is: c:\Program Files (x86)\Windows Kits\8.1\Include\um\gl\GL.h

8
Graphics / Re: Lighten/Darken Brush Photoshop style
« on: July 18, 2015, 02:21:19 am »
Got it, if anyone is interested, here's the code to find all pixels inside a circle:
        static List<Vector2f> FindPixelsOnSprite(CircleShape c, Sprite s)
        {
            List<Vector2f> results = new List<Vector2f>();
            float radius        = c.Radius;
            float width         = s.TextureRect.Width;
            float height        = s.TextureRect.Height;
            float circleCenterX = c.Position.X - s.Position.X;
            float circleCenterY = c.Position.Y - s.Position.Y;

            List<Vector2f> pixels = new List<Vector2f>((int)(width * height));

            for (float iX = 0; iX < width; iX++)
            {
                for (float iY = 0; iY < height; iY++)
                {
                    if (PixelInCircle(circleCenterX, circleCenterY, radius, iX, iY))
                        pixels.Add(new Vector2f(iX, iY));
                }
            }

            return pixels;
        }

        private static bool PixelInCircle(float circleCenterX, float circleCenterY, float radius, float pixelX, float pixelY)
        {
            float dx = circleCenterX - pixelX;
            float dy = circleCenterY - pixelY;
            dx *= dx;
            dy *= dy;
            float distanceSquared = dx + dy;
            float radiusSquared = radius * radius;
            return distanceSquared <= radiusSquared;
        }
 

After clicking, my program looks like this:


Next I have to find the distance of each pixel to the circle origin. :)

9
Graphics / Re: Lighten/Darken Brush Photoshop style
« on: July 18, 2015, 01:22:00 am »
Hi eXpl0it3r,

I attached the project just for the case anyone is willing to help me and wants the complete code instead of the snippet I posted (makes it easier to test stuff, maybe) :)

What do you mean with "actual" brush?
If I have understood you correctly, you mean blend a circle shaped texture onto my sprite?
If I do this and resize my "brush-sprite", the areas wouldn't come out so well I guess, since my brush texture would get distorted?!

My specific question is:

How do I get all the pixels of a sprite within a circle? :D
I am doing something wrong, but can't figure it out right now, maybe someone has a good advice.


Edit:
This is the effect I want to achieve on mouse click:

10
Graphics / Lighten/Darken Brush Photoshop style
« on: July 18, 2015, 01:04:13 am »
Hi,

I want to create a (circle) brush to lighten or darken pixels of a sprite/texture.

I thought about getting all the pixels inside the radius of my circle.
loop through the pixels from the inside to the outside and change the color depending on the distance of the circle origin.

I am struggling with a good way to implement this feature and my implementation seems to suck hard. First step is to find ALL the pixels inside the circle from a sprite ... fails :(

Here's my code:
        static List<Vector2f> FindPixelsOnSprite(CircleShape c, Sprite s)
        {
            List<Vector2f> pixels = new List<Vector2f>();

            float radius = c.Radius;
            float m1 = c.Position.X - s.Position.X;
            float m2 = c.Position.Y - s.Position.Y;

            for (float x = 0; x < s.TextureRect.Width; x++)
            {
                for (float y = 0; y < s.TextureRect.Height; y++)
                {                
                    float dx = x - m1;
                    float dy = y - m2;
                    float distance = dx * dx + dy * dy;

                    if(distance <= c.Radius)
                    {
                        pixels.Add(new Vector2f(x, y));
                    }
                }
            }

            return pixels;
        }
 

I attached my Visual Studio 2013 (Premium) project too ... set the working directory to the project directory, so the program will find the pic.png
Also add the NuGet SFML package (couldn't upload the whole solution)

Maybe you can help me out here :/

Edit:
This is the effect I want to achieve on mouse click:

11
DotNet / Re: RenderWindow as Control with own Render loop
« on: July 16, 2015, 07:04:19 pm »
Run the application loop yourself. The following should get you going.

http://en.sfml-dev.org/forums/index.php?topic=12466.msg87073#msg87073

Thanks zsbzsb for the answer,

but this is not quite what i am looking for. I managed to get it working based on this OpenTK Tutorial:
http://www.opentk.com/doc/chapter/2/glcontrol

The only thing I had to change is the call of Invalidate() to RaisePaintEvent(). So all the SFML stuff get's processed inside the OnPaint-Event of my c# UserControl now.

This way I am able to instantiate more than one SFML-Context/View (Both white rects are SFML-Controls each with it's own context, therefore the different zoom levels etc):


The only annoying thin is that Visual Studio gets an Exception in Design Mode :/ "Can't find module csfml-graphics2" ...
Edit: Never instantiate properties inside the class body ^^

12
DotNet / [SOLVED] RenderWindow as Control with own Render loop
« on: July 15, 2015, 10:49:40 pm »
Hi,

I am using a WinForms UserControl with a private RenderWindow property referencing the UserControl handle.
I am struggleing with the update of my UC. I tried a thread and inside OnPaint (stupid me ;D).

Can anyone think of a good way to get it to work?! :/

Here's my Code:
    using System.Windows.Forms;
    using SFML.Graphics;
    using SFML.System;

    internal class Viewport : UserControl
    {
        private RenderWindow _renderwindow;

        public Viewport()
        {
            _renderwindow = new SFML.Graphics.RenderWindow(this.Handle);
        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            //base.OnPaint(e);
        }

        protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
        {
            //base.OnPaintBackground(pevent);
        }
    }
 

13
Window / Ideas for making user defined controls?
« on: January 09, 2011, 07:59:10 pm »
Just my thoughts:

Abstract class Controls
with Methods like isKeyUp() , isKeyFire(), isKeySpecialMove() (pressed)
setKeyUp() etc...

Then inherited classes:

class KeyboardControl : Controls
class JoystickControl : Controls

overriding the virtual methods of the abstract class.

Both classes handle the input, one for Keyboard and the other for a Joystick. Each class has the setKeyXXX() method. I think because SMFL has Codes for Keyboard and Joystick, this would be a good solution.

You can change the Control while the game is running, just by replacing the Control object. :D

So, in game it would look like this:
Code: [Select]

JoystickControls* joystick = new JoystickControls();
Player p1("Name",joystick);
//playing game...etc...but then user goes to options and chooses keyboard...
KeyboardControls* keyboard = new KeyboardControls();
p1.setControl(keyboard);


Regards,

Wafthrudnir

14
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 06:38:39 pm »
Don't forget, when distributing your app to (e.g.) a friend, you have to ship this dlls with your app. The dlls should be placed in the same folder as the .exe.

15
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 06:32:27 pm »
Try putting the sfml-system-d.dll and all other right into your project folder of Visual Studio and run the program from within VS.

Pages: [1] 2
anything