-
Notifications
You must be signed in to change notification settings - Fork 212
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
[WIP] Strange code usage in core code that produce side-effects #133
Comments
In pixi its managed by |
Ohohoh |
Description was updated follow to current version. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this lib, but there are some problems!
Strange code structure that produce side effects.
Folow: #24
So, i think that this Core API look poor, because produce untraceable sideeffects:
1. Program issues
Direct state read from
monkey
field:ogl/src/core/Program.js
Line 149 in 2635658
Direct state push into
monkey
field:ogl/src/core/Program.js
Line 154 in 2635658
Why this is problem:
gl
which already is problem, because GLContext not hasrenderer
field, this is pre-mixed field - poor code.currentProgram
from current id that can be manually changed by some reason. Unstable, can produce side-effects!Possible solution:
Replace this:
ogl/src/core/Program.js
Lines 148 to 154 in 2635658
onto this:
And move check of current active program inside useProgram.
2. Geometry issues
ogl/src/core/Geometry.js
Lines 43 to 52 in 2635658
Why this is problem?
Because:
Also there are a strong reference to renderer state, that can be invalid for draw because can be resets into new object for some reason, for example for binding to another webgl libs, like pixi.
ogl/src/core/Geometry.js
Line 47 in 2635658
Possible solutions:
Move preparation step onto draw method and remove reference.
ogl/src/core/Geometry.js
Lines 170 to 174 in 2635658
Why this bad? There are not garanteed that
attributeOrder
is valid. Should be check on empty value.This can be easy demonstrated when program is sub class or was invalid. Draw method should be thrownable and crash when invalid state reached.
3. RenderTarget issues (Critical)
3. Texture issues
Directly state check and state update while update
ogl/src/core/Texture.js
Line 86 in 2635658
State reference holding, again:
ogl/src/core/Texture.js
Line 64 in 2635658
Problem that not all texture can was
update
. VideoTextures MUST wait readyState of HTMLVideoElement. This means that you MUST bind and activate texture but NOT upload it.Textures should split activation/bind and uploading process.
Possible solution:
Move texture bind and state check to renderer + isolate update and upload.
The text was updated successfully, but these errors were encountered: