-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Break up constants into section specific namespaces #5
Comments
Yes, that sounds like a good ideia. I've been thinking about replacing the constants with keywords for some time now as it would require some sort of lookup function and this could work as a way of self documenting the accepted values. I believe your idea would suffice, though. What do you think? |
I did wonder about keywords, but there will be a cost associated with the lookup function - whereas this'll come for free using namespaces and defs (I'm presuming) as the constants will get replaced at compile time. The only downside of using namespaces is that there will be a proliferation of source files (I dont think you can have many namespaces in one file?) |
I don't see a larger number of files as a big problem, and the fact that each of them defines related constants is a bonus for readability. So yes, lets do it! 😃 |
Fixed in 658570d. |
Nice one 👍 I fixed a typo - s/texure/texture/ in one of the cljs file Also, I wonder if namespaces Reason I ask is I've currently got a call out to (not checked this in yet): (init-texture gl
:image img
:texture tex2
:parameters {texture-parameter-name/texture-mag-filter texture-mag-filter/linear
texture-parameter-name/texture-min-filter texture-mag-filter/linear}) seems a bit odd to have a key Collapsing to a single namespace this becomes: (init-texture gl
:image img
:texture tex2
:parameters {texture-parameter-name/texture-mag-filter texture-filter/linear
texture-parameter-name/texture-min-filter texture-filter/linear}) Other option might be to replicate (ns cljs-webgl.constants.texture-min-filter)
(def nearest 0x2600)
(def linear 0x2601)
(def nearest-mipmap-nearest 0x2700)
(def linear-mipmap-nearest 0x2701)
(def nearest-mipmap-linear 0x2702)
(def linear-mipmap-linear 0x2703) and then this looks like: (init-texture gl
:image img
:texture tex2
:parameters {texture-parameter-name/texture-mag-filter texture-mag-filter/linear
texture-parameter-name/texture-min-filter texture-min-filter/linear}) |
@rm-hull I merged PS: I used the list of values in the WebGL Specification as a reference to break the constants into namespaces. |
Was wondering whether it might be an idea make better use of namespaces to separate the different groups of constants (almost treating them as pseudo-enums): this might work by creating a src/cljs-webgl/constants folder, and then break up all the constants into smaller files, eg. src/cljs-webgl/constants/begin-mode.cljs would contain:
src/cljs-webgl/constants/blending-factor-dest.cljs would contain:
etc.
Then referencing:
The text was updated successfully, but these errors were encountered: