Commit graph

555 commits

Author SHA1 Message Date
thefiddler
af16be42d5 Corrected Parameter.IsEnum property 2013-11-11 10:00:54 +01:00
thefiddler
dde7c645c4 Removed unused code 2013-11-11 10:00:32 +01:00
Stefanos A.
d0e025b86d Restrict convenience overloads
Only Get*, Gen*, Delete* and New* functions get convenience overloads.
This avoids issues with functions such as Rect() that have similar
signatures but cannot use such overloads.

This restriction will be relaxed in the future.
2013-11-10 19:03:49 +01:00
Stefanos A.
293c020151 Added WrapperTypes.ConvenienceArrayType
These are convenience parameters for function receiving a size and an
array parameter, like DeleteTextures(int n, int[] ids). The generator
will now add overloads taking a single parameter, such as
DeleteTexture(int id).
2013-11-10 18:29:53 +01:00
Stefanos A.
af7fdea449 Return types must be cls-compliant
CreateCLSCompliantWrappers must always change return types into
cls-compliant types. The reason is that we cannot overload on return
type alone, so we should always choose the compliant version.
2013-11-10 15:35:47 +01:00
Stefanos A.
6098fa05ce Plural name to singular in convenience overloads 2013-11-10 10:16:47 +01:00
Stefanos A.
11c1071625 Corrected declarations in convenience overloads 2013-11-10 10:08:04 +01:00
Stefanos A.
089c108ea0 Corrected indentation 2013-11-10 09:20:54 +01:00
Stefanos A.
c1cb70d215 Improve indentation for doc comments
Doc comments are now split at their source, as a first step in
normalizing their indentation between VS and MD.
2013-11-10 09:12:42 +01:00
thefiddler
d126d25215 Add helper overload generation
Functions returning a value or array via an 'out' parameter will now get a convenience overload that returns the result via a return statement. In the case of arrays, only single-valued arrays will be supported. For example:

void GetIntegerv(enum pname, out int value)

will be get an overload of

int GetIntegerv(enum pname)

This will reduce the amount of helper overloads that must be maintained manually in GLHelpers.cs.
2013-11-10 08:28:58 +01:00
thefiddler
0d73706c88 Added new WrapperTypes; removed unused code
New WrapperTypes for convenience functions: ConvenienceReturnType to
replace an "out" parameter by a return value, and
ConvenienceArrayReturnType to replace an out array parameter by a
single return value (array count of 1 only).
2013-11-09 19:24:43 +01:00
thefiddler
417aa67139 Implemented Add and AddRange methods
These supplant the static Utilities.Merge() overloads.
2013-11-09 19:22:31 +01:00
Stefanos A
49df5ff453 Do not generate delegates for overloads
We should only generate delegates for actual OpenGL entry points, not
for overloaded functions that resolve to the same entry point. This
improves loading speeds and reduces the size of the compiled dll.
2013-11-08 16:40:43 +01:00
Stefanos A
7ab5e3ab6c Use paths without apiversion attribute
Paths that don't define a "version" attribute will now match all
possible versions. This will make it easier to add support for newer
APIs as they are introduced.
2013-11-07 16:48:11 +01:00
Stefanos A
1f6d445021 Removed non-existent token from OpenGL
COMPRESSED_ALPHA_BPTC_UNORM does not appear to be defined anywhere.
Removed.
2013-11-07 16:46:38 +01:00
Stefanos A
be8f7c6311 Corrected ES 2.0 enums
After the previous commit, several ES 2.0 functions would refer to
enums found in ES 3.0. These enums have been copied to ES 2.0, either
as core enums or as extensions.
2013-11-07 16:25:19 +01:00
Stefanos A
735d05e496 Merged ES2.0 and ES3.0 replacements
ES 3.0 includes ES 2.0 verbatim. We can significantly reduce
duplication by using the same <replace> node for both APIs. Note that
the enumerations must remain separate, as ES 2.0 and 3.0 support
different tokens.
2013-11-07 11:37:51 +01:00
Stefanos A
7c54a19708 ES 3.0 fixed enums for GetIntegeri_v and GetInteger64i_v
These functions have a first parameter named "target", not "pname".
Fixed now.
2013-11-07 10:58:02 +01:00
Stefanos A
e59c95f2f9 ES 3.0 fixed enums for GetInteger64*
GetInteger64v should accept GetPName, while GetInteger64i_v should
accept GetIndexedPName.
2013-11-07 10:39:20 +01:00
Stefanos A
8de24c97fb ES 3.0 strong enums for DrawBuffersEXT and NV
Relax the extension constraint in DrawBuffers, in order to add strong
enums to the extension varieties of this function.
2013-11-07 10:33:02 +01:00
Stefanos A
2d1df46d98 ES 3.0 strong enums for DrawArrays*() and Draw*Elements*()
The strongly-typed enums include core and extension varieties.
2013-11-07 10:17:33 +01:00
Stefanos A
0002b2e23e Fixed typo in ES3Generator.cs
The DllImports file should be named ES30Core.cs, not ES3Core.cs. Fixed
now.
2013-11-07 10:09:17 +01:00
Stefanos A
0f98f0e00b Fixed misspelled and missing enums 2013-11-07 09:47:27 +01:00
Stefanos A
93b8d4b86e Fixed enums for (Get)ObjectLabel
ObjectLabel and GetObjectLabel are part of KHR_debug.
2013-11-07 09:34:48 +01:00
Stefanos A
0598e02140 Fixed enums for GetDebugMessageLog
GetDebugMessageLog was misspelled as GetMessageDebugLog. This is now
fixed.
2013-11-07 08:39:57 +01:00
Stefanos A
de38df8820 Fixed strong-enums for GetDebugMessageLog
GetDebugMessageLog is part of KHR_debug.
2013-11-07 08:36:23 +01:00
Stefanos A
a2f2ab29ea Fixes for ES 3.0 strongly-typed enums
Fixed parameter mismatches in CopyBufferSubData and BlendFuncSeparate.
Implemented KHR_debug extension.
2013-11-07 08:33:17 +01:00
Stefanos A
2b4d10ffd7 Strongly-typed enums for ES 3.0 (complete)
Implemented sectiosn: Pixel Rectangles. Binding & Managing Framebuffer
Objects, Renderbuffer Objects, Attaching Renderbuffer Images to
Framebuffer, Attaching Texture Images to Framebuffer, Framebuffer
Completeness, Invaildating Framebuffer Contents, Renderbuffer Object
Queries, Simple Queries, String Queries.
2013-11-07 08:14:49 +01:00
Stefanos A
1a02457ddc Strongly-typed enums for ES 3.0 (WIP8)
Implemented sections: Hints and Sync Object Quries.
Renamed SyncParameter to SyncParameterName, as per the OpenGL naming
conventions.
2013-11-05 10:23:25 +01:00
Stefanos A
167c97dd84 Strongly-typed enums for ES 3.0 (WIP7)
Implemented section: Sync Objects and Fences [5.2].
Fixed desktop OpenGL wrapper for ClientWaitSync and FenceSync.
2013-11-05 09:53:34 +01:00
Stefanos A
2511cb1086 Implemented support for <overload> element
The <overload> element simplifies the addition of overloads for
backwards compatibility. It is defined similar to the <replace>
element, but instead of replacing the parameters of a function
in-place, it adds a new overload and modifies the overload instead.
2013-11-05 08:55:52 +01:00
Stefanos A
25b9939263 Strongly-typed enums for ES 3.0 (WIP6)
Implemented strongly-typed enums for sections: Selecting a Buffer for
Writing, Fine Control of Buffer Updates, Clearing the Buffers.
2013-11-04 23:25:02 +01:00
Stefanos A
372dac9c48 Strongly-typed enums for ES 3.0 (WIP5)
Implemented sections: Stencil Test, Depth Buffer Test, Blending.
2013-11-04 23:01:25 +01:00
Stefanos A
dcd2d03e59 Strongly-typed enums for ES 3.0 (WIP4)
Implemented sections: Texture Image Specification, Alternative Texture
Image Specification, Compressed Texture Images, Texture Parameters,
Manual Mipmap Generation and Enumerated Queries.
2013-11-04 22:27:06 +01:00
Stefanos A
6921509680 Added "reuse" directive for enums
Sometimes an enum may reuse the tokens of another enum verbatim
(possibly adding a few extra tokens.) The reuse directive simplifies
the handling of this case:
<enum name="Foo">
  <reuse enum="Bar" />
</enum>
2013-11-04 22:26:06 +01:00
Stefanos A
20e70062f8 Strongly-typed enums for ES 3.0 (WIP3)
Implemented sections: Texturing, Sampler Objects, Sampler Queries,
Texture Image Specification.
2013-11-04 19:49:25 +01:00
Stefanos A
b29a4aacb3 Respect apiversion in overrides
We should not use overrides from foreign apiversions.
2013-11-04 19:32:52 +01:00
Stefanos A
9b5be9300b Strongly-typed enums for ES 3.0 (WIP2)
Added strongly-typed enums for sections: Vertices, Shaders and
Programs. Added a number of missing enums for ES 2.0. Normalized
several APIs between OpenGL and OpenGL ES.
2013-11-04 00:04:09 +01:00
Stefanos A
af78a01643 Strongly-typed enums for ES 3.0 (WIP)
Implemented strongly-typed enums for sections: Buffer Objects,
Asynchronous Queries, Transform Feedback, ReadingandCopying Pixels and
Rasterization.
2013-11-03 21:30:25 +01:00
Stefanos A
f95925302b No extension attribute now matches all extensions
This allows us to reduce the amount of clutter in overrides.xml.
2013-11-03 21:28:24 +01:00
Stefanos A
7978627ad4 Merge Delegate.Version
When a Delegate is defined multiple times in the spec, we should check
if any of these definitions contains a proper Delegate.Version and
store that. This improves the self-documentation aspect of the bindings.
2013-11-03 20:41:29 +01:00
Stefanos A
7322828304 Regenerated the bindings using the latest specs 2013-11-03 20:36:22 +01:00
Stefanos A
2ca8870420 More PrimitiveType->BeginMode overrides 2013-11-03 20:35:02 +01:00
Stefanos A
c47166e54d Mino fix in debug output
ParameterCollection.ToString() adds parentheses around its output, so
Delegate.ToString() should avoid adding a second pair.
2013-11-03 20:34:18 +01:00
Stefanos A
451bd62f63 ES 3.0 contains both 2.0 and 3.0 bindings
This is in accordance to the upstream gl3.h for ES 3.0.
2013-11-03 20:33:14 +01:00
Stefanos A
d20180cd2d gles1 API contains both versions 1.0 and 1.1
Khronos no longer distinguishes between ES 1.0 and 1.1.
2013-11-03 20:32:47 +01:00
Stefanos A
922fb935a1 Take api version into account
XmlSpecReader will now respect version attributes and will avoid
inserting foreign tokens into the generated bindings.
2013-11-03 20:32:10 +01:00
Stefanos A
2d33b10e1a Improve debug output
Function parameters are now displayed during binding generation.
2013-11-03 20:28:57 +01:00
Stefanos A.
35c0edfa42 Merge categories for redefined functions
Now that we support function overloads, it is safe to ignore functions
that are defined multiple times. We just merge their Category
properties if they are not identical.
2013-11-03 19:13:49 +01:00
Stefanos A
346547331a Improved detection of deprecated tokens 2013-11-03 17:58:28 +01:00
Stefanos A.
6f08995963 Added PrimitiveType <=> BeginMode overloads
Khronos renamed BeginMode to PrimitiveType starting with GL 4.4.
OpenTK now has overloads for both flavors.
2013-11-03 16:11:39 +01:00
Stefanos A.
9789225e0c Allow overloads of the same function
It is now possible to define multiple overloads of the same function,
each with different parameters. This is extremely useful for
maintaining backwards compatibility in the face of the changes between
GL 4.3 and 4.4.
2013-11-03 16:09:11 +01:00
Stefanos A
60f971ffed Updated to the latest gl4 specs and docs
Large code-drop from Khronos upstream.
2013-11-03 12:43:50 +01:00
Stefanos A
ec6c534d8a Updated using the latest converter
Tokens are now sorted according to their value, exactly is in the
upstream gl.xml spec. Additionally, gles1 and gles2 now include the
pre-defined groups in the specification.
2013-11-03 12:32:54 +01:00
Stefanos A.
a29e132172 Trim elements when reading them
Sometimes elements in overrides.xml contain extra spaces due to typos,
which are quite difficult to track down. The XmlSpecReader can now
cope with that.
2013-11-03 12:17:09 +01:00
Stefanos A.
513fa728d0 Replace in-place instead of removing/readding
There is no reason to remove and readd a Constant in order to replace
it in a ConstantCollection. We can actually do that in-place.
2013-11-03 12:16:07 +01:00
Stefanos A.
39b1f84fc8 Enum tokens are now sorted
This only affects the in-memory representation - sorted tokens are
easier to debug.
2013-11-03 12:15:08 +01:00
Stefanos A.
827fe0788a Use OpenTK.Graphics.OpenGL4 namespace for GL4.x 2013-11-03 12:14:13 +01:00
Stefanos A.
c83d6ad530 DefaultOutputPath now matches OpenTK source tree
By default, generated bindings are placed in the source tree of
OpenTK. This can be overriden via a commandline switch.
2013-11-03 12:13:35 +01:00
Stefanos A.
0548806487 Improved debug output on high-order pointers
OpenTK does not currently support generating bindings for pointers of
order 3 or higher. No OpenGL or OpenGL ES API currently uses such
pointers, so we just issue a warning message if such an API is
encountered in the future.
2013-11-03 12:12:39 +01:00
Stefanos A.
2d3b5ebe5c Added missing enums to gles2 profile
Fixed undefined reference in TextureCompareMode.COMPARE_REF_TO_TEXTURE
and added strongly-typed enums for KHR_debug.
2013-11-03 12:10:52 +01:00
Stefanos A.
7a403e474e Corrected ShaderSource for gles2 and ARB
The length parameter should be an array of integers, one for each
string in the shader source. The string parameter does not need to be
translated.
2013-11-03 02:25:15 +01:00
Stefanos A
888cb6637b Added generators for ES 2.0 and 3.0 2013-11-03 01:29:32 +01:00
Stefanos A
66b01873b0 Updated license information 2013-11-03 01:28:46 +01:00
Stefanos A
c349c82887 Cleaned up the generator constructors 2013-11-03 01:28:01 +01:00
Stefanos A
ab61e3f6a0 Added missing newline
Methods are now separated by a single newline.
2013-11-03 01:27:33 +01:00
Stefanos A
e8f46c87f6 Do not override user defined output files
The generator will now change the default output files to match its
bindings (e.g. GL vs ES), but the user is now able to override this
option.
2013-11-03 01:27:10 +01:00
Stefanos A
5ab8b451c9 Added apiversion support 2013-11-03 01:25:47 +01:00
Stefanos A
5298aff14d Added support for overriding default output files
This makes it possible to generate different output files when using
-mode:all to generate multiple bindings in the same run.
2013-11-03 01:25:27 +01:00
Stefanos A
23c084587a Added gles2; added missing fog groups 2013-11-03 01:24:31 +01:00
Stefanos A
56768a803a Added support for distinguishing between api versions
The registry reuses the "gles2" apiname for both OpenGL ES 2.0 and 3.0.
The generator will now use the apiversion attribute to distinguish
between the two APIs.
2013-11-03 01:24:02 +01:00
Stefanos A
c5b9dbc83e Added GetOverridesPath method
GetOverridesPath encapsulates the code that retrieves an override enum
or function from overrides.xml. Additionally, it now supports names and
extensions with multiple values (e.g. extension="Core|Ext").
2013-11-03 01:20:17 +01:00
Stefanos A.
add848f32d Fixed newline and indentation behavior
Mono and .Net have a few minor differences in their StreamWriter
implementations. Added workarounds to produce identical output on all
platforms.
2013-11-01 14:00:46 +01:00
Stefanos A.
b7f2379f87 Fixed infinite recursion issue. 2013-11-01 11:42:42 +01:00
Stefanos A.
9e74470e58 Avoid singletons; allow -mode:all
Explicit Settings objects are now created for each generator. A new
-mode:all option has been added, which generates bindings for all APIs
in one go (useful for the post-GL4.4 specs, which collect all APIs in a
single file.)
2013-11-01 09:28:54 +01:00
Stefanos A.
bf0f42be82 Avoid singletons; collect code generation
ISpecWriter implementations must now store explicit references to a
Settings object. Additionally, all code generation is now handled inside
the ISpecWriter implementation (it used to be scattered over all Type,
Parameter, etc classes resulting in unmaintainable spaghetti code.)
2013-11-01 09:27:46 +01:00
Stefanos A.
33e6a6eae2 Avoid singletons
A reference to a Settings instance must now be stored explicitly.
2013-11-01 09:26:13 +01:00
Stefanos A.
e1f064b634 Updated IBind implementations to avoid singletons
IBind implementations must now store explicit references to Settings,
GLTypes and CSTypes instances. This allows us to use multiple
configurations in the same process.
2013-11-01 09:25:31 +01:00
Stefanos A.
8219f7a0f6 Avoid singletons; collect all translation logic
FuncProcessor now implements all translation logic for types, parameters
and functions. This used to be scattered in the various classes (Type,
Parameter, etc) resulting in a rather disgusting spaghetti. Code
generation has been removed from FuncProcessor and is now handled by the
various language-specific ISpecWriter backends.
2013-11-01 09:24:18 +01:00
Stefanos A.
f0e0195799 Avoid singletons; improve ToString()
This is part of a long-due series of source cleanup patches. ToString()
is no longer used for code generation (code generation is handled by an
ISpecWriter instance.) Enum is no longer public. EnumCollection now
exposes its backing store through an interface, rather than a concrete
class (simpler to change backing store in the future.)
2013-11-01 09:21:50 +01:00
Stefanos A.
229856abba Avoid singletons; improved ToString()
This is part of a long-due series of source cleanup patches. ToString()
is no longer used for code generation (this is handled by an ISpecWriter
implementation). This class is no longer public.
2013-11-01 09:18:53 +01:00
Stefanos A.
679afcc27a Avoid singletons; logic in FuncProcessor
This is part of a long-due series of source cleanup patches. All
translation logic is now part of FuncProcessor. Code generation is now
handled by an ISpecWriter implementation. Minor improvements to
IEquatable and ToString() implementations. Reduced the surface of the
public API.
2013-11-01 09:17:34 +01:00
Stefanos A.
9c5d43b72b Avoid singletons; Move logic to FuncProcessor
This is part of a long-due cleanup patch series. All translation logic
is now part of the FuncProcessor. Language-specific code generation is
now part of the ISpecWriter, not the delegate class. Implemented the
IEquatable interface.
2013-11-01 09:15:02 +01:00
Stefanos A.
f83443d221 Avoid singletons; Translate*() in FuncProcessor
This is part of a long-due source cleanup series. All Translate*()
methods are now part of the FuncProcessor. Additionally, ToString() has
been improved and the IEquatable interface is now implemented.
ParameterCollection now has better control of when its cache should be
rebuilt.
2013-11-01 09:13:06 +01:00
Stefanos A.
83c0deb71c Avoid singletons; Translate*() in FuncProcessor
This is part of a long-due source cleanup operation. GLTypes and CSTypes
are no longer global singletons, but must now be accessed through an
IBind instance. All Translate*() methods are now part of the
FuncProcessor. ToString() has been improved and the IEquatable interface
is now explicitly implemented.
2013-11-01 09:10:46 +01:00
Stefanos A.
832db0da0d Settings is no longer a singleton
Multiple Settings instances can now be created and used in the same
process.
2013-11-01 09:07:34 +01:00
Stefanos A.
ffc79a749b Settings, GLTypes and CSTypes are now in IBind
Settings, GLTypes and CSTypes are no longer global singletons. Instead,
explicit instances must be stored in the IBind implementation. This
allows us to use multiple configurations in the same process.
2013-11-01 09:06:49 +01:00
Stefanos A.
f000bda891 Avoid singleton Settings; make internal
Utilities.Keywords now accepts an explicit parameter, instead of
accessing Settings directly. This allows us to use multiple
configurations in the same process.

Additionally, the Utilities class is no longer public (the Bind project
is not meant to be consumed as a dll.)
2013-11-01 09:03:36 +01:00
Stefanos A.
f00c2e0527 Avoid singleton Settings. Allow v1 signatures
A Settings object is now passed directly as a parameter, in order to
support different configurations in the same process. The XmlSpecReader
can now distinguish between, and support both, pre-GL4.4 and post-GL4.4
specs.
2013-11-01 09:01:35 +01:00
Stefanos A.
2eac75ea4d Avoid using singletons
The IBind generator and the Settings class are now passed directly as
parameters. This allows us to run multiple generators in a single
process.
2013-11-01 08:59:20 +01:00
Stefanos A.
6022ea9fbd Improved multiline output
This lets us compose and print multiline strings without manually
adjusting indentation on each line.
2013-11-01 08:57:44 +01:00
Stefanos A.
97bd6dbc39 Warn on function redefinition
A function redefinition usually stems from a bug in the OpenGL specs, or
a bug in the spec converter. The binding generator now logs a warning,
instead of crashing, when a redefinition is encountered.
2013-10-31 00:20:05 +01:00
Stefanos A.
285f238669 Renamed gloverrides.xml to overrides.xml
This aligns the name of the OpenGL overrides file with that of the
OpenGL|ES implementations.
2013-10-31 00:18:45 +01:00
Stefanos A.
a3bd227e20 Cleaned up Generator class tree
This significantly reduces the amount of duplicated code between
Generator implementations.
2013-10-31 00:18:07 +01:00
Stefanos A.
784d60b556 Corrected apiname xpath lookup 2013-10-29 09:32:28 +01:00
Stefanos A.
6185059adc More line ending troubles... 2013-10-28 14:28:57 +01:00
Stefanos A
7f9041417e Add apiname parameter to ISpecReader
This allows us to reuse the same ISpecReader implementation to parse
different APIs (GL and GLES).
2013-10-28 14:13:39 +01:00
Stefanos A.
2e435f97bb Re-added PixelInternalFormat
GL4.4 renamed PixelInternalFormat to InternalFormat. The missing tokens
are now re-added, since a lot of functions depend on them. Additionally,
a number of 'open' <use> elements now define a specific enum reference.
This is not necessary, but is good for documentation purposes.
2013-10-28 14:11:16 +01:00
Stefanos A.
6f4530f8a8 Sort tokens within an enum
This allows us to keep a specific ordering regardless of the token order
in the input file (much friendlier for source control!)
2013-10-28 14:08:55 +01:00
Stefanos A.
1b937b48f8 Simplifed Constant.Reference resolution
Instead of recursing, we use a simple do..while loop to resolve the
transitive reference of a constant. If there is a loop at any point, we
stop and use a brute force search over all tokens. If this still fails
to resolve the reference, then we report this reference as unresolved.
2013-10-28 14:07:45 +01:00