50 glRasterPos3f(
x,
y, 0);
51 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
53 printf(
"display %s\n", text);
55 for (c = text; *c !=
'\0'; c++) {
56 const uint8_t *bitmap = helvetica10_character_map[*c];
66 static string last_text;
68 if (text != last_text) {
77 const int height = 20;
81 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
82 glColor4f(0.1f, 0.1f, 0.1f, 0.8f);
86 glColor3f(0.5f, 0.5f, 0.5f);
92 glColor3f(1.0f, 1.0f, 1.0f);
98 const int w = (int)((
float)
V.
width / 1.15f);
99 const int h = (int)((
float)
V.
height / 1.15f);
101 const int x1 = (
V.
width -
w) / 2;
103 const int x2 = x1 +
w;
106 const int y1 = (
V.
height - h) / 2;
107 const int y2 = y1 + h;
111 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
112 glColor4f(0.5f, 0.5f, 0.5f, 0.8f);
113 glRectf(x1, y1, x2, y2);
116 glColor3f(0.8f, 0.8f, 0.8f);
137 glColor3f(1.0f, 1.0f, 1.0f);
158 glMatrixMode(GL_PROJECTION);
161 glMatrixMode(GL_MODELVIEW);
164 glClearColor(0.05f, 0.05f, 0.05f, 0.0f);
165 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
167 glMatrixMode(GL_PROJECTION);
171 glMatrixMode(GL_MODELVIEW);
174 glRasterPos3f(0, 0, 0);
214 if (button == SDL_BUTTON_LEFT) {
215 if (
state == SDL_MOUSEBUTTONDOWN) {
220 else if (
state == SDL_MOUSEBUTTONUP) {
224 else if (button == SDL_BUTTON_RIGHT) {
225 if (
state == SDL_MOUSEBUTTONDOWN) {
230 else if (
state == SDL_MOUSEBUTTONUP) {
259 SDL_GL_MakeCurrent(
V.
window,
nullptr);
284 SDL_Init(SDL_INIT_VIDEO);
285 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
286 SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
287 V.
window = SDL_CreateWindow(title,
288 SDL_WINDOWPOS_UNDEFINED,
289 SDL_WINDOWPOS_UNDEFINED,
292 SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
294 fprintf(stderr,
"Failed to create window: %s\n", SDL_GetError());
301 SDL_GL_MakeCurrent(
V.
window,
nullptr);
309 while (!quit && SDL_PollEvent(&event)) {
310 if (event.type == SDL_TEXTINPUT) {
313 else if (event.type == SDL_MOUSEMOTION) {
316 else if (event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP) {
317 window_mouse(event.button.button, event.button.state, event.button.x, event.button.y);
319 else if (event.type == SDL_WINDOWEVENT) {
320 if (event.window.event == SDL_WINDOWEVENT_RESIZED ||
321 event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
326 else if (event.type == SDL_QUIT) {
343 SDL_WaitEventTimeout(
nullptr, 100);
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
#define CCL_NAMESPACE_END
WindowKeyboardFunc keyboard
WindowDisplayFunc display
thread_mutex gl_context_mutex
#define CYCLES_VERSION_STRING
static void window_motion(const int x, const int y)
void window_opengl_context_disable()
bool window_opengl_context_enable()
void window_display_info(const char *info)
static void window_mouse(const int button, const int state, const int x, int y)
void window_main_loop(const char *title, const int width, const int height, WindowInitFunc initf, WindowExitFunc exitf, WindowResizeFunc resize, WindowDisplayFunc display, WindowKeyboardFunc keyboard, WindowMotionFunc motion)
static void window_display()
static void window_reshape(const int width, const int height)
CCL_NAMESPACE_BEGIN struct Window V
static void window_display_text(int, int, const char *text)
static bool window_keyboard(unsigned char key)
void window_display_help()
void(*)(unsigned char) WindowKeyboardFunc
void(*)(int, int, int) WindowMotionFunc
void(*)() WindowDisplayFunc
void(*)(int, int) WindowResizeFunc