18# pragma warning(disable : 4244 4305)
63void rect_bevel_side(
int rect[2][2],
int side,
float *lt,
float *dk,
const float col[3],
int width)
65 int ltidx = (side / 2) % 4;
66 int dkidx = (ltidx + 1 + (side & 1)) % 4;
70 for (
i = 0;
i < width;
i++) {
71 float ltf =
pow(lt[
i], 1.0 / 2.2), dkf =
pow(dk[
i], 1.0 / 2.2);
72 float stf = (dkidx > ltidx) ? dkf : ltf;
73 int lx = rect[1][0] -
i - 1;
74 int ly = rect[0][1] +
i;
76 glColor3f(
col[0] * stf,
col[1] * stf,
col[2] * stf);
77 for (corner = 0; corner < 4; corner++) {
78 int x = (corner == 0 || corner == 1) ? (rect[0][0] +
i) : (rect[1][0] -
i - 1);
79 int y = (corner == 0 || corner == 3) ? (rect[0][1] +
i) : (rect[1][1] -
i - 1);
81 if (ltidx == corner) {
82 glColor3f(
col[0] * ltf,
col[1] * ltf,
col[2] * ltf);
84 if (dkidx == corner) {
85 glColor3f(
col[0] * dkf,
col[1] * dkf,
col[2] * dkf);
89 glVertex2i(lx =
x, ly =
y);
95 glRecti(rect[0][0] + width, rect[0][1] + width, rect[1][0] - width, rect[1][1] - width);
100 float *lt = malloc(
sizeof(*lt) * width);
101 float *dk = malloc(
sizeof(*dk) * width);
105 for (
i = 0;
i < width;
i++) {
106 float v = width - 1 ? ((
float)
i / (width - 1)) : 0;
107 lt[
i] = 1.2 + (1.0 - 1.2) *
v;
108 dk[
i] = 0.2 + (1.0 - 0.2) *
v;
111 glGetFloatv(GL_CURRENT_COLOR,
col);
148 glClearColor(0.5, 0.5, 0.5, 1);
151 glClearColor(1, 1, 1, 1);
153 glClear(GL_COLOR_BUFFER_BIT);
155 glColor3f(0.5, 0.6, 0.8);
171 glViewport(0, 0, mw->
size[0], mw->
size[1]);
173 glMatrixMode(GL_PROJECTION);
175 glOrtho(0, mw->
size[0], 0, mw->
size[1], -1, 1);
176 glTranslatef(0.375, 0.375, 0.0);
178 glMatrixMode(GL_MODELVIEW);
221 for (
i = 0;
i < 10;
i++) {
247 mw->
lmbut[0] = press;
252 mw->
lmbut[1] = press;
255 mw->
lmbut[2] = press;
305 sprintf(buf,
"timer: %6.2f", (
double)((
int64_t)time) / 1000);
312 GHOST_WindowHandle win;
324 GHOST_kDrawingContextTypeOpenGL,
380#define SCROLLBAR_PAD 2
381#define SCROLLBAR_WIDTH 14
382#define TEXTAREA_PAD 2
405 glViewport(0, 0, lw->
size[0], lw->
size[1]);
407 glMatrixMode(GL_PROJECTION);
409 glOrtho(0, lw->
size[0], 0, lw->
size[1], -1, 1);
410 glTranslatef(0.375, 0.375, 0.0);
412 glMatrixMode(GL_MODELVIEW);
432 int i, ndisplines, startline;
433 int sb_rect[2][2], sb_thumb[2][2];
439 glClearColor(1, 1, 1, 1);
440 glClear(GL_COLOR_BUFFER_BIT);
442 glColor3f(0.8, 0.8, 0.8);
448 glColor3f(0.6, 0.6, 0.6);
452 glColor3f(0.6, 0.7, 0.5);
455 glColor3f(0.9, 0.9, 0.92);
463 for (
i = 0;
i < ndisplines;
i++) {
491 lw->
lmbut[0] = press;
509 lw->
lmbut[1] = press;
512 lw->
lmbut[2] = press;
568 uint32_t screensize[2];
569 GHOST_WindowHandle win;
574 posy = screensize[1] - 432;
586 GHOST_kDrawingContextTypeOpenGL,
665 glClearColor(1, 1, 1, 1);
666 glClear(GL_COLOR_BUFFER_BIT);
668 glColor3f(0.8, 0.8, 0.8);
669 glRecti(10, 10, ew->
size[0] - 10, ew->
size[1] - 10);
684 glViewport(0, 0, ew->
size[0], ew->
size[1]);
686 glMatrixMode(GL_PROJECTION);
688 glOrtho(0, ew->
size[0], 0, ew->
size[1], -1, 1);
689 glTranslatef(0.375, 0.375, 0.0);
691 glMatrixMode(GL_MODELVIEW);
708 uint8_t bitmap[16][2];
710 double ftime = (double)((
int64_t)time) / 1000;
711 float angle =
fmod(ftime, 1.0) * 3.1415 * 2;
714 memset(&bitmap, 0,
sizeof(bitmap));
717 bitmap[0][0] |=
mask[0][0] |= 0xF;
718 bitmap[1][0] |=
mask[1][0] |= 0xF;
719 bitmap[2][0] |=
mask[2][0] |= 0xF;
720 bitmap[3][0] |=
mask[3][0] |= 0xF;
722 for (
i = 0;
i < 7;
i++) {
726 mask[
y][
x / 8] |= (1 << (
x % 8));
728 for (
i = 0;
i < 64;
i++) {
729 float v = (
i / 63.0) * 3.1415 * 2;
730 int x = 7 +
cos(
v) * 7;
731 int y = 7 +
sin(
v) * 7;
733 mask[
y][
x / 8] |= (1 << (
x % 8));
736 const int size[2] = {16, 16};
737 const int hot_spot[2] = {0, 0};
782 GHOST_WindowHandle win;
793 GHOST_kDrawingContextTypeOpenGL,
839 GHOST_WindowHandle win;
881 fatal(
"Unable to create ghost system");
886 fatal(
"Unable to add multitest event consumer ");
891 fatal(
"Unable to create main window");
896 fatal(
"Unable to create logger window");
void BLF_size(int fontid, float size)
float BLF_height(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
int BLF_load_default(bool unique)
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
void BLF_position(int fontid, float x, float y, float z)
void BLI_kdtree_nd_ free(KDTree *tree)
void event_to_buf(GHOST_EventHandle evt, char buf[128])
char * eventtype_to_string(GHOST_TEventType type)
GHOST C-API function and type declarations.
int32_t GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle, GHOST_TWindowOrder order)
GHOST_TUserDataPtr GHOST_GetWindowUserData(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_SwapWindowBufferRelease(GHOST_WindowHandle windowhandle)
GHOST_EventConsumerHandle GHOST_CreateEventConsumer(GHOST_EventCallbackProcPtr eventCallback, GHOST_TUserDataPtr user_data)
GHOST_SystemHandle GHOST_CreateSystem(void)
GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
GHOST_TSuccess GHOST_SwapWindowBufferAcquire(GHOST_WindowHandle windowhandle)
bool GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, bool waitForEvent)
void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle, int32_t inX, int32_t inY, int32_t *outX, int32_t *outY)
GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle, GHOST_TStandardCursor cursorshape)
uint64_t GHOST_GetEventTime(GHOST_EventHandle eventhandle)
GHOST_TUserDataPtr GHOST_GetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle)
GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle)
int32_t GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle, const uint8_t *bitmap, const uint8_t *mask, const int size[2], const int hot_spot[2], bool can_invert_color)
GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
GHOST_TSuccess GHOST_SetCursorVisibility(GHOST_WindowHandle windowhandle, bool visible)
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
bool GHOST_ValidWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle)
GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
void GHOST_SetWindowUserData(GHOST_WindowHandle windowhandle, GHOST_TUserDataPtr user_data)
GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle)
GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle parent_windowhandle, const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, bool is_dialog, GHOST_GPUSettings gpu_settings)
void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
GHOST_TimerTaskHandle GHOST_InstallTimer(GHOST_SystemHandle systemhandle, uint64_t delay, uint64_t interval, GHOST_TimerProcPtr timer_proc, GHOST_TUserDataPtr user_data)
GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle)
GHOST_TSuccess GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle, uint32_t *r_width, uint32_t *r_height)
@ GHOST_kWindowStateNormal
void * GHOST_TUserDataPtr
@ GHOST_kStandardCursorUpDown
@ GHOST_kStandardCursorDefault
#define GHOST_kStandardCursorNumCursors
@ GHOST_kEventWindowClose
@ GHOST_kEventWindowUpdate
@ GHOST_kEventQuitRequest
@ GHOST_kWindowOrderBottom
@ GHOST_kButtonMaskMiddle
GPUContext * GPU_context_create(void *ghost_window, void *ghost_context)
void GPU_context_active_set(GPUContext *)
void GPU_backend_ghost_system_set(void *ghost_system_handle)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Read Guarded memory(de)allocation.
static void loggerwindow_recalc_regions(LoggerWindow *lw)
static void loggerwindow_setup_window_gl(LoggerWindow *lw)
void multitestapp_toggle_extra_window(MultiTestApp *app)
static void mainwindow_do_button(MainWindow *mw, int which, int press)
void loggerwindow_free(LoggerWindow *lw)
static void loggerwindow_do_move(LoggerWindow *lw, int x, int y)
static void extrawindow_spin_cursor(ExtraWindow *ew, uint64_t time)
GHOST_SystemHandle multitestapp_get_system(MultiTestApp *app)
static void mainwindow_do_move(MainWindow *mw, int x, int y)
static void loggerwindow_handle(void *priv, GHOST_EventHandle evt)
static void loggerwindow_do_reshape(LoggerWindow *lw)
struct _MultiTestApp MultiTestApp
int datatoc_bfont_ttf_size
void multitestapp_free(MultiTestApp *app)
MultiTestApp * multitestapp_new(void)
static bool multitest_event_handler(GHOST_EventHandle evt, GHOST_TUserDataPtr data)
void multitestapp_free_extrawindow(MultiTestApp *app)
void mainwindow_free(MainWindow *mw)
static void extrawindow_do_draw(ExtraWindow *ew)
static void mainwindow_do_key(MainWindow *mw, GHOST_TKey key, int press)
LoggerWindow * loggerwindow_new(MultiTestApp *app)
static void loggerwindow_do_key(LoggerWindow *lw, GHOST_TKey key, int press)
char const datatoc_bfont_ttf[]
static void mainwindow_timer_proc(GHOST_TimerTaskHandle task, uint64_t time)
struct _LoggerWindow LoggerWindow
void extrawindow_free(ExtraWindow *ew)
void rect_bevel_smooth(int rect[2][2], int width)
static void loggerwindow_do_button(LoggerWindow *lw, int which, int press)
void rect_bevel_side(int rect[2][2], int side, float *lt, float *dk, const float col[3], int width)
void multitestapp_exit(MultiTestApp *app)
ExtraWindow * extrawindow_new(MultiTestApp *app)
void multitestapp_run(MultiTestApp *app)
MainWindow * mainwindow_new(MultiTestApp *app)
LoggerWindow * multitestapp_get_logger(MultiTestApp *app)
static void mainwindow_log(MainWindow *mw, char *str)
static void extrawindow_handle(void *priv, GHOST_EventHandle evt)
void loggerwindow_log(LoggerWindow *lw, char *line)
static void extrawindow_do_reshape(ExtraWindow *ew)
static void mainwindow_handle(void *priv, GHOST_EventHandle evt)
static void mainwindow_do_reshape(MainWindow *mw)
static void loggerwindow_do_draw(LoggerWindow *lw)
static void mainwindow_do_draw(MainWindow *mw)
static void extrawindow_do_key(ExtraWindow *ew, GHOST_TKey key, int press)
char * string_dup(char *str)
void fatal(char *fmt,...)
void * memdbl(void *mem, int *size_pr, int item_size)
void windowdata_free(WindowData *wb)
WindowData * windowdata_new(void *data, WindowDataHandler handler)
void windowdata_handle(WindowData *wb, GHOST_EventHandle evt)
struct _WindowData WindowData
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
void * MEM_mallocN(size_t len, const char *str)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 fmod(const float2 a, const float b)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)