Gargaj / fwzSetup

Simple resolution enumerator / selector for demos (or games)
7 stars 0 forks source link

Example of how to use the resolution selector? #1

Closed pkanyuk closed 5 years ago

pkanyuk commented 5 years ago

Hi Gargaj,

I just gave the code in this repo a try, and while I can get it to run, I'm not able to get the dialog to show up. Admittedly, I'm a newb to demoscene and windows programming, so I'm going off this example:

https://github.com/anttihirvonen/demoscene-starter-kits/blob/master/windows/Windows1k_OpenGL/1kogl/main.cpp

I tried passing setup.srcWidth and setup.srcHeight following the call to OpenSetupDialog(), to CreateWindowExA(), but I'm not even sure if that's the right boiler plate to open a window. Basically what I'm curious about is an example that shows how your dialog is used end to end if possible.

Thanks! -- Paul

Gargaj commented 5 years ago

https://github.com/Gargaj/fwzSetup/blob/master/main.readme.cpp should provide you a good enough example; basically you set the values before the function call to set the "defaults", then call the function to pop the dialog with those values, and then the struct will contain the values the user selected.

pkanyuk commented 5 years ago

Thanks for the reply, I appreciate the help!

Gotcha, I did follow the steps in main.readme.cpp and that's roughly what i was expecting. Unfortunately I don't see a dialog popup and the code seemly proceeds. Should the program lock until the dialog pops up or do I need to loop until a certain condition is met?

I suspect the problem may also be in the windowing boiler plate I'm using based on https://github.com/anttihirvonen/demoscene-starter-kits/blob/master/windows/Windows1k_OpenGL/1kogl/main.cpp#L53 . That's why I'm curious if you could provide a few more lines in main.readme.cpp which shows how the values set by the dialog are used to create a new window.

Thanks! -- Paul

Gargaj commented 5 years ago

Did you add the .rc file into your solution?

pkanyuk commented 5 years ago

Yup, I'm using Visual Studio and I have the FWZ.rc file under Resources Files, and resource.h under the headers. I don't know Visual Studio very well, but it seems like that's what's required

Gargaj commented 5 years ago

Hmf, that's a good question then, OpenSetupDialog should pop the dialog no matter what you pass it as long as it's "relatively" correct.

Does execution stop when you hit that line or does it just pass through without popping a dialog?

pkanyuk commented 5 years ago

Execution does not stop when it hits the line:

if (!OpenSetupDialog(&setup)) return -1;

If I simply use "return -1;", then execution will stop, so OpenSetupDialog is being called. I wonder though about some visual studio misconfiguration silently allowing this to fail. I should probably start from a blank solution to rule out something about the one I inherited from

https://github.com/anttihirvonen/demoscene-starter-kits/blob/master/windows/Windows1k_OpenGL/1kogl/main.cpp

Thanks, -- Paul

Gargaj commented 5 years ago

If it's an 1k thing then it's possible that resources get optimized out; so yeah, blank solution recommended and then move stuff over slowly :)

pkanyuk commented 5 years ago

Yup, it's something about the 1k project. In a blank solution, your code works great, so I know where to look now for the issue. The only things I needed to change were replacing _snprintf with _snprintf_s and giving char s[500] a different variable name to appease some build errors.

Sorry about the false alarm, thanks for helping me debug!

Gargaj commented 5 years ago

What I'd check is whether in the optimized solution, the resources actually end up in the executable - for example, I assume if the 1k solution uses Crinkler to compress in the post-build step, then they get stripped out because generally there's no use for them in 1k.