Skip to content

Commit

Permalink
Correct glGetString return type (see KhronosGroup/OpenGL-Registry#363
Browse files Browse the repository at this point in the history
…for reference)
  • Loading branch information
heisluft committed Jul 13, 2021
1 parent adafb80 commit 35ab94c
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/main/java/de/heisluft/devtools/boglgen/HeaderGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,23 @@ public static void main(String[] args) throws Exception {
if (!reqFuncs.contains(funName)) return;
Node firstChild = proto.getFirstChild();
StringBuilder b = new StringBuilder(" public static function ");
if (firstChild instanceof Text) {
String text = firstChild.getNodeValue();
if (text.startsWith("const ")) text = text.substring(5);
int mod = text.endsWith("*") ? 1 : 0;
b.append(text).delete(b.length() - 1 - mod, b.length() - mod);
}
NodeList pTypeList = proto.getElementsByTagName("ptype");
if (pTypeList.getLength() != 0) {
Node ptype = pTypeList.item(0);
b.append(transformType(ptype.getFirstChild().getNodeValue()));
if (ptype.getNextSibling() instanceof Text && !ptype.getNextSibling().getNodeValue().isBlank())
b.append(ptype.getNextSibling().getNodeValue().replace(" ", ""));
//See https://github.com/KhronosGroup/OpenGL-Registry/issues/363
if("glGetString".equals(funName) || "glGetStringi".equals(funName)) {
b.append("char8*");
} else {
if (firstChild instanceof Text) {
String text = firstChild.getNodeValue();
if (text.startsWith("const ")) text = text.substring(5);
int mod = text.endsWith("*") ? 1 : 0;
b.append(text).delete(b.length() - 1 - mod, b.length() - mod);
}
NodeList pTypeList = proto.getElementsByTagName("ptype");
if (pTypeList.getLength() != 0) {
Node ptype = pTypeList.item(0);
b.append(transformType(ptype.getFirstChild().getNodeValue()));
if (ptype.getNextSibling() instanceof Text && !ptype.getNextSibling().getNodeValue().isBlank())
b.append(ptype.getNextSibling().getNodeValue().replace(" ", ""));
}
}
b.append("(");
forEachElement(commandNode.getElementsByTagName("param"), paramNode -> {
Expand Down Expand Up @@ -308,7 +313,7 @@ public static void main(String[] args) throws Exception {
reqFuncs.forEach(reqFunc -> lines.add(" " + reqFunc + " = (.)func(\"" + reqFunc + "\");"));
if(generateExtensionBooleans && foundExtensions.size() != 0) {
lines.add("\n for(uint i = 0; i < (.) *glGetIntegerv(.GL_NUM_EXTENSIONS, .. &(scope int[1])[0]); i++) {");
lines.add(" StringView currentExt = StringView((char8*) glGetStringi(.GL_EXTENSIONS, i));\n");
lines.add(" StringView currentExt = StringView(glGetStringi(.GL_EXTENSIONS, i));\n");
foundExtensions.keySet().forEach(ext ->
lines.add(" " + ext + " = currentExt.Equals(\"" + ext + "\");")
);
Expand Down

0 comments on commit 35ab94c

Please sign in to comment.