Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
vkd3d
Manage
Activity
Members
Labels
Plan
Wiki
Bugzilla
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wine
vkd3d
Commits
110edf32
Commit
110edf32
authored
2 weeks ago
by
Henri Verbeet
Browse files
Options
Downloads
Patches
Plain Diff
demos: Add basic DPI handling.
parent
21e08955
No related branches found
No related tags found
1 merge request
!1432
demos: Add basic DPI handling.
Pipeline
#39719
skipped
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
demos/demo_win32.h
+17
-0
17 additions, 0 deletions
demos/demo_win32.h
demos/demo_xcb.h
+14
-0
14 additions, 0 deletions
demos/demo_xcb.h
demos/gears.c
+4
-0
4 additions, 0 deletions
demos/gears.c
demos/triangle.c
+4
-0
4 additions, 0 deletions
demos/triangle.c
with
39 additions
and
0 deletions
demos/demo_win32.h
+
17
−
0
View file @
110edf32
...
...
@@ -31,6 +31,8 @@ struct demo
void
*
user_data
;
void
(
*
idle_func
)(
struct
demo
*
demo
,
void
*
user_data
);
UINT
(
*
GetDpiForSystem
)(
void
);
};
struct
demo_window
...
...
@@ -48,6 +50,11 @@ struct demo_swapchain
IDXGISwapChain3
*
swapchain
;
};
static
inline
void
demo_get_dpi
(
struct
demo
*
demo
,
double
*
dpi_x
,
double
*
dpi_y
)
{
*
dpi_x
=
*
dpi_y
=
demo
->
GetDpiForSystem
();
}
static
inline
struct
demo_window
*
demo_window_create
(
struct
demo
*
demo
,
const
char
*
title
,
unsigned
int
width
,
unsigned
int
height
,
void
*
user_data
)
{
...
...
@@ -191,6 +198,11 @@ static inline void demo_process_events(struct demo *demo)
}
}
static
inline
UINT
demo_GetDpiForSystem
(
void
)
{
return
96
;
}
static
inline
bool
demo_init
(
struct
demo
*
demo
,
void
*
user_data
)
{
WNDCLASSEXW
wc
;
...
...
@@ -215,6 +227,11 @@ static inline bool demo_init(struct demo *demo, void *user_data)
demo
->
user_data
=
user_data
;
demo
->
idle_func
=
NULL
;
if
((
demo
->
GetDpiForSystem
=
(
void
*
)
GetProcAddress
(
GetModuleHandleA
(
"user32"
),
"GetDpiForSystem"
)))
SetProcessDPIAware
();
else
demo
->
GetDpiForSystem
=
demo_GetDpiForSystem
;
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
demos/demo_xcb.h
+
14
−
0
View file @
110edf32
...
...
@@ -198,6 +198,20 @@ static inline xcb_screen_t *demo_get_screen(xcb_connection_t *c, int idx)
return
NULL
;
}
static
inline
void
demo_get_dpi
(
struct
demo
*
demo
,
double
*
dpi_x
,
double
*
dpi_y
)
{
xcb_screen_t
*
screen
;
if
(
!
(
screen
=
demo_get_screen
(
demo
->
connection
,
demo
->
screen
)))
{
*
dpi_x
=
*
dpi_y
=
96
.
0
;
return
;
}
*
dpi_x
=
screen
->
width_in_pixels
*
25
.
4
/
screen
->
width_in_millimeters
;
*
dpi_y
=
screen
->
height_in_pixels
*
25
.
4
/
screen
->
height_in_millimeters
;
}
static
inline
struct
demo_window
*
demo_window_create
(
struct
demo
*
demo
,
const
char
*
title
,
unsigned
int
width
,
unsigned
int
height
,
void
*
user_data
)
{
...
...
This diff is collapsed.
Click to expand it.
demos/gears.c
+
4
−
0
View file @
110edf32
...
...
@@ -849,12 +849,16 @@ static int cxg_main(void)
{
unsigned
int
width
=
300
,
height
=
300
;
struct
cx_gears
cxg
;
double
dpi_x
,
dpi_y
;
memset
(
&
cxg
,
0
,
sizeof
(
cxg
));
if
(
!
demo_init
(
&
cxg
.
demo
,
&
cxg
))
return
EXIT_FAILURE
;
demo_set_idle_func
(
&
cxg
.
demo
,
cxg_idle
);
demo_get_dpi
(
&
cxg
.
demo
,
&
dpi_x
,
&
dpi_y
);
width
*=
dpi_x
/
96
.
0
;
height
*=
dpi_y
/
96
.
0
;
cxg
.
window
=
demo_window_create
(
&
cxg
.
demo
,
"Vkd3d Gears"
,
width
,
height
,
&
cxg
);
demo_window_set_key_press_func
(
cxg
.
window
,
cxg_key_press
);
demo_window_set_expose_func
(
cxg
.
window
,
cxg_expose
);
...
...
This diff is collapsed.
Click to expand it.
demos/triangle.c
+
4
−
0
View file @
110edf32
...
...
@@ -368,12 +368,16 @@ static int cxt_main(void)
{
unsigned
int
width
=
640
,
height
=
480
;
struct
cx_triangle
cxt
;
double
dpi_x
,
dpi_y
;
memset
(
&
cxt
,
0
,
sizeof
(
cxt
));
if
(
!
demo_init
(
&
cxt
.
demo
,
NULL
))
return
EXIT_FAILURE
;
demo_get_dpi
(
&
cxt
.
demo
,
&
dpi_x
,
&
dpi_y
);
width
*=
dpi_x
/
96
.
0
;
height
*=
dpi_y
/
96
.
0
;
cxt
.
window
=
demo_window_create
(
&
cxt
.
demo
,
"Vkd3d Triangle"
,
width
,
height
,
&
cxt
);
demo_window_set_expose_func
(
cxt
.
window
,
cxt_render_frame
);
demo_window_set_key_press_func
(
cxt
.
window
,
cxt_key_press
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment