Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL build #37

Open
wants to merge 85 commits into
base: master
Choose a base branch
from
Open

SDL build #37

wants to merge 85 commits into from

Conversation

bobsayshilol
Copy link

@bobsayshilol bobsayshilol commented Oct 15, 2022

This PR gets delta-studio building on both Linux and Mac Edit: just Linux (though Mac doesn't run due to lack of GL support). Windows was tested and still builds and runs (for me).

Main changes include:

The work couldn't have been done without the help of @phire, @space55, @rhysperry111, and @jakelstr, as well as others on the discord server.

Note: this is a rebased #34 with additional stuff and is intended to replace it.

phire and others added 30 commits October 12, 2022 16:10
This allows subclasses to be enabled-disabled at compile-time simply
by if the ysRegisterSubclass instantiation is linked in.
This is probably a horrible idea, my original plan was to replace all uses
of _s functions with std::string where possible.

But they are everywhere in the codebase. and we need to do this port in
smaller steps. So this is the more sane solution in the short term.

Ideally we will remove these later
Does microsoft have a specialization for when the desitnation is a fixed
size buffer? Or is this a bug?
Lets not reinvent the wheel, it will be faster and less error prone to
use c++'s built in buffering and padding.

And I needed to get rid of some _s functions anyway. Also, despite using
the safe functions, this code still had a potential buffer overrun.
From memory, microsoft leave a non-std:: version of these lying around
as a landmine for cross-platform compatibility.
I think these are leftover, we will see if this causes any errors down the line
Arguably, it should be Hidden. But the existing behavour of the Win32
Windowing system is Visable, and lets keep that for now
Also use size_t's and add a template for the "no size provided" calls.
This is basically a copy of the Windows impl, but with some of the
extensions that aren't required removed.
Also remove Windows.h since the headers include them anyway if they're
required on your platform.
I'm not sure what's going on on other platforms, but having this here
causes the compiler to always pick this rather than waiting on the
linker to pick the externally implemented ones.
Spotted by GCC because that last argument isn't a pointer so it
shouldn't have been NULL.
These are Windows GL methods that don't need to exist on other platforms
Forgot to add this on first pass of the SDL context
Not sure how I missed this before...
The size must be a multiple of the alignment and the alignment must be
a power of 2, so static assert on the alignment and round up the size
if necessary.
delete isn't able to deduce the type of the object it's destroying
since it's the caller that runs the destructor. So we need to make sure
that types are as expected before calling the delete.
rhysperry111 and others added 22 commits October 12, 2022 16:11
This bug was probably caused by me when I added the GL flag, oops...
ASAN picks up that we're indexing out-of-bounds if the button is
Undefined, so don't do that since it's not going to be a valid
character for the input buffer.
Without this we can get use-after-frees when quitting.
The programs try to access the destroyed shaders as part of their
destruction, so move it that to before the shaders are destroyed.

tbh I'm not sure there should be a dependency here and destruction
could happen in any order.
This is by far the largest leak, but it only happens once AFAICT. Also
move some allocations to after a return statement that would also cause
a leak.
Most of the large leaks are now dealt with.
These are handled by the templates now.
Hopefully all are obvious why they're necessary.
This will come in useful in the following commit.
This way we get the same behaviour on all platforms, and RAII is just
nice to have.
Without this the register's constructor is never called.
The order of static ctors is undefined so we don't want this to nuke
any that have already registered (seen on Windows).
GCC complains that ysVector has special attributes that would be
ignored if used as a template (since ysVector is just a float), so wrap
it in a config-like struct to tell the allocation what to do.
GL and Vulkan need to have their windows configured in a special way in
order for them to be useable, so that info is required up-front.

Also add a commented out version of what's required for Metal.
Also remove unused member.
Also add the missing ones.
"There's nothing more permanent than a temporary fix"
@BenJuan26
Copy link

How are you managing to build this on Mac? There is a typo here, and SDL includes on Mac don't use a subdirectory.

@jakelstr
Copy link

jakelstr commented Oct 15, 2022 via email

@BenJuan26
Copy link

Ah ok so the description needs to be corrected

This is noted on cppreference, so it's not a good abstraction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants