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);
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_MOUSEBUTTONDOWN) {
221 else if (
state == SDL_MOUSEBUTTONUP) {
225 else if (button == SDL_BUTTON_RIGHT) {
226 if (
state == SDL_MOUSEBUTTONDOWN) {
231 else if (
state == SDL_MOUSEBUTTONUP) {
240 const int distX = x -
V.
mouseX;
241 const int distY = y -
V.
mouseY;
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,
289 SDL_WINDOWPOS_UNDEFINED,
290 SDL_WINDOWPOS_UNDEFINED,
293 SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
295 fprintf(stderr,
"Failed to create window: %s\n", SDL_GetError());
302 SDL_GL_MakeCurrent(
V.
window,
nullptr);
310 while (!quit && SDL_PollEvent(&event)) {
311 if (event.type == SDL_TEXTINPUT) {
314 else if (event.type == SDL_MOUSEMOTION) {
317 else if (event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP) {
318 window_mouse(event.button.button, event.button.state, event.button.x, event.button.y);
320 else if (event.type == SDL_WINDOWEVENT) {
321 if (event.window.event == SDL_WINDOWEVENT_RESIZED ||
322 event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
327 else if (event.type == SDL_QUIT) {
344 SDL_WaitEventTimeout(
NULL, 100);
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
#define CCL_NAMESPACE_END
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
WindowKeyboardFunc keyboard
WindowDisplayFunc display
thread_mutex gl_context_mutex
CCL_NAMESPACE_BEGIN typedef std::mutex thread_mutex
#define CYCLES_VERSION_STRING
void window_main_loop(const char *title, int width, int height, WindowInitFunc initf, WindowExitFunc exitf, WindowResizeFunc resize, WindowDisplayFunc display, WindowKeyboardFunc keyboard, WindowMotionFunc motion)
void window_opengl_context_disable()
static void window_reshape(int width, int height)
bool window_opengl_context_enable()
void window_display_info(const char *info)
static void window_display()
static void window_mouse(int button, int state, int x, int y)
static void window_display_text(int x, int y, const char *text)
CCL_NAMESPACE_BEGIN struct Window V
static bool window_keyboard(unsigned char key)
void window_display_help()
static void window_motion(int x, int y)
void(* WindowKeyboardFunc)(unsigned char key)
CCL_NAMESPACE_BEGIN typedef void(* WindowInitFunc)()
void(* WindowDisplayFunc)()
void(* WindowMotionFunc)(int x, int y, int button)
void(* WindowResizeFunc)(int width, int height)