Skip to content

Instantly share code, notes, and snippets.

@bazhenovc
bazhenovc / the_sane_rendering_manifesto.md
Last active April 13, 2024 12:57
The Sane Rendering Manifesto

The Sane Rendering Manifesto

The goal of this manifesto is to provide an easy to follow and reasonable rules that realtime and video game renderers can follow.

These rules highly prioritize image clarity/stability and pleasant gameplay experience over photorealism and excess graphics fidelity.

Keep in mind that shipping a game has priority over everything else and it is allowed to break the rules of the manifesto when there are no other good options in order to ship the game.

Do not use dynamic resolution.

@bazhenovc
bazhenovc / nvapi_force_discrete_card.cpp
Created September 7, 2016 15:03
nvapi force discrete card
void nvidiaForceUseDiscreteCard()
{
NvAPI_Status status = NvAPI_Initialize();
if(status != NVAPI_OK) return;
NvDRSSessionHandle hSession = 0;
status = NvAPI_DRS_CreateSession(&hSession);
if(status != NVAPI_OK) return;
status = NvAPI_DRS_LoadSettings(hSession);
@bazhenovc
bazhenovc / v8_wrap_class.cpp
Created September 28, 2015 15:25 — forked from mythagel/v8_wrap_class.cpp
Complete example of binding a C++ class with Google V8.
/*
* v8_wrap_class.cpp
*
* Created on: 14/01/2013
* Author: nicholas
* License: public domain
*/
/* CMakeLists.txt
project(v8_wrap_class)
template <unsigned x> struct PopCount
{
enum {
a = x - ((x >> 1) & 0x55555555),
b = (((a >> 2) & 0x33333333) + (a & 0x33333333)),
c = (((b >> 4) + b) & 0x0f0f0f0f),
d = c + (c >> 8),
e = d + (d >> 16),
result = e & 0x0000003f
};
template <typename T>
constexpr unsigned BitsRequired(T min, T max)
{
template <unsigned x> struct PopCount
{
enum {
a = x - ((x >> 1) & 0x55555555),
b = (((a >> 2) & 0x33333333) + (a & 0x33333333)),
c = (((b >> 4) + b) & 0x0f0f0f0f),
d = c + (c >> 8),
build.d(668): Error: cannot implicitly convert expression (indexOf(cast(const(char)[])arg,"[",cast(CaseSensitive)1)) of type long to int
build.d(669): Error: cannot implicitly convert expression (lastIndexOf(cast(const(char)[])arg,"]",cast(CaseSensitive)1)) of type long to int
diff --git a/build.d b/build.d
index f6d1053..aa1fd18 100644
--- a/build.d
+++ b/build.d
@@ -665,8 +665,8 @@ foreach (arg; args[1 .. $]) {
isDebug = true;
continue;
} else {
- int pi1 = std.string.indexOf(arg, "[");
- int pi2 = std.string.lastIndexOf(arg, "]");
cc -o libcheetah.so src/image_write.o src/filesystem.o src/particles.o src/framebuffer.o src/window.o src/atlas.o src/generator.o src/tilemap.o src/event.o src/vbo.o src/font.o src/graphics.o src/thread.o src/image.o src/render.o src/shader.o src/SOIL/image_DXT.o src/SOIL/stb_image_aug.o src/SOIL/SOIL.o src/SOIL/image_helper.o -Ofast -fomit-frame-pointer -funroll-loops -mmmx -msse -ftree-vectorize -flto -m32 -fprofile-use -Wall -Winline -pipe -fPIC -shared -L"lib" -lSDL -lGL
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../libSDL.so when searching for -lSDL
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/bin/ld: skipping incompatible /usr/lib/libSDL.so when searching for -lSDL
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lSDL
src/generator.o (symbol from plugin): warning: memset used with constant zero length parameter; this could be due to t
/// Increase the reference count on the object.
template< class T, class DeletePolicy >
inline void ThreadSafeRefCount< T, DeletePolicy >::addRef()
{
dFetchAndAdd( mRefCount, 2 );
}
/// Decrease the object's reference count and delete the object, if the count
/// drops to zero and claiming the object by the current thread succeeds.
class Thread
{
private:
uint8_t storage[kThreadDataStorage];
public:
typedef void (*ThreadWorkerFunction)(void*);
void StartWorkerFunction(ThreadWorkerFunction func);