Advertisement
Guest User

HaxePunk custom vertex attrib test

a guest
Nov 12th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.85 KB | None | 0 0
  1. import haxepunk.Scene;
  2.  
  3. import haxepunk.graphics.Image;
  4. import haxepunk.graphics.shader.TextureShader;
  5.  
  6. class MainScene extends Scene
  7. {
  8.     static var vertexShader =
  9. "#ifdef GL_ES
  10. precision mediump float;
  11. #endif
  12.  
  13. attribute vec4 aPosition;
  14. attribute vec2 aTexCoord;
  15. attribute vec4 aColor;
  16. attribute float aColorMult;
  17. varying vec2 vTexCoord;
  18. varying vec4 vColor;
  19. uniform mat4 uMatrix;
  20.  
  21. void main(void) {
  22.     vColor = vec4(aColor.bgr * aColor.a, aColor.a) * aColorMult;
  23.     vTexCoord = aTexCoord;
  24.     gl_Position = uMatrix * aPosition;
  25. }";
  26.  
  27.     override public function begin()
  28.     {
  29.         // Insert your scene code here...
  30.         var img = Image.createRect(100, 100, 0x8888ff);
  31.         img.shader = new TextureShader(vertexShader);
  32.         img.shader.log = true;
  33.         img.shader.setVertexAttribData("aColorMult", [ 1.0, 0.5, 0.5, 0.5, 0.5, 1.0 ], 1);
  34.         addGraphic(img);
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement