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 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); }
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); }
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 SkinnedModel() { myVbo = new VertexBufferObject <V3N3T2B4W4>(BufferUsageHint.StaticDraw); myIbo = new IndexBufferObject(BufferUsageHint.StaticDraw); myFrames = new ShaderStorageBufferObject(BufferUsageHint.StaticDraw); myMeshes = new List <Mesh>(); animations = new Dictionary <String, Animation>(); //insert the null animation animations["null"] = new Animation("null", 0, 0, 0, false); }
public void init() { myVbo = new VertexBufferObject <V3T2B4>(BufferUsageHint.DynamicDraw); myIbo = new IndexBufferObject(BufferUsageHint.DynamicDraw); myVao = new VertexArrayObject(); List <ShaderDescriptor> desc = new List <ShaderDescriptor>(); desc.Add(new ShaderDescriptor(ShaderType.VertexShader, "..\\src\\Graphics\\shaders\\debug-vs.glsl", ShaderDescriptor.Source.File)); desc.Add(new ShaderDescriptor(ShaderType.FragmentShader, "..\\src\\Graphics\\shaders\\debug-ps.glsl", ShaderDescriptor.Source.File)); ShaderProgramDescriptor sd = new ShaderProgramDescriptor(desc); myShader = Renderer.resourceManager.getResource(sd) as ShaderProgram; myVao.bindVertexFormat <V3T2B4>(myShader); myTexture = Graphics.Util.getEmbeddedTexture("Graphics.data.debugFont.png"); myTexture.setMinMagFilters(TextureMinFilter.NearestMipmapNearest, TextureMagFilter.Nearest); myTexture.setWrapping(TextureWrapMode.ClampToEdge, TextureWrapMode.ClampToEdge); myFont = FontManager.findFont("DEFAULT"); }
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()); }
public void init() { myVbo = new VertexBufferObject(BufferUsageHint.DynamicDraw); myIbo = new IndexBufferObject(BufferUsageHint.DynamicDraw); myVao = new VertexArrayObject(); List <ShaderDescriptor> desc = new List <ShaderDescriptor>(); desc.Add(new ShaderDescriptor(ShaderType.VertexShader, "Graphics.shaders.debug-vs.glsl")); desc.Add(new ShaderDescriptor(ShaderType.FragmentShader, "Graphics.shaders.debug-ps.glsl")); ShaderProgramDescriptor sd = new ShaderProgramDescriptor(desc); myShader = Renderer.resourceManager.getResource(sd) as ShaderProgram; myVao.bindVertexFormat(myShader, V3T2B4.bindings()); myTexture = Graphics.Util.getEmbeddedTexture("Graphics.data.debugFont.png"); //myTexture = Util.getEmbeddedTexture("Graphics.data.proggy12.png"); myTexture.setMinMagFilters(TextureMinFilter.NearestMipmapNearest, TextureMagFilter.Nearest); myTexture.setWrapping(TextureWrapMode.ClampToEdge, TextureWrapMode.ClampToEdge); myFont = new TextureFont("Debug", myTexture, 16, 16, 32); }
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 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)); }
public Model() { myVbos = new List <VertexBufferObject>(); myIbo = new IndexBufferObject(BufferUsageHint.StaticDraw); myMeshes = new List <Mesh>(); }
public abstract void updateText(String str, VertexBufferObject vbo, IndexBufferObject ibo);