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
/****************************************************************************** | |
Online C Compiler. | |
Code, Compile, Run and Debug C program online. | |
Write your code in this editor and press "Run" button to compile and execute it. | |
*******************************************************************************/ | |
#include <stdio.h> | |
#include <stdlib.h> |
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
class A { | |
private: | |
int p_i; | |
public: | |
A(int i) : p_i(i){} | |
A(const A& a) : p_i(a.p_i){} | |
operator int(){ return p_i; } | |
}; | |
int main(){ |
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 <cmath> | |
#include <vector> | |
#include <SDL/SDL.h> | |
#include <IL/il.h> | |
#include <math.h> | |
const float PI = 3.14159265359f; | |
typedef struct { | |
unsigned int id; |
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
c*x^2-2*b*x^2+a*x^2+2*b*x-2*a*x+a | |
Derive formula for quadratic bezier curve: | |
Interpolate from start point towards control point: | |
v1 = a + (b-a)*t | |
Interpolate from control point towards end point: | |
v2 = b + (c-b)*t | |
Interpolate between the two points computed from v1 and v2 (v is our point on the curve for any t in [0, 1]): | |
v = v1 + (v2 - v1)*t |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
static void sumSubArraysFast(int* arr, size_t size){ | |
int i,j,k; | |
int matsize = size * size; | |
int matsizebytes = sizeof(int) * matsize; | |
int* mat = malloc(matsizebytes); | |
memset(mat, 0, matsizebytes); |
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 <stdio.h> | |
static void printSubArrays(int* arr, size_t size){ | |
int i,j,k; | |
/* subarray sizes */ | |
for(i = 1; i < size; i++){ | |
printf("Subarrays with size %d:\n", i); | |
/* start position of subarray */ | |
for(j = 0; j <= (size - i); j++){ |
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
log2_integer_recur(x, integer_result, error, multiplier, level): | |
if x > multiplier: | |
x = log2_integer_recur(x, integer_result, error, multiplier*multiplier, level*2) | |
while x > multiplier: | |
x := x / multiplier | |
integer_result := integer_result + level | |
return x | |
else: | |
return x | |
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
class Asteroid; | |
class Ship; | |
class Bullet; | |
class GameObject; | |
class CollisionDispatcher { | |
public: | |
virtual bool collidesWith(Asteroid* obj1, GameObject* obj2){ | |
return obj2->collidesWithAsteroid(obj1); | |
} |
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
With glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA), scaling both source and destination with the same factor: | |
Note that: | |
(src*a*k) + (dst*(1-a)*k) = ((src*a) + (dst*(1-a)))*k | |
But since k is a part of a, we have to do some trickery: | |
alpha = (1.0 - (1.0 - alpha)*factor) | |
alpha = 1.0 - (factor - alpha*factor) | |
alpha = 1.0 + (alpha-1)*factor |
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
How to cross-compile guile guile-2.0.9.241-950a-dirty or later for Windows, from a GNU Linux-distro (without thread support for now) | |
0.) If you have Wine installed, make sure it is not associated with .exe files, as it messes up | |
./configure's cross-compiler detection. Run "sudo update-binfmts --disable wine" if this is the case. | |
1.) Compile guile locally | |
2.) Cross-compile all dependencies normally, except libgc which requires special treatment. The libraries you need are the | |
versions below, or later: | |
gettext-0.18.3.1 | |
gmp-5.1.3 |