[cogl/wip/cogl-sharp: 10/42] cogl-sharp: Create a cogl2-sharp assembly
- From: Damien Lespiau <dlespiau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/cogl-sharp: 10/42] cogl-sharp: Create a cogl2-sharp assembly
- Date: Mon, 22 Oct 2012 11:10:26 +0000 (UTC)
commit 4352d3d27b977591c7804ed84aa10d826ddd8871
Author: Damien Lespiau <damien lespiau intel com>
Date: Sat Sep 29 17:48:06 2012 +0100
cogl-sharp: Create a cogl2-sharp assembly
This commit includes quite of a bit of the administrative work to make
cogl2-sharp.dll assembly that can be used to access Cogl API with C#.
Let's start simple and bing CoglColor in this first commit.
.gitignore | 3 ++
Makefile.am | 4 +++
cogl-sharp/AssemblyInfo.cs.in | 4 +++
cogl-sharp/Color.cs | 55 +++++++++++++++++++++++++++++++++++++
cogl-sharp/Makefile.am | 31 +++++++++++++++++++++
cogl-sharp/cogl2-sharp.dll.config | 3 ++
cogl-sharp/cogl2-sharp.pc.in | 8 +++++
cogl-sharp/cogl2-sharp.rsp | 2 +
configure.ac | 22 +++++++++++++++
9 files changed, 132 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 1adb397..e0c8a27 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,8 @@ compile
*.la
*.gcov
*.exe
+*.dll
+*.mdb
/README
stamp-enum-types
stamp-marshal
@@ -29,6 +31,7 @@ stamp-marshal
*.gir
*.typelib
/cogl-pango/cogl-pango.rc
+/cogl-sharp/AssemblyInfo.cs
/cogl/cogl.rc
/cogl/cogl-defines.h
/cogl/cogl-defines.h.win32
diff --git a/Makefile.am b/Makefile.am
index c764b46..d3373a1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,6 +8,10 @@ if BUILD_COGL_GLES2
SUBDIRS += cogl-gles2
endif
+if BUILD_COGL_SHARP
+SUBDIRS += cogl-sharp
+endif
+
SUBDIRS += examples doc po build
ACLOCAL_AMFLAGS = -I build/autotools ${ACLOCAL_FLAGS}
diff --git a/cogl-sharp/AssemblyInfo.cs.in b/cogl-sharp/AssemblyInfo.cs.in
new file mode 100644
index 0000000..4c7e874
--- /dev/null
+++ b/cogl-sharp/AssemblyInfo.cs.in
@@ -0,0 +1,4 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly:AssemblyVersion ("@COGL_MAJOR_VERSION @COGL_MINOR_VERSION *")]
diff --git a/cogl-sharp/Color.cs b/cogl-sharp/Color.cs
new file mode 100644
index 0000000..6ff3121
--- /dev/null
+++ b/cogl-sharp/Color.cs
@@ -0,0 +1,55 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Damien Lespiau <damien lespiau intel com>
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Cogl
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Color
+ {
+ public float Red { get; set; }
+ public float Green { get; set; }
+ public float Blue { get; set; }
+ public float Alpha { get; set; }
+
+ [DllImport("cogl2.dll")]
+ private static extern void cogl_color_premultiply(ref Color color);
+
+ public void Premuliply()
+ {
+ cogl_color_premultiply(ref this);
+ }
+
+ [DllImport("cogl2.dll")]
+ private static extern void cogl_color_unpremultiply(ref Color color);
+
+ public void UnPremultiply()
+ {
+ cogl_color_unpremultiply(ref this);
+ }
+ }
+}
diff --git a/cogl-sharp/Makefile.am b/cogl-sharp/Makefile.am
new file mode 100644
index 0000000..a4066d7
--- /dev/null
+++ b/cogl-sharp/Makefile.am
@@ -0,0 +1,31 @@
+
+assemblydir = $(libdir)/cogl
+assembly_DATA = cogl2-sharp.dll cogl2-sharp.dll.config cogl2-sharp.dll.mdb
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = cogl2-sharp.pc
+
+sources = \
+ Color.cs \
+ AssemblyInfo.cs \
+ $(NULL)
+
+cogl2-sharp.dll: $(sources)
+ @rm -f cogl2-sharp.dll.mdb
+ $(MCS) $(CSFLAGS) @$(srcdir)/cogl2-sharp.rsp -debug $(sources)
+
+cogl2-sharp.dll.mdb: cogl2-sharp.dll
+
+EXTRA_DIST = \
+ $(sources) \
+ cogl2-sharp.pc.in \
+ $(NULL)
+
+CLEANFILES = \
+ cogl2-sharp.dll \
+ cogl2-sharp.dll.mdb \
+ $(NULL)
+
+DISTCLEANFILES = \
+ AssemblyInfo.cs \
+ $(NULL)
diff --git a/cogl-sharp/cogl2-sharp.dll.config b/cogl-sharp/cogl2-sharp.dll.config
new file mode 100644
index 0000000..3a2b8a7
--- /dev/null
+++ b/cogl-sharp/cogl2-sharp.dll.config
@@ -0,0 +1,3 @@
+<configuration>
+ <dllmap dll="Cogl2.dll" target="libcogl2.so" />
+</configuration>
diff --git a/cogl-sharp/cogl2-sharp.pc.in b/cogl-sharp/cogl2-sharp.pc.in
new file mode 100644
index 0000000..10242bc
--- /dev/null
+++ b/cogl-sharp/cogl2-sharp.pc.in
@@ -0,0 +1,8 @@
+prefix= prefix@
+assemblies_dir=${prefix}/lib/cogl
+Librairies=${assemblies_dir}/cogl2-sharp.dll
+
+Name: Cogl2 C# binding
+Description: An object oriented GL/GLES Abstraction/Utility Layer
+Version: @COGL_VERSION@
+Libs: -r:cogl2-sharp.dll
diff --git a/cogl-sharp/cogl2-sharp.rsp b/cogl-sharp/cogl2-sharp.rsp
new file mode 100644
index 0000000..9820937
--- /dev/null
+++ b/cogl-sharp/cogl2-sharp.rsp
@@ -0,0 +1,2 @@
+/target:library
+/out:cogl2-sharp.dll
diff --git a/configure.ac b/configure.ac
index ced55bf..60dd0f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1190,6 +1190,24 @@ COGL_DEFINES_EXTRA="$COGL_DEFINES_EXTRA
"
dnl ================================================================
+dnl C# bindings
+dnl ================================================================
+AC_PATH_PROG(MCS, [mcs], [no])
+AS_IF([test "x$MCS" != "xno"], [have_mcs=yes])
+
+AC_ARG_ENABLE(
+ [cogl-sharp],
+ [AC_HELP_STRING([--enable-cogl-sharp=@<:@no/yes@:>@], [Build C sharp bindings @<:@default=auto@:>@])],
+ [],
+ [enable_cogl_sharp=$have_mcs]
+)
+AS_IF([test "x$enable_cogl_sharp" = "xyes" -a "x$have_mcs" != "xyes"],
+ [AC_MSG_ERROR([Could not find a C sharp compiler])])
+
+AM_CONDITIONAL(BUILD_COGL_SHARP, [test "$enable_cogl_sharp" = "yes"])
+AC_SUBST(MCS)
+
+dnl ================================================================
dnl What needs to be substituted in other files
dnl ================================================================
COGL_DEFINES="$COGL_DEFINES_EXTRA"
@@ -1253,6 +1271,9 @@ cogl-pango/cogl-pango2.pc
cogl-pango/cogl-pango.rc
cogl-gles2/Makefile
cogl-gles2/cogl-gles2-experimental.pc
+cogl-sharp/Makefile
+cogl-sharp/AssemblyInfo.cs
+cogl-sharp/cogl2-sharp.pc
doc/Makefile
doc/reference/Makefile
doc/reference/cogl2/Makefile
@@ -1318,6 +1339,7 @@ echo " â Extra:"
echo " Build API reference: ${enable_gtk_doc}"
echo " Build introspection data: ${enable_introspection}"
echo " Enable internationalization: ${USE_NLS}"
+echo " Build C# binding: ${enable_cogl_sharp}"
echo ""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]