2 registered members (AndrewAMD, Ayumi),
853
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Regarding Lite-C and API-Calls
#252425
02/18/09 07:55
02/18/09 07:55
|
Joined: Feb 2009
Posts: 33 Germany, Hamburg
Vorick
OP
Newbie
|
OP
Newbie
Joined: Feb 2009
Posts: 33
Germany, Hamburg
|
Hi there, I just returned to 3DGS after a couple of years and Lite-C is quite new to me. The best way for me to learn a new programming language is to solve simple tasks, but the one I gave myself now is not quite that simple to me, so I'm asking for help. I'm trying to use an API-Call to read the first available screen resolution using "EnumDisplaySettings". After a little research I found out that I have to define a structure to contain the returned values of this call. Trouble is, that I don't know how to access the returned values, so I'd appreciate any help. This is my code so far: #include <acknex.h> // Pure-Mode
#include <default.c> // Standard-Keys
#include <windows.h> // Windows-API-Calls
typedef struct _devicemode {
DWORD dmBitsPerPel;
DWORD dmPelsWidth;
DWORD dmPelsHeight;
DWORD dmDisplayFlags;
DWORD dmDisplayFrequency;
} SCRMODE;
STRING* rvalue = "Test";
TEXT* doutput =
{
pos_x = 50;
pos_y = 50;
layer = 1;
string (rvalue);
flags = VISIBLE;
}
void main()
{
var rvalue;
d3d_antialias = 1;
video_mode = 8;
video_screen = 2;
wait(1);
level_load(_str("title.wmb"));
SCRMODE* resolution;
rvalue = EnumDisplaySettings(NULL, 0, resolution);
} So far I don't get any errors, but I don't really know how to put the return value "rvalue" or the members of "resolution" to use. What I like to do is to display rvalue in doutput.string and after a couple of frames to display the given resolution in the same panel in the format "width x height" (e.g. 800x600). How could I accomplish this. I hope my problem is understandable. Thanks in advance, Patrick PS: I know that EnumDisplaySettings uses a structure with more values of the DEVMODE-Type, but only the five given values are used by EnumDisplaySettings, so I figured that defining only those five needed members should be enough.
Last edited by Vorick; 02/18/09 10:35.
A8.10 Commercial
|
|
|
Re: Regarding Lite-C and API-Calls
[Re: Xarthor]
#252456
02/18/09 11:29
02/18/09 11:29
|
Joined: Feb 2009
Posts: 33 Germany, Hamburg
Vorick
OP
Newbie
|
OP
Newbie
Joined: Feb 2009
Posts: 33
Germany, Hamburg
|
Definitely a nice-to-know function, but sadly not what I'm looking for.
What I intend to do in the end is to get a list of viable resolutions according to the users system and then do a matchup between supported resolutions by my "game". Not that there is any game as of yet, but atm I'm messing around with panels and stuff and trying to create a main menu-settings-screen to get the hang of the Lite-C and 3DGS-workflow.
That's exactly what EnumDisplaySettings does. The parameter "0" gives you the first available resolution. By iterating this parameter until rvalue is false, you can get a list of all resolutions. This is what I'd like to do in the end.
A8.10 Commercial
|
|
|
Re: Regarding Lite-C and API-Calls
[Re: Vorick]
#252550
02/18/09 21:21
02/18/09 21:21
|
Joined: Feb 2009
Posts: 33 Germany, Hamburg
Vorick
OP
Newbie
|
OP
Newbie
Joined: Feb 2009
Posts: 33
Germany, Hamburg
|
Who would have thought that even simple things could be so hard with 3DGS. After two hours of basic trial and error i came up with this: #include <acknex.h> // Pure-Mode
#include <default.c> // Standard-Keys
#include <windows.h> // Windows-API-Calls
typedef struct _devicemode {
DWORD dmBitsPerPel;
DWORD dmPelsWidth;
DWORD dmPelsHeight;
DWORD dmDisplayFlags;
DWORD dmDisplayFrequency;
} SCRMODE;
var rvalue = 0;
var xvalue = 0;
PANEL* pan_results =
{
pos_x = 0;
pos_y = 0;
layer = 1;
flags = OVERLAY | VISIBLE;
digits(0, 40, 4, *, 1, rvalue);
digits(0, 60, 4, *, 1, xvalue);
}
function getscreenres()
{
SCRMODE* resolution;
rvalue = EnumDisplaySettings(NULL, 1, resolution);
}
void main()
{
video_mode = 8;
video_screen = 2;
level_load("title.wmb");
wait(1);
getscreenres();
} At this point I had encountered about three to four dozen SED-Crashes while trying to use printf for small debug outputs. As far as my code goes right now it seems to work. rvalue returns 1 or 0, depending on how high i set the second parameter of EnumDisplaySettings. Now i wanted to use xvalue to fetch the width of the returned resolution inside my resolution pointer. This is what I tried: Version 1: function getscreenres()
{
SCRMODE* resolution;
rvalue = EnumDisplaySettings(NULL, 1, resolution);
xvalue = resolution->dmPelsWidth;
} Version 2: function getscreenres()
{
SCRMODE* resolution;
rvalue = EnumDisplaySettings(NULL, 1, resolution);
xvalue = resolution.dmPelsWidth;
} Both ended up in Error E1513 "Crash in getscreenres". Any ideas how that could be fixed? I think I'm referencing wrong, but according to the manual it should work. Again, any help is appreciated. Patrick
A8.10 Commercial
|
|
|
Re: Regarding Lite-C and API-Calls
[Re: jcl]
#252615
02/19/09 09:03
02/19/09 09:03
|
Joined: Feb 2009
Posts: 33 Germany, Hamburg
Vorick
OP
Newbie
|
OP
Newbie
Joined: Feb 2009
Posts: 33
Germany, Hamburg
|
I'll try it first thing this evening as I get home. Thank you very much.
A8.10 Commercial
|
|
|
Re: Regarding Lite-C and API-Calls
[Re: Vorick]
#252701
02/19/09 20:02
02/19/09 20:02
|
Joined: Feb 2009
Posts: 33 Germany, Hamburg
Vorick
OP
Newbie
|
OP
Newbie
Joined: Feb 2009
Posts: 33
Germany, Hamburg
|
Okay, I tried it with your version of the function getscreenres and ended up without SED-Crashes but still with Error E1513 "Crash in getscreenres". Also xvalue seems to behave eradically. Each test run it changes displaying negative and positive values in the thousands. I also tried the following code without success: function getscreenres()
{
SCRMODE resolution;
rvalue = EnumDisplaySettings(NULL, 1, &resolution); // mind the '&'
xvalue = &resolution.dmPelsWidth; // another '&'
} I must be getting something very basic very wrong.
A8.10 Commercial
|
|
|
Re: Regarding Lite-C and API-Calls
[Re: jcl]
#252834
02/20/09 18:49
02/20/09 18:49
|
Joined: Feb 2009
Posts: 33 Germany, Hamburg
Vorick
OP
Newbie
|
OP
Newbie
Joined: Feb 2009
Posts: 33
Germany, Hamburg
|
Working like a breeze, thank you so much.
Regarding the struct I just did a bit of googeling it up. Seems like I got the wrong sources. But now I'm ready to let things roll.
A8.10 Commercial
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|