1 /* This is a small demo of the high-performance GUIX graphics framework. */
2 
3 #include <stdio.h>
4 #include "gx_api.h"
5 
6 #include "runtime_allocate_16bpp_resources.h"
7 #include "runtime_allocate_16bpp_specifications.h"
8 
9 
10 /* Define the ThreadX demo thread control block and stack.  */
11 
12 TX_THREAD          demo_thread;
13 UCHAR              demo_thread_stack[4096];
14 TX_BYTE_POOL       memory_pool;
15 
16 #define            SCRATCHPAD_PIXELS (DISPLAY_1_X_RESOLUTION * DISPLAY_1_Y_RESOLUTION * 4)
17 GX_COLOR           scratchpad[SCRATCHPAD_PIXELS];
18 
19 GX_WINDOW_ROOT    *root;
20 GX_WIDGET         *pMainWin;
21 
22 /* Define prototypes.   */
23 VOID  guix_setup();
24 extern UINT win32_graphics_driver_setup_565rgb(GX_DISPLAY *display);
25 
main(int argc,char ** argv)26 int main(int argc, char ** argv)
27 {
28   tx_kernel_enter();
29   return(0);
30 }
31 
memory_allocate(ULONG size)32 VOID *memory_allocate(ULONG size)
33 {
34     VOID *memptr;
35 
36     if (tx_byte_allocate(&memory_pool, &memptr, size, TX_NO_WAIT) == TX_SUCCESS)
37     {
38         return memptr;
39     }
40     return NULL;
41 }
42 
memory_free(VOID * mem)43 void memory_free(VOID *mem)
44 {
45     tx_byte_release(mem);
46 }
47 
tx_application_define(void * first_unused_memory)48 VOID tx_application_define(void *first_unused_memory)
49 {
50 
51     /* create byte pool for rotation to use */
52     tx_byte_pool_create(&memory_pool, "scratchpad", scratchpad,
53                         SCRATCHPAD_PIXELS * sizeof(GX_COLOR));
54 
55     guix_setup();
56 }
57 
58 
guix_setup()59 VOID  guix_setup()
60 {
61     /* Initialize GUIX.  */
62     gx_system_initialize();
63 
64 
65     gx_studio_display_configure(DISPLAY_1, win32_graphics_driver_setup_565rgb,
66                                 LANGUAGE_ENGLISH, DISPLAY_1_THEME_1, &root);
67 
68     /* install our memory allocator and de-allocator */
69     gx_system_memory_allocator_set(memory_allocate, memory_free);
70 
71     /* create the main screen */
72     gx_studio_named_widget_create("window", (GX_WIDGET *)root, &pMainWin);
73 
74     /* Show the root window to make it and patients screen visible.  */
75     gx_widget_show(root);
76 
77     /* let GUIX run */
78     gx_system_start();
79 }
80