Example #1
0
        /// <summary>
        /// Creates a new Glob Device. Can only be called once the OpenGL context is already created, for example by creating an OpenTK GameWindow.
        /// </summary>
        /// <param name="textOutput">Text output that will be used by Glob</param>
        /// <param name="fileManager">File manager that will be used by Glob</param>
        public Device(ITextOutputGlob textOutput, IFileManagerGlob fileManager)
        {
            TextOutput  = textOutput;
            FileManager = fileManager;

            DeviceInfo = new DeviceInfo();

            // TODO: move these to DeviceInfo.ToString()
            TextOutput.Print(OutputTypeGlob.Notify, "OpenGL: " + DeviceInfo.OpenGLVersion + " GLSL: " + DeviceInfo.GLSLVersion);
            TextOutput.Print(OutputTypeGlob.Notify, "Renderer: " + DeviceInfo.DeviceRenderer + ", " + DeviceInfo.DeviceVendor);

            // Print extensions
            StringBuilder allExtensionsStr = new StringBuilder();

            foreach (string extension in DeviceInfo.Extensions)
            {
                allExtensionsStr.Append(extension);
                allExtensionsStr.Append(" ");
            }
            TextOutput.Print(OutputTypeGlob.Notify, DeviceInfo.Extensions.Count.ToString() + " GL extensions found");
            TextOutput.Print(OutputTypeGlob.LogOnly, allExtensionsStr.ToString());

            ShaderRepository = new ShaderRepository(this, "#extension GL_ARB_separate_shader_objects : enable\n");
            ShaderRepository.StartFileWatcher(FileManager.GetPathShaderSource(""));

            _bufferBindingManager   = new BufferBindingManager();
            DebugMessageManager     = new DebugMessageManager(true);
            _textureUnit            = new TextureUnitState();
            _currentRasterizerState = new RasterizerState();
            _currentDepthState      = new DepthState();
            _currentBlendState      = new BlendState();

            // Create and bind a global vertex array object
            _vaoGlobal = GL.GenVertexArray();
            GL.BindVertexArray(_vaoGlobal);
        }