1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#include "SDL2/SDL.h"
#include "SDL2/SDL_syswm.h"
#include "bgfx/c99/bgfx.h"
#include "rodeo.h"
//static Rodeo__Data_t Rodeo__State = { 0 };
void
Rodeo__\
init_window(
Rodeo__Data_t* state,
int screen_height,
int screen_width,
char* title
)
{
state->window = NULL;
state->screen_surface = NULL;
state->screen_height = screen_height;
state->screen_width = screen_width;
if(SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
state->window = SDL_CreateWindow(
title,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
screen_width,
screen_height,
SDL_WINDOW_SHOWN
);
if(state->window == NULL)
{
printf("Window could not be created! SDL_Error %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
SDL_VERSION(&state->wmi.version);
if(
!SDL_GetWindowWMInfo(
state->window,
&state->wmi
)
)
{
printf("SDL_Error %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
bgfx_render_frame(-1);
bgfx_platform_data_t pd;
memset(&pd, 0, sizeof(bgfx_platform_data_t));
pd.ndt = state->wmi.info.x11.display;
pd.nwh = (void*)(uintptr_t)state->wmi.info.x11.window;
bgfx_init_t init = {0};
bgfx_init_ctor(&init);
init.type = BGFX_RENDERER_TYPE_COUNT; // auto determine renderer
init.resolution.width = state->screen_width;
init.resolution.height = state->screen_height;
init.resolution.reset = BGFX_RESET_VSYNC;
init.platformData = pd;
bgfx_init(&init);
bgfx_reset(state->screen_width, state->screen_height, BGFX_RESET_VSYNC, init.resolution.format);
bgfx_set_debug(BGFX_DEBUG_TEXT);
bgfx_set_view_clear(
0,
BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH,
0x443355FF,
1.0f,
0
);
bgfx_set_view_rect(0, 0, 0, state->screen_width, state->screen_height);
bgfx_touch(0);
bgfx_frame(false);
}
void
Rodeo__\
deinit_window(Rodeo__Data_t* state)
{
bgfx_shutdown();
SDL_DestroyWindow(state->window);
}
void
Rodeo__\
quit()
{
SDL_Quit();
}
void
Rodeo__\
begin(Rodeo__Data_t* state)
{
}
void
Rodeo__\
end(Rodeo__Data_t* state)
{
while(SDL_PollEvent(&state->sdl_event))
{
if(state->sdl_event.type == SDL_QUIT)
{
state->quit = true;
}
}
bgfx_touch(0);
bgfx_frame(false);
}
|