Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
fix textures, flatten/group-by, and project.clj
Browse files Browse the repository at this point in the history
  • Loading branch information
ztellman committed Apr 30, 2010
1 parent 7670ef8 commit 2e00d83
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 50 deletions.
4 changes: 3 additions & 1 deletion project.clj
@@ -1,7 +1,9 @@
(defproject penumbra "0.6.0-SNAPSHOT"
:description "An idiomatic wrapper for OpenGL"
:dependencies [[slick-util "1.0.0"]
[cantor "0.1.0"]]
[cantor "0.1.0"]
[org.clojure/clojure "1.2.0-master-SNAPSHOT"]
[org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]]
:native-dependencies [[penumbra/lwjgl "2.4.2"]]
:dev-dependencies [[native-deps "1.0.0"]
[lein-clojars "0.5.0-SNAPSHOT"]
Expand Down
2 changes: 1 addition & 1 deletion src/penumbra/glsl/operators.clj
Expand Up @@ -13,7 +13,7 @@
[penumbra.glsl core]
[penumbra.opengl.context :only (draw-frame-buffer)]
[clojure.contrib
(seq :only (separate indexed flatten))
(seq :only (separate indexed))
(def :only (defvar- defn-memo))
(pprint :only (pprint))])
(:require [clojure.zip :as zip]
Expand Down
4 changes: 1 addition & 3 deletions src/penumbra/opengl/context.clj
Expand Up @@ -35,9 +35,7 @@
(draw-frame-buffer 0 0 w h))
([x y w h]
(with-viewport [x y w h]
(push-matrix
(load-identity)
(call-display-list (force *display-list*))))))
(call-display-list (force *display-list*)))))

(defn create-context []
{:display-list (delay (create-display-list (draw)))
Expand Down
2 changes: 2 additions & 0 deletions src/penumbra/opengl/core.clj
Expand Up @@ -19,6 +19,7 @@
EXTTransformFeedback
ARBTextureRectangle
EXTTextureRectangle
EXTFramebufferObject
EXTGeometryShader4))
(:import (org.lwjgl.util.glu GLU))
(:import (java.lang.reflect Field Method))
Expand Down Expand Up @@ -92,6 +93,7 @@
ARBTextureFloat
ARBHalfFloatPixel
ARBFramebufferObject
EXTFramebufferObject
NVFloatBuffer
ATITextureFloat
EXTTextureRectangle
Expand Down
74 changes: 32 additions & 42 deletions src/penumbra/opengl/texture.clj
Expand Up @@ -47,41 +47,36 @@
;;;

(def internal-formats
[
[:float 1 :alpha-float32-apple]
[:float 1 :luminance32f-arb]
[:float 2 :luminance-alpha32f-arb]
[:float 3 :rgb32f-arb]
[:float 4 :rgba32f-arb]
[:float 1 :luminance-float32-apple]
[:float 1 :intensity-float32-apple]
[:float 1 :float-r32-nv]
[:float 2 :float-rg32-nv]
[:float 3 :float-rgb32-nv]
[:float 4 :float-rgba32-nv]
[:float 1 :alpha-float32-ati]
[:float 1 :intensity-float32-ati]
[:float 1 :luminance-float32-ati]
[:float 2 :luminance-alpha-float32-ati]
[:float 3 :rgb-float32-ati]
[:float 4 :rgba-float32-ati]
[:float 1 :luminance16f-arb]
[:int 1 :luminance32i]
[:int 2 :luminance-alpha32i]
[:int 3 :rgb32i]
[:int 4 :rgba32i]
[:int 1 :alpha-integer]
[:int 1 :luminance-integer]
[:int 2 :luminance-alpha-integer]
[:int 3 :rgb-integer]
[:int 4 :rgba-integer]
[:unsigned-byte 1 :luminance]
[:unsigned-byte 2 :luminance-alpha]
[:unsigned-byte 3 :rgb]
[:unsigned-byte 4 :rgba]])
[[:float 1 :luminance32f-arb]
[:float 2 :luminance-alpha32f-arb]
[:float 3 :rgb32f-arb]
[:float 4 :rgba32f-arb]
[:float 1 :float-r32-nv]
[:float 2 :float-rg32-nv]
[:float 3 :float-rgb32-nv]
[:float 4 :float-rgba32-nv]
[:float 1 :alpha-float32-ati]
[:float 1 :intensity-float32-ati]
[:float 1 :luminance-float32-ati]
[:float 2 :luminance-alpha-float32-ati]
[:float 3 :rgb-float32-ati]
[:float 4 :rgba-float32-ati]
[:int 1 :luminance32i]
[:int 2 :luminance-alpha32i]
[:int 3 :rgb32i]
[:int 4 :rgba32i]
[:int 1 :alpha-integer]
[:int 1 :luminance-integer]
[:int 2 :luminance-alpha-integer]
[:int 3 :rgb-integer]
[:int 4 :rgba-integer]
[:unsigned-byte 1 :luminance]
[:unsigned-byte 2 :luminance-alpha]
[:unsigned-byte 3 :rgb]
[:unsigned-byte 4 :rgba]])

(def tuple->pixel-format
{1 :red, 2 :luminance-alpha, 3 :rgb, 4 :rgba})
{1 :luminance, 2 :luminance-alpha, 3 :rgb, 4 :rgba})

(defn- internal-type-bytes [internal-type]
(if (= internal-type :unsigned-byte)
Expand Down Expand Up @@ -212,10 +207,6 @@
(gl-gen-textures buf)
(.get buf 0)))

(defn- destroy-texture [tex]
(let [buf (-> (BufferUtils/createIntBuffer 1) (.put (int-array [(id tex)])) .rewind)]
(gl-delete-textures buf)))

(defn- gen-texture [params]
(let [params (->> params
(map (fn [[k v]] [k (if (keyword? v) (enum v) v)]))
Expand All @@ -231,7 +222,6 @@
i-t (:internal-type params)
target (:target params)]
(gl-bind-texture (:target params) id)
(gl-tex-parameter (:target params) :texture-max-level 0)
(doseq [p (take (count dim) [:texture-wrap-s :texture-wrap-t :texture-wrap-r])]
(gl-tex-parameter (:target params) (enum p) (params p)))
(doseq [p [:texture-min-filter :texture-mag-filter]]
Expand Down Expand Up @@ -298,10 +288,10 @@
(write-to-texture this bounds data))
(destroy!
[this]
(when *texture-pool*
(remove! *texture-pool* this))
(destroy-texture this))))]
(when (and *texture-pool* (not located))
(if *texture-pool*
(remove! *texture-pool* this)
(destroy! this)))))]
(when-not located
(add! *texture-pool* texture))
texture))

Expand Down
3 changes: 1 addition & 2 deletions src/penumbra/translate/c.clj
Expand Up @@ -9,8 +9,7 @@
(ns penumbra.translate.c
(:use [penumbra.translate core]
[clojure.contrib
(def :only (defmacro-))
(seq :only (flatten))]))
(def :only (defmacro-))]))

;;;;;;;;;;;;;;;;;;;

Expand Down
2 changes: 1 addition & 1 deletion src/penumbra/translate/operators.clj
Expand Up @@ -10,7 +10,7 @@
(:use [clojure.walk]
[penumbra.translate core]
[cantor :only (rectangle-factors)]
[clojure.contrib.seq :only (indexed group-by separate)]
[clojure.contrib.seq :only (indexed separate)]
[clojure.contrib.def :only (defn-memo defvar-)]
[penumbra.translate.core])
(:require [clojure.zip :as zip]
Expand Down
1 change: 1 addition & 0 deletions test/example/opengl/gears.clj
Expand Up @@ -128,3 +128,4 @@
(app/start
{:reshape reshape, :display display-proxy, :init init, :mouse-drag mouse-drag, :key-press key-press}
{:rot-x 0, :rot-y 0, :gear nil}))

0 comments on commit 2e00d83

Please sign in to comment.