Skip to content

Instantly share code, notes, and snippets.

View jwbuurlage's full-sized avatar

Jan-Willem Buurlage jwbuurlage

View GitHub Profile
void Terrain::generateIndices() {
// we calculate the amount of levels and make the index buffers
int level_max = log2(patch_size - 1);
indexCount = new GLuint[level_max + 1];
indexBuffer = new GLuint[level_max + 1];
header = UILabel.alloc.initWithFrame([[20, 260], [view.frame.size.width - 20 * 2, 40]])
#=> expected instance of `CGPoint', got `20' (Fixnum) (TypeError)
// -----------------------------------------------------------------------------
// BYN SOFTWARE, COPYRIGHT 2012
//
// Author: Jan-Willem Buurlage et al.
// Contact: j.buurlage@students.uu.nl
//
// Part of the Starry project, an astronomy application for the regular user,
// for the iPad and iPhone.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// BYN SOFTWARE, COPYRIGHT 2012
//
// Author: Jan-Willem Buurlage et al.
// Contact: j.buurlage@students.uu.nl
//
// Part of the Starry project, an astronomy application for the regular user,
// for the iPad and iPhone.
// -----------------------------------------------------------------------------
module TicTacToe
class Board
def initialize
@grid = Array.new(9, -1)
end
def move(square, player)
return false unless @grid[square] == -1
@grid[square] = player
end
module SeaBattle
class Board
def initialize
@grid = Array.new(100, 0)
end
def set_boat(i, j, o, length)
# o = orientation, 0 = right, 1 = down
if(o == 0)
for x in j...(j+length)
@jwbuurlage
jwbuurlage / gist:3252098
Created August 3, 2012 22:18
Render loop
// relevant code before the call
// ...
glUseProgram(PROG_POINT);
glUniformMatrix4fv(LOC_POINT_MVP, 1, GL_FALSE, modelViewProjectionMatrix.m);
glUniform1i(LOC_POINT_TEXTURE, 0);
glUniform4f(LOC_POINT_COLOR, 1.0f, 1.0f, 1.0f, 1.0f);
glBindBuffer(GL_ARRAY_BUFFER, some_vertex_buffer);
glEnableVertexAttribArray(0);
SRInterfaceController* interface = [[SRInterfaceController alloc] init];
SomeGLKViewController* glVC = [[SomeGLKViewController alloc] initWithNibName:nil bundle:nil];
starVC.preferredFramesPerSecond = 60;
[mainVC addChildViewController:interface];
[mainVC addChildViewController:glVC];
[[mainVC view] addSubview:[glVC view]];
[[mainVC view] addSubview:[interface view]];
@jwbuurlage
jwbuurlage / gist:3312587
Created August 10, 2012 08:24
Extract red color in OpenGL
glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
glUniformMatrix4fv(LOC_BASIC_MVP, 1, GL_FALSE, GLKMatrix4Identity.m);
glUniform4f(LOC_BASIC_COLOR, 1.0f, 0.0f, 0.0f, 1.0f);
glBindBuffer(GL_ARRAY_BUFFER, unit_square_vertex_buffer);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float),(GLvoid*)0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@jwbuurlage
jwbuurlage / boat_raise.rb
Created August 22, 2012 18:21
Boats met raising errors
# ------------------------------------------------------------------------------
# dit is een proc
check = lambda do |i|
(i <= 5) # returned false als i > 5
end
# we callen de proc voor alle i in 1..6