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

Pages: 1 ... 3 4 [5] 6 7 ... 124
61
Basically, SFML Window module is nice for input handling, and if someone knows how to use it they have two choices when they want to move to DirectX, Vulkan or use software: totally ignore the GL context or use something else.

So my idea is: why not add some flag to turn off/stop SFML from using GL at all, no creating context, no nothing.

This would allow someone to use DirectX, Vulkan or WinAPI themselves. It (making Window work without GL) could also be a stepping stone towards Vulkan coming into SFML in the future.


Woops, this was already done, I don't follow GH so I didn't know such a major thing got into there without going through here.

And a side idea is to add some user data pointer (just set/get void *). WinAPI has a user data pointer for the window handle, but SFML tucks its own Window pointer there. This came up when I did example of handling drag and drop with WinAPI and SFML. Getting list of filenames out of that message handler would require using a global variable or something like that, but if SFML Window had a user data ptr in it then I could get that pointer from window handle and from that pointer get my userdata.

62
No, you need to copy (Ctrl-C, Ctrl-V) the dlls from bin near your exe.

Because of the license openal that SFML uses is under, SFML makes it always be a dll (even if you like audio statically).

Static vs. dynamic linking is broad topic and both have upsides and downsides.

63
If you like dynamically you need to put the corresponding dlls from bin near your exe itself. If you link statically you need to define that macro and link all the dependencies yourself (there's a table in the tutorial) too. No matter what kind of linking you use, if you use audio then openal will be a dll (due to licensing).

64
Did you not define SFML_STATIC? In bin you have dlls, which you don't need except for openal32.dll which is always dll due to licensing covering it. You also need to link all dependencies yourself if you link SFML statically.

65
Window / Re: Draw the window on top of other applications
« on: January 23, 2019, 02:22:17 pm »
Quote
"BringWindowToTop()" does not work.
Yes, it turns out it only worked when I had focus in the console of the program actually.

Quote
SetWindowPos(window.getSystemHandle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
Yes, it works, where did you get that if you don't know these flags? You can read what flags do (NOMOVE and NOSIZE are obvious and that's why those 4 zeroes don't do anything and TOPMOST is why the window ends up on top) on: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setwindowpos

66
Window / Re: Draw the window on top of other applications
« on: January 23, 2019, 12:41:17 am »
On Windows BringWindowToTop will put the window on top but it'll not steal focus/input. And yes, it's obnoxious.

67
Window / Re: Draw the window on top of other applications
« on: January 23, 2019, 12:00:28 am »
Does requestFocus do what you want?

Actually at least on Windows, it won't bring a window to front so on Windows try handle from getSystemHandle with: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-bringwindowtotop


68
General / Re: Making a game playble on other computers
« on: January 19, 2019, 09:35:20 pm »
Yes, I'd say there's little point and if you ever make some mistake in your code that does it that destroys one bit or byte once in a while then you'll spend lots of time trying to find out what's wrong.

But a well made (non-solid and with not too high of a compression ratio) zip or 7z still has a point since one archive is faster to read from than many small files, you can even preload entire archive into RAM which would made it crazy fast or make one file shadow another (for patches, user settings, mods etc.). It'll also be smaller for average end user not only due to compression but also since loose files on disk waste a bit of space due to block size. For development you can still use loose files (that's the point/use of a virtual file system like PHYSFS) and just pack them up when sending the game to people, your game code stays the same.

Just remember to grab latest PHYSFS code from Mercurial since latest stable source code is broken on latest Windows 10 (and badly - you get a failed init + no error message or code at all).

69
General / Re: Static SFML unresolved external symbol
« on: January 19, 2019, 01:41:44 pm »
This doesn't affect the linking but your event loop should be a while loop and pollEvent doesn't always return an event so your code is now sometimes accessing an uninitialized sf::Event structure. You should also add clear and display to your main while loop. And your GPU and RAM amount also wouldn't effect the linking ;D , I wonder what it was though.

70
General discussions / Re: PhysicsFS vs an SFML virutal filesystem
« on: January 18, 2019, 02:22:07 pm »
It's hard not to get a trolling intent from someone when they say things like these with such conviction.

SFML uses own enums, typedefs, void * for memory buffers and structs too. The 'make filesystem only read one kind of endian ever' is a crazy idea.

And PHYS is well behaved with const char *. It never tells you to free a returned const char * so you can always assign a returned one to std::string without a leak and it never frees or keeps one you pass in so you can use c_str.

It's as interoperable as it could ever be without returning and taking std::string itself (which would let you not call c_str and that's it, and forgetting c_str now is a compiler error so it's not like you can make a mistake and have your program break in weird ways).

71
General discussions / Re: PhysicsFS vs an SFML virutal filesystem
« on: January 18, 2019, 01:39:57 am »
Quote
Come on, it's not OO, it's normal procedural C functions like any other.
Most everyone calls this an OO design in C:
https://lwn.net/Articles/444910/
https://en.wikipedia.org/wiki/GObject

Inside PhysFS literally does (in C, by hand) literally same things like C++ does: a vtable of pointers for methods handling different IO types and archive types, members per concrete type, all hidden behind a common interface from physfs.h, etc.

Quote
As for what to do when a function fails, I'd say you should throw an exception: if a file is missing a value you expect it's surely corrupt and you'll have to deal with that. Or as you said yourself you could easily return an int bool pair, or you could return an optional. Plenty of ways to deal with erroneous calls.
Sure. But that's opinionated and mismatches what SFML (and many others) does now and what many people prefer (error codes, some kind of 'optional' template type). :P

Quote
You'd set the endianness for the filesystem because as the developer you know what endianness your data files are. So when the filesystem opens a file for reading, it can automatically convert from that to native, or vice versa for writing.
But you can have files of different endianess. Png and other 'portable' types has big, many Windows originating file types have little. There are even file formats that have some fields in their headers or something that say whether or not to read the ints in that file as big or little endian and you don't know which one it is until you parse the headers so your idea totally dies with such a file.

VirtualFilesystem<VFS_BIG_ENDIAN> filesystem();
filesystem.AddDirectory("search/this/path");
auto file = filesystem.GetFile("filename.ext");
auto num = file.ReadUInt16();
You need to remove () from after filesystem (most vexing parse is the name of this error/compiler mistake).

Anyway - this is crazy. Not only can you not read in another endian within one FS, you need to keep in mind (hundreds of lines away in another function) what kind of FS has made your file, to know what kind of read (big or little) you just did, all so you can write readUInt16 instead of readUInt16BE. You also can't write a function taking VirtualFilesystem easily (forcing everyone to use templates everywhere is not 'easily') because endianess is baked into the FS type for 0 real reason.

And that's more convenient than 10 plain C functions... And the only other 'improvement' over C here is that methods are obj.method and not method(obj) or that you can use std::string too without c_str.

It makes literally no sense to have endianess set on filesystem or even file, when it can (and is) be specified in each function with just few letters like BE, LE, Big, Little. That way you don't have to look around anywhere to file or filesystem constructor or something to find out what endianess you're working with.

IF you think you need these features then you can easily wrap Phys yourself to try, but I think you'll just get burned when you have two files with different endian (big endian is 'portable' or 'network' one so it gets used in some formats, but little one is native to Windows/Intel so its in lots of Windows file formats too) or start forgetting what endian your program is using while in middle of some file parsing or waste more time on this than you'll ever save by not writing func(obj) anymore but obj.method().

Quote
As far as duplicated functionality between SFML and standards, that's all been well-discussed here and in related topics: https://en.sfml-dev.org/forums/index.php?topic=21571.0
Nowhere in there did anyone suggest removing (???) sf::Vector2. We/they are debating removing the 'shortcuts' overloads in some classes (there is setPosition(x, y) and setPosition(vector)) which are there to not force user to keep doing someFunction(sf::Vector2f(x, y)) but with modern C++ they can do someFunction({x, y}) instead which will do the right thing (make a vector) so some people want the shortcut that takes two singular arguments removed (I don't but it's not a big deal and I write sf::Vector2f(x, y) all the time for clarity in cases like these). No one is removing sf::Vector2f itself, there is no 'replacement' for it in C++ or standard libraries of any version.

And the word duplicated doesn't appear in this thread even once. :P

I'm seriously done with this now, I feel like I took troll bait for even talking to someone who wants to force all files in an application to have same endianess to not add BE or LE to a readUint16 function name, finds it hard to use (?) struct Version {int major; int minor; int patch;} or says that C style strings (that are not your responsibility to allocate or free) are hard to use along std::string or that typedefs (that you can ignore and use std::intXX_t on your code) or void * pointer for a memory buffer are weird or complex to use from C++. And to 'fix' these 'problems' we need a VFS in SFML that either wraps or reimplements PhysFS and then add this silly Filesystem<BIG> interface on top of it.

Or says we said we're gonna remove sf::Vector2  ;D

72
General discussions / Re: PhysicsFS vs an SFML virutal filesystem
« on: January 18, 2019, 12:40:02 am »
Quote
I'm really not trolling, I am just saying that PhysicsFS is a C library with all the differences in implementation there are between C libraries and object-oriented C++ libraries.
I would prefer having a file class that provides the requisite functions.
The way PhysFS does File handle is literally OO with private members, virtual functions, etc., just done in C 'by hand' since C doesn't have OO features. The only difference is you go method(file, args) instead of file.method(args). It's a bit more work to know/remember and it works way worse with intelli sense but PhysFS has a laughably small amount of functions for file: close, file length, set internal cache size, read/write bytes, read/write object (deprecated). Plus tons of read/write different endianess of different ints.

Of other functions there's only a handful too like mount, set write dir, get user dir, open read/write file, etc. A C++ rewrite wouldn't effect these ones at all other than letting you not do .c_str on your std::string before passing a path to them. And PhysicsFS makes effort to behave well, e.g. the string given in get user dir isn't allocated for you so you can just do std::string usedir = etc. and there is no leak. Only slightly awkward thing is get list dir but that's such a tiny piece too and it's like 5 lines to make an std::vector<std::string> returning version.

auto file = filesystem.GetFile("file/path/name.ext");
You can use auto in your code already. And what is filesystem? You want a non-global filesystem? That's fair enough but just before you complained about 'custom unstandard data structures' like Version (literally 3 x 8 8 bit int named minor, major and patch number) or ArchiveInfo that is one int (used a boolean) saying if it has symlinks + 4 const chars fields: author, email, extension, name.

auto firstNum = file.ReadUInt16();
What happens when ReadUInt16 fails? Gotta check some other function wasThereError? Exception? They're not that common or widespread in C++ at all (I kinda dislike the trend by now but don't claim that all C++ uses exceptions so it's such a pain you don't have them in C because that's untrue), SFML doesn't use them right now either. Many huge libraries don't either - even Qt doesn't. This also has the problem that someone can do int = file.ReadUInt64() very easily by accident out of habit or something while PHYSFS's version forces you to get a proper sized type var somewhere at least once. This is also a trivial one or two liner to write yourself, even as a template. You can then return a bool + int pair, throw exception, return 0, as you prefer.

Quote
Endianness could be set for the filesystem and returned files using configuration options for the virtual filesystem, or better yet template parameters.
How do you set endianess for a 'filesystem'? Which bytes need swapping depend on how big of an int you're reading and it's not that uncommon for some format to have little endian ints but another to have big endian ones. And why would you bother with a template anywhere in here? Where even? You want Filesystem<Little> and Filesystem<Big> and then everything that uses a Filesystem must also be a template now or have two version of all functions? You want to go from (basically) readWhateverSizeEndianess(file, &variable) to having to think/remember what kind of an endianess of a filesystem you got the file object from and that's a simplification or more convenient to use? Just keep calling same endianess of a function if you want to always have one endian.

Quote
And while you bring up sf::Vector2u, there really are quite a few cases where the SFML types can and ought to be replaced with standards. Those have been discussed already elsewhere, but I'd say those are a pain point too. Not where they actually provide useful functionality, but where they simply duplicate the standards, or are actually less useful. But that's mostly down to C++ versions.
What functionality is duplicated? Is there a standard C++ 2d and 3d point or rect class in C++17 or C++20 or do you really want to replace it with std::pair or std::tuple and then claim it's simpler to have free functions instead of the overloaded operators and do .first and .second or std::get<0> and std::get<1> than having .x and .y?

73
General discussions / Re: PhysicsFS vs an SFML virutal filesystem
« on: January 17, 2019, 11:28:45 pm »
Quote
I would also say that endian-specific functions are worth including in the discussion: they are necessary for cross-platform data handling, and not at all intuitive in PhysicsFS. SFML is a cross platform library, and could do a much better job with this.

I said not to count them because there's so many of them and they are all the same: returning true if it works, taking a file handle and pointer to right int type (so there is no chance you can put it in wrong type like you could with doing a = to a return value).

I seriously feel like you're trolling (or very wrong about something) at this point but okay. How does your good intuitive function for reading an unsigned 16 bit big endian value from a file look like? Or swapping from little to native endian on a 32 bit int. This is the 'unituitive' versions from PHYS for comparison:
int PHYSFS_readUBE16 ( PHYSFS_File * file, PHYSFS_uint16 * val);
PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 val);

Feel free to include any other example of your better idea because right now I really don't get it - we need an entire VFS in SFML so you can no longer write c_str or no longer call close on a file once you're done? If SFML had a VFS it'd have a Stat struct too, probably, and an ArchiveInfo one, all with same fields as PHYSFS has, just const char * would be std::string, and it'd still be same types in all the places, and all custom error/filetype enums, and void * for passing a buffer.

74
General discussions / Re: PhysicsFS vs an SFML virutal filesystem
« on: January 17, 2019, 11:22:11 pm »
Well obviously a library has its own enums for its specific errors. :o

A C string you can just assign to an std::string and then c_str it back to the library and either way it's simple and safe (you'll get a compile error if you forget c_str).

A char *, unsigned char * or void * is how every library handling memory reading/writing does it (SFML streams and C++ iostream included).

The typedefs are same as in SFML and all straightforward since there is only one of each of: 8, 16, 32 and 64 bit type of int and uint. It's a typedef, if you use your own typedef to type of same size it'll work too.

Out of all these structs the only remotely commonly used is maybe PHYSFS_Stat and (if for some reason you want to know what version and formats you have) PHYSFS_ArchiveInfo and PHYSFS_Version. All of them are pure structs you only ever read fields of. They couldn't be simpler. This is like complaining you need to use sf::Vector2u to get sf::Image size and that's confusing because it's a custom struct and you wanted an std::pair or something to 'interoperate' better.

PHYSFS_File you don't "use" in any way, you only get a pointer to it and pass it to read, write and close.

PHYSFS_Io, PHYSFS_Archiver and PHYSFS_Allocator are all very specialized things (own IO, own archive format and own memory alloc). You don't need to use them if all you want to do is read zips, 7zips, isos and normal files. The documentation even has a 'WARNING' telling you not to use them unless you have a very special need and know what you're doing.

The only other 'structured' thing is a file list but that's also trivial to iterate over in a for. PhysFS also doesn't ever deal (except for mounts) with OS specific paths or file permissions, that's its whole point. You're not supposed to use C++17 filesystem path for its files, most of them aren't even files on disk but in archives.

You're the one here saying we 'could use' a virtual filesystem in SFML while claiming its complex to use PhysFS's 10-15 most common functions like 'open' 'close' and 'read bytes' or that there's too many (1? 2?) custom structs or that void * pointer to a memory buffer is unstandard. :o

If SFML had a virtual filesystem it'd look exactly or almost exactly the same as PhysFS, with minor changes like RAII instead of user needing to do close/free, methods instead of a handle + functions that take it (literally same thing with file.func(...) instead of func(file, ...)) and std::string instead of const char * (saving you one c_str when passing a path to it).

75
General discussions / Re: PhysicsFS vs an SFML virutal filesystem
« on: January 17, 2019, 10:26:09 pm »
What non-standard data structures and conventions (other than having to free something yourself) are there in common use cases? :o

Edit: this is a 100% serious question. I really just counted and there is 0 data structures and a total of like 11 or 12 functions for common use, all of them trivial.

Pages: 1 ... 3 4 [5] 6 7 ... 124