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

Pages: [1] 2 3
1
Graphics / How to draw Texture with black and white colors?
« on: February 22, 2019, 10:41:45 am »
I draw Texture on circle shape and it works. All textures are colored.
But I want to draw it with black and white tints in some cases.
Is it possible with no need to modify image and no need to load second copy of texture (black and white version)?

2
Graphics / CSFML 2.3 render text GetLocalBounds bug
« on: May 29, 2016, 04:25:32 pm »
I'm using UbuntuMono-R.ttf
MD5: 9383F4B0BC1D264A5A7E094EB1ED0C0B
Link: http://db.onlinewebfonts.com/t/9383f4b0bc1d264a5a7e094eb1ed0c0b.ttf

It's monospace font, and it works fine with different strings - all letters with the same size.

But now I found two strings, for which Text::GetLocalBounds returns incorrect sizes.
It happens with Text::CharacterSize = 20.

Example:

string "Level:" => size = [59; 26] (bounds = [FloatRect] Left=2; Top=6; Width=55; Height=14)
string "Xp:   " => size = [60; 30] (bounds = [FloatRect] Left=0; Top=7; Width=60; Height=16)

I'm calculate text size from bounds with the following code:
        public static Vector2f MeasureText(this Text text)
        {
            var bounds = text.GetLocalBounds();
            var size = new Vector2f(bounds.Width, bounds.Height);
            var padding = new Vector2f(bounds.Left, bounds.Top);
            return size + padding * 2F;
        }
 

For both strings GetLocalBounds should return the same size.

Is it really CSFML 2.3 bug? Or may be it's just incorrect way to calculate the text size?
How to fix it in order to get the same size for both strings. Because the font is monospace.

3
System / sfml.net crash in opengl.dll module
« on: February 17, 2016, 10:39:33 am »
I found issue with opengl crash. It happens when app was working in fullscreen mode and system is going into sleep mode. App was worked for several hours. I catch it on Windows 7.

App crash was reported by system in the module opengl32.dll:
Quote
Faulting application name: Client.exe, version: 1.0.0.0, time stamp: 0x56c36bff
Faulting module name: OPENGL32.dll, version: 6.1.7600.16385, time stamp: 0x4a5be02b
Exception code: 0xc0000005
Fault offset: 0x00000000000dd064
Faulting process id: 0x1298
Faulting application start time: 0x01d168fb82708356
Faulting application path: G:\SRC\_binrelease\Client.exe
Faulting module path: C:\Windows\system32\OPENGL32.dll
Report Id: ed8b0910-d558-11e5-8c29-005056c00008

I'm using SFML.NET binding (CSFML 2.3)

Before this crash the following error was happened:
Quote
Application: Client.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
   at SFML.Graphics.Context.sfContext_create()
   at SFML.Graphics.Context.sfContext_create()
   at SFML.Graphics.Context.get_Global()
   at SFML.Graphics.Texture.Destroy(Boolean)
   at SFML.ObjectBase.Dispose(Boolean)
   at SFML.ObjectBase.Finalize()

It seems like invalid finalizer implementation

4
here is short example which demonstrates the issue:

(click to show/hide)

I tried different ways but didn't found any solution to this.
Those distortions and moire looks very bad with some scale values.
Could you please help me to eliminate those weird distortions?

May be there is any way to fix it with some kind of shaders and post processing effects?

Also it looks much worse on the system which doesn't support MSAA (OpenGL 2.3).
Is there any way to fix it? May be there is any kind of software MSAA?

Here is screenshot:

5
Graphics / [SOLVED] how to render line with SFML?
« on: December 03, 2015, 01:01:13 am »
I need to render simple line from point V1 to point V2 with thickness N.
How can I do it with SFML?

I know about Window.Draw with primitive type Line, but it render one pixel line. I need to specify line thickness.

6
Graphics / sf::Clock and SetThreadAffinity
« on: November 18, 2015, 04:44:51 pm »
Oh god, setting it to fullscreen made all of my windows go to my right monitor, and disabled aero theme.
I also didn't even see my game I just saw a hugely zoomed in version of my desktop.

Force closed it and nothing responded for around 10 seconds.

Don't want to do that again.

So yeah still not sure what to do about the stuttering.

Try to not use sf::Clock, it has a bug inside (call to setthreadaffinity), so it may cause lags.

Just use QueryPerformanceCounter instead of sf::Clock.

Also, add setverticalsync call. It should be called together with setframelimit, because there is a bug in SFML. So if you're using vertical sync enabled, then don't forget to call setframelimit(0)

7
Graphics / Is there any way to eliminate aliasing?
« on: November 15, 2015, 01:25:53 am »
I'm already using AA=16, so there is even fonts looks a little blurry.
But when I drawing lines with RenderWindow.Draw (with PrimitiveType.Lines) and change View zoom and position, the result is still aliased. It looks very ugly and each line jumps from pixel to pixel when view position or zoom is changed.
So, how can I draw antialiased lines?

8
Graphics / ListView control with SFML
« on: November 12, 2015, 02:55:37 pm »
I need to implement some kind of entity list view with SFML. It should support vertical scroll and several columns.
What is the best approach to achieve it?

9
General / false trigger of mouse event
« on: November 11, 2015, 07:04:35 pm »
I'm using mouse button in my game to capture control of some entity. so, while mouse button is pressed I can move entity. And it works well.
But I catch some weird bug, sometimes when I hold mouse button pressed, it rases several pressed/released events, so I lose control on desired entity. It happens rare, so I cannot catch it under debugger. I added logging and all what I can see that there are some false triggered pressed/release event. Is there any way to prevent fire of unexpected pressed/released event when mouse button state actually didn't changed and it is still pressed?

10
Graphics / How to check video memory statistics?
« on: November 09, 2015, 04:34:29 am »
I need to load a lot of different images, so I want to get some kind of video memory statistics to implement some cache which will unload unused images. I need to know when available amount of video memory is too low.
So, is there any way to get total available video memory and used video memory?

11
Window / Key pressed event bugs
« on: October 26, 2015, 12:36:50 pm »
I found that KeyPressed event works incorrecly with language different than english.
Such event should produce keyCode which is independent on the keyboard localization.
For example if I presaing "q" it should always get keyCode Q. But it get localized chararacter instead of keyCode. It's really annoying bug, because there is no way to handle key independent feom current keyboard language.
Localized characters is good for TextEntered event, but it's real head pain for KeyPressed event.

I even can't imagine the reason why KeyPressed event returns localized characters instead of key codes. It's completely useless and meaningless.

It means that control keys, such as WASD for movement, will not works if a non-english keyboard is currently selected. So the user will not be able to control the game and even will not be able to know why.

12
Window / strange issue with fullscreen mode
« on: October 24, 2015, 01:26:57 am »
I found a strange issue which happens in fullscreen mode only.
When I'm trying to get a screenshot with Print Screen key in fullscreen mode, I get an image which were actually shown some time ago, but not at the moment of taking screenshot.
With windowed mode all works as expected.
I reproduced it on Windows 7 x64.
Why it happens?

13
Audio / How to play several sound effects simultaneously?
« on: October 23, 2015, 01:40:47 pm »
I need to play several sound effects simultaneously. Actually it's short ogg files which should be played on game events. Game events sometimes may happens very quickly, so there is need to play it simultaneously.
Currently I'm create 3 Sound objects and use first ready instance to play the effect.
But sometimes it happens that all 3 Sound objects is busy (already playing some effects) and in such case the next effect is just skipped.
I think it's not a good idea to create 5-10 Sound objects for such purposes.
So, is there any better way to play several sound effects simultaneously?

14
DotNet / Drawing circle segment
« on: October 17, 2015, 03:01:32 am »
I written a small function to render circle segment. It seems that it works ok.
Please review it, may be I didn't take into account something :)

        private static void DrawCircleSegment(
            RenderWindow window,
            Vector2f origin,
            float radius,
            float angle,
            float length,
            Color color,
            int maxPoints)
        {
            var ptCount = (int)(length * maxPoints / 2D * Math.PI + 0.5F);
            ptCount = Math.Min(ptCount, 2);
            ptCount = Math.Max(ptCount, maxPoints);
            var arc = GeometryHelper.CreateArcGeometry(radius, angle, length, ptCount);
            var center = new Vector2f(0F, 0F);
            var vertices = arc
                .Zip(arc.Skip(1), (p1, p2) => new[] { center, p1, p2, })
                .SelectMany(arg => arg)
                .Select(arg => new Vertex(origin + arg, color));
            window.Draw(vertices.ToArray(), PrimitiveType.Triangles);
        }

    public static class GeometryHelper
    {
        public static Vector2f[] CreateArcGeometry(
            float radius,
            float angle,    // 0F...2*PI
            float length,   // 0F...2*PI
            int segmentCount)
        {
            var theta = length / segmentCount;
            var sin = (float)Math.Sin(theta);
            var cos = (float)Math.Cos(theta);
            var point = new Vector2f(
                radius * (float)Math.Cos(angle),
                radius * (float)Math.Sin(angle));
            var result = new Vector2f[segmentCount + 1];
            for (var i = 0; i < result.Length; i++)
            {
                result[i] = point;
                point = new Vector2f(
                    cos * point.X - sin * point.Y,
                    sin * point.X + cos * point.Y);
            }
            return result;
        }
    }
 

15
Window / strange fullscreen behavior
« on: October 16, 2015, 04:16:10 pm »
I found some strange behavior with using fullscreen mode.
When I open app in the full screen, then switch it to windowed mode, the screen is blinking on app closing. It seems like video mode switch. It's strange, because app is already switched to window mode, so it should restore original video mode when I switched it to windowed mode, but it doing it on app close.
What happens exactly with display on app close and how to eliminate such blinking?

Pages: [1] 2 3