public override void UpdateViewContent(FormRenderUpdateEventArgs formRenderUpdateEventArgs) { //1. create platform bitmap // create the surface int w = 800; int h = 600; if (myImg == null) { myImg = new TestGlfw.MyNativeRGBA32BitsImage(w, h); //test1 // create the surface var info = new SKImageInfo(w, h, SKImageInfo.PlatformColorType, SKAlphaType.Premul); using (var surface = SKSurface.Create(info, myImg.Scan0, myImg.Stride)) { // start drawing SKCanvas canvas = surface.Canvas; DrawWithSkia(canvas); surface.Canvas.Flush(); } } var glBmp = new PixelFarm.DrawingGL.GLBitmap(w, h, myImg.Scan0); _glsx.DrawImage(glBmp, 0, 600); glBmp.Dispose(); }
protected override void OnInitGLProgram(object sender, EventArgs args) { string vs = @" attribute vec4 a_position; attribute vec2 a_texCoord; varying vec2 v_texCoord; void main() { gl_Position = a_position; v_texCoord = a_texCoord; } "; string fs = @" precision mediump float; varying vec2 v_texCoord; uniform sampler2D s_baseMap; uniform sampler2D s_lightMap; void main() { vec4 baseColor; vec4 lightColor; baseColor = texture2D(s_baseMap, v_texCoord); lightColor = texture2D(s_lightMap, v_texCoord); gl_FragColor = baseColor * (lightColor + 0.25); } "; mProgram = ES2Utils.CompileProgram(vs, fs); if (mProgram == 0) { throw new NotSupportedException(); } // Get the attribute locations mPositionLoc = GL.GetAttribLocation(mProgram, "a_position"); mTexCoordLoc = GL.GetAttribLocation(mProgram, "a_texCoord"); // Get the sampler location mBaseMapLoc = GL.GetUniformLocation(mProgram, "s_baseMap"); mLightMapLoc = GL.GetUniformLocation(mProgram, "s_lightMap"); // Load the textures baseMapBmp = LoadTexture(RootDemoPath.Path + @"\SampleImages\basemap01.png"); lightMapBmp = LoadTexture(RootDemoPath.Path + @"\SampleImages\lightmap01.png"); if (mBaseMapTexID == 0 || mLightMapTexID == 0) { throw new NotSupportedException(); } isGLInit = true; this.EnableAnimationTimer = true; }