Created
July 24, 2011 06:20
-
-
Save zoka/1102320 to your computer and use it in GitHub Desktop.
Penumbra patch
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
diff --git a/src/penumbra/opengl/texture.clj b/src/penumbra/opengl/texture.clj | |
index c606d06..f45568c 100644 | |
--- a/src/penumbra/opengl/texture.clj | |
+++ b/src/penumbra/opengl/texture.clj | |
@@ -13,6 +13,10 @@ | |
(:use [penumbra data]) | |
(:import [org.lwjgl BufferUtils]) | |
(:import (java.io File)) | |
+ (:import (java.nio DoubleBuffer)) | |
+ (:import (java.nio FloatBuffer)) | |
+ (:import (java.nio IntBuffer)) | |
+ (:import (java.nio ByteBuffer)) | |
(:import (org.newdawn.slick.opengl Texture))) | |
;;; | |
@@ -153,7 +157,7 @@ | |
(byte-array (denormalize-bytes s))))) | |
(defn- array-to-buffer [a type] | |
- (println "type" type) | |
+ ;(println "type" type) | |
(cond | |
(= type :double) (-> (BufferUtils/createDoubleBuffer (count a)) (.put a) .rewind) | |
(= type :float) (-> (BufferUtils/createFloatBuffer (count a)) (.put a) .rewind) | |
@@ -161,6 +165,23 @@ | |
(= type :unsigned-byte) (-> (BufferUtils/createByteBuffer (count a)) (.put a) .rewind) | |
:else (throw (Exception. (str "Don't recognize type " type))))) | |
+(defn- buffer-to-array [b type size] | |
+ ;(println "type" type) | |
+ (cond | |
+ (= type :double) (let [a (double-array)] | |
+ (.get ^DoubleBuffer b a) | |
+ a) | |
+ (= type :float) (let [a (float-array size)] | |
+ (.get ^FloatBuffer b a) | |
+ a) | |
+ (= type :int) (let [a (int-array size)] | |
+ (.get ^IntBuffer b a) | |
+ a) | |
+ (= type :unsigned-byte) (let [a (byte-array size)] | |
+ (.get ^ByteBuffer b a) | |
+ a) | |
+ :else (throw (Exception. (str "Don't recognize type " type))))) | |
+ | |
(defn- create-buffer [size type] | |
(cond | |
(= type :double) (BufferUtils/createDoubleBuffer size) | |
@@ -202,7 +223,8 @@ | |
(unwrap-texture tex (* (apply * (dim tex)) (->> tex params :internal-format internal-format->tuple)))) | |
([tex size] | |
(let [params (params tex) | |
- buf (create-buffer size (:internal-type params))] | |
+ type (:internal-type params) | |
+ buf (create-buffer size type)] | |
(bind-texture tex) | |
(gl-get-tex-image | |
(target tex) | |
@@ -210,7 +232,7 @@ | |
(enum (:pixel-format params)) | |
(enum (:internal-type params)) | |
buf) | |
- buf))) | |
+ (buffer-to-array buf type size)))) | |
;;; | |
diff --git a/test/example/app/async.clj b/test/example/app/async.clj | |
index 97443bc..9948ae0 100644 | |
--- a/test/example/app/async.clj | |
+++ b/test/example/app/async.clj | |
@@ -47,7 +47,7 @@ | |
(call-display-list (:cube state))) | |
(defn start [] | |
- (let [app (app/start* {:init init, :reshape reshape, :display display} {:rot 0})] | |
+ (let [app (app/start {:init init, :reshape reshape, :display display} {:rot 0})] | |
(Thread/sleep 5000) | |
(app/pause! app) | |
(Thread/sleep 1000) | |
diff --git a/test/example/gpgpu/n_body.clj b/test/example/gpgpu/n_body.clj | |
index 2e0caac..23db9af 100644 | |
--- a/test/example/gpgpu/n_body.clj | |
+++ b/test/example/gpgpu/n_body.clj | |
@@ -7,8 +7,7 @@ | |
;; You must not remove this notice, or any other, from this software. | |
(ns example.gpgpu.n-body | |
- (:use [penumbra compute] | |
- [clojure.contrib.seq :only (partition-all flatten)]) | |
+ (:use [penumbra compute]) | |
(:require [penumbra.app :as app] | |
[penumbra.data :as data])) | |
diff --git a/test/example/opengl/squares.clj b/test/example/opengl/squares.clj | |
index e1c68ab..fe3498f 100644 | |
--- a/test/example/opengl/squares.clj | |
+++ b/test/example/opengl/squares.clj | |
@@ -6,8 +6,7 @@ | |
;; You must not remove this notice, or any other, from this software. | |
(ns example.opengl.squares | |
- (:use [penumbra opengl compute] | |
- [clojure.contrib.seq :only (flatten)]) | |
+ (:use [penumbra opengl compute]) | |
(:require [penumbra.app :as app] | |
[penumbra.data :as data])) | |
diff --git a/test/example/wiki/clock3.clj b/test/example/wiki/clock3.clj | |
index 91d4e38..72e5ca8 100644 | |
--- a/test/example/wiki/clock3.clj | |
+++ b/test/example/wiki/clock3.clj | |
@@ -26,9 +26,9 @@ | |
(fn [state] (update-in state [k] inc))) | |
(defn init [state] | |
- (app/periodic-update 1 (incrementer :second)) | |
- (app/periodic-update (/ 1 60) (incrementer :minute)) | |
- (app/periodic-update (/ 1 3600) (incrementer :hour)) | |
+ (app/periodic-update! 1 (incrementer :second)) | |
+ (app/periodic-update! (/ 1 60) (incrementer :minute)) | |
+ (app/periodic-update! (/ 1 3600) (incrementer :hour)) | |
state) | |
(defn reshape [[x y w h] state] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment