In this post we are going to dive more deeply into the WebGL library methods that are included in the LimeJS WebGL branch. Those methods are used while making the lime.Renderer.WEBGL renderer and are available for developers to create custom WebGL games.
What it is about:
- Cleaned up workflow. No more multiline inlining shaders.
- Complete handling of format conversions. No need to convert something to another format before sending to WebGL.
- Debugging support. Get error messages for invalid inputs, instead of black screen.
- Make it easier to work with big models.
- Math utility helpers
- Getting out of your way and letting you concentrate on your shaders.
What it’s not about:
- A simplified or alternative way of making 3D
- A higher level abstraction layer.
- You still have to know how OpenGL works. You just have to code less and get your work done quicker.
- If you need a Closure port of something like three.js of GLGE this is not it.
GLController is front controller object for your 3D Canvas context. You can use controller object for storing data you need persistent for your context. It also provides method for resizing the viewport. Only real reason for this class existence is that we don’t want to modify the context object itself.
- GLController.forCanvas(element) - returns GLController instance for Canvas element. Always returns same object for same element.
- getSize() - get current canvas and viewport size.
- setSize(size) - resize canvas to new values and also resize WebGL viewport to same size.
- makeProgram() - Return new Program object for the context.
1 2 3 4
var glc = lime.webgl.GLController.forCanvas('mycanvas'), gl = glc.gl; glc.setSize(480,320);
Program connects the shaders to your code. You use it to initialize your shaders, set shaders properties and draw. Program object accepts data in almost any reasonable form and converts between formats if necessary. When you pass in data in wrong format it will let you know about the error and …