51 glRasterPos3f(
x,
y, 0);
52 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
54 printf(
"display %s\n", text);
56 for (c = text; *c !=
'\0'; c++) {
57 const uint8_t *bitmap = helvetica10_character_map[*c];
67 static string last_text;
69 if (text != last_text) {
78 const int height = 20;
82 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
83 glColor4f(0.1f, 0.1f, 0.1f, 0.8f);
87 glColor3f(0.5f, 0.5f, 0.5f);
93 glColor3f(1.0f, 1.0f, 1.0f);
99 const int w = (int)((
float)
V.
width / 1.15f);
100 const int h = (int)((
float)
V.
height / 1.15f);
102 const int x1 = (
V.
width -
w) / 2;
104 const int x2 = x1 +
w;
107 const int y1 = (
V.
height - h) / 2;
108 const int y2 = y1 + h;
112 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
113 glColor4f(0.5f, 0.5f, 0.5f, 0.8f);
114 glRectf(x1, y1, x2, y2);
117 glColor3f(0.8f, 0.8f, 0.8f);
138 glColor3f(1.0f, 1.0f, 1.0f);
159 glMatrixMode(GL_PROJECTION);
162 glMatrixMode(GL_MODELVIEW);
165 glClearColor(0.05f, 0.05f, 0.05f, 0.0f);
166 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
168 glMatrixMode(GL_PROJECTION);
172 glMatrixMode(GL_MODELVIEW);
175 glRasterPos3f(0, 0, 0);
215 if (button == SDL_BUTTON_LEFT) {
216 if (
state == SDL_EVENT_MOUSE_BUTTON_DOWN) {
221 else if (
state == SDL_EVENT_MOUSE_BUTTON_UP) {
225 else if (button == SDL_BUTTON_RIGHT) {
226 if (
state == SDL_EVENT_MOUSE_BUTTON_DOWN) {
231 else if (
state == SDL_EVENT_MOUSE_BUTTON_UP) {
260 SDL_GL_MakeCurrent(
V.
window,
nullptr);
285 SDL_Init(SDL_INIT_VIDEO);
286 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
287 SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
288 V.
window = SDL_CreateWindow(title, width, height, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL);
290 LOG_ERROR <<
"Failed to create window: " << SDL_GetError();
297 SDL_GL_MakeCurrent(
V.
window,
nullptr);
305 while (!quit && SDL_PollEvent(&event)) {
306 if (event.type == SDL_EVENT_KEY_DOWN && event.key.key < 128) {
309 else if (event.type == SDL_EVENT_MOUSE_MOTION) {
312 else if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN ||
313 event.type == SDL_EVENT_MOUSE_BUTTON_UP)
315 window_mouse(event.button.button, event.type,
int(event.button.x),
int(event.button.y));
317 else if (event.type == SDL_EVENT_WINDOW_RESIZED) {
320 else if (event.type == SDL_EVENT_QUIT) {
337 SDL_WaitEventTimeout(
nullptr, 100);
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
#define CCL_NAMESPACE_END
#define LOG_INFO_IMPORTANT
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