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

Pages: [1] 2
1
Window / Windows: extended window style (some progress added)
« on: December 23, 2019, 05:08:36 pm »
Hi Everyone,

I would like to create (on Windows 10) a window with an extended style (WS_EX_TOOLWINDOW, which does not create a taskbar icon when active, that's the objective). There is a "com-"way, but that seems complicated.

This code (in the constructor of my app-class) does the "non-extended" style creation (my starting-point):

m_context_settings.antialiasingLevel = 8u;
m_render_window.create ( sf::VideoMode ( 1200u, 150u ), L"yawa", sf::Style::None, m_context_settings );

This works (obviously) perfectly fine.

I worked out the extended style should be something like:

m_context_settings.antialiasingLevel = 8u;
sf::WindowHandle handle = CreateWindowEx ( WS_EX_TOOLWINDOW, TEXT ( "YAWA_CLASS" ), TEXT ( "yawa" ), WS_POPUP, 0, 0, 1200u, 150u,
                                           NULL, NULL, GetModuleHandle ( NULL ), NULL );
m_render_window.create ( handle, m_context_settings );

But this does not work, so I'm missing something (or I am mis-understanding things). Could someone please help me understand what to do?

EDIT1: I have now created a function (using Win32) to (properly this time, I hope) create an extended window and return a handle to it:


    //
    //
    // WndProc - Window procedure (dummy)
    //
    //
    LRESULT
    CALLBACK
    WndProc1 ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {

        switch ( uMsg ) {
            case WM_DESTROY: ::PostQuitMessage ( 0 ); break;
            default: return ::DefWindowProc ( hWnd, uMsg, wParam, lParam );
        }

        return 0;
    }

    HWND make_extended_window ( sf::VideoMode const & vm_ ) {

        HINSTANCE hInstance = ( HINSTANCE ) GetModuleHandle ( NULL );

        WNDCLASSEX wcex{ };

        wcex.cbSize        = sizeof ( wcex );                     // WNDCLASSEX size in bytes
        wcex.style         = CS_HREDRAW | CS_VREDRAW;             // Window class styles
        wcex.lpszClassName = TEXT ( "YAWAWINDOWCLASS" );          // Window class name
        wcex.hbrBackground = ( HBRUSH ) ( COLOR_WINDOW + 1 );     // Window background brush color.
        wcex.hCursor       = LoadCursor ( hInstance, IDC_ARROW ); // Window cursor
        wcex.lpfnWndProc   = WndProc1;                            // Window procedure associated to this window class.
        wcex.hInstance     = hInstance;                           // The application instance.

        // Register window and ensure registration success.
        if ( !RegisterClassEx ( &wcex ) )
            return nullptr;

        // Setup window initialization attributes.
        CREATESTRUCT cs{ };

        cs.cx        = vm_.width;             // Window width
        cs.cy        = vm_.height;            // Window height
        cs.hInstance = hInstance;             // Window instance.
        cs.lpszClass = wcex.lpszClassName;    // Window class name
        cs.lpszName  = TEXT ( "yawa" );       // Window title
        cs.style     = WS_VISIBLE | WS_POPUP; // Window style (sf::Style::None)
        cs.dwExStyle = WS_EX_TOOLWINDOW;      // Extended window style, no taskbar icon.

        // Create the window.
        return ::CreateWindowEx ( cs.dwExStyle, cs.lpszClass, cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy, cs.hwndParent, cs.hMenu,
                                  cs.hInstance, cs.lpCreateParams );
    }

and then at the call-site (the constructor):

    m_context_settings.antialiasingLevel = 8u;
    m_render_window.create ( make_extended_window ( sf::VideoMode ( 1200u, 150u ) ), m_context_settings );

This works sort of. To start with, the window icon is not present on the taskbar (mission achieved). I can write and display something in the window, so many things are good! But if I hover over the window, the cursor starts spinning (not with an ordinary window) and when I click the window, the app crashes. So something is still wrong.

When I look at the relevant constructorhttps://github.com/SFML/SFML/blob/80c3bdc23c1874494196bbf8a481a859712ece88/src/SFML/Window/Win32/WindowImplWin32.cpp#L132 , the right things seem to be happening, this-ptr is plugged in (cs.lpCreateParams) and the WndProc ptr is remapped, still something is wrong.

With this additional info, is there someone who sees the missing bit? Thanks in advance!

2
I was just gonna ask you what the magic incantations were, because I did not find them in the help screens.

So, one cannot convert svg to png using ffmpeg.

3
> ... but I later also found out ffmpeg also can do such conversions (and ffmpeg I do have installed) ...

Same here, I have that installed as well (and did not know about it!).

4
I'm posting a simple,and stupid command-line utility https://github.com/degski/svg2png to convert svg to png (as SFML does not support that format out of the box and there seem to be few on the ground).

It is based on sf-svg, all the credits go to Kamil Koczurek (github.com/kamirr).

I've released a 64-bit statically linked windows executable [in the releases section of the github repository], virustotal.com report linked.

If you have a folder of svg-files to convert (I had 222 of them), this saves you loads of time, and the results are altogether satisfying.

5
Window / Re: Rounded SFML window
« on: April 14, 2019, 11:04:08 am »
I have done some work on this and just for having something to apply it too I created my first Pong, here's a screenshot:



The repo is https://github.com/degski/pong (the above image is resized there)

It depends on https://github.com/degski/Sax (just C++-stuff), and the bit where the transparent/rounded (any shape really) Window related stuff gets done https://github.com/degski/SFML-Extensions (notably: https://github.com/degski/SFML-Extensions/blob/master/sfml-extensions/Extensions.cpp as from line 98).

Needless to say that this kind of manip is Windows only.

6
If a quad with all default-constructed vertices should appear as a white point at coordinates (0, 0).

Thanks Laurent. I got my extra strong spectacles out (not kidding) and had a look. I don't see a white pixel (everything is very dark, so it should have been visible easily (with the spectacles on a 1920*1080 display).

Iff I start seeing it [the white pixel] I'm warned, thanks.

7
Be aware that if you're drawing all of the vertices including the ones that are still in their default state, the shape may not be as expected as those vertices will 'pull' the shape to (0, 0).

I am drawing textured quads with the VertexArray, either a quad is proper (i.e. it's got position, color and texture coords) or it is completely default (all 4 vertices of a particular quad).

I hope(d) that that doesn't create any funny stuff (please comment if you have doubts over this). 

8
I understand, there are no allocations or whatever (they're POD's basically), but I am drawing them, for some animation I will set them to some values later and then when the animation is finished, I will reset (memset) them again. The objective is to keep everything in one sf::VertexArray.

9
A simple quick question [I hope].

Does drawing default constructed Vertices [in a sf::VertexArray] constitute UB and/or does it cause any other trouble?

Doing this appears to not create any problems (Debug or Release), but I just want to be sure!

10
Graphics / Re: Non-Square partially transparent Window (no border)
« on: February 10, 2018, 03:29:30 pm »
"duckduckgoing" doesn't roll of my tongue easily, though...

The Hapax post was the one I was looking for, the list effectively... Next time I find something I might think I need in the future, I'll be pocketing it immediately ;)...

Thanks, eXpl0it3r (and Hapax)...


#include <SFML/Graphics.hpp>
#include <Windows.h>
#include <Dwmapi.h>

#pragma comment ( lib, "Dwmapi.lib" )

void makeWindowSeeThrough ( sf::RenderWindow & window ) noexcept {

    // https://msdn.microsoft.com/en-us/library/windows/desktop/ms644898(v=vs.85).aspx
    // https://en.sfml-dev.org/forums/index.php?topic=21118.msg150860#msg150860

    // TODO: Add error checking...

    HWND hwnd = window.getSystemHandle ( );
    MARGINS margins;
    margins.cxLeftWidth = -1;
    SetWindowLongPtr ( hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE );
    DwmExtendFrameIntoClientArea ( hwnd, &margins );
}


I must say, I do share the OP's enthusiasm for this (is it a hack?)... StockTicker directly projected on the desktop, reminders, a game using a hex-shaped board (I never liked this, like sticking a square peg in a round hole)... the applications seem endless...

Yes it's windows only, surely some of the clever nix-coders can come up with an equivalent... after which this should (IMHO, of course) definitely be added to SFML...

Attached, an impression (it's a WIP) of what's possible..

11
Graphics / Non-Square partially transparent Window (no border)
« on: February 10, 2018, 12:19:24 am »
I was away from SFML for a while, and needed to do some freshing up, but what I would firstly like to state is that SFML is such a great library, consistent, simple (on the surface), and it just works! Thanks to all who have made this possible over the years!

Some days ago I ducked some posts on this forum that seemed to answer my question, I've been clicking and ducking for an hour or so now, and cannot find it anymore, my bad... So, I up front apologise for the question, that I know already has an answer somewhere here on the forum.

What I would like to do is create a window (without borders, no problem), that is partially transparent (in the sense that one can see through parts of it, i.e. see what's behind it). I remember reading that this was, in general, not recommended, but possible on windows.

Could someone either point me to the relevant post(s) (Hapax or eXpl0it3r, if I remember well) or try and put me in the right direction. I'm on Windows 10/1709/x64 and use SFML trunk from a few days ago.

Thanks in advance.

12
Graphics / Re: Pixel Drawing - 0- or 1-based?
« on: April 16, 2016, 03:21:14 pm »
How exactly did you check that? If you draw single pixels (sf::Points primitive) don't forget that their coordinates must be the pixel center, not a corner (thus {0.5, 0.5} if you want to draw the top-left pixel).

I checked that with integer coordinates... I did not forget (about the pixel centre), I didn't know...

Now (weapened with this new info) with 0.5 and 799.5 things work exactly as expected. Laurent, Merci Bocu!!!

13
Graphics / Re: Pixel Drawing - 0- or 1-based?
« on: April 16, 2016, 11:04:23 am »
Having the same issue, but my theory is that Windows 10 draws over the top pixel of a program

Well, I don't think so, as pixel x,800 (on this 800x800 window) does get drawn, which I would not expect...

14
Graphics / Pixel Drawing - 0- or 1-based? [Solved]
« on: April 16, 2016, 08:01:42 am »
Hi All,

I'm seeing (Win10/SFML-2.3.2) the following behaviour, when drawing some pixels to a 800x800 window.

Top left corner:            0,     1
Top right corner:      799,     1
Bottom left corner:       0, 800
Bottom right corner: 799, 800

So it seems the y-component is 1-based, while the x-component is 0-based. I would not expect that. Is this expected behaviour, or a known factoid?

15
Quote
optimising the constructor for speed
only the final texture and sprite need to survive the constructor.

Thanks for that information, I didn't realise that.

Have you tried to just draw the object directly with the blur shader, without all these intermediate drawings to render-textures?

I have tried that, it creates artifacts, the horizontal pass and the vertical pass will effect each other. I am re-using one RenderTexture once (the latest state of affairs is in the top post, maybe that created some confusion).

With the information about the (required) life-time of the texture/sprite I will see whether I can improve thing. I'll update if relevant.

Pages: [1] 2