static RenderWireframeCubeCommand() { //setup the shader List <ShaderDescriptor> desc = new List <ShaderDescriptor>(); desc.Add(new ShaderDescriptor(ShaderType.VertexShader, "..\\src\\Graphics\\shaders\\draw-vs.glsl", ShaderDescriptor.Source.File)); desc.Add(new ShaderDescriptor(ShaderType.FragmentShader, "..\\src\\Graphics\\shaders\\draw-ps.glsl", ShaderDescriptor.Source.File)); ShaderProgramDescriptor sd = new ShaderProgramDescriptor(desc); theShader = Renderer.resourceManager.getResource(sd) as ShaderProgram; theVBO = new VertexBufferObject <V3T2B4>(BufferUsageHint.DynamicDraw); theIBO = new IndexBufferObject(BufferUsageHint.StaticDraw); ushort[] index = { 4, 6, 2, 3, PRIM_RESTART, 1, 3, 7, 6, PRIM_RESTART, 7, 5, 1, 0, PRIM_RESTART, 2, 0, 4, 5 }; theIBO.setData(index); //setup the vao theVAO = new VertexArrayObject(); theVAO.bindVertexFormat <V3T2B4>(theShader); }
static RenderSphereCommand() { theVBO = new VertexBufferObject <V3T2B4>(BufferUsageHint.DynamicDraw); theIBO = new IndexBufferObject(BufferUsageHint.StaticDraw); //setup the shader List <ShaderDescriptor> desc = new List <ShaderDescriptor>(); desc.Add(new ShaderDescriptor(ShaderType.VertexShader, "..\\src\\Graphics\\shaders\\draw-vs.glsl", ShaderDescriptor.Source.File)); desc.Add(new ShaderDescriptor(ShaderType.FragmentShader, "..\\src\\Graphics\\shaders\\draw-ps.glsl", ShaderDescriptor.Source.File)); ShaderProgramDescriptor sd = new ShaderProgramDescriptor(desc); theShader = Renderer.resourceManager.getResource(sd) as ShaderProgram; theVBO = new VertexBufferObject <V3T2B4>(BufferUsageHint.DynamicDraw); theIBO = new IndexBufferObject(BufferUsageHint.StaticDraw); createTheSphere(); theIBO.setData(theSphereIndexes); //setup the vao theVAO = new VertexArrayObject(); theVAO.bindVertexFormat <V3T2B4>(theShader); }
static SkyBox() { Vector3[] verts = new Vector3[] { new Vector3(-1, -1, -1), new Vector3(1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1) }; ushort[] index = { 5, 1, 7, 7, 1, 3, //+X RIGHT 0, 4, 2, 2, 4, 6, //-X LEFT 6, 7, 2, 2, 7, 3, //+Y TOP 0, 1, 4, 4, 1, 5, //-Y BOTTOM 4, 5, 6, 6, 5, 7, //+Z BACK 1, 0, 3, 3, 0, 2 //-Z FRONT }; theVbo.setData(verts); theIbo.setData(index); theVao = new VertexArrayObject(); }
static RenderTextureCubeCommand() { //setup the shader List <ShaderDescriptor> desc = new List <ShaderDescriptor>(); desc.Add(new ShaderDescriptor(ShaderType.VertexShader, "..\\src\\Graphics\\shaders\\draw-vs.glsl", ShaderDescriptor.Source.File)); desc.Add(new ShaderDescriptor(ShaderType.FragmentShader, "..\\src\\Graphics\\shaders\\draw-ps.glsl", ShaderDescriptor.Source.File)); ShaderProgramDescriptor sd = new ShaderProgramDescriptor(desc); theShader = Renderer.resourceManager.getResource(sd) as ShaderProgram; theVBO = new VertexBufferObject <V3T2B4>(BufferUsageHint.DynamicDraw); theIBO = new IndexBufferObject(BufferUsageHint.StaticDraw); ushort[] index = { 0, 1, 2, 0, 2, 3, //front 4, 5, 6, 4, 6, 7, //left 8, 9, 10, 8, 10, 11, //right 12, 13, 14, 12, 14, 15, // top 16, 17, 18, 16, 18, 19, // bottom 20, 21, 22, 20, 22, 23 // back }; theIBO.setData(index); //setup the vao theVAO = new VertexArrayObject(); theVAO.bindVertexFormat <V3T2B4>(theShader); }
public override void updateText(String txt, VertexBufferObject vbo, IndexBufferObject ibo) { //build the VBO ushort counter = 0; ushort indexCount = 0; float posx = 0; float posy = 0; for (int i = 0; i < txt.Length; i++) { char ch = txt[i]; Glyph g = myGlyphs[(int)ch]; posx += g.offset.X; //posy = g.offset.Y - mySize; myVerts[counter * 4].Position.X = posx; myVerts[counter * 4].Position.Y = posy; myVerts[counter * 4].Position.Z = 0.0f; myVerts[counter * 4].TexCoord.X = g.minTexCoord.X; myVerts[counter * 4].TexCoord.Y = g.maxTexCoord.Y; myVerts[counter * 4 + 1].Position.X = posx + g.size.X; myVerts[counter * 4 + 1].Position.Y = posy; myVerts[counter * 4 + 1].Position.Z = 0.0f; myVerts[counter * 4 + 1].TexCoord.X = g.maxTexCoord.X; myVerts[counter * 4 + 1].TexCoord.Y = g.maxTexCoord.Y; myVerts[counter * 4 + 2].Position.X = posx + g.size.X; myVerts[counter * 4 + 2].Position.Y = posy + g.size.Y; myVerts[counter * 4 + 2].Position.Z = 0.0f; myVerts[counter * 4 + 2].TexCoord.X = g.maxTexCoord.X; myVerts[counter * 4 + 2].TexCoord.Y = g.minTexCoord.Y; myVerts[counter * 4 + 3].Position.X = posx; myVerts[counter * 4 + 3].Position.Y = posy + g.size.Y; myVerts[counter * 4 + 3].Position.Z = 0.0f; myVerts[counter * 4 + 3].TexCoord.X = g.minTexCoord.X; myVerts[counter * 4 + 3].TexCoord.Y = g.minTexCoord.Y; //indicies to draw as tris myIndexes[indexCount++] = (ushort)(0 + (counter * 4)); myIndexes[indexCount++] = (ushort)(1 + (counter * 4)); myIndexes[indexCount++] = (ushort)(2 + (counter * 4)); myIndexes[indexCount++] = (ushort)(0 + (counter * 4)); myIndexes[indexCount++] = (ushort)(2 + (counter * 4)); myIndexes[indexCount++] = (ushort)(3 + (counter * 4)); posx += g.advance.X; counter++; } //update the VBO vbo.setData(myVerts, 0, (counter * 4 * V3T2.stride)); ibo.setData(myIndexes, 0, (indexCount * 2)); }
public override void updateText(String txt) { int counter = 0; int indexCount = 0; float posx = 0; float posy = 0; float advance = mySize * 0.6f; for (int i = 0; i < txt.Length; i++) { char ch = txt[i]; Glyph g = myGlyphs[(int)ch - 32]; myVerts[counter * 4].Position.X = posx; myVerts[counter * 4].Position.Y = posy; myVerts[counter * 4].Position.Z = 0.0f; myVerts[counter * 4].TexCoord.X = g.minTexCoord.X; myVerts[counter * 4].TexCoord.Y = g.minTexCoord.Y; myVerts[counter * 4 + 1].Position.X = posx + mySize; myVerts[counter * 4 + 1].Position.Y = posy; myVerts[counter * 4 + 1].Position.Z = 0.0f; myVerts[counter * 4 + 1].TexCoord.X = g.maxTexCoord.X; myVerts[counter * 4 + 1].TexCoord.Y = g.minTexCoord.Y; myVerts[counter * 4 + 2].Position.X = posx + mySize; myVerts[counter * 4 + 2].Position.Y = posy + mySize; myVerts[counter * 4 + 2].Position.Z = 0.0f; myVerts[counter * 4 + 2].TexCoord.X = g.maxTexCoord.X; myVerts[counter * 4 + 2].TexCoord.Y = g.maxTexCoord.Y; myVerts[counter * 4 + 3].Position.X = posx; myVerts[counter * 4 + 3].Position.Y = posy + mySize; myVerts[counter * 4 + 3].Position.Z = 0.0f; myVerts[counter * 4 + 3].TexCoord.X = g.minTexCoord.X; myVerts[counter * 4 + 3].TexCoord.Y = g.maxTexCoord.Y; //indices to draw as tris myIndexes[indexCount++] = (ushort)(0 + (counter * 4)); myIndexes[indexCount++] = (ushort)(1 + (counter * 4)); myIndexes[indexCount++] = (ushort)(3 + (counter * 4)); myIndexes[indexCount++] = (ushort)(2 + (counter * 4)); posx += advance; counter++; } //update the VBO myVbo.setData(myVerts, 0, (counter * 4 * V3T2.stride)); myIbo.setData(myIndexes, 0, (indexCount * 2)); }
static RenderTexture2dCommand() { //setup the shader List <ShaderDescriptor> desc = new List <ShaderDescriptor>(); desc.Add(new ShaderDescriptor(ShaderType.VertexShader, "Graphics.shaders.draw-vs.glsl")); desc.Add(new ShaderDescriptor(ShaderType.FragmentShader, "Graphics.shaders.draw-ps.glsl")); ShaderProgramDescriptor sd = new ShaderProgramDescriptor(desc); theShader = Renderer.resourceManager.getResource(sd) as ShaderProgram; theVBO = new VertexBufferObject(BufferUsageHint.DynamicDraw); theIBO = new IndexBufferObject(BufferUsageHint.StaticDraw); ushort[] index = { 0, 1, 2, 0, 2, 3 }; theIBO.setData(index); //setup the vao theVAO = new VertexArrayObject(); theVAO.bindVertexFormat(theShader, V3T2B4.bindings()); }
static SkyBox() { Vector3[] verts = new Vector3[] { new Vector3(-1, -1, -1), new Vector3(1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1) }; ushort[] index = { //CCW inside box 5, 7, 1, 7, 3, 1, //+X RIGHT 0, 2, 4, 2, 6, 4, //-X LEFT 6, 2, 7, 2, 3, 7, //+Y TOP 0, 4, 1, 4, 5, 1, //-Y BOTTOM 4, 6, 5, 6, 7, 5, //+Z BACK 1, 3, 0, 3, 2, 0 //-Z FRONT /* * //CCW from outside box * 5,1,7, 7,1,3, //+X RIGHT * 0,4,2, 2,4,6, //-X LEFT * 6,7,2, 2,7,3, //+Y TOP * 0,1,4, 4,1,5, //-Y BOTTOM * 4,5,6, 6,5,7, //+Z BACK * 1,0,3, 3,0,2 //-Z FRONT */ }; theVbo.setData(verts); theIbo.setData(index); theVao = new VertexArrayObject(); }
static RenderFrustumCommand() { //setup the shader List <ShaderDescriptor> desc = new List <ShaderDescriptor>(); desc.Add(new ShaderDescriptor(ShaderType.VertexShader, "Graphics.shaders.draw-vs.glsl")); desc.Add(new ShaderDescriptor(ShaderType.FragmentShader, "Graphics.shaders.draw-ps.glsl")); ShaderProgramDescriptor sd = new ShaderProgramDescriptor(desc); theShader = Renderer.resourceManager.getResource(sd) as ShaderProgram; theVBO = new VertexBufferObject(BufferUsageHint.DynamicDraw); theIBO = new IndexBufferObject(BufferUsageHint.StaticDraw); ushort[] index = { 0, 1, 3, 2, PRIM_RESTART, 5, 1, 3, 7, PRIM_RESTART, 4, 5, 7, 6, PRIM_RESTART, 0, 4, 6, 2 }; theVerts[0] = new Vector4(-1, -1, -1, 1); theVerts[1] = new Vector4(1, -1, -1, 1); theVerts[2] = new Vector4(-1, 1, -1, 1); theVerts[3] = new Vector4(1, 1, -1, 1); theVerts[4] = new Vector4(-1, -1, 1, 1); theVerts[5] = new Vector4(1, -1, 1, 1); theVerts[6] = new Vector4(-1, 1, 1, 1); theVerts[7] = new Vector4(1, 1, 1, 1); theIBO.setData(index); //setup the vao theVAO = new VertexArrayObject(); theVAO.bindVertexFormat(theShader, V3T2B4.bindings()); }
public void updateBuffers() { myVbo.setData(myVerts, 0, myVertCount * V3T2B4.stride); myIbo.setData(myIndexes, 0, myIndexCount * 4); }
public override void updateText(String txt, VertexBufferObject vbo, IndexBufferObject ibo) { int counter = 0; int indexCount = 0; float posx = 0; float posy = 0; foreach (Char ch in txt) { if (ch < 32) { if (ch == '\n') { posx = 0; posy += fontSize; continue; } if (ch == '\r') { continue; } } Glyph g = myGlyphs[(int)ch - myLetteroffset]; if (g != null) { myVerts[counter * 4].Position.X = posx; myVerts[counter * 4].Position.Y = posy; myVerts[counter * 4].Position.Z = 0.0f; myVerts[counter * 4].TexCoord.X = g.minTexCoord.X; myVerts[counter * 4].TexCoord.Y = g.minTexCoord.Y; myVerts[counter * 4 + 1].Position.X = posx + mySize; myVerts[counter * 4 + 1].Position.Y = posy; myVerts[counter * 4 + 1].Position.Z = 0.0f; myVerts[counter * 4 + 1].TexCoord.X = g.maxTexCoord.X; myVerts[counter * 4 + 1].TexCoord.Y = g.minTexCoord.Y; myVerts[counter * 4 + 2].Position.X = posx + mySize; myVerts[counter * 4 + 2].Position.Y = posy + mySize; myVerts[counter * 4 + 2].Position.Z = 0.0f; myVerts[counter * 4 + 2].TexCoord.X = g.maxTexCoord.X; myVerts[counter * 4 + 2].TexCoord.Y = g.maxTexCoord.Y; myVerts[counter * 4 + 3].Position.X = posx; myVerts[counter * 4 + 3].Position.Y = posy + mySize; myVerts[counter * 4 + 3].Position.Z = 0.0f; myVerts[counter * 4 + 3].TexCoord.X = g.minTexCoord.X; myVerts[counter * 4 + 3].TexCoord.Y = g.maxTexCoord.Y; //indices to draw as tris myIndexes[indexCount++] = (ushort)(0 + (counter * 4)); myIndexes[indexCount++] = (ushort)(1 + (counter * 4)); myIndexes[indexCount++] = (ushort)(2 + (counter * 4)); myIndexes[indexCount++] = (ushort)(0 + (counter * 4)); myIndexes[indexCount++] = (ushort)(2 + (counter * 4)); myIndexes[indexCount++] = (ushort)(3 + (counter * 4)); posx += g.advance.X; counter++; } else { if (ch == ' ') { posx += g.advance.X; } if (ch == '\t') { posx += g.advance.X * 3; } } } //update the VBO vbo.setData(myVerts, 0, (counter * 4 * V3T2.stride)); ibo.setData(myIndexes, 0, (indexCount * 2)); }