Learningwebgl
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.
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 ?
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?
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:
- the gl-context is outside the opts map, so threading should still work
- 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
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 !
I'm enjoying these so far, thanks to the both of you.
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
Yay! Thanks. :)
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.
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.