internal PlatformVertexInputLayout(
     PlatformRenderContext context,
     VertexInputLayoutBinding[] bindings,
     VertexInputLayoutAttribute[] attributes)
 {
     Context = context;
     Initialize(bindings, attributes);
 }
Beispiel #2
0
 internal PlatformBuffer(PlatformRenderContext context, BufferType bufferType, int size, bool dynamic)
 {
     Context    = context;
     BufferType = bufferType;
     Size       = size;
     Dynamic    = dynamic;
     Initialize();
 }
Beispiel #3
0
 internal PlatformTexture2D(PlatformRenderContext context, Format format, int width, int height, bool mipmaps, TextureParams textureParams)
 {
     Context    = context;
     Format     = format;
     Width      = width;
     Height     = height;
     LevelCount = mipmaps ? GraphicsUtility.CalculateMipLevelCount(width, height) : 1;
     Initialize(textureParams);
 }
 public PlatformShaderProgram(
     PlatformRenderContext context,
     IPlatformShader[] shaders,
     ShaderProgram.AttribLocation[] attribLocations,
     ShaderProgram.Sampler[] samplers)
 {
     Context = context;
     Initialize(shaders, attribLocations, samplers);
 }
Beispiel #5
0
 protected override void OnHandleCreated(EventArgs e)
 {
     base.OnHandleCreated(e);
     windowInfo      = OpenTK.Platform.Utilities.CreateWindowsWindowInfo(Handle);
     graphicsContext = new OpenTK.Graphics.GraphicsContext(graphicsMode, windowInfo, major, minor, graphicsContextFlags);
     graphicsContext.MakeCurrent(windowInfo);
     graphicsContext.LoadAll();
     graphicsContext.SwapInterval = VSync ? 1 : 0;
     if (platformRenderContext == null)
     {
         platformRenderContext = new Graphics.Platform.OpenGL.PlatformRenderContext();
         PlatformRenderer.Initialize(platformRenderContext);
     }
     graphicsContext.MakeCurrent(null);
 }
 internal PlatformRenderTexture2D(PlatformRenderContext context, Format format, int width, int height, TextureParams textureParams)
     : base(context, format, width, height, false, textureParams)
 {
     Initialize();
 }
Beispiel #7
0
        public static void GetGLTextureFormat(PlatformRenderContext ctx, Format format, out All glInternalFormat, out All glFormat, out All glType)
        {
            const All CompressedRgb8Etc2 = (All)37492;
            const All CompressedRgb8PunchthroughAlpha1Etc2 = (All)37494;
            const All CompressedRgba8Etc2Eac = (All)37496;
            const All R8  = (All)33321;
            const All RG8 = (All)33323;

            glInternalFormat = 0;
            glFormat         = 0;
            glType           = 0;
            switch (format)
            {
            case Format.R8_UNorm:
                if (ctx.ESProfile && ctx.GLMajorVersion >= 3)
                {
                    glInternalFormat = R8;
                }
                else
                {
                    glInternalFormat = All.Red;
                }
                glFormat = All.Red;
                glType   = All.UnsignedByte;
                break;

            case Format.R8G8_UNorm:
                if (ctx.ESProfile && ctx.GLMajorVersion >= 3)
                {
                    glInternalFormat = RG8;
                }
                else
                {
                    glInternalFormat = All.RgExt;
                }
                glFormat = All.RgExt;
                glType   = All.UnsignedByte;
                break;

            case Format.R8G8B8_UNorm:
                glInternalFormat = All.Rgb;
                glFormat         = All.Rgb;
                glType           = All.UnsignedByte;
                break;

            case Format.R8G8B8A8_UNorm:
                glInternalFormat = All.Rgba;
                glFormat         = All.Rgba;
                glType           = All.UnsignedByte;
                break;

            case Format.B8G8R8A8_UNorm:
                glInternalFormat = All.Rgba;
                glFormat         = All.BgraExt;
                glType           = All.UnsignedByte;
                if (ctx.SupportsInternalFormatBgra8)
                {
                    glInternalFormat = All.BgraExt;
                }
                break;

            case Format.R5G6B5_UNorm_Pack16:
                glInternalFormat = All.Rgb;
                glFormat         = All.Rgb;
                glType           = All.UnsignedShort565;
                break;

            case Format.R5G5B5A1_UNorm_Pack16:
                glInternalFormat = All.Rgba;
                glFormat         = All.Rgba;
                glType           = All.UnsignedShort5551;
                break;

            case Format.R4G4B4A4_UNorm_Pack16:
                glInternalFormat = All.Rgba;
                glFormat         = All.Rgba;
                glType           = All.UnsignedShort4444;
                break;

            case Format.BC1_RGB_UNorm_Block:
                glInternalFormat = All.CompressedRgbS3tcDxt1Ext;
                break;

            case Format.BC1_RGBA_UNorm_Block:
                glInternalFormat = All.CompressedRgbaS3tcDxt1Ext;
                break;

            case Format.BC2_UNorm_Block:
                glInternalFormat = All.CompressedRgbaS3tcDxt3Ext;
                break;

            case Format.BC3_UNorm_Block:
                glInternalFormat = All.CompressedRgbaS3tcDxt5Ext;
                break;

            case Format.ETC1_R8G8B8_UNorm_Block:
                if (ctx.SupportsEtc2)
                {
                    glInternalFormat = CompressedRgb8Etc2;
                }
                else
                {
                    glInternalFormat = All.Etc1Rgb8Oes;
                }
                break;

            case Format.ETC2_R8G8B8_UNorm_Block:
                glInternalFormat = CompressedRgb8Etc2;
                break;

            case Format.ETC2_R8G8B8A1_UNorm_Block:
                glInternalFormat = CompressedRgb8PunchthroughAlpha1Etc2;
                break;

            case Format.ETC2_R8G8B8A8_UNorm_Block:
                glInternalFormat = CompressedRgba8Etc2Eac;
                break;

            case Format.PVRTC1_2Bpp_UNorm_Block:
                glInternalFormat = All.CompressedRgbaPvrtc2Bppv1Img;
                break;

            case Format.PVRTC1_4Bpp_UNorm_Block:
                glInternalFormat = All.CompressedRgbaPvrtc4Bppv1Img;
                break;

            case Format.PVRTC2_2Bpp_UNorm_Block:
                glInternalFormat = All.CompressedRgbaPvrtc2Bppv2Img;
                break;

            case Format.PVRTC2_4Bpp_UNorm_Block:
                glInternalFormat = All.CompressedRgbaPvrtc4Bppv2Img;
                break;

            default:
                throw new ArgumentException(nameof(format));
            }
        }
Beispiel #8
0
 internal PlatformShader(PlatformRenderContext context, ShaderStageMask stage, string source)
 {
     Context = context;
     Stage   = stage;
     Initialize(source);
 }