diff options
Diffstat (limited to 'tests/manyloc')
84 files changed, 17898 insertions, 0 deletions
diff --git a/tests/manyloc/argument_parser/argument_parser.nim b/tests/manyloc/argument_parser/argument_parser.nim new file mode 100644 index 000000000..0ad57167b --- /dev/null +++ b/tests/manyloc/argument_parser/argument_parser.nim @@ -0,0 +1,493 @@ +## Command line parsing module for Nim. +## +## `Nim <http://nim-lang.org>`_ provides the `parseopt module +## <http://nim-lang.org/parseopt.html>`_ to parse options from the +## commandline. This module tries to provide functionality to prevent you from +## writing commandline parsing and let you concentrate on providing the best +## possible experience for your users. +## +## Source code for this module can be found at +## https://github.com/gradha/argument_parser. + +import os, strutils, tables, math, parseutils, sequtils, sets, algorithm, + unicode + +const + VERSION_STR* = "0.1.2" ## Module version as a string. + VERSION_INT* = (major: 0, minor: 1, maintenance: 2) ## \ + ## Module version as an integer tuple. + ## + ## Major versions changes mean a break in API backwards compatibility, either + ## through removal of symbols or modification of their purpose. + ## + ## Minor version changes can add procs (and maybe default parameters). Minor + ## odd versions are development/git/unstable versions. Minor even versions + ## are public stable releases. + ## + ## Maintenance version changes mean bugfixes or non API changes. + +# - Types + +type + Tparam_kind* = enum ## Different types of results for parameter parsing. + PK_EMPTY, PK_INT, PK_FLOAT, PK_STRING, PK_BOOL, + PK_BIGGEST_INT, PK_BIGGEST_FLOAT, PK_HELP + + Tparameter_callback* = + proc (parameter: string; value: var Tparsed_parameter): string ## \ + ## Prototype of parameter callbacks + ## + ## A parameter callback is just a custom proc you provide which is invoked + ## after a parameter is parsed passing the basic type validation. The + ## `parameter` parameter is the string which triggered the option. The + ## `value` parameter contains the string passed by the user already parsed + ## into the basic type you specified for it. + ## + ## The callback proc has modification access to the Tparsed_parameter + ## `value` parameter that will be put into Tcommandline_results: you can + ## read it and also modify it, maybe changing its type. In fact, if you + ## need special parsing, most likely you will end up specifying PK_STRING + ## in the parameter input specification so that the parse() proc doesn't + ## *mangle* the string before you can process it yourself. + ## + ## If the callback decides to abort the validation of the parameter, it has + ## to put into result a non zero length string with a message for the user + ## explaining why the validation failed, and maybe offer a hint as to what + ## can be done to pass validation. + + Tparameter_specification* = object ## \ + ## Holds the expectations of a parameter. + ## + ## You create these objects and feed them to the parse() proc, which then + ## uses them to detect parameters and turn them into something uself. + names*: seq[string] ## List of possible parameters to catch for this. + consumes*: Tparam_kind ## Expected type of the parameter (empty for none) + custom_validator*: Tparameter_callback ## Optional custom callback + ## to run after type conversion. + help_text*: string ## Help for this group of parameters. + + Tparsed_parameter* = object ## \ + ## Contains the parsed value from the user. + ## + ## This implements an object variant through the kind field. You can 'case' + ## this field to write a generic proc to deal with parsed parameters, but + ## nothing prevents you from accessing directly the type of field you want + ## if you expect only one kind. + case kind*: Tparam_kind + of PK_EMPTY: discard + of PK_INT: int_val*: int + of PK_BIGGEST_INT: big_int_val*: BiggestInt + of PK_FLOAT: float_val*: float + of PK_BIGGEST_FLOAT: big_float_val*: BiggestFloat + of PK_STRING: str_val*: string + of PK_BOOL: bool_val*: bool + of PK_HELP: discard + + Tcommandline_results* = object of RootObj ## \ + ## Contains the results of the parsing. + ## + ## Usually this is the result of the parse() call, but you can inherit from + ## it to add your own fields for convenience. + ## + ## Note that you always have to access the ``options`` ordered table with + ## the first variant of a parameter name. For instance, if you have an + ## option specified like ``@["-s", "--silent"]`` and the user types + ## ``--silent`` at the commandline, you have to use + ## ``options.hasKey("-s")`` to test for it. This standarizes access through + ## the first name variant for all options to avoid you repeating the test + ## with different keys. + positional_parameters*: seq[Tparsed_parameter] + options*: OrderedTable[string, Tparsed_parameter] + + +# - Tparam_kind procs + +proc `$`*(value: Tparam_kind): string = + ## Stringifies the type, used to generate help texts. + case value: + of PK_EMPTY: result = "" + of PK_INT: result = "INT" + of PK_BIGGEST_INT: result = "BIG_INT" + of PK_FLOAT: result = "FLOAT" + of PK_BIGGEST_FLOAT: result = "BIG_FLOAG" + of PK_STRING: result = "STRING" + of PK_BOOL: result = "BOOL" + of PK_HELP: result = "" + +# - Tparameter_specification procs + +proc init*(param: var Tparameter_specification, consumes = PK_EMPTY, + custom_validator: Tparameter_callback = nil, help_text = "", + names: varargs[string]) = + ## Initialization helper with default parameters. + ## + ## You can decide to miss some if you like the defaults, reducing code. You + ## can also use new_parameter_specification() for single assignment + ## variables. + param.names = @names + param.consumes = consumes + param.custom_validator = custom_validator + param.help_text = help_text + +proc new_parameter_specification*(consumes = PK_EMPTY, + custom_validator: Tparameter_callback = nil, help_text = "", + names: varargs[string]): Tparameter_specification = + ## Initialization helper for single assignment variables. + result.init(consumes, custom_validator, help_text, names) + +# - Tparsed_parameter procs + +proc `$`*(data: Tparsed_parameter): string = + ## Stringifies the value, mostly for debug purposes. + ## + ## The proc will display the value followed by non string type in brackets. + ## The non string types would be PK_INT (i), PK_BIGGEST_INT (I), PK_FLOAT + ## (f), PK_BIGGEST_FLOAT (F), PK_BOOL (b). The string type would be enclosed + ## inside quotes. PK_EMPTY produces the word `nil`, and PK_HELP produces the + ## world `help`. + case data.kind: + of PK_EMPTY: result = "nil" + of PK_INT: result = "$1(i)" % $data.int_val + of PK_BIGGEST_INT: result = "$1(I)" % $data.big_int_val + of PK_FLOAT: result = "$1(f)" % $data.float_val + of PK_BIGGEST_FLOAT: result = "$1(F)" % $data.big_float_val + of PK_STRING: result = "\"" & $data.str_val & "\"" + of PK_BOOL: result = "$1(b)" % $data.bool_val + of PK_HELP: result = "help" + + +template new_parsed_parameter*(tkind: Tparam_kind, expr): Tparsed_parameter = + ## Handy compile time template to build Tparsed_parameter object variants. + ## + ## The problem with object variants is that you first have to initialise them + ## to a kind, then assign values to the correct variable, and it is a little + ## bit annoying. + ## + ## Through this template you specify as the first parameter the kind of the + ## Tparsed_parameter you want to build, and directly the value it will be + ## initialised with. The template figures out at compile time what field to + ## assign the variable to, and thus you reduce code clutter and may use this + ## to initialise single assignments variables in `let` blocks. Example: + ## ```nim + ## let + ## parsed_param1 = new_parsed_parameter(PK_FLOAT, 3.41) + ## parsed_param2 = new_parsed_parameter(PK_BIGGEST_INT, 2358123 * 23123) + ## # The following line doesn't compile due to + ## # type mismatch: got <string> but expected 'int' + ## #parsed_param3 = new_parsed_parameter(PK_INT, "231") + ## ``` + var result {.gensym.}: Tparsed_parameter + result.kind = tkind + when tkind == PK_EMPTY: discard + elif tkind == PK_INT: result.int_val = expr + elif tkind == PK_BIGGEST_INT: result.big_int_val = expr + elif tkind == PK_FLOAT: result.float_val = expr + elif tkind == PK_BIGGEST_FLOAT: result.big_float_val = expr + elif tkind == PK_STRING: result.str_val = expr + elif tkind == PK_BOOL: result.bool_val = expr + elif tkind == PK_HELP: discard + else: {.error: "unknown kind".} + result + +# - Tcommandline_results procs + +proc init*(param: var Tcommandline_results; + positional_parameters: seq[Tparsed_parameter] = @[]; + options: OrderedTable[string, Tparsed_parameter] = + initOrderedTable[string, Tparsed_parameter](4)) = + ## Initialization helper with default parameters. + param.positional_parameters = positional_parameters + param.options = options + +proc `$`*(data: Tcommandline_results): string = + ## Stringifies a Tcommandline_results structure for debug output + var dict: seq[string] = @[] + for key, value in data.options: + dict.add("$1: $2" % [escape(key), $value]) + result = "Tcommandline_result{positional_parameters:[$1], options:{$2}}" % [ + join(map(data.positional_parameters, `$`), ", "), join(dict, ", ")] + +# - Parse code + +template raise_or_quit(exception, message: untyped) = + ## Avoids repeating if check based on the default quit_on_failure variable. + ## + ## As a special case, if message has a zero length the call to quit won't + ## generate any messages or errors (used by the mechanism to echo help to the + ## user). + if quit_on_failure: + if len(message) > 0: + quit(message) + else: + quit() + else: + raise newException(exception, message) + +template run_custom_proc(parsed_parameter: Tparsed_parameter, + custom_validator: Tparameter_callback, + parameter: string) = + ## Runs the custom validator if it is not nil. + ## + ## Pass in the string of the parameter triggering the call. If the + if not custom_validator.isNil: + try: + let message = custom_validator(parameter, parsed_parameter) + if message.len > 0: + raise_or_quit(ValueError, ("Failed to validate value for " & + "parameter $1:\n$2" % [escape(parameter), message])) + except: + raise_or_quit(ValueError, ("Couldn't run custom proc for " & + "parameter $1:\n$2" % [escape(parameter), + getCurrentExceptionMsg()])) + +proc parse_parameter(quit_on_failure: bool, param, value: string, + param_kind: Tparam_kind): Tparsed_parameter = + ## Tries to parse a text according to the specified type. + ## + ## Pass the parameter string which requires a value and the text the user + ## passed in for it. It will be parsed according to the param_kind. This proc + ## will raise (ValueError, EOverflow) if something can't be parsed. + result.kind = param_kind + case param_kind: + of PK_INT: + try: result.int_val = value.parseInt + except OverflowDefect: + raise_or_quit(OverflowDefect, ("parameter $1 requires an " & + "integer, but $2 is too large to fit into one") % [param, + escape(value)]) + except ValueError: + raise_or_quit(ValueError, ("parameter $1 requires an " & + "integer, but $2 can't be parsed into one") % [param, escape(value)]) + of PK_STRING: + result.str_val = value + of PK_FLOAT: + try: result.float_val = value.parseFloat + except ValueError: + raise_or_quit(ValueError, ("parameter $1 requires a " & + "float, but $2 can't be parsed into one") % [param, escape(value)]) + of PK_BOOL: + try: result.bool_val = value.parseBool + except ValueError: + raise_or_quit(ValueError, ("parameter $1 requires a " & + "boolean, but $2 can't be parsed into one. Valid values are: " & + "y, yes, true, 1, on, n, no, false, 0, off") % [param, escape(value)]) + of PK_BIGGEST_INT: + try: + let parsed_len = parseBiggestInt(value, result.big_int_val) + if value.len != parsed_len or parsed_len < 1: + raise_or_quit(ValueError, ("parameter $1 requires an " & + "integer, but $2 can't be parsed completely into one") % [ + param, escape(value)]) + except ValueError: + raise_or_quit(ValueError, ("parameter $1 requires an " & + "integer, but $2 can't be parsed into one") % [param, escape(value)]) + of PK_BIGGEST_FLOAT: + try: + let parsed_len = parseBiggestFloat(value, result.big_float_val) + if value.len != parsed_len or parsed_len < 1: + raise_or_quit(ValueError, ("parameter $1 requires a " & + "float, but $2 can't be parsed completely into one") % [ + param, escape(value)]) + except ValueError: + raise_or_quit(ValueError, ("parameter $1 requires a " & + "float, but $2 can't be parsed into one") % [param, escape(value)]) + of PK_EMPTY: + discard + of PK_HELP: + discard + + +template build_specification_lookup(): + OrderedTable[string, ptr Tparameter_specification] = + ## Returns the table used to keep pointers to all of the specifications. + var result {.gensym.}: OrderedTable[string, ptr Tparameter_specification] + result = initOrderedTable[string, ptr Tparameter_specification](expected.len) + for i in 0..expected.len-1: + for param_to_detect in expected[i].names: + if result.hasKey(param_to_detect): + raise_or_quit(KeyError, + "Parameter $1 repeated in input specification" % param_to_detect) + else: + result[param_to_detect] = addr(expected[i]) + result + + +proc echo_help*(expected: seq[Tparameter_specification] = @[], + type_of_positional_parameters = PK_STRING, + bad_prefixes = @["-", "--"], end_of_options = "--") + + +proc parse*(expected: seq[Tparameter_specification] = @[], + type_of_positional_parameters = PK_STRING, args: seq[string] = @[], + bad_prefixes = @["-", "--"], end_of_options = "--", + quit_on_failure = true): Tcommandline_results = + ## Parses parameters and returns results. + ## + ## The expected array should contain a list of the parameters you want to + ## detect, which can capture additional values. Uncaptured parameters are + ## considered positional parameters for which you can specify a type with + ## type_of_positional_parameters. + ## + ## Before accepting a positional parameter, the list of bad_prefixes is + ## compared against it. If the positional parameter starts with any of them, + ## an error is displayed to the user due to ambiguity. The user can overcome + ## the ambiguity by typing the special string specified by end_of_options. + ## Note that values captured by parameters are not checked against bad + ## prefixes, otherwise it would be a problem to specify the dash as synonim + ## for standard input for many programs. + ## + ## The args sequence should be the list of parameters passed to your program + ## without the program binary (usually OSes provide the path to the binary as + ## the zeroth parameter). If args is empty, the list will be retrieved from the + ## OS. + ## + ## If there is any kind of error and quit_on_failure is true, the quit proc + ## will be called with a user error message. If quit_on_failure is false + ## errors will raise exceptions (usually ValueError or EOverflow) instead + ## for you to catch and handle. + + assert type_of_positional_parameters != PK_EMPTY and + type_of_positional_parameters != PK_HELP + for bad_prefix in bad_prefixes: + assert bad_prefix.len > 0, "Can't pass in a bad prefix of zero length" + var + expected = expected + adding_options = true + result.init() + + # Prepare the input parameter list, maybe get it from the OS if not available. + var args = args + if args.len == 0: + let total_params = paramCount() + #echo "Got no explicit args, retrieving from OS. Count: ", total_params + newSeq(args, total_params) + for i in 0..total_params - 1: + #echo ($i) + args[i] = paramStr(i + 1) + + # Generate lookup table for each type of parameter based on strings. + var lookup = build_specification_lookup() + + # Loop through the input arguments detecting their type and doing stuff. + var i = 0 + while i < args.len: + let arg = args[i] + block adding_positional_parameter: + if arg.len > 0 and adding_options: + if arg == end_of_options: + # Looks like we found the end_of_options marker, disable options. + adding_options = false + break adding_positional_parameter + elif lookup.hasKey(arg): + var parsed: Tparsed_parameter + let param = lookup[arg] + + # Insert check here for help, which aborts parsing. + if param.consumes == PK_HELP: + echo_help(expected, type_of_positional_parameters, + bad_prefixes, end_of_options) + raise_or_quit(KeyError, "") + + if param.consumes != PK_EMPTY: + if i + 1 < args.len: + parsed = parse_parameter(quit_on_failure, + arg, args[i + 1], param.consumes) + run_custom_proc(parsed, param.custom_validator, arg) + i += 1 + else: + raise_or_quit(ValueError, ("parameter $1 requires a " & + "value, but none was provided") % [arg]) + result.options[param.names[0]] = parsed + break adding_positional_parameter + else: + for bad_prefix in bad_prefixes: + if arg.startsWith(bad_prefix): + raise_or_quit(ValueError, ("Found ambiguos parameter '$1' " & + "starting with '$2', put '$3' as the previous parameter " & + "if you want to force it as positional parameter.") % [arg, + bad_prefix, end_of_options]) + + # Unprocessed, add the parameter to the list of positional parameters. + result.positional_parameters.add(parse_parameter(quit_on_failure, + $(1 + i), arg, type_of_positional_parameters)) + + i += 1 + + +proc toString(runes: seq[Rune]): string = + result = "" + for rune in runes: result.add(rune.toUTF8) + + +proc ascii_cmp(a, b: string): int = + ## Comparison ignoring non ascii characters, for better switch sorting. + let a = filterIt(toSeq(runes(a)), it.isAlpha()) + # Can't use filterIt twice, github bug #351. + let b = filter(toSeq(runes(b)), proc(x: Rune): bool = x.isAlpha()) + return system.cmp(toString(a), toString(b)) + + +proc build_help*(expected: seq[Tparameter_specification] = @[], + type_of_positional_parameters = PK_STRING, + bad_prefixes = @["-", "--"], end_of_options = "--"): seq[string] = + ## Builds basic help text and returns it as a sequence of strings. + ## + ## Note that this proc doesn't do as much sanity checks as the normal parse() + ## proc, though it's unlikely you will be using one without the other, so if + ## you had a parameter specification problem you would find out soon. + result = @["Usage parameters: "] + + # Generate lookup table for each type of parameter based on strings. + let quit_on_failure = false + var + expected = expected + lookup = build_specification_lookup() + keys = toSeq(lookup.keys()) + + # First generate the joined version of input parameters in a list. + var + seen = initHashSet[string]() + prefixes: seq[string] = @[] + helps: seq[string] = @[] + for key in keys: + if seen.contains(key): + continue + + # Add the joined string to the list. + let param = lookup[key][] + var param_names = param.names + sort(param_names, ascii_cmp) + var prefix = join(param_names, ", ") + # Don't forget about the type, if the parameter consumes values + if param.consumes != PK_EMPTY and param.consumes != PK_HELP: + prefix &= " " & $param.consumes + prefixes.add(prefix) + helps.add(param.help_text) + # Ignore future elements. + for name in param.names: seen.incl(name) + + # Calculate the biggest width and try to use that + let width = prefixes.map(proc (x: string): int = 3 + len(x)).max + + for line in zip(prefixes, helps): + result.add(line[0] & spaces(width - line[0].len) & line[1]) + + +proc echo_help*(expected: seq[Tparameter_specification] = @[], + type_of_positional_parameters = PK_STRING, + bad_prefixes = @["-", "--"], end_of_options = "--") = + ## Prints out help on the terminal. + ## + ## This is just a wrapper around build_help. Note that calling this proc + ## won't exit your program, you should call quit() yourself. + for line in build_help(expected, + type_of_positional_parameters, bad_prefixes, end_of_options): + echo line + + +when true: + # Simply tests code embedded in docs. + let + parsed_param1 = new_parsed_parameter(PK_FLOAT, 3.41) + parsed_param2 = new_parsed_parameter(PK_BIGGEST_INT, 2358123 * 23123) + #parsed_param3 = new_parsed_parameter(PK_INT, "231") diff --git a/tests/manyloc/argument_parser/ex_wget.nim b/tests/manyloc/argument_parser/ex_wget.nim new file mode 100644 index 000000000..ebbf1933f --- /dev/null +++ b/tests/manyloc/argument_parser/ex_wget.nim @@ -0,0 +1,87 @@ +import argument_parser, tables, strutils, parseutils + +## Example defining a subset of wget's functionality + +const + PARAM_VERSION = @["-V", "--version"] + PARAM_HELP = @["-h", "--help"] + PARAM_BACKGROUND = @["-b", "--background"] + PARAM_OUTPUT = @["-o", "--output"] + PARAM_NO_CLOBBER = @["-nc", "--no-clobber"] + PARAM_PROGRESS = @["--progress"] + PARAM_NO_PROXY = @["--no-proxy"] + + +template P(tnames: varargs[string], thelp: string, ttype = PK_EMPTY, + tcallback: Tparameter_callback = nil) = + ## Helper to avoid repetition of parameter adding boilerplate. + params.add(new_parameter_specification(ttype, custom_validator = tcallback, + help_text = thelp, names = tnames)) + + +template got(param: varargs[string]) = + ## Just dump the detected options on output. + if result.options.hasKey(param[0]): echo("Found option '$1'." % [param[0]]) + + +proc parse_progress(parameter: string; value: var Tparsed_parameter): string = + ## Custom parser and validator of progress types for PARAM_PROGRESS. + ## + ## If the user specifies the PARAM_PROGRESS option this proc will be called + ## so we can validate the input. The proc returns a non empty string if + ## something went wrong with the description of the error, otherwise + ## execution goes ahead. + ## + ## This validator only accepts values without changing the final output. + if value.str_val == "bar" or value.str_val == "dot": + return + + result = "The string $1 is not valid, use bar or dot." % [value.str_val] + + +proc process_commandline(): Tcommandline_results = + ## Parses the commandline. + ## + ## Returns a Tcommandline_results with at least two positional parameter, + ## where the last parameter is implied to be the destination of the copying. + var params: seq[Tparameter_specification] = @[] + + P(PARAM_VERSION, "Shows the version of the program") + P(PARAM_HELP, "Shows this help on the commandline", PK_HELP) + P(PARAM_BACKGROUND, "Continues execution in the background") + P(PARAM_OUTPUT, "Specifies a specific output file name", PK_STRING) + P(PARAM_NO_CLOBBER, "Skip downloads that would overwrite existing files") + P(PARAM_PROGRESS, "Select progress look (bar or dot)", + PK_STRING, parse_progress) + P(PARAM_NO_PROXY, "Don't use proxies even if available") + + result = parse(params) + + if result.positional_parameters.len < 1: + echo "Missing URL(s) to download" + echo_help(params) + quit() + + got(PARAM_NO_CLOBBER) + got(PARAM_BACKGROUND) + got(PARAM_NO_PROXY) + + if result.options.hasKey(PARAM_VERSION[0]): + echo "Version 3.1415" + quit() + + if result.options.hasKey(PARAM_OUTPUT[0]): + if result.positional_parameters.len > 1: + echo "Error: can't use $1 option with multiple URLs" % [PARAM_OUTPUT[0]] + echo_help(params) + quit() + echo "Will download to $1" % [result.options[PARAM_OUTPUT[0]].str_val] + + if result.options.hasKey(PARAM_PROGRESS[0]): + echo "Will use progress type $1" % [result.options[PARAM_PROGRESS[0]].str_val] + + +when true: + let args = process_commandline() + for param in args.positional_parameters: + echo "Downloading $1" % param.str_val diff --git a/tests/manyloc/argument_parser/ex_wget.nim.cfg b/tests/manyloc/argument_parser/ex_wget.nim.cfg new file mode 100644 index 000000000..4ea571d31 --- /dev/null +++ b/tests/manyloc/argument_parser/ex_wget.nim.cfg @@ -0,0 +1 @@ +# This file exists only to mark 'ex_wget' as the project file diff --git a/tests/manyloc/keineschweine/README.md b/tests/manyloc/keineschweine/README.md new file mode 100644 index 000000000..20facbced --- /dev/null +++ b/tests/manyloc/keineschweine/README.md @@ -0,0 +1,26 @@ +keineSchweine +======================== +Just a dumb little game + +### Dependencies + +* nim 0.8.15, Until this version is released I'm working off nim HEAD: https://github.com/Araq/nim +* SFML 2.0 (git), https://github.com/LaurentGomila/SFML +* CSFML 2.0 (git), https://github.com/LaurentGomila/CSFML +* Chipmunk 6.1.1 http://chipmunk-physics.net/downloads.php + +### How to build? + +* `git clone --recursive https://github.com/fowlmouth/keineSchweine.git somedir` +* `cd somedir` +* `nim c -r nakefile test` or `nim c -r keineschweine && ./keineschweine` + +### Download the game data + +You need to download the game data before you can play: +http://dl.dropbox.com/u/37533467/data-08-01-2012.7z + +Unpack it to the root directory. You can use the nakefile to do this easily: + +* `nim c -r nakefile` +* `./nakefile download` diff --git a/tests/manyloc/keineschweine/TODO.md b/tests/manyloc/keineschweine/TODO.md new file mode 100644 index 000000000..1145949aa --- /dev/null +++ b/tests/manyloc/keineschweine/TODO.md @@ -0,0 +1,21 @@ +##Main State +* Add GUI: + * Player list + * Chat box + * Escape menu + +##Lobby +* Add GUI: + * options menu + * key configuration + +## Animations +* Need one-shot explosion animations + * Thrusters (maybe a particle system instead) + +## Networking +* zone server should verify users through the dir server or handle its own users +* directory server should handle asset patching + +## Genpacket +* add support for branching types with case diff --git a/tests/manyloc/keineschweine/client_settings.json b/tests/manyloc/keineschweine/client_settings.json new file mode 100644 index 000000000..59facf1ad --- /dev/null +++ b/tests/manyloc/keineschweine/client_settings.json @@ -0,0 +1,10 @@ +{ + "resolution": [800,600,32], + "default-file": "alphazone.json", + "alias": "foo", + "directory-server":{ + "host":"localhost", + "port":8024 + }, + "website":"https://github.com/fowlmouth/keineSchweine" +} diff --git a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim new file mode 100644 index 000000000..6eb1b3844 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim @@ -0,0 +1,1514 @@ +# Copyright (c) 2007 Scott Lembcke +# +# 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. +# + +const Lib = "libchipmunk.so.6.1.1" + +when defined(MoreNim): + {.hint: "MoreNim defined; some Chipmunk functions replaced in Nim".} +from math import sqrt, sin, cos, arctan2 +when defined(CpUseFloat): + {.hint: "CpUseFloat defined; using float32 as float".} + type CpFloat* = cfloat +else: + type CpFloat* = cdouble +const + CP_BUFFER_BYTES* = (32 * 1024) + CP_MAX_CONTACTS_PER_ARBITER* = 4 + CpInfinity*: CpFloat = 1.0/0 +{.pragma: pf, pure, final.} +type + Bool32* = cint #replace one day with cint-compatible bool + CpDataPointer* = pointer + TVector* {.final, pure.} = object + x*, y*: CpFloat + TTimestamp* = cuint + TBodyVelocityFunc* = proc(body: PBody, gravity: TVector, + damping: CpFloat; dt: CpFloat){.cdecl.} + TBodyPositionFunc* = proc(body: PBody; dt: CpFloat){.cdecl.} + TComponentNode*{.pf.} = object + root*: PBody + next*: PBody + idleTime*: CpFloat + + THashValue = cuint # uintptr_t + TCollisionType* = cuint #uintptr_t + TGroup * = cuint #uintptr_t + TLayers* = cuint + PArray = ptr TArray + TArray{.pure,final.} = object + PHashSet = ptr THashSet + THashSet{.pf.} = object + PContact* = ptr TContact + TContact*{.pure,final.} = object + PArbiter* = ptr TArbiter + TArbiter*{.pf.} = object + e*: CpFloat + u*: CpFloat + surface_vr*: TVector + a*: PShape + b*: PShape + body_a*: PBody + body_b*: PBody + thread_a*: TArbiterThread + thread_b*: TArbiterThread + numContacts*: cint + contacts*: PContact + stamp*: TTimestamp + handler*: PCollisionHandler + swappedColl*: Bool32 + state*: TArbiterState + PCollisionHandler* = ptr TCollisionHandler + TCollisionHandler*{.pf.} = object + a*: TCollisionType + b*: TCollisionType + begin*: TCollisionBeginFunc + preSolve*: TCollisionPreSolveFunc + postSolve*: TCollisionPostSolveFunc + separate*: TCollisionSeparateFunc + data*: pointer + TArbiterState*{.size: sizeof(cint).} = enum + ArbiterStateFirstColl, # Arbiter is active and its not the first collision. + ArbiterStateNormal, # Collision has been explicitly ignored. + # Either by returning false from a begin collision handler or calling cpArbiterIgnore(). + ArbiterStateIgnore, # Collison is no longer active. A space will cache an arbiter for up to cpSpace.collisionPersistence more steps. + ArbiterStateCached + TArbiterThread*{.pf.} = object + next*: PArbiter # Links to next and previous arbiters in the contact graph. + prev*: PArbiter + + TContactPoint*{.pf.} = object + point*: TVector #/ The position of the contact point. + normal*: TVector #/ The normal of the contact point. + dist*: CpFloat #/ The depth of the contact point. + #/ A struct that wraps up the important collision data for an arbiter. + PContactPointSet* = ptr TContactPointSet + TContactPointSet*{.pf.} = object + count*: cint #/ The number of contact points in the set. + points*: array[0..CP_MAX_CONTACTS_PER_ARBITER - 1, TContactPoint] #/ The array of contact points. + + #/ Collision begin event function callback type. + #/ Returning false from a begin callback causes the collision to be ignored until + #/ the separate callback is called when the objects stop colliding. + TCollisionBeginFunc* = proc (arb: PArbiter; space: PSpace; data: pointer): bool{. + cdecl.} + #/ Collision pre-solve event function callback type. + #/ Returning false from a pre-step callback causes the collision to be ignored until the next step. + TCollisionPreSolveFunc* = proc (arb: PArbiter; space: PSpace; + data: pointer): bool {.cdecl.} + #/ Collision post-solve event function callback type. + TCollisionPostSolveFunc* = proc (arb: PArbiter; space: PSpace; + data: pointer){.cdecl.} + #/ Collision separate event function callback type. + TCollisionSeparateFunc* = proc (arb: PArbiter; space: PSpace; + data: pointer){.cdecl.} + + #/ Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top) + PBB* = ptr TBB + TBB* {.pf.} = object + l*, b*, r*, t*: CpFloat + + #/ Spatial index bounding box callback function type. + #/ The spatial index calls this function and passes you a pointer to an object you added + #/ when it needs to get the bounding box associated with that object. + TSpatialIndexBBFunc* = proc (obj: pointer): TBB{.cdecl.} + #/ Spatial index/object iterator callback function type. + TSpatialIndexIteratorFunc* = proc (obj: pointer; data: pointer){.cdecl.} + #/ Spatial query callback function type. + TSpatialIndexQueryFunc* = proc (obj1: pointer; obj2: pointer; data: pointer){. + cdecl.} + #/ Spatial segment query callback function type. + TSpatialIndexSegmentQueryFunc* = proc (obj1: pointer; obj2: pointer; + data: pointer): CpFloat {.cdecl.} + #/ private + PSpatialIndex = ptr TSpatialIndex + TSpatialIndex{.pf.} = object + klass: PSpatialIndexClass + bbfun: TSpatialIndexBBFunc + staticIndex: PSpatialIndex + dynamicIndex: PSpatialIndex + + TSpatialIndexDestroyImpl* = proc (index: PSpatialIndex){.cdecl.} + TSpatialIndexCountImpl* = proc (index: PSpatialIndex): cint{.cdecl.} + TSpatialIndexEachImpl* = proc (index: PSpatialIndex; + fun: TSpatialIndexIteratorFunc; data: pointer){. + cdecl.} + TSpatialIndexContainsImpl* = proc (index: PSpatialIndex; obj: pointer; + hashid: THashValue): Bool32 {.cdecl.} + TSpatialIndexInsertImpl* = proc (index: PSpatialIndex; obj: pointer; + hashid: THashValue){.cdecl.} + TSpatialIndexRemoveImpl* = proc (index: PSpatialIndex; obj: pointer; + hashid: THashValue){.cdecl.} + TSpatialIndexReindexImpl* = proc (index: PSpatialIndex){.cdecl.} + TSpatialIndexReindexObjectImpl* = proc (index: PSpatialIndex; + obj: pointer; hashid: THashValue){.cdecl.} + TSpatialIndexReindexQueryImpl* = proc (index: PSpatialIndex; + fun: TSpatialIndexQueryFunc; data: pointer){.cdecl.} + TSpatialIndexPointQueryImpl* = proc (index: PSpatialIndex; point: TVector; + fun: TSpatialIndexQueryFunc; + data: pointer){.cdecl.} + TSpatialIndexSegmentQueryImpl* = proc (index: PSpatialIndex; obj: pointer; + a: TVector; b: TVector; t_exit: CpFloat; fun: TSpatialIndexSegmentQueryFunc; + data: pointer){.cdecl.} + TSpatialIndexQueryImpl* = proc (index: PSpatialIndex; obj: pointer; + bb: TBB; fun: TSpatialIndexQueryFunc; + data: pointer){.cdecl.} + PSpatialIndexClass* = ptr TSpatialIndexClass + TSpatialIndexClass*{.pf.} = object + destroy*: TSpatialIndexDestroyImpl + count*: TSpatialIndexCountImpl + each*: TSpatialIndexEachImpl + contains*: TSpatialIndexContainsImpl + insert*: TSpatialIndexInsertImpl + remove*: TSpatialIndexRemoveImpl + reindex*: TSpatialIndexReindexImpl + reindexObject*: TSpatialIndexReindexObjectImpl + reindexQuery*: TSpatialIndexReindexQueryImpl + pointQuery*: TSpatialIndexPointQueryImpl + segmentQuery*: TSpatialIndexSegmentQueryImpl + query*: TSpatialIndexQueryImpl + + PSpaceHash* = ptr TSpaceHash + TSpaceHash* {.pf.} = object + PBBTree* = ptr TBBTree + TBBTree* {.pf.} = object + PSweep1D* = ptr TSweep1D + TSweep1D* {.pf.} = object + + #/ Bounding box tree velocity callback function. + #/ This function should return an estimate for the object's velocity. + TBBTreeVelocityFunc* = proc (obj: pointer): TVector {.cdecl.} + + PContactBufferHeader* = ptr TContentBufferHeader + TContentBufferHeader* {.pf.} = object + TSpaceArbiterApplyImpulseFunc* = proc (arb: PArbiter){.cdecl.} + + PSpace* = ptr TSpace + TSpace* {.pf.} = object + iterations*: cint + gravity*: TVector + damping*: CpFloat + idleSpeedThreshold*: CpFloat + sleepTimeThreshold*: CpFloat + collisionSlop*: CpFloat + collisionBias*: CpFloat + collisionPersistence*: TTimestamp + enableContactGraph*: cint ##BOOL + data*: pointer + staticBody*: PBody + stamp: TTimestamp + currDT: CpFloat + bodies: PArray + rousedBodies: PArray + sleepingComponents: PArray + staticShapes: PSpatialIndex + activeShapes: PSpatialIndex + arbiters: PArray + contactBuffersHead: PContactBufferHeader + cachedArbiters: PHashSet + pooledArbiters: PArray + constraints: PArray + allocatedBuffers: PArray + locked: cint + collisionHandlers: PHashSet + defaultHandler: TCollisionHandler + postStepCallbacks: PHashSet + arbiterApplyImpulse: TSpaceArbiterApplyImpulseFunc + staticBody2: TBody #_staticBody + PBody* = ptr TBody + TBody*{.pf.} = object + velocityFunc*: TBodyVelocityFunc + positionFunc*: TBodyPositionFunc + m*: CpFloat + mInv*: CpFloat + i*: CpFloat + iInv*: CpFloat + p*: TVector + v*: TVector + f*: TVector + a*: CpFloat + w*: CpFloat + t*: CpFloat + rot*: TVector + data*: pointer + vLimit*: CpFloat + wLimit*: CpFloat + vBias*: TVector + wBias*: CpFloat + space*: PSpace + shapeList*: PShape + arbiterList*: PArbiter + constraintList*: PConstraint + node*: TComponentNode + #/ Body/shape iterator callback function type. + TBodyShapeIteratorFunc* = proc (body: PBody; shape: PShape; + data: pointer) {.cdecl.} + #/ Body/constraint iterator callback function type. + TBodyConstraintIteratorFunc* = proc (body: PBody; + constraint: PConstraint; + data: pointer) {.cdecl.} + #/ Body/arbiter iterator callback function type. + TBodyArbiterIteratorFunc* = proc (body: PBody; arbiter: PArbiter; + data: pointer) {.cdecl.} + + PNearestPointQueryInfo* = ptr TNearestPointQueryInfo + #/ Nearest point query info struct. + TNearestPointQueryInfo*{.pf.} = object + shape: PShape #/ The nearest shape, NULL if no shape was within range. + p: TVector #/ The closest point on the shape's surface. (in world space coordinates) + d: CpFloat #/ The distance to the point. The distance is negative if the point is inside the shape. + + PSegmentQueryInfo* = ptr TSegmentQueryInfo + #/ Segment query info struct. + TSegmentQueryInfo*{.pf.} = object + shape*: PShape #/ The shape that was hit, NULL if no collision occurred. + t*: CpFloat #/ The normalized distance along the query segment in the range [0, 1]. + n*: TVector #/ The normal of the surface hit. + TShapeType*{.size: sizeof(cint).} = enum + CP_CIRCLE_SHAPE, CP_SEGMENT_SHAPE, CP_POLY_SHAPE, CP_NUM_SHAPES + TShapeCacheDataImpl* = proc (shape: PShape; p: TVector; rot: TVector): TBB{.cdecl.} + TShapeDestroyImpl* = proc (shape: PShape){.cdecl.} + TShapePointQueryImpl* = proc (shape: PShape; p: TVector): Bool32 {.cdecl.} + TShapeSegmentQueryImpl* = proc (shape: PShape; a: TVector; b: TVector; + info: PSegmentQueryInfo){.cdecl.} + PShapeClass* = ptr TShapeClass + TShapeClass*{.pf.} = object + kind*: TShapeType + cacheData*: TShapeCacheDataImpl + destroy*: TShapeDestroyImpl + pointQuery*: TShapePointQueryImpl + segmentQuery*: TShapeSegmentQueryImpl + PShape* = ptr TShape + TShape*{.pf.} = object + klass: PShapeClass #/ PRIVATE + body*: PBody #/ The rigid body this collision shape is attached to. + bb*: TBB #/ The current bounding box of the shape. + sensor*: Bool32 #/ Sensor flag. + #/ Sensor shapes call collision callbacks but don't produce collisions. + e*: CpFloat #/ Coefficient of restitution. (elasticity) + u*: CpFloat #/ Coefficient of friction. + surface_v*: TVector #/ Surface velocity used when solving for friction. + data*: pointer #/ User definable data pointer. Generally this points to your the game object class so you can access it when given a cpShape reference in a callback. + collision_type*: TCollisionType #/ Collision type of this shape used when picking collision handlers. + group*: TGroup #/ Group of this shape. Shapes in the same group don't collide. + layers*: TLayers #/ Layer bitmask for this shape. Shapes only collide if the bitwise and of their layers is non-zero. + space: PSpace #PRIVATE + next: PShape #PRIVATE + prev: PShape #PRIVATE + hashid: THashValue #PRIVATE + PCircleShape* = ptr TCircleShape + TCircleShape*{.pf.} = object + shape: PShape + c, tc: TVector + r: CpFloat + PPolyShape* = ptr TPolyShape + TPolyShape*{.pf.} = object + shape: PShape + numVerts: cint + verts, tVerts: TVector + planes, tPlanes: PSplittingPlane + PSegmentShape* = ptr TSegmentShape + TSegmentShape*{.pf.} = object + shape: PShape + a, b, n: TVector + ta, tb, tn: TVector + r: CpFloat + aTangent, bTangent: TVector + PSplittingPlane* = ptr TSplittingPlane + TSplittingPlane*{.pf.} = object + n: TVector + d: CpFloat + + #/ Post Step callback function type. + TPostStepFunc* = proc (space: PSpace; obj: pointer; data: pointer){.cdecl.} + #/ Point query callback function type. + TSpacePointQueryFunc* = proc (shape: PShape; data: pointer){.cdecl.} + #/ Segment query callback function type. + TSpaceSegmentQueryFunc* = proc (shape: PShape; t: CpFloat; n: TVector; + data: pointer){.cdecl.} + #/ Rectangle Query callback function type. + TSpaceBBQueryFunc* = proc (shape: PShape; data: pointer){.cdecl.} + #/ Shape query callback function type. + TSpaceShapeQueryFunc* = proc (shape: PShape; points: PContactPointSet; + data: pointer){.cdecl.} + #/ Space/body iterator callback function type. + TSpaceBodyIteratorFunc* = proc (body: PBody; data: pointer){.cdecl.} + #/ Space/body iterator callback function type. + TSpaceShapeIteratorFunc* = proc (shape: PShape; data: pointer){.cdecl.} + #/ Space/constraint iterator callback function type. + TSpaceConstraintIteratorFunc* = proc (constraint: PConstraint; + data: pointer){.cdecl.} + #/ Opaque cpConstraint struct. + PConstraint* = ptr TConstraint + TConstraint*{.pf.} = object + klass: PConstraintClass #/PRIVATE + a*: PBody #/ The first body connected to this constraint. + b*: PBody #/ The second body connected to this constraint. + space: PSpace #/PRIVATE + next_a: PConstraint #/PRIVATE + next_b: PConstraint #/PRIVATE + maxForce*: CpFloat #/ The maximum force that this constraint is allowed to use. Defaults to infinity. + errorBias*: CpFloat #/ The rate at which joint error is corrected. Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second. + maxBias*: CpFloat #/ The maximum rate at which joint error is corrected. Defaults to infinity. + preSolve*: TConstraintPreSolveFunc #/ Function called before the solver runs. Animate your joint anchors, update your motor torque, etc. + postSolve*: TConstraintPostSolveFunc #/ Function called after the solver runs. Use the applied impulse to perform effects like breakable joints. + data*: CpDataPointer # User definable data pointer. Generally this points to your the game object class so you can access it when given a cpConstraint reference in a callback. + TConstraintPreStepImpl = proc (constraint: PConstraint; dt: CpFloat){.cdecl.} + TConstraintApplyCachedImpulseImpl = proc (constraint: PConstraint; dt_coef: CpFloat){.cdecl.} + TConstraintApplyImpulseImpl = proc (constraint: PConstraint){.cdecl.} + TConstraintGetImpulseImpl = proc (constraint: PConstraint): CpFloat{.cdecl.} + PConstraintClass = ptr TConstraintClass + TConstraintClass{.pf.} = object + preStep*: TConstraintPreStepImpl + applyCachedImpulse*: TConstraintApplyCachedImpulseImpl + applyImpulse*: TConstraintApplyImpulseImpl + getImpulse*: TConstraintGetImpulseImpl + #/ Callback function type that gets called before solving a joint. + TConstraintPreSolveFunc* = proc (constraint: PConstraint; space: PSpace){. + cdecl.} + #/ Callback function type that gets called after solving a joint. + TConstraintPostSolveFunc* = proc (constraint: PConstraint; space: PSpace){. + cdecl.} + +##cp property emulators +template defGetter(otype: typedesc, memberType: typedesc, memberName, procName: untyped) = + proc `get procName`*(obj: otype): memberType {.cdecl.} = + return obj.memberName +template defSetter(otype: typedesc, memberType: typedesc, memberName, procName: untyped) = + proc `set procName`*(obj: otype, value: memberType) {.cdecl.} = + obj.memberName = value +template defProp(otype: typedesc, memberType: typedesc, memberName, procName: untyped) = + defGetter(otype, memberType, memberName, procName) + defSetter(otype, memberType, memberName, procName) + + +##cpspace.h +proc allocSpace*(): PSpace {. + importc: "cpSpaceAlloc", dynlib: Lib.} +proc Init*(space: PSpace): PSpace {. + importc: "cpSpaceInit", dynlib: Lib.} +proc newSpace*(): PSpace {. + importc: "cpSpaceNew", dynlib: Lib.} +proc destroy*(space: PSpace) {. + importc: "cpSpaceDestroy", dynlib: Lib.} +proc free*(space: PSpace) {. + importc: "cpSpaceFree", dynlib: Lib.} + +defProp(PSpace, cint, iterations, Iterations) +defProp(PSpace, TVector, gravity, Gravity) +defProp(PSpace, CpFloat, damping, Damping) +defProp(PSpace, CpFloat, idleSpeedThreshold, IdleSpeedThreshold) +defProp(PSpace, CpFloat, sleepTimeThreshold, SleepTimeThreshold) +defProp(PSpace, CpFloat, collisionSlop, CollisionSlop) +defProp(PSpace, CpFloat, collisionBias, CollisionBias) +defProp(PSpace, TTimestamp, collisionPersistence, CollisionPersistence) +defProp(PSpace, Bool32, enableContactGraph, EnableContactGraph) +defProp(PSpace, pointer, data, UserData) +defGetter(PSpace, PBody, staticBody, StaticBody) +defGetter(PSpace, CpFloat, currDt, CurrentTimeStep) + + +#/ returns true from inside a callback and objects cannot be added/removed. +proc isLocked*(space: PSpace): bool{.inline.} = + result = space.locked.bool + +#/ Set a default collision handler for this space. +#/ The default collision handler is invoked for each colliding pair of shapes +#/ that isn't explicitly handled by a specific collision handler. +#/ You can pass NULL for any function you don't want to implement. +proc setDefaultCollisionHandler*(space: PSpace; begin: TCollisionBeginFunc; + preSolve: TCollisionPreSolveFunc; + postSolve: TCollisionPostSolveFunc; + separate: TCollisionSeparateFunc; + data: pointer){. + cdecl, importc: "cpSpaceSetDefaultCollisionHandler", dynlib: Lib.} +#/ Set a collision handler to be used whenever the two shapes with the given collision types collide. +#/ You can pass NULL for any function you don't want to implement. +proc addCollisionHandler*(space: PSpace; a, b: TCollisionType; + begin: TCollisionBeginFunc; + preSolve: TCollisionPreSolveFunc; + postSolve: TCollisionPostSolveFunc; + separate: TCollisionSeparateFunc; data: pointer){. + cdecl, importc: "cpSpaceAddCollisionHandler", dynlib: Lib.} +#/ Unset a collision handler. +proc removeCollisionHandler*(space: PSpace; a: TCollisionType; + b: TCollisionType){. + cdecl, importc: "cpSpaceRemoveCollisionHandler", dynlib: Lib.} +#/ Add a collision shape to the simulation. +#/ If the shape is attached to a static body, it will be added as a static shape. +proc addShape*(space: PSpace; shape: PShape): PShape{. + cdecl, importc: "cpSpaceAddShape", dynlib: Lib.} +#/ Explicitly add a shape as a static shape to the simulation. +proc addStaticShape*(space: PSpace; shape: PShape): PShape{. + cdecl, importc: "cpSpaceAddStaticShape", dynlib: Lib.} +#/ Add a rigid body to the simulation. +proc addBody*(space: PSpace; body: PBody): PBody{. + cdecl, importc: "cpSpaceAddBody", dynlib: Lib.} +#/ Add a constraint to the simulation. +proc addConstraint*(space: PSpace; constraint: PConstraint): PConstraint{. + cdecl, importc: "cpSpaceAddConstraint", dynlib: Lib.} +#/ Remove a collision shape from the simulation. +proc removeShape*(space: PSpace; shape: PShape){. + cdecl, importc: "cpSpaceRemoveShape", dynlib: Lib.} +#/ Remove a collision shape added using cpSpaceAddStaticShape() from the simulation. +proc removeStaticShape*(space: PSpace; shape: PShape){. + cdecl, importc: "cpSpaceRemoveStaticShape", dynlib: Lib.} +#/ Remove a rigid body from the simulation. +proc removeBody*(space: PSpace; body: PBody){. + cdecl, importc: "cpSpaceRemoveBody", dynlib: Lib.} +#/ Remove a constraint from the simulation. +proc RemoveConstraint*(space: PSpace; constraint: PConstraint){. + cdecl, importc: "cpSpaceRemoveConstraint", dynlib: Lib.} +#/ Test if a collision shape has been added to the space. +proc containsShape*(space: PSpace; shape: PShape): bool{. + cdecl, importc: "cpSpaceContainsShape", dynlib: Lib.} +#/ Test if a rigid body has been added to the space. +proc containsBody*(space: PSpace; body: PBody): bool{. + cdecl, importc: "cpSpaceContainsBody", dynlib: Lib.} +#/ Test if a constraint has been added to the space. + +proc containsConstraint*(space: PSpace; constraint: PConstraint): bool{. + cdecl, importc: "cpSpaceContainsConstraint", dynlib: Lib.} +#/ Schedule a post-step callback to be called when cpSpaceStep() finishes. +#/ @c obj is used a key, you can only register one callback per unique value for @c obj +proc addPostStepCallback*(space: PSpace; fun: TPostStepFunc; + obj: pointer; data: pointer){. + cdecl, importc: "cpSpaceAddPostStepCallback", dynlib: Lib.} + +#/ Query the space at a point and call @c func for each shape found. +proc pointQuery*(space: PSpace; point: TVector; layers: TLayers; + group: TGroup; fun: TSpacePointQueryFunc; data: pointer){. + cdecl, importc: "cpSpacePointQuery", dynlib: Lib.} + +#/ Query the space at a point and return the first shape found. Returns NULL if no shapes were found. +proc pointQueryFirst*(space: PSpace; point: TVector; layers: TLayers; + group: TGroup): PShape{. + cdecl, importc: "cpSpacePointQueryFirst", dynlib: Lib.} + +#/ Perform a directed line segment query (like a raycast) against the space calling @c func for each shape intersected. +proc segmentQuery*(space: PSpace; start: TVector; to: TVector; + layers: TLayers; group: TGroup; + fun: TSpaceSegmentQueryFunc; data: pointer){. + cdecl, importc: "cpSpaceSegmentQuery", dynlib: Lib.} +#/ Perform a directed line segment query (like a raycast) against the space and return the first shape hit. Returns NULL if no shapes were hit. +proc segmentQueryFirst*(space: PSpace; start: TVector; to: TVector; + layers: TLayers; group: TGroup; + res: PSegmentQueryInfo): PShape{. + cdecl, importc: "cpSpaceSegmentQueryFirst", dynlib: Lib.} + +#/ Perform a fast rectangle query on the space calling @c func for each shape found. +#/ Only the shape's bounding boxes are checked for overlap, not their full shape. +proc BBQuery*(space: PSpace; bb: TBB; layers: TLayers; group: TGroup; + fun: TSpaceBBQueryFunc; data: pointer){. + cdecl, importc: "cpSpaceBBQuery", dynlib: Lib.} + +#/ Query a space for any shapes overlapping the given shape and call @c func for each shape found. +proc shapeQuery*(space: PSpace; shape: PShape; fun: TSpaceShapeQueryFunc; data: pointer): bool {. + cdecl, importc: "cpSpaceShapeQuery", dynlib: Lib.} +#/ Call cpBodyActivate() for any shape that is overlaps the given shape. +proc activateShapesTouchingShape*(space: PSpace; shape: PShape){. + cdecl, importc: "cpSpaceActivateShapesTouchingShape", dynlib: Lib.} + +#/ Call @c func for each body in the space. +proc eachBody*(space: PSpace; fun: TSpaceBodyIteratorFunc; data: pointer){. + cdecl, importc: "cpSpaceEachBody", dynlib: Lib.} + +#/ Call @c func for each shape in the space. +proc eachShape*(space: PSpace; fun: TSpaceShapeIteratorFunc; + data: pointer){. + cdecl, importc: "cpSpaceEachShape", dynlib: Lib.} +#/ Call @c func for each shape in the space. +proc eachConstraint*(space: PSpace; fun: TSpaceConstraintIteratorFunc; + data: pointer){. + cdecl, importc: "cpSpaceEachConstraint", dynlib: Lib.} +#/ Update the collision detection info for the static shapes in the space. +proc reindexStatic*(space: PSpace){. + cdecl, importc: "cpSpaceReindexStatic", dynlib: Lib.} +#/ Update the collision detection data for a specific shape in the space. +proc reindexShape*(space: PSpace; shape: PShape){. + cdecl, importc: "cpSpaceReindexShape", dynlib: Lib.} +#/ Update the collision detection data for all shapes attached to a body. +proc reindexShapesForBody*(space: PSpace; body: PBody){. + cdecl, importc: "cpSpaceReindexShapesForBody", dynlib: Lib.} +#/ Switch the space to use a spatial has as it's spatial index. +proc SpaceUseSpatialHash*(space: PSpace; dim: CpFloat; count: cint){. + cdecl, importc: "cpSpaceUseSpatialHash", dynlib: Lib.} +#/ Step the space forward in time by @c dt. +proc step*(space: PSpace; dt: CpFloat) {. + cdecl, importc: "cpSpaceStep", dynlib: Lib.} + + +#/ Convenience constructor for cpVect structs. +proc vector*(x, y: CpFloat): TVector {.inline.} = + result.x = x + result.y = y +proc newVector*(x, y: CpFloat): TVector {.inline.} = + return vector(x, y) +#let VectorZero* = newVector(0.0, 0.0) +var VectorZero* = newVector(0.0, 0.0) + +#/ Vector dot product. +proc dot*(v1, v2: TVector): CpFloat {.inline.} = + result = v1.x * v2.x + v1.y * v2.y + +#/ Returns the length of v. +#proc len*(v: TVector): CpFloat {. +# cdecl, importc: "cpvlength", dynlib: Lib.} +proc len*(v: TVector): CpFloat {.inline.} = + result = v.dot(v).sqrt +#/ Spherical linearly interpolate between v1 and v2. +proc slerp*(v1, v2: TVector; t: CpFloat): TVector {. + cdecl, importc: "cpvslerp", dynlib: Lib.} +#/ Spherical linearly interpolate between v1 towards v2 by no more than angle a radians +proc slerpconst*(v1, v2: TVector; a: CpFloat): TVector {. + cdecl, importc: "cpvslerpconst", dynlib: Lib.} +#/ Returns the unit length vector for the given angle (in radians). +#proc vectorForAngle*(a: CpFloat): TVector {. +# cdecl, importc: "cpvforangle", dynlib: Lib.} +proc vectorForAngle*(a: CpFloat): TVector {.inline.} = + result = newVector(math.cos(a), math.sin(a)) +#/ Returns the angular direction v is pointing in (in radians). +proc toAngle*(v: TVector): CpFloat {.inline.} = + result = math.arctan2(v.y, v.x) +#/ Returns a string representation of v. Intended mostly for debugging purposes and not production use. +#/ @attention The string points to a static local and is reset every time the function is called. +#/ If you want to print more than one vector you will have to split up your printing onto separate lines. +proc `$`*(v: TVector): cstring {.cdecl, importc: "cpvstr", dynlib: Lib.} + + +#/ Check if two vectors are equal. (Be careful when comparing floating point numbers!) +proc `==`*(v1, v2: TVector): bool {.inline.} = + result = v1.x == v2.x and v1.y == v2.y + +#/ Add two vectors +proc `+`*(v1, v2: TVector): TVector {.inline.} = + result = newVector(v1.x + v2.x, v1.y + v2.y) +proc `+=`*(v1: var TVector; v2: TVector) = + v1.x = v1.x + v2.x + v1.y = v1.y + v2.y + +#/ Subtract two vectors. +proc `-`*(v1, v2: TVector): TVector {.inline.} = + result = newVector(v1.x - v2.x, v1.y - v2.y) +proc `-=`*(v1: var TVector; v2: TVector) = + v1.x = v1.x - v2.x + v1.y = v1.y - v2.y + +#/ Negate a vector. +proc `-`*(v: TVector): TVector {.inline.} = + result = newVector(- v.x, - v.y) + +#/ Scalar multiplication. +proc `*`*(v: TVector, s: CpFloat): TVector {.inline.} = + result.x = v.x * s + result.y = v.y * s +proc `*=`*(v: var TVector; s: CpFloat) = + v.x = v.x * s + v.y = v.y * s + +#/ 2D vector cross product analog. +#/ The cross product of 2D vectors results in a 3D vector with only a z component. +#/ This function returns the magnitude of the z value. +proc cross*(v1, v2: TVector): CpFloat {.inline.} = + result = v1.x * v2.y - v1.y * v2.x + +#/ Returns a perpendicular vector. (90 degree rotation) +proc perp*(v: TVector): TVector {.inline.} = + result = newVector(- v.y, v.x) + +#/ Returns a perpendicular vector. (-90 degree rotation) +proc rperp*(v: TVector): TVector {.inline.} = + result = newVector(v.y, - v.x) + +#/ Returns the vector projection of v1 onto v2. +proc project*(v1,v2: TVector): TVector {.inline.} = + result = v2 * (v1.dot(v2) / v2.dot(v2)) + +#/ Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a unit vector. + +proc rotate*(v1, v2: TVector): TVector {.inline.} = + result = newVector(v1.x * v2.x - v1.y * v2.y, v1.x * v2.y + v1.y * v2.x) +#/ Inverse of cpvrotate(). +proc unrotate*(v1, v2: TVector): TVector {.inline.} = + result = newVector(v1.x * v2.x + v1.y * v2.y, v1.y * v2.x - v1.x * v2.y) +#/ Returns the squared length of v. Faster than cpvlength() when you only need to compare lengths. +proc lenSq*(v: TVector): CpFloat {.inline.} = + result = v.dot(v) +#/ Linearly interpolate between v1 and v2. +proc lerp*(v1, v2: TVector; t: CpFloat): TVector {.inline.} = + result = (v1 * (1.0 - t)) + (v2 * t) +#/ Returns a normalized copy of v. +proc normalize*(v: TVector): TVector {.inline.} = + result = v * (1.0 / v.len) +#/ Returns a normalized copy of v or cpvzero if v was already cpvzero. Protects against divide by zero errors. +proc normalizeSafe*(v: TVector): TVector {.inline.} = + result = if v.x == 0.0 and v.y == 0.0: VectorZero else: v.normalize +#/ Clamp v to length len. +proc clamp*(v: TVector; len: CpFloat): TVector {.inline.} = + result = if v.dot(v) > len * len: v.normalize * len else: v +#/ Linearly interpolate between v1 towards v2 by distance d. +proc lerpconst*(v1, v2: TVector; d: CpFloat): TVector {.inline.} = + result = v1 + clamp(v2 - v1, d) #vadd(v1 + vclamp(vsub(v2, v1), d)) +#/ Returns the distance between v1 and v2. +proc dist*(v1, v2: TVector): CpFloat {.inline.} = + result = (v1 - v2).len #vlength(vsub(v1, v2)) +#/ Returns the squared distance between v1 and v2. Faster than cpvdist() when you only need to compare distances. +proc distsq*(v1, v2: TVector): CpFloat {.inline.} = + result = (v1 - v2).lenSq #vlengthsq(vsub(v1, v2)) +#/ Returns true if the distance between v1 and v2 is less than dist. +proc near*(v1, v2: TVector; dist: CpFloat): bool{.inline.} = + result = v1.distSq(v2) < dist * dist + + + +##cpBody.h +proc allocBody*(): PBody {.importc: "cpBodyAlloc", dynlib: Lib.} +proc init*(body: PBody; m: CpFloat; i: CpFloat): PBody {. + importc: "cpBodyInit", dynlib: Lib.} +proc newBody*(m: CpFloat; i: CpFloat): PBody {. + importc: "cpBodyNew", dynlib: Lib.} + +proc initStaticBody*(body: PBody): PBody{. + importc: "cpBodyInitStatic", dynlib: Lib.} +#/ Allocate and initialize a static cpBody. +proc newStatic*(): PBody{.importc: "cpBodyNewStatic", dynlib: Lib.} +#/ Destroy a cpBody. +proc destroy*(body: PBody){.importc: "cpBodyDestroy", dynlib: Lib.} +#/ Destroy and free a cpBody. +proc free*(body: PBody){.importc: "cpBodyFree", dynlib: Lib.} + +#/ Wake up a sleeping or idle body. +proc activate*(body: PBody){.importc: "cpBodyActivate", dynlib: Lib.} +#/ Wake up any sleeping or idle bodies touching a static body. +proc activateStatic*(body: PBody; filter: PShape){. + importc: "cpBodyActivateStatic", dynlib: Lib.} +#/ Force a body to fall asleep immediately. +proc Sleep*(body: PBody){.importc: "cpBodySleep", dynlib: Lib.} +#/ Force a body to fall asleep immediately along with other bodies in a group. +proc SleepWithGroup*(body: PBody; group: PBody){. + importc: "cpBodySleepWithGroup", dynlib: Lib.} +#/ Returns true if the body is sleeping. +proc isSleeping*(body: PBody): bool {.inline.} = + return body.node.root != nil +#/ Returns true if the body is static. +proc isStatic*(body: PBody): bool {.inline.} = + return body.node.idleTime == CpInfinity +#/ Returns true if the body has not been added to a space. +proc isRogue*(body: PBody): bool {.inline.} = + return body.space == nil + +# #define CP_DefineBodyStructGetter(type, member, name) \ +# static inline type cpBodyGet##name(const cpBody *body){return body->member;} +# #define CP_DefineBodyStructSetter(type, member, name) \ +# static inline void cpBodySet##name(cpBody *body, const type value){ \ +# cpBodyActivate(body); \ +# cpBodyAssertSane(body); \ +# body->member = value; \ +# } +# #define CP_DefineBodyStructProperty(type, member, name) \ +# CP_DefineBodyStructGetter(type, member, name) \ +# CP_DefineBodyStructSetter(type, member, name) + +defGetter(PBody, CpFloat, m, Mass) +#/ Set the mass of a body. +when defined(MoreNim): + defSetter(PBody, CpFloat, m, Mass) +else: + proc setMass*(body: PBody; m: CpFloat){. + cdecl, importc: "cpBodySetMass", dynlib: Lib.} + +#/ Get the moment of a body. +defGetter(PBody, CpFloat, i, Moment) +#/ Set the moment of a body. +when defined(MoreNim): + defSetter(PBody, CpFloat, i, Moment) +else: + proc SetMoment*(body: PBody; i: CpFloat) {. + cdecl, importc: "cpBodySetMoment", dynlib: Lib.} + +#/ Get the position of a body. +defGetter(PBody, TVector, p, Pos) +#/ Set the position of a body. +when defined(MoreNim): + defSetter(PBody, TVector, p, Pos) +else: + proc setPos*(body: PBody; pos: TVector) {. + cdecl, importc: "cpBodySetPos", dynlib: Lib.} + +defProp(PBody, TVector, v, Vel) +defProp(PBody, TVector, f, Force) + +#/ Get the angle of a body. +defGetter(PBody, CpFloat, a, Angle) +#/ Set the angle of a body. +proc setAngle*(body: PBody; a: CpFloat){. + cdecl, importc: "cpBodySetAngle", dynlib: Lib.} + +defProp(PBody, CpFloat, w, AngVel) +defProp(PBody, CpFloat, t, Torque) +defGetter(PBody, TVector, rot, Rot) +defProp(PBody, CpFloat, v_limit, VelLimit) +defProp(PBody, CpFloat, w_limit, AngVelLimit) +defProp(PBody, pointer, data, UserData) + +#/ Default Integration functions. +proc UpdateVelocity*(body: PBody; gravity: TVector; damping: CpFloat; dt: CpFloat){. + cdecl, importc: "cpBodyUpdateVelocity", dynlib: Lib.} +proc UpdatePosition*(body: PBody; dt: CpFloat){. + cdecl, importc: "cpBodyUpdatePosition", dynlib: Lib.} +#/ Convert body relative/local coordinates to absolute/world coordinates. +proc Local2World*(body: PBody; v: TVector): TVector{.inline.} = + result = body.p + v.rotate(body.rot) ##return cpvadd(body.p, cpvrotate(v, body.rot)) +#/ Convert body absolute/world coordinates to relative/local coordinates. +proc world2Local*(body: PBody; v: TVector): TVector{.inline.} = + result = (v - body.p).unrotate(body.rot) +#/ Set the forces and torque or a body to zero. +proc resetForces*(body: PBody){. + cdecl, importc: "cpBodyResetForces", dynlib: Lib.} +#/ Apply an force (in world coordinates) to the body at a point relative to the center of gravity (also in world coordinates). +proc applyForce*(body: PBody; f, r: TVector){. + cdecl, importc: "cpBodyApplyForce", dynlib: Lib.} +#/ Apply an impulse (in world coordinates) to the body at a point relative to the center of gravity (also in world coordinates). +proc applyImpulse*(body: PBody; j, r: TVector){. + cdecl, importc: "cpBodyApplyImpulse", dynlib: Lib.} +#/ Get the velocity on a body (in world units) at a point on the body in world coordinates. + +proc getVelAtWorldPoint*(body: PBody; point: TVector): TVector{. + cdecl, importc: "cpBodyGetVelAtWorldPoint", dynlib: Lib.} +#/ Get the velocity on a body (in world units) at a point on the body in local coordinates. +proc getVelAtLocalPoint*(body: PBody; point: TVector): TVector{. + cdecl, importc: "cpBodyGetVelAtLocalPoint", dynlib: Lib.} +#/ Get the kinetic energy of a body. +# static inline CpFloat cpBodyKineticEnergy(const cpBody *body) +# { +# // Need to do some fudging to avoid NaNs +# cpFloat vsq = cpvdot(body->v, body->v); +# cpFloat wsq = body->w*body->w; +# return (vsq ? vsq*body->m : 0.0f) + (wsq ? wsq*body->i : 0.0f); +# } +proc kineticEnergy*(body: PBOdy): CpFloat = + result = (body.v.dot(body.v) * body.m) + (body.w * body.w * body.i) + +#/ Call @c func once for each shape attached to @c body and added to the space. +proc eachShape*(body: PBody; fun: TBodyShapeIteratorFunc; + data: pointer){. + cdecl, importc: "cpBodyEachShape", dynlib: Lib.} +#/ Call @c func once for each constraint attached to @c body and added to the space. +proc eachConstraint*(body: PBody; fun: TBodyConstraintIteratorFunc; + data: pointer) {. + cdecl, importc: "cpBodyEachConstraint", dynlib: Lib.} +#/ Call @c func once for each arbiter that is currently active on the body. +proc eachArbiter*(body: PBody; fun: TBodyArbiterIteratorFunc; + data: pointer){. + cdecl, importc: "cpBodyEachArbiter", dynlib: Lib.} +#/ Allocate a spatial hash. +proc SpaceHashAlloc*(): PSpaceHash{. + cdecl, importc: "cpSpaceHashAlloc", dynlib: Lib.} +#/ Initialize a spatial hash. +proc SpaceHashInit*(hash: PSpaceHash; celldim: CpFloat; numcells: cint; + bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{. + cdecl, importc: "cpSpaceHashInit", dynlib: Lib.} +#/ Allocate and initialize a spatial hash. +proc SpaceHashNew*(celldim: CpFloat; cells: cint; bbfun: TSpatialIndexBBFunc; + staticIndex: PSpatialIndex): PSpatialIndex{. + cdecl, importc: "cpSpaceHashNew", dynlib: Lib.} +#/ Change the cell dimensions and table size of the spatial hash to tune it. +#/ The cell dimensions should roughly match the average size of your objects +#/ and the table size should be ~10 larger than the number of objects inserted. +#/ Some trial and error is required to find the optimum numbers for efficiency. +proc SpaceHashResize*(hash: PSpaceHash; celldim: CpFloat; numcells: cint){. + cdecl, importc: "cpSpaceHashResize", dynlib: Lib.} +#MARK: AABB Tree + + +#/ Allocate a bounding box tree. +proc BBTreeAlloc*(): PBBTree{.cdecl, importc: "cpBBTreeAlloc", dynlib: Lib.} +#/ Initialize a bounding box tree. +proc BBTreeInit*(tree: PBBTree; bbfun: TSpatialIndexBBFunc; + staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl, + importc: "cpBBTreeInit", dynlib: Lib.} +#/ Allocate and initialize a bounding box tree. +proc BBTreeNew*(bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{. + cdecl, importc: "cpBBTreeNew", dynlib: Lib.} +#/ Perform a static top down optimization of the tree. +proc BBTreeOptimize*(index: PSpatialIndex){. + cdecl, importc: "cpBBTreeOptimize", dynlib: Lib.} +#/ Set the velocity function for the bounding box tree to enable temporal coherence. + +proc BBTreeSetVelocityFunc*(index: PSpatialIndex; fun: TBBTreeVelocityFunc){. + cdecl, importc: "cpBBTreeSetVelocityFunc", dynlib: Lib.} +#MARK: Single Axis Sweep + + +#/ Allocate a 1D sort and sweep broadphase. + +proc Sweep1DAlloc*(): ptr TSweep1D{.cdecl, importc: "cpSweep1DAlloc", + dynlib: Lib.} +#/ Initialize a 1D sort and sweep broadphase. + +proc Sweep1DInit*(sweep: ptr TSweep1D; bbfun: TSpatialIndexBBFunc; + staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl, + importc: "cpSweep1DInit", dynlib: Lib.} +#/ Allocate and initialize a 1D sort and sweep broadphase. + +proc Sweep1DNew*(bbfun: TSpatialIndexBBFunc; staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{. + cdecl, importc: "cpSweep1DNew", dynlib: Lib.} + + + +defProp(PArbiter, CpFloat, e, Elasticity) +defProp(PArbiter, CpFloat, u, Friction) +defProp(PArbiter, TVector, surface_vr, SurfaceVelocity) + +#/ Calculate the total impulse that was applied by this +#/ This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback. +proc totalImpulse*(obj: PArbiter): TVector {.cdecl, importc: "cpArbiterTotalImpulse", dynlib: Lib.} + +#/ Calculate the total impulse including the friction that was applied by this arbiter. +#/ This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback. +proc totalImpulseWithFriction*(obj: PArbiter): TVector {.cdecl, importc: "cpArbiterTotalImpulseWithFriction", dynlib: Lib.} + +#/ Calculate the amount of energy lost in a collision including static, but not dynamic friction. +#/ This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback. +proc totalKE*(obj: PArbiter): CpFloat {.cdecl, importc: "cpArbiterTotalKE", dynlib: Lib.} + + +#/ Causes a collision pair to be ignored as if you returned false from a begin callback. +#/ If called from a pre-step callback, you will still need to return false +#/ if you want it to be ignored in the current step. +proc ignore*(arb: PArbiter) {.cdecl, importc: "cpArbiterIgnore", dynlib: Lib.} + +#/ Return the colliding shapes involved for this arbiter. +#/ The order of their cpSpace.collision_type values will match +#/ the order set when the collision handler was registered. +proc getShapes*(arb: PArbiter, a, b: var PShape) {.inline.} = + if arb.swappedColl.bool: + a = arb.b + b = arb.a + else: + a = arb.a + b = arb.b + +#/ A macro shortcut for defining and retrieving the shapes from an arbiter. +#define CP_ARBITER_GET_SHAPES(arb, a, b) cpShape *a, *b; cpArbiterGetShapes(arb, &a, &b); +template getShapes*(arb: PArbiter, name1, name2: untyped) = + var name1, name2: PShape + getShapes(arb, name1, name2) + + +#/ Return the colliding bodies involved for this arbiter. +#/ The order of the cpSpace.collision_type the bodies are associated with values will match +#/ the order set when the collision handler was registered. +#proc getBodies*(arb: PArbiter, a, b: var PBody) {.inline.} = +# getShapes(arb, shape1, shape2) +# a = shape1.body +# b = shape2.body + +#/ A macro shortcut for defining and retrieving the bodies from an arbiter. +#define CP_ARBITER_GET_BODIES(arb, a, b) cpBody *a, *b; cpArbiterGetBodies(arb, &a, &b); +template getBodies*(arb: PArbiter, name1, name2: untyped) = + var name1, name2: PBOdy + getBodies(arb, name1, name2) + +proc isFirstContact*(arb: PArbiter): bool {.inline.} = + result = arb.state == ArbiterStateFirstColl + +proc getCount*(arb: PArbiter): cint {.inline.} = + result = arb.numContacts + +#/ Return a contact set from an arbiter. +proc getContactPointSet*(arb: PArbiter): TContactPointSet {. + cdecl, importc: "cpArbiterGetContactPointSet", dynlib: Lib.} +#/ Get the normal of the @c ith contact point. +proc getNormal*(arb: PArbiter; i: cint): TVector {. + cdecl, importc: "cpArbiterGetNormal", dynlib: Lib.} +#/ Get the position of the @c ith contact point. +proc getPoint*(arb: PArbiter; i: cint): TVector {. + cdecl, importc: "cpArbiterGetPoint", dynlib: Lib.} +#/ Get the depth of the @c ith contact point. +proc getDepth*(arb: PArbiter; i: cint): CpFloat {. + cdecl, importc: "cpArbiterGetDepth", dynlib: Lib.} + +##Shapes +template defShapeSetter(memberType: typedesc, memberName: untyped, procName: untyped, activates: bool) = + proc `set procName`*(obj: PShape, value: memberType) {.cdecl.} = + if activates and obj.body != nil: obj.body.activate() + obj.memberName = value +template defShapeProp(memberType: typedesc, memberName: untyped, procName: untyped, activates: bool) = + defGetter(PShape, memberType, memberName, procName) + defShapeSetter(memberType, memberName, procName, activates) + +#/ Destroy a shape. +proc destroy*(shape: PShape) {. + cdecl, importc: "cpShapeDestroy", dynlib: Lib.} +#/ Destroy and Free a shape. +proc free*(shape: PShape){. + cdecl, importc: "cpShapeFree", dynlib: Lib.} +#/ Update, cache and return the bounding box of a shape based on the body it's attached to. +proc cacheBB*(shape: PShape): TBB{. + cdecl, importc: "cpShapeCacheBB", dynlib: Lib.} +#/ Update, cache and return the bounding box of a shape with an explicit transformation. +proc update*(shape: PShape; pos: TVector; rot: TVector): TBB {. + cdecl, importc: "cpShapeUpdate", dynlib: Lib.} +#/ Test if a point lies within a shape. +proc pointQuery*(shape: PShape; p: TVector): Bool32 {. + cdecl, importc: "cpShapePointQuery", dynlib: Lib.} + +#/ Perform a nearest point query. It finds the closest point on the surface of shape to a specific point. +#/ The value returned is the distance between the points. A negative distance means the point is inside the shape. +proc nearestPointQuery*(shape: PShape; p: TVector; res: PNearestPointQueryInfo): CpFloat {. + cdecl, importc: "cpShapeNearestPointQuery", dynlib: Lib.} +#/ Perform a segment query against a shape. @c info must be a pointer to a valid cpSegmentQueryInfo structure. +proc segmentQuery*(shape: PShape, a, b: TVector, info: PSegmentQueryInfo): bool {. + cdecl, importc: "cpShapeSegmentQuery", dynlib: Lib.} + +#/ Get the hit point for a segment query. +## Possibly change; info to PSegmentQueryInfo +proc queryHitPoint*(start, to: TVector, info: TSegmentQueryInfo): TVector {.inline.} = + result = start.lerp(to, info.t) + +#/ Get the hit distance for a segment query. +proc queryHitDist*(start, to: TVector, info: TSegmentQueryInfo): CpFloat {.inline.} = + result = start.dist(to) * info.t + +defGetter(PShape, PSpace, space, Space) + +defGetter(PShape, PBody, body, Body) +proc setBody*(shape: PShape, value: PBody) {. + cdecl, importc: "cpShapeSetBody", dynlib: Lib.} + + +defGetter(PShape, TBB, bb, BB) +defShapeProp(Bool32, sensor, Sensor, true) +defShapeProp(CpFloat, e, Elasticity, false) +defShapeProp(CpFloat, u, Friction, true) +defShapeProp(TVector, surface_v, SurfaceVelocity, true) +defShapeProp(pointer, data, UserData, false) +defShapeProp(TCollisionType, collision_type, CollisionType, true) +defShapeProp(TGroup, group, Group, true) +defShapeProp(TLayers, layers, Layers, true) + +#/ When initializing a shape, it's hash value comes from a counter. +#/ Because the hash value may affect iteration order, you can reset the shape ID counter +#/ when recreating a space. This will make the simulation be deterministic. +proc resetShapeIdCounter*(): void {.cdecl, importc: "cpResetShapeIdCounter", dynlib: Lib.} +#/ Allocate a circle shape. +proc CircleShapeAlloc*(): PCircleShape {.cdecl, importc: "cpCircleShapeAlloc", dynlib: Lib.} +#/ Initialize a circle shape. +proc init*(circle: PCircleShape, body: PBody, radius: CpFloat, offset: TVector): PCircleShape {. + cdecl, importc: "cpCircleShapeInit", dynlib: Lib.} +#/ Allocate and initialize a circle shape. +proc newCircleShape*(body: PBody, radius: CpFloat, offset: TVector): PShape {. + cdecl, importc: "cpCircleShapeNew", dynlib: Lib.} + +proc getCircleOffset*(shape: PShape): TVector {. + cdecl, importc: "cpCircleShapeGetOffset", dynlib: Lib.} +proc getCircleRadius*(shape: PShape): CpFloat {. + cdecl, importc: "cpCircleShapeGetRadius", dynlib: Lib.} + + +#/ Allocate a polygon shape. +proc allocPolyShape*(): PPolyShape {. + cdecl, importc: "cpPolyShapeAlloc", dynlib: Lib.} +#/ Initialize a polygon shape. +#/ A convex hull will be created from the vertices. +proc init*(poly: PPolyShape; body: PBody, numVerts: cint; + verts: ptr TVector; offset: TVector): PPolyShape {. + cdecl, importc: "cpPolyShapeInit", dynlib: Lib.} +#/ Allocate and initialize a polygon shape. +#/ A convex hull will be created from the vertices. +proc newPolyShape*(body: PBody; numVerts: cint; verts: ptr TVector; + offset: TVector): PShape {. + cdecl, importc: "cpPolyShapeNew", dynlib: Lib.} +#/ Initialize a box shaped polygon shape. +proc init*(poly: PPolyShape; body: PBody; width, height: CpFloat): PPolyShape {. + cdecl, importc: "cpBoxShapeInit", dynlib: Lib.} +#/ Initialize an offset box shaped polygon shape. +proc init*(poly: PPolyShape; body: PBody; box: TBB): PPolyShape {. + cdecl, importc: "cpBoxShapeInit2", dynlib: Lib.} +#/ Allocate and initialize a box shaped polygon shape. +proc newBoxShape*(body: PBody; width, height: CpFloat): PShape {. + cdecl, importc: "cpBoxShapeNew", dynlib: Lib.} +#/ Allocate and initialize an offset box shaped polygon shape. +proc newBoxShape*(body: PBody; box: TBB): PShape {. + cdecl, importc: "cpBoxShapeNew2", dynlib: Lib.} + +#/ Check that a set of vertices is convex and has a clockwise winding. +#/ NOTE: Due to floating point precision issues, hulls created with cpQuickHull() are not guaranteed to validate! +proc validatePoly*(verts: ptr TVector; numVerts: cint): bool {. + cdecl, importc: "cpPolyValidate", dynlib: Lib.} +#/ Get the number of verts in a polygon shape. +proc getNumVerts*(shape: PShape): cint {. + cdecl, importc: "cpPolyShapeGetNumVerts", dynlib: Lib.} +#/ Get the @c ith vertex of a polygon shape. +proc getVert*(shape: PShape; index: cint): TVector {. + cdecl, importc: "cpPolyShapeGetVert", dynlib: Lib.} + +#/ Allocate a segment shape. +proc allocSegmentShape*(): PSegmentShape {. + cdecl, importc: "cpSegmentShapeAlloc", dynlib: Lib.} +#/ Initialize a segment shape. +proc init*(seg: PSegmentShape, body: PBody, a, b: TVector, radius: CpFloat): PSegmentShape {. + cdecl, importc: "cpSegmentShapeInit", dynlib: Lib.} +#/ Allocate and initialize a segment shape. +proc newSegmentShape*(body: PBody, a, b: TVector, radius: CpFloat): PShape {. + cdecl, importc: "cpSegmentShapeNew", dynlib: Lib.} + +proc setSegmentNeighbors*(shape: PShape, prev, next: TVector) {. + cdecl, importc: "cpSegmentShapeSetNeighbors", dynlib: Lib.} +proc getSegmentA*(shape: PShape): TVector {. + cdecl, importc: "cpSegmentShapeGetA", dynlib: Lib.} +proc getSegmentB*(shape: PShape): TVector {. + cdecl, importc: "cpSegmentShapeGetB", dynlib: Lib.} +proc getSegmentNormal*(shape: PShape): TVector {. + cdecl, importc: "cpSegmentShapeGetNormal", dynlib: Lib.} +proc getSegmentRadius*(shape: PShape): CpFloat {. + cdecl, importc: "cpSegmentShapeGetRadius", dynlib: Lib.} + + +#/ Version string. +#var VersionString*{.importc: "cpVersionString", dynlib: Lib.}: cstring +#/ Calculate the moment of inertia for a circle. +#/ @c r1 and @c r2 are the inner and outer diameters. A solid circle has an inner diameter of 0. +when defined(MoreNim): + proc momentForCircle*(m, r1, r2: CpFloat; offset: TVector): CpFloat {.cdecl.} = + result = m * (0.5 * (r1 * r1 + r2 * r2) + lenSq(offset)) +else: + proc momentForCircle*(m, r1, r2: CpFloat; offset: TVector): CpFloat {. + cdecl, importc: "cpMomentForCircle", dynlib: Lib.} + +#/ Calculate area of a hollow circle. +#/ @c r1 and @c r2 are the inner and outer diameters. A solid circle has an inner diameter of 0. +proc AreaForCircle*(r1: CpFloat; r2: CpFloat): CpFloat {. + cdecl, importc: "cpAreaForCircle", dynlib: Lib.} +#/ Calculate the moment of inertia for a line segment. +#/ Beveling radius is not supported. +proc MomentForSegment*(m: CpFloat; a, b: TVector): CpFloat {. + cdecl, importc: "cpMomentForSegment", dynlib: Lib.} +#/ Calculate the area of a fattened (capsule shaped) line segment. +proc AreaForSegment*(a, b: TVector; r: CpFloat): CpFloat {. + cdecl, importc: "cpAreaForSegment", dynlib: Lib.} +#/ Calculate the moment of inertia for a solid polygon shape assuming it's center of gravity is at it's centroid. The offset is added to each vertex. +proc MomentForPoly*(m: CpFloat; numVerts: cint; verts: ptr TVector; offset: TVector): CpFloat {. + cdecl, importc: "cpMomentForPoly", dynlib: Lib.} +#/ Calculate the signed area of a polygon. A Clockwise winding gives positive area. +#/ This is probably backwards from what you expect, but matches Chipmunk's the winding for poly shapes. +proc AreaForPoly*(numVerts: cint; verts: ptr TVector): CpFloat {. + cdecl, importc: "cpAreaForPoly", dynlib: Lib.} +#/ Calculate the natural centroid of a polygon. +proc CentroidForPoly*(numVerts: cint; verts: ptr TVector): TVector {. + cdecl, importc: "cpCentroidForPoly", dynlib: Lib.} +#/ Center the polygon on the origin. (Subtracts the centroid of the polygon from each vertex) +proc RecenterPoly*(numVerts: cint; verts: ptr TVector) {. + cdecl, importc: "cpRecenterPoly", dynlib: Lib.} +#/ Calculate the moment of inertia for a solid box. +proc MomentForBox*(m, width, height: CpFloat): CpFloat {. + cdecl, importc: "cpMomentForBox", dynlib: Lib.} +#/ Calculate the moment of inertia for a solid box. +proc MomentForBox2*(m: CpFloat; box: TBB): CpFloat {. + cdecl, importc: "cpMomentForBox2", dynlib: Lib.} + + + +##constraints +type + #TODO: all these are private + #TODO: defConstraintProp() + PPinJoint = ptr TPinJoint + TPinJoint{.pf.} = object + constraint: PConstraint + anchr1: TVector + anchr2: TVector + dist: CpFloat + r1: TVector + r2: TVector + n: TVector + nMass: CpFloat + jnAcc: CpFloat + jnMax: CpFloat + bias: CpFloat + PSlideJoint = ptr TSlideJoint + TSlideJoint{.pf.} = object + constraint: PConstraint + anchr1: TVector + anchr2: TVector + min: CpFloat + max: CpFloat + r1: TVector + r2: TVector + n: TVector + nMass: CpFloat + jnAcc: CpFloat + jnMax: CpFloat + bias: CpFloat + PPivotJoint = ptr TPivotJoint + TPivotJoint{.pf.} = object + constraint: PConstraint + anchr1: TVector + anchr2: TVector + r1: TVector + r2: TVector + k1: TVector + k2: TVector + jAcc: TVector + jMaxLen: CpFloat + bias: TVector + PGrooveJoint = ptr TGrooveJoint + TGrooveJoint{.pf.} = object + constraint: PConstraint + grv_n: TVector + grv_a: TVector + grv_b: TVector + anchr2: TVector + grv_tn: TVector + clamp: CpFloat + r1: TVector + r2: TVector + k1: TVector + k2: TVector + jAcc: TVector + jMaxLen: CpFloat + bias: TVector + PDampedSpring = ptr TDampedSpring + TDampedSpring{.pf.} = object + constraint: PConstraint + anchr1: TVector + anchr2: TVector + restLength: CpFloat + stiffness: CpFloat + damping: CpFloat + springForceFunc: TDampedSpringForceFunc + target_vrn: CpFloat + v_coef: CpFloat + r1: TVector + r2: TVector + nMass: CpFloat + n: TVector + PDampedRotarySpring = ptr TDampedRotarySpring + TDampedRotarySpring{.pf.} = object + constraint: PConstraint + restAngle: CpFloat + stiffness: CpFloat + damping: CpFloat + springTorqueFunc: TDampedRotarySpringTorqueFunc + target_wrn: CpFloat + w_coef: CpFloat + iSum: CpFloat + PRotaryLimitJoint = ptr TRotaryLimitJoint + TRotaryLimitJoint{.pf.} = object + constraint: PConstraint + min: CpFloat + max: CpFloat + iSum: CpFloat + bias: CpFloat + jAcc: CpFloat + jMax: CpFloat + PRatchetJoint = ptr TRatchetJoint + TRatchetJoint{.pf.} = object + constraint: PConstraint + angle: CpFloat + phase: CpFloat + ratchet: CpFloat + iSum: CpFloat + bias: CpFloat + jAcc: CpFloat + jMax: CpFloat + PGearJoint = ptr TGearJoint + TGearJoint{.pf.} = object + constraint: PConstraint + phase: CpFloat + ratio: CpFloat + ratio_inv: CpFloat + iSum: CpFloat + bias: CpFloat + jAcc: CpFloat + jMax: CpFloat + PSimpleMotor = ptr TSimpleMotor + TSimpleMotor{.pf.} = object + constraint: PConstraint + rate: CpFloat + iSum: CpFloat + jAcc: CpFloat + jMax: CpFloat + TDampedSpringForceFunc* = proc (spring: PConstraint; dist: CpFloat): CpFloat{. + cdecl.} + TDampedRotarySpringTorqueFunc* = proc (spring: PConstraint; + relativeAngle: CpFloat): CpFloat {.cdecl.} +#/ Destroy a constraint. +proc destroy*(constraint: PConstraint){. + cdecl, importc: "cpConstraintDestroy", dynlib: Lib.} +#/ Destroy and free a constraint.111 +proc free*(constraint: PConstraint){. + cdecl, importc: "cpConstraintFree", dynlib: Lib.} + +#/ @private +proc activateBodies(constraint: PConstraint) {.inline.} = + if not constraint.a.isNil: constraint.a.activate() + if not constraint.b.isNil: constraint.b.activate() + +# /// @private +# #define CP_DefineConstraintStructGetter(type, member, name) \ +# static inline type cpConstraint##Get##name(const cpConstraint *constraint){return constraint->member;} +# /// @private +# #define CP_DefineConstraintStructSetter(type, member, name) \ +# static inline void cpConstraint##Set##name(cpConstraint *constraint, type value){ \ +# cpConstraintActivateBodies(constraint); \ +# constraint->member = value; \ +# } +template defConstraintSetter(memberType: typedesc, member, name: untyped) = + proc `set name`*(constraint: PConstraint, value: memberType) {.cdecl.} = + activateBodies(constraint) + constraint.member = value +template defConstraintProp(memberType: typedesc, member, name: untyped) = + defGetter(PConstraint, memberType, member, name) + defConstraintSetter(memberType, member, name) +# CP_DefineConstraintStructGetter(cpSpace*, CP_PRIVATE(space), Space) +defGetter(PConstraint, PSpace, space, Space) +defGetter(PConstraint, PBody, a, A) +defGetter(PConstraint, PBody, a, B) +defGetter(PConstraint, CpFloat, maxForce, MaxForce) +defGetter(PConstraint, CpFloat, errorBias, ErrorBias) +defGetter(PConstraint, CpFloat, maxBias, MaxBias) +defGetter(PConstraint, TConstraintPreSolveFunc, preSolve, PreSolveFunc) +defGetter(PConstraint, TConstraintPostSolveFunc, postSolve, PostSolveFunc) +defGetter(PConstraint, CpDataPointer, data, UserData) +# Get the last impulse applied by this constraint. +proc getImpulse*(constraint: PConstraint): CpFloat {.inline.} = + return constraint.klass.getImpulse(constraint) + +# #define cpConstraintCheckCast(constraint, struct) \ +# cpAssertHard(constraint->CP_PRIVATE(klass) == struct##GetClass(), "Constraint is not a "#struct) +# #define CP_DefineConstraintGetter(struct, type, member, name) \ +# static inline type struct##Get##name(const cpConstraint *constraint){ \ +# cpConstraintCheckCast(constraint, struct); \ +# return ((struct *)constraint)->member; \ +# } +# #define CP_DefineConstraintSetter(struct, type, member, name) \ +# static inline void struct##Set##name(cpConstraint *constraint, type value){ \ +# cpConstraintCheckCast(constraint, struct); \ +# cpConstraintActivateBodies(constraint); \ +# ((struct *)constraint)->member = value; \ +# } +template constraintCheckCast(constraint: PConstraint, ctype: untyped) = + assert(constraint.klass == `ctype getClass`(), "Constraint is the wrong class") +template defCGetter(ctype: untyped, memberType: typedesc, member, name: untyped) = + proc `get ctype name`*(constraint: PConstraint): memberType {.cdecl.} = + constraintCheckCast(constraint, ctype) + result = cast[`P ctype`](constraint).member +template defCSetter(ctype: untyped, memberType: typedesc, member, name: untyped) = + proc `set ctype name`*(constraint: PConstraint, value: memberType) {.cdecl.} = + constraintCheckCast(constraint, ctype) + activateBodies(constraint) + cast[`P ctype`](constraint).member = value +template defCProp(ctype: untyped, memberType: typedesc, member, name: untyped) = + defCGetter(ctype, memberType, member, name) + defCSetter(ctype, memberType, member, name) + +proc PinJointGetClass*(): PConstraintClass{. + cdecl, importc: "cpPinJointGetClass", dynlib: Lib.} +#/ @private + +#/ Allocate a pin joint. +proc AllocPinJoint*(): PPinJoint{. + cdecl, importc: "cpPinJointAlloc", dynlib: Lib.} +#/ Initialize a pin joint. +proc PinJointInit*(joint: PPinJoint; a: PBody; b: PBody; anchr1: TVector; + anchr2: TVector): PPinJoint{. + cdecl, importc: "cpPinJointInit", dynlib: Lib.} +#/ Allocate and initialize a pin joint. +proc newPinJoint*(a: PBody; b: PBody; anchr1: TVector; anchr2: TVector): PConstraint{. + cdecl, importc: "cpPinJointNew", dynlib: Lib.} +# CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr1, Anchr1) +defCProp(PinJoint, TVector, anchr1, Anchr1) +defCProp(PinJoint, TVector, anchr2, Anchr2) +defCProp(PinJoint, CpFloat, dist, Dist) + +proc SlideJointGetClass*(): PConstraintClass{. + cdecl, importc: "cpSlideJointGetClass", dynlib: Lib.} +#/ Allocate a slide joint. +proc AllocSlideJoint*(): PSlideJoint{. + cdecl, importc: "cpSlideJointAlloc", dynlib: Lib.} +#/ Initialize a slide joint. +proc init*(joint: PSlideJoint; a, b: PBody; anchr1, anchr2: TVector; + min, max: CpFloat): PSlideJoint{. + cdecl, importc: "cpSlideJointInit", dynlib: Lib.} +#/ Allocate and initialize a slide joint. +proc newSlideJoint*(a, b: PBody; anchr1, anchr2: TVector; min, max: CpFloat): PConstraint{. + cdecl, importc: "cpSlideJointNew", dynlib: Lib.} + +defCProp(SlideJoint, TVector, anchr1, Anchr1) +defCProp(SlideJoint, TVector, anchr2, Anchr2) +defCProp(SlideJoint, CpFloat, min, Min) +defCProp(SlideJoint, CpFloat, max, Max) + +proc PivotJointGetClass*(): PConstraintClass {. + cdecl, importc: "cpPivotJointGetClass", dynlib: Lib.} + +#/ Allocate a pivot joint +proc allocPivotJoint*(): PPivotJoint{. + cdecl, importc: "cpPivotJointAlloc", dynlib: Lib.} +#/ Initialize a pivot joint. +proc init*(joint: PPivotJoint; a, b: PBody; anchr1, anchr2: TVector): PPivotJoint{. + cdecl, importc: "cpPivotJointInit", dynlib: Lib.} +#/ Allocate and initialize a pivot joint. +proc newPivotJoint*(a, b: PBody; pivot: TVector): PConstraint{. + cdecl, importc: "cpPivotJointNew", dynlib: Lib.} +#/ Allocate and initialize a pivot joint with specific anchors. +proc newPivotJoint*(a, b: PBody; anchr1, anchr2: TVector): PConstraint{. + cdecl, importc: "cpPivotJointNew2", dynlib: Lib.} + +defCProp(PivotJoint, TVector, anchr1, Anchr1) +defCProp(PivotJoint, TVector, anchr2, Anchr2) + + +proc GrooveJointGetClass*(): PConstraintClass{. + cdecl, importc: "cpGrooveJointGetClass", dynlib: Lib.} +#/ Allocate a groove joint. +proc GrooveJointAlloc*(): ptr TGrooveJoint{. + cdecl, importc: "cpGrooveJointAlloc", dynlib: Lib.} +#/ Initialize a groove joint. +proc Init*(joint: PGrooveJoint; a, b: PBody; groove_a, groove_b, anchr2: TVector): PGrooveJoint{. + cdecl, importc: "cpGrooveJointInit", dynlib: Lib.} +#/ Allocate and initialize a groove joint. +proc newGrooveJoint*(a, b: PBody; groove_a, groove_b, anchr2: TVector): PConstraint{. + cdecl, importc: "cpGrooveJointNew", dynlib: Lib.} + +defCGetter(GrooveJoint, TVector, grv_a, GrooveA) +defCGetter(GrooveJoint, TVector, grv_b, GrooveB) +# /// Set endpoint a of a groove joint's groove +proc SetGrooveA*(constraint: PConstraint, value: TVector) {. + cdecl, importc: "cpGrooveJointSetGrooveA", dynlib: Lib.} +# /// Set endpoint b of a groove joint's groove +proc SetGrooveB*(constraint: PConstraint, value: TVector) {. + cdecl, importc: "cpGrooveJointSetGrooveB", dynlib: Lib.} +defCProp(GrooveJoint, TVector, anchr2, Anchr2) + +proc DampedSpringGetClass*(): PConstraintClass{. + cdecl, importc: "cpDampedSpringGetClass", dynlib: Lib.} +#/ Allocate a damped spring. +proc AllocDampedSpring*(): PDampedSpring{. + cdecl, importc: "cpDampedSpringAlloc", dynlib: Lib.} +#/ Initialize a damped spring. +proc init*(joint: PDampedSpring; a, b: PBody; anchr1, anchr2: TVector; + restLength, stiffness, damping: CpFloat): PDampedSpring{. + cdecl, importc: "cpDampedSpringInit", dynlib: Lib.} +#/ Allocate and initialize a damped spring. +proc newDampedSpring*(a, b: PBody; anchr1, anchr2: TVector; + restLength, stiffness, damping: CpFloat): PConstraint{. + cdecl, importc: "cpDampedSpringNew", dynlib: Lib.} + +# CP_DefineConstraintProperty(cpDampedSpring, cpVect, anchr1, Anchr1) +defCProp(DampedSpring, TVector, anchr1, Anchr1) +defCProp(DampedSpring, TVector, anchr2, Anchr2) +defCProp(DampedSpring, CpFloat, restLength, RestLength) +defCProp(DampedSpring, CpFloat, stiffness, Stiffness) +defCProp(DampedSpring, CpFloat, damping, Damping) +defCProp(DampedSpring, TDampedSpringForceFunc, springForceFunc, SpringForceFunc) + + +proc DampedRotarySpringGetClass*(): PConstraintClass{. + cdecl, importc: "cpDampedRotarySpringGetClass", dynlib: Lib.} + +#/ Allocate a damped rotary spring. +proc DampedRotarySpringAlloc*(): PDampedRotarySpring{. + cdecl, importc: "cpDampedRotarySpringAlloc", dynlib: Lib.} +#/ Initialize a damped rotary spring. +proc init*(joint: PDampedRotarySpring; a, b: PBody; + restAngle, stiffness, damping: CpFloat): PDampedRotarySpring{. + cdecl, importc: "cpDampedRotarySpringInit", dynlib: Lib.} +#/ Allocate and initialize a damped rotary spring. +proc DampedRotarySpringNew*(a, b: PBody; restAngle, stiffness, damping: CpFloat): PConstraint{. + cdecl, importc: "cpDampedRotarySpringNew", dynlib: Lib.} + +defCProp(DampedRotarySpring, CpFloat, restAngle, RestAngle) +defCProp(DampedRotarySpring, CpFloat, stiffness, Stiffness) +defCProp(DampedRotarySpring, CpFloat, damping, Damping) +defCProp(DampedRotarySpring, TDampedRotarySpringTorqueFunc, springTorqueFunc, SpringTorqueFunc) + + +proc RotaryLimitJointGetClass*(): PConstraintClass{. + cdecl, importc: "cpRotaryLimitJointGetClass", dynlib: Lib.} +#/ Allocate a damped rotary limit joint. +proc allocRotaryLimitJoint*(): PRotaryLimitJoint{. + cdecl, importc: "cpRotaryLimitJointAlloc", dynlib: Lib.} +#/ Initialize a damped rotary limit joint. +proc init*(joint: PRotaryLimitJoint; a, b: PBody; min, max: CpFloat): PRotaryLimitJoint{. + cdecl, importc: "cpRotaryLimitJointInit", dynlib: Lib.} +#/ Allocate and initialize a damped rotary limit joint. +proc newRotaryLimitJoint*(a, b: PBody; min, max: CpFloat): PConstraint{. + cdecl, importc: "cpRotaryLimitJointNew", dynlib: Lib.} + +defCProp(RotaryLimitJoint, CpFloat, min, Min) +defCProp(RotaryLimitJoint, CpFloat, max, Max) + + +proc RatchetJointGetClass*(): PConstraintClass{. + cdecl, importc: "cpRatchetJointGetClass", dynlib: Lib.} +#/ Allocate a ratchet joint. +proc AllocRatchetJoint*(): PRatchetJoint{. + cdecl, importc: "cpRatchetJointAlloc", dynlib: Lib.} +#/ Initialize a ratched joint. +proc init*(joint: PRatchetJoint; a, b: PBody; phase, ratchet: CpFloat): PRatchetJoint{. + cdecl, importc: "cpRatchetJointInit", dynlib: Lib.} +#/ Allocate and initialize a ratchet joint. +proc NewRatchetJoint*(a, b: PBody; phase, ratchet: CpFloat): PConstraint{. + cdecl, importc: "cpRatchetJointNew", dynlib: Lib.} + +defCProp(RatchetJoint, CpFloat, angle, Angle) +defCProp(RatchetJoint, CpFloat, phase, Phase) +defCProp(RatchetJoint, CpFloat, ratchet, Ratchet) + + +proc GearJointGetClass*(): PConstraintClass{.cdecl, + importc: "cpGearJointGetClass", dynlib: Lib.} +#/ Allocate a gear joint. +proc AllocGearJoint*(): PGearJoint{. + cdecl, importc: "cpGearJointAlloc", dynlib: Lib.} +#/ Initialize a gear joint. +proc init*(joint: PGearJoint; a, b: PBody, phase, ratio: CpFloat): PGearJoint{. + cdecl, importc: "cpGearJointInit", dynlib: Lib.} +#/ Allocate and initialize a gear joint. +proc NewGearJoint*(a, b: PBody; phase, ratio: CpFloat): PConstraint{. + cdecl, importc: "cpGearJointNew", dynlib: Lib.} + +defCProp(GearJoint, CpFloat, phase, Phase) +defCGetter(GearJoint, CpFloat, ratio, Ratio) +#/ Set the ratio of a gear joint. +proc GearJointSetRatio*(constraint: PConstraint; value: CpFloat){. + cdecl, importc: "cpGearJointSetRatio", dynlib: Lib.} + + +proc SimpleMotorGetClass*(): PConstraintClass{. + cdecl, importc: "cpSimpleMotorGetClass", dynlib: Lib.} +#/ Allocate a simple motor. +proc AllocSimpleMotor*(): PSimpleMotor{. + cdecl, importc: "cpSimpleMotorAlloc", dynlib: Lib.} +#/ initialize a simple motor. +proc init*(joint: PSimpleMotor; a, b: PBody; + rate: CpFloat): PSimpleMotor{. + cdecl, importc: "cpSimpleMotorInit", dynlib: Lib.} +#/ Allocate and initialize a simple motor. +proc newSimpleMotor*(a, b: PBody; rate: CpFloat): PConstraint{. + cdecl, importc: "cpSimpleMotorNew", dynlib: Lib.} + +defCProp(SimpleMotor, CpFloat, rate, Rate) + + + diff --git a/tests/manyloc/keineschweine/dependencies/enet/enet.nim b/tests/manyloc/keineschweine/dependencies/enet/enet.nim new file mode 100644 index 000000000..5dee6ae9c --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/enet/enet.nim @@ -0,0 +1,611 @@ +discard """Copyright (c) 2002-2012 Lee Salzman + +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. +""" + +const Lib = "libenet.so.1(|.0.3)" + +const + ENET_VERSION_MAJOR* = 1 + ENET_VERSION_MINOR* = 3 + ENET_VERSION_PATCH* = 3 +template ENET_VERSION_CREATE(major, minor, patch: untyped): untyped = + (((major) shl 16) or ((minor) shl 8) or (patch)) + +const + ENET_VERSION* = ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR, + ENET_VERSION_PATCH) +type + TVersion* = cuint + TSocketType*{.size: sizeof(cint).} = enum + ENET_SOCKET_TYPE_STREAM = 1, ENET_SOCKET_TYPE_DATAGRAM = 2 + TSocketWait*{.size: sizeof(cint).} = enum + ENET_SOCKET_WAIT_NONE = 0, ENET_SOCKET_WAIT_SEND = (1 shl 0), + ENET_SOCKET_WAIT_RECEIVE = (1 shl 1) + TSocketOption*{.size: sizeof(cint).} = enum + ENET_SOCKOPT_NONBLOCK = 1, ENET_SOCKOPT_BROADCAST = 2, + ENET_SOCKOPT_RCVBUF = 3, ENET_SOCKOPT_SNDBUF = 4, + ENET_SOCKOPT_REUSEADDR = 5 +const + ENET_HOST_ANY* = 0 + ENET_HOST_BROADCAST* = 0xFFFFFFFF + ENET_PORT_ANY* = 0 + + ENET_PROTOCOL_MINIMUM_MTU* = 576 + ENET_PROTOCOL_MAXIMUM_MTU* = 4096 + ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS* = 32 + ENET_PROTOCOL_MINIMUM_WINDOW_SIZE* = 4096 + ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE* = 32768 + ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT* = 1 + ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT* = 255 + ENET_PROTOCOL_MAXIMUM_PEER_ID* = 0x00000FFF +type + PAddress* = ptr TAddress + TAddress*{.pure, final.} = object + host*: cuint + port*: cushort + + TPacketFlag*{.size: sizeof(cint).} = enum + FlagReliable = (1 shl 0), + FlagUnsequenced = (1 shl 1), + NoAllocate = (1 shl 2), + UnreliableFragment = (1 shl 3) + + TENetListNode*{.pure, final.} = object + next*: ptr T_ENetListNode + previous*: ptr T_ENetListNode + + PENetListIterator* = ptr TENetListNode + TENetList*{.pure, final.} = object + sentinel*: TENetListNode + + T_ENetPacket*{.pure, final.} = object + TPacketFreeCallback* = proc (a2: ptr T_ENetPacket){.cdecl.} + + PPacket* = ptr TPacket + TPacket*{.pure, final.} = object + referenceCount: csize_t + flags*: cint + data*: cstring#ptr cuchar + dataLength*: csize_t + freeCallback*: TPacketFreeCallback + + PAcknowledgement* = ptr TAcknowledgement + TAcknowledgement*{.pure, final.} = object + acknowledgementList*: TEnetListNode + sentTime*: cuint + command*: TEnetProtocol + + POutgoingCommand* = ptr TOutgoingCommand + TOutgoingCommand*{.pure, final.} = object + outgoingCommandList*: TEnetListNode + reliableSequenceNumber*: cushort + unreliableSequenceNumber*: cushort + sentTime*: cuint + roundTripTimeout*: cuint + roundTripTimeoutLimit*: cuint + fragmentOffset*: cuint + fragmentLength*: cushort + sendAttempts*: cushort + command*: TEnetProtocol + packet*: PPacket + + PIncomingCommand* = ptr TIncomingCommand + TIncomingCommand*{.pure, final.} = object + incomingCommandList*: TEnetListNode + reliableSequenceNumber*: cushort + unreliableSequenceNumber*: cushort + command*: TEnetProtocol + fragmentCount*: cuint + fragmentsRemaining*: cuint + fragments*: ptr cuint + packet*: ptr TPacket + + TPeerState*{.size: sizeof(cint).} = enum + ENET_PEER_STATE_DISCONNECTED = 0, ENET_PEER_STATE_CONNECTING = 1, + ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2, + ENET_PEER_STATE_CONNECTION_PENDING = 3, + ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4, ENET_PEER_STATE_CONNECTED = 5, + ENET_PEER_STATE_DISCONNECT_LATER = 6, ENET_PEER_STATE_DISCONNECTING = 7, + ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT = 8, ENET_PEER_STATE_ZOMBIE = 9 + + TENetProtocolCommand*{.size: sizeof(cint).} = enum + ENET_PROTOCOL_COMMAND_NONE = 0, ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1, + ENET_PROTOCOL_COMMAND_CONNECT = 2, + ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3, + ENET_PROTOCOL_COMMAND_DISCONNECT = 4, ENET_PROTOCOL_COMMAND_PING = 5, + ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6, + ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7, + ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8, + ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9, + ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10, + ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11, + ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12, + ENET_PROTOCOL_COMMAND_COUNT = 13, ENET_PROTOCOL_COMMAND_MASK = 0x0000000F + TENetProtocolFlag*{.size: sizeof(cint).} = enum + ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12, + ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 shl 6), + ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 shl 7), + ENET_PROTOCOL_HEADER_SESSION_MASK = (3 shl 12), + ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 shl 14), + ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 shl 15), + ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED.cint or + ENET_PROTOCOL_HEADER_FLAG_SENT_TIME.cint + + TENetProtocolHeader*{.pure, final.} = object + peerID*: cushort + sentTime*: cushort + + TENetProtocolCommandHeader*{.pure, final.} = object + command*: cuchar + channelID*: cuchar + reliableSequenceNumber*: cushort + + TENetProtocolAcknowledge*{.pure, final.} = object + header*: TENetProtocolCommandHeader + receivedReliableSequenceNumber*: cushort + receivedSentTime*: cushort + + TENetProtocolConnect*{.pure, final.} = object + header*: TENetProtocolCommandHeader + outgoingPeerID*: cushort + incomingSessionID*: cuchar + outgoingSessionID*: cuchar + mtu*: cuint + windowSize*: cuint + channelCount*: cuint + incomingBandwidth*: cuint + outgoingBandwidth*: cuint + packetThrottleInterval*: cuint + packetThrottleAcceleration*: cuint + packetThrottleDeceleration*: cuint + connectID*: cuint + data*: cuint + + TENetProtocolVerifyConnect*{.pure, final.} = object + header*: TENetProtocolCommandHeader + outgoingPeerID*: cushort + incomingSessionID*: cuchar + outgoingSessionID*: cuchar + mtu*: cuint + windowSize*: cuint + channelCount*: cuint + incomingBandwidth*: cuint + outgoingBandwidth*: cuint + packetThrottleInterval*: cuint + packetThrottleAcceleration*: cuint + packetThrottleDeceleration*: cuint + connectID*: cuint + + TENetProtocolBandwidthLimit*{.pure, final.} = object + header*: TENetProtocolCommandHeader + incomingBandwidth*: cuint + outgoingBandwidth*: cuint + + TENetProtocolThrottleConfigure*{.pure, final.} = object + header*: TENetProtocolCommandHeader + packetThrottleInterval*: cuint + packetThrottleAcceleration*: cuint + packetThrottleDeceleration*: cuint + + TENetProtocolDisconnect*{.pure, final.} = object + header*: TENetProtocolCommandHeader + data*: cuint + + TENetProtocolPing*{.pure, final.} = object + header*: TENetProtocolCommandHeader + + TENetProtocolSendReliable*{.pure, final.} = object + header*: TENetProtocolCommandHeader + dataLength*: cushort + + TENetProtocolSendUnreliable*{.pure, final.} = object + header*: TENetProtocolCommandHeader + unreliableSequenceNumber*: cushort + dataLength*: cushort + + TENetProtocolSendUnsequenced*{.pure, final.} = object + header*: TENetProtocolCommandHeader + unsequencedGroup*: cushort + dataLength*: cushort + + TENetProtocolSendFragment*{.pure, final.} = object + header*: TENetProtocolCommandHeader + startSequenceNumber*: cushort + dataLength*: cushort + fragmentCount*: cuint + fragmentNumber*: cuint + totalLength*: cuint + fragmentOffset*: cuint + + ## this is incomplete; need helper templates or something + ## ENetProtocol + TENetProtocol*{.pure, final.} = object + header*: TENetProtocolCommandHeader +const + ENET_BUFFER_MAXIMUM* = (1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS) + ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024 + ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024 + ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL = 1000 + ENET_HOST_DEFAULT_MTU = 1400 + + ENET_PEER_DEFAULT_ROUND_TRIP_TIME = 500 + ENET_PEER_DEFAULT_PACKET_THROTTLE = 32 + ENET_PEER_PACKET_THROTTLE_SCALE = 32 + ENET_PEER_PACKET_THROTTLE_COUNTER = 7 + ENET_PEER_PACKET_THROTTLE_ACCELERATION = 2 + ENET_PEER_PACKET_THROTTLE_DECELERATION = 2 + ENET_PEER_PACKET_THROTTLE_INTERVAL = 5000 + ENET_PEER_PACKET_LOSS_SCALE = (1 shl 16) + ENET_PEER_PACKET_LOSS_INTERVAL = 10000 + ENET_PEER_WINDOW_SIZE_SCALE = 64 * 1024 + ENET_PEER_TIMEOUT_LIMIT = 32 + ENET_PEER_TIMEOUT_MINIMUM = 5000 + ENET_PEER_TIMEOUT_MAXIMUM = 30000 + ENET_PEER_PING_INTERVAL = 500 + ENET_PEER_UNSEQUENCED_WINDOWS = 64 + ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 1024 + ENET_PEER_FREE_UNSEQUENCED_WINDOWS = 32 + ENET_PEER_RELIABLE_WINDOWS = 16 + ENET_PEER_RELIABLE_WINDOW_SIZE = 0x1000 + ENET_PEER_FREE_RELIABLE_WINDOWS = 8 + +when defined(linux) or true: + import posix + const + ENET_SOCKET_NULL*: cint = -1 + type + TENetSocket* = cint + PEnetBuffer* = ptr object + TENetBuffer*{.pure, final.} = object + data*: pointer + dataLength*: csize_t + TENetSocketSet* = Tfd_set + ## see if these are different on win32, if not then get rid of these + template ENET_HOST_TO_NET_16*(value: untyped): untyped = + (htons(value)) + template ENET_HOST_TO_NET_32*(value: untyped): untyped = + (htonl(value)) + template ENET_NET_TO_HOST_16*(value: untyped): untyped = + (ntohs(value)) + template ENET_NET_TO_HOST_32*(value: untyped): untyped = + (ntohl(value)) + + template ENET_SOCKETSET_EMPTY*(sockset: untyped): untyped = + FD_ZERO(addr((sockset))) + template ENET_SOCKETSET_ADD*(sockset, socket: untyped): untyped = + FD_SET(socket, addr((sockset))) + template ENET_SOCKETSET_REMOVE*(sockset, socket: untyped): untyped = + FD_CLEAR(socket, addr((sockset))) + template ENET_SOCKETSET_CHECK*(sockset, socket: untyped): untyped = + FD_ISSET(socket, addr((sockset))) + +when defined(windows): + ## put the content of win32.h in here + + +type + PChannel* = ptr TChannel + TChannel*{.pure, final.} = object + outgoingReliableSequenceNumber*: cushort + outgoingUnreliableSequenceNumber*: cushort + usedReliableWindows*: cushort + reliableWindows*: array[0..ENET_PEER_RELIABLE_WINDOWS - 1, cushort] + incomingReliableSequenceNumber*: cushort + incomingUnreliableSequenceNumber*: cushort + incomingReliableCommands*: TENetList + incomingUnreliableCommands*: TENetList + + PPeer* = ptr TPeer + TPeer*{.pure, final.} = object + dispatchList*: TEnetListNode + host*: ptr THost + outgoingPeerID*: cushort + incomingPeerID*: cushort + connectID*: cuint + outgoingSessionID*: cuchar + incomingSessionID*: cuchar + address*: TAddress + data*: pointer + state*: TPeerState + channels*: PChannel + channelCount*: csize_t + incomingBandwidth*: cuint + outgoingBandwidth*: cuint + incomingBandwidthThrottleEpoch*: cuint + outgoingBandwidthThrottleEpoch*: cuint + incomingDataTotal*: cuint + outgoingDataTotal*: cuint + lastSendTime*: cuint + lastReceiveTime*: cuint + nextTimeout*: cuint + earliestTimeout*: cuint + packetLossEpoch*: cuint + packetsSent*: cuint + packetsLost*: cuint + packetLoss*: cuint + packetLossVariance*: cuint + packetThrottle*: cuint + packetThrottleLimit*: cuint + packetThrottleCounter*: cuint + packetThrottleEpoch*: cuint + packetThrottleAcceleration*: cuint + packetThrottleDeceleration*: cuint + packetThrottleInterval*: cuint + lastRoundTripTime*: cuint + lowestRoundTripTime*: cuint + lastRoundTripTimeVariance*: cuint + highestRoundTripTimeVariance*: cuint + roundTripTime*: cuint + roundTripTimeVariance*: cuint + mtu*: cuint + windowSize*: cuint + reliableDataInTransit*: cuint + outgoingReliableSequenceNumber*: cushort + acknowledgements*: TENetList + sentReliableCommands*: TENetList + sentUnreliableCommands*: TENetList + outgoingReliableCommands*: TENetList + outgoingUnreliableCommands*: TENetList + dispatchedCommands*: TENetList + needsDispatch*: cint + incomingUnsequencedGroup*: cushort + outgoingUnsequencedGroup*: cushort + unsequencedWindow*: array[0..ENET_PEER_UNSEQUENCED_WINDOW_SIZE div 32 - 1, + cuint] + eventData*: cuint + + PCompressor* = ptr TCompressor + TCompressor*{.pure, final.} = object + context*: pointer + compress*: proc (context: pointer; inBuffers: ptr TEnetBuffer; + inBufferCount: csize_t; inLimit: csize_t; + outData: ptr cuchar; outLimit: csize_t): csize_t{.cdecl.} + decompress*: proc (context: pointer; inData: ptr cuchar; inLimit: csize_t; + outData: ptr cuchar; outLimit: csize_t): csize_t{.cdecl.} + destroy*: proc (context: pointer){.cdecl.} + + TChecksumCallback* = proc (buffers: ptr TEnetBuffer; bufferCount: csize_t): cuint{. + cdecl.} + + PHost* = ptr THost + THost*{.pure, final.} = object + socket*: TEnetSocket + address*: TAddress + incomingBandwidth*: cuint + outgoingBandwidth*: cuint + bandwidthThrottleEpoch*: cuint + mtu*: cuint + randomSeed*: cuint + recalculateBandwidthLimits*: cint + peers*: ptr TPeer + peerCount*: csize_t + channelLimit*: csize_t + serviceTime*: cuint + dispatchQueue*: TEnetList + continueSending*: cint + packetSize*: csize_t + headerFlags*: cushort + commands*: array[0..ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS - 1, + TEnetProtocol] + commandCount*: csize_t + buffers*: array[0..ENET_BUFFER_MAXIMUM - 1, TEnetBuffer] + bufferCount*: csize_t + checksum*: TChecksumCallback + compressor*: TCompressor + packetData*: array[0..ENET_PROTOCOL_MAXIMUM_MTU - 1, + array[0..2 - 1, cuchar]] + receivedAddress*: TAddress + receivedData*: ptr cuchar + receivedDataLength*: csize_t + totalSentData*: cuint + totalSentPackets*: cuint + totalReceivedData*: cuint + totalReceivedPackets*: cuint + + TEventType*{.size: sizeof(cint).} = enum + EvtNone = 0, EvtConnect = 1, + EvtDisconnect = 2, EvtReceive = 3 + PEvent* = ptr TEvent + TEvent*{.pure, final.} = object + kind*: TEventType + peer*: ptr TPeer + channelID*: cuchar + data*: cuint + packet*: ptr TPacket + + TENetCallbacks*{.pure, final.} = object + malloc*: proc (size: csize_t): pointer{.cdecl.} + free*: proc (memory: pointer){.cdecl.} + no_memory*: proc (){.cdecl.} + +{.push callConv:cdecl.} +proc enet_malloc*(a2: csize_t): pointer{. + importc: "enet_malloc", dynlib: Lib.} +proc enet_free*(a2: pointer){. + importc: "enet_free", dynlib: Lib.} + +proc enetInit*(): cint{. + importc: "enet_initialize", dynlib: Lib.} +proc enetInit*(version: TVersion; inits: ptr TENetCallbacks): cint{. + importc: "enet_initialize_with_callbacks", dynlib: Lib.} +proc enetDeinit*(){. + importc: "enet_deinitialize", dynlib: Lib.} +proc enet_time_get*(): cuint{. + importc: "enet_time_get", dynlib: Lib.} +proc enet_time_set*(a2: cuint){. + importc: "enet_time_set", dynlib: Lib.} + +#enet docs are pretty lacking, i'm not sure what the names of these arguments should be +proc createSocket*(kind: TSocketType): TEnetSocket{. + importc: "enet_socket_create", dynlib: Lib.} +proc bindTo*(socket: TEnetSocket; address: var TAddress): cint{. + importc: "enet_socket_bind", dynlib: Lib.} +proc bindTo*(socket: TEnetSocket; address: ptr TAddress): cint{. + importc: "enet_socket_bind", dynlib: Lib.} +proc listen*(socket: TEnetSocket; a3: cint): cint{. + importc: "enet_socket_listen", dynlib: Lib.} +proc accept*(socket: TEnetSocket; address: var TAddress): TEnetSocket{. + importc: "enet_socket_accept", dynlib: Lib.} +proc accept*(socket: TEnetSocket; address: ptr TAddress): TEnetSocket{. + importc: "enet_socket_accept", dynlib: Lib.} +proc connect*(socket: TEnetSocket; address: var TAddress): cint{. + importc: "enet_socket_connect", dynlib: Lib.} +proc connect*(socket: TEnetSocket; address: ptr TAddress): cint{. + importc: "enet_socket_connect", dynlib: Lib.} +proc send*(socket: TEnetSocket; address: var TAddress; buffer: ptr TEnetBuffer; size: csize_t): cint{. + importc: "enet_socket_send", dynlib: Lib.} +proc send*(socket: TEnetSocket; address: ptr TAddress; buffer: ptr TEnetBuffer; size: csize_t): cint{. + importc: "enet_socket_send", dynlib: Lib.} +proc receive*(socket: TEnetSocket; address: var TAddress; + buffer: ptr TEnetBuffer; size: csize_t): cint{. + importc: "enet_socket_receive", dynlib: Lib.} +proc receive*(socket: TEnetSocket; address: ptr TAddress; + buffer: ptr TEnetBuffer; size: csize_t): cint{. + importc: "enet_socket_receive", dynlib: Lib.} +proc wait*(socket: TEnetSocket; a3: ptr cuint; a4: cuint): cint{. + importc: "enet_socket_wait", dynlib: Lib.} +proc setOption*(socket: TEnetSocket; a3: TSocketOption; a4: cint): cint{. + importc: "enet_socket_set_option", dynlib: Lib.} +proc destroy*(socket: TEnetSocket){. + importc: "enet_socket_destroy", dynlib: Lib.} +proc select*(socket: TEnetSocket; a3: ptr TENetSocketSet; + a4: ptr TENetSocketSet; a5: cuint): cint{. + importc: "enet_socketset_select", dynlib: Lib.} + +proc setHost*(address: PAddress; hostName: cstring): cint{. + importc: "enet_address_set_host", dynlib: Lib.} +proc setHost*(address: var TAddress; hostName: cstring): cint{. + importc: "enet_address_set_host", dynlib: Lib.} +proc getHostIP*(address: var TAddress; hostName: cstring; nameLength: csize_t): cint{. + importc: "enet_address_get_host_ip", dynlib: Lib.} +proc getHost*(address: var TAddress; hostName: cstring; nameLength: csize_t): cint{. + importc: "enet_address_get_host", dynlib: Lib.} + +## Call the above two funcs but trim the result string +proc getHostIP*(address: var TAddress; hostName: var string; nameLength: csize_t): cint{.inline.} = + hostName.setLen nameLength + result = getHostIP(address, cstring(hostName), nameLength) + if result == 0: + hostName.setLen(len(cstring(hostName))) +proc getHost*(address: var TAddress; hostName: var string; nameLength: csize_t): cint{.inline.} = + hostName.setLen nameLength + result = getHost(address, cstring(hostName), nameLength) + if result == 0: + hostName.setLen(len(cstring(hostName))) + +proc createPacket*(data: pointer; len: csize_t; flag: TPacketFlag): PPacket{. + importc: "enet_packet_create", dynlib: Lib.} +proc destroy*(packet: PPacket){. + importc: "enet_packet_destroy", dynlib: Lib.} +proc resize*(packet: PPacket; dataLength: csize_t): cint{. + importc: "enet_packet_resize", dynlib: Lib.} + +proc crc32*(buffers: ptr TEnetBuffer; bufferCount: csize_t): cuint{. + importc: "enet_crc32", dynlib: Lib.} + +proc createHost*(address: ptr TAddress; maxConnections, maxChannels: csize_t; downSpeed, upSpeed: cuint): PHost{. + importc: "enet_host_create", dynlib: Lib.} +proc createHost*(address: var TAddress; maxConnections, maxChannels: csize_t; downSpeed, upSpeed: cuint): PHost{. + importc: "enet_host_create", dynlib: Lib.} +proc destroy*(host: PHost){. + importc: "enet_host_destroy", dynlib: Lib.} +proc connect*(host: PHost; address: ptr TAddress; channelCount: csize_t; data: cuint): PPeer{. + importc: "enet_host_connect", dynlib: Lib.} +proc connect*(host: PHost; address: var TAddress; channelCount: csize_t; data: cuint): PPeer{. + importc: "enet_host_connect", dynlib: Lib.} + +proc checkEvents*(host: PHost; event: var TEvent): cint{. + importc: "enet_host_check_events", dynlib: Lib.} +proc checkEvents*(host: PHost; event: ptr TEvent): cint{. + importc: "enet_host_check_events", dynlib: Lib.} +proc hostService*(host: PHost; event: var TEvent; timeout: cuint): cint{. + importc: "enet_host_service", dynlib: Lib.} +proc hostService*(host: PHost; event: ptr TEvent; timeout: cuint): cint{. + importc: "enet_host_service", dynlib: Lib.} +proc flush*(host: PHost){. + importc: "enet_host_flush", dynlib: Lib.} +proc broadcast*(host: PHost; channelID: cuchar; packet: PPacket){. + importc: "enet_host_broadcast", dynlib: Lib.} +proc compress*(host: PHost; compressor: PCompressor){. + importc: "enet_host_compress", dynlib: Lib.} +proc compressWithRangeCoder*(host: PHost): cint{. + importc: "enet_host_compress_with_range_coder", dynlib: Lib.} +proc channelLimit*(host: PHost; channelLimit: csize_t){. + importc: "enet_host_channel_limit", dynlib: Lib.} +proc bandwidthLimit*(host: PHost; incoming, outgoing: cuint){. + importc: "enet_host_bandwidth_limit", dynlib: Lib.} +proc bandwidthThrottle*(host: PHost){. + importc: "enet_host_bandwidth_throttle", dynlib: Lib.} + + +proc send*(peer: PPeer; channel: cuchar; packet: PPacket): cint{. + importc: "enet_peer_send", dynlib: Lib.} +proc receive*(peer: PPeer; channelID: ptr cuchar): PPacket{. + importc: "enet_peer_receive", dynlib: Lib.} +proc ping*(peer: PPeer){. + importc: "enet_peer_ping", dynlib: Lib.} +proc reset*(peer: PPeer){. + importc: "enet_peer_reset", dynlib: Lib.} +proc disconnect*(peer: PPeer; a3: cuint){. + importc: "enet_peer_disconnect", dynlib: Lib.} +proc disconnectNow*(peer: PPeer; a3: cuint){. + importc: "enet_peer_disconnect_now", dynlib: Lib.} +proc disconnectLater*(peer: PPeer; a3: cuint){. + importc: "enet_peer_disconnect_later", dynlib: Lib.} +proc throttleConfigure*(peer: PPeer; interval, acceleration, deceleration: cuint){. + importc: "enet_peer_throttle_configure", dynlib: Lib.} +proc throttle*(peer: PPeer; rtt: cuint): cint{. + importc: "enet_peer_throttle", dynlib: Lib.} +proc resetQueues*(peer: PPeer){. + importc: "enet_peer_reset_queues", dynlib: Lib.} +proc setupOutgoingCommand*(peer: PPeer; outgoingCommand: POutgoingCommand){. + importc: "enet_peer_setup_outgoing_command", dynlib: Lib.} + +proc queueOutgoingCommand*(peer: PPeer; command: ptr TEnetProtocol; + packet: PPacket; offset: cuint; length: cushort): POutgoingCommand{. + importc: "enet_peer_queue_outgoing_command", dynlib: Lib.} +proc queueIncomingCommand*(peer: PPeer; command: ptr TEnetProtocol; + packet: PPacket; fragmentCount: cuint): PIncomingCommand{. + importc: "enet_peer_queue_incoming_command", dynlib: Lib.} +proc queueAcknowledgement*(peer: PPeer; command: ptr TEnetProtocol; + sentTime: cushort): PAcknowledgement{. + importc: "enet_peer_queue_acknowledgement", dynlib: Lib.} +proc dispatchIncomingUnreliableCommands*(peer: PPeer; channel: PChannel){. + importc: "enet_peer_dispatch_incoming_unreliable_commands", dynlib: Lib.} +proc dispatchIncomingReliableCommands*(peer: PPeer; channel: PChannel){. + importc: "enet_peer_dispatch_incoming_reliable_commands", dynlib: Lib.} + +proc createRangeCoder*(): pointer{. + importc: "enet_range_coder_create", dynlib: Lib.} +proc rangeCoderDestroy*(context: pointer){. + importc: "enet_range_coder_destroy", dynlib: Lib.} +proc rangeCoderCompress*(context: pointer; inBuffers: PEnetBuffer; inLimit, + bufferCount: csize_t; outData: cstring; outLimit: csize_t): csize_t{. + importc: "enet_range_coder_compress", dynlib: Lib.} +proc rangeCoderDecompress*(context: pointer; inData: cstring; inLimit: csize_t; + outData: cstring; outLimit: csize_t): csize_t{. + importc: "enet_range_coder_decompress", dynlib: Lib.} +proc protocolCommandSize*(commandNumber: cuchar): csize_t{. + importc: "enet_protocol_command_size", dynlib: Lib.} + +{.pop.} + +from hashes import `!$`, `!&`, Hash, hash +proc hash*(x: TAddress): Hash {.nimcall, noSideEffect.} = + result = !$(hash(x.host.int32) !& hash(x.port.int16)) diff --git a/tests/manyloc/keineschweine/dependencies/enet/testclient.nim b/tests/manyloc/keineschweine/dependencies/enet/testclient.nim new file mode 100644 index 000000000..2447a1fb5 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/enet/testclient.nim @@ -0,0 +1,49 @@ +import enet, strutils + +if enetInit() != 0: + quit "Could not initialize ENet" +var + address: enet.TAddress + event: TEvent + peer: PPeer + client: PHost + +client = createHost(nil, 1, 2, 0, 0) +if client == nil: + quit "Could not create client!" + +if setHost(addr address, "localhost") != 0: + quit "Could not set host" +address.port = 8024 + +peer = client.connect(addr address, 2, 0) +if peer == nil: + quit "No available peers" + +block: + var bConnected = false + while not bConnected: + if client.hostService(event, 5000) > 0 and event.kind == EvtConnect: + echo "Connected" + bConnected = true + else: + echo "Connection failed" + quit 0 + +var runServer = true +while client.hostService(event, 1000) >= 0 and runServer: + case event.kind + of EvtReceive: + echo "Recvd ($1) $2 ".format( + event.packet.dataLength, + event.packet.data) + of EvtDisconnect: + echo "Disconnected" + event.peer.data = nil + runServer = false + of EvtNone: discard + else: + echo repr(event) + + +client.destroy() diff --git a/tests/manyloc/keineschweine/dependencies/enet/testserver.nim b/tests/manyloc/keineschweine/dependencies/enet/testserver.nim new file mode 100644 index 000000000..6d6de90c1 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/enet/testserver.nim @@ -0,0 +1,45 @@ +import enet, strutils +var + address: enet.TAddress + server: PHost + event: TEvent + +if enetInit() != 0: + quit "Could not initialize ENet" + +address.host = EnetHostAny +address.port = 8024 + +server = enet.createHost( + addr address, 32, 2, 0, 0) +if server == nil: + quit "Could not create the server!" + +while server.hostService(addr event, 2500) >= 0: + case event.kind + of EvtConnect: + echo "New client from $1:$2".format(event.peer.address.host, event.peer.address.port) + + var + msg = "hello" + resp = createPacket(cstring(msg), msg.len + 1, FlagReliable) + + if event.peer.send(0.cuchar, resp) < 0: + echo "FAILED" + else: + echo "Replied" + of EvtReceive: + echo "Recvd ($1) $2 ".format( + event.packet.dataLength, + event.packet.data) + + destroy(event.packet) + + of EvtDisconnect: + echo "Disconnected" + event.peer.data = nil + else: + discard + +server.destroy() +enetDeinit() diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim new file mode 100644 index 000000000..d91f1cb35 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim @@ -0,0 +1,287 @@ +import macros, macro_dsl, estreams +from strutils import format + +template newLenName() = + let lenName {.inject.} = ^("len" & $lenNames) + inc(lenNames) + +template defPacketImports*() {.dirty.} = + import macros, macro_dsl, estreams + from strutils import format + +macro defPacket*(typeNameN: untyped, typeFields: untyped): untyped = + result = newNimNode(nnkStmtList) + let + typeName = quoted2ident(typeNameN) + packetID = ^"p" + streamID = ^"s" + var + constructorParams = newNimNode(nnkFormalParams).und(typeName) + constructor = newNimNode(nnkProcDef).und( + postfix(^("new" & $typeName.ident), "*"), + emptyNode(), + emptyNode(), + constructorParams, + emptyNode(), + emptyNode()) + pack = newNimNode(nnkProcDef).und( + postfix(^"pack", "*"), + emptyNode(), + emptyNode(), + newNimNode(nnkFormalParams).und( + emptyNode(), # : void + newNimNode(nnkIdentDefs).und( + streamID, # s: PBuffer + ^"PBuffer", + newNimNode(nnkNilLit)), + newNimNode(nnkIdentDefs).und( + packetID, # p: var typeName + newNimNode(nnkVarTy).und(typeName), + emptyNode())), + emptyNode(), + emptyNode()) + read = newNimNode(nnkProcDef).und( + newIdentNode("read" & $typeName.ident).postfix("*"), + emptyNode(), + emptyNode(), + newNimNode(nnkFormalParams).und( + typeName, #result type + newNimNode(nnkIdentDefs).und( + streamID, # s: PBuffer = nil + ^"PBuffer", + newNimNode(nnkNilLit))), + emptyNode(), + emptyNode()) + constructorBody = newNimNode(nnkStmtList) + packBody = newNimNode(nnkStmtList) + readBody = newNimNode(nnkStmtList) + lenNames = 0 + for i in 0.. typeFields.len - 1: + let + name = typeFields[i][0] + dotName = packetID.dot(name) + resName = newIdentNode("result").dot(name) + case typeFields[i][1].kind + of nnkBracketExpr: #ex: paddedstring[32, '\0'], array[range, type] + case $typeFields[i][1][0].ident + of "seq": + ## let lenX = readInt16(s) + newLenName() + let + item = ^"item" ## item name in our iterators + seqType = typeFields[i][1][1] ## type of seq + readName = newIdentNode("read" & $seqType.ident) + readBody.add(newNimNode(nnkLetSection).und( + newNimNode(nnkIdentDefs).und( + lenName, + newNimNode(nnkEmpty), + newCall("readInt16", streamID)))) + readBody.add( ## result.name = @[] + resName := ("@".prefix(newNimNode(nnkBracket))), + newNimNode(nnkForStmt).und( ## for item in 1..len: + item, + infix(1.lit, "..", lenName), + newNimNode(nnkStmtList).und( + newCall( ## add(result.name, unpack[seqType](stream)) + "add", resName, newNimNode(nnkCall).und(readName, streamID) + ) ) ) ) + packbody.add( + newNimNode(nnkVarSection).und(newNimNode(nnkIdentDefs).und( + lenName, ## var lenName = int16(len(p.name)) + newIdentNode("int16"), + newCall("int16", newCall("len", dotName)))), + newCall("writeBE", streamID, lenName), + newNimNode(nnkForStmt).und( ## for item in 0..length - 1: pack(p.name[item], stream) + item, + infix(0.lit, "..", infix(lenName, "-", 1.lit)), + newNimNode(nnkStmtList).und( + newCall("echo", item, ": ".lit), + newCall("pack", streamID, dotName[item])))) + #set the default value to @[] (new sequence) + typeFields[i][2] = "@".prefix(newNimNode(nnkBracket)) + else: + error("Unknown type: " & treeRepr(typeFields[i])) + of nnkIdent: ##normal type + case $typeFields[i][1].ident + of "string": # length encoded string + packBody.add(newCall("write", streamID, dotName)) + readBody.add(resName := newCall("readStr", streamID)) + of "int8", "int16", "int32", "float32", "float64", "char", "bool": + packBody.add(newCall( + "writeBE", streamID, dotName)) + readBody.add(resName := newCall("read" & $typeFields[i][1].ident, streamID)) + else: ## hopefully the type you specified was another defpacket() type + packBody.add(newCall("pack", streamID, dotName)) + readBody.add(resName := newCall("read" & $typeFields[i][1].ident, streamID)) + else: + error("I don't know what to do with: " & treerepr(typeFields[i])) + + var + toStringFunc = newNimNode(nnkProcDef).und( + newNimNode(nnkPostfix).und( + ^"*", + newNimNode(nnkAccQuoted).und(^"$")), + emptyNode(), + emptyNode(), + newNimNode(nnkFormalParams).und( + ^"string", + newNimNode(nnkIdentDefs).und( + packetID, # p: typeName + typeName, + emptyNode())), + emptyNode(), + emptyNode(), + newNimNode(nnkStmtList).und(# [6] + newNimNode(nnkAsgn).und( + ^"result", ## result = + newNimNode(nnkCall).und(# [6][0][1] + ^"format", ## format + emptyNode())))) ## "[TypeName $1 $2]" + formatStr = "[" & $typeName.ident + + const emptyFields = {nnkEmpty, nnkNilLit} + var objFields = newNimNode(nnkRecList) + for i in 0 ..< len(typeFields): + let fname = typeFields[i][0] + constructorParams.add(newNimNode(nnkIdentDefs).und( + fname, + typeFields[i][1], + typeFields[i][2])) + constructorBody.add((^"result").dot(fname) := fname) + #export the name + typeFields[i][0] = fname.postfix("*") + if not(typeFields[i][2].kind in emptyFields): + ## empty the type default for the type def + typeFields[i][2] = newNimNode(nnkEmpty) + objFields.add(typeFields[i]) + toStringFunc[6][0][1].add( + prefix("$", packetID.dot(fname))) + formatStr.add " $" + formatStr.add($(i + 1)) + + formatStr.add ']' + toStringFunc[6][0][1][1] = formatStr.lit() + + result.add( + newNimNode(nnkTypeSection).und( + newNimNode(nnkTypeDef).und( + typeName.postfix("*"), + newNimNode(nnkEmpty), + newNimNode(nnkObjectTy).und( + newNimNode(nnkEmpty), #not sure what this is + newNimNode(nnkEmpty), #parent: OfInherit(Ident(!"SomeObj")) + objFields)))) + result.add(constructor.und(constructorBody)) + result.add(pack.und(packBody)) + result.add(read.und(readBody)) + result.add(toStringFunc) + when defined(GenPacketShowOutput): + echo(repr(result)) + +proc newProc*(name: NimNode; params: varargs[NimNode]; resultType: NimNode): NimNode {.compileTime.} = + result = newNimNode(nnkProcDef).und( + name, + emptyNode(), + emptyNode(), + newNimNode(nnkFormalParams).und(resultType), + emptyNode(), + emptyNode(), + newNimNode(nnkStmtList)) + result[3].add(params) + +proc body*(procNode: NimNode): NimNode {.compileTime.} = + assert procNode.kind == nnkProcDef and procNode[6].kind == nnkStmtList + result = procNode[6] + +proc iddefs*(a, b: string; c: NimNode): NimNode {.compileTime.} = + result = newNimNode(nnkIdentDefs).und(^a, ^b, c) +proc iddefs*(a: string; b: NimNode): NimNode {.compileTime.} = + result = newNimNode(nnkIdentDefs).und(^a, b, emptyNode()) +proc varTy*(a: NimNode): NimNode {.compileTime.} = + result = newNimNode(nnkVarTy).und(a) + +macro forwardPacket*(typeName: untyped, underlyingType: untyped): untyped = + var + packetID = ^"p" + streamID = ^"s" + result = newNimNode(nnkStmtList).und( + newProc( + (^("read" & $typeName.ident)).postfix("*"), + [ iddefs("s", "PBuffer", newNimNode(nnkNilLit)) ], + typeName), + newProc( + (^"pack").postfix("*"), + [ iddefs("s", "PBuffer", newNimNode(nnkNilLit)), + iddefs("p", varTy(typeName)) ], + emptyNode())) + var + readBody = result[0][6] + packBody = result[1][6] + resName = ^"result" + + case underlyingType.kind + of nnkBracketExpr: + case $underlyingType[0].ident + of "array": + for i in underlyingType[1][1].intval.int .. underlyingType[1][2].intval.int: + readBody.add( + newCall("read", ^"s", resName[lit(i)])) + packBody.add( + newCall("writeBE", ^"s", packetID[lit(i)])) + else: + echo "Unknown type: ", repr(underlyingtype) + else: + echo "unknown type:", repr(underlyingtype) + echo(repr(result)) + +template forwardPacketT*(typeName: untyped; underlyingType: untyped) {.dirty.} = + proc `read typeName`*(buffer: PBuffer): typeName = + #discard readData(s, addr result, sizeof(result)) + var res: underlyingType + buffer.read(res) + result = typeName(res) + proc `pack`*(buffer: PBuffer; ord: var typeName) = + #writeData(s, addr p, sizeof(p)) + buffer.write(underlyingType(ord)) + +when false: + type + SomeEnum = enum + A = 0'i8, + B, C + forwardPacket(SomeEnum, int8) + + + defPacket(Foo, tuple[x: array[0..4, int8]]) + var f = newFoo([4'i8, 3'i8, 2'i8, 1'i8, 0'i8]) + var s2 = newStringStream("") + f.pack(s2) + assert s2.data == "\4\3\2\1\0" + + var s = newStringStream() + s.flushImpl = proc(s: PStream) = + var z = PStringStream(s) + z.setPosition(0) + z.data.setLen(0) + + + s.setPosition(0) + s.data.setLen(0) + var o = B + o.pack(s) + o = A + o.pack(s) + o = C + o.pack(s) + assert s.data == "\1\0\2" + s.flush + + defPacket(Y, tuple[z: int8]) + proc `$`(z: Y): string = result = "Y(" & $z.z & ")" + defPacket(TestPkt, tuple[x: seq[Y]]) + var test = newTestPkt() + test.x.add([newY(5), newY(4), newY(3), newY(2), newY(1)]) + for itm in test.x: + echo(itm) + test.pack(s) + echo(repr(s.data)) diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim b/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim new file mode 100644 index 000000000..3341f42c2 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim @@ -0,0 +1,64 @@ +import macros + +#Inline macro.add() to allow for easier nesting +proc und*(a: NimNode; b: NimNode): NimNode {.compileTime.} = + a.add(b) + result = a +proc und*(a: NimNode; b: varargs[NimNode]): NimNode {.compileTime.} = + a.add(b) + result = a + +proc `^`*(a: string): NimNode {.compileTime.} = + ## new ident node + result = newIdentNode(a) +proc `[]`*(a, b: NimNode): NimNode {.compileTime.} = + ## new bracket expression: node[node] not to be confused with node[indx] + result = newNimNode(nnkBracketExpr).und(a, b) +proc `:=`*(left, right: NimNode): NimNode {.compileTime.} = + ## new Asgn node: left = right + result = newNimNode(nnkAsgn).und(left, right) + +proc lit*(a: string): NimNode {.compileTime.} = + result = newStrLitNode(a) +proc lit*(a: int): NimNode {.compileTime.} = + result = newIntLitNode(a) +proc lit*(a: float): NimNode {.compileTime.} = + result = newFloatLitNode(a) +proc lit*(a: char): NimNode {.compileTime.} = + result = newNimNode(nnkCharLit) + result.intval = a.ord + +proc emptyNode*(): NimNode {.compileTime.} = + result = newNimNode(nnkEmpty) + +proc dot*(left, right: NimNode): NimNode {.compileTime.} = + result = newNimNode(nnkDotExpr).und(left, right) +proc prefix*(a: string, b: NimNode): NimNode {.compileTime.} = + result = newNimNode(nnkPrefix).und(newIdentNode(a), b) + +proc quoted2ident*(a: NimNode): NimNode {.compileTime.} = + if a.kind != nnkAccQuoted: + return a + var pname = "" + for piece in 0..a.len - 1: + pname.add($a[piece].ident) + result = ^pname + + +macro `?`(a: untyped): untyped = + ## Character literal ?A #=> 'A' + result = ($a[1].ident)[0].lit +## echo(?F,?a,?t,?t,?y) + +when false: + macro foo(x: untyped) = + result = newNimNode(nnkStmtList) + result.add(newNimNode(nnkCall).und(!!"echo", "Hello thar".lit)) + result.add(newCall("echo", lit("3 * 45 = "), (3.lit.infix("*", 45.lit)))) + let stmtlist = x[1] + for i in countdown(len(stmtlist)-1, 0): + result.add(stmtlist[i]) + foo: + echo y, " * 2 = ", y * 2 + let y = 320 + diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim b/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim new file mode 100644 index 000000000..a0c8a7a3c --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim @@ -0,0 +1,47 @@ +import streams +from strutils import repeat + +proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): string = + var lastChr = length + result = s.readStr(length) + while lastChr >= 0 and result[lastChr - 1] == padChar: dec(lastChr) + result.setLen(lastChr) + +proc writePaddedStr*(s: PStream, str: string, length: int, padChar = '\0') = + if str.len < length: + s.write(str) + s.write(repeat(padChar, length - str.len)) + elif str.len > length: + s.write(str.substr(0, length - 1)) + else: + s.write(str) + +proc readLEStr*(s: PStream): string = + var len = s.readInt16() + result = s.readStr(len) + +proc writeLEStr*(s: PStream, str: string) = + s.write(str.len.int16) + s.write(str) + +when true: + var testStream = newStringStream() + + testStream.writeLEStr("Hello") + doAssert testStream.data == "\5\0Hello" + + testStream.setPosition 0 + var res = testStream.readLEStr() + doAssert res == "Hello" + + testStream.setPosition 0 + testStream.writePaddedStr("Sup", 10) + echo(repr(testStream), testStream.data.len) + doAssert testStream.data == "Sup"&repeat('\0', 7) + + testStream.setPosition 0 + res = testStream.readPaddedStr(10) + doAssert res == "Sup" + + testStream.close() + diff --git a/tests/manyloc/keineschweine/dependencies/nake/nake.nim b/tests/manyloc/keineschweine/dependencies/nake/nake.nim new file mode 100644 index 000000000..36538097e --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/nake/nake.nim @@ -0,0 +1,88 @@ +discard """ +DO AS THOU WILST PUBLIC LICENSE + +Whoever should stumble upon this document is henceforth and forever +entitled to DO AS THOU WILST with aforementioned document and the +contents thereof. + +As said in the Olde Country, `Keepe it Gangster'.""" + +#[ +xxx remove this? seems mostly duplicate of: tests/manyloc/nake/nake.nim +]# + +import strutils, parseopt, tables, os + +type + PTask* = ref object + desc*: string + action*: TTaskFunction + TTaskFunction* = proc() {.closure.} +var + tasks* = initTable[string, PTask](16) + +proc newTask*(desc: string; action: TTaskFunction): PTask +proc runTask*(name: string) {.inline.} +proc shell*(cmd: varargs[string, `$`]): int {.discardable.} +proc cd*(dir: string) {.inline.} + +template nakeImports*(): stmt {.immediate.} = + import tables, parseopt, strutils, os + +template task*(name: string; description: string; body: stmt): stmt {.dirty, immediate.} = + block: + var t = newTask(description, proc() {.closure.} = + body) + tasks[name] = t + +proc newTask*(desc: string; action: TTaskFunction): PTask = + new(result) + result.desc = desc + result.action = action +proc runTask*(name: string) = tasks[name].action() + +proc shell*(cmd: varargs[string, `$`]): int = + result = execShellCmd(cmd.join(" ")) +proc cd*(dir: string) = setCurrentDir(dir) +template withDir*(dir: string; body: stmt): stmt = + ## temporary cd + ## withDir "foo": + ## # inside foo + ## #back to last dir + var curDir = getCurrentDir() + cd(dir) + body + cd(curDir) + +when true: + if not fileExists("nakefile.nim"): + echo "No nakefile.nim found. Current working dir is ", getCurrentDir() + quit 1 + var args = "" + for i in 1..paramCount(): + args.add paramStr(i) + args.add " " + quit(shell("nim", "c", "-r", "nakefile.nim", args)) +else: + import std/exitprocs + addExitProc(proc() {.noconv.} = + var + task: string + printTaskList: bool + for kind, key, val in getopt(): + case kind + of cmdLongOption, cmdShortOption: + case key.tolower + of "tasks", "t": + printTaskList = true + else: + echo "Unknown option: ", key, ": ", val + of cmdArgument: + task = key + else: nil + if printTaskList or task.isNil or not(tasks.hasKey(task)): + echo "Available tasks:" + for name, task in pairs(tasks): + echo name, " - ", task.desc + quit 0 + tasks[task].action()) diff --git a/tests/manyloc/keineschweine/dependencies/nake/nakefile.nim b/tests/manyloc/keineschweine/dependencies/nake/nakefile.nim new file mode 100644 index 000000000..5490211de --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/nake/nakefile.nim @@ -0,0 +1,23 @@ +import nake +nakeImports + +task "install", "compile and install nake binary": + if shell("nim", "c", "nake") == 0: + let path = getEnv("PATH").split(PathSep) + for index, dir in pairs(path): + echo " ", index, ". ", dir + echo "Where to install nake binary? (quit with ^C or quit or exit)" + let ans = stdin.readLine().toLowerAscii + var index = 0 + case ans + of "q", "quit", "x", "exit": + quit 0 + else: + index = parseInt(ans) + if index > path.len or index < 0: + echo "Invalid index." + quit 1 + moveFile "nake", path[index]/"nake" + echo "Great success!" + + diff --git a/tests/manyloc/keineschweine/dependencies/sfml/README.md b/tests/manyloc/keineschweine/dependencies/sfml/README.md new file mode 100644 index 000000000..bd9b3d0e7 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/sfml/README.md @@ -0,0 +1,13 @@ +sfml-nimrod +=========== + +Nimrod binding of SFML 2.0 + +This is only tested for Linux at the moment + +### What is needed for Windows / OS X? + +* The library names need filling in +* TWindowHandle is handled differently on those platforms + +I believe that is it diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim new file mode 100644 index 000000000..0060bf12b --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim @@ -0,0 +1,1121 @@ +import + strutils, math +when defined(linux): + const + LibG = "libcsfml-graphics.so.2.0" + LibS = "libcsfml-system.so.2.0" + LibW = "libcsfml-window.so.2.0" +else: + # We only compile for testing here, so it doesn't matter it's not supported + const + LibG = "libcsfml-graphics.so.2.0" + LibS = "libcsfml-system.so.2.0" + LibW = "libcsfml-window.so.2.0" + #{.error: "Platform unsupported".} + +{.pragma: pf, pure, final.} +type + PClock* = ptr TClock + TClock* {.pf.} = object + TTime* {.pf.} = object + microseconds*: int64 + TVector2i* {.pf.} = object + x*, y*: cint + TVector2f* {.pf.} = object + x*, y*: cfloat + TVector3f* {.pf.} = object + x*, y*, z*: cfloat + + PInputStream* = ptr TInputStream + TInputStream* {.pf.} = object + read*: TInputStreamReadFunc + seek*: TInputStreamSeekFunc + tell*: TInputStreamTellFunc + getSize*: TInputStreamGetSizeFunc + userData*: pointer + TInputStreamReadFunc* = proc (data: pointer, size: int64, userData: pointer): int64{. + cdecl.} + TInputStreamSeekFunc* = proc (position: int16, userData: pointer): int64{. + cdecl.} + TInputStreamTellFunc* = proc (userData: pointer): int64 {.cdecl.} + TInputStreamGetSizeFunc* = proc (userData: pointer): int64 {.cdecl.} + PWindow* = ptr TWindow + TWindow* {.pf.} = object + PContextSettings* = ptr TContextSettings + TContextSettings*{.pf.} = object + depthBits: cint + stencilBits: cint + antialiasingLevel: cint + majorVersion: cint + minorVersion: cint + TVideoMode* {.pf.} = object + width*: cint + height*: cint + bitsPerPixel*: cint + TEventType*{.size: sizeof(cint).} = enum + EvtClosed, EvtResized, EvtLostFocus, EvtGainedFocus, + EvtTextEntered, EvtKeyPressed, EvtKeyReleased, EvtMouseWheelMoved, + EvtMouseButtonPressed, EvtMouseButtonReleased, EvtMouseMoved, + EvtMouseEntered, EvtMouseLeft, EvtJoystickButtonPressed, + EvtJoystickButtonReleased, EvtJoystickMoved, EvtJoystickConnected, + EvtJoystickDisconnected + TKeyEvent*{.pf.} = object + code*: TKeyCode + alt* : bool + control*: bool + shift* : bool + system* : bool + TJoystickConnectEvent*{.pf.} = object + joystickId*: cint + TJoystickButtonEvent*{.pf.} = object + joystickId*: cint + button*: cint + TJoystickMoveEvent*{.pf.} = object + joystickId*: cint + axis*: TJoystickAxis + position*: cfloat + TMouseWheelEvent*{.pf.} = object + delta*: cint + x*: cint + y*: cint + TMouseButtonEvent*{.pf.} = object + button*: TMouseButton + x*: cint + y*: cint + TMouseMoveEvent*{.pf.} = object + x*: cint + y*: cint + TTextEvent*{.pf.} = object + unicode*: cint + PEvent* = ptr TEvent + TEvent*{.pf.} = object + case kind*: TEventType + of EvtKeyPressed, EvtKeyReleased: + key*: TKeyEvent + of EvtMouseButtonPressed, EvtMouseButtonReleased: + mouseButton*: TMouseButtonEvent + of EvtTextEntered: + text*: TTextEvent + of EvtJoystickConnected, EvtJoystickDisconnected: + joystickConnect*: TJoystickConnectEvent + of EvtJoystickMoved: + joystickMove*: TJoystickMoveEvent + of EvtJoystickButtonPressed, EvtJoystickButtonReleased: + joystickButton*: TJoystickButtonEvent + of EvtResized: + size*: TSizeEvent + of EvtMouseMoved, EvtMouseEntered, EvtMouseLeft: + mouseMove*: TMouseMoveEvent + of EvtMouseWheelMoved: + mouseWheel*: TMouseWheelEvent + else: nil + TJoystickAxis*{.size: sizeof(cint).} = enum + JoystickX, JoystickY, JoystickZ, JoystickR, + JoystickU, JoystickV, JoystickPovX, JoystickPovY + TSizeEvent*{.pf.} = object + width*: cint + height*: cint + TMouseButton*{.size: sizeof(cint).} = enum + MouseLeft, MouseRight, MouseMiddle, + MouseXButton1, MouseXButton2, MouseButtonCount + TKeyCode*{.size: sizeof(cint).} = enum + KeyUnknown = - 1, KeyA, KeyB, KeyC, KeyD, KeyE, + KeyF, KeyG, KeyH, KeyI, KeyJ, KeyK, KeyL, KeyM, #/< The M key + KeyN, KeyO, KeyP, KeyQ, KeyR, KeyS, KeyT, KeyU, #/< The U key + KeyV, KeyW, KeyX, KeyY, KeyZ, KeyNum0, KeyNum1, #/< The 1 key + KeyNum2, KeyNum3, KeyNum4, KeyNum5, KeyNum6, #/< The 6 key + KeyNum7, KeyNum8, KeyNum9, KeyEscape, KeyLControl, #/< The left Control key + KeyLShift, KeyLAlt, KeyLSystem, KeyRControl, #/< The right Control key + KeyRShift, KeyRAlt, KeyRSystem, KeyMenu, #/< The Menu key + KeyLBracket, KeyRBracket, KeySemiColon, KeyComma, #/< The , key + KeyPeriod, KeyQuote, KeySlash, KeyBackSlash, #/< The \ key + KeyTilde, KeyEqual, KeyDash, KeySpace, KeyReturn, #/< The Return key + KeyBack, KeyTab, KeyPageUp, KeyPageDown, KeyEnd, #/< The End key + KeyHome, KeyInsert, KeyDelete, KeyAdd, KeySubtract, #/< - + KeyMultiply, KeyDivide, KeyLeft, KeyRight, KeyUp, #/< Up arrow + KeyDown, KeyNumpad0, KeyNumpad1, KeyNumpad2, #/< The numpad 2 key + KeyNumpad3, #/< The numpad 3 key + KeyNumpad4, #/< The numpad 4 key + KeyNumpad5, #/< The numpad 5 key + KeyNumpad6, #/< The numpad 6 key + KeyNumpad7, #/< The numpad 7 key + KeyNumpad8, #/< The numpad 8 key + KeyNumpad9, #/< The numpad 9 key + KeyF1, #/< The F1 key + KeyF2, #/< The F2 key + KeyF3, #/< The F3 key + KeyF4, #/< The F4 key + KeyF5, #/< The F5 key + KeyF6, #/< The F6 key + KeyF7, #/< The F7 key + KeyF8, #/< The F8 key + KeyF9, #/< The F8 key + KeyF10, #/< The F10 key + KeyF11, #/< The F11 key + KeyF12, #/< The F12 key + KeyF13, #/< The F13 key + KeyF14, #/< The F14 key + KeyF15, #/< The F15 key + KeyPause, #/< The Pause key + KeyCount #/< Keep last -- the total number of keyboard keys + +type TWindowHandle* = clong + +#elif defined(mac): +# type TWindowHandle* = pointer ##typedef void* sfWindowHandle; <- whatever the hell that is +#elif defined(windows): +# type TWindowHandle* = HWND__ ? windows is crazy. ##struct HWND__; typedef struct HWND__* sfWindowHandle; +const + sfNone* = 0 + sfTitlebar* = 1 shl 0 + sfResize* = 1 shl 1 + sfClose* = 1 shl 2 + sfFullscreen* = 1 shl 3 + sfDefaultStyle* = sfTitlebar or sfResize or sfClose +type + PRenderWindow* = ptr TRenderWindow + TRenderWindow* {.pf.} = object + + PFont* = ptr TFont + TFont* {.pf.} = object + PImage* = ptr TImage + TImage* {.pf.} = object + PShader* = ptr TShader + TShader* {.pf.} = object + PSprite* = ptr TSprite + TSprite* {.pf.} = object + PText* = ptr TText + TText* {.pf.} = object + PTexture* = ptr TTexture + TTexture* {.pf.} = object + PVertexArray* = ptr TVertexArray + TVertexArray* {.pf.} = object + PView* = ptr TView + TView* {.pf.} = object + PRenderTexture* = ptr TRenderTexture + TRenderTexture* {.pf.} = object + + PShape* = ptr TShape + TShape* {.pf.} = object + PCircleShape* = ptr TCircleShape + TCircleShape* {.pf.} = object + PRectangleShape* = ptr TRectangleShape + TRectangleShape* {.pf.} = object + PConvexShape* = ptr TConvexShape + TConvexShape* {.pf.} = object + + TTextStyle*{.size: sizeof(cint).} = enum + TextRegular = 0, TextBold = 1 shl 0, TextItalic = 1 shl 1, + TextUnderlined = 1 shl 2 + + TBlendMode*{.size: sizeof(cint).} = enum + BlendAlpha, BlendAdd, BlendMultiply, BlendNone + PRenderStates* = ptr TRenderStates + TRenderStates* {.pf.} = object + blendMode*: TBlendMode + transform*: TTransform + texture*: PTexture + shader*: PShader + + PTransform* = ptr TTransform + TTransform* {.pf.} = object + matrix*: array[0..8, cfloat] + TColor* {.pf.} = object + r*: uint8 + g*: uint8 + b*: uint8 + a*: uint8 + PFloatRect* = ptr TFloatRect + TFloatRect*{.pf.} = object + left*: cfloat + top*: cfloat + width*: cfloat + height*: cfloat + PIntRect* = ptr TIntRect + TIntRect*{.pf.} = object + left*: cint + top*: cint + width*: cint + height*: cint + TGlyph* {.pf.} = object + advance*: cint + bounds*: TIntRect + textureRect*: TIntRect + PVertex* = ptr TVertex + TVertex* {.pf.} = object + position*: TVector2f + color*: TColor + texCoords*: TVector2f + TPrimitiveType*{.size: sizeof(cint).} = enum + Points, #/< List of individual points + Lines, #/< List of individual lines + LinesStrip, #/< List of connected lines, a point uses the previous point to form a line + Triangles, #/< List of individual triangles + TrianglesStrip, #/< List of connected triangles, a point uses the two previous points to form a triangle + TrianglesFan, #/< List of connected triangles, a point uses the common center and the previous point to form a triangle + Quads + + +proc newWindow*(mode: TVideoMode, title: cstring, style: uint32, settings: PContextSettings = nil): PWindow {. + cdecl, importc: "sfWindow_create", dynlib: LibW.} + +proc close*(window: PWindow) {. + cdecl, importc: "sfWindow_close", dynlib: LibW.} +proc isOpen*(window: PWindow): bool {.cdecl, importc: "sfWindow_isOpen", dynlib: LibW.} + +proc pollEvent*(window: PWindow, event: PEvent): bool {. + cdecl, importc: "sfWindow_pollEvent", dynlib: LibW.} +proc waitEvent*(window: PWindow, event: PEvent): bool {. + cdecl, importc: "sfWindow_waitEvent", dynlib: LibW.} + +proc getDesktopMode*(): TVideoMode {. + cdecl, importc: "sfVideoMode_getDesktopMode", dynlib: LibW.} +proc isKeyPressed*(key: TKeyCode): bool {. + cdecl, importc: "sfKeyboard_isKeyPressed", dynlib: LibW.} + +proc mouseIsButtonPressed*(button: TMouseButton): bool {. + cdecl, importc: "sfMouse_isButtonPressed", dynlib: LibW.} +proc mouseGetPosition*(relativeTo: PWindow): TVector2i {. + cdecl, importc: "sfMouse_getPosition", dynlib: LibW.} +proc mouseSetPosition*(position: TVector2i, relativeTo: PWindow) {. + cdecl, importc: "sfMouse_setPosition", dynlib: LibW.} + +proc joystickIsConnected*(joystick: cint): bool {. + cdecl, importc: "sfJoystick_isConnected", dynlib: LibW.} +proc joystickGetButtonCount*(joystick: cint): cint {. + cdecl, importc: "sfJoystick_getButtonCount", dynlib: LibW.} +proc joystickHasAxis*(joystick: cint, axis: TJoystickAxis): bool {. + cdecl, importc: "sfJoystick_hasAxis", dynlib: LibW.} +proc joystickIsButtonPressed*(joystick: cint, button: cint): bool {. + cdecl, importc: "sfJoystick_isButtonPressed", dynlib: LibW.} +proc joystickGetAxisPosition*(joystick: cint, axis: TJoystickAxis): float {. + cdecl, importc: "sfJoystick_getAxisPosition", dynlib: LibW.} +proc joystickUpdate*(): void {. + cdecl, importc: "sfJoystick_update", dynlib: LibW.} + + +proc newRenderWindow*(handle: TWindowHandle, settings: PContextSettings = nil): PRenderWindow{. + cdecl, importc: "sfRenderWindow_createFromHandle", dynlib: LibG.} +proc newRenderWindow*(mode: TVideoMode, title: cstring, style: int32, settings: PContextSettings = nil): PRenderWindow {. + cdecl, importc: "sfRenderWindow_create", dynlib: LibG.} + +proc destroy*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_destroy", dynlib: LibG.} +proc close*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_close", dynlib: LibG.} +proc isOpen*(window: PRenderWindow): bool {. + cdecl, importc: "sfRenderWindow_isOpen", dynlib: LibG.} + +#void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfuint8* pixels); +#proc setIcon*(window: PRenderWindow, width, height: cint, pixels: seq[uint8]) {. +# cdecl, importc: "sfRenderWindow_setIcon", dynlib: LibG.} + +proc getSettings*(window: PRenderWindow): TContextSettings {. + cdecl, importc: "sfRenderWindow_getSettings", dynlib: LibG.} + +proc pollEvent*(window: PRenderWindow, event: PEvent): bool {. + cdecl, importc: "sfRenderWindow_pollEvent", dynlib: LibG.} +proc pollEvent*(window: PRenderWindow; event: var TEvent): bool {. + cdecl, importc: "sfRenderWindow_pollEvent", dynlib: LibG.} +proc waitEvent*(window: PRenderWindow, event: PEvent): bool {. + cdecl, importc: "sfRenderWindow_waitEvent", dynlib: LibG.} +proc waitEvent*(window: PRenderWindow, event: var TEvent): bool {. + cdecl, importc: "sfRenderWindow_waitEvent", dynlib: LibG.} +proc getPosition*(window: PRenderWindow): TVector2i {. + cdecl, importc: "sfRenderWindow_getPosition", dynlib: LibG.} +proc setPosition*(window: PRenderWindow, position: TVector2i) {. + cdecl, importc: "sfRenderWindow_setPosition", dynlib: LibG.} +proc getSize*(window: PRenderWindow): TVector2i {. + cdecl, importc: "sfRenderWindow_getSize", dynlib: LibG.} +proc setSize*(window: PRenderWindow, size: TVector2i): void {. + cdecl, importc: "sfRenderWindow_setSize", dynlib: LibG.} +proc setTitle*(window: PRenderWindow, title: cstring): void {. + cdecl, importc: "sfRenderWindow_setTitle", dynlib: LibG.} + +proc setVisible*(window: PRenderWindow, visible: bool) {. + cdecl, importc: "sfRenderWindow_setVisible", dynlib: LibG.} +proc setMouseCursorVisible*(window: PRenderWindow, show: bool) {. + cdecl, importc: "sfRenderWindow_setMouseCursorVisible", dynlib: LibG.} +proc setVerticalSyncEnabled*(window: PRenderWindow, enabled: bool) {. + cdecl, importc: "sfRenderWindow_setVerticalSyncEnabled", dynlib: LibG.} +proc setKeyRepeatEnabled*(window: PRenderWindow, enabled: bool) {. + cdecl, importc: "sfRenderWindow_setKeyRepeatEnabled", dynlib: LibG.} +proc setActive*(window: PRenderWindow, active: bool): bool {. + cdecl, importc: "sfRenderWindow_setActive", dynlib: LibG.} +proc display*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_display", dynlib: LibG.} +proc setFramerateLimit*(window: PRenderWindow, limit: uint) {. + cdecl, importc: "sfRenderWindow_setFramerateLimit", dynlib: LibG.} +proc setJoystickThreshold*(window: PRenderWindow, threshold: float) {. + cdecl, importc: "sfRenderWindow_setJoystickThreshold", dynlib: LibG.} +proc getSystemHandle*(window: PRenderWindow): TWindowHandle {. + cdecl, importc: "sfRenderWindow_getSystemHandle", dynlib: LibG.} + +proc clear*(window: PRenderWindow, color: TColor) {. + cdecl, importc: "sfRenderWindow_clear", dynlib: LibG.} + +proc setView*(window: PRenderWindow, view: PView) {. + cdecl, importc: "sfRenderWindow_setView", dynlib: LibG.} +proc getView*(window: PRenderWindow): PView {. + cdecl, importc: "sfRenderWindow_getView", dynlib: LibG.} +proc getDefaultView*(window: PRenderWindow): PView {. + cdecl, importc: "sfRenderWindow_getDefaultView", dynlib: LibG.} +proc getViewport*(window: PRenderWindow, view: PView): TIntRect {. + cdecl, importc: "sfRenderWindow_getViewport", dynlib: LibG.} + +proc convertCoords*(window: PRenderWindow, point: TVector2i, targetView: PView): TVector2f {. + cdecl, importc: "sfRenderWindow_convertCoords", dynlib: LibG.} + +proc draw*(window: PRenderWindow, sprite: PSprite, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawSprite", dynlib: LibG.} +proc draw*(window: PRenderWindow, text: PText, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawText", dynlib: LibG.} +proc draw*(window: PRenderWindow, shape: PShape, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawShape", dynlib: LibG.} +proc draw*(window: PRenderWindow, shape: PCircleShape, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawCircleShape", dynlib: LibG.} +proc draw*(window: PRenderWindow, shape: PRectangleShape, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawRectangleShape", dynlib: LibG.} + +proc draw*(window: PRenderWindow, shape: PConvexShape, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawConvexShape", dynlib: LibG.} +proc draw*(window: PRenderWindow, shape: PVertexArray, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawVertexArray", dynlib: LibG.} +proc draw*(window: PRenderWindow, vertices: PVertex, vertexCount: cint, + vertexType: TPrimitiveType, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawPrimitives", dynlib: LibG.} + +proc pushGlStates*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_pushGLStates", dynlib: LibG.} +proc popGlStates*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_popGLStates", dynlib: LibG.} +proc resetGlStates*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_resetGLStates", dynlib: LibG.} +proc capture*(window: PRenderWindow): PImage {. + cdecl, importc: "sfRenderWindow_capture", dynlib: LibG.} + +#Construct a new render texture +proc newRenderTexture*(width, height: cint; depthBuffer: bool): PRenderTexture {. + cdecl, importc: "sfRenderTexture_create", dynlib: LibG.} +#Destroy an existing render texture +proc destroy*(renderTexture: PRenderTexture){. + cdecl, importc: "sfRenderTexture_destroy", dynlib: LibG.} +#Get the size of the rendering region of a render texture +proc getSize*(renderTexture: PRenderTexture): TVector2i {. + cdecl, importc: "sfRenderTexture_getSize", dynlib: LibG.} +#Activate or deactivate a render texture as the current target for rendering +proc setActive*(renderTexture: PRenderTexture; active: bool): bool{. + cdecl, importc: "sfRenderTexture_setActive", dynlib: LibG.} +#Update the contents of the target texture +proc display*(renderTexture: PRenderTexture){. + cdecl, importc: "sfRenderTexture_display", dynlib: LibG.} +#Clear the rendertexture with the given color +proc clear*(renderTexture: PRenderTexture; color: TColor){. + cdecl, importc: "sfRenderTexture_clear", dynlib: LibG.} +#Change the current active view of a render texture +proc setView*(renderTexture: PRenderTexture; view: PView){. + cdecl, importc: "sfRenderTexture_setView", dynlib: LibG.} +#Get the current active view of a render texture +proc getView*(renderTexture: PRenderTexture): PView{. + cdecl, importc: "sfRenderTexture_getView", dynlib: LibG.} +#Get the default view of a render texture +proc getDefaultView*(renderTexture: PRenderTexture): PView{. + cdecl, importc: "sfRenderTexture_getDefaultView", dynlib: LibG.} +#Get the viewport of a view applied to this target +proc getViewport*(renderTexture: PRenderTexture; view: PView): TIntRect{. + cdecl, importc: "sfRenderTexture_getViewport", dynlib: LibG.} +#Convert a point in texture coordinates into view coordinates +proc convertCoords*(renderTexture: PRenderTexture; point: TVector2i; targetView: PView): TVector2f{. + cdecl, importc: "sfRenderTexture_convertCoords", dynlib: LibG.} +#Draw a drawable object to the render-target +proc draw*(renderTexture: PRenderTexture; sprite: PSprite; states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawSprite", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; text: PText; states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawText", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; shape: PShape; states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawShape", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; shape: PCircleShape; + states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawCircleShape", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; shape: PConvexShape; + states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawConvexShape", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; shape: PRectangleShape; + states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawRectangleShape", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; va: PVertexArray; + states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawVertexArray", dynlib: LibG.} +#Draw primitives defined by an array of vertices to a render texture +proc draw*(renderTexture: PRenderTexture; vertices: PVertex; vertexCount: cint; + primitiveType: TPrimitiveType; states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawPrimitives", dynlib: LibG.} +#Save the current OpenGL render states and matrices +#/ +#/ This function can be used when you mix SFML drawing +#/ and direct OpenGL rendering. Combined with popGLStates, +#/ it ensures that: +#/ * SFML's internal states are not messed up by your OpenGL code +#/ * your OpenGL states are not modified by a call to a SFML function +#/ +#/ Note that this function is quite expensive: it saves all the +#/ possible OpenGL states and matrices, even the ones you +#/ don't care about. Therefore it should be used wisely. +#/ It is provided for convenience, but the best results will +#/ be achieved if you handle OpenGL states yourself (because +#/ you know which states have really changed, and need to be +#/ saved and restored). Take a look at the resetGLStates +#/ function if you do so. +proc pushGLStates*(renderTexture: PRenderTexture){. + cdecl, importc: "sfRenderTexture_pushGLStates", dynlib: LibG.} +#Restore the previously saved OpenGL render states and matrices +#/ +#/ See the description of pushGLStates to get a detailed +#/ description of these functions. +proc popGLStates*(renderTexture: PRenderTexture){. + cdecl, importc: "sfRenderTexture_popGLStates", dynlib: LibG.} +#Reset the internal OpenGL states so that the target is ready for drawing +#/ +#/ This function can be used when you mix SFML drawing +#/ and direct OpenGL rendering, if you choose not to use +#/ pushGLStates/popGLStates. It makes sure that all OpenGL +#/ states needed by SFML are set, so that subsequent sfRenderTexture_draw*() +#/ calls will work as expected. +proc resetGLStates*(renderTexture: PRenderTexture){. + cdecl, importc: "sfRenderTexture_resetGLStates", dynlib: LibG.} +#Get the target texture of a render texture +proc getTexture*(renderTexture: PRenderTexture): PTexture{. + cdecl, importc: "sfRenderTexture_getTexture", dynlib: LibG.} +#Enable or disable the smooth filter on a render texture +proc setSmooth*(renderTexture: PRenderTexture; smooth: bool){. + cdecl, importc: "sfRenderTexture_setSmooth", dynlib: LibG.} +#Tell whether the smooth filter is enabled or not for a render texture +proc isSmooth*(renderTexture: PRenderTexture): bool {. + cdecl, importc: "sfRenderTexture_isSmooth", dynlib: LibG.} + +proc intRect*(left, top, width, height: cint): TIntRect = + result.left = left + result.top = top + result.width = width + result.height = height +proc floatRect*(left, top, width, height: cfloat): TFloatRect = + result.left = left + result.top = top + result.width = width + result.height = height +proc contains*(rect: PFloatRect, x, y: cfloat): bool {. + cdecl, importc: "sfFloatRect_contains", dynlib: LibG.} +proc contains*(rect: PIntRect, x: cint, y: cint): bool{.cdecl, + importc: "sfIntRect_contains", dynlib: LibG.} +proc intersects*(rect1, rect2, intersection: PFloatRect): bool {. + cdecl, importc: "sfFloatRect_intersects", dynlib: LibG.} +proc intersects*(rect1, rect2, intersection: PIntRect): bool {. + cdecl, importc: "sfIntRect_intersects", dynlib: LibG.} + +proc newFont*(filename: cstring): PFont {. + cdecl, importc: "sfFont_createFromFile", dynlib: LibG.} +proc newFont*(data: pointer, sizeInBytes: cint): PFont {. + cdecl, importc: "sfFont_createFromMemory", dynlib: LibG.} +proc newFont*(stream: PInputStream): PFont {. + cdecl, importc: "sfFont_createFromStream", dynlib: LibG.} +proc copy*(font: PFont): PFont {. + cdecl, importc: "sfFont_copy", dynlib: LibG.} +proc destroy*(font: PFont) {. + cdecl, importc: "sfFont_destroy", dynlib: LibG.} +proc getGlyph*(font: PFont, codePoint: uint32, characterSize: cint, bold: bool): TGlyph{. + cdecl, importc: "sfFont_getGlyph", dynlib: LibG.} +proc getKerning*(font: PFont, first: uint32, second: uint32, characterSize: cint): cint {. + cdecl, importc: "sfFont_getKerning", dynlib: LibG.} +proc getLineSpacing*(font: PFont, characterSize: cint): cint {. + cdecl, importc: "sfFont_getLineSpacing", dynlib: LibG.} +proc getTexture*(font: PFont, characterSize: cint): PTexture {. + cdecl, importc: "sfFont_getTexture", dynlib: LibG.} +#getDefaultFont() has been removed from CSFML +proc getDefaultFont*(): PFont {. + error, cdecl, importc: "sfFont_getDefaultFont", dynlib: LibG.} + +proc newCircleShape*(): PCircleShape {. + cdecl, importc: "sfCircleShape_create", dynlib: LibG.} +proc copy*(shape: PCircleShape): PCircleShape {. + cdecl, importc: "sfCircleShape_copy", dynlib: LibG.} +proc destroy*(shape: PCircleShape) {. + cdecl, importc: "sfCircleShape_destroy", dynlib: LibG.} +proc setPosition*(shape: PCircleShape, position: TVector2f) {. + cdecl, importc: "sfCircleShape_setPosition", dynlib: LibG.} +proc setRotation*(shape: PCircleShape, angle: cfloat) {. + cdecl, importc: "sfCircleShape_setRotation", dynlib: LibG.} +proc setScale*(shape: PCircleShape, scale: TVector2f) {. + cdecl, importc: "sfCircleShape_setScale", dynlib: LibG.} +proc setOrigin*(shape: PCircleShape, origin: TVector2f) {. + cdecl, importc: "sfCircleShape_setOrigin", dynlib: LibG.} +proc getPosition*(shape: PCircleShape): TVector2f {. + cdecl, importc: "sfCircleShape_getPosition", dynlib: LibG.} +proc getRotation*(shape: PCircleShape): cfloat {. + cdecl, importc: "sfCircleShape_getRotation", dynlib: LibG.} +proc getScale*(shape: PCircleShape): TVector2f {. + cdecl, importc: "sfCircleShape_getScale", dynlib: LibG.} +proc getOrigin*(shape: PCircleShape): TVector2f {. + cdecl, importc: "sfCircleShape_getOrigin", dynlib: LibG.} +proc move*(shape: PCircleShape, offset: TVector2f) {. + cdecl, importc: "sfCircleShape_move", dynlib: LibG.} +proc rotate*(shape: PCircleShape, angle: cfloat){. + cdecl, importc: "sfCircleShape_rotate", dynlib: LibG.} +proc scale*(shape: PCircleShape, factors: TVector2f) {. + cdecl, importc: "sfCircleShape_scale", dynlib: LibG.} +proc getTransform*(shape: PCircleShape): TTransform {. + cdecl, importc: "sfCircleShape_getTransform", dynlib: LibG.} +proc getInverseTransform*(shape: PCircleShape): TTransform {. + cdecl, importc: "sfCircleShape_getInverseTransform", dynlib: LibG.} +proc setTexture*(shape: PCircleShape, texture: PTexture, resetRect: bool) {. + cdecl, importc: "sfCircleShape_setTexture", dynlib: LibG.} +proc setTextureRect*(shape: PCircleShape, rect: TIntRect) {. + cdecl, importc: "sfCircleShape_setTextureRect", dynlib: LibG.} +proc setFillColor*(shape: PCircleShape, color: TColor) {. + cdecl, importc: "sfCircleShape_setFillColor", dynlib: LibG.} +proc setOutlineColor*(shape: PCircleShape, color: TColor) {. + cdecl, importc: "sfCircleShape_setOutlineColor", dynlib: LibG.} +proc setOutlineThickness*(shape: PCircleShape, thickness: cfloat) {. + cdecl, importc: "sfCircleShape_setOutlineThickness", dynlib: LibG.} +proc getTexture*(shape: PCircleShape): PTexture {. + cdecl, importc: "sfCircleShape_getTexture", dynlib: LibG.} +proc getTextureRect*(shape: PCircleShape): TIntRect {. + cdecl, importc: "sfCircleShape_getTextureRect", dynlib: LibG.} +proc getFillColor*(shape: PCircleShape): TColor {. + cdecl, importc: "sfCircleShape_getFillColor", dynlib: LibG.} +proc getOutlineColor*(shape: PCircleShape): TColor {. + cdecl, importc: "sfCircleShape_getOutlineColor", dynlib: LibG.} +proc getOutlineThickness*(shape: PCircleShape): cfloat {. + cdecl, importc: "sfCircleShape_getOutlineThickness", dynlib: LibG.} +proc getPointCount*(shape: PCircleShape): cint {. + cdecl, importc: "sfCircleShape_getPointCount", dynlib: LibG.} +proc getPoint*(shape: PCircleShape, index: cint): TVector2f {. + cdecl, importc: "sfCircleShape_getPoint", dynlib: LibG.} +proc setRadius*(shape: PCircleShape, radius: cfloat) {. + cdecl, importc: "sfCircleShape_setRadius", dynlib: LibG.} +proc getRadius*(shape: PCircleShape): cfloat {. + cdecl, importc: "sfCircleShape_getRadius", dynlib: LibG.} +proc setPointCount*(shape: PCircleShape, count: cint) {. + cdecl, importc: "sfCircleShape_setPointCount", dynlib: LibG.} +proc getLocalBounds*(shape: PCircleShape): TFloatRect {. + cdecl, importc: "sfCircleShape_getLocalBounds", dynlib: LibG.} +proc getGlobalBounds*(shape: PCircleShape): TFloatRect {. + cdecl, importc: "sfCircleShape_getGlobalBounds", dynlib: LibG.} + +proc newRectangleShape*(): PRectangleShape {. + cdecl, importc: "sfRectangleShape_create", dynlib: LibG.} +proc copy*(shape: PRectangleShape): PRectangleShape {. + cdecl, importc: "sfRectangleShape_copy", dynlib: LibG.} +proc destroy*(shape: PRectangleShape){. + cdecl, importc: "sfRectangleShape_destroy", dynlib: LibG.} +proc setPosition*(shape: PRectangleShape, position: TVector2f) {. + cdecl, importc: "sfRectangleShape_setPosition", dynlib: LibG.} +proc setRotation*(shape: PRectangleShape, angle: cfloat) {. + cdecl, importc: "sfRectangleShape_setRotation", dynlib: LibG.} +proc setScale*(shape: PRectangleShape, scale: TVector2f) {. + cdecl, importc: "sfRectangleShape_setScale", dynlib: LibG.} +proc setOrigin*(shape: PRectangleShape, origin: TVector2f) {. + cdecl, importc: "sfRectangleShape_setOrigin", dynlib: LibG.} +proc getPosition*(shape: PRectangleShape): TVector2f {. + cdecl, importc: "sfRectangleShape_getPosition", dynlib: LibG.} +proc getRotation*(shape: PRectangleShape): cfloat {. + cdecl, importc: "sfRectangleShape_getRotation", dynlib: LibG.} +proc getScale*(shape: PRectangleShape): TVector2f {. + cdecl, importc: "sfRectangleShape_getScale", dynlib: LibG.} +proc getOrigin*(shape: PRectangleShape): TVector2f {. + cdecl, importc: "sfRectangleShape_getOrigin", dynlib: LibG.} +proc move*(shape: PRectangleShape, offset: TVector2f) {. + cdecl, importc: "sfRectangleShape_move", dynlib: LibG.} +proc rotate*(shape: PRectangleShape, angle: cfloat) {. + cdecl, importc: "sfRectangleShape_rotate", dynlib: LibG.} +proc scale*(shape: PRectangleShape, factors: TVector2f) {. + cdecl, importc: "sfRectangleShape_scale", dynlib: LibG.} +proc getTransform*(shape: PRectangleShape): TTransform {. + cdecl, importc: "sfRectangleShape_getTransform", dynlib: LibG.} +proc getInverseTransform*(shape: PRectangleShape): TTransform {. + cdecl, importc: "sfRectangleShape_getInverseTransform", dynlib: LibG.} +proc setTexture*(shape: PRectangleShape, texture: PTexture, resetRect: bool) {. + cdecl, importc: "sfRectangleShape_setTexture", dynlib: LibG.} +proc setTextureRect*(shape: PRectangleShape, rect: TIntRect) {. + cdecl, importc: "sfRectangleShape_setTextureRect", dynlib: LibG.} +proc setFillColor*(shape: PRectangleShape, color: TColor) {. + cdecl, importc: "sfRectangleShape_setFillColor", dynlib: LibG.} +proc setOutlineColor*(shape: PRectangleShape, color: TColor) {. + cdecl, importc: "sfRectangleShape_setOutlineColor", dynlib: LibG.} +proc setOutlineThickness*(shape: PRectangleShape, thickness: cfloat) {. + cdecl, importc: "sfRectangleShape_setOutlineThickness", dynlib: LibG.} +proc getTexture*(shape: PRectangleShape): PTexture {. + cdecl, importc: "sfRectangleShape_getTexture", dynlib: LibG.} +proc getTextureRect*(shape: PRectangleShape): TIntRect {. + cdecl, importc: "sfRectangleShape_getTextureRect", dynlib: LibG.} +proc getFillColor*(shape: PRectangleShape): TColor {. + cdecl, importc: "sfRectangleShape_getFillColor", dynlib: LibG.} +proc getOutlineColor*(shape: PRectangleShape): TColor {. + cdecl, importc: "sfRectangleShape_getOutlineColor", dynlib: LibG.} +proc getOutlineThickness*(shape: PRectangleShape): cfloat {. + cdecl, importc: "sfRectangleShape_getOutlineThickness", dynlib: LibG.} +proc getPointCount*(shape: PRectangleShape): cint {. + cdecl, importc: "sfRectangleShape_getPointCount", dynlib: LibG.} +proc getPoint*(shape: PRectangleShape, index: cint): TVector2f {. + cdecl, importc: "sfRectangleShape_getPoint", dynlib: LibG.} +proc setSize*(shape: PRectangleShape, size: TVector2f) {. + cdecl, importc: "sfRectangleShape_setSize", dynlib: LibG.} +proc getSize*(shape: PRectangleShape): TVector2f {. + cdecl, importc: "sfRectangleShape_getSize", dynlib: LibG.} +proc getLocalBounds*(shape: PRectangleShape): TFloatRect {. + cdecl, importc: "sfRectangleShape_getLocalBounds", dynlib: LibG.} +proc getGlobalBounds*(shape: PRectangleShape): TFloatRect {. + cdecl, importc: "sfRectangleShape_getGlobalBounds", dynlib: LibG.} + + +proc newView*(): PView {. + cdecl, importc: "sfView_create", dynlib: LibG.} +proc viewFromRect*(rectangle: TFloatRect): PView{. + cdecl, importc: "sfView_createFromRect", dynlib: LibG.} +proc copy*(view: PView): PView {. + cdecl, importc: "sfView_copy", dynlib: LibG.} +proc destroy*(view: PView) {. + cdecl, importc: "sfView_destroy", dynlib: LibG.} +proc setCenter*(view: PView, center: TVector2f) {. + cdecl, importc: "sfView_setCenter", dynlib: LibG.} +proc setSize*(view: PView, size: TVector2f) {. + cdecl, importc: "sfView_setSize", dynlib: LibG.} +proc setRotation*(view: PView, angle: cfloat) {. + cdecl, importc: "sfView_setRotation", dynlib: LibG.} +proc setViewport*(view: PView, viewport: TFloatRect) {. + cdecl, importc: "sfView_setViewport", dynlib: LibG.} +proc reset*(view: PView, rectangle: TFloatRect) {. + cdecl, importc: "sfView_reset", dynlib: LibG.} +proc getCenter*(view: PView): TVector2f {. + cdecl, importc: "sfView_getCenter", dynlib: LibG.} +proc getSize*(view: PView): TVector2f {. + cdecl, importc: "sfView_getSize", dynlib: LibG.} +proc getRotation*(view: PView): cfloat {. + cdecl, importc: "sfView_getRotation", dynlib: LibG.} +proc getViewport*(view: PView): TFloatRect {. + cdecl, importc: "sfView_getViewport", dynlib: LibG.} +proc move*(view: PView, offset: TVector2f) {. + cdecl, importc: "sfView_move", dynlib: LibG.} +proc rotate*(view: PView, angle: cfloat) {. + cdecl, importc: "sfView_rotate", dynlib: LibG.} +proc zoom*(view: PView, factor: cfloat) {. + cdecl, importc: "sfView_zoom", dynlib: LibG.} + +proc newImage*(width, height: cint): PImage {. + cdecl, importc: "sfImage_create", dynlib: LibG.} +proc newImage*(width, height: cint, color: TColor): PImage {. + cdecl, importc: "sfImage_createFromColor", dynlib: LibG.} +proc newImage*(width, height: cint, pixels: pointer): PImage {. ##same deal as setIcon() + cdecl, importc: "sfImage_createFromPixels", dynlib: LibG.} +proc newImage*(filename: cstring): PImage {. + cdecl, importc: "sfImage_createFromFile", dynlib: LibG.} +proc newImage*(data: pointer, size: cint): PImage {. + cdecl, importc: "sfImage_createFromMemory", dynlib: LibG.} +proc newImage*(stream: PInputStream): PImage {. + cdecl, importc: "sfImage_createFromStream", dynlib: LibG.} +proc copy*(image: PImage): PImage {. + cdecl, importc: "sfImage_copy", dynlib: LibG.} +proc destroy*(image: PImage) {. + cdecl, importc: "sfImage_destroy", dynlib: LibG.} +proc save*(image: PImage, filename: cstring): bool {. + cdecl, importc: "sfImage_saveToFile", dynlib: LibG.} +proc getSize*(image: PImage): TVector2i {. + cdecl, importc: "sfImage_getSize", dynlib: LibG.} +proc createMask*(image: PImage, color: TColor, alpha: cchar) {. + cdecl, importc: "sfImage_createMaskFromColor", dynlib: LibG.} +proc copy*(destination, source: PImage, destX, destY: cint; + sourceRect: TIntRect, applyAlpha: bool) {. + cdecl, importc: "sfImage_copyImage", dynlib: LibG.} +proc setPixel*(image: PImage, x, y: cint, color: TColor) {. + cdecl, importc: "sfImage_setPixel", dynlib: LibG.} +proc getPixel*(image: PImage, x, y: cint): TColor {. + cdecl, importc: "sfImage_getPixel", dynlib: LibG.} +proc getPixels*(image: PImage): pointer {. + cdecl, importc: "sfImage_getPixelsPtr", dynlib: LibG.} +proc flipHorizontally*(image: PImage) {. + cdecl, importc: "sfImage_flipHorizontally", dynlib: LibG.} +proc flipVertically*(image: PImage) {. + cdecl, importc: "sfImage_flipVertically", dynlib: LibG.} + +proc newSprite*(): PSprite {. + cdecl, importc: "sfSprite_create", dynlib: LibG.} +proc copy*(sprite: PSprite): PSprite {. + cdecl, importc: "sfSprite_copy", dynlib: LibG.} +proc destroy*(sprite: PSprite) {. + cdecl, importc: "sfSprite_destroy", dynlib: LibG.} +proc setPosition*(sprite: PSprite, position: TVector2f) {. + cdecl, importc: "sfSprite_setPosition", dynlib: LibG.} +proc setRotation*(sprite: PSprite, angle: cfloat) {. + cdecl, importc: "sfSprite_setRotation", dynlib: LibG.} +proc setScale*(sprite: PSprite, scale: TVector2f) {. + cdecl, importc: "sfSprite_setScale", dynlib: LibG.} +proc setOrigin*(sprite: PSprite, origin: TVector2f) {. + cdecl, importc: "sfSprite_setOrigin", dynlib: LibG.} +proc getPosition*(sprite: PSprite): TVector2f {. + cdecl, importc: "sfSprite_getPosition", dynlib: LibG.} +proc getRotation*(sprite: PSprite): cfloat {. + cdecl, importc: "sfSprite_getRotation", dynlib: LibG.} +proc getScale*(sprite: PSprite): TVector2f {. + cdecl, importc: "sfSprite_getScale", dynlib: LibG.} +proc getOrigin*(sprite: PSprite): TVector2f {. + cdecl, importc: "sfSprite_getOrigin", dynlib: LibG.} +proc move*(sprite: PSprite, offset: TVector2f) {. + cdecl, importc: "sfSprite_move", dynlib: LibG.} +proc rotate*(sprite: PSprite, angle: cfloat) {. + cdecl, importc: "sfSprite_rotate", dynlib: LibG.} +proc scale*(sprite: PSprite, factor: TVector2f) {. + cdecl, importc: "sfSprite_scale", dynlib: LibG.} +proc getTransform*(sprite: PSprite): TTransform {. + cdecl, importc: "sfSprite_getTransform", dynlib: LibG.} +proc getInverseTransform*(sprite: PSprite): TTransform {. + cdecl, importc: "sfSprite_getInverseTransform", dynlib: LibG.} +proc setTexture*(sprite: PSprite, texture: PTexture, resetRect: bool) {. + cdecl, importc: "sfSprite_setTexture", dynlib: LibG.} +proc setTextureRect*(sprite: PSprite, rectangle: TIntRect) {. + cdecl, importc: "sfSprite_setTextureRect", dynlib: LibG.} +proc setColor*(sprite: PSprite, color: TColor) {. + cdecl, importc: "sfSprite_setColor", dynlib: LibG.} +proc getTexture*(sprite: PSprite): TTexture {. + cdecl, importc: "sfSprite_getTexture", dynlib: LibG.} +proc getTextureRect*(sprite: PSprite): TIntRect {. + cdecl, importc: "sfSprite_getTextureRect", dynlib: LibG.} +proc getColor*(sprite: PSprite): TColor {. + cdecl, importc: "sfSprite_getColor", dynlib: LibG.} +proc getLocalBounds*(sprite: PSprite): TFloatRect {. + cdecl, importc: "sfSprite_getLocalBounds", dynlib: LibG.} +proc getGlobalBounds*(sprite: PSprite): TFloatRect {. + cdecl, importc: "sfSprite_getGlobalBounds", dynlib: LibG.} + +proc newTexture*(width, height: cint): PTexture {. + cdecl, importc: "sfTexture_create", dynlib: LibG.} +proc newTexture*(filename: cstring): PTexture {. + cdecl, importc: "sfTexture_createFromFile", dynlib: LibG.} +proc newTexture*(data: pointer, size: cint, area: PIntRect): PTexture {. + cdecl, importc: "sfTexture_createFromMemory", dynlib: LibG.} +proc newTexture*(stream: PInputStream, area: PIntRect): PTexture {. + cdecl, importc: "sfTexture_createFromStream", dynlib: LibG.} +proc newTexture*(image: PImage, area: PIntRect = nil): PTexture {. + cdecl, importc: "sfTexture_createFromImage", dynlib: LibG.} +proc copy*(texture: PTexture): PTexture {. + cdecl, importc: "sfTexture_copy", dynlib: LibG.} +proc destroy*(texture: PTexture) {. + cdecl, importc: "sfTexture_destroy", dynlib: LibG.} +proc getSize*(texture: PTexture): TVector2i {. + cdecl, importc: "sfTexture_getSize", dynlib: LibG.} +proc copyToImage*(texture: PTexture): PImage {. + cdecl, importc: "sfTexture_copyToImage", dynlib: LibG.} +proc updateFromPixels*(texture: PTexture, pixels: pointer, width, height, x, y: cint) {. + cdecl, importc: "sfTexture_updateFromPixels", dynlib: LibG.} +proc updateFromImage*(texture: PTexture, image: PImage, x, y: cint) {. + cdecl, importc: "sfTexture_updateFromImage", dynlib: LibG.} +proc updateFromWindow*(texture: PTexture, window: PWindow, x, y: cint) {. + cdecl, importc: "sfTexture_updateFromWindow", dynlib: LibG.} +proc updateFromWindow*(texture: PTexture, window: PRenderWindow, x, y: cint) {. + cdecl, importc: "sfTexture_updateFromRenderWindow", dynlib: LibG.} +proc bindGL*(texture: PTexture) {. + cdecl, importc: "sfTexture_bind", dynlib: LibG.} +proc setSmooth*(texture: PTexture, smooth: bool) {. + cdecl, importc: "sfTexture_setSmooth", dynlib: LibG.} +proc isSmooth*(texture: PTexture): bool {. + cdecl, importc: "sfTexture_isSmooth", dynlib: LibG.} +proc setRepeated*(texture: PTexture, repeated: bool) {. + cdecl, importc: "sfTexture_setRepeated", dynlib: LibG.} +proc isRepeated*(texture: PTexture): bool {. + cdecl, importc: "sfTexture_isRepeated", dynlib: LibG.} +proc textureMaxSize*(): cint {. + cdecl, importc: "sfTexture_getMaximumSize", dynlib: LibG.} + +proc newVertexArray*(): PVertexArray {. + cdecl, importc: "sfVertexArray_create", dynlib: LibG.} +proc copy*(vertexArray: PVertexArray): PVertexArray {. + cdecl, importc: "sfVertexArray_copy", dynlib: LibG.} +proc destroy*(va: PVertexArray) {. + cdecl, importc: "sfVertexArray_destroy", dynlib: LibG.} +proc getVertexCount*(va: PVertexArray): cint {. + cdecl, importc: "sfVertexArray_getVertexCount", dynlib: LibG.} +proc getVertex*(va: PVertexArray, index: cint): PVertex {. + cdecl, importc: "sfVertexArray_getVertex", dynlib: LibG.} +proc clear*(va: PVertexArray) {. + cdecl, importc: "sfVertexArray_clear", dynlib: LibG.} +proc resize*(va: PVertexArray, size: cint) {. + cdecl, importc: "sfVertexArray_resize", dynlib: LibG.} +proc append*(va: PVertexArray, vertex: TVertex) {. + cdecl, importc: "sfVertexArray_append", dynlib: LibG.} +proc setPrimitiveType*(va: PVertexArray, primitiveType: TPrimitiveType) {. + cdecl, importc: "sfVertexArray_setPrimitiveType", dynlib: LibG.} +proc getPrimitiveType*(va: PVertexArray): TPrimitiveType {. + cdecl, importc: "sfVertexArray_getPrimitiveType", dynlib: LibG.} +proc getBounds*(va: PVertexArray): TFloatRect {. + cdecl, importc: "sfVertexArray_getBounds", dynlib: LibG.} + + +proc newText*(): PText {. + cdecl, importc: "sfText_create", dynlib: LibG.} +proc copy*(text: PText): PText {. + cdecl, importc: "sfText_copy", dynlib: LibG.} +proc destroy*(text: PText) {. + cdecl, importc: "sfText_destroy", dynlib: LibG.} +proc setPosition*(text: PText, position: TVector2f) {. + cdecl, importc: "sfText_setPosition", dynlib: LibG.} +proc setRotation*(text: PText, angle: cfloat) {. + cdecl, importc: "sfText_setRotation", dynlib: LibG.} +proc setScale*(text: PText, scale: TVector2f) {. + cdecl, importc: "sfText_setScale", dynlib: LibG.} +proc setOrigin*(text: PText, origin: TVector2f) {. + cdecl, importc: "sfText_setOrigin", dynlib: LibG.} +proc getPosition*(text: PText): TVector2f {. + cdecl, importc: "sfText_getPosition", dynlib: LibG.} +proc getRotation*(text: PText): cfloat {. + cdecl, importc: "sfText_getRotation", dynlib: LibG.} +proc getScale*(text: PText): TVector2f {. + cdecl, importc: "sfText_getScale", dynlib: LibG.} +proc getOrigin*(text: PText): TVector2f {. + cdecl, importc: "sfText_getOrigin", dynlib: LibG.} +proc move*(text: PText, offset: TVector2f) {. + cdecl, importc: "sfText_move", dynlib: LibG.} +proc rotate*(text: PText, angle: cfloat) {. + cdecl, importc: "sfText_rotate", dynlib: LibG.} +proc scale*(text: PText, factors: TVector2f) {. + cdecl, importc: "sfText_scale", dynlib: LibG.} +proc getTransform*(text: PText): TTransform {. + cdecl, importc: "sfText_getTransform", dynlib: LibG.} +proc getInverseTransform*(text: PText): TTransform {. + cdecl, importc: "sfText_getInverseTransform", dynlib: LibG.} +proc setString*(text: PText, string: cstring) {. + cdecl, importc: "sfText_setString", dynlib: LibG.} +proc setUnicodeString*(text: PText, string: ptr uint32) {. + cdecl, importc: "sfText_setUnicodeString", dynlib: LibG.} +proc setFont*(text: PText, font: PFont) {. + cdecl, importc: "sfText_setFont", dynlib: LibG.} +proc setCharacterSize*(text: PText, size: cint) {. + cdecl, importc: "sfText_setCharacterSize", dynlib: LibG.} +proc setStyle*(text: PText, style: TTextStyle) {. + cdecl, importc: "sfText_setStyle", dynlib: LibG.} +proc setColor*(text: PText, color: TColor) {. + cdecl, importc: "sfText_setColor", dynlib: LibG.} +proc getString*(text: PText): cstring {. + cdecl, importc: "sfText_getString", dynlib: LibG.} +proc getUnicodeString*(text: PText): ptr uint32 {.cdecl, + importc: "sfText_getUnicodeString", dynlib: LibG.} +proc getFont*(text: PText): PFont {. + cdecl, importc: "sfText_getFont", dynlib: LibG.} +proc getCharacterSize*(text: PText): cint {. + cdecl, importc: "sfText_getCharacterSize", dynlib: LibG.} +proc getStyle*(text: PText): uint32 {. + cdecl, importc: "sfText_getStyle", dynlib: LibG.} +proc getColor*(text: PText): TColor {. + cdecl, importc: "sfText_getColor", dynlib: LibG.} +proc findCharacterPos*(text: PText, index: cint): TVector2f {. + cdecl, importc: "sfText_findCharacterPos", dynlib: LibG.} +proc getLocalBounds*(text: PText): TFloatRect {. + cdecl, importc: "sfText_getLocalBounds", dynlib: LibG.} +proc getGlobalBounds*(text: PText): TFloatRect {. + cdecl, importc: "sfText_getGlobalBounds", dynlib: LibG.} + +proc transformFromMatrix*(a00, a01, a02, a10, a11, a12, a20, a21, a22: cfloat): TTransform {. + cdecl, importc: "sfTransform_fromMatrix", dynlib: LibG.} +proc getMatrix*(transform: PTransform, matrix: ptr cfloat) {. + cdecl, importc: "sfTransform_getMatrix", dynlib: LibG.} +proc getInverse*(transform: PTransform): TTransform {. + cdecl, importc: "sfTransform_getInverse", dynlib: LibG.} +proc transformPoint*(transform: PTransform, point: TVector2f): TVector2f {. + cdecl, importc: "sfTransform_transformPoint", dynlib: LibG.} +proc transformRect*(transform: PTransform, rectangle: TFloatRect): TFloatRect {. + cdecl, importc: "sfTransform_transformRect", dynlib: LibG.} +proc combine*(transform: PTransform, other: PTransform) {. + cdecl, importc: "sfTransform_combine", dynlib: LibG.} +proc translate*(transform: PTransform, x, y: cfloat) {. + cdecl, importc: "sfTransform_translate", dynlib: LibG.} +proc rotate*(transform: PTransform, angle: cfloat) {. + cdecl, importc: "sfTransform_rotate", dynlib: LibG.} +proc rotateWithCenter*(transform: PTransform, angle, centerX, centerY: cfloat){. + cdecl, importc: "sfTransform_rotateWithCenter", dynlib: LibG.} +proc scale*(transform: PTransform, scaleX, scaleY: cfloat) {. + cdecl, importc: "sfTransform_scale", dynlib: LibG.} +proc scaleWithCenter*(transform: PTransform, scaleX, scaleY, centerX, centerY: cfloat) {. + cdecl, importc: "sfTransform_scaleWithCenter", dynlib: LibG.} +let IdentityMatrix*: TTransform = transformFromMatrix(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0) + + +proc newShader*(VSfilename: cstring, fragmentShaderFilename: cstring): PShader {. + cdecl, importc: "sfShader_createFromFile", dynlib: LibG.} +proc newShaderFromStr*(vertexShader: cstring, fragmentShader: cstring): PShader {. + cdecl, importc: "sfShader_createFromMemory", dynlib: LibG.} +proc newShader*(vertexShaderStream: PInputStream, fragmentShaderStream: PInputStream): PShader {. + cdecl, importc: "sfShader_createFromStream", dynlib: LibG.} +proc destroy*(shader: PShader) {. + cdecl, importc: "sfShader_destroy", dynlib: LibG.} +proc setFloatParameter*(shader: PShader, name: cstring, x: cfloat) {. + cdecl, importc: "sfShader_setFloatParameter", dynlib: LibG.} +proc setFloat2Parameter*(shader: PShader, name: cstring, x, y: cfloat) {. + cdecl, importc: "sfShader_setFloat2Parameter", dynlib: LibG.} +proc setFloat3Parameter*(shader: PShader, name: cstring, x, y, z: cfloat) {. + cdecl, importc: "sfShader_setFloat3Parameter", dynlib: LibG.} +proc setFloat4Parameter*(shader: PShader, name: cstring, x, y, z, w: cfloat) {. + cdecl, importc: "sfShader_setFloat4Parameter", dynlib: LibG.} +proc setVector2Parameter*(shader: PShader, name: cstring, vector: TVector2f) {. + cdecl, importc: "sfShader_setVector2Parameter", dynlib: LibG.} +proc setVector3Parameter*(shader: PShader, name: cstring, vector: TVector3f) {. + cdecl, importc: "sfShader_setVector3Parameter", dynlib: LibG.} +proc setColorParameter*(shader: PShader, name: cstring, color: TColor) {. + cdecl, importc: "sfShader_setColorParameter", dynlib: LibG.} +proc setTransformParameter*(shader: PShader, name: cstring, transform: TTransform) {. + cdecl, importc: "sfShader_setTransformParameter", dynlib: LibG.} +proc setTextureParameter*(shader: PShader, name: cstring, texture: PTexture) {. + cdecl, importc: "sfShader_setTextureParameter", dynlib: LibG.} +proc setCurrentTextureParameter*(shader: PShader, name: cstring) {. + cdecl, importc: "sfShader_setCurrentTextureParameter", dynlib: LibG.} +proc bindGL*(shader: PShader) {. + cdecl, importc: "sfShader_bind", dynlib: LibG.} +proc unbindGL*(shader: PShader) {. + cdecl, importc: "sfShader_unbind", dynlib: LibG.} +proc shaderIsAvailable*(): bool {. + cdecl, importc: "sfShader_isAvailable", dynlib: LibG.} + +proc color*(red, green, blue: cchar): TColor {. + cdecl, importc: "sfColor_fromRGB", dynlib: LibG.} +proc color*(red, green, blue: int): TColor {.inline.} = + return color(red.cchar, green.cchar, blue.cchar) +proc color*(red, green, blue, alpha: cchar): TColor {. + cdecl, importc: "sfColor_fromRGBA", dynlib: LibG.} +proc color*(red, green, blue, alpha: int): TColor {.inline.} = + return color(red.cchar, green.cchar, blue.cchar, alpha.cchar) +proc `+`*(color1, color2: TColor): TColor {. + cdecl, importc: "sfColor_add", dynlib: LibG.} +proc `*`*(color1, color2: TColor): TColor {. + cdecl, importc: "sfColor_modulate", dynlib: LibG.} +proc newColor*(r,g,b: int): TColor {.inline.} = + return color(r,g,b) +proc newColor*(r,g,b,a: int): TColor {.inline.} = + return color(r,g,b,a) + +proc newClock*(): PClock {. + cdecl, importc: "sfClock_create", dynlib: LibS.} +proc copy*(clocK: PClock): PClock {. + cdecl, importc: "sfClock_copy", dynlib: LibS.} +proc destroy*(clock: PClock): PClock {. + cdecl, importc: "sfClock_destroy", dynlib: LibS.} +proc getElapsedTime*(clock: PClock): TTime {. + cdecl, importc: "sfClock_getElapsedTime", dynlib: LibS.} +proc restart*(clock: PClock): TTime {. + cdecl, importc: "sfClock_restart", dynlib: LibS, discardable.} +proc asSeconds*(time: TTime): cfloat {. + cdecl, importc: "sfTime_asSeconds", dynlib: LibS.} +proc asMilliseconds*(time: TTime): int32 {. + cdecl, importc: "sfTime_asMilliseconds", dynlib: LibS.} +proc asMicroseconds*(time: TTime): int64 {. + cdecl, importc: "sfTime_asMicroseconds", dynlib: LibS.} +proc seconds*(seconds: cfloat): TTime {. + cdecl, importc: "sfSeconds", dynlib: LibS.} +proc milliseconds*(ms: int32): TTime {. + cdecl, importc: "sfMilliseconds", dynlib: LibS.} +proc microseconds*(us: int64): TTime {. + cdecl, importc: "sfMicroseconds", dynlib: LibS.} + +proc newContextSettings*(depthBits: cint = 0, + stencilBits: cint = 0, + antialiasingLevel: cint = 0, + majorVersion: cint = 0, + minorVersion: cint = 0): TContextSettings = + result.depthBits = depthBits + result.stencilBits = stencilBits + result.antialiasingLevel = antialiasingLevel + result.majorVersion = majorVersion + result.minorVersion = minorVersion + +proc newCircleShape*(radius: cfloat; pointCount: cint = 30): PCircleShape = + result = newCircleShape() + result.setRadius radius + result.setPointCount pointCount +proc newText*(str: string, font: PFont, size: int): PText = + result = newText() + result.setString(str) + result.setFont(font) + result.setCharacterSize(size.cint) +proc newVertexArray*(primitiveType: TPrimitiveType, vertexCount: cint = 0): PVertexArray = + result = newVertexArray() + result.setPrimitiveType(primitiveType) + if vertexCount != 0: + result.resize(vertexCount) +proc videoMode*(width, height, bpp: cint): TVideoMode = + result.width = width + result.height = height + result.bitsPerPixel = bpp + +proc `[]`*(a: PVertexArray, index: int): PVertex = + return getVertex(a, index.cint) + +proc `$` *(a: TContextSettings): string = + return "<TContextSettings stencil=$1 aa=$2 major=$3 minor=$4 depth=$5>" % [ + $a.stencilBits, $a.antialiasingLevel, $a.majorVersion, $a.minorVersion, $a.depthBits] +proc `$` *(a: TVideoMode): string = + return "<TVideoMode $1x$2 $3bpp>" % [$a.width, $a.height, $a.bitsPerPixel] +proc `$` *(a: TFloatRect): string = + return "<TFloatRect $1,$2 $3x$4>" % [$a.left, $a.top, $a.width, $a.height] +proc `$` *(a: PView): string = + return $a.getViewport() +proc `$` *(a: TVector2f): string = + return "<TVector2f $1,$2>" % [$a.x, $a.y] + +proc vec2i*(x, y: int): TVector2i = + result.x = x.cint + result.y = y.cint +proc vec2f*(x, y: float): TVector2f = + result.x = x.cfloat + result.y = y.cfloat + +proc `+`*(a, b: TVector2f): TVector2f {.inline.} = + result.x = a.x + b.x + result.y = a.y + b.y +proc `-`*(a: TVector2f): TVector2f {.inline.} = + result.x = -a.x + result.y = -a.y +proc `-`*(a, b: TVector2f): TVector2f {.inline.}= + result.x = a.x - b.x + result.y = a.y - b.y +proc `*`*(a: TVector2f, b: cfloat): TVector2f {.inline.} = + result.x = a.x * b + result.y = a.y * b +proc `*`*(a, b: TVector2f): TVector2f {.inline.} = + result.x = a.x * b.x + result.y = a.y * b.y +proc `/`*(a: TVector2f, b: cfloat): TVector2f {.inline.} = + result.x = a.x / b + result.y = a.y / b +proc `+=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = + a = a + b +proc `-=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = + a = a - b +proc `*=` *(a: var TVector2f, b: float) {.inline, noSideEffect.} = + a = a * b +proc `*=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = + a = a * b +proc `/=` *(a: var TVector2f, b: float) {.inline, noSideEffect.} = + a = a / b +proc `<` *(a, b: TVector2f): bool {.inline, noSideEffect.} = + return a.x < b.x or (a.x == b.x and a.y < b.y) +proc `<=` *(a, b: TVector2f): bool {.inline, noSideEffect.} = + return a.x <= b.x and a.y <= b.y +proc `==` *(a, b: TVector2f): bool {.inline, noSideEffect.} = + return a.x == b.x and a.y == b.y +proc length*(a: TVector2f): float {.inline.} = + return sqrt(pow(a.x, 2.0) + pow(a.y, 2.0)) +proc lengthSq*(a: TVector2f): float {.inline.} = + return pow(a.x, 2.0) + pow(a.y, 2.0) +proc distanceSq*(a, b: TVector2f): float {.inline.} = + return pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0) +proc distance*(a, b: TVector2f): float {.inline.} = + return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0)) +proc permul*(a, b: TVector2f): TVector2f = + result.x = a.x * b.x + result.y = a.y * b.y +proc rotate*(a: TVector2f, phi: float): TVector2f = + var c = cos(phi) + var s = sin(phi) + result.x = a.x * c - a.y * s + result.y = a.x * s + a.y * c +proc perpendicular(a: TVector2f): TVector2f = + result.x = -a.x + result.y = a.y +proc cross(a, b: TVector2f): float = + return a.x * b.y - a.y * b.x + diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim new file mode 100644 index 000000000..6f81e50a3 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim @@ -0,0 +1,899 @@ +import + sfml +const + Lib = "libcsfml-audio.so.2.0" +type + PMusic* = ptr TMusic + TMusic* {.pure, final.} = object + PSound* = ptr TSound + TSound* {.pure, final.} = object + PSoundBuffer* = ptr TSoundBuffer + TSoundBuffer* {.pure, final.} = object + PSoundBufferRecorder* = ptr TSoundBufferRecorder + TSoundBufferRecorder* {.pure, final.} = object + PSoundRecorder* = ptr TSoundRecorder + TSoundRecorder* {.pure, final.} = object + PSoundStream* = ptr TSoundStream + TSoundStream* {.pure, final.} = object + TSoundStatus* {.size: sizeof(cint).} = enum + Stopped, Paused, Playing + +proc newMusic*(filename: cstring): PMusic {. + cdecl, importc: "sfMusic_createFromFile", dynlib: Lib.} +proc newMusic*(data: pointer, size: cint): PMusic {. + cdecl, importc: "sfMusic_createFromMemory", dynlib: Lib.} +proc newMusic*(stream: PInputStream): PMusic {. + cdecl, importc: "sfMusic_createFromStream", dynlib: Lib.} +proc destroy*(music: PMusic) {. + cdecl, importc: "sfMusic_destroy", dynlib: Lib.} +proc setLoop*(music: PMusic, loop: bool) {. + cdecl, importc: "sfMusic_setLoop", dynlib: Lib.} +proc getLoop*(music: PMusic): bool {. + cdecl, importc: "sfMusic_getLoop", dynlib: Lib.} +proc getDuration*(music: PMusic): TTime {. + cdecl, importc: "sfMusic_getDuration", dynlib: Lib.} +proc play*(music: PMusic) {. + cdecl, importc: "sfMusic_play", dynlib: Lib.} +proc pause*(music: PMusic) {. + cdecl, importc: "sfMusic_pause", dynlib: Lib.} +proc stop*(music: PMusic) {. + cdecl, importc: "sfMusic_stop", dynlib: Lib.} +proc getChannelCount*(music: PMusic): cint {. + cdecl, importc: "sfMusic_getChannelCount", dynlib: Lib.} +proc getSampleRate*(music: PMusic): cint {. + cdecl, importc: "sfMusic_getSampleRate", dynlib: Lib.} +proc getStatus*(music: PMusic): TSoundStatus {. + cdecl, importc: "sfMusic_getStatus", dynlib: Lib.} +proc getPlayingOffset*(music: PMusic): TTime {. + cdecl, importc: "sfMusic_getPlayingOffset", dynlib: Lib.} +proc setPitch*(music: PMusic, pitch: cfloat) {. + cdecl, importc: "sfMusic_setPitch", dynlib: Lib.} +proc setVolume*(music: PMusic, volume: float) {. + cdecl, importc: "sfMusic_setVolume", dynlib: Lib.} +proc setPosition*(music: PMusic, position: TVector3f) {. + cdecl, importc: "sfMusic_setPosition", dynlib: Lib.} +proc setRelativeToListener*(music: PMusic, relative: bool) {. + cdecl, importc: "sfMusic_setRelativeToListener", dynlib: Lib.} +proc setMinDistance*(music: PMusic, distance: cfloat) {. + cdecl, importc: "sfMusic_setMinDistance", dynlib: Lib.} +proc setAttenuation*(music: PMusic, attenuation: cfloat) {. + cdecl, importc: "sfMusic_setAttenuation", dynlib: Lib.} +proc setPlayingOffset*(music: PMusic, time: TTime) {. + cdecl, importc: "sfMusic_setPlayingOffset", dynlib: Lib.} +proc getPitch*(music: PMusic): cfloat {. + cdecl, importc: "sfMusic_getPitch", dynlib: Lib.} +proc getVolume*(music: PMusic): cfloat {. + cdecl, importc: "sfMusic_getVolume", dynlib: Lib.} +proc getPosition*(music: PMusic): TVector3f {. + cdecl, importc: "sfMusic_getPosition", dynlib: Lib.} +proc isRelativeToListener*(music: PMusic): bool {. + cdecl, importc: "sfMusic_isRelativeToListener", dynlib: Lib.} +proc getMinDistance*(music: PMusic): cfloat {. + cdecl, importc: "sfMusic_isRelativeToListener", dynlib: Lib.} +proc getAttenuation*(music: PMusic): cfloat {. + cdecl, importc: "sfMusic_isRelativeToListener", dynlib: Lib.} + +#/ \brief Create a new sound +proc newSound*(): PSound{. + cdecl, importc: "sfSound_create", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound by copying an existing one +#/ +#/ \param sound Sound to copy +#/ +#/ \return A new sfSound object which is a copy of \a sound +#/ +#////////////////////////////////////////////////////////// +proc copy*(sound: PSound): PSound{. + cdecl, importc: "sfSound_copy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Destroy a sound +proc destroy*(sound: PSound){. + cdecl, importc: "sfSound_destroy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Start or resume playing a sound +#/ +#/ This function starts the sound if it was stopped, resumes +#/ it if it was paused, and restarts it from beginning if it +#/ was it already playing. +#/ This function uses its own thread so that it doesn't block +#/ the rest of the program while the sound is played. +proc play*(sound: PSound){. + cdecl, importc: "sfSound_play", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ This function pauses the sound if it was playing, +#/ otherwise (sound already paused or stopped) it has no effect. +proc pause*(sound: PSound){. + cdecl, importc: "sfSound_pause", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ This function stops the sound if it was playing or paused, +#/ and does nothing if it was already stopped. +#/ It also resets the playing position (unlike sfSound_pause). +proc stop*(sound: PSound){. + cdecl, importc: "sfSound_stop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ It is important to note that the sound buffer is not copied, +#/ thus the sfSoundBuffer object must remain alive as long +#/ as it is attached to the sound. +proc setBuffer*(sound: PSound; buffer: PSoundBuffer){. + cdecl, importc: "sfSound_setBuffer", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the audio buffer attached to a sound +proc getBuffer*(sound: PSound): PSoundBuffer{. + cdecl, importc: "sfSound_getBuffer", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set whether or not a sound should loop after reaching the end +#/ +#/ If set, the sound will restart from beginning after +#/ reaching the end and so on, until it is stopped or +#/ sfSound_setLoop(sound, sfFalse) is called. +#/ The default looping state for sounds is false. +proc setLoop*(sound: PSound; loop: bool){. + cdecl, importc: "sfSound_setLoop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Tell whether or not a soud is in loop mode +proc getLoop*(sound: PSound): bool {. + cdecl, importc: "sfSound_getLoop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current status of a sound (stopped, paused, playing) +proc getStatus*(sound: PSound): TSoundStatus{. + cdecl, importc: "sfSound_getStatus", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the pitch of a sound +#/ +#/ The pitch represents the perceived fundamental frequency +#/ of a sound; thus you can make a sound more acute or grave +#/ by changing its pitch. A side effect of changing the pitch +#/ is to modify the playing speed of the sound as well. +#/ The default value for the pitch is 1. +proc setPitch*(sound: PSound; pitch: cfloat){. + cdecl, importc: "sfSound_setPitch", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the volume of a sound +#/ +#/ The volume is a value between 0 (mute) and 100 (full volume). +#/ The default value for the volume is 100. +proc setVolume*(sound: PSound; volume: cfloat){. + cdecl, importc: "sfSound_setVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the 3D position of a sound in the audio scene +#/ +#/ Only sounds with one channel (mono sounds) can be +#/ spatialized. +#/ The default position of a sound is (0, 0, 0). +proc setPosition*(sound: PSound; position: TVector3f){. + cdecl, importc: "sfSound_setPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Make the sound's position relative to the listener or absolute +#/ +#/ Making a sound relative to the listener will ensure that it will always +#/ be played the same way regardless the position of the listener. +#/ This can be useful for non-spatialized sounds, sounds that are +#/ produced by the listener, or sounds attached to it. +#/ The default value is false (position is absolute). +proc setRelativeToListener*(sound: PSound; relative: bool){. + cdecl, importc: "sfSound_setRelativeToListener", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the minimum distance of a sound +#/ +#/ The "minimum distance" of a sound is the maximum +#/ distance at which it is heard at its maximum volume. Further +#/ than the minimum distance, it will start to fade out according +#/ to its attenuation factor. A value of 0 ("inside the head +#/ of the listener") is an invalid value and is forbidden. +#/ The default value of the minimum distance is 1. +proc setMinDistance*(sound: PSound; distance: cfloat){. + cdecl, importc: "sfSound_setMinDistance", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the attenuation factor of a sound +#/ +#/ The attenuation is a multiplicative factor which makes +#/ the sound more or less loud according to its distance +#/ from the listener. An attenuation of 0 will produce a +#/ non-attenuated sound, i.e. its volume will always be the same +#/ whether it is heard from near or from far. On the other hand, +#/ an attenuation value such as 100 will make the sound fade out +#/ very quickly as it gets further from the listener. +#/ The default value of the attenuation is 1. +proc setAttenuation*(sound: PSound; attenuation: cfloat){. + cdecl, importc: "sfSound_setAttenuation", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Change the current playing position of a sound +#/ +#/ The playing position can be changed when the sound is +#/ either paused or playing. +proc setPlayingOffset*(sound: PSound; timeOffset: sfml.TTime){. + cdecl, importc: "sfSound_setPlayingOffset", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the pitch of a sound +proc getPitch*(sound: PSound): cfloat{. + cdecl, importc: "sfSound_getPitch", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the volume of a sound +proc getVolume*(sound: PSound): cfloat{. + cdecl, importc: "sfSound_getVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the 3D position of a sound in the audio scene +proc getPosition*(sound: PSound): TVector3f{. + cdecl, importc: "sfSound_getPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Tell whether a sound's position is relative to the +#/ listener or is absolute +proc isRelativeToListener*(sound: PSound): bool{. + cdecl, importc: "sfSound_isRelativeToListener", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the minimum distance of a sound +proc getMinDistance*(sound: PSound): cfloat{. + cdecl, importc: "sfSound_getMinDistance", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the attenuation factor of a sound +proc getAttenuation*(sound: PSound): cfloat{. + cdecl, importc: "sfSound_getAttenuation", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current playing position of a sound +proc getPlayingOffset*(sound: PSound): TTime{. + cdecl, importc: "sfSound_getPlayingOffset", dynlib: Lib.} + +#////////////////////////////////////////////////////////// +# Headers +#////////////////////////////////////////////////////////// +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer and load it from a file +#/ +#/ Here is a complete list of all the supported audio formats: +#/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, +#/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. +#/ +#/ \param filename Path of the sound file to load +#/ +#/ \return A new sfSoundBuffer object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc newSoundBuffer*(filename: cstring): PSoundBuffer{. + cdecl, importc: "sfSoundBuffer_createFromFile", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer and load it from a file in memory +#/ +#/ Here is a complete list of all the supported audio formats: +#/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, +#/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. +#/ +#/ \param data Pointer to the file data in memory +#/ \param sizeInBytes Size of the data to load, in bytes +#/ +#/ \return A new sfSoundBuffer object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc newSoundBuffer*(data: pointer; sizeInBytes: cint): PSoundBuffer{. + cdecl, importc: "sfSoundBuffer_createFromMemory", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer and load it from a custom stream +#/ +#/ Here is a complete list of all the supported audio formats: +#/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, +#/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. +#/ +#/ \param stream Source stream to read from +#/ +#/ \return A new sfSoundBuffer object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc newSoundBuffer*(stream: PInputStream): PSoundBuffer{. + cdecl, importc: "sfSoundBuffer_createFromStream", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer and load it from an array of samples in memory +#/ +#/ The assumed format of the audio samples is 16 bits signed integer +#/ (sfint16). +#/ +#/ \param samples Pointer to the array of samples in memory +#/ \param sampleCount Number of samples in the array +#/ \param channelCount Number of channels (1 = mono, 2 = stereo, ...) +#/ \param sampleRate Sample rate (number of samples to play per second) +#/ +#/ \return A new sfSoundBuffer object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc createFromSamples*(samples: ptr int16; sampleCount: cuint; + channelCount: cuint; sampleRate: cuint): PSoundBuffer{. + cdecl, importc: "sfSoundBuffer_createFromSamples", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer by copying an existing one +#/ +#/ \param soundBuffer Sound buffer to copy +#/ +#/ \return A new sfSoundBuffer object which is a copy of \a soundBuffer +#/ +#////////////////////////////////////////////////////////// +proc copy*(soundBuffer: PSoundBuffer): PSoundBuffer{. + cdecl, importc: "sfSoundBuffer_copy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Destroy a sound buffer +#/ +#/ \param soundBuffer Sound buffer to destroy +#/ +#////////////////////////////////////////////////////////// +proc destroy*(soundBuffer: PSoundBuffer){. + cdecl, importc: "sfSoundBuffer_destroy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Save a sound buffer to an audio file +#/ +#/ Here is a complete list of all the supported audio formats: +#/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, +#/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. +#/ +#/ \param soundBuffer Sound buffer object +#/ \param filename Path of the sound file to write +#/ +#/ \return sfTrue if saving succeeded, sfFalse if it failed +#/ +#////////////////////////////////////////////////////////// +proc saveToFile*(soundBuffer: PSoundBuffer; filename: cstring): bool {. + cdecl, importc: "sfSoundBuffer_saveToFile", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the array of audio samples stored in a sound buffer +#/ +#/ The format of the returned samples is 16 bits signed integer +#/ (sfint16). The total number of samples in this array +#/ is given by the sfSoundBuffer_getSampleCount function. +#/ +#/ \param soundBuffer Sound buffer object +#/ +#/ \return Read-only pointer to the array of sound samples +#/ +#////////////////////////////////////////////////////////// +proc sfSoundBuffer_getSamples*(soundBuffer: PSoundBuffer): ptr int16{. + cdecl, importc: "sfSoundBuffer_getSamples", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the number of samples stored in a sound buffer +#/ +#/ The array of samples can be accessed with the +#/ sfSoundBuffer_getSamples function. +proc getSampleCount*(soundBuffer: PSoundBuffer): cint{. + cdecl, importc: "sfSoundBuffer_getSampleCount", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the sample rate of a sound buffer +#/ +#/ The sample rate is the number of samples played per second. +#/ The higher, the better the quality (for example, 44100 +#/ samples/s is CD quality). +proc getSampleRate*(soundBuffer: PSoundBuffer): cuint{. + cdecl, importc: "sfSoundBuffer_getSampleRate", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the number of channels used by a sound buffer +#/ +#/ If the sound is mono then the number of channels will +#/ be 1, 2 for stereo, etc. +proc getChannelCount*(soundBuffer: PSoundBuffer): cuint{. + cdecl, importc: "sfSoundBuffer_getChannelCount", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the total duration of a sound buffer +#/ +#/ \param soundBuffer Sound buffer object +#/ +#/ \return Sound duration +#/ +#////////////////////////////////////////////////////////// +proc getDuration*(soundBuffer: PSoundBuffer): TTime{. + cdecl, importc: "sfSoundBuffer_getDuration", dynlib: Lib.} + +#////////////////////////////////////////////////////////// +#/ \brief Change the global volume of all the sounds and musics +#/ +#/ The volume is a number between 0 and 100; it is combined with +#/ the individual volume of each sound / music. +#/ The default value for the volume is 100 (maximum). +#/ +#/ \param volume New global volume, in the range [0, 100] +#/ +#////////////////////////////////////////////////////////// +proc listenerSetGlobalVolume*(volume: cfloat){. + cdecl, importc: "sfListener_setGlobalVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current value of the global volume +#/ +#/ \return Current global volume, in the range [0, 100] +#/ +#////////////////////////////////////////////////////////// +proc listenerGetGlobalVolume*(): cfloat{. + cdecl, importc: "sfListener_getGlobalVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the position of the listener in the scene +#/ +#/ The default listener's position is (0, 0, 0). +#/ +#/ \param position New position of the listener +#/ +#////////////////////////////////////////////////////////// +proc listenerSetPosition*(position: TVector3f){. + cdecl, importc: "sfListener_setPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current position of the listener in the scene +#/ +#/ \return The listener's position +#/ +#////////////////////////////////////////////////////////// +proc listenerGetPosition*(): TVector3f{. + cdecl, importc: "sfListener_getPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the orientation of the listener in the scene +#/ +#/ The orientation defines the 3D axes of the listener +#/ (left, up, front) in the scene. The orientation vector +#/ doesn't have to be normalized. +#/ The default listener's orientation is (0, 0, -1). +#/ +#/ \param position New direction of the listener +#/ +#////////////////////////////////////////////////////////// +proc listenerSetDirection*(orientation: TVector3f){. + cdecl, importc: "sfListener_setDirection", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current orientation of the listener in the scene +#/ +#/ \return The listener's direction +#/ +#////////////////////////////////////////////////////////// +proc listenerGetDirection*(): TVector3f{. + cdecl, importc: "sfListener_getDirection", dynlib: Lib.} + +type + TSoundRecorderStartCallback* = proc (a2: pointer): bool {.cdecl.} + #/< Type of the callback used when starting a capture + TSoundRecorderProcessCallback* = proc(a2: ptr int16; a3: cuint; + a4: pointer): bool {.cdecl.} + #/< Type of the callback used to process audio data + TSoundRecorderStopCallback* = proc (a2: pointer){.cdecl.} + #/< Type of the callback used when stopping a capture +#////////////////////////////////////////////////////////// +#/ \brief Construct a new sound recorder from callback functions +#/ +#/ \param onStart Callback function which will be called when a new capture starts (can be NULL) +#/ \param onProcess Callback function which will be called each time there's audio data to process +#/ \param onStop Callback function which will be called when the current capture stops (can be NULL) +#/ \param userData Data to pass to the callback function (can be NULL) +#/ +#/ \return A new sfSoundRecorder object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc newSoundRecorder*(onStart: TSoundRecorderStartCallback; + onProcess: TSoundRecorderProcessCallback; + onStop: TSoundRecorderStopCallback; + userData: pointer = nil): PSoundRecorder{. + cdecl, importc: "sfSoundRecorder_create", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Destroy a sound recorder +#/ +#/ \param soundRecorder Sound recorder to destroy +#/ +#////////////////////////////////////////////////////////// +proc destroy*(soundRecorder: PSoundRecorder){. + cdecl, importc: "sfSoundRecorder_destroy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Start the capture of a sound recorder +#/ +#/ The \a sampleRate parameter defines the number of audio samples +#/ captured per second. The higher, the better the quality +#/ (for example, 44100 samples/sec is CD quality). +#/ This function uses its own thread so that it doesn't block +#/ the rest of the program while the capture runs. +#/ Please note that only one capture can happen at the same time. +#/ +#/ \param soundRecorder Sound recorder object +#/ \param sampleRate Desired capture rate, in number of samples per second +#/ +#////////////////////////////////////////////////////////// +proc start*(soundRecorder: PSoundRecorder; sampleRate: cuint){. + cdecl, importc: "sfSoundRecorder_start", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Stop the capture of a sound recorder +#/ +#/ \param soundRecorder Sound recorder object +#/ +#////////////////////////////////////////////////////////// +proc stop*(soundRecorder: PSoundRecorder){. + cdecl, importc: "sfSoundRecorder_stop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the sample rate of a sound recorder +#/ +#/ The sample rate defines the number of audio samples +#/ captured per second. The higher, the better the quality +#/ (for example, 44100 samples/sec is CD quality). +#/ +#/ \param soundRecorder Sound recorder object +#/ +#/ \return Sample rate, in samples per second +#/ +#////////////////////////////////////////////////////////// +proc getSampleRate*(soundRecorder: PSoundRecorder): cuint{. + cdecl, importc: "sfSoundRecorder_getSampleRate", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Check if the system supports audio capture +#/ +#/ This function should always be called before using +#/ the audio capture features. If it returns false, then +#/ any attempt to use sfSoundRecorder will fail. +#/ +#/ \return sfTrue if audio capture is supported, sfFalse otherwise +#/ +#////////////////////////////////////////////////////////// +proc soundRecorderIsAvailable*(): bool {. + cdecl, importc: "sfSoundRecorder_isAvailable", dynlib: Lib.} + +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer recorder +#/ +#/ \return A new sfSoundBufferRecorder object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc newSoundBufferRecorder*(): PSoundBufferRecorder{. + cdecl, importc: "sfSoundBufferRecorder_create", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Destroy a sound buffer recorder +#/ +#/ \param soundBufferRecorder Sound buffer recorder to destroy +#/ +#////////////////////////////////////////////////////////// +proc destroy*(soundBufferRecorder: PSoundBufferRecorder){. + cdecl, importc: "sfSoundBufferRecorder_destroy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Start the capture of a sound recorder recorder +#/ +#/ The \a sampleRate parameter defines the number of audio samples +#/ captured per second. The higher, the better the quality +#/ (for example, 44100 samples/sec is CD quality). +#/ This function uses its own thread so that it doesn't block +#/ the rest of the program while the capture runs. +#/ Please note that only one capture can happen at the same time. +#/ +#/ \param soundBufferRecorder Sound buffer recorder object +#/ \param sampleRate Desired capture rate, in number of samples per second +#/ +#////////////////////////////////////////////////////////// +proc start*(soundBufferRecorder: PSoundBufferRecorder; sampleRate: cuint){. + cdecl, importc: "sfSoundBufferRecorder_start", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Stop the capture of a sound recorder +#/ +#/ \param soundBufferRecorder Sound buffer recorder object +#/ +#////////////////////////////////////////////////////////// +proc stop*(soundBufferRecorder: PSoundBufferRecorder){. + cdecl, importc: "sfSoundBufferRecorder_stop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the sample rate of a sound buffer recorder +#/ +#/ The sample rate defines the number of audio samples +#/ captured per second. The higher, the better the quality +#/ (for example, 44100 samples/sec is CD quality). +#/ +#/ \param soundBufferRecorder Sound buffer recorder object +#/ +#/ \return Sample rate, in samples per second +#/ +#////////////////////////////////////////////////////////// +proc getSampleRate*(soundBufferRecorder: PSoundBufferRecorder): cuint{. + cdecl, importc: "sfSoundBufferRecorder_getSampleRate", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the sound buffer containing the captured audio data +#/ +#/ The sound buffer is valid only after the capture has ended. +#/ This function provides a read-only access to the internal +#/ sound buffer, but it can be copied if you need to +#/ make any modification to it. +#/ +#/ \param soundBufferRecorder Sound buffer recorder object +#/ +#/ \return Read-only access to the sound buffer +#/ +#////////////////////////////////////////////////////////// +proc getBuffer*(soundBufferRecorder: PSoundBufferRecorder): PSoundBuffer{. + cdecl, importc: "sfSoundBufferRecorder_getBuffer", dynlib: Lib.} + + +#////////////////////////////////////////////////////////// +#/ \brief defines the data to fill by the OnGetData callback +#/ +#////////////////////////////////////////////////////////// +type + PSoundStreamChunk* = ptr TSoundStreamChunk + TSoundStreamChunk*{.pure, final.} = object + samples*: ptr int16 #/< Pointer to the audio samples + sampleCount*: cuint #/< Number of samples pointed by Samples + + TSoundStreamGetDataCallback* = proc (a2: PSoundStreamChunk; + a3: pointer): bool{.cdecl.} + #/< Type of the callback used to get a sound stream data + TSoundStreamSeekCallback* = proc (a2: TTime; a3: pointer){.cdecl.} + #/< Type of the callback used to seek in a sound stream +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound stream +#/ +#/ \param onGetData Function called when the stream needs more data (can't be NULL) +#/ \param onSeek Function called when the stream seeks (can't be NULL) +#/ \param channelCount Number of channels to use (1 = mono, 2 = stereo) +#/ \param sampleRate Sample rate of the sound (44100 = CD quality) +#/ \param userData Data to pass to the callback functions +#/ +#/ \return A new sfSoundStream object +#/ +#////////////////////////////////////////////////////////// +proc create*(onGetData: TSoundStreamGetDataCallback; onSeek: TSoundStreamSeekCallback; + channelCount: cuint; sampleRate: cuint; userData: pointer): PSoundStream{. + cdecl, importc: "sfSoundStream_create", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Destroy a sound stream +#/ +#/ \param soundStream Sound stream to destroy +#/ +#////////////////////////////////////////////////////////// +proc destroy*(soundStream: PSoundStream){. + cdecl, importc: "sfSoundStream_destroy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Start or resume playing a sound stream +#/ +#/ This function starts the stream if it was stopped, resumes +#/ it if it was paused, and restarts it from beginning if it +#/ was it already playing. +#/ This function uses its own thread so that it doesn't block +#/ the rest of the program while the music is played. +#/ +#/ \param soundStream Sound stream object +#/ +#////////////////////////////////////////////////////////// +proc play*(soundStream: PSoundStream){. + cdecl, importc: "sfSoundStream_play", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Pause a sound stream +#/ +#/ This function pauses the stream if it was playing, +#/ otherwise (stream already paused or stopped) it has no effect. +#/ +#/ \param soundStream Sound stream object +#/ +#////////////////////////////////////////////////////////// +proc pause*(soundStream: PSoundStream){. + cdecl, importc: "sfSoundStream_pause", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Stop playing a sound stream +#/ +#/ This function stops the stream if it was playing or paused, +#/ and does nothing if it was already stopped. +#/ It also resets the playing position (unlike sfSoundStream_pause). +#/ +#/ \param soundStream Sound stream object +#/ +#////////////////////////////////////////////////////////// +proc stop*(soundStream: PSoundStream){. + cdecl, importc: "sfSoundStream_stop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current status of a sound stream (stopped, paused, playing) +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Current status +#/ +#////////////////////////////////////////////////////////// +proc getStatus*(soundStream: PSoundStream): TSoundStatus{. + cdecl, importc: "sfSoundStream_getStatus", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Return the number of channels of a sound stream +#/ +#/ 1 channel means a mono sound, 2 means stereo, etc. +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Number of channels +#/ +#////////////////////////////////////////////////////////// +proc getChannelCount*(soundStream: PSoundStream): cuint{. + cdecl, importc: "sfSoundStream_getChannelCount", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the sample rate of a sound stream +#/ +#/ The sample rate is the number of audio samples played per +#/ second. The higher, the better the quality. +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Sample rate, in number of samples per second +#/ +#////////////////////////////////////////////////////////// +proc getSampleRate*(soundStream: PSoundStream): cuint{. + cdecl, importc: "sfSoundStream_getSampleRate", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the pitch of a sound stream +#/ +#/ The pitch represents the perceived fundamental frequency +#/ of a sound; thus you can make a stream more acute or grave +#/ by changing its pitch. A side effect of changing the pitch +#/ is to modify the playing speed of the stream as well. +#/ The default value for the pitch is 1. +#/ +#/ \param soundStream Sound stream object +#/ \param pitch New pitch to apply to the stream +#/ +#////////////////////////////////////////////////////////// +proc setPitch*(soundStream: PSoundStream; pitch: cfloat){. + cdecl, importc: "sfSoundStream_setPitch", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the volume of a sound stream +#/ +#/ The volume is a value between 0 (mute) and 100 (full volume). +#/ The default value for the volume is 100. +#/ +#/ \param soundStream Sound stream object +#/ \param volume Volume of the stream +#/ +#////////////////////////////////////////////////////////// +proc setVolume*(soundStream: PSoundStream; volume: cfloat){. + cdecl, importc: "sfSoundStream_setVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the 3D position of a sound stream in the audio scene +#/ +#/ Only streams with one channel (mono streams) can be +#/ spatialized. +#/ The default position of a stream is (0, 0, 0). +#/ +#/ \param soundStream Sound stream object +#/ \param position Position of the stream in the scene +#/ +#////////////////////////////////////////////////////////// +proc setPosition*(soundStream: PSoundStream; position: TVector3f){. + cdecl, importc: "sfSoundStream_setPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Make a sound stream's position relative to the listener or absolute +#/ +#/ Making a stream relative to the listener will ensure that it will always +#/ be played the same way regardless the position of the listener. +#/ This can be useful for non-spatialized streams, streams that are +#/ produced by the listener, or streams attached to it. +#/ The default value is false (position is absolute). +#/ +#/ \param soundStream Sound stream object +#/ \param relative sfTrue to set the position relative, sfFalse to set it absolute +#/ +#////////////////////////////////////////////////////////// +proc setRelativeToListener*(soundStream: PSoundStream; relative: bool){. + cdecl, importc: "sfSoundStream_setRelativeToListener", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the minimum distance of a sound stream +#/ +#/ The "minimum distance" of a stream is the maximum +#/ distance at which it is heard at its maximum volume. Further +#/ than the minimum distance, it will start to fade out according +#/ to its attenuation factor. A value of 0 ("inside the head +#/ of the listener") is an invalid value and is forbidden. +#/ The default value of the minimum distance is 1. +#/ +#/ \param soundStream Sound stream object +#/ \param distance New minimum distance of the stream +#/ +#////////////////////////////////////////////////////////// +proc setMinDistance*(soundStream: PSoundStream; distance: cfloat){. + cdecl, importc: "sfSoundStream_setMinDistance", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the attenuation factor of a sound stream +#/ +#/ The attenuation is a multiplicative factor which makes +#/ the stream more or less loud according to its distance +#/ from the listener. An attenuation of 0 will produce a +#/ non-attenuated stream, i.e. its volume will always be the same +#/ whether it is heard from near or from far. On the other hand, +#/ an attenuation value such as 100 will make the stream fade out +#/ very quickly as it gets further from the listener. +#/ The default value of the attenuation is 1. +#/ +#/ \param soundStream Sound stream object +#/ \param attenuation New attenuation factor of the stream +#/ +#////////////////////////////////////////////////////////// +proc setAttenuation*(soundStream: PSoundStream; attenuation: cfloat){. + cdecl, importc: "sfSoundStream_setAttenuation", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Change the current playing position of a sound stream +#/ +#/ The playing position can be changed when the stream is +#/ either paused or playing. +#/ +#/ \param soundStream Sound stream object +#/ \param timeOffset New playing position +#/ +#////////////////////////////////////////////////////////// +proc setPlayingOffset*(soundStream: PSoundStream; timeOffset: TTime){. + cdecl, importc: "sfSoundStream_setPlayingOffset", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set whether or not a sound stream should loop after reaching the end +#/ +#/ If set, the stream will restart from beginning after +#/ reaching the end and so on, until it is stopped or +#/ sfSoundStream_setLoop(stream, sfFalse) is called. +#/ The default looping state for sound streams is false. +#/ +#/ \param soundStream Sound stream object +#/ \param loop sfTrue to play in loop, sfFalse to play once +#/ +#////////////////////////////////////////////////////////// +proc setLoop*(soundStream: PSoundStream; loop: bool){. + cdecl, importc: "sfSoundStream_setLoop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the pitch of a sound stream +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Pitch of the stream +#/ +#////////////////////////////////////////////////////////// +proc getPitch*(soundStream: PSoundStream): cfloat{. + cdecl, importc: "sfSoundStream_getPitch", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the volume of a sound stream +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Volume of the stream, in the range [0, 100] +#/ +#////////////////////////////////////////////////////////// +proc getVolume*(soundStream: PSoundStream): cfloat{. + cdecl, importc: "sfSoundStream_getVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the 3D position of a sound stream in the audio scene +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Position of the stream in the world +#/ +#////////////////////////////////////////////////////////// +proc getPosition*(soundStream: PSoundStream): TVector3f{. + cdecl, importc: "sfSoundStream_getPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Tell whether a sound stream's position is relative to the +#/ listener or is absolute +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return sfTrue if the position is relative, sfFalse if it's absolute +#/ +#////////////////////////////////////////////////////////// +proc isRelativeToListener*(soundStream: PSoundStream): bool{. + cdecl, importc: "sfSoundStream_isRelativeToListener", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the minimum distance of a sound stream +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Minimum distance of the stream +#/ +#////////////////////////////////////////////////////////// +proc getMinDistance*(soundStream: PSoundStream): cfloat{. + cdecl, importc: "sfSoundStream_getMinDistance", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the attenuation factor of a sound stream +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Attenuation factor of the stream +#/ +#////////////////////////////////////////////////////////// +proc getAttenuation*(soundStream: PSoundStream): cfloat{. + cdecl, importc: "sfSoundStream_getAttenuation", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Tell whether or not a sound stream is in loop mode +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return sfTrue if the music is looping, sfFalse otherwise +#/ +#////////////////////////////////////////////////////////// +proc getLoop*(soundStream: PSoundStream): bool{. + cdecl, importc: "sfSoundStream_getLoop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current playing position of a sound stream +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Current playing position +#/ +#////////////////////////////////////////////////////////// +proc getPlayingOffset*(soundStream: PSoundStream): TTime{. + cdecl, importc: "sfSoundStream_getPlayingOffset", dynlib: Lib.} diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml_colors.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml_colors.nim new file mode 100644 index 000000000..b4eb1b8f0 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml_colors.nim @@ -0,0 +1,15 @@ +import sfml + +let + Black*: TColor = color(0, 0, 0) + White*: TColor = color(255, 255, 255) + Red*: TColor = color(255, 0, 0) + Green*: TColor = color(0, 255, 0) + Blue*: TColor = color(0, 0, 255) + Yellow*: TColor = color(255, 255, 0) + Magenta*: TColor = color(255, 0, 255) + Cyan*: TColor = color(0, 255, 255) + Transparent*: TColor = color(0, 0, 0, 0) + Gray* = color(84, 84, 84) + RoyalBlue* = color(65, 105, 225) +##todo: define more colors lul diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml_vector.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml_vector.nim new file mode 100644 index 000000000..94c5308a9 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml_vector.nim @@ -0,0 +1 @@ +import sfml, math, strutils diff --git a/tests/manyloc/keineschweine/enet_server/enet_client.nim b/tests/manyloc/keineschweine/enet_server/enet_client.nim new file mode 100644 index 000000000..7aa7b9c2f --- /dev/null +++ b/tests/manyloc/keineschweine/enet_server/enet_client.nim @@ -0,0 +1,229 @@ +import enet, strutils, + sfml, sfml_colors, sg_gui, input_helpers, + math_helpers, sg_packets, estreams, tables, + json, sg_assets, client_helpers +if enetInit() != 0: + quit "Could not initialize ENet" +type + TClientSettings = object + resolution*: TVideoMode + offlineFile: string + dirserver: tuple[host: string, port: int16] + website*: string +var + clientSettings: TClientSettings + event: enet.TEvent + bConnected = false + runServer = true + gui = newGuiContainer() + zonelist = newGuiContainer() + kc = newKeyClient(setActive = true) + clock = newClock() + chatBox: PMessageArea + chatInput: PTextEntry + loginBtn, playBtn: PButton + fpsText = newText("", guiFont, 18) + connectionButtons: seq[PButton] + connectButton: PButton + u_alias, u_passwd: PTextEntry + dirServer: PServer + zone: PServer + showZoneList = false + myCreds = newScLogin(0, "", "") ##my session token + +proc handleChat(server: PServer; buf: PBuffer) = + let msg = readScChat(buf) + chatBox.add msg +proc handlePlayerLogin(server: PServer; buf: PBuffer) = + let login = readScLogin(buf) + myCreds = login + echo("I am ", $myCreds) + + +kc.registerHandler MouseLeft, down, proc() = + gui.click(input_helpers.getMousePos()) + +block: + var pos = vec2f(15, 550) + chatBox = gui.newMessageArea(pos) + pos.y += 20 + chatInput = gui.newTextEntry("...", pos, proc() = + sendPubChat dirServer, chatInput.getText() + chatInput.clearText()) + +gui.setActive(chatInput) + +proc dispMessage(args: varargs[string, `$`]) = + var s = "" + for it in items(args): + s.add it + chatbox.add(s) +proc dispMessage(text: string) {.inline.} = + chatbox.add(text) +proc dispError(text: string) {.inline.} = + chatBox.add(newScChat(kind = CError, text = text)) + +proc updateButtons() = + let conn = dirServer.connected + for b in connectionButtons: setEnabled(b, conn) + if conn: + connectButton.setString "Disconnect" + else: + connectButton.setString "Connect" + +proc poll(serv: PServer; timeout: cuint = 30) = + if serv.isNil or serv.host.isNil: return + if serv.connected: + while serv.host.hostService(event, timeout) > 0: + case event.kind + of EvtReceive: + var buf = newBuffer(event.packet) + + serv.handlePackets(buf) + + event.packet.destroy() + of EvtDisconnect: + dispMessage "Disconnected" + serv.connected = false + event.peer.data = nil + updateButtons() + of EvtNone: discard + else: + echo repr(event) + else: + if serv.host.hostService(event, timeout) > 0 and event.kind == EvtConnect: + dispMessage "Connected" + serv.connected = true + if serv.peer != event.peer: + serv.peer = event.peer + event.peer.data = serv + updateButtons() + +proc tryLogin*(b: PButton) = + var login = newCsLogin( + alias = u_alias.getText(), + passwd = u_passwd.getText()) + dirServer.send HLogin, login +proc tryTransition*(b: PButton) = + discard + #zone.writePkt HZoneJoinReq, myCreds +proc tryConnect*(b: PButton) = + if not dirServer.connected: + var error: string + if not dirServer.connect( + clientSettings.dirServer.host, + clientSettings.dirServer.port, + error): + dispError(error) + else: + dirServer.peer.disconnect(1) + +proc playOffline*(b: PButton) = + var errors: seq[string] = @[] + if loadSettingsFromFile(clientSettings.offlineFile, errors): + transition() + else: + dispMessage "Errors reading the file (", clientSettings.offlineFile, "):" + for e in errors: dispError(e) + +proc getClientSettings*(): TClientSettings = + result = clientSettings + + +proc lobbyInit*() = + var s = json.parseFile("./client_settings.json") + clientSettings.offlineFile = "data/" + clientSettings.offlineFile.add s["default-file"].str + let dirserv = s["directory-server"] + clientSettings.dirserver.host = dirserv["host"].str + clientSettings.dirserver.port = dirserv["port"].num.int16 + clientSettings.resolution.width = s["resolution"][0].num.cint + clientSettings.resolution.height= s["resolution"][1].num.cint + clientSettings.resolution.bitsPerPixel = s["resolution"][2].num.cint + clientSettings.website = s["website"].str + zonelist.setPosition(vec2f(200.0, 100.0)) + connectionButtons = @[] + + var pos = vec2f(10, 10) + u_alias = gui.newTextEntry( + if s.hasKey("alias"): s["alias"].str else: "alias", + pos) + pos.y += 20 + u_passwd = gui.newTextEntry("buzz", pos) + pos.y += 20 + connectionButtons.add(gui.newButton( + text = "Login", + position = pos, + onClick = tryLogin, + startEnabled = false)) + pos.y += 20 + fpsText.setPosition pos + pos.y += 20 + connectButton = gui.newButton( + text = "Connect", + position = pos, + onClick = tryConnect) + pos.y += 20 + gui.newButton("Test Files", position = pos, onClick = proc(b: PButton) = + var req = newCsZoneJoinReq(myCreds) + dirServer.send HZoneJoinReq, req) + pos.y += 20 + connectionButtons.add(gui.newButton( + text = "Test Chat", + position = pos, + onClick = (proc(b: PButton) = + var pkt = newCsChat(text = "ohai") + dirServer.send HChat, pkt), + startEnabled = false)) + pos.y += 20 + downloadProgress.setPosition(pos) + downloadProgress.bg.setFillColor(color(34, 139, 34)) + downloadProgress.bg.setSize(vec2f(0, 0)) + gui.add(downloadProgress) + + playBtn = gui.newButton( + text = "Play", + position = vec2f(680.0, 8.0), + onClick = tryTransition, + startEnabled = false) + gui.newButton( + text = "Play Offline", + position = vec2f(680.0, 28.0), + onClick = playOffline) + discard """gui.newButton(text = "Scrollback + 1", position = vec2f(185, 10), onClick = proc(b: PButton) = + messageArea.scrollBack += 1 + update(messageArea)) + gui.newButton(text = "Scrollback - 1", position = vec2f(185+160, 10), onClick = proc(b: PButton) = + messageArea.scrollBack -= 1 + update(messageArea)) + gui.newButton(text = "Flood msg area", position = vec2f(185, 30), onClick = proc(b: PButton) = + for i in 0..< 30: + dispMessage($i))""" + dirServer = newServer() + dirServer.addHandler HChat, handleChat + dirServer.addHandler HLogin, handlePlayerLogin + dirServer.addHandler HFileTransfer, client_helpers.handleFilePartRecv + dirServer.addHandler HChallengeResult, client_helpers.handleFileChallengeResult + dirServer.addHandler HFileChallenge, client_helpers.handleFileChallenge + +proc lobbyReady*() = + kc.setActive() + gui.setActive(u_alias) + +var i = 0 +proc lobbyUpdate*(dt: float) = + dirServer.poll() + #let res = disp.poll() + gui.update(dt) + i = (i + 1) mod 60 + if i == 0: + fpsText.setString("FPS: " & ff(1.0/dt)) + +proc lobbyDraw*(window: PRenderWindow) = + window.clear(Black) + window.draw chatBox + window.draw gui + window.draw fpsText + if showZonelist: window.draw zonelist + window.display() + diff --git a/tests/manyloc/keineschweine/enet_server/enet_server.nim b/tests/manyloc/keineschweine/enet_server/enet_server.nim new file mode 100644 index 000000000..86d0ab360 --- /dev/null +++ b/tests/manyloc/keineschweine/enet_server/enet_server.nim @@ -0,0 +1,294 @@ +import enet, strutils, idgen, tables, math_helpers, + estreams, sg_packets, server_utils, sg_assets, client_helpers +when appType == "gui": + import sfml, sfml_colors, sg_gui, + input_helpers, sfml_stuff +else: + import times +type + TCallback = proc(client: PClient; buffer: PBuffer) +var + server: PHost + dirServer: PServer + standAloneMode = true + event: enet.TEvent + clientID = newIDGen[int32]() + clients = initTable[int32, PClient](64) + handlers = initTable[char, TCallback](32) + +when appType == "gui": + var + gui = newGuiContainer() + chatBox = gui.newMessageArea(vec2f(15, 550)) + window = newRenderWindow(videoMode(800, 600, 32), "Sup yo", sfDefaultSTyle) + mousepos = newText("", guiFont, 16) + fpsText = mousePos.copy() + inputClient = newKeyClient(setActive = true) + chatBox.sizeVisible = 30 + mousePos.setColor(Green) + fpsText.setposition(vec2f(0, 20)) + inputClient.registerHandler MouseLeft, down, proc() = + gui.click(input_helpers.getMousePos()) + inputClient.registerHandler MouseMiddle, down, proc() = + let pos = input_helpers.getMousePos() + mousePos.setString("($1,$2)".format(ff(pos.x), ff(pos.y))) + mousePos.setPosition(pos) + proc dispMessage(args: varargs[string, `$`]) = + var s = "" + for it in items(args): + s.add it + chatbox.add(s) + proc dispError(args: varargs[string, `$`]) = + var s = "" + for it in items(args): s.add(it) + chatBox.add(newScChat(kind = CError, text = s)) +else: + proc dispMessage(args: varargs[string, `$`]) = + var m = "" + for it in items(args): m.add(it) + echo "<msg> ", m + proc dispError(args: varargs[string, `$`]) = + var m = "" + for it in items(args): m.add(it) + echo "**", m + + +var pubChatQueue = newBuffer(1024) +proc queuePub(sender: PClient, msg: CsChat) = + var chat = newScChat(kind = CPub, fromPlayer = sender.alias, text = msg.text) + pubChatQueue.write(HChat) + pubChatQueue.pack(chat) +proc flushPubChat() = + if pubChatQueue.isDirty: + let packet = pubChatQueue.toPacket(FlagReliable) + for id, client in pairs(clients): + discard client.peer.send(0.cuchar, packet) + pubChatQueue.flush() + +handlers[HChat] = proc(client: PClient; buffer: PBuffer) = + var chat = readCsChat(buffer) + + if not client.auth: + client.sendError("You are not logged in.") + return + #if chat.target != "": ##private + # if alias2client.hasKey(chat.target): + # alias2client[chat.target].forwardPrivate(client, chat.text) + #else: + + dispmessage("<", client.alias, "> ", chat.text) + queuePub(client, chat) + +handlers[HLogin] = proc(client: PClient; buffer: PBuffer) = + var info = readCsLogin(buffer) + if client.auth: + client.sendError "You are already logged in." + return + client.alias = info.alias + client.auth = true + var resp = newScLogin(client.id, client.alias, "sessionkeylulz") + client.send HLogin, resp + client.sendMessage "welcome" + dispMessage("Client logged in: ", client) + + +handlers[HFileTransfer] = server_utils.handleFilePartAck +handlers[HFileChallenge] = server_utils.handleFileChallengeResp + +handlers[HZoneJoinReq] = proc(client: PClient; buffer: PBuffer) = + var info = readCsZoneJoinReq(buffer) + dispmessage "Got zone join request" + client.startVerifyingFiles() + + + +when true: + import parseopt, os, json + + + if enetInit() != 0: + quit "Could not initialize ENet" + + var address: enet.TAddress + + block: + var zoneCfgFile = "./server_settings.json" + for kind, key, val in getopt(): + case kind + of cmdShortOption, cmdLongOption: + case key + of "f", "file": + if fileExists(val): + zoneCfgFile = val + else: + echo("File does not exist: ", val) + else: + echo("Unknown option: ", key," ", val) + else: + echo("Unknown option: ", key, " ", val) + var jsonSettings = parseFile(zoneCfgFile) + let + port = uint16(jsonSettings["port"].num) + zoneFile = jsonSettings["settings"].str + dirServerInfo = jsonSettings["dirserver"] + + address.host = EnetHostAny + address.port = port + + var path = getAppDir()/../"data"/zoneFile + if not fileExists(path): + echo("Zone settings file does not exist: ../data/", zoneFile) + echo(path) + quit(1) + + discard """block: + var + TestFile: FileChallengePair + contents = repeat("abcdefghijklmnopqrstuvwxyz", 2) + testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32) + testFile.file = checksumStr(contents) + myAssets.add testFile""" + + setCurrentDir getAppDir().parentDir() + let zonesettings = readFile(path) + var + errors: seq[string] = @[] + if not loadSettings(zoneSettings, errors): + echo("You have errors in your zone settings:") + for e in errors: echo("**", e) + quit(1) + errors.setLen 0 + + var pair: FileChallengePair + pair.challenge.file = zoneFile + pair.challenge.assetType = FZoneCfg + pair.challenge.fullLen = zoneSettings.len.int32 + pair.file = checksumStr(zoneSettings) + myAssets.add pair + + allAssets: + if not load(asset): + echo "Invalid or missing file ", file + else: + var pair: FileChallengePair + pair.challenge.file = file + pair.challenge.assetType = assetType + pair.challenge.fullLen = getFileSize( + expandPath(assetType, file)).int32 + pair.file = asset.contents + myAssets.add pair + + echo "Zone has ", myAssets.len, " associated assets" + + dirServer = newServer() + + dirServer.addHandler HDsMsg, proc(serv: PServer; buffer: PBuffer) = + var m = readDsMsg(buffer) + dispMessage("<DirServer> ", m.msg) + dirServer.addHandler HZoneLogin, proc(serv: PServer; buffer: PBuffer) = + let loggedIn = readDsZoneLogin(buffer).status + if loggedIn: + #dirServerConnected = true + + if dirServerInfo.kind == JArray: + var error: string + if not dirServer.connect(dirServerInfo[0].str, dirServerInfo[1].num.int16, error): + dispError("<DirServer> "&error) + + + server = enet.createHost(address, 32, 2, 0, 0) + if server == nil: + quit "Could not create the server!" + + dispMessage("Listening on port ", address.port) + + var + serverRunning = true + when appType == "gui": + var frameRate = newClock() + var pubChatDelay = newClock() + else: + var frameRate = epochTime() + var pubChatDelay = frameRate + + while serverRunning: + when appType == "gui": + let dt = frameRate.restart.asMilliseconds().float / 1000.0 + + for event in window.filterEvents(): + case event.kind + of sfml.EvtClosed: + window.close() + serverRunning = false + else: + discard + else: + let dt = epochTime() - frameRate ##is this right? probably not + frameRate = epochTime() + + while server.hostService(event, 10) > 0: + case event.kind + of EvtConnect: + var client = newClient() + clients[client.id] = client + + event.peer.data = addr client.id + client.peer = event.peer + + dispMessage("New client connected ", client) + + var + msg = "hello" + resp = createPacket(cstring(msg), msg.len + 1, FlagReliable) + + if event.peer.send(0.cuchar, resp) < 0: + echo "FAILED" + else: + echo "Replied" + of EvtReceive: + let client = clients[cast[ptr int32](event.peer.data)[]] + + var buf = newBuffer(event.packet) + let k = buf.readChar() + if handlers.hasKey(k): + handlers[k](client, buf) + else: + dispError("Unknown packet from ", client) + + destroy(event.packet) + of EvtDisconnect: + var + id = cast[ptr int32](event.peer.data)[] + client = clients[id] + if client.isNil: + disperror("CLIENT IS NIL!") + dispmessage(event.peer.data.isNil) + else: + dispMessage(clients[id], " disconnected") + GCUnref(clients[id]) + clients.del id + + event.peer.data = nil + else: + discard + + when appType == "gui": + fpsText.setString(ff(1.0/dt)) + if pubChatDelay.getElapsedTime.asSeconds > 0.25: + pubChatDelay.restart() + flushPubChat() + else: + pubChatDelay -= dt + if frameRate - pubChatDelay > 0.25: + flushPubChat() + + when appType == "gui": + window.clear(Black) + window.draw(GUI) + window.draw chatbox + window.draw mousePos + window.draw fpstext + window.display() + + server.destroy() + enetDeinit() diff --git a/tests/manyloc/keineschweine/enet_server/nakefile.nim b/tests/manyloc/keineschweine/enet_server/nakefile.nim new file mode 100644 index 000000000..3764c6271 --- /dev/null +++ b/tests/manyloc/keineschweine/enet_server/nakefile.nim @@ -0,0 +1,13 @@ +import nake +nakeimports + +const + ServerDefines = "-d:NoSFML --forceBuild" + +task "server", "build the server": + if shell("nim", ServerDefines, "-r", "compile", "enet_server") != 0: + quit "Failed to build" +task "gui", "build the server GUI mode": + if shell("nim", "--app:gui", ServerDefines, "-r", "compile", "enet_server") != 0: + quit "Failed to build" + diff --git a/tests/manyloc/keineschweine/enet_server/nim.cfg b/tests/manyloc/keineschweine/enet_server/nim.cfg new file mode 100644 index 000000000..72ef47ee0 --- /dev/null +++ b/tests/manyloc/keineschweine/enet_server/nim.cfg @@ -0,0 +1,9 @@ +path = ".." +path = "../dependencies/sfml" +path = "../dependencies/enet" +path = "../dependencies/nake" +path = "../dependencies/genpacket" +path = "../lib" +define = "noChipmunk" +define = "noSFML" + diff --git a/tests/manyloc/keineschweine/enet_server/server_settings.json b/tests/manyloc/keineschweine/enet_server/server_settings.json new file mode 100644 index 000000000..7d2f1d822 --- /dev/null +++ b/tests/manyloc/keineschweine/enet_server/server_settings.json @@ -0,0 +1,8 @@ +{ + "name": "Alpha Zone", + "desc": "Beta Testing", + "host": "localhost", + "port": 8024, + "settings": "alphazone.json", + "dirserver":["localhost",2049,"alphazone","skittles"] +} diff --git a/tests/manyloc/keineschweine/enet_server/server_utils.nim b/tests/manyloc/keineschweine/enet_server/server_utils.nim new file mode 100644 index 000000000..3940dcf01 --- /dev/null +++ b/tests/manyloc/keineschweine/enet_server/server_utils.nim @@ -0,0 +1,122 @@ +import ../../../../dist/checksums/src/checksums/md5 + +import enet, sg_packets, estreams, zlib_helpers, client_helpers, strutils, + idgen, sg_assets, tables, os +type + PClient* = ref object + id*: int32 + auth*: bool + alias*: string + peer*: PPeer + + FileChallengePair* = tuple[challenge: ScFileChallenge; file: TChecksumFile] + PFileChallengeSequence* = ref TFileChallengeSequence + TFileChallengeSequence = object + index: int #which file is active + transfer: ScFileTransfer + file: ptr FileChallengePair +var + clientID = newIdGen[int32]() + myAssets*: seq[FileChallengePair] = @[] + fileChallenges = initTable[int32, PFileChallengeSequence](32) +const FileChunkSize = 256 + +proc free(client: PClient) = + if client.id != 0: + fileChallenges.del client.id + clientID.del client.id +proc newClient*(): PClient = + new(result, free) + result.id = clientID.next() + result.alias = "billy" + +proc `$`*(client: PClient): string = + result = "$1:$2".format(client.id, client.alias) + +proc send*[T](client: PClient; pktType: char; pkt: var T) = + var buf = newBuffer(128) + buf.write pktType + buf.pack pkt + discard client.peer.send(0.cuchar, buf, flagReliable) + +proc sendMessage*(client: PClient; txt: string) = + var m = newScChat(CSystem, text = txt) + client.send HChat, m +proc sendError*(client: PClient; error: string) = + var m = newScChat(CError, text = error) + client.send HChat, m + + + + +proc next*(challenge: PFileChallengeSequence, client: PClient) +proc sendChunk*(challenge: PFileChallengeSequence, client: PClient) + +proc startVerifyingFiles*(client: PClient) = + var fcs: PFileChallengeSequence + new(fcs) + fcs.index = -1 + fileChallenges[client.id] = fcs + next(fcs, client) + +proc next*(challenge: PFileChallengeSequence, client: PClient) = + inc(challenge.index) + if challenge.index >= myAssets.len: + client.sendMessage "You are cleared to enter" + fileChallenges.del client.id + return + else: + echo myAssets.len, "assets" + challenge.file = addr myAssets[challenge.index] + client.send HFileChallenge, challenge.file.challenge # :rolleyes: + echo "sent challenge" + +proc sendChunk*(challenge: PFileChallengeSequence, client: PClient) = + let size = min(FileChunkSize, challenge.transfer.fileSize - challenge.transfer.pos) + challenge.transfer.data.setLen size + copyMem( + addr challenge.transfer.data[0], + addr challenge.file.file.compressed[challenge.transfer.pos], + size) + client.send HFileTransfer, challenge.transfer + echo "chunk sent" + +proc startSend*(challenge: PFileChallengeSequence, client: PClient) = + challenge.transfer.fileSize = challenge.file.file.compressed.len().int32 + challenge.transfer.pos = 0 + challenge.transfer.data = "" + challenge.transfer.data.setLen FileChunkSize + challenge.sendChunk(client) + echo "starting xfer" + +## HFileTransfer +proc handleFilePartAck*(client: PClient; buffer: PBuffer) = + echo "got filepartack" + var + ftrans = readCsFilepartAck(buffer) + fcSeq = fileChallenges[client.id] + fcSeq.transfer.pos = ftrans.lastPos + fcSeq.sendChunk client + +## HFileCHallenge +proc handleFileChallengeResp*(client: PClient; buffer: PBuffer) = + echo "got file challenge resp" + var + fcResp = readCsFileChallenge(buffer) + fcSeq = fileChallenges[client.id] + let index = $(fcSeq.index + 1) / $(myAssets.len) + if fcResp.needFile: + client.sendMessage "Sending file... "&index + fcSeq.startSend(client) + else: + var resp = newScChallengeResult(false) + if fcResp.checksum == fcSeq.file.file.sum: ##client is good + client.sendMessage "Checksum is good. "&index + resp.status = true + client.send HChallengeResult, resp + fcSeq.next(client) + else: + client.sendMessage "Checksum is bad, sending file... "&index + client.send HChallengeResult, resp + fcSeq.startSend(client) + diff --git a/tests/manyloc/keineschweine/keineschweine.nim b/tests/manyloc/keineschweine/keineschweine.nim new file mode 100644 index 000000000..123a4aebb --- /dev/null +++ b/tests/manyloc/keineschweine/keineschweine.nim @@ -0,0 +1,726 @@ +import + os, math, strutils, gl, tables, + sfml, sfml_audio, sfml_colors, chipmunk, math_helpers, + input_helpers, animations, game_objects, sfml_stuff, map_filter, + sg_gui, sg_assets, sound_buffer, enet_client +when defined(profiler): + import nimprof + +type + PPlayer* = ref TPlayer + TPlayer* = object + id: uint16 + vehicle: PVehicle + spectator: bool + alias: string + nameTag: PText + items: seq[PItem] + PVehicle* = ref TVehicle + TVehicle* = object + body*: chipmunk.PBody + shape*: chipmunk.PShape + record*: PVehicleRecord + sprite*: PSprite + spriteRect*: TIntRect + occupant: PPlayer + when false: + position*: TVector2f + velocity*: TVector2f + angle*: float + PItem* = ref object + record: PItemRecord + cooldown: float + PLiveBullet* = ref TLiveBullet ##represents a live bullet in the arena + TLiveBullet* = object + lifetime*: float + dead: bool + anim*: PAnimation + record*: PBulletRecord + fromPlayer*: PPlayer + trailDelay*: float + body: chipmunk.PBody + shape: chipmunk.PShape +include vehicles +const + LGrabbable* = (1 shl 0).TLayers + LBorders* = (1 shl 1).TLayers + LPlayer* = ((1 shl 2) and LBorders.int).TLayers + LEnemy* = ((1 shl 4) and LBorders.int).TLayers + LEnemyFire* = (LPlayer).TLayers + LPlayerFire* = (LEnemy).TLayers + CTBullet = 1.TCollisionType + CTVehicle= 2.TCollisionType + ##temporary constants + W_LIMIT = 2.3 + V_LIMIT = 35 + MaxLocalBots = 3 +var + localPlayer: PPlayer + localBots: seq[PPlayer] = @[] + activeVehicle: PVehicle + myVehicles: seq[PVehicle] = @[] + objects: seq[PGameObject] = @[] + liveBullets: seq[PLiveBullet] = @[] + explosions: seq[PAnimation] = @[] + gameRunning = true + frameRate = newClock() + showStars = off + levelArea: TIntRect + videoMode: TVideoMode + window: PRenderWindow + worldView: PView + guiView: PView + space = newSpace() + ingameClient = newKeyClient("ingame") + specInputClient = newKeyClient("spec") + specGui = newGuiContainer() + stars: seq[PSpriteSheet] = @[] + playBtn: PButton + shipSelect = newGuiContainer() + delObjects: seq[int] = @[] + showShipSelect = false + myPosition: array[0..1, TVector3f] ##for audio positioning +let + nameTagOffset = vec2f(0.0, 1.0) +when defined(escapeMenuTest): + import browsers + var + escMenu = newGuiContainer(vec2f(100, 100)) + escMenuOpen = false + pos = vec2f(0, 0) + escMenu.newButton("Some Website", pos, proc(b: PButton) = + openDefaultBrowser(getClientSettings().website)) + pos.y += 20.0 + escMenu.newButton("Back to Lobby", pos, proc(b: PButton) = + echo "herro") + proc toggleEscape() = + escMenuOpen = not escMenuOpen + ingameClient.registerHandler(KeyEscape, down, toggleEscape) + specInputClient.registerHandler(KeyEscape, down, toggleEscape) +when defined(foo): + var mouseSprite: sfml.PCircleShape +when defined(recordMode): + var + snapshots: seq[PImage] = @[] + isRecording = false + proc startRecording() = + if snapshots.len > 100: return + echo "Started recording" + isRecording = true + proc stopRecording() = + if isRecording: + echo "Stopped recording. ", snapshots.len, " images." + isRecording = false + proc zeroPad*(s: string; minLen: int): string = + if s.len < minLen: + result = repeat(0, minLen - s.len) + result.add s + else: + result = s + var + recordButton = newButton( + nil, text = "Record", position = vec2f(680, 50), + onClick = proc(b: PButton) = startRecording()) + +proc newNameTag*(text: string): PText = + result = newText() + result.setFont(guiFont) + result.setCharacterSize(14) + result.setColor(Red) + result.setString(text) + +var debugText = newNameTag("Loading...") +debugText.setPosition(vec2f(0.0, 600.0 - 50.0)) + +when defined(showFPS): + var fpsText = newNameTag("0") + #fpsText.setCharacterSize(16) + fpsText.setPosition(vec2f(300.0, (800 - 50).float)) + +proc mouseToSpace*(): TVector = + result = window.convertCoords(vec2i(getMousePos()), worldView).sfml2cp() + +proc explode*(b: PLiveBullet) +## TCollisionBeginFunc +proc collisionBulletPlayer(arb: PArbiter; space: PSpace; + data: pointer): bool{.cdecl.} = + var + bullet = cast[PLiveBullet](arb.a.data) + target = cast[PVehicle](arb.b.data) + if target.occupant.isNil or target.occupant == bullet.fromPlayer: return + bullet.explode() + +proc angularDampingSim(body: PBody, gravity: TVector, damping, dt: CpFloat){.cdecl.} = + body.w -= (body.w * 0.98 * dt) + body.UpdateVelocity(gravity, damping, dt) + +proc initLevel() = + loadAllAssets() + + if not space.isNil: space.destroy() + space = newSpace() + space.addCollisionHandler CTBullet, CTVehicle, collisionBulletPlayer, + nil, nil, nil, nil + + let levelSettings = getLevelSettings() + levelArea.width = levelSettings.size.x + levelArea.height= levelSettings.size.y + let borderSeq = @[ + vector(0, 0), vector(levelArea.width.float, 0.0), + vector(levelArea.width.float, levelArea.height.float), vector(0.0, levelArea.height.float)] + for i in 0..3: + var seg = space.addShape( + newSegmentShape( + space.staticBody, + borderSeq[i], + borderSeq[(i + 1) mod 4], + 8.0)) + seg.setElasticity 0.96 + seg.setLayers(LBorders) + if levelSettings.starfield.len > 0: + showStars = true + for sprite in levelSettings.starfield: + sprite.tex.setRepeated(true) + sprite.sprite.setTextureRect(levelArea) + sprite.sprite.setOrigin(vec2f(0, 0)) + stars.add(sprite) + var pos = vec2f(0.0, 0.0) + for veh in playableVehicles(): + shipSelect.newButton( + veh.name, + position = pos, + onClick = proc(b: PButton) = + echo "-__-") + pos.y += 18.0 + + +proc newItem*(record: PItemRecord): PItem = + new(result) + result.record = record +proc newItem*(name: string): PItem {.inline.} = + return newItem(fetchItm(name)) +proc canUse*(itm: PItem): bool = + if itm.cooldown > 0.0: return + return true +proc update*(itm: PItem; dt: float) = + if itm.cooldown > 0: + itm.cooldown -= dt + +proc free(obj: PLiveBullet) = + obj.shape.free + obj.body.free + obj.record = nil + + +template newExplosion(obj, animation) = + explosions.add(newAnimation(animation, AnimOnce, obj.body.getPos.cp2sfml, obj.body.getAngle)) + +template newExplosion(obj, animation, angle) = + explosions.add(newAnimation(animation, AnimOnce, obj.body.getPos.cp2sfml, angle)) + +proc explode*(b: PLiveBullet) = + if b.dead: return + b.dead = true + space.removeShape b.shape + space.removeBody b.body + if not b.record.explosion.anim.isNil: + newExplosion(b, b.record.explosion.anim) + playSound(b.record.explosion.sound, b.body.getPos()) + +proc bulletUpdate(body: PBody, gravity: TVector, damping, dt: CpFloat){.cdecl.} = + body.UpdateVelocity(gravity, damping, dt) + +template getPhysical() {.dirty.} = + result.body = space.addBody(newBody( + record.physics.mass, + record.physics.moment)) + result.shape = space.addShape( + chipmunk.newCircleShape( + result.body, + record.physics.radius, + VectorZero)) + +proc newBullet*(record: PBulletRecord; fromPlayer: PPlayer): PLiveBullet = + new(result, free) + result.anim = newAnimation(record.anim, AnimLoop) + result.fromPlayer = fromPlayer + result.lifetime = record.lifetime + result.record = record + getPhysical() + if fromPlayer == localPlayer: + result.shape.setLayers(LPlayerFire) + else: + result.shape.setLayers(LEnemyFire) + result.shape.setCollisionType CTBullet + result.shape.setUserData(cast[ptr TLiveBullet](result)) + let + fireAngle = fromPlayer.vehicle.body.getAngle() + fireAngleV = vectorForAngle(fireAngle) + result.body.setAngle fireAngle + result.body.setPos(fromPlayer.vehicle.body.getPos() + (fireAngleV * fromPlayer.vehicle.shape.getCircleRadius())) + #result.body.velocityFunc = bulletUpdate + result.body.setVel((fromPlayer.vehicle.body.getVel() * record.inheritVelocity) + (fireAngleV * record.baseVelocity)) + +proc update*(b: PLiveBullet; dt: float): bool = + if b.dead: return true + b.lifetime -= dt + b.anim.next(dt) + #b.anim.sprite.setPosition(b.body.getPos.floor()) + b.anim.setPos(b.body.getPos) + b.anim.setAngle(b.body.getAngle()) + if b.lifetime <= 0.0: + b.explode() + return true + b.trailDelay -= dt + if b.trailDelay <= 0.0: + b.trailDelay += b.record.trail.timer + if b.record.trail.anim.isNil: return + newExplosion(b, b.record.trail.anim) +proc draw*(window: PRenderWindow; b: PLiveBullet) {.inline.} = + draw(window, b.anim.sprite) + + +proc free*(veh: PVehicle) = + ("Destroying vehicle " & veh.record.name).echo + destroy(veh.sprite) + if veh.shape.isNil: "Free'd vehicle's shape was NIL!".echo + else: space.removeShape(veh.shape) + if veh.body.isNil: "Free'd vehicle's BODY was NIL!".echo + else: space.removeBody(veh.body) + veh.body.free() + veh.shape.free() + veh.sprite = nil + veh.body = nil + veh.shape = nil + + +proc newVehicle*(record: PVehicleRecord): PVehicle = + echo("Creating " & record.name) + new(result, free) + result.record = record + result.sprite = result.record.anim.spriteSheet.sprite.copy() + result.spriteRect = result.sprite.getTextureRect() + getPhysical() + result.body.setAngVelLimit W_LIMIT + result.body.setVelLimit result.record.handling.topSpeed + result.body.velocityFunc = angularDampingSim + result.shape.setCollisionType CTVehicle + result.shape.setUserData(cast[ptr TVehicle](result)) +proc newVehicle*(name: string): PVehicle = + result = newVehicle(fetchVeh(name)) + +proc update*(obj: PVehicle) = + obj.sprite.setPosition(obj.body.getPos.floor) + obj.spriteRect.left = (((-obj.body.getAngVel + W_LIMIT) / (W_LIMIT*2.0) * (obj.record.anim.spriteSheet.cols - 1).float).floor.int * obj.record.anim.spriteSheet.framew).cint + obj.spriteRect.top = ((obj.offsetAngle.wmod(TAU) / TAU) * obj.record.anim.spriteSheet.rows.float).floor.cint * obj.record.anim.spriteSheet.frameh.cint + obj.sprite.setTextureRect(obj.spriteRect) + + +proc newPlayer*(alias: string = "poo"): PPlayer = + new(result) + result.spectator = true + result.alias = alias + result.nameTag = newNameTag(result.alias) + result.items = @[] +proc updateItems*(player: PPlayer, dt: float) = + for i in items(player.items): + update(i, dt) +proc addItem*(player: PPlayer; name: string) = + player.items.add newItem(name) +proc useItem*(player: PPlayer; slot: int) = + if slot > player.items.len - 1: return + let item = player.items[slot] + if item.canUse: + item.cooldown += item.record.cooldown + let b = newBullet(item.record.bullet, player) + liveBullets.add(b) + sound_buffer.playSound(item.record.useSound, b.body.getPos) + +proc update*(obj: PPlayer) = + if not obj.spectator: + obj.vehicle.update() + obj.nameTag.setPosition(obj.vehicle.body.getPos.floor + (nameTagOffset * (obj.vehicle.record.physics.radius + 5).cfloat)) + +proc draw(window: PRenderWindow, player: PPlayer) {.inline.} = + if not player.spectator: + if player.vehicle != nil: + window.draw(player.vehicle.sprite) + window.draw(player.nameTag) + +proc setVehicle(p: PPlayer; v: PVehicle) = + p.vehicle = v #sorry mom, this is just how things worked out ;( + if not v.isNil: + v.occupant = p + +proc createBot() = + if localBots.len < MaxLocalBots: + var bot = newPlayer("Dodo Brown") + bot.setVehicle(newVehicle("Turret0")) + if bot.isNil: + echo "BOT IS NIL" + return + elif bot.vehicle.isNil: + echo "BOT VEH IS NIL" + return + localBots.add(bot) + bot.vehicle.body.setPos(vector(100, 100)) + echo "new bot at ", $bot.vehicle.body.getPos() + +var inputCursor = newVertexArray(sfml.Lines, 2) +inputCursor[0].position = vec2f(10.0, 10.0) +inputCursor[1].position = vec2f(50.0, 90.0) + +proc hasVehicle(p: PPlayer): bool {.inline.} = + result = not p.spectator and not p.vehicle.isNil + +proc setMyVehicle(v: PVehicle) {.inline.} = + activeVehicle = v + localPlayer.setVehicle v + +proc unspec() = + var veh = newVehicle("Turret0") + if not veh.isNil: + setMyVehicle veh + localPlayer.spectator = false + ingameClient.setActive + veh.body.setPos vector(100, 100) + veh.shape.setLayers(LPlayer) + when defined(debugWeps): + localPlayer.addItem("Mass Driver") + localPlayer.addItem("Neutron Bomb") + localPlayer.additem("Dem Lasers") + localPlayer.addItem("Mold Spore Beam") + localPlayer.addItem("Genericorp Mine") + localPlayer.addItem("Gravitic Bomb") +proc spec() = + setMyVehicle nil + localPlayer.spectator = true + specInputClient.setActive + +var + specLimiter = newClock() + timeBetweenSpeccing = 1.0 #seconds +proc toggleSpec() {.inline.} = + if specLimiter.getElapsedTime.asSeconds < timeBetweenSpeccing: + return + specLimiter.restart() + if localPlayer.isNil: + echo("OMG WTF PLAYER IS NILL!!") + elif localPlayer.spectator: unspec() + else: spec() + +proc addObject*(name: string) = + var o = newObject(name) + if not o.isNil: + echo "Adding object ", o + discard space.addBody(o.body) + discard space.addShape(o.shape) + o.shape.setLayers(LGrabbable) + objects.add(o) +proc explode(obj: PGameObject) = + echo obj, " exploded" + let ind = objects.find(obj) + if ind != -1: + delObjects.add ind +proc update(obj: PGameObject; dt: float) = + if not(obj.anim.next(dt)): + obj.explode() + else: + obj.anim.setPos(obj.body.getPos) + obj.anim.setAngle(obj.body.getAngle) + +proc toggleShipSelect() = + showShipSelect = not showShipSelect +proc handleLClick() = + let pos = input_helpers.getMousePos() + when defined(escapeMenuTest): + if escMenuOpen: + escMenu.click(pos) + return + if showShipSelect: + shipSelect.click(pos) + if localPlayer.spectator: + specGui.click(pos) + +ingameClient.registerHandler(KeyF12, down, proc() = toggleSpec()) +ingameClient.registerHandler(KeyF11, down, toggleShipSelect) +ingameClient.registerHandler(MouseLeft, down, handleLClick) +when defined(recordMode): + if not dirExists("data/snapshots"): + createDir("data/snapshots") + ingameClient.registerHandler(keynum9, down, proc() = + if not isRecording: startRecording() + else: stopRecording()) + ingameClient.registerHandler(keynum0, down, proc() = + if snapshots.len > 0 and not isRecording: + echo "Saving images (LOL)" + for i in 0..high(snapshots): + if not(snapshots[i].save("data/snapshots/image"&(zeroPad($i, 3))&".jpg")): + echo "Could not save" + snapshots[i].destroy() + snapshots.setLen 0) +when defined(DebugKeys): + ingameClient.registerHandler MouseRight, down, proc() = + echo($activevehicle.body.getAngle.vectorForAngle()) + ingameClient.registerHandler KeyBackslash, down, proc() = + createBot() + ingameClient.registerHandler(KeyNum1, down, proc() = + if localPlayer.items.len == 0: + localPlayer.addItem("Mass Driver") + echo "Gave you a mass driverz") + ingameClient.registerHandler(KeyL, down, proc() = + echo("len(livebullets) = ", len(livebullets))) + ingameClient.registerHandler(KeyRShift, down, proc() = + if keyPressed(KeyR): + echo("Friction: ", ff(activeVehicle.shape.getFriction())) + echo("Damping: ", ff(space.getDamping())) + elif keypressed(KeyM): + echo("Mass: ", activeVehicle.body.getMass.ff()) + echo("Moment: ", activeVehicle.body.getMoment.ff()) + elif keypressed(KeyI): + echo(repr(activeVehicle.record)) + elif keyPressed(KeyH): + activeVehicle.body.setPos(vector(100.0, 100.0)) + activeVehicle.body.setVel(VectorZero) + elif keyPressed(KeyComma): + activeVehicle.body.setPos mouseToSpace()) + ingameClient.registerHandler(KeyY, down, proc() = + const looloo = ["Asteroid1", "Asteroid2"] + addObject(looloo[rand(looloo.len)])) + ingameClient.registerHandler(KeyO, down, proc() = + if objects.len == 0: + echo "Objects is empty" + return + for i, o in pairs(objects): + echo i, " ", o) + ingameClient.registerHandler(KeyLBracket, down, sound_buffer.report) + var + mouseJoint: PConstraint + mouseBody = space.addBody(newBody(CpInfinity, CpInfinity)) + ingameClient.registerHandler(MouseMiddle, down, proc() = + var point = mouseToSpace() + var shape = space.pointQueryFirst(point, LGrabbable, 0) + if not mouseJoint.isNil: + space.removeConstraint mouseJoint + mouseJoint.destroy() + mouseJoint = nil + if shape.isNil: + return + let body = shape.getBody() + mouseJoint = space.addConstraint( + newPivotJoint(mouseBody, body, VectorZero, body.world2local(point))) + mouseJoint.maxForce = 50000.0 + mouseJoint.errorBias = pow(1.0 - 0.15, 60)) + +var specCameraSpeed = 5.0 +specInputClient.registerHandler(MouseLeft, down, handleLClick) +specInputClient.registerHandler(KeyF11, down, toggleShipSelect) +specInputClient.registerHandler(KeyF12, down, proc() = toggleSpec()) +specInputClient.registerHandler(KeyLShift, down, proc() = specCameraSpeed *= 2) +specInputClient.registerHandler(KeyLShift, up, proc() = specCameraSpeed /= 2) + +specInputClient.registerHandler(KeyP, down, proc() = + echo("addObject(solar mold)") + addObject("Solar Mold")) + +proc resetForcesCB(body: PBody; data: pointer) {.cdecl.} = + body.resetForces() + +var frameCount= 0 +proc mainUpdate(dt: float) = + if localPlayer.spectator: + if keyPressed(KeyLeft): + worldView.move(vec2f(-1.0, 0.0) * specCameraSpeed) + elif keyPressed(KeyRight): + worldView.move(vec2f( 1.0, 0.0) * specCameraSpeed) + if keyPressed(KeyUp): + worldView.move(vec2f(0.0, -1.0) * specCameraSpeed) + elif keyPressed(KeyDown): + worldView.move(vec2f(0.0, 1.0) * specCameraSpeed) + elif not activeVehicle.isNil: + if keyPressed(KeyUp): + activeVehicle.accel(dt) + elif keyPressed(KeyDown): + activeVehicle.reverse(dt) + if keyPressed(KeyRight): + activeVehicle.turn_right(dt) + elif keyPressed(KeyLeft): + activeVehicle.turn_left(dt) + if keyPressed(Keyz): + activeVehicle.strafe_left(dt) + elif keyPressed(Keyx): + activeVehicle.strafe_right(dt) + if keyPressed(KeyLControl): + localPlayer.useItem 0 + if keyPressed(KeyTab): + localPlayer.useItem 1 + if keyPressed(KeyQ): + localPlayer.useItem 2 + if keyPressed(KeyW): + localPlayer.useItem 3 + if keyPressed(KeyA): + localPlayer.useItem 4 + if keyPressed(sfml.KeyS): + localPlayer.useItem 5 + if keyPressed(KeyD): + localPlayer.useItem 6 + worldView.setCenter(activeVehicle.body.getPos.floor)#cp2sfml) + + if localPlayer != nil: + localPlayer.update() + localPlayer.updateItems(dt) + for b in localBots: + b.update() + + for o in items(objects): + o.update(dt) + for i in countdown(high(delObjects), 0): + objects.del i + delObjects.setLen 0 + + var i = 0 + while i < len(liveBullets): + if liveBullets[i].update(dt): + liveBullets.del i + else: + inc i + i = 0 + while i < len(explosions): + if explosions[i].next(dt): inc i + else: explosions.del i + + when defined(DebugKeys): + mouseBody.setPos(mouseToSpace()) + + space.step(dt) + space.eachBody(resetForcesCB, nil) + + when defined(foo): + var coords = window.convertCoords(vec2i(getMousePos()), worldView) + mouseSprite.setPosition(coords) + + if localPlayer != nil and localPlayer.vehicle != nil: + let + pos = localPlayer.vehicle.body.getPos() + ang = localPlayer.vehicle.body.getAngle.vectorForAngle() + myPosition[0].x = pos.x + myPosition[0].z = pos.y + myPosition[1].x = ang.x + myPosition[1].z = ang.y + listenerSetPosition(myPosition[0]) + listenerSetDirection(myPosition[1]) + + inc frameCount + when defined(showFPS): + if frameCount mod 60 == 0: + fpsText.setString($(1.0/dt).round) + if frameCount mod 250 == 0: + updateSoundBuffer() + frameCount = 0 + +proc mainRender() = + window.clear(Black) + window.setView(worldView) + + if showStars: + for star in stars: + window.draw(star.sprite) + window.draw(localPlayer) + + for b in localBots: + window.draw(b) + for o in objects: + window.draw(o) + + for b in explosions: window.draw(b) + for b in liveBullets: window.draw(b) + + when defined(Foo): + window.draw(mouseSprite) + + window.setView(guiView) + + when defined(EscapeMenuTest): + if escMenuOpen: + window.draw escMenu + when defined(showFPS): + window.draw(fpsText) + when defined(recordMode): + window.draw(recordButton) + + if localPlayer.spectator: + window.draw(specGui) + if showShipSelect: window.draw shipSelect + window.display() + + when defined(recordMode): + if isRecording: + if snapshots.len < 100: + if frameCount mod 5 == 0: + snapshots.add(window.capture()) + else: stopRecording() + +proc readyMainState() = + specInputClient.setActive() + +when true: + import parseopt + + localPlayer = newPlayer() + lobbyInit() + + videoMode = getClientSettings().resolution + window = newRenderWindow(videoMode, "sup", sfDefaultStyle) + window.setFrameRateLimit 60 + + worldView = window.getView.copy() + guiView = worldView.copy() + shipSelect.setPosition vec2f(665.0, 50.0) + + when defined(foo): + mouseSprite = sfml.newCircleShape(14) + mouseSprite.setFillColor Transparent + mouseSprite.setOutlineColor RoyalBlue + mouseSprite.setOutlineThickness 1.4 + mouseSprite.setOrigin vec2f(14, 14) + + lobbyReady() + playBtn = specGui.newButton( + "Unspec - F12", position = vec2f(680.0, 8.0), onClick = proc(b: PButton) = + toggleSpec()) + + block: + var bPlayOffline = false + for kind, key, val in getopt(): + case kind + of cmdArgument: + if key == "offline": bPlayOffline = true + else: + echo "Invalid argument ", key, " ", val + if bPlayOffline: + playoffline(nil) + + gameRunning = true + while gameRunning: + for event in window.filterEvents: + if event.kind == EvtClosed: + gameRunning = false + break + elif event.kind == EvtMouseWheelMoved and getActiveState() == Field: + if event.mouseWheel.delta == 1: + worldView.zoom(0.9) + else: + worldView.zoom(1.1) + let dt = frameRate.restart.asMilliSeconds().float / 1000.0 + case getActiveState() + of Field: + mainUpdate(dt) + mainRender() + of Lobby: + lobbyUpdate(dt) + lobbyDraw(window) + else: + initLevel() + echo("Done? lol") + doneWithSaidTransition() + readyMainState() diff --git a/tests/manyloc/keineschweine/keineschweine.nim.cfg b/tests/manyloc/keineschweine/keineschweine.nim.cfg new file mode 100644 index 000000000..a670e2b77 --- /dev/null +++ b/tests/manyloc/keineschweine/keineschweine.nim.cfg @@ -0,0 +1,10 @@ +path = "lib" +path = "dependencies/sfml" +path = "dependencies/chipmunk" +path = "dependencies/nake" +path = "dependencies/enet" +path = "dependencies/genpacket" +path = "enet_server" +debugger = off +warning[SmallLshouldNotBeUsed] = off +mm = refc diff --git a/tests/manyloc/keineschweine/lib/animations.nim b/tests/manyloc/keineschweine/lib/animations.nim new file mode 100644 index 000000000..a021005f0 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/animations.nim @@ -0,0 +1,75 @@ +import + math, + sfml, chipmunk, + sg_assets, sfml_stuff, math_helpers +type + PAnimation* = ref TAnimation + TAnimation* = object + sprite*: PSprite + record*: PAnimationRecord + delay*: float + index*: int + direction*: int + spriteRect*: TIntRect + style*: TAnimationStyle + TAnimationStyle* = enum + AnimLoop = 0'i8, AnimBounce, AnimOnce + +proc setPos*(obj: PAnimation; pos: TVector) {.inline.} +proc setPos*(obj: PAnimation; pos: TVector2f) {.inline.} +proc setAngle*(obj: PAnimation; radians: float) {.inline.} + +proc free*(obj: PAnimation) = + obj.sprite.destroy() + obj.record = nil + +proc newAnimation*(src: PAnimationRecord; style: TAnimationStyle): PAnimation = + new(result, free) + result.sprite = src.spriteSheet.sprite.copy() + result.record = src + result.delay = src.delay + result.index = 0 + result.direction = 1 + result.spriteRect = result.sprite.getTextureRect() + result.style = style +proc newAnimation*(src: PAnimationRecord; style: TAnimationStyle; + pos: TVector2f; angle: float): PAnimation = + result = newAnimation(src, style) + result.setPos pos + setAngle(result, angle) + +proc next*(obj: PAnimation; dt: float): bool {.discardable.} = + ## step the animation. Returns false if the object is out of frames + result = true + obj.delay -= dt + if obj.delay <= 0.0: + obj.delay += obj.record.delay + obj.index += obj.direction + #if obj.index > (obj.record.spriteSheet.cols - 1) or obj.index < 0: + if not(obj.index in 0..(obj.record.spriteSheet.cols - 1)): + case obj.style + of AnimOnce: + return false + of AnimBounce: + obj.direction *= -1 + obj.index += obj.direction * 2 + of AnimLoop: + obj.index = 0 + obj.spriteRect.left = obj.index.cint * obj.record.spriteSheet.frameW.cint + obj.sprite.setTextureRect obj.spriteRect + +proc setPos*(obj: PAnimation; pos: TVector) = + setPosition(obj.sprite, pos.floor()) +proc setPos*(obj: PAnimation; pos: TVector2f) = + setPosition(obj.sprite, pos) +proc setAngle*(obj: PAnimation; radians: float) = + let rads = (radians + obj.record.angle).wmod(TAU) + if obj.record.spriteSheet.rows > 1: + ## (rotation percent * rows).floor * frameheight + obj.spriteRect.top = (rads / TAU * obj.record.spriteSheet.rows.float).floor.cint * obj.record.spriteSheet.frameh.cint + obj.sprite.setTextureRect obj.spriteRect + else: + setRotation(obj.sprite, degrees(rads)) #stupid sfml, who uses degrees these days? -__- + +proc draw*(window: PRenderWindow; obj: PAnimation) {.inline.} = + window.draw(obj.sprite) diff --git a/tests/manyloc/keineschweine/lib/client_helpers.nim b/tests/manyloc/keineschweine/lib/client_helpers.nim new file mode 100644 index 000000000..b21e67cf7 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/client_helpers.nim @@ -0,0 +1,144 @@ +import ../../../../dist/checksums/src/checksums/md5 + +import + tables, sg_packets, enet, estreams, sg_gui, sfml, + zlib_helpers, sg_assets, os +type + PServer* = ptr TServer + TServer* = object + connected*: bool + addy: enet.TAddress + host*: PHost + peer*: PPeer + handlers*: Table[char, TScPktHandler] + TScPktHandler* = proc(serv: PServer; buffer: PBuffer) + TFileTransfer = object + fileName: string + assetType: TAssetType + fullLen: int + pos: int32 + data: string + readyToSave: bool +var + currentFileTransfer: TFileTransfer + downloadProgress* = newButton(nil, "", vec2f(0,0), nil) +currentFileTransfer.data = "" + +proc addHandler*(serv: PServer; packetType: char; handler: TScPktHandler) = + serv.handlers[packetType] = handler + +proc newServer*(): PServer = + result = cast[PServer](alloc0(sizeof(TServer))) + result.connected = false + result.host = createHost(nil, 1, 2, 0, 0) + result.handlers = initTable[char, TScPktHandler](32) + +proc connect*(serv: PServer; host: string; port: int16; error: var string): bool = + if setHost(serv.addy, host) != 0: + error = "Could not resolve host " + error.add host + return false + serv.addy.port = port.cushort + serv.peer = serv.host.connect(serv.addy, 2, 0) + if serv.peer.isNil: + error = "Could not connect to host " + error.add host + return false + return true + +proc send*[T](serv: PServer; packetType: char; pkt: var T) = + if serv.connected: + var b = newBuffer(100) + b.write packetType + b.pack pkt + serv.peer.send(0.cuchar, b, FlagUnsequenced) + +proc sendPubChat*(server: PServer; msg: string) = + var chat = newCsChat("", msg) + server.send HChat, chat + +proc handlePackets*(server: PServer; buf: PBuffer) = + while not buf.atEnd(): + let typ = readChar(buf) + if server.handlers.hasKey(typ): + server.handlers[typ](server, buf) + else: + break + +proc updateFileProgress*() = + let progress = currentFileTransfer.pos / currentFileTransfer.fullLen + downloadProgress.bg.setSize(vec2f(progress * 100, 20)) + downloadProgress.setString($currentFileTransfer.pos & '/' & $currentFileTransfer.fullLen) + +## HFileTransfer +proc handleFilePartRecv*(serv: PServer; buffer: PBuffer) = + var + f = readScFileTransfer(buffer) + updateFileProgress() + if not(f.pos == currentFileTransfer.pos): + echo "returning early from filepartrecv" + return ##issues, probably + if currentFileTransfer.data.len == 0: + echo "setting current file size" + currentFileTransfer.data.setLen f.fileSize + let len = f.data.len + copymem( + addr currentFileTransfer.data[f.pos], + addr f.data[0], + len) + currentFileTransfer.pos = f.pos + len.int32 + if currentFileTransfer.pos == f.fileSize: #file should be done, rizzight + currentFileTransfer.data = uncompress( + currentFileTransfer.data, currentFileTransfer.fullLen) + currentFileTransfer.readyToSave = true + var resp: CsFileChallenge + resp.checksum = toMD5(currentFileTransfer.data) + serv.send HFileChallenge, resp + echo "responded with challenge (ready to save)" + else: + var resp = newCsFilepartAck(currentFileTransfer.pos) + serv.send HFileTransfer, resp + echo "responded for next part" + +proc saveCurrentFile() = + if not currentFileTransfer.readyToSave: return + let + path = expandPath(currentFileTransfer.assetType, currentFileTransfer.fileName) + parent = parentDir(path) + if not dirExists(parent): + createDir(parent) + echo("Created dir") + writeFile path, currentFIleTransfer.data + echo "Write file" + +## HChallengeResult +proc handleFileChallengeResult*(serv: PServer; buffer: PBuffer) = + var res = readScChallengeResult(buffer).status + echo "got challnege result: ", res + if res and currentFileTransfer.readyToSave: + echo "saving" + saveCurrentFile() + else: + currentFileTransfer.readyToSave = false + currentFileTransfer.pos = 0 + echo "REsetting current file" + +## HFileCHallenge +proc handleFileChallenge*(serv: PServer; buffer: PBuffer) = + var + challenge = readScFileChallenge(buffer) + path = expandPath(challenge) + resp: CsFileChallenge + if not fileExists(path): + resp.needFile = true + echo "Got file challenge, need file." + else: + resp.checksum = toMD5(readFile(path)) + echo "got file challenge, sending sum" + currentFileTransfer.fileName = challenge.file + currentFileTransfer.assetType = challenge.assetType + currentFileTransfer.fullLen = challenge.fullLen.int + currentFileTransfer.pos = 0 + currentFileTransfer.data.setLen 0 + currentFileTransfer.readyToSave = false + serv.send HFileChallenge, resp diff --git a/tests/manyloc/keineschweine/lib/estreams.nim b/tests/manyloc/keineschweine/lib/estreams.nim new file mode 100644 index 000000000..c5e45e0e7 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/estreams.nim @@ -0,0 +1,120 @@ +import endians + +proc swapEndian16*(outp, inp: pointer) = + ## copies `inp` to `outp` swapping bytes. Both buffers are supposed to + ## contain at least 2 bytes. + var i = cast[cstring](inp) + var o = cast[cstring](outp) + o[0] = i[1] + o[1] = i[0] + +import enet + +type + PBuffer* = ref object + data*: string + pos: int + +proc free(b: PBuffer) = + GCunref b.data +proc newBuffer*(len: int): PBuffer = + new result, free + result.data = newString(len) +proc newBuffer*(pkt: PPacket): PBuffer = + new result, free + result.data = newString(pkt.dataLength) + copyMem(addr result.data[0], pkt.data, pkt.dataLength) +proc toPacket*(buffer: PBuffer; flags: TPacketFlag): PPacket = + buffer.data.setLen buffer.pos + result = createPacket(cstring(buffer.data), cast[csize_t](buffer.pos), flags) + +proc isDirty*(buffer: PBuffer): bool {.inline.} = + result = (buffer.pos != 0) +proc atEnd*(buffer: PBuffer): bool {.inline.} = + result = (buffer.pos == buffer.data.len) +proc reset*(buffer: PBuffer) {.inline.} = + buffer.pos = 0 + +proc flush*(buf: PBuffer) = + buf.pos = 0 + buf.data.setLen(0) +proc send*(peer: PPeer; channel: cuchar; buf: PBuffer; flags: TPacketFlag): cint {.discardable.} = + result = send(peer, channel, buf.toPacket(flags)) + +proc read*[T: int16|uint16](buffer: PBuffer; outp: var T) = + bigEndian16(addr outp, addr buffer.data[buffer.pos]) + inc buffer.pos, 2 +proc read*[T: float32|int32|uint32](buffer: PBuffer; outp: var T) = + bigEndian32(addr outp, addr buffer.data[buffer.pos]) + inc buffer.pos, 4 +proc read*[T: float64|int64|uint64](buffer: PBuffer; outp: var T) = + bigEndian64(addr outp, addr buffer.data[buffer.pos]) + inc buffer.pos, 8 +proc read*[T: int8|uint8|byte|bool|char](buffer: PBuffer; outp: var T) = + copyMem(addr outp, addr buffer.data[buffer.pos], 1) + inc buffer.pos, 1 + +proc writeBE*[T: int16|uint16](buffer: PBuffer; val: var T) = + setLen buffer.data, buffer.pos + 2 + bigEndian16(addr buffer.data[buffer.pos], addr val) + inc buffer.pos, 2 +proc writeBE*[T: int32|uint32|float32](buffer: PBuffer; val: var T) = + setLen buffer.data, buffer.pos + 4 + bigEndian32(addr buffer.data[buffer.pos], addr val) + inc buffer.pos, 4 +proc writeBE*[T: int64|uint64|float64](buffer: PBuffer; val: var T) = + setLen buffer.data, buffer.pos + 8 + bigEndian64(addr buffer.data[buffer.pos], addr val) + inc buffer.pos, 8 +proc writeBE*[T: char|int8|uint8|byte|bool](buffer: PBuffer; val: var T) = + setLen buffer.data, buffer.pos + 1 + copyMem(addr buffer.data[buffer.pos], addr val, 1) + inc buffer.pos, 1 + + +proc write*(buffer: PBuffer; val: var string) = + var length = len(val).uint16 + writeBE buffer, length + setLen buffer.data, buffer.pos + length.int + copyMem(addr buffer.data[buffer.pos], addr val[0], length.int) + inc buffer.pos, length.int +proc write*[T: SomeNumber|bool|char|byte](buffer: PBuffer; val: sink T) = + var v: T + v = val + writeBE buffer, v + +proc readInt8*(buffer: PBuffer): int8 = + read buffer, result +proc readInt16*(buffer: PBuffer): int16 = + read buffer, result +proc readInt32*(buffer: PBuffer): int32 = + read buffer, result +proc readInt64*(buffer: PBuffer): int64 = + read buffer, result +proc readFloat32*(buffer: PBuffer): float32 = + read buffer, result +proc readFloat64*(buffer: PBuffer): float64 = + read buffer, result +proc readStr*(buffer: PBuffer): string = + let len = readInt16(buffer).int + result = "" + if len > 0: + result.setLen len + copyMem(addr result[0], addr buffer.data[buffer.pos], len) + inc buffer.pos, len +proc readChar*(buffer: PBuffer): char {.inline.} = return readInt8(buffer).char +proc readBool*(buffer: PBuffer): bool {.inline.} = return readInt8(buffer).bool + + +when false: + var b = newBuffer(100) + var str = "hello there" + b.write str + echo(repr(b)) + b.pos = 0 + echo(repr(b.readStr())) + + b.flush() + echo "flushed" + b.writeC([1,2,3]) + echo(repr(b)) diff --git a/tests/manyloc/keineschweine/lib/game_objects.nim b/tests/manyloc/keineschweine/lib/game_objects.nim new file mode 100644 index 000000000..277ffb6cb --- /dev/null +++ b/tests/manyloc/keineschweine/lib/game_objects.nim @@ -0,0 +1,34 @@ +import chipmunk, sfml, animations, sg_assets +type + PGameObject* = ref TGameObject + TGameObject = object + body*: chipmunk.PBody + shape*: chipmunk.PShape + record*: PObjectRecord + anim*: PAnimation + + +proc `$`*(obj: PGameObject): string = + result = "<Object " + result.add obj.record.name + result.add ' ' + result.add($obj.body.getpos()) + result.add '>' +proc free(obj: PGameObject) = + obj.record = nil + free(obj.anim) + obj.anim = nil +proc newObject*(record: PObjectRecord): PGameObject = + if record.isNil: return nil + new(result, free) + result.record = record + result.anim = newAnimation(record.anim, AnimLoop) + when false: + result.sprite = record.anim.spriteSheet.sprite.copy() + result.body = newBody(result.record.physics.mass, 10.0) + result.shape = chipmunk.newCircleShape(result.body, result.record.physics.radius, VectorZero) + result.body.setPos(vector(100, 100)) +proc newObject*(name: string): PGameObject = + result = newObject(fetchObj(name)) +proc draw*(window: PRenderWindow, obj: PGameObject) {.inline.} = + window.draw(obj.anim.sprite) diff --git a/tests/manyloc/keineschweine/lib/gl.nim b/tests/manyloc/keineschweine/lib/gl.nim new file mode 100644 index 000000000..b634a96cf --- /dev/null +++ b/tests/manyloc/keineschweine/lib/gl.nim @@ -0,0 +1,1536 @@ +# +# +# Adaption of the delphi3d.net OpenGL units to FreePascal +# Sebastian Guenther (sg@freepascal.org) in 2002 +# These units are free to use +# +#****************************************************************************** +# Converted to Delphi by Tom Nuydens (tom@delphi3d.net) +# For the latest updates, visit Delphi3D: http://www.delphi3d.net +#****************************************************************************** + +when defined(windows): + {.push, callconv: stdcall.} +else: + {.push, callconv: cdecl.} +when defined(windows): + const + dllname* = "opengl32.dll" +elif defined(macosx): + const + dllname* = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" +else: + const + dllname* = "libGL.so.1" +type + PGLenum* = ptr TGLenum + PGLboolean* = ptr TGLboolean + PGLbitfield* = ptr TGLbitfield + TGLbyte* = int8 + PGLbyte* = ptr TGlbyte + PGLshort* = ptr TGLshort + PGLint* = ptr TGLint + PGLsizei* = ptr TGLsizei + PGLubyte* = ptr TGLubyte + PGLushort* = ptr TGLushort + PGLuint* = ptr TGLuint + PGLfloat* = ptr TGLfloat + PGLclampf* = ptr TGLclampf + PGLdouble* = ptr TGLdouble + PGLclampd* = ptr TGLclampd + PGLvoid* = pointer + PPGLvoid* = ptr PGLvoid + TGLenum* = cint + TGLboolean* = bool + TGLbitfield* = cint + TGLshort* = int16 + TGLint* = cint + TGLsizei* = int + TGLubyte* = int8 + TGLushort* = int16 + TGLuint* = cint + TGLfloat* = float32 + TGLclampf* = float32 + TGLdouble* = float + TGLclampd* = float + +const # Version + GL_VERSION_1_1* = 1 # AccumOp + constGL_ACCUM* = 0x00000100 + GL_LOAD* = 0x00000101 + GL_RETURN* = 0x00000102 + GL_MULT* = 0x00000103 + GL_ADD* = 0x00000104 # AlphaFunction + GL_NEVER* = 0x00000200 + GL_LESS* = 0x00000201 + GL_EQUAL* = 0x00000202 + GL_LEQUAL* = 0x00000203 + GL_GREATER* = 0x00000204 + GL_NOTEQUAL* = 0x00000205 + GL_GEQUAL* = 0x00000206 + GL_ALWAYS* = 0x00000207 # AttribMask + GL_CURRENT_BIT* = 0x00000001 + GL_POINT_BIT* = 0x00000002 + GL_LINE_BIT* = 0x00000004 + GL_POLYGON_BIT* = 0x00000008 + GL_POLYGON_STIPPLE_BIT* = 0x00000010 + GL_PIXEL_MODE_BIT* = 0x00000020 + GL_LIGHTING_BIT* = 0x00000040 + GL_FOG_BIT* = 0x00000080 + GL_DEPTH_BUFFER_BIT* = 0x00000100 + GL_ACCUM_BUFFER_BIT* = 0x00000200 + GL_STENCIL_BUFFER_BIT* = 0x00000400 + GL_VIEWPORT_BIT* = 0x00000800 + GL_TRANSFORM_BIT* = 0x00001000 + GL_ENABLE_BIT* = 0x00002000 + GL_COLOR_BUFFER_BIT* = 0x00004000 + GL_HINT_BIT* = 0x00008000 + GL_EVAL_BIT* = 0x00010000 + GL_LIST_BIT* = 0x00020000 + GL_TEXTURE_BIT* = 0x00040000 + GL_SCISSOR_BIT* = 0x00080000 + GL_ALL_ATTRIB_BITS* = 0x000FFFFF # BeginMode + GL_POINTS* = 0x00000000 + GL_LINES* = 0x00000001 + GL_LINE_LOOP* = 0x00000002 + GL_LINE_STRIP* = 0x00000003 + GL_TRIANGLES* = 0x00000004 + GL_TRIANGLE_STRIP* = 0x00000005 + GL_TRIANGLE_FAN* = 0x00000006 + GL_QUADS* = 0x00000007 + GL_QUAD_STRIP* = 0x00000008 + GL_POLYGON* = 0x00000009 # BlendingFactorDest + GL_ZERO* = 0 + GL_ONE* = 1 + GL_SRC_COLOR* = 0x00000300 + GL_ONE_MINUS_SRC_COLOR* = 0x00000301 + GL_SRC_ALPHA* = 0x00000302 + GL_ONE_MINUS_SRC_ALPHA* = 0x00000303 + GL_DST_ALPHA* = 0x00000304 + GL_ONE_MINUS_DST_ALPHA* = 0x00000305 # BlendingFactorSrc + # GL_ZERO + # GL_ONE + GL_DST_COLOR* = 0x00000306 + GL_ONE_MINUS_DST_COLOR* = 0x00000307 + GL_SRC_ALPHA_SATURATE* = 0x00000308 # GL_SRC_ALPHA + # GL_ONE_MINUS_SRC_ALPHA + # GL_DST_ALPHA + # GL_ONE_MINUS_DST_ALPHA + # Boolean + GL_TRUE* = 1 + GL_FALSE* = 0 # ClearBufferMask + # GL_COLOR_BUFFER_BIT + # GL_ACCUM_BUFFER_BIT + # GL_STENCIL_BUFFER_BIT + # GL_DEPTH_BUFFER_BIT + # ClientArrayType + # GL_VERTEX_ARRAY + # GL_NORMAL_ARRAY + # GL_COLOR_ARRAY + # GL_INDEX_ARRAY + # GL_TEXTURE_COORD_ARRAY + # GL_EDGE_FLAG_ARRAY + # ClipPlaneName + GL_CLIP_PLANE0* = 0x00003000 + GL_CLIP_PLANE1* = 0x00003001 + GL_CLIP_PLANE2* = 0x00003002 + GL_CLIP_PLANE3* = 0x00003003 + GL_CLIP_PLANE4* = 0x00003004 + GL_CLIP_PLANE5* = 0x00003005 # ColorMaterialFace + # GL_FRONT + # GL_BACK + # GL_FRONT_AND_BACK + # ColorMaterialParameter + # GL_AMBIENT + # GL_DIFFUSE + # GL_SPECULAR + # GL_EMISSION + # GL_AMBIENT_AND_DIFFUSE + # ColorPointerType + # GL_BYTE + # GL_UNSIGNED_BYTE + # GL_SHORT + # GL_UNSIGNED_SHORT + # GL_INT + # GL_UNSIGNED_INT + # GL_FLOAT + # GL_DOUBLE + # CullFaceMode + # GL_FRONT + # GL_BACK + # GL_FRONT_AND_BACK + # DataType + GL_BYTE* = 0x00001400 + GL_UNSIGNED_BYTE* = 0x00001401 + GL_SHORT* = 0x00001402 + GL_UNSIGNED_SHORT* = 0x00001403 + GL_INT* = 0x00001404 + GL_UNSIGNED_INT* = 0x00001405 + GL_FLOAT* = 0x00001406 + GL_2_BYTES* = 0x00001407 + GL_3_BYTES* = 0x00001408 + GL_4_BYTES* = 0x00001409 + GL_DOUBLE* = 0x0000140A # DepthFunction + # GL_NEVER + # GL_LESS + # GL_EQUAL + # GL_LEQUAL + # GL_GREATER + # GL_NOTEQUAL + # GL_GEQUAL + # GL_ALWAYS + # DrawBufferMode + GL_NONE* = 0 + GL_FRONT_LEFT* = 0x00000400 + GL_FRONT_RIGHT* = 0x00000401 + GL_BACK_LEFT* = 0x00000402 + GL_BACK_RIGHT* = 0x00000403 + GL_FRONT* = 0x00000404 + GL_BACK* = 0x00000405 + GL_LEFT* = 0x00000406 + GL_RIGHT* = 0x00000407 + GL_FRONT_AND_BACK* = 0x00000408 + GL_AUX0* = 0x00000409 + GL_AUX1* = 0x0000040A + GL_AUX2* = 0x0000040B + GL_AUX3* = 0x0000040C # Enable + # GL_FOG + # GL_LIGHTING + # GL_TEXTURE_1D + # GL_TEXTURE_2D + # GL_LINE_STIPPLE + # GL_POLYGON_STIPPLE + # GL_CULL_FACE + # GL_ALPHA_TEST + # GL_BLEND + # GL_INDEX_LOGIC_OP + # GL_COLOR_LOGIC_OP + # GL_DITHER + # GL_STENCIL_TEST + # GL_DEPTH_TEST + # GL_CLIP_PLANE0 + # GL_CLIP_PLANE1 + # GL_CLIP_PLANE2 + # GL_CLIP_PLANE3 + # GL_CLIP_PLANE4 + # GL_CLIP_PLANE5 + # GL_LIGHT0 + # GL_LIGHT1 + # GL_LIGHT2 + # GL_LIGHT3 + # GL_LIGHT4 + # GL_LIGHT5 + # GL_LIGHT6 + # GL_LIGHT7 + # GL_TEXTURE_GEN_S + # GL_TEXTURE_GEN_T + # GL_TEXTURE_GEN_R + # GL_TEXTURE_GEN_Q + # GL_MAP1_VERTEX_3 + # GL_MAP1_VERTEX_4 + # GL_MAP1_COLOR_4 + # GL_MAP1_INDEX + # GL_MAP1_NORMAL + # GL_MAP1_TEXTURE_COORD_1 + # GL_MAP1_TEXTURE_COORD_2 + # GL_MAP1_TEXTURE_COORD_3 + # GL_MAP1_TEXTURE_COORD_4 + # GL_MAP2_VERTEX_3 + # GL_MAP2_VERTEX_4 + # GL_MAP2_COLOR_4 + # GL_MAP2_INDEX + # GL_MAP2_NORMAL + # GL_MAP2_TEXTURE_COORD_1 + # GL_MAP2_TEXTURE_COORD_2 + # GL_MAP2_TEXTURE_COORD_3 + # GL_MAP2_TEXTURE_COORD_4 + # GL_POINT_SMOOTH + # GL_LINE_SMOOTH + # GL_POLYGON_SMOOTH + # GL_SCISSOR_TEST + # GL_COLOR_MATERIAL + # GL_NORMALIZE + # GL_AUTO_NORMAL + # GL_VERTEX_ARRAY + # GL_NORMAL_ARRAY + # GL_COLOR_ARRAY + # GL_INDEX_ARRAY + # GL_TEXTURE_COORD_ARRAY + # GL_EDGE_FLAG_ARRAY + # GL_POLYGON_OFFSET_POINT + # GL_POLYGON_OFFSET_LINE + # GL_POLYGON_OFFSET_FILL + # ErrorCode + GL_NO_ERROR* = 0 + GL_INVALID_ENUM* = 0x00000500 + GL_INVALID_VALUE* = 0x00000501 + GL_INVALID_OPERATION* = 0x00000502 + GL_STACK_OVERFLOW* = 0x00000503 + GL_STACK_UNDERFLOW* = 0x00000504 + GL_OUT_OF_MEMORY* = 0x00000505 # FeedBackMode + GL_2D* = 0x00000600 + GL_3D* = 0x00000601 + GL_3D_COLOR* = 0x00000602 + GL_3D_COLOR_TEXTURE* = 0x00000603 + GL_4D_COLOR_TEXTURE* = 0x00000604 # FeedBackToken + GL_PASS_THROUGH_TOKEN* = 0x00000700 + GL_POINT_TOKEN* = 0x00000701 + GL_LINE_TOKEN* = 0x00000702 + GL_POLYGON_TOKEN* = 0x00000703 + GL_BITMAP_TOKEN* = 0x00000704 + GL_DRAW_PIXEL_TOKEN* = 0x00000705 + GL_COPY_PIXEL_TOKEN* = 0x00000706 + GL_LINE_RESET_TOKEN* = 0x00000707 # FogMode + # GL_LINEAR + GL_EXP* = 0x00000800 + GL_EXP2* = 0x00000801 # FogParameter + # GL_FOG_COLOR + # GL_FOG_DENSITY + # GL_FOG_END + # GL_FOG_INDEX + # GL_FOG_MODE + # GL_FOG_START + # FrontFaceDirection + GL_CW* = 0x00000900 + GL_CCW* = 0x00000901 # GetMapTarget + GL_COEFF* = 0x00000A00 + GL_ORDER* = 0x00000A01 + GL_DOMAIN* = 0x00000A02 # GetPixelMap + # GL_PIXEL_MAP_I_TO_I + # GL_PIXEL_MAP_S_TO_S + # GL_PIXEL_MAP_I_TO_R + # GL_PIXEL_MAP_I_TO_G + # GL_PIXEL_MAP_I_TO_B + # GL_PIXEL_MAP_I_TO_A + # GL_PIXEL_MAP_R_TO_R + # GL_PIXEL_MAP_G_TO_G + # GL_PIXEL_MAP_B_TO_B + # GL_PIXEL_MAP_A_TO_A + # GetPointerTarget + # GL_VERTEX_ARRAY_POINTER + # GL_NORMAL_ARRAY_POINTER + # GL_COLOR_ARRAY_POINTER + # GL_INDEX_ARRAY_POINTER + # GL_TEXTURE_COORD_ARRAY_POINTER + # GL_EDGE_FLAG_ARRAY_POINTER + # GetTarget + GL_CURRENT_COLOR* = 0x00000B00 + GL_CURRENT_INDEX* = 0x00000B01 + GL_CURRENT_NORMAL* = 0x00000B02 + GL_CURRENT_TEXTURE_COORDS* = 0x00000B03 + GL_CURRENT_RASTER_COLOR* = 0x00000B04 + GL_CURRENT_RASTER_INDEX* = 0x00000B05 + GL_CURRENT_RASTER_TEXTURE_COORDS* = 0x00000B06 + GL_CURRENT_RASTER_POSITION* = 0x00000B07 + GL_CURRENT_RASTER_POSITION_VALID* = 0x00000B08 + GL_CURRENT_RASTER_DISTANCE* = 0x00000B09 + GL_POINT_SMOOTH* = 0x00000B10 + constGL_POINT_SIZE* = 0x00000B11 + GL_POINT_SIZE_RANGE* = 0x00000B12 + GL_POINT_SIZE_GRANULARITY* = 0x00000B13 + GL_LINE_SMOOTH* = 0x00000B20 + constGL_LINE_WIDTH* = 0x00000B21 + GL_LINE_WIDTH_RANGE* = 0x00000B22 + GL_LINE_WIDTH_GRANULARITY* = 0x00000B23 + constGL_LINE_STIPPLE* = 0x00000B24 + GL_LINE_STIPPLE_PATTERN* = 0x00000B25 + GL_LINE_STIPPLE_REPEAT* = 0x00000B26 + GL_LIST_MODE* = 0x00000B30 + GL_MAX_LIST_NESTING* = 0x00000B31 + constGL_LIST_BASE* = 0x00000B32 + GL_LIST_INDEX* = 0x00000B33 + constGL_POLYGON_MODE* = 0x00000B40 + GL_POLYGON_SMOOTH* = 0x00000B41 + constGL_POLYGON_STIPPLE* = 0x00000B42 + constGL_EDGE_FLAG* = 0x00000B43 + constGL_CULL_FACE* = 0x00000B44 + GL_CULL_FACE_MODE* = 0x00000B45 + constGL_FRONT_FACE* = 0x00000B46 + GL_LIGHTING* = 0x00000B50 + GL_LIGHT_MODEL_LOCAL_VIEWER* = 0x00000B51 + GL_LIGHT_MODEL_TWO_SIDE* = 0x00000B52 + GL_LIGHT_MODEL_AMBIENT* = 0x00000B53 + constGL_SHADE_MODEL* = 0x00000B54 + GL_COLOR_MATERIAL_FACE* = 0x00000B55 + GL_COLOR_MATERIAL_PARAMETER* = 0x00000B56 + constGL_COLOR_MATERIAL* = 0x00000B57 + GL_FOG* = 0x00000B60 + GL_FOG_INDEX* = 0x00000B61 + GL_FOG_DENSITY* = 0x00000B62 + GL_FOG_START* = 0x00000B63 + GL_FOG_END* = 0x00000B64 + GL_FOG_MODE* = 0x00000B65 + GL_FOG_COLOR* = 0x00000B66 + constGL_DEPTH_RANGE* = 0x00000B70 + GL_DEPTH_TEST* = 0x00000B71 + GL_DEPTH_WRITEMASK* = 0x00000B72 + GL_DEPTH_CLEAR_VALUE* = 0x00000B73 + constGL_DEPTH_FUNC* = 0x00000B74 + GL_ACCUM_CLEAR_VALUE* = 0x00000B80 + GL_STENCIL_TEST* = 0x00000B90 + GL_STENCIL_CLEAR_VALUE* = 0x00000B91 + constGL_STENCIL_FUNC* = 0x00000B92 + GL_STENCIL_VALUE_MASK* = 0x00000B93 + GL_STENCIL_FAIL* = 0x00000B94 + GL_STENCIL_PASS_DEPTH_FAIL* = 0x00000B95 + GL_STENCIL_PASS_DEPTH_PASS* = 0x00000B96 + GL_STENCIL_REF* = 0x00000B97 + GL_STENCIL_WRITEMASK* = 0x00000B98 + constGL_MATRIX_MODE* = 0x00000BA0 + GL_NORMALIZE* = 0x00000BA1 + constGL_VIEWPORT* = 0x00000BA2 + GL_MODELVIEW_STACK_DEPTH* = 0x00000BA3 + GL_PROJECTION_STACK_DEPTH* = 0x00000BA4 + GL_TEXTURE_STACK_DEPTH* = 0x00000BA5 + GL_MODELVIEW_MATRIX* = 0x00000BA6 + GL_PROJECTION_MATRIX* = 0x00000BA7 + GL_TEXTURE_MATRIX* = 0x00000BA8 + GL_ATTRIB_STACK_DEPTH* = 0x00000BB0 + GL_CLIENT_ATTRIB_STACK_DEPTH* = 0x00000BB1 + GL_ALPHA_TEST* = 0x00000BC0 + GL_ALPHA_TEST_FUNC* = 0x00000BC1 + GL_ALPHA_TEST_REF* = 0x00000BC2 + GL_DITHER* = 0x00000BD0 + GL_BLEND_DST* = 0x00000BE0 + GL_BLEND_SRC* = 0x00000BE1 + GL_BLEND* = 0x00000BE2 + GL_LOGIC_OP_MODE* = 0x00000BF0 + GL_INDEX_LOGIC_OP* = 0x00000BF1 + GL_COLOR_LOGIC_OP* = 0x00000BF2 + GL_AUX_BUFFERS* = 0x00000C00 + constGL_DRAW_BUFFER* = 0x00000C01 + constGL_READ_BUFFER* = 0x00000C02 + GL_SCISSOR_BOX* = 0x00000C10 + GL_SCISSOR_TEST* = 0x00000C11 + GL_INDEX_CLEAR_VALUE* = 0x00000C20 + GL_INDEX_WRITEMASK* = 0x00000C21 + GL_COLOR_CLEAR_VALUE* = 0x00000C22 + GL_COLOR_WRITEMASK* = 0x00000C23 + GL_INDEX_MODE* = 0x00000C30 + GL_RGBA_MODE* = 0x00000C31 + GL_DOUBLEBUFFER* = 0x00000C32 + GL_STEREO* = 0x00000C33 + constGL_RENDER_MODE* = 0x00000C40 + GL_PERSPECTIVE_CORRECTION_HINT* = 0x00000C50 + GL_POINT_SMOOTH_HINT* = 0x00000C51 + GL_LINE_SMOOTH_HINT* = 0x00000C52 + GL_POLYGON_SMOOTH_HINT* = 0x00000C53 + GL_FOG_HINT* = 0x00000C54 + GL_TEXTURE_GEN_S* = 0x00000C60 + GL_TEXTURE_GEN_T* = 0x00000C61 + GL_TEXTURE_GEN_R* = 0x00000C62 + GL_TEXTURE_GEN_Q* = 0x00000C63 + GL_PIXEL_MAP_I_TO_I* = 0x00000C70 + GL_PIXEL_MAP_S_TO_S* = 0x00000C71 + GL_PIXEL_MAP_I_TO_R* = 0x00000C72 + GL_PIXEL_MAP_I_TO_G* = 0x00000C73 + GL_PIXEL_MAP_I_TO_B* = 0x00000C74 + GL_PIXEL_MAP_I_TO_A* = 0x00000C75 + GL_PIXEL_MAP_R_TO_R* = 0x00000C76 + GL_PIXEL_MAP_G_TO_G* = 0x00000C77 + GL_PIXEL_MAP_B_TO_B* = 0x00000C78 + GL_PIXEL_MAP_A_TO_A* = 0x00000C79 + GL_PIXEL_MAP_I_TO_I_SIZE* = 0x00000CB0 + GL_PIXEL_MAP_S_TO_S_SIZE* = 0x00000CB1 + GL_PIXEL_MAP_I_TO_R_SIZE* = 0x00000CB2 + GL_PIXEL_MAP_I_TO_G_SIZE* = 0x00000CB3 + GL_PIXEL_MAP_I_TO_B_SIZE* = 0x00000CB4 + GL_PIXEL_MAP_I_TO_A_SIZE* = 0x00000CB5 + GL_PIXEL_MAP_R_TO_R_SIZE* = 0x00000CB6 + GL_PIXEL_MAP_G_TO_G_SIZE* = 0x00000CB7 + GL_PIXEL_MAP_B_TO_B_SIZE* = 0x00000CB8 + GL_PIXEL_MAP_A_TO_A_SIZE* = 0x00000CB9 + GL_UNPACK_SWAP_BYTES* = 0x00000CF0 + GL_UNPACK_LSB_FIRST* = 0x00000CF1 + GL_UNPACK_ROW_LENGTH* = 0x00000CF2 + GL_UNPACK_SKIP_ROWS* = 0x00000CF3 + GL_UNPACK_SKIP_PIXELS* = 0x00000CF4 + GL_UNPACK_ALIGNMENT* = 0x00000CF5 + GL_PACK_SWAP_BYTES* = 0x00000D00 + GL_PACK_LSB_FIRST* = 0x00000D01 + GL_PACK_ROW_LENGTH* = 0x00000D02 + GL_PACK_SKIP_ROWS* = 0x00000D03 + GL_PACK_SKIP_PIXELS* = 0x00000D04 + GL_PACK_ALIGNMENT* = 0x00000D05 + GL_MAP_COLOR* = 0x00000D10 + GL_MAP_STENCIL* = 0x00000D11 + GL_INDEX_SHIFT* = 0x00000D12 + GL_INDEX_OFFSET* = 0x00000D13 + GL_RED_SCALE* = 0x00000D14 + GL_RED_BIAS* = 0x00000D15 + GL_ZOOM_X* = 0x00000D16 + GL_ZOOM_Y* = 0x00000D17 + GL_GREEN_SCALE* = 0x00000D18 + GL_GREEN_BIAS* = 0x00000D19 + GL_BLUE_SCALE* = 0x00000D1A + GL_BLUE_BIAS* = 0x00000D1B + GL_ALPHA_SCALE* = 0x00000D1C + GL_ALPHA_BIAS* = 0x00000D1D + GL_DEPTH_SCALE* = 0x00000D1E + GL_DEPTH_BIAS* = 0x00000D1F + GL_MAX_EVAL_ORDER* = 0x00000D30 + GL_MAX_LIGHTS* = 0x00000D31 + GL_MAX_CLIP_PLANES* = 0x00000D32 + GL_MAX_TEXTURE_SIZE* = 0x00000D33 + GL_MAX_PIXEL_MAP_TABLE* = 0x00000D34 + GL_MAX_ATTRIB_STACK_DEPTH* = 0x00000D35 + GL_MAX_MODELVIEW_STACK_DEPTH* = 0x00000D36 + GL_MAX_NAME_STACK_DEPTH* = 0x00000D37 + GL_MAX_PROJECTION_STACK_DEPTH* = 0x00000D38 + GL_MAX_TEXTURE_STACK_DEPTH* = 0x00000D39 + GL_MAX_VIEWPORT_DIMS* = 0x00000D3A + GL_MAX_CLIENT_ATTRIB_STACK_DEPTH* = 0x00000D3B + GL_SUBPIXEL_BITS* = 0x00000D50 + GL_INDEX_BITS* = 0x00000D51 + GL_RED_BITS* = 0x00000D52 + GL_GREEN_BITS* = 0x00000D53 + GL_BLUE_BITS* = 0x00000D54 + GL_ALPHA_BITS* = 0x00000D55 + GL_DEPTH_BITS* = 0x00000D56 + GL_STENCIL_BITS* = 0x00000D57 + GL_ACCUM_RED_BITS* = 0x00000D58 + GL_ACCUM_GREEN_BITS* = 0x00000D59 + GL_ACCUM_BLUE_BITS* = 0x00000D5A + GL_ACCUM_ALPHA_BITS* = 0x00000D5B + GL_NAME_STACK_DEPTH* = 0x00000D70 + GL_AUTO_NORMAL* = 0x00000D80 + GL_MAP1_COLOR_4* = 0x00000D90 + GL_MAP1_INDEX* = 0x00000D91 + GL_MAP1_NORMAL* = 0x00000D92 + GL_MAP1_TEXTURE_COORD_1* = 0x00000D93 + GL_MAP1_TEXTURE_COORD_2* = 0x00000D94 + GL_MAP1_TEXTURE_COORD_3* = 0x00000D95 + GL_MAP1_TEXTURE_COORD_4* = 0x00000D96 + GL_MAP1_VERTEX_3* = 0x00000D97 + GL_MAP1_VERTEX_4* = 0x00000D98 + GL_MAP2_COLOR_4* = 0x00000DB0 + GL_MAP2_INDEX* = 0x00000DB1 + GL_MAP2_NORMAL* = 0x00000DB2 + GL_MAP2_TEXTURE_COORD_1* = 0x00000DB3 + GL_MAP2_TEXTURE_COORD_2* = 0x00000DB4 + GL_MAP2_TEXTURE_COORD_3* = 0x00000DB5 + GL_MAP2_TEXTURE_COORD_4* = 0x00000DB6 + GL_MAP2_VERTEX_3* = 0x00000DB7 + GL_MAP2_VERTEX_4* = 0x00000DB8 + GL_MAP1_GRID_DOMAIN* = 0x00000DD0 + GL_MAP1_GRID_SEGMENTS* = 0x00000DD1 + GL_MAP2_GRID_DOMAIN* = 0x00000DD2 + GL_MAP2_GRID_SEGMENTS* = 0x00000DD3 + GL_TEXTURE_1D* = 0x00000DE0 + GL_TEXTURE_2D* = 0x00000DE1 + GL_FEEDBACK_BUFFER_POINTER* = 0x00000DF0 + GL_FEEDBACK_BUFFER_SIZE* = 0x00000DF1 + GL_FEEDBACK_BUFFER_TYPE* = 0x00000DF2 + GL_SELECTION_BUFFER_POINTER* = 0x00000DF3 + GL_SELECTION_BUFFER_SIZE* = 0x00000DF4 # GL_TEXTURE_BINDING_1D + # GL_TEXTURE_BINDING_2D + # GL_VERTEX_ARRAY + # GL_NORMAL_ARRAY + # GL_COLOR_ARRAY + # GL_INDEX_ARRAY + # GL_TEXTURE_COORD_ARRAY + # GL_EDGE_FLAG_ARRAY + # GL_VERTEX_ARRAY_SIZE + # GL_VERTEX_ARRAY_TYPE + # GL_VERTEX_ARRAY_STRIDE + # GL_NORMAL_ARRAY_TYPE + # GL_NORMAL_ARRAY_STRIDE + # GL_COLOR_ARRAY_SIZE + # GL_COLOR_ARRAY_TYPE + # GL_COLOR_ARRAY_STRIDE + # GL_INDEX_ARRAY_TYPE + # GL_INDEX_ARRAY_STRIDE + # GL_TEXTURE_COORD_ARRAY_SIZE + # GL_TEXTURE_COORD_ARRAY_TYPE + # GL_TEXTURE_COORD_ARRAY_STRIDE + # GL_EDGE_FLAG_ARRAY_STRIDE + # GL_POLYGON_OFFSET_FACTOR + # GL_POLYGON_OFFSET_UNITS + # GetTextureParameter + # GL_TEXTURE_MAG_FILTER + # GL_TEXTURE_MIN_FILTER + # GL_TEXTURE_WRAP_S + # GL_TEXTURE_WRAP_T + GL_TEXTURE_WIDTH* = 0x00001000 + GL_TEXTURE_HEIGHT* = 0x00001001 + GL_TEXTURE_INTERNAL_FORMAT* = 0x00001003 + GL_TEXTURE_BORDER_COLOR* = 0x00001004 + GL_TEXTURE_BORDER* = 0x00001005 # GL_TEXTURE_RED_SIZE + # GL_TEXTURE_GREEN_SIZE + # GL_TEXTURE_BLUE_SIZE + # GL_TEXTURE_ALPHA_SIZE + # GL_TEXTURE_LUMINANCE_SIZE + # GL_TEXTURE_INTENSITY_SIZE + # GL_TEXTURE_PRIORITY + # GL_TEXTURE_RESIDENT + # HintMode + GL_DONT_CARE* = 0x00001100 + GL_FASTEST* = 0x00001101 + GL_NICEST* = 0x00001102 # HintTarget + # GL_PERSPECTIVE_CORRECTION_HINT + # GL_POINT_SMOOTH_HINT + # GL_LINE_SMOOTH_HINT + # GL_POLYGON_SMOOTH_HINT + # GL_FOG_HINT + # IndexPointerType + # GL_SHORT + # GL_INT + # GL_FLOAT + # GL_DOUBLE + # LightModelParameter + # GL_LIGHT_MODEL_AMBIENT + # GL_LIGHT_MODEL_LOCAL_VIEWER + # GL_LIGHT_MODEL_TWO_SIDE + # LightName + GL_LIGHT0* = 0x00004000 + GL_LIGHT1* = 0x00004001 + GL_LIGHT2* = 0x00004002 + GL_LIGHT3* = 0x00004003 + GL_LIGHT4* = 0x00004004 + GL_LIGHT5* = 0x00004005 + GL_LIGHT6* = 0x00004006 + GL_LIGHT7* = 0x00004007 # LightParameter + GL_AMBIENT* = 0x00001200 + GL_DIFFUSE* = 0x00001201 + GL_SPECULAR* = 0x00001202 + GL_POSITION* = 0x00001203 + GL_SPOT_DIRECTION* = 0x00001204 + GL_SPOT_EXPONENT* = 0x00001205 + GL_SPOT_CUTOFF* = 0x00001206 + GL_CONSTANT_ATTENUATION* = 0x00001207 + GL_LINEAR_ATTENUATION* = 0x00001208 + GL_QUADRATIC_ATTENUATION* = 0x00001209 # InterleavedArrays + # GL_V2F + # GL_V3F + # GL_C4UB_V2F + # GL_C4UB_V3F + # GL_C3F_V3F + # GL_N3F_V3F + # GL_C4F_N3F_V3F + # GL_T2F_V3F + # GL_T4F_V4F + # GL_T2F_C4UB_V3F + # GL_T2F_C3F_V3F + # GL_T2F_N3F_V3F + # GL_T2F_C4F_N3F_V3F + # GL_T4F_C4F_N3F_V4F + # ListMode + GL_COMPILE* = 0x00001300 + GL_COMPILE_AND_EXECUTE* = 0x00001301 # ListNameType + # GL_BYTE + # GL_UNSIGNED_BYTE + # GL_SHORT + # GL_UNSIGNED_SHORT + # GL_INT + # GL_UNSIGNED_INT + # GL_FLOAT + # GL_2_BYTES + # GL_3_BYTES + # GL_4_BYTES + # LogicOp + constGL_CLEAR* = 0x00001500 + GL_AND* = 0x00001501 + GL_AND_REVERSE* = 0x00001502 + GL_COPY* = 0x00001503 + GL_AND_INVERTED* = 0x00001504 + GL_NOOP* = 0x00001505 + GL_XOR* = 0x00001506 + GL_OR* = 0x00001507 + GL_NOR* = 0x00001508 + GL_EQUIV* = 0x00001509 + GL_INVERT* = 0x0000150A + GL_OR_REVERSE* = 0x0000150B + GL_COPY_INVERTED* = 0x0000150C + GL_OR_INVERTED* = 0x0000150D + GL_NAND* = 0x0000150E + GL_SET* = 0x0000150F # MapTarget + # GL_MAP1_COLOR_4 + # GL_MAP1_INDEX + # GL_MAP1_NORMAL + # GL_MAP1_TEXTURE_COORD_1 + # GL_MAP1_TEXTURE_COORD_2 + # GL_MAP1_TEXTURE_COORD_3 + # GL_MAP1_TEXTURE_COORD_4 + # GL_MAP1_VERTEX_3 + # GL_MAP1_VERTEX_4 + # GL_MAP2_COLOR_4 + # GL_MAP2_INDEX + # GL_MAP2_NORMAL + # GL_MAP2_TEXTURE_COORD_1 + # GL_MAP2_TEXTURE_COORD_2 + # GL_MAP2_TEXTURE_COORD_3 + # GL_MAP2_TEXTURE_COORD_4 + # GL_MAP2_VERTEX_3 + # GL_MAP2_VERTEX_4 + # MaterialFace + # GL_FRONT + # GL_BACK + # GL_FRONT_AND_BACK + # MaterialParameter + GL_EMISSION* = 0x00001600 + GL_SHININESS* = 0x00001601 + GL_AMBIENT_AND_DIFFUSE* = 0x00001602 + GL_COLOR_INDEXES* = 0x00001603 # GL_AMBIENT + # GL_DIFFUSE + # GL_SPECULAR + # MatrixMode + GL_MODELVIEW* = 0x00001700 + GL_PROJECTION* = 0x00001701 + GL_TEXTURE* = 0x00001702 # MeshMode1 + # GL_POINT + # GL_LINE + # MeshMode2 + # GL_POINT + # GL_LINE + # GL_FILL + # NormalPointerType + # GL_BYTE + # GL_SHORT + # GL_INT + # GL_FLOAT + # GL_DOUBLE + # PixelCopyType + GL_COLOR* = 0x00001800 + GL_DEPTH* = 0x00001801 + GL_STENCIL* = 0x00001802 # PixelFormat + GL_COLOR_INDEX* = 0x00001900 + GL_STENCIL_INDEX* = 0x00001901 + GL_DEPTH_COMPONENT* = 0x00001902 + GL_RED* = 0x00001903 + GL_GREEN* = 0x00001904 + GL_BLUE* = 0x00001905 + GL_ALPHA* = 0x00001906 + GL_RGB* = 0x00001907 + GL_RGBA* = 0x00001908 + GL_LUMINANCE* = 0x00001909 + GL_LUMINANCE_ALPHA* = 0x0000190A # PixelMap + # GL_PIXEL_MAP_I_TO_I + # GL_PIXEL_MAP_S_TO_S + # GL_PIXEL_MAP_I_TO_R + # GL_PIXEL_MAP_I_TO_G + # GL_PIXEL_MAP_I_TO_B + # GL_PIXEL_MAP_I_TO_A + # GL_PIXEL_MAP_R_TO_R + # GL_PIXEL_MAP_G_TO_G + # GL_PIXEL_MAP_B_TO_B + # GL_PIXEL_MAP_A_TO_A + # PixelStore + # GL_UNPACK_SWAP_BYTES + # GL_UNPACK_LSB_FIRST + # GL_UNPACK_ROW_LENGTH + # GL_UNPACK_SKIP_ROWS + # GL_UNPACK_SKIP_PIXELS + # GL_UNPACK_ALIGNMENT + # GL_PACK_SWAP_BYTES + # GL_PACK_LSB_FIRST + # GL_PACK_ROW_LENGTH + # GL_PACK_SKIP_ROWS + # GL_PACK_SKIP_PIXELS + # GL_PACK_ALIGNMENT + # PixelTransfer + # GL_MAP_COLOR + # GL_MAP_STENCIL + # GL_INDEX_SHIFT + # GL_INDEX_OFFSET + # GL_RED_SCALE + # GL_RED_BIAS + # GL_GREEN_SCALE + # GL_GREEN_BIAS + # GL_BLUE_SCALE + # GL_BLUE_BIAS + # GL_ALPHA_SCALE + # GL_ALPHA_BIAS + # GL_DEPTH_SCALE + # GL_DEPTH_BIAS + # PixelType + constGL_BITMAP* = 0x00001A00 + GL_POINT* = 0x00001B00 + GL_LINE* = 0x00001B01 + GL_FILL* = 0x00001B02 # ReadBufferMode + # GL_FRONT_LEFT + # GL_FRONT_RIGHT + # GL_BACK_LEFT + # GL_BACK_RIGHT + # GL_FRONT + # GL_BACK + # GL_LEFT + # GL_RIGHT + # GL_AUX0 + # GL_AUX1 + # GL_AUX2 + # GL_AUX3 + # RenderingMode + GL_RENDER* = 0x00001C00 + GL_FEEDBACK* = 0x00001C01 + GL_SELECT* = 0x00001C02 # ShadingModel + GL_FLAT* = 0x00001D00 + GL_SMOOTH* = 0x00001D01 # StencilFunction + # GL_NEVER + # GL_LESS + # GL_EQUAL + # GL_LEQUAL + # GL_GREATER + # GL_NOTEQUAL + # GL_GEQUAL + # GL_ALWAYS + # StencilOp + # GL_ZERO + GL_KEEP* = 0x00001E00 + GL_REPLACE* = 0x00001E01 + GL_INCR* = 0x00001E02 + GL_DECR* = 0x00001E03 # GL_INVERT + # StringName + GL_VENDOR* = 0x00001F00 + GL_RENDERER* = 0x00001F01 + GL_VERSION* = 0x00001F02 + GL_EXTENSIONS* = 0x00001F03 # TextureCoordName + GL_S* = 0x00002000 + GL_T* = 0x00002001 + GL_R* = 0x00002002 + GL_Q* = 0x00002003 # TexCoordPointerType + # GL_SHORT + # GL_INT + # GL_FLOAT + # GL_DOUBLE + # TextureEnvMode + GL_MODULATE* = 0x00002100 + GL_DECAL* = 0x00002101 # GL_BLEND + # GL_REPLACE + # TextureEnvParameter + GL_TEXTURE_ENV_MODE* = 0x00002200 + GL_TEXTURE_ENV_COLOR* = 0x00002201 # TextureEnvTarget + GL_TEXTURE_ENV* = 0x00002300 # TextureGenMode + GL_EYE_LINEAR* = 0x00002400 + GL_OBJECT_LINEAR* = 0x00002401 + GL_SPHERE_MAP* = 0x00002402 # TextureGenParameter + GL_TEXTURE_GEN_MODE* = 0x00002500 + GL_OBJECT_PLANE* = 0x00002501 + GL_EYE_PLANE* = 0x00002502 # TextureMagFilter + GL_NEAREST* = 0x00002600 + GL_LINEAR* = 0x00002601 # TextureMinFilter + # GL_NEAREST + # GL_LINEAR + GL_NEAREST_MIPMAP_NEAREST* = 0x00002700 + GL_LINEAR_MIPMAP_NEAREST* = 0x00002701 + GL_NEAREST_MIPMAP_LINEAR* = 0x00002702 + GL_LINEAR_MIPMAP_LINEAR* = 0x00002703 # TextureParameterName + GL_TEXTURE_MAG_FILTER* = 0x00002800 + GL_TEXTURE_MIN_FILTER* = 0x00002801 + GL_TEXTURE_WRAP_S* = 0x00002802 + GL_TEXTURE_WRAP_T* = 0x00002803 # GL_TEXTURE_BORDER_COLOR + # GL_TEXTURE_PRIORITY + # TextureTarget + # GL_TEXTURE_1D + # GL_TEXTURE_2D + # GL_PROXY_TEXTURE_1D + # GL_PROXY_TEXTURE_2D + # TextureWrapMode + GL_CLAMP* = 0x00002900 + GL_REPEAT* = 0x00002901 # VertexPointerType + # GL_SHORT + # GL_INT + # GL_FLOAT + # GL_DOUBLE + # ClientAttribMask + GL_CLIENT_PIXEL_STORE_BIT* = 0x00000001 + GL_CLIENT_VERTEX_ARRAY_BIT* = 0x00000002 + GL_CLIENT_ALL_ATTRIB_BITS* = 0xFFFFFFFF # polygon_offset + GL_POLYGON_OFFSET_FACTOR* = 0x00008038 + GL_POLYGON_OFFSET_UNITS* = 0x00002A00 + GL_POLYGON_OFFSET_POINT* = 0x00002A01 + GL_POLYGON_OFFSET_LINE* = 0x00002A02 + GL_POLYGON_OFFSET_FILL* = 0x00008037 # texture + GL_ALPHA4* = 0x0000803B + GL_ALPHA8* = 0x0000803C + GL_ALPHA12* = 0x0000803D + GL_ALPHA16* = 0x0000803E + GL_LUMINANCE4* = 0x0000803F + GL_LUMINANCE8* = 0x00008040 + GL_LUMINANCE12* = 0x00008041 + GL_LUMINANCE16* = 0x00008042 + GL_LUMINANCE4_ALPHA4* = 0x00008043 + GL_LUMINANCE6_ALPHA2* = 0x00008044 + GL_LUMINANCE8_ALPHA8* = 0x00008045 + GL_LUMINANCE12_ALPHA4* = 0x00008046 + GL_LUMINANCE12_ALPHA12* = 0x00008047 + GL_LUMINANCE16_ALPHA16* = 0x00008048 + GL_INTENSITY* = 0x00008049 + GL_INTENSITY4* = 0x0000804A + GL_INTENSITY8* = 0x0000804B + GL_INTENSITY12* = 0x0000804C + GL_INTENSITY16* = 0x0000804D + GL_R3_G3_B2* = 0x00002A10 + GL_RGB4* = 0x0000804F + GL_RGB5* = 0x00008050 + GL_RGB8* = 0x00008051 + GL_RGB10* = 0x00008052 + GL_RGB12* = 0x00008053 + GL_RGB16* = 0x00008054 + GL_RGBA2* = 0x00008055 + GL_RGBA4* = 0x00008056 + GL_RGB5_A1* = 0x00008057 + GL_RGBA8* = 0x00008058 + GL_RGB10_A2* = 0x00008059 + GL_RGBA12* = 0x0000805A + GL_RGBA16* = 0x0000805B + GL_TEXTURE_RED_SIZE* = 0x0000805C + GL_TEXTURE_GREEN_SIZE* = 0x0000805D + GL_TEXTURE_BLUE_SIZE* = 0x0000805E + GL_TEXTURE_ALPHA_SIZE* = 0x0000805F + GL_TEXTURE_LUMINANCE_SIZE* = 0x00008060 + GL_TEXTURE_INTENSITY_SIZE* = 0x00008061 + GL_PROXY_TEXTURE_1D* = 0x00008063 + GL_PROXY_TEXTURE_2D* = 0x00008064 # texture_object + GL_TEXTURE_PRIORITY* = 0x00008066 + GL_TEXTURE_RESIDENT* = 0x00008067 + GL_TEXTURE_BINDING_1D* = 0x00008068 + GL_TEXTURE_BINDING_2D* = 0x00008069 # vertex_array + GL_VERTEX_ARRAY* = 0x00008074 + GL_NORMAL_ARRAY* = 0x00008075 + GL_COLOR_ARRAY* = 0x00008076 + GL_INDEX_ARRAY* = 0x00008077 + GL_TEXTURE_COORD_ARRAY* = 0x00008078 + GL_EDGE_FLAG_ARRAY* = 0x00008079 + GL_VERTEX_ARRAY_SIZE* = 0x0000807A + GL_VERTEX_ARRAY_TYPE* = 0x0000807B + GL_VERTEX_ARRAY_STRIDE* = 0x0000807C + GL_NORMAL_ARRAY_TYPE* = 0x0000807E + GL_NORMAL_ARRAY_STRIDE* = 0x0000807F + GL_COLOR_ARRAY_SIZE* = 0x00008081 + GL_COLOR_ARRAY_TYPE* = 0x00008082 + GL_COLOR_ARRAY_STRIDE* = 0x00008083 + GL_INDEX_ARRAY_TYPE* = 0x00008085 + GL_INDEX_ARRAY_STRIDE* = 0x00008086 + GL_TEXTURE_COORD_ARRAY_SIZE* = 0x00008088 + GL_TEXTURE_COORD_ARRAY_TYPE* = 0x00008089 + GL_TEXTURE_COORD_ARRAY_STRIDE* = 0x0000808A + GL_EDGE_FLAG_ARRAY_STRIDE* = 0x0000808C + GL_VERTEX_ARRAY_POINTER* = 0x0000808E + GL_NORMAL_ARRAY_POINTER* = 0x0000808F + GL_COLOR_ARRAY_POINTER* = 0x00008090 + GL_INDEX_ARRAY_POINTER* = 0x00008091 + GL_TEXTURE_COORD_ARRAY_POINTER* = 0x00008092 + GL_EDGE_FLAG_ARRAY_POINTER* = 0x00008093 + GL_V2F* = 0x00002A20 + GL_V3F* = 0x00002A21 + GL_C4UB_V2F* = 0x00002A22 + GL_C4UB_V3F* = 0x00002A23 + GL_C3F_V3F* = 0x00002A24 + GL_N3F_V3F* = 0x00002A25 + GL_C4F_N3F_V3F* = 0x00002A26 + GL_T2F_V3F* = 0x00002A27 + GL_T4F_V4F* = 0x00002A28 + GL_T2F_C4UB_V3F* = 0x00002A29 + GL_T2F_C3F_V3F* = 0x00002A2A + GL_T2F_N3F_V3F* = 0x00002A2B + GL_T2F_C4F_N3F_V3F* = 0x00002A2C + GL_T4F_C4F_N3F_V4F* = 0x00002A2D # Extensions + GL_EXT_vertex_array* = 1 + GL_WIN_swap_hint* = 1 + GL_EXT_bgra* = 1 + GL_EXT_paletted_texture* = 1 # EXT_vertex_array + GL_VERTEX_ARRAY_EXT* = 0x00008074 + GL_NORMAL_ARRAY_EXT* = 0x00008075 + GL_COLOR_ARRAY_EXT* = 0x00008076 + GL_INDEX_ARRAY_EXT* = 0x00008077 + GL_TEXTURE_COORD_ARRAY_EXT* = 0x00008078 + GL_EDGE_FLAG_ARRAY_EXT* = 0x00008079 + GL_VERTEX_ARRAY_SIZE_EXT* = 0x0000807A + GL_VERTEX_ARRAY_TYPE_EXT* = 0x0000807B + GL_VERTEX_ARRAY_STRIDE_EXT* = 0x0000807C + GL_VERTEX_ARRAY_COUNT_EXT* = 0x0000807D + GL_NORMAL_ARRAY_TYPE_EXT* = 0x0000807E + GL_NORMAL_ARRAY_STRIDE_EXT* = 0x0000807F + GL_NORMAL_ARRAY_COUNT_EXT* = 0x00008080 + GL_COLOR_ARRAY_SIZE_EXT* = 0x00008081 + GL_COLOR_ARRAY_TYPE_EXT* = 0x00008082 + GL_COLOR_ARRAY_STRIDE_EXT* = 0x00008083 + GL_COLOR_ARRAY_COUNT_EXT* = 0x00008084 + GL_INDEX_ARRAY_TYPE_EXT* = 0x00008085 + GL_INDEX_ARRAY_STRIDE_EXT* = 0x00008086 + GL_INDEX_ARRAY_COUNT_EXT* = 0x00008087 + GL_TEXTURE_COORD_ARRAY_SIZE_EXT* = 0x00008088 + GL_TEXTURE_COORD_ARRAY_TYPE_EXT* = 0x00008089 + GL_TEXTURE_COORD_ARRAY_STRIDE_EXT* = 0x0000808A + GL_TEXTURE_COORD_ARRAY_COUNT_EXT* = 0x0000808B + GL_EDGE_FLAG_ARRAY_STRIDE_EXT* = 0x0000808C + GL_EDGE_FLAG_ARRAY_COUNT_EXT* = 0x0000808D + GL_VERTEX_ARRAY_POINTER_EXT* = 0x0000808E + GL_NORMAL_ARRAY_POINTER_EXT* = 0x0000808F + GL_COLOR_ARRAY_POINTER_EXT* = 0x00008090 + GL_INDEX_ARRAY_POINTER_EXT* = 0x00008091 + GL_TEXTURE_COORD_ARRAY_POINTER_EXT* = 0x00008092 + GL_EDGE_FLAG_ARRAY_POINTER_EXT* = 0x00008093 + GL_DOUBLE_EXT* = GL_DOUBLE # EXT_bgra + GL_BGR_EXT* = 0x000080E0 + GL_BGRA_EXT* = 0x000080E1 # EXT_paletted_texture + # These must match the GL_COLOR_TABLE_*_SGI enumerants + GL_COLOR_TABLE_FORMAT_EXT* = 0x000080D8 + GL_COLOR_TABLE_WIDTH_EXT* = 0x000080D9 + GL_COLOR_TABLE_RED_SIZE_EXT* = 0x000080DA + GL_COLOR_TABLE_GREEN_SIZE_EXT* = 0x000080DB + GL_COLOR_TABLE_BLUE_SIZE_EXT* = 0x000080DC + GL_COLOR_TABLE_ALPHA_SIZE_EXT* = 0x000080DD + GL_COLOR_TABLE_LUMINANCE_SIZE_EXT* = 0x000080DE + GL_COLOR_TABLE_INTENSITY_SIZE_EXT* = 0x000080DF + GL_COLOR_INDEX1_EXT* = 0x000080E2 + GL_COLOR_INDEX2_EXT* = 0x000080E3 + GL_COLOR_INDEX4_EXT* = 0x000080E4 + GL_COLOR_INDEX8_EXT* = 0x000080E5 + GL_COLOR_INDEX12_EXT* = 0x000080E6 + GL_COLOR_INDEX16_EXT* = 0x000080E7 # For compatibility with OpenGL v1.0 + constGL_LOGIC_OP* = GL_INDEX_LOGIC_OP + GL_TEXTURE_COMPONENTS* = GL_TEXTURE_INTERNAL_FORMAT + +proc glAccum*(op: TGLenum, value: TGLfloat){.dynlib: dllname, importc: "glAccum".} +proc glAlphaFunc*(fun: TGLenum, theref: TGLclampf){.dynlib: dllname, + importc: "glAlphaFunc".} +proc glAreTexturesResident*(n: TGLsizei, textures: PGLuint, + residences: PGLboolean): TGLboolean{. + dynlib: dllname, importc: "glAreTexturesResident".} +proc glArrayElement*(i: TGLint){.dynlib: dllname, importc: "glArrayElement".} +proc glBegin*(mode: TGLenum){.dynlib: dllname, importc: "glBegin".} +proc glBindTexture*(target: TGLenum, texture: TGLuint){.dynlib: dllname, + importc: "glBindTexture".} +proc glBitmap*(width, height: TGLsizei, xorig, yorig: TGLfloat, + xmove, ymove: TGLfloat, bitmap: PGLubyte){.dynlib: dllname, + importc: "glBitmap".} +proc glBlendFunc*(sfactor, dfactor: TGLenum){.dynlib: dllname, + importc: "glBlendFunc".} +proc glCallList*(list: TGLuint){.dynlib: dllname, importc: "glCallList".} +proc glCallLists*(n: TGLsizei, atype: TGLenum, lists: pointer){.dynlib: dllname, + importc: "glCallLists".} +proc glClear*(mask: TGLbitfield){.dynlib: dllname, importc: "glClear".} +proc glClearAccum*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, + importc: "glClearAccum".} +proc glClearColor*(red, green, blue, alpha: TGLclampf){.dynlib: dllname, + importc: "glClearColor".} +proc glClearDepth*(depth: TGLclampd){.dynlib: dllname, importc: "glClearDepth".} +proc glClearIndex*(c: TGLfloat){.dynlib: dllname, importc: "glClearIndex".} +proc glClearStencil*(s: TGLint){.dynlib: dllname, importc: "glClearStencil".} +proc glClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, + importc: "glClipPlane".} +proc glColor3b*(red, green, blue: TGlbyte){.dynlib: dllname, + importc: "glColor3b".} +proc glColor3bv*(v: PGLbyte){.dynlib: dllname, importc: "glColor3bv".} +proc glColor3d*(red, green, blue: TGLdouble){.dynlib: dllname, + importc: "glColor3d".} +proc glColor3dv*(v: PGLdouble){.dynlib: dllname, importc: "glColor3dv".} +proc glColor3f*(red, green, blue: TGLfloat){.dynlib: dllname, + importc: "glColor3f".} +proc glColor3fv*(v: PGLfloat){.dynlib: dllname, importc: "glColor3fv".} +proc glColor3i*(red, green, blue: TGLint){.dynlib: dllname, importc: "glColor3i".} +proc glColor3iv*(v: PGLint){.dynlib: dllname, importc: "glColor3iv".} +proc glColor3s*(red, green, blue: TGLshort){.dynlib: dllname, + importc: "glColor3s".} +proc glColor3sv*(v: PGLshort){.dynlib: dllname, importc: "glColor3sv".} +proc glColor3ub*(red, green, blue: TGLubyte){.dynlib: dllname, + importc: "glColor3ub".} +proc glColor3ubv*(v: PGLubyte){.dynlib: dllname, importc: "glColor3ubv".} +proc glColor3ui*(red, green, blue: TGLuint){.dynlib: dllname, + importc: "glColor3ui".} +proc glColor3uiv*(v: PGLuint){.dynlib: dllname, importc: "glColor3uiv".} +proc glColor3us*(red, green, blue: TGLushort){.dynlib: dllname, + importc: "glColor3us".} +proc glColor3usv*(v: PGLushort){.dynlib: dllname, importc: "glColor3usv".} +proc glColor4b*(red, green, blue, alpha: TGlbyte){.dynlib: dllname, + importc: "glColor4b".} +proc glColor4bv*(v: PGLbyte){.dynlib: dllname, importc: "glColor4bv".} +proc glColor4d*(red, green, blue, alpha: TGLdouble){.dynlib: dllname, + importc: "glColor4d".} +proc glColor4dv*(v: PGLdouble){.dynlib: dllname, importc: "glColor4dv".} +proc glColor4f*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, + importc: "glColor4f".} +proc glColor4fv*(v: PGLfloat){.dynlib: dllname, importc: "glColor4fv".} +proc glColor4i*(red, green, blue, alpha: TGLint){.dynlib: dllname, + importc: "glColor4i".} +proc glColor4iv*(v: PGLint){.dynlib: dllname, importc: "glColor4iv".} +proc glColor4s*(red, green, blue, alpha: TGLshort){.dynlib: dllname, + importc: "glColor4s".} +proc glColor4sv*(v: PGLshort){.dynlib: dllname, importc: "glColor4sv".} +proc glColor4ub*(red, green, blue, alpha: TGLubyte){.dynlib: dllname, + importc: "glColor4ub".} +proc glColor4ubv*(v: PGLubyte){.dynlib: dllname, importc: "glColor4ubv".} +proc glColor4ui*(red, green, blue, alpha: TGLuint){.dynlib: dllname, + importc: "glColor4ui".} +proc glColor4uiv*(v: PGLuint){.dynlib: dllname, importc: "glColor4uiv".} +proc glColor4us*(red, green, blue, alpha: TGLushort){.dynlib: dllname, + importc: "glColor4us".} +proc glColor4usv*(v: PGLushort){.dynlib: dllname, importc: "glColor4usv".} +proc glColorMask*(red, green, blue, alpha: TGLboolean){.dynlib: dllname, + importc: "glColorMask".} +proc glColorMaterial*(face, mode: TGLenum){.dynlib: dllname, + importc: "glColorMaterial".} +proc glColorPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, + p: pointer){.dynlib: dllname, + importc: "glColorPointer".} +proc glCopyPixels*(x, y: TGLint, width, height: TGLsizei, atype: TGLenum){. + dynlib: dllname, importc: "glCopyPixels".} +proc glCopyTexImage1D*(target: TGLenum, level: TGLint, internalFormat: TGLenum, + x, y: TGLint, width: TGLsizei, border: TGLint){. + dynlib: dllname, importc: "glCopyTexImage1D".} +proc glCopyTexImage2D*(target: TGLenum, level: TGLint, internalFormat: TGLenum, + x, y: TGLint, width, height: TGLsizei, border: TGLint){. + dynlib: dllname, importc: "glCopyTexImage2D".} +proc glCopyTexSubImage1D*(target: TGLenum, level, xoffset, x, y: TGLint, + width: TGLsizei){.dynlib: dllname, + importc: "glCopyTexSubImage1D".} +proc glCopyTexSubImage2D*(target: TGLenum, + level, xoffset, yoffset, x, y: TGLint, + width, height: TGLsizei){.dynlib: dllname, + importc: "glCopyTexSubImage2D".} +proc glCullFace*(mode: TGLenum){.dynlib: dllname, importc: "glCullFace".} +proc glDeleteLists*(list: TGLuint, range: TGLsizei){.dynlib: dllname, + importc: "glDeleteLists".} +proc glDeleteTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, + importc: "glDeleteTextures".} +proc glDepthFunc*(fun: TGLenum){.dynlib: dllname, importc: "glDepthFunc".} +proc glDepthMask*(flag: TGLboolean){.dynlib: dllname, importc: "glDepthMask".} +proc glDepthRange*(zNear, zFar: TGLclampd){.dynlib: dllname, + importc: "glDepthRange".} +proc glDisable*(cap: TGLenum){.dynlib: dllname, importc: "glDisable".} +proc glDisableClientState*(aarray: TGLenum){.dynlib: dllname, + importc: "glDisableClientState".} +proc glDrawArrays*(mode: TGLenum, first: TGLint, count: TGLsizei){. + dynlib: dllname, importc: "glDrawArrays".} +proc glDrawBuffer*(mode: TGLenum){.dynlib: dllname, importc: "glDrawBuffer".} +proc glDrawElements*(mode: TGLenum, count: TGLsizei, atype: TGLenum, + indices: pointer){.dynlib: dllname, + importc: "glDrawElements".} +proc glDrawPixels*(width, height: TGLsizei, format, atype: TGLenum, + pixels: pointer){.dynlib: dllname, importc: "glDrawPixels".} +proc glEdgeFlag*(flag: TGLboolean){.dynlib: dllname, importc: "glEdgeFlag".} +proc glEdgeFlagPointer*(stride: TGLsizei, p: pointer){.dynlib: dllname, + importc: "glEdgeFlagPointer".} +proc glEdgeFlagv*(flag: PGLboolean){.dynlib: dllname, importc: "glEdgeFlagv".} +proc glEnable*(cap: TGLenum){.dynlib: dllname, importc: "glEnable".} +proc glEnableClientState*(aarray: TGLenum){.dynlib: dllname, + importc: "glEnableClientState".} +proc glEnd*(){.dynlib: dllname, importc: "glEnd".} +proc glEndList*(){.dynlib: dllname, importc: "glEndList".} +proc glEvalCoord1d*(u: TGLdouble){.dynlib: dllname, importc: "glEvalCoord1d".} +proc glEvalCoord1dv*(u: PGLdouble){.dynlib: dllname, importc: "glEvalCoord1dv".} +proc glEvalCoord1f*(u: TGLfloat){.dynlib: dllname, importc: "glEvalCoord1f".} +proc glEvalCoord1fv*(u: PGLfloat){.dynlib: dllname, importc: "glEvalCoord1fv".} +proc glEvalCoord2d*(u, v: TGLdouble){.dynlib: dllname, importc: "glEvalCoord2d".} +proc glEvalCoord2dv*(u: PGLdouble){.dynlib: dllname, importc: "glEvalCoord2dv".} +proc glEvalCoord2f*(u, v: TGLfloat){.dynlib: dllname, importc: "glEvalCoord2f".} +proc glEvalCoord2fv*(u: PGLfloat){.dynlib: dllname, importc: "glEvalCoord2fv".} +proc glEvalMesh1*(mode: TGLenum, i1, i2: TGLint){.dynlib: dllname, + importc: "glEvalMesh1".} +proc glEvalMesh2*(mode: TGLenum, i1, i2, j1, j2: TGLint){.dynlib: dllname, + importc: "glEvalMesh2".} +proc glEvalPoint1*(i: TGLint){.dynlib: dllname, importc: "glEvalPoint1".} +proc glEvalPoint2*(i, j: TGLint){.dynlib: dllname, importc: "glEvalPoint2".} +proc glFeedbackBuffer*(size: TGLsizei, atype: TGLenum, buffer: PGLfloat){. + dynlib: dllname, importc: "glFeedbackBuffer".} +proc glFinish*(){.dynlib: dllname, importc: "glFinish".} +proc glFlush*(){.dynlib: dllname, importc: "glFlush".} +proc glFogf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glFogf".} +proc glFogfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glFogfv".} +proc glFogi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glFogi".} +proc glFogiv*(pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glFogiv".} +proc glFrontFace*(mode: TGLenum){.dynlib: dllname, importc: "glFrontFace".} +proc glFrustum*(left, right, bottom, top, zNear, zFar: TGLdouble){. + dynlib: dllname, importc: "glFrustum".} +proc glGenLists*(range: TGLsizei): TGLuint{.dynlib: dllname, + importc: "glGenLists".} +proc glGenTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, + importc: "glGenTextures".} +proc glGetBooleanv*(pname: TGLenum, params: PGLboolean){.dynlib: dllname, + importc: "glGetBooleanv".} +proc glGetClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, + importc: "glGetClipPlane".} +proc glGetDoublev*(pname: TGLenum, params: PGLdouble){.dynlib: dllname, + importc: "glGetDoublev".} +proc glGetError*(): TGLenum{.dynlib: dllname, importc: "glGetError".} +proc glGetFloatv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glGetFloatv".} +proc glGetIntegerv*(pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glGetIntegerv".} +proc glGetLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glGetLightfv".} +proc glGetLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glGetLightiv".} +proc glGetMapdv*(target, query: TGLenum, v: PGLdouble){.dynlib: dllname, + importc: "glGetMapdv".} +proc glGetMapfv*(target, query: TGLenum, v: PGLfloat){.dynlib: dllname, + importc: "glGetMapfv".} +proc glGetMapiv*(target, query: TGLenum, v: PGLint){.dynlib: dllname, + importc: "glGetMapiv".} +proc glGetMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glGetMaterialfv".} +proc glGetMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glGetMaterialiv".} +proc glGetPixelMapfv*(map: TGLenum, values: PGLfloat){.dynlib: dllname, + importc: "glGetPixelMapfv".} +proc glGetPixelMapuiv*(map: TGLenum, values: PGLuint){.dynlib: dllname, + importc: "glGetPixelMapuiv".} +proc glGetPixelMapusv*(map: TGLenum, values: PGLushort){.dynlib: dllname, + importc: "glGetPixelMapusv".} +proc glGetPointerv*(pname: TGLenum, params: pointer){.dynlib: dllname, + importc: "glGetPointerv".} +proc glGetPolygonStipple*(mask: PGLubyte){.dynlib: dllname, + importc: "glGetPolygonStipple".} +proc glGetString*(name: TGLenum): cstring{.dynlib: dllname, + importc: "glGetString".} +proc glGetTexEnvfv*(target, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glGetTexEnvfv".} +proc glGetTexEnviv*(target, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glGetTexEnviv".} +proc glGetTexGendv*(coord, pname: TGLenum, params: PGLdouble){.dynlib: dllname, + importc: "glGetTexGendv".} +proc glGetTexGenfv*(coord, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glGetTexGenfv".} +proc glGetTexGeniv*(coord, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glGetTexGeniv".} +proc glGetTexImage*(target: TGLenum, level: TGLint, format: TGLenum, + atype: TGLenum, pixels: pointer){.dynlib: dllname, + importc: "glGetTexImage".} +proc glGetTexLevelParameterfv*(target: TGLenum, level: TGLint, pname: TGLenum, + params: pointer){.dynlib: dllname, + importc: "glGetTexLevelParameterfv".} +proc glGetTexLevelParameteriv*(target: TGLenum, level: TGLint, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetTexLevelParameteriv".} +proc glGetTexParameterfv*(target, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetTexParameterfv".} +proc glGetTexParameteriv*(target, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetTexParameteriv".} +proc glHint*(target, mode: TGLenum){.dynlib: dllname, importc: "glHint".} +proc glIndexMask*(mask: TGLuint){.dynlib: dllname, importc: "glIndexMask".} +proc glIndexPointer*(atype: TGLenum, stride: TGLsizei, p: pointer){. + dynlib: dllname, importc: "glIndexPointer".} +proc glIndexd*(c: TGLdouble){.dynlib: dllname, importc: "glIndexd".} +proc glIndexdv*(c: PGLdouble){.dynlib: dllname, importc: "glIndexdv".} +proc glIndexf*(c: TGLfloat){.dynlib: dllname, importc: "glIndexf".} +proc glIndexfv*(c: PGLfloat){.dynlib: dllname, importc: "glIndexfv".} +proc glIndexi*(c: TGLint){.dynlib: dllname, importc: "glIndexi".} +proc glIndexiv*(c: PGLint){.dynlib: dllname, importc: "glIndexiv".} +proc glIndexs*(c: TGLshort){.dynlib: dllname, importc: "glIndexs".} +proc glIndexsv*(c: PGLshort){.dynlib: dllname, importc: "glIndexsv".} +proc glIndexub*(c: TGLubyte){.dynlib: dllname, importc: "glIndexub".} +proc glIndexubv*(c: PGLubyte){.dynlib: dllname, importc: "glIndexubv".} +proc glInitNames*(){.dynlib: dllname, importc: "glInitNames".} +proc glInterleavedArrays*(format: TGLenum, stride: TGLsizei, p: pointer){. + dynlib: dllname, importc: "glInterleavedArrays".} +proc glIsEnabled*(cap: TGLenum): TGLboolean{.dynlib: dllname, + importc: "glIsEnabled".} +proc glIsList*(list: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsList".} +proc glIsTexture*(texture: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsTexture".} +proc glLightModelf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glLightModelf".} +proc glLightModelfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glLightModelfv".} +proc glLightModeli*(pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glLightModeli".} +proc glLightModeliv*(pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glLightModeliv".} +proc glLightf*(light, pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glLightf".} +proc glLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glLightfv".} +proc glLighti*(light, pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glLighti".} +proc glLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glLightiv".} +proc glLineStipple*(factor: TGLint, pattern: TGLushort){.dynlib: dllname, + importc: "glLineStipple".} +proc glLineWidth*(width: TGLfloat){.dynlib: dllname, importc: "glLineWidth".} +proc glListBase*(base: TGLuint){.dynlib: dllname, importc: "glListBase".} +proc glLoadIdentity*(){.dynlib: dllname, importc: "glLoadIdentity".} +proc glLoadMatrixd*(m: PGLdouble){.dynlib: dllname, importc: "glLoadMatrixd".} +proc glLoadMatrixf*(m: PGLfloat){.dynlib: dllname, importc: "glLoadMatrixf".} +proc glLoadName*(name: TGLuint){.dynlib: dllname, importc: "glLoadName".} +proc glLogicOp*(opcode: TGLenum){.dynlib: dllname, importc: "glLogicOp".} +proc glMap1d*(target: TGLenum, u1, u2: TGLdouble, stride, order: TGLint, + points: PGLdouble){.dynlib: dllname, importc: "glMap1d".} +proc glMap1f*(target: TGLenum, u1, u2: TGLfloat, stride, order: TGLint, + points: PGLfloat){.dynlib: dllname, importc: "glMap1f".} +proc glMap2d*(target: TGLenum, u1, u2: TGLdouble, ustride, uorder: TGLint, + v1, v2: TGLdouble, vstride, vorder: TGLint, points: PGLdouble){. + dynlib: dllname, importc: "glMap2d".} +proc glMap2f*(target: TGLenum, u1, u2: TGLfloat, ustride, uorder: TGLint, + v1, v2: TGLfloat, vstride, vorder: TGLint, points: PGLfloat){. + dynlib: dllname, importc: "glMap2f".} +proc glMapGrid1d*(un: TGLint, u1, u2: TGLdouble){.dynlib: dllname, + importc: "glMapGrid1d".} +proc glMapGrid1f*(un: TGLint, u1, u2: TGLfloat){.dynlib: dllname, + importc: "glMapGrid1f".} +proc glMapGrid2d*(un: TGLint, u1, u2: TGLdouble, vn: TGLint, v1, v2: TGLdouble){. + dynlib: dllname, importc: "glMapGrid2d".} +proc glMapGrid2f*(un: TGLint, u1, u2: TGLfloat, vn: TGLint, v1, v2: TGLfloat){. + dynlib: dllname, importc: "glMapGrid2f".} +proc glMaterialf*(face, pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glMaterialf".} +proc glMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glMaterialfv".} +proc glMateriali*(face, pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glMateriali".} +proc glMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glMaterialiv".} +proc glMatrixMode*(mode: TGLenum){.dynlib: dllname, importc: "glMatrixMode".} +proc glMultMatrixd*(m: PGLdouble){.dynlib: dllname, importc: "glMultMatrixd".} +proc glMultMatrixf*(m: PGLfloat){.dynlib: dllname, importc: "glMultMatrixf".} +proc glNewList*(list: TGLuint, mode: TGLenum){.dynlib: dllname, + importc: "glNewList".} +proc glNormal3b*(nx, ny, nz: TGlbyte){.dynlib: dllname, importc: "glNormal3b".} +proc glNormal3bv*(v: PGLbyte){.dynlib: dllname, importc: "glNormal3bv".} +proc glNormal3d*(nx, ny, nz: TGLdouble){.dynlib: dllname, importc: "glNormal3d".} +proc glNormal3dv*(v: PGLdouble){.dynlib: dllname, importc: "glNormal3dv".} +proc glNormal3f*(nx, ny, nz: TGLfloat){.dynlib: dllname, importc: "glNormal3f".} +proc glNormal3fv*(v: PGLfloat){.dynlib: dllname, importc: "glNormal3fv".} +proc glNormal3i*(nx, ny, nz: TGLint){.dynlib: dllname, importc: "glNormal3i".} +proc glNormal3iv*(v: PGLint){.dynlib: dllname, importc: "glNormal3iv".} +proc glNormal3s*(nx, ny, nz: TGLshort){.dynlib: dllname, importc: "glNormal3s".} +proc glNormal3sv*(v: PGLshort){.dynlib: dllname, importc: "glNormal3sv".} +proc glNormalPointer*(atype: TGLenum, stride: TGLsizei, p: pointer){. + dynlib: dllname, importc: "glNormalPointer".} +proc glOrtho*(left, right, bottom, top, zNear, zFar: TGLdouble){. + dynlib: dllname, importc: "glOrtho".} +proc glPassThrough*(token: TGLfloat){.dynlib: dllname, importc: "glPassThrough".} +proc glPixelMapfv*(map: TGLenum, mapsize: TGLsizei, values: PGLfloat){. + dynlib: dllname, importc: "glPixelMapfv".} +proc glPixelMapuiv*(map: TGLenum, mapsize: TGLsizei, values: PGLuint){. + dynlib: dllname, importc: "glPixelMapuiv".} +proc glPixelMapusv*(map: TGLenum, mapsize: TGLsizei, values: PGLushort){. + dynlib: dllname, importc: "glPixelMapusv".} +proc glPixelStoref*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glPixelStoref".} +proc glPixelStorei*(pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glPixelStorei".} +proc glPixelTransferf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glPixelTransferf".} +proc glPixelTransferi*(pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glPixelTransferi".} +proc glPixelZoom*(xfactor, yfactor: TGLfloat){.dynlib: dllname, + importc: "glPixelZoom".} +proc glPointSize*(size: TGLfloat){.dynlib: dllname, importc: "glPointSize".} +proc glPolygonMode*(face, mode: TGLenum){.dynlib: dllname, + importc: "glPolygonMode".} +proc glPolygonOffset*(factor, units: TGLfloat){.dynlib: dllname, + importc: "glPolygonOffset".} +proc glPolygonStipple*(mask: PGLubyte){.dynlib: dllname, + importc: "glPolygonStipple".} +proc glPopAttrib*(){.dynlib: dllname, importc: "glPopAttrib".} +proc glPopClientAttrib*(){.dynlib: dllname, importc: "glPopClientAttrib".} +proc glPopMatrix*(){.dynlib: dllname, importc: "glPopMatrix".} +proc glPopName*(){.dynlib: dllname, importc: "glPopName".} +proc glPrioritizeTextures*(n: TGLsizei, textures: PGLuint, priorities: PGLclampf){. + dynlib: dllname, importc: "glPrioritizeTextures".} +proc glPushAttrib*(mask: TGLbitfield){.dynlib: dllname, importc: "glPushAttrib".} +proc glPushClientAttrib*(mask: TGLbitfield){.dynlib: dllname, + importc: "glPushClientAttrib".} +proc glPushMatrix*(){.dynlib: dllname, importc: "glPushMatrix".} +proc glPushName*(name: TGLuint){.dynlib: dllname, importc: "glPushName".} +proc glRasterPos2d*(x, y: TGLdouble){.dynlib: dllname, importc: "glRasterPos2d".} +proc glRasterPos2dv*(v: PGLdouble){.dynlib: dllname, importc: "glRasterPos2dv".} +proc glRasterPos2f*(x, y: TGLfloat){.dynlib: dllname, importc: "glRasterPos2f".} +proc glRasterPos2fv*(v: PGLfloat){.dynlib: dllname, importc: "glRasterPos2fv".} +proc glRasterPos2i*(x, y: TGLint){.dynlib: dllname, importc: "glRasterPos2i".} +proc glRasterPos2iv*(v: PGLint){.dynlib: dllname, importc: "glRasterPos2iv".} +proc glRasterPos2s*(x, y: TGLshort){.dynlib: dllname, importc: "glRasterPos2s".} +proc glRasterPos2sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos2sv".} +proc glRasterPos3d*(x, y, z: TGLdouble){.dynlib: dllname, + importc: "glRasterPos3d".} +proc glRasterPos3dv*(v: PGLdouble){.dynlib: dllname, importc: "glRasterPos3dv".} +proc glRasterPos3f*(x, y, z: TGLfloat){.dynlib: dllname, + importc: "glRasterPos3f".} +proc glRasterPos3fv*(v: PGLfloat){.dynlib: dllname, importc: "glRasterPos3fv".} +proc glRasterPos3i*(x, y, z: TGLint){.dynlib: dllname, importc: "glRasterPos3i".} +proc glRasterPos3iv*(v: PGLint){.dynlib: dllname, importc: "glRasterPos3iv".} +proc glRasterPos3s*(x, y, z: TGLshort){.dynlib: dllname, + importc: "glRasterPos3s".} +proc glRasterPos3sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos3sv".} +proc glRasterPos4d*(x, y, z, w: TGLdouble){.dynlib: dllname, + importc: "glRasterPos4d".} +proc glRasterPos4dv*(v: PGLdouble){.dynlib: dllname, importc: "glRasterPos4dv".} +proc glRasterPos4f*(x, y, z, w: TGLfloat){.dynlib: dllname, + importc: "glRasterPos4f".} +proc glRasterPos4fv*(v: PGLfloat){.dynlib: dllname, importc: "glRasterPos4fv".} +proc glRasterPos4i*(x, y, z, w: TGLint){.dynlib: dllname, + importc: "glRasterPos4i".} +proc glRasterPos4iv*(v: PGLint){.dynlib: dllname, importc: "glRasterPos4iv".} +proc glRasterPos4s*(x, y, z, w: TGLshort){.dynlib: dllname, + importc: "glRasterPos4s".} +proc glRasterPos4sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos4sv".} +proc glReadBuffer*(mode: TGLenum){.dynlib: dllname, importc: "glReadBuffer".} +proc glReadPixels*(x, y: TGLint, width, height: TGLsizei, + format, atype: TGLenum, pixels: pointer){.dynlib: dllname, + importc: "glReadPixels".} +proc glRectd*(x1, y1, x2, y2: TGLdouble){.dynlib: dllname, importc: "glRectd".} +proc glRectdv*(v1: PGLdouble, v2: PGLdouble){.dynlib: dllname, + importc: "glRectdv".} +proc glRectf*(x1, y1, x2, y2: TGLfloat){.dynlib: dllname, importc: "glRectf".} +proc glRectfv*(v1: PGLfloat, v2: PGLfloat){.dynlib: dllname, importc: "glRectfv".} +proc glRecti*(x1, y1, x2, y2: TGLint){.dynlib: dllname, importc: "glRecti".} +proc glRectiv*(v1: PGLint, v2: PGLint){.dynlib: dllname, importc: "glRectiv".} +proc glRects*(x1, y1, x2, y2: TGLshort){.dynlib: dllname, importc: "glRects".} +proc glRectsv*(v1: PGLshort, v2: PGLshort){.dynlib: dllname, importc: "glRectsv".} +proc glRenderMode*(mode: TGLint): TGLint{.dynlib: dllname, + importc: "glRenderMode".} +proc glRotated*(angle, x, y, z: TGLdouble){.dynlib: dllname, + importc: "glRotated".} +proc glRotatef*(angle, x, y, z: TGLfloat){.dynlib: dllname, importc: "glRotatef".} +proc glScaled*(x, y, z: TGLdouble){.dynlib: dllname, importc: "glScaled".} +proc glScalef*(x, y, z: TGLfloat){.dynlib: dllname, importc: "glScalef".} +proc glScissor*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, + importc: "glScissor".} +proc glSelectBuffer*(size: TGLsizei, buffer: PGLuint){.dynlib: dllname, + importc: "glSelectBuffer".} +proc glShadeModel*(mode: TGLenum){.dynlib: dllname, importc: "glShadeModel".} +proc glStencilFunc*(fun: TGLenum, theref: TGLint, mask: TGLuint){. + dynlib: dllname, importc: "glStencilFunc".} +proc glStencilMask*(mask: TGLuint){.dynlib: dllname, importc: "glStencilMask".} +proc glStencilOp*(fail, zfail, zpass: TGLenum){.dynlib: dllname, + importc: "glStencilOp".} +proc glTexCoord1d*(s: TGLdouble){.dynlib: dllname, importc: "glTexCoord1d".} +proc glTexCoord1dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord1dv".} +proc glTexCoord1f*(s: TGLfloat){.dynlib: dllname, importc: "glTexCoord1f".} +proc glTexCoord1fv*(v: PGLfloat){.dynlib: dllname, importc: "glTexCoord1fv".} +proc glTexCoord1i*(s: TGLint){.dynlib: dllname, importc: "glTexCoord1i".} +proc glTexCoord1iv*(v: PGLint){.dynlib: dllname, importc: "glTexCoord1iv".} +proc glTexCoord1s*(s: TGLshort){.dynlib: dllname, importc: "glTexCoord1s".} +proc glTexCoord1sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord1sv".} +proc glTexCoord2d*(s, t: TGLdouble){.dynlib: dllname, importc: "glTexCoord2d".} +proc glTexCoord2dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord2dv".} +proc glTexCoord2f*(s, t: TGLfloat){.dynlib: dllname, importc: "glTexCoord2f".} +proc glTexCoord2fv*(v: PGLfloat){.dynlib: dllname, importc: "glTexCoord2fv".} +proc glTexCoord2i*(s, t: TGLint){.dynlib: dllname, importc: "glTexCoord2i".} +proc glTexCoord2iv*(v: PGLint){.dynlib: dllname, importc: "glTexCoord2iv".} +proc glTexCoord2s*(s, t: TGLshort){.dynlib: dllname, importc: "glTexCoord2s".} +proc glTexCoord2sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord2sv".} +proc glTexCoord3d*(s, t, r: TGLdouble){.dynlib: dllname, importc: "glTexCoord3d".} +proc glTexCoord3dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord3dv".} +proc glTexCoord3f*(s, t, r: TGLfloat){.dynlib: dllname, importc: "glTexCoord3f".} +proc glTexCoord3fv*(v: PGLfloat){.dynlib: dllname, importc: "glTexCoord3fv".} +proc glTexCoord3i*(s, t, r: TGLint){.dynlib: dllname, importc: "glTexCoord3i".} +proc glTexCoord3iv*(v: PGLint){.dynlib: dllname, importc: "glTexCoord3iv".} +proc glTexCoord3s*(s, t, r: TGLshort){.dynlib: dllname, importc: "glTexCoord3s".} +proc glTexCoord3sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord3sv".} +proc glTexCoord4d*(s, t, r, q: TGLdouble){.dynlib: dllname, + importc: "glTexCoord4d".} +proc glTexCoord4dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord4dv".} +proc glTexCoord4f*(s, t, r, q: TGLfloat){.dynlib: dllname, + importc: "glTexCoord4f".} +proc glTexCoord4fv*(v: PGLfloat){.dynlib: dllname, importc: "glTexCoord4fv".} +proc glTexCoord4i*(s, t, r, q: TGLint){.dynlib: dllname, importc: "glTexCoord4i".} +proc glTexCoord4iv*(v: PGLint){.dynlib: dllname, importc: "glTexCoord4iv".} +proc glTexCoord4s*(s, t, r, q: TGLshort){.dynlib: dllname, + importc: "glTexCoord4s".} +proc glTexCoord4sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord4sv".} +proc glTexCoordPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, + p: pointer){.dynlib: dllname, + importc: "glTexCoordPointer".} +proc glTexEnvf*(target: TGLenum, pname: TGLenum, param: TGLfloat){. + dynlib: dllname, importc: "glTexEnvf".} +proc glTexEnvfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glTexEnvfv".} +proc glTexEnvi*(target: TGLenum, pname: TGLenum, param: TGLint){. + dynlib: dllname, importc: "glTexEnvi".} +proc glTexEnviv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glTexEnviv".} +proc glTexGend*(coord: TGLenum, pname: TGLenum, param: TGLdouble){. + dynlib: dllname, importc: "glTexGend".} +proc glTexGendv*(coord: TGLenum, pname: TGLenum, params: PGLdouble){. + dynlib: dllname, importc: "glTexGendv".} +proc glTexGenf*(coord: TGLenum, pname: TGLenum, param: TGLfloat){. + dynlib: dllname, importc: "glTexGenf".} +proc glTexGenfv*(coord: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glTexGenfv".} +proc glTexGeni*(coord: TGLenum, pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glTexGeni".} +proc glTexGeniv*(coord: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glTexGeniv".} +proc glTexImage1D*(target: TGLenum, level, internalformat: TGLint, + width: TGLsizei, border: TGLint, format, atype: TGLenum, + pixels: pointer){.dynlib: dllname, importc: "glTexImage1D".} +proc glTexImage2D*(target: TGLenum, level, internalformat: TGLint, + width, height: TGLsizei, border: TGLint, + format, atype: TGLenum, pixels: pointer){.dynlib: dllname, + importc: "glTexImage2D".} +proc glTexParameterf*(target: TGLenum, pname: TGLenum, param: TGLfloat){. + dynlib: dllname, importc: "glTexParameterf".} +proc glTexParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glTexParameterfv".} +proc glTexParameteri*(target: TGLenum, pname: TGLenum, param: TGLint){. + dynlib: dllname, importc: "glTexParameteri".} +proc glTexParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glTexParameteriv".} +proc glTexSubImage1D*(target: TGLenum, level, xoffset: TGLint, width: TGLsizei, + format, atype: TGLenum, pixels: pointer){.dynlib: dllname, + importc: "glTexSubImage1D".} +proc glTexSubImage2D*(target: TGLenum, level, xoffset, yoffset: TGLint, + width, height: TGLsizei, format, atype: TGLenum, + pixels: pointer){.dynlib: dllname, + importc: "glTexSubImage2D".} +proc glTranslated*(x, y, z: TGLdouble){.dynlib: dllname, importc: "glTranslated".} +proc glTranslatef*(x, y, z: TGLfloat){.dynlib: dllname, importc: "glTranslatef".} +proc glVertex2d*(x, y: TGLdouble){.dynlib: dllname, importc: "glVertex2d".} +proc glVertex2dv*(v: PGLdouble){.dynlib: dllname, importc: "glVertex2dv".} +proc glVertex2f*(x, y: TGLfloat){.dynlib: dllname, importc: "glVertex2f".} +proc glVertex2fv*(v: PGLfloat){.dynlib: dllname, importc: "glVertex2fv".} +proc glVertex2i*(x, y: TGLint){.dynlib: dllname, importc: "glVertex2i".} +proc glVertex2iv*(v: PGLint){.dynlib: dllname, importc: "glVertex2iv".} +proc glVertex2s*(x, y: TGLshort){.dynlib: dllname, importc: "glVertex2s".} +proc glVertex2sv*(v: PGLshort){.dynlib: dllname, importc: "glVertex2sv".} +proc glVertex3d*(x, y, z: TGLdouble){.dynlib: dllname, importc: "glVertex3d".} +proc glVertex3dv*(v: PGLdouble){.dynlib: dllname, importc: "glVertex3dv".} +proc glVertex3f*(x, y, z: TGLfloat){.dynlib: dllname, importc: "glVertex3f".} +proc glVertex3fv*(v: PGLfloat){.dynlib: dllname, importc: "glVertex3fv".} +proc glVertex3i*(x, y, z: TGLint){.dynlib: dllname, importc: "glVertex3i".} +proc glVertex3iv*(v: PGLint){.dynlib: dllname, importc: "glVertex3iv".} +proc glVertex3s*(x, y, z: TGLshort){.dynlib: dllname, importc: "glVertex3s".} +proc glVertex3sv*(v: PGLshort){.dynlib: dllname, importc: "glVertex3sv".} +proc glVertex4d*(x, y, z, w: TGLdouble){.dynlib: dllname, importc: "glVertex4d".} +proc glVertex4dv*(v: PGLdouble){.dynlib: dllname, importc: "glVertex4dv".} +proc glVertex4f*(x, y, z, w: TGLfloat){.dynlib: dllname, importc: "glVertex4f".} +proc glVertex4fv*(v: PGLfloat){.dynlib: dllname, importc: "glVertex4fv".} +proc glVertex4i*(x, y, z, w: TGLint){.dynlib: dllname, importc: "glVertex4i".} +proc glVertex4iv*(v: PGLint){.dynlib: dllname, importc: "glVertex4iv".} +proc glVertex4s*(x, y, z, w: TGLshort){.dynlib: dllname, importc: "glVertex4s".} +proc glVertex4sv*(v: PGLshort){.dynlib: dllname, importc: "glVertex4sv".} +proc glVertexPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, + p: pointer){.dynlib: dllname, + importc: "glVertexPointer".} +proc glViewport*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, + importc: "glViewport".} +type + PFN_GLARRAY_ELEMENT_EXTPROC* = proc (i: TGLint) + PFN_GLDRAW_ARRAYS_EXTPROC* = proc (mode: TGLenum, first: TGLint, + count: TGLsizei) + PFN_GLVERTEX_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, + stride, count: TGLsizei, + p: pointer) + PFN_GLNORMAL_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, + p: pointer) + PFN_GLCOLOR_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, + stride, count: TGLsizei, p: pointer) + PFN_GLINDEX_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, + p: pointer) + PFN_GLTEXCOORD_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, + stride, count: TGLsizei, p: pointer) + PFN_GLEDGEFLAG_POINTER_EXTPROC* = proc (stride, count: TGLsizei, + pointer: PGLboolean) + PFN_GLGET_POINTER_VEXT_PROC* = proc (pname: TGLenum, params: pointer) + PFN_GLARRAY_ELEMENT_ARRAY_EXTPROC* = proc (mode: TGLenum, count: TGLsizei, + pi: pointer) # WIN_swap_hint + PFN_GLADDSWAPHINT_RECT_WINPROC* = proc (x, y: TGLint, width, height: TGLsizei) + PFN_GLCOLOR_TABLE_EXTPROC* = proc (target, internalFormat: TGLenum, + width: TGLsizei, format, atype: TGLenum, + data: pointer) + PFN_GLCOLOR_SUBTABLE_EXTPROC* = proc (target: TGLenum, start, count: TGLsizei, + format, atype: TGLenum, data: pointer) + PFN_GLGETCOLOR_TABLE_EXTPROC* = proc (target, format, atype: TGLenum, + data: pointer) + PFN_GLGETCOLOR_TABLE_PARAMETER_IVEXTPROC* = proc (target, pname: TGLenum, + params: PGLint) + PFN_GLGETCOLOR_TABLE_PARAMETER_FVEXTPROC* = proc (target, pname: TGLenum, + params: PGLfloat) + +{.pop.} +# implementation diff --git a/tests/manyloc/keineschweine/lib/glext.nim b/tests/manyloc/keineschweine/lib/glext.nim new file mode 100644 index 000000000..1e1bdb958 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/glext.nim @@ -0,0 +1,4673 @@ +# +# +# Adaption of the delphi3d.net OpenGL units to FreePascal +# Sebastian Guenther (sg@freepascal.org) in 2002 +# These units are free to use +# +# + +#************************************************* +# * OpenGL extension loading library * +# * Generated by MetaGLext, written by Tom Nuydens * +# * (tom@delphi3d.net -- http://www.delphi3d.net * +# ************************************************* +#*** Generated on 10/11/2002 + +when defined(windows): + {.push, callconv: stdcall.} +else: + {.push, callconv: cdecl.} +import + gl + +type + GLcharARB* = Char + TGLcharARB* = GLcharARB + PGLcharARB* = ptr GLcharARB + GLhandleARB* = int + TGLhandleARB* = GLhandleARB + PGLhandleARB* = ptr GLhandleARB + GLintptr* = int + TGLintptr* = GLintptr + PGLintptr* = ptr GLintptr + GLsizeiptr* = int + TGLsizeiptr* = GLsizeiptr + PGLsizeiptr* = ptr GLsizeiptr + GLchar* = Char + TGLchar* = GLchar + PGLchar* = cstring #***** GL_version_1_2 *****// + +const + GL_UNSIGNED_BYTE_3_3_2* = 0x00008032 + GL_UNSIGNED_SHORT_4_4_4_4* = 0x00008033 + GL_UNSIGNED_SHORT_5_5_5_1* = 0x00008034 + GL_UNSIGNED_INT_8_8_8_8* = 0x00008035 + GL_UNSIGNED_INT_10_10_10_2* = 0x00008036 + GL_RESCALE_NORMAL* = 0x0000803A + GL_UNSIGNED_BYTE_2_3_3_REV* = 0x00008362 + GL_UNSIGNED_SHORT_5_6_5* = 0x00008363 + GL_UNSIGNED_SHORT_5_6_5_REV* = 0x00008364 + GL_UNSIGNED_SHORT_4_4_4_4_REV* = 0x00008365 + GL_UNSIGNED_SHORT_1_5_5_5_REV* = 0x00008366 + GL_UNSIGNED_INT_8_8_8_8_REV* = 0x00008367 + GL_UNSIGNED_INT_2_10_10_10_REV* = 0x00008368 + GL_BGR* = 0x000080E0 + GL_BGRA* = 0x000080E1 + GL_MAX_ELEMENTS_VERTICES* = 0x000080E8 + GL_MAX_ELEMENTS_INDICES* = 0x000080E9 + GL_CLAMP_TO_EDGE* = 0x0000812F + GL_TEXTURE_MIN_LOD* = 0x0000813A + GL_TEXTURE_MAX_LOD* = 0x0000813B + GL_TEXTURE_BASE_LEVEL* = 0x0000813C + GL_TEXTURE_MAX_LEVEL* = 0x0000813D + GL_LIGHT_MODEL_COLOR_CONTROL* = 0x000081F8 + GL_SINGLE_COLOR* = 0x000081F9 + GL_SEPARATE_SPECULAR_COLOR* = 0x000081FA + GL_SMOOTH_POINT_SIZE_RANGE* = 0x00000B12 + GL_SMOOTH_POINT_SIZE_GRANULARITY* = 0x00000B13 + GL_SMOOTH_LINE_WIDTH_RANGE* = 0x00000B22 + GL_SMOOTH_LINE_WIDTH_GRANULARITY* = 0x00000B23 + GL_ALIASED_POINT_SIZE_RANGE* = 0x0000846D + GL_ALIASED_LINE_WIDTH_RANGE* = 0x0000846E + GL_PACK_SKIP_IMAGES* = 0x0000806B + GL_PACK_IMAGE_HEIGHT* = 0x0000806C + GL_UNPACK_SKIP_IMAGES* = 0x0000806D + GL_UNPACK_IMAGE_HEIGHT* = 0x0000806E + GL_TEXTURE_3D* = 0x0000806F + GL_PROXY_TEXTURE_3D* = 0x00008070 + GL_TEXTURE_DEPTH* = 0x00008071 + GL_TEXTURE_WRAP_R* = 0x00008072 + GL_MAX_3D_TEXTURE_SIZE* = 0x00008073 + +proc glBlendColor*(red: TGLclampf, green: TGLclampf, blue: TGLclampf, + alpha: TGLclampf){.dynlib: dllname, importc: "glBlendColor".} +proc glBlendEquation*(mode: TGLenum){.dynlib: dllname, + importc: "glBlendEquation".} +proc glDrawRangeElements*(mode: TGLenum, start: TGLuint, theend: TGLuint, + count: TGLsizei, thetype: TGLenum, indices: PGLvoid){. + dynlib: dllname, importc: "glDrawRangeElements".} +proc glColorTable*(target: TGLenum, internalformat: TGLenum, width: TGLsizei, + format: TGLenum, thetype: TGLenum, table: PGLvoid){. + dynlib: dllname, importc: "glColorTable".} +proc glColorTableParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glColorTableParameterfv".} +proc glColorTableParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glColorTableParameteriv".} +proc glCopyColorTable*(target: TGLenum, internalformat: TGLenum, x: TGLint, + y: TGLint, width: TGLsizei){.dynlib: dllname, + importc: "glCopyColorTable".} +proc glGetColorTable*(target: TGLenum, format: TGLenum, thetype: TGLenum, + table: PGLvoid){.dynlib: dllname, + importc: "glGetColorTable".} +proc glGetColorTableParameterfv*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetColorTableParameterfv".} +proc glGetColorTableParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetColorTableParameteriv".} +proc glColorSubTable*(target: TGLenum, start: TGLsizei, count: TGLsizei, + format: TGLenum, thetype: TGLenum, data: PGLvoid){. + dynlib: dllname, importc: "glColorSubTable".} +proc glCopyColorSubTable*(target: TGLenum, start: TGLsizei, x: TGLint, + y: TGLint, width: TGLsizei){.dynlib: dllname, + importc: "glCopyColorSubTable".} +proc glConvolutionFilter1D*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, format: TGLenum, thetype: TGLenum, + image: PGLvoid){.dynlib: dllname, + importc: "glConvolutionFilter1D".} +proc glConvolutionFilter2D*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, + thetype: TGLenum, image: PGLvoid){.dynlib: dllname, + importc: "glConvolutionFilter2D".} +proc glConvolutionParameterf*(target: TGLenum, pname: TGLenum, params: TGLfloat){. + dynlib: dllname, importc: "glConvolutionParameterf".} +proc glConvolutionParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glConvolutionParameterfv".} +proc glConvolutionParameteri*(target: TGLenum, pname: TGLenum, params: TGLint){. + dynlib: dllname, importc: "glConvolutionParameteri".} +proc glConvolutionParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glConvolutionParameteriv".} +proc glCopyConvolutionFilter1D*(target: TGLenum, internalformat: TGLenum, + x: TGLint, y: TGLint, width: TGLsizei){. + dynlib: dllname, importc: "glCopyConvolutionFilter1D".} +proc glCopyConvolutionFilter2D*(target: TGLenum, internalformat: TGLenum, + x: TGLint, y: TGLint, width: TGLsizei, + height: TGLsizei){.dynlib: dllname, + importc: "glCopyConvolutionFilter2D".} +proc glGetConvolutionFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, + image: PGLvoid){.dynlib: dllname, + importc: "glGetConvolutionFilter".} +proc glGetConvolutionParameterfv*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetConvolutionParameterfv".} +proc glGetConvolutionParameteriv*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetConvolutionParameteriv".} +proc glGetSeparableFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, + row: PGLvoid, column: PGLvoid, span: PGLvoid){. + dynlib: dllname, importc: "glGetSeparableFilter".} +proc glSeparableFilter2D*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, + thetype: TGLenum, row: PGLvoid, column: PGLvoid){. + dynlib: dllname, importc: "glSeparableFilter2D".} +proc glGetHistogram*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, + importc: "glGetHistogram".} +proc glGetHistogramParameterfv*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetHistogramParameterfv".} +proc glGetHistogramParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetHistogramParameteriv".} +proc glGetMinmax*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, + importc: "glGetMinmax".} +proc glGetMinmaxParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetMinmaxParameterfv".} +proc glGetMinmaxParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetMinmaxParameteriv".} +proc glHistogram*(target: TGLenum, width: TGLsizei, internalformat: TGLenum, + sink: TGLboolean){.dynlib: dllname, importc: "glHistogram".} +proc glMinmax*(target: TGLenum, internalformat: TGLenum, sink: TGLboolean){. + dynlib: dllname, importc: "glMinmax".} +proc glResetHistogram*(target: TGLenum){.dynlib: dllname, + importc: "glResetHistogram".} +proc glResetMinmax*(target: TGLenum){.dynlib: dllname, importc: "glResetMinmax".} +proc glTexImage3D*(target: TGLenum, level: TGLint, internalformat: TGLint, + width: TGLsizei, height: TGLsizei, depth: TGLsizei, + border: TGLint, format: TGLenum, thetype: TGLenum, + pixels: PGLvoid){.dynlib: dllname, importc: "glTexImage3D".} +proc glTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, format: TGLenum, + thetype: TGLenum, pixels: PGLvoid){.dynlib: dllname, + importc: "glTexSubImage3D".} +proc glCopyTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, x: TGLint, + y: TGLint, width: TGLsizei, height: TGLsizei){. + dynlib: dllname, importc: "glCopyTexSubImage3D".} +proc glActiveTextureARB*(texture: TGLenum){.dynlib: dllname, + importc: "glActiveTextureARB".} +proc glClientActiveTextureARB*(texture: TGLenum){.dynlib: dllname, + importc: "glClientActiveTextureARB".} +proc glMultiTexCoord1dARB*(target: TGLenum, s: TGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord1dARB".} +proc glMultiTexCoord1dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord1dvARB".} +proc glMultiTexCoord1fARB*(target: TGLenum, s: TGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord1fARB".} +proc glMultiTexCoord1fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord1fvARB".} +proc glMultiTexCoord1iARB*(target: TGLenum, s: TGLint){.dynlib: dllname, + importc: "glMultiTexCoord1iARB".} +proc glMultiTexCoord1ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, + importc: "glMultiTexCoord1ivARB".} +proc glMultiTexCoord1sARB*(target: TGLenum, s: TGLshort){.dynlib: dllname, + importc: "glMultiTexCoord1sARB".} +proc glMultiTexCoord1svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc: "glMultiTexCoord1svARB".} +proc glMultiTexCoord2dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble){. + dynlib: dllname, importc: "glMultiTexCoord2dARB".} +proc glMultiTexCoord2dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord2dvARB".} +proc glMultiTexCoord2fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat){. + dynlib: dllname, importc: "glMultiTexCoord2fARB".} +proc glMultiTexCoord2fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord2fvARB".} +proc glMultiTexCoord2iARB*(target: TGLenum, s: TGLint, t: TGLint){. + dynlib: dllname, importc: "glMultiTexCoord2iARB".} +proc glMultiTexCoord2ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, + importc: "glMultiTexCoord2ivARB".} +proc glMultiTexCoord2sARB*(target: TGLenum, s: TGLshort, t: TGLshort){. + dynlib: dllname, importc: "glMultiTexCoord2sARB".} +proc glMultiTexCoord2svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc: "glMultiTexCoord2svARB".} +proc glMultiTexCoord3dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, + r: TGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord3dARB".} +proc glMultiTexCoord3dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord3dvARB".} +proc glMultiTexCoord3fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, + r: TGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord3fARB".} +proc glMultiTexCoord3fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord3fvARB".} +proc glMultiTexCoord3iARB*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint){. + dynlib: dllname, importc: "glMultiTexCoord3iARB".} +proc glMultiTexCoord3ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, + importc: "glMultiTexCoord3ivARB".} +proc glMultiTexCoord3sARB*(target: TGLenum, s: TGLshort, t: TGLshort, + r: TGLshort){.dynlib: dllname, + importc: "glMultiTexCoord3sARB".} +proc glMultiTexCoord3svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc: "glMultiTexCoord3svARB".} +proc glMultiTexCoord4dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, + r: TGLdouble, q: TGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord4dARB".} +proc glMultiTexCoord4dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord4dvARB".} +proc glMultiTexCoord4fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, + r: TGLfloat, q: TGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord4fARB".} +proc glMultiTexCoord4fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord4fvARB".} +proc glMultiTexCoord4iARB*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, + q: TGLint){.dynlib: dllname, + importc: "glMultiTexCoord4iARB".} +proc glMultiTexCoord4ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, + importc: "glMultiTexCoord4ivARB".} +proc glMultiTexCoord4sARB*(target: TGLenum, s: TGLshort, t: TGLshort, + r: TGLshort, q: TGLshort){.dynlib: dllname, + importc: "glMultiTexCoord4sARB".} +proc glMultiTexCoord4svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc: "glMultiTexCoord4svARB".} +proc glSampleCoverageARB*(value: TGLclampf, invert: TGLboolean){. + dynlib: dllname, importc: "glSampleCoverageARB".} + #***** GL_ARB_texture_env_add *****// +proc glWeightbvARB*(size: TGLint, weights: PGLbyte){.dynlib: dllname, + importc: "glWeightbvARB".} +proc glWeightsvARB*(size: TGLint, weights: PGLshort){.dynlib: dllname, + importc: "glWeightsvARB".} +proc glWeightivARB*(size: TGLint, weights: PGLint){.dynlib: dllname, + importc: "glWeightivARB".} +proc glWeightfvARB*(size: TGLint, weights: PGLfloat){.dynlib: dllname, + importc: "glWeightfvARB".} +proc glWeightdvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, + importc: "glWeightdvARB".} +proc glWeightvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, + importc: "glWeightvARB".} +proc glWeightubvARB*(size: TGLint, weights: PGLubyte){.dynlib: dllname, + importc: "glWeightubvARB".} +proc glWeightusvARB*(size: TGLint, weights: PGLushort){.dynlib: dllname, + importc: "glWeightusvARB".} +proc glWeightuivARB*(size: TGLint, weights: PGLuint){.dynlib: dllname, + importc: "glWeightuivARB".} +proc glWeightPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, + importc: "glWeightPointerARB".} +proc glVertexBlendARB*(count: TGLint){.dynlib: dllname, + importc: "glVertexBlendARB".} +proc glVertexAttrib1sARB*(index: TGLuint, x: TGLshort){.dynlib: dllname, + importc: "glVertexAttrib1sARB".} +proc glVertexAttrib1fARB*(index: TGLuint, x: TGLfloat){.dynlib: dllname, + importc: "glVertexAttrib1fARB".} +proc glVertexAttrib1dARB*(index: TGLuint, x: TGLdouble){.dynlib: dllname, + importc: "glVertexAttrib1dARB".} +proc glVertexAttrib2sARB*(index: TGLuint, x: TGLshort, y: TGLshort){. + dynlib: dllname, importc: "glVertexAttrib2sARB".} +proc glVertexAttrib2fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat){. + dynlib: dllname, importc: "glVertexAttrib2fARB".} +proc glVertexAttrib2dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble){. + dynlib: dllname, importc: "glVertexAttrib2dARB".} +proc glVertexAttrib3sARB*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){. + dynlib: dllname, importc: "glVertexAttrib3sARB".} +proc glVertexAttrib3fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glVertexAttrib3fARB".} +proc glVertexAttrib3dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble, + z: TGLdouble){.dynlib: dllname, + importc: "glVertexAttrib3dARB".} +proc glVertexAttrib4sARB*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, + w: TGLshort){.dynlib: dllname, + importc: "glVertexAttrib4sARB".} +proc glVertexAttrib4fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, + importc: "glVertexAttrib4fARB".} +proc glVertexAttrib4dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble, + z: TGLdouble, w: TGLdouble){.dynlib: dllname, + importc: "glVertexAttrib4dARB".} +proc glVertexAttrib4NubARB*(index: TGLuint, x: TGLubyte, y: TGLubyte, + z: TGLubyte, w: TGLubyte){.dynlib: dllname, + importc: "glVertexAttrib4NubARB".} +proc glVertexAttrib1svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib1svARB".} +proc glVertexAttrib1fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib1fvARB".} +proc glVertexAttrib1dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib1dvARB".} +proc glVertexAttrib2svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib2svARB".} +proc glVertexAttrib2fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib2fvARB".} +proc glVertexAttrib2dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib2dvARB".} +proc glVertexAttrib3svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib3svARB".} +proc glVertexAttrib3fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib3fvARB".} +proc glVertexAttrib3dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib3dvARB".} +proc glVertexAttrib4bvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, + importc: "glVertexAttrib4bvARB".} +proc glVertexAttrib4svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib4svARB".} +proc glVertexAttrib4ivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, + importc: "glVertexAttrib4ivARB".} +proc glVertexAttrib4ubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, + importc: "glVertexAttrib4ubvARB".} +proc glVertexAttrib4usvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, + importc: "glVertexAttrib4usvARB".} +proc glVertexAttrib4uivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, + importc: "glVertexAttrib4uivARB".} +proc glVertexAttrib4fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib4fvARB".} +proc glVertexAttrib4dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib4dvARB".} +proc glVertexAttrib4NbvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, + importc: "glVertexAttrib4NbvARB".} +proc glVertexAttrib4NsvARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib4NsvARB".} +proc glVertexAttrib4NivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, + importc: "glVertexAttrib4NivARB".} +proc glVertexAttrib4NubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, + importc: "glVertexAttrib4NubvARB".} +proc glVertexAttrib4NusvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, + importc: "glVertexAttrib4NusvARB".} +proc glVertexAttrib4NuivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, + importc: "glVertexAttrib4NuivARB".} +proc glVertexAttribPointerARB*(index: TGLuint, size: TGLint, thetype: TGLenum, + normalized: TGLboolean, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, + importc: "glVertexAttribPointerARB".} +proc glEnableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, + importc: "glEnableVertexAttribArrayARB".} +proc glDisableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, + importc: "glDisableVertexAttribArrayARB".} +proc glProgramStringARB*(target: TGLenum, format: TGLenum, length: TGLsizei, + str: PGLvoid){.dynlib: dllname, + importc: "glProgramStringARB".} +proc glBindProgramARB*(target: TGLenum, theProgram: TGLuint){.dynlib: dllname, + importc: "glBindProgramARB".} +proc glDeleteProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, + importc: "glDeleteProgramsARB".} +proc glGenProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, + importc: "glGenProgramsARB".} +proc glProgramEnvParameter4dARB*(target: TGLenum, index: TGLuint, x: TGLdouble, + y: TGLdouble, z: TGLdouble, w: TGLdouble){. + dynlib: dllname, importc: "glProgramEnvParameter4dARB".} +proc glProgramEnvParameter4dvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, + importc: "glProgramEnvParameter4dvARB".} +proc glProgramEnvParameter4fARB*(target: TGLenum, index: TGLuint, x: TGLfloat, + y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc: "glProgramEnvParameter4fARB".} +proc glProgramEnvParameter4fvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, + importc: "glProgramEnvParameter4fvARB".} +proc glProgramLocalParameter4dARB*(target: TGLenum, index: TGLuint, + x: TGLdouble, y: TGLdouble, z: TGLdouble, + w: TGLdouble){.dynlib: dllname, + importc: "glProgramLocalParameter4dARB".} +proc glProgramLocalParameter4dvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, + importc: "glProgramLocalParameter4dvARB".} +proc glProgramLocalParameter4fARB*(target: TGLenum, index: TGLuint, x: TGLfloat, + y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc: "glProgramLocalParameter4fARB".} +proc glProgramLocalParameter4fvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, + importc: "glProgramLocalParameter4fvARB".} +proc glGetProgramEnvParameterdvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, + importc: "glGetProgramEnvParameterdvARB".} +proc glGetProgramEnvParameterfvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, + importc: "glGetProgramEnvParameterfvARB".} +proc glGetProgramLocalParameterdvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, + importc: "glGetProgramLocalParameterdvARB".} +proc glGetProgramLocalParameterfvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, + importc: "glGetProgramLocalParameterfvARB".} +proc glGetProgramivARB*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetProgramivARB".} +proc glGetProgramStringARB*(target: TGLenum, pname: TGLenum, str: PGLvoid){. + dynlib: dllname, importc: "glGetProgramStringARB".} +proc glGetVertexAttribdvARB*(index: TGLuint, pname: TGLenum, params: PGLdouble){. + dynlib: dllname, importc: "glGetVertexAttribdvARB".} +proc glGetVertexAttribfvARB*(index: TGLuint, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetVertexAttribfvARB".} +proc glGetVertexAttribivARB*(index: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetVertexAttribivARB".} +proc glGetVertexAttribPointervARB*(index: TGLuint, pname: TGLenum, + pointer: PGLvoid){.dynlib: dllname, + importc: "glGetVertexAttribPointervARB".} +proc glIsProgramARB*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsProgramARB".} + #***** GL_ARB_window_pos *****// +proc glWindowPos2dARB*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, + importc: "glWindowPos2dARB".} +proc glWindowPos2fARB*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, + importc: "glWindowPos2fARB".} +proc glWindowPos2iARB*(x: TGLint, y: TGLint){.dynlib: dllname, + importc: "glWindowPos2iARB".} +proc glWindowPos2sARB*(x: TGLshort, y: TGLshort){.dynlib: dllname, + importc: "glWindowPos2sARB".} +proc glWindowPos2dvARB*(p: PGLdouble){.dynlib: dllname, + importc: "glWindowPos2dvARB".} +proc glWindowPos2fvARB*(p: PGLfloat){.dynlib: dllname, + importc: "glWindowPos2fvARB".} +proc glWindowPos2ivARB*(p: PGLint){.dynlib: dllname, + importc: "glWindowPos2ivARB".} +proc glWindowPos2svARB*(p: PGLshort){.dynlib: dllname, + importc: "glWindowPos2svARB".} +proc glWindowPos3dARB*(x: TGLdouble, y: TGLdouble, z: TGLdouble){. + dynlib: dllname, importc: "glWindowPos3dARB".} +proc glWindowPos3fARB*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc: "glWindowPos3fARB".} +proc glWindowPos3iARB*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, + importc: "glWindowPos3iARB".} +proc glWindowPos3sARB*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, + importc: "glWindowPos3sARB".} +proc glWindowPos3dvARB*(p: PGLdouble){.dynlib: dllname, + importc: "glWindowPos3dvARB".} +proc glWindowPos3fvARB*(p: PGLfloat){.dynlib: dllname, + importc: "glWindowPos3fvARB".} +proc glWindowPos3ivARB*(p: PGLint){.dynlib: dllname, + importc: "glWindowPos3ivARB".} +proc glWindowPos3svARB*(p: PGLshort){.dynlib: dllname, + importc: "glWindowPos3svARB".} +proc glBlendEquationSeparate*(modeRGB: TGLenum, modeAlpha: TGLenum){. + dynlib: dllname, importc: "glBlendEquationSeparate".} +proc glDrawBuffers*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, + importc: "glDrawBuffers".} +proc glStencilOpSeparate*(face: TGLenum, sfail: TGLenum, dpfail: TGLenum, + dppass: TGLenum){.dynlib: dllname, + importc: "glStencilOpSeparate".} +proc glStencilFuncSeparate*(frontfunc: TGLenum, backfunc: TGLenum, + theRef: TGLint, mask: TGLuint){.dynlib: dllname, + importc: "glStencilFuncSeparate".} +proc glStencilMaskSeparate*(face: TGLenum, mask: TGLuint){.dynlib: dllname, + importc: "glStencilMaskSeparate".} +proc glAttachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, + importc: "glAttachShader".} +proc glBindAttribLocation*(theProgram: TGLuint, index: TGLuint, name: PGLchar){. + dynlib: dllname, importc: "glBindAttribLocation".} +proc glCompileShader*(shader: TGLuint){.dynlib: dllname, + importc: "glCompileShader".} +proc glCreateProgram*(): TGLuint{.dynlib: dllname, importc: "glCreateProgram".} +proc glCreateShader*(thetype: TGLenum): TGLuint{.dynlib: dllname, + importc: "glCreateShader".} +proc glDeleteProgram*(theProgram: TGLuint){.dynlib: dllname, + importc: "glDeleteProgram".} +proc glDeleteShader*(shader: TGLuint){.dynlib: dllname, + importc: "glDeleteShader".} +proc glDetachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, + importc: "glDetachShader".} +proc glDisableVertexAttribArray*(index: TGLuint){.dynlib: dllname, + importc: "glDisableVertexAttribArray".} +proc glEnableVertexAttribArray*(index: TGLuint){.dynlib: dllname, + importc: "glEnableVertexAttribArray".} +proc glGetActiveAttrib*(theProgram: TGLuint, index: TGLuint, bufSize: TGLsizei, + len: PGLsizei, size: PGLint, thetype: PGLenum, + name: PGLchar){.dynlib: dllname, + importc: "glGetActiveAttrib".} +proc glGetActiveUniform*(theProgram: TGLuint, index: TGLuint, bufSize: TGLsizei, + len: PGLsizei, size: PGLint, thetype: PGLenum, + name: PGLchar){.dynlib: dllname, + importc: "glGetActiveUniform".} +proc glGetAttachedShaders*(theProgram: TGLuint, maxCount: TGLsizei, + count: PGLsizei, obj: PGLuint){.dynlib: dllname, + importc: "glGetAttachedShaders".} +proc glGetAttribLocation*(theProgram: TGLuint, name: PGLchar): TGLint{. + dynlib: dllname, importc: "glGetAttribLocation".} +proc glGetProgramiv*(theProgram: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetProgramiv".} +proc glGetProgramInfoLog*(theProgram: TGLuint, bufSize: TGLsizei, len: PGLsizei, + infoLog: PGLchar){.dynlib: dllname, + importc: "glGetProgramInfoLog".} +proc glGetShaderiv*(shader: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetShaderiv".} +proc glGetShaderInfoLog*(shader: TGLuint, bufSize: TGLsizei, len: PGLsizei, + infoLog: PGLchar){.dynlib: dllname, + importc: "glGetShaderInfoLog".} +proc glGetShaderSource*(shader: TGLuint, bufSize: TGLsizei, len: PGLsizei, + source: PGLchar){.dynlib: dllname, + importc: "glGetShaderSource".} +proc glGetUniformLocation*(theProgram: TGLuint, name: PGLchar): TGLint{. + dynlib: dllname, importc: "glGetUniformLocation".} +proc glGetUniformfv*(theProgram: TGLuint, location: TGLint, params: PGLfloat){. + dynlib: dllname, importc: "glGetUniformfv".} +proc glGetUniformiv*(theProgram: TGLuint, location: TGLint, params: PGLint){. + dynlib: dllname, importc: "glGetUniformiv".} +proc glGetVertexAttribdv*(index: TGLuint, pname: TGLenum, params: PGLdouble){. + dynlib: dllname, importc: "glGetVertexAttribdv".} +proc glGetVertexAttribfv*(index: TGLuint, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetVertexAttribfv".} +proc glGetVertexAttribiv*(index: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetVertexAttribiv".} +proc glGetVertexAttribPointerv*(index: TGLuint, pname: TGLenum, pointer: PGLvoid){. + dynlib: dllname, importc: "glGetVertexAttribPointerv".} +proc glIsProgram*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsProgram".} +proc glIsShader*(shader: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsShader".} +proc glLinkProgram*(theProgram: TGLuint){.dynlib: dllname, + importc: "glLinkProgram".} +proc glShaderSource*(shader: TGLuint, count: TGLsizei, str: PGLchar, len: PGLint){. + dynlib: dllname, importc: "glShaderSource".} +proc glUseProgram*(theProgram: TGLuint){.dynlib: dllname, + importc: "glUseProgram".} +proc glUniform1f*(location: TGLint, v0: TGLfloat){.dynlib: dllname, + importc: "glUniform1f".} +proc glUniform2f*(location: TGLint, v0: TGLfloat, v1: TGLfloat){. + dynlib: dllname, importc: "glUniform2f".} +proc glUniform3f*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat){. + dynlib: dllname, importc: "glUniform3f".} +proc glUniform4f*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat, + v3: TGLfloat){.dynlib: dllname, importc: "glUniform4f".} +proc glUniform1i*(location: TGLint, v0: TGLint){.dynlib: dllname, + importc: "glUniform1i".} +proc glUniform2i*(location: TGLint, v0: TGLint, v1: TGLint){.dynlib: dllname, + importc: "glUniform2i".} +proc glUniform3i*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint){. + dynlib: dllname, importc: "glUniform3i".} +proc glUniform4i*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint, + v3: TGLint){.dynlib: dllname, importc: "glUniform4i".} +proc glUniform1fv*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc: "glUniform1fv".} +proc glUniform2fv*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc: "glUniform2fv".} +proc glUniform3fv*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc: "glUniform3fv".} +proc glUniform4fv*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc: "glUniform4fv".} +proc glUniform1iv*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc: "glUniform1iv".} +proc glUniform2iv*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc: "glUniform2iv".} +proc glUniform3iv*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc: "glUniform3iv".} +proc glUniform4iv*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc: "glUniform4iv".} +proc glUniformMatrix2fv*(location: TGLint, count: TGLsizei, + transpose: TGLboolean, value: PGLfloat){. + dynlib: dllname, importc: "glUniformMatrix2fv".} +proc glUniformMatrix3fv*(location: TGLint, count: TGLsizei, + transpose: TGLboolean, value: PGLfloat){. + dynlib: dllname, importc: "glUniformMatrix3fv".} +proc glUniformMatrix4fv*(location: TGLint, count: TGLsizei, + transpose: TGLboolean, value: PGLfloat){. + dynlib: dllname, importc: "glUniformMatrix4fv".} +proc glValidateProgram*(theProgram: TGLuint){.dynlib: dllname, + importc: "glValidateProgram".} +proc glVertexAttrib1d*(index: TGLuint, x: TGLdouble){.dynlib: dllname, + importc: "glVertexAttrib1d".} +proc glVertexAttrib1dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib1dv".} +proc glVertexAttrib1f*(index: TGLuint, x: TGLfloat){.dynlib: dllname, + importc: "glVertexAttrib1f".} +proc glVertexAttrib1fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib1fv".} +proc glVertexAttrib1s*(index: TGLuint, x: TGLshort){.dynlib: dllname, + importc: "glVertexAttrib1s".} +proc glVertexAttrib1sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib1sv".} +proc glVertexAttrib2d*(index: TGLuint, x: TGLdouble, y: TGLdouble){. + dynlib: dllname, importc: "glVertexAttrib2d".} +proc glVertexAttrib2dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib2dv".} +proc glVertexAttrib2f*(index: TGLuint, x: TGLfloat, y: TGLfloat){. + dynlib: dllname, importc: "glVertexAttrib2f".} +proc glVertexAttrib2fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib2fv".} +proc glVertexAttrib2s*(index: TGLuint, x: TGLshort, y: TGLshort){. + dynlib: dllname, importc: "glVertexAttrib2s".} +proc glVertexAttrib2sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib2sv".} +proc glVertexAttrib3d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble){. + dynlib: dllname, importc: "glVertexAttrib3d".} +proc glVertexAttrib3dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib3dv".} +proc glVertexAttrib3f*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glVertexAttrib3f".} +proc glVertexAttrib3fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib3fv".} +proc glVertexAttrib3s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){. + dynlib: dllname, importc: "glVertexAttrib3s".} +proc glVertexAttrib3sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib3sv".} +proc glVertexAttrib4Nbv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, + importc: "glVertexAttrib4Nbv".} +proc glVertexAttrib4Niv*(index: TGLuint, v: PGLint){.dynlib: dllname, + importc: "glVertexAttrib4Niv".} +proc glVertexAttrib4Nsv*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib4Nsv".} +proc glVertexAttrib4Nub*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, + w: TGLubyte){.dynlib: dllname, + importc: "glVertexAttrib4Nub".} +proc glVertexAttrib4Nubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, + importc: "glVertexAttrib4Nubv".} +proc glVertexAttrib4Nuiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, + importc: "glVertexAttrib4Nuiv".} +proc glVertexAttrib4Nusv*(index: TGLuint, v: PGLushort){.dynlib: dllname, + importc: "glVertexAttrib4Nusv".} +proc glVertexAttrib4bv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, + importc: "glVertexAttrib4bv".} +proc glVertexAttrib4d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, + w: TGLdouble){.dynlib: dllname, + importc: "glVertexAttrib4d".} +proc glVertexAttrib4dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib4dv".} +proc glVertexAttrib4f*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, + importc: "glVertexAttrib4f".} +proc glVertexAttrib4fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib4fv".} +proc glVertexAttrib4iv*(index: TGLuint, v: PGLint){.dynlib: dllname, + importc: "glVertexAttrib4iv".} +proc glVertexAttrib4s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, + w: TGLshort){.dynlib: dllname, + importc: "glVertexAttrib4s".} +proc glVertexAttrib4sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib4sv".} +proc glVertexAttrib4ubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, + importc: "glVertexAttrib4ubv".} +proc glVertexAttrib4uiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, + importc: "glVertexAttrib4uiv".} +proc glVertexAttrib4usv*(index: TGLuint, v: PGLushort){.dynlib: dllname, + importc: "glVertexAttrib4usv".} +proc glVertexAttribPointer*(index: TGLuint, size: TGLint, thetype: TGLenum, + normalized: TGLboolean, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, + importc: "glVertexAttribPointer".} +const + GL_CONSTANT_COLOR* = 0x00008001 + GL_ONE_MINUS_CONSTANT_COLOR* = 0x00008002 + GL_CONSTANT_ALPHA* = 0x00008003 + GL_ONE_MINUS_CONSTANT_ALPHA* = 0x00008004 + constGL_BLEND_COLOR* = 0x00008005 + GL_FUNC_ADD* = 0x00008006 + GL_MIN* = 0x00008007 + GL_MAX* = 0x00008008 + constGL_BLEND_EQUATION* = 0x00008009 + GL_FUNC_SUBTRACT* = 0x0000800A + GL_FUNC_REVERSE_SUBTRACT* = 0x0000800B + GL_CONVOLUTION_1D* = 0x00008010 + GL_CONVOLUTION_2D* = 0x00008011 + GL_SEPARABLE_2D* = 0x00008012 + GL_CONVOLUTION_BORDER_MODE* = 0x00008013 + GL_CONVOLUTION_FILTER_SCALE* = 0x00008014 + GL_CONVOLUTION_FILTER_BIAS* = 0x00008015 + GL_REDUCE* = 0x00008016 + GL_CONVOLUTION_FORMAT* = 0x00008017 + GL_CONVOLUTION_WIDTH* = 0x00008018 + GL_CONVOLUTION_HEIGHT* = 0x00008019 + GL_MAX_CONVOLUTION_WIDTH* = 0x0000801A + GL_MAX_CONVOLUTION_HEIGHT* = 0x0000801B + GL_POST_CONVOLUTION_RED_SCALE* = 0x0000801C + GL_POST_CONVOLUTION_GREEN_SCALE* = 0x0000801D + GL_POST_CONVOLUTION_BLUE_SCALE* = 0x0000801E + GL_POST_CONVOLUTION_ALPHA_SCALE* = 0x0000801F + GL_POST_CONVOLUTION_RED_BIAS* = 0x00008020 + GL_POST_CONVOLUTION_GREEN_BIAS* = 0x00008021 + GL_POST_CONVOLUTION_BLUE_BIAS* = 0x00008022 + GL_POST_CONVOLUTION_ALPHA_BIAS* = 0x00008023 + constGL_HISTOGRAM* = 0x00008024 + GL_PROXY_HISTOGRAM* = 0x00008025 + GL_HISTOGRAM_WIDTH* = 0x00008026 + GL_HISTOGRAM_FORMAT* = 0x00008027 + GL_HISTOGRAM_RED_SIZE* = 0x00008028 + GL_HISTOGRAM_GREEN_SIZE* = 0x00008029 + GL_HISTOGRAM_BLUE_SIZE* = 0x0000802A + GL_HISTOGRAM_ALPHA_SIZE* = 0x0000802B + GL_HISTOGRAM_LUMINANCE_SIZE* = 0x0000802C + GL_HISTOGRAM_SINK* = 0x0000802D + constGL_MINMAX* = 0x0000802E + GL_MINMAX_FORMAT* = 0x0000802F + GL_MINMAX_SINK* = 0x00008030 + GL_TABLE_TOO_LARGE* = 0x00008031 + GL_COLOR_MATRIX* = 0x000080B1 + GL_COLOR_MATRIX_STACK_DEPTH* = 0x000080B2 + GL_MAX_COLOR_MATRIX_STACK_DEPTH* = 0x000080B3 + GL_POST_COLOR_MATRIX_RED_SCALE* = 0x000080B4 + GL_POST_COLOR_MATRIX_GREEN_SCALE* = 0x000080B5 + GL_POST_COLOR_MATRIX_BLUE_SCALE* = 0x000080B6 + GL_POST_COLOR_MATRIX_ALPHA_SCALE* = 0x000080B7 + GL_POST_COLOR_MATRIX_RED_BIAS* = 0x000080B8 + GL_POST_COLOR_MATRIX_GREEN_BIAS* = 0x000080B9 + GL_POST_COLOR_MATRIX_BLUE_BIAS* = 0x000080BA + GL_POST_COLOR_MATIX_ALPHA_BIAS* = 0x000080BB + constGL_COLOR_TABLE* = 0x000080D0 + GL_POST_CONVOLUTION_COLOR_TABLE* = 0x000080D1 + GL_POST_COLOR_MATRIX_COLOR_TABLE* = 0x000080D2 + GL_PROXY_COLOR_TABLE* = 0x000080D3 + GL_PROXY_POST_CONVOLUTION_COLOR_TABLE* = 0x000080D4 + GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE* = 0x000080D5 + GL_COLOR_TABLE_SCALE* = 0x000080D6 + GL_COLOR_TABLE_BIAS* = 0x000080D7 + GL_COLOR_TABLE_FORMAT* = 0x000080D8 + GL_COLOR_TABLE_WIDTH* = 0x000080D9 + GL_COLOR_TABLE_RED_SIZE* = 0x000080DA + GL_COLOR_TABLE_GREEN_SIZE* = 0x000080DB + GL_COLOR_TABLE_BLUE_SIZE* = 0x000080DC + GL_COLOR_TABLE_ALPHA_SIZE* = 0x000080DD + GL_COLOR_TABLE_LUMINANCE_SIZE* = 0x000080DE + GL_COLOR_TABLE_INTENSITY_SIZE* = 0x000080DF + GL_IGNORE_BORDER* = 0x00008150 + GL_CONSTANT_BORDER* = 0x00008151 + GL_WRAP_BORDER* = 0x00008152 + GL_REPLICATE_BORDER* = 0x00008153 + GL_CONVOLUTION_BORDER_COLOR* = 0x00008154 + +proc glActiveTexture*(texture: TGLenum){.dynlib: dllname, + importc: "glActiveTexture".} +proc glClientActiveTexture*(texture: TGLenum){.dynlib: dllname, + importc: "glClientActiveTexture".} +proc glMultiTexCoord1d*(target: TGLenum, s: TGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord1d".} +proc glMultiTexCoord1dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord1dv".} +proc glMultiTexCoord1f*(target: TGLenum, s: TGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord1f".} +proc glMultiTexCoord1fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord1fv".} +proc glMultiTexCoord1i*(target: TGLenum, s: TGLint){.dynlib: dllname, + importc: "glMultiTexCoord1i".} +proc glMultiTexCoord1iv*(target: TGLenum, v: PGLint){.dynlib: dllname, + importc: "glMultiTexCoord1iv".} +proc glMultiTexCoord1s*(target: TGLenum, s: TGLshort){.dynlib: dllname, + importc: "glMultiTexCoord1s".} +proc glMultiTexCoord1sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc: "glMultiTexCoord1sv".} +proc glMultiTexCoord2d*(target: TGLenum, s: TGLdouble, t: TGLdouble){. + dynlib: dllname, importc: "glMultiTexCoord2d".} +proc glMultiTexCoord2dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord2dv".} +proc glMultiTexCoord2f*(target: TGLenum, s: TGLfloat, t: TGLfloat){. + dynlib: dllname, importc: "glMultiTexCoord2f".} +proc glMultiTexCoord2fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord2fv".} +proc glMultiTexCoord2i*(target: TGLenum, s: TGLint, t: TGLint){.dynlib: dllname, + importc: "glMultiTexCoord2i".} +proc glMultiTexCoord2iv*(target: TGLenum, v: PGLint){.dynlib: dllname, + importc: "glMultiTexCoord2iv".} +proc glMultiTexCoord2s*(target: TGLenum, s: TGLshort, t: TGLshort){. + dynlib: dllname, importc: "glMultiTexCoord2s".} +proc glMultiTexCoord2sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc: "glMultiTexCoord2sv".} +proc glMultiTexCoord3d*(target: TGLenum, s: TGLdouble, t: TGLdouble, + r: TGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord3d".} +proc glMultiTexCoord3dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord3dv".} +proc glMultiTexCoord3f*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat){. + dynlib: dllname, importc: "glMultiTexCoord3f".} +proc glMultiTexCoord3fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord3fv".} +proc glMultiTexCoord3i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint){. + dynlib: dllname, importc: "glMultiTexCoord3i".} +proc glMultiTexCoord3iv*(target: TGLenum, v: PGLint){.dynlib: dllname, + importc: "glMultiTexCoord3iv".} +proc glMultiTexCoord3s*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort){. + dynlib: dllname, importc: "glMultiTexCoord3s".} +proc glMultiTexCoord3sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc: "glMultiTexCoord3sv".} +proc glMultiTexCoord4d*(target: TGLenum, s: TGLdouble, t: TGLdouble, + r: TGLdouble, q: TGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord4d".} +proc glMultiTexCoord4dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc: "glMultiTexCoord4dv".} +proc glMultiTexCoord4f*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat, + q: TGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord4f".} +proc glMultiTexCoord4fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc: "glMultiTexCoord4fv".} +proc glMultiTexCoord4i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, + q: TGLint){.dynlib: dllname, + importc: "glMultiTexCoord4i".} +proc glMultiTexCoord4iv*(target: TGLenum, v: PGLint){.dynlib: dllname, + importc: "glMultiTexCoord4iv".} +proc glMultiTexCoord4s*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort, + q: TGLshort){.dynlib: dllname, + importc: "glMultiTexCoord4s".} +proc glMultiTexCoord4sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc: "glMultiTexCoord4sv".} +proc glLoadTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, + importc: "glLoadTransposeMatrixf".} +proc glLoadTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, + importc: "glLoadTransposeMatrixd".} +proc glMultTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, + importc: "glMultTransposeMatrixf".} +proc glMultTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, + importc: "glMultTransposeMatrixd".} +proc glSampleCoverage*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, + importc: "glSampleCoverage".} +proc glCompressedTexImage3D*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, border: TGLint, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc: "glCompressedTexImage3D".} +proc glCompressedTexImage2D*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, border: TGLint, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc: "glCompressedTexImage2D".} +proc glCompressedTexImage1D*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + border: TGLint, imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc: "glCompressedTexImage1D".} +proc glCompressedTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, + width: TGLsizei, height: TGLsizei, + depth: TGLsizei, format: TGLenum, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc: "glCompressedTexSubImage3D".} +proc glCompressedTexSubImage2D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, width: TGLsizei, + height: TGLsizei, format: TGLenum, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc: "glCompressedTexSubImage2D".} +proc glCompressedTexSubImage1D*(target: TGLenum, level: TGLint, xoffset: TGLint, + width: TGLsizei, format: TGLenum, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc: "glCompressedTexSubImage1D".} +proc glGetCompressedTexImage*(target: TGLenum, level: TGLint, img: PGLvoid){. + dynlib: dllname, importc: "glGetCompressedTexImage".} + #***** GL_version_1_3 *****// +const + GL_TEXTURE0* = 0x000084C0 + GL_TEXTURE1* = 0x000084C1 + GL_TEXTURE2* = 0x000084C2 + GL_TEXTURE3* = 0x000084C3 + GL_TEXTURE4* = 0x000084C4 + GL_TEXTURE5* = 0x000084C5 + GL_TEXTURE6* = 0x000084C6 + GL_TEXTURE7* = 0x000084C7 + GL_TEXTURE8* = 0x000084C8 + GL_TEXTURE9* = 0x000084C9 + GL_TEXTURE10* = 0x000084CA + GL_TEXTURE11* = 0x000084CB + GL_TEXTURE12* = 0x000084CC + GL_TEXTURE13* = 0x000084CD + GL_TEXTURE14* = 0x000084CE + GL_TEXTURE15* = 0x000084CF + GL_TEXTURE16* = 0x000084D0 + GL_TEXTURE17* = 0x000084D1 + GL_TEXTURE18* = 0x000084D2 + GL_TEXTURE19* = 0x000084D3 + GL_TEXTURE20* = 0x000084D4 + GL_TEXTURE21* = 0x000084D5 + GL_TEXTURE22* = 0x000084D6 + GL_TEXTURE23* = 0x000084D7 + GL_TEXTURE24* = 0x000084D8 + GL_TEXTURE25* = 0x000084D9 + GL_TEXTURE26* = 0x000084DA + GL_TEXTURE27* = 0x000084DB + GL_TEXTURE28* = 0x000084DC + GL_TEXTURE29* = 0x000084DD + GL_TEXTURE30* = 0x000084DE + GL_TEXTURE31* = 0x000084DF + constGL_ACTIVE_TEXTURE* = 0x000084E0 + constGL_CLIENT_ACTIVE_TEXTURE* = 0x000084E1 + GL_MAX_TEXTURE_UNITS* = 0x000084E2 + GL_TRANSPOSE_MODELVIEW_MATRIX* = 0x000084E3 + GL_TRANSPOSE_PROJECTION_MATRIX* = 0x000084E4 + GL_TRANSPOSE_TEXTURE_MATRIX* = 0x000084E5 + GL_TRANSPOSE_COLOR_MATRIX* = 0x000084E6 + GL_MULTISAMPLE* = 0x0000809D + GL_SAMPLE_ALPHA_TO_COVERAGE* = 0x0000809E + GL_SAMPLE_ALPHA_TO_ONE* = 0x0000809F + constGL_SAMPLE_COVERAGE* = 0x000080A0 + GL_SAMPLE_BUFFERS* = 0x000080A8 + GL_SAMPLES* = 0x000080A9 + GL_SAMPLE_COVERAGE_VALUE* = 0x000080AA + GL_SAMPLE_COVERAGE_INVERT* = 0x000080AB + GL_MULTISAMPLE_BIT* = 0x20000000 + GL_NORMAL_MAP* = 0x00008511 + GL_REFLECTION_MAP* = 0x00008512 + GL_TEXTURE_CUBE_MAP* = 0x00008513 + GL_TEXTURE_BINDING_CUBE_MAP* = 0x00008514 + GL_TEXTURE_CUBE_MAP_POSITIVE_X* = 0x00008515 + GL_TEXTURE_CUBE_MAP_NEGATIVE_X* = 0x00008516 + GL_TEXTURE_CUBE_MAP_POSITIVE_Y* = 0x00008517 + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y* = 0x00008518 + GL_TEXTURE_CUBE_MAP_POSITIVE_Z* = 0x00008519 + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z* = 0x0000851A + GL_PROXY_TEXTURE_CUBE_MAP* = 0x0000851B + GL_MAX_CUBE_MAP_TEXTURE_SIZE* = 0x0000851C + GL_COMPRESSED_ALPHA* = 0x000084E9 + GL_COMPRESSED_LUMINANCE* = 0x000084EA + GL_COMPRESSED_LUMINANCE_ALPHA* = 0x000084EB + GL_COMPRESSED_INTENSITY* = 0x000084EC + GL_COMPRESSED_RGB* = 0x000084ED + GL_COMPRESSED_RGBA* = 0x000084EE + GL_TEXTURE_COMPRESSION_HINT* = 0x000084EF + GL_TEXTURE_COMPRESSED_IMAGE_SIZE* = 0x000086A0 + GL_TEXTURE_COMPRESSED* = 0x000086A1 + GL_NUM_COMPRESSED_TEXTURE_FORMATS* = 0x000086A2 + GL_COMPRESSED_TEXTURE_FORMATS* = 0x000086A3 + GL_CLAMP_TO_BORDER* = 0x0000812D + GL_CLAMP_TO_BORDER_SGIS* = 0x0000812D + GL_COMBINE* = 0x00008570 + GL_COMBINE_RGB* = 0x00008571 + GL_COMBINE_ALPHA* = 0x00008572 + GL_SOURCE0_RGB* = 0x00008580 + GL_SOURCE1_RGB* = 0x00008581 + GL_SOURCE2_RGB* = 0x00008582 + GL_SOURCE0_ALPHA* = 0x00008588 + GL_SOURCE1_ALPHA* = 0x00008589 + GL_SOURCE2_ALPHA* = 0x0000858A + GL_OPERAND0_RGB* = 0x00008590 + GL_OPERAND1_RGB* = 0x00008591 + GL_OPERAND2_RGB* = 0x00008592 + GL_OPERAND0_ALPHA* = 0x00008598 + GL_OPERAND1_ALPHA* = 0x00008599 + GL_OPERAND2_ALPHA* = 0x0000859A + GL_RGB_SCALE* = 0x00008573 + GL_ADD_SIGNED* = 0x00008574 + GL_INTERPOLATE* = 0x00008575 + GL_SUBTRACT* = 0x000084E7 + GL_CONSTANT* = 0x00008576 + GL_PRIMARY_COLOR* = 0x00008577 + GL_PREVIOUS* = 0x00008578 + GL_DOT3_RGB* = 0x000086AE + GL_DOT3_RGBA* = 0x000086AF + +const + GL_TEXTURE0_ARB* = 0x000084C0 + GL_TEXTURE1_ARB* = 0x000084C1 + GL_TEXTURE2_ARB* = 0x000084C2 + GL_TEXTURE3_ARB* = 0x000084C3 + GL_TEXTURE4_ARB* = 0x000084C4 + GL_TEXTURE5_ARB* = 0x000084C5 + GL_TEXTURE6_ARB* = 0x000084C6 + GL_TEXTURE7_ARB* = 0x000084C7 + GL_TEXTURE8_ARB* = 0x000084C8 + GL_TEXTURE9_ARB* = 0x000084C9 + GL_TEXTURE10_ARB* = 0x000084CA + GL_TEXTURE11_ARB* = 0x000084CB + GL_TEXTURE12_ARB* = 0x000084CC + GL_TEXTURE13_ARB* = 0x000084CD + GL_TEXTURE14_ARB* = 0x000084CE + GL_TEXTURE15_ARB* = 0x000084CF + GL_TEXTURE16_ARB* = 0x000084D0 + GL_TEXTURE17_ARB* = 0x000084D1 + GL_TEXTURE18_ARB* = 0x000084D2 + GL_TEXTURE19_ARB* = 0x000084D3 + GL_TEXTURE20_ARB* = 0x000084D4 + GL_TEXTURE21_ARB* = 0x000084D5 + GL_TEXTURE22_ARB* = 0x000084D6 + GL_TEXTURE23_ARB* = 0x000084D7 + GL_TEXTURE24_ARB* = 0x000084D8 + GL_TEXTURE25_ARB* = 0x000084D9 + GL_TEXTURE26_ARB* = 0x000084DA + GL_TEXTURE27_ARB* = 0x000084DB + GL_TEXTURE28_ARB* = 0x000084DC + GL_TEXTURE29_ARB* = 0x000084DD + GL_TEXTURE30_ARB* = 0x000084DE + GL_TEXTURE31_ARB* = 0x000084DF + constGL_ACTIVE_TEXTURE_ARB* = 0x000084E0 + constGL_CLIENT_ACTIVE_TEXTURE_ARB* = 0x000084E1 + GL_MAX_TEXTURE_UNITS_ARB* = 0x000084E2 + #***** GL_ARB_transpose_matrix *****// + +const + GL_TRANSPOSE_MODELVIEW_MATRIX_ARB* = 0x000084E3 + GL_TRANSPOSE_PROJECTION_MATRIX_ARB* = 0x000084E4 + GL_TRANSPOSE_TEXTURE_MATRIX_ARB* = 0x000084E5 + GL_TRANSPOSE_COLOR_MATRIX_ARB* = 0x000084E6 + +proc glLoadTransposeMatrixfARB*(m: PGLfloat){.dynlib: dllname, + importc: "glLoadTransposeMatrixfARB".} +proc glLoadTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, + importc: "glLoadTransposeMatrixdARB".} +proc glMultTransposeMatrixfARB*(m: PGLfloat){.dynlib: dllname, + importc: "glMultTransposeMatrixfARB".} +proc glMultTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, + importc: "glMultTransposeMatrixdARB".} +const + WGL_SAMPLE_BUFFERS_ARB* = 0x00002041 + WGL_SAMPLES_ARB* = 0x00002042 + GL_MULTISAMPLE_ARB* = 0x0000809D + GL_SAMPLE_ALPHA_TO_COVERAGE_ARB* = 0x0000809E + GL_SAMPLE_ALPHA_TO_ONE_ARB* = 0x0000809F + constGL_SAMPLE_COVERAGE_ARB* = 0x000080A0 + GL_MULTISAMPLE_BIT_ARB* = 0x20000000 + GL_SAMPLE_BUFFERS_ARB* = 0x000080A8 + GL_SAMPLES_ARB* = 0x000080A9 + GL_SAMPLE_COVERAGE_VALUE_ARB* = 0x000080AA + GL_SAMPLE_COVERAGE_INVERT_ARB* = 0x000080AB + +const + GL_NORMAL_MAP_ARB* = 0x00008511 + GL_REFLECTION_MAP_ARB* = 0x00008512 + GL_TEXTURE_CUBE_MAP_ARB* = 0x00008513 + GL_TEXTURE_BINDING_CUBE_MAP_ARB* = 0x00008514 + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB* = 0x00008515 + GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB* = 0x00008516 + GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB* = 0x00008517 + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB* = 0x00008518 + GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB* = 0x00008519 + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB* = 0x0000851A + GL_PROXY_TEXTURE_CUBE_MAP_ARB* = 0x0000851B + GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB* = 0x0000851C + +const + GL_DEPTH_COMPONENT16_ARB* = 0x000081A5 + GL_DEPTH_COMPONENT24_ARB* = 0x000081A6 + GL_DEPTH_COMPONENT32_ARB* = 0x000081A7 + GL_TEXTURE_DEPTH_SIZE_ARB* = 0x0000884A + GL_DEPTH_TEXTURE_MODE_ARB* = 0x0000884B + #***** GL_ARB_point_parameters *****// + +const + GL_POINT_SIZE_MIN_ARB* = 0x00008126 + GL_POINT_SIZE_MAX_ARB* = 0x00008127 + GL_POINT_FADE_THRESHOLD_SIZE_ARB* = 0x00008128 + GL_POINT_DISTANCE_ATTENUATION_ARB* = 0x00008129 + +proc glPointParameterfARB*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glPointParameterfARB".} +proc glPointParameterfvARB*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glPointParameterfvARB".} +const + GL_TEXTURE_COMPARE_MODE_ARB* = 0x0000884C + GL_TEXTURE_COMPARE_FUNC_ARB* = 0x0000884D + GL_COMPARE_R_TO_TEXTURE_ARB* = 0x0000884E + +const + GL_TEXTURE_COMPARE_FAIL_VALUE_ARB* = 0x000080BF + GL_CLAMP_TO_BORDER_ARB* = 0x0000812D + +const + GL_COMPRESSED_ALPHA_ARB* = 0x000084E9 + GL_COMPRESSED_LUMINANCE_ARB* = 0x000084EA + GL_COMPRESSED_LUMINANCE_ALPHA_ARB* = 0x000084EB + GL_COMPRESSED_INTENSITY_ARB* = 0x000084EC + GL_COMPRESSED_RGB_ARB* = 0x000084ED + GL_COMPRESSED_RGBA_ARB* = 0x000084EE + GL_TEXTURE_COMPRESSION_HINT_ARB* = 0x000084EF + GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB* = 0x000086A0 + GL_TEXTURE_COMPRESSED_ARB* = 0x000086A1 + GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB* = 0x000086A2 + GL_COMPRESSED_TEXTURE_FORMATS_ARB* = 0x000086A3 + +proc glCompressedTexImage3DARB*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, + border: TGLint, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, + importc: "glCompressedTexImage3DARB".} +proc glCompressedTexImage2DARB*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, border: TGLint, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc: "glCompressedTexImage2DARB".} +proc glCompressedTexImage1DARB*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + border: TGLint, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, + importc: "glCompressedTexImage1DARB".} +proc glCompressedTexSubImage3DARB*(target: TGLenum, level: TGLint, + xoffset: TGLint, yoffset: TGLint, + zoffset: TGLint, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, + format: TGLenum, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, + importc: "glCompressedTexSubImage3DARB".} +proc glCompressedTexSubImage2DARB*(target: TGLenum, level: TGLint, + xoffset: TGLint, yoffset: TGLint, + width: TGLsizei, height: TGLsizei, + format: TGLenum, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, + importc: "glCompressedTexSubImage2DARB".} +proc glCompressedTexSubImage1DARB*(target: TGLenum, level: TGLint, + xoffset: TGLint, width: TGLsizei, + format: TGLenum, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, + importc: "glCompressedTexSubImage1DARB".} +proc glGetCompressedTexImageARB*(target: TGLenum, lod: TGLint, img: PGLvoid){. + dynlib: dllname, importc: "glGetCompressedTexImageARB".} + #***** GL_ARB_texture_env_combine *****// +const + GL_COMBINE_ARB* = 0x00008570 + GL_COMBINE_RGB_ARB* = 0x00008571 + GL_COMBINE_ALPHA_ARB* = 0x00008572 + GL_SOURCE0_RGB_ARB* = 0x00008580 + GL_SOURCE1_RGB_ARB* = 0x00008581 + GL_SOURCE2_RGB_ARB* = 0x00008582 + GL_SOURCE0_ALPHA_ARB* = 0x00008588 + GL_SOURCE1_ALPHA_ARB* = 0x00008589 + GL_SOURCE2_ALPHA_ARB* = 0x0000858A + GL_OPERAND0_RGB_ARB* = 0x00008590 + GL_OPERAND1_RGB_ARB* = 0x00008591 + GL_OPERAND2_RGB_ARB* = 0x00008592 + GL_OPERAND0_ALPHA_ARB* = 0x00008598 + GL_OPERAND1_ALPHA_ARB* = 0x00008599 + GL_OPERAND2_ALPHA_ARB* = 0x0000859A + GL_RGB_SCALE_ARB* = 0x00008573 + GL_ADD_SIGNED_ARB* = 0x00008574 + GL_INTERPOLATE_ARB* = 0x00008575 + GL_SUBTRACT_ARB* = 0x000084E7 + GL_CONSTANT_ARB* = 0x00008576 + GL_PRIMARY_COLOR_ARB* = 0x00008577 + GL_PREVIOUS_ARB* = 0x00008578 + #***** GL_ARB_texture_env_crossbar *****// + #***** GL_ARB_texture_env_dot3 *****// + +const + GL_DOT3_RGB_ARB* = 0x000086AE + GL_DOT3_RGBA_ARB* = 0x000086AF + #***** GL_ARB_texture_mirrored_repeat *****// + +const + GL_MIRRORED_REPEAT_ARB* = 0x00008370 + #***** GL_ARB_vertex_blend *****// + +const + GL_MAX_VERTEX_UNITS_ARB* = 0x000086A4 + GL_ACTIVE_VERTEX_UNITS_ARB* = 0x000086A5 + GL_WEIGHT_SUM_UNITY_ARB* = 0x000086A6 + constGL_VERTEX_BLEND_ARB* = 0x000086A7 + GL_MODELVIEW0_ARB* = 0x00001700 + GL_MODELVIEW1_ARB* = 0x0000850A + GL_MODELVIEW2_ARB* = 0x00008722 + GL_MODELVIEW3_ARB* = 0x00008723 + GL_MODELVIEW4_ARB* = 0x00008724 + GL_MODELVIEW5_ARB* = 0x00008725 + GL_MODELVIEW6_ARB* = 0x00008726 + GL_MODELVIEW7_ARB* = 0x00008727 + GL_MODELVIEW8_ARB* = 0x00008728 + GL_MODELVIEW9_ARB* = 0x00008729 + GL_MODELVIEW10_ARB* = 0x0000872A + GL_MODELVIEW11_ARB* = 0x0000872B + GL_MODELVIEW12_ARB* = 0x0000872C + GL_MODELVIEW13_ARB* = 0x0000872D + GL_MODELVIEW14_ARB* = 0x0000872E + GL_MODELVIEW15_ARB* = 0x0000872F + GL_MODELVIEW16_ARB* = 0x00008730 + GL_MODELVIEW17_ARB* = 0x00008731 + GL_MODELVIEW18_ARB* = 0x00008732 + GL_MODELVIEW19_ARB* = 0x00008733 + GL_MODELVIEW20_ARB* = 0x00008734 + GL_MODELVIEW21_ARB* = 0x00008735 + GL_MODELVIEW22_ARB* = 0x00008736 + GL_MODELVIEW23_ARB* = 0x00008737 + GL_MODELVIEW24_ARB* = 0x00008738 + GL_MODELVIEW25_ARB* = 0x00008739 + GL_MODELVIEW26_ARB* = 0x0000873A + GL_MODELVIEW27_ARB* = 0x0000873B + GL_MODELVIEW28_ARB* = 0x0000873C + GL_MODELVIEW29_ARB* = 0x0000873D + GL_MODELVIEW30_ARB* = 0x0000873E + GL_MODELVIEW31_ARB* = 0x0000873F + GL_CURRENT_WEIGHT_ARB* = 0x000086A8 + GL_WEIGHT_ARRAY_TYPE_ARB* = 0x000086A9 + GL_WEIGHT_ARRAY_STRIDE_ARB* = 0x000086AA + GL_WEIGHT_ARRAY_SIZE_ARB* = 0x000086AB + GL_WEIGHT_ARRAY_POINTER_ARB* = 0x000086AC + GL_WEIGHT_ARRAY_ARB* = 0x000086AD + +const + GL_VERTEX_PROGRAM_ARB* = 0x00008620 + GL_VERTEX_PROGRAM_POINT_SIZE_ARB* = 0x00008642 + GL_VERTEX_PROGRAM_TWO_SIDE_ARB* = 0x00008643 + GL_COLOR_SUM_ARB* = 0x00008458 + GL_PROGRAM_FORMAT_ASCII_ARB* = 0x00008875 + GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB* = 0x00008622 + GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB* = 0x00008623 + GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB* = 0x00008624 + GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB* = 0x00008625 + GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB* = 0x0000886A + GL_CURRENT_VERTEX_ATTRIB_ARB* = 0x00008626 + GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB* = 0x00008645 + GL_PROGRAM_LENGTH_ARB* = 0x00008627 + GL_PROGRAM_FORMAT_ARB* = 0x00008876 + GL_PROGRAM_BINDING_ARB* = 0x00008677 + GL_PROGRAM_INSTRUCTIONS_ARB* = 0x000088A0 + GL_MAX_PROGRAM_INSTRUCTIONS_ARB* = 0x000088A1 + GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB* = 0x000088A2 + GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB* = 0x000088A3 + GL_PROGRAM_TEMPORARIES_ARB* = 0x000088A4 + GL_MAX_PROGRAM_TEMPORARIES_ARB* = 0x000088A5 + GL_PROGRAM_NATIVE_TEMPORARIES_ARB* = 0x000088A6 + GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB* = 0x000088A7 + GL_PROGRAM_PARAMETERS_ARB* = 0x000088A8 + GL_MAX_PROGRAM_PARAMETERS_ARB* = 0x000088A9 + GL_PROGRAM_NATIVE_PARAMETERS_ARB* = 0x000088AA + GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB* = 0x000088AB + GL_PROGRAM_ATTRIBS_ARB* = 0x000088AC + GL_MAX_PROGRAM_ATTRIBS_ARB* = 0x000088AD + GL_PROGRAM_NATIVE_ATTRIBS_ARB* = 0x000088AE + GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB* = 0x000088AF + GL_PROGRAM_ADDRESS_REGISTERS_ARB* = 0x000088B0 + GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB* = 0x000088B1 + GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB* = 0x000088B2 + GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB* = 0x000088B3 + GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB* = 0x000088B4 + GL_MAX_PROGRAM_ENV_PARAMETERS_ARB* = 0x000088B5 + GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB* = 0x000088B6 + constGL_PROGRAM_STRING_ARB* = 0x00008628 + GL_PROGRAM_ERROR_POSITION_ARB* = 0x0000864B + GL_CURRENT_MATRIX_ARB* = 0x00008641 + GL_TRANSPOSE_CURRENT_MATRIX_ARB* = 0x000088B7 + GL_CURRENT_MATRIX_STACK_DEPTH_ARB* = 0x00008640 + GL_MAX_VERTEX_ATTRIBS_ARB* = 0x00008869 + GL_MAX_PROGRAM_MATRICES_ARB* = 0x0000862F + GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB* = 0x0000862E + GL_PROGRAM_ERROR_STRING_ARB* = 0x00008874 + GL_MATRIX0_ARB* = 0x000088C0 + GL_MATRIX1_ARB* = 0x000088C1 + GL_MATRIX2_ARB* = 0x000088C2 + GL_MATRIX3_ARB* = 0x000088C3 + GL_MATRIX4_ARB* = 0x000088C4 + GL_MATRIX5_ARB* = 0x000088C5 + GL_MATRIX6_ARB* = 0x000088C6 + GL_MATRIX7_ARB* = 0x000088C7 + GL_MATRIX8_ARB* = 0x000088C8 + GL_MATRIX9_ARB* = 0x000088C9 + GL_MATRIX10_ARB* = 0x000088CA + GL_MATRIX11_ARB* = 0x000088CB + GL_MATRIX12_ARB* = 0x000088CC + GL_MATRIX13_ARB* = 0x000088CD + GL_MATRIX14_ARB* = 0x000088CE + GL_MATRIX15_ARB* = 0x000088CF + GL_MATRIX16_ARB* = 0x000088D0 + GL_MATRIX17_ARB* = 0x000088D1 + GL_MATRIX18_ARB* = 0x000088D2 + GL_MATRIX19_ARB* = 0x000088D3 + GL_MATRIX20_ARB* = 0x000088D4 + GL_MATRIX21_ARB* = 0x000088D5 + GL_MATRIX22_ARB* = 0x000088D6 + GL_MATRIX23_ARB* = 0x000088D7 + GL_MATRIX24_ARB* = 0x000088D8 + GL_MATRIX25_ARB* = 0x000088D9 + GL_MATRIX26_ARB* = 0x000088DA + GL_MATRIX27_ARB* = 0x000088DB + GL_MATRIX28_ARB* = 0x000088DC + GL_MATRIX29_ARB* = 0x000088DD + GL_MATRIX30_ARB* = 0x000088DE + GL_MATRIX31_ARB* = 0x000088DF + +const + GL_422_EXT* = 0x000080CC + GL_422_REV_EXT* = 0x000080CD + GL_422_AVERAGE_EXT* = 0x000080CE + GL_422_REV_AVERAGE_EXT* = 0x000080CF + #***** GL_EXT_abgr *****// + +const + GL_ABGR_EXT* = 0x00008000 + #***** GL_EXT_bgra *****// + +const + GL_BGR_EXT* = 0x000080E0 + GL_BGRA_EXT* = 0x000080E1 + #***** GL_EXT_blend_color *****// + +const + GL_CONSTANT_COLOR_EXT* = 0x00008001 + GL_ONE_MINUS_CONSTANT_COLOR_EXT* = 0x00008002 + GL_CONSTANT_ALPHA_EXT* = 0x00008003 + GL_ONE_MINUS_CONSTANT_ALPHA_EXT* = 0x00008004 + constGL_BLEND_COLOR_EXT* = 0x00008005 + +proc glBlendColorEXT*(red: TGLclampf, green: TGLclampf, blue: TGLclampf, + alpha: TGLclampf){.dynlib: dllname, + importc: "glBlendColorEXT".} + #***** GL_EXT_blend_func_separate *****// +const + GL_BLEND_DST_RGB_EXT* = 0x000080C8 + GL_BLEND_SRC_RGB_EXT* = 0x000080C9 + GL_BLEND_DST_ALPHA_EXT* = 0x000080CA + GL_BLEND_SRC_ALPHA_EXT* = 0x000080CB + +proc glBlendFuncSeparateEXT*(sfactorRGB: TGLenum, dfactorRGB: TGLenum, + sfactorAlpha: TGLenum, dfactorAlpha: TGLenum){. + dynlib: dllname, importc: "glBlendFuncSeparateEXT".} + #***** GL_EXT_blend_logic_op *****// + #***** GL_EXT_blend_minmax *****// +const + GL_FUNC_ADD_EXT* = 0x00008006 + GL_MIN_EXT* = 0x00008007 + GL_MAX_EXT* = 0x00008008 + constGL_BLEND_EQUATION_EXT* = 0x00008009 + +proc glBlendEquationEXT*(mode: TGLenum){.dynlib: dllname, + importc: "glBlendEquationEXT".} + #***** GL_EXT_blend_subtract *****// +const + GL_FUNC_SUBTRACT_EXT* = 0x0000800A + GL_FUNC_REVERSE_SUBTRACT_EXT* = 0x0000800B + #***** GL_EXT_clip_volume_hint *****// + +const + GL_CLIP_VOLUME_CLIPPING_HINT_EXT* = 0x000080F0 + #***** GL_EXT_color_subtable *****// + +proc glColorSubTableEXT*(target: TGLenum, start: TGLsizei, count: TGLsizei, + format: TGLenum, thetype: TGLenum, data: PGLvoid){. + dynlib: dllname, importc: "glColorSubTableEXT".} +proc glCopyColorSubTableEXT*(target: TGLenum, start: TGLsizei, x: TGLint, + y: TGLint, width: TGLsizei){.dynlib: dllname, + importc: "glCopyColorSubTableEXT".} + #***** GL_EXT_compiled_vertex_array *****// +const + GL_ARRAY_ELEMENT_LOCK_FIRST_EXT* = 0x000081A8 + GL_ARRAY_ELEMENT_LOCK_COUNT_EXT* = 0x000081A9 + +proc glLockArraysEXT*(first: TGLint, count: TGLsizei){.dynlib: dllname, + importc: "glLockArraysEXT".} +proc glUnlockArraysEXT*(){.dynlib: dllname, importc: "glUnlockArraysEXT".} + #***** GL_EXT_convolution *****// +const + GL_CONVOLUTION_1D_EXT* = 0x00008010 + GL_CONVOLUTION_2D_EXT* = 0x00008011 + GL_SEPARABLE_2D_EXT* = 0x00008012 + GL_CONVOLUTION_BORDER_MODE_EXT* = 0x00008013 + GL_CONVOLUTION_FILTER_SCALE_EXT* = 0x00008014 + GL_CONVOLUTION_FILTER_BIAS_EXT* = 0x00008015 + GL_REDUCE_EXT* = 0x00008016 + GL_CONVOLUTION_FORMAT_EXT* = 0x00008017 + GL_CONVOLUTION_WIDTH_EXT* = 0x00008018 + GL_CONVOLUTION_HEIGHT_EXT* = 0x00008019 + GL_MAX_CONVOLUTION_WIDTH_EXT* = 0x0000801A + GL_MAX_CONVOLUTION_HEIGHT_EXT* = 0x0000801B + GL_POST_CONVOLUTION_RED_SCALE_EXT* = 0x0000801C + GL_POST_CONVOLUTION_GREEN_SCALE_EXT* = 0x0000801D + GL_POST_CONVOLUTION_BLUE_SCALE_EXT* = 0x0000801E + GL_POST_CONVOLUTION_ALPHA_SCALE_EXT* = 0x0000801F + GL_POST_CONVOLUTION_RED_BIAS_EXT* = 0x00008020 + GL_POST_CONVOLUTION_GREEN_BIAS_EXT* = 0x00008021 + GL_POST_CONVOLUTION_BLUE_BIAS_EXT* = 0x00008022 + GL_POST_CONVOLUTION_ALPHA_BIAS_EXT* = 0x00008023 + +proc glConvolutionFilter1DEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, format: TGLenum, + thetype: TGLenum, image: PGLvoid){. + dynlib: dllname, importc: "glConvolutionFilter1DEXT".} +proc glConvolutionFilter2DEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, + format: TGLenum, thetype: TGLenum, image: PGLvoid){. + dynlib: dllname, importc: "glConvolutionFilter2DEXT".} +proc glCopyConvolutionFilter1DEXT*(target: TGLenum, internalformat: TGLenum, + x: TGLint, y: TGLint, width: TGLsizei){. + dynlib: dllname, importc: "glCopyConvolutionFilter1DEXT".} +proc glCopyConvolutionFilter2DEXT*(target: TGLenum, internalformat: TGLenum, + x: TGLint, y: TGLint, width: TGLsizei, + height: TGLsizei){.dynlib: dllname, + importc: "glCopyConvolutionFilter2DEXT".} +proc glGetConvolutionFilterEXT*(target: TGLenum, format: TGLenum, + thetype: TGLenum, image: PGLvoid){. + dynlib: dllname, importc: "glGetConvolutionFilterEXT".} +proc glSeparableFilter2DEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, + thetype: TGLenum, row: PGLvoid, column: PGLvoid){. + dynlib: dllname, importc: "glSeparableFilter2DEXT".} +proc glGetSeparableFilterEXT*(target: TGLenum, format: TGLenum, + thetype: TGLenum, row: PGLvoid, column: PGLvoid, + span: PGLvoid){.dynlib: dllname, + importc: "glGetSeparableFilterEXT".} +proc glConvolutionParameteriEXT*(target: TGLenum, pname: TGLenum, param: TGLint){. + dynlib: dllname, importc: "glConvolutionParameteriEXT".} +proc glConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glConvolutionParameterivEXT".} +proc glConvolutionParameterfEXT*(target: TGLenum, pname: TGLenum, + param: TGLfloat){.dynlib: dllname, + importc: "glConvolutionParameterfEXT".} +proc glConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glConvolutionParameterfvEXT".} +proc glGetConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetConvolutionParameterivEXT".} +proc glGetConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetConvolutionParameterfvEXT".} + #***** GL_EXT_fog_coord *****// +const + GL_FOG_COORDINATE_SOURCE_EXT* = 0x00008450 + GL_FOG_COORDINATE_EXT* = 0x00008451 + GL_FRAGMENT_DEPTH_EXT* = 0x00008452 + GL_CURRENT_FOG_COORDINATE_EXT* = 0x00008453 + GL_FOG_COORDINATE_ARRAY_TYPE_EXT* = 0x00008454 + GL_FOG_COORDINATE_ARRAY_STRIDE_EXT* = 0x00008455 + GL_FOG_COORDINATE_ARRAY_POINTER_EXT* = 0x00008456 + GL_FOG_COORDINATE_ARRAY_EXT* = 0x00008457 + +proc glFogCoordfEXfloat*(coord: TGLfloat){.dynlib: dllname, + importc: "glFogCoordfEXfloat".} +proc glFogCoorddEXdouble*(coord: TGLdouble){.dynlib: dllname, + importc: "glFogCoorddEXdouble".} +proc glFogCoordfvEXfloat*(coord: TGLfloat){.dynlib: dllname, + importc: "glFogCoordfvEXfloat".} +proc glFogCoorddvEXdouble*(coord: TGLdouble){.dynlib: dllname, + importc: "glFogCoorddvEXdouble".} +proc glFogCoordPointerEXT*(thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc: "glFogCoordPointerEXT".} + #***** GL_EXT_histogram *****// +const + constGL_HISTOGRAM_EXT* = 0x00008024 + GL_PROXY_HISTOGRAM_EXT* = 0x00008025 + GL_HISTOGRAM_WIDTH_EXT* = 0x00008026 + GL_HISTOGRAM_FORMAT_EXT* = 0x00008027 + GL_HISTOGRAM_RED_SIZE_EXT* = 0x00008028 + GL_HISTOGRAM_GREEN_SIZE_EXT* = 0x00008029 + GL_HISTOGRAM_BLUE_SIZE_EXT* = 0x0000802A + GL_HISTOGRAM_ALPHA_SIZE_EXT* = 0x0000802B + GL_HISTOGRAM_LUMINANCE_SIZE_EXT* = 0x0000802C + GL_HISTOGRAM_SINK_EXT* = 0x0000802D + constGL_MINMAX_EXT* = 0x0000802E + GL_MINMAX_FORMAT_EXT* = 0x0000802F + GL_MINMAX_SINK_EXT* = 0x00008030 + +proc glHistogramEXT*(target: TGLenum, width: TGLsizei, internalformat: TGLenum, + sink: TGLboolean){.dynlib: dllname, + importc: "glHistogramEXT".} +proc glResetHistogramEXT*(target: TGLenum){.dynlib: dllname, + importc: "glResetHistogramEXT".} +proc glGetHistogramEXT*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, + importc: "glGetHistogramEXT".} +proc glGetHistogramParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetHistogramParameterivEXT".} +proc glGetHistogramParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetHistogramParameterfvEXT".} +proc glMinmaxEXT*(target: TGLenum, internalformat: TGLenum, sink: TGLboolean){. + dynlib: dllname, importc: "glMinmaxEXT".} +proc glResetMinmaxEXT*(target: TGLenum){.dynlib: dllname, + importc: "glResetMinmaxEXT".} +proc glGetMinmaxEXT*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, + importc: "glGetMinmaxEXT".} +proc glGetMinmaxParameterivEXT*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetMinmaxParameterivEXT".} +proc glGetMinmaxParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetMinmaxParameterfvEXT".} + #***** GL_EXT_multi_draw_arrays *****// +proc glMultiDrawArraysEXT*(mode: TGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei){.dynlib: dllname, + importc: "glMultiDrawArraysEXT".} +proc glMultiDrawElementsEXT*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, + indices: PGLvoid, primcount: TGLsizei){. + dynlib: dllname, importc: "glMultiDrawElementsEXT".} + #***** GL_EXT_packed_pixels *****// +const + GL_UNSIGNED_BYTE_3_3_2_EXT* = 0x00008032 + GL_UNSIGNED_SHORT_4_4_4_4_EXT* = 0x00008033 + GL_UNSIGNED_SHORT_5_5_5_1_EXT* = 0x00008034 + GL_UNSIGNED_INT_8_8_8_8_EXT* = 0x00008035 + GL_UNSIGNED_INT_10_10_10_2_EXT* = 0x00008036 + #***** GL_EXT_paletted_texture *****// + +const + GL_COLOR_INDEX1_EXT* = 0x000080E2 + GL_COLOR_INDEX2_EXT* = 0x000080E3 + GL_COLOR_INDEX4_EXT* = 0x000080E4 + GL_COLOR_INDEX8_EXT* = 0x000080E5 + GL_COLOR_INDEX12_EXT* = 0x000080E6 + GL_COLOR_INDEX16_EXT* = 0x000080E7 + GL_COLOR_TABLE_FORMAT_EXT* = 0x000080D8 + GL_COLOR_TABLE_WIDTH_EXT* = 0x000080D9 + GL_COLOR_TABLE_RED_SIZE_EXT* = 0x000080DA + GL_COLOR_TABLE_GREEN_SIZE_EXT* = 0x000080DB + GL_COLOR_TABLE_BLUE_SIZE_EXT* = 0x000080DC + GL_COLOR_TABLE_ALPHA_SIZE_EXT* = 0x000080DD + GL_COLOR_TABLE_LUMINANCE_SIZE_EXT* = 0x000080DE + GL_COLOR_TABLE_INTENSITY_SIZE_EXT* = 0x000080DF + GL_TEXTURE_INDEX_SIZE_EXT* = 0x000080ED + GL_TEXTURE_1D* = 0x00000DE0 + GL_TEXTURE_2D* = 0x00000DE1 + GL_TEXTURE_3D_EXT* = 0x0000806F # GL_TEXTURE_CUBE_MAP_ARB { already defined } + GL_PROXY_TEXTURE_1D* = 0x00008063 + GL_PROXY_TEXTURE_2D* = 0x00008064 + GL_PROXY_TEXTURE_3D_EXT* = 0x00008070 # GL_PROXY_TEXTURE_CUBE_MAP_ARB { already defined } + # GL_TEXTURE_1D { already defined } + # GL_TEXTURE_2D { already defined } + # GL_TEXTURE_3D_EXT { already defined } + # GL_TEXTURE_CUBE_MAP_ARB { already defined } + +proc glColorTableEXT*(target: TGLenum, internalFormat: TGLenum, width: TGLsizei, + format: TGLenum, thetype: TGLenum, data: PGLvoid){. + dynlib: dllname, importc: "glColorTableEXT".} + # glColorSubTableEXT { already defined } +proc glGetColorTableEXT*(target: TGLenum, format: TGLenum, thetype: TGLenum, + data: PGLvoid){.dynlib: dllname, + importc: "glGetColorTableEXT".} +proc glGetColorTableParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetColorTableParameterivEXT".} +proc glGetColorTableParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetColorTableParameterfvEXT".} + #***** GL_EXT_point_parameters *****// +const + GL_POINT_SIZE_MIN_EXT* = 0x00008126 + GL_POINT_SIZE_MAX_EXT* = 0x00008127 + GL_POINT_FADE_THRESHOLD_SIZE_EXT* = 0x00008128 + GL_DISTANCE_ATTENUATION_EXT* = 0x00008129 + +proc glPointParameterfEXT*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glPointParameterfEXT".} +proc glPointParameterfvEXT*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glPointParameterfvEXT".} + #***** GL_EXT_polygon_offset *****// +const + constGL_POLYGON_OFFSET_EXT* = 0x00008037 + GL_POLYGON_OFFSET_FACTOR_EXT* = 0x00008038 + GL_POLYGON_OFFSET_BIAS_EXT* = 0x00008039 + +proc glPolygonOffsetEXT*(factor: TGLfloat, bias: TGLfloat){.dynlib: dllname, + importc: "glPolygonOffsetEXT".} + #***** GL_EXT_secondary_color *****// +const + GL_COLOR_SUM_EXT* = 0x00008458 + GL_CURRENT_SECONDARY_COLOR_EXT* = 0x00008459 + GL_SECONDARY_COLOR_ARRAY_SIZE_EXT* = 0x0000845A + GL_SECONDARY_COLOR_ARRAY_TYPE_EXT* = 0x0000845B + GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT* = 0x0000845C + GL_SECONDARY_COLOR_ARRAY_POINTER_EXT* = 0x0000845D + GL_SECONDARY_COLOR_ARRAY_EXT* = 0x0000845E + +proc glSecondaryColor3bEXT*(components: TGLbyte){.dynlib: dllname, + importc: "glSecondaryColor3bEXT".} +proc glSecondaryColor3sEXT*(components: TGLshort){.dynlib: dllname, + importc: "glSecondaryColor3sEXT".} +proc glSecondaryColor3iEXT*(components: TGLint){.dynlib: dllname, + importc: "glSecondaryColor3iEXT".} +proc glSecondaryColor3fEXT*(components: TGLfloat){.dynlib: dllname, + importc: "glSecondaryColor3fEXT".} +proc glSecondaryColor3dEXT*(components: TGLdouble){.dynlib: dllname, + importc: "glSecondaryColor3dEXT".} +proc glSecondaryColor3ubEXT*(components: TGLubyte){.dynlib: dllname, + importc: "glSecondaryColor3ubEXT".} +proc glSecondaryColor3usEXT*(components: TGLushort){.dynlib: dllname, + importc: "glSecondaryColor3usEXT".} +proc glSecondaryColor3uiEXT*(components: TGLuint){.dynlib: dllname, + importc: "glSecondaryColor3uiEXT".} +proc glSecondaryColor3bvEXT*(components: TGLbyte){.dynlib: dllname, + importc: "glSecondaryColor3bvEXT".} +proc glSecondaryColor3svEXT*(components: TGLshort){.dynlib: dllname, + importc: "glSecondaryColor3svEXT".} +proc glSecondaryColor3ivEXT*(components: TGLint){.dynlib: dllname, + importc: "glSecondaryColor3ivEXT".} +proc glSecondaryColor3fvEXT*(components: TGLfloat){.dynlib: dllname, + importc: "glSecondaryColor3fvEXT".} +proc glSecondaryColor3dvEXT*(components: TGLdouble){.dynlib: dllname, + importc: "glSecondaryColor3dvEXT".} +proc glSecondaryColor3ubvEXT*(components: TGLubyte){.dynlib: dllname, + importc: "glSecondaryColor3ubvEXT".} +proc glSecondaryColor3usvEXT*(components: TGLushort){.dynlib: dllname, + importc: "glSecondaryColor3usvEXT".} +proc glSecondaryColor3uivEXT*(components: TGLuint){.dynlib: dllname, + importc: "glSecondaryColor3uivEXT".} +proc glSecondaryColorPointerEXT*(size: TGLint, thetype: TGLenum, + stride: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc: "glSecondaryColorPointerEXT".} + #***** GL_EXT_separate_specular_color *****// +const + GL_LIGHT_MODEL_COLOR_CONTROL_EXT* = 0x000081F8 + GL_SINGLE_COLOR_EXT* = 0x000081F9 + GL_SEPARATE_SPECULAR_COLOR_EXT* = 0x000081FA + #***** GL_EXT_shadow_funcs *****// + #***** GL_EXT_shared_texture_palette *****// + +const + GL_SHARED_TEXTURE_PALETTE_EXT* = 0x000081FB + #***** GL_EXT_stencil_two_side *****// + +const + GL_STENCIL_TEST_TWO_SIDE_EXT* = 0x00008910 + constGL_ACTIVE_STENCIL_FACE_EXT* = 0x00008911 + +proc glActiveStencilFaceEXT*(face: TGLenum){.dynlib: dllname, + importc: "glActiveStencilFaceEXT".} + #***** GL_EXT_stencil_wrap *****// +const + GL_INCR_WRAP_EXT* = 0x00008507 + GL_DECR_WRAP_EXT* = 0x00008508 + #***** GL_EXT_subtexture *****// + +proc glTexSubImage1DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, + width: TGLsizei, format: TGLenum, thetype: TGLenum, + pixels: PGLvoid){.dynlib: dllname, + importc: "glTexSubImage1DEXT".} +proc glTexSubImage2DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, width: TGLsizei, height: TGLsizei, + format: TGLenum, thetype: TGLenum, pixels: PGLvoid){. + dynlib: dllname, importc: "glTexSubImage2DEXT".} +proc glTexSubImage3DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, format: TGLenum, + thetype: TGLenum, pixels: PGLvoid){.dynlib: dllname, + importc: "glTexSubImage3DEXT".} + #***** GL_EXT_texture3D *****// +const + GL_PACK_SKIP_IMAGES_EXT* = 0x0000806B + GL_PACK_IMAGE_HEIGHT_EXT* = 0x0000806C + GL_UNPACK_SKIP_IMAGES_EXT* = 0x0000806D + GL_UNPACK_IMAGE_HEIGHT_EXT* = 0x0000806E # GL_TEXTURE_3D_EXT { already defined } + # GL_PROXY_TEXTURE_3D_EXT { already defined } + GL_TEXTURE_DEPTH_EXT* = 0x00008071 + GL_TEXTURE_WRAP_R_EXT* = 0x00008072 + GL_MAX_3D_TEXTURE_SIZE_EXT* = 0x00008073 + +proc glTexImage3DEXT*(target: TGLenum, level: TGLint, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, depth: TGLsizei, + border: TGLint, format: TGLenum, thetype: TGLenum, + pixels: PGLvoid){.dynlib: dllname, + importc: "glTexImage3DEXT".} + #***** GL_EXT_texture_compression_s3tc *****// +const + GL_COMPRESSED_RGB_S3TC_DXT1_EXT* = 0x000083F0 + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT* = 0x000083F1 + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT* = 0x000083F2 + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT* = 0x000083F3 + #***** GL_EXT_texture_env_add *****// + #***** GL_EXT_texture_env_combine *****// + +const + GL_COMBINE_EXT* = 0x00008570 + GL_COMBINE_RGB_EXT* = 0x00008571 + GL_COMBINE_ALPHA_EXT* = 0x00008572 + GL_SOURCE0_RGB_EXT* = 0x00008580 + GL_SOURCE1_RGB_EXT* = 0x00008581 + GL_SOURCE2_RGB_EXT* = 0x00008582 + GL_SOURCE0_ALPHA_EXT* = 0x00008588 + GL_SOURCE1_ALPHA_EXT* = 0x00008589 + GL_SOURCE2_ALPHA_EXT* = 0x0000858A + GL_OPERAND0_RGB_EXT* = 0x00008590 + GL_OPERAND1_RGB_EXT* = 0x00008591 + GL_OPERAND2_RGB_EXT* = 0x00008592 + GL_OPERAND0_ALPHA_EXT* = 0x00008598 + GL_OPERAND1_ALPHA_EXT* = 0x00008599 + GL_OPERAND2_ALPHA_EXT* = 0x0000859A + GL_RGB_SCALE_EXT* = 0x00008573 + GL_ADD_SIGNED_EXT* = 0x00008574 + GL_INTERPOLATE_EXT* = 0x00008575 + GL_CONSTANT_EXT* = 0x00008576 + GL_PRIMARY_COLOR_EXT* = 0x00008577 + GL_PREVIOUS_EXT* = 0x00008578 + #***** GL_EXT_texture_env_dot3 *****// + +const + GL_DOT3_RGB_EXT* = 0x00008740 + GL_DOT3_RGBA_EXT* = 0x00008741 + #***** GL_EXT_texture_filter_anisotropic *****// + +const + GL_TEXTURE_MAX_ANISOTROPY_EXT* = 0x000084FE + GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT* = 0x000084FF + #***** GL_EXT_texture_lod_bias *****// + +const + GL_TEXTURE_FILTER_CONTROL_EXT* = 0x00008500 + GL_TEXTURE_LOD_BIAS_EXT* = 0x00008501 + GL_MAX_TEXTURE_LOD_BIAS_EXT* = 0x000084FD + #***** GL_EXT_texture_object *****// + +const + GL_TEXTURE_PRIORITY_EXT* = 0x00008066 + GL_TEXTURE_RESIDENT_EXT* = 0x00008067 + GL_TEXTURE_1D_BINDING_EXT* = 0x00008068 + GL_TEXTURE_2D_BINDING_EXT* = 0x00008069 + GL_TEXTURE_3D_BINDING_EXT* = 0x0000806A + +proc glGenTexturesEXT*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, + importc: "glGenTexturesEXT".} +proc glDeleteTexturesEXT*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, + importc: "glDeleteTexturesEXT".} +proc glBindTextureEXT*(target: TGLenum, texture: TGLuint){.dynlib: dllname, + importc: "glBindTextureEXT".} +proc glPrioritizeTexturesEXT*(n: TGLsizei, textures: PGLuint, + priorities: PGLclampf){.dynlib: dllname, + importc: "glPrioritizeTexturesEXT".} +proc glAreTexturesResidentEXT*(n: TGLsizei, textures: PGLuint, + residences: PGLboolean): TGLboolean{. + dynlib: dllname, importc: "glAreTexturesResidentEXT".} +proc glIsTextureEXT*(texture: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsTextureEXT".} + #***** GL_EXT_vertex_array *****// +const + GL_VERTEX_ARRAY_EXT* = 0x00008074 + GL_NORMAL_ARRAY_EXT* = 0x00008075 + GL_COLOR_ARRAY_EXT* = 0x00008076 + GL_INDEX_ARRAY_EXT* = 0x00008077 + GL_TEXTURE_COORD_ARRAY_EXT* = 0x00008078 + GL_EDGE_FLAG_ARRAY_EXT* = 0x00008079 + GL_DOUBLE_EXT* = 0x0000140A + GL_VERTEX_ARRAY_SIZE_EXT* = 0x0000807A + GL_VERTEX_ARRAY_TYPE_EXT* = 0x0000807B + GL_VERTEX_ARRAY_STRIDE_EXT* = 0x0000807C + GL_VERTEX_ARRAY_COUNT_EXT* = 0x0000807D + GL_NORMAL_ARRAY_TYPE_EXT* = 0x0000807E + GL_NORMAL_ARRAY_STRIDE_EXT* = 0x0000807F + GL_NORMAL_ARRAY_COUNT_EXT* = 0x00008080 + GL_COLOR_ARRAY_SIZE_EXT* = 0x00008081 + GL_COLOR_ARRAY_TYPE_EXT* = 0x00008082 + GL_COLOR_ARRAY_STRIDE_EXT* = 0x00008083 + GL_COLOR_ARRAY_COUNT_EXT* = 0x00008084 + GL_INDEX_ARRAY_TYPE_EXT* = 0x00008085 + GL_INDEX_ARRAY_STRIDE_EXT* = 0x00008086 + GL_INDEX_ARRAY_COUNT_EXT* = 0x00008087 + GL_TEXTURE_COORD_ARRAY_SIZE_EXT* = 0x00008088 + GL_TEXTURE_COORD_ARRAY_TYPE_EXT* = 0x00008089 + GL_TEXTURE_COORD_ARRAY_STRIDE_EXT* = 0x0000808A + GL_TEXTURE_COORD_ARRAY_COUNT_EXT* = 0x0000808B + GL_EDGE_FLAG_ARRAY_STRIDE_EXT* = 0x0000808C + GL_EDGE_FLAG_ARRAY_COUNT_EXT* = 0x0000808D + GL_VERTEX_ARRAY_POINTER_EXT* = 0x0000808E + GL_NORMAL_ARRAY_POINTER_EXT* = 0x0000808F + GL_COLOR_ARRAY_POINTER_EXT* = 0x00008090 + GL_INDEX_ARRAY_POINTER_EXT* = 0x00008091 + GL_TEXTURE_COORD_ARRAY_POINTER_EXT* = 0x00008092 + GL_EDGE_FLAG_ARRAY_POINTER_EXT* = 0x00008093 + +proc glArrayElementEXT*(i: TGLint){.dynlib: dllname, + importc: "glArrayElementEXT".} +proc glDrawArraysEXT*(mode: TGLenum, first: TGLint, count: TGLsizei){. + dynlib: dllname, importc: "glDrawArraysEXT".} +proc glVertexPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, + importc: "glVertexPointerEXT".} +proc glNormalPointerEXT*(thetype: TGLenum, stride: TGLsizei, count: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, + importc: "glNormalPointerEXT".} +proc glColorPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, + importc: "glColorPointerEXT".} +proc glIndexPointerEXT*(thetype: TGLenum, stride: TGLsizei, count: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, + importc: "glIndexPointerEXT".} +proc glTexCoordPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, + importc: "glTexCoordPointerEXT".} +proc glEdgeFlagPointerEXT*(stride: TGLsizei, count: TGLsizei, + pointer: PGLboolean){.dynlib: dllname, + importc: "glEdgeFlagPointerEXT".} +proc glGetPointervEXT*(pname: TGLenum, params: PGLvoid){.dynlib: dllname, + importc: "glGetPointervEXT".} + #***** GL_EXT_vertex_shader *****// +const + GL_VERTEX_SHADER_EXT* = 0x00008780 + GL_VARIANT_VALUE_EXT* = 0x000087E4 + GL_VARIANT_DATATYPE_EXT* = 0x000087E5 + GL_VARIANT_ARRAY_STRIDE_EXT* = 0x000087E6 + GL_VARIANT_ARRAY_TYPE_EXT* = 0x000087E7 + GL_VARIANT_ARRAY_EXT* = 0x000087E8 + GL_VARIANT_ARRAY_POINTER_EXT* = 0x000087E9 + GL_INVARIANT_VALUE_EXT* = 0x000087EA + GL_INVARIANT_DATATYPE_EXT* = 0x000087EB + GL_LOCAL_CONSTANT_VALUE_EXT* = 0x000087EC + GL_LOCAL_CONSTANT_DATATYPE_EXT* = 0x000087ED + GL_OP_INDEX_EXT* = 0x00008782 + GL_OP_NEGATE_EXT* = 0x00008783 + GL_OP_DOT3_EXT* = 0x00008784 + GL_OP_DOT4_EXT* = 0x00008785 + GL_OP_MUL_EXT* = 0x00008786 + GL_OP_ADD_EXT* = 0x00008787 + GL_OP_MADD_EXT* = 0x00008788 + GL_OP_FRAC_EXT* = 0x00008789 + GL_OP_MAX_EXT* = 0x0000878A + GL_OP_MIN_EXT* = 0x0000878B + GL_OP_SET_GE_EXT* = 0x0000878C + GL_OP_SET_LT_EXT* = 0x0000878D + GL_OP_CLAMP_EXT* = 0x0000878E + GL_OP_FLOOR_EXT* = 0x0000878F + GL_OP_ROUND_EXT* = 0x00008790 + GL_OP_EXP_BASE_2_EXT* = 0x00008791 + GL_OP_LOG_BASE_2_EXT* = 0x00008792 + GL_OP_POWER_EXT* = 0x00008793 + GL_OP_RECIP_EXT* = 0x00008794 + GL_OP_RECIP_SQRT_EXT* = 0x00008795 + GL_OP_SUB_EXT* = 0x00008796 + GL_OP_CROSS_PRODUCT_EXT* = 0x00008797 + GL_OP_MULTIPLY_MATRIX_EXT* = 0x00008798 + GL_OP_MOV_EXT* = 0x00008799 + GL_OUTPUT_VERTEX_EXT* = 0x0000879A + GL_OUTPUT_COLOR0_EXT* = 0x0000879B + GL_OUTPUT_COLOR1_EXT* = 0x0000879C + GL_OUTPUT_TEXTURE_COORD0_EXT* = 0x0000879D + GL_OUTPUT_TEXTURE_COORD1_EXT* = 0x0000879E + GL_OUTPUT_TEXTURE_COORD2_EXT* = 0x0000879F + GL_OUTPUT_TEXTURE_COORD3_EXT* = 0x000087A0 + GL_OUTPUT_TEXTURE_COORD4_EXT* = 0x000087A1 + GL_OUTPUT_TEXTURE_COORD5_EXT* = 0x000087A2 + GL_OUTPUT_TEXTURE_COORD6_EXT* = 0x000087A3 + GL_OUTPUT_TEXTURE_COORD7_EXT* = 0x000087A4 + GL_OUTPUT_TEXTURE_COORD8_EXT* = 0x000087A5 + GL_OUTPUT_TEXTURE_COORD9_EXT* = 0x000087A6 + GL_OUTPUT_TEXTURE_COORD10_EXT* = 0x000087A7 + GL_OUTPUT_TEXTURE_COORD11_EXT* = 0x000087A8 + GL_OUTPUT_TEXTURE_COORD12_EXT* = 0x000087A9 + GL_OUTPUT_TEXTURE_COORD13_EXT* = 0x000087AA + GL_OUTPUT_TEXTURE_COORD14_EXT* = 0x000087AB + GL_OUTPUT_TEXTURE_COORD15_EXT* = 0x000087AC + GL_OUTPUT_TEXTURE_COORD16_EXT* = 0x000087AD + GL_OUTPUT_TEXTURE_COORD17_EXT* = 0x000087AE + GL_OUTPUT_TEXTURE_COORD18_EXT* = 0x000087AF + GL_OUTPUT_TEXTURE_COORD19_EXT* = 0x000087B0 + GL_OUTPUT_TEXTURE_COORD20_EXT* = 0x000087B1 + GL_OUTPUT_TEXTURE_COORD21_EXT* = 0x000087B2 + GL_OUTPUT_TEXTURE_COORD22_EXT* = 0x000087B3 + GL_OUTPUT_TEXTURE_COORD23_EXT* = 0x000087B4 + GL_OUTPUT_TEXTURE_COORD24_EXT* = 0x000087B5 + GL_OUTPUT_TEXTURE_COORD25_EXT* = 0x000087B6 + GL_OUTPUT_TEXTURE_COORD26_EXT* = 0x000087B7 + GL_OUTPUT_TEXTURE_COORD27_EXT* = 0x000087B8 + GL_OUTPUT_TEXTURE_COORD28_EXT* = 0x000087B9 + GL_OUTPUT_TEXTURE_COORD29_EXT* = 0x000087BA + GL_OUTPUT_TEXTURE_COORD30_EXT* = 0x000087BB + GL_OUTPUT_TEXTURE_COORD31_EXT* = 0x000087BC + GL_OUTPUT_FOG_EXT* = 0x000087BD + GL_SCALAR_EXT* = 0x000087BE + GL_VECTOR_EXT* = 0x000087BF + GL_MATRIX_EXT* = 0x000087C0 + GL_VARIANT_EXT* = 0x000087C1 + GL_INVARIANT_EXT* = 0x000087C2 + GL_LOCAL_CONSTANT_EXT* = 0x000087C3 + GL_LOCAL_EXT* = 0x000087C4 + GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT* = 0x000087C5 + GL_MAX_VERTEX_SHADER_VARIANTS_EXT* = 0x000087C6 + GL_MAX_VERTEX_SHADER_INVARIANTS_EXT* = 0x000087C7 + GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT* = 0x000087C8 + GL_MAX_VERTEX_SHADER_LOCALS_EXT* = 0x000087C9 + GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT* = 0x000087CA + GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT* = 0x000087CB + GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT* = 0x000087CC + GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT* = 0x000087CD + GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT* = 0x000087CE + GL_VERTEX_SHADER_INSTRUCTIONS_EXT* = 0x000087CF + GL_VERTEX_SHADER_VARIANTS_EXT* = 0x000087D0 + GL_VERTEX_SHADER_INVARIANTS_EXT* = 0x000087D1 + GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT* = 0x000087D2 + GL_VERTEX_SHADER_LOCALS_EXT* = 0x000087D3 + GL_VERTEX_SHADER_BINDING_EXT* = 0x00008781 + GL_VERTEX_SHADER_OPTIMIZED_EXT* = 0x000087D4 + GL_X_EXT* = 0x000087D5 + GL_Y_EXT* = 0x000087D6 + GL_Z_EXT* = 0x000087D7 + GL_W_EXT* = 0x000087D8 + GL_NEGATIVE_X_EXT* = 0x000087D9 + GL_NEGATIVE_Y_EXT* = 0x000087DA + GL_NEGATIVE_Z_EXT* = 0x000087DB + GL_NEGATIVE_W_EXT* = 0x000087DC + GL_ZERO_EXT* = 0x000087DD + GL_ONE_EXT* = 0x000087DE + GL_NEGATIVE_ONE_EXT* = 0x000087DF + GL_NORMALIZED_RANGE_EXT* = 0x000087E0 + GL_FULL_RANGE_EXT* = 0x000087E1 + GL_CURRENT_VERTEX_EXT* = 0x000087E2 + GL_MVP_MATRIX_EXT* = 0x000087E3 + +proc glBeginVertexShaderEXT*(){.dynlib: dllname, + importc: "glBeginVertexShaderEXT".} +proc glEndVertexShaderEXT*(){.dynlib: dllname, importc: "glEndVertexShaderEXT".} +proc glBindVertexShaderEXT*(id: TGLuint){.dynlib: dllname, + importc: "glBindVertexShaderEXT".} +proc glGenVertexShadersEXT*(range: TGLuint): TGLuint{.dynlib: dllname, + importc: "glGenVertexShadersEXT".} +proc glDeleteVertexShaderEXT*(id: TGLuint){.dynlib: dllname, + importc: "glDeleteVertexShaderEXT".} +proc glShaderOp1EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint){.dynlib: dllname, + importc: "glShaderOp1EXT".} +proc glShaderOp2EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint, arg2: TGLuint){. + dynlib: dllname, importc: "glShaderOp2EXT".} +proc glShaderOp3EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint, arg2: TGLuint, + arg3: TGLuint){.dynlib: dllname, importc: "glShaderOp3EXT".} +proc glSwizzleEXT*(res: TGLuint, theIn: TGLuint, outX: TGLenum, outY: TGLenum, + outZ: TGLenum, outW: TGLenum){.dynlib: dllname, + importc: "glSwizzleEXT".} +proc glWriteMaskEXT*(res: TGLuint, theIn: TGLuint, outX: TGLenum, outY: TGLenum, + outZ: TGLenum, outW: TGLenum){.dynlib: dllname, + importc: "glWriteMaskEXT".} +proc glInsertComponentEXT*(res: TGLuint, src: TGLuint, num: TGLuint){. + dynlib: dllname, importc: "glInsertComponentEXT".} +proc glExtractComponentEXT*(res: TGLuint, src: TGLuint, num: TGLuint){. + dynlib: dllname, importc: "glExtractComponentEXT".} +proc glGenSymbolsEXT*(datatype: TGLenum, storagetype: TGLenum, range: TGLenum, + components: TGLuint): TGLuint{.dynlib: dllname, + importc: "glGenSymbolsEXT".} +proc glSetInvariantEXT*(id: TGLuint, thetype: TGLenum, address: PGLvoid){. + dynlib: dllname, importc: "glSetInvariantEXT".} +proc glSetLocalConstantEXT*(id: TGLuint, thetype: TGLenum, address: PGLvoid){. + dynlib: dllname, importc: "glSetLocalConstantEXT".} +proc glVariantbvEXT*(id: TGLuint, address: PGLbyte){.dynlib: dllname, + importc: "glVariantbvEXT".} +proc glVariantsvEXT*(id: TGLuint, address: PGLshort){.dynlib: dllname, + importc: "glVariantsvEXT".} +proc glVariantivEXT*(id: TGLuint, address: PGLint){.dynlib: dllname, + importc: "glVariantivEXT".} +proc glVariantfvEXT*(id: TGLuint, address: PGLfloat){.dynlib: dllname, + importc: "glVariantfvEXT".} +proc glVariantdvEXT*(id: TGLuint, address: PGLdouble){.dynlib: dllname, + importc: "glVariantdvEXT".} +proc glVariantubvEXT*(id: TGLuint, address: PGLubyte){.dynlib: dllname, + importc: "glVariantubvEXT".} +proc glVariantusvEXT*(id: TGLuint, address: PGLushort){.dynlib: dllname, + importc: "glVariantusvEXT".} +proc glVariantuivEXT*(id: TGLuint, address: PGLuint){.dynlib: dllname, + importc: "glVariantuivEXT".} +proc glVariantPointerEXT*(id: TGLuint, thetype: TGLenum, stride: TGLuint, + address: PGLvoid){.dynlib: dllname, + importc: "glVariantPointerEXT".} +proc glEnableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, + importc: "glEnableVariantClientStateEXT".} +proc glDisableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, + importc: "glDisableVariantClientStateEXT".} +proc glBindLightParameterEXT*(light: TGLenum, value: TGLenum): TGLuint{. + dynlib: dllname, importc: "glBindLightParameterEXT".} +proc glBindMaterialParameterEXT*(face: TGLenum, value: TGLenum): TGLuint{. + dynlib: dllname, importc: "glBindMaterialParameterEXT".} +proc glBindTexGenParameterEXT*(theunit: TGLenum, coord: TGLenum, value: TGLenum): TGLuint{. + dynlib: dllname, importc: "glBindTexGenParameterEXT".} +proc glBindTextureUnitParameterEXT*(theunit: TGLenum, value: TGLenum): TGLuint{. + dynlib: dllname, importc: "glBindTextureUnitParameterEXT".} +proc glBindParameterEXT*(value: TGLenum): TGLuint{.dynlib: dllname, + importc: "glBindParameterEXT".} +proc glIsVariantEnabledEXT*(id: TGLuint, cap: TGLenum): TGLboolean{. + dynlib: dllname, importc: "glIsVariantEnabledEXT".} +proc glGetVariantBooleanvEXT*(id: TGLuint, value: TGLenum, data: PGLboolean){. + dynlib: dllname, importc: "glGetVariantBooleanvEXT".} +proc glGetVariantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){. + dynlib: dllname, importc: "glGetVariantIntegervEXT".} +proc glGetVariantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){. + dynlib: dllname, importc: "glGetVariantFloatvEXT".} +proc glGetVariantPointervEXT*(id: TGLuint, value: TGLenum, data: PGLvoid){. + dynlib: dllname, importc: "glGetVariantPointervEXT".} +proc glGetInvariantBooleanvEXT*(id: TGLuint, value: TGLenum, data: PGLboolean){. + dynlib: dllname, importc: "glGetInvariantBooleanvEXT".} +proc glGetInvariantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){. + dynlib: dllname, importc: "glGetInvariantIntegervEXT".} +proc glGetInvariantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){. + dynlib: dllname, importc: "glGetInvariantFloatvEXT".} +proc glGetLocalConstantBooleanvEXT*(id: TGLuint, value: TGLenum, + data: PGLboolean){.dynlib: dllname, + importc: "glGetLocalConstantBooleanvEXT".} +proc glGetLocalConstantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){. + dynlib: dllname, importc: "glGetLocalConstantIntegervEXT".} +proc glGetLocalConstantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){. + dynlib: dllname, importc: "glGetLocalConstantFloatvEXT".} + #***** GL_EXT_vertex_weighting *****// +const + GL_VERTEX_WEIGHTING_EXT* = 0x00008509 + GL_MODELVIEW0_EXT* = 0x00001700 + GL_MODELVIEW1_EXT* = 0x0000850A + GL_MODELVIEW0_MATRIX_EXT* = 0x00000BA6 + GL_MODELVIEW1_MATRIX_EXT* = 0x00008506 + GL_CURRENT_VERTEX_WEIGHT_EXT* = 0x0000850B + GL_VERTEX_WEIGHT_ARRAY_EXT* = 0x0000850C + GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT* = 0x0000850D + GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT* = 0x0000850E + GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT* = 0x0000850F + GL_MODELVIEW0_STACK_DEPTH_EXT* = 0x00000BA3 + GL_MODELVIEW1_STACK_DEPTH_EXT* = 0x00008502 + GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT* = 0x00008510 + +proc glVertexWeightfEXT*(weight: TGLfloat){.dynlib: dllname, + importc: "glVertexWeightfEXT".} +proc glVertexWeightfvEXT*(weight: PGLfloat){.dynlib: dllname, + importc: "glVertexWeightfvEXT".} +proc glVertexWeightPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, + importc: "glVertexWeightPointerEXT".} + #***** GL_HP_occlusion_test *****// +const + GL_OCCLUSION_TEST_HP* = 0x00008165 + GL_OCCLUSION_TEST_RESULT_HP* = 0x00008166 + #***** GL_NV_blend_square *****// + #***** GL_NV_copy_depth_to_color *****// + +const + GL_DEPTH_STENCIL_TO_RGBA_NV* = 0x0000886E + GL_DEPTH_STENCIL_TO_BGRA_NV* = 0x0000886F + #***** GL_NV_depth_clamp *****// + +const + GL_DEPTH_CLAMP_NV* = 0x0000864F + #***** GL_NV_evaluators *****// + +const + GL_EVAL_2D_NV* = 0x000086C0 + GL_EVAL_TRIANGULAR_2D_NV* = 0x000086C1 + GL_MAP_TESSELLATION_NV* = 0x000086C2 + GL_MAP_ATTRIB_U_ORDER_NV* = 0x000086C3 + GL_MAP_ATTRIB_V_ORDER_NV* = 0x000086C4 + GL_EVAL_FRACTIONAL_TESSELLATION_NV* = 0x000086C5 + GL_EVAL_VERTEX_ATTRIB0_NV* = 0x000086C6 + GL_EVAL_VERTEX_ATTRIB1_NV* = 0x000086C7 + GL_EVAL_VERTEX_ATTRIB2_NV* = 0x000086C8 + GL_EVAL_VERTEX_ATTRIB3_NV* = 0x000086C9 + GL_EVAL_VERTEX_ATTRIB4_NV* = 0x000086CA + GL_EVAL_VERTEX_ATTRIB5_NV* = 0x000086CB + GL_EVAL_VERTEX_ATTRIB6_NV* = 0x000086CC + GL_EVAL_VERTEX_ATTRIB7_NV* = 0x000086CD + GL_EVAL_VERTEX_ATTRIB8_NV* = 0x000086CE + GL_EVAL_VERTEX_ATTRIB9_NV* = 0x000086CF + GL_EVAL_VERTEX_ATTRIB10_NV* = 0x000086D0 + GL_EVAL_VERTEX_ATTRIB11_NV* = 0x000086D1 + GL_EVAL_VERTEX_ATTRIB12_NV* = 0x000086D2 + GL_EVAL_VERTEX_ATTRIB13_NV* = 0x000086D3 + GL_EVAL_VERTEX_ATTRIB14_NV* = 0x000086D4 + GL_EVAL_VERTEX_ATTRIB15_NV* = 0x000086D5 + GL_MAX_MAP_TESSELLATION_NV* = 0x000086D6 + GL_MAX_RATIONAL_EVAL_ORDER_NV* = 0x000086D7 + +proc glMapControlPointsNV*(target: TGLenum, index: TGLuint, thetype: TGLenum, + ustride: TGLsizei, vstride: TGLsizei, uorder: TGLint, + vorder: TGLint, thepacked: TGLboolean, + points: PGLvoid){.dynlib: dllname, + importc: "glMapControlPointsNV".} +proc glMapParameterivNV*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glMapParameterivNV".} +proc glMapParameterfvNV*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glMapParameterfvNV".} +proc glGetMapControlPointsNV*(target: TGLenum, index: TGLuint, thetype: TGLenum, + ustride: TGLsizei, vstride: TGLsizei, + thepacked: TGLboolean, points: PGLvoid){. + dynlib: dllname, importc: "glGetMapControlPointsNV".} +proc glGetMapParameterivNV*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetMapParameterivNV".} +proc glGetMapParameterfvNV*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetMapParameterfvNV".} +proc glGetMapAttribParameterivNV*(target: TGLenum, index: TGLuint, + pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetMapAttribParameterivNV".} +proc glGetMapAttribParameterfvNV*(target: TGLenum, index: TGLuint, + pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetMapAttribParameterfvNV".} +proc glEvalMapsNV*(target: TGLenum, mode: TGLenum){.dynlib: dllname, + importc: "glEvalMapsNV".} + #***** GL_NV_fence *****// +const + GL_ALL_COMPLETED_NV* = 0x000084F2 + GL_FENCE_STATUS_NV* = 0x000084F3 + GL_FENCE_CONDITION_NV* = 0x000084F4 + +proc glGenFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, + importc: "glGenFencesNV".} +proc glDeleteFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, + importc: "glDeleteFencesNV".} +proc glSetFenceNV*(fence: TGLuint, condition: TGLenum){.dynlib: dllname, + importc: "glSetFenceNV".} +proc glTestFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glTestFenceNV".} +proc glFinishFenceNV*(fence: TGLuint){.dynlib: dllname, + importc: "glFinishFenceNV".} +proc glIsFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsFenceNV".} +proc glGetFenceivNV*(fence: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetFenceivNV".} + #***** GL_NV_fog_distance *****// +const + GL_FOG_DISTANCE_MODE_NV* = 0x0000855A + GL_EYE_RADIAL_NV* = 0x0000855B + GL_EYE_PLANE_ABSOLUTE_NV* = 0x0000855C + #***** GL_NV_light_max_exponent *****// + +const + GL_MAX_SHININESS_NV* = 0x00008504 + GL_MAX_SPOT_EXPONENT_NV* = 0x00008505 + #***** GL_NV_multisample_filter_hint *****// + +const + GL_MULTISAMPLE_FILTER_HINT_NV* = 0x00008534 + #***** GL_NV_occlusion_query *****// + # GL_OCCLUSION_TEST_HP { already defined } + # GL_OCCLUSION_TEST_RESULT_HP { already defined } + +const + GL_PIXEL_COUNTER_BITS_NV* = 0x00008864 + GL_CURRENT_OCCLUSION_QUERY_ID_NV* = 0x00008865 + GL_PIXEL_COUNT_NV* = 0x00008866 + GL_PIXEL_COUNT_AVAILABLE_NV* = 0x00008867 + +proc glGenOcclusionQueriesNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc: "glGenOcclusionQueriesNV".} +proc glDeleteOcclusionQueriesNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc: "glDeleteOcclusionQueriesNV".} +proc glIsOcclusionQueryNV*(id: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsOcclusionQueryNV".} +proc glBeginOcclusionQueryNV*(id: TGLuint){.dynlib: dllname, + importc: "glBeginOcclusionQueryNV".} +proc glEndOcclusionQueryNV*(){.dynlib: dllname, importc: "glEndOcclusionQueryNV".} +proc glGetOcclusionQueryivNV*(id: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetOcclusionQueryivNV".} +proc glGetOcclusionQueryuivNV*(id: TGLuint, pname: TGLenum, params: PGLuint){. + dynlib: dllname, importc: "glGetOcclusionQueryuivNV".} + #***** GL_NV_packed_depth_stencil *****// +const + GL_DEPTH_STENCIL_NV* = 0x000084F9 + GL_UNSIGNED_INT_24_8_NV* = 0x000084FA + #***** GL_NV_point_sprite *****// + +const + GL_POINT_SPRITE_NV* = 0x00008861 + GL_COORD_REPLACE_NV* = 0x00008862 + GL_POINT_SPRITE_R_MODE_NV* = 0x00008863 + +proc glPointParameteriNV*(pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glPointParameteriNV".} +proc glPointParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glPointParameterivNV".} + #***** GL_NV_register_combiners *****// +const + GL_REGISTER_COMBINERS_NV* = 0x00008522 + GL_COMBINER0_NV* = 0x00008550 + GL_COMBINER1_NV* = 0x00008551 + GL_COMBINER2_NV* = 0x00008552 + GL_COMBINER3_NV* = 0x00008553 + GL_COMBINER4_NV* = 0x00008554 + GL_COMBINER5_NV* = 0x00008555 + GL_COMBINER6_NV* = 0x00008556 + GL_COMBINER7_NV* = 0x00008557 + GL_VARIABLE_A_NV* = 0x00008523 + GL_VARIABLE_B_NV* = 0x00008524 + GL_VARIABLE_C_NV* = 0x00008525 + GL_VARIABLE_D_NV* = 0x00008526 + GL_VARIABLE_E_NV* = 0x00008527 + GL_VARIABLE_F_NV* = 0x00008528 + GL_VARIABLE_G_NV* = 0x00008529 + GL_CONSTANT_COLOR0_NV* = 0x0000852A + GL_CONSTANT_COLOR1_NV* = 0x0000852B + GL_PRIMARY_COLOR_NV* = 0x0000852C + GL_SECONDARY_COLOR_NV* = 0x0000852D + GL_SPARE0_NV* = 0x0000852E + GL_SPARE1_NV* = 0x0000852F + GL_UNSIGNED_IDENTITY_NV* = 0x00008536 + GL_UNSIGNED_INVERT_NV* = 0x00008537 + GL_EXPAND_NORMAL_NV* = 0x00008538 + GL_EXPAND_NEGATE_NV* = 0x00008539 + GL_HALF_BIAS_NORMAL_NV* = 0x0000853A + GL_HALF_BIAS_NEGATE_NV* = 0x0000853B + GL_SIGNED_IDENTITY_NV* = 0x0000853C + GL_SIGNED_NEGATE_NV* = 0x0000853D + GL_E_TIMES_F_NV* = 0x00008531 + GL_SPARE0_PLUS_SECONDARY_COLOR_NV* = 0x00008532 + GL_SCALE_BY_TWO_NV* = 0x0000853E + GL_SCALE_BY_FOUR_NV* = 0x0000853F + GL_SCALE_BY_ONE_HALF_NV* = 0x00008540 + GL_BIAS_BY_NEGATIVE_ONE_HALF_NV* = 0x00008541 + GL_DISCARD_NV* = 0x00008530 + constGL_COMBINER_INPUT_NV* = 0x00008542 + GL_COMBINER_MAPPING_NV* = 0x00008543 + GL_COMBINER_COMPONENT_USAGE_NV* = 0x00008544 + GL_COMBINER_AB_DOT_PRODUCT_NV* = 0x00008545 + GL_COMBINER_CD_DOT_PRODUCT_NV* = 0x00008546 + GL_COMBINER_MUX_SUM_NV* = 0x00008547 + GL_COMBINER_SCALE_NV* = 0x00008548 + GL_COMBINER_BIAS_NV* = 0x00008549 + GL_COMBINER_AB_OUTPUT_NV* = 0x0000854A + GL_COMBINER_CD_OUTPUT_NV* = 0x0000854B + GL_COMBINER_SUM_OUTPUT_NV* = 0x0000854C + GL_NUM_GENERAL_COMBINERS_NV* = 0x0000854E + GL_COLOR_SUM_CLAMP_NV* = 0x0000854F + GL_MAX_GENERAL_COMBINERS_NV* = 0x0000854D + +proc glCombinerParameterfvNV*(pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glCombinerParameterfvNV".} +proc glCombinerParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glCombinerParameterivNV".} +proc glCombinerParameterfNV*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glCombinerParameterfNV".} +proc glCombinerParameteriNV*(pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glCombinerParameteriNV".} +proc glCombinerInputNV*(stage: TGLenum, portion: TGLenum, variable: TGLenum, + input: TGLenum, mapping: TGLenum, + componentUsage: TGLenum){.dynlib: dllname, + importc: "glCombinerInputNV".} +proc glCombinerOutputNV*(stage: TGLenum, portion: TGLenum, abOutput: TGLenum, + cdOutput: TGLenum, sumOutput: TGLenum, scale: TGLenum, + bias: TGLenum, abDotProduct: TGLboolean, + cdDotProduct: TGLboolean, muxSum: TGLboolean){. + dynlib: dllname, importc: "glCombinerOutputNV".} +proc glFinalCombinerInputNV*(variable: TGLenum, input: TGLenum, + mapping: TGLenum, componentUsage: TGLenum){. + dynlib: dllname, importc: "glFinalCombinerInputNV".} +proc glGetCombinerInputParameterfvNV*(stage: TGLenum, portion: TGLenum, + variable: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetCombinerInputParameterfvNV".} +proc glGetCombinerInputParameterivNV*(stage: TGLenum, portion: TGLenum, + variable: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetCombinerInputParameterivNV".} +proc glGetCombinerOutputParameterfvNV*(stage: TGLenum, portion: TGLenum, + pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetCombinerOutputParameterfvNV".} +proc glGetCombinerOutputParameterivNV*(stage: TGLenum, portion: TGLenum, + pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetCombinerOutputParameterivNV".} +proc glGetFinalCombinerInputParameterfvNV*(variable: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetFinalCombinerInputParameterfvNV".} +proc glGetFinalCombinerInputParameterivNV*(variable: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetFinalCombinerInputParameterivNV".} + #***** GL_NV_register_combiners2 *****// +const + GL_PER_STAGE_CONSTANTS_NV* = 0x00008535 + +proc glCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glCombinerStageParameterfvNV".} +proc glGetCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetCombinerStageParameterfvNV".} + #***** GL_NV_texgen_emboss *****// +const + GL_EMBOSS_MAP_NV* = 0x0000855F + GL_EMBOSS_LIGHT_NV* = 0x0000855D + GL_EMBOSS_CONSTANT_NV* = 0x0000855E + #***** GL_NV_texgen_reflection *****// + +const + GL_NORMAL_MAP_NV* = 0x00008511 + GL_REFLECTION_MAP_NV* = 0x00008512 + #***** GL_NV_texture_compression_vtc *****// + # GL_COMPRESSED_RGB_S3TC_DXT1_EXT { already defined } + # GL_COMPRESSED_RGBA_S3TC_DXT1_EXT { already defined } + # GL_COMPRESSED_RGBA_S3TC_DXT3_EXT { already defined } + # GL_COMPRESSED_RGBA_S3TC_DXT5_EXT { already defined } + #***** GL_NV_texture_env_combine4 *****// + +const + GL_COMBINE4_NV* = 0x00008503 + GL_SOURCE3_RGB_NV* = 0x00008583 + GL_SOURCE3_ALPHA_NV* = 0x0000858B + GL_OPERAND3_RGB_NV* = 0x00008593 + GL_OPERAND3_ALPHA_NV* = 0x0000859B + #***** GL_NV_texture_rectangle *****// + +const + GL_TEXTURE_RECTANGLE_NV* = 0x000084F5 + GL_TEXTURE_BINDING_RECTANGLE_NV* = 0x000084F6 + GL_PROXY_TEXTURE_RECTANGLE_NV* = 0x000084F7 + GL_MAX_RECTANGLE_TEXTURE_SIZE_NV* = 0x000084F8 + #***** GL_NV_texture_shader *****// + +const + GL_TEXTURE_SHADER_NV* = 0x000086DE + GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV* = 0x000086D9 + GL_SHADER_OPERATION_NV* = 0x000086DF + GL_CULL_MODES_NV* = 0x000086E0 + GL_OFFSET_TEXTURE_MATRIX_NV* = 0x000086E1 + GL_OFFSET_TEXTURE_SCALE_NV* = 0x000086E2 + GL_OFFSET_TEXTURE_BIAS_NV* = 0x000086E3 + GL_PREVIOUS_TEXTURE_INPUT_NV* = 0x000086E4 + GL_CONST_EYE_NV* = 0x000086E5 + GL_SHADER_CONSISTENT_NV* = 0x000086DD + GL_PASS_THROUGH_NV* = 0x000086E6 + GL_CULL_FRAGMENT_NV* = 0x000086E7 + GL_OFFSET_TEXTURE_2D_NV* = 0x000086E8 + GL_OFFSET_TEXTURE_RECTANGLE_NV* = 0x0000864C + GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV* = 0x0000864D + GL_DEPENDENT_AR_TEXTURE_2D_NV* = 0x000086E9 + GL_DEPENDENT_GB_TEXTURE_2D_NV* = 0x000086EA + GL_DOT_PRODUCT_NV* = 0x000086EC + GL_DOT_PRODUCT_DEPTH_REPLACE_NV* = 0x000086ED + GL_DOT_PRODUCT_TEXTURE_2D_NV* = 0x000086EE + GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV* = 0x0000864E + GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV* = 0x000086F0 + GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV* = 0x000086F1 + GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV* = 0x000086F2 + GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV* = 0x000086F3 + GL_HILO_NV* = 0x000086F4 + GL_DSDT_NV* = 0x000086F5 + GL_DSDT_MAG_NV* = 0x000086F6 + GL_DSDT_MAG_VIB_NV* = 0x000086F7 + GL_UNSIGNED_INT_S8_S8_8_8_NV* = 0x000086DA + GL_UNSIGNED_INT_8_8_S8_S8_REV_NV* = 0x000086DB + GL_SIGNED_RGBA_NV* = 0x000086FB + GL_SIGNED_RGBA8_NV* = 0x000086FC + GL_SIGNED_RGB_NV* = 0x000086FE + GL_SIGNED_RGB8_NV* = 0x000086FF + GL_SIGNED_LUMINANCE_NV* = 0x00008701 + GL_SIGNED_LUMINANCE8_NV* = 0x00008702 + GL_SIGNED_LUMINANCE_ALPHA_NV* = 0x00008703 + GL_SIGNED_LUMINANCE8_ALPHA8_NV* = 0x00008704 + GL_SIGNED_ALPHA_NV* = 0x00008705 + GL_SIGNED_ALPHA8_NV* = 0x00008706 + GL_SIGNED_INTENSITY_NV* = 0x00008707 + GL_SIGNED_INTENSITY8_NV* = 0x00008708 + GL_SIGNED_RGB_UNSIGNED_ALPHA_NV* = 0x0000870C + GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV* = 0x0000870D + GL_HILO16_NV* = 0x000086F8 + GL_SIGNED_HILO_NV* = 0x000086F9 + GL_SIGNED_HILO16_NV* = 0x000086FA + GL_DSDT8_NV* = 0x00008709 + GL_DSDT8_MAG8_NV* = 0x0000870A + GL_DSDT_MAG_INTENSITY_NV* = 0x000086DC + GL_DSDT8_MAG8_INTENSITY8_NV* = 0x0000870B + GL_HI_SCALE_NV* = 0x0000870E + GL_LO_SCALE_NV* = 0x0000870F + GL_DS_SCALE_NV* = 0x00008710 + GL_DT_SCALE_NV* = 0x00008711 + GL_MAGNITUDE_SCALE_NV* = 0x00008712 + GL_VIBRANCE_SCALE_NV* = 0x00008713 + GL_HI_BIAS_NV* = 0x00008714 + GL_LO_BIAS_NV* = 0x00008715 + GL_DS_BIAS_NV* = 0x00008716 + GL_DT_BIAS_NV* = 0x00008717 + GL_MAGNITUDE_BIAS_NV* = 0x00008718 + GL_VIBRANCE_BIAS_NV* = 0x00008719 + GL_TEXTURE_BORDER_VALUES_NV* = 0x0000871A + GL_TEXTURE_HI_SIZE_NV* = 0x0000871B + GL_TEXTURE_LO_SIZE_NV* = 0x0000871C + GL_TEXTURE_DS_SIZE_NV* = 0x0000871D + GL_TEXTURE_DT_SIZE_NV* = 0x0000871E + GL_TEXTURE_MAG_SIZE_NV* = 0x0000871F + #***** GL_NV_texture_shader2 *****// + +const + GL_DOT_PRODUCT_TEXTURE_3D_NV* = 0x000086EF # GL_HILO_NV { already defined } + # GL_DSDT_NV { already defined } + # GL_DSDT_MAG_NV { already defined } + # GL_DSDT_MAG_VIB_NV { already defined } + # GL_UNSIGNED_INT_S8_S8_8_8_NV { already defined } + # GL_UNSIGNED_INT_8_8_S8_S8_REV_NV { already defined } + # GL_SIGNED_RGBA_NV { already defined } + # GL_SIGNED_RGBA8_NV { already defined } + # GL_SIGNED_RGB_NV { already defined } + # GL_SIGNED_RGB8_NV { already defined } + # GL_SIGNED_LUMINANCE_NV { already defined } + # GL_SIGNED_LUMINANCE8_NV { already defined } + # GL_SIGNED_LUMINANCE_ALPHA_NV { already defined } + # GL_SIGNED_LUMINANCE8_ALPHA8_NV { already defined } + # GL_SIGNED_ALPHA_NV { already defined } + # GL_SIGNED_ALPHA8_NV { already defined } + # GL_SIGNED_INTENSITY_NV { already defined } + # GL_SIGNED_INTENSITY8_NV { already defined } + # GL_SIGNED_RGB_UNSIGNED_ALPHA_NV { already defined } + # GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV { already defined } + # GL_HILO16_NV { already defined } + # GL_SIGNED_HILO_NV { already defined } + # GL_SIGNED_HILO16_NV { already defined } + # GL_DSDT8_NV { already defined } + # GL_DSDT8_MAG8_NV { already defined } + # GL_DSDT_MAG_INTENSITY_NV { already defined } + # GL_DSDT8_MAG8_INTENSITY8_NV { already defined } + #***** GL_NV_texture_shader3 *****// + +const + GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV* = 0x00008850 + GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV* = 0x00008851 + GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV* = 0x00008852 + GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV* = 0x00008853 + GL_OFFSET_HILO_TEXTURE_2D_NV* = 0x00008854 + GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV* = 0x00008855 + GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV* = 0x00008856 + GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV* = 0x00008857 + GL_DEPENDENT_HILO_TEXTURE_2D_NV* = 0x00008858 + GL_DEPENDENT_RGB_TEXTURE_3D_NV* = 0x00008859 + GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV* = 0x0000885A + GL_DOT_PRODUCT_PASS_THROUGH_NV* = 0x0000885B + GL_DOT_PRODUCT_TEXTURE_1D_NV* = 0x0000885C + GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV* = 0x0000885D + GL_HILO8_NV* = 0x0000885E + GL_SIGNED_HILO8_NV* = 0x0000885F + GL_FORCE_BLUE_TO_ONE_NV* = 0x00008860 + #***** GL_NV_vertex_array_range *****// + +const + constGL_VERTEX_ARRAY_RANGE_NV* = 0x0000851D + GL_VERTEX_ARRAY_RANGE_LENGTH_NV* = 0x0000851E + GL_VERTEX_ARRAY_RANGE_VALID_NV* = 0x0000851F + GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV* = 0x00008520 + GL_VERTEX_ARRAY_RANGE_POINTER_NV* = 0x00008521 + +proc glVertexArrayRangeNV*(len: TGLsizei, pointer: PGLvoid){.dynlib: dllname, + importc: "glVertexArrayRangeNV".} +proc glFlushVertexArrayRangeNV*(){.dynlib: dllname, + importc: "glFlushVertexArrayRangeNV".} + #***** GL_NV_vertex_array_range2 *****// +const + GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV* = 0x00008533 + #***** GL_NV_vertex_program *****// + +const + GL_VERTEX_PROGRAM_NV* = 0x00008620 + GL_VERTEX_PROGRAM_POINT_SIZE_NV* = 0x00008642 + GL_VERTEX_PROGRAM_TWO_SIDE_NV* = 0x00008643 + GL_VERTEX_STATE_PROGRAM_NV* = 0x00008621 + GL_ATTRIB_ARRAY_SIZE_NV* = 0x00008623 + GL_ATTRIB_ARRAY_STRIDE_NV* = 0x00008624 + GL_ATTRIB_ARRAY_TYPE_NV* = 0x00008625 + GL_CURRENT_ATTRIB_NV* = 0x00008626 + GL_PROGRAM_PARAMETER_NV* = 0x00008644 + GL_ATTRIB_ARRAY_POINTER_NV* = 0x00008645 + GL_PROGRAM_TARGET_NV* = 0x00008646 + GL_PROGRAM_LENGTH_NV* = 0x00008627 + GL_PROGRAM_RESIDENT_NV* = 0x00008647 + GL_PROGRAM_STRING_NV* = 0x00008628 + constGL_TRACK_MATRIX_NV* = 0x00008648 + GL_TRACK_MATRIX_TRANSFORM_NV* = 0x00008649 + GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV* = 0x0000862E + GL_MAX_TRACK_MATRICES_NV* = 0x0000862F + GL_CURRENT_MATRIX_STACK_DEPTH_NV* = 0x00008640 + GL_CURRENT_MATRIX_NV* = 0x00008641 + GL_VERTEX_PROGRAM_BINDING_NV* = 0x0000864A + GL_PROGRAM_ERROR_POSITION_NV* = 0x0000864B + GL_MODELVIEW_PROJECTION_NV* = 0x00008629 + GL_MATRIX0_NV* = 0x00008630 + GL_MATRIX1_NV* = 0x00008631 + GL_MATRIX2_NV* = 0x00008632 + GL_MATRIX3_NV* = 0x00008633 + GL_MATRIX4_NV* = 0x00008634 + GL_MATRIX5_NV* = 0x00008635 + GL_MATRIX6_NV* = 0x00008636 + GL_MATRIX7_NV* = 0x00008637 + GL_IDENTITY_NV* = 0x0000862A + GL_INVERSE_NV* = 0x0000862B + GL_TRANSPOSE_NV* = 0x0000862C + GL_INVERSE_TRANSPOSE_NV* = 0x0000862D + GL_VERTEX_ATTRIB_ARRAY0_NV* = 0x00008650 + GL_VERTEX_ATTRIB_ARRAY1_NV* = 0x00008651 + GL_VERTEX_ATTRIB_ARRAY2_NV* = 0x00008652 + GL_VERTEX_ATTRIB_ARRAY3_NV* = 0x00008653 + GL_VERTEX_ATTRIB_ARRAY4_NV* = 0x00008654 + GL_VERTEX_ATTRIB_ARRAY5_NV* = 0x00008655 + GL_VERTEX_ATTRIB_ARRAY6_NV* = 0x00008656 + GL_VERTEX_ATTRIB_ARRAY7_NV* = 0x00008657 + GL_VERTEX_ATTRIB_ARRAY8_NV* = 0x00008658 + GL_VERTEX_ATTRIB_ARRAY9_NV* = 0x00008659 + GL_VERTEX_ATTRIB_ARRAY10_NV* = 0x0000865A + GL_VERTEX_ATTRIB_ARRAY11_NV* = 0x0000865B + GL_VERTEX_ATTRIB_ARRAY12_NV* = 0x0000865C + GL_VERTEX_ATTRIB_ARRAY13_NV* = 0x0000865D + GL_VERTEX_ATTRIB_ARRAY14_NV* = 0x0000865E + GL_VERTEX_ATTRIB_ARRAY15_NV* = 0x0000865F + GL_MAP1_VERTEX_ATTRIB0_4_NV* = 0x00008660 + GL_MAP1_VERTEX_ATTRIB1_4_NV* = 0x00008661 + GL_MAP1_VERTEX_ATTRIB2_4_NV* = 0x00008662 + GL_MAP1_VERTEX_ATTRIB3_4_NV* = 0x00008663 + GL_MAP1_VERTEX_ATTRIB4_4_NV* = 0x00008664 + GL_MAP1_VERTEX_ATTRIB5_4_NV* = 0x00008665 + GL_MAP1_VERTEX_ATTRIB6_4_NV* = 0x00008666 + GL_MAP1_VERTEX_ATTRIB7_4_NV* = 0x00008667 + GL_MAP1_VERTEX_ATTRIB8_4_NV* = 0x00008668 + GL_MAP1_VERTEX_ATTRIB9_4_NV* = 0x00008669 + GL_MAP1_VERTEX_ATTRIB10_4_NV* = 0x0000866A + GL_MAP1_VERTEX_ATTRIB11_4_NV* = 0x0000866B + GL_MAP1_VERTEX_ATTRIB12_4_NV* = 0x0000866C + GL_MAP1_VERTEX_ATTRIB13_4_NV* = 0x0000866D + GL_MAP1_VERTEX_ATTRIB14_4_NV* = 0x0000866E + GL_MAP1_VERTEX_ATTRIB15_4_NV* = 0x0000866F + GL_MAP2_VERTEX_ATTRIB0_4_NV* = 0x00008670 + GL_MAP2_VERTEX_ATTRIB1_4_NV* = 0x00008671 + GL_MAP2_VERTEX_ATTRIB2_4_NV* = 0x00008672 + GL_MAP2_VERTEX_ATTRIB3_4_NV* = 0x00008673 + GL_MAP2_VERTEX_ATTRIB4_4_NV* = 0x00008674 + GL_MAP2_VERTEX_ATTRIB5_4_NV* = 0x00008675 + GL_MAP2_VERTEX_ATTRIB6_4_NV* = 0x00008676 + GL_MAP2_VERTEX_ATTRIB7_4_NV* = 0x00008677 + GL_MAP2_VERTEX_ATTRIB8_4_NV* = 0x00008678 + GL_MAP2_VERTEX_ATTRIB9_4_NV* = 0x00008679 + GL_MAP2_VERTEX_ATTRIB10_4_NV* = 0x0000867A + GL_MAP2_VERTEX_ATTRIB11_4_NV* = 0x0000867B + GL_MAP2_VERTEX_ATTRIB12_4_NV* = 0x0000867C + GL_MAP2_VERTEX_ATTRIB13_4_NV* = 0x0000867D + GL_MAP2_VERTEX_ATTRIB14_4_NV* = 0x0000867E + GL_MAP2_VERTEX_ATTRIB15_4_NV* = 0x0000867F + +proc glBindProgramNV*(target: TGLenum, id: TGLuint){.dynlib: dllname, + importc: "glBindProgramNV".} +proc glDeleteProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc: "glDeleteProgramsNV".} +proc glExecuteProgramNV*(target: TGLenum, id: TGLuint, params: PGLfloat){. + dynlib: dllname, importc: "glExecuteProgramNV".} +proc glGenProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc: "glGenProgramsNV".} +proc glAreProgramsResidentNV*(n: TGLsizei, ids: PGLuint, residences: PGLboolean): TGLboolean{. + dynlib: dllname, importc: "glAreProgramsResidentNV".} +proc glRequestResidentProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc: "glRequestResidentProgramsNV".} +proc glGetProgramParameterfvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetProgramParameterfvNV".} +proc glGetProgramParameterdvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, + params: PGLdouble){.dynlib: dllname, + importc: "glGetProgramParameterdvNV".} +proc glGetProgramivNV*(id: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetProgramivNV".} +proc glGetProgramStringNV*(id: TGLuint, pname: TGLenum, theProgram: PGLubyte){. + dynlib: dllname, importc: "glGetProgramStringNV".} +proc glGetTrackMatrixivNV*(target: TGLenum, address: TGLuint, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetTrackMatrixivNV".} +proc glGetVertexAttribdvNV*(index: TGLuint, pname: TGLenum, params: PGLdouble){. + dynlib: dllname, importc: "glGetVertexAttribdvNV".} +proc glGetVertexAttribfvNV*(index: TGLuint, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetVertexAttribfvNV".} +proc glGetVertexAttribivNV*(index: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetVertexAttribivNV".} +proc glGetVertexAttribPointervNV*(index: TGLuint, pname: TGLenum, + pointer: PGLvoid){.dynlib: dllname, + importc: "glGetVertexAttribPointervNV".} +proc glIsProgramNV*(id: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsProgramNV".} +proc glLoadProgramNV*(target: TGLenum, id: TGLuint, length: TGLsizei, + theProgram: PGLubyte){.dynlib: dllname, + importc: "glLoadProgramNV".} +proc glProgramParameter4fNV*(target: TGLenum, index: TGLuint, x: TGLfloat, + y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc: "glProgramParameter4fNV".} +proc glProgramParameter4fvNV*(target: TGLenum, index: TGLuint, params: PGLfloat){. + dynlib: dllname, importc: "glProgramParameter4fvNV".} +proc glProgramParameters4dvNV*(target: TGLenum, index: TGLuint, num: TGLuint, + params: PGLdouble){.dynlib: dllname, + importc: "glProgramParameters4dvNV".} +proc glProgramParameters4fvNV*(target: TGLenum, index: TGLuint, num: TGLuint, + params: PGLfloat){.dynlib: dllname, + importc: "glProgramParameters4fvNV".} +proc glTrackMatrixNV*(target: TGLenum, address: TGLuint, matrix: TGLenum, + transform: TGLenum){.dynlib: dllname, + importc: "glTrackMatrixNV".} +proc glVertexAttribPointerNV*(index: TGLuint, size: TGLint, thetype: TGLenum, + stride: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc: "glVertexAttribPointerNV".} +proc glVertexAttrib1sNV*(index: TGLuint, x: TGLshort){.dynlib: dllname, + importc: "glVertexAttrib1sNV".} +proc glVertexAttrib1fNV*(index: TGLuint, x: TGLfloat){.dynlib: dllname, + importc: "glVertexAttrib1fNV".} +proc glVertexAttrib1dNV*(index: TGLuint, x: TGLdouble){.dynlib: dllname, + importc: "glVertexAttrib1dNV".} +proc glVertexAttrib2sNV*(index: TGLuint, x: TGLshort, y: TGLshort){. + dynlib: dllname, importc: "glVertexAttrib2sNV".} +proc glVertexAttrib2fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat){. + dynlib: dllname, importc: "glVertexAttrib2fNV".} +proc glVertexAttrib2dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble){. + dynlib: dllname, importc: "glVertexAttrib2dNV".} +proc glVertexAttrib3sNV*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){. + dynlib: dllname, importc: "glVertexAttrib3sNV".} +proc glVertexAttrib3fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glVertexAttrib3fNV".} +proc glVertexAttrib3dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble, + z: TGLdouble){.dynlib: dllname, + importc: "glVertexAttrib3dNV".} +proc glVertexAttrib4sNV*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, + w: TGLshort){.dynlib: dllname, + importc: "glVertexAttrib4sNV".} +proc glVertexAttrib4fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, + importc: "glVertexAttrib4fNV".} +proc glVertexAttrib4dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble, + z: TGLdouble, w: TGLdouble){.dynlib: dllname, + importc: "glVertexAttrib4dNV".} +proc glVertexAttrib4ubNV*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, + w: TGLubyte){.dynlib: dllname, + importc: "glVertexAttrib4ubNV".} +proc glVertexAttrib1svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib1svNV".} +proc glVertexAttrib1fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib1fvNV".} +proc glVertexAttrib1dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib1dvNV".} +proc glVertexAttrib2svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib2svNV".} +proc glVertexAttrib2fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib2fvNV".} +proc glVertexAttrib2dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib2dvNV".} +proc glVertexAttrib3svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib3svNV".} +proc glVertexAttrib3fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib3fvNV".} +proc glVertexAttrib3dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib3dvNV".} +proc glVertexAttrib4svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc: "glVertexAttrib4svNV".} +proc glVertexAttrib4fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, + importc: "glVertexAttrib4fvNV".} +proc glVertexAttrib4dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc: "glVertexAttrib4dvNV".} +proc glVertexAttrib4ubvNV*(index: TGLuint, v: PGLubyte){.dynlib: dllname, + importc: "glVertexAttrib4ubvNV".} +proc glVertexAttribs1svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){. + dynlib: dllname, importc: "glVertexAttribs1svNV".} +proc glVertexAttribs1fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){. + dynlib: dllname, importc: "glVertexAttribs1fvNV".} +proc glVertexAttribs1dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){. + dynlib: dllname, importc: "glVertexAttribs1dvNV".} +proc glVertexAttribs2svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){. + dynlib: dllname, importc: "glVertexAttribs2svNV".} +proc glVertexAttribs2fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){. + dynlib: dllname, importc: "glVertexAttribs2fvNV".} +proc glVertexAttribs2dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){. + dynlib: dllname, importc: "glVertexAttribs2dvNV".} +proc glVertexAttribs3svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){. + dynlib: dllname, importc: "glVertexAttribs3svNV".} +proc glVertexAttribs3fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){. + dynlib: dllname, importc: "glVertexAttribs3fvNV".} +proc glVertexAttribs3dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){. + dynlib: dllname, importc: "glVertexAttribs3dvNV".} +proc glVertexAttribs4svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){. + dynlib: dllname, importc: "glVertexAttribs4svNV".} +proc glVertexAttribs4fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){. + dynlib: dllname, importc: "glVertexAttribs4fvNV".} +proc glVertexAttribs4dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){. + dynlib: dllname, importc: "glVertexAttribs4dvNV".} +proc glVertexAttribs4ubvNV*(index: TGLuint, n: TGLsizei, v: PGLubyte){. + dynlib: dllname, importc: "glVertexAttribs4ubvNV".} + #***** GL_NV_vertex_program1_1 *****// + #***** GL_ATI_element_array *****// +const + GL_ELEMENT_ARRAY_ATI* = 0x00008768 + GL_ELEMENT_ARRAY_TYPE_ATI* = 0x00008769 + GL_ELEMENT_ARRAY_POINTER_ATI* = 0x0000876A + +proc glElementPointerATI*(thetype: TGLenum, pointer: PGLvoid){.dynlib: dllname, + importc: "glElementPointerATI".} +proc glDrawElementArrayATI*(mode: TGLenum, count: TGLsizei){.dynlib: dllname, + importc: "glDrawElementArrayATI".} +proc glDrawRangeElementArrayATI*(mode: TGLenum, start: TGLuint, theend: TGLuint, + count: TGLsizei){.dynlib: dllname, + importc: "glDrawRangeElementArrayATI".} + #***** GL_ATI_envmap_bumpmap *****// +const + GL_BUMP_ROT_MATRIX_ATI* = 0x00008775 + GL_BUMP_ROT_MATRIX_SIZE_ATI* = 0x00008776 + GL_BUMP_NUM_TEX_UNITS_ATI* = 0x00008777 + GL_BUMP_TEX_UNITS_ATI* = 0x00008778 + GL_DUDV_ATI* = 0x00008779 + GL_DU8DV8_ATI* = 0x0000877A + GL_BUMP_ENVMAP_ATI* = 0x0000877B + GL_BUMP_TARGET_ATI* = 0x0000877C + +proc glTexBumpParameterivATI*(pname: TGLenum, param: PGLint){.dynlib: dllname, + importc: "glTexBumpParameterivATI".} +proc glTexBumpParameterfvATI*(pname: TGLenum, param: PGLfloat){.dynlib: dllname, + importc: "glTexBumpParameterfvATI".} +proc glGetTexBumpParameterivATI*(pname: TGLenum, param: PGLint){. + dynlib: dllname, importc: "glGetTexBumpParameterivATI".} +proc glGetTexBumpParameterfvATI*(pname: TGLenum, param: PGLfloat){. + dynlib: dllname, importc: "glGetTexBumpParameterfvATI".} + #***** GL_ATI_fragment_shader *****// +const + GL_FRAGMENT_SHADER_ATI* = 0x00008920 + GL_REG_0_ATI* = 0x00008921 + GL_REG_1_ATI* = 0x00008922 + GL_REG_2_ATI* = 0x00008923 + GL_REG_3_ATI* = 0x00008924 + GL_REG_4_ATI* = 0x00008925 + GL_REG_5_ATI* = 0x00008926 + GL_CON_0_ATI* = 0x00008941 + GL_CON_1_ATI* = 0x00008942 + GL_CON_2_ATI* = 0x00008943 + GL_CON_3_ATI* = 0x00008944 + GL_CON_4_ATI* = 0x00008945 + GL_CON_5_ATI* = 0x00008946 + GL_CON_6_ATI* = 0x00008947 + GL_CON_7_ATI* = 0x00008948 + GL_MOV_ATI* = 0x00008961 + GL_ADD_ATI* = 0x00008963 + GL_MUL_ATI* = 0x00008964 + GL_SUB_ATI* = 0x00008965 + GL_DOT3_ATI* = 0x00008966 + GL_DOT4_ATI* = 0x00008967 + GL_MAD_ATI* = 0x00008968 + GL_LERP_ATI* = 0x00008969 + GL_CND_ATI* = 0x0000896A + GL_CND0_ATI* = 0x0000896B + GL_DOT2_ADD_ATI* = 0x0000896C + GL_SECONDARY_INTERPOLATOR_ATI* = 0x0000896D + GL_SWIZZLE_STR_ATI* = 0x00008976 + GL_SWIZZLE_STQ_ATI* = 0x00008977 + GL_SWIZZLE_STR_DR_ATI* = 0x00008978 + GL_SWIZZLE_STQ_DQ_ATI* = 0x00008979 + GL_RED_BIT_ATI* = 0x00000001 + GL_GREEN_BIT_ATI* = 0x00000002 + GL_BLUE_BIT_ATI* = 0x00000004 + GL_2X_BIT_ATI* = 0x00000001 + GL_4X_BIT_ATI* = 0x00000002 + GL_8X_BIT_ATI* = 0x00000004 + GL_HALF_BIT_ATI* = 0x00000008 + GL_QUARTER_BIT_ATI* = 0x00000010 + GL_EIGHTH_BIT_ATI* = 0x00000020 + GL_SATURATE_BIT_ATI* = 0x00000040 # GL_2X_BIT_ATI { already defined } + GL_COMP_BIT_ATI* = 0x00000002 + GL_NEGATE_BIT_ATI* = 0x00000004 + GL_BIAS_BIT_ATI* = 0x00000008 + +proc glGenFragmentShadersATI*(range: TGLuint): TGLuint{.dynlib: dllname, + importc: "glGenFragmentShadersATI".} +proc glBindFragmentShaderATI*(id: TGLuint){.dynlib: dllname, + importc: "glBindFragmentShaderATI".} +proc glDeleteFragmentShaderATI*(id: TGLuint){.dynlib: dllname, + importc: "glDeleteFragmentShaderATI".} +proc glBeginFragmentShaderATI*(){.dynlib: dllname, + importc: "glBeginFragmentShaderATI".} +proc glEndFragmentShaderATI*(){.dynlib: dllname, + importc: "glEndFragmentShaderATI".} +proc glPassTexCoordATI*(dst: TGLuint, coord: TGLuint, swizzle: TGLenum){. + dynlib: dllname, importc: "glPassTexCoordATI".} +proc glSampleMapATI*(dst: TGLuint, interp: TGLuint, swizzle: TGLenum){. + dynlib: dllname, importc: "glSampleMapATI".} +proc glColorFragmentOp1ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, + dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, + arg1Mod: TGLuint){.dynlib: dllname, + importc: "glColorFragmentOp1ATI".} +proc glColorFragmentOp2ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, + dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, + arg1Mod: TGLuint, arg2: TGLuint, arg2Rep: TGLuint, + arg2Mod: TGLuint){.dynlib: dllname, + importc: "glColorFragmentOp2ATI".} +proc glColorFragmentOp3ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, + dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, + arg1Mod: TGLuint, arg2: TGLuint, arg2Rep: TGLuint, + arg2Mod: TGLuint, arg3: TGLuint, arg3Rep: TGLuint, + arg3Mod: TGLuint){.dynlib: dllname, + importc: "glColorFragmentOp3ATI".} +proc glAlphaFragmentOp1ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, + arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint){. + dynlib: dllname, importc: "glAlphaFragmentOp1ATI".} +proc glAlphaFragmentOp2ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, + arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint, + arg2: TGLuint, arg2Rep: TGLuint, arg2Mod: TGLuint){. + dynlib: dllname, importc: "glAlphaFragmentOp2ATI".} +proc glAlphaFragmentOp3ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, + arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint, + arg2: TGLuint, arg2Rep: TGLuint, arg2Mod: TGLuint, + arg3: TGLuint, arg3Rep: TGLuint, arg3Mod: TGLuint){. + dynlib: dllname, importc: "glAlphaFragmentOp3ATI".} +proc glSetFragmentShaderConstantATI*(dst: TGLuint, value: PGLfloat){. + dynlib: dllname, importc: "glSetFragmentShaderConstantATI".} + #***** GL_ATI_pn_triangles *****// +const + GL_PN_TRIANGLES_ATI* = 0x000087F0 + GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI* = 0x000087F1 + GL_PN_TRIANGLES_POINT_MODE_ATI* = 0x000087F2 + GL_PN_TRIANGLES_NORMAL_MODE_ATI* = 0x000087F3 + GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI* = 0x000087F4 + GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI* = 0x000087F5 + GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI* = 0x000087F6 + GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI* = 0x000087F7 + GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI* = 0x000087F8 + +proc glPNTrianglesiATI*(pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glPNTrianglesiATI".} +proc glPNTrianglesfATI*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glPNTrianglesfATI".} + #***** GL_ATI_texture_mirror_once *****// +const + GL_MIRROR_CLAMP_ATI* = 0x00008742 + GL_MIRROR_CLAMP_TO_EDGE_ATI* = 0x00008743 + #***** GL_ATI_vertex_array_object *****// + +const + GL_STATIC_ATI* = 0x00008760 + GL_DYNAMIC_ATI* = 0x00008761 + GL_PRESERVE_ATI* = 0x00008762 + GL_DISCARD_ATI* = 0x00008763 + GL_OBJECT_BUFFER_SIZE_ATI* = 0x00008764 + GL_OBJECT_BUFFER_USAGE_ATI* = 0x00008765 + GL_ARRAY_OBJECT_BUFFER_ATI* = 0x00008766 + GL_ARRAY_OBJECT_OFFSET_ATI* = 0x00008767 + +proc glNewObjectBufferATI*(size: TGLsizei, pointer: PGLvoid, usage: TGLenum): TGLuint{. + dynlib: dllname, importc: "glNewObjectBufferATI".} +proc glIsObjectBufferATI*(buffer: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsObjectBufferATI".} +proc glUpdateObjectBufferATI*(buffer: TGLuint, offset: TGLuint, size: TGLsizei, + pointer: PGLvoid, preserve: TGLenum){. + dynlib: dllname, importc: "glUpdateObjectBufferATI".} +proc glGetObjectBufferfvATI*(buffer: TGLuint, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetObjectBufferfvATI".} +proc glGetObjectBufferivATI*(buffer: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetObjectBufferivATI".} +proc glDeleteObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, + importc: "glDeleteObjectBufferATI".} +proc glArrayObjectATI*(thearray: TGLenum, size: TGLint, thetype: TGLenum, + stride: TGLsizei, buffer: TGLuint, offset: TGLuint){. + dynlib: dllname, importc: "glArrayObjectATI".} +proc glGetArrayObjectfvATI*(thearray: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetArrayObjectfvATI".} +proc glGetArrayObjectivATI*(thearray: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetArrayObjectivATI".} +proc glVariantArrayObjectATI*(id: TGLuint, thetype: TGLenum, stride: TGLsizei, + buffer: TGLuint, offset: TGLuint){. + dynlib: dllname, importc: "glVariantArrayObjectATI".} +proc glGetVariantArrayObjectfvATI*(id: TGLuint, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc: "glGetVariantArrayObjectfvATI".} +proc glGetVariantArrayObjectivATI*(id: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetVariantArrayObjectivATI".} + #***** GL_ATI_vertex_streams *****// +const + GL_MAX_VERTEX_STREAMS_ATI* = 0x0000876B + GL_VERTEX_STREAM0_ATI* = 0x0000876C + GL_VERTEX_STREAM1_ATI* = 0x0000876D + GL_VERTEX_STREAM2_ATI* = 0x0000876E + GL_VERTEX_STREAM3_ATI* = 0x0000876F + GL_VERTEX_STREAM4_ATI* = 0x00008770 + GL_VERTEX_STREAM5_ATI* = 0x00008771 + GL_VERTEX_STREAM6_ATI* = 0x00008772 + GL_VERTEX_STREAM7_ATI* = 0x00008773 + GL_VERTEX_SOURCE_ATI* = 0x00008774 + +proc glVertexStream1s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc: "glVertexStream1s".} +proc glVertexStream1i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, + importc: "glVertexStream1i".} +proc glVertexStream1f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc: "glVertexStream1f".} +proc glVertexStream1d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc: "glVertexStream1d".} +proc glVertexStream1sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc: "glVertexStream1sv".} +proc glVertexStream1iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, + importc: "glVertexStream1iv".} +proc glVertexStream1fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc: "glVertexStream1fv".} +proc glVertexStream1dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc: "glVertexStream1dv".} +proc glVertexStream2s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc: "glVertexStream2s".} +proc glVertexStream2i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, + importc: "glVertexStream2i".} +proc glVertexStream2f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc: "glVertexStream2f".} +proc glVertexStream2d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc: "glVertexStream2d".} +proc glVertexStream2sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc: "glVertexStream2sv".} +proc glVertexStream2iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, + importc: "glVertexStream2iv".} +proc glVertexStream2fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc: "glVertexStream2fv".} +proc glVertexStream2dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc: "glVertexStream2dv".} +proc glVertexStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc: "glVertexStream3s".} +proc glVertexStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, + importc: "glVertexStream3i".} +proc glVertexStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc: "glVertexStream3f".} +proc glVertexStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc: "glVertexStream3d".} +proc glVertexStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc: "glVertexStream3sv".} +proc glVertexStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, + importc: "glVertexStream3iv".} +proc glVertexStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc: "glVertexStream3fv".} +proc glVertexStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc: "glVertexStream3dv".} +proc glVertexStream4s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc: "glVertexStream4s".} +proc glVertexStream4i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, + importc: "glVertexStream4i".} +proc glVertexStream4f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc: "glVertexStream4f".} +proc glVertexStream4d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc: "glVertexStream4d".} +proc glVertexStream4sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc: "glVertexStream4sv".} +proc glVertexStream4iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, + importc: "glVertexStream4iv".} +proc glVertexStream4fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc: "glVertexStream4fv".} +proc glVertexStream4dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc: "glVertexStream4dv".} +proc glNormalStream3b*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, + importc: "glNormalStream3b".} +proc glNormalStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc: "glNormalStream3s".} +proc glNormalStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, + importc: "glNormalStream3i".} +proc glNormalStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc: "glNormalStream3f".} +proc glNormalStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc: "glNormalStream3d".} +proc glNormalStream3bv*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, + importc: "glNormalStream3bv".} +proc glNormalStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc: "glNormalStream3sv".} +proc glNormalStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, + importc: "glNormalStream3iv".} +proc glNormalStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc: "glNormalStream3fv".} +proc glNormalStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc: "glNormalStream3dv".} +proc glClientActiveVertexStream*(stream: TGLenum){.dynlib: dllname, + importc: "glClientActiveVertexStream".} +proc glVertexBlendEnvi*(pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glVertexBlendEnvi".} +proc glVertexBlendEnvf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glVertexBlendEnvf".} + #***** GL_3DFX_texture_compression_FXT1 *****// +const + GL_COMPRESSED_RGB_FXT1_3DFX* = 0x000086B0 + GL_COMPRESSED_RGBA_FXT1_3DFX* = 0x000086B1 + #***** GL_IBM_cull_vertex *****// + +const + GL_CULL_VERTEX_IBM* = 0x0001928A + #***** GL_IBM_multimode_draw_arrays *****// + +proc glMultiModeDrawArraysIBM*(mode: PGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei, modestride: TGLint){. + dynlib: dllname, importc: "glMultiModeDrawArraysIBM".} +proc glMultiModeDrawElementsIBM*(mode: PGLenum, count: PGLsizei, + thetype: TGLenum, indices: PGLvoid, + primcount: TGLsizei, modestride: TGLint){. + dynlib: dllname, importc: "glMultiModeDrawElementsIBM".} + #***** GL_IBM_raster_pos_clip *****// +const + GL_RASTER_POSITION_UNCLIPPED_IBM* = 0x00019262 + #***** GL_IBM_texture_mirrored_repeat *****// + +const + GL_MIRRORED_REPEAT_IBM* = 0x00008370 + #***** GL_IBM_vertex_array_lists *****// + +const + GL_VERTEX_ARRAY_LIST_IBM* = 0x0001929E + GL_NORMAL_ARRAY_LIST_IBM* = 0x0001929F + GL_COLOR_ARRAY_LIST_IBM* = 0x000192A0 + GL_INDEX_ARRAY_LIST_IBM* = 0x000192A1 + GL_TEXTURE_COORD_ARRAY_LIST_IBM* = 0x000192A2 + GL_EDGE_FLAG_ARRAY_LIST_IBM* = 0x000192A3 + GL_FOG_COORDINATE_ARRAY_LIST_IBM* = 0x000192A4 + GL_SECONDARY_COLOR_ARRAY_LIST_IBM* = 0x000192A5 + GL_VERTEX_ARRAY_LIST_STRIDE_IBM* = 0x000192A8 + GL_NORMAL_ARRAY_LIST_STRIDE_IBM* = 0x000192A9 + GL_COLOR_ARRAY_LIST_STRIDE_IBM* = 0x000192AA + GL_INDEX_ARRAY_LIST_STRIDE_IBM* = 0x000192AB + GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM* = 0x000192AC + GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM* = 0x000192AD + GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM* = 0x000192AE + GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM* = 0x000192AF + +proc glColorPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, + pointer: PGLvoid, ptrstride: TGLint){. + dynlib: dllname, importc: "glColorPointerListIBM".} +proc glSecondaryColorPointerListIBM*(size: TGLint, thetype: TGLenum, + stride: TGLint, pointer: PGLvoid, + ptrstride: TGLint){.dynlib: dllname, + importc: "glSecondaryColorPointerListIBM".} +proc glEdgeFlagPointerListIBM*(stride: TGLint, pointer: PGLboolean, + ptrstride: TGLint){.dynlib: dllname, + importc: "glEdgeFlagPointerListIBM".} +proc glFogCoordPointerListIBM*(thetype: TGLenum, stride: TGLint, + pointer: PGLvoid, ptrstride: TGLint){. + dynlib: dllname, importc: "glFogCoordPointerListIBM".} +proc glNormalPointerListIBM*(thetype: TGLenum, stride: TGLint, pointer: PGLvoid, + ptrstride: TGLint){.dynlib: dllname, + importc: "glNormalPointerListIBM".} +proc glTexCoordPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, + pointer: PGLvoid, ptrstride: TGLint){. + dynlib: dllname, importc: "glTexCoordPointerListIBM".} +proc glVertexPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, + pointer: PGLvoid, ptrstride: TGLint){. + dynlib: dllname, importc: "glVertexPointerListIBM".} + #***** GL_MESA_resize_buffers *****// +proc glResizeBuffersMESA*(){.dynlib: dllname, importc: "glResizeBuffersMESA".} + #***** GL_MESA_window_pos *****// +proc glWindowPos2dMESA*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, + importc: "glWindowPos2dMESA".} +proc glWindowPos2fMESA*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, + importc: "glWindowPos2fMESA".} +proc glWindowPos2iMESA*(x: TGLint, y: TGLint){.dynlib: dllname, + importc: "glWindowPos2iMESA".} +proc glWindowPos2sMESA*(x: TGLshort, y: TGLshort){.dynlib: dllname, + importc: "glWindowPos2sMESA".} +proc glWindowPos2ivMESA*(p: PGLint){.dynlib: dllname, + importc: "glWindowPos2ivMESA".} +proc glWindowPos2svMESA*(p: PGLshort){.dynlib: dllname, + importc: "glWindowPos2svMESA".} +proc glWindowPos2fvMESA*(p: PGLfloat){.dynlib: dllname, + importc: "glWindowPos2fvMESA".} +proc glWindowPos2dvMESA*(p: PGLdouble){.dynlib: dllname, + importc: "glWindowPos2dvMESA".} +proc glWindowPos3iMESA*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, + importc: "glWindowPos3iMESA".} +proc glWindowPos3sMESA*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, + importc: "glWindowPos3sMESA".} +proc glWindowPos3fMESA*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc: "glWindowPos3fMESA".} +proc glWindowPos3dMESA*(x: TGLdouble, y: TGLdouble, z: TGLdouble){. + dynlib: dllname, importc: "glWindowPos3dMESA".} +proc glWindowPos3ivMESA*(p: PGLint){.dynlib: dllname, + importc: "glWindowPos3ivMESA".} +proc glWindowPos3svMESA*(p: PGLshort){.dynlib: dllname, + importc: "glWindowPos3svMESA".} +proc glWindowPos3fvMESA*(p: PGLfloat){.dynlib: dllname, + importc: "glWindowPos3fvMESA".} +proc glWindowPos3dvMESA*(p: PGLdouble){.dynlib: dllname, + importc: "glWindowPos3dvMESA".} +proc glWindowPos4iMESA*(x: TGLint, y: TGLint, z: TGLint, w: TGLint){. + dynlib: dllname, importc: "glWindowPos4iMESA".} +proc glWindowPos4sMESA*(x: TGLshort, y: TGLshort, z: TGLshort, w: TGLshort){. + dynlib: dllname, importc: "glWindowPos4sMESA".} +proc glWindowPos4fMESA*(x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc: "glWindowPos4fMESA".} +proc glWindowPos4dMESA*(x: TGLdouble, y: TGLdouble, z: TGLdouble, w: TGLdouble){. + dynlib: dllname, importc: "glWindowPos4dMESA".} +proc glWindowPos4ivMESA*(p: PGLint){.dynlib: dllname, + importc: "glWindowPos4ivMESA".} +proc glWindowPos4svMESA*(p: PGLshort){.dynlib: dllname, + importc: "glWindowPos4svMESA".} +proc glWindowPos4fvMESA*(p: PGLfloat){.dynlib: dllname, + importc: "glWindowPos4fvMESA".} +proc glWindowPos4dvMESA*(p: PGLdouble){.dynlib: dllname, + importc: "glWindowPos4dvMESA".} + #***** GL_OML_interlace *****// +const + GL_INTERLACE_OML* = 0x00008980 + GL_INTERLACE_READ_OML* = 0x00008981 + #***** GL_OML_resample *****// + +const + GL_PACK_RESAMPLE_OML* = 0x00008984 + GL_UNPACK_RESAMPLE_OML* = 0x00008985 + GL_RESAMPLE_REPLICATE_OML* = 0x00008986 + GL_RESAMPLE_ZERO_FILL_OML* = 0x00008987 + GL_RESAMPLE_AVERAGE_OML* = 0x00008988 + GL_RESAMPLE_DECIMATE_OML* = 0x00008989 # GL_RESAMPLE_AVERAGE_OML { already defined } + #***** GL_OML_subsample *****// + +const + GL_FORMAT_SUBSAMPLE_24_24_OML* = 0x00008982 + GL_FORMAT_SUBSAMPLE_244_244_OML* = 0x00008983 + #***** GL_SGIS_generate_mipmap *****// + +const + GL_GENERATE_MIPMAP_SGIS* = 0x00008191 + GL_GENERATE_MIPMAP_HINT_SGIS* = 0x00008192 + #***** GL_SGIS_multisample *****// + +const + GLX_SAMPLE_BUFFERS_SGIS* = 0x000186A0 + GLX_SAMPLES_SGIS* = 0x000186A1 + GL_MULTISAMPLE_SGIS* = 0x0000809D + GL_SAMPLE_ALPHA_TO_MASK_SGIS* = 0x0000809E + GL_SAMPLE_ALPHA_TO_ONE_SGIS* = 0x0000809F + constGL_SAMPLE_MASK_SGIS* = 0x000080A0 + GL_MULTISAMPLE_BIT_EXT* = 0x20000000 + GL_1PASS_SGIS* = 0x000080A1 + GL_2PASS_0_SGIS* = 0x000080A2 + GL_2PASS_1_SGIS* = 0x000080A3 + GL_4PASS_0_SGIS* = 0x000080A4 + GL_4PASS_1_SGIS* = 0x000080A5 + GL_4PASS_2_SGIS* = 0x000080A6 + GL_4PASS_3_SGIS* = 0x000080A7 + GL_SAMPLE_BUFFERS_SGIS* = 0x000080A8 + GL_SAMPLES_SGIS* = 0x000080A9 + GL_SAMPLE_MASK_VALUE_SGIS* = 0x000080AA + GL_SAMPLE_MASK_INVERT_SGIS* = 0x000080AB + constGL_SAMPLE_PATTERN_SGIS* = 0x000080AC + +proc glSampleMaskSGIS*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, + importc: "glSampleMaskSGIS".} +proc glSamplePatternSGIS*(pattern: TGLenum){.dynlib: dllname, + importc: "glSamplePatternSGIS".} + #***** GL_SGIS_pixel_texture *****// +const + GL_PIXEL_TEXTURE_SGIS* = 0x00008353 + GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS* = 0x00008354 + GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS* = 0x00008355 + GL_PIXEL_GROUP_COLOR_SGIS* = 0x00008356 + +proc glPixelTexGenParameteriSGIS*(pname: TGLenum, param: TGLint){. + dynlib: dllname, importc: "glPixelTexGenParameteriSGIS".} +proc glPixelTexGenParameterfSGIS*(pname: TGLenum, param: TGLfloat){. + dynlib: dllname, importc: "glPixelTexGenParameterfSGIS".} +proc glGetPixelTexGenParameterivSGIS*(pname: TGLenum, params: TGLint){. + dynlib: dllname, importc: "glGetPixelTexGenParameterivSGIS".} +proc glGetPixelTexGenParameterfvSGIS*(pname: TGLenum, params: TGLfloat){. + dynlib: dllname, importc: "glGetPixelTexGenParameterfvSGIS".} + #***** GL_SGIS_texture_border_clamp *****// + # GL_CLAMP_TO_BORDER_SGIS { already defined } + #***** GL_SGIS_texture_color_mask *****// +const + GL_TEXTURE_COLOR_WRITEMASK_SGIS* = 0x000081EF + +proc glTextureColorMaskSGIS*(r: TGLboolean, g: TGLboolean, b: TGLboolean, + a: TGLboolean){.dynlib: dllname, + importc: "glTextureColorMaskSGIS".} + #***** GL_SGIS_texture_edge_clamp *****// +const + GL_CLAMP_TO_EDGE_SGIS* = 0x0000812F + #***** GL_SGIS_texture_lod *****// + +const + GL_TEXTURE_MIN_LOD_SGIS* = 0x0000813A + GL_TEXTURE_MAX_LOD_SGIS* = 0x0000813B + GL_TEXTURE_BASE_LEVEL_SGIS* = 0x0000813C + GL_TEXTURE_MAX_LEVEL_SGIS* = 0x0000813D + #***** GL_SGIS_depth_texture *****// + +const + GL_DEPTH_COMPONENT16_SGIX* = 0x000081A5 + GL_DEPTH_COMPONENT24_SGIX* = 0x000081A6 + GL_DEPTH_COMPONENT32_SGIX* = 0x000081A7 + #***** GL_SGIX_fog_offset *****// + +const + GL_FOG_OFFSET_SGIX* = 0x00008198 + GL_FOG_OFFSET_VALUE_SGIX* = 0x00008199 + #***** GL_SGIX_interlace *****// + +const + GL_INTERLACE_SGIX* = 0x00008094 + #***** GL_SGIX_shadow_ambient *****// + +const + GL_SHADOW_AMBIENT_SGIX* = 0x000080BF + #***** GL_SGI_color_matrix *****// + +const + GL_COLOR_MATRIX_SGI* = 0x000080B1 + GL_COLOR_MATRIX_STACK_DEPTH_SGI* = 0x000080B2 + GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI* = 0x000080B3 + GL_POST_COLOR_MATRIX_RED_SCALE_SGI* = 0x000080B4 + GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI* = 0x000080B5 + GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI* = 0x000080B6 + GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI* = 0x000080B7 + GL_POST_COLOR_MATRIX_RED_BIAS_SGI* = 0x000080B8 + GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI* = 0x000080B9 + GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI* = 0x000080BA + GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI* = 0x000080BB + #***** GL_SGI_color_table *****// + +const + constGL_COLOR_TABLE_SGI* = 0x000080D0 + GL_POST_CONVOLUTION_COLOR_TABLE_SGI* = 0x000080D1 + GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI* = 0x000080D2 + GL_PROXY_COLOR_TABLE_SGI* = 0x000080D3 + GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI* = 0x000080D4 + GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI* = 0x000080D5 + GL_COLOR_TABLE_SCALE_SGI* = 0x000080D6 + GL_COLOR_TABLE_BIAS_SGI* = 0x000080D7 + GL_COLOR_TABLE_FORMAT_SGI* = 0x000080D8 + GL_COLOR_TABLE_WIDTH_SGI* = 0x000080D9 + GL_COLOR_TABLE_RED_SIZE_SGI* = 0x000080DA + GL_COLOR_TABLE_GREEN_SIZE_SGI* = 0x000080DB + GL_COLOR_TABLE_BLUE_SIZE_SGI* = 0x000080DC + GL_COLOR_TABLE_ALPHA_SIZE_SGI* = 0x000080DD + GL_COLOR_TABLE_LUMINANCE_SIZE_SGI* = 0x000080DE + GL_COLOR_TABLE_INTENSITY_SIZE_SGI* = 0x000080DF + +proc glColorTableSGI*(target: TGLenum, internalformat: TGLenum, width: TGLsizei, + format: TGLenum, thetype: TGLenum, table: PGLvoid){. + dynlib: dllname, importc: "glColorTableSGI".} +proc glCopyColorTableSGI*(target: TGLenum, internalformat: TGLenum, x: TGLint, + y: TGLint, width: TGLsizei){.dynlib: dllname, + importc: "glCopyColorTableSGI".} +proc glColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glColorTableParameterivSGI".} +proc glColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glColorTableParameterfvSGI".} +proc glGetColorTableSGI*(target: TGLenum, format: TGLenum, thetype: TGLenum, + table: PGLvoid){.dynlib: dllname, + importc: "glGetColorTableSGI".} +proc glGetColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetColorTableParameterivSGI".} +proc glGetColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetColorTableParameterfvSGI".} + #***** GL_SGI_texture_color_table *****// +const + GL_TEXTURE_COLOR_TABLE_SGI* = 0x000080BC + GL_PROXY_TEXTURE_COLOR_TABLE_SGI* = 0x000080BD + #***** GL_SUN_vertex *****// + +proc glColor4ubVertex2fSUN*(r: TGLubyte, g: TGLubyte, b: TGLubyte, a: TGLubyte, + x: TGLfloat, y: TGLfloat){.dynlib: dllname, + importc: "glColor4ubVertex2fSUN".} +proc glColor4ubVertex2fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, + importc: "glColor4ubVertex2fvSUN".} +proc glColor4ubVertex3fSUN*(r: TGLubyte, g: TGLubyte, b: TGLubyte, a: TGLubyte, + x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glColor4ubVertex3fSUN".} +proc glColor4ubVertex3fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, + importc: "glColor4ubVertex3fvSUN".} +proc glColor3fVertex3fSUN*(r: TGLfloat, g: TGLfloat, b: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc: "glColor3fVertex3fSUN".} +proc glColor3fVertex3fvSUN*(c: PGLfloat, v: PGLfloat){.dynlib: dllname, + importc: "glColor3fVertex3fvSUN".} +proc glNormal3fVertex3fSUN*(nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, + x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glNormal3fVertex3fSUN".} +proc glNormal3fVertex3fvSUN*(n: PGLfloat, v: PGLfloat){.dynlib: dllname, + importc: "glNormal3fVertex3fvSUN".} +proc glColor4fNormal3fVertex3fSUN*(r: TGLfloat, g: TGLfloat, b: TGLfloat, + a: TGLfloat, nx: TGLfloat, ny: TGLfloat, + nz: TGLfloat, x: TGLfloat, y: TGLfloat, + z: TGLfloat){.dynlib: dllname, + importc: "glColor4fNormal3fVertex3fSUN".} +proc glColor4fNormal3fVertex3fvSUN*(c: PGLfloat, n: PGLfloat, v: PGLfloat){. + dynlib: dllname, importc: "glColor4fNormal3fVertex3fvSUN".} +proc glTexCoord2fVertex3fSUN*(s: TGLfloat, t: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc: "glTexCoord2fVertex3fSUN".} +proc glTexCoord2fVertex3fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, + importc: "glTexCoord2fVertex3fvSUN".} +proc glTexCoord4fVertex4fSUN*(s: TGLfloat, t: TGLfloat, p: TGLfloat, + q: TGLfloat, x: TGLfloat, y: TGLfloat, + z: TGLfloat, w: TGLfloat){.dynlib: dllname, + importc: "glTexCoord4fVertex4fSUN".} +proc glTexCoord4fVertex4fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, + importc: "glTexCoord4fVertex4fvSUN".} +proc glTexCoord2fColor4ubVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLubyte, + g: TGLubyte, b: TGLubyte, a: TGLubyte, + x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glTexCoord2fColor4ubVertex3fSUN".} +proc glTexCoord2fColor4ubVertex3fvSUN*(tc: PGLfloat, c: PGLubyte, v: PGLfloat){. + dynlib: dllname, importc: "glTexCoord2fColor4ubVertex3fvSUN".} +proc glTexCoord2fColor3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLfloat, + g: TGLfloat, b: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc: "glTexCoord2fColor3fVertex3fSUN".} +proc glTexCoord2fColor3fVertex3fvSUN*(tc: PGLfloat, c: PGLfloat, v: PGLfloat){. + dynlib: dllname, importc: "glTexCoord2fColor3fVertex3fvSUN".} +proc glTexCoord2fNormal3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, nx: TGLfloat, + ny: TGLfloat, nz: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glTexCoord2fNormal3fVertex3fSUN".} +proc glTexCoord2fNormal3fVertex3fvSUN*(tc: PGLfloat, n: PGLfloat, v: PGLfloat){. + dynlib: dllname, importc: "glTexCoord2fNormal3fVertex3fvSUN".} +proc glTexCoord2fColor4fNormal3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, + r: TGLfloat, g: TGLfloat, b: TGLfloat, a: TGLfloat, nx: TGLfloat, + ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glTexCoord2fColor4fNormal3fVertex3fSUN".} +proc glTexCoord2fColor4fNormal3fVertex3fvSUN*(tc: PGLfloat, c: PGLfloat, + n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glTexCoord2fColor4fNormal3fVertex3fvSUN".} +proc glTexCoord4fColor4fNormal3fVertex4fSUN*(s: TGLfloat, t: TGLfloat, + p: TGLfloat, q: TGLfloat, r: TGLfloat, g: TGLfloat, b: TGLfloat, + a: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat, w: TGLfloat){.dynlib: dllname, + importc: "glTexCoord4fColor4fNormal3fVertex4fSUN".} +proc glTexCoord4fColor4fNormal3fVertex4fvSUN*(tc: PGLfloat, c: PGLfloat, + n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glTexCoord4fColor4fNormal3fVertex4fvSUN".} +proc glReplacementCodeuiVertex3fSUN*(rc: TGLuint, x: TGLfloat, y: TGLfloat, + z: TGLfloat){.dynlib: dllname, + importc: "glReplacementCodeuiVertex3fSUN".} +proc glReplacementCodeuiVertex3fvSUN*(rc: PGLuint, v: PGLfloat){. + dynlib: dllname, importc: "glReplacementCodeuiVertex3fvSUN".} +proc glReplacementCodeuiColor4ubVertex3fSUN*(rc: TGLuint, r: TGLubyte, + g: TGLubyte, b: TGLubyte, a: TGLubyte, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glReplacementCodeuiColor4ubVertex3fSUN".} +proc glReplacementCodeuiColor4ubVertex3fvSUN*(rc: PGLuint, c: PGLubyte, + v: PGLfloat){.dynlib: dllname, + importc: "glReplacementCodeuiColor4ubVertex3fvSUN".} +proc glReplacementCodeuiColor3fVertex3fSUN*(rc: TGLuint, r: TGLfloat, + g: TGLfloat, b: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glReplacementCodeuiColor3fVertex3fSUN".} +proc glReplacementCodeuiColor3fVertex3fvSUN*(rc: PGLuint, c: PGLfloat, + v: PGLfloat){.dynlib: dllname, + importc: "glReplacementCodeuiColor3fVertex3fvSUN".} +proc glReplacementCodeuiNormal3fVertex3fSUN*(rc: TGLuint, nx: TGLfloat, + ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc: "glReplacementCodeuiNormal3fVertex3fSUN".} +proc glReplacementCodeuiNormal3fVertex3fvSUN*(rc: PGLuint, n: PGLfloat, + v: PGLfloat){.dynlib: dllname, + importc: "glReplacementCodeuiNormal3fVertex3fvSUN".} +proc glReplacementCodeuiColor4fNormal3fVertex3fSUN*(rc: TGLuint, r: TGLfloat, + g: TGLfloat, b: TGLfloat, a: TGLfloat, nx: TGLfloat, ny: TGLfloat, + nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc: "glReplacementCodeuiColor4fNormal3fVertex3fSUN".} +proc glReplacementCodeuiColor4fNormal3fVertex3fvSUN*(rc: PGLuint, c: PGLfloat, + n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiColor4fNormal3fVertex3fvSUN".} +proc glReplacementCodeuiTexCoord2fVertex3fSUN*(rc: TGLuint, s: TGLfloat, + t: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc: "glReplacementCodeuiTexCoord2fVertex3fSUN".} +proc glReplacementCodeuiTexCoord2fVertex3fvSUN*(rc: PGLuint, tc: PGLfloat, + v: PGLfloat){.dynlib: dllname, + importc: "glReplacementCodeuiTexCoord2fVertex3fvSUN".} +proc glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN*(rc: TGLuint, s: TGLfloat, + t: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN".} +proc glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN*(rc: PGLuint, + tc: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, + importc: "glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN".} +proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN*(rc: TGLuint, + s: TGLfloat, t: TGLfloat, r: TGLfloat, g: TGLfloat, b: TGLfloat, + a: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN".} +proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN*(rc: PGLuint, + tc: PGLfloat, c: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, + importc: "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN".} + #***** GL_ARB_fragment_program *****// +const + GL_FRAGMENT_PROGRAM_ARB* = 0x00008804 # GL_PROGRAM_FORMAT_ASCII_ARB { already defined } + # GL_PROGRAM_LENGTH_ARB { already defined } + # GL_PROGRAM_FORMAT_ARB { already defined } + # GL_PROGRAM_BINDING_ARB { already defined } + # GL_PROGRAM_INSTRUCTIONS_ARB { already defined } + # GL_MAX_PROGRAM_INSTRUCTIONS_ARB { already defined } + # GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB { already defined } + # GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB { already defined } + # GL_PROGRAM_TEMPORARIES_ARB { already defined } + # GL_MAX_PROGRAM_TEMPORARIES_ARB { already defined } + # GL_PROGRAM_NATIVE_TEMPORARIES_ARB { already defined } + # GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB { already defined } + # GL_PROGRAM_PARAMETERS_ARB { already defined } + # GL_MAX_PROGRAM_PARAMETERS_ARB { already defined } + # GL_PROGRAM_NATIVE_PARAMETERS_ARB { already defined } + # GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB { already defined } + # GL_PROGRAM_ATTRIBS_ARB { already defined } + # GL_MAX_PROGRAM_ATTRIBS_ARB { already defined } + # GL_PROGRAM_NATIVE_ATTRIBS_ARB { already defined } + # GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB { already defined } + # GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB { already defined } + # GL_MAX_PROGRAM_ENV_PARAMETERS_ARB { already defined } + # GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB { already defined } + GL_PROGRAM_ALU_INSTRUCTIONS_ARB* = 0x00008805 + GL_PROGRAM_TEX_INSTRUCTIONS_ARB* = 0x00008806 + GL_PROGRAM_TEX_INDIRECTIONS_ARB* = 0x00008807 + GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB* = 0x00008808 + GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB* = 0x00008809 + GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB* = 0x0000880A + GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB* = 0x0000880B + GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB* = 0x0000880C + GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB* = 0x0000880D + GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB* = 0x0000880E + GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB* = 0x0000880F + GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB* = 0x00008810 # GL_PROGRAM_STRING_ARB { already defined } + # + # + # GL_PROGRAM_ERROR_POSITION_ARB { already defined } + # GL_CURRENT_MATRIX_ARB { already defined } + # + # + # GL_TRANSPOSE_CURRENT_MATRIX_ARB { already defined } + # + # + # GL_CURRENT_MATRIX_STACK_DEPTH_ARB { already defined } + # + # + # GL_MAX_PROGRAM_MATRICES_ARB { already defined } + # + # + # GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB { already defined } + GL_MAX_TEXTURE_COORDS_ARB* = 0x00008871 + GL_MAX_TEXTURE_IMAGE_UNITS_ARB* = 0x00008872 # GL_PROGRAM_ERROR_STRING_ARB { already defined } + # GL_MATRIX0_ARB { already defined } + # GL_MATRIX1_ARB { already defined } + # GL_MATRIX2_ARB { already defined } + # GL_MATRIX3_ARB { already defined } + # GL_MATRIX4_ARB { already defined } + # GL_MATRIX5_ARB { already defined } + # GL_MATRIX6_ARB { already defined } + # GL_MATRIX7_ARB { already defined } + # GL_MATRIX8_ARB { already defined } + # GL_MATRIX9_ARB { already defined } + # GL_MATRIX10_ARB { already defined } + # GL_MATRIX11_ARB { already defined } + # GL_MATRIX12_ARB { already defined } + # GL_MATRIX13_ARB { already defined } + # GL_MATRIX14_ARB { already defined } + # GL_MATRIX15_ARB { already defined } + # GL_MATRIX16_ARB { already defined } + # GL_MATRIX17_ARB { already defined } + # GL_MATRIX18_ARB { already defined } + # GL_MATRIX19_ARB { already defined } + # GL_MATRIX20_ARB { already defined } + # GL_MATRIX21_ARB { already defined } + # GL_MATRIX22_ARB { already defined } + # GL_MATRIX23_ARB { already defined } + # GL_MATRIX24_ARB { already defined } + # GL_MATRIX25_ARB { already defined } + # GL_MATRIX26_ARB { already defined } + # GL_MATRIX27_ARB { already defined } + # GL_MATRIX28_ARB { already defined } + # GL_MATRIX29_ARB { already defined } + # GL_MATRIX30_ARB { already defined } + # GL_MATRIX31_ARB { already defined } + # glProgramStringARB { already defined } + # glBindProgramARB { already defined } + # glDeleteProgramsARB { already defined } + # glGenProgramsARB { already defined } + # glProgramEnvParameter4dARB { already defined } + # glProgramEnvParameter4dvARB { already defined } + # glProgramEnvParameter4fARB { already defined } + # glProgramEnvParameter4fvARB { already defined } + # glProgramLocalParameter4dARB { already defined } + # glProgramLocalParameter4dvARB { already defined } + # glProgramLocalParameter4fARB { already defined } + # glProgramLocalParameter4fvARB { already defined } + # glGetProgramEnvParameterdvARB { already defined } + # glGetProgramEnvParameterfvARB { already defined } + # glGetProgramLocalParameterdvARB { already defined } + # glGetProgramLocalParameterfvARB { already defined } + # glGetProgramivARB { already defined } + # glGetProgramStringARB { already defined } + # glIsProgramARB { already defined } + #***** GL_ATI_text_fragment_shader ***** + +const + GL_TEXT_FRAGMENT_SHADER_ATI* = 0x00008200 #***** GL_ARB_vertex_buffer_object ***** + +const + GL_BUFFER_SIZE_ARB* = 0x00008764 + GL_BUFFER_USAGE_ARB* = 0x00008765 + GL_ARRAY_BUFFER_ARB* = 0x00008892 + GL_ELEMENT_ARRAY_BUFFER_ARB* = 0x00008893 + GL_ARRAY_BUFFER_BINDING_ARB* = 0x00008894 + GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB* = 0x00008895 + GL_VERTEX_ARRAY_BUFFER_BINDING_ARB* = 0x00008896 + GL_NORMAL_ARRAY_BUFFER_BINDING_ARB* = 0x00008897 + GL_COLOR_ARRAY_BUFFER_BINDING_ARB* = 0x00008898 + GL_INDEX_ARRAY_BUFFER_BINDING_ARB* = 0x00008899 + GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB* = 0x0000889A + GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB* = 0x0000889B + GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB* = 0x0000889C + GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB* = 0x0000889D + GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB* = 0x0000889E + GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB* = 0x0000889F + GL_READ_ONLY_ARB* = 0x000088B8 + GL_WRITE_ONLY_ARB* = 0x000088B9 + GL_READ_WRITE_ARB* = 0x000088BA + GL_BUFFER_ACCESS_ARB* = 0x000088BB + GL_BUFFER_MAPPED_ARB* = 0x000088BC + GL_BUFFER_MAP_POINTER_ARB* = 0x000088BD + GL_STREAM_DRAW_ARB* = 0x000088E0 + GL_STREAM_READ_ARB* = 0x000088E1 + GL_STREAM_COPY_ARB* = 0x000088E2 + GL_STATIC_DRAW_ARB* = 0x000088E4 + GL_STATIC_READ_ARB* = 0x000088E5 + GL_STATIC_COPY_ARB* = 0x000088E6 + GL_DYNAMIC_DRAW_ARB* = 0x000088E8 + GL_DYNAMIC_READ_ARB* = 0x000088E9 + GL_DYNAMIC_COPY_ARB* = 0x000088EA + +proc glBindBufferARB*(target: TGLenum, buffer: TGLuint){.dynlib: dllname, + importc: "glBindBufferARB".} +proc glDeleteBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, + importc: "glDeleteBuffersARB".} +proc glGenBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, + importc: "glGenBuffersARB".} +proc glIsBufferARB*(buffer: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsBufferARB".} +proc glBufferDataARB*(target: TGLenum, size: TGLsizei, data: PGLvoid, + usage: TGLenum){.dynlib: dllname, + importc: "glBufferDataARB".} +proc glBufferSubDataARB*(target: TGLenum, offset: TGLint, size: TGLsizei, + data: PGLvoid){.dynlib: dllname, + importc: "glBufferSubDataARB".} +proc glGetBufferSubDataARB*(target: TGLenum, offset: TGLint, size: TGLsizei, + data: PGLvoid){.dynlib: dllname, + importc: "glGetBufferSubDataARB".} +proc glMapBufferARB*(target: TGLenum, access: TGLenum): PGLvoid{. + dynlib: dllname, importc: "glMapBufferARB".} +proc glUnmapBufferARB*(target: TGLenum): TGLboolean{.dynlib: dllname, + importc: "glUnmapBufferARB".} +proc glGetBufferParameterivARB*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetBufferParameterivARB".} +proc glGetBufferPointervARB*(target: TGLenum, pname: TGLenum, params: PPGLvoid){. + dynlib: dllname, importc: "glGetBufferPointervARB".} + #***** GL_APPLE_client_storage *****// +const + GL_UNPACK_CLIENT_STORAGE_APPLE* = 0x000085B2 + #***** GL_APPLE_element_array *****// + +const + GL_ELEMENT_ARRAY_APPLE* = 0x00008768 + GL_ELEMENT_ARRAY_TYPE_APPLE* = 0x00008769 + GL_ELEMENT_ARRAY_POINTER_APPLE* = 0x0000876A + +proc glElementPointerAPPLE*(thetype: TGLenum, pointer: PGLvoid){. + dynlib: dllname, importc: "glElementPointerAPPLE".} +proc glDrawElementArrayAPPLE*(mode: TGLenum, first: TGLint, count: TGLsizei){. + dynlib: dllname, importc: "glDrawElementArrayAPPLE".} +proc glDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, + theend: TGLuint, first: TGLint, + count: TGLsizei){.dynlib: dllname, + importc: "glDrawRangeElementArrayAPPLE".} +proc glMultiDrawElementArrayAPPLE*(mode: TGLenum, first: PGLint, + count: PGLsizei, primcount: TGLsizei){. + dynlib: dllname, importc: "glMultiDrawElementArrayAPPLE".} +proc glMultiDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, + theend: TGLuint, first: PGLint, + count: PGLsizei, primcount: TGLsizei){. + dynlib: dllname, importc: "glMultiDrawRangeElementArrayAPPLE".} + #***** GL_APPLE_fence *****// +const + GL_DRAW_PIXELS_APPLE* = 0x00008A0A + GL_FENCE_APPLE* = 0x00008A0B + +proc glGenFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, + importc: "glGenFencesAPPLE".} +proc glDeleteFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, + importc: "glDeleteFencesAPPLE".} +proc glSetFenceAPPLE*(fence: TGLuint){.dynlib: dllname, + importc: "glSetFenceAPPLE".} +proc glIsFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsFenceAPPLE".} +proc glTestFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glTestFenceAPPLE".} +proc glFinishFenceAPPLE*(fence: TGLuint){.dynlib: dllname, + importc: "glFinishFenceAPPLE".} +proc glTestObjectAPPLE*(theobject: TGLenum, name: TGLuint): TGLboolean{. + dynlib: dllname, importc: "glTestObjectAPPLE".} +proc glFinishObjectAPPLE*(theobject: TGLenum, name: TGLint){.dynlib: dllname, + importc: "glFinishObjectAPPLE".} + #***** GL_APPLE_vertex_array_object *****// +const + GL_VERTEX_ARRAY_BINDING_APPLE* = 0x000085B5 + +proc glBindVertexArrayAPPLE*(thearray: TGLuint){.dynlib: dllname, + importc: "glBindVertexArrayAPPLE".} +proc glDeleteVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, + importc: "glDeleteVertexArraysAPPLE".} +proc glGenVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, + importc: "glGenVertexArraysAPPLE".} +proc glIsVertexArrayAPPLE*(thearray: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsVertexArrayAPPLE".} + #***** GL_APPLE_vertex_array_range *****// +const + constGL_VERTEX_ARRAY_RANGE_APPLE* = 0x0000851D + GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE* = 0x0000851E + GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE* = 0x00008520 + GL_VERTEX_ARRAY_RANGE_POINTER_APPLE* = 0x00008521 + GL_VERTEX_ARRAY_STORAGE_HINT_APPLE* = 0x0000851F + GL_STORAGE_CACHED_APPLE* = 0x000085BE + GL_STORAGE_SHARED_APPLE* = 0x000085BF + +proc glVertexArrayRangeAPPLE*(len: TGLsizei, pointer: PGLvoid){.dynlib: dllname, + importc: "glVertexArrayRangeAPPLE".} +proc glFlushVertexArrayRangeAPPLE*(len: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc: "glFlushVertexArrayRangeAPPLE".} +proc glVertexArrayParameteriAPPLE*(pname: TGLenum, param: TGLint){. + dynlib: dllname, importc: "glVertexArrayParameteriAPPLE".} + #***** GL_ARB_matrix_palette *****// +const + GL_MATRIX_PALETTE_ARB* = 0x00008840 + GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB* = 0x00008841 + GL_MAX_PALETTE_MATRICES_ARB* = 0x00008842 + constGL_CURRENT_PALETTE_MATRIX_ARB* = 0x00008843 + GL_MATRIX_INDEX_ARRAY_ARB* = 0x00008844 + GL_CURRENT_MATRIX_INDEX_ARB* = 0x00008845 + GL_MATRIX_INDEX_ARRAY_SIZE_ARB* = 0x00008846 + GL_MATRIX_INDEX_ARRAY_TYPE_ARB* = 0x00008847 + GL_MATRIX_INDEX_ARRAY_STRIDE_ARB* = 0x00008848 + GL_MATRIX_INDEX_ARRAY_POINTER_ARB* = 0x00008849 + +proc glCurrentPaletteMatrixARB*(index: TGLint){.dynlib: dllname, + importc: "glCurrentPaletteMatrixARB".} +proc glMatrixIndexubvARB*(size: TGLint, indices: PGLubyte){.dynlib: dllname, + importc: "glMatrixIndexubvARB".} +proc glMatrixIndexusvARB*(size: TGLint, indices: PGLushort){.dynlib: dllname, + importc: "glMatrixIndexusvARB".} +proc glMatrixIndexuivARB*(size: TGLint, indices: PGLuint){.dynlib: dllname, + importc: "glMatrixIndexuivARB".} +proc glMatrixIndexPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, + importc: "glMatrixIndexPointerARB".} + #***** GL_NV_element_array *****// +const + GL_ELEMENT_ARRAY_TYPE_NV* = 0x00008769 + GL_ELEMENT_ARRAY_POINTER_NV* = 0x0000876A + +proc glElementPointerNV*(thetype: TGLenum, pointer: PGLvoid){.dynlib: dllname, + importc: "glElementPointerNV".} +proc glDrawElementArrayNV*(mode: TGLenum, first: TGLint, count: TGLsizei){. + dynlib: dllname, importc: "glDrawElementArrayNV".} +proc glDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, theend: TGLuint, + first: TGLint, count: TGLsizei){. + dynlib: dllname, importc: "glDrawRangeElementArrayNV".} +proc glMultiDrawElementArrayNV*(mode: TGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei){.dynlib: dllname, + importc: "glMultiDrawElementArrayNV".} +proc glMultiDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, + theend: TGLuint, first: PGLint, + count: PGLsizei, primcount: TGLsizei){. + dynlib: dllname, importc: "glMultiDrawRangeElementArrayNV".} + #***** GL_NV_float_buffer *****// +const + GL_FLOAT_R_NV* = 0x00008880 + GL_FLOAT_RG_NV* = 0x00008881 + GL_FLOAT_RGB_NV* = 0x00008882 + GL_FLOAT_RGBA_NV* = 0x00008883 + GL_FLOAT_R16_NV* = 0x00008884 + GL_FLOAT_R32_NV* = 0x00008885 + GL_FLOAT_RG16_NV* = 0x00008886 + GL_FLOAT_RG32_NV* = 0x00008887 + GL_FLOAT_RGB16_NV* = 0x00008888 + GL_FLOAT_RGB32_NV* = 0x00008889 + GL_FLOAT_RGBA16_NV* = 0x0000888A + GL_FLOAT_RGBA32_NV* = 0x0000888B + GL_TEXTURE_FLOAT_COMPONENTS_NV* = 0x0000888C + GL_FLOAT_CLEAR_COLOR_VALUE_NV* = 0x0000888D + GL_FLOAT_RGBA_MODE_NV* = 0x0000888E + #***** GL_NV_fragment_program *****// + +const + GL_FRAGMENT_PROGRAM_NV* = 0x00008870 + GL_MAX_TEXTURE_COORDS_NV* = 0x00008871 + GL_MAX_TEXTURE_IMAGE_UNITS_NV* = 0x00008872 + GL_FRAGMENT_PROGRAM_BINDING_NV* = 0x00008873 + GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV* = 0x00008868 + GL_PROGRAM_ERROR_STRING_NV* = 0x00008874 + +proc glProgramNamedParameter4fNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, + x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, + importc: "glProgramNamedParameter4fNV".} +proc glProgramNamedParameter4dNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, + x: TGLdouble, y: TGLdouble, z: TGLdouble, + w: TGLdouble){.dynlib: dllname, + importc: "glProgramNamedParameter4dNV".} +proc glGetProgramNamedParameterfvNV*(id: TGLuint, length: TGLsizei, + name: PGLubyte, params: PGLfloat){. + dynlib: dllname, importc: "glGetProgramNamedParameterfvNV".} +proc glGetProgramNamedParameterdvNV*(id: TGLuint, length: TGLsizei, + name: PGLubyte, params: PGLdouble){. + dynlib: dllname, importc: "glGetProgramNamedParameterdvNV".} + # glProgramLocalParameter4dARB { already defined } + # glProgramLocalParameter4dvARB { already defined } + # glProgramLocalParameter4fARB { already defined } + # glProgramLocalParameter4fvARB { already defined } + # glGetProgramLocalParameterdvARB { already defined } + # glGetProgramLocalParameterfvARB { already defined } + #***** GL_NV_primitive_restart *****// +const + constGL_PRIMITIVE_RESTART_NV* = 0x00008558 + constGL_PRIMITIVE_RESTART_INDEX_NV* = 0x00008559 + +proc glPrimitiveRestartNV*(){.dynlib: dllname, importc: "glPrimitiveRestartNV".} +proc glPrimitiveRestartIndexNV*(index: TGLuint){.dynlib: dllname, + importc: "glPrimitiveRestartIndexNV".} + #***** GL_NV_vertex_program2 *****// + #***** GL_NV_pixel_data_range *****// +const + GL_WRITE_PIXEL_DATA_RANGE_NV* = 0x00008878 + GL_READ_PIXEL_DATA_RANGE_NV* = 0x00008879 + GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV* = 0x0000887A + GL_READ_PIXEL_DATA_RANGE_LENGTH_NV* = 0x0000887B + GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV* = 0x0000887C + GL_READ_PIXEL_DATA_RANGE_POINTER_NV* = 0x0000887D + +proc glPixelDataRangeNV*(target: TGLenum, len: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc: "glPixelDataRangeNV".} +proc glFlushPixelDataRangeNV*(target: TGLenum){.dynlib: dllname, + importc: "glFlushPixelDataRangeNV".} + # wglAllocateMemoryNV { already defined } + # wglFreeMemoryNV { already defined } + #***** GL_EXT_texture_rectangle *****// +const + GL_TEXTURE_RECTANGLE_EXT* = 0x000084F5 + GL_TEXTURE_BINDING_RECTANGLE_EXT* = 0x000084F6 + GL_PROXY_TEXTURE_RECTANGLE_EXT* = 0x000084F7 + GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT* = 0x000084F8 + #***** GL_S3_s3tc *****// + +const + GL_RGB_S3TC* = 0x000083A0 + GL_RGB4_S3TC* = 0x000083A1 + GL_RGBA_S3TC* = 0x000083A2 + GL_RGBA4_S3TC* = 0x000083A3 + #***** GL_ATI_draw_buffers *****// + +const + GL_MAX_DRAW_BUFFERS_ATI* = 0x00008824 + GL_DRAW_BUFFER0_ATI* = 0x00008825 + GL_DRAW_BUFFER1_ATI* = 0x00008826 + GL_DRAW_BUFFER2_ATI* = 0x00008827 + GL_DRAW_BUFFER3_ATI* = 0x00008828 + GL_DRAW_BUFFER4_ATI* = 0x00008829 + GL_DRAW_BUFFER5_ATI* = 0x0000882A + GL_DRAW_BUFFER6_ATI* = 0x0000882B + GL_DRAW_BUFFER7_ATI* = 0x0000882C + GL_DRAW_BUFFER8_ATI* = 0x0000882D + GL_DRAW_BUFFER9_ATI* = 0x0000882E + GL_DRAW_BUFFER10_ATI* = 0x0000882F + GL_DRAW_BUFFER11_ATI* = 0x00008830 + GL_DRAW_BUFFER12_ATI* = 0x00008831 + GL_DRAW_BUFFER13_ATI* = 0x00008832 + GL_DRAW_BUFFER14_ATI* = 0x00008833 + GL_DRAW_BUFFER15_ATI* = 0x00008834 + +proc glDrawBuffersATI*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, + importc: "glDrawBuffersATI".} + #***** GL_ATI_texture_env_combine3 *****// +const + GL_MODULATE_ADD_ATI* = 0x00008744 + GL_MODULATE_SIGNED_ADD_ATI* = 0x00008745 + GL_MODULATE_SUBTRACT_ATI* = 0x00008746 + #***** GL_ATI_texture_float *****// + +const + GL_RGBA_FLOAT32_ATI* = 0x00008814 + GL_RGB_FLOAT32_ATI* = 0x00008815 + GL_ALPHA_FLOAT32_ATI* = 0x00008816 + GL_INTENSITY_FLOAT32_ATI* = 0x00008817 + GL_LUMINANCE_FLOAT32_ATI* = 0x00008818 + GL_LUMINANCE_ALPHA_FLOAT32_ATI* = 0x00008819 + GL_RGBA_FLOAT16_ATI* = 0x0000881A + GL_RGB_FLOAT16_ATI* = 0x0000881B + GL_ALPHA_FLOAT16_ATI* = 0x0000881C + GL_INTENSITY_FLOAT16_ATI* = 0x0000881D + GL_LUMINANCE_FLOAT16_ATI* = 0x0000881E + GL_LUMINANCE_ALPHA_FLOAT16_ATI* = 0x0000881F + #***** GL_NV_texture_expand_normal *****// + +const + GL_TEXTURE_UNSIGNED_REMAP_MODE_NV* = 0x0000888F + #***** GL_NV_half_float *****// + +const + GL_HALF_FLOAT_NV* = 0x0000140B + +proc glVertex2hNV*(x: TGLushort, y: TGLushort){.dynlib: dllname, + importc: "glVertex2hNV".} +proc glVertex2hvNV*(v: PGLushort){.dynlib: dllname, importc: "glVertex2hvNV".} +proc glVertex3hNV*(x: TGLushort, y: TGLushort, z: TGLushort){.dynlib: dllname, + importc: "glVertex3hNV".} +proc glVertex3hvNV*(v: PGLushort){.dynlib: dllname, importc: "glVertex3hvNV".} +proc glVertex4hNV*(x: TGLushort, y: TGLushort, z: TGLushort, w: TGLushort){. + dynlib: dllname, importc: "glVertex4hNV".} +proc glVertex4hvNV*(v: PGLushort){.dynlib: dllname, importc: "glVertex4hvNV".} +proc glNormal3hNV*(nx: TGLushort, ny: TGLushort, nz: TGLushort){. + dynlib: dllname, importc: "glNormal3hNV".} +proc glNormal3hvNV*(v: PGLushort){.dynlib: dllname, importc: "glNormal3hvNV".} +proc glColor3hNV*(red: TGLushort, green: TGLushort, blue: TGLushort){. + dynlib: dllname, importc: "glColor3hNV".} +proc glColor3hvNV*(v: PGLushort){.dynlib: dllname, importc: "glColor3hvNV".} +proc glColor4hNV*(red: TGLushort, green: TGLushort, blue: TGLushort, + alpha: TGLushort){.dynlib: dllname, importc: "glColor4hNV".} +proc glColor4hvNV*(v: PGLushort){.dynlib: dllname, importc: "glColor4hvNV".} +proc glTexCoord1hNV*(s: TGLushort){.dynlib: dllname, importc: "glTexCoord1hNV".} +proc glTexCoord1hvNV*(v: PGLushort){.dynlib: dllname, importc: "glTexCoord1hvNV".} +proc glTexCoord2hNV*(s: TGLushort, t: TGLushort){.dynlib: dllname, + importc: "glTexCoord2hNV".} +proc glTexCoord2hvNV*(v: PGLushort){.dynlib: dllname, importc: "glTexCoord2hvNV".} +proc glTexCoord3hNV*(s: TGLushort, t: TGLushort, r: TGLushort){.dynlib: dllname, + importc: "glTexCoord3hNV".} +proc glTexCoord3hvNV*(v: PGLushort){.dynlib: dllname, importc: "glTexCoord3hvNV".} +proc glTexCoord4hNV*(s: TGLushort, t: TGLushort, r: TGLushort, q: TGLushort){. + dynlib: dllname, importc: "glTexCoord4hNV".} +proc glTexCoord4hvNV*(v: PGLushort){.dynlib: dllname, importc: "glTexCoord4hvNV".} +proc glMultiTexCoord1hNV*(target: TGLenum, s: TGLushort){.dynlib: dllname, + importc: "glMultiTexCoord1hNV".} +proc glMultiTexCoord1hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, + importc: "glMultiTexCoord1hvNV".} +proc glMultiTexCoord2hNV*(target: TGLenum, s: TGLushort, t: TGLushort){. + dynlib: dllname, importc: "glMultiTexCoord2hNV".} +proc glMultiTexCoord2hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, + importc: "glMultiTexCoord2hvNV".} +proc glMultiTexCoord3hNV*(target: TGLenum, s: TGLushort, t: TGLushort, + r: TGLushort){.dynlib: dllname, + importc: "glMultiTexCoord3hNV".} +proc glMultiTexCoord3hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, + importc: "glMultiTexCoord3hvNV".} +proc glMultiTexCoord4hNV*(target: TGLenum, s: TGLushort, t: TGLushort, + r: TGLushort, q: TGLushort){.dynlib: dllname, + importc: "glMultiTexCoord4hNV".} +proc glMultiTexCoord4hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, + importc: "glMultiTexCoord4hvNV".} +proc glFogCoordhNV*(fog: TGLushort){.dynlib: dllname, importc: "glFogCoordhNV".} +proc glFogCoordhvNV*(fog: PGLushort){.dynlib: dllname, importc: "glFogCoordhvNV".} +proc glSecondaryColor3hNV*(red: TGLushort, green: TGLushort, blue: TGLushort){. + dynlib: dllname, importc: "glSecondaryColor3hNV".} +proc glSecondaryColor3hvNV*(v: PGLushort){.dynlib: dllname, + importc: "glSecondaryColor3hvNV".} +proc glVertexWeighthNV*(weight: TGLushort){.dynlib: dllname, + importc: "glVertexWeighthNV".} +proc glVertexWeighthvNV*(weight: PGLushort){.dynlib: dllname, + importc: "glVertexWeighthvNV".} +proc glVertexAttrib1hNV*(index: TGLuint, x: TGLushort){.dynlib: dllname, + importc: "glVertexAttrib1hNV".} +proc glVertexAttrib1hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, + importc: "glVertexAttrib1hvNV".} +proc glVertexAttrib2hNV*(index: TGLuint, x: TGLushort, y: TGLushort){. + dynlib: dllname, importc: "glVertexAttrib2hNV".} +proc glVertexAttrib2hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, + importc: "glVertexAttrib2hvNV".} +proc glVertexAttrib3hNV*(index: TGLuint, x: TGLushort, y: TGLushort, + z: TGLushort){.dynlib: dllname, + importc: "glVertexAttrib3hNV".} +proc glVertexAttrib3hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, + importc: "glVertexAttrib3hvNV".} +proc glVertexAttrib4hNV*(index: TGLuint, x: TGLushort, y: TGLushort, + z: TGLushort, w: TGLushort){.dynlib: dllname, + importc: "glVertexAttrib4hNV".} +proc glVertexAttrib4hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, + importc: "glVertexAttrib4hvNV".} +proc glVertexAttribs1hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. + dynlib: dllname, importc: "glVertexAttribs1hvNV".} +proc glVertexAttribs2hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. + dynlib: dllname, importc: "glVertexAttribs2hvNV".} +proc glVertexAttribs3hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. + dynlib: dllname, importc: "glVertexAttribs3hvNV".} +proc glVertexAttribs4hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. + dynlib: dllname, importc: "glVertexAttribs4hvNV".} + #***** GL_ATI_map_object_buffer *****// +proc glMapObjectBufferATI*(buffer: TGLuint): PGLvoid{.dynlib: dllname, + importc: "glMapObjectBufferATI".} +proc glUnmapObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, + importc: "glUnmapObjectBufferATI".} + #***** GL_ATI_separate_stencil *****// +const + GL_KEEP* = 0x00001E00 + GL_ZERO* = 0x00000000 + GL_REPLACE* = 0x00001E01 + GL_INCR* = 0x00001E02 + GL_DECR* = 0x00001E03 + GL_INVERT* = 0x0000150A + GL_NEVER* = 0x00000200 + GL_LESS* = 0x00000201 + GL_LEQUAL* = 0x00000203 + GL_GREATER* = 0x00000204 + GL_GEQUAL* = 0x00000206 + GL_EQUAL* = 0x00000202 + GL_NOTEQUAL* = 0x00000205 + GL_ALWAYS* = 0x00000207 + GL_FRONT* = 0x00000404 + GL_BACK* = 0x00000405 + GL_FRONT_AND_BACK* = 0x00000408 + GL_STENCIL_BACK_FUNC_ATI* = 0x00008800 + GL_STENCIL_BACK_FAIL_ATI* = 0x00008801 + GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI* = 0x00008802 + GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI* = 0x00008803 + +proc glStencilOpSeparateATI*(face: TGLenum, sfail: TGLenum, dpfail: TGLenum, + dppass: TGLenum){.dynlib: dllname, + importc: "glStencilOpSeparateATI".} +proc glStencilFuncSeparateATI*(frontfunc: TGLenum, backfunc: TGLenum, + theRef: TGLint, mask: TGLuint){.dynlib: dllname, + importc: "glStencilFuncSeparateATI".} + #***** GL_ATI_vertex_attrib_array_object *****// +proc glVertexAttribArrayObjectATI*(index: TGLuint, size: TGLint, + thetype: TGLenum, normalized: TGLboolean, + stride: TGLsizei, buffer: TGLuint, + offset: TGLuint){.dynlib: dllname, + importc: "glVertexAttribArrayObjectATI".} +proc glGetVertexAttribArrayObjectfvATI*(index: TGLuint, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetVertexAttribArrayObjectfvATI".} +proc glGetVertexAttribArrayObjectivATI*(index: TGLuint, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetVertexAttribArrayObjectivATI".} + #***** GL_ARB_occlusion_query *****// +const + GL_SAMPLES_PASSED_ARB* = 0x00008914 + GL_QUERY_COUNTER_BITS_ARB* = 0x00008864 + GL_CURRENT_QUERY_ARB* = 0x00008865 + GL_QUERY_RESULT_ARB* = 0x00008866 + GL_QUERY_RESULT_AVAILABLE_ARB* = 0x00008867 + +proc glGenQueriesARB*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc: "glGenQueriesARB".} +proc glDeleteQueriesARB*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc: "glDeleteQueriesARB".} +proc glIsQueryARB*(id: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsQueryARB".} +proc glBeginQueryARB*(target: TGLenum, id: TGLuint){.dynlib: dllname, + importc: "glBeginQueryARB".} +proc glEndQueryARB*(target: TGLenum){.dynlib: dllname, importc: "glEndQueryARB".} +proc glGetQueryivARB*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetQueryivARB".} +proc glGetQueryObjectivARB*(id: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetQueryObjectivARB".} +proc glGetQueryObjectuivARB*(id: TGLuint, pname: TGLenum, params: PGLuint){. + dynlib: dllname, importc: "glGetQueryObjectuivARB".} + #***** GL_ARB_shader_objects *****// +const + GL_PROGRAM_OBJECT_ARB* = 0x00008B40 + GL_OBJECT_TYPE_ARB* = 0x00008B4E + GL_OBJECT_SUBTYPE_ARB* = 0x00008B4F + GL_OBJECT_DELETE_STATUS_ARB* = 0x00008B80 + GL_OBJECT_COMPILE_STATUS_ARB* = 0x00008B81 + GL_OBJECT_LINK_STATUS_ARB* = 0x00008B82 + GL_OBJECT_VALIDATE_STATUS_ARB* = 0x00008B83 + GL_OBJECT_INFO_LOG_LENGTH_ARB* = 0x00008B84 + GL_OBJECT_ATTACHED_OBJECTS_ARB* = 0x00008B85 + GL_OBJECT_ACTIVE_UNIFORMS_ARB* = 0x00008B86 + GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB* = 0x00008B87 + GL_OBJECT_SHADER_SOURCE_LENGTH_ARB* = 0x00008B88 + GL_SHADER_OBJECT_ARB* = 0x00008B48 + GL_FLOAT* = 0x00001406 + GL_FLOAT_VEC2_ARB* = 0x00008B50 + GL_FLOAT_VEC3_ARB* = 0x00008B51 + GL_FLOAT_VEC4_ARB* = 0x00008B52 + GL_INT* = 0x00001404 + GL_INT_VEC2_ARB* = 0x00008B53 + GL_INT_VEC3_ARB* = 0x00008B54 + GL_INT_VEC4_ARB* = 0x00008B55 + GL_BOOL_ARB* = 0x00008B56 + GL_BOOL_VEC2_ARB* = 0x00008B57 + GL_BOOL_VEC3_ARB* = 0x00008B58 + GL_BOOL_VEC4_ARB* = 0x00008B59 + GL_FLOAT_MAT2_ARB* = 0x00008B5A + GL_FLOAT_MAT3_ARB* = 0x00008B5B + GL_FLOAT_MAT4_ARB* = 0x00008B5C + +proc glDeleteObjectARB*(obj: GLhandleARB){.dynlib: dllname, + importc: "glDeleteObjectARB".} +proc glGetHandleARB*(pname: TGLenum): GLhandleARB{.dynlib: dllname, + importc: "glGetHandleARB".} +proc glDetachObjectARB*(containerObj: GLhandleARB, attachedObj: GLhandleARB){. + dynlib: dllname, importc: "glDetachObjectARB".} +proc glCreateShaderObjectARB*(shaderType: TGLenum): GLhandleARB{. + dynlib: dllname, importc: "glCreateShaderObjectARB".} +proc glShaderSourceARB*(shaderObj: GLhandleARB, count: TGLsizei, str: PGLvoid, + len: PGLint){.dynlib: dllname, + importc: "glShaderSourceARB".} +proc glCompileShaderARB*(shaderObj: GLhandleARB){.dynlib: dllname, + importc: "glCompileShaderARB".} +proc glCreateProgramObjectARB*(): GLhandleARB{.dynlib: dllname, + importc: "glCreateProgramObjectARB".} +proc glAttachObjectARB*(containerObj: GLhandleARB, obj: GLhandleARB){. + dynlib: dllname, importc: "glAttachObjectARB".} +proc glLinkProgramARB*(programObj: GLhandleARB){.dynlib: dllname, + importc: "glLinkProgramARB".} +proc glUseProgramObjectARB*(programObj: GLhandleARB){.dynlib: dllname, + importc: "glUseProgramObjectARB".} +proc glValidateProgramARB*(programObj: GLhandleARB){.dynlib: dllname, + importc: "glValidateProgramARB".} +proc glUniform1fARB*(location: TGLint, v0: TGLfloat){.dynlib: dllname, + importc: "glUniform1fARB".} +proc glUniform2fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat){. + dynlib: dllname, importc: "glUniform2fARB".} +proc glUniform3fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat){. + dynlib: dllname, importc: "glUniform3fARB".} +proc glUniform4fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat, + v3: TGLfloat){.dynlib: dllname, importc: "glUniform4fARB".} +proc glUniform1iARB*(location: TGLint, v0: TGLint){.dynlib: dllname, + importc: "glUniform1iARB".} +proc glUniform2iARB*(location: TGLint, v0: TGLint, v1: TGLint){.dynlib: dllname, + importc: "glUniform2iARB".} +proc glUniform3iARB*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint){. + dynlib: dllname, importc: "glUniform3iARB".} +proc glUniform4iARB*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint, + v3: TGLint){.dynlib: dllname, importc: "glUniform4iARB".} +proc glUniform1fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc: "glUniform1fvARB".} +proc glUniform2fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc: "glUniform2fvARB".} +proc glUniform3fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc: "glUniform3fvARB".} +proc glUniform4fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc: "glUniform4fvARB".} +proc glUniform1ivARB*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc: "glUniform1ivARB".} +proc glUniform2ivARB*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc: "glUniform2ivARB".} +proc glUniform3ivARB*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc: "glUniform3ivARB".} +proc glUniform4ivARB*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc: "glUniform4ivARB".} +proc glUniformMatrix2fvARB*(location: TGLint, count: TGLsizei, + transpose: TGLboolean, value: PGLfloat){. + dynlib: dllname, importc: "glUniformMatrix2fvARB".} +proc glUniformMatrix3fvARB*(location: TGLint, count: TGLsizei, + transpose: TGLboolean, value: PGLfloat){. + dynlib: dllname, importc: "glUniformMatrix3fvARB".} +proc glUniformMatrix4fvARB*(location: TGLint, count: TGLsizei, + transpose: TGLboolean, value: PGLfloat){. + dynlib: dllname, importc: "glUniformMatrix4fvARB".} +proc glGetObjectParameterfvARB*(obj: GLhandleARB, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc: "glGetObjectParameterfvARB".} +proc glGetObjectParameterivARB*(obj: GLhandleARB, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetObjectParameterivARB".} +proc glGetInfoLogARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, + infoLog: PGLcharARB){.dynlib: dllname, + importc: "glGetInfoLogARB".} +proc glGetAttachedObjectsARB*(containerObj: GLhandleARB, maxCount: TGLsizei, + count: PGLsizei, obj: PGLhandleARB){. + dynlib: dllname, importc: "glGetAttachedObjectsARB".} +proc glGetUniformLocationARB*(programObj: GLhandleARB, name: PGLcharARB): TGLint{. + dynlib: dllname, importc: "glGetUniformLocationARB".} +proc glGetActiveUniformARB*(programObj: GLhandleARB, index: TGLuint, + maxLength: TGLsizei, len: PGLsizei, size: PGLint, + thetype: PGLenum, name: PGLcharARB){. + dynlib: dllname, importc: "glGetActiveUniformARB".} +proc glGetUniformfvARB*(programObj: GLhandleARB, location: TGLint, + params: PGLfloat){.dynlib: dllname, + importc: "glGetUniformfvARB".} +proc glGetUniformivARB*(programObj: GLhandleARB, location: TGLint, + params: PGLint){.dynlib: dllname, + importc: "glGetUniformivARB".} +proc glGetShaderSourceARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, + source: PGLcharARB){.dynlib: dllname, + importc: "glGetShaderSourceARB".} +const + GL_VERTEX_SHADER_ARB* = 0x00008B31 + GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB* = 0x00008B4A + GL_MAX_VARYING_FLOATS_ARB* = 0x00008B4B # GL_MAX_VERTEX_ATTRIBS_ARB { already defined } + # GL_MAX_TEXTURE_IMAGE_UNITS_ARB { already defined } + GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB* = 0x00008B4C + GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB* = 0x00008B4D # + # + # GL_MAX_TEXTURE_COORDS_ARB { already defined } + # + # + # GL_VERTEX_PROGRAM_POINT_SIZE_ARB { already defined } + # + # + # GL_VERTEX_PROGRAM_TWO_SIDE_ARB { already defined } + # GL_OBJECT_TYPE_ARB { already defined } + # GL_OBJECT_SUBTYPE_ARB { already defined } + GL_OBJECT_ACTIVE_ATTRIBUTES_ARB* = 0x00008B89 + GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB* = 0x00008B8A # GL_SHADER_OBJECT_ARB { already defined } + # + # + # GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB { already defined } + # + # + # GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB { already defined } + # + # + # GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB { already defined } + # + # + # GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB { already defined } + # + # + # GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB { already defined } + # + # + # GL_CURRENT_VERTEX_ATTRIB_ARB { already defined } + # + # + # GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB { already defined } + # GL_FLOAT { already defined } + # GL_FLOAT_VEC2_ARB { already defined } + # GL_FLOAT_VEC3_ARB { already defined } + # GL_FLOAT_VEC4_ARB { already defined } + # GL_FLOAT_MAT2_ARB { already defined } + # GL_FLOAT_MAT3_ARB { already defined } + # GL_FLOAT_MAT4_ARB { already defined } + # glVertexAttrib1fARB { already defined } + # glVertexAttrib1sARB { already defined } + # glVertexAttrib1dARB { already defined } + # glVertexAttrib2fARB { already defined } + # glVertexAttrib2sARB { already defined } + # glVertexAttrib2dARB { already defined } + # glVertexAttrib3fARB { already defined } + # glVertexAttrib3sARB { already defined } + # glVertexAttrib3dARB { already defined } + # glVertexAttrib4fARB { already defined } + # glVertexAttrib4sARB { already defined } + # glVertexAttrib4dARB { already defined } + # glVertexAttrib4NubARB { already defined } + # glVertexAttrib1fvARB { already defined } + # glVertexAttrib1svARB { already defined } + # glVertexAttrib1dvARB { already defined } + # glVertexAttrib2fvARB { already defined } + # glVertexAttrib2svARB { already defined } + # glVertexAttrib2dvARB { already defined } + # glVertexAttrib3fvARB { already defined } + # glVertexAttrib3svARB { already defined } + # glVertexAttrib3dvARB { already defined } + # glVertexAttrib4fvARB { already defined } + # glVertexAttrib4svARB { already defined } + # glVertexAttrib4dvARB { already defined } + # glVertexAttrib4ivARB { already defined } + # glVertexAttrib4bvARB { already defined } + # glVertexAttrib4ubvARB { already defined } + # glVertexAttrib4usvARB { already defined } + # glVertexAttrib4uivARB { already defined } + # glVertexAttrib4NbvARB { already defined } + # glVertexAttrib4NsvARB { already defined } + # glVertexAttrib4NivARB { already defined } + # glVertexAttrib4NubvARB { already defined } + # glVertexAttrib4NusvARB { already defined } + # glVertexAttrib4NuivARB { already defined } + # + # + # glVertexAttribPointerARB { already defined } + # + # + # glEnableVertexAttribArrayARB { already defined } + # + # + # glDisableVertexAttribArrayARB { already defined } + +proc glBindAttribLocationARB*(programObj: GLhandleARB, index: TGLuint, + name: PGLcharARB){.dynlib: dllname, + importc: "glBindAttribLocationARB".} +proc glGetActiveAttribARB*(programObj: GLhandleARB, index: TGLuint, + maxLength: TGLsizei, len: PGLsizei, size: PGLint, + thetype: PGLenum, name: PGLcharARB){.dynlib: dllname, + importc: "glGetActiveAttribARB".} +proc glGetAttribLocationARB*(programObj: GLhandleARB, name: PGLcharARB): TGLint{. + dynlib: dllname, importc: "glGetAttribLocationARB".} + # glGetVertexAttribdvARB { already defined } + # glGetVertexAttribfvARB { already defined } + # glGetVertexAttribivARB { already defined } + # glGetVertexAttribPointervARB { already defined } + #***** GL_ARB_fragment_shader *****// +const + GL_FRAGMENT_SHADER_ARB* = 0x00008B30 + GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB* = 0x00008B49 # GL_MAX_TEXTURE_COORDS_ARB { already defined } + # + # + # GL_MAX_TEXTURE_IMAGE_UNITS_ARB { already defined } + # GL_OBJECT_TYPE_ARB { already defined } + # GL_OBJECT_SUBTYPE_ARB { already defined } + # GL_SHADER_OBJECT_ARB { already defined } + #***** GL_ARB_shading_language_100 *****// + #***** GL_ARB_texture_non_power_of_two *****// + #***** GL_ARB_point_sprite *****// + +const + GL_POINT_SPRITE_ARB* = 0x00008861 + GL_COORD_REPLACE_ARB* = 0x00008862 + #***** GL_EXT_depth_bounds_test *****// + +const + constGL_DEPTH_BOUNDS_TEST_EXT* = 0x00008890 + constGL_DEPTH_BOUNDS_EXT* = 0x00008891 + +proc glDepthBoundsEXT*(zmin: TGLclampd, zmax: TGLclampd){.dynlib: dllname, + importc: "glDepthBoundsEXT".} + #***** GL_EXT_texture_mirror_clamp *****// +const + GL_MIRROR_CLAMP_EXT* = 0x00008742 + GL_MIRROR_CLAMP_TO_EDGE_EXT* = 0x00008743 + GL_MIRROR_CLAMP_TO_BORDER_EXT* = 0x00008912 + #***** GL_EXT_blend_equation_separate *****// + +const + GL_BLEND_EQUATION_RGB_EXT* = 0x00008009 + GL_BLEND_EQUATION_ALPHA_EXT* = 0x0000883D + +proc glBlendEquationSeparateEXT*(modeRGB: TGLenum, modeAlpha: TGLenum){. + dynlib: dllname, importc: "glBlendEquationSeparateEXT".} + #***** GL_MESA_pack_invert *****// +const + GL_PACK_INVERT_MESA* = 0x00008758 + #***** GL_MESA_ycbcr_texture *****// + +const + GL_YCBCR_MESA* = 0x00008757 + GL_UNSIGNED_SHORT_8_8_MESA* = 0x000085BA + GL_UNSIGNED_SHORT_8_8_REV_MESA* = 0x000085BB + #***** GL_ARB_fragment_program_shadow *****// + #***** GL_NV_fragment_program_option *****// + #***** GL_EXT_pixel_buffer_object *****// + +const + GL_PIXEL_PACK_BUFFER_EXT* = 0x000088EB + GL_PIXEL_UNPACK_BUFFER_EXT* = 0x000088EC + GL_PIXEL_PACK_BUFFER_BINDING_EXT* = 0x000088ED + GL_PIXEL_UNPACK_BUFFER_BINDING_EXT* = 0x000088EF + #***** GL_NV_fragment_program2 *****// + +const + GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV* = 0x000088F4 + GL_MAX_PROGRAM_CALL_DEPTH_NV* = 0x000088F5 + GL_MAX_PROGRAM_IF_DEPTH_NV* = 0x000088F6 + GL_MAX_PROGRAM_LOOP_DEPTH_NV* = 0x000088F7 + GL_MAX_PROGRAM_LOOP_COUNT_NV* = 0x000088F8 + #***** GL_NV_vertex_program2_option *****// + # GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV { already defined } + # GL_MAX_PROGRAM_CALL_DEPTH_NV { already defined } + #***** GL_NV_vertex_program3 *****// + # GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB { already defined } + #***** GL_ARB_draw_buffers *****// + +const + GL_MAX_DRAW_BUFFERS_ARB* = 0x00008824 + GL_DRAW_BUFFER0_ARB* = 0x00008825 + GL_DRAW_BUFFER1_ARB* = 0x00008826 + GL_DRAW_BUFFER2_ARB* = 0x00008827 + GL_DRAW_BUFFER3_ARB* = 0x00008828 + GL_DRAW_BUFFER4_ARB* = 0x00008829 + GL_DRAW_BUFFER5_ARB* = 0x0000882A + GL_DRAW_BUFFER6_ARB* = 0x0000882B + GL_DRAW_BUFFER7_ARB* = 0x0000882C + GL_DRAW_BUFFER8_ARB* = 0x0000882D + GL_DRAW_BUFFER9_ARB* = 0x0000882E + GL_DRAW_BUFFER10_ARB* = 0x0000882F + GL_DRAW_BUFFER11_ARB* = 0x00008830 + GL_DRAW_BUFFER12_ARB* = 0x00008831 + GL_DRAW_BUFFER13_ARB* = 0x00008832 + GL_DRAW_BUFFER14_ARB* = 0x00008833 + GL_DRAW_BUFFER15_ARB* = 0x00008834 + +proc glDrawBuffersARB*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, + importc: "glDrawBuffersARB".} + #***** GL_ARB_texture_rectangle *****// +const + GL_TEXTURE_RECTANGLE_ARB* = 0x000084F5 + GL_TEXTURE_BINDING_RECTANGLE_ARB* = 0x000084F6 + GL_PROXY_TEXTURE_RECTANGLE_ARB* = 0x000084F7 + GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB* = 0x000084F8 + #***** GL_ARB_color_buffer_float *****// + +const + GL_RGBA_FLOAT_MODE_ARB* = 0x00008820 + GL_CLAMP_VERTEX_COLOR_ARB* = 0x0000891A + GL_CLAMP_FRAGMENT_COLOR_ARB* = 0x0000891B + GL_CLAMP_READ_COLOR_ARB* = 0x0000891C + GL_FIXED_ONLY_ARB* = 0x0000891D + WGL_TYPE_RGBA_FLOAT_ARB* = 0x000021A0 + +proc glClampColorARB*(target: TGLenum, clamp: TGLenum){.dynlib: dllname, + importc: "glClampColorARB".} + #***** GL_ARB_half_float_pixel *****// +const + GL_HALF_FLOAT_ARB* = 0x0000140B + #***** GL_ARB_texture_float *****// + +const + GL_TEXTURE_RED_TYPE_ARB* = 0x00008C10 + GL_TEXTURE_GREEN_TYPE_ARB* = 0x00008C11 + GL_TEXTURE_BLUE_TYPE_ARB* = 0x00008C12 + GL_TEXTURE_ALPHA_TYPE_ARB* = 0x00008C13 + GL_TEXTURE_LUMINANCE_TYPE_ARB* = 0x00008C14 + GL_TEXTURE_INTENSITY_TYPE_ARB* = 0x00008C15 + GL_TEXTURE_DEPTH_TYPE_ARB* = 0x00008C16 + GL_UNSIGNED_NORMALIZED_ARB* = 0x00008C17 + GL_RGBA32F_ARB* = 0x00008814 + GL_RGB32F_ARB* = 0x00008815 + GL_ALPHA32F_ARB* = 0x00008816 + GL_INTENSITY32F_ARB* = 0x00008817 + GL_LUMINANCE32F_ARB* = 0x00008818 + GL_LUMINANCE_ALPHA32F_ARB* = 0x00008819 + GL_RGBA16F_ARB* = 0x0000881A + GL_RGB16F_ARB* = 0x0000881B + GL_ALPHA16F_ARB* = 0x0000881C + GL_INTENSITY16F_ARB* = 0x0000881D + GL_LUMINANCE16F_ARB* = 0x0000881E + GL_LUMINANCE_ALPHA16F_ARB* = 0x0000881F + #***** GL_EXT_texture_compression_dxt1 *****// + # GL_COMPRESSED_RGB_S3TC_DXT1_EXT { already defined } + # GL_COMPRESSED_RGBA_S3TC_DXT1_EXT { already defined } + #***** GL_ARB_pixel_buffer_object *****// + +const + GL_PIXEL_PACK_BUFFER_ARB* = 0x000088EB + GL_PIXEL_UNPACK_BUFFER_ARB* = 0x000088EC + GL_PIXEL_PACK_BUFFER_BINDING_ARB* = 0x000088ED + GL_PIXEL_UNPACK_BUFFER_BINDING_ARB* = 0x000088EF + #***** GL_EXT_framebuffer_object *****// + +const + GL_FRAMEBUFFER_EXT* = 0x00008D40 + GL_RENDERBUFFER_EXT* = 0x00008D41 + GL_STENCIL_INDEX_EXT* = 0x00008D45 + GL_STENCIL_INDEX1_EXT* = 0x00008D46 + GL_STENCIL_INDEX4_EXT* = 0x00008D47 + GL_STENCIL_INDEX8_EXT* = 0x00008D48 + GL_STENCIL_INDEX16_EXT* = 0x00008D49 + GL_RENDERBUFFER_WIDTH_EXT* = 0x00008D42 + GL_RENDERBUFFER_HEIGHT_EXT* = 0x00008D43 + GL_RENDERBUFFER_INTERNAL_FORMAT_EXT* = 0x00008D44 + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT* = 0x00008CD0 + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT* = 0x00008CD1 + GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT* = 0x00008CD2 + GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT* = 0x00008CD3 + GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT* = 0x00008CD4 + GL_COLOR_ATTACHMENT0_EXT* = 0x00008CE0 + GL_COLOR_ATTACHMENT1_EXT* = 0x00008CE1 + GL_COLOR_ATTACHMENT2_EXT* = 0x00008CE2 + GL_COLOR_ATTACHMENT3_EXT* = 0x00008CE3 + GL_COLOR_ATTACHMENT4_EXT* = 0x00008CE4 + GL_COLOR_ATTACHMENT5_EXT* = 0x00008CE5 + GL_COLOR_ATTACHMENT6_EXT* = 0x00008CE6 + GL_COLOR_ATTACHMENT7_EXT* = 0x00008CE7 + GL_COLOR_ATTACHMENT8_EXT* = 0x00008CE8 + GL_COLOR_ATTACHMENT9_EXT* = 0x00008CE9 + GL_COLOR_ATTACHMENT10_EXT* = 0x00008CEA + GL_COLOR_ATTACHMENT11_EXT* = 0x00008CEB + GL_COLOR_ATTACHMENT12_EXT* = 0x00008CEC + GL_COLOR_ATTACHMENT13_EXT* = 0x00008CED + GL_COLOR_ATTACHMENT14_EXT* = 0x00008CEE + GL_COLOR_ATTACHMENT15_EXT* = 0x00008CEF + GL_DEPTH_ATTACHMENT_EXT* = 0x00008D00 + GL_STENCIL_ATTACHMENT_EXT* = 0x00008D20 + GL_FRAMEBUFFER_COMPLETE_EXT* = 0x00008CD5 + GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT* = 0x00008CD6 + GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT* = 0x00008CD7 + GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT* = 0x00008CD8 + GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT* = 0x00008CD9 + GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT* = 0x00008CDA + GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT* = 0x00008CDB + GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT* = 0x00008CDC + GL_FRAMEBUFFER_UNSUPPORTED_EXT* = 0x00008CDD + GL_FRAMEBUFFER_STATUS_ERROR_EXT* = 0x00008CDE + GL_FRAMEBUFFER_BINDING_EXT* = 0x00008CA6 + GL_RENDERBUFFER_BINDING_EXT* = 0x00008CA7 + GL_MAX_COLOR_ATTACHMENTS_EXT* = 0x00008CDF + GL_MAX_RENDERBUFFER_SIZE_EXT* = 0x000084E8 + GL_INVALID_FRAMEBUFFER_OPERATION_EXT* = 0x00000506 + +proc glIsRenderbufferEXT*(renderbuffer: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsRenderbufferEXT".} +proc glBindRenderbufferEXT*(target: TGLenum, renderbuffer: TGLuint){. + dynlib: dllname, importc: "glBindRenderbufferEXT".} +proc glDeleteRenderbuffersEXT*(n: TGLsizei, renderbuffers: PGLuint){. + dynlib: dllname, importc: "glDeleteRenderbuffersEXT".} +proc glGenRenderbuffersEXT*(n: TGLsizei, renderbuffers: PGLuint){. + dynlib: dllname, importc: "glGenRenderbuffersEXT".} +proc glRenderbufferStorageEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei){. + dynlib: dllname, importc: "glRenderbufferStorageEXT".} +proc glGetRenderbufferParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc: "glGetRenderbufferParameterivEXT".} +proc glIsFramebufferEXT*(framebuffer: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsFramebufferEXT".} +proc glBindFramebufferEXT*(target: TGLenum, framebuffer: TGLuint){. + dynlib: dllname, importc: "glBindFramebufferEXT".} +proc glDeleteFramebuffersEXT*(n: TGLsizei, framebuffers: PGLuint){. + dynlib: dllname, importc: "glDeleteFramebuffersEXT".} +proc glGenFramebuffersEXT*(n: TGLsizei, framebuffers: PGLuint){.dynlib: dllname, + importc: "glGenFramebuffersEXT".} +proc glCheckFramebufferStatusEXT*(target: TGLenum): TGLenum{.dynlib: dllname, + importc: "glCheckFramebufferStatusEXT".} +proc glFramebufferTexture1DEXT*(target: TGLenum, attachment: TGLenum, + textarget: TGLenum, texture: TGLuint, + level: TGLint){.dynlib: dllname, + importc: "glFramebufferTexture1DEXT".} +proc glFramebufferTexture2DEXT*(target: TGLenum, attachment: TGLenum, + textarget: TGLenum, texture: TGLuint, + level: TGLint){.dynlib: dllname, + importc: "glFramebufferTexture2DEXT".} +proc glFramebufferTexture3DEXT*(target: TGLenum, attachment: TGLenum, + textarget: TGLenum, texture: TGLuint, + level: TGLint, zoffset: TGLint){. + dynlib: dllname, importc: "glFramebufferTexture3DEXT".} +proc glFramebufferRenderbufferEXT*(target: TGLenum, attachment: TGLenum, + renderbuffertarget: TGLenum, + renderbuffer: TGLuint){.dynlib: dllname, + importc: "glFramebufferRenderbufferEXT".} +proc glGetFramebufferAttachmentParameterivEXT*(target: TGLenum, + attachment: TGLenum, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glGetFramebufferAttachmentParameterivEXT".} +proc glGenerateMipmapEXT*(target: TGLenum){.dynlib: dllname, + importc: "glGenerateMipmapEXT".} + #***** GL_version_1_4 *****// +const + GL_BLEND_DST_RGB* = 0x000080C8 + GL_BLEND_SRC_RGB* = 0x000080C9 + GL_BLEND_DST_ALPHA* = 0x000080CA + GL_BLEND_SRC_ALPHA* = 0x000080CB + GL_POINT_SIZE_MIN* = 0x00008126 + GL_POINT_SIZE_MAX* = 0x00008127 + GL_POINT_FADE_THRESHOLD_SIZE* = 0x00008128 + GL_POINT_DISTANCE_ATTENUATION* = 0x00008129 + GL_GENERATE_MIPMAP* = 0x00008191 + GL_GENERATE_MIPMAP_HINT* = 0x00008192 + GL_DEPTH_COMPONENT16* = 0x000081A5 + GL_DEPTH_COMPONENT24* = 0x000081A6 + GL_DEPTH_COMPONENT32* = 0x000081A7 + GL_MIRRORED_REPEAT* = 0x00008370 + GL_FOG_COORDINATE_SOURCE* = 0x00008450 + GL_FOG_COORDINATE* = 0x00008451 + GL_FRAGMENT_DEPTH* = 0x00008452 + GL_CURRENT_FOG_COORDINATE* = 0x00008453 + GL_FOG_COORDINATE_ARRAY_TYPE* = 0x00008454 + GL_FOG_COORDINATE_ARRAY_STRIDE* = 0x00008455 + GL_FOG_COORDINATE_ARRAY_POINTER* = 0x00008456 + GL_FOG_COORDINATE_ARRAY* = 0x00008457 + GL_COLOR_SUM* = 0x00008458 + GL_CURRENT_SECONDARY_COLOR* = 0x00008459 + GL_SECONDARY_COLOR_ARRAY_SIZE* = 0x0000845A + GL_SECONDARY_COLOR_ARRAY_TYPE* = 0x0000845B + GL_SECONDARY_COLOR_ARRAY_STRIDE* = 0x0000845C + GL_SECONDARY_COLOR_ARRAY_POINTER* = 0x0000845D + GL_SECONDARY_COLOR_ARRAY* = 0x0000845E + GL_MAX_TEXTURE_LOD_BIAS* = 0x000084FD + GL_TEXTURE_FILTER_CONTROL* = 0x00008500 + GL_TEXTURE_LOD_BIAS* = 0x00008501 + GL_INCR_WRAP* = 0x00008507 + GL_DECR_WRAP* = 0x00008508 + GL_TEXTURE_DEPTH_SIZE* = 0x0000884A + GL_DEPTH_TEXTURE_MODE* = 0x0000884B + GL_TEXTURE_COMPARE_MODE* = 0x0000884C + GL_TEXTURE_COMPARE_FUNC* = 0x0000884D + GL_COMPARE_R_TO_TEXTURE* = 0x0000884E + +proc glBlendFuncSeparate*(sfactorRGB: TGLenum, dfactorRGB: TGLenum, + sfactorAlpha: TGLenum, dfactorAlpha: TGLenum){. + dynlib: dllname, importc: "glBlendFuncSeparate".} +proc glFogCoordf*(coord: TGLfloat){.dynlib: dllname, importc: "glFogCoordf".} +proc glFogCoordfv*(coord: PGLfloat){.dynlib: dllname, importc: "glFogCoordfv".} +proc glFogCoordd*(coord: TGLdouble){.dynlib: dllname, importc: "glFogCoordd".} +proc glFogCoorddv*(coord: PGLdouble){.dynlib: dllname, importc: "glFogCoorddv".} +proc glFogCoordPointer*(thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc: "glFogCoordPointer".} +proc glMultiDrawArrays*(mode: TGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei){.dynlib: dllname, + importc: "glMultiDrawArrays".} +proc glMultiDrawElements*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, + indices: PGLvoid, primcount: TGLsizei){. + dynlib: dllname, importc: "glMultiDrawElements".} +proc glPointParameterf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc: "glPointParameterf".} +proc glPointParameterfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc: "glPointParameterfv".} +proc glPointParameteri*(pname: TGLenum, param: TGLint){.dynlib: dllname, + importc: "glPointParameteri".} +proc glPointParameteriv*(pname: TGLenum, params: PGLint){.dynlib: dllname, + importc: "glPointParameteriv".} +proc glSecondaryColor3b*(red: TGLByte, green: TGLByte, blue: TGLByte){. + dynlib: dllname, importc: "glSecondaryColor3b".} +proc glSecondaryColor3bv*(v: PGLbyte){.dynlib: dllname, + importc: "glSecondaryColor3bv".} +proc glSecondaryColor3d*(red: TGLdouble, green: TGLdouble, blue: TGLdouble){. + dynlib: dllname, importc: "glSecondaryColor3d".} +proc glSecondaryColor3dv*(v: PGLdouble){.dynlib: dllname, + importc: "glSecondaryColor3dv".} +proc glSecondaryColor3f*(red: TGLfloat, green: TGLfloat, blue: TGLfloat){. + dynlib: dllname, importc: "glSecondaryColor3f".} +proc glSecondaryColor3fv*(v: PGLfloat){.dynlib: dllname, + importc: "glSecondaryColor3fv".} +proc glSecondaryColor3i*(red: TGLint, green: TGLint, blue: TGLint){. + dynlib: dllname, importc: "glSecondaryColor3i".} +proc glSecondaryColor3iv*(v: PGLint){.dynlib: dllname, + importc: "glSecondaryColor3iv".} +proc glSecondaryColor3s*(red: TGLshort, green: TGLshort, blue: TGLshort){. + dynlib: dllname, importc: "glSecondaryColor3s".} +proc glSecondaryColor3sv*(v: PGLshort){.dynlib: dllname, + importc: "glSecondaryColor3sv".} +proc glSecondaryColor3ub*(red: TGLubyte, green: TGLubyte, blue: TGLubyte){. + dynlib: dllname, importc: "glSecondaryColor3ub".} +proc glSecondaryColor3ubv*(v: PGLubyte){.dynlib: dllname, + importc: "glSecondaryColor3ubv".} +proc glSecondaryColor3ui*(red: TGLuint, green: TGLuint, blue: TGLuint){. + dynlib: dllname, importc: "glSecondaryColor3ui".} +proc glSecondaryColor3uiv*(v: PGLuint){.dynlib: dllname, + importc: "glSecondaryColor3uiv".} +proc glSecondaryColor3us*(red: TGLushort, green: TGLushort, blue: TGLushort){. + dynlib: dllname, importc: "glSecondaryColor3us".} +proc glSecondaryColor3usv*(v: PGLushort){.dynlib: dllname, + importc: "glSecondaryColor3usv".} +proc glSecondaryColorPointer*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, + importc: "glSecondaryColorPointer".} +proc glWindowPos2d*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, + importc: "glWindowPos2d".} +proc glWindowPos2dv*(v: PGLdouble){.dynlib: dllname, importc: "glWindowPos2dv".} +proc glWindowPos2f*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, + importc: "glWindowPos2f".} +proc glWindowPos2fv*(v: PGLfloat){.dynlib: dllname, importc: "glWindowPos2fv".} +proc glWindowPos2i*(x: TGLint, y: TGLint){.dynlib: dllname, + importc: "glWindowPos2i".} +proc glWindowPos2iv*(v: PGLint){.dynlib: dllname, importc: "glWindowPos2iv".} +proc glWindowPos2s*(x: TGLshort, y: TGLshort){.dynlib: dllname, + importc: "glWindowPos2s".} +proc glWindowPos2sv*(v: PGLshort){.dynlib: dllname, importc: "glWindowPos2sv".} +proc glWindowPos3d*(x: TGLdouble, y: TGLdouble, z: TGLdouble){.dynlib: dllname, + importc: "glWindowPos3d".} +proc glWindowPos3dv*(v: PGLdouble){.dynlib: dllname, importc: "glWindowPos3dv".} +proc glWindowPos3f*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc: "glWindowPos3f".} +proc glWindowPos3fv*(v: PGLfloat){.dynlib: dllname, importc: "glWindowPos3fv".} +proc glWindowPos3i*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, + importc: "glWindowPos3i".} +proc glWindowPos3iv*(v: PGLint){.dynlib: dllname, importc: "glWindowPos3iv".} +proc glWindowPos3s*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, + importc: "glWindowPos3s".} +proc glWindowPos3sv*(v: PGLshort){.dynlib: dllname, importc: "glWindowPos3sv".} + #***** GL_version_1_5 *****// +const + GL_BUFFER_SIZE* = 0x00008764 + GL_BUFFER_USAGE* = 0x00008765 + GL_QUERY_COUNTER_BITS* = 0x00008864 + GL_CURRENT_QUERY* = 0x00008865 + GL_QUERY_RESULT* = 0x00008866 + GL_QUERY_RESULT_AVAILABLE* = 0x00008867 + GL_ARRAY_BUFFER* = 0x00008892 + GL_ELEMENT_ARRAY_BUFFER* = 0x00008893 + GL_ARRAY_BUFFER_BINDING* = 0x00008894 + GL_ELEMENT_ARRAY_BUFFER_BINDING* = 0x00008895 + GL_VERTEX_ARRAY_BUFFER_BINDING* = 0x00008896 + GL_NORMAL_ARRAY_BUFFER_BINDING* = 0x00008897 + GL_COLOR_ARRAY_BUFFER_BINDING* = 0x00008898 + GL_INDEX_ARRAY_BUFFER_BINDING* = 0x00008899 + GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING* = 0x0000889A + GL_EDGE_FLAG_ARRAY_BUFFER_BINDING* = 0x0000889B + GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING* = 0x0000889C + GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING* = 0x0000889D + GL_WEIGHT_ARRAY_BUFFER_BINDING* = 0x0000889E + GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING* = 0x0000889F + GL_READ_ONLY* = 0x000088B8 + GL_WRITE_ONLY* = 0x000088B9 + GL_READ_WRITE* = 0x000088BA + GL_BUFFER_ACCESS* = 0x000088BB + GL_BUFFER_MAPPED* = 0x000088BC + GL_BUFFER_MAP_POINTER* = 0x000088BD + GL_STREAM_DRAW* = 0x000088E0 + GL_STREAM_READ* = 0x000088E1 + GL_STREAM_COPY* = 0x000088E2 + GL_STATIC_DRAW* = 0x000088E4 + GL_STATIC_READ* = 0x000088E5 + GL_STATIC_COPY* = 0x000088E6 + GL_DYNAMIC_DRAW* = 0x000088E8 + GL_DYNAMIC_READ* = 0x000088E9 + GL_DYNAMIC_COPY* = 0x000088EA + GL_SAMPLES_PASSED* = 0x00008914 + GL_FOG_COORD_SRC* = 0x00008450 + GL_FOG_COORD* = 0x00008451 + GL_CURRENT_FOG_COORD* = 0x00008453 + GL_FOG_COORD_ARRAY_TYPE* = 0x00008454 + GL_FOG_COORD_ARRAY_STRIDE* = 0x00008455 + GL_FOG_COORD_ARRAY_POINTER* = 0x00008456 + GL_FOG_COORD_ARRAY* = 0x00008457 + GL_FOG_COORD_ARRAY_BUFFER_BINDING* = 0x0000889D + GL_SRC0_RGB* = 0x00008580 + GL_SRC1_RGB* = 0x00008581 + GL_SRC2_RGB* = 0x00008582 + GL_SRC0_ALPHA* = 0x00008588 + GL_SRC1_ALPHA* = 0x00008589 + GL_SRC2_ALPHA* = 0x0000858A + +proc glGenQueries*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc: "glGenQueries".} +proc glDeleteQueries*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc: "glDeleteQueries".} +proc glIsQuery*(id: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsQuery".} +proc glBeginQuery*(target: TGLenum, id: TGLuint){.dynlib: dllname, + importc: "glBeginQuery".} +proc glEndQuery*(target: TGLenum){.dynlib: dllname, importc: "glEndQuery".} +proc glGetQueryiv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetQueryiv".} +proc glGetQueryObjectiv*(id: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetQueryObjectiv".} +proc glGetQueryObjectuiv*(id: TGLuint, pname: TGLenum, params: PGLuint){. + dynlib: dllname, importc: "glGetQueryObjectuiv".} +proc glBindBuffer*(target: TGLenum, buffer: TGLuint){.dynlib: dllname, + importc: "glBindBuffer".} +proc glDeleteBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, + importc: "glDeleteBuffers".} +proc glGenBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, + importc: "glGenBuffers".} +proc glIsBuffer*(buffer: TGLuint): TGLboolean{.dynlib: dllname, + importc: "glIsBuffer".} +proc glBufferData*(target: TGLenum, size: GLsizeiptr, data: PGLvoid, + usage: TGLenum){.dynlib: dllname, importc: "glBufferData".} +proc glBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, + data: PGLvoid){.dynlib: dllname, + importc: "glBufferSubData".} +proc glGetBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, + data: PGLvoid){.dynlib: dllname, + importc: "glGetBufferSubData".} +proc glMapBuffer*(target: TGLenum, access: TGLenum): PGLvoid{.dynlib: dllname, + importc: "glMapBuffer".} +proc glUnmapBuffer*(target: TGLenum): TGLboolean{.dynlib: dllname, + importc: "glUnmapBuffer".} +proc glGetBufferParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc: "glGetBufferParameteriv".} +proc glGetBufferPointerv*(target: TGLenum, pname: TGLenum, params: PGLvoid){. + dynlib: dllname, importc: "glGetBufferPointerv".} + #***** GL_version_2_0 *****// +const + GL_BLEND_EQUATION_RGB* = 0x00008009 + GL_VERTEX_ATTRIB_ARRAY_ENABLED* = 0x00008622 + GL_VERTEX_ATTRIB_ARRAY_SIZE* = 0x00008623 + GL_VERTEX_ATTRIB_ARRAY_STRIDE* = 0x00008624 + GL_VERTEX_ATTRIB_ARRAY_TYPE* = 0x00008625 + GL_CURRENT_VERTEX_ATTRIB* = 0x00008626 + GL_VERTEX_PROGRAM_POINT_SIZE* = 0x00008642 + GL_VERTEX_PROGRAM_TWO_SIDE* = 0x00008643 + GL_VERTEX_ATTRIB_ARRAY_POINTER* = 0x00008645 + GL_STENCIL_BACK_FUNC* = 0x00008800 + GL_STENCIL_BACK_FAIL* = 0x00008801 + GL_STENCIL_BACK_PASS_DEPTH_FAIL* = 0x00008802 + GL_STENCIL_BACK_PASS_DEPTH_PASS* = 0x00008803 + GL_MAX_DRAW_BUFFERS* = 0x00008824 + GL_DRAW_BUFFER0* = 0x00008825 + GL_DRAW_BUFFER1* = 0x00008826 + GL_DRAW_BUFFER2* = 0x00008827 + GL_DRAW_BUFFER3* = 0x00008828 + GL_DRAW_BUFFER4* = 0x00008829 + GL_DRAW_BUFFER5* = 0x0000882A + GL_DRAW_BUFFER6* = 0x0000882B + GL_DRAW_BUFFER7* = 0x0000882C + GL_DRAW_BUFFER8* = 0x0000882D + GL_DRAW_BUFFER9* = 0x0000882E + GL_DRAW_BUFFER10* = 0x0000882F + GL_DRAW_BUFFER11* = 0x00008830 + GL_DRAW_BUFFER12* = 0x00008831 + GL_DRAW_BUFFER13* = 0x00008832 + GL_DRAW_BUFFER14* = 0x00008833 + GL_DRAW_BUFFER15* = 0x00008834 + GL_BLEND_EQUATION_ALPHA* = 0x0000883D + GL_POINT_SPRITE* = 0x00008861 + GL_COORD_REPLACE* = 0x00008862 + GL_MAX_VERTEX_ATTRIBS* = 0x00008869 + GL_VERTEX_ATTRIB_ARRAY_NORMALIZED* = 0x0000886A + GL_MAX_TEXTURE_COORDS* = 0x00008871 + GL_MAX_TEXTURE_IMAGE_UNITS* = 0x00008872 + GL_FRAGMENT_SHADER* = 0x00008B30 + GL_VERTEX_SHADER* = 0x00008B31 + GL_MAX_FRAGMENT_UNIFORM_COMPONENTS* = 0x00008B49 + GL_MAX_VERTEX_UNIFORM_COMPONENTS* = 0x00008B4A + GL_MAX_VARYING_FLOATS* = 0x00008B4B + GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS* = 0x00008B4C + GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS* = 0x00008B4D + GL_SHADER_TYPE* = 0x00008B4F + GL_FLOAT_VEC2* = 0x00008B50 + GL_FLOAT_VEC3* = 0x00008B51 + GL_FLOAT_VEC4* = 0x00008B52 + GL_INT_VEC2* = 0x00008B53 + GL_INT_VEC3* = 0x00008B54 + GL_INT_VEC4* = 0x00008B55 + GL_BOOL* = 0x00008B56 + GL_BOOL_VEC2* = 0x00008B57 + GL_BOOL_VEC3* = 0x00008B58 + GL_BOOL_VEC4* = 0x00008B59 + GL_FLOAT_MAT2* = 0x00008B5A + GL_FLOAT_MAT3* = 0x00008B5B + GL_FLOAT_MAT4* = 0x00008B5C + GL_SAMPLER_1D* = 0x00008B5D + GL_SAMPLER_2D* = 0x00008B5E + GL_SAMPLER_3D* = 0x00008B5F + GL_SAMPLER_CUBE* = 0x00008B60 + GL_SAMPLER_1D_SHADOW* = 0x00008B61 + GL_SAMPLER_2D_SHADOW* = 0x00008B62 + GL_DELETE_STATUS* = 0x00008B80 + GL_COMPILE_STATUS* = 0x00008B81 + GL_LINK_STATUS* = 0x00008B82 + GL_VALIDATE_STATUS* = 0x00008B83 + GL_INFO_LOG_LENGTH* = 0x00008B84 + GL_ATTACHED_SHADERS* = 0x00008B85 + GL_ACTIVE_UNIFORMS* = 0x00008B86 + GL_ACTIVE_UNIFORM_MAX_LENGTH* = 0x00008B87 + GL_SHADER_SOURCE_LENGTH* = 0x00008B88 + GL_ACTIVE_ATTRIBUTES* = 0x00008B89 + GL_ACTIVE_ATTRIBUTE_MAX_LENGTH* = 0x00008B8A + GL_FRAGMENT_SHADER_DERIVATIVE_HINT* = 0x00008B8B + GL_SHADING_LANGUAGE_VERSION* = 0x00008B8C + GL_CURRENT_PROGRAM* = 0x00008B8D + GL_POINT_SPRITE_COORD_ORIGIN* = 0x00008CA0 + GL_LOWER_LEFT* = 0x00008CA1 + GL_UPPER_LEFT* = 0x00008CA2 + GL_STENCIL_BACK_REF* = 0x00008CA3 + GL_STENCIL_BACK_VALUE_MASK* = 0x00008CA4 + GL_STENCIL_BACK_WRITEMASK* = 0x00008CA5 + +{.pop.} diff --git a/tests/manyloc/keineschweine/lib/glu.nim b/tests/manyloc/keineschweine/lib/glu.nim new file mode 100644 index 000000000..867d0e47f --- /dev/null +++ b/tests/manyloc/keineschweine/lib/glu.nim @@ -0,0 +1,335 @@ +# +# +# Adaption of the delphi3d.net OpenGL units to FreePascal +# Sebastian Guenther (sg@freepascal.org) in 2002 +# These units are free to use +#****************************************************************************** +# Converted to Delphi by Tom Nuydens (tom@delphi3d.net) +# For the latest updates, visit Delphi3D: http://www.delphi3d.net +#****************************************************************************** + +import + GL + +when defined(windows): + {.push, callconv: stdcall.} +else: + {.push, callconv: cdecl.} + +when defined(windows): + const + dllname = "glu32.dll" +elif defined(macosx): + const + dllname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib" +else: + const + dllname = "libGLU.so.1" +type + TViewPortArray* = array[0..3, TGLint] + T16dArray* = array[0..15, TGLdouble] + TCallBack* = proc () + T3dArray* = array[0..2, TGLdouble] + T4pArray* = array[0..3, Pointer] + T4fArray* = array[0..3, TGLfloat] + PPointer* = ptr Pointer + +type + GLUnurbs*{.final.} = object + PGLUnurbs* = ptr GLUnurbs + GLUquadric*{.final.} = object + PGLUquadric* = ptr GLUquadric + GLUtesselator*{.final.} = object + PGLUtesselator* = ptr GLUtesselator # backwards compatibility: + GLUnurbsObj* = GLUnurbs + PGLUnurbsObj* = PGLUnurbs + GLUquadricObj* = GLUquadric + PGLUquadricObj* = PGLUquadric + GLUtesselatorObj* = GLUtesselator + PGLUtesselatorObj* = PGLUtesselator + GLUtriangulatorObj* = GLUtesselator + PGLUtriangulatorObj* = PGLUtesselator + TGLUnurbs* = GLUnurbs + TGLUquadric* = GLUquadric + TGLUtesselator* = GLUtesselator + TGLUnurbsObj* = GLUnurbsObj + TGLUquadricObj* = GLUquadricObj + TGLUtesselatorObj* = GLUtesselatorObj + TGLUtriangulatorObj* = GLUtriangulatorObj + +proc gluErrorString*(errCode: TGLenum): cstring{.dynlib: dllname, + importc: "gluErrorString".} +proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname, + importc: "gluErrorUnicodeStringEXT".} +proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname, + importc: "gluGetString".} +proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname, + importc: "gluOrtho2D".} +proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname, + importc: "gluPerspective".} +proc gluPickMatrix*(x, y, width, height: TGLdouble, viewport: var TViewPortArray){. + dynlib: dllname, importc: "gluPickMatrix".} +proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: TGLdouble){. + dynlib: dllname, importc: "gluLookAt".} +proc gluProject*(objx, objy, objz: TGLdouble, + modelMatrix, projMatrix: var T16dArray, + viewport: var TViewPortArray, winx, winy, winz: PGLdouble): int{. + dynlib: dllname, importc: "gluProject".} +proc gluUnProject*(winx, winy, winz: TGLdouble, + modelMatrix, projMatrix: var T16dArray, + viewport: var TViewPortArray, objx, objy, objz: PGLdouble): int{. + dynlib: dllname, importc: "gluUnProject".} +proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum, + datain: Pointer, widthout, heightout: TGLint, + typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname, + importc: "gluScaleImage".} +proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint, + format, atype: TGLenum, data: Pointer): int{. + dynlib: dllname, importc: "gluBuild1DMipmaps".} +proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint, + format, atype: TGLenum, data: Pointer): int{. + dynlib: dllname, importc: "gluBuild2DMipmaps".} +proc gluNewQuadric*(): PGLUquadric{.dynlib: dllname, importc: "gluNewQuadric".} +proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname, + importc: "gluDeleteQuadric".} +proc gluQuadricNormals*(quadObject: PGLUquadric, normals: TGLenum){. + dynlib: dllname, importc: "gluQuadricNormals".} +proc gluQuadricTexture*(quadObject: PGLUquadric, textureCoords: TGLboolean){. + dynlib: dllname, importc: "gluQuadricTexture".} +proc gluQuadricOrientation*(quadObject: PGLUquadric, orientation: TGLenum){. + dynlib: dllname, importc: "gluQuadricOrientation".} +proc gluQuadricDrawStyle*(quadObject: PGLUquadric, drawStyle: TGLenum){. + dynlib: dllname, importc: "gluQuadricDrawStyle".} +proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble, + slices, stacks: TGLint){.dynlib: dllname, + importc: "gluCylinder".} +proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, + slices, loops: TGLint){.dynlib: dllname, importc: "gluDisk".} +proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, + slices, loops: TGLint, startAngle, sweepAngle: TGLdouble){. + dynlib: dllname, importc: "gluPartialDisk".} +proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){. + dynlib: dllname, importc: "gluSphere".} +proc gluQuadricCallback*(qobj: PGLUquadric, which: TGLenum, fn: TCallBack){. + dynlib: dllname, importc: "gluQuadricCallback".} +proc gluNewTess*(): PGLUtesselator{.dynlib: dllname, importc: "gluNewTess".} +proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname, + importc: "gluDeleteTess".} +proc gluTessBeginPolygon*(tess: PGLUtesselator, polygon_data: Pointer){. + dynlib: dllname, importc: "gluTessBeginPolygon".} +proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname, + importc: "gluTessBeginContour".} +proc gluTessVertex*(tess: PGLUtesselator, coords: var T3dArray, data: Pointer){. + dynlib: dllname, importc: "gluTessVertex".} +proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname, + importc: "gluTessEndContour".} +proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, + importc: "gluTessEndPolygon".} +proc gluTessProperty*(tess: PGLUtesselator, which: TGLenum, value: TGLdouble){. + dynlib: dllname, importc: "gluTessProperty".} +proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname, + importc: "gluTessNormal".} +proc gluTessCallback*(tess: PGLUtesselator, which: TGLenum, fn: TCallBack){. + dynlib: dllname, importc: "gluTessCallback".} +proc gluGetTessProperty*(tess: PGLUtesselator, which: TGLenum, value: PGLdouble){. + dynlib: dllname, importc: "gluGetTessProperty".} +proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname, + importc: "gluNewNurbsRenderer".} +proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname, + importc: "gluDeleteNurbsRenderer".} +proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname, + importc: "gluBeginSurface".} +proc gluBeginCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginCurve".} +proc gluEndCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndCurve".} +proc gluEndSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndSurface".} +proc gluBeginTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginTrim".} +proc gluEndTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndTrim".} +proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat, + stride: TGLint, atype: TGLenum){.dynlib: dllname, + importc: "gluPwlCurve".} +proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat, + stride: TGLint, ctlarray: PGLfloat, order: TGLint, + atype: TGLenum){.dynlib: dllname, importc: "gluNurbsCurve".} +proc gluNurbsSurface*(nobj: PGLUnurbs, sknot_count: TGLint, sknot: PGLfloat, + tknot_count: TGLint, tknot: PGLfloat, + s_stride, t_stride: TGLint, ctlarray: PGLfloat, + sorder, torder: TGLint, atype: TGLenum){.dynlib: dllname, + importc: "gluNurbsSurface".} +proc gluLoadSamplingMatrices*(nobj: PGLUnurbs, + modelMatrix, projMatrix: var T16dArray, + viewport: var TViewPortArray){.dynlib: dllname, + importc: "gluLoadSamplingMatrices".} +proc gluNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: TGLfloat){. + dynlib: dllname, importc: "gluNurbsProperty".} +proc gluGetNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: PGLfloat){. + dynlib: dllname, importc: "gluGetNurbsProperty".} +proc gluNurbsCallback*(nobj: PGLUnurbs, which: TGLenum, fn: TCallBack){. + dynlib: dllname, importc: "gluNurbsCallback".} + #*** Callback function prototypes *** +type # gluQuadricCallback + GLUquadricErrorProc* = proc (p: TGLenum) # gluTessCallback + GLUtessBeginProc* = proc (p: TGLenum) + GLUtessEdgeFlagProc* = proc (p: TGLboolean) + GLUtessVertexProc* = proc (p: Pointer) + GLUtessEndProc* = proc () + GLUtessErrorProc* = proc (p: TGLenum) + GLUtessCombineProc* = proc (p1: var T3dArray, p2: T4pArray, p3: T4fArray, + p4: PPointer) + GLUtessBeginDataProc* = proc (p1: TGLenum, p2: Pointer) + GLUtessEdgeFlagDataProc* = proc (p1: TGLboolean, p2: Pointer) + GLUtessVertexDataProc* = proc (p1, p2: Pointer) + GLUtessEndDataProc* = proc (p: Pointer) + GLUtessErrorDataProc* = proc (p1: TGLenum, p2: Pointer) + GLUtessCombineDataProc* = proc (p1: var T3dArray, p2: var T4pArray, + p3: var T4fArray, p4: PPointer, p5: Pointer) # + # + # gluNurbsCallback + GLUnurbsErrorProc* = proc (p: TGLenum) #*** Generic constants ****/ + +const # Version + GLU_VERSION_1_1* = 1 + GLU_VERSION_1_2* = 1 # Errors: (return value 0 = no error) + GLU_INVALID_ENUM* = 100900 + GLU_INVALID_VALUE* = 100901 + GLU_OUT_OF_MEMORY* = 100902 + GLU_INCOMPATIBLE_GL_VERSION* = 100903 # StringName + GLU_VERSION* = 100800 + GLU_EXTENSIONS* = 100801 # Boolean + GLU_TRUE* = GL_TRUE + GLU_FALSE* = GL_FALSE #*** Quadric constants ****/ + # QuadricNormal + GLU_SMOOTH* = 100000 + GLU_FLAT* = 100001 + GLU_NONE* = 100002 # QuadricDrawStyle + GLU_POINT* = 100010 + GLU_LINE* = 100011 + GLU_FILL* = 100012 + GLU_SILHOUETTE* = 100013 # QuadricOrientation + GLU_OUTSIDE* = 100020 + GLU_INSIDE* = 100021 # Callback types: + # GLU_ERROR = 100103; + #*** Tesselation constants ****/ + GLU_TESS_MAX_COORD* = 1.00000e+150 # TessProperty + GLU_TESS_WINDING_RULE* = 100140 + GLU_TESS_BOUNDARY_ONLY* = 100141 + GLU_TESS_TOLERANCE* = 100142 # TessWinding + GLU_TESS_WINDING_ODD* = 100130 + GLU_TESS_WINDING_NONZERO* = 100131 + GLU_TESS_WINDING_POSITIVE* = 100132 + GLU_TESS_WINDING_NEGATIVE* = 100133 + GLU_TESS_WINDING_ABS_GEQ_TWO* = 100134 # TessCallback + GLU_TESS_BEGIN* = 100100 # void (CALLBACK*)(TGLenum type) + constGLU_TESS_VERTEX* = 100101 # void (CALLBACK*)(void *data) + GLU_TESS_END* = 100102 # void (CALLBACK*)(void) + GLU_TESS_ERROR* = 100103 # void (CALLBACK*)(TGLenum errno) + GLU_TESS_EDGE_FLAG* = 100104 # void (CALLBACK*)(TGLboolean boundaryEdge) + GLU_TESS_COMBINE* = 100105 # void (CALLBACK*)(TGLdouble coords[3], + # void *data[4], + # TGLfloat weight[4], + # void **dataOut) + GLU_TESS_BEGIN_DATA* = 100106 # void (CALLBACK*)(TGLenum type, + # void *polygon_data) + GLU_TESS_VERTEX_DATA* = 100107 # void (CALLBACK*)(void *data, + # void *polygon_data) + GLU_TESS_END_DATA* = 100108 # void (CALLBACK*)(void *polygon_data) + GLU_TESS_ERROR_DATA* = 100109 # void (CALLBACK*)(TGLenum errno, + # void *polygon_data) + GLU_TESS_EDGE_FLAG_DATA* = 100110 # void (CALLBACK*)(TGLboolean boundaryEdge, + # void *polygon_data) + GLU_TESS_COMBINE_DATA* = 100111 # void (CALLBACK*)(TGLdouble coords[3], + # void *data[4], + # TGLfloat weight[4], + # void **dataOut, + # void *polygon_data) + # TessError + GLU_TESS_ERROR1* = 100151 + GLU_TESS_ERROR2* = 100152 + GLU_TESS_ERROR3* = 100153 + GLU_TESS_ERROR4* = 100154 + GLU_TESS_ERROR5* = 100155 + GLU_TESS_ERROR6* = 100156 + GLU_TESS_ERROR7* = 100157 + GLU_TESS_ERROR8* = 100158 + GLU_TESS_MISSING_BEGIN_POLYGON* = GLU_TESS_ERROR1 + GLU_TESS_MISSING_BEGIN_CONTOUR* = GLU_TESS_ERROR2 + GLU_TESS_MISSING_END_POLYGON* = GLU_TESS_ERROR3 + GLU_TESS_MISSING_END_CONTOUR* = GLU_TESS_ERROR4 + GLU_TESS_COORD_TOO_LARGE* = GLU_TESS_ERROR5 + GLU_TESS_NEED_COMBINE_CALLBACK* = GLU_TESS_ERROR6 #*** NURBS constants ****/ + # NurbsProperty + GLU_AUTO_LOAD_MATRIX* = 100200 + GLU_CULLING* = 100201 + GLU_SAMPLING_TOLERANCE* = 100203 + GLU_DISPLAY_MODE* = 100204 + GLU_PARAMETRIC_TOLERANCE* = 100202 + GLU_SAMPLING_METHOD* = 100205 + GLU_U_STEP* = 100206 + GLU_V_STEP* = 100207 # NurbsSampling + GLU_PATH_LENGTH* = 100215 + GLU_PARAMETRIC_ERROR* = 100216 + GLU_DOMAIN_DISTANCE* = 100217 # NurbsTrim + GLU_MAP1_TRIM_2* = 100210 + GLU_MAP1_TRIM_3* = 100211 # NurbsDisplay + # GLU_FILL = 100012; + GLU_OUTLINE_POLYGON* = 100240 + GLU_OUTLINE_PATCH* = 100241 # NurbsCallback + # GLU_ERROR = 100103; + # NurbsErrors + GLU_NURBS_ERROR1* = 100251 + GLU_NURBS_ERROR2* = 100252 + GLU_NURBS_ERROR3* = 100253 + GLU_NURBS_ERROR4* = 100254 + GLU_NURBS_ERROR5* = 100255 + GLU_NURBS_ERROR6* = 100256 + GLU_NURBS_ERROR7* = 100257 + GLU_NURBS_ERROR8* = 100258 + GLU_NURBS_ERROR9* = 100259 + GLU_NURBS_ERROR10* = 100260 + GLU_NURBS_ERROR11* = 100261 + GLU_NURBS_ERROR12* = 100262 + GLU_NURBS_ERROR13* = 100263 + GLU_NURBS_ERROR14* = 100264 + GLU_NURBS_ERROR15* = 100265 + GLU_NURBS_ERROR16* = 100266 + GLU_NURBS_ERROR17* = 100267 + GLU_NURBS_ERROR18* = 100268 + GLU_NURBS_ERROR19* = 100269 + GLU_NURBS_ERROR20* = 100270 + GLU_NURBS_ERROR21* = 100271 + GLU_NURBS_ERROR22* = 100272 + GLU_NURBS_ERROR23* = 100273 + GLU_NURBS_ERROR24* = 100274 + GLU_NURBS_ERROR25* = 100275 + GLU_NURBS_ERROR26* = 100276 + GLU_NURBS_ERROR27* = 100277 + GLU_NURBS_ERROR28* = 100278 + GLU_NURBS_ERROR29* = 100279 + GLU_NURBS_ERROR30* = 100280 + GLU_NURBS_ERROR31* = 100281 + GLU_NURBS_ERROR32* = 100282 + GLU_NURBS_ERROR33* = 100283 + GLU_NURBS_ERROR34* = 100284 + GLU_NURBS_ERROR35* = 100285 + GLU_NURBS_ERROR36* = 100286 + GLU_NURBS_ERROR37* = 100287 #*** Backwards compatibility for old tesselator ****/ + +proc gluBeginPolygon*(tess: PGLUtesselator){.dynlib: dllname, + importc: "gluBeginPolygon".} +proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname, + importc: "gluNextContour".} +proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, + importc: "gluEndPolygon".} +const # Contours types -- obsolete! + GLU_CW* = 100120 + GLU_CCW* = 100121 + GLU_INTERIOR* = 100122 + GLU_EXTERIOR* = 100123 + GLU_UNKNOWN* = 100124 # Names without "TESS_" prefix + GLU_BEGIN* = GLU_TESS_BEGIN + GLU_VERTEX* = constGLU_TESS_VERTEX + GLU_END* = GLU_TESS_END + GLU_ERROR* = GLU_TESS_ERROR + GLU_EDGE_FLAG* = GLU_TESS_EDGE_FLAG + +{.pop.} +# implementation diff --git a/tests/manyloc/keineschweine/lib/glut.nim b/tests/manyloc/keineschweine/lib/glut.nim new file mode 100644 index 000000000..de9a97456 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/glut.nim @@ -0,0 +1,438 @@ +# +# +# Adaption of the delphi3d.net OpenGL units to FreePascal +# Sebastian Guenther (sg@freepascal.org) in 2002 +# These units are free to use +# + +# Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. +# This program is freely distributable without licensing fees and is +# provided without guarantee or warrantee expressed or implied. This +# program is -not- in the public domain. +#****************************************************************************** +# Converted to Delphi by Tom Nuydens (tom@delphi3d.net) +# Contributions by Igor Karpov (glygrik@hotbox.ru) +# For the latest updates, visit Delphi3D: http://www.delphi3d.net +#****************************************************************************** + +import + GL + +when defined(windows): + const + dllname = "glut32.dll" +elif defined(macosx): + const + dllname = "/System/Library/Frameworks/GLUT.framework/GLUT" +else: + const + dllname = "libglut.so.3" +type + TGlutVoidCallback* = proc (){.cdecl.} + TGlut1IntCallback* = proc (value: cint){.cdecl.} + TGlut2IntCallback* = proc (v1, v2: cint){.cdecl.} + TGlut3IntCallback* = proc (v1, v2, v3: cint){.cdecl.} + TGlut4IntCallback* = proc (v1, v2, v3, v4: cint){.cdecl.} + TGlut1Char2IntCallback* = proc (c: int8, v1, v2: cint){.cdecl.} + TGlut1UInt3IntCallback* = proc (u, v1, v2, v3: cint){.cdecl.} + +const + GLUT_API_VERSION* = 3 + GLUT_XLIB_IMPLEMENTATION* = 12 # Display mode bit masks. + GLUT_RGB* = 0 + GLUT_RGBA* = GLUT_RGB + GLUT_INDEX* = 1 + GLUT_SINGLE* = 0 + GLUT_DOUBLE* = 2 + GLUT_ACCUM* = 4 + GLUT_ALPHA* = 8 + GLUT_DEPTH* = 16 + GLUT_STENCIL* = 32 + GLUT_MULTISAMPLE* = 128 + GLUT_STEREO* = 256 + GLUT_LUMINANCE* = 512 # Mouse buttons. + GLUT_LEFT_BUTTON* = 0 + GLUT_MIDDLE_BUTTON* = 1 + GLUT_RIGHT_BUTTON* = 2 # Mouse button state. + GLUT_DOWN* = 0 + GLUT_UP* = 1 # function keys + GLUT_KEY_F1* = 1 + GLUT_KEY_F2* = 2 + GLUT_KEY_F3* = 3 + GLUT_KEY_F4* = 4 + GLUT_KEY_F5* = 5 + GLUT_KEY_F6* = 6 + GLUT_KEY_F7* = 7 + GLUT_KEY_F8* = 8 + GLUT_KEY_F9* = 9 + GLUT_KEY_F10* = 10 + GLUT_KEY_F11* = 11 + GLUT_KEY_F12* = 12 # directional keys + GLUT_KEY_LEFT* = 100 + GLUT_KEY_UP* = 101 + GLUT_KEY_RIGHT* = 102 + GLUT_KEY_DOWN* = 103 + GLUT_KEY_PAGE_UP* = 104 + GLUT_KEY_PAGE_DOWN* = 105 + GLUT_KEY_HOME* = 106 + GLUT_KEY_END* = 107 + GLUT_KEY_INSERT* = 108 # Entry/exit state. + GLUT_LEFT* = 0 + GLUT_ENTERED* = 1 # Menu usage state. + GLUT_MENU_NOT_IN_USE* = 0 + GLUT_MENU_IN_USE* = 1 # Visibility state. + GLUT_NOT_VISIBLE* = 0 + GLUT_VISIBLE* = 1 # Window status state. + GLUT_HIDDEN* = 0 + GLUT_FULLY_RETAINED* = 1 + GLUT_PARTIALLY_RETAINED* = 2 + GLUT_FULLY_COVERED* = 3 # Color index component selection values. + GLUT_RED* = 0 + GLUT_GREEN* = 1 + GLUT_BLUE* = 2 # Layers for use. + GLUT_NORMAL* = 0 + GLUT_OVERLAY* = 1 + +when defined(windows): + const # Stroke font constants (use these in GLUT program). + GLUT_STROKE_ROMAN* = cast[Pointer](0) + GLUT_STROKE_MONO_ROMAN* = cast[Pointer](1) # Bitmap font constants (use these in GLUT program). + GLUT_BITMAP_9_BY_15* = cast[Pointer](2) + GLUT_BITMAP_8_BY_13* = cast[Pointer](3) + GLUT_BITMAP_TIMES_ROMAN_10* = cast[Pointer](4) + GLUT_BITMAP_TIMES_ROMAN_24* = cast[Pointer](5) + GLUT_BITMAP_HELVETICA_10* = cast[Pointer](6) + GLUT_BITMAP_HELVETICA_12* = cast[Pointer](7) + GLUT_BITMAP_HELVETICA_18* = cast[Pointer](8) +else: + var # Stroke font constants (use these in GLUT program). + GLUT_STROKE_ROMAN*: Pointer + GLUT_STROKE_MONO_ROMAN*: Pointer # Bitmap font constants (use these in GLUT program). + GLUT_BITMAP_9_BY_15*: Pointer + GLUT_BITMAP_8_BY_13*: Pointer + GLUT_BITMAP_TIMES_ROMAN_10*: Pointer + GLUT_BITMAP_TIMES_ROMAN_24*: Pointer + GLUT_BITMAP_HELVETICA_10*: Pointer + GLUT_BITMAP_HELVETICA_12*: Pointer + GLUT_BITMAP_HELVETICA_18*: Pointer +const # glutGet parameters. + GLUT_WINDOW_X* = 100 + GLUT_WINDOW_Y* = 101 + GLUT_WINDOW_WIDTH* = 102 + GLUT_WINDOW_HEIGHT* = 103 + GLUT_WINDOW_BUFFER_SIZE* = 104 + GLUT_WINDOW_STENCIL_SIZE* = 105 + GLUT_WINDOW_DEPTH_SIZE* = 106 + GLUT_WINDOW_RED_SIZE* = 107 + GLUT_WINDOW_GREEN_SIZE* = 108 + GLUT_WINDOW_BLUE_SIZE* = 109 + GLUT_WINDOW_ALPHA_SIZE* = 110 + GLUT_WINDOW_ACCUM_RED_SIZE* = 111 + GLUT_WINDOW_ACCUM_GREEN_SIZE* = 112 + GLUT_WINDOW_ACCUM_BLUE_SIZE* = 113 + GLUT_WINDOW_ACCUM_ALPHA_SIZE* = 114 + GLUT_WINDOW_DOUBLEBUFFER* = 115 + GLUT_WINDOW_RGBA* = 116 + GLUT_WINDOW_PARENT* = 117 + GLUT_WINDOW_NUM_CHILDREN* = 118 + GLUT_WINDOW_COLORMAP_SIZE* = 119 + GLUT_WINDOW_NUM_SAMPLES* = 120 + GLUT_WINDOW_STEREO* = 121 + GLUT_WINDOW_CURSOR* = 122 + GLUT_SCREEN_WIDTH* = 200 + GLUT_SCREEN_HEIGHT* = 201 + GLUT_SCREEN_WIDTH_MM* = 202 + GLUT_SCREEN_HEIGHT_MM* = 203 + GLUT_MENU_NUM_ITEMS* = 300 + GLUT_DISPLAY_MODE_POSSIBLE* = 400 + GLUT_INIT_WINDOW_X* = 500 + GLUT_INIT_WINDOW_Y* = 501 + GLUT_INIT_WINDOW_WIDTH* = 502 + GLUT_INIT_WINDOW_HEIGHT* = 503 + constGLUT_INIT_DISPLAY_MODE* = 504 + GLUT_ELAPSED_TIME* = 700 + GLUT_WINDOW_FORMAT_ID* = 123 # glutDeviceGet parameters. + GLUT_HAS_KEYBOARD* = 600 + GLUT_HAS_MOUSE* = 601 + GLUT_HAS_SPACEBALL* = 602 + GLUT_HAS_DIAL_AND_BUTTON_BOX* = 603 + GLUT_HAS_TABLET* = 604 + GLUT_NUM_MOUSE_BUTTONS* = 605 + GLUT_NUM_SPACEBALL_BUTTONS* = 606 + GLUT_NUM_BUTTON_BOX_BUTTONS* = 607 + GLUT_NUM_DIALS* = 608 + GLUT_NUM_TABLET_BUTTONS* = 609 + GLUT_DEVICE_IGNORE_KEY_REPEAT* = 610 + GLUT_DEVICE_KEY_REPEAT* = 611 + GLUT_HAS_JOYSTICK* = 612 + GLUT_OWNS_JOYSTICK* = 613 + GLUT_JOYSTICK_BUTTONS* = 614 + GLUT_JOYSTICK_AXES* = 615 + GLUT_JOYSTICK_POLL_RATE* = 616 # glutLayerGet parameters. + GLUT_OVERLAY_POSSIBLE* = 800 + GLUT_LAYER_IN_USE* = 801 + GLUT_HAS_OVERLAY* = 802 + GLUT_TRANSPARENT_INDEX* = 803 + GLUT_NORMAL_DAMAGED* = 804 + GLUT_OVERLAY_DAMAGED* = 805 # glutVideoResizeGet parameters. + GLUT_VIDEO_RESIZE_POSSIBLE* = 900 + GLUT_VIDEO_RESIZE_IN_USE* = 901 + GLUT_VIDEO_RESIZE_X_DELTA* = 902 + GLUT_VIDEO_RESIZE_Y_DELTA* = 903 + GLUT_VIDEO_RESIZE_WIDTH_DELTA* = 904 + GLUT_VIDEO_RESIZE_HEIGHT_DELTA* = 905 + GLUT_VIDEO_RESIZE_X* = 906 + GLUT_VIDEO_RESIZE_Y* = 907 + GLUT_VIDEO_RESIZE_WIDTH* = 908 + GLUT_VIDEO_RESIZE_HEIGHT* = 909 # glutGetModifiers return mask. + GLUT_ACTIVE_SHIFT* = 1 + GLUT_ACTIVE_CTRL* = 2 + GLUT_ACTIVE_ALT* = 4 # glutSetCursor parameters. + # Basic arrows. + GLUT_CURSOR_RIGHT_ARROW* = 0 + GLUT_CURSOR_LEFT_ARROW* = 1 # Symbolic cursor shapes. + GLUT_CURSOR_INFO* = 2 + GLUT_CURSOR_DESTROY* = 3 + GLUT_CURSOR_HELP* = 4 + GLUT_CURSOR_CYCLE* = 5 + GLUT_CURSOR_SPRAY* = 6 + GLUT_CURSOR_WAIT* = 7 + GLUT_CURSOR_TEXT* = 8 + GLUT_CURSOR_CROSSHAIR* = 9 # Directional cursors. + GLUT_CURSOR_UP_DOWN* = 10 + GLUT_CURSOR_LEFT_RIGHT* = 11 # Sizing cursors. + GLUT_CURSOR_TOP_SIDE* = 12 + GLUT_CURSOR_BOTTOM_SIDE* = 13 + GLUT_CURSOR_LEFT_SIDE* = 14 + GLUT_CURSOR_RIGHT_SIDE* = 15 + GLUT_CURSOR_TOP_LEFT_CORNER* = 16 + GLUT_CURSOR_TOP_RIGHT_CORNER* = 17 + GLUT_CURSOR_BOTTOM_RIGHT_CORNER* = 18 + GLUT_CURSOR_BOTTOM_LEFT_CORNER* = 19 # Inherit from parent window. + GLUT_CURSOR_INHERIT* = 100 # Blank cursor. + GLUT_CURSOR_NONE* = 101 # Fullscreen crosshair (if available). + GLUT_CURSOR_FULL_CROSSHAIR* = 102 # GLUT device control sub-API. + # glutSetKeyRepeat modes. + GLUT_KEY_REPEAT_OFF* = 0 + GLUT_KEY_REPEAT_ON* = 1 + GLUT_KEY_REPEAT_DEFAULT* = 2 # Joystick button masks. + GLUT_JOYSTICK_BUTTON_A* = 1 + GLUT_JOYSTICK_BUTTON_B* = 2 + GLUT_JOYSTICK_BUTTON_C* = 4 + GLUT_JOYSTICK_BUTTON_D* = 8 # GLUT game mode sub-API. + # glutGameModeGet. + GLUT_GAME_MODE_ACTIVE* = 0 + GLUT_GAME_MODE_POSSIBLE* = 1 + GLUT_GAME_MODE_WIDTH* = 2 + GLUT_GAME_MODE_HEIGHT* = 3 + GLUT_GAME_MODE_PIXEL_DEPTH* = 4 + GLUT_GAME_MODE_REFRESH_RATE* = 5 + GLUT_GAME_MODE_DISPLAY_CHANGED* = 6 # GLUT initialization sub-API. + +proc glutInit*(argcp: ptr cint, argv: pointer){.dynlib: dllname, + importc: "glutInit".} + +proc glutInit*() = + ## version that passes `argc` and `argc` implicitely. + var + cmdLine {.importc: "cmdLine".}: array[0..255, cstring] + cmdCount {.importc: "cmdCount".}: cint + glutInit(addr(cmdCount), addr(cmdLine)) + +proc glutInitDisplayMode*(mode: int16){.dynlib: dllname, + importc: "glutInitDisplayMode".} +proc glutInitDisplayString*(str: cstring){.dynlib: dllname, + importc: "glutInitDisplayString".} +proc glutInitWindowPosition*(x, y: int){.dynlib: dllname, + importc: "glutInitWindowPosition".} +proc glutInitWindowSize*(width, height: int){.dynlib: dllname, + importc: "glutInitWindowSize".} +proc glutMainLoop*(){.dynlib: dllname, importc: "glutMainLoop".} + # GLUT window sub-API. +proc glutCreateWindow*(title: cstring): int{.dynlib: dllname, + importc: "glutCreateWindow".} +proc glutCreateSubWindow*(win, x, y, width, height: int): int{.dynlib: dllname, + importc: "glutCreateSubWindow".} +proc glutDestroyWindow*(win: int){.dynlib: dllname, importc: "glutDestroyWindow".} +proc glutPostRedisplay*(){.dynlib: dllname, importc: "glutPostRedisplay".} +proc glutPostWindowRedisplay*(win: int){.dynlib: dllname, + importc: "glutPostWindowRedisplay".} +proc glutSwapBuffers*(){.dynlib: dllname, importc: "glutSwapBuffers".} +proc glutGetWindow*(): int{.dynlib: dllname, importc: "glutGetWindow".} +proc glutSetWindow*(win: int){.dynlib: dllname, importc: "glutSetWindow".} +proc glutSetWindowTitle*(title: cstring){.dynlib: dllname, + importc: "glutSetWindowTitle".} +proc glutSetIconTitle*(title: cstring){.dynlib: dllname, + importc: "glutSetIconTitle".} +proc glutPositionWindow*(x, y: int){.dynlib: dllname, + importc: "glutPositionWindow".} +proc glutReshapeWindow*(width, height: int){.dynlib: dllname, + importc: "glutReshapeWindow".} +proc glutPopWindow*(){.dynlib: dllname, importc: "glutPopWindow".} +proc glutPushWindow*(){.dynlib: dllname, importc: "glutPushWindow".} +proc glutIconifyWindow*(){.dynlib: dllname, importc: "glutIconifyWindow".} +proc glutShowWindow*(){.dynlib: dllname, importc: "glutShowWindow".} +proc glutHideWindow*(){.dynlib: dllname, importc: "glutHideWindow".} +proc glutFullScreen*(){.dynlib: dllname, importc: "glutFullScreen".} +proc glutSetCursor*(cursor: int){.dynlib: dllname, importc: "glutSetCursor".} +proc glutWarpPointer*(x, y: int){.dynlib: dllname, importc: "glutWarpPointer".} + # GLUT overlay sub-API. +proc glutEstablishOverlay*(){.dynlib: dllname, importc: "glutEstablishOverlay".} +proc glutRemoveOverlay*(){.dynlib: dllname, importc: "glutRemoveOverlay".} +proc glutUseLayer*(layer: TGLenum){.dynlib: dllname, importc: "glutUseLayer".} +proc glutPostOverlayRedisplay*(){.dynlib: dllname, + importc: "glutPostOverlayRedisplay".} +proc glutPostWindowOverlayRedisplay*(win: int){.dynlib: dllname, + importc: "glutPostWindowOverlayRedisplay".} +proc glutShowOverlay*(){.dynlib: dllname, importc: "glutShowOverlay".} +proc glutHideOverlay*(){.dynlib: dllname, importc: "glutHideOverlay".} + # GLUT menu sub-API. +proc glutCreateMenu*(callback: TGlut1IntCallback): int{.dynlib: dllname, + importc: "glutCreateMenu".} +proc glutDestroyMenu*(menu: int){.dynlib: dllname, importc: "glutDestroyMenu".} +proc glutGetMenu*(): int{.dynlib: dllname, importc: "glutGetMenu".} +proc glutSetMenu*(menu: int){.dynlib: dllname, importc: "glutSetMenu".} +proc glutAddMenuEntry*(caption: cstring, value: int){.dynlib: dllname, + importc: "glutAddMenuEntry".} +proc glutAddSubMenu*(caption: cstring, submenu: int){.dynlib: dllname, + importc: "glutAddSubMenu".} +proc glutChangeToMenuEntry*(item: int, caption: cstring, value: int){. + dynlib: dllname, importc: "glutChangeToMenuEntry".} +proc glutChangeToSubMenu*(item: int, caption: cstring, submenu: int){. + dynlib: dllname, importc: "glutChangeToSubMenu".} +proc glutRemoveMenuItem*(item: int){.dynlib: dllname, + importc: "glutRemoveMenuItem".} +proc glutAttachMenu*(button: int){.dynlib: dllname, importc: "glutAttachMenu".} +proc glutDetachMenu*(button: int){.dynlib: dllname, importc: "glutDetachMenu".} + # GLUT window callback sub-API. +proc glutDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, + importc: "glutDisplayFunc".} +proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname, + importc: "glutReshapeFunc".} +proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, + importc: "glutKeyboardFunc".} +proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname, + importc: "glutMouseFunc".} +proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, + importc: "glutMotionFunc".} +proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, + importc: "glutPassiveMotionFunc".} +proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname, + importc: "glutEntryFunc".} +proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname, + importc: "glutVisibilityFunc".} +proc glutIdleFunc*(f: TGlutVoidCallback){.dynlib: dllname, + importc: "glutIdleFunc".} +proc glutTimerFunc*(millis: int16, f: TGlut1IntCallback, value: int){. + dynlib: dllname, importc: "glutTimerFunc".} +proc glutMenuStateFunc*(f: TGlut1IntCallback){.dynlib: dllname, + importc: "glutMenuStateFunc".} +proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname, + importc: "glutSpecialFunc".} +proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname, + importc: "glutSpaceballMotionFunc".} +proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname, + importc: "glutSpaceballRotateFunc".} +proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname, + importc: "glutSpaceballButtonFunc".} +proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname, + importc: "glutButtonBoxFunc".} +proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname, + importc: "glutDialsFunc".} +proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, + importc: "glutTabletMotionFunc".} +proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname, + importc: "glutTabletButtonFunc".} +proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname, + importc: "glutMenuStatusFunc".} +proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, + importc: "glutOverlayDisplayFunc".} +proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname, + importc: "glutWindowStatusFunc".} +proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, + importc: "glutKeyboardUpFunc".} +proc glutSpecialUpFunc*(f: TGlut3IntCallback){.dynlib: dllname, + importc: "glutSpecialUpFunc".} +proc glutJoystickFunc*(f: TGlut1UInt3IntCallback, pollInterval: int){. + dynlib: dllname, importc: "glutJoystickFunc".} + # GLUT color index sub-API. +proc glutSetColor*(cell: int, red, green, blue: TGLfloat){.dynlib: dllname, + importc: "glutSetColor".} +proc glutGetColor*(ndx, component: int): TGLfloat{.dynlib: dllname, + importc: "glutGetColor".} +proc glutCopyColormap*(win: int){.dynlib: dllname, importc: "glutCopyColormap".} + # GLUT state retrieval sub-API. +proc glutGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutGet".} +proc glutDeviceGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutDeviceGet".} + # GLUT extension support sub-API +proc glutExtensionSupported*(name: cstring): int{.dynlib: dllname, + importc: "glutExtensionSupported".} +proc glutGetModifiers*(): int{.dynlib: dllname, importc: "glutGetModifiers".} +proc glutLayerGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutLayerGet".} + # GLUT font sub-API +proc glutBitmapCharacter*(font: pointer, character: int){.dynlib: dllname, + importc: "glutBitmapCharacter".} +proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname, + importc: "glutBitmapWidth".} +proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname, + importc: "glutStrokeCharacter".} +proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname, + importc: "glutStrokeWidth".} +proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname, + importc: "glutBitmapLength".} +proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname, + importc: "glutStrokeLength".} + # GLUT pre-built models sub-API +proc glutWireSphere*(radius: TGLdouble, slices, stacks: TGLint){. + dynlib: dllname, importc: "glutWireSphere".} +proc glutSolidSphere*(radius: TGLdouble, slices, stacks: TGLint){. + dynlib: dllname, importc: "glutSolidSphere".} +proc glutWireCone*(base, height: TGLdouble, slices, stacks: TGLint){. + dynlib: dllname, importc: "glutWireCone".} +proc glutSolidCone*(base, height: TGLdouble, slices, stacks: TGLint){. + dynlib: dllname, importc: "glutSolidCone".} +proc glutWireCube*(size: TGLdouble){.dynlib: dllname, importc: "glutWireCube".} +proc glutSolidCube*(size: TGLdouble){.dynlib: dllname, importc: "glutSolidCube".} +proc glutWireTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){. + dynlib: dllname, importc: "glutWireTorus".} +proc glutSolidTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){. + dynlib: dllname, importc: "glutSolidTorus".} +proc glutWireDodecahedron*(){.dynlib: dllname, importc: "glutWireDodecahedron".} +proc glutSolidDodecahedron*(){.dynlib: dllname, importc: "glutSolidDodecahedron".} +proc glutWireTeapot*(size: TGLdouble){.dynlib: dllname, + importc: "glutWireTeapot".} +proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname, + importc: "glutSolidTeapot".} +proc glutWireOctahedron*(){.dynlib: dllname, importc: "glutWireOctahedron".} +proc glutSolidOctahedron*(){.dynlib: dllname, importc: "glutSolidOctahedron".} +proc glutWireTetrahedron*(){.dynlib: dllname, importc: "glutWireTetrahedron".} +proc glutSolidTetrahedron*(){.dynlib: dllname, importc: "glutSolidTetrahedron".} +proc glutWireIcosahedron*(){.dynlib: dllname, importc: "glutWireIcosahedron".} +proc glutSolidIcosahedron*(){.dynlib: dllname, importc: "glutSolidIcosahedron".} + # GLUT video resize sub-API. +proc glutVideoResizeGet*(param: TGLenum): int{.dynlib: dllname, + importc: "glutVideoResizeGet".} +proc glutSetupVideoResizing*(){.dynlib: dllname, + importc: "glutSetupVideoResizing".} +proc glutStopVideoResizing*(){.dynlib: dllname, importc: "glutStopVideoResizing".} +proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname, + importc: "glutVideoResize".} +proc glutVideoPan*(x, y, width, height: int){.dynlib: dllname, + importc: "glutVideoPan".} + # GLUT debugging sub-API. +proc glutReportErrors*(){.dynlib: dllname, importc: "glutReportErrors".} + # GLUT device control sub-API. +proc glutIgnoreKeyRepeat*(ignore: int){.dynlib: dllname, + importc: "glutIgnoreKeyRepeat".} +proc glutSetKeyRepeat*(repeatMode: int){.dynlib: dllname, + importc: "glutSetKeyRepeat".} +proc glutForceJoystickFunc*(){.dynlib: dllname, importc: "glutForceJoystickFunc".} + # GLUT game mode sub-API. + #example glutGameModeString('1280x1024:32@75'); +proc glutGameModeString*(AString: cstring){.dynlib: dllname, + importc: "glutGameModeString".} +proc glutEnterGameMode*(): int{.dynlib: dllname, importc: "glutEnterGameMode".} +proc glutLeaveGameMode*(){.dynlib: dllname, importc: "glutLeaveGameMode".} +proc glutGameModeGet*(mode: TGLenum): int{.dynlib: dllname, + importc: "glutGameModeGet".} +# implementation diff --git a/tests/manyloc/keineschweine/lib/glx.nim b/tests/manyloc/keineschweine/lib/glx.nim new file mode 100644 index 000000000..ce02835bd --- /dev/null +++ b/tests/manyloc/keineschweine/lib/glx.nim @@ -0,0 +1,153 @@ +# +# +# Translation of the Mesa GLX headers for FreePascal +# Copyright (C) 1999 Sebastian Guenther +# +# +# Mesa 3-D graphics library +# Version: 3.0 +# Copyright (C) 1995-1998 Brian Paul +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library 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 +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the Free +# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +import + X, XLib, XUtil, gl + +when defined(windows): + const + dllname = "GL.dll" +elif defined(macosx): + const + dllname = "/usr/X11R6/lib/libGL.dylib" +else: + const + dllname = "libGL.so" +const + GLX_USE_GL* = 1 + GLX_BUFFER_SIZE* = 2 + GLX_LEVEL* = 3 + GLX_RGBA* = 4 + GLX_DOUBLEBUFFER* = 5 + GLX_STEREO* = 6 + GLX_AUX_BUFFERS* = 7 + GLX_RED_SIZE* = 8 + GLX_GREEN_SIZE* = 9 + GLX_BLUE_SIZE* = 10 + GLX_ALPHA_SIZE* = 11 + GLX_DEPTH_SIZE* = 12 + GLX_STENCIL_SIZE* = 13 + GLX_ACCUM_RED_SIZE* = 14 + GLX_ACCUM_GREEN_SIZE* = 15 + GLX_ACCUM_BLUE_SIZE* = 16 + GLX_ACCUM_ALPHA_SIZE* = 17 # GLX_EXT_visual_info extension + GLX_X_VISUAL_TYPE_EXT* = 0x00000022 + GLX_TRANSPARENT_TYPE_EXT* = 0x00000023 + GLX_TRANSPARENT_INDEX_VALUE_EXT* = 0x00000024 + GLX_TRANSPARENT_RED_VALUE_EXT* = 0x00000025 + GLX_TRANSPARENT_GREEN_VALUE_EXT* = 0x00000026 + GLX_TRANSPARENT_BLUE_VALUE_EXT* = 0x00000027 + GLX_TRANSPARENT_ALPHA_VALUE_EXT* = 0x00000028 # Error codes returned by glXGetConfig: + GLX_BAD_SCREEN* = 1 + GLX_BAD_ATTRIBUTE* = 2 + GLX_NO_EXTENSION* = 3 + GLX_BAD_VISUAL* = 4 + GLX_BAD_CONTEXT* = 5 + GLX_BAD_VALUE* = 6 + GLX_BAD_ENUM* = 7 # GLX 1.1 and later: + GLX_VENDOR* = 1 + GLX_VERSION* = 2 + GLX_EXTENSIONS* = 3 # GLX_visual_info extension + GLX_TRUE_COLOR_EXT* = 0x00008002 + GLX_DIRECT_COLOR_EXT* = 0x00008003 + GLX_PSEUDO_COLOR_EXT* = 0x00008004 + GLX_STATIC_COLOR_EXT* = 0x00008005 + GLX_GRAY_SCALE_EXT* = 0x00008006 + GLX_STATIC_GRAY_EXT* = 0x00008007 + GLX_NONE_EXT* = 0x00008000 + GLX_TRANSPARENT_RGB_EXT* = 0x00008008 + GLX_TRANSPARENT_INDEX_EXT* = 0x00008009 + +type # From XLib: + XPixmap* = TXID + XFont* = TXID + XColormap* = TXID + GLXContext* = Pointer + GLXPixmap* = TXID + GLXDrawable* = TXID + GLXContextID* = TXID + TXPixmap* = XPixmap + TXFont* = XFont + TXColormap* = XColormap + TGLXContext* = GLXContext + TGLXPixmap* = GLXPixmap + TGLXDrawable* = GLXDrawable + TGLXContextID* = GLXContextID + +proc glXChooseVisual*(dpy: PDisplay, screen: int, attribList: ptr int32): PXVisualInfo{. + cdecl, dynlib: dllname, importc: "glXChooseVisual".} +proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext, + direct: bool): GLXContext{.cdecl, dynlib: dllname, + importc: "glXCreateContext".} +proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname, + importc: "glXDestroyContext".} +proc glXMakeCurrent*(dpy: PDisplay, drawable: GLXDrawable, ctx: GLXContext): bool{. + cdecl, dynlib: dllname, importc: "glXMakeCurrent".} +proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl, + dynlib: dllname, importc: "glXCopyContext".} +proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl, + dynlib: dllname, importc: "glXSwapBuffers".} +proc glXCreateGLXPixmap*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap): GLXPixmap{. + cdecl, dynlib: dllname, importc: "glXCreateGLXPixmap".} +proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl, + dynlib: dllname, importc: "glXDestroyGLXPixmap".} +proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl, + dynlib: dllname, importc: "glXQueryExtension".} +proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl, + dynlib: dllname, importc: "glXQueryVersion".} +proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname, + importc: "glXIsDirect".} +proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int, + value: var int): int{.cdecl, dynlib: dllname, + importc: "glXGetConfig".} +proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname, + importc: "glXGetCurrentContext".} +proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname, + importc: "glXGetCurrentDrawable".} +proc glXWaitGL*(){.cdecl, dynlib: dllname, importc: "glXWaitGL".} +proc glXWaitX*(){.cdecl, dynlib: dllname, importc: "glXWaitX".} +proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname, + importc: "glXUseXFont".} + # GLX 1.1 and later +proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl, + dynlib: dllname, importc: "glXQueryExtensionsString".} +proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl, + dynlib: dllname, importc: "glXQueryServerString".} +proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl, + dynlib: dllname, importc: "glXGetClientString".} + # Mesa GLX Extensions +proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo, + pixmap: XPixmap, cmap: XColormap): GLXPixmap{. + cdecl, dynlib: dllname, importc: "glXCreateGLXPixmapMESA".} +proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl, + dynlib: dllname, importc: "glXReleaseBufferMESA".} +proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable, + x, y, width, height: int){.cdecl, dynlib: dllname, + importc: "glXCopySubBufferMESA".} +proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname, + importc: "glXGetVideoSyncSGI".} +proc glXWaitVideoSyncSGI*(divisor, remainder: int, count: var int32): int{. + cdecl, dynlib: dllname, importc: "glXWaitVideoSyncSGI".} +# implementation diff --git a/tests/manyloc/keineschweine/lib/idgen.nim b/tests/manyloc/keineschweine/lib/idgen.nim new file mode 100644 index 000000000..1ed196d88 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/idgen.nim @@ -0,0 +1,23 @@ +type + PIDGen*[T: Ordinal] = ref TIDGen[T] + TIDGen*[T: Ordinal] = object + max: T + freeIDs: seq[T] + EOutOfIDs* = object of EInvalidKey + +#proc free[T](idg: PIDgen[T]) = +# result.freeIDs = nil +proc newIDGen*[T: Ordinal](): PIDGen[T] = + new(result)#, free) + result.max = 0.T + result.freeIDs = @[] +proc next*[T](idg: PIDGen[T]): T = + if idg.freeIDs.len > 0: + result = idg.freeIDs.pop + elif idg.max < high(T)-T(1): + inc idg.max + result = idg.max + else: + raise newException(EOutOfIDs, "ID generator hit max value") +proc del*[T](idg: PIDGen[T]; id: T) = + idg.freeIDs.add id diff --git a/tests/manyloc/keineschweine/lib/input_helpers.nim b/tests/manyloc/keineschweine/lib/input_helpers.nim new file mode 100644 index 000000000..ff1286c8d --- /dev/null +++ b/tests/manyloc/keineschweine/lib/input_helpers.nim @@ -0,0 +1,138 @@ +import + sfml, tables, hashes +type + TKeyEventKind* = enum down, up + TInputFinishedProc* = proc() + TKeyCallback = proc() + PKeyClient* = ref object + onKeyDown: Table[int32, TKeyCallback] + onKeyUp: Table[int32, TKeyCallback] + name: string + PTextInput* = ref object + text*: string + cursor: int + onEnter: TInputFinishedProc +var + keyState: array[-MouseButtonCount.int32 .. KeyCount.int32, bool] + mousePos: TVector2f + activeClient: PKeyClient = nil + activeInput: PTextInput = nil + +proc setActive*(client: PKeyClient) = + activeClient = client + echo("** set active client ", client.name) +proc newKeyClient*(name: string = "unnamed", setactive = false): PKeyClient = + new(result) + result.onKeyDown = initTable[int32, TKeyCallback](16) + result.onKeyUp = initTable[int32, TKeyCallback](16) + result.name = name + if setActive: + setActive(result) + +proc keyPressed*(key: TKeyCode): bool {.inline.} = + return keyState[key.int32] +proc buttonPressed*(btn: TMouseButton): bool {.inline.} = + return keyState[-btn.int32] + +proc clearKey*(key: TKeyCode) {.inline.} = + keyState[key.int32] = false +proc clearButton*(btn: TMouseButton) {.inline.} = + keyState[-btn.int32] = false + +proc addKeyEvent*(key: TKeyCode, ev: TKeyEventKind) {.inline.} = + if activeClient.isNil: return + let k = key.int32 + case ev + of down: + keyState[k] = true + if activeClient.onKeyDown.hasKey(k): + activeClient.onKeyDown[k]() + else: + keyState[k] = false + if activeClient.onKeyUp.hasKey(k): + activeClient.onKeyUp[k]() +proc addButtonEvent*(btn: TMouseButton, ev: TKeyEventKind) {.inline.} = + if activeClient.isNil: return + let b = -btn.int32 + case ev + of down: + keyState[b] = true + if activeClient.onKeyDown.hasKey(b): + activeClient.onKeyDown[b]() + else: + keyState[b] = false + if activeClient.onKeyUp.hasKey(b): + activeClient.onKeyUp[b]() +proc registerHandler*(client: PKeyClient; key: TKeyCode; + ev: TKeyEventKind; fn: TKeyCallback) = + case ev + of down: client.onKeyDown[key.int32] = fn + of up: client.onKeyUp[key.int32] = fn +proc registerHandler*(client: PKeyClient; btn: TMouseButton; + ev: TKeyEventKind; fn: TKeyCallback) = + case ev + of down: client.onKeyDown[-btn.int32] = fn + of up: client.onKeyUp[-btn.int32] = fn + +proc newTextInput*(text = "", pos = 0, onEnter: TInputFinishedProc = nil): PTextInput = + new(result) + result.text = text + result.cursor = pos + result.onEnter = onEnter +proc setActive*(i: PTextInput) = + activeInput = i +proc stopCapturingText*() = + activeInput = nil +proc clear*(i: PTextInput) = + i.text.setLen 0 + i.cursor = 0 +proc recordText*(i: PTextInput; c: cint) = + if c > 127 or i.isNil: return + if c in 32..126: ##printable + if i.cursor == i.text.len: i.text.add(c.int.chr) + else: + let rem = i.text.substr(i.cursor) + i.text.setLen(i.cursor) + i.text.add(chr(c.int)) + i.text.add(rem) + inc(i.cursor) + elif c == 8: ## \b backspace + if i.text.len > 0 and i.cursor > 0: + dec(i.cursor) + let rem = i.text.substr(i.cursor + 1) + i.text.setLen(i.cursor) + i.text.add(rem) + elif c == 10 or c == 13:## \n, \r enter + if not i.onEnter.isNil: i.onEnter() +proc recordText*(i: PTextInput; e: TTextEvent) {.inline.} = + recordText(i, e.unicode) + +proc setMousePos*(x, y: cint) {.inline.} = + mousePos.x = x.float + mousePos.y = y.float +proc getMousePos*(): TVector2f {.inline.} = result = mousePos + +var event: TEvent +# Handle and filter input-related events +iterator filterEvents*(window: PRenderWindow): PEvent = + while window.pollEvent(addr event): + case event.kind + of EvtKeyPressed: addKeyEvent(event.key.code, down) + of EvtKeyReleased: addKeyEvent(event.key.code, up) + of EvtMouseButtonPressed: addButtonEvent(event.mouseButton.button, down) + of EvtMouseButtonReleased: addButtonEvent(event.mouseButton.button, up) + of EvtTextEntered: recordText(activeInput, event.text) + of EvtMouseMoved: setMousePos(event.mouseMove.x, event.mouseMove.y) + else: yield(addr event) +# Handle and return input-related events +iterator pollEvents*(window: PRenderWindow): PEvent = + while window.pollEvent(addr event): + case event.kind + of EvtKeyPressed: addKeyEvent(event.key.code, down) + of EvtKeyReleased: addKeyEvent(event.key.code, up) + of EvtMouseButtonPressed: addButtonEvent(event.mouseButton.button, down) + of EvtMouseButtonReleased: addButtonEvent(event.mouseButton.button, up) + of EvtTextEntered: recordText(activeInput, event.text) + of EvtMouseMoved: setMousePos(event.mouseMove.x, event.mouseMove.y) + else: discard + yield(addr event) diff --git a/tests/manyloc/keineschweine/lib/map_filter.nim b/tests/manyloc/keineschweine/lib/map_filter.nim new file mode 100644 index 000000000..acb58c60e --- /dev/null +++ b/tests/manyloc/keineschweine/lib/map_filter.nim @@ -0,0 +1,41 @@ +template filterIt2*(seq, pred: untyped, body: untyped) = + ## sequtils defines a filterIt() that returns a new seq, but this one is called + ## with a statement body to iterate directly over it + for it in items(seq): + if pred: body + +proc map*[A, B](x: seq[A], fun: proc(y: A): B {.closure.}): seq[B] = + result = @[] + for item in x.items: + result.add fun(item) + +proc mapInPlace*[A](x: var seq[A], fun: proc(y: A): A {.closure.}) = + for i in 0..x.len-1: + x[i] = fun(x[i]) + +template unless*(condition: untyped; body: untyped) {.dirty.} = + if not condition: + body + +when false: + proc dumpSeq[T](x: seq[T]) = + for index, item in x.pairs: + echo index, " ", item + echo "-------" + + var t= @[1,2,3,4,5] + var res = t.map(proc(z: int): int = result = z * 10) + dumpSeq res + + from strutils import toHex + var foocakes = t.map(proc(z: int): string = + result = toHex((z * 23).BiggestInt, 4)) + dumpSeq foocakes + + t.mapInPlace(proc(z: int): int = result = z * 30) + dumpSeq t + + var someSeq = @[9,8,7,6,5,4,3,2,1] ## numbers < 6 or even + filterIt2 someSeq, it < 6 or (it and 1) == 0: + echo(it) + echo "-----------" diff --git a/tests/manyloc/keineschweine/lib/math_helpers.nim b/tests/manyloc/keineschweine/lib/math_helpers.nim new file mode 100644 index 000000000..5427dd80e --- /dev/null +++ b/tests/manyloc/keineschweine/lib/math_helpers.nim @@ -0,0 +1,10 @@ +import strutils, math + +proc degrees*(rad: float): float = + return rad * 180.0 / PI +proc radians*(deg: float): float = + return deg * PI / 180.0 + +## V not math, sue me +proc ff*(f: float, precision = 2): string {.inline.} = + return formatFloat(f, ffDecimal, precision) diff --git a/tests/manyloc/keineschweine/lib/sfml_stuff.nim b/tests/manyloc/keineschweine/lib/sfml_stuff.nim new file mode 100644 index 000000000..5ff80b295 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/sfml_stuff.nim @@ -0,0 +1,37 @@ +import + math, strutils, + sfml, input_helpers +when not defined(NoChipmunk): + import chipmunk + proc floor*(a: TVector): TVector2f {.inline.} = + result.x = a.x.floor + result.y = a.y.floor + proc sfml2cp*(a: TVector2f): TVector {.inline.} = + result.x = a.x + result.y = a.y + proc cp2sfml*(a: TVector): TVector2f {.inline.} = + result.x = a.x + result.y = a.y + +proc vec2f*(a: TVector2i): TVector2f = + result.x = a.x.cfloat + result.y = a.y.cfloat +proc vec2i*(a: TVector2f): TVector2i = + result.x = a.x.cint + result.y = a.y.cint +proc vec3f*(x, y, z: float): TVector3f = + result.x = x.cfloat + result.y = y.cfloat + result.z = z.cfloat + +proc `$`*(a: var TIntRect): string = + result = "[TIntRect $1,$2 $3x$4]".format($a.left, $a.top, $a.width, $a.height) +proc `$`*(a: TKeyEvent): string = + return "KeyEvent: code=$1 alt=$2 control=$3 shift=$4 system=$5".format( + $a.code, $a.alt, $a.control, $a.shift, $a.system) + +proc `wmod`*(x, y: float): float = return x - y * (x/y).floor +proc move*(a: var TIntRect, left, top: cint): bool = + if a.left != left or a.top != top: result = true + a.left = left + a.top = top diff --git a/tests/manyloc/keineschweine/lib/sg_assets.nim b/tests/manyloc/keineschweine/lib/sg_assets.nim new file mode 100644 index 000000000..96c962dc3 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/sg_assets.nim @@ -0,0 +1,611 @@ +import ../../../../dist/checksums/src/checksums/md5 + +import + re, json, strutils, tables, math, os, math_helpers, + sg_packets, zlib_helpers + +when defined(NoSFML): + import server_utils + type TVector2i = object + x*, y*: int32 + proc vec2i(x, y: int32): TVector2i = + result.x = x + result.y = y +else: + import sfml, sfml_audio, sfml_stuff +when not defined(NoChipmunk): + import chipmunk + +type + TChecksumFile* = object + unpackedSize*: int + sum*: MD5Digest + compressed*: string + PZoneSettings* = ref TZoneSettings + TZoneSettings* = object + vehicles: seq[PVehicleRecord] + items: seq[PItemRecord] + objects: seq[PObjectRecord] + bullets: seq[PBulletRecord] + levelSettings: PLevelSettings + PLevelSettings* = ref TLevelSettings + TLevelSettings* = object + size*: TVector2i + starfield*: seq[PSpriteSheet] + PVehicleRecord* = ref TVehicleRecord + TVehicleRecord* = object + id*: int16 + name*: string + playable*: bool + anim*: PAnimationRecord + physics*: TPhysicsRecord + handling*: THandlingRecord + TItemKind* = enum + Projectile, Utility, Ammo + PObjectRecord* = ref TObjectRecord + TObjectRecord* = object + id*: int16 + name*: string + anim*: PAnimationRecord + physics*: TPhysicsRecord + PItemRecord* = ref TItemRecord + TItemRecord* = object + id*: int16 + name*: string + anim*: PAnimationRecord + physics*: TPhysicsRecord ##apply when the item is dropped in the arena + cooldown*: float + energyCost*: float + useSound*: PSoundRecord + case kind*: TItemKind + of Projectile: + bullet*: PBulletRecord + else: + discard + PBulletRecord* = ref TBulletRecord + TBulletRecord* = object + id*: int16 + name*: string + anim*: PAnimationRecord + physics*: TPhysicsRecord + lifetime*, inheritVelocity*, baseVelocity*: float + explosion*: TExplosionRecord + trail*: TTrailRecord + TTrailRecord* = object + anim*: PAnimationRecord + timer*: float ##how often it should be created + TPhysicsRecord* = object + mass*: float + radius*: float + moment*: float + THandlingRecord = object + thrust*, top_speed*: float + reverse*, strafe*, rotation*: float + TSoulRecord = object + energy*: int + health*: int + TExplosionRecord* = object + anim*: PAnimationRecord + sound*: PSoundRecord + PAnimationRecord* = ref TAnimationRecord + TAnimationRecord* = object + spriteSheet*: PSpriteSheet + angle*: float + delay*: float ##animation delay + PSoundRecord* = ref TSoundRecord + TSoundRecord* = object + file*: string + when defined(NoSFML): + contents*: TChecksumFile + else: + soundBuf*: PSoundBuffer + PSpriteSheet* = ref TSpriteSheet + TSpriteSheet* = object + file*: string + framew*,frameh*: int + rows*, cols*: int + when defined(NoSFML): + contents*: TChecksumFile + when not defined(NoSFML): + sprite*: PSprite + tex*: PTexture + TGameState* = enum + Lobby, Transitioning, Field +const + MomentMult* = 0.62 ## global moment of inertia multiplier +var + cfg: PZoneSettings + SpriteSheets* = initTable[string, PSpriteSheet](64) + SoundCache * = initTable[string, PSoundRecord](64) + nameToVehID*: Table[string, int] + nameToItemID*: Table[string, int] + nameToObjID*: Table[string, int] + nameToBulletID*: Table[string, int] + activeState = Lobby + +proc newSprite*(filename: string; errors: var seq[string]): PSpriteSheet +proc load*(ss: PSpriteSheet): bool {.discardable.} +proc newSound*(filename: string; errors: var seq[string]): PSoundRecord +proc load*(s: PSoundRecord): bool {.discardable.} + +proc validateSettings*(settings: JsonNode; errors: var seq[string]): bool +proc loadSettings*(rawJson: string, errors: var seq[string]): bool +proc loadSettingsFromFile*(filename: string, errors: var seq[string]): bool + +proc fetchVeh*(name: string): PVehicleRecord +proc fetchItm*(itm: string): PItemRecord +proc fetchObj*(name: string): PObjectRecord +proc fetchBullet(name: string): PBulletRecord + +proc importLevel(data: JsonNode; errors: var seq[string]): PLevelSettings +proc importVeh(data: JsonNode; errors: var seq[string]): PVehicleRecord +proc importObject(data: JsonNode; errors: var seq[string]): PObjectRecord +proc importItem(data: JsonNode; errors: var seq[string]): PItemRecord +proc importPhys(data: JsonNode): TPhysicsRecord +proc importAnim(data: JsonNode; errors: var seq[string]): PAnimationRecord +proc importHandling(data: JsonNode): THandlingRecord +proc importBullet(data: JsonNode; errors: var seq[string]): PBulletRecord +proc importSoul(data: JsonNode): TSoulRecord +proc importExplosion(data: JsonNode; errors: var seq[string]): TExplosionRecord +proc importSound*(data: JsonNode; errors: var seq[string]; fieldName: string = ""): PSoundRecord + +## this is the only pipe between lobby and main.nim +proc getActiveState*(): TGameState = + result = activeState +proc transition*() = + assert activeState == Lobby, "Transition() called from a state other than lobby!" + activeState = Transitioning +proc doneWithSaidTransition*() = + assert activeState == Transitioning, "Finished() called from a state other than transitioning!" + activeState = Field + + +proc checksumFile*(filename: string): TChecksumFile = + let fullText = readFile(filename) + result.unpackedSize = fullText.len + result.sum = toMD5(fullText) + result.compressed = compress(fullText) +proc checksumStr*(str: string): TChecksumFile = + result.unpackedSize = str.len + result.sum = toMD5(str) + result.compressed = compress(str) + + +##at this point none of these should ever be freed +proc free*(obj: PZoneSettings) = + echo "Free'd zone settings" +proc free*(obj: PSpriteSheet) = + echo "Free'd ", obj.file +proc free*(obj: PSoundRecord) = + echo "Free'd ", obj.file + +proc loadAllAssets*() = + var + loaded = 0 + failed = 0 + for name, ss in SpriteSheets.pairs(): + if load(ss): + inc loaded + else: + inc failed + echo loaded," sprites loaded. ", failed, " sprites failed." + loaded = 0 + failed = 0 + for name, s in SoundCache.pairs(): + if load(s): + inc loaded + else: + inc failed + echo loaded, " sounds loaded. ", failed, " sounds failed." +proc getLevelSettings*(): PLevelSettings = + result = cfg.levelSettings + +iterator playableVehicles*(): PVehicleRecord = + for v in cfg.vehicles.items(): + if v.playable: + yield v + +template allAssets*(body: untyped) {.dirty.}= + block: + var assetType = FGraphics + for file, asset in pairs(SpriteSheets): + body + assetType = FSound + for file, asset in pairs(SoundCache): + body + +template cacheImpl(procName, cacheName, resultType, body: untyped) {.dirty.} = + proc procName*(filename: string; errors: var seq[string]): resulttype = + if hasKey(cacheName, filename): + return cacheName[filename] + new(result, free) + body + cacheName[filename] = result + +template checkFile(path: untyped) {.dirty.} = + if not fileExists(path): + errors.add("File missing: " & path) + +cacheImpl newSprite, SpriteSheets, PSpriteSheet: + result.file = filename + if filename =~ re"\S+_(\d+)x(\d+)\.\S\S\S": + result.framew = strutils.parseInt(matches[0]) + result.frameh = strutils.parseInt(matches[1]) + checkFile("data/gfx"/result.file) + else: + errors.add "Bad file: " & filename & " must be in format name_WxH.png" + return + +cacheImpl newSound, SoundCache, PSoundRecord: + result.file = filename + checkFile("data/sfx"/result.file) + +proc expandPath*(assetType: TAssetType; fileName: string): string = + result = "data/" + case assetType + of FGraphics: result.add "gfx/" + of FSound: result.add "sfx/" + else: discard + result.add fileName +proc expandPath*(fc: ScFileChallenge): string {.inline.} = + result = expandPath(fc.assetType, fc.file) + +when defined(NoSFML): + proc load*(ss: PSpriteSheet): bool = + if not ss.contents.unpackedSize == 0: return + ss.contents = checksumFile(expandPath(FGraphics, ss.file)) + result = true + proc load*(s: PSoundRecord): bool = + if not s.contents.unpackedSize == 0: return + s.contents = checksumFile(expandPath(FSound, s.file)) + result = true +else: + proc load*(ss: PSpriteSheet): bool = + if not ss.sprite.isNil: + return + var image = sfml.newImage("data/gfx/"/ss.file) + if image == nil: + echo "Image could not be loaded" + return + let size = image.getSize() + ss.rows = int(size.y / ss.frameh) #y is h + ss.cols = int(size.x / ss.framew) #x is w + ss.tex = newTexture(image) + image.destroy() + ss.sprite = newSprite() + ss.sprite.setTexture(ss.tex, true) + ss.sprite.setTextureRect(intrect(0, 0, ss.framew.cint, ss.frameh.cint)) + ss.sprite.setOrigin(vec2f(ss.framew / 2, ss.frameh / 2)) + result = true + proc load*(s: PSoundRecord): bool = + s.soundBuf = newSoundBuffer("data/sfx"/s.file) + if not s.soundBuf.isNil: + result = true + +template addError(e: untyped) = + errors.add(e) + result = false +proc validateSettings*(settings: JsonNode, errors: var seq[string]): bool = + result = true + if settings.kind != JObject: + addError("Settings root must be an object") + return + if not settings.hasKey("vehicles"): + addError("Vehicles section missing") + if not settings.hasKey("objects"): + errors.add("Objects section is missing") + result = false + if not settings.hasKey("level"): + errors.add("Level settings section is missing") + result = false + else: + let lvl = settings["level"] + if lvl.kind != JObject or not lvl.hasKey("size"): + errors.add("Invalid level settings") + result = false + elif not lvl.hasKey("size") or lvl["size"].kind != JArray or lvl["size"].len != 2: + errors.add("Invalid/missing level size") + result = false + if not settings.hasKey("items"): + errors.add("Items section missing") + result = false + else: + let items = settings["items"] + if items.kind != JArray or items.len == 0: + errors.add "Invalid or empty item list" + else: + var id = 0 + for i in items.items: + if i.kind != JArray: errors.add("Item #$1 is not an array" % $id) + elif i.len != 3: errors.add("($1) Item record should have 3 fields"%($id)) + elif i[0].kind != JString or i[1].kind != JString or i[2].kind != JObject: + errors.add("($1) Item should be in form [name, type, {item: data}]" % $id) + result = false + inc id + +proc loadSettingsFromFile*(filename: string, errors: var seq[string]): bool = + if not fileExists(filename): + errors.add("File does not exist: "&filename) + else: + result = loadSettings(readFile(filename), errors) + +proc loadSettings*(rawJson: string, errors: var seq[string]): bool = + var settings: JsonNode + try: + settings = parseJson(rawJson) + except JsonParsingError: + errors.add("JSON parsing error: " & getCurrentExceptionMsg()) + return + except: + errors.add("Unknown exception: " & getCurrentExceptionMsg()) + return + if not validateSettings(settings, errors): + return + if cfg != nil: #TODO try this + echo("Overwriting zone settings") + free(cfg) + cfg = nil + new(cfg, free) + cfg.levelSettings = importLevel(settings, errors) + cfg.vehicles = @[] + cfg.items = @[] + cfg.objects = @[] + cfg.bullets = @[] + nameToVehID = initTable[string, int](32) + nameToItemID = initTable[string, int](32) + nameToObjID = initTable[string, int](32) + nameToBulletID = initTable[string, int](32) + var + vID = 0'i16 + bID = 0'i16 + for vehicle in settings["vehicles"].items: + var veh = importVeh(vehicle, errors) + veh.id = vID + cfg.vehicles.add veh + nameToVehID[veh.name] = veh.id + inc vID + vID = 0 + if settings.hasKey("bullets"): + for blt in settings["bullets"].items: + var bullet = importBullet(blt, errors) + bullet.id = bID + cfg.bullets.add bullet + nameToBulletID[bullet.name] = bullet.id + inc bID + for item in settings["items"].items: + var itm = importItem(item, errors) + itm.id = vID + cfg.items.add itm + nameToItemID[itm.name] = itm.id + inc vID + if itm.kind == Projectile: + if itm.bullet.isNil: + errors.add("Projectile #$1 has no bullet!" % $vID) + elif itm.bullet.id == -1: + ## this item has an anonymous bullet, fix the ID and name + itm.bullet.id = bID + itm.bullet.name = itm.name + cfg.bullets.add itm.bullet + nameToBulletID[itm.bullet.name] = itm.bullet.id + inc bID + vID = 0 + for obj in settings["objects"].items: + var o = importObject(obj, errors) + o.id = vID + cfg.objects.add o + nameToObjID[o.name] = o.id + inc vID + result = (errors.len == 0) + +proc `$`*(obj: PSpriteSheet): string = + return "<Sprite $1 ($2x$3) $4 rows $5 cols>" % [obj.file, $obj.framew, $obj.frameh, $obj.rows, $obj.cols] + +proc fetchVeh*(name: string): PVehicleRecord = + return cfg.vehicles[nameToVehID[name]] +proc fetchItm*(itm: string): PItemRecord = + return cfg.items[nameToItemID[itm]] +proc fetchObj*(name: string): PObjectRecord = + return cfg.objects[nameToObjID[name]] +proc fetchBullet(name: string): PBulletRecord = + return cfg.bullets[nameToBulletID[name]] + +proc getField(node: JsonNode, field: string, target: var float) = + if not node.hasKey(field): + return + if node[field].kind == JFloat: + target = node[field].fnum + elif node[field].kind == JInt: + target = node[field].num.float +proc getField(node: JsonNode, field: string, target: var int) = + if not node.hasKey(field): + return + if node[field].kind == JInt: + target = node[field].num.int + elif node[field].kind == JFloat: + target = node[field].fnum.int +proc getField(node: JsonNode; field: string; target: var bool) = + if not node.hasKey(field): + return + case node[field].kind + of JBool: + target = node[field].bval + of JInt: + target = (node[field].num != 0) + of JFloat: + target = (node[field].fnum != 0.0) + else: discard + +template checkKey(node: untyped; key: string) = + if not hasKey(node, key): + return + +proc importTrail(data: JsonNode; errors: var seq[string]): TTrailRecord = + checkKey(data, "trail") + result.anim = importAnim(data["trail"], errors) + result.timer = 1000.0 + getField(data["trail"], "timer", result.timer) + result.timer /= 1000.0 +proc importLevel(data: JsonNode; errors: var seq[string]): PLevelSettings = + new(result) + result.size = vec2i(5000, 5000) + result.starfield = @[] + + checkKey(data, "level") + var level = data["level"] + if level.hasKey("size") and level["size"].kind == JArray and level["size"].len == 2: + result.size.x = level["size"][0].num.cint + result.size.y = level["size"][1].num.cint + if level.hasKey("starfield"): + for star in level["starfield"].items: + result.starfield.add(newSprite(star.str, errors)) +proc importPhys(data: JsonNode): TPhysicsRecord = + result.radius = 20.0 + result.mass = 10.0 + + if data.hasKey("physics") and data["physics"].kind == JObject: + let phys = data["physics"] + phys.getField("radius", result.radius) + phys.getField("mass", result.mass) + when not defined(NoChipmunk): + result.moment = momentForCircle(result.mass, 0.0, result.radius, VectorZero) * MomentMult +proc importHandling(data: JsonNode): THandlingRecord = + result.thrust = 45.0 + result.topSpeed = 100.0 #unused + result.reverse = 30.0 + result.strafe = 30.0 + result.rotation = 2200.0 + + checkKey(data, "handling") + if data["handling"].kind != JObject: + return + + let hand = data["handling"] + hand.getField("thrust", result.thrust) + hand.getField("top_speed", result.topSpeed) + hand.getField("reverse", result.reverse) + hand.getField("strafe", result.strafe) + hand.getField("rotation", result.rotation) +proc importAnim(data: JsonNode, errors: var seq[string]): PAnimationRecord = + new(result) + result.angle = 0.0 + result.delay = 1000.0 + result.spriteSheet = nil + + if data.hasKey("anim"): + let anim = data["anim"] + if anim.kind == JObject: + if anim.hasKey("file"): + result.spriteSheet = newSprite(anim["file"].str, errors) + + anim.getField "angle", result.angle + anim.getField "delay", result.delay + elif data["anim"].kind == JString: + result.spriteSheet = newSprite(anim.str, errors) + + result.angle = radians(result.angle) ## comes in as degrees + result.delay /= 1000 ## delay comes in as milliseconds +proc importSoul(data: JsonNode): TSoulRecord = + result.energy = 10000 + result.health = 1 + checkKey(data, "soul") + let soul = data["soul"] + soul.getField("energy", result.energy) + soul.getField("health", result.health) +proc importExplosion(data: JsonNode; errors: var seq[string]): TExplosionRecord = + checkKey(data, "explode") + let expl = data["explode"] + result.anim = importAnim(expl, errors) + result.sound = importSound(expl, errors, "sound") +proc importSound*(data: JsonNode; errors: var seq[string]; fieldName: string = ""): PSoundRecord = + if data.kind == JObject: + checkKey(data, fieldName) + result = newSound(data[fieldName].str, errors) + elif data.kind == JString: + result = newSound(data.str, errors) + +proc importVeh(data: JsonNode; errors: var seq[string]): PVehicleRecord = + new(result) + result.playable = false + if data.kind != JArray or data.len != 2 or + (data.kind == JArray and + (data[0].kind != JString or data[1].kind != JObject)): + result.name = "(broken)" + errors.add "Vehicle record is malformed" + return + var vehData = data[1] + result.name = data[0].str + result.anim = importAnim(vehdata, errors) + result.physics = importPhys(vehdata) + result.handling = importHandling(vehdata) + vehdata.getField("playable", result.playable) + if result.anim.spriteSheet.isNil and result.playable: + result.playable = false +proc importObject(data: JsonNode; errors: var seq[string]): PObjectRecord = + new(result) + if data.kind != JArray or data.len != 2: + result.name = "(broken)" + return + result.name = data[0].str + result.anim = importAnim(data[1], errors) + result.physics = importPhys(data[1]) +proc importItem(data: JsonNode; errors: var seq[string]): PItemRecord = + new(result) + if data.kind != JArray or data.len != 3: + result.name = "(broken)" + errors.add "Item record is malformed" + return + result.name = data[0].str + result.anim = importAnim(data[2], errors) + result.physics = importPhys(data[2]) + + result.cooldown = 100.0 + data[2].getField("cooldown", result.cooldown) + result.cooldown /= 1000.0 ##cooldown is stored in ms + + result.useSound = importSound(data[2], errors, "useSound") + + case data[1].str.toLowerAscii + of "projectile": + result.kind = Projectile + if data[2]["bullet"].kind == JString: + result.bullet = fetchBullet(data[2]["bullet"].str) + elif data[2]["bullet"].kind == JInt: + result.bullet = cfg.bullets[data[2]["bullet"].num.int] + elif data[2]["bullet"].kind == JObject: + result.bullet = importBullet(data[2]["bullet"], errors) + else: + errors.add "UNKNOWN BULLET TYPE for item " & result.name + of "ammo": + result.kind = Ammo + of "utility": + discard + else: + errors.add "Invalid item type \""&data[1].str&"\" for item "&result.name + +proc importBullet(data: JsonNode; errors: var seq[string]): PBulletRecord = + new(result) + result.id = -1 + + var bdata: JsonNode + if data.kind == JArray: + result.name = data[0].str + bdata = data[1] + elif data.kind == JObject: + bdata = data + else: + errors.add "Malformed bullet record" + return + + result.anim = importAnim(bdata, errors) + result.physics = importPhys(bdata) + + result.lifetime = 2000.0 + result.inheritVelocity = 1000.0 + result.baseVelocity = 30.0 + getField(bdata, "lifetime", result.lifetime) + getField(bdata, "inheritVelocity", result.inheritVelocity) + getField(bdata, "baseVelocity", result.baseVelocity) + result.lifetime /= 1000.0 ## lifetime is stored as milliseconds + result.inheritVelocity /= 1000.0 ## inherit velocity 1000 = 1.0 (100%) + result.explosion = importExplosion(bdata, errors) + result.trail = importTrail(bdata, errors) diff --git a/tests/manyloc/keineschweine/lib/sg_gui.nim b/tests/manyloc/keineschweine/lib/sg_gui.nim new file mode 100644 index 000000000..bcf415556 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/sg_gui.nim @@ -0,0 +1,281 @@ +import + sfml, sfml_colors, + input_helpers, sg_packets +from strutils import countlines + +type + PGuiContainer* = ref TGuiContainer + TGuiContainer* = object of RootObj + position: TVector2f + activeEntry: PTextEntry + widgets: seq[PGuiObject] + buttons: seq[PButton] + PGuiObject* = ref TGuiObject + TGuiObject* = object of RootObj + PButton* = ref TButton + TButton* = object of TGuiObject + enabled: bool + bg*: sfml.PRectangleShape + text*: PText + onClick*: TButtonClicked + bounds: TFloatRect + PButtonCollection* = ref TButtonCollection + TButtonCollection* = object of TGuiContainer + PTextEntry* = ref TTextEntry + TTextEntry* = object of TButton + inputClient: input_helpers.PTextInput + PMessageArea* = ref TMessageArea + TMessageArea* = object of TGuiObject + pos: TVector2f + messages: seq[TMessage] + texts: seq[PText] + scrollBack*: int + sizeVisible*: int + direction*: int + TMessage = object + color: TColor + text: string + lines: int + TButtonClicked = proc(button: PButton) +var + guiFont* = newFont("data/fnt/LiberationMono-Regular.ttf") + messageProto* = newText("", guiFont, 16) +let + vectorZeroF* = vec2f(0.0, 0.0) + +proc newGuiContainer*(): PGuiContainer +proc newGuiContainer*(pos: TVector2f): PGuiContainer {.inline.} +proc free*(container: PGuiContainer) +proc add*(container: PGuiContainer; widget: PGuiObject) +proc clearButtons*(container: PGuiContainer) +proc click*(container: PGuiContainer; position: TVector2f) +proc setActive*(container: PGuiContainer; entry: PTextEntry) +proc setPosition*(container: PGuiContainer; position: TVector2f) + +proc update*(container: PGuiContainer; dt: float) +proc draw*(window: PRenderWindow; container: PGuiContainer) {.inline.} + +proc newMessageArea*(container: PGuiContainer; position: TVector2f): PMessageArea {.discardable.} +proc add*(m: PMessageArea; msg: ScChat) + +proc draw*(window: PRenderWindow; b: PButton) {.inline.} +proc click*(b: PButton; p: TVector2f) +proc setPosition*(b: PButton; p: TVector2f) +proc setString*(b: PButton; s: string) {.inline.} + +proc newButton*(container: PGuiContainer; text: string; position: TVector2f; + onClick: TButtonClicked; startEnabled: bool = true): PButton {.discardable.} +proc init(b: PButton; text: string; position: TVector2f; onClick: TButtonClicked) +proc setEnabled*(b: PButton; enabled: bool) +proc disable*(b: PButton) {.inline.} +proc enable*(b: PButton) {.inline.} + +proc newTextEntry*(container: PGuiContainer; text: string; + position: TVector2f; onEnter: TInputFinishedProc = nil): PTextEntry {.discardable.} +proc init(t: PTextEntry; text: string; onEnter: TInputFinishedProc) +proc draw*(window: PRenderWindow, t: PTextEntry) {.inline.} +proc setActive*(t: PTextEntry) {.inline.} +proc clearText*(t: PTextEntry) {.inline.} +proc getText*(t: PTextEntry): string {.inline.} + +proc update*(m: PMessageArea) + +if guiFont == nil: + echo("Could not load font, crying softly to myself.") + quit(1) + +proc newGuiContainer*(): PGuiContainer = + new(result, free) + result.widgets = @[] + result.buttons = @[] +proc newGuiContainer*(pos: TVector2f): PGuiContainer = + result = newGuiContainer() + result.setPosition pos +proc free*(container: PGuiContainer) = + container.widgets = @[] + container.buttons = @[] +proc add*(container: PGuiContainer; widget: PGuiObject) = + container.widgets.add(widget) +proc add*(container: PGuiContainer; button: PButton) = + if container.isNil: return + container.buttons.add(button) +proc clearButtons*(container: PGuiContainer) = + container.buttons.setLen 0 +proc click*(container: PGuiContainer; position: TVector2f) = + for b in container.buttons: + click(b, position) +proc setActive*(container: PGuiContainer; entry: PTextEntry) = + container.activeEntry = entry + setActive(entry) +proc setPosition*(container: PGuiContainer; position: TVector2f) = + container.position = position + + +proc update*(container: PGuiContainer; dt: float) = + if not container.activeEntry.isNil: + container.activeEntry.setString(container.activeEntry.getText()) +proc draw*(window: PRenderWindow; container: PGuiContainer) = + for b in container.buttons: + window.draw b + +proc free(c: PButton) = + c.bg.destroy() + c.text.destroy() + c.bg = nil + c.text = nil + c.onClick = nil +proc newButton*(container: PGuiContainer; text: string; + position: TVector2f; onClick: TButtonClicked; + startEnabled: bool = true): PButton = + new(result, free) + init(result, + text, + if not container.isNil: position + container.position else: position, + onClick) + container.add result + if not startEnabled: disable(result) + +proc init(b: PButton; text: string; position: TVector2f; onClick: TButtonClicked) = + b.bg = newRectangleShape() + b.bg.setSize(vec2f(80.0, 16.0)) + b.bg.setFillColor(color(20, 30, 15)) + b.text = newText(text, guiFont, 16) + b.onClick = onClick + b.setPosition(position) + b.enabled = true +proc copy*(c: PButton): PButton = + new(result, free) + result.bg = c.bg.copy() + result.text = c.text.copy() + result.onClick = c.onClick + result.setPosition(result.bg.getPosition()) + +proc setEnabled*(b: PButton; enabled: bool) = + b.enabled = enabled + if enabled: + b.text.setColor(White) + else: + b.text.setColor(Gray) +proc enable*(b: PButton) = setEnabled(b, true) +proc disable*(b: PButton) = setEnabled(b, false) + +proc draw*(window: PRenderWindow; b: PButton) = + window.draw b.bg + window.draw b.text +proc setPosition*(b: PButton, p: TVector2f) = + b.bg.setPosition(p) + b.text.setPosition(p) + b.bounds = b.text.getGlobalBounds() +proc setString*(b: PButton; s: string) = + b.text.setString(s) +proc click*(b: PButton, p: TVector2f) = + if b.enabled and (addr b.bounds).contains(p.x, p.y): + b.onClick(b) + +proc free(obj: PTextEntry) = + free(PButton(obj)) +proc newTextEntry*(container: PGuiContainer; text: string; + position: TVector2F; onEnter: TInputFinishedProc = nil): PTextEntry = + new(result, free) + init(PButton(result), text, position + container.position, proc(b: PButton) = + setActive(container, PTextEntry(b))) + init(result, text, onEnter) + container.add result +proc init(t: PTextEntry; text: string; onEnter: TInputFinishedProc) = + t.inputClient = newTextInput(text, text.len, onEnter) +proc draw(window: PRenderWindow; t: PTextEntry) = + window.draw PButton(t) +proc clearText*(t: PTextEntry) = + t.inputClient.clear() +proc getText*(t: PTextEntry): string = + return t.inputClient.text +proc setActive*(t: PTextEntry) = + if not t.isNil and not t.inputClient.isNil: + input_helpers.setActive(t.inputClient) + +when false: + proc newMessageArea*(container: PGuiContainer; position: TVector2f): PMessageArea = + new(result) + result.messages = @[] + result.pos = position + container.add(result) + proc add*(m: PMessageArea, text: string): PText = + result = messageProto.copy() + result.setString(text) + m.messages.add(result) + let nmsgs = len(m.messages) + var pos = vec2f(m.pos.x, m.pos.y) + for i in countdown(nmsgs - 1, max(nmsgs - 30, 0)): + setPosition(m.messages[i], pos) + pos.y -= 16.0 + + proc draw*(window: PRenderWindow; m: PMessageArea) = + let nmsgs = len(m.messages) + if nmsgs == 0: return + for i in countdown(nmsgs - 1, max(nmsgs - 30, 0)): + window.draw(m.messages[i]) + +proc newMessageArea*(container: PGuiContainer; position: TVector2f): PMessageArea = + new(result) + result.messages = @[] + result.texts = @[] + result.pos = position + container.position + result.sizeVisible = 10 + result.scrollBack = 0 + result.direction = -1 ## to push old messages up + container.add(result) + +proc add*(m: PMessageArea, msg: ScChat) = + const prependName = {CPub, CPriv} + var mmm: TMessage + if msg.kind in prependName: + mmm.text = "<" + mmm.text.add msg.fromPlayer + mmm.text.add "> " + mmm.text.add msg.text + else: + mmm.text = msg.text + case msg.kind + of CPub: mmm.color = RoyalBlue + of CPriv, CSystem: mmm.color = Green + of CError: mmm.color = Red + + mmm.lines = countLines(mmm.text) + + m.messages.add mmm + update m +proc add*(m: PMessageArea, msg: string) {.inline.} = + var chat = newScChat(kind = CSystem, text = msg) + add(m, chat) + +proc proctor*(m: PText; msg: ptr TMessage; pos: ptr TVector2f) = + m.setString msg.text + m.setColor msg.color + m.setPosition pos[] +proc update*(m: PMessageArea) = + if m.texts.len < m.sizeVisible: + echo "adding ", m.sizeVisible - m.texts.len, " fields" + for i in 1..m.sizeVisible - m.texts.len: + var t = messageProto.copy() + m.texts.add messageProto.copy() + elif m.texts.len > m.sizeVisible: + echo "cutting ", m.texts.len - m.sizeVisible, " fields" + for i in m.sizeVisible ..< m.texts.len: + m.texts.pop().destroy() + let nmsgs = m.messages.len() + if m.sizeVisible == 0 or nmsgs == 0: + echo "no messages? ", m.sizeVisible, ", ", nmsgs + return + var pos = vec2f(m.pos.x, m.pos.y) + for i in 0.. min(m.sizeVisible, nmsgs)-1: + ##echo nmsgs - i - 1 - m.scrollBack + let msg = addr m.messages[nmsgs - i - 1 - m.scrollBack] + proctor(m.texts[i], msg, addr pos) + pos.y += (16 * m.direction * msg.lines).cfloat + +proc draw*(window: PRenderWindow; m: PMessageArea) = + let nmsgs = len(m.texts) + if nmsgs == 0: return + for i in countdown(nmsgs - 1, max(nmsgs - m.sizeVisible, 0)): + window.draw m.texts[i] + diff --git a/tests/manyloc/keineschweine/lib/sg_packets.nim b/tests/manyloc/keineschweine/lib/sg_packets.nim new file mode 100644 index 000000000..797a60706 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/sg_packets.nim @@ -0,0 +1,110 @@ +import ../../../../dist/checksums/src/checksums/md5 + +import genpacket_enet, nativesockets, net, enet +defPacketImports() + +type + PacketID* = char + +template idpacket(pktName, id, s2c, c2s: untyped) {.dirty.} = + let `H pktName`* {.inject.} = id + defPacket(`Sc pktName`, s2c) + defPacket(`Cs pktName`, c2s) + +forwardPacketT(uint8, int8) +forwardPacketT(uint16, int16) +forwardPacketT(Port, int16) + +idPacket(Login, 'a', + tuple[id: int32; alias: string; sessionKey: string], + tuple[alias: string, passwd: string]) + +let HZoneJoinReq* = 'j' +defPacket(CsZoneJoinReq, tuple[session: ScLogin]) + +defPacket(ScZoneRecord, tuple[ + name: string = "", desc: string = "", + ip: string = "", port: Port = 0.Port]) +idPacket(ZoneList, 'z', + tuple[network: string = "", zones: seq[ScZoneRecord]], + tuple[time: string]) + +let HPoing* = 'p' +defPacket(Poing, tuple[id: int32, time: float32]) + +type ChatType* = enum + CPub = 0'i8, CPriv, CSystem, CError +forwardPacketT(ChatType, int8) +idPacket(Chat, 'C', + tuple[kind: ChatType = CPub; fromPlayer: string = ""; text: string = ""], + tuple[target: string = ""; text: string = ""]) + +idPacket(Hello, 'h', + tuple[resp: string], + tuple[i: int8 = 14]) + +let HPlayerList* = 'P' +defPacket(ScPlayerRec, tuple[id: int32; alias: string = ""]) +defPacket(ScPlayerList, tuple[players: seq[ScPlayerRec]]) + +let HTeamList* = 'T' +defPacket(ScTeam, tuple[id: int8; name: string = ""]) +defPacket(ScTeamList, tuple[teams: seq[ScTeam]]) +let HTeamChange* = 't' + +idPacket(ZoneQuery, 'Q', + tuple[playerCount: uint16], ##i should include a time here or something + tuple[pad: char = '\0']) + +type SpawnKind = enum + SpawnDummy, + SpawnItem, SpawnVehicle, SpawnObject +forwardPacketT(SpawnKind, int8) +defPacket(ScSpawn, tuple[ + kind: SpawnKind; id: uint16; record: uint16; amount: uint16]) + + + + +type TAssetType* = enum + FDummy, + FZoneCfg, FGraphics, FSound + +forwardPacketT(TAssetType, int8) +forwardPacket(MD5Digest, array[0..15, int8]) + +idPacket(FileChallenge, 'F', + tuple[file: string; assetType: TAssetType; fullLen: int32], + tuple[needFile: bool; checksum: MD5Digest]) + + +let HChallengeResult* = '(' +defPacket(ScChallengeResult, tuple[status: bool]) + +let HFileTransfer* = 'f' +defPacket(ScFileTransfer, tuple[fileSize: int32; pos: int32; data: string]) +defPacket(CsFilepartAck, tuple[lastpos: int32]) + +##dir server messages +let HZoneLogin* = 'u' +defPacket(SdZoneLogin, tuple[name: string; key: string; record: ScZoneRecord]) +defPacket(DsZoneLogin, tuple[status: bool]) +let HDsMsg* = 'c' +defPacket(DsMsg, tuple[msg: string]) +let HVerifyClient* = 'v' +defPacket(SdVerifyClient, tuple[session: ScLogin]) + +when true: + + var buf = newBuffer(100) + var m = toMd5("hello there") + echo(repr(m)) + buf.pack m + + echo(repr(buf.data)) + echo(len(buf.data)) + + buf.reset() + + var x = buf.readMD5Digest() + echo(repr(x)) diff --git a/tests/manyloc/keineschweine/lib/sound_buffer.nim b/tests/manyloc/keineschweine/lib/sound_buffer.nim new file mode 100644 index 000000000..a88eb08de --- /dev/null +++ b/tests/manyloc/keineschweine/lib/sound_buffer.nim @@ -0,0 +1,38 @@ +when defined(NoSFML) or defined(NoChipmunk): + {.error.} +import sfml_audio, sfml_stuff, sg_assets, chipmunk +const + MinDistance* = 350.0 + Attenuation* = 20.0 +var + liveSounds: seq[PSound] = @[] + deadSounds: seq[PSound] = @[] + +proc playSound*(sound: PSoundRecord, pos: TVector) = + if sound.isNil or sound.soundBuf.isNil: return + var s: PSound + if deadSounds.len == 0: + s = sfml_audio.newSound() + s.setLoop false + s.setRelativeToListener true + s.setAttenuation Attenuation + s.setMinDistance MinDistance + else: + s = deadSounds.pop() + s.setPosition(vec3f(pos.x, 0, pos.y)) + s.setBuffer(sound.soundBuf) + s.play() + liveSounds.add s + +proc updateSoundBuffer*() = + var i = 0 + while i < len(liveSounds): + if liveSounds[i].getStatus == Stopped: + deadSounds.add liveSounds[i] + liveSounds.del i + else: + inc i + +proc report*() = + echo "live: ", liveSounds.len + echo "dead: ", deadSounds.len diff --git a/tests/manyloc/keineschweine/lib/vehicles.nim b/tests/manyloc/keineschweine/lib/vehicles.nim new file mode 100644 index 000000000..2c6e54d2b --- /dev/null +++ b/tests/manyloc/keineschweine/lib/vehicles.nim @@ -0,0 +1,35 @@ +import + sfml, chipmunk, + sg_assets, sfml_stuff#, "../keineschweine" + + +proc accel*(obj: PVehicle, dt: float) = + #obj.velocity += vec2f( + # cos(obj.angle) * obj.record.handling.thrust.float * dt, + # sin(obj.angle) * obj.record.handling.thrust.float * dt) + obj.body.applyImpulse( + vectorForAngle(obj.body.getAngle()) * dt * obj.record.handling.thrust, + VectorZero) +proc reverse*(obj: PVehicle, dt: float) = + #obj.velocity += vec2f( + # -cos(obj.angle) * obj.record.handling.reverse.float * dt, + # -sin(obj.angle) * obj.record.handling.reverse.float * dt) + obj.body.applyImpulse( + -vectorForAngle(obj.body.getAngle()) * dt * obj.record.handling.reverse, + VectorZero) +proc strafe_left*(obj: PVehicle, dt: float) = + obj.body.applyImpulse( + vectorForAngle(obj.body.getAngle()).perp() * obj.record.handling.strafe * dt, + VectorZero) +proc strafe_right*(obj: PVehicle, dt: float) = + obj.body.applyImpulse( + vectorForAngle(obj.body.getAngle()).rperp() * obj.record.handling.strafe * dt, + VectorZero) +proc turn_right*(obj: PVehicle, dt: float) = + #obj.angle = (obj.angle + (obj.record.handling.rotation.float / 10.0 * dt)) mod TAU + obj.body.setTorque(obj.record.handling.rotation) +proc turn_left*(obj: PVehicle, dt: float) = + #obj.angle = (obj.angle - (obj.record.handling.rotation.float / 10.0 * dt)) mod TAU + obj.body.setTorque(-obj.record.handling.rotation) +proc offsetAngle*(obj: PVehicle): float {.inline.} = + return (obj.record.anim.angle + obj.body.getAngle()) diff --git a/tests/manyloc/keineschweine/lib/wingl.nim b/tests/manyloc/keineschweine/lib/wingl.nim new file mode 100644 index 000000000..5bd199911 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/wingl.nim @@ -0,0 +1,368 @@ +import + gl, windows + +proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname, + importc: "wglGetExtensionsStringARB".} +const + WGL_FRONT_COLOR_BUFFER_BIT_ARB* = 0x00000001 + WGL_BACK_COLOR_BUFFER_BIT_ARB* = 0x00000002 + WGL_DEPTH_BUFFER_BIT_ARB* = 0x00000004 + WGL_STENCIL_BUFFER_BIT_ARB* = 0x00000008 + +proc WinChoosePixelFormat*(DC: HDC, p2: PPixelFormatDescriptor): int{. + dynlib: "gdi32", importc: "ChoosePixelFormat".} +proc wglCreateBufferRegionARB*(hDC: HDC, iLayerPlane: TGLint, uType: TGLuint): THandle{. + dynlib: dllname, importc: "wglCreateBufferRegionARB".} +proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname, + importc: "wglDeleteBufferRegionARB".} +proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, + width: TGLint, height: TGLint): BOOL{. + dynlib: dllname, importc: "wglSaveBufferRegionARB".} +proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, + width: TGLint, height: TGLint, xSrc: TGLint, + ySrc: TGLint): BOOL{.dynlib: dllname, + importc: "wglRestoreBufferRegionARB".} +proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat, + writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{. + dynlib: dllname, importc: "wglAllocateMemoryNV".} +proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname, + importc: "wglFreeMemoryNV".} +const + WGL_IMAGE_BUFFER_MIN_ACCESS_I3D* = 0x00000001 + WGL_IMAGE_BUFFER_LOCK_I3D* = 0x00000002 + +proc wglCreateImageBufferI3D*(hDC: HDC, dwSize: DWORD, uFlags: UINT): PGLvoid{. + dynlib: dllname, importc: "wglCreateImageBufferI3D".} +proc wglDestroyImageBufferI3D*(hDC: HDC, pAddress: PGLvoid): BOOL{. + dynlib: dllname, importc: "wglDestroyImageBufferI3D".} +proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle, + pAddress: PGLvoid, pSize: PDWORD, + count: UINT): BOOL{.dynlib: dllname, + importc: "wglAssociateImageBufferEventsI3D".} +proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{. + dynlib: dllname, importc: "wglReleaseImageBufferEventsI3D".} +proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname, + importc: "wglEnableFrameLockI3D".} +proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname, + importc: "wglDisableFrameLockI3D".} +proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, + importc: "wglIsEnabledFrameLockI3D".} +proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, + importc: "wglQueryFrameLockMasterI3D".} +proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname, + importc: "wglGetFrameUsageI3D".} +proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname, + importc: "wglBeginFrameTrackingI3D".} +proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname, + importc: "wglEndFrameTrackingI3D".} +proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD, + pLastMissedUsage: PGLfloat): BOOL{. + dynlib: dllname, importc: "wglQueryFrameTrackingI3D".} +const + WGL_NUMBER_PIXEL_FORMATS_ARB* = 0x00002000 + WGL_DRAW_TO_WINDOW_ARB* = 0x00002001 + WGL_DRAW_TO_BITMAP_ARB* = 0x00002002 + WGL_ACCELERATION_ARB* = 0x00002003 + WGL_NEED_PALETTE_ARB* = 0x00002004 + WGL_NEED_SYSTEM_PALETTE_ARB* = 0x00002005 + WGL_SWAP_LAYER_BUFFERS_ARB* = 0x00002006 + WGL_SWAP_METHOD_ARB* = 0x00002007 + WGL_NUMBER_OVERLAYS_ARB* = 0x00002008 + WGL_NUMBER_UNDERLAYS_ARB* = 0x00002009 + WGL_TRANSPARENT_ARB* = 0x0000200A + WGL_TRANSPARENT_RED_VALUE_ARB* = 0x00002037 + WGL_TRANSPARENT_GREEN_VALUE_ARB* = 0x00002038 + WGL_TRANSPARENT_BLUE_VALUE_ARB* = 0x00002039 + WGL_TRANSPARENT_ALPHA_VALUE_ARB* = 0x0000203A + WGL_TRANSPARENT_INDEX_VALUE_ARB* = 0x0000203B + WGL_SHARE_DEPTH_ARB* = 0x0000200C + WGL_SHARE_STENCIL_ARB* = 0x0000200D + WGL_SHARE_ACCUM_ARB* = 0x0000200E + WGL_SUPPORT_GDI_ARB* = 0x0000200F + WGL_SUPPORT_OPENGL_ARB* = 0x00002010 + WGL_DOUBLE_BUFFER_ARB* = 0x00002011 + WGL_STEREO_ARB* = 0x00002012 + WGL_PIXEL_TYPE_ARB* = 0x00002013 + WGL_COLOR_BITS_ARB* = 0x00002014 + WGL_RED_BITS_ARB* = 0x00002015 + WGL_RED_SHIFT_ARB* = 0x00002016 + WGL_GREEN_BITS_ARB* = 0x00002017 + WGL_GREEN_SHIFT_ARB* = 0x00002018 + WGL_BLUE_BITS_ARB* = 0x00002019 + WGL_BLUE_SHIFT_ARB* = 0x0000201A + WGL_ALPHA_BITS_ARB* = 0x0000201B + WGL_ALPHA_SHIFT_ARB* = 0x0000201C + WGL_ACCUM_BITS_ARB* = 0x0000201D + WGL_ACCUM_RED_BITS_ARB* = 0x0000201E + WGL_ACCUM_GREEN_BITS_ARB* = 0x0000201F + WGL_ACCUM_BLUE_BITS_ARB* = 0x00002020 + WGL_ACCUM_ALPHA_BITS_ARB* = 0x00002021 + WGL_DEPTH_BITS_ARB* = 0x00002022 + WGL_STENCIL_BITS_ARB* = 0x00002023 + WGL_AUX_BUFFERS_ARB* = 0x00002024 + WGL_NO_ACCELERATION_ARB* = 0x00002025 + WGL_GENERIC_ACCELERATION_ARB* = 0x00002026 + WGL_FULL_ACCELERATION_ARB* = 0x00002027 + WGL_SWAP_EXCHANGE_ARB* = 0x00002028 + WGL_SWAP_COPY_ARB* = 0x00002029 + WGL_SWAP_UNDEFINED_ARB* = 0x0000202A + WGL_TYPE_RGBA_ARB* = 0x0000202B + WGL_TYPE_COLORINDEX_ARB* = 0x0000202C + +proc wglGetPixelFormatAttribivARB*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, + piAttributes: PGLint, piValues: PGLint): BOOL{. + dynlib: dllname, importc: "wglGetPixelFormatAttribivARB".} +proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, + piAttributes: PGLint, pfValues: PGLfloat): BOOL{. + dynlib: dllname, importc: "wglGetPixelFormatAttribfvARB".} +proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint, + pfAttribFList: PGLfloat, nMaxFormats: TGLuint, + piFormats: PGLint, nNumFormats: PGLuint): BOOL{. + dynlib: dllname, importc: "wglChoosePixelFormatARB".} +const + WGL_ERROR_INVALID_PIXEL_TYPE_ARB* = 0x00002043 + WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB* = 0x00002054 + +proc wglMakeContextCurrentARB*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{. + dynlib: dllname, importc: "wglMakeContextCurrentARB".} +proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname, + importc: "wglGetCurrentReadDCARB".} +const + WGL_DRAW_TO_PBUFFER_ARB* = 0x0000202D # WGL_DRAW_TO_PBUFFER_ARB { already defined } + WGL_MAX_PBUFFER_PIXELS_ARB* = 0x0000202E + WGL_MAX_PBUFFER_WIDTH_ARB* = 0x0000202F + WGL_MAX_PBUFFER_HEIGHT_ARB* = 0x00002030 + WGL_PBUFFER_LARGEST_ARB* = 0x00002033 + WGL_PBUFFER_WIDTH_ARB* = 0x00002034 + WGL_PBUFFER_HEIGHT_ARB* = 0x00002035 + WGL_PBUFFER_LOST_ARB* = 0x00002036 + +proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, + iHeight: TGLint, piAttribList: PGLint): THandle{. + dynlib: dllname, importc: "wglCreatePbufferARB".} +proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname, + importc: "wglGetPbufferDCARB".} +proc wglReleasePbufferDCARB*(hPbuffer: THandle, hDC: HDC): TGLint{. + dynlib: dllname, importc: "wglReleasePbufferDCARB".} +proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname, + importc: "wglDestroyPbufferARB".} +proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{. + dynlib: dllname, importc: "wglQueryPbufferARB".} +proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname, + importc: "wglSwapIntervalEXT".} +proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname, + importc: "wglGetSwapIntervalEXT".} +const + WGL_BIND_TO_TEXTURE_RGB_ARB* = 0x00002070 + WGL_BIND_TO_TEXTURE_RGBA_ARB* = 0x00002071 + WGL_TEXTURE_FORMAT_ARB* = 0x00002072 + WGL_TEXTURE_TARGET_ARB* = 0x00002073 + WGL_MIPMAP_TEXTURE_ARB* = 0x00002074 + WGL_TEXTURE_RGB_ARB* = 0x00002075 + WGL_TEXTURE_RGBA_ARB* = 0x00002076 + WGL_NO_TEXTURE_ARB* = 0x00002077 + WGL_TEXTURE_CUBE_MAP_ARB* = 0x00002078 + WGL_TEXTURE_1D_ARB* = 0x00002079 + WGL_TEXTURE_2D_ARB* = 0x0000207A # WGL_NO_TEXTURE_ARB { already defined } + WGL_MIPMAP_LEVEL_ARB* = 0x0000207B + WGL_CUBE_MAP_FACE_ARB* = 0x0000207C + WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB* = 0x0000207D + WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB* = 0x0000207E + WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB* = 0x0000207F + WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB* = 0x00002080 + WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB* = 0x00002081 + WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB* = 0x00002082 + WGL_FRONT_LEFT_ARB* = 0x00002083 + WGL_FRONT_RIGHT_ARB* = 0x00002084 + WGL_BACK_LEFT_ARB* = 0x00002085 + WGL_BACK_RIGHT_ARB* = 0x00002086 + WGL_AUX0_ARB* = 0x00002087 + WGL_AUX1_ARB* = 0x00002088 + WGL_AUX2_ARB* = 0x00002089 + WGL_AUX3_ARB* = 0x0000208A + WGL_AUX4_ARB* = 0x0000208B + WGL_AUX5_ARB* = 0x0000208C + WGL_AUX6_ARB* = 0x0000208D + WGL_AUX7_ARB* = 0x0000208E + WGL_AUX8_ARB* = 0x0000208F + WGL_AUX9_ARB* = 0x00002090 + +proc wglBindTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{. + dynlib: dllname, importc: "wglBindTexImageARB".} +proc wglReleaseTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{. + dynlib: dllname, importc: "wglReleaseTexImageARB".} +proc wglSetPbufferAttribARB*(hPbuffer: THandle, piAttribList: PGLint): BOOL{. + dynlib: dllname, importc: "wglSetPbufferAttribARB".} +proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname, + importc: "wglGetExtensionsStringEXT".} +proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{. + dynlib: dllname, importc: "wglMakeContextCurrentEXT".} +proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname, + importc: "wglGetCurrentReadDCEXT".} +const + WGL_DRAW_TO_PBUFFER_EXT* = 0x0000202D + WGL_MAX_PBUFFER_PIXELS_EXT* = 0x0000202E + WGL_MAX_PBUFFER_WIDTH_EXT* = 0x0000202F + WGL_MAX_PBUFFER_HEIGHT_EXT* = 0x00002030 + WGL_OPTIMAL_PBUFFER_WIDTH_EXT* = 0x00002031 + WGL_OPTIMAL_PBUFFER_HEIGHT_EXT* = 0x00002032 + WGL_PBUFFER_LARGEST_EXT* = 0x00002033 + WGL_PBUFFER_WIDTH_EXT* = 0x00002034 + WGL_PBUFFER_HEIGHT_EXT* = 0x00002035 + +proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, + iHeight: TGLint, piAttribList: PGLint): THandle{. + dynlib: dllname, importc: "wglCreatePbufferEXT".} +proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname, + importc: "wglGetPbufferDCEXT".} +proc wglReleasePbufferDCEXT*(hPbuffer: THandle, hDC: HDC): TGLint{. + dynlib: dllname, importc: "wglReleasePbufferDCEXT".} +proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname, + importc: "wglDestroyPbufferEXT".} +proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{. + dynlib: dllname, importc: "wglQueryPbufferEXT".} +const + WGL_NUMBER_PIXEL_FORMATS_EXT* = 0x00002000 + WGL_DRAW_TO_WINDOW_EXT* = 0x00002001 + WGL_DRAW_TO_BITMAP_EXT* = 0x00002002 + WGL_ACCELERATION_EXT* = 0x00002003 + WGL_NEED_PALETTE_EXT* = 0x00002004 + WGL_NEED_SYSTEM_PALETTE_EXT* = 0x00002005 + WGL_SWAP_LAYER_BUFFERS_EXT* = 0x00002006 + WGL_SWAP_METHOD_EXT* = 0x00002007 + WGL_NUMBER_OVERLAYS_EXT* = 0x00002008 + WGL_NUMBER_UNDERLAYS_EXT* = 0x00002009 + WGL_TRANSPARENT_EXT* = 0x0000200A + WGL_TRANSPARENT_VALUE_EXT* = 0x0000200B + WGL_SHARE_DEPTH_EXT* = 0x0000200C + WGL_SHARE_STENCIL_EXT* = 0x0000200D + WGL_SHARE_ACCUM_EXT* = 0x0000200E + WGL_SUPPORT_GDI_EXT* = 0x0000200F + WGL_SUPPORT_OPENGL_EXT* = 0x00002010 + WGL_DOUBLE_BUFFER_EXT* = 0x00002011 + WGL_STEREO_EXT* = 0x00002012 + WGL_PIXEL_TYPE_EXT* = 0x00002013 + WGL_COLOR_BITS_EXT* = 0x00002014 + WGL_RED_BITS_EXT* = 0x00002015 + WGL_RED_SHIFT_EXT* = 0x00002016 + WGL_GREEN_BITS_EXT* = 0x00002017 + WGL_GREEN_SHIFT_EXT* = 0x00002018 + WGL_BLUE_BITS_EXT* = 0x00002019 + WGL_BLUE_SHIFT_EXT* = 0x0000201A + WGL_ALPHA_BITS_EXT* = 0x0000201B + WGL_ALPHA_SHIFT_EXT* = 0x0000201C + WGL_ACCUM_BITS_EXT* = 0x0000201D + WGL_ACCUM_RED_BITS_EXT* = 0x0000201E + WGL_ACCUM_GREEN_BITS_EXT* = 0x0000201F + WGL_ACCUM_BLUE_BITS_EXT* = 0x00002020 + WGL_ACCUM_ALPHA_BITS_EXT* = 0x00002021 + WGL_DEPTH_BITS_EXT* = 0x00002022 + WGL_STENCIL_BITS_EXT* = 0x00002023 + WGL_AUX_BUFFERS_EXT* = 0x00002024 + WGL_NO_ACCELERATION_EXT* = 0x00002025 + WGL_GENERIC_ACCELERATION_EXT* = 0x00002026 + WGL_FULL_ACCELERATION_EXT* = 0x00002027 + WGL_SWAP_EXCHANGE_EXT* = 0x00002028 + WGL_SWAP_COPY_EXT* = 0x00002029 + WGL_SWAP_UNDEFINED_EXT* = 0x0000202A + WGL_TYPE_RGBA_EXT* = 0x0000202B + WGL_TYPE_COLORINDEX_EXT* = 0x0000202C + +proc wglGetPixelFormatAttribivEXT*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, + piAttributes: PGLint, piValues: PGLint): BOOL{. + dynlib: dllname, importc: "wglGetPixelFormatAttribivEXT".} +proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, + piAttributes: PGLint, pfValues: PGLfloat): BOOL{. + dynlib: dllname, importc: "wglGetPixelFormatAttribfvEXT".} +proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint, + pfAttribFList: PGLfloat, nMaxFormats: TGLuint, + piFormats: PGLint, nNumFormats: PGLuint): BOOL{. + dynlib: dllname, importc: "wglChoosePixelFormatEXT".} +const + WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D* = 0x00002050 + WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D* = 0x00002051 + WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D* = 0x00002052 + WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D* = 0x00002053 + +proc wglGetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, + importc: "wglGetDigitalVideoParametersI3D".} +proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, + importc: "wglSetDigitalVideoParametersI3D".} +const + WGL_GAMMA_TABLE_SIZE_I3D* = 0x0000204E + WGL_GAMMA_EXCLUDE_DESKTOP_I3D* = 0x0000204F + +proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, + importc: "wglGetGammaTableParametersI3D".} +proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, + importc: "wglSetGammaTableParametersI3D".} +proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, + puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{. + dynlib: dllname, importc: "wglGetGammaTableI3D".} +proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, + puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{. + dynlib: dllname, importc: "wglSetGammaTableI3D".} +const + WGL_GENLOCK_SOURCE_MULTIVIEW_I3D* = 0x00002044 + WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D* = 0x00002045 + WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D* = 0x00002046 + WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D* = 0x00002047 + WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D* = 0x00002048 + WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D* = 0x00002049 + WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D* = 0x0000204A + WGL_GENLOCK_SOURCE_EDGE_RISING_I3D* = 0x0000204B + WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D* = 0x0000204C + WGL_FLOAT_COMPONENTS_NV* = 0x000020B0 + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV* = 0x000020B1 + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV* = 0x000020B2 + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV* = 0x000020B3 + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV* = 0x000020B4 + WGL_TEXTURE_FLOAT_R_NV* = 0x000020B5 + WGL_TEXTURE_FLOAT_RG_NV* = 0x000020B6 + WGL_TEXTURE_FLOAT_RGB_NV* = 0x000020B7 + WGL_TEXTURE_FLOAT_RGBA_NV* = 0x000020B8 + +proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, + importc: "wglEnableGenlockI3D".} +proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, + importc: "wglDisableGenlockI3D".} +proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname, + importc: "wglIsEnabledGenlockI3D".} +proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname, + importc: "wglGenlockSourceI3D".} +proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname, + importc: "wglGetGenlockSourceI3D".} +proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname, + importc: "wglGenlockSourceEdgeI3D".} +proc wglGetGenlockSourceEdgeI3D*(hDC: HDC, uEdge: PGLUINT): BOOL{. + dynlib: dllname, importc: "wglGetGenlockSourceEdgeI3D".} +proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname, + importc: "wglGenlockSampleRateI3D".} +proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{. + dynlib: dllname, importc: "wglGetGenlockSampleRateI3D".} +proc wglGenlockSourceDelayI3D*(hDC: HDC, uDelay: TGLuint): BOOL{. + dynlib: dllname, importc: "wglGenlockSourceDelayI3D".} +proc wglGetGenlockSourceDelayI3D*(hDC: HDC, uDelay: PGLUINT): BOOL{. + dynlib: dllname, importc: "wglGetGenlockSourceDelayI3D".} +proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT, + uMaxPixelDelay: PGLUINT): BOOL{. + dynlib: dllname, importc: "wglQueryGenlockMaxSourceDelayI3D".} +const + WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV* = 0x000020A0 + WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV* = 0x000020A1 + WGL_TEXTURE_RECTANGLE_NV* = 0x000020A2 + +const + WGL_RGBA_FLOAT_MODE_ATI* = 0x00008820 + WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI* = 0x00008835 + WGL_TYPE_RGBA_FLOAT_ATI* = 0x000021A0 + +# implementation diff --git a/tests/manyloc/keineschweine/lib/zlib_helpers.nim b/tests/manyloc/keineschweine/lib/zlib_helpers.nim new file mode 100644 index 000000000..e51c000c8 --- /dev/null +++ b/tests/manyloc/keineschweine/lib/zlib_helpers.nim @@ -0,0 +1,45 @@ +# xxx this test is bad (echo instead of error, etc) + +import zip/zlib + +proc compress*(source: string): string = + var + sourcelen = source.len + destLen = sourcelen + (sourcelen.float * 0.1).int + 16 + result = "" + result.setLen destLen + # see http://www.zlib.net/zlib-1.2.11.tar.gz for correct definitions + var destLen2 = destLen.Ulongf + var res = zlib.compress(cstring(result), addr destLen2, cstring(source), sourceLen.Ulong) + if res != Z_OK: + echo "Error occurred: ", res + elif destLen2.int < result.len: + result.setLen(destLen2.int) + +proc uncompress*(source: string, destLen: var int): string = + result = "" + result.setLen destLen + var destLen2 = destLen.Ulongf + var res = zlib.uncompress(cstring(result), addr destLen2, cstring(source), source.len.Ulong) + if res != Z_OK: + echo "Error occurred: ", res + + +when true: + import strutils + var r = compress("Hello") + echo repr(r) + var ln = "Hello".len + var rr = uncompress(r, ln) + echo repr(rr) + assert rr == "Hello" + + proc `*`(a: string; b: int): string {.inline.} = result = repeat(a, b) + var s = "yo dude sup bruh homie" * 50 + r = compress(s) + echo s.len, " -> ", r.len + + ln = s.len + rr = uncompress(r, ln) + echo r.len, " -> ", rr.len + assert rr == s diff --git a/tests/manyloc/keineschweine/server/dirserver_settings.json b/tests/manyloc/keineschweine/server/dirserver_settings.json new file mode 100644 index 000000000..18c15fb46 --- /dev/null +++ b/tests/manyloc/keineschweine/server/dirserver_settings.json @@ -0,0 +1,7 @@ +{ + "network":"lamenet", + "port":2049, + "zones":[ + {"name":"alphazone","key":"skittles"} + ] +} \ No newline at end of file diff --git a/tests/manyloc/keineschweine/server/nim.cfg b/tests/manyloc/keineschweine/server/nim.cfg new file mode 100644 index 000000000..211ad3003 --- /dev/null +++ b/tests/manyloc/keineschweine/server/nim.cfg @@ -0,0 +1,5 @@ +debugger = off +path = ".." +path = "../genpacket" +path = "../helpers" +define = NoSFML diff --git a/tests/manyloc/keineschweine/server/old_dirserver.nim b/tests/manyloc/keineschweine/server/old_dirserver.nim new file mode 100644 index 000000000..a63829691 --- /dev/null +++ b/tests/manyloc/keineschweine/server/old_dirserver.nim @@ -0,0 +1,201 @@ +## directory server +## handles client authorization and assets +import ../../../dist/checksums/src/checksums/md5 +import + sockets, times, streams, streams_enh, tables, json, os, + sg_packets, sg_assets, server_utils, map_filter +type + THandler = proc(client: PCLient; stream: PStream) +var + server: TSocket + handlers = initTable[char, THandler](16) + thisZone = newScZoneRecord("local", "sup") + zoneList = newScZoneList() + thisZoneSettings: string + zoneSlots: seq[tuple[name: string; key: string]] = @[] + zones: seq[PClient] = @[] + ## I was high. + clients = initTable[TupAddress, PClient](16) + alias2client = initTable[string, PClient](32) + allClients: seq[PClient] = @[] + +proc findClient*(host: string; port: int16): PClient = + let addy: TupAddress = (host, port) + if clients.hasKey(addy): + return clients[addy] + result = newClient(addy) + clients[addy] = result + allClients.add(result) + +proc loginZone(client: PClient; login: SdZoneLogin): bool = + if not client.auth: + for s in zoneSlots.items: + if s.name == login.name and s.key == login.key: + client.auth = true + client.kind = CServer + client.record = login.record + result = true + break + +proc sendZoneList(client: PClient) = + echo(">> zonelist ", client, ' ', HZoneList) + client.send(HZonelist, zonelist) +proc forwardPrivate(rcv: PClient; sender: PClient; txt: string) = + var m = newScChat(CPriv, sender.alias, txt) + rcv.send(HChat, m) +proc sendChat(client: PClient; kind: ChatType; txt: string) = + echo(">> chat ", client) + var m = newScChat(kind, "", txt) + client.send(HChat, m) + + + +var pubChatQueue = newIncomingBuffer() +proc queuePub(sender: string, msg: CsChat) = + var chat = newScChat(kind = CPub, fromPlayer = sender, text = msg.text) + pubChatQueue.write(HChat) + chat.pack(pubChatQueue) + +handlers[HHello] = (proc(client: PClient; stream: PStream) = + var h = readCsHello(stream) + if h.i == 14: + var greet = newScHello("Well hello there") + client.send(HHello, greet)) +handlers[HLogin] = proc(client: PClient; stream: PStream) = + var loginInfo = readCsLogin(stream) + echo("** login: alias = ", loginInfo.alias) + if alias2client.hasKey(loginInfo.alias): + client.sendError("Alias in use.") + return + if client.loginPlayer(loginInfo): + alias2client[client.alias] = client + client.sendMessage("Welcome "& client.alias) + var session = newScLogin(client.id, client.alias, client.session) + client.send HLogin, session + client.sendZonelist() + +handlers[HZoneList] = proc(client: PClient; stream: PStream) = + var pinfo = readCsZoneList(stream) + echo("** zonelist req") + sendZoneList client +handlers[HChat] = proc(client: PClient; stream: PStream) = + var chat = readCsChat(stream) + if not client.auth: + client.sendError("You are not logged in.") + return + if chat.target != "": ##private + if alias2client.hasKey(chat.target): + alias2client[chat.target].forwardPrivate(client, chat.text) + else: + queuePub(client.alias, chat) + +proc sendServMsg(client: PClient; msg: string) = + var m = newDsMsg(msg) + client.send HDsMsg, m +handlers[HZoneLogin] = proc(client: PClient; stream: PStream) = + var + login = readSdZoneLogin(stream) + if not client.loginZone(login): + client.sendServMsg "Invalid login" + else: + client.sendServMsg "Welcome to the servers" + echo "** Zone logged in: ", login + zones.add client + zonelist.zones.add client.record + + +handlers[HFileChallenge] = proc(client: PClient; stream: PStream) = + if client.auth: + if client.kind == CServer: + var chg = readScFileChallenge(stream) + +proc handlePkt(s: PClient; stream: PStream) = + while not stream.atEnd: + var typ = readChar(stream) + if not handlers.hasKey(typ): + break + else: + handlers[typ](s, stream) + +proc createServer(port: TPort) = + if not server.isNil: + server.close() + server = socket(typ = SOCK_DGRAM, protocol = IPPROTO_UDP, buffered = false) + server.bindAddr(port) + + +var clientIndex = 0 +var incoming = newIncomingBuffer() +proc poll*(timeout: int = 250) = + if server.isNil: return + var + reads = @[server] + writes = @[server] + if select(reads, timeout) > 0: + var + addy = "" + port: TPort + incoming.data.setLen 512 + let res = server.recvFromAsync(incoming.data, 512, addy, port, 0) + if not res: + echo("No recv") + return + else: + var client = findClient(addy, port.int16) + echo "<< ", res, " ", client, ": ", len(incoming.data), " ", repr(incoming.data) + handlePkt(client, incoming) + incoming.flush() + if selectWrite(writes, timeout) > 0: + let nclients = allClients.len + if nclients == 0: + return + clientIndex = (clientIndex + 1) mod nclients + var c = allClients[clientIndex] + if c.outputBuf.getPosition > 0: + let res = server.sendTo(c.addy.host, c.addy.port.TPort, c.outputBuf.data) + echo("Write ", c, " result: ", res, " data: ", repr(c.outputBuf.data)) + c.outputBuf.flush() + +when true: + import parseopt, strutils + var cfgFile = "dirserver_settings.json" + for kind, key, val in getopt(): + case kind + of cmdShortOption, cmdLongOption: + case key + of "f", "file": + if fileExists(val): + cfgFile = val + else: + echo("File does not exist: ", val) + else: + echo("Unknown option: ", key," ", val) + else: + echo("Unknown option: ", key, " ", val) + var jsonSettings = parseFile(cfgFile) + let port = TPort(jsonSettings["port"].num) + zonelist.network = jsonSettings["network"].str + for slot in jsonSettings["zones"].items: + zoneSlots.add((slot["name"].str, slot["key"].str)) + + createServer(port) + echo("Listening on port ", port, "...") + var pubChatTimer = cpuTime() #newClock() + const PubChatDelay = 1000/1000 + while true: + poll(15) + ## TODO sort this type of thing VV into a queue api + if cpuTime() - pubChatTimer > PubChatDelay: #.getElapsedTime.asMilliseconds > 100: + pubChatTimer -= pubChatDelay + if pubChatQueue.getPosition > 0: + var cn = 0 + let sizePubChat = pubChatQueue.data.len + var sent = 0 + filterIt2(allClients, it.auth == true and it.kind == CPlayer): + it.outputBuf.writeData(addr pubChatQueue.data[0], sizePubChat) + sent += 1 + #for c in allClients: + # c.outputBuf.writeData(addr pubChatQueue.data[0], sizePubChat) + pubChatQueue.flush() + echo "pubChatQueue flushed to ", sent, "clients" + diff --git a/tests/manyloc/keineschweine/server/old_server_utils.nim b/tests/manyloc/keineschweine/server/old_server_utils.nim new file mode 100644 index 000000000..f389c0836 --- /dev/null +++ b/tests/manyloc/keineschweine/server/old_server_utils.nim @@ -0,0 +1,100 @@ +import ../../../dist/checksums/src/checksums/md5 + +import + streams, sockets, + sg_packets, zlib_helpers, idgen +type + TClientType* = enum + CServer = 0'i8, CPlayer, CUnknown + PClient* = ref TClient + TClient* = object of TObject + id*: int32 + addy*: TupAddress + clientID*: uint16 + auth*: bool + outputBuf*: PStringStream + case kind*: TClientType + of CPlayer: + alias*: string + session*: string + lastPing*: float + failedPings*: int + of CServer: + record*: ScZoneRecord + cfg*: TChecksumFile + of CUnknown: nil + TChecksumFile* = object + unpackedSize*: int + sum*: MD5Digest + compressed*: string + TupAddress* = tuple[host: string, port: int16] + PIDGen*[T: Ordinal] = ref TIDGen[T] + TIDGen[T: Ordinal] = object + max: T + freeIDs: seq[T] +var cliID = newIdGen[int32]() + +proc sendMessage*(client: PClient; txt: string) +proc sendError*(client: PClient; txt: string) +proc `$`*(client: PClient): string + +proc newIncomingBuffer*(size = 1024): PStringStream = + result = newStringStream("") + result.data.setLen size + result.data.setLen 0 + result.flushImpl = proc(stream: PStream) = + stream.setPosition(0) + PStringStream(stream).data.setLen(0) + + +proc free*(c: PClient) = + echo "Client freed: ", c + cliID.del c.id + c.outputBuf.flush() + c.outputBuf = nil +proc newClient*(addy: TupAddress): PClient = + new(result, free) + result.addy = addy + result.outputBuf = newStringStream("") + result.outputBuf.flushImpl = proc(stream: PStream) = + stream.setPosition 0 + PStringStream(stream).data.setLen 0 + +proc loginPlayer*(client: PClient; login: CsLogin): bool = + if client.auth: + client.sendError("You are already logged in.") + return + client.id = cliID.next() + client.auth = true + client.kind = CPlayer + client.alias = login.alias + client.session = getMD5(client.alias & $rand(10000)) + result = true + +proc `$`*(client: PClient): string = + if not client.auth: return $client.addy + case client.kind + of CPlayer: result = client.alias + of CServer: result = client.record.name + else: result = $client.addy +proc send*[T](client: PClient; pktType: char; pkt: var T) = + client.outputBuf.write(pktType) + pkt.pack(client.outputBuf) + +proc sendMessage*(client: PClient; txt: string) = + var m = newScChat(CSystem, text = txt) + client.send HChat, m +proc sendError*(client: PClient; txt: string) = + var m = newScChat(CError, text = txt) + client.send HChat, m + +proc checksumFile*(filename: string): TChecksumFile = + let fullText = readFile(filename) + result.unpackedSize = fullText.len + result.sum = toMD5(fullText) + result.compressed = compress(fullText) +proc checksumStr*(str: string): TChecksumFile = + result.unpackedSize = str.len + result.sum = toMD5(str) + result.compressed = compress(str) + diff --git a/tests/manyloc/keineschweine/server/old_sg_server.nim b/tests/manyloc/keineschweine/server/old_sg_server.nim new file mode 100644 index 000000000..d6fbbe99e --- /dev/null +++ b/tests/manyloc/keineschweine/server/old_sg_server.nim @@ -0,0 +1,254 @@ +import + sockets, times, streams, streams_enh, tables, json, os, + sg_packets, sg_assets, md5, server_utils, client_helpers +var + dirServer: PServer + thisZone = newScZoneRecord("local", "sup") + thisZoneSettings: PZoneSettings + dirServerConnected = false + ## I was high. + clients = initTable[TupAddress, PClient](16) + alias2client = initTable[string, PClient](32) + allClients: seq[PClient] = @[] + zonePlayers: seq[PClient] = @[] +const + PubChatDelay = 100/1000 #100 ms + +import hashes +proc hash*(x: uint16): THash {.inline.} = + result = int32(x) + +proc findClient*(host: string; port: int16): PClient = + let addy: TupAddress = (host, port) + if clients.hasKey(addy): + return clients[addy] + result = newClient(addy) + clients[addy] = result + allClients.add(result) + + +proc sendZoneList(client: PClient) = + echo(">> zonelist ", client) + #client.send(HZonelist, zonelist) + +proc forwardPrivate(rcv: PClient; sender: PClient; txt: string) = + var m = newScChat(CPriv, sender.alias, txt) + rcv.send(HChat, m) +proc sendChat(client: PClient; kind: ChatType; txt: string) = + echo(">> chat ", client) + var m = newScChat(kind, "", txt) + client.send(HChat, m) + +var pubChatQueue = newStringStream("") +pubChatQueue.flushImpl = proc(stream: PStream) = + stream.setPosition(0) + PStringStream(stream).data.setLen(0) +proc queuePub(sender: string, msg: CsChat) = + var chat = newScChat(kind = CPub, fromPlayer = sender, text = msg.text) + pubChatQueue.write(HChat) + chat.pack(pubChatQueue) + +handlers[HHello] = (proc(client: PClient; stream: PStream) = + var h = readCsHello(stream) + if h.i == 14: + var greet = newScHello("Well hello there") + client.send(HHello, greet)) +handlers[HLogin] = proc(client: PClient; stream: PStream) = + var loginInfo = readCsLogin(stream) + echo("** login: alias = ", loginInfo.alias) + if not dirServerConnected and client.loginPlayer(loginInfo): + client.sendMessage("Welcome "& client.alias) + alias2client[client.alias] = client + client.sendZonelist() +handlers[HZoneList] = proc(client: PClient; stream: PStream) = + var pinfo = readCsZoneList(stream) + echo("** zonelist req") +handlers[HChat] = proc(client: PClient; stream: PStream) = + var chat = readCsChat(stream) + if not client.auth: + client.sendError("You are not logged in.") + return + if chat.target != "": ##private + if alias2client.hasKey(chat.target): + alias2client[chat.target].forwardPrivate(client, chat.text) + else: + queuePub(client.alias, chat) +handlers[HZoneQuery] = proc(client: PClient; stream: PStream) = + echo("Got zone query") + var q = readCsZoneQuery(stream) + var resp = newScZoneQuery(zonePlayers.len.uint16) + client.send(HZoneQuery, resp) + + + +handlers[HZoneJoinReq] = proc(client: PClient; stream: PStream) = + var req = readCsZoneJoinReq(stream) + echo "Join zone request from (",req.session.id,") ", req.session.alias + if client.auth and client.kind == CPlayer: + echo "Client is authenticated, verifying filez" + client.startVerifyingFiles() + elif dirServerConnected: + echo "Dirserver is connected, verifying client" + dirServer.send HVerifyClient, req.session + else: + echo "Dirserver is disconnected =(" + client.startVerifyingFiles() + + + +proc handlePkt(s: PClient; stream: PStream) = + while not stream.atEnd: + var typ = readChar(stream) + if not handlers.hasKey(typ): + break + else: + handlers[typ](s, stream) + +proc createServer(port: TPort) = + if not server.isNil: + server.close() + server = socket(typ = SOCK_DGRAM, protocol = IPPROTO_UDP, buffered = false) + server.bindAddr(port) + +var clientIndex = 0 +var incoming = newIncomingBuffer() +proc poll*(timeout: int = 250) = + if server.isNil: return + var + reads = @[server] + writes = @[server] + if select(reads, timeout) > 0: + var + addy = "" + port: TPort + let res = server.recvFromAsync(incoming.data, 512, addy, port, 0) + if not res: + echo("No recv") + return + else: + var client = findClient(addy, port.int16) + #echo("<< ", res, " ", client.alias, ": ", len(line.data), " ", repr(line.data)) + handlePkt(client, incoming) + incoming.flush() + if selectWrite(writes, timeout) > 0: + let nclients = allClients.len + if nclients == 0: + return + clientIndex = (clientIndex + 1) mod nclients + var c = allClients[clientIndex] + if c.outputBuf.getPosition > 0: + let res = server.sendTo(c.addy.host, c.addy.port.TPort, c.outputBuf.data) + echo("Write ", c, " result: ", res, " data: ", c.outputBuf.data) + c.outputBuf.flush() + +when true: + import parseopt, strutils + var zoneCfgFile = "./server_settings.json" + for kind, key, val in getopt(): + case kind + of cmdShortOption, cmdLongOption: + case key + of "f", "file": + if fileExists(val): + zoneCfgFile = val + else: + echo("File does not exist: ", val) + else: + echo("Unknown option: ", key," ", val) + else: + echo("Unknown option: ", key, " ", val) + var jsonSettings = parseFile(zoneCfgFile) + let + host = jsonSettings["host"].str + port = TPort(jsonSettings["port"].num) + zoneFile = jsonSettings["settings"].str + dirServerInfo = jsonSettings["dirserver"] + + var path = getAppDir()/../"data"/zoneFile + if not fileExists(path): + echo("Zone settings file does not exist: ../data/", zoneFile) + echo(path) + quit(1) + + ## Test file + block: + var + TestFile: FileChallengePair + contents = repeat("abcdefghijklmnopqrstuvwxyz", 2) + testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32) + testFile.file = checksumStr(contents) + myAssets.add testFile + + setCurrentDir getAppDir().parentDir() + block: + let zonesettings = readFile(path) + var + errors: seq[string] = @[] + if not loadSettings(zoneSettings, errors): + echo("You have errors in your zone settings:") + for e in errors: echo("**", e) + quit(1) + errors.setLen 0 + + var pair: FileChallengePair + pair.challenge.file = zoneFile + pair.challenge.assetType = FZoneCfg + pair.challenge.fullLen = zoneSettings.len.int32 + pair.file = checksumStr(zoneSettings) + myAssets.add pair + + allAssets: + if not load(asset): + echo "Invalid or missing file ", file + else: + var pair: FileChallengePair + pair.challenge.file = file + pair.challenge.assetType = assetType + pair.challenge.fullLen = getFileSize( + expandPath(assetType, file)).int32 + pair.file = asset.contents + myAssets.add pair + + echo "Zone has ", myAssets.len, " associated assets" + + + dirServer = newServerConnection(dirServerInfo[0].str, dirServerInfo[1].num.TPort) + dirServer.handlers[HDsMsg] = proc(serv: PServer; stream: PStream) = + var m = readDsMsg(stream) + echo("DirServer> ", m.msg) + dirServer.handlers[HZoneLogin] = proc(serv: PServer; stream: PStream) = + let loggedIn = readDsZoneLogin(stream).status + if loggedIn: + dirServerConnected = true + dirServer.writePkt HZoneLogin, login + + thisZone.name = jsonSettings["name"].str + thisZone.desc = jsonSettings["desc"].str + thisZone.ip = "localhost" + thisZone.port = port + var login = newSdZoneLogin( + dirServerInfo[2].str, dirServerInfo[3].str, + thisZone) + #echo "MY LOGIN: ", $login + + + + createServer(port) + echo("Listening on port ", port, "...") + var pubChatTimer = cpuTime()#newClock() + while true: + discard dirServer.pollServer(15) + poll(15) + ## TODO sort this type of thing VV into a queue api + #let now = cpuTime() + if cpuTime() - pubChatTimer > PubChatDelay: #.getElapsedTime.asMilliseconds > 100: + pubChatTimer -= pubChatDelay #.restart() + if pubChatQueue.getPosition > 0: + var cn = 0 + let sizePubChat = pubChatQueue.data.len + for c in allClients: + c.outputBuf.writeData(addr pubChatQueue.data[0], sizePubChat) + pubChatQueue.flush() + + + diff --git a/tests/manyloc/keineschweine/server/sg_lobby.nim b/tests/manyloc/keineschweine/server/sg_lobby.nim new file mode 100644 index 000000000..04ce10f08 --- /dev/null +++ b/tests/manyloc/keineschweine/server/sg_lobby.nim @@ -0,0 +1,268 @@ +import ../../../dist/checksums/src/checksums/md5 + +import + sockets, streams, tables, times, math, strutils, json, os, + sfml, sfml_vector, sfml_colors, + streams_enh, input_helpers, zlib_helpers, client_helpers, sg_packets, sg_assets, sg_gui +type + TClientSettings = object + resolution*: TVideoMode + offlineFile: string + dirserver: tuple[host: string, port: TPort] + website*: string +var + clientSettings: TClientSettings + gui = newGuiContainer() + zonelist = newGuiContainer() + u_alias, u_passwd: PTextEntry + activeInput = 0 + aliasText, passwdText: PText + fpsTimer: PButton + loginBtn: PButton + playBtn: PButton + keyClient = newKeyClient("lobby") + showZonelist = false + chatInput*: PTextEntry + messageArea*: PMessageArea + mySession*: ScLogin +var + dirServer: PServer + zone*: PServer + activeServer: PServer + bConnected = false + outgoing = newStringStream("") + downloadProgress: PButton + connectionButtons: seq[PButton] #buttons that depend on connection to function + +template dispmessage(m: expr): stmt = + messageArea.add(m) +proc connectZone(host: string; port: TPort) +proc connectToDirserv() + +proc writePkt[T](pid: PacketID; p: var T) = + if activeServer.isNil: return + activeServer.writePkt pid, p + +proc setConnected(state: bool) = + if state: + bConnected = true + for b in connectionButtons: enable(b) + else: + bConnected = false + for b in connectionButtons: disable(b) + +proc setActiveZone(ind: int; zone: ScZoneRecord) = + #highlight it or something + dispmessage("Selected " & zone.name) + connectZone(zone.ip, zone.port) + playBtn.enable() + +proc handleChat(serv: PServer; s: PStream) = + var msg = readScChat(s) + messageArea.add(msg) + +proc connectToDirserv() = + if dirServer.isNil: + dirServer = newServerConnection(clientSettings.dirserver.host, clientSettings.dirserver.port) + dirServer.handlers[HHello] = proc(serv: PServer; s: PStream) = + let msg = readScHello(s) + dispMessage(msg.resp) + setConnected(true) + dirServer.handlers[HLogin] = proc(serv: PServer; s: PStream) = + mySession = readScLogin(s) + ##do something here + dirServer.handlers[HZonelist] = proc(serv: PServer; s: PStream) = + var + info = readScZonelist(s) + zones = info.zones + if zones.len > 0: + zonelist.clearButtons() + var pos = vec2f(0.0, 0.0) + zonelist.newButton( + text = "Zonelist - "& info.network, + position = pos, + onClick = proc(b: PButton) = + dispmessage("Click on header")) + pos.y += 20 + for i in 0..zones.len - 1: + var z = zones[i] + zonelist.newButton( + text = z.name, position = pos, + onClick = proc(b: PButton) = + setActiveZone(i, z)) + pos.y += 20 + showZonelist = true + dirServer.handlers[HPoing] = proc(serv: PServer; s: PStream) = + var ping = readPoing(s) + dispmessage("Ping: "& $ping.time) + ping.time = epochTime().float32 + serv.writePkt HPoing, ping + dirServer.handlers[HChat] = handleChat + dirServer.handlers[HFileChallenge] = handleFileChallenge + var hello = newCsHello() + dirServer.writePkt HHello, hello + activeServer = dirServer + + +proc zoneListReq() = + var pkt = newCsZonelist("sup") + writePkt HZonelist, pkt + +##key handlers +keyClient.registerHandler(MouseMiddle, down, proc() = + gui.setPosition(getMousePos())) + +keyClient.registerHandler(KeyO, down, proc() = + if keyPressed(KeyRShift): echo(repr(outgoing))) +keyClient.registerHandler(KeyTab, down, proc() = + activeInput = (activeInput + 1) mod 2) #does this work? +keyClient.registerHandler(MouseLeft, down, proc() = + let p = getMousePos() + gui.click(p) + if showZonelist: zonelist.click(p)) +var mptext = newText("", guiFont, 16) +keyClient.registerHandler(MouseRight, down, proc() = + let p = getMousePos() + mptext.setPosition(p) + mptext.setString("($1,$2)"%[$p.x.int,$p.y.int])) + + +proc connectZone(host: string, port: TPort) = + echo "Connecting to zone at ", host, ':', port + if zone.isNil: + zone = newServerConnection(host, port) + zone.handlers[HFileChallenge] = handleFileChallenge + zone.handlers[HChallengeResult] = handleFileChallengeResult + zone.handlers[HFileTransfer] = handleFileTransfer + zone.handlers[HChat] = handleChat + else: + zone.sock.connect(host, port) + var hello = newCsHello() + zone.writePkt HHello, hello + + + +proc lobbyReady*() = + keyClient.setActive() + gui.setActive(u_alias) + +proc tryConnect*(b: PButton) = + connectToDirserv() +proc tryLogin*(b: PButton) = + var login = newCsLogin( + alias = u_alias.getText(), + passwd = u_passwd.getText()) + writePkt HLogin, login +proc tryTransition*(b: PButton) = + ##check if we're logged in + #<implementation censored by the church> + #var joinReq = newCsJ + zone.writePkt HZoneJoinReq, mySession + #var errors: seq[string] = @[] + #if loadSettings("", errors): + # transition() + #else: + # for e in errors: dispmessage(e) +proc playOffline*(b: PButton) = + var errors: seq[string] = @[] + if loadSettingsFromFile(clientSettings.offlineFile, errors): + transition() + else: + dispmessage("Errors reading the file ("& clientSettings.offlineFile &"):") + for e in errors: dispmessage(e) + +proc getClientSettings*(): TClientSettings = + result = clientSettings + +proc lobbyInit*() = + var s = json.parseFile("./client_settings.json") + clientSettings.offlineFile = "data/" + clientSettings.offlineFile.add s["default-file"].str + let dirserv = s["directory-server"] + clientSettings.dirserver.host = dirserv["host"].str + clientSettings.dirserver.port = dirserv["port"].num.TPort + clientSettings.resolution.width = s["resolution"][0].num.cint + clientSettings.resolution.height= s["resolution"][1].num.cint + clientSettings.resolution.bitsPerPixel = s["resolution"][2].num.cint + clientSettings.website = s["website"].str + zonelist.setPosition(vec2f(200.0, 100.0)) + connectionButtons = @[] + + downloadProgress = gui.newButton( + text = "", position = vec2f(10, 130), onClick = nil) + downloadProgress.bg.setFillColor(color(34, 139, 34)) + downloadProgress.bg.setSize(vec2f(0, 0)) + + var pos = vec2f(10, 10) + u_alias = gui.newTextEntry( + if s.existsKey("alias"): s["alias"].str else: "alias", + pos) + pos.y += 20 + u_passwd = gui.newTextEntry("buzz", pos) + pos.y += 20 + connectionButtons.add(gui.newButton( + text = "Login", + position = pos, + onClick = tryLogin, + startEnabled = false)) + pos.y += 20 + fpsText.setPosition(pos) + + playBtn = gui.newButton( + text = "Play", + position = vec2f(680.0, 8.0), + onClick = tryTransition, + startEnabled = false) + gui.newButton( + text = "Play Offline", + position = vec2f(680.0, 28.0), + onClick = playOffline) + fpsTimer = gui.newButton( + text = "FPS: ", + position = vec2f(10.0, 70.0), + onClick = proc(b: PButton) = nil) + gui.newButton( + text = "Connect", + position = vec2f(10.0, 90.0), + onClick = tryConnect) + connectionButtons.add(gui.newButton( + text = "Test Chat", + position = vec2f(10.0, 110.0), + onClick = (proc(b: PButton) = + var pkt = newCsChat(text = "ohai") + writePkt HChat, pkt), + startEnabled = false)) + chatInput = gui.newTextEntry("...", vec2f(10.0, 575.0), proc() = + sendChat dirServer, chatInput.getText() + chatInput.clearText()) + messageArea = gui.newMessageArea(vec2f(10.0, 575.0 - 20.0)) + messageArea.sizeVisible = 25 + gui.newButton(text = "Scrollback + 1", position = vec2f(185, 10), onClick = proc(b: PButton) = + messageArea.scrollBack += 1 + update(messageArea)) + gui.newButton(text = "Scrollback - 1", position = vec2f(185+160, 10), onClick = proc(b: PButton) = + messageArea.scrollBack -= 1 + update(messageArea)) + gui.newButton(text = "Flood msg area", position = vec2f(185, 30), onClick = proc(b: PButton) = + for i in 0..< 30: + dispMessage($i)) + +var i = 0 +proc lobbyUpdate*(dt: float) = + #let res = disp.poll() + gui.update(dt) + i = (i + 1) mod 60 + if i == 0: + fpsTimer.setString("FPS: "& $round(1.0/dt)) + if not pollServer(dirServer, 5) and bConnected: + setConnected(false) + echo("Lost connection") + discard pollServer(zone, 5) + +proc lobbyDraw*(window: PRenderWindow) = + window.clear(Black) + window.draw messageArea + window.draw mptext + window.draw gui + if showZonelist: window.draw zonelist + window.display() diff --git a/tests/manyloc/nake/nake.nim b/tests/manyloc/nake/nake.nim new file mode 100644 index 000000000..5d3173a20 --- /dev/null +++ b/tests/manyloc/nake/nake.nim @@ -0,0 +1,84 @@ +discard """ +DO AS THOU WILST PUBLIC LICENSE + +Whoever should stumble upon this document is henceforth and forever +entitled to DO AS THOU WILST with aforementioned document and the +contents thereof. + +As said in the Olde Country, `Keepe it Gangster'.""" + +import strutils, parseopt, tables, os + +type + PTask* = ref object + desc*: string + action*: TTaskFunction + TTaskFunction* = proc() {.closure.} +var + tasks* = initTable[string, PTask](16) + +proc newTask*(desc: string; action: TTaskFunction): PTask +proc runTask*(name: string) {.inline.} +proc shell*(cmd: varargs[string, `$`]): int {.discardable.} +proc cd*(dir: string) {.inline.} + +template nakeImports*() = + import tables, parseopt, strutils, os + +template task*(name: string; description: string; body: untyped) {.dirty.} = + block: + var t = newTask(description, proc() {.closure.} = + body) + tasks[name] = t + +proc newTask*(desc: string; action: TTaskFunction): PTask = + new(result) + result.desc = desc + result.action = action +proc runTask*(name: string) = tasks[name].action() + +proc shell*(cmd: varargs[string, `$`]): int = + result = execShellCmd(cmd.join(" ")) +proc cd*(dir: string) = setCurrentDir(dir) +template withDir*(dir: string; body: untyped) = + ## temporary cd + ## withDir "foo": + ## # inside foo + ## #back to last dir + var curDir = getCurrentDir() + cd(dir) + body + cd(curDir) + +when true: + if not fileExists("nakefile.nim"): + echo "No nakefile.nim found. Current working dir is ", getCurrentDir() + quit 1 + var args = "" + for i in 1..paramCount(): + args.add paramStr(i) + args.add " " + quit(shell("nim", "c", "-r", "nakefile.nim", args)) +else: + import std/exitprocs + addExitProc(proc() {.noconv.} = + var + task: string + printTaskList: bool + for kind, key, val in getopt(): + case kind + of cmdLongOption, cmdShortOption: + case key.tolowerAscii + of "tasks", "t": + printTaskList = true + else: + echo "Unknown option: ", key, ": ", val + of cmdArgument: + task = key + else: discard + if printTaskList or task.len == 0 or not(tasks.hasKey(task)): + echo "Available tasks:" + for name, task in pairs(tasks): + echo name, " - ", task.desc + quit 0 + tasks[task].action()) diff --git a/tests/manyloc/nake/nakefile.nim b/tests/manyloc/nake/nakefile.nim new file mode 100644 index 000000000..fc479a5c2 --- /dev/null +++ b/tests/manyloc/nake/nakefile.nim @@ -0,0 +1,157 @@ +import nake +import httpclient, zip/zipfiles, times, random, sequtils +nakeImports + +randomize() + +const + GameAssets = "http://dl.dropbox.com/u/37533467/data-08-01-2012.7z" + BinLibs = "http://dl.dropbox.com/u/37533467/libs-2012-09-12.zip" + ExeName = "keineschweine" + ServerDefines = "-d:NoSFML -d:NoChipmunk" + TestBuildDefines = "-d:escapeMenuTest -d:debugWeps -d:showFPS -d:moreNim -d:debugKeys -d:foo -d:recordMode --forceBuild" + ReleaseDefines = "-d:release" + ReleaseTestDefines = "-d:debugWeps -d:debugKeys --forceBuild" + +task "testprofile", "..": + if shell("nim", TestBuildDefines, "--profiler:on", "--stacktrace:on", "compile", ExeName) == 0: + shell "."/ExeName, "offline" + +task "test", "Build with test defines": + if shell("nim", TestBuildDefines, "compile", ExeName) != 0: + quit "The build failed." + +task "testrun", "Build with test defines and run": + runTask "test" + shell "."/ExeName + +task "test2", "Build release test build test release build": + if shell("nim", ReleaseDefines, ReleaseTestDefines, "compile", ExeName) == 0: + shell "."/ExeName + +when false: + task "dirserver", "build the directory server": + withDir "server": + if shell("nim", ServerDefines, "compile", "dirserver") != 0: + echo "Failed to build the dirserver" + quit 1 + +task "zoneserver", "build the zone server": + withDir "enet_server": + if shell("nim", ServerDefines, "compile", "enet_server") != 0: + quit "Failed to build the zoneserver" +task "zoneserver-gui", "build the zone server, with gui!": + withDir "enet_server": + if shell("nim", ServerDefines, "--app:gui", "compile", "enet_server") != 0: + quit "Failed to build the zoneserver" + +task "servers", "build the server and directory server": + #runTask "dirserver" + runTask "zoneserver" + echo "Successfully built both servers :')" + +task "all", "run SERVERS and TEST tasks": + runTask "servers" + runTask "test" + +task "release", "release build": + let res = shell("nim", ReleaseDefines, "compile", ExeName) + if res != 0: + echo "The build failed." + quit 1 + else: + runTask "clean" + ## zip up all the files and such or something useful here + +task "testskel", "create skeleton test dir for testing": + let dirname = "test-" & $rand(5000) + removeDir dirName + createDir dirName/"data/fnt" + copyFile "data/fnt/LiberationMono-Regular", dirName/"data/fnt/LiberationMono-Regular.ttf" + copyFile "client_settings.json", dirName/"client_settings.json" + runTask "test" + copyFile ExeName, dirName/ExeName + withDir dirName: + shell "."/ExeName + + +task "clean", "cleanup generated files": + var dirs = @["nimcache", "server"/"nimcache"] + dirs.apply(proc(x: var string) = + if dirExists(x): removeDir(x)) + +task "download", "download game assets": + var + skipAssets = false + path = expandFilename("data") + client = newHttpClient() + path.add DirSep + path.add(extractFilename(GameAssets)) + if fileExists(path): + echo "The file already exists\n", + "[R]emove [M]ove [Q]uit [S]kip Source: ", GameAssets + case stdin.readLine.toLowerAscii + of "r": + removeFile path + of "m": + moveFile path, path/../(extractFilename(GameAssets)&"-old") + of "s": + skipAssets = true + else: + quit 0 + else: + echo "Downloading from ", GameAssets + if not skipAssets: + echo "Downloading to ", path + client.downloadFile(GameAssets, path) + echo "Download finished" + + let targetDir = parentDir(parentDir(path)) + when defined(linux): + let z7 = findExe("7z") + if z7 == "": + echo "Could not find 7z" + elif shell(z7, "t", path) != 0: ##note to self: make sure this is right + echo "Bad download" + else: + echo "Unpacking..." + shell(z7, "x", "-w[$1]" % targetDir, path) + else: + echo "I do not know how to unpack the data on this system. Perhaps you could ", + "fill this part in?" + + echo "Download binary libs? Only libs for linux are available currently, enjoy the irony.\n", + "[Y]es [N]o Source: ", BinLibs + case stdin.readline.toLowerAscii + of "y", "yes": + discard ## o_O + else: + return + path = extractFilename(BinLibs) + client.downloadFile(BinLibs, path) + echo "Downloaded dem libs ", path + when true: echo "Unpack it yourself, sorry." + else: ## this crashes, dunno why + var + z: TZipArchive + destDir = getCurrentDir()/("unzip" & $rand(5000)) + if not z.open(path, fmRead): + echo "Could not open zip, bad download?" + return + echo "Extracting to ", destDir + createDir destDir + #z.extractAll destDir + for f in z.walkFiles(): + z.extractFile(f, destDir/f) + z.close() + echo "Extracted the libs dir. Copy the ones you need to this dir." + +task "zip-lib", "zip up the libs dir": + var z: ZipArchive + if not z.open("libs-" & getDateStr() & ".zip", fmReadWrite): + quit "Could not open zip" + for file in walkDirRec("libs", {pcFile, pcDir}): + echo "adding file ", file + z.addFile(file) + z.close() + echo "Great success!" diff --git a/tests/manyloc/nake/nakefile.nim.cfg b/tests/manyloc/nake/nakefile.nim.cfg new file mode 100644 index 000000000..6f3e86fe6 --- /dev/null +++ b/tests/manyloc/nake/nakefile.nim.cfg @@ -0,0 +1 @@ +path = "dependencies/nake" diff --git a/tests/manyloc/named_argument_bug/gui.nim b/tests/manyloc/named_argument_bug/gui.nim new file mode 100644 index 000000000..1e0bc6ffd --- /dev/null +++ b/tests/manyloc/named_argument_bug/gui.nim @@ -0,0 +1,44 @@ +import + tri_engine/gfx/gl/primitive, + tri_engine/gfx/tex, + tri_engine/gfx/color, + tri_engine/math/rect, + tri_engine/math/vec + +type + TWidgetLayer* = enum + wlBg = 100, + wlOverlap = 200, + wlMain = 300, + wlOverlay = 400, + wlCursor = 500 + TWidgetLayerType = TWidgetLayer|int + TWidgetType* = enum + wtImg + PWidget* = ref object + `type`* : TWidgetType + layer* : TWidgetLayer + rect* : TRect + prim* : PPrimitive + +const + baseZ = 5000 + +proc newWidget*(`type`: TWidgetType, layer: TWidgetLayerType, rect: TRect): PWidget = + new(result) + result.`type` = `type` + result.layer = layer + result.rect = rect + + var verts = newVert(rect) + + # This works because z is accessible at this scope. + #var z = baseZ + layer.int + #result.prim = newPrimitive(verts, z=z) + + # Doesn't work, because the compiler looks for a symbol called z in this scope, + # but it should only check that it is the name of one of the params. + #result.prim = newPrimitive(verts, z=baseZ + layer.int) + + # This doesn't work either. + result.prim = newPrimitive(verts, z=0) diff --git a/tests/manyloc/named_argument_bug/main.nim b/tests/manyloc/named_argument_bug/main.nim new file mode 100644 index 000000000..767674428 --- /dev/null +++ b/tests/manyloc/named_argument_bug/main.nim @@ -0,0 +1,23 @@ +import + tri_engine/config, + tri_engine/math/vec, + tri_engine/math/circle, + tri_engine/gfx/gl/primitive, + tri_engine/gfx/tex, + tri_engine/gfx/color, + tri_engine/tri_engine, + gui + +var isRunning = true + +block: + var renderer = newRenderer(w=10, h=10) + + var primitive = newPrimitiveCircle(0.3.TR, color=white(0.5, 0.8), z=15) + renderer.addPrimitive(primitive) + + var verts = newVert((min: newV2xy(-0.4), size: newV2xy(0.3))) + var primitive2 = newPrimitive(verts, color=red(0.5, 0.8), z=10) + renderer.addPrimitive(primitive2) + + var mainMenuWidget = newWidget(wtImg, wlBg, rect=(newV2xy(-1.0), newV2xy(2.0))) diff --git a/tests/manyloc/named_argument_bug/main.nim.cfg b/tests/manyloc/named_argument_bug/main.nim.cfg new file mode 100644 index 000000000..7df7a0e97 --- /dev/null +++ b/tests/manyloc/named_argument_bug/main.nim.cfg @@ -0,0 +1,3 @@ +# this file only exists to mark 'main.nim' as the main file + +--path:"$projectpath" diff --git a/tests/manyloc/named_argument_bug/tri_engine/config.nim b/tests/manyloc/named_argument_bug/tri_engine/config.nim new file mode 100644 index 000000000..b90dc0b26 --- /dev/null +++ b/tests/manyloc/named_argument_bug/tri_engine/config.nim @@ -0,0 +1,6 @@ +when defined(doublePrecision): + type + TR* = float64 +else: + type + TR* = float32 diff --git a/tests/manyloc/named_argument_bug/tri_engine/gfx/color.nim b/tests/manyloc/named_argument_bug/tri_engine/gfx/color.nim new file mode 100644 index 000000000..b84be7a4c --- /dev/null +++ b/tests/manyloc/named_argument_bug/tri_engine/gfx/color.nim @@ -0,0 +1,54 @@ +import + tri_engine/config, + tri_engine/math/vec + +from strutils import + formatFloat, + TFloatFormat, + `%`, + ffDecimal + +type + TColor* = tuple[r, g, b, a: TR] + +converter toColor*(o: uint32): TColor = + ## Convert an integer to a color. This is mostly useful when the integer is specified as a hex + ## literal such as 0xFF00007F, which is 100% red, with 50% alpha. + ## TODO: turn this into a template that can take either 4 or 8 characters? + ((((o and 0xff000000'u32) shr 24).TR / 255.0).TR, + (((o and 0xff0000'u32) shr 16).TR / 255.0).TR, + (((o and 0xff00'u32) shr 8).TR / 255.0).TR, + (((o and 0xff'u32)).TR / 255.0).TR) + +converter toV4*(o: TColor): TV4[TR] = + cast[TV4[TR]](o) + +proc newColor*(r, g, b: TR=0.0, a: TR=1.0): TColor = + (r, g, b, a) + +proc white*(rgb, a: TR=1.0): TColor = + (rgb, rgb, rgb, a) + +proc red*(r, a: TR=1.0): TColor = + newColor(r=r, a=a) + +proc green*(g, a: TR=1.0): TColor = + newColor(g=g, a=a) + +proc yellow*(rg, a: TR=1.0): TColor = + newColor(r=rg, g=rg, a=a) + +proc blue*(b, a: TR=1.0): TColor = + newColor(b=b, a=a) + +proc cyan*(gb, a: TR=1.0): TColor = + newColor(g=gb, b=gb, a=a) + +proc purple*(rb, a: TR=1.0): TColor = + newColor(r=rb, b=rb, a=a) + +proc `$`*(o: TColor): string = + proc f(f: float): string = + f.formatFloat(precision=2, format=ffDecimal) + + "(r: $#, g: $#, b: $#, s: $#)" % [f(o.r), f(o.g), f(o.b), f(o.a)] diff --git a/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/gl.nim b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/gl.nim new file mode 100644 index 000000000..29e23f9d0 --- /dev/null +++ b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/gl.nim @@ -0,0 +1,61 @@ +import + opengl, + tri_engine/math/vec + +export + opengl + +type + EGL* = object of Exception + EGL_code* = object of EGL + code*: EGL_err + EGL_err {.pure.} = enum + none = GL_NO_ERROR + invalidEnum = GL_INVALID_ENUM + invalidVal = GL_INVALID_VALUE + invalidOp = GL_INVALID_OPERATION + stackOverflow = GL_STACK_OVERFLOW + stackUnderflow = GL_STACK_UNDERFLOW + outOfMem = GL_OUT_OF_MEMORY + invalidFramebufferOp = GL_INVALID_FRAMEBUFFER_OPERATION + unknown + +proc newGL_codeException*(msg: string, code: EGL_err): ref EGL_code = + result = newException(EGL_code, $code) + result.code = code + +proc getErr*(): EGL_err = + result = glGetError().EGL_err + if result notin {EGL_err.none, + EGL_err.invalidEnum, + EGL_err.invalidVal, + EGL_err.invalidOp, + EGL_err.invalidFramebufferOp, + EGL_err.outOfMem, + EGL_err.stackUnderflow, + EGL_err.stackOverflow}: + return EGL_err.unknown + +proc errCheck*() = + let err = getErr() + if err != EGL_err.none: + raise newGL_codeException($err, err) + +macro `?`*(call: expr{nkCall}): expr = + result = call + # Can't yet reference foreign symbols in macros. + #errCheck() + +when defined(doublePrecision): + const + glRealType* = cGLdouble +else: + const + glRealType* = cGLfloat + +proc setUniformV4*[T](loc: GLint, vecs: var openArray[TV4[T]]) = + glUniform4fv(loc, vecs.len.GLsizei, cast[ptr GLfloat](vecs[0].addr)) + +proc setUniformV4*[T](loc: GLint, vec: TV4[T]) = + var vecs = [vec] + setUniformV4(loc, vecs) diff --git a/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/primitive.nim b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/primitive.nim new file mode 100644 index 000000000..accc2d96b --- /dev/null +++ b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/primitive.nim @@ -0,0 +1,157 @@ +import + math, + tri_engine/config, + tri_engine/gfx/gl/gl, + tri_engine/gfx/tex, + tri_engine/gfx/color, + tri_engine/math/vec, + tri_engine/math/rect, + tri_engine/math/circle + +import strutils + +type + TVert* = tuple[pos: TV2[TR], texCoord: TV2[TR]] + TVertAttrib* = object + i* : GLuint + size* : GLint + stride* : GLsizei + offset* : GLvoid + TVertMode* = enum + vmTriStrip = GLtriangleStrip, + vmTriFan = GLtriangleFan + TZ_range* = range[-100_000..100_000] + PPrimitive* = ref object + verts* : seq[TVert] + indices* : seq[GLushort] + arrBufId* : GLuint + elemArrBufId* : GLuint + tex* : TTex + color* : TColor + vertMode* : TVertMode + z* : int + +proc newVert*(pos, texCoord: TV2): TVert = + (pos, texCoord) + +proc newVertQuad*(min, minRight, maxLeft, max: TV2[TR]): seq[TVert] = + @[newVert(min, newV2()), + newVert(minRight, newV2(x=1.0)), + newVert(maxLeft, newV2(y=1.0)), + newVert(max, newV2xy(1.0)) + ] + +proc newVert*(rect: rect.TRect): seq[TVert] = + newVertQuad(rect.min, newV2(rect.max.x, rect.min.y), newV2(rect.min.x, rect.max.y), rect.max) + +proc newVertAttrib(i: GLuint, size: GLint, stride: GLsizei, offset: GLvoid): TVertAttrib = + TVertAttrib(i: i, size: size, stride: stride, offset: offset) + +proc genBuf*[T](vboTarget, objUsage: GLenum, data: var openArray[T]): GLuint = + result = 0.GLuint + ?glGenBuffers(1, result.addr) + ?glBindBuffer(vboTarget, result) + + let size = (data.len * T.sizeof).GLsizeiptr + ?glBufferData(vboTarget, size, data[0].addr, objUsage) + +proc newPrimitive*(verts: var seq[TVert], + vertMode=vmTriStrip, + tex=whiteTex(), + color=white(), + z: TZ_range=0): PPrimitive = + var indices = newSeq[GLushort](verts.len) + for i in 0 ..< verts.len: + indices[i] = i.GLushort + + new(result) + result.verts = verts + result.indices = indices + + result.arrBufId = genBuf(GLarrayBuffer, GL_STATIC_DRAW, verts) + result.elemArrBufId = genBuf(GLelementArrayBuffer, GL_STATIC_DRAW, indices) + result.tex = tex + result.color = color + result.vertMode = vertMode + result.z = z + +proc bindBufs*(o: PPrimitive) = + ?glBindBuffer(GLarrayBuffer, o.arrBufId) + ?glBindBuffer(GLelementArrayBuffer, o.elemArrBufId) + +proc enableVertAttribArrs*() = + ?glEnableVertexAttribArray(0) + ?glEnableVertexAttribArray(1) + +proc disableVertAttribArrs*() = + ?glDisableVertexAttribArray(1) + ?glDisableVertexAttribArray(0) + +proc setVertAttribPointers*() = + let vertSize {.global.} = TVert.sizeof.GLint + ?glVertexAttribPointer(0, 2, glRealType, false, vertSize, nil) + ?glVertexAttribPointer(1, 2, glRealType, false, vertSize, cast[GLvoid](TR.sizeof * 2)) + +proc updVerts*(o: PPrimitive, start, `end`: int, f: proc(i: int, vert: var TVert)) = + assert start <= `end` + assert `end` < o.verts.len + for i in start..`end`: + f(i, o.verts[i]) + + ?glBindBuffer(GLarrayBuffer, o.arrBufId) + + let byteLen = `end` - start + 1 * TVert.sizeof + let byteOffset = start * TVert.sizeof + ?glBufferSubData(GLarrayBuffer, + byteOffset.GLintptr, # Offset. Is this right? + byteLen.GLsizeiptr, # Size. + cast[GLvoid](cast[int](o.verts[0].addr) + byteOffset)) + +proc updAllVerts(o: PPrimitive, f: proc(i: int, vert: var TVert)) = + for i in 0 ..< o.verts.len: + f(i, o.verts[i]) + + ?glBindBuffer(GLarrayBuffer, o.arrBufId) + + # Discard old buffer before creating a new one. + let byteLen = (o.verts.len * TVert.sizeof).GLsizeiptr + ?glBufferData(GLarrayBuffer, byteLen, nil, GLstaticDraw) + ?glBufferData(GLarrayBuffer, byteLen, o.verts[0].addr, GLstaticDraw) + +proc newVertCircle*(circle: TCircle, nSegs: Natural=0): seq[TVert] = + let nSegs = if nSegs == 0: + (circle.r.sqrt() * 400.0).int # TODO: Base this on the window resolution? + else: + max(nSegs, 3) + + let theta: TR = (PI * 2.0) / (nSegs.TR) + let tanFactor = theta.tan() + let radialFactor = theta.cos() + var x = circle.r + var y: TR = 0.0 + + result = newSeq[TVert](nSegs) + #result[0] = newVert(circle.p, newV2xy(0.5)) + for i in 1 ..< nSegs: + let pos = newV2(x + circle.p.x, y + circle.p.y) + let texCoord = pos * newV2xy(1.0 / circle.r) + + result[i] = newVert(pos, texCoord) + + let tx = -y + let ty = x + x += tx * tanFactor + y += ty * tanFactor + + x *= radialFactor + y *= radialFactor + + result.add(result[1]) + +proc newPrimitiveCircle*(circle: TCircle, + nSegs: Natural=0, + tex=whiteTex(), + color=white(), + z: TZ_range=0): PPrimitive = + var verts = newVertCircle(circle, nSegs) + newPrimitive(verts, vmTriFan, tex, color, z) diff --git a/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/shader.nim b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/shader.nim new file mode 100644 index 000000000..970885b3d --- /dev/null +++ b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/shader.nim @@ -0,0 +1,103 @@ +import + pure/os, + tri_engine/gfx/gl/gl + +type + TShader* = object + id*: GL_handle + TShaderType* {.pure.} = enum + frag = GL_FRAGMENT_SHADER, + vert = GL_VERTEX_SHADER + E_Shader* = object of Exception + E_UnknownShaderType* = object of E_Shader + +converter pathToShaderType*(s: string): TShaderType = + case s.splitFile().ext: + of ".vs": + return TShaderType.vert + of ".fs": + return TShaderType.frag + else: + raise newException(E_UnknownShaderType, "Can't determine shader type from file extension: " & s) + +proc setSrc*(shader: TShader, src: string) = + var s = src.cstring + ?glShaderSource(shader.id, 1, cast[cstringarray](s.addr), nil) + +proc newShader*(id: GL_handle): TShader = + if id.int != 0 and not (?glIsShader(id)).bool: + raise newException(E_GL, "Invalid shader ID: " & $id) + + result.id = id + +proc shaderInfoLog*(o: TShader): string = + var log {.global.}: array[0..1024, char] + var logLen: GLsizei + ?glGetShaderInfoLog(o.id.GLuint, log.len.GLsizei, addr logLen, cast[cstring](log.addr)) + cast[string](log.addr).substr(0, logLen) + +proc compile*(shader: TShader, path="") = + ?glCompileShader(shader.id) + var compileStatus = 0.GLint + ?glGetShaderIv(shader.id, GL_COMPILE_STATUS, compileStatus.addr) + + if compileStatus == 0: + raise newException(E_GL, if path.len == 0: + shaderInfoLog(shader) + else: + path & ":\n" & shaderInfoLog(shader) + ) + +proc newShaderFromSrc*(src: string, `type`: TShaderType): TShader = + result.id = ?glCreateShader(`type`.GLenum) + result.setSrc(src) + result.compile() + +proc newShaderFromFile*(path: string): TShader = + newShaderFromSrc(readFile(path), path) + +type + TProgram* = object + id*: GL_handle + shaders: seq[TShader] + +proc attach*(o: TProgram, shader: TShader) = + ?glAttachShader(o.id, shader.id) + +proc infoLog*(o: TProgram): string = + var log {.global.}: array[0..1024, char] + var logLen: GLsizei + ?glGetProgramInfoLog(o.id.GLuint, log.len.GLsizei, addr logLen, cast[cstring](log.addr)) + cast[string](log.addr).substr(0, logLen) + +proc link*(o: TProgram) = + ?glLinkProgram(o.id) + var linkStatus = 0.GLint + ?glGetProgramIv(o.id, GL_LINK_STATUS, linkStatus.addr) + if linkStatus == 0: + raise newException(E_GL, o.infoLog()) + +proc validate*(o: TProgram) = + ?glValidateProgram(o.id) + var validateStatus = 0.GLint + ?glGetProgramIv(o.id, GL_VALIDATE_STATUS, validateStatus.addr) + if validateStatus == 0: + raise newException(E_GL, o.infoLog()) + +proc newProgram*(shaders: seq[TShader]): TProgram = + result.id = ?glCreateProgram() + if result.id.int == 0: + return + + for shader in shaders: + if shader.id.int == 0: + return + + ?result.attach(shader) + + result.shaders = shaders + result.link() + result.validate() + +proc use*(o: TProgram) = + ?glUseProgram(o.id) diff --git a/tests/manyloc/named_argument_bug/tri_engine/gfx/tex.nim b/tests/manyloc/named_argument_bug/tri_engine/gfx/tex.nim new file mode 100644 index 000000000..282a1ac99 --- /dev/null +++ b/tests/manyloc/named_argument_bug/tri_engine/gfx/tex.nim @@ -0,0 +1,31 @@ +import + tri_engine/gfx/gl/gl + +type + TTex* = object + id*: GLuint + +var gWhiteTex = TTex(id: 0) + +proc setTexParams() = + ?glTexParameteri(GLtexture2D, GLtextureMinFilter, GLlinear) + + #glTexParameteri(GLtexture2D, GLtextureMagFilter, GLlinear) + ?glTexParameteri(GLtexture2D, GLTextureMagFilter, GLnearest) + + ?glTexParameteri(GLtexture2D, GLTextureWrapS, GLClampToEdge) + ?glTexParameteri(GLtexture2D, GLTextureWrapT, GLClampToEdge) + +proc whiteTex*(): TTex = + if gWhiteTex.id.int != 0: + return gWhiteTex + + ?glGenTextures(1, gWhiteTex.id.addr) + ?glBindTexture(GLtexture2D, gWhiteTex.id) + setTexParams() + + var pixel = [255'u8, 255'u8, 255'u8, 255'u8] + ?glTexImage2D(GLtexture2D, 0, GLint GL_RGBA, 1, 1, 0, GL_BGRA, cGLUnsignedByte, pixel[0].addr) + ?glBindTexture(GLtexture2D, 0) + + result = gWhiteTex diff --git a/tests/manyloc/named_argument_bug/tri_engine/math/circle.nim b/tests/manyloc/named_argument_bug/tri_engine/math/circle.nim new file mode 100644 index 000000000..b95cfa379 --- /dev/null +++ b/tests/manyloc/named_argument_bug/tri_engine/math/circle.nim @@ -0,0 +1,9 @@ +import + ../config, + vec + +type + TCircle* = tuple[p: TV2[TR], r: TR] + +converter toCircle*(o: TR): TCircle = + (newV2(), o) diff --git a/tests/manyloc/named_argument_bug/tri_engine/math/rect.nim b/tests/manyloc/named_argument_bug/tri_engine/math/rect.nim new file mode 100644 index 000000000..b6fd9ce84 --- /dev/null +++ b/tests/manyloc/named_argument_bug/tri_engine/math/rect.nim @@ -0,0 +1,8 @@ +import + tri_engine/config, + tri_engine/math/vec + +type + TRect* = tuple[min, size: TV2[TR]] + +proc max*(o: TRect): TV2[TR] = o.min + o.size diff --git a/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim b/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim new file mode 100644 index 000000000..18ede6100 --- /dev/null +++ b/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim @@ -0,0 +1,55 @@ +import + macros, + "../config" + +type + TV2*[T:SomeNumber=TR] = array[0..1, T] + TV3*[T:SomeNumber=TR] = array[0..2, T] + TV4*[T:SomeNumber=TR] = array[0..3, T] + TVT*[T:SomeNumber=TR] = TV2|TV3|TV4 + #TV2* = array[0..1, TR] + #TV3* = array[0..2, TR] + #TV4* = array[0..3, TR] + +# TODO: Change to TVT when compiler issue is resolved. +proc `$`*[T](o: TV2[T]): string = + result = "(" + for i in 0 ..< o.len: + result &= $o[0] + if i != o.len - 1: + result &= ", " + + result & ")" + +proc newV2T*[T](x, y: T=0): TV2[T] = + [x, y] + +proc newV2*(x, y: TR=0.0): TV2[TR] = + [x, y] + +proc newV2xy*(xy: TR): TV2[TR] = + [xy, xy] + +proc x*[T](o: TV2[T]): T = + o[0] + +proc y*[T](o: TV2[T]): T = + o[1] + +proc `*`*(lhs: TV2[TR], rhs: TV2[TR]): TV2[TR] = + [(lhs.x * rhs.x).TR, (lhs.y * rhs.y).TR] + +proc `+`*(lhs: TV2[TR], rhs: TV2[TR]): TV2[TR] = + [(lhs.x + rhs.x).TR, (lhs.y + rhs.y).TR] + +#proc dotProduct[T](a: TVT[T], b: TVT[T]): T = +# for i in 0 .. a.len - 1: +# result += a[i] * b[i] + +proc dot[T](a, b: TV2[T]): T = + for i in 0 ..< a.len: + result += a[i] * b[i] + +assert dot(newV2(), newV2()) == 0.0 +assert dot(newV2(2, 3), newV2(6, 7)) == 33.0 +assert dot([2.0, 3.0], [6.0, 7.0]) == 33.0 diff --git a/tests/manyloc/named_argument_bug/tri_engine/tri_engine.nim b/tests/manyloc/named_argument_bug/tri_engine/tri_engine.nim new file mode 100644 index 000000000..ba9989bbb --- /dev/null +++ b/tests/manyloc/named_argument_bug/tri_engine/tri_engine.nim @@ -0,0 +1,106 @@ +import + algorithm, + tri_engine/config, + tri_engine/gfx/gl/gl, + tri_engine/gfx/gl/primitive, + tri_engine/gfx/gl/shader, + tri_engine/gfx/color + +const primitiveVs = """ +#version 330 core + +layout(location = 0) in vec2 pos; +layout(location = 1) in vec2 texCoord; + +out vec2 uv; + +void main() +{ + gl_Position = vec4(pos, 0, 1); + uv = texCoord; +} + +""" +const primitiveFs = """ +#version 330 core + +in vec2 uv; +out vec4 color; +uniform sampler2D tex; +uniform vec4 inColor; + +void main() +{ + color = texture(tex, uv) * inColor; +} + +""" + +var gW, gH: Natural = 0 + +proc w*(): int = + gW + +proc h*(): int = + gH + +type + PRenderer = ref object + primitiveProgram: TProgram + primitives: seq[PPrimitive] + +proc setupGL() = + ?glEnable(GLblend) + ?glBlendFunc(GLsrcAlpha, GLoneMinusSrcAlpha) + ?glClearColor(0.0, 0.0, 0.0, 1.0) + ?glPolygonMode(GLfrontAndBack, GLfill) + +proc newRenderer*(w, h: Positive): PRenderer = + gW = w + gH = h + + new(result) + newSeq(result.primitives, 0) + loadExtensions() + setupGL() + result.primitiveProgram = newProgram(@[ + newShaderFromSrc(primitiveVs, TShaderType.vert), + newShaderFromSrc(primitiveFs, TShaderType.frag)]) + +proc draw(o: PRenderer, p: PPrimitive) = + let loc = proc(x: string): Glint = + result = glGetUniformLocation(o.primitiveProgram.id, x) + if result == -1: + raise newException(E_GL, "Shader error: " & x & " does not correspond to a uniform variable") + + setUniformV4(loc("inColor"), p.color) + ?glActiveTexture(GLtexture0) + ?glBindTexture(GLtexture2D, p.tex.id.GLuint) + ?glUniform1i(loc("tex"), 0) + + p.bindBufs() + setVertAttribPointers() + + ?glDrawElements(p.vertMode.GLenum, p.indices.len.GLsizei, cGLunsignedShort, nil) + +proc draw*(o: PRenderer) = + ?glClear(GLcolorBufferBit) + o.primitiveProgram.use() + + enableVertAttribArrs() + var zSortedPrimitives = o.primitives + zSortedPrimitives.sort(proc(x, y: PPrimitive): int = + if x.z < y.z: + -1 + elif x.z > y.z: + 1 + else: + 0) + + for x in zSortedPrimitives: + o.draw(x) + + disableVertAttribArrs() + +proc addPrimitive*(o: PRenderer, p: PPrimitive) = + o.primitives.add(p) diff --git a/tests/manyloc/packages/noconflicts.nim b/tests/manyloc/packages/noconflicts.nim new file mode 100644 index 000000000..2183d01a8 --- /dev/null +++ b/tests/manyloc/packages/noconflicts.nim @@ -0,0 +1,16 @@ +discard """ + output: '''package1/strutils +package2/strutils +noconflicts +new os.nim''' +""" + +import package1/strutils as su1 +import package2.strutils as su2 + +import os + +su1.foo() +su2.foo() +echo "noconflicts" +yay() diff --git a/tests/manyloc/packages/noconflicts.nim.cfg b/tests/manyloc/packages/noconflicts.nim.cfg new file mode 100644 index 000000000..88974ab8c --- /dev/null +++ b/tests/manyloc/packages/noconflicts.nim.cfg @@ -0,0 +1 @@ +# Mark noconflicts as project file \ No newline at end of file diff --git a/tests/manyloc/packages/os.nim b/tests/manyloc/packages/os.nim new file mode 100644 index 000000000..8a59612f9 --- /dev/null +++ b/tests/manyloc/packages/os.nim @@ -0,0 +1,5 @@ + +# Overrides lib/pure/os.nim + +proc yay* = echo "new os.nim" + diff --git a/tests/manyloc/packages/package1/p1.babel b/tests/manyloc/packages/package1/p1.babel new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/manyloc/packages/package1/p1.babel diff --git a/tests/manyloc/packages/package1/strutils.nim b/tests/manyloc/packages/package1/strutils.nim new file mode 100644 index 000000000..b283600ea --- /dev/null +++ b/tests/manyloc/packages/package1/strutils.nim @@ -0,0 +1,5 @@ + +# Overrides lib/pure/os.nim + +proc foo* = echo "package1/strutils" + diff --git a/tests/manyloc/packages/package2/p2.babel b/tests/manyloc/packages/package2/p2.babel new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/manyloc/packages/package2/p2.babel diff --git a/tests/manyloc/packages/package2/strutils.nim b/tests/manyloc/packages/package2/strutils.nim new file mode 100644 index 000000000..1fb4abd41 --- /dev/null +++ b/tests/manyloc/packages/package2/strutils.nim @@ -0,0 +1,5 @@ + +# Overrides lib/pure/os.nim + +proc foo* = echo "package2/strutils" + diff --git a/tests/manyloc/standalone/barebone.nim b/tests/manyloc/standalone/barebone.nim new file mode 100644 index 000000000..487f6da65 --- /dev/null +++ b/tests/manyloc/standalone/barebone.nim @@ -0,0 +1,16 @@ +discard """ +ccodecheck: "\\i !@('systemInit')" +ccodecheck: "\\i !@('systemDatInit')" +output: "hello" +""" +# bug #2041: Macros need to be available for os:standalone! +import macros + +proc printf(frmt: cstring) {.varargs, header: "<stdio.h>", cdecl.} + +var x = 0 +inc x +printf("hi %ld\n", x+4777) + +proc substr(a: string): string = a[0 .. 3] # This should compile. See #9762 +const a = substr("foobar") diff --git a/tests/manyloc/standalone/barebone.nim.cfg b/tests/manyloc/standalone/barebone.nim.cfg new file mode 100644 index 000000000..b956bef8e --- /dev/null +++ b/tests/manyloc/standalone/barebone.nim.cfg @@ -0,0 +1,2 @@ +--os:standalone +--gc:none diff --git a/tests/manyloc/standalone/panicoverride.nim b/tests/manyloc/standalone/panicoverride.nim new file mode 100644 index 000000000..c0b8bb030 --- /dev/null +++ b/tests/manyloc/standalone/panicoverride.nim @@ -0,0 +1,14 @@ + +proc printf(frmt: cstring) {.varargs, importc, header: "<stdio.h>", cdecl.} +proc exit(code: int) {.importc, header: "<stdlib.h>", cdecl.} + +{.push stack_trace: off, profiler:off.} + +proc rawoutput(s: string) = + printf("%s\n", s) + +proc panic(s: string) {.noreturn.} = + rawoutput(s) + exit(1) + +{.pop.} diff --git a/tests/manyloc/standalone2/panicoverride.nim b/tests/manyloc/standalone2/panicoverride.nim new file mode 100644 index 000000000..c0b8bb030 --- /dev/null +++ b/tests/manyloc/standalone2/panicoverride.nim @@ -0,0 +1,14 @@ + +proc printf(frmt: cstring) {.varargs, importc, header: "<stdio.h>", cdecl.} +proc exit(code: int) {.importc, header: "<stdlib.h>", cdecl.} + +{.push stack_trace: off, profiler:off.} + +proc rawoutput(s: string) = + printf("%s\n", s) + +proc panic(s: string) {.noreturn.} = + rawoutput(s) + exit(1) + +{.pop.} diff --git a/tests/manyloc/standalone2/tavr.nim b/tests/manyloc/standalone2/tavr.nim new file mode 100644 index 000000000..6cbc5c699 --- /dev/null +++ b/tests/manyloc/standalone2/tavr.nim @@ -0,0 +1,7 @@ +# bug #16404 + +proc printf(frmt: cstring) {.varargs, header: "<stdio.h>", cdecl.} + +var x = 0 +inc x +printf("hi %ld\n", x+4777) diff --git a/tests/manyloc/standalone2/tavr.nim.cfg b/tests/manyloc/standalone2/tavr.nim.cfg new file mode 100644 index 000000000..2a31618d0 --- /dev/null +++ b/tests/manyloc/standalone2/tavr.nim.cfg @@ -0,0 +1,5 @@ +--gc:arc +--cpu:avr +--os:standalone +--compileOnly +--threads:off |