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
GLvoid* load_image(NSString* imagename){ | |
CGImageRef img = [[NSImage imageNamed:imagename] CGImage]; | |
if(!img) NSLog(@"Image loading failed for \"%@\"", imagename); | |
NSInteger width = CGImageGetWidth(img); | |
NSInteger height = CGImageGetHeight(img); | |
unsigned char *data = (unsigned char*) malloc(width*height*4); | |
// Create a context to draw the new bitmap into | |
CGContextRef context = CGBitmapContextCreate(data, width, height, 8, width * 4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedLast); |
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
GLvoid* load_image(NSString* imagename){ | |
CFURLRef url = (CFURLRef)[[NSBundle mainBundle] URLForImageResource:imagename]; | |
CGImageSourceRef source = CGImageSourceCreateWithURL(url, NULL); | |
CGImageRef img = CGImageSourceCreateImageAtIndex(source, 0, NULL); | |
if(!img) NSLog(@"Image loading failed for \"%@\"", imagename); | |
NSInteger width = CGImageGetWidth(img); |
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
- (GLvoid)setupOpenGL{ | |
/* Create buffers */ { | |
glGenBuffers(2, buffers); | |
// Vertex buffer | |
glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); | |
glBufferData(GL_ARRAY_BUFFER, sizeof(vbdata), vbdata, GL_STATIC_DRAW); | |
// Element buffer | |
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]); | |
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(ebdata), ebdata, GL_STATIC_DRAW); | |
} |
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
/* Load textures */ { | |
glGenTextures(2, textures); | |
GLsizei width, height; | |
GLvoid* pixels; | |
// Texture #1 | |
pixels = load_image(@"hello1.png", &width, &height); | |
glBindTexture(GL_TEXTURE_2D, textures[0]); | |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
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
// | |
// CNWorldView+Drawing.m | |
// Concorde | |
// | |
// Created by Dylan Lukes on 9/22/10. | |
// Copyright 2010 Dylan Lukes. All rights reserved. | |
// | |
#import <OpenGL/gl.h> | |
#import <OpenGL/glu.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
- (void)loadShaderNamed:(NSString*)shaderName buffer:(const GLchar**)buffer length:(GLuint*)length{ | |
NSURL *url; | |
NSString *shader; | |
NSError *error; | |
NSDictionary *errorInfo; | |
url = [self URLForResource:shaderName withExtension:nil subdirectory:@"Shaders"]; | |
shader = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error]; | |
if (!shader) { |
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
// | |
// NSBundle+GLUtil.m | |
// Concorde | |
// | |
// Created by Dylan Lukes on 9/25/10. | |
// Copyright 2010 Dylan Lukes. All rights reserved. | |
// | |
#import "NSBundle+CGLUtil.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
package alphatunnel; | |
import java.io.IOException; | |
import java.io.FilterInputStream; | |
import java.net.Socket; | |
import java.net.UnknownHostException; | |
import java.nio.CharBuffer; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; |
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
require 'socket' | |
class ClientQuitError < RuntimeError; end | |
port = ARGV.shift || 0 # default is to use the next available port | |
host = ARGV.shift # default is to bind everything | |
server = host ? TCPServer.open(host, port) : TCPServer.open(port) | |
port = server.addr[1] |
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
require 'socket' | |
local_port = 45788 | |
# Quick check | |
if ARGV.length() < 2 then | |
puts "Syntax: 'ruby InventProxy.rb [dest_host] [dest_port]'" | |
exit() | |
end |