Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Start of OpenGL bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
Perksey committed Nov 11, 2023
1 parent 9b449ec commit 8c83c28
Show file tree
Hide file tree
Showing 30 changed files with 326,264 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
[submodule "eng/submodules/glfw"]
path = eng/submodules/glfw
url = https://github.com/glfw/glfw
[submodule "eng/submodules/opengl"]
path = eng/submodules/opengl
url = https://github.com/KhronosGroup/OpenGL-Registry.git
[submodule "eng/submodules/egl"]
path = eng/submodules/egl
url = https://github.com/KhronosGroup/EGL-Registry/
10,618 changes: 10,618 additions & 0 deletions eng/include/glcompat/gl.h

Large diffs are not rendered by default.

4,527 changes: 4,527 additions & 0 deletions eng/include/glcore/gl.h

Large diffs are not rendered by default.

1,276 changes: 1,276 additions & 0 deletions eng/include/gles1/gl.h

Large diffs are not rendered by default.

3,747 changes: 3,747 additions & 0 deletions eng/include/gles2/gl.h

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions eng/include/silkglhgen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env python3
# -*- encoding utf-8 -*-
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.

from genheaders import *

buildList.clear()
buildList.append(
CGeneratorOptions(
filename="../../../include/glcompat/gl.h", # output file name
apiname="gl", # profile name
profile="compatibility", # core/compatibility/common
versions=allVersions, # include all versions in output
emitversions=allVersions, # emit all of the included versions
defaultExtensions="gl", # include all gl extensions
addExtensions=None, # also include these extensions (none)
removeExtensions=None, # but don't include these extensions (none)
prefixText=prefixStrings + glExtPlatformStrings, # prefix the header with this text
genFuncPointers=False, # generate function pointer typedefs?
protectFile=protectFile, # protect against multiple includes?
protectFeature=protectFeature, # protect against multiple feature definitions?
protectProto=False, # protect against multiple typedef definitiosn?
protectProtoStr="GL_GLEXT_PROTOTYPES", # if we're protecting against multiple typedefs, what define should we use?
apicall="GLAPI ", # calling convention macro prefix
apientry="APIENTRY ", # function typedef prefix
apientryp="APIENTRYP ", # function pointer typedef prefix
)
)
buildList.append(
CGeneratorOptions(
filename="../../../include/glcore/gl.h", # output file name
apiname="gl", # profile name
profile="core", # core/compatibility/common
versions=allVersions, # include all versions in output
emitversions=allVersions, # emit all of the included versions
defaultExtensions="glcore", # include all gl extensions
addExtensions=None, # also include these extensions (none)
removeExtensions=None, # but don't include these extensions (none)
prefixText=prefixStrings + glExtPlatformStrings, # prefix the header with this text
genFuncPointers=False, # generate function pointer typedefs?
protectFile=protectFile, # protect against multiple includes?
protectFeature=protectFeature, # protect against multiple feature definitions?
protectProto=False, # protect against multiple typedef definitiosn?
protectProtoStr="GL_GLEXT_PROTOTYPES", # if we're protecting against multiple typedefs, what define should we use?
apicall="GLAPI ", # calling convention macro prefix
apientry="APIENTRY ", # function typedef prefix
apientryp="APIENTRYP ", # function pointer typedef prefix
)
)
buildList.append(
CGeneratorOptions(
filename="../../../include/gles1/gl.h", # output file name
apiname="gles1", # profile name
profile="common", # core/compatibility/common
versions=allVersions, # include all versions in output
emitversions=allVersions, # emit all of the included versions
defaultExtensions="gles1", # include all gl extensions
addExtensions=None, # also include these extensions (none)
removeExtensions=None, # but don't include these extensions (none)
prefixText=prefixStrings
+ gles1PlatformStrings
+ apiEntryPrefixStrings, # prefix the header with this text
genFuncPointers=False, # generate function pointer typedefs?
protectFile=protectFile, # protect against multiple includes?
protectFeature=protectFeature, # protect against multiple feature definitions?
protectProto=False, # protect against multiple typedef definitiosn?
protectProtoStr="GL_GLEXT_PROTOTYPES", # if we're protecting against multiple typedefs, what define should we use?
apicall="GL_API ",
apientry="GL_APIENTRY ",
apientryp="GL_APIENTRYP ",
)
)
buildList.append(
CGeneratorOptions(
filename="../../../include/gles2/gl.h", # output file name
apiname="gles2", # profile name
profile="common", # core/compatibility/common
versions=gles2onlyPat, # include all versions in output
emitversions=allVersions, # emit all of the included versions
defaultExtensions="gles2", # include all gl extensions
addExtensions=None, # also include these extensions (none)
removeExtensions=None, # but don't include these extensions (none)
prefixText=prefixStrings
+ gles2PlatformStrings
+ apiEntryPrefixStrings, # prefix the header with this text
genFuncPointers=False, # generate function pointer typedefs?
protectFile=protectFile, # protect against multiple includes?
protectFeature=protectFeature, # protect against multiple feature definitions?
protectProto=False, # protect against multiple typedef definitiosn?
protectProtoStr="GL_GLEXT_PROTOTYPES", # if we're protecting against multiple typedefs, what define should we use?
apicall="GL_APICALL ",
apientry="GL_APIENTRY ",
apientryp="GL_APIENTRYP ",
)
)
for genOpts in buildList:
diag = open("gen.log", "w")
gen = COutputGenerator(errFile=sys.stderr, warnFile=sys.stderr, diagFile=diag)
reg = Registry()
tree = etree.parse(regFilename)
reg.loadElementTree(tree)
reg.setGenerator(gen)
reg.apiGen(genOpts)
diag.close()
17 changes: 17 additions & 0 deletions eng/silktouch/opengl/glcompat/generate.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@../settings.rsp
@../remap.rsp
--exclude
__gl_gl_h_
WIN32_LEAN_AND_MEAN
--file
opengl-gl.h
--methodClassName
GL
--namespace
Silk.NET.OpenGL
--output
../../../../sources/OpenGL/glcompat/gl
--test-output
../../../../tests/OpenGL/glcompat/gl
--traverse
../../../include/glcompat/gl.h
5 changes: 5 additions & 0 deletions eng/silktouch/opengl/glcompat/header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Ported from the OpenGL headers and corresponding dependencies.
// Original source is Copyright 2013-2020 The Khronos Group Inc. Licensed under the MIT license.
1 change: 1 addition & 0 deletions eng/silktouch/opengl/glcompat/opengl-gl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <glcompat/gl.h>
17 changes: 17 additions & 0 deletions eng/silktouch/opengl/glcore/generate.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@../settings.rsp
@../remap.rsp
--exclude
__gl_gl_h_
WIN32_LEAN_AND_MEAN
--file
opengl-gl.h
--methodClassName
GL
--namespace
Silk.NET.OpenGL
--output
../../../../sources/OpenGL/glcore/gl
--test-output
../../../../tests/OpenGL/glcore/gl
--traverse
../../../include/glcore/gl.h
5 changes: 5 additions & 0 deletions eng/silktouch/opengl/glcore/header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Ported from the OpenGL Core Profile headers and corresponding dependencies.
// Original source is Copyright 2013-2020 The Khronos Group Inc. Licensed under the MIT license.
1 change: 1 addition & 0 deletions eng/silktouch/opengl/glcore/opengl-gl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <glcore/gl.h>
17 changes: 17 additions & 0 deletions eng/silktouch/opengl/gles1/generate.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@../settings.rsp
@../remap.rsp
--exclude
__gles1_gl_h_
WIN32_LEAN_AND_MEAN
--file
opengl-gl.h
--methodClassName
GL
--namespace
Silk.NET.OpenGL
--output
../../../../sources/OpenGL/gles1/gl
--test-output
../../../../tests/OpenGL/gles1/gl
--traverse
../../../include/gles1/gl.h
5 changes: 5 additions & 0 deletions eng/silktouch/opengl/gles1/header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Ported from the OpenGLES 1.0 headers and corresponding dependencies.
// Original source is Copyright 2013-2020 The Khronos Group Inc. Licensed under the MIT license.
1 change: 1 addition & 0 deletions eng/silktouch/opengl/gles1/opengl-gl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <gles1/gl.h>
17 changes: 17 additions & 0 deletions eng/silktouch/opengl/gles2/generate.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@../settings.rsp
@../remap.rsp
--exclude
__gles2_gl_h_
WIN32_LEAN_AND_MEAN
--file
opengl-gl.h
--methodClassName
GL
--namespace
Silk.NET.OpenGL
--output
../../../../sources/OpenGL/gles2/gl
--test-output
../../../../tests/OpenGL/gles2/gl
--traverse
../../../include/gles2/gl.h
5 changes: 5 additions & 0 deletions eng/silktouch/opengl/gles2/header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Ported from the OpenGLES 2.0+ headers and corresponding dependencies.
// Original source is Copyright 2013-2020 The Khronos Group Inc. Licensed under the MIT license.
1 change: 1 addition & 0 deletions eng/silktouch/opengl/gles2/opengl-gl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <gles2/gl.h>
2 changes: 2 additions & 0 deletions eng/silktouch/opengl/remap.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--remap
TODO_ADD_REMAPPINGS=HERE
13 changes: 13 additions & 0 deletions eng/silktouch/opengl/settings.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@../../common.rsp
--define-macro
TODO_DEFINE_MACROS=HERE
--headerFile
header.txt
--include-directory
../../../submodules/opengl/api
../../../submodules/egl/api
../../../include
--with-callconv
*=Winapi
--with-librarypath
*=opengl
1 change: 1 addition & 0 deletions eng/submodules/egl
Submodule egl added at 5f2c71
1 change: 1 addition & 0 deletions eng/submodules/opengl
Submodule opengl added at 0ef89b
7 changes: 6 additions & 1 deletion sources/GLFW/Glfw.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ namespace Silk.NET.GLFW;

partial class Glfw(INativeContext nativeContext) : IDisposable
{
public partial class DllImport
{
static DllImport() => LoaderInterface.RegisterHook(Assembly.GetExecutingAssembly)
}

public partial class ThisThread : IGlfw.Static<ThisThread>
{
public static System.Threading.ThreadLocal<IGlfw> Underlying { get; } =
public static ThreadLocal<IGlfw> Underlying { get; } =
new(static () => new StaticWrapper<DllImport>());

public static void MakeCurrent(IGlfw ctx) => Underlying.Value = ctx;
Expand Down
27 changes: 27 additions & 0 deletions sources/OpenGL/GL.gen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Runtime.CompilerServices;
using Silk.NET.Core.Loader;

namespace Silk.NET.OpenGL;

partial class GL(INativeContext nativeContext) : IDisposable
{
public partial class DllImport
{
static DllImport() => LoaderInterface.RegisterHook(Assembly.GetExecutingAssembly)
}

public partial class ThisThread : IGL.Static<ThisThread>
{
public static ThreadLocal<IGL> Underlying { get; } =
new(static () => new StaticWrapper<DllImport>());

public static void MakeCurrent(IGL ctx) => Underlying.Value = ctx;
}

public static IGL Create() => new StaticWrapper<DllImport>();

public static IGL Create(INativeContext ctx) => new GL(ctx);

/// <inheritdoc/>
public void Dispose() => nativeContext.Dispose();
}
Loading

0 comments on commit 8c83c28

Please sign in to comment.