cljs-webgl icon indicating copy to clipboard operation
cljs-webgl copied to clipboard

Learningwebgl

Open rm-hull opened this issue 12 years ago • 9 comments

Going to try and port some lessons from http://learningwebgl.com/ to see how it well it works with the codebase. I will commit changes on a branch called feature/learningwebgl, and probably push into master after each lesson is reasonably complete.

rm-hull avatar Mar 14 '14 00:03 rm-hull

Hey @Asakeron, I've implemented the code behind the first two lessons on the feature/learningwebgl branch... and made a few small changes to the source on the way - just want to check you're ok with the commits so far ?

rm-hull avatar Mar 24 '14 23:03 rm-hull

Yes, I have been reading your commits and I'm okay with all the changes so far. I do belive the code is getting more readable. The examples look great. Thank you! :thumbsup:

One thing I noticed, though, is that you were forced to call a few WebGL methods directly from the js object, such as glEnable and glViewPort. I believe they should ideally be parameters to the draw!function.

With that being said, I also believe the draw! function should receive one map object instead of multiple parameters - as in your big-bang library - , this way the calls will be easier to read considering the number of parameters will probably grow a lot as soon as we implement textures, framebuffers, etc...

Any thoughts?

asakeron avatar Mar 25 '14 03:03 asakeron

I was just thinking the same about the draw function, if the method signature is something like:

(defn draw! 
  [gl & {:keys [shader-program draw-mode first count 
                attributes uniforms element-array] :as opts}]
  ...)

then we can still thread the gl-context, but all other parameters are named, and some might be defaultable. The only downside with using & opts is that it is not so easy to compose functions, but I don't think this matters much here as:

  1. the gl-context is outside the opts map, so threading should still work
  2. draw! is, by its nature, an imperative operation with side-effects

Also, I agree about the javascript methods and attributes - they should be wrapped - I was/am still getting a handle on what's best to encapsulate and what's not

rm-hull avatar Mar 25 '14 21:03 rm-hull

Ok, so that's lessons 3 (simple animation), 4 (3d shapes), 5 (texture mapping) implemented. I've made a rough start on a textures namespace and :textures parameter to draw! - see what you think & make changes where you see fit !

rm-hull avatar Mar 27 '14 01:03 rm-hull

I'm enjoying these so far, thanks to the both of you.

accidentally-altoid avatar Mar 27 '14 04:03 accidentally-altoid

I've added a gh-pages branch, and copied the learningwebgl examples in there, so you can view at http://asakeron.github.io/cljs-webgl/examples/learningwebgl/lesson_01.html

rm-hull avatar Apr 04 '14 20:04 rm-hull

Yay! Thanks. :)

asakeron avatar Apr 05 '14 17:04 asakeron

Was wondering about pushing this branch into master as-is?

I would've liked to have implemented a few more lessons, but have been stacked out at work so this has been a little neglected lately... hopefully I should be able to pick it up again nearer the end of this month.

rm-hull avatar May 08 '14 20:05 rm-hull

I'm okay with that, @rm-hull. We ended up making massive changes to the API as needed while you implemented the examples, so to push them into master now, makes sense.

asakeron avatar May 08 '14 22:05 asakeron