Skip to content

Commit

Permalink
graphics: add the whole glLoadGen
Browse files Browse the repository at this point in the history
alfonse (Jason L. McKesson) has disappeard from the face of
the internet and so his repositories. So it's better to add the version
of glLoadGen that I used.

Originally cloned from here;
 https://bitbucket.org/alfonse/glloadgen
  • Loading branch information
Hedede committed Apr 6, 2024
1 parent 6a0d664 commit e24a0d1
Show file tree
Hide file tree
Showing 69 changed files with 132,274 additions and 0 deletions.
21 changes: 21 additions & 0 deletions graphics/glloadgen/Changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

## Version 2.0.3
* Supports OpenGL 4.5 and recent extensions.
* Adds `-geninfo` option, for creating comments in generated files about how it was generated.
* Issue #50 fixed: LFS file loading.
* Issue #29 fixed: Errors in MacOSX compilation.
* Issue #61 fixed:
* Fixed IsVersionGEQ bug in multiple styles.
* Issued #59 fixed: Working directory can be something other than the glLoadGen directory.
* C-based styles now conform to C expectations in comments and empty parameter lists.

## Version 1.0:
* New Noload loader. Works like GLee.
* -stdext now works relative to the extfiles directory, not just LoadGen. So no need to do -stdext=extfiles/gl_name_of_standard_file.txt.
* A test suite.
* Lua Filesystem is now in use; if it's not available, then you must create the destination directory yourself.

## Version 0.3:
* Replaced the old generation system with a flexible structure system.
* Migrated the styles to the structure system.

79 changes: 79 additions & 0 deletions graphics/glloadgen/GenTests.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

local prelims =
{
[[lua $<dir>MakeAllExts.lua -spec=gl $<dir>allgl.txt]],
[[lua $<dir>MakeAllExts.lua -spec=wgl $<dir>allwgl.txt]],
[[lua $<dir>MakeAllExts.lua -spec=glX $<dir>allglx.txt]],
}

local tests =
{
[[lua $<dir>LoadGen.lua -spec=gl -version=max -profile=core -style=pointer_cpp -stdext=gl_ubiquitous.txt $<dir>test/ptr_cpp/test]],
[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=core -style=pointer_c -stdext=gl_ubiquitous.txt $<dir>test/ptr_c/test]],
[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=core -style=func_cpp -stdext=gl_ubiquitous.txt $<dir>test/func_cpp/test]],
[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=compatibility -style=pointer_cpp -stdext=gl_ubiquitous.txt $<dir>test/ptr_cpp_comp/test]],
[[lua $<dir>LoadGen.lua -spec=gl -version=2.1 -style=func_cpp -stdext=gl_ubiquitous.txt $<dir>test/func_cpp_comp/test]],
[[lua $<dir>LoadGen.lua -spec=gl -version=4.4 -profile=compatibility -style=pointer_c -stdext=gl_ubiquitous.txt $<dir>test/ptr_c_comp/test]],
[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=compatibility -style=noload_cpp -stdext=gl_ubiquitous.txt $<dir>test/noload_cpp/test]],
[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=compatibility -style=noload_cpp $<dir>test/noload_cpp_noext/test]],
[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=core -style=noload_c -stdext=gl_ubiquitous.txt $<dir>test/noload_c/test]],
[[lua $<dir>LoadGen.lua -spec=gl -version=2.1 -style=noload_c -stdext=gl_ubiquitous.txt $<dir>test/noload_c_old/test]],
[[lua $<dir>LoadGen.lua -spec=gl -version=3.3 -profile=compatibility -style=noload_c $<dir>test/noload_c_noext/test]],
}

local platTests =
{
wgl =
{
[[lua $<dir>LoadGen.lua -spec=wgl -style=pointer_cpp -stdext=wgl_common.txt $<dir>test/ptr_cpp/test]],
[[lua $<dir>LoadGen.lua -spec=wgl -style=pointer_c -stdext=wgl_common.txt $<dir>test/ptr_c/test]],
[[lua $<dir>LoadGen.lua -spec=wgl -style=func_cpp -stdext=wgl_common.txt $<dir>test/func_cpp/test]],
[[lua $<dir>LoadGen.lua -spec=wgl -style=pointer_cpp -stdext=wgl_common.txt $<dir>test/ptr_cpp_comp/test]],
[[lua $<dir>LoadGen.lua -spec=wgl -style=func_cpp -stdext=wgl_common.txt $<dir>test/func_cpp_comp/test]],
[[lua $<dir>LoadGen.lua -spec=wgl -style=pointer_c -stdext=wgl_common.txt $<dir>test/ptr_c_comp/test]],
[[lua $<dir>LoadGen.lua -spec=wgl -style=noload_cpp -stdext=wgl_common.txt $<dir>test/noload_cpp/test]],
[[lua $<dir>LoadGen.lua -spec=wgl -style=noload_cpp -stdext=wgl_common.txt $<dir>test/noload_cpp_noext/test]],
[[lua $<dir>LoadGen.lua -spec=wgl -style=noload_c -stdext=wgl_common.txt $<dir>test/noload_c/test]],
[[lua $<dir>LoadGen.lua -spec=wgl -style=noload_c -stdext=wgl_common.txt $<dir>test/noload_c_old/test]],
[[lua $<dir>LoadGen.lua -spec=wgl -style=noload_c $<dir>test/noload_c_noext/test]],
},

glX =
{
[[lua $<dir>LoadGen.lua -spec=glX -style=pointer_cpp -extfile=allglx.txt $<dir>test/ptr_cpp/test]],
[[lua $<dir>LoadGen.lua -spec=glX -style=pointer_c -stdext=glx_common.txt $<dir>test/ptr_c/test]],
[[lua $<dir>LoadGen.lua -spec=glX -style=func_cpp -stdext=glx_common.txt $<dir>test/func_cpp/test]],
[[lua $<dir>LoadGen.lua -spec=glX -style=pointer_cpp -stdext=glx_common.txt $<dir>test/ptr_cpp_comp/test]],
[[lua $<dir>LoadGen.lua -spec=glX -style=func_cpp -stdext=glx_common.txt $<dir>test/func_cpp_comp/test]],
[[lua $<dir>LoadGen.lua -spec=glX -style=pointer_c -stdext=glx_common.txt $<dir>test/ptr_c_comp/test]],
[[lua $<dir>LoadGen.lua -spec=glX -style=noload_cpp -stdext=glx_common.txt $<dir>test/noload_cpp/test]],
[[lua $<dir>LoadGen.lua -spec=glX -style=noload_cpp -stdext=glx_common.txt $<dir>test/noload_cpp_noext/test]],
[[lua $<dir>LoadGen.lua -spec=glX -style=noload_c -stdext=glx_common.txt $<dir>test/noload_c/test]],
[[lua $<dir>LoadGen.lua -spec=glX -style=noload_c -stdext=glx_common.txt $<dir>test/noload_c_old/test]],
[[lua $<dir>LoadGen.lua -spec=glX -style=noload_c $<dir>test/noload_c_noext/test]],
},
}

local glXTests = {}

local baseDir = arg[0]:match("^(.*[\\/])")
baseDir = baseDir or "./"

local function ExecTests(testList)
for _, test in ipairs(testList) do
test = test:gsub("%$<dir>", baseDir)
print(test)
os.execute(test)
end
end

if(arg[1]) then
assert(platTests[arg[1]], "Invalid platform " .. arg[1])
end

ExecTests(prelims)
ExecTests(tests)
if(arg[1]) then
ExecTests(platTests[arg[1]])
end

22 changes: 22 additions & 0 deletions graphics/glloadgen/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Copyright (C) 2011-2015 by Jason L. McKesson

The source code in this distribution is licensed under the terms of the MIT license, as stated below. The source code generated by this tool is yours to do with as you will.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
65 changes: 65 additions & 0 deletions graphics/glloadgen/LoadGen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
assert(arg and arg[0], "You ran this script incorrectly.")

--Get the location of our modules relative to here.
local baseDir = arg[0]:match("^(.*[\\/])")
baseDir = baseDir or "./"
assert(baseDir, arg[0] .. " No directory")

--Fixup the package path to be relative to this directory.
package.path = baseDir .. "modules/?.lua;" .. package.path

--Make a function to get the correct directory name.
function SysRelPath(relativePath)
return baseDir .. relativePath
end
FixupPath = SysRelPath --Older name.

local opts = require "GetOptions"
local Specs = require "Specs"
local Styles = require "Styles"
local LoadSpec = require "LoadLuaSpec"
local util = require "util"

--Get the options.
local status, options = pcall(opts.GetOptions, arg)

if(not status) then
io.stdout:write(options, "\n")
return
end

--Load the spec data.
local spec = Specs.GetSpec(options.spec)
local specData = spec.LoadSpec()

--Verify that every extension in `options.extensions` is a real extension.
local badExts = {}
for _, extName in ipairs(options.extensions) do
if(not specData.extdefs[extName]) then
badExts[#badExts + 1] = extName
end
end

if(#badExts > 0) then
io.stdout:write("The following extensions are not in the spec ", options.spec, ":\n")
for _, extName in ipairs(badExts) do
io.stdout:write("\t", extName, "\n")
end
return
end

--Extract the path and base-filename from the filename.
local simplename, dir = util.ParsePath(options.outname)
dir = dir or "./"

assert(simplename,
"There is no filename in the path '" .. options.outname .. "'")

local style, structure = Styles.GetStyle(options.style)

--Compute the filename, minus style-specific suffix.
local basename = dir .. spec:FilePrefix() .. simplename

structure.Proc(basename, style, specData, spec, options)


72 changes: 72 additions & 0 deletions graphics/glloadgen/MakeAllExts.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
assert(arg and arg[0], "You ran this script incorrectly.")

--Get the location of our modules relative to here.
local baseDir = arg[0]:match("^(.*[\\/])")
baseDir = baseDir or "./"

--Fixup the package path to be relative to this directory.
package.path = baseDir .. "modules/?.lua;" .. package.path

--Make a function to get the correct directory name.
function SysRelPath(relativePath)
return baseDir .. relativePath
end
FixupPath = SysRelPath --Older name.

local cmd = require "CmdLineOptions"
local Specs = require "Specs"

local parseOpts = cmd.CreateOptionGroup()
parseOpts:enum(
"spec",
"spec",
"Specification to use.",
{"gl", "glX", "wgl"})
parseOpts:pos_opt(
1,
"outname",
"Output filename to generate.",
"outname")

local options, pos_args = parseOpts:ProcessCmdLine(arg)

local dups = {}
local exts = {}

local spec = Specs.GetSpec(options.spec)
local specData = spec.LoadSpec()

local coreExts = spec.GetCoreExts()

for _, version in ipairs(specData.versions or {}) do
if(coreExts[version]) then
for _, extName in ipairs(coreExts[version]) do
if(not dups[extName]) then
exts[#exts + 1] = extName
dups[extName] = true
end
end
end
end

local sortExts = {}

for _, extName in ipairs(specData.extensions) do
if(not dups[extName]) then
sortExts[#sortExts + 1] = extName
dups[extName] = true
end
end

table.sort(sortExts)

local hFile = io.open(options.outname, "w")
for _, extName in ipairs(exts) do
hFile:write(extName, "\n")
end
for _, extName in ipairs(sortExts) do
hFile:write(extName, "\n")
end
hFile:close()


24 changes: 24 additions & 0 deletions graphics/glloadgen/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
glLoadGenerator, version 2.0.3


Please see the documentation available on the web at https://bitbucket.org/alfonse/glloadgen/wiki/Home for detailed information on how to use this software.

The license for this distribution is available in the `License.txt` file.


Usage
-----

This loader generation system is used to create OpenGL headers and loading code for your specific needs. Rather than getting every extension and core enumerator/function all in one massive header, you get only what you actually want and ask for.

The scripts in this package are licensed under the terms of the MIT License. You will need to have Lua installed for this to work.

To use the code generator, with Lua in your path (assuming that "lua" is the name of your Lua executable), type this:

lua LoadGen.lua -style=pointer_c -spec=gl -version=3.3 -profile=core core_3_3

This tells the system to generate a header/source pair for OpenGL ("-spec=gl", as opposed to WGL or GLX), for version 3.3, the core profile. It will generate it in the "pointer_c" style, which means that it will use function pointer-style, with C linkage and source files. Such code is usable from C and C++, or other languages that can interface with C.

The option "core_3_3" is the basic component of the filename that will be used for the generation. Since it is generating OpenGL loaders (again, as opposed to WGL or GLX), it will generate files named "gl_core_3_3.*", where * is the extension used by the particular style.

The above command line will generate "gl_core_3_3.h" and "gl_core_3_3.c" files. Simply include them in your project; there is no library to build, no unresolved extenals to filter through. They just work.
21 changes: 21 additions & 0 deletions graphics/glloadgen/_FindFileInPath.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

require("ex")
require "ufs"

function FindFileInPath(filename)
local path = ex.getenv("PATH");

for pathname in path:gmatch("([^%;%\"]+)%;?") do
pathname = ufs.path(pathname);

local testName = pathname / filename;

if(ufs.exists(testName)) then
return tostring(testName);
end
end

return nil;
end


Loading

0 comments on commit e24a0d1

Please sign in to comment.