From: Jean-Philippe Bruyère Date: Tue, 1 Sep 2020 18:49:24 +0000 (+0200) Subject: test cairo egl X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=refs%2Fheads%2FtestEglBackend;p=jp%2Fcrow.git test cairo egl --- diff --git a/Crow.sln b/Crow.sln index ee474496..8648c524 100644 --- a/Crow.sln +++ b/Crow.sln @@ -29,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerfTests", "Samples\PerfTe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugLogAnalyzer", "Samples\DebugLogAnalyzer\DebugLogAnalyzer.csproj", "{7915538F-B2B1-414C-95A3-1FC58E3286B9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EglBackend", "Samples\EglBackend\EglBackend.csproj", "{B815F4D2-D2C4-4914-AE18-676DA05C66B2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -65,6 +67,10 @@ Global {7915538F-B2B1-414C-95A3-1FC58E3286B9}.Debug|Any CPU.Build.0 = Debug|Any CPU {7915538F-B2B1-414C-95A3-1FC58E3286B9}.Release|Any CPU.ActiveCfg = Release|Any CPU {7915538F-B2B1-414C-95A3-1FC58E3286B9}.Release|Any CPU.Build.0 = Release|Any CPU + {B815F4D2-D2C4-4914-AE18-676DA05C66B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B815F4D2-D2C4-4914-AE18-676DA05C66B2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B815F4D2-D2C4-4914-AE18-676DA05C66B2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B815F4D2-D2C4-4914-AE18-676DA05C66B2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -76,6 +82,7 @@ Global {7AEB6DD5-916E-4415-84E1-78EC6E5881CE} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} {18EBB41F-815E-4BF5-B80F-C9E2FAB2993A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} {7915538F-B2B1-414C-95A3-1FC58E3286B9} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} + {B815F4D2-D2C4-4914-AE18-676DA05C66B2} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {00D4E149-7131-49F4-BAAD-559AA961A78E} diff --git a/Samples/EglBackend/EglBackend.csproj b/Samples/EglBackend/EglBackend.csproj new file mode 100644 index 00000000..d5be01b9 --- /dev/null +++ b/Samples/EglBackend/EglBackend.csproj @@ -0,0 +1,8 @@ + + + + + ui.%(Filename)%(Extension) + + + \ No newline at end of file diff --git a/Samples/EglBackend/Program.cs b/Samples/EglBackend/Program.cs new file mode 100644 index 00000000..fcca84ee --- /dev/null +++ b/Samples/EglBackend/Program.cs @@ -0,0 +1,98 @@ +// Copyright (c) 2013-2020 Jean-Philippe Bruyère +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) +using System; +using System.Threading; +using Crow; +using Glfw; + +namespace EglBackend +{ + + class MainClass : Interface + { + const int OpenglEsApi = 0x00030002; + const int EglContextApi = 0x00036002; + Crow.Cairo.EGLDevice dev; + + MainClass (IntPtr hWnd) : base (800, 600, hWnd) { + IntPtr eglDisp = Glfw3.GetEGLDisplay (); + IntPtr eglCtx = Glfw3.GetEGLContext (hWnd); + + dev = new Crow.Cairo.EGLDevice (eglDisp, eglCtx); + Console.WriteLine ($"Egl device creation status: {dev.Status}"); + surf = new Crow.Cairo.GLSurface (dev, Glfw3.GetEGLSurface (hWnd), this.clientRectangle.Width, this.clientRectangle.Height); + Console.WriteLine ($"Cairo surface creation status: {surf.Status}"); + Glfw3.MakeContextCurrent (hWnd); + Glfw3.SwapInterval (1); + + using (Crow.Cairo.Context ctx = new Crow.Cairo.Context (surf)) { + ctx.SetSourceRGB (1, 0, 0); + ctx.Paint (); + } + + /*Thread t = new Thread (InterfaceThread) { + IsBackground = true + }; + t.Start ();*/ + + } + protected override void Dispose (bool disposing) + { + surf.Dispose (); + dev.Dispose (); + + base.Dispose (disposing); + } + + public static void Main (string [] args) + { + Glfw3.Init (); + Glfw3.SetErrorCallback ((error, description) => Console.WriteLine ($"{error}:{description}")); + Glfw3.WindowHint (WindowAttribute.ClientApi, OpenglEsApi); + Glfw3.WindowHint (WindowAttribute.ContextVersionMajor, 2); + Glfw3.WindowHint (WindowAttribute.ContextCreationApi, EglContextApi); + + /*Glfw3.WindowHint (WindowAttribute.RedBits, 8); + Glfw3.WindowHint (WindowAttribute.GreenBits, 8); + Glfw3.WindowHint (WindowAttribute.BlueBits, 8); + Glfw3.WindowHint (WindowAttribute.DepthBits, 8);*/ + + + IntPtr hWnd = Glfw3.CreateWindow (800, 600, "Egl Test", MonitorHandle.Zero, IntPtr.Zero); + + if (hWnd == IntPtr.Zero) + throw new Exception ("[GLFW3] Unable to create egl Window"); + + Glfw3.MakeContextCurrent (hWnd); + + using (MainClass app = new MainClass (hWnd)) { + app.Init (); + while(!Glfw3.WindowShouldClose(hWnd)) { + app.Update (); + if (app.IsDirty) { + (app.surf as Crow.Cairo.GLSurface).SwapBuffers (); + //Glfw3.SwapBuffers (hWnd); + app.IsDirty = false; + } + Glfw3.PollEvents (); + } + } + + + Glfw3.DestroyWindow (hWnd); + Glfw3.Terminate (); + } + + protected override void OnInitialized () + { + base.OnInitialized (); + registerGlfwCallbacks (); + foreach (string s in System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceNames ()) { + Console.WriteLine (s); + } + + Load ("#ui.helloworld.crow").DataSource = this; + } + } +} diff --git a/Samples/EglBackend/ui/helloworld.crow b/Samples/EglBackend/ui/helloworld.crow new file mode 100644 index 00000000..c7536e46 --- /dev/null +++ b/Samples/EglBackend/ui/helloworld.crow @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/common/ui/Interfaces/testWindow.goml.sav b/Samples/common/ui/Interfaces/testWindow.goml.sav deleted file mode 100644 index 42b4b744..00000000 --- a/Samples/common/ui/Interfaces/testWindow.goml.sav +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file