public DCTProcessor(GraphicsInterface gi, int width, int height) { fGI = gi; fWidth = width; fHeight = height; // Create the cosine buffer // Calculate the cosines // assign the values to the texture object fCosineBuffer = new GLTextureRectangle(gi, 8, 8, TextureInternalFormat.Luminance, TexturePixelFormat.Luminance, PixelType.Float); fRenderTarget = new GLRenderTarget(gi, width, height); fDCTOutputTexture = new GLTextureRectangle(gi, width, height, TextureInternalFormat.Rgba, TexturePixelFormat.Rgba, PixelType.Float); // We attach the texture 4 times so we can output to the same texture four times // in one shader pass using gl_FragData[0,1,2,3] fRenderTarget.AttachColorBuffer(fDCTOutputTexture, ColorBufferAttachPoint.Position0); fRenderTarget.AttachColorBuffer(fDCTOutputTexture, ColorBufferAttachPoint.Position1); fRenderTarget.AttachColorBuffer(fDCTOutputTexture, ColorBufferAttachPoint.Position2); fRenderTarget.AttachColorBuffer(fDCTOutputTexture, ColorBufferAttachPoint.Position3); fRenderTarget.Unbind(); // Precalculate the basis functions (cosine tables) }
public DisplaySurface(GraphicsInterface gi, Resolution res, IHaveTexture imageSource) { fGI = gi; fResolution = res; fImageSource = imageSource; fRenderTarget = new GLRenderTarget(gi, res.Columns, res.Rows); fRenderTarget.Unbind(); }
protected override void OnSetContext() { // When debugging, it's nice to turn on the following check. // If you do, whenever there is an error while calling one of the // underlying OpenGL functions, a GLException will be thrown. // If this flag is not set, then errors will be silently passed by and // rendering will continue. //GraphicsInterface.gCheckErrors = true; // Enable a couple of features for nice rendering. // For this program, Texturing, and DepthTest are essential. // The hint for perspective correction is optional GI.Features.Texturing2D.Enable(); GI.Features.DepthTest.Enable(); GI.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); // Set an overall color buffer background color of Invisible, // so when we clear the color buffer, it starts out blank. GI.Buffers.ColorBuffer.Color = ColorRGBA.Invisible; // Create the offscreen render target fRenderTarget = new GLRenderTarget(GI, fOffscreenWidth, fOffscreenHeight); // Create the texture object that we will be using to do normal rendering. // aTexture = TextureHelper.CreateTextureFromFile(GI, "tex.png", false); // Create the shader programs using the easy static method that // takes vertex and fragment shader strings. fFixedPipeline = GLSLShaderProgram.CreateUsingVertexAndFragmentStrings(GI, ShaderStrings.FixedVert, ShaderStrings.FixedFrag); fImageProcProgram = GLSLShaderProgram.CreateUsingVertexAndFragmentStrings(GI, ShaderStrings.FixedVert, ShaderStrings.ConvolutionFrag); // This is an alternate method of creating the shader programs. // You get absolute control of the individual pieces as they // are created, at the cost of brevity //GLSLVertexShader fixedVertexShader = new GLSLVertexShader(GI, ShaderStrings.FixedVert); //GLSLFragmentShader fixedFragmentShader = new GLSLFragmentShader(GI, ShaderStrings.FixedFrag); //GLSLFragmentShader convolutionFragmentShader = new GLSLFragmentShader(GI, ShaderStrings.ConvolutionFrag); //// Create the pipeline shader program //fFixedPipeline = new GLSLShaderProgram(GI); //fFixedPipeline.AttachShader(fixedVertexShader); //fFixedPipeline.AttachShader(fixedFragmentShader); //fFixedPipeline.Link(); //// Create the convolution shader program //fImageProcProgram = new GLSLShaderProgram(GI); //fImageProcProgram.AttachShader(fixedVertexShader); //fImageProcProgram.AttachShader(convolutionFragmentShader); //fImageProcProgram.Link(); }
public DissolveProcessor(GraphicsInterface gi, int width, int height, float noiseScale) { fGI = gi; fWidth = width; fHeight = height; fNoiseScale = noiseScale; // Create the texture objects that will receive the output fOutputTexture = new GLTexture2D(GI, width, height, TextureInternalFormat.Rgba, TexturePixelFormat.Bgr, PixelComponentType.Byte, IntPtr.Zero, false); // Setup the render target that has 3 color channels for Multi Render Target // output in a shader using gl_FragData[n] fOutputTarget = new GLRenderTarget(GI); fOutputTarget.AttachColorBuffer(fOutputTexture, ColorBufferAttachPoint.Position0); fOutputTarget.Unbind(); // Create the shader program that does the actual separation fDissolveShader = GLSLShaderProgram.CreateUsingVertexAndFragmentStrings(GI, FixedVert, Dissolve_Frag); }
public YCrCbProcessor(GraphicsInterface gi, int width, int height) { fGI = gi; fWidth = width; fHeight = height; // Create the texture objects that will receive the output fYTexture = new GLTexture2D(GI, width, height, TextureInternalFormat.Luminance, TexturePixelFormat.Luminance, PixelType.Byte, IntPtr.Zero, false); fCrTexture = new GLTexture2D(GI, width, height, TextureInternalFormat.Luminance, TexturePixelFormat.Luminance, PixelType.Byte, IntPtr.Zero, false); fCbTexture = new GLTexture2D(GI, width, height, TextureInternalFormat.Luminance, TexturePixelFormat.Luminance, PixelType.Byte, IntPtr.Zero, false); // Setup the render target that has 3 color channels for Multi Render Target // output in a shader using gl_FragData[n] fYCrCbTarget = new GLRenderTarget(GI); fYCrCbTarget.AttachColorBuffer(fYTexture, ColorBufferAttachPoint.Position0); fYCrCbTarget.AttachColorBuffer(fCrTexture, ColorBufferAttachPoint.Position1); fYCrCbTarget.AttachColorBuffer(fCbTexture, ColorBufferAttachPoint.Position2); fYCrCbTarget.Unbind(); // Create the shader program that does the actual separation fYCrCbChannelSep = GLSLShaderProgram.CreateUsingVertexAndFragmentStrings(GI, FixedVert, YCrCb_Frag); }