This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
option(WITH_FINAL "Use the `final` specifier on derived classes (faster?)" OFF) | |
# ... | |
if (WITH_FINAL) | |
message(STATUS "Using `final` spicifer (faster?)") | |
target_compile_definitions(PSRayTracing_StaticLibrary PUBLIC USE_FINAL) | |
else() | |
message(STATUS "Turned off use of `final` (slower?)") | |
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# `Linguist` is required | |
find_package(Qt6 COMPONENTS Linguist REQUIRED) | |
# ... | |
# Have your app specified | |
qt_add_executable(myapp ... | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check if we're building for iOS (and put it into a more friendly variable) | |
set(IOS FALSE) | |
if (${CMAKE_SYSTEM_NAME} STREQUAL iOS) | |
set(IOS TRUE) | |
endif() | |
# If we're building for Android or iOS, turn on the UI | |
set(IS_MOBILE FALSE) | |
if (ANDROID OR IOS) | |
set(IS_MOBILE TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -157,8 +166,15 @@ int main(int argc, char *argv[]) { | |
} | |
// Print some info | |
- const rreal renderTime = rreal(chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count()) / 1000.0f; | |
- cout << "Render took " << renderTime << " seconds" << endl; | |
+ if (run_in_testing_mode) { | |
+ // For machines, we show nanoseconds (as integers) | |
+ const auto render_time_us = chrono::duration_cast<std::chrono::nanoseconds>(endTime - startTime).count(); | |
+ cout << render_time_us << " ns" << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
import random | |
import math | |
import matplotlib.pyplot as plt | |
class Vec3: | |
__slots__ = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If on OS, we need to fix some issues with the dylibs | |
# namely the rpath stuff & dylib IDs, it's a bit of a pain | |
if is_osx: | |
cmds = [] | |
# First fix Ids | |
dylibs = ['ogg', 'vorbis', 'vorbisenc', 'vorbisfile', 'sndfile'] | |
for lib in dylibs: | |
lib_filename = 'lib%s.dylib' % (lib) | |
cmd = 'install_name_tool -id "@rpath/{0}" lib/{0}'.format(lib_filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random, rdstdin, strutils | |
randomize() | |
let iRange = 1..100 | |
echo "Guess my target number that is between ", iRange.a, " and ", iRange.b, " (inclusive)." | |
let target = random(iRange) | |
var answer, i = 0 | |
while answer != target: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import osproc | |
# Where your Nim compiler is located | |
const nimEXE = "/home/ben/bin/Nim/bin/nim" | |
# Compile and wait for it to be done | |
let | |
compile = startProcess(nimEXE, "", ["c", "--app:lib", "game"]) | |
compileStatus = waitForExit(compile) | |
close(compile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
method hit*(ry: rotate_y, r: ray, t_min, t_max: float, rec: var hit_record): bool= | |
# I thought this was copying the vec3 data, but it wasn't. It was copying the pointer... | |
var | |
origin = r.origin() | |
direction = r.direction() | |
# origin and direction are modified after this which caused the issue... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stb_image.h" | |
// Get the image data | |
int width, height, channels; | |
unsigned char *data = stbi_load("kevin_bacon.jpeg", &width, &height, &channels, STBI_default); | |
// Do what you want... | |
// Cleanup | |
stbi_image_free(data); |
NewerOlder