Exemplo n.º 1
0
        public VertexShader(string filePath)
        {
            FilePath   = filePath;
            SourceCode = File.ReadAllText(FilePath);

            VertexShaderObjectHandle = SDL_gpu.GPU_CompileShader(SDL_gpu.GPU_ShaderEnum.GPU_VERTEX_SHADER, SourceCode);

            if (VertexShaderObjectHandle == 0)
            {
                throw new ShaderException("Compilation failed.", SDL_gpu.GPU_GetShaderMessage());
            }

            CompileAndSetDefaultPixelShader();
            if (PixelShaderObjectHandle == 0)
            {
                throw new ShaderException(
                          "Default Chroma pixel shader compilation failed. " +
                          "Report an issue - be sure to include GLSL errors or I'll f**k you up just like I did with this framework.", SDL_gpu.GPU_GetShaderMessage());
            }

            ProgramHandle = SDL_gpu.GPU_LinkShaders(PixelShaderObjectHandle, VertexShaderObjectHandle);

            if (ProgramHandle == 0)
            {
                throw new ShaderException("Linkage failed.", SDL_gpu.GPU_GetShaderMessage());
            }

            CreateShaderBlock();
        }
Exemplo n.º 2
0
        private void LinkShaders()
        {
            ProgramHandle = SDL_gpu.GPU_LinkShaders(PixelShaderObjectHandle, VertexShaderObjectHandle);

            if (ProgramHandle == 0)
            {
                throw new ShaderException("Compound shader linkage failed.", SDL_gpu.GPU_GetShaderMessage());
            }
        }
Exemplo n.º 3
0
        private void TryCompileVertexShader()
        {
            VertexShaderSourceCode   = File.ReadAllText(VertexShaderFilePath);
            VertexShaderObjectHandle = SDL_gpu.GPU_CompileShader(SDL_gpu.GPU_ShaderEnum.GPU_VERTEX_SHADER, VertexShaderSourceCode);

            if (VertexShaderObjectHandle == 0)
            {
                throw new ShaderException("Vertex shader compilation failed.", SDL_gpu.GPU_GetShaderMessage());
            }
        }
Exemplo n.º 4
0
        private void TryCompilePixelShader()
        {
            PixelShaderSourceCode   = File.ReadAllText(PixelShaderFilePath);
            PixelShaderObjectHandle = SDL_gpu.GPU_CompileShader(SDL_gpu.GPU_ShaderEnum.GPU_PIXEL_SHADER, PixelShaderSourceCode);

            if (PixelShaderObjectHandle == 0)
            {
                throw new ShaderException("Pixel shader compilation failed.", SDL_gpu.GPU_GetShaderMessage());
            }
        }