ztellman / penumbra

not under active development - idiomatic opengl bindings for clojure
354 stars 43 forks source link

glTexParameter GL_NEAREST #13

Closed elliottslaughter closed 15 years ago

elliottslaughter commented 15 years ago

I'm wondering if penumbra provides a way to specify GL_NEAREST for textures loaded with load-texture-from-file.

Thanks.

ztellman commented 15 years ago

While the texture is bound, call

(tex-parameter :texture-2d :texture-min-factor :nearest)
(tex-parameter :texture-2d :texture-max-factor :nearest)

If you're not sure if it's :texture-2d or :texture-rectangle, you can replace the first parameter with (enum (:target tex)), where tex is the texture in qeustion.

elliottslaughter commented 15 years ago
user=> (use '[penumbra.opengl :only (tex-parameter)])
java.lang.IllegalAccessError: tex-parameter is not public (NO_SOURCE_FILE:0)
ztellman commented 15 years ago

Oh, whoops. Okay, I'll make that public and also add in an overloaded version of load-texture-from-file tonight. Sorry about that.

ztellman commented 15 years ago

Done.

elliottslaughter commented 15 years ago

Now I get:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Wrong number of args passed to: core$with-meta
        at clojure.lang.AFn.throwArity(AFn.java:449)
        at clojure.lang.AFn.invoke(AFn.java:52)
        at penumbra.opengl.texture$texture_from_texture_io__2085.invoke(texture.clj:186)
        at penumbra.opengl.texture$texture_from_texture_io__2085.invoke(texture.clj:189)
        at penumbra.opengl$load_texture_from_file__3381.invoke(opengl.clj:522)
        at blackthorn.graphics$load_texture__3851.invoke(graphics.clj:57)
        at blackthorn.graphics$get_image__3854$fn__3856.invoke(graphics.clj:62)
        at clojure.lang.AFn.call(AFn.java:31)
        at clojure.lang.LockingTransaction.run(LockingTransaction.java:263)
        at clojure.lang.LockingTransaction.runInTransaction(LockingTransaction.java:231)
        at blackthorn.graphics$get_image__3854.invoke(graphics.clj:60)
        at blackthorn.engine$display__3982.invoke(engine.clj:149)
        at penumbra.window$start__3645$fn__3669.invoke(window.clj:255)
        at penumbra.window.proxy$java.lang.Object$GLEventListener$9d230aec.display(Unknown Source)
        at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:94)
        at javax.media.opengl.awt.GLCanvas$DisplayAction.run(GLCanvas.java:620)
        at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:156)
        at javax.media.opengl.awt.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:553)
        at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:290)
        at javax.media.opengl.awt.GLCanvas.paint(GLCanvas.java:368)
        at javax.media.opengl.awt.GLCanvas.update(GLCanvas.java:462)
        at sun.awt.RepaintArea.updateComponent(RepaintArea.java:239)
        at sun.awt.X11.XRepaintArea.updateComponent(XRepaintArea.java:43)
        at sun.awt.RepaintArea.paint(RepaintArea.java:216)
        at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:683)
        at java.awt.Component.dispatchEventImpl(Component.java:4486)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
elliottslaughter commented 15 years ago

The problem is parens in texture-from-texture-io. I think you'll see it right away if you reindent the function.

Edit: Although that doesn't look like the only problem. After I fixed the above, I got "No matching method found: glBindTexture for class com.sun.opengl.impl.gl2.GL2Impl".

ztellman commented 15 years ago

Ha, wow. I'll fix it for real tonight, I promise.