1 module unecht.core.components.editor.gismo; 2 3 version(UEIncludeEditor): 4 5 import unecht.core.component; 6 import unecht.gl.vertexBufferObject; 7 import unecht.gl.vertexArrayObject; 8 9 import unecht.core.entity; 10 import unecht.core.components.renderer; 11 import unecht.core.components.material; 12 13 import gl3n.linalg; 14 15 /// 16 final class UEEditorGismo : UEComponent { 17 18 mixin(UERegisterObject!()); 19 20 override void onCreate() { 21 super.onCreate; 22 23 import unecht.core.components.misc; 24 25 entity.layer = UELayer.editor; 26 27 auto renderer = this.entity.addComponent!UERenderer; 28 auto mesh = this.entity.addComponent!UEMesh; 29 30 renderer.mesh = mesh; 31 auto material = renderer.material = this.entity.addComponent!UEMaterial; 32 material.setProgram(UEMaterial.vs_flatcolor,UEMaterial.fs_flatcolor, "flat colored"); 33 material.depthTest = false; 34 35 mesh.vertexArrayObject = new GLVertexArrayObject(); 36 mesh.vertexArrayObject.bind(); 37 38 enum length = 2; 39 mesh.vertexBuffer = new GLVertexBufferObject([ 40 vec3(0,0,0), 41 vec3(length,0,0), 42 43 vec3(0,0,0), 44 vec3(0,length,0), 45 46 vec3(0,0,0), 47 vec3(0,0,length), 48 ]); 49 50 mesh.colorBuffer = new GLVertexBufferObject([ 51 vec3(1,0,0), 52 vec3(1,0,0), 53 54 vec3(0,1,0), 55 vec3(0,1,0), 56 57 vec3(0,0,1), 58 vec3(0,0,1), 59 ]); 60 61 mesh.indexBuffer = new GLVertexBufferObject([0,1, 2,3, 4,5]); 62 mesh.indexBuffer.primitiveType = GLRenderPrimitive.lines; 63 64 mesh.vertexArrayObject.unbind(); 65 } 66 }