diff --git a/.vscode/settings.json b/.vscode/settings.json index 555509a..7e89774 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,6 +12,9 @@ "stdlib.h": "c", "serialhelper.h": "c", "coprocessorjs.h": "c", - "dialogs.h": "c" + "dialogs.h": "c", + "osutils.h": "c", + "traps.h": "c", + "quickdraw.h": "c" } } \ No newline at end of file diff --git a/Sample.c b/Sample.c index fed759b..f26296c 100644 --- a/Sample.c +++ b/Sample.c @@ -21,6 +21,73 @@ #include #include #include "Sample.h" + +//#define PROFILING 1 +#ifdef PROFILING + +OSErr writeSerialPortProfile(const char* str) +{ + + #define PRINTER_PORT_OUT "\p.BOut" + + OSErr err; + short serialPort = 0; + err = OpenDriver(PRINTER_PORT_OUT, &serialPort); + if (err < 0) return err; + + CntrlParam cb2; + cb2.ioCRefNum = serialPort; + cb2.csCode = 8; + cb2.csParam[0] = stop10 | noParity | data8 | baud9600; + err = PBControl ((ParmBlkPtr) & cb2, 0); + if (err < 0) return err; + + IOParam pb2; + pb2.ioRefNum = serialPort; + + char str2[1024]; + sprintf(str2, "%s\n", str); + pb2.ioBuffer = (Ptr) str2; + pb2.ioReqCount = strlen(str2); + + err = PBWrite((ParmBlkPtr)& pb2, 0); + if (err < 0) return err; + + // hangs on Mac512K (write hasn't finished due to slow Speed when we wants to close driver + // err = CloseDriver(serialPort); + + return err; +} + +void PROFILE_START(char *name) { + + char profileMessage[255]; + sprintf(profileMessage, "PROFILE_START %s", name); + + writeSerialPortProfile(profileMessage); + + return; +} + +void PROFILE_END(char *name) { + + char profileMessage[255]; + sprintf(profileMessage, "PROFILE_END %s", name); + + writeSerialPortProfile(profileMessage); + + return; +} + +void PROFILE_COMPLETE() { + + writeSerialPortProfile("PROFILE_COMPLETE"); + + return; +} + +#endif + #include "SerialHelper.h" #include "Quickdraw.h" #include "output_js.h" @@ -115,6 +182,12 @@ void EventLoop(struct nk_context *ctx) do { + // Don't do this, it won't yield anything useful + // and will make your app very slow: + // #ifdef PROFILING + // PROFILE_START("eventloop"); + // #endif + // check for new stuff every 10 sec? // note! this is used by some of the functionality in our nuklear_app to trigger // new chat lookups @@ -141,31 +214,42 @@ void EventLoop(struct nk_context *ctx) // call the nk_input_motion command if (lastMouseHPos != mouse.h || lastMouseVPos != mouse.v) { - #ifdef MAC_APP_DEBUGGING + // if the mouse is in motion, try to capture all motion before moving on to rendering + while (lastMouseHPos != mouse.h || lastMouseVPos != mouse.v) { - writeSerialPortDebug(boutRefNum, "nk_input_motion!"); - #endif + #ifdef MAC_APP_DEBUGGING - firstOrMouseMove = true; - beganInput = true; + writeSerialPortDebug(boutRefNum, "nk_input_motion!"); + #endif - Point tempPoint; - SetPt(&tempPoint, mouse.h, mouse.v); - GlobalToLocal(&tempPoint); - nk_input_begin(ctx); - nk_input_motion(ctx, tempPoint.h, tempPoint.v); + Point tempPoint; + SetPt(&tempPoint, mouse.h, mouse.v); + GlobalToLocal(&tempPoint); - mouse_x = tempPoint.h; - mouse_y = tempPoint.v; + if (!beganInput) { + nk_input_begin(ctx); + } - lastUpdatedTickCount = TickCount(); + nk_input_motion(ctx, tempPoint.h, tempPoint.v); + + firstOrMouseMove = true; + beganInput = true; + + mouse_x = tempPoint.h; + mouse_y = tempPoint.v; + + lastUpdatedTickCount = TickCount(); + lastMouseHPos = mouse.h; + lastMouseVPos = mouse.v; + GetGlobalMouse(&mouse); + } } else { gotEvent = GetNextEvent(everyEvent, &event); gotMouseEvent = false; - // drain all events before rendering -- really this only applies to keyboard events now + // drain all events before rendering -- really this only applies to keyboard events and single mouse clicks now while (gotEvent) { lastUpdatedTickCount = TickCount(); @@ -206,8 +290,17 @@ void EventLoop(struct nk_context *ctx) // only re-render if there is an event, prevents screen flickering, speeds up app if (beganInput || firstOrMouseMove) { + #ifdef PROFILING + PROFILE_START("nk_input_end"); + #endif + nk_input_end(ctx); + #ifdef PROFILING + PROFILE_END("nk_input_end"); + PROFILE_START("nuklearApp"); + #endif + firstOrMouseMove = false; #ifdef MAC_APP_DEBUGGING @@ -217,15 +310,35 @@ void EventLoop(struct nk_context *ctx) nuklearApp(ctx); + #ifdef PROFILING + PROFILE_END("nuklearApp"); + PROFILE_START("nk_quickdraw_render"); + #endif + nk_quickdraw_render(FrontWindow(), ctx); + #ifdef PROFILING + PROFILE_END("nk_quickdraw_render"); + PROFILE_START("nk_clear"); + #endif + nk_clear(ctx); + + #ifdef PROFILING + PROFILE_END("nk_clear"); + #endif + } #ifdef MAC_APP_DEBUGGING writeSerialPortDebug(boutRefNum, "nk_input_render complete"); #endif + + + // #ifdef PROFILING + // PROFILE_END("eventloop"); + // #endif } while ( true ); /* loop forever; we quit via ExitToShell */ } /*EventLoop*/ @@ -621,6 +734,10 @@ void Terminate() { WindowPtr aWindow; Boolean closed; + + #ifdef PROFILING + PROFILE_COMPLETE(); + #endif closed = true; do { diff --git a/SerialHelper.c b/SerialHelper.c index 5afbb17..5bf61b3 100644 --- a/SerialHelper.c +++ b/SerialHelper.c @@ -10,7 +10,13 @@ https://opensource.apple.com/source/gdb/gdb-186.1/src/gdb/ser-mac.c?txt http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/Devices/Devices-320.html */ OSErr writeSerialPortDebug(short refNum, const char* str) -{ +{ + #ifdef PROFILING + + // we need to bail on profiling, because the profile watcher will be reading this serial port + return; + + #endif #define MODEM_PORT_OUT "\p.AOut" #define PRINTER_PORT_OUT "\p.BOut" // OSErr err; diff --git a/build/%NuklearQuickDraw.ad b/build/%NuklearQuickDraw.ad index e2137eb..f1ca1b6 100644 Binary files a/build/%NuklearQuickDraw.ad and b/build/%NuklearQuickDraw.ad differ diff --git a/build/.rsrc/NuklearQuickDraw.APPL b/build/.rsrc/NuklearQuickDraw.APPL index f17b824..a08c68d 100644 Binary files a/build/.rsrc/NuklearQuickDraw.APPL and b/build/.rsrc/NuklearQuickDraw.APPL differ diff --git a/build/CMakeFiles/CMakeOutput.log b/build/CMakeFiles/CMakeOutput.log index 2c8d759..f5428af 100644 --- a/build/CMakeFiles/CMakeOutput.log +++ b/build/CMakeFiles/CMakeOutput.log @@ -33,13 +33,13 @@ The CXX compiler identification is GNU, found in "/home/camh/Documents/Retro68kA Determining if the C compiler works passed with the following output: Change Dir: /home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp -Run Build Command(s):/usr/bin/make cmTC_8caf1/fast && /usr/bin/make -f CMakeFiles/cmTC_8caf1.dir/build.make CMakeFiles/cmTC_8caf1.dir/build +Run Build Command(s):/usr/bin/make cmTC_d209b/fast && /usr/bin/make -f CMakeFiles/cmTC_d209b.dir/build.make CMakeFiles/cmTC_d209b.dir/build make[1]: Entering directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp' -Building C object CMakeFiles/cmTC_8caf1.dir/testCCompiler.c.obj -/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc -o CMakeFiles/cmTC_8caf1.dir/testCCompiler.c.obj -c /home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp/testCCompiler.c -Linking C executable cmTC_8caf1 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8caf1.dir/link.txt --verbose=1 -/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc CMakeFiles/cmTC_8caf1.dir/testCCompiler.c.obj -o cmTC_8caf1 +Building C object CMakeFiles/cmTC_d209b.dir/testCCompiler.c.obj +/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc -o CMakeFiles/cmTC_d209b.dir/testCCompiler.c.obj -c /home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp/testCCompiler.c +Linking C executable cmTC_d209b +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d209b.dir/link.txt --verbose=1 +/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc CMakeFiles/cmTC_d209b.dir/testCCompiler.c.obj -o cmTC_d209b make[1]: Leaving directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp' @@ -47,18 +47,18 @@ make[1]: Leaving directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/b Detecting C compiler ABI info compiled with the following output: Change Dir: /home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp -Run Build Command(s):/usr/bin/make cmTC_70a53/fast && /usr/bin/make -f CMakeFiles/cmTC_70a53.dir/build.make CMakeFiles/cmTC_70a53.dir/build +Run Build Command(s):/usr/bin/make cmTC_f2ad3/fast && /usr/bin/make -f CMakeFiles/cmTC_f2ad3.dir/build.make CMakeFiles/cmTC_f2ad3.dir/build make[1]: Entering directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp' -Building C object CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj -/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc -v -o CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj -c /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c +Building C object CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj +/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc -v -o CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj -c /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c Using built-in specs. COLLECT_GCC=/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc Target: m68k-apple-macos Configured with: /home/camh/Retro68/gcc/configure --target=m68k-apple-macos --prefix=/home/camh/Retro68-build/toolchain/ --enable-languages=c,c++ --with-arch=m68k --with-cpu=m68000 --disable-libssp MAKEINFO=missing Thread model: single gcc version 9.1.0 (GCC) -COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000' - /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/cc1 -quiet -v -Wno-trigraphs /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mcpu=68000 -auxbase-strip CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj -version -o /tmp/ccDysVb7.s +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000' + /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/cc1 -quiet -v -Wno-trigraphs /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mcpu=68000 -auxbase-strip CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj -version -o /tmp/ccR5oK71.s GNU C17 (GCC) version 9.1.0 (m68k-apple-macos) compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 @@ -73,14 +73,14 @@ GNU C17 (GCC) version 9.1.0 (m68k-apple-macos) compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 68baab70957df643ffb4605a09112146 -COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000' - /home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/as -mcpu=68000 -o CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj /tmp/ccDysVb7.s +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000' + /home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/as -mcpu=68000 -o CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj /tmp/ccR5oK71.s COMPILER_PATH=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/ LIBRARY_PATH=/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib/ -COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000' -Linking C executable cmTC_70a53 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_70a53.dir/link.txt --verbose=1 -/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc -v CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj -o cmTC_70a53 +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000' +Linking C executable cmTC_f2ad3 +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f2ad3.dir/link.txt --verbose=1 +/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc -v CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj -o cmTC_f2ad3 Using built-in specs. COLLECT_GCC=/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc COLLECT_LTO_WRAPPER=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper @@ -90,9 +90,9 @@ Thread model: single gcc version 9.1.0 (GCC) COMPILER_PATH=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/ LIBRARY_PATH=/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib/ -COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_70a53' '-mcpu=68000' - /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/collect2 -plugin /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/liblto_plugin.so -plugin-opt=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccKhTygx.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lretrocrt -plugin-opt=-pass-through=-lInterface -elf2mac -q -undefined=_consolewrite -o cmTC_70a53 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj --start-group -lgcc -lc -lretrocrt -lInterface --end-group -COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_70a53' '-mcpu=68000' +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_f2ad3' '-mcpu=68000' + /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/collect2 -plugin /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/liblto_plugin.so -plugin-opt=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccUBj7Uv.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lretrocrt -plugin-opt=-pass-through=-lInterface -elf2mac -q -undefined=_consolewrite -o cmTC_f2ad3 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj --start-group -lgcc -lc -lretrocrt -lInterface --end-group +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_f2ad3' '-mcpu=68000' make[1]: Leaving directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp' @@ -114,18 +114,18 @@ Parsed C implicit link information from above output: link line regex: [^( *|.*[/\])(m68k-apple-macos-ld|CMAKE_LINK_STARTFILE-NOTFOUND|([^/\]+-)?ld|collect2)[^/\]*( |$)] ignore line: [Change Dir: /home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp] ignore line: [] - ignore line: [Run Build Command(s):/usr/bin/make cmTC_70a53/fast && /usr/bin/make -f CMakeFiles/cmTC_70a53.dir/build.make CMakeFiles/cmTC_70a53.dir/build] + ignore line: [Run Build Command(s):/usr/bin/make cmTC_f2ad3/fast && /usr/bin/make -f CMakeFiles/cmTC_f2ad3.dir/build.make CMakeFiles/cmTC_f2ad3.dir/build] ignore line: [make[1]: Entering directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp'] - ignore line: [Building C object CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj] - ignore line: [/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc -v -o CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj -c /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c] + ignore line: [Building C object CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj] + ignore line: [/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc -v -o CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj -c /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c] ignore line: [Using built-in specs.] ignore line: [COLLECT_GCC=/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc] ignore line: [Target: m68k-apple-macos] ignore line: [Configured with: /home/camh/Retro68/gcc/configure --target=m68k-apple-macos --prefix=/home/camh/Retro68-build/toolchain/ --enable-languages=c c++ --with-arch=m68k --with-cpu=m68000 --disable-libssp MAKEINFO=missing] ignore line: [Thread model: single] ignore line: [gcc version 9.1.0 (GCC) ] - ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000'] - ignore line: [ /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/cc1 -quiet -v -Wno-trigraphs /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mcpu=68000 -auxbase-strip CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj -version -o /tmp/ccDysVb7.s] + ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000'] + ignore line: [ /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/cc1 -quiet -v -Wno-trigraphs /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mcpu=68000 -auxbase-strip CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj -version -o /tmp/ccR5oK71.s] ignore line: [GNU C17 (GCC) version 9.1.0 (m68k-apple-macos)] ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version none] ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072] @@ -140,14 +140,14 @@ Parsed C implicit link information from above output: ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version none] ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072] ignore line: [Compiler executable checksum: 68baab70957df643ffb4605a09112146] - ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000'] - ignore line: [ /home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/as -mcpu=68000 -o CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj /tmp/ccDysVb7.s] + ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000'] + ignore line: [ /home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/as -mcpu=68000 -o CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj /tmp/ccR5oK71.s] ignore line: [COMPILER_PATH=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/] ignore line: [LIBRARY_PATH=/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib/] - ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000'] - ignore line: [Linking C executable cmTC_70a53] - ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_70a53.dir/link.txt --verbose=1] - ignore line: [/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc -v CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj -o cmTC_70a53 ] + ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj' '-c' '-mcpu=68000'] + ignore line: [Linking C executable cmTC_f2ad3] + ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f2ad3.dir/link.txt --verbose=1] + ignore line: [/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc -v CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj -o cmTC_f2ad3 ] ignore line: [Using built-in specs.] ignore line: [COLLECT_GCC=/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-gcc] ignore line: [COLLECT_LTO_WRAPPER=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper] @@ -157,13 +157,13 @@ Parsed C implicit link information from above output: ignore line: [gcc version 9.1.0 (GCC) ] ignore line: [COMPILER_PATH=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/] ignore line: [LIBRARY_PATH=/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib/] - ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_70a53' '-mcpu=68000'] - link line: [ /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/collect2 -plugin /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/liblto_plugin.so -plugin-opt=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccKhTygx.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lretrocrt -plugin-opt=-pass-through=-lInterface -elf2mac -q -undefined=_consolewrite -o cmTC_70a53 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj --start-group -lgcc -lc -lretrocrt -lInterface --end-group] + ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_f2ad3' '-mcpu=68000'] + link line: [ /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/collect2 -plugin /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/liblto_plugin.so -plugin-opt=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccUBj7Uv.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lretrocrt -plugin-opt=-pass-through=-lInterface -elf2mac -q -undefined=_consolewrite -o cmTC_f2ad3 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj --start-group -lgcc -lc -lretrocrt -lInterface --end-group] arg [/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/collect2] ==> ignore arg [-plugin] ==> ignore arg [/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/liblto_plugin.so] ==> ignore arg [-plugin-opt=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper] ==> ignore - arg [-plugin-opt=-fresolution=/tmp/ccKhTygx.res] ==> ignore + arg [-plugin-opt=-fresolution=/tmp/ccUBj7Uv.res] ==> ignore arg [-plugin-opt=-pass-through=-lgcc] ==> ignore arg [-plugin-opt=-pass-through=-lc] ==> ignore arg [-plugin-opt=-pass-through=-lretrocrt] ==> ignore @@ -172,10 +172,10 @@ Parsed C implicit link information from above output: arg [-q] ==> ignore arg [-undefined=_consolewrite] ==> ignore arg [-o] ==> ignore - arg [cmTC_70a53] ==> ignore + arg [cmTC_f2ad3] ==> ignore arg [-L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0] ==> dir [/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0] arg [-L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib] ==> dir [/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib] - arg [CMakeFiles/cmTC_70a53.dir/CMakeCCompilerABI.c.obj] ==> ignore + arg [CMakeFiles/cmTC_f2ad3.dir/CMakeCCompilerABI.c.obj] ==> ignore arg [--start-group] ==> ignore arg [-lgcc] ==> lib [gcc] arg [-lc] ==> lib [c] @@ -192,13 +192,13 @@ Parsed C implicit link information from above output: Determining if the CXX compiler works passed with the following output: Change Dir: /home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp -Run Build Command(s):/usr/bin/make cmTC_93c14/fast && /usr/bin/make -f CMakeFiles/cmTC_93c14.dir/build.make CMakeFiles/cmTC_93c14.dir/build +Run Build Command(s):/usr/bin/make cmTC_b0b45/fast && /usr/bin/make -f CMakeFiles/cmTC_b0b45.dir/build.make CMakeFiles/cmTC_b0b45.dir/build make[1]: Entering directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp' -Building CXX object CMakeFiles/cmTC_93c14.dir/testCXXCompiler.cxx.obj -/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ -o CMakeFiles/cmTC_93c14.dir/testCXXCompiler.cxx.obj -c /home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx -Linking CXX executable cmTC_93c14 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_93c14.dir/link.txt --verbose=1 -/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ CMakeFiles/cmTC_93c14.dir/testCXXCompiler.cxx.obj -o cmTC_93c14 +Building CXX object CMakeFiles/cmTC_b0b45.dir/testCXXCompiler.cxx.obj +/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ -o CMakeFiles/cmTC_b0b45.dir/testCXXCompiler.cxx.obj -c /home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx +Linking CXX executable cmTC_b0b45 +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b0b45.dir/link.txt --verbose=1 +/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ CMakeFiles/cmTC_b0b45.dir/testCXXCompiler.cxx.obj -o cmTC_b0b45 make[1]: Leaving directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp' @@ -206,18 +206,18 @@ make[1]: Leaving directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/b Detecting CXX compiler ABI info compiled with the following output: Change Dir: /home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp -Run Build Command(s):/usr/bin/make cmTC_f30f5/fast && /usr/bin/make -f CMakeFiles/cmTC_f30f5.dir/build.make CMakeFiles/cmTC_f30f5.dir/build +Run Build Command(s):/usr/bin/make cmTC_e45aa/fast && /usr/bin/make -f CMakeFiles/cmTC_e45aa.dir/build.make CMakeFiles/cmTC_e45aa.dir/build make[1]: Entering directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp' -Building CXX object CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj -/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ -v -o CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj -c /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp +Building CXX object CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj +/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ -v -o CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj -c /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp Using built-in specs. COLLECT_GCC=/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ Target: m68k-apple-macos Configured with: /home/camh/Retro68/gcc/configure --target=m68k-apple-macos --prefix=/home/camh/Retro68-build/toolchain/ --enable-languages=c,c++ --with-arch=m68k --with-cpu=m68000 --disable-libssp MAKEINFO=missing Thread model: single gcc version 9.1.0 (GCC) -COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000' - /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/cc1plus -quiet -v -Wno-trigraphs /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mcpu=68000 -auxbase-strip CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj -version -o /tmp/ccpKfWFb.s +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000' + /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/cc1plus -quiet -v -Wno-trigraphs /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mcpu=68000 -auxbase-strip CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj -version -o /tmp/cc3vCbPa.s GNU C++14 (GCC) version 9.1.0 (m68k-apple-macos) compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 @@ -235,14 +235,14 @@ GNU C++14 (GCC) version 9.1.0 (m68k-apple-macos) compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 5b31867a30cfa7e65d4bce12c39f8a21 -COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000' - /home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/as -mcpu=68000 -o CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj /tmp/ccpKfWFb.s +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000' + /home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/as -mcpu=68000 -o CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj /tmp/cc3vCbPa.s COMPILER_PATH=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/ LIBRARY_PATH=/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib/ -COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000' -Linking CXX executable cmTC_f30f5 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f30f5.dir/link.txt --verbose=1 -/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ -v CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj -o cmTC_f30f5 +COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000' +Linking CXX executable cmTC_e45aa +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e45aa.dir/link.txt --verbose=1 +/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ -v CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj -o cmTC_e45aa Using built-in specs. COLLECT_GCC=/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ COLLECT_LTO_WRAPPER=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper @@ -252,9 +252,9 @@ Thread model: single gcc version 9.1.0 (GCC) COMPILER_PATH=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/ LIBRARY_PATH=/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib/ -COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_f30f5' '-mcpu=68000' - /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/collect2 -plugin /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/liblto_plugin.so -plugin-opt=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccLc3iPF.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lretrocrt -plugin-opt=-pass-through=-lInterface -elf2mac -q -undefined=_consolewrite -o cmTC_f30f5 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj -lstdc++ -lm --start-group -lgcc -lc -lretrocrt -lInterface --end-group -COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_f30f5' '-mcpu=68000' +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_e45aa' '-mcpu=68000' + /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/collect2 -plugin /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/liblto_plugin.so -plugin-opt=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccpTTxYC.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lretrocrt -plugin-opt=-pass-through=-lInterface -elf2mac -q -undefined=_consolewrite -o cmTC_e45aa -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj -lstdc++ -lm --start-group -lgcc -lc -lretrocrt -lInterface --end-group +COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_e45aa' '-mcpu=68000' make[1]: Leaving directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp' @@ -282,18 +282,18 @@ Parsed CXX implicit link information from above output: link line regex: [^( *|.*[/\])(m68k-apple-macos-ld|CMAKE_LINK_STARTFILE-NOTFOUND|([^/\]+-)?ld|collect2)[^/\]*( |$)] ignore line: [Change Dir: /home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp] ignore line: [] - ignore line: [Run Build Command(s):/usr/bin/make cmTC_f30f5/fast && /usr/bin/make -f CMakeFiles/cmTC_f30f5.dir/build.make CMakeFiles/cmTC_f30f5.dir/build] + ignore line: [Run Build Command(s):/usr/bin/make cmTC_e45aa/fast && /usr/bin/make -f CMakeFiles/cmTC_e45aa.dir/build.make CMakeFiles/cmTC_e45aa.dir/build] ignore line: [make[1]: Entering directory '/home/camh/Documents/Retro68kApps/NuklearQuickDraw/build/CMakeFiles/CMakeTmp'] - ignore line: [Building CXX object CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj] - ignore line: [/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ -v -o CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj -c /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp] + ignore line: [Building CXX object CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj] + ignore line: [/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ -v -o CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj -c /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp] ignore line: [Using built-in specs.] ignore line: [COLLECT_GCC=/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++] ignore line: [Target: m68k-apple-macos] ignore line: [Configured with: /home/camh/Retro68/gcc/configure --target=m68k-apple-macos --prefix=/home/camh/Retro68-build/toolchain/ --enable-languages=c c++ --with-arch=m68k --with-cpu=m68000 --disable-libssp MAKEINFO=missing] ignore line: [Thread model: single] ignore line: [gcc version 9.1.0 (GCC) ] - ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000'] - ignore line: [ /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/cc1plus -quiet -v -Wno-trigraphs /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mcpu=68000 -auxbase-strip CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj -version -o /tmp/ccpKfWFb.s] + ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000'] + ignore line: [ /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/cc1plus -quiet -v -Wno-trigraphs /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mcpu=68000 -auxbase-strip CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj -version -o /tmp/cc3vCbPa.s] ignore line: [GNU C++14 (GCC) version 9.1.0 (m68k-apple-macos)] ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version none] ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072] @@ -311,14 +311,14 @@ Parsed CXX implicit link information from above output: ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version none] ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072] ignore line: [Compiler executable checksum: 5b31867a30cfa7e65d4bce12c39f8a21] - ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000'] - ignore line: [ /home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/as -mcpu=68000 -o CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj /tmp/ccpKfWFb.s] + ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000'] + ignore line: [ /home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/as -mcpu=68000 -o CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj /tmp/cc3vCbPa.s] ignore line: [COMPILER_PATH=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/] ignore line: [LIBRARY_PATH=/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib/] - ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000'] - ignore line: [Linking CXX executable cmTC_f30f5] - ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f30f5.dir/link.txt --verbose=1] - ignore line: [/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ -v CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj -o cmTC_f30f5 ] + ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj' '-c' '-mcpu=68000'] + ignore line: [Linking CXX executable cmTC_e45aa] + ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e45aa.dir/link.txt --verbose=1] + ignore line: [/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++ -v CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj -o cmTC_e45aa ] ignore line: [Using built-in specs.] ignore line: [COLLECT_GCC=/home/camh/Retro68-build/toolchain/bin/m68k-apple-macos-g++] ignore line: [COLLECT_LTO_WRAPPER=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper] @@ -328,13 +328,13 @@ Parsed CXX implicit link information from above output: ignore line: [gcc version 9.1.0 (GCC) ] ignore line: [COMPILER_PATH=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/bin/] ignore line: [LIBRARY_PATH=/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/:/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib/] - ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_f30f5' '-mcpu=68000'] - link line: [ /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/collect2 -plugin /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/liblto_plugin.so -plugin-opt=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccLc3iPF.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lretrocrt -plugin-opt=-pass-through=-lInterface -elf2mac -q -undefined=_consolewrite -o cmTC_f30f5 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj -lstdc++ -lm --start-group -lgcc -lc -lretrocrt -lInterface --end-group] + ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_e45aa' '-mcpu=68000'] + link line: [ /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/collect2 -plugin /home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/liblto_plugin.so -plugin-opt=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccpTTxYC.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lretrocrt -plugin-opt=-pass-through=-lInterface -elf2mac -q -undefined=_consolewrite -o cmTC_e45aa -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0 -L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj -lstdc++ -lm --start-group -lgcc -lc -lretrocrt -lInterface --end-group] arg [/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/collect2] ==> ignore arg [-plugin] ==> ignore arg [/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/liblto_plugin.so] ==> ignore arg [-plugin-opt=/home/camh/Retro68-build/toolchain/libexec/gcc/m68k-apple-macos/9.1.0/lto-wrapper] ==> ignore - arg [-plugin-opt=-fresolution=/tmp/ccLc3iPF.res] ==> ignore + arg [-plugin-opt=-fresolution=/tmp/ccpTTxYC.res] ==> ignore arg [-plugin-opt=-pass-through=-lgcc] ==> ignore arg [-plugin-opt=-pass-through=-lc] ==> ignore arg [-plugin-opt=-pass-through=-lretrocrt] ==> ignore @@ -343,10 +343,10 @@ Parsed CXX implicit link information from above output: arg [-q] ==> ignore arg [-undefined=_consolewrite] ==> ignore arg [-o] ==> ignore - arg [cmTC_f30f5] ==> ignore + arg [cmTC_e45aa] ==> ignore arg [-L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0] ==> dir [/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0] arg [-L/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib] ==> dir [/home/camh/Retro68-build/toolchain/lib/gcc/m68k-apple-macos/9.1.0/../../../../m68k-apple-macos/lib] - arg [CMakeFiles/cmTC_f30f5.dir/CMakeCXXCompilerABI.cpp.obj] ==> ignore + arg [CMakeFiles/cmTC_e45aa.dir/CMakeCXXCompilerABI.cpp.obj] ==> ignore arg [-lstdc++] ==> lib [stdc++] arg [-lm] ==> lib [m] arg [--start-group] ==> ignore diff --git a/build/CMakeFiles/NuklearQuickDraw.dir/Sample.c.obj b/build/CMakeFiles/NuklearQuickDraw.dir/Sample.c.obj index 7e491d3..c049f3f 100644 Binary files a/build/CMakeFiles/NuklearQuickDraw.dir/Sample.c.obj and b/build/CMakeFiles/NuklearQuickDraw.dir/Sample.c.obj differ diff --git a/build/NuklearQuickDraw.bin b/build/NuklearQuickDraw.bin index 62c8b7c..fd79194 100644 Binary files a/build/NuklearQuickDraw.bin and b/build/NuklearQuickDraw.bin differ diff --git a/build/NuklearQuickDraw.code.bin b/build/NuklearQuickDraw.code.bin index 7425f02..4cb267b 100644 Binary files a/build/NuklearQuickDraw.code.bin and b/build/NuklearQuickDraw.code.bin differ diff --git a/build/NuklearQuickDraw.code.bin.gdb b/build/NuklearQuickDraw.code.bin.gdb index cb9b6c0..bc256dc 100755 Binary files a/build/NuklearQuickDraw.code.bin.gdb and b/build/NuklearQuickDraw.code.bin.gdb differ diff --git a/build/NuklearQuickDraw.dsk b/build/NuklearQuickDraw.dsk index 647ab56..922a2f0 100644 Binary files a/build/NuklearQuickDraw.dsk and b/build/NuklearQuickDraw.dsk differ diff --git a/nuklear.h b/nuklear.h index 58b534f..4d6a411 100644 --- a/nuklear.h +++ b/nuklear.h @@ -4236,7 +4236,7 @@ NK_API void nk_textedit_redo(struct nk_text_edit*); if (state != NK_WIDGET_ROM) update_your_widget_by_user_input(...); - nk_fill_rect(canvas, space, 0, nk_rgb(255,0,0)); + nk_fill_rect(canvas, space, 0, nk_rgb(255,0,0), true); } if (nk_begin(...)) { @@ -4322,6 +4322,7 @@ struct nk_command_rect_filled { short x, y; unsigned short w, h; struct nk_color color; + Boolean allowCache; }; struct nk_command_rect_multi_color { @@ -4460,7 +4461,7 @@ NK_API void nk_stroke_polyline(struct nk_command_buffer*, short *points, short p NK_API void nk_stroke_polygon(struct nk_command_buffer*, short*, short point_count, short line_thickness, struct nk_color); /* filled shades */ -NK_API void nk_fill_rect(struct nk_command_buffer*, struct nk_rect, short rounding, struct nk_color); +NK_API void nk_fill_rect(struct nk_command_buffer*, struct nk_rect, short rounding, struct nk_color, Boolean allowCache); NK_API void nk_fill_rect_multi_color(struct nk_command_buffer*, struct nk_rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom); NK_API void nk_fill_circle(struct nk_command_buffer*, struct nk_rect, struct nk_color); NK_API void nk_fill_arc(struct nk_command_buffer*, short cx, short cy, short radius, short a_min, short a_max, struct nk_color); @@ -8520,27 +8521,32 @@ nk_stroke_rect(struct nk_command_buffer *b, struct nk_rect rect, cmd->color = c; } NK_API void -nk_fill_rect(struct nk_command_buffer *b, struct nk_rect rect, - short rounding, struct nk_color c) +nk_fill_rect(struct nk_command_buffer *b, struct nk_rect rect, short rounding, struct nk_color c, Boolean allowCache) { struct nk_command_rect_filled *cmd; // NK_ASSERT(b); - if (!b || c.a == 0 || rect.w == 0 || rect.h == 0) return; + if (!b || c.a == 0 || rect.w == 0 || rect.h == 0) { + + return; + } if (b->use_clipping) { const struct nk_rect *clip = &b->clip; - if (!NK_INTERSECT(rect.x, rect.y, rect.w, rect.h, - clip->x, clip->y, clip->w, clip->h)) return; + if (!NK_INTERSECT(rect.x, rect.y, rect.w, rect.h, clip->x, clip->y, clip->w, clip->h)) { + return; + } } - cmd = (struct nk_command_rect_filled*) - nk_command_buffer_push(b, NK_COMMAND_RECT_FILLED, sizeof(*cmd)); - if (!cmd) return; + cmd = (struct nk_command_rect_filled*) nk_command_buffer_push(b, NK_COMMAND_RECT_FILLED, sizeof(*cmd)); + if (!cmd) { + return; + } cmd->rounding = (unsigned short)rounding; cmd->x = (short)rect.x; cmd->y = (short)rect.y; cmd->w = (unsigned short)NK_MAX(0, rect.w); cmd->h = (unsigned short)NK_MAX(0, rect.h); cmd->color = c; + cmd->allowCache = allowCache; } NK_API void nk_fill_rect_multi_color(struct nk_command_buffer *b, struct nk_rect rect, @@ -10755,7 +10761,7 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan break; case NK_STYLE_ITEM_COLOR: text.background = background->data.color; - nk_fill_rect(out, header, 0, background->data.color); + nk_fill_rect(out, header, 0, background->data.color, true); break; } @@ -10836,7 +10842,7 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan // nk_draw_nine_slice(out, body, &style->window.fixed_background.data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(out, body, 0, style->window.fixed_background.data.color); + nk_fill_rect(out, body, 0, style->window.fixed_background.data.color, true); break; } } @@ -10896,14 +10902,14 @@ nk_panel_end(struct nk_context *ctx) empty_space.y = layout->bounds.y; empty_space.h = panel_padding.y; empty_space.w = window->bounds.w; - nk_fill_rect(out, empty_space, 0, style->window.background); + nk_fill_rect(out, empty_space, 0, style->window.background, true); /* fill left empty space */ empty_space.x = window->bounds.x; empty_space.y = layout->bounds.y; empty_space.w = panel_padding.x + layout->border; empty_space.h = layout->bounds.h; - nk_fill_rect(out, empty_space, 0, style->window.background); + nk_fill_rect(out, empty_space, 0, style->window.background, true); /* fill right empty space */ empty_space.x = layout->bounds.x + layout->bounds.w; @@ -10912,7 +10918,7 @@ nk_panel_end(struct nk_context *ctx) empty_space.h = layout->bounds.h; if (*layout->offset_y == 0 && !(layout->flags & NK_WINDOW_NO_SCROLLBAR)) empty_space.w += scrollbar_size.x; - nk_fill_rect(out, empty_space, 0, style->window.background); + nk_fill_rect(out, empty_space, 0, style->window.background, true); /* fill bottom empty space */ if (layout->footer_height > 0) { @@ -10920,7 +10926,7 @@ nk_panel_end(struct nk_context *ctx) empty_space.y = layout->bounds.y + layout->bounds.h; empty_space.w = window->bounds.w; empty_space.h = layout->footer_height; - nk_fill_rect(out, empty_space, 0, style->window.background); + nk_fill_rect(out, empty_space, 0, style->window.background, true); } } @@ -12709,7 +12715,7 @@ nk_panel_layout(const struct nk_context *ctx, struct nk_window *win, background.w = win->bounds.w; background.y = layout->at_y - 1; background.h = layout->row.height + 1; - nk_fill_rect(out, background, 0, color); + nk_fill_rect(out, background, 0, color, true); } } NK_LIB void @@ -13422,9 +13428,9 @@ nk_tree_state_base(struct nk_context *ctx, enum nk_tree_type type, // nk_draw_nine_slice(out, header, &background->data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(out, header, 0, style->tab.border_color); + nk_fill_rect(out, header, 0, style->tab.border_color, true); nk_fill_rect(out, nk_shrink_rect(header, style->tab.border), - style->tab.rounding, background->data.color); + style->tab.rounding, background->data.color, true); break; } } else text.background = style->window.background; @@ -13605,9 +13611,9 @@ nk_tree_element_image_push_hashed_base(struct nk_context *ctx, enum nk_tree_type // nk_draw_nine_slice(out, header, &background->data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(out, header, 0, style->tab.border_color); + nk_fill_rect(out, header, 0, style->tab.border_color, true); nk_fill_rect(out, nk_shrink_rect(header, style->tab.border), - style->tab.rounding, background->data.color); + style->tab.rounding, background->data.color, true); break; } } @@ -14301,6 +14307,7 @@ nk_widget_text(struct nk_command_buffer *o, struct nk_rect b, label.y = b.y + b.h - f->height; label.h = f->height; } + nk_draw_text(o, label, (const char*)string, len, f, t->background, t->text); } NK_LIB void @@ -14824,9 +14831,9 @@ nk_draw_symbol(struct nk_command_buffer *out, enum nk_symbol_type type, case NK_SYMBOL_RECT_OUTLINE: { /* simple empty/filled shapes */ if (type == NK_SYMBOL_RECT_SOLID || type == NK_SYMBOL_RECT_OUTLINE) { - nk_fill_rect(out, content, 0, foreground); + nk_fill_rect(out, content, 0, foreground, true); if (type == NK_SYMBOL_RECT_OUTLINE) - nk_fill_rect(out, nk_shrink_rect(content, border_width), 0, background); + nk_fill_rect(out, nk_shrink_rect(content, border_width), 0, background, true); } else { nk_fill_circle(out, content, foreground); if (type == NK_SYMBOL_CIRCLE_OUTLINE) @@ -14898,7 +14905,7 @@ nk_draw_button(struct nk_command_buffer *out, // nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(out, *bounds, style->rounding, background->data.color); + nk_fill_rect(out, *bounds, style->rounding, background->data.color, true); nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color); break; } @@ -15514,14 +15521,14 @@ nk_draw_checkbox(struct nk_command_buffer *out, /* draw background and cursor */ if (background->type == NK_STYLE_ITEM_COLOR) { - nk_fill_rect(out, *selector, 0, style->border_color); - nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, background->data.color); + nk_fill_rect(out, *selector, 0, style->border_color, true); + nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, background->data.color, true); }// } else nk_draw_image(out, *selector, &background->data.image, nk_white); if (active) { // if (cursor->type == NK_STYLE_ITEM_IMAGE) // // nk_draw_image(out, *cursors, &cursor->data.image, nk_white); // else - nk_fill_rect(out, *cursors, 0, cursor->data.color); + nk_fill_rect(out, *cursors, 0, cursor->data.color, true); } text.padding.x = 0; @@ -15841,7 +15848,7 @@ nk_draw_selectable(struct nk_command_buffer *out, break; case NK_STYLE_ITEM_COLOR: text.background = background->data.color; - nk_fill_rect(out, *bounds, style->rounding, background->data.color); + nk_fill_rect(out, *bounds, style->rounding, background->data.color, true); break; } if (icon) { @@ -16218,14 +16225,14 @@ nk_draw_slider(struct nk_command_buffer *out, nk_flags state, // nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(out, *bounds, style->rounding, background->data.color); + nk_fill_rect(out, *bounds, style->rounding, background->data.color, true); nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color); break; } /* draw slider bar */ - nk_fill_rect(out, bar, style->rounding, bar_color); - nk_fill_rect(out, fill, style->rounding, style->bar_filled); + nk_fill_rect(out, bar, style->rounding, bar_color, true); + nk_fill_rect(out, fill, style->rounding, style->bar_filled, true); /* draw cursor */ // if (cursor->type == NK_STYLE_ITEM_IMAGE) @@ -16434,7 +16441,7 @@ nk_draw_progress(struct nk_command_buffer *out, nk_flags state, // nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(out, *bounds, style->rounding, background->data.color); + nk_fill_rect(out, *bounds, style->rounding, background->data.color, true); nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color); break; } @@ -16448,7 +16455,7 @@ nk_draw_progress(struct nk_command_buffer *out, nk_flags state, // nk_draw_nine_slice(out, *scursor, &cursor->data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(out, *scursor, style->rounding, cursor->data.color); + nk_fill_rect(out, *scursor, style->rounding, cursor->data.color, true); nk_stroke_rect(out, *scursor, style->rounding, style->border, style->border_color); break; } @@ -16627,11 +16634,11 @@ nk_draw_scrollbar(struct nk_command_buffer *out, nk_flags state, cursor = &style->cursor_normal; } - nk_fill_rect(out, *bounds, style->rounding, cursor->data.color); + nk_fill_rect(out, *bounds, style->rounding, cursor->data.color, true); nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color); /* draw cursor */ - nk_fill_rect(out, *scroll, style->rounding_cursor, background->data.color); + nk_fill_rect(out, *scroll, style->rounding_cursor, background->data.color, true); nk_stroke_rect(out, *scroll, style->rounding_cursor, style->border_cursor, style->cursor_border_color); } NK_LIB short @@ -17960,7 +17967,7 @@ nk_edit_draw_text(struct nk_command_buffer *out, label.x += x_offset; if (is_selected) /* selection needs to draw different background color */ - nk_fill_rect(out, label, 0, background); + nk_fill_rect(out, label, 0, background, true); nk_widget_text(out, label, line, ((text + text_len) - line), &txt, NK_TEXT_CENTERED, font); @@ -17994,7 +18001,7 @@ nk_edit_draw_text(struct nk_command_buffer *out, label.x += x_offset; if (is_selected) - nk_fill_rect(out, label, 0, background); + nk_fill_rect(out, label, 0, background, true); nk_widget_text(out, label, line, ((text + text_len) - line), &txt, NK_TEXT_LEFT, font); }} @@ -18188,7 +18195,7 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out, // nk_draw_nine_slice(out, bounds, &background->data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(out, bounds, style->rounding, background->data.color); + nk_fill_rect(out, bounds, style->rounding, background->data.color, true); nk_stroke_rect(out, bounds, style->rounding, style->border, style->border_color); break; }} @@ -18368,8 +18375,18 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out, struct nk_color cursor_color; struct nk_color cursor_text_color; const struct nk_style_item *background; + clip.w = area.w; + nk_push_scissor(out, clip); + // this is meant to fix text boxes when scrolling to the right when typing long text + struct nk_rect whiteTextarea; + whiteTextarea.x = clip.x + line_width - edit->scrollbar.x; + whiteTextarea.y = clip.y; + whiteTextarea.h = clip.h; + whiteTextarea.w = line_width - (line_width - edit->scrollbar.x); + nk_fill_rect(out, whiteTextarea, style->rounding, nk_rgba(255,255,255,255), false); + /* select correct colors to draw */ if (*state & NK_WIDGET_STATE_ACTIVED) { background = &style->active; @@ -18403,6 +18420,12 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out, /* no selection so just draw the complete text */ const char *begin = nk_str_get_const(&edit->string); short l = nk_str_len_char(&edit->string); + + // (struct nk_command_buffer *out, + // const struct nk_style_edit *style, short pos_x, short pos_y, + // short x_offset, const char *text, short byte_len, short row_height, + // const struct nk_user_font *font, struct nk_color background, + // struct nk_color foreground, nk_bool is_selected) nk_edit_draw_text(out, style, area.x - edit->scrollbar.x, area.y - edit->scrollbar.y, 0, begin, l, row_height, font, background_color, text_color, nk_false); @@ -18459,7 +18482,14 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out, cursor.x = area.x + cursor_pos.x - edit->scrollbar.x; cursor.y = area.y + cursor_pos.y + row_height/2 - cursor.h/2; cursor.y -= edit->scrollbar.y; - nk_fill_rect(out, cursor, 0, cursor_color); + nk_fill_rect(out, cursor, 0, cursor_color, true); + + struct nk_rect whiteTextarea2; + whiteTextarea2.x = cursor.x + cursor.w; + whiteTextarea2.y = cursor.y - 2; + whiteTextarea2.h = cursor.h + 6; + whiteTextarea2.w = cursor.w * 2; + nk_fill_rect(out, whiteTextarea2, 0, nk_rgba(255,255,255,255), false); } else { /* draw cursor inside text */ short glyph_len; @@ -18478,7 +18508,15 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out, txt.padding = nk_vec2(0,0); txt.background = cursor_color;; txt.text = cursor_text_color; - nk_fill_rect(out, label, 0, cursor_color); + nk_fill_rect(out, label, 0, cursor_color, true); + + struct nk_rect whiteTextarea2; + whiteTextarea2.x = label.x + label.w; + whiteTextarea2.y = label.y - 2; + whiteTextarea2.h = label.h + 6; + whiteTextarea2.w = label.w; + nk_fill_rect(out, whiteTextarea2, 0, nk_rgba(255,255,255,255), false); + nk_widget_text(out, label, cursor_ptr, glyph_len, &txt, NK_TEXT_LEFT, font); } }} @@ -18761,7 +18799,7 @@ nk_draw_property(struct nk_command_buffer *out, const struct nk_style_property * break; case NK_STYLE_ITEM_COLOR: text.background = background->data.color; - nk_fill_rect(out, *bounds, style->rounding, background->data.color); + nk_fill_rect(out, *bounds, style->rounding, background->data.color, true); nk_stroke_rect(out, *bounds, style->rounding, style->border, background->data.color); break; } @@ -19127,9 +19165,8 @@ nk_chart_begin_colored(struct nk_context *ctx, enum nk_chart_type type, // nk_draw_nine_slice(&win->buffer, bounds, &background->data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(&win->buffer, bounds, style->rounding, style->border_color); - nk_fill_rect(&win->buffer, nk_shrink_rect(bounds, style->border), - style->rounding, style->background.data.color); + nk_fill_rect(&win->buffer, bounds, style->rounding, style->border_color, true); + nk_fill_rect(&win->buffer, nk_shrink_rect(bounds, style->border), style->rounding, style->background.data.color, true); break; } return 1; @@ -19209,7 +19246,7 @@ nk_chart_push_line(struct nk_context *ctx, struct nk_window *win, i->mouse.buttons[NK_BUTTON_LEFT].clicked) ? NK_CHART_CLICKED: 0; color = g->slots[slot].highlight; } - nk_fill_rect(out, bounds, 0, color); + nk_fill_rect(out, bounds, 0, color, true); g->slots[slot].index += 1; return ret; } @@ -19233,7 +19270,7 @@ nk_chart_push_line(struct nk_context *ctx, struct nk_window *win, color = g->slots[slot].highlight; } } - nk_fill_rect(out, nk_rect(cur.x - 2, cur.y - 2, 4, 4), 0, color); + nk_fill_rect(out, nk_rect(cur.x - 2, cur.y - 2, 4, 4), 0, color, true); /* save current data point position */ g->slots[slot].last.x = cur.x; @@ -19283,7 +19320,7 @@ nk_chart_push_column(const struct nk_context *ctx, struct nk_window *win, in->mouse.buttons[NK_BUTTON_LEFT].clicked) ? NK_CHART_CLICKED: 0; color = chart->slots[slot].highlight; } - nk_fill_rect(out, item, 0, color); + nk_fill_rect(out, item, 0, color, true); chart->slots[slot].index += 1; return ret; } @@ -19684,7 +19721,7 @@ nk_combo_begin_text(struct nk_context *ctx, const char *selected, short len, break; case NK_STYLE_ITEM_COLOR: text.background = background->data.color; - nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color); + nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color, true); nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color); break; } @@ -19784,7 +19821,7 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve // nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color); + nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color, true); nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color); break; } @@ -19823,7 +19860,7 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve bounds.w = (button.x - (style->combo.content_padding.x + style->combo.spacing.x)) - bounds.x; else bounds.w = header.w - 4 * style->combo.content_padding.x; - nk_fill_rect(&win->buffer, bounds, 0, color); + nk_fill_rect(&win->buffer, bounds, 0, color, true); /* draw open/close button */ if (draw_button_symbol) @@ -19885,7 +19922,7 @@ nk_combo_begin_symbol(struct nk_context *ctx, enum nk_symbol_type symbol, struct break; case NK_STYLE_ITEM_COLOR: sym_background = background->data.color; - nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color); + nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color, true); nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color); break; } @@ -19982,7 +20019,7 @@ nk_combo_begin_symbol_text(struct nk_context *ctx, const char *selected, short l break; case NK_STYLE_ITEM_COLOR: text.background = background->data.color; - nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color); + nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color, true); nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color); break; } @@ -20073,7 +20110,7 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2 // nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white); break; case NK_STYLE_ITEM_COLOR: - nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color); + nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color, true); nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color); break; } @@ -20173,7 +20210,7 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, short le break; case NK_STYLE_ITEM_COLOR: text.background = background->data.color; - nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color); + nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color, true); nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color); break; } diff --git a/nuklear_app.c b/nuklear_app.c index 816a253..90dcfdc 100644 --- a/nuklear_app.c +++ b/nuklear_app.c @@ -5,8 +5,6 @@ // - get new messages in other chats and display some sort of alert // - need timeout on serial messages in case the computer at the other end dies (prevent hard reset) // - delete doesnt work right (leaves characters at end of string) -// - move app-specific code to distinct file -// - 1 too many lines in the chat -- just reduce line spacing a bit #define WINDOW_WIDTH 510 #define WINDOW_HEIGHT 302 @@ -70,7 +68,9 @@ struct nk_rect chats_window_size; struct nk_rect graphql_input_window_size; struct nk_rect message_input_window_size; struct nk_rect messages_window_size; -struct nuklear_context *ctx; +struct nk_context *ctx; + +void refreshNuklearApp(Boolean blankInput); void getMessagesFromjsFunctionResponse() { @@ -171,6 +171,7 @@ void getHasNewMessagesInChat(char *thread) { return; } + // set up function to get available chat (fill buttons on right hand side) // run it on some interval? make sure user is not typing!!! void getChats() { diff --git a/nuklear_quickdraw.h b/nuklear_quickdraw.h index 2742532..40db852 100644 --- a/nuklear_quickdraw.h +++ b/nuklear_quickdraw.h @@ -24,6 +24,11 @@ #include #include "SerialHelper.h" +#define ENABLED_DOUBLE_BUFFERING +#define COMMAND_CACHING + +Boolean lastInputWasBackspace; + typedef struct NkQuickDrawFont NkQuickDrawFont; NK_API struct nk_context* nk_quickdraw_init(unsigned int width, unsigned int height); NK_API int nk_quickdraw_handle_event(EventRecord *event, struct nk_context *nuklear_context); @@ -85,12 +90,9 @@ typedef struct { long RowBytes; GrafPtr bits; Rect bounds; - BitMap BWBits; GrafPort BWPort; - Handle OrigBits; - } ShockBitmap; void NewShockBitmap(ShockBitmap *theMap, short width, short height) { @@ -115,7 +117,6 @@ void NewShockBitmap(ShockBitmap *theMap, short width, short height) { theMap->Address = theMap->BWBits.baseAddr; theMap->RowBytes = (long) theMap->BWBits.rowBytes; theMap->bits = (GrafPtr) &theMap->BWPort; - } ShockBitmap gMainOffScreen; @@ -423,8 +424,6 @@ static int _get_text_width(const char *text, int len) { return width; } - - static int nk_color_to_quickdraw_bw_color(struct nk_color color) { // TODO: since we are operating under a b&w display - we need to convert these colors to black and white @@ -434,7 +433,7 @@ static int nk_color_to_quickdraw_bw_color(struct nk_color color) { // if (red*0.299 + green*0.587 + blue*0.114) > 186 use #000000 else use #ffffff // return al_map_rgba((unsigned char)color.r, (unsigned char)color.g, (unsigned char)color.b, (unsigned char)color.a); - float magicColorNumber = color.r * 0.299 + color.g * 0.587 + color.b * 0.114; + short magicColorNumber = color.r / 3 + color.g / 2 + color.b / 10; #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING @@ -457,10 +456,7 @@ static Pattern nk_color_to_quickdraw_color(struct nk_color color) { // as a future upgrade, we could support color quickdraw // using an algorithm from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color // if (red*0.299 + green*0.587 + blue*0.114) > 186 use #000000 else use #ffffff - uint8_t red; - uint8_t blue; - uint8_t green; - float magicColorNumber = color.r * 0.299 + color.g * 0.587 + color.b * 0.114; + short magicColorNumber = color.r / 3 + color.g / 2 + color.b / 10; if (magicColorNumber > 150) { @@ -495,8 +491,653 @@ NK_API NkQuickDrawFont* nk_quickdraw_font_create_from_file() { return font; } +#ifdef COMMAND_CACHING + const struct nk_command *lastCmd; +#endif + +// used for bounds checking +int mostLeft;// = 1; +int mostBottom;// = 1; +int mostTop;// = WINDOW_HEIGHT; +int mostRight;// = WINDOW_WIDTH; + +void updateBounds(int top, int bottom, int left, int right) { + + if (left < mostLeft) { + + mostLeft = left; + } + + if (right > mostRight) { + + mostRight = right; + } + + if (top < mostTop) { + + mostTop = top; + } + + if (bottom > mostBottom) { + + mostBottom = bottom; + } +} + +void runDrawCommand(const struct nk_command *cmd) { + + int color; + + switch (cmd->type) { + + case NK_COMMAND_NOP: + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_NOP"); + #endif + + break; + case NK_COMMAND_SCISSOR: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_SCISSOR"); + #endif + + const struct nk_command_scissor *s =(const struct nk_command_scissor*)cmd; + + // there is no point in supressing scissor commands because they only affect + // where we can actually draw to: + // #ifdef COMMAND_CACHING + // if (memcmp(s, lastCmd, sizeof(struct nk_command_scissor)) == 0) { + + // #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + // writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_scissor"); + // #endif + + // break; + // } + // #endif + + Rect quickDrawRectangle; + quickDrawRectangle.top = (int)s->y; + quickDrawRectangle.left = (int)s->x; + quickDrawRectangle.bottom = (int)s->y + (int)s->h; + quickDrawRectangle.right = (int)s->x + (int)s->w; + + #ifdef ENABLED_DOUBLE_BUFFERING + // we use "-8192" here to filter out nuklear "nk_null_rect" which we do not want updating bounds + if (quickDrawRectangle.top != -8192) { + + updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right); + } + #endif + + ClipRect(&quickDrawRectangle); + } + + break; + case NK_COMMAND_LINE: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_LINE"); + #endif + + const struct nk_command_line *l = (const struct nk_command_line *)cmd; + + #ifdef COMMAND_CACHING + + if (memcmp(l, lastCmd, sizeof(struct nk_command_line)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_line"); + #endif + + break; + } + #endif + + color = nk_color_to_quickdraw_bw_color(l->color); + // great reference: http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-60.html + ForeColor(color); + PenSize((int)l->line_thickness, (int)l->line_thickness); + MoveTo((int)l->begin.x, (int)l->begin.y); + LineTo((int)l->end.x, (int)l->end.y); + } + + break; + case NK_COMMAND_RECT: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT"); + #endif + + // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-102.html#MARKER-9-372 + // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-103.html#HEADING103-0 + const struct nk_command_rect *r = (const struct nk_command_rect *)cmd; + + #ifdef COMMAND_CACHING + if (memcmp(r, lastCmd, sizeof(struct nk_command_rect)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_rect"); + #endif + + break; + } + #endif + + color = nk_color_to_quickdraw_bw_color(r->color); + + ForeColor(color); + PenSize((int)r->line_thickness, (int)r->line_thickness); + + Rect quickDrawRectangle; + quickDrawRectangle.top = (int)r->y; + quickDrawRectangle.left = (int)r->x; + quickDrawRectangle.bottom = (int)r->y + (int)r->h; + quickDrawRectangle.right = (int)r->x + (int)r->w; + + #ifdef ENABLED_DOUBLE_BUFFERING + updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right); + #endif + + FrameRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding); + } + + break; + case NK_COMMAND_RECT_FILLED: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED"); + #endif + + const struct nk_command_rect_filled *r = (const struct nk_command_rect_filled *)cmd; + + if (r->allowCache == false) { + + Rect quickDrawRectangle; + quickDrawRectangle.top = (int)r->y; + quickDrawRectangle.left = (int)r->x; + quickDrawRectangle.bottom = (int)r->y + (int)r->h; + quickDrawRectangle.right = (int)r->x + (int)r->w; + + #ifdef ENABLED_DOUBLE_BUFFERING + updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right); + #endif + + FillRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding, &qd.white); + break; + } + + + #ifdef COMMAND_CACHING + if (memcmp(r, lastCmd, sizeof(struct nk_command_rect_filled)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_rect_filled"); + #endif + + break; + } + #endif + + color = nk_color_to_quickdraw_bw_color(r->color); + + ForeColor(color); + Pattern colorPattern = nk_color_to_quickdraw_color(r->color); + + // BackPat(&colorPattern); // inside macintosh: imaging with quickdraw 3-48 + PenSize(1.0, 1.0); // no member line thickness on this struct so assume we want a thin line + // might actually need to build this with SetRect, search inside macintosh: imaging with quickdraw + Rect quickDrawRectangle; + quickDrawRectangle.top = (int)r->y; + quickDrawRectangle.left = (int)r->x; + quickDrawRectangle.bottom = (int)r->y + (int)r->h; + quickDrawRectangle.right = (int)r->x + (int)r->w; + + #ifdef ENABLED_DOUBLE_BUFFERING + updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right); + #endif + + FillRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding, &colorPattern); + FrameRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding); // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-105.html#HEADING105-0 + } + + break; + case NK_COMMAND_CIRCLE: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_CIRCLE"); + #endif + + const struct nk_command_circle *c = (const struct nk_command_circle *)cmd; + + #ifdef COMMAND_CACHING + if (memcmp(c, lastCmd, sizeof(struct nk_command_circle)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_circle"); + #endif + + break; + } + #endif + + color = nk_color_to_quickdraw_bw_color(c->color); + + ForeColor(color); + Rect quickDrawRectangle; + quickDrawRectangle.top = (int)c->y; + quickDrawRectangle.left = (int)c->x; + quickDrawRectangle.bottom = (int)c->y + (int)c->h; + quickDrawRectangle.right = (int)c->x + (int)c->w; + + #ifdef ENABLED_DOUBLE_BUFFERING + updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right); + #endif + + FrameOval(&quickDrawRectangle); // An oval is a circular or elliptical shape defined by the bounding rectangle that encloses it. inside macintosh: imaging with quickdraw 3-25 + } + + break; + case NK_COMMAND_CIRCLE_FILLED: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_CIRCLE_FILLED"); + #endif + + const struct nk_command_circle_filled *c = (const struct nk_command_circle_filled *)cmd; + + #ifdef COMMAND_CACHING + if (memcmp(c, lastCmd, sizeof(struct nk_command_circle_filled)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_circle_filled"); + #endif + + break; + } + #endif + + color = nk_color_to_quickdraw_bw_color(c->color); + + ForeColor(color); + Pattern colorPattern = nk_color_to_quickdraw_color(c->color); + // BackPat(&colorPattern); // inside macintosh: imaging with quickdraw 3-48 + PenSize(1.0, 1.0); + Rect quickDrawRectangle; + quickDrawRectangle.top = (int)c->y; + quickDrawRectangle.left = (int)c->x; + quickDrawRectangle.bottom = (int)c->y + (int)c->h; + quickDrawRectangle.right = (int)c->x + (int)c->w; + + #ifdef ENABLED_DOUBLE_BUFFERING + updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right); + #endif + + FillOval(&quickDrawRectangle, &colorPattern); + FrameOval(&quickDrawRectangle);// An oval is a circular or elliptical shape defined by the bounding rectangle that encloses it. inside macintosh: imaging with quickdraw 3-25 + // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-111.html#HEADING111-0 + } + + break; + case NK_COMMAND_TRIANGLE: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_TRIANGLE"); + #endif + + const struct nk_command_triangle *t = (const struct nk_command_triangle*)cmd; + + #ifdef COMMAND_CACHING + if (memcmp(t, lastCmd, sizeof(struct nk_command_triangle)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_triangle"); + #endif + + break; + } + #endif + + color = nk_color_to_quickdraw_bw_color(t->color); + + ForeColor(color); + PenSize((int)t->line_thickness, (int)t->line_thickness); + + MoveTo((int)t->a.x, (int)t->a.y); + LineTo((int)t->b.x, (int)t->b.y); + LineTo((int)t->c.x, (int)t->c.y); + LineTo((int)t->a.x, (int)t->a.y); + } + + break; + case NK_COMMAND_TRIANGLE_FILLED: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_TRIANGLE_FILLED"); + #endif + + const struct nk_command_triangle_filled *t = (const struct nk_command_triangle_filled *)cmd; + + #ifdef COMMAND_CACHING + if (memcmp(t, lastCmd, sizeof(struct nk_command_triangle_filled)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_triangle_filled"); + #endif + + break; + } + #endif + + Pattern colorPattern = nk_color_to_quickdraw_color(t->color); + color = nk_color_to_quickdraw_bw_color(t->color); + PenSize(1.0, 1.0); + // BackPat(&colorPattern); // inside macintosh: imaging with quickdraw 3-48 + ForeColor(color); + + PolyHandle trianglePolygon = OpenPoly(); + MoveTo((int)t->a.x, (int)t->a.y); + LineTo((int)t->b.x, (int)t->b.y); + LineTo((int)t->c.x, (int)t->c.y); + LineTo((int)t->a.x, (int)t->a.y); + ClosePoly(); + + FillPoly(trianglePolygon, &colorPattern); + KillPoly(trianglePolygon); + } + + break; + case NK_COMMAND_POLYGON: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_POLYGON"); + #endif + + const struct nk_command_polygon *p = (const struct nk_command_polygon*)cmd; + + #ifdef COMMAND_CACHING + if (memcmp(p, lastCmd, sizeof(struct nk_command_polygon)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_polygon"); + #endif + + break; + } + #endif + + color = nk_color_to_quickdraw_bw_color(p->color); + ForeColor(color); + int i; + + for (i = 0; i < p->point_count; i++) { + + if (i == 0) { + + MoveTo(p->points[i].x, p->points[i].y); + } + + LineTo(p->points[i].x, p->points[i].y); + + if (i == p->point_count - 1) { + + LineTo(p->points[0].x, p->points[0].y); + } + } + } + + break; + case NK_COMMAND_POLYGON_FILLED: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_POLYGON_FILLED"); + #endif + + const struct nk_command_polygon *p = (const struct nk_command_polygon*)cmd; + + #ifdef COMMAND_CACHING + if (memcmp(p, lastCmd, sizeof(struct nk_command_polygon)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_polygon"); + #endif + + break; + } + #endif + + Pattern colorPattern = nk_color_to_quickdraw_color(p->color); + color = nk_color_to_quickdraw_bw_color(p->color); + // BackPat(&colorPattern); // inside macintosh: imaging with quickdraw 3-48 -- but might actually need PenPat -- look into this + ForeColor(color); + int i; + + PolyHandle trianglePolygon = OpenPoly(); + for (i = 0; i < p->point_count; i++) { + + if (i == 0) { + + MoveTo(p->points[i].x, p->points[i].y); + } + + LineTo(p->points[i].x, p->points[i].y); + + if (i == p->point_count - 1) { + + LineTo(p->points[0].x, p->points[0].y); + } + } + + ClosePoly(); + + FillPoly(trianglePolygon, &colorPattern); + KillPoly(trianglePolygon); + } + + break; + case NK_COMMAND_POLYLINE: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_POLYLINE"); + #endif + + // this is similar to polygons except the polygon does not get closed to the 0th point + // check out the slight difference in the for loop + const struct nk_command_polygon *p = (const struct nk_command_polygon*)cmd; + + #ifdef COMMAND_CACHING + if (memcmp(p, lastCmd, sizeof(struct nk_command_polygon)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_polygon"); + #endif + + break; + } + #endif + + color = nk_color_to_quickdraw_bw_color(p->color); + ForeColor(color); + int i; + + for (i = 0; i < p->point_count; i++) { + + if (i == 0) { + + MoveTo(p->points[i].x, p->points[i].y); + } + + LineTo(p->points[i].x, p->points[i].y); + } + } + + break; + case NK_COMMAND_TEXT: { + + const struct nk_command_text *t = (const struct nk_command_text*)cmd; + + #ifdef COMMAND_CACHING + if (memcmp(t, lastCmd, sizeof(struct nk_command_text)) == 0) { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_text"); + #endif + + break; + } + #endif + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_TEXT"); + char log[255]; + sprintf(log, "%f: %c, %d", (int)t->height, &t->string, (int)t->length); + writeSerialPortDebug(boutRefNum, log); + #endif + + Rect quickDrawRectangle; + quickDrawRectangle.top = (int)t->y; + quickDrawRectangle.left = (int)t->x; + quickDrawRectangle.bottom = (int)t->y + 15; + quickDrawRectangle.right = (int)t->x + _get_text_width((const char*)t->string, (int)t->length); + + // #ifdef COMMAND_CACHING + // if (lastInputWasBackspace) { + + // quickDrawRectangle.right += 20; + // } + // #endif + + #ifdef ENABLED_DOUBLE_BUFFERING + updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right); + #endif + + EraseRect(&quickDrawRectangle); + + color = nk_color_to_quickdraw_bw_color(t->foreground); + ForeColor(color); + MoveTo((int)t->x, (int)t->y + (int)t->height); + + PenSize(1.0, 1.0); + DrawText((const char*)t->string, 0, (int)t->length); + } + + break; + case NK_COMMAND_CURVE: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_CURVE"); + #endif + + const struct nk_command_curve *q = (const struct nk_command_curve *)cmd; + color = nk_color_to_quickdraw_bw_color(q->color); + ForeColor(color); + Point p1 = { (int)q->begin.x, (int)q->begin.y}; + Point p2 = { (int)q->ctrl[0].x, (int)q->ctrl[0].y}; + Point p3 = { (int)q->ctrl[1].x, (int)q->ctrl[1].y}; + Point p4 = { (int)q->end.x, (int)q->end.y}; + + BezierCurve(p1, p2, p3, p4); + } + + break; + case NK_COMMAND_ARC: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_ARC"); + #endif + + const struct nk_command_arc *a = (const struct nk_command_arc *)cmd; + + color = nk_color_to_quickdraw_bw_color(a->color); + ForeColor(color); + Rect arcBoundingBoxRectangle; + // this is kind of silly because the cx is at the center of the arc and we need to create a rectangle around it + // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-60.html#MARKER-2-116 + int x1 = (int)a->cx - (int)a->r; + int y1 = (int)a->cy - (int)a->r; + int x2 = (int)a->cx + (int)a->r; + int y2 = (int)a->cy + (int)a->r; + SetRect(&arcBoundingBoxRectangle, x1, y1, x2, y2); + // SetRect(secondRect,90,20,140,70); + + FrameArc(&arcBoundingBoxRectangle, a->a[0], a->a[1]); + } + + break; + case NK_COMMAND_IMAGE: { + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_IMAGE"); + #endif + + const struct nk_command_image *i = (const struct nk_command_image *)cmd; + // al_draw_bitmap_region(i->img.handle.ptr, 0, 0, i->w, i->h, i->x, i->y, 0); // TODO: look up and convert al_draw_bitmap_region + // TODO: consider implementing a bitmap drawing routine. we could iterate pixel by pixel and draw + // here is some super naive code that could work, used for another project that i was working on with a custom format but would be + // easy to modify for standard bitmap files (just need to know how many bytes represent each pixel and iterate from there): + // + // for (int i = 0; i < strlen(string); i++) { + // printf("\nchar: %c", string[i]); + // char pixel[1]; + // memcpy(pixel, &string[i], 1); + // if (strcmp(pixel, "0") == 0) { // white pixel + // MoveTo(++x, y); + // } else if (strcmp(pixel, "1") == 0) { // black pixel + // // advance the pen and draw a 1px x 1px "line" + // MoveTo(++x, y); + // LineTo(x, y); + // } else if (strcmp(pixel, "|") == 0) { // next line + // x = 1; + // MoveTo(x, ++y); + // } else if (strcmp(pixel, "/") == 0) { // end + // } + // } + } + + break; + + // why are these cases not implemented? + case NK_COMMAND_RECT_MULTI_COLOR: + case NK_COMMAND_ARC_FILLED: + default: + + #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING + + writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_MULTI_COLOR/NK_COMMAND_ARC_FILLED/default"); + #endif + break; + } + +} + NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) { + #ifdef PROFILING + PROFILE_START("IN nk_quickdraw_render"); + #endif + + #ifdef PROFILING + PROFILE_START("get cmds and memcmp them"); + #endif + void *cmds = nk_buffer_memory(&ctx->memory); // do not render if the buffer did not change from the previous rendering run @@ -510,429 +1151,105 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) { return; } - memcpy(last, cmds, ctx->memory.allocated); + #ifdef PROFILING + PROFILE_END("get cmds and memcmp them"); + #endif const struct nk_command *cmd = 0; - OpenPort(&gMainOffScreen.BWPort); - SetPort(&gMainOffScreen.BWPort); - SetPortBits(&gMainOffScreen.BWBits); + #ifdef ENABLED_DOUBLE_BUFFERING + OpenPort(&gMainOffScreen.BWPort); + SetPort(&gMainOffScreen.BWPort); + SetPortBits(&gMainOffScreen.BWBits); + #endif + + #ifdef PROFILING + PROFILE_START("rendering loop and switch"); + #endif + + short iterations = 0; + + #ifdef COMMAND_CACHING + lastCmd = nk_ptr_add_const(struct nk_command, last, 0); + #endif nk_foreach(cmd, ctx) { - int color; + runDrawCommand(cmd); - switch (cmd->type) { - - case NK_COMMAND_NOP: - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_NOP"); - #endif - - break; - case NK_COMMAND_SCISSOR: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_SCISSOR"); - #endif - - const struct nk_command_scissor *s =(const struct nk_command_scissor*)cmd; - - Rect quickDrawRectangle; - quickDrawRectangle.top = (int)s->y; - quickDrawRectangle.left = (int)s->x; - quickDrawRectangle.bottom = (int)s->y + (int)s->h; - quickDrawRectangle.right = (int)s->x + (int)s->w; - - ClipRect(&quickDrawRectangle); - } - - break; - case NK_COMMAND_LINE: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_LINE"); - #endif - - const struct nk_command_line *l = (const struct nk_command_line *)cmd; - - color = nk_color_to_quickdraw_bw_color(l->color); - // great reference: http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-60.html - ForeColor(color); - PenSize((int)l->line_thickness, (int)l->line_thickness); - MoveTo((int)l->begin.x, (int)l->begin.y); - LineTo((int)l->end.x, (int)l->end.y); - } - - break; - case NK_COMMAND_RECT: { - - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT"); - #endif - - // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-102.html#MARKER-9-372 - // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-103.html#HEADING103-0 - const struct nk_command_rect *r = (const struct nk_command_rect *)cmd; - - color = nk_color_to_quickdraw_bw_color(r->color); - - ForeColor(color); - PenSize((int)r->line_thickness, (int)r->line_thickness); - - Rect quickDrawRectangle; - quickDrawRectangle.top = (int)r->y; - quickDrawRectangle.left = (int)r->x; - quickDrawRectangle.bottom = (int)r->y + (int)r->h; - quickDrawRectangle.right = (int)r->x + (int)r->w; - - FrameRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding); - } - - break; - case NK_COMMAND_RECT_FILLED: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED"); - #endif - - const struct nk_command_rect_filled *r = (const struct nk_command_rect_filled *)cmd; - - color = nk_color_to_quickdraw_bw_color(r->color); - - ForeColor(color); - Pattern colorPattern = nk_color_to_quickdraw_color(r->color); - - // BackPat(&colorPattern); // inside macintosh: imaging with quickdraw 3-48 - PenSize(1.0, 1.0); // no member line thickness on this struct so assume we want a thin line - // might actually need to build this with SetRect, search inside macintosh: imaging with quickdraw - Rect quickDrawRectangle; - quickDrawRectangle.top = (int)r->y; - quickDrawRectangle.left = (int)r->x; - quickDrawRectangle.bottom = (int)r->y + (int)r->h; - quickDrawRectangle.right = (int)r->x + (int)r->w; - - FillRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding, &colorPattern); - FrameRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding); // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-105.html#HEADING105-0 - } - - break; - case NK_COMMAND_CIRCLE: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_CIRCLE"); - #endif - - const struct nk_command_circle *c = (const struct nk_command_circle *)cmd; - - color = nk_color_to_quickdraw_bw_color(c->color); - - ForeColor(color); - Rect quickDrawRectangle; - quickDrawRectangle.top = (int)c->y; - quickDrawRectangle.left = (int)c->x; - quickDrawRectangle.bottom = (int)c->y + (int)c->h; - quickDrawRectangle.right = (int)c->x + (int)c->w; - - FrameOval(&quickDrawRectangle); // An oval is a circular or elliptical shape defined by the bounding rectangle that encloses it. inside macintosh: imaging with quickdraw 3-25 - } - - break; - case NK_COMMAND_CIRCLE_FILLED: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_CIRCLE_FILLED"); - #endif - - const struct nk_command_circle_filled *c = (const struct nk_command_circle_filled *)cmd; - - color = nk_color_to_quickdraw_bw_color(c->color); - - ForeColor(color); - Pattern colorPattern = nk_color_to_quickdraw_color(c->color); - // BackPat(&colorPattern); // inside macintosh: imaging with quickdraw 3-48 - PenSize(1.0, 1.0); - Rect quickDrawRectangle; - quickDrawRectangle.top = (int)c->y; - quickDrawRectangle.left = (int)c->x; - quickDrawRectangle.bottom = (int)c->y + (int)c->h; - quickDrawRectangle.right = (int)c->x + (int)c->w; - - FillOval(&quickDrawRectangle, &colorPattern); - FrameOval(&quickDrawRectangle);// An oval is a circular or elliptical shape defined by the bounding rectangle that encloses it. inside macintosh: imaging with quickdraw 3-25 - // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-111.html#HEADING111-0 - } - - break; - case NK_COMMAND_TRIANGLE: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_TRIANGLE"); - #endif - - const struct nk_command_triangle *t = (const struct nk_command_triangle*)cmd; - color = nk_color_to_quickdraw_bw_color(t->color); - - ForeColor(color); - PenSize((int)t->line_thickness, (int)t->line_thickness); - - MoveTo((int)t->a.x, (int)t->a.y); - LineTo((int)t->b.x, (int)t->b.y); - LineTo((int)t->c.x, (int)t->c.y); - LineTo((int)t->a.x, (int)t->a.y); - } - - break; - case NK_COMMAND_TRIANGLE_FILLED: { - - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_TRIANGLE_FILLED"); - #endif - - const struct nk_command_triangle_filled *t = (const struct nk_command_triangle_filled *)cmd; - Pattern colorPattern = nk_color_to_quickdraw_color(t->color); - color = nk_color_to_quickdraw_bw_color(t->color); - PenSize(1.0, 1.0); - // BackPat(&colorPattern); // inside macintosh: imaging with quickdraw 3-48 - ForeColor(color); - - PolyHandle trianglePolygon = OpenPoly(); - MoveTo((int)t->a.x, (int)t->a.y); - LineTo((int)t->b.x, (int)t->b.y); - LineTo((int)t->c.x, (int)t->c.y); - LineTo((int)t->a.x, (int)t->a.y); - ClosePoly(); - - FillPoly(trianglePolygon, &colorPattern); - KillPoly(trianglePolygon); - } - - break; - case NK_COMMAND_POLYGON: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_POLYGON"); - #endif - - const struct nk_command_polygon *p = (const struct nk_command_polygon*)cmd; - - color = nk_color_to_quickdraw_bw_color(p->color); - ForeColor(color); - int i; - - for (i = 0; i < p->point_count; i++) { - - if (i == 0) { - - MoveTo(p->points[i].x, p->points[i].y); - } - - LineTo(p->points[i].x, p->points[i].y); - - if (i == p->point_count - 1) { - - LineTo(p->points[0].x, p->points[0].y); - } - } - } - - break; - case NK_COMMAND_POLYGON_FILLED: { - - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_POLYGON_FILLED"); - #endif - - const struct nk_command_polygon *p = (const struct nk_command_polygon*)cmd; - - Pattern colorPattern = nk_color_to_quickdraw_color(p->color); - color = nk_color_to_quickdraw_bw_color(p->color); - // BackPat(&colorPattern); // inside macintosh: imaging with quickdraw 3-48 -- but might actually need PenPat -- look into this - ForeColor(color); - int i; - - PolyHandle trianglePolygon = OpenPoly(); - for (i = 0; i < p->point_count; i++) { - - if (i == 0) { - - MoveTo(p->points[i].x, p->points[i].y); - } - - LineTo(p->points[i].x, p->points[i].y); - - if (i == p->point_count - 1) { - - - LineTo(p->points[0].x, p->points[0].y); - } - } - - ClosePoly(); - - FillPoly(trianglePolygon, &colorPattern); - KillPoly(trianglePolygon); - } - - break; - case NK_COMMAND_POLYLINE: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_POLYLINE"); - #endif - - // this is similar to polygons except the polygon does not get closed to the 0th point - // check out the slight difference in the for loop - const struct nk_command_polygon *p = (const struct nk_command_polygon*)cmd; - - color = nk_color_to_quickdraw_bw_color(p->color); - ForeColor(color); - int i; - - for (i = 0; i < p->point_count; i++) { - - if (i == 0) { - - MoveTo(p->points[i].x, p->points[i].y); - } - - LineTo(p->points[i].x, p->points[i].y); - } - } - - break; - case NK_COMMAND_TEXT: { - - const struct nk_command_text *t = (const struct nk_command_text*)cmd; - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_TEXT"); - char log[255]; - sprintf(log, "%f: %c, %d", (int)t->height, &t->string, (int)t->length); - writeSerialPortDebug(boutRefNum, log); - #endif - - color = nk_color_to_quickdraw_bw_color(t->foreground); - ForeColor(color); - MoveTo((int)t->x, (int)t->y + (int)t->height); - - PenSize(1.0, 1.0); - DrawText((const char*)t->string, 0, (int)t->length); - } - - break; - case NK_COMMAND_CURVE: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_CURVE"); - #endif - - const struct nk_command_curve *q = (const struct nk_command_curve *)cmd; - color = nk_color_to_quickdraw_bw_color(q->color); - ForeColor(color); - Point p1 = { (int)q->begin.x, (int)q->begin.y}; - Point p2 = { (int)q->ctrl[0].x, (int)q->ctrl[0].y}; - Point p3 = { (int)q->ctrl[1].x, (int)q->ctrl[1].y}; - Point p4 = { (int)q->end.x, (int)q->end.y}; - - BezierCurve(p1, p2, p3, p4); - } - - break; - case NK_COMMAND_ARC: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_ARC"); - #endif - - const struct nk_command_arc *a = (const struct nk_command_arc *)cmd; - - color = nk_color_to_quickdraw_bw_color(a->color); - ForeColor(color); - Rect arcBoundingBoxRectangle; - // this is kind of silly because the cx is at the center of the arc and we need to create a rectangle around it - // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-60.html#MARKER-2-116 - int x1 = (int)a->cx - (int)a->r; - int y1 = (int)a->cy - (int)a->r; - int x2 = (int)a->cx + (int)a->r; - int y2 = (int)a->cy + (int)a->r; - SetRect(&arcBoundingBoxRectangle, x1, y1, x2, y2); - // SetRect(secondRect,90,20,140,70); - - FrameArc(&arcBoundingBoxRectangle, a->a[0], a->a[1]); - } - - break; - case NK_COMMAND_IMAGE: { - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_IMAGE"); - #endif - - const struct nk_command_image *i = (const struct nk_command_image *)cmd; - // al_draw_bitmap_region(i->img.handle.ptr, 0, 0, i->w, i->h, i->x, i->y, 0); // TODO: look up and convert al_draw_bitmap_region - // TODO: consider implementing a bitmap drawing routine. we could iterate pixel by pixel and draw - // here is some super naive code that could work, used for another project that i was working on with a custom format but would be - // easy to modify for standard bitmap files (just need to know how many bytes represent each pixel and iterate from there): - // - // for (int i = 0; i < strlen(string); i++) { - // printf("\nchar: %c", string[i]); - // char pixel[1]; - // memcpy(pixel, &string[i], 1); - // if (strcmp(pixel, "0") == 0) { // white pixel - // MoveTo(++x, y); - // } else if (strcmp(pixel, "1") == 0) { // black pixel - // // advance the pen and draw a 1px x 1px "line" - // MoveTo(++x, y); - // LineTo(x, y); - // } else if (strcmp(pixel, "|") == 0) { // next line - // x = 1; - // MoveTo(x, ++y); - // } else if (strcmp(pixel, "/") == 0) { // end - // } - // } - } - - break; - - // why are these cases not implemented? - case NK_COMMAND_RECT_MULTI_COLOR: - case NK_COMMAND_ARC_FILLED: - default: - - #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING - - writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_MULTI_COLOR/NK_COMMAND_ARC_FILLED/default"); - #endif - break; - } + #ifdef COMMAND_CACHING + if (lastCmd->next < ctx->memory.allocated) { + lastCmd = nk_ptr_add_const(struct nk_command, last, lastCmd->next); + } + #endif } - SetPort(window); + #ifdef PROFILING + PROFILE_START("memcpy commands"); + #endif - // our offscreen bitmap is the same size as our port rectangle, so we - // get away with using the portRect sizing for source and destination - CopyBits(&gMainOffScreen.bits->portBits, &window->portBits, &window->portRect, &window->portRect, srcCopy, 0L); + memcpy(last, cmds, ctx->memory.allocated); + + #ifdef PROFILING + PROFILE_END("memcpy commands"); + #endif + + #ifdef PROFILING + PROFILE_END("rendering loop and switch"); + #endif + + #ifdef COMMAND_CACHING + lastInputWasBackspace = false; + #endif + + #ifdef ENABLED_DOUBLE_BUFFERING + + #ifdef PROFILING + PROFILE_START("copy bits"); + #endif + + SetPort(window); + + /* + PROCEDURE CopyBits (srcBits,dstBits: BitMap; + srcRect,dstRect:ðRect; mode:ðInteger; + maskRgn:ðRgnHandle); + srcBits + The source BitMap record. + dstBits + The destination BitMap record. + srcRect + The source rectangle. + dstRect + The destination rectangle. + mode + One of the eight source modes in which the copy is to be performed. + maskRgn + A region to use as a clipping mask. + */ + // our offscreen bitmap is the same size as our port rectangle, so we + // get away with using the portRect sizing for source and destination + Rect quickDrawRectangle; + quickDrawRectangle.top = mostTop; + quickDrawRectangle.left = mostLeft; + quickDrawRectangle.bottom = mostBottom; + quickDrawRectangle.right = mostRight; + + CopyBits(&gMainOffScreen.bits->portBits, &window->portBits, &quickDrawRectangle, &quickDrawRectangle, srcCopy, 0L); + + mostLeft = 1; + mostBottom = 1; + mostTop = WINDOW_HEIGHT; + mostRight = WINDOW_WIDTH; + + #ifdef PROFILING + PROFILE_END("copy bits"); + #endif + #endif + + #ifdef PROFILING + PROFILE_END("IN nk_quickdraw_render"); + #endif } NK_API int nk_quickdraw_handle_event(EventRecord *event, struct nk_context *nuklear_context) { @@ -1107,6 +1424,9 @@ NK_API int nk_quickdraw_handle_event(EventRecord *event, struct nk_context *nukl nk_input_key(nuklear_context, NK_KEY_DOWN, isKeyDown); } else if (key == backspaceKey) { + #ifdef COMMAND_CACHING + lastInputWasBackspace = true; + #endif nk_input_key(nuklear_context, NK_KEY_BACKSPACE, isKeyDown); } else if (key == escapeKey) { @@ -1177,7 +1497,13 @@ NK_API struct nk_context* nk_quickdraw_init(unsigned int width, unsigned int hei // needed to calculate bezier info, see mactech article. setupBezier(); - NewShockBitmap(&gMainOffScreen, width, height); + #ifdef ENABLED_DOUBLE_BUFFERING + NewShockBitmap(&gMainOffScreen, width, height); + #else + TextFont(0); + TextSize(12); + TextFace(0); + #endif NkQuickDrawFont *quickdrawfont = nk_quickdraw_font_create_from_file(); struct nk_user_font *font = &quickdrawfont->nk;