public void GlobalSetup() { Engine.Setup(); _asset = Engine.AssetLoader.Get <AudioAsset>("Audio/pepsi.wav"); var testAudio = new AudioTests.TestAudioContext(); _layer = (AudioTests.TestAudioContext.TestAudioLayer)testAudio.CreateLayer("Benchmark"); _layer.PlayNext(new AudioTrack(_asset) { SetLoopingCurrent = true }); _layer.ProcessAhead(1); // To create test array. _textureOne = Engine.AssetLoader.Get <TextureAsset>("logoAlpha.png"); _textureTwo = Engine.AssetLoader.Get <TextureAsset>("logoAsymmetric.png"); _atlas = new TextureAtlas(false, 1); _atlas.TryBatchTexture(_textureOne?.Texture); _atlas.TryBatchTexture(_textureTwo?.Texture); _atlasMemorySize = VertexData.SizeInBytes * 1024; _atlasMemory = UnmanagedMemoryAllocator.MemAlloc(_atlasMemorySize); _atlas.Update(Engine.Renderer); }
private Dictionary <uint, BufferMappingState> _bufferMapping = new Dictionary <uint, BufferMappingState>(); // <BufferId, state> public WebGLContext(IJSUnmarshalledRuntime glContext) { Native = false; _gl = glContext; const int maxGenAtOnce = 5; _objectGenPtrHolder = UnmanagedMemoryAllocator.MemAlloc(sizeof(uint) * maxGenAtOnce); _webGlFuncDictionary.Add("glGetError", (Gl.Delegates.glGetError)GetError); _webGlFuncDictionary.Add("glGetString", (Gl.Delegates.glGetString)GetString); _webGlFuncDictionary.Add("glGetIntegerv", (Gl.Delegates.glGetIntegerv)GetInteger); _webGlFuncDictionary.Add("glGetFloatv", (Gl.Delegates.glGetFloatv)GetFloat); _webGlFuncDictionary.Add("glGenBuffers", (Gl.Delegates.glGenBuffers)GenBuffers); _webGlFuncDictionary.Add("glBindBuffer", (Gl.Delegates.glBindBuffer)BindBuffer); _webGlFuncDictionary.Add("glBufferData", (Gl.Delegates.glBufferData)BufferData); _webGlFuncDictionary.Add("glBufferSubData", (Gl.Delegates.glBufferSubData)BufferSubData); _webGlFuncDictionary.Add("glMapBuffer", (Gl.Delegates.glMapBuffer)MapBuffer); _webGlFuncDictionary.Add("glMapBufferRange", (Gl.Delegates.glMapBufferRange)MapBufferRange); _webGlFuncDictionary.Add("glUnmapBuffer", (Gl.Delegates.glUnmapBuffer)UnmapBuffer); _webGlFuncDictionary.Add("glFlushMappedBufferRange", (Gl.Delegates.glFlushMappedBufferRange)FlushMappedRange); _webGlFuncDictionary.Add("glClear", (Gl.Delegates.glClear)Clear); _webGlFuncDictionary.Add("glClearColor", (Gl.Delegates.glClearColor)SetClearColor); _webGlFuncDictionary.Add("glColorMask", (Gl.Delegates.glColorMask)ColorMask); _webGlFuncDictionary.Add("glEnable", (Gl.Delegates.glEnable)Enable); _webGlFuncDictionary.Add("glDisable", (Gl.Delegates.glDisable)Disable); _webGlFuncDictionary.Add("glDepthFunc", (Gl.Delegates.glDepthFunc)DepthFunc); _webGlFuncDictionary.Add("glStencilMask", (Gl.Delegates.glStencilMask)StencilMask); _webGlFuncDictionary.Add("glStencilFunc", (Gl.Delegates.glStencilFunc)StencilFunc); _webGlFuncDictionary.Add("glStencilOp", (Gl.Delegates.glStencilOp)StencilOpF); _webGlFuncDictionary.Add("glBlendFuncSeparate", (Gl.Delegates.glBlendFuncSeparate)BlendFuncSeparate); _webGlFuncDictionary.Add("glViewport", (Gl.Delegates.glViewport)Viewport); _webGlFuncDictionary.Add("glCreateShader", (Gl.Delegates.glCreateShader)CreateShader); _webGlFuncDictionary.Add("glShaderSource", (Gl.Delegates.glShaderSource)ShaderSource); _webGlFuncDictionary.Add("glCompileShader", (Gl.Delegates.glCompileShader)CompileShader); _webGlFuncDictionary.Add("glGetShaderiv", (Gl.Delegates.glGetShaderiv)ShaderGetParam); _webGlFuncDictionary.Add("glGetShaderInfoLog", (Gl.Delegates.glGetShaderInfoLog)ShaderInfoLog); _webGlFuncDictionary.Add("glCreateProgram", (Gl.Delegates.glCreateProgram)CreateProgram); _webGlFuncDictionary.Add("glDeleteShader", (Gl.Delegates.glDeleteShader)DeleteShader); _webGlFuncDictionary.Add("glUseProgram", (Gl.Delegates.glUseProgram)UseProgram); _webGlFuncDictionary.Add("glAttachShader", (Gl.Delegates.glAttachShader)AttachShader); _webGlFuncDictionary.Add("glBindAttribLocation", (Gl.Delegates.glBindAttribLocation)BindAttributeLocation); _webGlFuncDictionary.Add("glLinkProgram", (Gl.Delegates.glLinkProgram)LinkProgram); _webGlFuncDictionary.Add("glGetProgramInfoLog", (Gl.Delegates.glGetProgramInfoLog)ProgramInfoLog); _webGlFuncDictionary.Add("glGetProgramiv", (Gl.Delegates.glGetProgramiv)ProgramGetParam); _webGlFuncDictionary.Add("glGetUniformLocation", (Gl.Delegates.glGetUniformLocation)GetUniformLocation); _webGlFuncDictionary.Add("glUniform1iv", (Gl.Delegates.glUniform1iv)UploadUniform); _webGlFuncDictionary.Add("glUniform1f", (Gl.Delegates.glUniform1f)UploadUniform); _webGlFuncDictionary.Add("glUniform2f", (Gl.Delegates.glUniform2f)UploadUniform); _webGlFuncDictionary.Add("glUniform1i", (Gl.Delegates.glUniform1i)UploadUniform); _webGlFuncDictionary.Add("glUniform3f", (Gl.Delegates.glUniform3f)UploadUniform); _webGlFuncDictionary.Add("glUniform4f", (Gl.Delegates.glUniform4f)UploadUniform); _webGlFuncDictionary.Add("glUniform1fv", (Gl.Delegates.glUniform1fv)UploadUniform); _webGlFuncDictionary.Add("glUniform2fv", (Gl.Delegates.glUniform2fv)UploadUniformFloatArrayMultiComponent2); _webGlFuncDictionary.Add("glUniform3fv", (Gl.Delegates.glUniform3fv)UploadUniformFloatArrayMultiComponent3); _webGlFuncDictionary.Add("glUniform4fv", (Gl.Delegates.glUniform4fv)UploadUniformFloatArrayMultiComponent4); _webGlFuncDictionary.Add("glUniformMatrix4fv", (Gl.Delegates.glUniformMatrix4fv)UploadUniformMat4); _webGlFuncDictionary.Add("glGenFramebuffers", (Gl.Delegates.glGenFramebuffers)CreateFramebuffer); _webGlFuncDictionary.Add("glBindFramebuffer", (Gl.Delegates.glBindFramebuffer)BindFramebuffer); _webGlFuncDictionary.Add("glFramebufferTexture2D", (Gl.Delegates.glFramebufferTexture2D)FramebufferUploadTexture2D); _webGlFuncDictionary.Add("glCheckFramebufferStatus", (Gl.Delegates.glCheckFramebufferStatus)FramebufferStatus); _webGlFuncDictionary.Add("glDrawBuffers", (Gl.Delegates.glDrawBuffers)DrawBuffers); _webGlFuncDictionary.Add("glGenVertexArrays", (Gl.Delegates.glGenVertexArrays)GenVertexArrays); _webGlFuncDictionary.Add("glBindVertexArray", (Gl.Delegates.glBindVertexArray)BindVertexArray); _webGlFuncDictionary.Add("glEnableVertexAttribArray", (Gl.Delegates.glEnableVertexAttribArray)EnableVertexAttribArray); _webGlFuncDictionary.Add("glVertexAttribPointer", (Gl.Delegates.glVertexAttribPointer)VertexAttribPointer); _webGlFuncDictionary.Add("glDrawElements", (Gl.Delegates.glDrawElements)DrawElements); _webGlFuncDictionary.Add("glDrawArrays", (Gl.Delegates.glDrawArrays)DrawArrays); _webGlFuncDictionary.Add("glFenceSync", (Gl.Delegates.glFenceSync)FenceSync); _webGlFuncDictionary.Add("glClientWaitSync", (Gl.Delegates.glClientWaitSync)ClientWaitSync); _webGlFuncDictionary.Add("glGenTextures", (Gl.Delegates.glGenTextures)CreateTexture); _webGlFuncDictionary.Add("glDeleteTextures", (Gl.Delegates.glDeleteTextures)DeleteTextures); _webGlFuncDictionary.Add("glBindTexture", (Gl.Delegates.glBindTexture)BindTexture); _webGlFuncDictionary.Add("glActiveTexture", (Gl.Delegates.glActiveTexture)ActiveTexture); _webGlFuncDictionary.Add("glTexImage2D", (Gl.Delegates.glTexImage2D)UploadTexture); _webGlFuncDictionary.Add("glTexParameteri", (Gl.Delegates.glTexParameteri)TexParameterInteger); _webGlFuncDictionary.Add("glGenRenderbuffers", (Gl.Delegates.glGenRenderbuffers)CreateRenderbuffer); _webGlFuncDictionary.Add("glBindRenderbuffer", (Gl.Delegates.glBindRenderbuffer)BindRenderbuffer); _webGlFuncDictionary.Add("glRenderbufferStorage", (Gl.Delegates.glRenderbufferStorage)RenderbufferStorage); _webGlFuncDictionary.Add("glFramebufferRenderbuffer", (Gl.Delegates.glFramebufferRenderbuffer)FramebufferRenderbuffer); Valid = true; }