2014-01-27 00:02:21 +00:00
using System ;
using System.IO ;
2014-02-03 05:27:59 +00:00
using System.Drawing ;
2014-01-27 00:02:21 +00:00
using swf = System . Windows . Forms ;
2014-01-27 00:38:10 +00:00
using OpenTK ;
2014-01-27 09:45:16 +00:00
using OpenTK.Graphics.OpenGL ;
2014-01-27 00:38:10 +00:00
2014-01-27 00:02:21 +00:00
namespace BizHawk.Bizware.BizwareGL
{
/// <summary>
/// This is a wrapper over hopefully any OpenGL bindings..
/// And possibly, quite possibly, Direct3d.. even though none of your shaders would work. (could use nvidia CG, native dlls in necessary since this would only be for windows)
/// TODO - This really needs to be split up into an internal and a user interface. so many of the functions are made to support the smart wrappers
/// Maybe make a method that returns an interface used for advanced methods (and IGL_TK could implement that as well and just "return this:")
2014-01-30 04:54:02 +00:00
///
/// NOTE: THIS SHOULD NOT BE ASSUMED TO BE THREAD SAFE! Make a new IGL if you want to use it in a new thread. I hope that will work...
2014-01-27 00:02:21 +00:00
/// </summary>
2014-01-27 05:37:04 +00:00
public interface IGL : IDisposable
2014-01-27 00:02:21 +00:00
{
/// <summary>
/// Clears the specified buffer parts
/// </summary>
/// <param name="mask"></param>
void Clear ( ClearBufferMask mask ) ;
/// <summary>
/// Sets the current clear color
/// </summary>
2014-02-03 05:27:59 +00:00
void SetClearColor ( Color color ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// returns an empty handle
/// </summary>
IntPtr GetEmptyHandle ( ) ;
/// <summary>
/// returns an empty uniform handle
/// </summary>
IntPtr GetEmptyUniformHandle ( ) ;
/// <summary>
/// compile a fragment shader. This is the simplified method. A more complex method may be added later which will accept multiple sources and preprocessor definitions independently
/// </summary>
2014-02-03 07:43:47 +00:00
Shader CreateFragmentShader ( string source , bool required ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// compile a vertex shader. This is the simplified method. A more complex method may be added later which will accept multiple sources and preprocessor definitions independently
/// </summary>
2014-02-03 07:43:47 +00:00
Shader CreateVertexShader ( string source , bool required ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// Creates a complete pipeline from the provided vertex and fragment shader handles
/// </summary>
2014-02-03 07:43:47 +00:00
Pipeline CreatePipeline ( VertexLayout vertexLayout , Shader vertexShader , Shader fragmentShader , bool required ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// Binds this pipeline as the current used for rendering
/// </summary>
void BindPipeline ( Pipeline pipeline ) ;
/// <summary>
/// Sets a uniform sampler to use use the provided texture handle
/// </summary>
void SetPipelineUniformSampler ( PipelineUniform uniform , IntPtr texHandle ) ;
/// <summary>
/// Sets a uniform value
/// </summary>
2014-01-27 00:38:10 +00:00
void SetPipelineUniformMatrix ( PipelineUniform uniform , Matrix4 mat , bool transpose ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// Sets a uniform value
/// </summary>
2014-01-27 00:38:10 +00:00
void SetPipelineUniformMatrix ( PipelineUniform uniform , ref Matrix4 mat , bool transpose ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// sets a uniform value
/// </summary>
void SetPipelineUniform ( PipelineUniform uniform , Vector4 value ) ;
/// <summary>
2014-02-03 05:27:59 +00:00
/// sets a uniform value
/// </summary>
void SetPipelineUniform ( PipelineUniform uniform , Vector2 value ) ;
/// <summary>
/// sets a uniform value
2014-01-27 00:02:21 +00:00
/// </summary>
2014-02-03 05:27:59 +00:00
void SetPipelineUniform ( PipelineUniform uniform , float value ) ;
2014-01-27 00:02:21 +00:00
2014-02-06 09:45:55 +00:00
/// <summary>
/// sets uniform values
/// </summary>
void SetPipelineUniform ( PipelineUniform uniform , Vector4 [ ] values ) ;
/// <summary>
/// sets a uniform value
/// </summary>
void SetPipelineUniform ( PipelineUniform uniform , bool value ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// Binds array data for use with the currently-bound VertexLayout
/// </summary>
unsafe void BindArrayData ( void * pData ) ;
/// <summary>
/// Draws based on the currently set VertexLayout and ArrayData
/// </summary>
void DrawArrays ( PrimitiveType mode , int first , int count ) ;
/// <summary>
/// Frees the provided shader handle
/// </summary>
void FreeShader ( IntPtr shader ) ;
/// <summary>
2014-12-08 02:15:42 +00:00
/// frees the provided texture
2014-01-27 00:02:21 +00:00
/// </summary>
2014-12-08 02:15:42 +00:00
void FreeTexture ( Texture2d tex ) ;
2014-01-27 00:02:21 +00:00
2014-02-07 23:06:51 +00:00
/// <summary>
/// resolves the texture into a new BitmapBuffer
/// </summary>
BitmapBuffer ResolveTexture2d ( Texture2d texture ) ;
2014-01-28 19:33:49 +00:00
/// <summary>
/// frees the provided render target
/// </summary>
void FreeRenderTarget ( RenderTarget rt ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// Binds this texture as the current texture2d target for parameter-specification
/// </summary>
void BindTexture2d ( Texture2d texture ) ;
/// <summary>
/// Sets a 2d texture parameter
/// </summary>
void TexParameter2d ( TextureParameterName pname , int param ) ;
/// <summary>
/// creates a vertex layout resource
/// </summary>
VertexLayout CreateVertexLayout ( ) ;
/// <summary>
/// Creates a blending state object
/// </summary>
2014-01-27 09:45:16 +00:00
IBlendState CreateBlendState ( BlendingFactorSrc colorSource , BlendEquationMode colorEquation , BlendingFactorDest colorDest ,
BlendingFactorSrc alphaSource , BlendEquationMode alphaEquation , BlendingFactorDest alphaDest ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// retrieves a blend state for opaque rendering
/// Alpha values are copied from the source fragment.
/// </summary>
2014-12-13 23:04:22 +00:00
IBlendState BlendNoneCopy { get ; }
/// <summary>
/// retrieves a blend state for opaque rendering
/// Alpha values are written as opaque
/// </summary>
IBlendState BlendNoneOpaque { get ; }
2014-01-27 00:02:21 +00:00
/// <summary>
/// retrieves a blend state for normal (non-premultiplied) alpha blending.
/// Alpha values are copied from the source fragment.
/// </summary>
IBlendState BlendNormal { get ; }
/// <summary>
/// Sets the current blending state object
/// </summary>
void SetBlendState ( IBlendState rsBlend ) ;
/// <summary>
/// Creates a texture with the specified dimensions
/// TODO - pass in specifications somehow
/// </summary>
Texture2d CreateTexture ( int width , int height ) ;
2014-04-15 21:46:18 +00:00
/// <summary>
/// In case you already have the texture ID (from an opengl emulator gpu core) you can get a Texture2d with it this way.
/// Otherwise, if this isn't an OpenGL frontend implementation, I guess... try reading the texturedata out of it and making a new texture?
/// </summary>
Texture2d WrapGLTexture2d ( IntPtr glTexId , int width , int height ) ;
/// <summary>
/// Sets the clamp mode (for both uv) for the Texture2d
/// </summary>
void SetTextureWrapMode ( Texture2d tex , bool clamp ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// Loads the texture with new data. This isnt supposed to be especially versatile, it just blasts a bitmap buffer into the texture
/// </summary>
void LoadTextureData ( Texture2d tex , BitmapBuffer bmp ) ;
/// <summary>
/// Loads a texture from disk
/// </summary>
Texture2d LoadTexture ( string path ) ;
/// <summary>
/// Loads a texture from the stream
/// </summary>
Texture2d LoadTexture ( Stream stream ) ;
/// <summary>
/// Loads a texture from the BitmapBuffer
/// </summary>
Texture2d LoadTexture ( BitmapBuffer buffer ) ;
/// <summary>
/// Loads a texture from the System.Drawing.Bitmap
/// </summary>
2014-02-03 05:27:59 +00:00
Texture2d LoadTexture ( Bitmap bitmap ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// sets the viewport according to the provided specifications
/// </summary>
void SetViewport ( int x , int y , int width , int height ) ;
2014-01-27 09:36:18 +00:00
/// <summary>
/// sets the viewport according to the provided specifications
/// </summary>
void SetViewport ( int width , int height ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// sets the viewport according to the client area of the provided control
/// </summary>
void SetViewport ( swf . Control control ) ;
2014-02-03 05:27:59 +00:00
/// <summary>
/// sets the viewport according to the provided specifications
/// </summary>
void SetViewport ( Size size ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// generates a proper 2d othographic projection for the given destination size, suitable for use in a GUI
/// </summary>
2014-01-27 00:38:10 +00:00
Matrix4 CreateGuiProjectionMatrix ( int w , int h ) ;
2014-01-27 00:02:21 +00:00
2014-02-03 05:27:59 +00:00
/// <summary>
/// generates a proper 2d othographic projection for the given destination size, suitable for use in a GUI
/// </summary>
Matrix4 CreateGuiProjectionMatrix ( Size dims ) ;
2014-01-27 00:02:21 +00:00
/// <summary>
/// generates a proper view transform for a standard 2d ortho projection, including half-pixel jitter if necessary and
/// re-establishing of a normal 2d graphics top-left origin. suitable for use in a GUI
/// </summary>
2014-01-27 00:38:10 +00:00
Matrix4 CreateGuiViewMatrix ( int w , int h ) ;
2014-01-27 09:36:18 +00:00
2014-02-03 05:27:59 +00:00
/// <summary>
/// generates a proper view transform for a standard 2d ortho projection, including half-pixel jitter if necessary and
/// re-establishing of a normal 2d graphics top-left origin. suitable for use in a GUI
/// </summary>
Matrix4 CreateGuiViewMatrix ( Size dims ) ;
2014-01-27 09:36:18 +00:00
/// <summary>
/// Creates a render target. Includes a color buffer. Pixel format control TBD
/// </summary>
RenderTarget CreateRenderTarget ( int w , int h ) ;
/// <summary>
/// Binds a RenderTarget for current rendering
/// </summary>
void BindRenderTarget ( RenderTarget rt ) ;
2014-01-28 19:33:49 +00:00
IGraphicsControl Internal_CreateGraphicsControl ( ) ;
2014-12-08 02:15:42 +00:00
/// <summary>
/// returns a string representing the API employed by this context
/// </summary>
string API { get ; }
2014-01-27 00:02:21 +00:00
}
}