mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-27 13:25:06 +00:00
version 0.7.0
This commit is contained in:
2199
lib/base/devel/FGInt.pas
Normal file
2199
lib/base/devel/FGInt.pas
Normal file
File diff suppressed because it is too large
Load Diff
1712
lib/base/devel/bignums.nim
Normal file
1712
lib/base/devel/bignums.nim
Normal file
File diff suppressed because it is too large
Load Diff
460
lib/base/devel/diff.nim
Normal file
460
lib/base/devel/diff.nim
Normal file
@@ -0,0 +1,460 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2008 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implements the Difference Algorithm published in
|
||||
## "An O(ND) Difference Algorithm and its Variations" by Eugene Myers
|
||||
## Algorithmica Vol. 1 No. 2, 1986, p 251.
|
||||
|
||||
## This implementation is based on:
|
||||
##
|
||||
## diff.cs: A port of the algorythm to C#
|
||||
## Copyright (c) by Matthias Hertel, http://www.mathertel.de
|
||||
## This work is licensed under a BSD style license.
|
||||
## See http://www.mathertel.de/License.aspx
|
||||
|
||||
{.push debugger:off .} # the user does not want to trace a part
|
||||
# of the standard library!
|
||||
|
||||
import
|
||||
strutils
|
||||
|
||||
type
|
||||
TResultItem* = object of TObject
|
||||
startA*: int ## start of line number in A
|
||||
startB*: int ## start of line number in B
|
||||
deletedA*: int ## number of deletions in A
|
||||
deletedB*: int ## number of deletions in B
|
||||
|
||||
SMSRD = tuple[x, y: int] ## shortest middle snake return data
|
||||
|
||||
TDiffData {.final.} = object
|
||||
len: int
|
||||
data: seq[int]
|
||||
modified: seq[bool]
|
||||
|
||||
proc diffText*(a, b: seq[string],
|
||||
eq: proc (x, y: string): bool): seq[TResultItem] =
|
||||
## returns the difference of two texts `a` and `b`. The texts are compared
|
||||
## line by line with the `eq` proc.
|
||||
nil
|
||||
|
||||
proc diffText*(a, b: string, eq: proc (x, y: string): bool): seq[TResultItem] =
|
||||
## returns the difference of two texts `a` and `b`. The texts are compared
|
||||
## line by line with the `eq` proc.
|
||||
result = diffText(linesSeq(a), linesSeq(b), eq)
|
||||
|
||||
/// <summary>details of one difference.</summary>
|
||||
public struct Item
|
||||
{
|
||||
/// <summary>Start Line number in Data A.</summary>
|
||||
public int StartA;
|
||||
/// <summary>Start Line number in Data B.</summary>
|
||||
public int StartB;
|
||||
|
||||
/// <summary>Number of changes in Data A.</summary>
|
||||
public int deletedA;
|
||||
/// <summary>Number of changes in Data B.</summary>
|
||||
public int insertedB;
|
||||
} // Item
|
||||
|
||||
/// <summary>
|
||||
/// Shortest Middle Snake Return Data
|
||||
/// </summary>
|
||||
private struct SMSRD
|
||||
{
|
||||
internal int x, y;
|
||||
// internal int u, v; // 2002.09.20: no need for 2 points
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find the difference in 2 texts, comparing by textlines.
|
||||
/// </summary>
|
||||
/// <param name="TextA">A-version of the text (usualy the old one)</param>
|
||||
/// <param name="TextB">B-version of the text (usualy the new one)</param>
|
||||
/// <returns>Returns a array of Items that describe the differences.</returns>
|
||||
public Item[] DiffText(string TextA, string TextB) {
|
||||
return (DiffText(TextA, TextB, false, false, false));
|
||||
} // DiffText
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find the difference in 2 text documents, comparing by textlines.
|
||||
/// The algorithm itself is comparing 2 arrays of numbers so when comparing 2 text documents
|
||||
/// each line is converted into a (hash) number. This hash-value is computed by storing all
|
||||
/// textlines into a common hashtable so i can find dublicates in there, and generating a
|
||||
/// new number each time a new textline is inserted.
|
||||
/// </summary>
|
||||
/// <param name="TextA">A-version of the text (usualy the old one)</param>
|
||||
/// <param name="TextB">B-version of the text (usualy the new one)</param>
|
||||
/// <param name="trimSpace">When set to true, all leading and trailing whitespace characters are stripped out before the comparation is done.</param>
|
||||
/// <param name="ignoreSpace">When set to true, all whitespace characters are converted to a single space character before the comparation is done.</param>
|
||||
/// <param name="ignoreCase">When set to true, all characters are converted to their lowercase equivivalence before the comparation is done.</param>
|
||||
/// <returns>Returns a array of Items that describe the differences.</returns>
|
||||
public static Item[] DiffText(string TextA, string TextB, bool trimSpace, bool ignoreSpace, bool ignoreCase) {
|
||||
// prepare the input-text and convert to comparable numbers.
|
||||
Hashtable h = new Hashtable(TextA.Length + TextB.Length);
|
||||
|
||||
// The A-Version of the data (original data) to be compared.
|
||||
DiffData DataA = new DiffData(DiffCodes(TextA, h, trimSpace, ignoreSpace, ignoreCase));
|
||||
|
||||
// The B-Version of the data (modified data) to be compared.
|
||||
DiffData DataB = new DiffData(DiffCodes(TextB, h, trimSpace, ignoreSpace, ignoreCase));
|
||||
|
||||
h = null; // free up hashtable memory (maybe)
|
||||
|
||||
int MAX = DataA.Length + DataB.Length + 1;
|
||||
/// vector for the (0,0) to (x,y) search
|
||||
int[] DownVector = new int[2 * MAX + 2];
|
||||
/// vector for the (u,v) to (N,M) search
|
||||
int[] UpVector = new int[2 * MAX + 2];
|
||||
|
||||
LCS(DataA, 0, DataA.Length, DataB, 0, DataB.Length, DownVector, UpVector);
|
||||
|
||||
Optimize(DataA);
|
||||
Optimize(DataB);
|
||||
return CreateDiffs(DataA, DataB);
|
||||
} // DiffText
|
||||
|
||||
|
||||
proc Optimize(d: var TDiffData) =
|
||||
## If a sequence of modified lines starts with a line that contains the
|
||||
## same content as the line that appends the changes, the difference sequence
|
||||
## is modified so that the appended line and not the starting line is marked
|
||||
## as modified. This leads to more readable diff sequences when comparing
|
||||
## text files.
|
||||
var startPos = 0
|
||||
while startPos < d.len:
|
||||
while StartPos < d.len and not d.modified[StartPos]: inc(startPos)
|
||||
var endPos = startPos
|
||||
while EndPos < d.len and d.modified[EndPos]: inc(endPos)
|
||||
if EndPos < d.len and d.data[StartPos] == d.data[EndPos]:
|
||||
d.modified[StartPos] = false
|
||||
d.modified[EndPos] = true
|
||||
else:
|
||||
StartPos = EndPos
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find the difference in 2 arrays of integers.
|
||||
/// </summary>
|
||||
/// <param name="ArrayA">A-version of the numbers (usualy the old one)</param>
|
||||
/// <param name="ArrayB">B-version of the numbers (usualy the new one)</param>
|
||||
/// <returns>Returns a array of Items that describe the differences.</returns>
|
||||
public static Item[] DiffInt(int[] ArrayA, int[] ArrayB) {
|
||||
// The A-Version of the data (original data) to be compared.
|
||||
DiffData DataA = new DiffData(ArrayA);
|
||||
|
||||
// The B-Version of the data (modified data) to be compared.
|
||||
DiffData DataB = new DiffData(ArrayB);
|
||||
|
||||
int MAX = DataA.Length + DataB.Length + 1;
|
||||
/// vector for the (0,0) to (x,y) search
|
||||
int[] DownVector = new int[2 * MAX + 2];
|
||||
/// vector for the (u,v) to (N,M) search
|
||||
int[] UpVector = new int[2 * MAX + 2];
|
||||
|
||||
LCS(DataA, 0, DataA.Length, DataB, 0, DataB.Length, DownVector, UpVector);
|
||||
return CreateDiffs(DataA, DataB);
|
||||
} // Diff
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This function converts all textlines of the text into unique numbers for every unique textline
|
||||
/// so further work can work only with simple numbers.
|
||||
/// </summary>
|
||||
/// <param name="aText">the input text</param>
|
||||
/// <param name="h">This extern initialized hashtable is used for storing all ever used textlines.</param>
|
||||
/// <param name="trimSpace">ignore leading and trailing space characters</param>
|
||||
/// <returns>a array of integers.</returns>
|
||||
private static int[] DiffCodes(string aText, Hashtable h, bool trimSpace, bool ignoreSpace, bool ignoreCase) {
|
||||
// get all codes of the text
|
||||
string[] Lines;
|
||||
int[] Codes;
|
||||
int lastUsedCode = h.Count;
|
||||
object aCode;
|
||||
string s;
|
||||
|
||||
// strip off all cr, only use lf as textline separator.
|
||||
aText = aText.Replace("\r", "");
|
||||
Lines = aText.Split('\n');
|
||||
|
||||
Codes = new int[Lines.Length];
|
||||
|
||||
for (int i = 0; i < Lines.Length; ++i) {
|
||||
s = Lines[i];
|
||||
if (trimSpace)
|
||||
s = s.Trim();
|
||||
|
||||
if (ignoreSpace) {
|
||||
s = Regex.Replace(s, "\\s+", " "); // TODO: optimization: faster blank removal.
|
||||
}
|
||||
|
||||
if (ignoreCase)
|
||||
s = s.ToLower();
|
||||
|
||||
aCode = h[s];
|
||||
if (aCode == null) {
|
||||
lastUsedCode++;
|
||||
h[s] = lastUsedCode;
|
||||
Codes[i] = lastUsedCode;
|
||||
} else {
|
||||
Codes[i] = (int)aCode;
|
||||
} // if
|
||||
} // for
|
||||
return (Codes);
|
||||
} // DiffCodes
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This is the algorithm to find the Shortest Middle Snake (SMS).
|
||||
/// </summary>
|
||||
/// <param name="DataA">sequence A</param>
|
||||
/// <param name="LowerA">lower bound of the actual range in DataA</param>
|
||||
/// <param name="UpperA">upper bound of the actual range in DataA (exclusive)</param>
|
||||
/// <param name="DataB">sequence B</param>
|
||||
/// <param name="LowerB">lower bound of the actual range in DataB</param>
|
||||
/// <param name="UpperB">upper bound of the actual range in DataB (exclusive)</param>
|
||||
/// <param name="DownVector">a vector for the (0,0) to (x,y) search. Passed as a parameter for speed reasons.</param>
|
||||
/// <param name="UpVector">a vector for the (u,v) to (N,M) search. Passed as a parameter for speed reasons.</param>
|
||||
/// <returns>a MiddleSnakeData record containing x,y and u,v</returns>
|
||||
private static SMSRD SMS(DiffData DataA, int LowerA, int UpperA, DiffData DataB, int LowerB, int UpperB,
|
||||
int[] DownVector, int[] UpVector) {
|
||||
|
||||
SMSRD ret;
|
||||
int MAX = DataA.Length + DataB.Length + 1;
|
||||
|
||||
int DownK = LowerA - LowerB; // the k-line to start the forward search
|
||||
int UpK = UpperA - UpperB; // the k-line to start the reverse search
|
||||
|
||||
int Delta = (UpperA - LowerA) - (UpperB - LowerB);
|
||||
bool oddDelta = (Delta & 1) != 0;
|
||||
|
||||
// The vectors in the publication accepts negative indexes. the vectors implemented here are 0-based
|
||||
// and are access using a specific offset: UpOffset UpVector and DownOffset for DownVektor
|
||||
int DownOffset = MAX - DownK;
|
||||
int UpOffset = MAX - UpK;
|
||||
|
||||
int MaxD = ((UpperA - LowerA + UpperB - LowerB) / 2) + 1;
|
||||
|
||||
// Debug.Write(2, "SMS", String.Format("Search the box: A[{0}-{1}] to B[{2}-{3}]", LowerA, UpperA, LowerB, UpperB));
|
||||
|
||||
// init vectors
|
||||
DownVector[DownOffset + DownK + 1] = LowerA;
|
||||
UpVector[UpOffset + UpK - 1] = UpperA;
|
||||
|
||||
for (int D = 0; D <= MaxD; D++) {
|
||||
|
||||
// Extend the forward path.
|
||||
for (int k = DownK - D; k <= DownK + D; k += 2) {
|
||||
// Debug.Write(0, "SMS", "extend forward path " + k.ToString());
|
||||
|
||||
// find the only or better starting point
|
||||
int x, y;
|
||||
if (k == DownK - D) {
|
||||
x = DownVector[DownOffset + k + 1]; // down
|
||||
} else {
|
||||
x = DownVector[DownOffset + k - 1] + 1; // a step to the right
|
||||
if ((k < DownK + D) && (DownVector[DownOffset + k + 1] >= x))
|
||||
x = DownVector[DownOffset + k + 1]; // down
|
||||
}
|
||||
y = x - k;
|
||||
|
||||
// find the end of the furthest reaching forward D-path in diagonal k.
|
||||
while ((x < UpperA) && (y < UpperB) && (DataA.data[x] == DataB.data[y])) {
|
||||
x++; y++;
|
||||
}
|
||||
DownVector[DownOffset + k] = x;
|
||||
|
||||
// overlap ?
|
||||
if (oddDelta && (UpK - D < k) && (k < UpK + D)) {
|
||||
if (UpVector[UpOffset + k] <= DownVector[DownOffset + k]) {
|
||||
ret.x = DownVector[DownOffset + k];
|
||||
ret.y = DownVector[DownOffset + k] - k;
|
||||
// ret.u = UpVector[UpOffset + k]; // 2002.09.20: no need for 2 points
|
||||
// ret.v = UpVector[UpOffset + k] - k;
|
||||
return (ret);
|
||||
} // if
|
||||
} // if
|
||||
|
||||
} // for k
|
||||
|
||||
// Extend the reverse path.
|
||||
for (int k = UpK - D; k <= UpK + D; k += 2) {
|
||||
// Debug.Write(0, "SMS", "extend reverse path " + k.ToString());
|
||||
|
||||
// find the only or better starting point
|
||||
int x, y;
|
||||
if (k == UpK + D) {
|
||||
x = UpVector[UpOffset + k - 1]; // up
|
||||
} else {
|
||||
x = UpVector[UpOffset + k + 1] - 1; // left
|
||||
if ((k > UpK - D) && (UpVector[UpOffset + k - 1] < x))
|
||||
x = UpVector[UpOffset + k - 1]; // up
|
||||
} // if
|
||||
y = x - k;
|
||||
|
||||
while ((x > LowerA) && (y > LowerB) && (DataA.data[x - 1] == DataB.data[y - 1])) {
|
||||
x--; y--; // diagonal
|
||||
}
|
||||
UpVector[UpOffset + k] = x;
|
||||
|
||||
// overlap ?
|
||||
if (!oddDelta && (DownK - D <= k) && (k <= DownK + D)) {
|
||||
if (UpVector[UpOffset + k] <= DownVector[DownOffset + k]) {
|
||||
ret.x = DownVector[DownOffset + k];
|
||||
ret.y = DownVector[DownOffset + k] - k;
|
||||
// ret.u = UpVector[UpOffset + k]; // 2002.09.20: no need for 2 points
|
||||
// ret.v = UpVector[UpOffset + k] - k;
|
||||
return (ret);
|
||||
} // if
|
||||
} // if
|
||||
|
||||
} // for k
|
||||
|
||||
} // for D
|
||||
|
||||
throw new ApplicationException("the algorithm should never come here.");
|
||||
} // SMS
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This is the divide-and-conquer implementation of the longes common-subsequence (LCS)
|
||||
/// algorithm.
|
||||
/// The published algorithm passes recursively parts of the A and B sequences.
|
||||
/// To avoid copying these arrays the lower and upper bounds are passed while the sequences stay constant.
|
||||
/// </summary>
|
||||
/// <param name="DataA">sequence A</param>
|
||||
/// <param name="LowerA">lower bound of the actual range in DataA</param>
|
||||
/// <param name="UpperA">upper bound of the actual range in DataA (exclusive)</param>
|
||||
/// <param name="DataB">sequence B</param>
|
||||
/// <param name="LowerB">lower bound of the actual range in DataB</param>
|
||||
/// <param name="UpperB">upper bound of the actual range in DataB (exclusive)</param>
|
||||
/// <param name="DownVector">a vector for the (0,0) to (x,y) search. Passed as a parameter for speed reasons.</param>
|
||||
/// <param name="UpVector">a vector for the (u,v) to (N,M) search. Passed as a parameter for speed reasons.</param>
|
||||
private static void LCS(DiffData DataA, int LowerA, int UpperA, DiffData DataB, int LowerB, int UpperB, int[] DownVector, int[] UpVector) {
|
||||
// Debug.Write(2, "LCS", String.Format("Analyse the box: A[{0}-{1}] to B[{2}-{3}]", LowerA, UpperA, LowerB, UpperB));
|
||||
|
||||
// Fast walkthrough equal lines at the start
|
||||
while (LowerA < UpperA && LowerB < UpperB && DataA.data[LowerA] == DataB.data[LowerB]) {
|
||||
LowerA++; LowerB++;
|
||||
}
|
||||
|
||||
// Fast walkthrough equal lines at the end
|
||||
while (LowerA < UpperA && LowerB < UpperB && DataA.data[UpperA - 1] == DataB.data[UpperB - 1]) {
|
||||
--UpperA; --UpperB;
|
||||
}
|
||||
|
||||
if (LowerA == UpperA) {
|
||||
// mark as inserted lines.
|
||||
while (LowerB < UpperB)
|
||||
DataB.modified[LowerB++] = true;
|
||||
|
||||
} else if (LowerB == UpperB) {
|
||||
// mark as deleted lines.
|
||||
while (LowerA < UpperA)
|
||||
DataA.modified[LowerA++] = true;
|
||||
|
||||
} else {
|
||||
// Find the middle snakea and length of an optimal path for A and B
|
||||
SMSRD smsrd = SMS(DataA, LowerA, UpperA, DataB, LowerB, UpperB, DownVector, UpVector);
|
||||
// Debug.Write(2, "MiddleSnakeData", String.Format("{0},{1}", smsrd.x, smsrd.y));
|
||||
|
||||
// The path is from LowerX to (x,y) and (x,y) to UpperX
|
||||
LCS(DataA, LowerA, smsrd.x, DataB, LowerB, smsrd.y, DownVector, UpVector);
|
||||
LCS(DataA, smsrd.x, UpperA, DataB, smsrd.y, UpperB, DownVector, UpVector); // 2002.09.20: no need for 2 points
|
||||
}
|
||||
} // LCS()
|
||||
|
||||
|
||||
/// <summary>Scan the tables of which lines are inserted and deleted,
|
||||
/// producing an edit script in forward order.
|
||||
/// </summary>
|
||||
/// dynamic array
|
||||
private static Item[] CreateDiffs(DiffData DataA, DiffData DataB) {
|
||||
ArrayList a = new ArrayList();
|
||||
Item aItem;
|
||||
Item[] result;
|
||||
|
||||
int StartA, StartB;
|
||||
int LineA, LineB;
|
||||
|
||||
LineA = 0;
|
||||
LineB = 0;
|
||||
while (LineA < DataA.Length || LineB < DataB.Length) {
|
||||
if ((LineA < DataA.Length) && (!DataA.modified[LineA])
|
||||
&& (LineB < DataB.Length) && (!DataB.modified[LineB])) {
|
||||
// equal lines
|
||||
LineA++;
|
||||
LineB++;
|
||||
|
||||
} else {
|
||||
// maybe deleted and/or inserted lines
|
||||
StartA = LineA;
|
||||
StartB = LineB;
|
||||
|
||||
while (LineA < DataA.Length && (LineB >= DataB.Length || DataA.modified[LineA]))
|
||||
// while (LineA < DataA.Length && DataA.modified[LineA])
|
||||
LineA++;
|
||||
|
||||
while (LineB < DataB.Length && (LineA >= DataA.Length || DataB.modified[LineB]))
|
||||
// while (LineB < DataB.Length && DataB.modified[LineB])
|
||||
LineB++;
|
||||
|
||||
if ((StartA < LineA) || (StartB < LineB)) {
|
||||
// store a new difference-item
|
||||
aItem = new Item();
|
||||
aItem.StartA = StartA;
|
||||
aItem.StartB = StartB;
|
||||
aItem.deletedA = LineA - StartA;
|
||||
aItem.insertedB = LineB - StartB;
|
||||
a.Add(aItem);
|
||||
} // if
|
||||
} // if
|
||||
} // while
|
||||
|
||||
result = new Item[a.Count];
|
||||
a.CopyTo(result);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
} // class Diff
|
||||
|
||||
/// <summary>Data on one input file being compared.
|
||||
/// </summary>
|
||||
internal class DiffData
|
||||
{
|
||||
|
||||
/// <summary>Number of elements (lines).</summary>
|
||||
internal int Length;
|
||||
|
||||
/// <summary>Buffer of numbers that will be compared.</summary>
|
||||
internal int[] data;
|
||||
|
||||
/// <summary>
|
||||
/// Array of booleans that flag for modified data.
|
||||
/// This is the result of the diff.
|
||||
/// This means deletedA in the first Data or inserted in the second Data.
|
||||
/// </summary>
|
||||
internal bool[] modified;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the Diff-Data buffer.
|
||||
/// </summary>
|
||||
/// <param name="data">reference to the buffer</param>
|
||||
internal DiffData(int[] initData) {
|
||||
data = initData;
|
||||
Length = initData.Length;
|
||||
modified = new bool[Length + 2];
|
||||
} // DiffData
|
||||
|
||||
} // class DiffData
|
||||
|
||||
{.pop.}
|
||||
73
lib/base/devel/lex.nim
Normal file
73
lib/base/devel/lex.nim
Normal file
@@ -0,0 +1,73 @@
|
||||
# Lexer generator for Nimrod
|
||||
# (c) 2008 Andreas Rumpf
|
||||
|
||||
# Stress testing for the macro feature
|
||||
|
||||
# the syntax that should be supported is:
|
||||
|
||||
# template numpostfix =
|
||||
# '\'' & 'F'|'f'|'i'|'I' & "32"|"64"|"8"|"16"
|
||||
# template edigits =
|
||||
# 'e'|'E' & +digits
|
||||
# tokens(
|
||||
# tkIdent: +UniIdentStart & *UniIdentRest,
|
||||
# tkHexNumber: '0' & ('x'|'X') & +hexDigits & ?( numpostfix ),
|
||||
# tkOctNumber: '0' & ('c'|'C') & +octDigits & ?( numpostfix ),
|
||||
# tkBinNumber: '0' & ('b'|'B') & +binDigits & ?( numpostfix ),
|
||||
# tkIntNumber: +digits & ?( numpostfix ),
|
||||
# tkFloatNumber: +digits & ('.' & +digits & ?(edigits) | edigits) & ?(numpostfix),
|
||||
#
|
||||
# )
|
||||
# actions(
|
||||
# tkIdent: lookup
|
||||
# )
|
||||
#
|
||||
|
||||
#
|
||||
# match inputstream
|
||||
# of +('A'..'Z' | '_' | 'a'..'z') *('A'..'Z' | '_' | 'a'..'z' | '0'..'9') :
|
||||
#
|
||||
# x = inputstream[pos..length]
|
||||
# of '0' 'x' +('0'..'9' | 'a'..'f' | '_' | 'A'..'F') :
|
||||
# y = ...
|
||||
|
||||
const
|
||||
AsciiLetter = {'A'..'Z', 'a'..'z'}
|
||||
uniLetter = AsciiLetter + {'\128'..'\255'}
|
||||
digits = {'0'..'9'}
|
||||
hexDigits = {'0'..'9', 'a'..'f', 'A'..'F'}
|
||||
octDigits = {'0'..'7'}
|
||||
binDigits = {'0'..'1'}
|
||||
AsciiIdentStart = AsciiLetter + {'_'}
|
||||
AsciiIdentRest = AsciiIdentStart + Digits
|
||||
UniIdentStart = UniLetter + {'_'}
|
||||
UniIdentRest = UniIdentStart + Digits
|
||||
|
||||
# --> if match(s, +AsciiIdentStart & *AsciiIdentRest):
|
||||
|
||||
# Regular expressions in Nimrod itself!
|
||||
# -------------------------------------
|
||||
#
|
||||
# 'a' -- matches the character a
|
||||
# 'a'..'z' -- range operator '-'
|
||||
# 'A' | 'B' -- alternative operator |
|
||||
# * 'a' -- prefix * is needed
|
||||
# + 'a' -- prefix + is needed
|
||||
# ? 'a' -- prefix ? is needed
|
||||
# *? prefix is needed
|
||||
# +? prefix is needed
|
||||
# letter -- character classes with real names!
|
||||
# letters
|
||||
# white
|
||||
# whites
|
||||
# any -- any character
|
||||
# () -- are Nimrod syntax
|
||||
# ! 'a'-'z'
|
||||
#
|
||||
# -- concatentation via proc call:
|
||||
#
|
||||
# re('A' 'Z' *word )
|
||||
|
||||
macro re(n: expr): expr =
|
||||
|
||||
result = newCall("magic_re", x)
|
||||
124
lib/base/devel/nregex.nim
Normal file
124
lib/base/devel/nregex.nim
Normal file
@@ -0,0 +1,124 @@
|
||||
# new implementation of regular expressions
|
||||
|
||||
type
|
||||
TRegexKind = enum
|
||||
regNone,
|
||||
regChar,
|
||||
regSet,
|
||||
regConc,
|
||||
regAlt,
|
||||
regStar,
|
||||
regPlus,
|
||||
regMN,
|
||||
regNewline
|
||||
|
||||
TRegex = object of TObject
|
||||
case kind: TRegexKind
|
||||
of regChar: c: char
|
||||
of regSet: s: ref set[char]
|
||||
else: a, b: PRegEx
|
||||
|
||||
PRegEx* = ref TRegEx
|
||||
|
||||
TRegExFlag* = enum ## Flags concerning the semantics of regular expressions
|
||||
reCaseInsensitive, ## case insensitive match
|
||||
reStyleInsensitive ## style insensitive match
|
||||
|
||||
|
||||
TRegExFlags* = set[TRegExFlag]
|
||||
## Flags concerning the semantics of regular expressions
|
||||
|
||||
proc raiseRegex(msg: string) {.noreturn.} =
|
||||
var e: ref Exception
|
||||
new(e)
|
||||
e.msg = msg
|
||||
raise e
|
||||
|
||||
proc compileAux(i: int, s: string, r: PRegEx): int
|
||||
|
||||
proc compileBackslash(i: int, s: string, r: PRegEx): int =
|
||||
var i = i
|
||||
inc(i)
|
||||
case s[i]
|
||||
of 'A'..'Z':
|
||||
of 'a'..'z':
|
||||
of '0':
|
||||
of '1'..'9':
|
||||
|
||||
else:
|
||||
r.kind = regChar
|
||||
r.c = s[i]
|
||||
inc(i)
|
||||
result = i
|
||||
|
||||
proc compileAtom(i: int, s: string, r: PRegEx): int =
|
||||
var i = i
|
||||
case s[i]
|
||||
of '[':
|
||||
inc(i)
|
||||
var inverse = s[i] == '^'
|
||||
if inverse: inc(i)
|
||||
r.kind = regSet
|
||||
new(r.s)
|
||||
while true:
|
||||
case s[i]
|
||||
of '\\': i = compileBackslash(i, s, r)
|
||||
of ']':
|
||||
inc(i)
|
||||
break
|
||||
of '\0':
|
||||
raiseRegex("']' expected")
|
||||
elif s[i+1] == '-':
|
||||
var x = s[i]
|
||||
inc(i, 2)
|
||||
var y = s[i]
|
||||
inc(i)
|
||||
r.s = r.s + {x..y}
|
||||
else:
|
||||
incl(r.s, s[i])
|
||||
inc(i)
|
||||
if inverse:
|
||||
r.s = {'\0'..'\255'} - r.s
|
||||
of '\\':
|
||||
inc(i)
|
||||
i = compileBackslash(i, s, r)
|
||||
of '.':
|
||||
r.kind = regAny
|
||||
inc(i)
|
||||
of '(':
|
||||
inc(i)
|
||||
i = compileAux(i, s, r)
|
||||
if s[i] = ')': inc(i)
|
||||
else: raiseRegex("')' expected")
|
||||
of '\0': nil # do nothing
|
||||
else:
|
||||
r.kind = regChar
|
||||
r.c = s[i]
|
||||
inc(i)
|
||||
result = i
|
||||
|
||||
proc compilePostfix(i: int, s: string, r: PRegEx): int =
|
||||
var i = compileAtom(i, s, r)
|
||||
var a: PRegEx
|
||||
case s[i]
|
||||
of '*':
|
||||
of '+':
|
||||
of '?':
|
||||
else: nil
|
||||
|
||||
proc compileAux(i: int, s: string, r: PRegEx): int =
|
||||
var i = i
|
||||
i = compileAtom(i, s, r)
|
||||
|
||||
while s[i] != '\0':
|
||||
|
||||
result = i
|
||||
|
||||
proc compile*(regex: string, flags: TRegExFlags = {}): PRegEx =
|
||||
## Compiles the string `regex` that represents a regular expression into
|
||||
## an internal data structure that can be used for matching.
|
||||
new(result)
|
||||
var i = compileAux(0, regex, result)
|
||||
if i < len(regex)-1:
|
||||
# not all characters used for the regular expression?
|
||||
raiseRegEx("invalid regular expression")
|
||||
1877
lib/base/devel/python.nim
Normal file
1877
lib/base/devel/python.nim
Normal file
File diff suppressed because it is too large
Load Diff
2205
lib/base/devel/python.pas
Normal file
2205
lib/base/devel/python.pas
Normal file
File diff suppressed because it is too large
Load Diff
224
lib/base/lua/lauxlib.nim
Normal file
224
lib/base/lua/lauxlib.nim
Normal file
@@ -0,0 +1,224 @@
|
||||
#*****************************************************************************
|
||||
# * *
|
||||
# * File: lauxlib.pas *
|
||||
# * Authors: TeCGraf (C headers + actual Lua libraries) *
|
||||
# * Lavergne Thomas (original translation to Pascal) *
|
||||
# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) *
|
||||
# * Description: Lua auxiliary library *
|
||||
# * *
|
||||
# *****************************************************************************
|
||||
#
|
||||
#** $Id: lauxlib.h,v 1.59 2003/03/18 12:25:32 roberto Exp $
|
||||
#** Auxiliary functions for building Lua libraries
|
||||
#** See Copyright Notice in lua.h
|
||||
#
|
||||
#
|
||||
#** Translated to pascal by Lavergne Thomas
|
||||
#** Notes :
|
||||
#** - Pointers type was prefixed with 'P'
|
||||
#** Bug reports :
|
||||
#** - thomas.lavergne@laposte.net
|
||||
#** In french or in english
|
||||
#
|
||||
|
||||
import "lib/base/lua/lua"
|
||||
|
||||
proc lua_pushstring*(L: Plua_State, s: string)
|
||||
# compatibilty macros
|
||||
proc luaL_getn*(L: Plua_State, n: int): int
|
||||
# calls lua_objlen
|
||||
proc luaL_setn*(L: Plua_State, t, n: int)
|
||||
# does nothing!
|
||||
type
|
||||
TLuaL_reg*{.final.} = object
|
||||
name*: cstring
|
||||
func*: lua_CFunction
|
||||
|
||||
PluaL_reg* = ptr TLuaL_reg
|
||||
|
||||
proc luaL_openlib*(L: Plua_State, libname: cstring, lr: PluaL_reg, nup: int){.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_register*(L: Plua_State, libname: cstring, lr: PluaL_reg){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_getmetafield*(L: Plua_State, obj: int, e: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_callmeta*(L: Plua_State, obj: int, e: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_typerror*(L: Plua_State, narg: int, tname: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_argerror*(L: Plua_State, numarg: int, extramsg: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_checklstring*(L: Plua_State, numArg: int, l_: Psize_t): cstring{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_optlstring*(L: Plua_State, numArg: int, def: cstring, l_: Psize_t): cstring{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_checknumber*(L: Plua_State, numArg: int): lua_Number{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_optnumber*(L: Plua_State, nArg: int, def: lua_Number): lua_Number{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_checkinteger*(L: Plua_State, numArg: int): lua_Integer{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_optinteger*(L: Plua_State, nArg: int, def: lua_Integer): lua_Integer{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_checkstack*(L: Plua_State, sz: int, msg: cstring){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_checktype*(L: Plua_State, narg, t: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaL_checkany*(L: Plua_State, narg: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaL_newmetatable*(L: Plua_State, tname: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_checkudata*(L: Plua_State, ud: int, tname: cstring): Pointer{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_where*(L: Plua_State, lvl: int){.cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_error*(L: Plua_State, fmt: cstring): int{.cdecl, varargs,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_checkoption*(L: Plua_State, narg: int, def: cstring, lst: cstringArray): int{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_ref*(L: Plua_State, t: int): int{.cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_unref*(L: Plua_State, t, theref: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaL_loadfile*(L: Plua_State, filename: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_loadbuffer*(L: Plua_State, buff: cstring, size: size_t, name: cstring): int{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_loadstring*(L: Plua_State, s: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_newstate*(): Plua_State{.cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc lua_open*(): Plua_State
|
||||
# compatibility; moved from unit lua to lauxlib because it needs luaL_newstate
|
||||
#
|
||||
#** ===============================================================
|
||||
#** some useful macros
|
||||
#** ===============================================================
|
||||
#
|
||||
proc luaL_argcheck*(L: Plua_State, cond: bool, numarg: int, extramsg: cstring)
|
||||
proc luaL_checkstring*(L: Plua_State, n: int): cstring
|
||||
proc luaL_optstring*(L: Plua_State, n: int, d: cstring): cstring
|
||||
proc luaL_checkint*(L: Plua_State, n: int): int
|
||||
proc luaL_checklong*(L: Plua_State, n: int): int32
|
||||
proc luaL_optint*(L: Plua_State, n: int, d: float64): int
|
||||
proc luaL_optlong*(L: Plua_State, n: int, d: float64): int32
|
||||
proc luaL_typename*(L: Plua_State, i: int): cstring
|
||||
proc lua_dofile*(L: Plua_State, filename: cstring): int
|
||||
proc lua_dostring*(L: Plua_State, str: cstring): int
|
||||
proc lua_Lgetmetatable*(L: Plua_State, tname: cstring)
|
||||
# not translated:
|
||||
# #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
|
||||
#
|
||||
#** =======================================================
|
||||
#** Generic Buffer manipulation
|
||||
#** =======================================================
|
||||
#
|
||||
const # note: this is just arbitrary, as it related to the BUFSIZ defined in stdio.h ...
|
||||
LUAL_BUFFERSIZE* = 4096
|
||||
|
||||
type
|
||||
luaL_Buffer*{.final.} = object
|
||||
p*: cstring # current position in buffer
|
||||
lvl*: int # number of strings in the stack (level)
|
||||
L*: Plua_State
|
||||
buffer*: array[0..LUAL_BUFFERSIZE - 1, Char] # warning: see note above about LUAL_BUFFERSIZE
|
||||
|
||||
PluaL_Buffer* = ptr luaL_Buffer
|
||||
|
||||
proc luaL_addchar*(B: PluaL_Buffer, c: Char)
|
||||
# warning: see note above about LUAL_BUFFERSIZE
|
||||
# compatibility only (alias for luaL_addchar)
|
||||
proc luaL_putchar*(B: PluaL_Buffer, c: Char)
|
||||
# warning: see note above about LUAL_BUFFERSIZE
|
||||
proc luaL_addsize*(B: PluaL_Buffer, n: int)
|
||||
proc luaL_buffinit*(L: Plua_State, B: PluaL_Buffer){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_prepbuffer*(B: PluaL_Buffer): cstring{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaL_addlstring*(B: PluaL_Buffer, s: cstring, L: size_t){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_addstring*(B: PluaL_Buffer, s: cstring){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaL_addvalue*(B: PluaL_Buffer){.cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_pushresult*(B: PluaL_Buffer){.cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_gsub*(L: Plua_State, s, p, r: cstring): cstring{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaL_findtable*(L: Plua_State, idx: int, fname: cstring, szhint: int): cstring{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
# compatibility with ref system
|
||||
# pre-defined references
|
||||
const
|
||||
LUA_NOREF* = - 2
|
||||
LUA_REFNIL* = - 1
|
||||
|
||||
proc lua_unref*(L: Plua_State, theref: int)
|
||||
proc lua_getref*(L: Plua_State, theref: int)
|
||||
#
|
||||
#** Compatibility macros and functions
|
||||
#
|
||||
|
||||
# implementation
|
||||
|
||||
proc lua_pushstring(L: Plua_State, s: string) =
|
||||
lua_pushlstring(L, cstring(s), len(s))
|
||||
|
||||
proc luaL_getn(L: Plua_State, n: int): int =
|
||||
Result = lua_objlen(L, n)
|
||||
|
||||
proc luaL_setn(L: Plua_State, t, n: int) =
|
||||
# does nothing as this operation is deprecated
|
||||
nil
|
||||
|
||||
proc lua_open(): Plua_State =
|
||||
Result = luaL_newstate()
|
||||
|
||||
proc luaL_typename(L: Plua_State, i: int): cstring =
|
||||
Result = lua_typename(L, lua_type(L, i))
|
||||
|
||||
proc lua_dofile(L: Plua_State, filename: cstring): int =
|
||||
Result = luaL_loadfile(L, filename)
|
||||
if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0)
|
||||
|
||||
proc lua_dostring(L: Plua_State, str: cstring): int =
|
||||
Result = luaL_loadstring(L, str)
|
||||
if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0)
|
||||
|
||||
proc lua_Lgetmetatable(L: Plua_State, tname: cstring) =
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, tname)
|
||||
|
||||
proc luaL_argcheck(L: Plua_State, cond: bool, numarg: int, extramsg: cstring) =
|
||||
if not cond:
|
||||
discard luaL_argerror(L, numarg, extramsg)
|
||||
|
||||
proc luaL_checkstring(L: Plua_State, n: int): cstring =
|
||||
Result = luaL_checklstring(L, n, nil)
|
||||
|
||||
proc luaL_optstring(L: Plua_State, n: int, d: cstring): cstring =
|
||||
Result = luaL_optlstring(L, n, d, nil)
|
||||
|
||||
proc luaL_checkint(L: Plua_State, n: int): int =
|
||||
Result = toInt(luaL_checknumber(L, n))
|
||||
|
||||
proc luaL_checklong(L: Plua_State, n: int): int32 =
|
||||
Result = int32(ToInt(luaL_checknumber(L, n)))
|
||||
|
||||
proc luaL_optint(L: Plua_State, n: int, d: float64): int =
|
||||
Result = int(ToInt(luaL_optnumber(L, n, d)))
|
||||
|
||||
proc luaL_optlong(L: Plua_State, n: int, d: float64): int32 =
|
||||
Result = int32(ToInt(luaL_optnumber(L, n, d)))
|
||||
|
||||
proc luaL_addchar(B: PluaL_Buffer, c: Char) =
|
||||
if cast[int](addr((B.p))) < (cast[int](addr((B.buffer[0]))) + LUAL_BUFFERSIZE):
|
||||
discard luaL_prepbuffer(B)
|
||||
B.p[1] = c
|
||||
B.p = cast[cstring](cast[int](B.p) + 1)
|
||||
|
||||
proc luaL_putchar(B: PluaL_Buffer, c: Char) =
|
||||
luaL_addchar(B, c)
|
||||
|
||||
proc luaL_addsize(B: PluaL_Buffer, n: int) =
|
||||
B.p = cast[cstring](cast[int](B.p) + n)
|
||||
|
||||
proc lua_unref(L: Plua_State, theref: int) =
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, theref)
|
||||
|
||||
proc lua_getref(L: Plua_State, theref: int) =
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, theref)
|
||||
384
lib/base/lua/lua.nim
Normal file
384
lib/base/lua/lua.nim
Normal file
@@ -0,0 +1,384 @@
|
||||
#*****************************************************************************
|
||||
# * *
|
||||
# * File: lua.pas *
|
||||
# * Authors: TeCGraf (C headers + actual Lua libraries) *
|
||||
# * Lavergne Thomas (original translation to Pascal) *
|
||||
# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) *
|
||||
# * Description: Basic Lua library *
|
||||
# * *
|
||||
# *****************************************************************************
|
||||
#
|
||||
#** $Id: lua.h,v 1.175 2003/03/18 12:31:39 roberto Exp $
|
||||
#** Lua - An Extensible Extension Language
|
||||
#** TeCGraf: Computer Graphics Technology Group, PUC-Rio, Brazil
|
||||
#** http://www.lua.org mailto:info@lua.org
|
||||
#** See Copyright Notice at the end of this file
|
||||
#
|
||||
#
|
||||
#** Updated to Lua 5.1.1 by Bram Kuijvenhoven (bram at kuijvenhoven dot net),
|
||||
#** Hexis BV (http://www.hexis.nl), the Netherlands
|
||||
#** Notes:
|
||||
#** - Only tested with FPC (FreePascal Compiler)
|
||||
#** - Using LuaBinaries styled DLL/SO names, which include version names
|
||||
#** - LUA_YIELD was suffixed by '_' for avoiding name collision
|
||||
#
|
||||
#
|
||||
#** Translated to pascal by Lavergne Thomas
|
||||
#** Notes :
|
||||
#** - Pointers type was prefixed with 'P'
|
||||
#** - lua_upvalueindex constant was transformed to function
|
||||
#** - Some compatibility function was isolated because with it you must have
|
||||
#** lualib.
|
||||
#** - LUA_VERSION was suffixed by '_' for avoiding name collision.
|
||||
#** Bug reports :
|
||||
#** - thomas.lavergne@laposte.net
|
||||
#** In french or in english
|
||||
#
|
||||
|
||||
when defined(MACOSX):
|
||||
const
|
||||
LUA_NAME* = "liblua5.1.dylib"
|
||||
LUA_LIB_NAME* = "liblua5.1.dylib"
|
||||
elif defined(UNIX):
|
||||
const
|
||||
LUA_NAME* = "liblua5.1.so"
|
||||
LUA_LIB_NAME* = "liblua5.1.so"
|
||||
else:
|
||||
const
|
||||
LUA_NAME* = "lua5.1.dll"
|
||||
LUA_LIB_NAME* = "lua5.1.dll"
|
||||
type
|
||||
size_t* = int
|
||||
Psize_t* = ptr size_t
|
||||
|
||||
const
|
||||
LUA_VERSION* = "Lua 5.1"
|
||||
LUA_RELEASE* = "Lua 5.1.1"
|
||||
LUA_VERSION_NUM* = 501
|
||||
LUA_COPYRIGHT* = "Copyright (C) 1994-2006 Lua.org, PUC-Rio"
|
||||
LUA_AUTHORS* = "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" # option for multiple returns in `lua_pcall' and `lua_call'
|
||||
LUA_MULTRET* = - 1 #
|
||||
#** pseudo-indices
|
||||
#
|
||||
LUA_REGISTRYINDEX* = - 10000
|
||||
LUA_ENVIRONINDEX* = - 10001
|
||||
LUA_GLOBALSINDEX* = - 10002
|
||||
|
||||
proc lua_upvalueindex*(I: int): int
|
||||
const # thread status; 0 is OK
|
||||
LUA_YIELD_* = 1
|
||||
LUA_ERRRUN* = 2
|
||||
LUA_ERRSYNTAX* = 3
|
||||
LUA_ERRMEM* = 4
|
||||
LUA_ERRERR* = 5
|
||||
|
||||
type
|
||||
Plua_State* = Pointer
|
||||
lua_CFunction* = proc (L: Plua_State): int{.cdecl.} #
|
||||
#** functions that read/write blocks when loading/dumping Lua chunks
|
||||
#
|
||||
|
||||
type
|
||||
lua_Reader* = proc (L: Plua_State, ud: Pointer, sz: Psize_t): cstring{.cdecl.}
|
||||
lua_Writer* = proc (L: Plua_State, p: Pointer, sz: size_t, ud: Pointer): int{.
|
||||
cdecl.} #
|
||||
#** prototype for memory-allocation functions
|
||||
#
|
||||
lua_Alloc* = proc (ud, theptr: Pointer, osize, nsize: size_t){.cdecl.}
|
||||
|
||||
const
|
||||
LUA_TNONE* = - 1
|
||||
LUA_TNIL* = 0
|
||||
LUA_TBOOLEAN* = 1
|
||||
LUA_TLIGHTUSERDATA* = 2
|
||||
LUA_TNUMBER* = 3
|
||||
LUA_TSTRING* = 4
|
||||
LUA_TTABLE* = 5
|
||||
LUA_TFUNCTION* = 6
|
||||
LUA_TUSERDATA* = 7
|
||||
LUA_TTHREAD* = 8 # minimum Lua stack available to a C function
|
||||
LUA_MINSTACK* = 20
|
||||
|
||||
type # Type of Numbers in Lua
|
||||
lua_Number* = float
|
||||
lua_Integer* = int
|
||||
|
||||
proc lua_newstate*(f: lua_Alloc, ud: Pointer): Plua_State{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_close*(L: Plua_State){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_newthread*(L: Plua_State): Plua_State{.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_atpanic*(L: Plua_State, panicf: lua_CFunction): lua_CFunction{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_gettop*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_settop*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_pushvalue*(L: Plua_State, Idx: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_remove*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_insert*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_replace*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_checkstack*(L: Plua_State, sz: int): cint{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_xmove*(`from`, `to`: Plua_State, n: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_isnumber*(L: Plua_State, idx: int): cint{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_isstring*(L: Plua_State, idx: int): cint{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_iscfunction*(L: Plua_State, idx: int): cint{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_isuserdata*(L: Plua_State, idx: int): cint{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_type*(L: Plua_State, idx: int): int{.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_typename*(L: Plua_State, tp: int): cstring{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_equal*(L: Plua_State, idx1, idx2: int): cint{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_rawequal*(L: Plua_State, idx1, idx2: int): cint{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_lessthan*(L: Plua_State, idx1, idx2: int): cint{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_tonumber*(L: Plua_State, idx: int): lua_Number{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_tointeger*(L: Plua_State, idx: int): lua_Integer{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_toboolean*(L: Plua_State, idx: int): cint{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_tolstring*(L: Plua_State, idx: int, length: Psize_t): cstring{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_objlen*(L: Plua_State, idx: int): size_t{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_tocfunction*(L: Plua_State, idx: int): lua_CFunction{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_touserdata*(L: Plua_State, idx: int): Pointer{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_tothread*(L: Plua_State, idx: int): Plua_State{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_topointer*(L: Plua_State, idx: int): Pointer{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_pushnil*(L: Plua_State){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_pushnumber*(L: Plua_State, n: lua_Number){.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_pushinteger*(L: Plua_State, n: lua_Integer){.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_pushlstring*(L: Plua_State, s: cstring, l_: size_t){.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_pushstring*(L: Plua_State, s: cstring){.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_pushvfstring*(L: Plua_State, fmt: cstring, argp: Pointer): cstring{.
|
||||
cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_pushfstring*(L: Plua_State, fmt: cstring): cstring{.cdecl, varargs,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_pushcclosure*(L: Plua_State, fn: lua_CFunction, n: int){.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_pushboolean*(L: Plua_State, b: cint){.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_pushlightuserdata*(L: Plua_State, p: Pointer){.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_pushthread*(L: Plua_State){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_gettable*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_getfield*(L: Plua_state, idx: int, k: cstring){.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_rawget*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_rawgeti*(L: Plua_State, idx, n: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_createtable*(L: Plua_State, narr, nrec: int){.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_newuserdata*(L: Plua_State, sz: size_t): Pointer{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_getmetatable*(L: Plua_State, objindex: int): int{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_getfenv*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_settable*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_setfield*(L: Plua_State, idx: int, k: cstring){.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_rawset*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_rawseti*(L: Plua_State, idx, n: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_setmetatable*(L: Plua_State, objindex: int): int{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_setfenv*(L: Plua_State, idx: int): int{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_call*(L: Plua_State, nargs, nresults: int){.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_pcall*(L: Plua_State, nargs, nresults, errf: int): int{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_cpcall*(L: Plua_State, func: lua_CFunction, ud: Pointer): int{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_load*(L: Plua_State, reader: lua_Reader, dt: Pointer,
|
||||
chunkname: cstring): int{.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_dump*(L: Plua_State, writer: lua_Writer, data: Pointer): int{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_yield*(L: Plua_State, nresults: int): int{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_resume*(L: Plua_State, narg: int): int{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_status*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_gc*(L: Plua_State, what, data: int): int{.cdecl, dynlib: LUA_NAME,
|
||||
importc.}
|
||||
proc lua_error*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_next*(L: Plua_State, idx: int): int{.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_concat*(L: Plua_State, n: int){.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_getallocf*(L: Plua_State, ud: ptr Pointer): lua_Alloc{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_setallocf*(L: Plua_State, f: lua_Alloc, ud: Pointer){.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
#
|
||||
#** Garbage-collection functions and options
|
||||
#
|
||||
const
|
||||
LUA_GCSTOP* = 0
|
||||
LUA_GCRESTART* = 1
|
||||
LUA_GCCOLLECT* = 2
|
||||
LUA_GCCOUNT* = 3
|
||||
LUA_GCCOUNTB* = 4
|
||||
LUA_GCSTEP* = 5
|
||||
LUA_GCSETPAUSE* = 6
|
||||
LUA_GCSETSTEPMUL* = 7 #
|
||||
#** ===============================================================
|
||||
#** some useful macros
|
||||
#** ===============================================================
|
||||
#
|
||||
|
||||
proc lua_pop*(L: Plua_State, n: int)
|
||||
proc lua_newtable*(L: Plua_state)
|
||||
proc lua_register*(L: Plua_State, n: cstring, f: lua_CFunction)
|
||||
proc lua_pushcfunction*(L: Plua_State, f: lua_CFunction)
|
||||
proc lua_strlen*(L: Plua_state, i: int): size_t
|
||||
proc lua_isfunction*(L: Plua_State, n: int): bool
|
||||
proc lua_istable*(L: Plua_State, n: int): bool
|
||||
proc lua_islightuserdata*(L: Plua_State, n: int): bool
|
||||
proc lua_isnil*(L: Plua_State, n: int): bool
|
||||
proc lua_isboolean*(L: Plua_State, n: int): bool
|
||||
proc lua_isthread*(L: Plua_State, n: int): bool
|
||||
proc lua_isnone*(L: Plua_State, n: int): bool
|
||||
proc lua_isnoneornil*(L: Plua_State, n: int): bool
|
||||
proc lua_pushliteral*(L: Plua_State, s: cstring)
|
||||
proc lua_setglobal*(L: Plua_State, s: cstring)
|
||||
proc lua_getglobal*(L: Plua_State, s: cstring)
|
||||
proc lua_tostring*(L: Plua_State, i: int): cstring
|
||||
#
|
||||
#** compatibility macros and functions
|
||||
#
|
||||
proc lua_getregistry*(L: Plua_State)
|
||||
proc lua_getgccount*(L: Plua_State): int
|
||||
type
|
||||
lua_Chunkreader* = lua_Reader
|
||||
lua_Chunkwriter* = lua_Writer #
|
||||
#** {======================================================================
|
||||
#** Debug API
|
||||
#** =======================================================================
|
||||
#
|
||||
|
||||
const
|
||||
LUA_HOOKCALL* = 0
|
||||
LUA_HOOKRET* = 1
|
||||
LUA_HOOKLINE* = 2
|
||||
LUA_HOOKCOUNT* = 3
|
||||
LUA_HOOKTAILRET* = 4
|
||||
|
||||
const
|
||||
LUA_MASKCALL* = 1 shl Ord(LUA_HOOKCALL)
|
||||
LUA_MASKRET* = 1 shl Ord(LUA_HOOKRET)
|
||||
LUA_MASKLINE* = 1 shl Ord(LUA_HOOKLINE)
|
||||
LUA_MASKCOUNT* = 1 shl Ord(LUA_HOOKCOUNT)
|
||||
|
||||
const
|
||||
LUA_IDSIZE* = 60
|
||||
|
||||
type
|
||||
lua_Debug*{.final.} = object # activation record
|
||||
event*: int
|
||||
name*: cstring # (n)
|
||||
namewhat*: cstring # (n) `global', `local', `field', `method'
|
||||
what*: cstring # (S) `Lua', `C', `main', `tail'
|
||||
source*: cstring # (S)
|
||||
currentline*: int # (l)
|
||||
nups*: int # (u) number of upvalues
|
||||
linedefined*: int # (S)
|
||||
lastlinedefined*: int # (S)
|
||||
short_src*: array[0..LUA_IDSIZE - 1, Char] # (S)
|
||||
# private part
|
||||
i_ci*: int # active function
|
||||
|
||||
Plua_Debug* = ptr lua_Debug
|
||||
lua_Hook* = proc (L: Plua_State, ar: Plua_Debug){.cdecl.} #
|
||||
#** {======================================================================
|
||||
#** Debug API
|
||||
#** =======================================================================
|
||||
#
|
||||
|
||||
proc lua_getstack*(L: Plua_State, level: int, ar: Plua_Debug): int{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_getinfo*(L: Plua_State, what: cstring, ar: Plua_Debug): int{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_getlocal*(L: Plua_State, ar: Plua_Debug, n: int): cstring{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_setlocal*(L: Plua_State, ar: Plua_Debug, n: int): cstring{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_getupvalue*(L: Plua_State, funcindex: int, n: int): cstring{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_setupvalue*(L: Plua_State, funcindex: int, n: int): cstring{.cdecl,
|
||||
dynlib: LUA_NAME, importc.}
|
||||
proc lua_sethook*(L: Plua_State, func: lua_Hook, mask: int, count: int): int{.
|
||||
cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_gethook*(L: Plua_State): lua_Hook{.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_gethookmask*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.}
|
||||
proc lua_gethookcount*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.}
|
||||
# implementation
|
||||
|
||||
proc lua_upvalueindex(I: int): int =
|
||||
Result = LUA_GLOBALSINDEX - i
|
||||
|
||||
proc lua_pop(L: Plua_State, n: int) =
|
||||
lua_settop(L, - n - 1)
|
||||
|
||||
proc lua_newtable(L: Plua_State) =
|
||||
lua_createtable(L, 0, 0)
|
||||
|
||||
proc lua_register(L: Plua_State, n: cstring, f: lua_CFunction) =
|
||||
lua_pushcfunction(L, f)
|
||||
lua_setglobal(L, n)
|
||||
|
||||
proc lua_pushcfunction(L: Plua_State, f: lua_CFunction) =
|
||||
lua_pushcclosure(L, f, 0)
|
||||
|
||||
proc lua_strlen(L: Plua_State, i: int): size_t =
|
||||
Result = lua_objlen(L, i)
|
||||
|
||||
proc lua_isfunction(L: Plua_State, n: int): bool =
|
||||
Result = lua_type(L, n) == LUA_TFUNCTION
|
||||
|
||||
proc lua_istable(L: Plua_State, n: int): bool =
|
||||
Result = lua_type(L, n) == LUA_TTABLE
|
||||
|
||||
proc lua_islightuserdata(L: Plua_State, n: int): bool =
|
||||
Result = lua_type(L, n) == LUA_TLIGHTUSERDATA
|
||||
|
||||
proc lua_isnil(L: Plua_State, n: int): bool =
|
||||
Result = lua_type(L, n) == LUA_TNIL
|
||||
|
||||
proc lua_isboolean(L: Plua_State, n: int): bool =
|
||||
Result = lua_type(L, n) == LUA_TBOOLEAN
|
||||
|
||||
proc lua_isthread(L: Plua_State, n: int): bool =
|
||||
Result = lua_type(L, n) == LUA_TTHREAD
|
||||
|
||||
proc lua_isnone(L: Plua_State, n: int): bool =
|
||||
Result = lua_type(L, n) == LUA_TNONE
|
||||
|
||||
proc lua_isnoneornil(L: Plua_State, n: int): bool =
|
||||
Result = lua_type(L, n) <= 0
|
||||
|
||||
proc lua_pushliteral(L: Plua_State, s: cstring) =
|
||||
lua_pushlstring(L, s, len(s))
|
||||
|
||||
proc lua_setglobal(L: Plua_State, s: cstring) =
|
||||
lua_setfield(L, LUA_GLOBALSINDEX, s)
|
||||
|
||||
proc lua_getglobal(L: Plua_State, s: cstring) =
|
||||
lua_getfield(L, LUA_GLOBALSINDEX, s)
|
||||
|
||||
proc lua_tostring(L: Plua_State, i: int): cstring =
|
||||
Result = lua_tolstring(L, i, nil)
|
||||
|
||||
proc lua_getregistry(L: Plua_State) =
|
||||
lua_pushvalue(L, LUA_REGISTRYINDEX)
|
||||
|
||||
proc lua_getgccount(L: Plua_State): int =
|
||||
Result = lua_gc(L, LUA_GCCOUNT, 0)
|
||||
73
lib/base/lua/lualib.nim
Normal file
73
lib/base/lua/lualib.nim
Normal file
@@ -0,0 +1,73 @@
|
||||
#*****************************************************************************
|
||||
# * *
|
||||
# * File: lualib.pas *
|
||||
# * Authors: TeCGraf (C headers + actual Lua libraries) *
|
||||
# * Lavergne Thomas (original translation to Pascal) *
|
||||
# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) *
|
||||
# * Description: Standard Lua libraries *
|
||||
# * *
|
||||
# *****************************************************************************
|
||||
#
|
||||
#** $Id: lualib.h,v 1.28 2003/03/18 12:24:26 roberto Exp $
|
||||
#** Lua standard libraries
|
||||
#** See Copyright Notice in lua.h
|
||||
#
|
||||
#
|
||||
#** Translated to pascal by Lavergne Thomas
|
||||
#** Bug reports :
|
||||
#** - thomas.lavergne@laposte.net
|
||||
#** In french or in english
|
||||
#
|
||||
|
||||
import "lib/base/lua/lua"
|
||||
|
||||
const
|
||||
LUA_COLIBNAME* = "coroutine"
|
||||
LUA_TABLIBNAME* = "table"
|
||||
LUA_IOLIBNAME* = "io"
|
||||
LUA_OSLIBNAME* = "os"
|
||||
LUA_STRLINAME* = "string"
|
||||
LUA_MATHLIBNAME* = "math"
|
||||
LUA_DBLIBNAME* = "debug"
|
||||
LUA_LOADLIBNAME* = "package"
|
||||
|
||||
proc luaopen_base*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaopen_table*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaopen_io*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
proc luaopen_string*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaopen_math*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaopen_debug*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaopen_package*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc.}
|
||||
proc luaL_openlibs*(L: Plua_State){.cdecl, dynlib: LUA_LIB_NAME, importc.}
|
||||
# compatibility code
|
||||
proc lua_baselibopen*(L: Plua_State): Bool
|
||||
proc lua_tablibopen*(L: Plua_State): Bool
|
||||
proc lua_iolibopen*(L: Plua_State): Bool
|
||||
proc lua_strlibopen*(L: Plua_State): Bool
|
||||
proc lua_mathlibopen*(L: Plua_State): Bool
|
||||
proc lua_dblibopen*(L: Plua_State): Bool
|
||||
# implementation
|
||||
|
||||
proc lua_baselibopen(L: Plua_State): Bool =
|
||||
Result = luaopen_base(L) != 0'i32
|
||||
|
||||
proc lua_tablibopen(L: Plua_State): Bool =
|
||||
Result = luaopen_table(L) != 0'i32
|
||||
|
||||
proc lua_iolibopen(L: Plua_State): Bool =
|
||||
Result = luaopen_io(L) != 0'i32
|
||||
|
||||
proc lua_strlibopen(L: Plua_State): Bool =
|
||||
Result = luaopen_string(L) != 0'i32
|
||||
|
||||
proc lua_mathlibopen(L: Plua_State): Bool =
|
||||
Result = luaopen_math(L) != 0'i32
|
||||
|
||||
proc lua_dblibopen(L: Plua_State): Bool =
|
||||
Result = luaopen_debug(L) != 0'i32
|
||||
783
lib/base/odbcsql.nim
Normal file
783
lib/base/odbcsql.nim
Normal file
@@ -0,0 +1,783 @@
|
||||
|
||||
when not defined(ODBCVER):
|
||||
const
|
||||
ODBCVER = 0x0351 ## define ODBC version 3.51 by default
|
||||
|
||||
when defined(windows):
|
||||
{.push callconv: stdcall.}
|
||||
const odbclib = "odbc32.dll"
|
||||
else:
|
||||
{.push callconv: cdecl.}
|
||||
const odbclib = "libodbc.so"
|
||||
|
||||
# DATA TYPES CORRESPONDENCE
|
||||
# BDE fields ODBC types
|
||||
# ---------- ------------------
|
||||
# ftBlob SQL_BINARY
|
||||
# ftBoolean SQL_BIT
|
||||
# ftDate SQL_TYPE_DATE
|
||||
# ftTime SQL_TYPE_TIME
|
||||
# ftDateTime SQL_TYPE_TIMESTAMP
|
||||
# ftInteger SQL_INTEGER
|
||||
# ftSmallint SQL_SMALLINT
|
||||
# ftFloat SQL_DOUBLE
|
||||
# ftString SQL_CHAR
|
||||
# ftMemo SQL_BINARY // SQL_VARCHAR
|
||||
#
|
||||
|
||||
type
|
||||
TSqlChar* = char
|
||||
TSqlSmallInt* = int16
|
||||
TSqlUSmallInt* = int16
|
||||
TSqlHandle* = pointer
|
||||
TSqlHEnv* = TSqlHandle
|
||||
TSqlHDBC* = TSqlHandle
|
||||
TSqlHStmt* = TSqlHandle
|
||||
TSqlHDesc* = TSqlHandle
|
||||
TSqlInteger* = int
|
||||
TSqlUInteger* = int
|
||||
TSqlPointer* = pointer
|
||||
TSqlReal* = cfloat
|
||||
TSqlDouble* = cdouble
|
||||
TSqlFloat* = cdouble
|
||||
TSqlHWND* = pointer
|
||||
PSQLCHAR* = cstring
|
||||
PSQLINTEGER* = ptr TSqlInteger
|
||||
PSQLUINTEGER* = ptr TSqlUInteger
|
||||
PSQLSMALLINT* = ptr TSqlSmallInt
|
||||
PSQLUSMALLINT* = ptr TSqlUSmallInt
|
||||
PSQLREAL* = ptr TSqlReal
|
||||
PSQLDOUBLE* = ptr TSqlDouble
|
||||
PSQLFLOAT* = ptr TSqlFloat
|
||||
PSQLHANDLE* = ptr TSqlHandle
|
||||
|
||||
const # SQL data type codes
|
||||
SQL_UNKNOWN_TYPE* = 0
|
||||
SQL_LONGVARCHAR* = (- 1)
|
||||
SQL_BINARY* = (- 2)
|
||||
SQL_VARBINARY* = (- 3)
|
||||
SQL_LONGVARBINARY* = (- 4)
|
||||
SQL_BIGINT* = (- 5)
|
||||
SQL_TINYINT* = (- 6)
|
||||
SQL_BIT* = (- 7)
|
||||
SQL_WCHAR* = (- 8)
|
||||
SQL_WVARCHAR* = (- 9)
|
||||
SQL_WLONGVARCHAR* = (- 10)
|
||||
SQL_CHAR* = 1
|
||||
SQL_NUMERIC* = 2
|
||||
SQL_DECIMAL* = 3
|
||||
SQL_INTEGER* = 4
|
||||
SQL_SMALLINT* = 5
|
||||
SQL_FLOAT* = 6
|
||||
SQL_REAL* = 7
|
||||
SQL_DOUBLE* = 8
|
||||
SQL_DATETIME* = 9
|
||||
SQL_VARCHAR* = 12
|
||||
SQL_TYPE_DATE* = 91
|
||||
SQL_TYPE_TIME* = 92
|
||||
SQL_TYPE_TIMESTAMP* = 93
|
||||
SQL_DATE* = 9
|
||||
SQL_TIME* = 10
|
||||
SQL_TIMESTAMP* = 11
|
||||
SQL_INTERVAL* = 10
|
||||
SQL_GUID* = - 11 # interval codes
|
||||
|
||||
when ODBCVER >= 0x0300:
|
||||
const
|
||||
SQL_CODE_YEAR* = 1
|
||||
SQL_CODE_MONTH* = 2
|
||||
SQL_CODE_DAY* = 3
|
||||
SQL_CODE_HOUR* = 4
|
||||
SQL_CODE_MINUTE* = 5
|
||||
SQL_CODE_SECOND* = 6
|
||||
SQL_CODE_YEAR_TO_MONTH* = 7
|
||||
SQL_CODE_DAY_TO_HOUR* = 8
|
||||
SQL_CODE_DAY_TO_MINUTE* = 9
|
||||
SQL_CODE_DAY_TO_SECOND* = 10
|
||||
SQL_CODE_HOUR_TO_MINUTE* = 11
|
||||
SQL_CODE_HOUR_TO_SECOND* = 12
|
||||
SQL_CODE_MINUTE_TO_SECOND* = 13
|
||||
SQL_INTERVAL_YEAR* = 100 + SQL_CODE_YEAR
|
||||
SQL_INTERVAL_MONTH* = 100 + SQL_CODE_MONTH
|
||||
SQL_INTERVAL_DAY* = 100 + SQL_CODE_DAY
|
||||
SQL_INTERVAL_HOUR* = 100 + SQL_CODE_HOUR
|
||||
SQL_INTERVAL_MINUTE* = 100 + SQL_CODE_MINUTE
|
||||
SQL_INTERVAL_SECOND* = 100 + SQL_CODE_SECOND
|
||||
SQL_INTERVAL_YEAR_TO_MONTH* = 100 + SQL_CODE_YEAR_TO_MONTH
|
||||
SQL_INTERVAL_DAY_TO_HOUR* = 100 + SQL_CODE_DAY_TO_HOUR
|
||||
SQL_INTERVAL_DAY_TO_MINUTE* = 100 + SQL_CODE_DAY_TO_MINUTE
|
||||
SQL_INTERVAL_DAY_TO_SECOND* = 100 + SQL_CODE_DAY_TO_SECOND
|
||||
SQL_INTERVAL_HOUR_TO_MINUTE* = 100 + SQL_CODE_HOUR_TO_MINUTE
|
||||
SQL_INTERVAL_HOUR_TO_SECOND* = 100 + SQL_CODE_HOUR_TO_SECOND
|
||||
SQL_INTERVAL_MINUTE_TO_SECOND* = 100 + SQL_CODE_MINUTE_TO_SECOND
|
||||
else:
|
||||
const
|
||||
SQL_INTERVAL_YEAR* = - 80
|
||||
SQL_INTERVAL_MONTH* = - 81
|
||||
SQL_INTERVAL_YEAR_TO_MONTH* = - 82
|
||||
SQL_INTERVAL_DAY* = - 83
|
||||
SQL_INTERVAL_HOUR* = - 84
|
||||
SQL_INTERVAL_MINUTE* = - 85
|
||||
SQL_INTERVAL_SECOND* = - 86
|
||||
SQL_INTERVAL_DAY_TO_HOUR* = - 87
|
||||
SQL_INTERVAL_DAY_TO_MINUTE* = - 88
|
||||
SQL_INTERVAL_DAY_TO_SECOND* = - 89
|
||||
SQL_INTERVAL_HOUR_TO_MINUTE* = - 90
|
||||
SQL_INTERVAL_HOUR_TO_SECOND* = - 91
|
||||
SQL_INTERVAL_MINUTE_TO_SECOND* = - 92
|
||||
|
||||
|
||||
when ODBCVER < 0x0300:
|
||||
const
|
||||
SQL_UNICODE* = - 95
|
||||
SQL_UNICODE_VARCHAR* = - 96
|
||||
SQL_UNICODE_LONGVARCHAR* = - 97
|
||||
SQL_UNICODE_CHAR* = SQL_UNICODE
|
||||
else:
|
||||
# The previous definitions for SQL_UNICODE_ are historical and obsolete
|
||||
const
|
||||
SQL_UNICODE* = SQL_WCHAR
|
||||
SQL_UNICODE_VARCHAR* = SQL_WVARCHAR
|
||||
SQL_UNICODE_LONGVARCHAR* = SQL_WLONGVARCHAR
|
||||
SQL_UNICODE_CHAR* = SQL_WCHAR
|
||||
const # C datatype to SQL datatype mapping
|
||||
SQL_C_CHAR* = SQL_CHAR
|
||||
SQL_C_LONG* = SQL_INTEGER
|
||||
SQL_C_SHORT* = SQL_SMALLINT
|
||||
SQL_C_FLOAT* = SQL_REAL
|
||||
SQL_C_DOUBLE* = SQL_DOUBLE
|
||||
SQL_C_NUMERIC* = SQL_NUMERIC
|
||||
SQL_C_DEFAULT* = 99
|
||||
SQL_SIGNED_OFFSET* = - 20
|
||||
SQL_UNSIGNED_OFFSET* = - 22
|
||||
SQL_C_DATE* = SQL_DATE
|
||||
SQL_C_TIME* = SQL_TIME
|
||||
SQL_C_TIMESTAMP* = SQL_TIMESTAMP
|
||||
SQL_C_TYPE_DATE* = SQL_TYPE_DATE
|
||||
SQL_C_TYPE_TIME* = SQL_TYPE_TIME
|
||||
SQL_C_TYPE_TIMESTAMP* = SQL_TYPE_TIMESTAMP
|
||||
SQL_C_INTERVAL_YEAR* = SQL_INTERVAL_YEAR
|
||||
SQL_C_INTERVAL_MONTH* = SQL_INTERVAL_MONTH
|
||||
SQL_C_INTERVAL_DAY* = SQL_INTERVAL_DAY
|
||||
SQL_C_INTERVAL_HOUR* = SQL_INTERVAL_HOUR
|
||||
SQL_C_INTERVAL_MINUTE* = SQL_INTERVAL_MINUTE
|
||||
SQL_C_INTERVAL_SECOND* = SQL_INTERVAL_SECOND
|
||||
SQL_C_INTERVAL_YEAR_TO_MONTH* = SQL_INTERVAL_YEAR_TO_MONTH
|
||||
SQL_C_INTERVAL_DAY_TO_HOUR* = SQL_INTERVAL_DAY_TO_HOUR
|
||||
SQL_C_INTERVAL_DAY_TO_MINUTE* = SQL_INTERVAL_DAY_TO_MINUTE
|
||||
SQL_C_INTERVAL_DAY_TO_SECOND* = SQL_INTERVAL_DAY_TO_SECOND
|
||||
SQL_C_INTERVAL_HOUR_TO_MINUTE* = SQL_INTERVAL_HOUR_TO_MINUTE
|
||||
SQL_C_INTERVAL_HOUR_TO_SECOND* = SQL_INTERVAL_HOUR_TO_SECOND
|
||||
SQL_C_INTERVAL_MINUTE_TO_SECOND* = SQL_INTERVAL_MINUTE_TO_SECOND
|
||||
SQL_C_BINARY* = SQL_BINARY
|
||||
SQL_C_BIT* = SQL_BIT
|
||||
SQL_C_SBIGINT* = SQL_BIGINT + SQL_SIGNED_OFFSET # SIGNED BIGINT
|
||||
SQL_C_UBIGINT* = SQL_BIGINT + SQL_UNSIGNED_OFFSET # UNSIGNED BIGINT
|
||||
SQL_C_TINYINT* = SQL_TINYINT
|
||||
SQL_C_SLONG* = SQL_C_LONG + SQL_SIGNED_OFFSET # SIGNED INTEGER
|
||||
SQL_C_SSHORT* = SQL_C_SHORT + SQL_SIGNED_OFFSET # SIGNED SMALLINT
|
||||
SQL_C_STINYINT* = SQL_TINYINT + SQL_SIGNED_OFFSET # SIGNED TINYINT
|
||||
SQL_C_ULONG* = SQL_C_LONG + SQL_UNSIGNED_OFFSET # UNSIGNED INTEGER
|
||||
SQL_C_USHORT* = SQL_C_SHORT + SQL_UNSIGNED_OFFSET # UNSIGNED SMALLINT
|
||||
SQL_C_UTINYINT* = SQL_TINYINT + SQL_UNSIGNED_OFFSET # UNSIGNED TINYINT
|
||||
SQL_C_BOOKMARK* = SQL_C_ULONG # BOOKMARK
|
||||
SQL_C_GUID* = SQL_GUID
|
||||
SQL_TYPE_NULL* = 0
|
||||
|
||||
when ODBCVER < 0x0300:
|
||||
const
|
||||
SQL_TYPE_MIN* = SQL_BIT
|
||||
SQL_TYPE_MAX* = SQL_VARCHAR
|
||||
|
||||
const
|
||||
SQL_C_VARBOOKMARK* = SQL_C_BINARY
|
||||
SQL_API_SQLDESCRIBEPARAM* = 58
|
||||
SQL_NO_TOTAL* = - 4
|
||||
|
||||
type
|
||||
SQL_DATE_STRUCT* {.final, pure.} = object
|
||||
Year*: TSqlSmallInt
|
||||
Month*: TSqlUSmallInt
|
||||
Day*: TSqlUSmallInt
|
||||
|
||||
PSQL_DATE_STRUCT* = ptr SQL_DATE_STRUCT
|
||||
SQL_TIME_STRUCT* {.final, pure.} = object
|
||||
Hour*: TSqlUSmallInt
|
||||
Minute*: TSqlUSmallInt
|
||||
Second*: TSqlUSmallInt
|
||||
|
||||
PSQL_TIME_STRUCT* = ptr SQL_TIME_STRUCT
|
||||
SQL_TIMESTAMP_STRUCT* {.final, pure.} = object
|
||||
Year*: TSqlUSmallInt
|
||||
Month*: TSqlUSmallInt
|
||||
Day*: TSqlUSmallInt
|
||||
Hour*: TSqlUSmallInt
|
||||
Minute*: TSqlUSmallInt
|
||||
Second*: TSqlUSmallInt
|
||||
Fraction*: TSqlUInteger
|
||||
|
||||
PSQL_TIMESTAMP_STRUCT* = ptr SQL_TIMESTAMP_STRUCT
|
||||
|
||||
const
|
||||
SQL_NAME_LEN* = 128
|
||||
SQL_OV_ODBC3* = 3
|
||||
SQL_OV_ODBC2* = 2
|
||||
SQL_ATTR_ODBC_VERSION* = 200 # Options for SQLDriverConnect
|
||||
SQL_DRIVER_NOPROMPT* = 0
|
||||
SQL_DRIVER_COMPLETE* = 1
|
||||
SQL_DRIVER_PROMPT* = 2
|
||||
SQL_DRIVER_COMPLETE_REQUIRED* = 3 # whether an attribute is a pointer or not
|
||||
SQL_IS_POINTER* = (- 4)
|
||||
SQL_IS_UINTEGER* = (- 5)
|
||||
SQL_IS_INTEGER* = (- 6)
|
||||
SQL_IS_USMALLINT* = (- 7)
|
||||
SQL_IS_SMALLINT* = (- 8) # SQLExtendedFetch "fFetchType" values
|
||||
SQL_FETCH_BOOKMARK* = 8
|
||||
SQL_SCROLL_OPTIONS* = 44 # SQL_USE_BOOKMARKS options
|
||||
SQL_UB_OFF* = 0
|
||||
SQL_UB_ON* = 1
|
||||
SQL_UB_DEFAULT* = SQL_UB_OFF
|
||||
SQL_UB_FIXED* = SQL_UB_ON
|
||||
SQL_UB_VARIABLE* = 2 # SQL_SCROLL_OPTIONS masks
|
||||
SQL_SO_FORWARD_ONLY* = 0x00000001
|
||||
SQL_SO_KEYSET_DRIVEN* = 0x00000002
|
||||
SQL_SO_DYNAMIC* = 0x00000004
|
||||
SQL_SO_MIXED* = 0x00000008
|
||||
SQL_SO_STATIC* = 0x00000010
|
||||
SQL_BOOKMARK_PERSISTENCE* = 82
|
||||
SQL_STATIC_SENSITIVITY* = 83 # SQL_BOOKMARK_PERSISTENCE values
|
||||
SQL_BP_CLOSE* = 0x00000001
|
||||
SQL_BP_DELETE* = 0x00000002
|
||||
SQL_BP_DROP* = 0x00000004
|
||||
SQL_BP_TRANSACTION* = 0x00000008
|
||||
SQL_BP_UPDATE* = 0x00000010
|
||||
SQL_BP_OTHER_HSTMT* = 0x00000020
|
||||
SQL_BP_SCROLL* = 0x00000040
|
||||
SQL_DYNAMIC_CURSOR_ATTRIBUTES1* = 144
|
||||
SQL_DYNAMIC_CURSOR_ATTRIBUTES2* = 145
|
||||
SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1* = 146
|
||||
SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2* = 147
|
||||
SQL_INDEX_KEYWORDS* = 148
|
||||
SQL_INFO_SCHEMA_VIEWS* = 149
|
||||
SQL_KEYSET_CURSOR_ATTRIBUTES1* = 150
|
||||
SQL_KEYSET_CURSOR_ATTRIBUTES2* = 151
|
||||
SQL_STATIC_CURSOR_ATTRIBUTES1* = 167
|
||||
SQL_STATIC_CURSOR_ATTRIBUTES2* = 168 # supported SQLFetchScroll FetchOrientation's
|
||||
SQL_CA1_NEXT* = 1
|
||||
SQL_CA1_ABSOLUTE* = 2
|
||||
SQL_CA1_RELATIVE* = 4
|
||||
SQL_CA1_BOOKMARK* = 8 # supported SQLSetPos LockType's
|
||||
SQL_CA1_LOCK_NO_CHANGE* = 0x00000040
|
||||
SQL_CA1_LOCK_EXCLUSIVE* = 0x00000080
|
||||
SQL_CA1_LOCK_UNLOCK* = 0x00000100 # supported SQLSetPos Operations
|
||||
SQL_CA1_POS_POSITION* = 0x00000200
|
||||
SQL_CA1_POS_UPDATE* = 0x00000400
|
||||
SQL_CA1_POS_DELETE* = 0x00000800
|
||||
SQL_CA1_POS_REFRESH* = 0x00001000 # positioned updates and deletes
|
||||
SQL_CA1_POSITIONED_UPDATE* = 0x00002000
|
||||
SQL_CA1_POSITIONED_DELETE* = 0x00004000
|
||||
SQL_CA1_SELECT_FOR_UPDATE* = 0x00008000 # supported SQLBulkOperations operations
|
||||
SQL_CA1_BULK_ADD* = 0x00010000
|
||||
SQL_CA1_BULK_UPDATE_BY_BOOKMARK* = 0x00020000
|
||||
SQL_CA1_BULK_DELETE_BY_BOOKMARK* = 0x00040000
|
||||
SQL_CA1_BULK_FETCH_BY_BOOKMARK* = 0x00080000 # supported values for SQL_ATTR_SCROLL_CONCURRENCY
|
||||
SQL_CA2_READ_ONLY_CONCURRENCY* = 1
|
||||
SQL_CA2_LOCK_CONCURRENCY* = 2
|
||||
SQL_CA2_OPT_ROWVER_CONCURRENCY* = 4
|
||||
SQL_CA2_OPT_VALUES_CONCURRENCY* = 8 # sensitivity of the cursor to its own inserts, deletes, and updates
|
||||
SQL_CA2_SENSITIVITY_ADDITIONS* = 0x00000010
|
||||
SQL_CA2_SENSITIVITY_DELETIONS* = 0x00000020
|
||||
SQL_CA2_SENSITIVITY_UPDATES* = 0x00000040 # semantics of SQL_ATTR_MAX_ROWS
|
||||
SQL_CA2_MAX_ROWS_SELECT* = 0x00000080
|
||||
SQL_CA2_MAX_ROWS_INSERT* = 0x00000100
|
||||
SQL_CA2_MAX_ROWS_DELETE* = 0x00000200
|
||||
SQL_CA2_MAX_ROWS_UPDATE* = 0x00000400
|
||||
SQL_CA2_MAX_ROWS_CATALOG* = 0x00000800
|
||||
SQL_CA2_MAX_ROWS_AFFECTS_ALL* = (SQL_CA2_MAX_ROWS_SELECT or
|
||||
SQL_CA2_MAX_ROWS_INSERT or SQL_CA2_MAX_ROWS_DELETE or
|
||||
SQL_CA2_MAX_ROWS_UPDATE or SQL_CA2_MAX_ROWS_CATALOG) # semantics of
|
||||
# SQL_DIAG_CURSOR_ROW_COUNT
|
||||
SQL_CA2_CRC_EXACT* = 0x00001000
|
||||
SQL_CA2_CRC_APPROXIMATE* = 0x00002000 # the kinds of positioned statements that can be simulated
|
||||
SQL_CA2_SIMULATE_NON_UNIQUE* = 0x00004000
|
||||
SQL_CA2_SIMULATE_TRY_UNIQUE* = 0x00008000
|
||||
SQL_CA2_SIMULATE_UNIQUE* = 0x00010000 # Operations in SQLBulkOperations
|
||||
SQL_ADD* = 4
|
||||
SQL_SETPOS_MAX_OPTION_VALUE* = SQL_ADD
|
||||
SQL_UPDATE_BY_BOOKMARK* = 5
|
||||
SQL_DELETE_BY_BOOKMARK* = 6
|
||||
SQL_FETCH_BY_BOOKMARK* = 7 # Operations in SQLSetPos
|
||||
SQL_POSITION* = 0
|
||||
SQL_REFRESH* = 1
|
||||
SQL_UPDATE* = 2
|
||||
SQL_DELETE* = 3 # Lock options in SQLSetPos
|
||||
SQL_LOCK_NO_CHANGE* = 0
|
||||
SQL_LOCK_EXCLUSIVE* = 1
|
||||
SQL_LOCK_UNLOCK* = 2 # SQLExtendedFetch "rgfRowStatus" element values
|
||||
SQL_ROW_SUCCESS* = 0
|
||||
SQL_ROW_DELETED* = 1
|
||||
SQL_ROW_UPDATED* = 2
|
||||
SQL_ROW_NOROW* = 3
|
||||
SQL_ROW_ADDED* = 4
|
||||
SQL_ROW_ERROR* = 5
|
||||
SQL_ROW_SUCCESS_WITH_INFO* = 6
|
||||
SQL_ROW_PROCEED* = 0
|
||||
SQL_ROW_IGNORE* = 1
|
||||
SQL_MAX_DSN_LENGTH* = 32 # maximum data source name size
|
||||
SQL_MAX_OPTION_STRING_LENGTH* = 256
|
||||
SQL_ODBC_CURSORS* = 110
|
||||
SQL_ATTR_ODBC_CURSORS* = SQL_ODBC_CURSORS # SQL_ODBC_CURSORS options
|
||||
SQL_CUR_USE_IF_NEEDED* = 0
|
||||
SQL_CUR_USE_ODBC* = 1
|
||||
SQL_CUR_USE_DRIVER* = 2
|
||||
SQL_CUR_DEFAULT* = SQL_CUR_USE_DRIVER
|
||||
SQL_PARAM_TYPE_UNKNOWN* = 0
|
||||
SQL_PARAM_INPUT* = 1
|
||||
SQL_PARAM_INPUT_OUTPUT* = 2
|
||||
SQL_RESULT_COL* = 3
|
||||
SQL_PARAM_OUTPUT* = 4
|
||||
SQL_RETURN_VALUE* = 5 # special length/indicator values
|
||||
SQL_NULL_DATA* = (- 1)
|
||||
SQL_DATA_AT_EXEC* = (- 2)
|
||||
SQL_SUCCESS* = 0
|
||||
SQL_SUCCESS_WITH_INFO* = 1
|
||||
SQL_NO_DATA* = 100
|
||||
SQL_ERROR* = (- 1)
|
||||
SQL_INVALID_HANDLE* = (- 2)
|
||||
SQL_STILL_EXECUTING* = 2
|
||||
SQL_NEED_DATA* = 99 # flags for null-terminated string
|
||||
SQL_NTS* = (- 3) # maximum message length
|
||||
SQL_MAX_MESSAGE_LENGTH* = 512 # date/time length constants
|
||||
SQL_DATE_LEN* = 10
|
||||
SQL_TIME_LEN* = 8 # add P+1 if precision is nonzero
|
||||
SQL_TIMESTAMP_LEN* = 19 # add P+1 if precision is nonzero
|
||||
# handle type identifiers
|
||||
SQL_HANDLE_ENV* = 1
|
||||
SQL_HANDLE_DBC* = 2
|
||||
SQL_HANDLE_STMT* = 3
|
||||
SQL_HANDLE_DESC* = 4 # environment attribute
|
||||
SQL_ATTR_OUTPUT_NTS* = 10001 # connection attributes
|
||||
SQL_ATTR_AUTO_IPD* = 10001
|
||||
SQL_ATTR_METADATA_ID* = 10014 # statement attributes
|
||||
SQL_ATTR_APP_ROW_DESC* = 10010
|
||||
SQL_ATTR_APP_PARAM_DESC* = 10011
|
||||
SQL_ATTR_IMP_ROW_DESC* = 10012
|
||||
SQL_ATTR_IMP_PARAM_DESC* = 10013
|
||||
SQL_ATTR_CURSOR_SCROLLABLE* = (- 1)
|
||||
SQL_ATTR_CURSOR_SENSITIVITY* = (- 2)
|
||||
SQL_QUERY_TIMEOUT* = 0
|
||||
SQL_MAX_ROWS* = 1
|
||||
SQL_NOSCAN* = 2
|
||||
SQL_MAX_LENGTH* = 3
|
||||
SQL_ASYNC_ENABLE* = 4 # same as SQL_ATTR_ASYNC_ENABLE */
|
||||
SQL_BIND_TYPE* = 5
|
||||
SQL_CURSOR_TYPE* = 6
|
||||
SQL_CONCURRENCY* = 7
|
||||
SQL_KEYSET_SIZE* = 8
|
||||
SQL_ROWSET_SIZE* = 9
|
||||
SQL_SIMULATE_CURSOR* = 10
|
||||
SQL_RETRIEVE_DATA* = 11
|
||||
SQL_USE_BOOKMARKS* = 12
|
||||
SQL_GET_BOOKMARK* = 13 # GetStmtOption Only */
|
||||
SQL_ROW_NUMBER* = 14 # GetStmtOption Only */
|
||||
SQL_ATTR_CURSOR_TYPE* = SQL_CURSOR_TYPE
|
||||
SQL_ATTR_CONCURRENCY* = SQL_CONCURRENCY
|
||||
SQL_ATTR_FETCH_BOOKMARK_PTR* = 16
|
||||
SQL_ATTR_ROW_STATUS_PTR* = 25
|
||||
SQL_ATTR_ROWS_FETCHED_PTR* = 26
|
||||
SQL_AUTOCOMMIT* = 102
|
||||
SQL_ATTR_AUTOCOMMIT* = SQL_AUTOCOMMIT
|
||||
SQL_ATTR_ROW_NUMBER* = SQL_ROW_NUMBER
|
||||
SQL_TXN_ISOLATION* = 108
|
||||
SQL_ATTR_TXN_ISOLATION* = SQL_TXN_ISOLATION
|
||||
SQL_ATTR_MAX_ROWS* = SQL_MAX_ROWS
|
||||
SQL_ATTR_USE_BOOKMARKS* = SQL_USE_BOOKMARKS #* connection attributes */
|
||||
SQL_ACCESS_MODE* = 101 # SQL_AUTOCOMMIT =102;
|
||||
SQL_LOGIN_TIMEOUT* = 103
|
||||
SQL_OPT_TRACE* = 104
|
||||
SQL_OPT_TRACEFILE* = 105
|
||||
SQL_TRANSLATE_DLL* = 106
|
||||
SQL_TRANSLATE_OPTION* = 107 # SQL_TXN_ISOLATION =108;
|
||||
SQL_CURRENT_QUALIFIER* = 109 # SQL_ODBC_CURSORS =110;
|
||||
SQL_QUIET_MODE* = 111
|
||||
SQL_PACKET_SIZE* = 112 #* connection attributes with new names */
|
||||
SQL_ATTR_ACCESS_MODE* = SQL_ACCESS_MODE # SQL_ATTR_AUTOCOMMIT =SQL_AUTOCOMMIT;
|
||||
SQL_ATTR_CONNECTION_DEAD* = 1209 #* GetConnectAttr only */
|
||||
SQL_ATTR_CONNECTION_TIMEOUT* = 113
|
||||
SQL_ATTR_CURRENT_CATALOG* = SQL_CURRENT_QUALIFIER
|
||||
SQL_ATTR_DISCONNECT_BEHAVIOR* = 114
|
||||
SQL_ATTR_ENLIST_IN_DTC* = 1207
|
||||
SQL_ATTR_ENLIST_IN_XA* = 1208
|
||||
SQL_ATTR_LOGIN_TIMEOUT* = SQL_LOGIN_TIMEOUT # SQL_ATTR_ODBC_CURSORS =SQL_ODBC_CURSORS;
|
||||
SQL_ATTR_PACKET_SIZE* = SQL_PACKET_SIZE
|
||||
SQL_ATTR_QUIET_MODE* = SQL_QUIET_MODE
|
||||
SQL_ATTR_TRACE* = SQL_OPT_TRACE
|
||||
SQL_ATTR_TRACEFILE* = SQL_OPT_TRACEFILE
|
||||
SQL_ATTR_TRANSLATE_LIB* = SQL_TRANSLATE_DLL
|
||||
SQL_ATTR_TRANSLATE_OPTION* = SQL_TRANSLATE_OPTION # SQL_ATTR_TXN_ISOLATION =SQL_TXN_ISOLATION;
|
||||
#* SQL_ACCESS_MODE options */
|
||||
SQL_MODE_READ_WRITE* = 0
|
||||
SQL_MODE_READ_ONLY* = 1
|
||||
SQL_MODE_DEFAULT* = SQL_MODE_READ_WRITE #* SQL_AUTOCOMMIT options */
|
||||
SQL_AUTOCOMMIT_OFF* = 0
|
||||
SQL_AUTOCOMMIT_ON* = 1
|
||||
SQL_AUTOCOMMIT_DEFAULT* = SQL_AUTOCOMMIT_ON # SQL_ATTR_CURSOR_SCROLLABLE values
|
||||
SQL_NONSCROLLABLE* = 0
|
||||
SQL_SCROLLABLE* = 1 # SQL_CURSOR_TYPE options
|
||||
SQL_CURSOR_FORWARD_ONLY* = 0
|
||||
SQL_CURSOR_KEYSET_DRIVEN* = 1
|
||||
SQL_CURSOR_DYNAMIC* = 2
|
||||
SQL_CURSOR_STATIC* = 3
|
||||
SQL_CURSOR_TYPE_DEFAULT* = SQL_CURSOR_FORWARD_ONLY # Default value
|
||||
# SQL_CONCURRENCY options
|
||||
SQL_CONCUR_READ_ONLY* = 1
|
||||
SQL_CONCUR_LOCK* = 2
|
||||
SQL_CONCUR_ROWVER* = 3
|
||||
SQL_CONCUR_VALUES* = 4
|
||||
SQL_CONCUR_DEFAULT* = SQL_CONCUR_READ_ONLY # Default value
|
||||
# identifiers of fields in the SQL descriptor
|
||||
SQL_DESC_COUNT* = 1001
|
||||
SQL_DESC_TYPE* = 1002
|
||||
SQL_DESC_LENGTH* = 1003
|
||||
SQL_DESC_OCTET_LENGTH_PTR* = 1004
|
||||
SQL_DESC_PRECISION* = 1005
|
||||
SQL_DESC_SCALE* = 1006
|
||||
SQL_DESC_DATETIME_INTERVAL_CODE* = 1007
|
||||
SQL_DESC_NULLABLE* = 1008
|
||||
SQL_DESC_INDICATOR_PTR* = 1009
|
||||
SQL_DESC_DATA_PTR* = 1010
|
||||
SQL_DESC_NAME* = 1011
|
||||
SQL_DESC_UNNAMED* = 1012
|
||||
SQL_DESC_OCTET_LENGTH* = 1013
|
||||
SQL_DESC_ALLOC_TYPE* = 1099 # identifiers of fields in the diagnostics area
|
||||
SQL_DIAG_RETURNCODE* = 1
|
||||
SQL_DIAG_NUMBER* = 2
|
||||
SQL_DIAG_ROW_COUNT* = 3
|
||||
SQL_DIAG_SQLSTATE* = 4
|
||||
SQL_DIAG_NATIVE* = 5
|
||||
SQL_DIAG_MESSAGE_TEXT* = 6
|
||||
SQL_DIAG_DYNAMIC_FUNCTION* = 7
|
||||
SQL_DIAG_CLASS_ORIGIN* = 8
|
||||
SQL_DIAG_SUBCLASS_ORIGIN* = 9
|
||||
SQL_DIAG_CONNECTION_NAME* = 10
|
||||
SQL_DIAG_SERVER_NAME* = 11
|
||||
SQL_DIAG_DYNAMIC_FUNCTION_CODE* = 12 # dynamic function codes
|
||||
SQL_DIAG_ALTER_TABLE* = 4
|
||||
SQL_DIAG_CREATE_INDEX* = (- 1)
|
||||
SQL_DIAG_CREATE_TABLE* = 77
|
||||
SQL_DIAG_CREATE_VIEW* = 84
|
||||
SQL_DIAG_DELETE_WHERE* = 19
|
||||
SQL_DIAG_DROP_INDEX* = (- 2)
|
||||
SQL_DIAG_DROP_TABLE* = 32
|
||||
SQL_DIAG_DROP_VIEW* = 36
|
||||
SQL_DIAG_DYNAMIC_DELETE_CURSOR* = 38
|
||||
SQL_DIAG_DYNAMIC_UPDATE_CURSOR* = 81
|
||||
SQL_DIAG_GRANT* = 48
|
||||
SQL_DIAG_INSERT* = 50
|
||||
SQL_DIAG_REVOKE* = 59
|
||||
SQL_DIAG_SELECT_CURSOR* = 85
|
||||
SQL_DIAG_UNKNOWN_STATEMENT* = 0
|
||||
SQL_DIAG_UPDATE_WHERE* = 82 # Statement attribute values for cursor sensitivity
|
||||
SQL_UNSPECIFIED* = 0
|
||||
SQL_INSENSITIVE* = 1
|
||||
SQL_SENSITIVE* = 2 # GetTypeInfo() request for all data types
|
||||
SQL_ALL_TYPES* = 0 # Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData()
|
||||
SQL_DEFAULT* = 99 # SQLGetData() code indicating that the application row descriptor
|
||||
# specifies the data type
|
||||
SQL_ARD_TYPE* = (- 99) # SQL date/time type subcodes
|
||||
SQL_CODE_DATE* = 1
|
||||
SQL_CODE_TIME* = 2
|
||||
SQL_CODE_TIMESTAMP* = 3 # CLI option values
|
||||
SQL_FALSE* = 0
|
||||
SQL_TRUE* = 1 # values of NULLABLE field in descriptor
|
||||
SQL_NO_NULLS* = 0
|
||||
SQL_NULLABLE* = 1 # Value returned by SQLGetTypeInfo() to denote that it is
|
||||
# not known whether or not a data type supports null values.
|
||||
SQL_NULLABLE_UNKNOWN* = 2
|
||||
SQL_CLOSE* = 0
|
||||
SQL_DROP* = 1
|
||||
SQL_UNBIND* = 2
|
||||
SQL_RESET_PARAMS* = 3 # Codes used for FetchOrientation in SQLFetchScroll(),
|
||||
# and in SQLDataSources()
|
||||
SQL_FETCH_NEXT* = 1
|
||||
SQL_FETCH_FIRST* = 2
|
||||
SQL_FETCH_FIRST_USER* = 31
|
||||
SQL_FETCH_FIRST_SYSTEM* = 32 # Other codes used for FetchOrientation in SQLFetchScroll()
|
||||
SQL_FETCH_LAST* = 3
|
||||
SQL_FETCH_PRIOR* = 4
|
||||
SQL_FETCH_ABSOLUTE* = 5
|
||||
SQL_FETCH_RELATIVE* = 6
|
||||
SQL_NULL_HENV* = TSqlHEnv(nil)
|
||||
SQL_NULL_HDBC* = TSqlHDBC(nil)
|
||||
SQL_NULL_HSTMT* = TSqlHStmt(nil)
|
||||
SQL_NULL_HDESC* = TSqlHDesc(nil) #* null handle used in place of parent handle when allocating HENV */
|
||||
SQL_NULL_HANDLE* = TSqlHandle(nil) #* Values that may appear in the result set of SQLSpecialColumns() */
|
||||
SQL_SCOPE_CURROW* = 0
|
||||
SQL_SCOPE_TRANSACTION* = 1
|
||||
SQL_SCOPE_SESSION* = 2 #* Column types and scopes in SQLSpecialColumns. */
|
||||
SQL_BEST_ROWID* = 1
|
||||
SQL_ROWVER* = 2
|
||||
SQL_ROW_IDENTIFIER* = 1 #* Reserved values for UNIQUE argument of SQLStatistics() */
|
||||
SQL_INDEX_UNIQUE* = 0
|
||||
SQL_INDEX_ALL* = 1 #* Reserved values for RESERVED argument of SQLStatistics() */
|
||||
SQL_QUICK* = 0
|
||||
SQL_ENSURE* = 1 #* Values that may appear in the result set of SQLStatistics() */
|
||||
SQL_TABLE_STAT* = 0
|
||||
SQL_INDEX_CLUSTERED* = 1
|
||||
SQL_INDEX_HASHED* = 2
|
||||
SQL_INDEX_OTHER* = 3
|
||||
SQL_SCROLL_CONCURRENCY* = 43
|
||||
SQL_TXN_CAPABLE* = 46
|
||||
SQL_TRANSACTION_CAPABLE* = SQL_TXN_CAPABLE
|
||||
SQL_USER_NAME* = 47
|
||||
SQL_TXN_ISOLATION_OPTION* = 72
|
||||
SQL_TRANSACTION_ISOLATION_OPTION* = SQL_TXN_ISOLATION_OPTION
|
||||
SQL_OJ_CAPABILITIES* = 115
|
||||
SQL_OUTER_JOIN_CAPABILITIES* = SQL_OJ_CAPABILITIES
|
||||
SQL_XOPEN_CLI_YEAR* = 10000
|
||||
SQL_CURSOR_SENSITIVITY* = 10001
|
||||
SQL_DESCRIBE_PARAMETER* = 10002
|
||||
SQL_CATALOG_NAME* = 10003
|
||||
SQL_COLLATION_SEQ* = 10004
|
||||
SQL_MAX_IDENTIFIER_LEN* = 10005
|
||||
SQL_MAXIMUM_IDENTIFIER_LENGTH* = SQL_MAX_IDENTIFIER_LEN
|
||||
SQL_SCCO_READ_ONLY* = 1
|
||||
SQL_SCCO_LOCK* = 2
|
||||
SQL_SCCO_OPT_ROWVER* = 4
|
||||
SQL_SCCO_OPT_VALUES* = 8 #* SQL_TXN_CAPABLE values */
|
||||
SQL_TC_NONE* = 0
|
||||
SQL_TC_DML* = 1
|
||||
SQL_TC_ALL* = 2
|
||||
SQL_TC_DDL_COMMIT* = 3
|
||||
SQL_TC_DDL_IGNORE* = 4 #* SQL_TXN_ISOLATION_OPTION bitmasks */
|
||||
SQL_TXN_READ_UNCOMMITTED* = 1
|
||||
SQL_TRANSACTION_READ_UNCOMMITTED* = SQL_TXN_READ_UNCOMMITTED
|
||||
SQL_TXN_READ_COMMITTED* = 2
|
||||
SQL_TRANSACTION_READ_COMMITTED* = SQL_TXN_READ_COMMITTED
|
||||
SQL_TXN_REPEATABLE_READ* = 4
|
||||
SQL_TRANSACTION_REPEATABLE_READ* = SQL_TXN_REPEATABLE_READ
|
||||
SQL_TXN_SERIALIZABLE* = 8
|
||||
SQL_TRANSACTION_SERIALIZABLE* = SQL_TXN_SERIALIZABLE
|
||||
SQL_SS_ADDITIONS* = 1
|
||||
SQL_SS_DELETIONS* = 2
|
||||
SQL_SS_UPDATES* = 4 # SQLColAttributes defines
|
||||
SQL_COLUMN_COUNT* = 0
|
||||
SQL_COLUMN_NAME* = 1
|
||||
SQL_COLUMN_TYPE* = 2
|
||||
SQL_COLUMN_LENGTH* = 3
|
||||
SQL_COLUMN_PRECISION* = 4
|
||||
SQL_COLUMN_SCALE* = 5
|
||||
SQL_COLUMN_DISPLAY_SIZE* = 6
|
||||
SQL_COLUMN_NULLABLE* = 7
|
||||
SQL_COLUMN_UNSIGNED* = 8
|
||||
SQL_COLUMN_MONEY* = 9
|
||||
SQL_COLUMN_UPDATABLE* = 10
|
||||
SQL_COLUMN_AUTO_INCREMENT* = 11
|
||||
SQL_COLUMN_CASE_SENSITIVE* = 12
|
||||
SQL_COLUMN_SEARCHABLE* = 13
|
||||
SQL_COLUMN_TYPE_NAME* = 14
|
||||
SQL_COLUMN_TABLE_NAME* = 15
|
||||
SQL_COLUMN_OWNER_NAME* = 16
|
||||
SQL_COLUMN_QUALIFIER_NAME* = 17
|
||||
SQL_COLUMN_LABEL* = 18
|
||||
SQL_COLATT_OPT_MAX* = SQL_COLUMN_LABEL
|
||||
SQL_COLUMN_DRIVER_START* = 1000
|
||||
SQL_DESC_ARRAY_SIZE* = 20
|
||||
SQL_DESC_ARRAY_STATUS_PTR* = 21
|
||||
SQL_DESC_AUTO_UNIQUE_VALUE* = SQL_COLUMN_AUTO_INCREMENT
|
||||
SQL_DESC_BASE_COLUMN_NAME* = 22
|
||||
SQL_DESC_BASE_TABLE_NAME* = 23
|
||||
SQL_DESC_BIND_OFFSET_PTR* = 24
|
||||
SQL_DESC_BIND_TYPE* = 25
|
||||
SQL_DESC_CASE_SENSITIVE* = SQL_COLUMN_CASE_SENSITIVE
|
||||
SQL_DESC_CATALOG_NAME* = SQL_COLUMN_QUALIFIER_NAME
|
||||
SQL_DESC_CONCISE_TYPE* = SQL_COLUMN_TYPE
|
||||
SQL_DESC_DATETIME_INTERVAL_PRECISION* = 26
|
||||
SQL_DESC_DISPLAY_SIZE* = SQL_COLUMN_DISPLAY_SIZE
|
||||
SQL_DESC_FIXED_PREC_SCALE* = SQL_COLUMN_MONEY
|
||||
SQL_DESC_LABEL* = SQL_COLUMN_LABEL
|
||||
SQL_DESC_LITERAL_PREFIX* = 27
|
||||
SQL_DESC_LITERAL_SUFFIX* = 28
|
||||
SQL_DESC_LOCAL_TYPE_NAME* = 29
|
||||
SQL_DESC_MAXIMUM_SCALE* = 30
|
||||
SQL_DESC_MINIMUM_SCALE* = 31
|
||||
SQL_DESC_NUM_PREC_RADIX* = 32
|
||||
SQL_DESC_PARAMETER_TYPE* = 33
|
||||
SQL_DESC_ROWS_PROCESSED_PTR* = 34
|
||||
SQL_DESC_SCHEMA_NAME* = SQL_COLUMN_OWNER_NAME
|
||||
SQL_DESC_SEARCHABLE* = SQL_COLUMN_SEARCHABLE
|
||||
SQL_DESC_TYPE_NAME* = SQL_COLUMN_TYPE_NAME
|
||||
SQL_DESC_TABLE_NAME* = SQL_COLUMN_TABLE_NAME
|
||||
SQL_DESC_UNSIGNED* = SQL_COLUMN_UNSIGNED
|
||||
SQL_DESC_UPDATABLE* = SQL_COLUMN_UPDATABLE #* SQLEndTran() options */
|
||||
SQL_COMMIT* = 0
|
||||
SQL_ROLLBACK* = 1
|
||||
SQL_ATTR_ROW_ARRAY_SIZE* = 27 #* SQLConfigDataSource() options */
|
||||
ODBC_ADD_DSN* = 1
|
||||
ODBC_CONFIG_DSN* = 2
|
||||
ODBC_REMOVE_DSN* = 3
|
||||
ODBC_ADD_SYS_DSN* = 4
|
||||
ODBC_CONFIG_SYS_DSN* = 5
|
||||
ODBC_REMOVE_SYS_DSN* = 6
|
||||
|
||||
proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: TSqlHandle,
|
||||
OutputHandlePtr: var TSqlHandle): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger,
|
||||
Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger,
|
||||
Value: TSqlPointer, BufferLength: TSqlInteger,
|
||||
StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLFreeHandle*(HandleType: TSqlSmallInt, Handle: TSqlHandle): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: TSqlHandle,
|
||||
RecNumber: TSqlSmallInt, Sqlstate: PSQLCHAR,
|
||||
NativeError: var TSqlInteger, MessageText: PSQLCHAR,
|
||||
BufferLength: TSqlSmallInt, TextLength: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: TSqlHandle,
|
||||
RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt,
|
||||
DiagInfoPtr: TSqlPointer, BufferLength: TSqlSmallInt,
|
||||
StringLengthPtr: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLConnect*(ConnectionHandle: TSqlHDBC, ServerName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, UserName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, Authentication: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLDisconnect*(ConnectionHandle: TSqlHDBC): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLDriverConnect*(hdbc: TSqlHDBC, hwnd: TSqlHWND, szCsin: cstring,
|
||||
szCLen: TSqlSmallInt, szCsout: cstring,
|
||||
cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt,
|
||||
f: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLBrowseConnect*(hdbc: TSqlHDBC, szConnStrIn: PSQLCHAR,
|
||||
cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR,
|
||||
cbConnStrOutMax: TSqlSmallInt,
|
||||
cbConnStrOut: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLExecDirect*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR,
|
||||
TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLPrepare*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR,
|
||||
TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLCloseCursor*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLExecute*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLFetch*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLNumResultCols*(StatementHandle: TSqlHStmt, ColumnCount: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLDescribeCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt,
|
||||
ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt,
|
||||
NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt,
|
||||
ColumnSize: var TSqlUInteger,
|
||||
DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLFetchScroll*(StatementHandle: TSqlHStmt, FetchOrientation: TSqlSmallInt,
|
||||
FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLExtendedFetch*(hstmt: TSqlHStmt, fFetchType: TSqlUSmallInt,
|
||||
irow: TSqlInteger, pcrow: PSQLUINTEGER,
|
||||
rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLGetData*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt,
|
||||
TargetType: TSqlSmallInt, TargetValue: TSqlPointer,
|
||||
BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger,
|
||||
Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger,
|
||||
Value: TSqlPointer, BufferLength: TSqlInteger,
|
||||
StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLGetInfo*(ConnectionHandle: TSqlHDBC, InfoType: TSqlUSmallInt,
|
||||
InfoValue: TSqlPointer, BufferLength: TSqlSmallInt,
|
||||
StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLBulkOperations*(StatementHandle: TSqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLPutData*(StatementHandle: TSqlHStmt, Data: TSqlPointer,
|
||||
StrLen_or_Ind: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLBindCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt,
|
||||
TargetType: TSqlSmallInt, TargetValue: TSqlPointer,
|
||||
BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetPos*(hstmt: TSqlHStmt, irow: TSqlUSmallInt, fOption: TSqlUSmallInt,
|
||||
fLock: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLDataSources*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt,
|
||||
ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt,
|
||||
NameLength1: PSQLSMALLINT, Description: PSQLCHAR,
|
||||
BufferLength2: TSqlSmallInt, NameLength2: PSQLSMALLINT): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLDrivers*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt,
|
||||
DriverDescription: PSQLCHAR, BufferLength1: TSqlSmallInt,
|
||||
DescriptionLength1: PSQLSMALLINT, DriverAttributes: PSQLCHAR,
|
||||
BufferLength2: TSqlSmallInt, AttributesLength2: PSQLSMALLINT): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetConnectAttr*(ConnectionHandle: TSqlHDBC, Attribute: TSqlInteger,
|
||||
Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR,
|
||||
BufferLength: TSqlSmallInt, NameLength: PSQLSMALLINT): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR,
|
||||
NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLRowCount*(StatementHandle: TSqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLBindParameter*(hstmt: TSqlHStmt, ipar: TSqlUSmallInt,
|
||||
fParamType: TSqlSmallInt, fCType: TSqlSmallInt,
|
||||
fSqlType: TSqlSmallInt, cbColDef: TSqlUInteger,
|
||||
ibScale: TSqlSmallInt, rgbValue: TSqlPointer,
|
||||
cbValueMax: TSqlInteger, pcbValue: PSQLINTEGER): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLFreeStmt*(StatementHandle: TSqlHStmt, Option: TSqlUSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLColAttribute*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt,
|
||||
FieldIdentifier: TSqlUSmallInt,
|
||||
CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt,
|
||||
StringLength: PSQLSMALLINT, NumericAttribute: TSqlPointer): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: TSqlHandle,
|
||||
CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLTables*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR,
|
||||
cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
|
||||
cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
|
||||
cbTableName: TSqlSmallInt, szTableType: PSQLCHAR,
|
||||
cbTableType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLColumns*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR,
|
||||
cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
|
||||
cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
|
||||
cbTableName: TSqlSmallInt, szColumnName: PSQLCHAR,
|
||||
cbColumnName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLSpecialColumns*(StatementHandle: TSqlHStmt, IdentifierType: TSqlUSmallInt,
|
||||
CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt,
|
||||
SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt,
|
||||
TableName: PSQLCHAR, NameLength3: TSqlSmallInt,
|
||||
Scope: TSqlUSmallInt, Nullable: TSqlUSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLProcedures*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR,
|
||||
cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
|
||||
cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
|
||||
cbTableName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLPrimaryKeys*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, TableName: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLProcedureColumns*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, ProcName: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt, ColumnName: PSQLCHAR,
|
||||
NameLength4: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLStatistics*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, TableName: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt, Unique: TSqlUSmallInt,
|
||||
Reserved: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
|
||||
{.pop.}
|
||||
1432
lib/base/opengl/gl.nim
Normal file
1432
lib/base/opengl/gl.nim
Normal file
File diff suppressed because it is too large
Load Diff
1548
lib/base/opengl/gl.pp
Normal file
1548
lib/base/opengl/gl.pp
Normal file
File diff suppressed because it is too large
Load Diff
4175
lib/base/opengl/glext.nim
Normal file
4175
lib/base/opengl/glext.nim
Normal file
File diff suppressed because it is too large
Load Diff
3857
lib/base/opengl/glext.pp
Normal file
3857
lib/base/opengl/glext.pp
Normal file
File diff suppressed because it is too large
Load Diff
311
lib/base/opengl/glu.nim
Normal file
311
lib/base/opengl/glu.nim
Normal file
@@ -0,0 +1,311 @@
|
||||
#
|
||||
#
|
||||
# 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):
|
||||
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.}
|
||||
proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname,
|
||||
importc.}
|
||||
proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname, importc.}
|
||||
proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname, importc.}
|
||||
proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname,
|
||||
importc.}
|
||||
proc gluPickMatrix*(x, y, width, height: TGLdouble, viewport: var TViewPortArray){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: TGLdouble){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluProject*(objx, objy, objz: TGLdouble,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
viewport: var TViewPortArray, winx, winy, winz: PGLdouble): int{.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluUnProject*(winx, winy, winz: TGLdouble,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
viewport: var TViewPortArray, objx, objy, objz: PGLdouble): int{.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum,
|
||||
datain: Pointer, widthout, heightout: TGLint,
|
||||
typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname,
|
||||
importc.}
|
||||
proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint,
|
||||
format, atype: TGLenum, data: Pointer): int{.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint,
|
||||
format, atype: TGLenum, data: Pointer): int{.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluNewQuadric*(): PGLUquadric{.dynlib: dllname, importc.}
|
||||
proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname, importc.}
|
||||
proc gluQuadricNormals*(quadObject: PGLUquadric, normals: TGLenum){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluQuadricTexture*(quadObject: PGLUquadric, textureCoords: TGLboolean){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluQuadricOrientation*(quadObject: PGLUquadric, orientation: TGLenum){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluQuadricDrawStyle*(quadObject: PGLUquadric, drawStyle: TGLenum){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble,
|
||||
slices, stacks: TGLint){.dynlib: dllname, importc.}
|
||||
proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
|
||||
slices, loops: TGLint){.dynlib: dllname, importc.}
|
||||
proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
|
||||
slices, loops: TGLint, startAngle, sweepAngle: TGLdouble){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluQuadricCallback*(qobj: PGLUquadric, which: TGLenum, fn: TCallBack){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluNewTess*(): PGLUtesselator{.dynlib: dllname, importc.}
|
||||
proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname, importc.}
|
||||
proc gluTessBeginPolygon*(tess: PGLUtesselator, polygon_data: Pointer){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname, importc.}
|
||||
proc gluTessVertex*(tess: PGLUtesselator, coords: var T3dArray, data: Pointer){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname, importc.}
|
||||
proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, importc.}
|
||||
proc gluTessProperty*(tess: PGLUtesselator, which: TGLenum, value: TGLdouble){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname,
|
||||
importc.}
|
||||
proc gluTessCallback*(tess: PGLUtesselator, which: TGLenum, fn: TCallBack){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluGetTessProperty*(tess: PGLUtesselator, which: TGLenum, value: PGLdouble){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname, importc.}
|
||||
proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
|
||||
proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
|
||||
proc gluBeginCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
|
||||
proc gluEndCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
|
||||
proc gluEndSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
|
||||
proc gluBeginTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
|
||||
proc gluEndTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
|
||||
proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat,
|
||||
stride: TGLint, atype: TGLenum){.dynlib: dllname, importc.}
|
||||
proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat,
|
||||
stride: TGLint, ctlarray: PGLfloat, order: TGLint,
|
||||
atype: TGLenum){.dynlib: dllname, importc.}
|
||||
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.}
|
||||
proc gluLoadSamplingMatrices*(nobj: PGLUnurbs,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
viewport: var TViewPortArray){.dynlib: dllname,
|
||||
importc.}
|
||||
proc gluNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: TGLfloat){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluGetNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: PGLfloat){.
|
||||
dynlib: dllname, importc.}
|
||||
proc gluNurbsCallback*(nobj: PGLUnurbs, which: TGLenum, fn: TCallBack){.
|
||||
dynlib: dllname, importc.}
|
||||
#*** 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.}
|
||||
proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname,
|
||||
importc.}
|
||||
proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, importc.}
|
||||
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
|
||||
|
||||
# implementation
|
||||
368
lib/base/opengl/glu.pp
Normal file
368
lib/base/opengl/glu.pp
Normal file
@@ -0,0 +1,368 @@
|
||||
{
|
||||
|
||||
Adaption of the delphi3d.net OpenGL units to FreePascal
|
||||
Sebastian Guenther (sg@freepascal.org) in 2002
|
||||
These units are free to use
|
||||
}
|
||||
|
||||
{*++ BUILD Version: 0004 // Increment this if a change has global effects
|
||||
|
||||
Copyright (c) 1985-95, Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
glu.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Procedure declarations, constant definitions and macros for the OpenGL
|
||||
Utility Library.
|
||||
|
||||
--*}
|
||||
|
||||
{*
|
||||
** Copyright 1991-1993, Silicon Graphics, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
|
||||
** the contents of this file may not be disclosed to third parties, copied or
|
||||
** duplicated in any form, in whole or in part, without the prior written
|
||||
** permission of Silicon Graphics, Inc.
|
||||
**
|
||||
** RESTRICTED RIGHTS LEGEND:
|
||||
** Use, duplication or disclosure by the Government is subject to restrictions
|
||||
** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
|
||||
** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
|
||||
** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
|
||||
** rights reserved under the Copyright Laws of the United States.
|
||||
*}
|
||||
|
||||
{*
|
||||
** Return the error string associated with a particular error code.
|
||||
** This will return 0 for an invalid error code.
|
||||
**
|
||||
** The generic function prototype that can be compiled for ANSI or Unicode
|
||||
** is defined as follows:
|
||||
**
|
||||
** LPCTSTR APIENTRY gluErrorStringWIN (GLenum errCode);
|
||||
*}
|
||||
|
||||
{******************************************************************************}
|
||||
{ Converted to Delphi by Tom Nuydens (tom@delphi3d.net) }
|
||||
{ For the latest updates, visit Delphi3D: http://www.delphi3d.net }
|
||||
{******************************************************************************}
|
||||
|
||||
unit GLu;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
GL;
|
||||
|
||||
const
|
||||
dllname = 'glu32.dll';
|
||||
dylibname = '/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib';
|
||||
libname = 'libGLU.so.1';
|
||||
|
||||
type
|
||||
TViewPortArray = array [0..3] of GLint;
|
||||
T16dArray = array [0..15] of GLdouble;
|
||||
TCallBack = procedure;
|
||||
T3dArray = array [0..2] of GLdouble;
|
||||
T4pArray = array [0..3] of Pointer;
|
||||
T4fArray = array [0..3] of GLfloat;
|
||||
PPointer = ^Pointer;
|
||||
|
||||
type
|
||||
GLUnurbs = record end; PGLUnurbs = ^GLUnurbs;
|
||||
GLUquadric = record end; PGLUquadric = ^GLUquadric;
|
||||
GLUtesselator = record end; PGLUtesselator = ^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;
|
||||
|
||||
|
||||
function gluErrorString(errCode: GLenum): PChar; external dllname;
|
||||
function gluErrorUnicodeStringEXT(errCode: GLenum): PWideChar; external dllname;
|
||||
function gluGetString(name: GLenum): PChar; external dllname;
|
||||
procedure gluOrtho2D(left,right, bottom, top: GLdouble); external dllname;
|
||||
procedure gluPerspective(fovy, aspect, zNear, zFar: GLdouble); external dllname;
|
||||
procedure gluPickMatrix(x, y, width, height: GLdouble; var viewport: TViewPortArray); external dllname;
|
||||
procedure gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: GLdouble); external dllname;
|
||||
function gluProject(objx, objy, objz: GLdouble; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray; winx, winy, winz: PGLdouble): Integer; external dllname;
|
||||
function gluUnProject(winx, winy, winz: GLdouble; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray; objx, objy, objz: PGLdouble): Integer; external dllname;
|
||||
function gluScaleImage(format: GLenum; widthin, heightin: GLint; typein: GLenum; const datain: Pointer; widthout, heightout: GLint; typeout: GLenum; dataout: Pointer): Integer; external dllname;
|
||||
function gluBuild1DMipmaps(target: GLenum; components, width: GLint; format, atype: GLenum; const data: Pointer): Integer; external dllname;
|
||||
function gluBuild2DMipmaps(target: GLenum; components, width, height: GLint; format, atype: GLenum; const data: Pointer): Integer; external dllname;
|
||||
|
||||
|
||||
function gluNewQuadric: PGLUquadric; external dllname;
|
||||
procedure gluDeleteQuadric(state: PGLUquadric); external dllname;
|
||||
procedure gluQuadricNormals(quadObject: PGLUquadric; normals: GLenum); external dllname;
|
||||
procedure gluQuadricTexture(quadObject: PGLUquadric; textureCoords: GLboolean); external dllname;
|
||||
procedure gluQuadricOrientation(quadObject: PGLUquadric; orientation: GLenum); external dllname;
|
||||
procedure gluQuadricDrawStyle(quadObject: PGLUquadric; drawStyle: GLenum); external dllname;
|
||||
procedure gluCylinder(qobj: PGLUquadric; baseRadius, topRadius, height: GLdouble; slices, stacks: GLint); external dllname;
|
||||
procedure gluDisk(qobj: PGLUquadric; innerRadius, outerRadius: GLdouble; slices, loops: GLint); external dllname;
|
||||
procedure gluPartialDisk(qobj: PGLUquadric; innerRadius, outerRadius: GLdouble; slices, loops: GLint; startAngle, sweepAngle: GLdouble); external dllname;
|
||||
procedure gluSphere(qobj: PGLuquadric; radius: GLdouble; slices, stacks: GLint); external dllname;
|
||||
procedure gluQuadricCallback(qobj: PGLUquadric; which: GLenum; fn: TCallBack); external dllname;
|
||||
function gluNewTess: PGLUtesselator; external dllname;
|
||||
procedure gluDeleteTess(tess: PGLUtesselator); external dllname;
|
||||
procedure gluTessBeginPolygon(tess: PGLUtesselator; polygon_data: Pointer); external dllname;
|
||||
procedure gluTessBeginContour(tess: PGLUtesselator); external dllname;
|
||||
procedure gluTessVertex(tess: PGLUtesselator; var coords: T3dArray; data: Pointer); external dllname;
|
||||
procedure gluTessEndContour(tess: PGLUtesselator); external dllname;
|
||||
procedure gluTessEndPolygon(tess: PGLUtesselator); external dllname;
|
||||
procedure gluTessProperty(tess: PGLUtesselator; which: GLenum; value: GLdouble); external dllname;
|
||||
procedure gluTessNormal(tess: PGLUtesselator; x, y, z: GLdouble); external dllname;
|
||||
procedure gluTessCallback(tess: PGLUtesselator; which: GLenum;fn: TCallBack); external dllname;
|
||||
procedure gluGetTessProperty(tess: PGLUtesselator; which: GLenum; value: PGLdouble); external dllname;
|
||||
function gluNewNurbsRenderer: PGLUnurbs; external dllname;
|
||||
procedure gluDeleteNurbsRenderer(nobj: PGLUnurbs); external dllname;
|
||||
procedure gluBeginSurface(nobj: PGLUnurbs); external dllname;
|
||||
procedure gluBeginCurve(nobj: PGLUnurbs); external dllname;
|
||||
procedure gluEndCurve(nobj: PGLUnurbs); external dllname;
|
||||
procedure gluEndSurface(nobj: PGLUnurbs); external dllname;
|
||||
procedure gluBeginTrim(nobj: PGLUnurbs); external dllname;
|
||||
procedure gluEndTrim(nobj: PGLUnurbs); external dllname;
|
||||
procedure gluPwlCurve(nobj: PGLUnurbs; count: GLint; aarray: PGLfloat; stride: GLint; atype: GLenum); external dllname;
|
||||
procedure gluNurbsCurve(nobj: PGLUnurbs; nknots: GLint; knot: PGLfloat; stride: GLint; ctlarray: PGLfloat; order: GLint; atype: GLenum); external dllname;
|
||||
procedure gluNurbsSurface(nobj: PGLUnurbs; sknot_count: GLint; sknot: PGLfloat; tknot_count: GLint; tknot: PGLfloat; s_stride, t_stride: GLint; ctlarray: PGLfloat; sorder, torder: GLint; atype: GLenum); external dllname;
|
||||
procedure gluLoadSamplingMatrices(nobj: PGLUnurbs; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray); external dllname;
|
||||
procedure gluNurbsProperty(nobj: PGLUnurbs; aproperty: GLenum; value: GLfloat); external dllname;
|
||||
procedure gluGetNurbsProperty(nobj: PGLUnurbs; aproperty: GLenum; value: PGLfloat); external dllname;
|
||||
procedure gluNurbsCallback(nobj: PGLUnurbs; which: GLenum; fn: TCallBack); external dllname;
|
||||
|
||||
(**** Callback function prototypes ****)
|
||||
|
||||
type
|
||||
// gluQuadricCallback
|
||||
GLUquadricErrorProc = procedure(p: GLenum);
|
||||
|
||||
// gluTessCallback
|
||||
GLUtessBeginProc = procedure(p: GLenum);
|
||||
GLUtessEdgeFlagProc = procedure(p: GLboolean);
|
||||
GLUtessVertexProc = procedure(p: Pointer);
|
||||
GLUtessEndProc = procedure;
|
||||
GLUtessErrorProc = procedure(p: GLenum);
|
||||
GLUtessCombineProc = procedure(var p1: T3dArray; p2: T4pArray; p3: T4fArray; p4: PPointer);
|
||||
GLUtessBeginDataProc = procedure(p1: GLenum; p2: Pointer);
|
||||
GLUtessEdgeFlagDataProc = procedure(p1: GLboolean; p2: Pointer);
|
||||
GLUtessVertexDataProc = procedure(p1, p2: Pointer);
|
||||
GLUtessEndDataProc = procedure(p: Pointer);
|
||||
GLUtessErrorDataProc = procedure(p1: GLenum; p2: Pointer);
|
||||
GLUtessCombineDataProc = procedure(var p1: T3dArray; var p2: T4pArray; var p3: T4fArray;
|
||||
p4: PPointer; p5: Pointer);
|
||||
|
||||
// gluNurbsCallback
|
||||
GLUnurbsErrorProc = procedure(p: GLenum);
|
||||
|
||||
|
||||
//*** 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.0e150;
|
||||
|
||||
// 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*)(GLenum type)
|
||||
GLU_TESS_VERTEX = 100101; // void (CALLBACK*)(void *data)
|
||||
GLU_TESS_END = 100102; // void (CALLBACK*)(void)
|
||||
GLU_TESS_ERROR = 100103; // void (CALLBACK*)(GLenum errno)
|
||||
GLU_TESS_EDGE_FLAG = 100104; // void (CALLBACK*)(GLboolean boundaryEdge)
|
||||
GLU_TESS_COMBINE = 100105; { void (CALLBACK*)(GLdouble coords[3],
|
||||
void *data[4],
|
||||
GLfloat weight[4],
|
||||
void **dataOut) }
|
||||
GLU_TESS_BEGIN_DATA = 100106; { void (CALLBACK*)(GLenum 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*)(GLenum errno,
|
||||
void *polygon_data) }
|
||||
GLU_TESS_EDGE_FLAG_DATA = 100110; { void (CALLBACK*)(GLboolean boundaryEdge,
|
||||
void *polygon_data) }
|
||||
GLU_TESS_COMBINE_DATA = 100111; { void (CALLBACK*)(GLdouble coords[3],
|
||||
void *data[4],
|
||||
GLfloat 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 ****/
|
||||
|
||||
|
||||
procedure gluBeginPolygon(tess: PGLUtesselator); external dllname;
|
||||
procedure gluNextContour(tess: PGLUtesselator; atype: GLenum); external dllname;
|
||||
procedure gluEndPolygon(tess: PGLUtesselator); external dllname;
|
||||
|
||||
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 = GLU_TESS_VERTEX;
|
||||
GLU_END = GLU_TESS_END;
|
||||
GLU_ERROR = GLU_TESS_ERROR;
|
||||
GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
378
lib/base/opengl/glut.nim
Normal file
378
lib/base/opengl/glut.nim
Normal file
@@ -0,0 +1,378 @@
|
||||
#
|
||||
#
|
||||
# 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
|
||||
PInteger* = ptr int
|
||||
PPChar* = ptr cstring
|
||||
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: PInteger, argv: PPChar){.dynlib: dllname, importc.}
|
||||
proc glutInitDisplayMode*(mode: int16){.dynlib: dllname, importc.}
|
||||
proc glutInitDisplayString*(str: cstring){.dynlib: dllname, importc.}
|
||||
proc glutInitWindowPosition*(x, y: int){.dynlib: dllname, importc.}
|
||||
proc glutInitWindowSize*(width, height: int){.dynlib: dllname, importc.}
|
||||
proc glutMainLoop*(){.dynlib: dllname, importc.}
|
||||
# GLUT window sub-API.
|
||||
proc glutCreateWindow*(title: cstring): int{.dynlib: dllname, importc.}
|
||||
proc glutCreateSubWindow*(win, x, y, width, height: int): int{.dynlib: dllname,
|
||||
importc.}
|
||||
proc glutDestroyWindow*(win: int){.dynlib: dllname, importc.}
|
||||
proc glutPostRedisplay*(){.dynlib: dllname, importc.}
|
||||
proc glutPostWindowRedisplay*(win: int){.dynlib: dllname, importc.}
|
||||
proc glutSwapBuffers*(){.dynlib: dllname, importc.}
|
||||
proc glutGetWindow*(): int{.dynlib: dllname, importc.}
|
||||
proc glutSetWindow*(win: int){.dynlib: dllname, importc.}
|
||||
proc glutSetWindowTitle*(title: cstring){.dynlib: dllname, importc.}
|
||||
proc glutSetIconTitle*(title: cstring){.dynlib: dllname, importc.}
|
||||
proc glutPositionWindow*(x, y: int){.dynlib: dllname, importc.}
|
||||
proc glutReshapeWindow*(width, height: int){.dynlib: dllname, importc.}
|
||||
proc glutPopWindow*(){.dynlib: dllname, importc.}
|
||||
proc glutPushWindow*(){.dynlib: dllname, importc.}
|
||||
proc glutIconifyWindow*(){.dynlib: dllname, importc.}
|
||||
proc glutShowWindow*(){.dynlib: dllname, importc.}
|
||||
proc glutHideWindow*(){.dynlib: dllname, importc.}
|
||||
proc glutFullScreen*(){.dynlib: dllname, importc.}
|
||||
proc glutSetCursor*(cursor: int){.dynlib: dllname, importc.}
|
||||
proc glutWarpPointer*(x, y: int){.dynlib: dllname, importc.}
|
||||
# GLUT overlay sub-API.
|
||||
proc glutEstablishOverlay*(){.dynlib: dllname, importc.}
|
||||
proc glutRemoveOverlay*(){.dynlib: dllname, importc.}
|
||||
proc glutUseLayer*(layer: TGLenum){.dynlib: dllname, importc.}
|
||||
proc glutPostOverlayRedisplay*(){.dynlib: dllname, importc.}
|
||||
proc glutPostWindowOverlayRedisplay*(win: int){.dynlib: dllname, importc.}
|
||||
proc glutShowOverlay*(){.dynlib: dllname, importc.}
|
||||
proc glutHideOverlay*(){.dynlib: dllname, importc.}
|
||||
# GLUT menu sub-API.
|
||||
proc glutCreateMenu*(callback: TGlut1IntCallback): int{.dynlib: dllname, importc.}
|
||||
proc glutDestroyMenu*(menu: int){.dynlib: dllname, importc.}
|
||||
proc glutGetMenu*(): int{.dynlib: dllname, importc.}
|
||||
proc glutSetMenu*(menu: int){.dynlib: dllname, importc.}
|
||||
proc glutAddMenuEntry*(caption: cstring, value: int){.dynlib: dllname, importc.}
|
||||
proc glutAddSubMenu*(caption: cstring, submenu: int){.dynlib: dllname, importc.}
|
||||
proc glutChangeToMenuEntry*(item: int, caption: cstring, value: int){.
|
||||
dynlib: dllname, importc.}
|
||||
proc glutChangeToSubMenu*(item: int, caption: cstring, submenu: int){.
|
||||
dynlib: dllname, importc.}
|
||||
proc glutRemoveMenuItem*(item: int){.dynlib: dllname, importc.}
|
||||
proc glutAttachMenu*(button: int){.dynlib: dllname, importc.}
|
||||
proc glutDetachMenu*(button: int){.dynlib: dllname, importc.}
|
||||
# GLUT window callback sub-API.
|
||||
proc glutDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc.}
|
||||
proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutIdleFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc.}
|
||||
proc glutTimerFunc*(millis: int16, f: TGlut1IntCallback, value: int){.
|
||||
dynlib: dllname, importc.}
|
||||
proc glutMenuStateFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc.}
|
||||
proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutSpecialUpFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.}
|
||||
proc glutJoystickFunc*(f: TGlut1UInt3IntCallback, pollInterval: int){.
|
||||
dynlib: dllname, importc.}
|
||||
# GLUT color index sub-API.
|
||||
proc glutSetColor*(cell: int, red, green, blue: TGLfloat){.dynlib: dllname,
|
||||
importc.}
|
||||
proc glutGetColor*(ndx, component: int): TGLfloat{.dynlib: dllname, importc.}
|
||||
proc glutCopyColormap*(win: int){.dynlib: dllname, importc.}
|
||||
# GLUT state retrieval sub-API.
|
||||
proc glutGet*(t: TGLenum): int{.dynlib: dllname, importc.}
|
||||
proc glutDeviceGet*(t: TGLenum): int{.dynlib: dllname, importc.}
|
||||
# GLUT extension support sub-API
|
||||
proc glutExtensionSupported*(name: cstring): int{.dynlib: dllname, importc.}
|
||||
proc glutGetModifiers*(): int{.dynlib: dllname, importc.}
|
||||
proc glutLayerGet*(t: TGLenum): int{.dynlib: dllname, importc.}
|
||||
# GLUT font sub-API
|
||||
proc glutBitmapCharacter*(font: pointer, character: int){.dynlib: dllname,
|
||||
importc.}
|
||||
proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname,
|
||||
importc.}
|
||||
proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname,
|
||||
importc.}
|
||||
proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname,
|
||||
importc.}
|
||||
proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname,
|
||||
importc.}
|
||||
proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname,
|
||||
importc.}
|
||||
# GLUT pre-built models sub-API
|
||||
proc glutWireSphere*(radius: TGLdouble, slices, stacks: TGLint){.dynlib: dllname,
|
||||
importc.}
|
||||
proc glutSolidSphere*(radius: TGLdouble, slices, stacks: TGLint){.dynlib: dllname,
|
||||
importc.}
|
||||
proc glutWireCone*(base, height: TGLdouble, slices, stacks: TGLint){.
|
||||
dynlib: dllname, importc.}
|
||||
proc glutSolidCone*(base, height: TGLdouble, slices, stacks: TGLint){.
|
||||
dynlib: dllname, importc.}
|
||||
proc glutWireCube*(size: TGLdouble){.dynlib: dllname, importc.}
|
||||
proc glutSolidCube*(size: TGLdouble){.dynlib: dllname, importc.}
|
||||
proc glutWireTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){.
|
||||
dynlib: dllname, importc.}
|
||||
proc glutSolidTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){.
|
||||
dynlib: dllname, importc.}
|
||||
proc glutWireDodecahedron*(){.dynlib: dllname, importc.}
|
||||
proc glutSolidDodecahedron*(){.dynlib: dllname, importc.}
|
||||
proc glutWireTeapot*(size: TGLdouble){.dynlib: dllname, importc.}
|
||||
proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname, importc.}
|
||||
proc glutWireOctahedron*(){.dynlib: dllname, importc.}
|
||||
proc glutSolidOctahedron*(){.dynlib: dllname, importc.}
|
||||
proc glutWireTetrahedron*(){.dynlib: dllname, importc.}
|
||||
proc glutSolidTetrahedron*(){.dynlib: dllname, importc.}
|
||||
proc glutWireIcosahedron*(){.dynlib: dllname, importc.}
|
||||
proc glutSolidIcosahedron*(){.dynlib: dllname, importc.}
|
||||
# GLUT video resize sub-API.
|
||||
proc glutVideoResizeGet*(param: TGLenum): int{.dynlib: dllname, importc.}
|
||||
proc glutSetupVideoResizing*(){.dynlib: dllname, importc.}
|
||||
proc glutStopVideoResizing*(){.dynlib: dllname, importc.}
|
||||
proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname, importc.}
|
||||
proc glutVideoPan*(x, y, width, height: int){.dynlib: dllname, importc.}
|
||||
# GLUT debugging sub-API.
|
||||
proc glutReportErrors*(){.dynlib: dllname, importc.}
|
||||
# GLUT device control sub-API.
|
||||
proc glutIgnoreKeyRepeat*(ignore: int){.dynlib: dllname, importc.}
|
||||
proc glutSetKeyRepeat*(repeatMode: int){.dynlib: dllname, importc.}
|
||||
proc glutForceJoystickFunc*(){.dynlib: dllname, importc.}
|
||||
# GLUT game mode sub-API.
|
||||
#example glutGameModeString('1280x1024:32@75');
|
||||
proc glutGameModeString*(AString: cstring){.dynlib: dllname, importc.}
|
||||
proc glutEnterGameMode*(): int{.dynlib: dllname, importc.}
|
||||
proc glutLeaveGameMode*(){.dynlib: dllname, importc.}
|
||||
proc glutGameModeGet*(mode: TGLenum): int{.dynlib: dllname, importc.}
|
||||
# implementation
|
||||
436
lib/base/opengl/glut.pp
Normal file
436
lib/base/opengl/glut.pp
Normal file
@@ -0,0 +1,436 @@
|
||||
{
|
||||
|
||||
Adaption of the delphi3d.net OpenGL units to FreePascal
|
||||
Sebastian Guenther (sg@freepascal.org) in 2002
|
||||
These units are free to use
|
||||
}
|
||||
|
||||
unit Glut;
|
||||
|
||||
// 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 }
|
||||
{******************************************************************************}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
GL;
|
||||
|
||||
const
|
||||
dllname = 'glut32.dll';
|
||||
dynlibname = '/System/Library/Frameworks/GLUT.framework/GLUT';
|
||||
libname = 'libglut.so.3';
|
||||
|
||||
type
|
||||
PInteger = ^Integer;
|
||||
PPChar = ^PChar;
|
||||
TGlutVoidCallback = procedure; cdecl;
|
||||
TGlut1IntCallback = procedure(value: Integer); cdecl;
|
||||
TGlut2IntCallback = procedure(v1, v2: Integer); cdecl;
|
||||
TGlut3IntCallback = procedure(v1, v2, v3: Integer); cdecl;
|
||||
TGlut4IntCallback = procedure(v1, v2, v3, v4: Integer); cdecl;
|
||||
TGlut1Char2IntCallback = procedure(c: Byte; v1, v2: Integer); cdecl;
|
||||
TGlut1UInt3IntCallback = procedure(u: Cardinal; v1, v2, v3: Integer); 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;
|
||||
|
||||
{$ifdef Windows}
|
||||
const
|
||||
// Stroke font constants (use these in GLUT program).
|
||||
GLUT_STROKE_ROMAN = Pointer(0);
|
||||
GLUT_STROKE_MONO_ROMAN = Pointer(1);
|
||||
|
||||
// Bitmap font constants (use these in GLUT program).
|
||||
GLUT_BITMAP_9_BY_15 = Pointer(2);
|
||||
GLUT_BITMAP_8_BY_13 = Pointer(3);
|
||||
GLUT_BITMAP_TIMES_ROMAN_10 = Pointer(4);
|
||||
GLUT_BITMAP_TIMES_ROMAN_24 = Pointer(5);
|
||||
GLUT_BITMAP_HELVETICA_10 = Pointer(6);
|
||||
GLUT_BITMAP_HELVETICA_12 = Pointer(7);
|
||||
GLUT_BITMAP_HELVETICA_18 = Pointer(8);
|
||||
{$else Windows}
|
||||
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;
|
||||
{$endif Windows}
|
||||
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;
|
||||
GLUT_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.
|
||||
procedure glutInit(argcp: PInteger; argv: PPChar); external dllname;
|
||||
procedure glutInitDisplayMode(mode: Word); external dllname;
|
||||
procedure glutInitDisplayString(const str: PChar); external dllname;
|
||||
procedure glutInitWindowPosition(x, y: Integer); external dllname;
|
||||
procedure glutInitWindowSize(width, height: Integer); external dllname;
|
||||
procedure glutMainLoop; external dllname;
|
||||
|
||||
// GLUT window sub-API.
|
||||
function glutCreateWindow(const title: PChar): Integer; external dllname;
|
||||
function glutCreateSubWindow(win, x, y, width, height: Integer): Integer; external dllname;
|
||||
procedure glutDestroyWindow(win: Integer); external dllname;
|
||||
procedure glutPostRedisplay; external dllname;
|
||||
procedure glutPostWindowRedisplay(win: Integer); external dllname;
|
||||
procedure glutSwapBuffers; external dllname;
|
||||
function glutGetWindow: Integer; external dllname;
|
||||
procedure glutSetWindow(win: Integer); external dllname;
|
||||
procedure glutSetWindowTitle(const title: PChar); external dllname;
|
||||
procedure glutSetIconTitle(const title: PChar); external dllname;
|
||||
procedure glutPositionWindow(x, y: Integer); external dllname;
|
||||
procedure glutReshapeWindow(width, height: Integer); external dllname;
|
||||
procedure glutPopWindow; external dllname;
|
||||
procedure glutPushWindow; external dllname;
|
||||
procedure glutIconifyWindow; external dllname;
|
||||
procedure glutShowWindow; external dllname;
|
||||
procedure glutHideWindow; external dllname;
|
||||
procedure glutFullScreen; external dllname;
|
||||
procedure glutSetCursor(cursor: Integer); external dllname;
|
||||
procedure glutWarpPointer(x, y: Integer); external dllname;
|
||||
|
||||
// GLUT overlay sub-API.
|
||||
procedure glutEstablishOverlay; external dllname;
|
||||
procedure glutRemoveOverlay; external dllname;
|
||||
procedure glutUseLayer(layer: GLenum); external dllname;
|
||||
procedure glutPostOverlayRedisplay; external dllname;
|
||||
procedure glutPostWindowOverlayRedisplay(win: Integer); external dllname;
|
||||
procedure glutShowOverlay; external dllname;
|
||||
procedure glutHideOverlay; external dllname;
|
||||
|
||||
// GLUT menu sub-API.
|
||||
function glutCreateMenu(callback: TGlut1IntCallback): Integer; external dllname;
|
||||
procedure glutDestroyMenu(menu: Integer); external dllname;
|
||||
function glutGetMenu: Integer; external dllname;
|
||||
procedure glutSetMenu(menu: Integer); external dllname;
|
||||
procedure glutAddMenuEntry(const caption: PChar; value: Integer); external dllname;
|
||||
procedure glutAddSubMenu(const caption: PChar; submenu: Integer); external dllname;
|
||||
procedure glutChangeToMenuEntry(item: Integer; const caption: PChar; value: Integer); external dllname;
|
||||
procedure glutChangeToSubMenu(item: Integer; const caption: PChar; submenu: Integer); external dllname;
|
||||
procedure glutRemoveMenuItem(item: Integer); external dllname;
|
||||
procedure glutAttachMenu(button: Integer); external dllname;
|
||||
procedure glutDetachMenu(button: Integer); external dllname;
|
||||
|
||||
// GLUT window callback sub-API.
|
||||
procedure glutDisplayFunc(f: TGlutVoidCallback); external dllname;
|
||||
procedure glutReshapeFunc(f: TGlut2IntCallback); external dllname;
|
||||
procedure glutKeyboardFunc(f: TGlut1Char2IntCallback); external dllname;
|
||||
procedure glutMouseFunc(f: TGlut4IntCallback); external dllname;
|
||||
procedure glutMotionFunc(f: TGlut2IntCallback); external dllname;
|
||||
procedure glutPassiveMotionFunc(f: TGlut2IntCallback); external dllname;
|
||||
procedure glutEntryFunc(f: TGlut1IntCallback); external dllname;
|
||||
procedure glutVisibilityFunc(f: TGlut1IntCallback); external dllname;
|
||||
procedure glutIdleFunc(f: TGlutVoidCallback); external dllname;
|
||||
procedure glutTimerFunc(millis: Word; f: TGlut1IntCallback; value: Integer); external dllname;
|
||||
procedure glutMenuStateFunc(f: TGlut1IntCallback); external dllname;
|
||||
procedure glutSpecialFunc(f: TGlut3IntCallback); external dllname;
|
||||
procedure glutSpaceballMotionFunc(f: TGlut3IntCallback); external dllname;
|
||||
procedure glutSpaceballRotateFunc(f: TGlut3IntCallback); external dllname;
|
||||
procedure glutSpaceballButtonFunc(f: TGlut2IntCallback); external dllname;
|
||||
procedure glutButtonBoxFunc(f: TGlut2IntCallback); external dllname;
|
||||
procedure glutDialsFunc(f: TGlut2IntCallback); external dllname;
|
||||
procedure glutTabletMotionFunc(f: TGlut2IntCallback); external dllname;
|
||||
procedure glutTabletButtonFunc(f: TGlut4IntCallback); external dllname;
|
||||
procedure glutMenuStatusFunc(f: TGlut3IntCallback); external dllname;
|
||||
procedure glutOverlayDisplayFunc(f:TGlutVoidCallback); external dllname;
|
||||
procedure glutWindowStatusFunc(f: TGlut1IntCallback); external dllname;
|
||||
procedure glutKeyboardUpFunc(f: TGlut1Char2IntCallback); external dllname;
|
||||
procedure glutSpecialUpFunc(f: TGlut3IntCallback); external dllname;
|
||||
procedure glutJoystickFunc(f: TGlut1UInt3IntCallback; pollInterval: Integer); external dllname;
|
||||
|
||||
// GLUT color index sub-API.
|
||||
procedure glutSetColor(cell: Integer; red, green, blue: GLfloat); external dllname;
|
||||
function glutGetColor(ndx, component: Integer): GLfloat; external dllname;
|
||||
procedure glutCopyColormap(win: Integer); external dllname;
|
||||
|
||||
// GLUT state retrieval sub-API.
|
||||
function glutGet(t: GLenum): Integer; external dllname;
|
||||
function glutDeviceGet(t: GLenum): Integer; external dllname;
|
||||
|
||||
// GLUT extension support sub-API
|
||||
function glutExtensionSupported(const name: PChar): Integer; external dllname;
|
||||
function glutGetModifiers: Integer; external dllname;
|
||||
function glutLayerGet(t: GLenum): Integer; external dllname;
|
||||
|
||||
// GLUT font sub-API
|
||||
procedure glutBitmapCharacter(font : pointer; character: Integer); external dllname;
|
||||
function glutBitmapWidth(font : pointer; character: Integer): Integer; external dllname;
|
||||
procedure glutStrokeCharacter(font : pointer; character: Integer); external dllname;
|
||||
function glutStrokeWidth(font : pointer; character: Integer): Integer; external dllname;
|
||||
function glutBitmapLength(font: pointer; const str: PChar): Integer; external dllname;
|
||||
function glutStrokeLength(font: pointer; const str: PChar): Integer; external dllname;
|
||||
|
||||
// GLUT pre-built models sub-API
|
||||
procedure glutWireSphere(radius: GLdouble; slices, stacks: GLint); external dllname;
|
||||
procedure glutSolidSphere(radius: GLdouble; slices, stacks: GLint); external dllname;
|
||||
procedure glutWireCone(base, height: GLdouble; slices, stacks: GLint); external dllname;
|
||||
procedure glutSolidCone(base, height: GLdouble; slices, stacks: GLint); external dllname;
|
||||
procedure glutWireCube(size: GLdouble); external dllname;
|
||||
procedure glutSolidCube(size: GLdouble); external dllname;
|
||||
procedure glutWireTorus(innerRadius, outerRadius: GLdouble; sides, rings: GLint); external dllname;
|
||||
procedure glutSolidTorus(innerRadius, outerRadius: GLdouble; sides, rings: GLint); external dllname;
|
||||
procedure glutWireDodecahedron; external dllname;
|
||||
procedure glutSolidDodecahedron; external dllname;
|
||||
procedure glutWireTeapot(size: GLdouble); external dllname;
|
||||
procedure glutSolidTeapot(size: GLdouble); external dllname;
|
||||
procedure glutWireOctahedron; external dllname;
|
||||
procedure glutSolidOctahedron; external dllname;
|
||||
procedure glutWireTetrahedron; external dllname;
|
||||
procedure glutSolidTetrahedron; external dllname;
|
||||
procedure glutWireIcosahedron; external dllname;
|
||||
procedure glutSolidIcosahedron; external dllname;
|
||||
|
||||
// GLUT video resize sub-API.
|
||||
function glutVideoResizeGet(param: GLenum): Integer; external dllname;
|
||||
procedure glutSetupVideoResizing; external dllname;
|
||||
procedure glutStopVideoResizing; external dllname;
|
||||
procedure glutVideoResize(x, y, width, height: Integer); external dllname;
|
||||
procedure glutVideoPan(x, y, width, height: Integer); external dllname;
|
||||
|
||||
// GLUT debugging sub-API.
|
||||
procedure glutReportErrors; external dllname;
|
||||
|
||||
// GLUT device control sub-API.
|
||||
|
||||
procedure glutIgnoreKeyRepeat(ignore: Integer); external dllname;
|
||||
procedure glutSetKeyRepeat(repeatMode: Integer); external dllname;
|
||||
procedure glutForceJoystickFunc; external dllname;
|
||||
|
||||
// GLUT game mode sub-API.
|
||||
|
||||
//example glutGameModeString('1280x1024:32@75');
|
||||
procedure glutGameModeString (const AString : PChar); external dllname;
|
||||
function glutEnterGameMode : integer; external dllname;
|
||||
procedure glutLeaveGameMode; external dllname;
|
||||
function glutGameModeGet (mode : GLenum) : integer; external dllname;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
148
lib/base/opengl/glx.nim
Normal file
148
lib/base/opengl/glx.nim
Normal file
@@ -0,0 +1,148 @@
|
||||
#
|
||||
#
|
||||
# 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.}
|
||||
proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext,
|
||||
direct: bool): GLXContext{.cdecl, dynlib: dllname,
|
||||
importc.}
|
||||
proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname,
|
||||
importc.}
|
||||
proc glXMakeCurrent*(dpy: PDisplay, drawable: GLXDrawable, ctx: GLXContext): bool{.
|
||||
cdecl, dynlib: dllname, importc.}
|
||||
proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl,
|
||||
dynlib: dllname, importc.}
|
||||
proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl,
|
||||
dynlib: dllname, importc.}
|
||||
proc glXCreateGLXPixmap*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap): GLXPixmap{.
|
||||
cdecl, dynlib: dllname, importc.}
|
||||
proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl,
|
||||
dynlib: dllname, importc.}
|
||||
proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl,
|
||||
dynlib: dllname, importc.}
|
||||
proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl,
|
||||
dynlib: dllname, importc.}
|
||||
proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname,
|
||||
importc.}
|
||||
proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int,
|
||||
value: var int): int{.cdecl, dynlib: dllname, importc.}
|
||||
proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname, importc.}
|
||||
proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname, importc.}
|
||||
proc glXWaitGL*(){.cdecl, dynlib: dllname, importc.}
|
||||
proc glXWaitX*(){.cdecl, dynlib: dllname, importc.}
|
||||
proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname,
|
||||
importc.}
|
||||
# GLX 1.1 and later
|
||||
proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl,
|
||||
dynlib: dllname, importc.}
|
||||
proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl,
|
||||
dynlib: dllname, importc.}
|
||||
proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl,
|
||||
dynlib: dllname, importc.}
|
||||
# Mesa GLX Extensions
|
||||
proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo,
|
||||
pixmap: XPixmap, cmap: XColormap): GLXPixmap{.
|
||||
cdecl, dynlib: dllname, importc.}
|
||||
proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl,
|
||||
dynlib: dllname, importc.}
|
||||
proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable,
|
||||
x, y, width, height: int){.cdecl, dynlib: dllname,
|
||||
importc.}
|
||||
proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname,
|
||||
importc.}
|
||||
proc glXWaitVideoSyncSGI*(divisor, remainder: int, count: var int32): int{.
|
||||
cdecl, dynlib: dllname, importc.}
|
||||
# implementation
|
||||
156
lib/base/opengl/glx.pp
Normal file
156
lib/base/opengl/glx.pp
Normal file
@@ -0,0 +1,156 @@
|
||||
{
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
unit GLX;
|
||||
|
||||
interface
|
||||
|
||||
{$IFDEF Unix}
|
||||
uses
|
||||
X, XLib, XUtil, gl;
|
||||
{$DEFINE HasGLX} // Activate GLX stuff
|
||||
{$ELSE}
|
||||
{$MESSAGE Unsupported platform.}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF HasGLX}
|
||||
{$MESSAGE GLX not present on this platform.}
|
||||
{$ENDIF}
|
||||
|
||||
const
|
||||
dylibname = '/usr/X11R6/lib/libGL.dylib';
|
||||
|
||||
// =======================================================
|
||||
// GLX consts, types and functions
|
||||
// =======================================================
|
||||
|
||||
// Tokens for glXChooseVisual and glXGetConfig:
|
||||
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 = $22;
|
||||
GLX_TRANSPARENT_TYPE_EXT = $23;
|
||||
GLX_TRANSPARENT_INDEX_VALUE_EXT = $24;
|
||||
GLX_TRANSPARENT_RED_VALUE_EXT = $25;
|
||||
GLX_TRANSPARENT_GREEN_VALUE_EXT = $26;
|
||||
GLX_TRANSPARENT_BLUE_VALUE_EXT = $27;
|
||||
GLX_TRANSPARENT_ALPHA_VALUE_EXT = $28;
|
||||
|
||||
|
||||
// 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 = $8002;
|
||||
GLX_DIRECT_COLOR_EXT = $8003;
|
||||
GLX_PSEUDO_COLOR_EXT = $8004;
|
||||
GLX_STATIC_COLOR_EXT = $8005;
|
||||
GLX_GRAY_SCALE_EXT = $8006;
|
||||
GLX_STATIC_GRAY_EXT = $8007;
|
||||
GLX_NONE_EXT = $8000;
|
||||
GLX_TRANSPARENT_RGB_EXT = $8008;
|
||||
GLX_TRANSPARENT_INDEX_EXT = $8009;
|
||||
|
||||
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;
|
||||
|
||||
function glXChooseVisual(dpy: PDisplay; screen: Integer; attribList: PInteger): PXVisualInfo; cdecl; external dllname;
|
||||
function glXCreateContext(dpy: PDisplay; vis: PXVisualInfo; shareList: GLXContext; direct: Boolean): GLXContext; cdecl; external dllname;
|
||||
procedure glXDestroyContext(dpy: PDisplay; ctx: GLXContext); cdecl; external dllname;
|
||||
function glXMakeCurrent(dpy: PDisplay; drawable: GLXDrawable; ctx: GLXContext): Boolean; cdecl; external dllname;
|
||||
procedure glXCopyContext(dpy: PDisplay; src, dst: GLXContext; mask: LongWord); cdecl; external dllname;
|
||||
procedure glXSwapBuffers(dpy: PDisplay; drawable: GLXDrawable); cdecl; external dllname;
|
||||
function glXCreateGLXPixmap(dpy: PDisplay; visual: PXVisualInfo; pixmap: XPixmap): GLXPixmap; cdecl; external dllname;
|
||||
procedure glXDestroyGLXPixmap(dpy: PDisplay; pixmap: GLXPixmap); cdecl; external dllname;
|
||||
function glXQueryExtension(dpy: PDisplay; var errorb, event: Integer): Boolean; cdecl; external dllname;
|
||||
function glXQueryVersion(dpy: PDisplay; var maj, min: Integer): Boolean; cdecl; external dllname;
|
||||
function glXIsDirect(dpy: PDisplay; ctx: GLXContext): Boolean; cdecl; external dllname;
|
||||
function glXGetConfig(dpy: PDisplay; visual: PXVisualInfo; attrib: Integer; var value: Integer): Integer; cdecl; external dllname;
|
||||
function glXGetCurrentContext: GLXContext; cdecl; external dllname;
|
||||
function glXGetCurrentDrawable: GLXDrawable; cdecl; external dllname;
|
||||
procedure glXWaitGL; cdecl; external dllname;
|
||||
procedure glXWaitX; cdecl; external dllname;
|
||||
procedure glXUseXFont(font: XFont; first, count, list: Integer); cdecl; external dllname;
|
||||
|
||||
// GLX 1.1 and later
|
||||
function glXQueryExtensionsString(dpy: PDisplay; screen: Integer): PChar; cdecl; external dllname;
|
||||
function glXQueryServerString(dpy: PDisplay; screen, name: Integer): PChar; cdecl; external dllname;
|
||||
function glXGetClientString(dpy: PDisplay; name: Integer): PChar; cdecl; external dllname;
|
||||
|
||||
// Mesa GLX Extensions
|
||||
function glXCreateGLXPixmapMESA(dpy: PDisplay; visual: PXVisualInfo; pixmap: XPixmap; cmap: XColormap): GLXPixmap; cdecl; external dllname;
|
||||
function glXReleaseBufferMESA(dpy: PDisplay; d: GLXDrawable): Boolean; cdecl; external dllname;
|
||||
procedure glXCopySubBufferMESA(dpy: PDisplay; drawbale: GLXDrawable; x, y, width, height: Integer); cdecl; external dllname;
|
||||
function glXGetVideoSyncSGI(var counter: LongWord): Integer; cdecl; external dllname;
|
||||
function glXWaitVideoSyncSGI(divisor, remainder: Integer; var count: LongWord): Integer; cdecl; external dllname;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
348
lib/base/opengl/wingl.nim
Normal file
348
lib/base/opengl/wingl.nim
Normal file
@@ -0,0 +1,348 @@
|
||||
|
||||
import
|
||||
gl, windows
|
||||
|
||||
proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname, importc.}
|
||||
|
||||
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.}
|
||||
proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname, importc.}
|
||||
proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
|
||||
width: TGLint, height: TGLint): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
|
||||
width: TGLint, height: TGLint, xSrc: TGLint,
|
||||
ySrc: TGLint): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat,
|
||||
writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname, importc.}
|
||||
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.}
|
||||
proc wglDestroyImageBufferI3D*(hDC: HDC, pAddress: PGLvoid): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle,
|
||||
pAddress: PGLvoid, pSize: PDWORD,
|
||||
count: UINT): BOOL{.dynlib: dllname,
|
||||
importc.}
|
||||
proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD,
|
||||
pLastMissedUsage: PGLfloat): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
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.}
|
||||
proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint,
|
||||
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
|
||||
piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
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.}
|
||||
proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname, importc.}
|
||||
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.}
|
||||
proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname, importc.}
|
||||
proc wglReleasePbufferDCARB*(hPbuffer: THandle, hDC: HDC): TGLint{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname, importc.}
|
||||
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.}
|
||||
proc wglReleaseTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglSetPbufferAttribARB*(hPbuffer: THandle, piAttribList: PGLint): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname, importc.}
|
||||
proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname, importc.}
|
||||
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.}
|
||||
proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname, importc.}
|
||||
proc wglReleasePbufferDCEXT*(hPbuffer: THandle, hDC: HDC): TGLint{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
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.}
|
||||
proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint,
|
||||
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
|
||||
piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
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.}
|
||||
proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
importc.}
|
||||
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.}
|
||||
proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
importc.}
|
||||
proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
|
||||
puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
|
||||
puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
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.}
|
||||
proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, importc.}
|
||||
proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||
importc.}
|
||||
proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname,
|
||||
importc.}
|
||||
proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname,
|
||||
importc.}
|
||||
proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname,
|
||||
importc.}
|
||||
proc wglGetGenlockSourceEdgeI3D*(hDC: HDC, uEdge: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname,
|
||||
importc.}
|
||||
proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglGenlockSourceDelayI3D*(hDC: HDC, uDelay: TGLuint): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglGetGenlockSourceDelayI3D*(hDC: HDC, uDelay: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT,
|
||||
uMaxPixelDelay: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc.}
|
||||
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
|
||||
313
lib/base/opengl/wingl.pp
Normal file
313
lib/base/opengl/wingl.pp
Normal file
@@ -0,0 +1,313 @@
|
||||
unit wingl;
|
||||
|
||||
interface
|
||||
|
||||
uses gl;
|
||||
|
||||
function wglGetExtensionsStringARB(hdc: HDC): Pchar; external dllname;
|
||||
|
||||
function Load_WGL_ARB_extensions_string: Boolean; external dllname;
|
||||
|
||||
const
|
||||
WGL_FRONT_COLOR_BUFFER_BIT_ARB = $0001;
|
||||
WGL_BACK_COLOR_BUFFER_BIT_ARB = $0002;
|
||||
WGL_DEPTH_BUFFER_BIT_ARB = $0004;
|
||||
WGL_STENCIL_BUFFER_BIT_ARB = $0008;
|
||||
|
||||
function WinChoosePixelFormat(DC: HDC; p2: PPixelFormatDescriptor): Integer; external dllname; external 'gdi32' name 'ChoosePixelFormat';
|
||||
|
||||
function wglCreateBufferRegionARB(hDC: HDC; iLayerPlane: TGLint; uType: TGLuint): THandle; external dllname;
|
||||
procedure wglDeleteBufferRegionARB(hRegion: THandle); external dllname;
|
||||
function wglSaveBufferRegionARB(hRegion: THandle; x: TGLint; y: TGLint; width: TGLint; height: TGLint): BOOL; external dllname;
|
||||
function wglRestoreBufferRegionARB(hRegion: THandle; x: TGLint; y: TGLint; width: TGLint; height: TGLint; xSrc: TGLint; ySrc: TGLint): BOOL; external dllname;
|
||||
|
||||
function wglAllocateMemoryNV(size: TGLsizei; readFrequency: TGLfloat; writeFrequency: TGLfloat; priority: TGLfloat): PGLvoid; external dllname;
|
||||
procedure wglFreeMemoryNV(pointer: PGLvoid); external dllname;
|
||||
|
||||
const
|
||||
WGL_IMAGE_BUFFER_MIN_ACCESS_I3D = $0001;
|
||||
WGL_IMAGE_BUFFER_LOCK_I3D = $0002;
|
||||
|
||||
function wglCreateImageBufferI3D(hDC: HDC; dwSize: DWORD; uFlags: UINT): PGLvoid; external dllname;
|
||||
function wglDestroyImageBufferI3D(hDC: HDC; pAddress: PGLvoid): BOOL; external dllname;
|
||||
function wglAssociateImageBufferEventsI3D(hdc: HDC; pEvent: PHandle; pAddress: PGLvoid; pSize: PDWORD; count: UINT): BOOL; external dllname;
|
||||
function wglReleaseImageBufferEventsI3D(hdc: HDC; pAddress: PGLvoid; count: UINT): BOOL; external dllname;
|
||||
|
||||
function wglEnableFrameLockI3D(): BOOL; external dllname;
|
||||
function wglDisableFrameLockI3D(): BOOL; external dllname;
|
||||
function wglIsEnabledFrameLockI3D(pFlag: PBOOL): BOOL; external dllname;
|
||||
function wglQueryFrameLockMasterI3D(pFlag: PBOOL): BOOL; external dllname;
|
||||
|
||||
function wglGetFrameUsageI3D(pUsage: PGLfloat): BOOL; external dllname;
|
||||
function wglBeginFrameTrackingI3D(): BOOL; external dllname;
|
||||
function wglEndFrameTrackingI3D(): BOOL; external dllname;
|
||||
function wglQueryFrameTrackingI3D(pFrameCount: PDWORD; pMissedFrames: PDWORD; pLastMissedUsage: PGLfloat): BOOL; external dllname;
|
||||
|
||||
const
|
||||
WGL_NUMBER_PIXEL_FORMATS_ARB = $2000;
|
||||
WGL_DRAW_TO_WINDOW_ARB = $2001;
|
||||
WGL_DRAW_TO_BITMAP_ARB = $2002;
|
||||
WGL_ACCELERATION_ARB = $2003;
|
||||
WGL_NEED_PALETTE_ARB = $2004;
|
||||
WGL_NEED_SYSTEM_PALETTE_ARB = $2005;
|
||||
WGL_SWAP_LAYER_BUFFERS_ARB = $2006;
|
||||
WGL_SWAP_METHOD_ARB = $2007;
|
||||
WGL_NUMBER_OVERLAYS_ARB = $2008;
|
||||
WGL_NUMBER_UNDERLAYS_ARB = $2009;
|
||||
WGL_TRANSPARENT_ARB = $200A;
|
||||
WGL_TRANSPARENT_RED_VALUE_ARB = $2037;
|
||||
WGL_TRANSPARENT_GREEN_VALUE_ARB = $2038;
|
||||
WGL_TRANSPARENT_BLUE_VALUE_ARB = $2039;
|
||||
WGL_TRANSPARENT_ALPHA_VALUE_ARB = $203A;
|
||||
WGL_TRANSPARENT_INDEX_VALUE_ARB = $203B;
|
||||
WGL_SHARE_DEPTH_ARB = $200C;
|
||||
WGL_SHARE_STENCIL_ARB = $200D;
|
||||
WGL_SHARE_ACCUM_ARB = $200E;
|
||||
WGL_SUPPORT_GDI_ARB = $200F;
|
||||
WGL_SUPPORT_OPENGL_ARB = $2010;
|
||||
WGL_DOUBLE_BUFFER_ARB = $2011;
|
||||
WGL_STEREO_ARB = $2012;
|
||||
WGL_PIXEL_TYPE_ARB = $2013;
|
||||
WGL_COLOR_BITS_ARB = $2014;
|
||||
WGL_RED_BITS_ARB = $2015;
|
||||
WGL_RED_SHIFT_ARB = $2016;
|
||||
WGL_GREEN_BITS_ARB = $2017;
|
||||
WGL_GREEN_SHIFT_ARB = $2018;
|
||||
WGL_BLUE_BITS_ARB = $2019;
|
||||
WGL_BLUE_SHIFT_ARB = $201A;
|
||||
WGL_ALPHA_BITS_ARB = $201B;
|
||||
WGL_ALPHA_SHIFT_ARB = $201C;
|
||||
WGL_ACCUM_BITS_ARB = $201D;
|
||||
WGL_ACCUM_RED_BITS_ARB = $201E;
|
||||
WGL_ACCUM_GREEN_BITS_ARB = $201F;
|
||||
WGL_ACCUM_BLUE_BITS_ARB = $2020;
|
||||
WGL_ACCUM_ALPHA_BITS_ARB = $2021;
|
||||
WGL_DEPTH_BITS_ARB = $2022;
|
||||
WGL_STENCIL_BITS_ARB = $2023;
|
||||
WGL_AUX_BUFFERS_ARB = $2024;
|
||||
WGL_NO_ACCELERATION_ARB = $2025;
|
||||
WGL_GENERIC_ACCELERATION_ARB = $2026;
|
||||
WGL_FULL_ACCELERATION_ARB = $2027;
|
||||
WGL_SWAP_EXCHANGE_ARB = $2028;
|
||||
WGL_SWAP_COPY_ARB = $2029;
|
||||
WGL_SWAP_UNDEFINED_ARB = $202A;
|
||||
WGL_TYPE_RGBA_ARB = $202B;
|
||||
WGL_TYPE_COLORINDEX_ARB = $202C;
|
||||
|
||||
function wglGetPixelFormatAttribivARB(hdc: HDC; iPixelFormat: TGLint; iLayerPlane: TGLint; nAttributes: TGLuint; const piAttributes: PGLint; piValues: PGLint): BOOL; external dllname;
|
||||
function wglGetPixelFormatAttribfvARB(hdc: HDC; iPixelFormat: TGLint; iLayerPlane: TGLint; nAttributes: TGLuint; const piAttributes: PGLint; pfValues: PGLfloat): BOOL; external dllname;
|
||||
function wglChoosePixelFormatARB(hdc: HDC; const piAttribIList: PGLint; const pfAttribFList: PGLfloat; nMaxFormats: TGLuint; piFormats: PGLint; nNumFormats: PGLuint): BOOL; external dllname;
|
||||
|
||||
|
||||
const
|
||||
WGL_ERROR_INVALID_PIXEL_TYPE_ARB = $2043;
|
||||
WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB = $2054;
|
||||
|
||||
function wglMakeContextCurrentARB(hDrawDC: HDC; hReadDC: HDC; hglrc: HGLRC): BOOL; external dllname;
|
||||
function wglGetCurrentReadDCARB(): HDC; external dllname;
|
||||
|
||||
function Load_WGL_ARB_make_current_read: Boolean;
|
||||
|
||||
const
|
||||
WGL_DRAW_TO_PBUFFER_ARB = $202D;
|
||||
// WGL_DRAW_TO_PBUFFER_ARB { already defined }
|
||||
WGL_MAX_PBUFFER_PIXELS_ARB = $202E;
|
||||
WGL_MAX_PBUFFER_WIDTH_ARB = $202F;
|
||||
WGL_MAX_PBUFFER_HEIGHT_ARB = $2030;
|
||||
WGL_PBUFFER_LARGEST_ARB = $2033;
|
||||
WGL_PBUFFER_WIDTH_ARB = $2034;
|
||||
WGL_PBUFFER_HEIGHT_ARB = $2035;
|
||||
WGL_PBUFFER_LOST_ARB = $2036;
|
||||
|
||||
function wglCreatePbufferARB(hDC: HDC; iPixelFormat: TGLint; iWidth: TGLint; iHeight: TGLint; const piAttribList: PGLint): THandle; external dllname;
|
||||
function wglGetPbufferDCARB(hPbuffer: THandle): HDC; external dllname;
|
||||
function wglReleasePbufferDCARB(hPbuffer: THandle; hDC: HDC): TGLint; external dllname;
|
||||
function wglDestroyPbufferARB(hPbuffer: THandle): BOOL; external dllname;
|
||||
function wglQueryPbufferARB(hPbuffer: THandle; iAttribute: TGLint; piValue: PGLint): BOOL; external dllname;
|
||||
|
||||
|
||||
function wglSwapIntervalEXT(interval: TGLint): BOOL; external dllname;
|
||||
function wglGetSwapIntervalEXT(): TGLint; external dllname;
|
||||
|
||||
const
|
||||
WGL_BIND_TO_TEXTURE_RGB_ARB = $2070;
|
||||
WGL_BIND_TO_TEXTURE_RGBA_ARB = $2071;
|
||||
WGL_TEXTURE_FORMAT_ARB = $2072;
|
||||
WGL_TEXTURE_TARGET_ARB = $2073;
|
||||
WGL_MIPMAP_TEXTURE_ARB = $2074;
|
||||
WGL_TEXTURE_RGB_ARB = $2075;
|
||||
WGL_TEXTURE_RGBA_ARB = $2076;
|
||||
WGL_NO_TEXTURE_ARB = $2077;
|
||||
WGL_TEXTURE_CUBE_MAP_ARB = $2078;
|
||||
WGL_TEXTURE_1D_ARB = $2079;
|
||||
WGL_TEXTURE_2D_ARB = $207A;
|
||||
// WGL_NO_TEXTURE_ARB { already defined }
|
||||
WGL_MIPMAP_LEVEL_ARB = $207B;
|
||||
WGL_CUBE_MAP_FACE_ARB = $207C;
|
||||
WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = $207D;
|
||||
WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = $207E;
|
||||
WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = $207F;
|
||||
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = $2080;
|
||||
WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = $2081;
|
||||
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = $2082;
|
||||
WGL_FRONT_LEFT_ARB = $2083;
|
||||
WGL_FRONT_RIGHT_ARB = $2084;
|
||||
WGL_BACK_LEFT_ARB = $2085;
|
||||
WGL_BACK_RIGHT_ARB = $2086;
|
||||
WGL_AUX0_ARB = $2087;
|
||||
WGL_AUX1_ARB = $2088;
|
||||
WGL_AUX2_ARB = $2089;
|
||||
WGL_AUX3_ARB = $208A;
|
||||
WGL_AUX4_ARB = $208B;
|
||||
WGL_AUX5_ARB = $208C;
|
||||
WGL_AUX6_ARB = $208D;
|
||||
WGL_AUX7_ARB = $208E;
|
||||
WGL_AUX8_ARB = $208F;
|
||||
WGL_AUX9_ARB = $2090;
|
||||
|
||||
function wglBindTexImageARB(hPbuffer: THandle; iBuffer: TGLint): BOOL; external dllname;
|
||||
function wglReleaseTexImageARB(hPbuffer: THandle; iBuffer: TGLint): BOOL; external dllname;
|
||||
function wglSetPbufferAttribARB(hPbuffer: THandle; const piAttribList: PGLint): BOOL; external dllname;
|
||||
|
||||
|
||||
function wglGetExtensionsStringEXT(): Pchar; external dllname;
|
||||
|
||||
function wglMakeContextCurrentEXT(hDrawDC: HDC; hReadDC: HDC; hglrc: HGLRC): BOOL; external dllname;
|
||||
function wglGetCurrentReadDCEXT(): HDC; external dllname;
|
||||
|
||||
const
|
||||
WGL_DRAW_TO_PBUFFER_EXT = $202D;
|
||||
WGL_MAX_PBUFFER_PIXELS_EXT = $202E;
|
||||
WGL_MAX_PBUFFER_WIDTH_EXT = $202F;
|
||||
WGL_MAX_PBUFFER_HEIGHT_EXT = $2030;
|
||||
WGL_OPTIMAL_PBUFFER_WIDTH_EXT = $2031;
|
||||
WGL_OPTIMAL_PBUFFER_HEIGHT_EXT = $2032;
|
||||
WGL_PBUFFER_LARGEST_EXT = $2033;
|
||||
WGL_PBUFFER_WIDTH_EXT = $2034;
|
||||
WGL_PBUFFER_HEIGHT_EXT = $2035;
|
||||
|
||||
function wglCreatePbufferEXT(hDC: HDC; iPixelFormat: TGLint; iWidth: TGLint; iHeight: TGLint; const piAttribList: PGLint): THandle; external dllname;
|
||||
function wglGetPbufferDCEXT(hPbuffer: THandle): HDC; external dllname;
|
||||
function wglReleasePbufferDCEXT(hPbuffer: THandle; hDC: HDC): TGLint; external dllname;
|
||||
function wglDestroyPbufferEXT(hPbuffer: THandle): BOOL; external dllname;
|
||||
function wglQueryPbufferEXT(hPbuffer: THandle; iAttribute: TGLint; piValue: PGLint): BOOL; external dllname;
|
||||
|
||||
const
|
||||
WGL_NUMBER_PIXEL_FORMATS_EXT = $2000;
|
||||
WGL_DRAW_TO_WINDOW_EXT = $2001;
|
||||
WGL_DRAW_TO_BITMAP_EXT = $2002;
|
||||
WGL_ACCELERATION_EXT = $2003;
|
||||
WGL_NEED_PALETTE_EXT = $2004;
|
||||
WGL_NEED_SYSTEM_PALETTE_EXT = $2005;
|
||||
WGL_SWAP_LAYER_BUFFERS_EXT = $2006;
|
||||
WGL_SWAP_METHOD_EXT = $2007;
|
||||
WGL_NUMBER_OVERLAYS_EXT = $2008;
|
||||
WGL_NUMBER_UNDERLAYS_EXT = $2009;
|
||||
WGL_TRANSPARENT_EXT = $200A;
|
||||
WGL_TRANSPARENT_VALUE_EXT = $200B;
|
||||
WGL_SHARE_DEPTH_EXT = $200C;
|
||||
WGL_SHARE_STENCIL_EXT = $200D;
|
||||
WGL_SHARE_ACCUM_EXT = $200E;
|
||||
WGL_SUPPORT_GDI_EXT = $200F;
|
||||
WGL_SUPPORT_OPENGL_EXT = $2010;
|
||||
WGL_DOUBLE_BUFFER_EXT = $2011;
|
||||
WGL_STEREO_EXT = $2012;
|
||||
WGL_PIXEL_TYPE_EXT = $2013;
|
||||
WGL_COLOR_BITS_EXT = $2014;
|
||||
WGL_RED_BITS_EXT = $2015;
|
||||
WGL_RED_SHIFT_EXT = $2016;
|
||||
WGL_GREEN_BITS_EXT = $2017;
|
||||
WGL_GREEN_SHIFT_EXT = $2018;
|
||||
WGL_BLUE_BITS_EXT = $2019;
|
||||
WGL_BLUE_SHIFT_EXT = $201A;
|
||||
WGL_ALPHA_BITS_EXT = $201B;
|
||||
WGL_ALPHA_SHIFT_EXT = $201C;
|
||||
WGL_ACCUM_BITS_EXT = $201D;
|
||||
WGL_ACCUM_RED_BITS_EXT = $201E;
|
||||
WGL_ACCUM_GREEN_BITS_EXT = $201F;
|
||||
WGL_ACCUM_BLUE_BITS_EXT = $2020;
|
||||
WGL_ACCUM_ALPHA_BITS_EXT = $2021;
|
||||
WGL_DEPTH_BITS_EXT = $2022;
|
||||
WGL_STENCIL_BITS_EXT = $2023;
|
||||
WGL_AUX_BUFFERS_EXT = $2024;
|
||||
WGL_NO_ACCELERATION_EXT = $2025;
|
||||
WGL_GENERIC_ACCELERATION_EXT = $2026;
|
||||
WGL_FULL_ACCELERATION_EXT = $2027;
|
||||
WGL_SWAP_EXCHANGE_EXT = $2028;
|
||||
WGL_SWAP_COPY_EXT = $2029;
|
||||
WGL_SWAP_UNDEFINED_EXT = $202A;
|
||||
WGL_TYPE_RGBA_EXT = $202B;
|
||||
WGL_TYPE_COLORINDEX_EXT = $202C;
|
||||
|
||||
function wglGetPixelFormatAttribivEXT(hdc: HDC; iPixelFormat: TGLint; iLayerPlane: TGLint; nAttributes: TGLuint; piAttributes: PGLint; piValues: PGLint): BOOL; external dllname;
|
||||
function wglGetPixelFormatAttribfvEXT(hdc: HDC; iPixelFormat: TGLint; iLayerPlane: TGLint; nAttributes: TGLuint; piAttributes: PGLint; pfValues: PGLfloat): BOOL; external dllname;
|
||||
function wglChoosePixelFormatEXT(hdc: HDC; const piAttribIList: PGLint; const pfAttribFList: PGLfloat; nMaxFormats: TGLuint; piFormats: PGLint; nNumFormats: PGLuint): BOOL; external dllname;
|
||||
|
||||
|
||||
const
|
||||
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D = $2050;
|
||||
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D = $2051;
|
||||
WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D = $2052;
|
||||
WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D = $2053;
|
||||
|
||||
function wglGetDigitalVideoParametersI3D(hDC: HDC; iAttribute: TGLint; piValue: PGLint): BOOL; external dllname;
|
||||
function wglSetDigitalVideoParametersI3D(hDC: HDC; iAttribute: TGLint; const piValue: PGLint): BOOL; external dllname;
|
||||
|
||||
|
||||
const
|
||||
WGL_GAMMA_TABLE_SIZE_I3D = $204E;
|
||||
WGL_GAMMA_EXCLUDE_DESKTOP_I3D = $204F;
|
||||
|
||||
function wglGetGammaTableParametersI3D(hDC: HDC; iAttribute: TGLint; piValue: PGLint): BOOL; external dllname;
|
||||
function wglSetGammaTableParametersI3D(hDC: HDC; iAttribute: TGLint; const piValue: PGLint): BOOL; external dllname;
|
||||
function wglGetGammaTableI3D(hDC: HDC; iEntries: TGLint; puRed: PGLUSHORT; puGreen: PGLUSHORT; puBlue: PGLUSHORT): BOOL; external dllname;
|
||||
function wglSetGammaTableI3D(hDC: HDC; iEntries: TGLint; const puRed: PGLUSHORT; const puGreen: PGLUSHORT; const puBlue: PGLUSHORT): BOOL; external dllname;
|
||||
|
||||
const
|
||||
WGL_GENLOCK_SOURCE_MULTIVIEW_I3D = $2044;
|
||||
WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D = $2045;
|
||||
WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D = $2046;
|
||||
WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D = $2047;
|
||||
WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D = $2048;
|
||||
WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D = $2049;
|
||||
WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D = $204A;
|
||||
WGL_GENLOCK_SOURCE_EDGE_RISING_I3D = $204B;
|
||||
WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D = $204C;
|
||||
|
||||
WGL_FLOAT_COMPONENTS_NV = $20B0;
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV = $20B1;
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV = $20B2;
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV = $20B3;
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV = $20B4;
|
||||
WGL_TEXTURE_FLOAT_R_NV = $20B5;
|
||||
WGL_TEXTURE_FLOAT_RG_NV = $20B6;
|
||||
WGL_TEXTURE_FLOAT_RGB_NV = $20B7;
|
||||
WGL_TEXTURE_FLOAT_RGBA_NV = $20B8;
|
||||
|
||||
function wglEnableGenlockI3D(hDC: HDC): BOOL; external dllname;
|
||||
function wglDisableGenlockI3D(hDC: HDC): BOOL; external dllname;
|
||||
function wglIsEnabledGenlockI3D(hDC: HDC; pFlag: PBOOL): BOOL; external dllname;
|
||||
function wglGenlockSourceI3D(hDC: HDC; uSource: TGLuint): BOOL; external dllname;
|
||||
function wglGetGenlockSourceI3D(hDC: HDC; uSource: PGLUINT): BOOL; external dllname;
|
||||
function wglGenlockSourceEdgeI3D(hDC: HDC; uEdge: TGLuint): BOOL; external dllname;
|
||||
function wglGetGenlockSourceEdgeI3D(hDC: HDC; uEdge: PGLUINT): BOOL; external dllname;
|
||||
function wglGenlockSampleRateI3D(hDC: HDC; uRate: TGLuint): BOOL; external dllname;
|
||||
function wglGetGenlockSampleRateI3D(hDC: HDC; uRate: PGLUINT): BOOL; external dllname;
|
||||
function wglGenlockSourceDelayI3D(hDC: HDC; uDelay: TGLuint): BOOL; external dllname;
|
||||
function wglGetGenlockSourceDelayI3D(hDC: HDC; uDelay: PGLUINT): BOOL; external dllname;
|
||||
function wglQueryGenlockMaxSourceDelayI3D(hDC: HDC; uMaxLineDelay: PGLUINT; uMaxPixelDelay: PGLUINT): BOOL; external dllname;
|
||||
|
||||
const
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV = $20A0;
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV = $20A1;
|
||||
WGL_TEXTURE_RECTANGLE_NV = $20A2;
|
||||
|
||||
|
||||
const
|
||||
WGL_RGBA_FLOAT_MODE_ATI = $8820;
|
||||
WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI = $8835;
|
||||
WGL_TYPE_RGBA_FLOAT_ATI = $21A0;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
2521
lib/base/sdl/sdl.nim
Normal file
2521
lib/base/sdl/sdl.nim
Normal file
File diff suppressed because it is too large
Load Diff
421
lib/base/sdl/sdl_gfx.nim
Normal file
421
lib/base/sdl/sdl_gfx.nim
Normal file
@@ -0,0 +1,421 @@
|
||||
|
||||
#
|
||||
# $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# $Log: sdl_gfx.pas,v $
|
||||
# Revision 1.3 2007/05/29 21:31:04 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.2 2007/05/20 20:30:18 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.1 2005/01/03 19:08:32 savage
|
||||
# Header for the SDL_Gfx library.
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const SDLgfxLibName = "SDL_gfx.dll"
|
||||
elif defined(macosx):
|
||||
const SDLgfxLibName = "libSDL_gfx.dylib"
|
||||
else:
|
||||
const SDLgfxLibName = "libSDL_gfx.so"
|
||||
|
||||
const # Some rates in Hz
|
||||
FPS_UPPER_LIMIT* = 200
|
||||
FPS_LOWER_LIMIT* = 1
|
||||
FPS_DEFAULT* = 30 # ---- Defines
|
||||
SMOOTHING_OFF* = 0
|
||||
SMOOTHING_ON* = 1
|
||||
|
||||
type
|
||||
PFPSmanager* = ptr TFPSmanager
|
||||
TFPSmanager*{.final.} = object # ---- Structures
|
||||
framecount*: Uint32
|
||||
rateticks*: float32
|
||||
lastticks*: Uint32
|
||||
rate*: Uint32
|
||||
|
||||
PColorRGBA* = ptr TColorRGBA
|
||||
TColorRGBA*{.final.} = object
|
||||
r*: Uint8
|
||||
g*: Uint8
|
||||
b*: Uint8
|
||||
a*: Uint8
|
||||
|
||||
PColorY* = ptr TColorY
|
||||
TColorY*{.final.} = object #
|
||||
#
|
||||
# SDL_framerate: framerate manager
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
y*: Uint8
|
||||
|
||||
|
||||
proc SDL_initFramerate*(manager: PFPSmanager){.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc SDL_setFramerate*(manager: PFPSmanager, rate: int): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
proc SDL_getFramerate*(manager: PFPSmanager): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc SDL_framerateDelay*(manager: PFPSmanager){.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
#
|
||||
#
|
||||
# SDL_gfxPrimitives: graphics primitives for SDL
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
# Note: all ___Color routines expect the color to be in format 0xRRGGBBAA
|
||||
# Pixel
|
||||
proc pixelColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, color: Uint32): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc pixelRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Uint8, g: Uint8,
|
||||
b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Horizontal line
|
||||
proc hlineColor*(dst: PSDL_Surface, x1: Sint16, x2: Sint16, y: Sint16,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc hlineRGBA*(dst: PSDL_Surface, x1: Sint16, x2: Sint16, y: Sint16, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Vertical line
|
||||
proc vlineColor*(dst: PSDL_Surface, x: Sint16, y1: Sint16, y2: Sint16,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc vlineRGBA*(dst: PSDL_Surface, x: Sint16, y1: Sint16, y2: Sint16, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Rectangle
|
||||
proc rectangleColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, color: Uint32): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
proc rectangleRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Filled rectangle (Box)
|
||||
proc boxColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc boxRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# Line
|
||||
proc lineColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc lineRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# AA Line
|
||||
proc aalineColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc aalineRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Circle
|
||||
proc circleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc circleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# AA Circle
|
||||
proc aacircleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc aacircleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# Filled Circle
|
||||
proc filledCircleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc filledCircleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# Ellipse
|
||||
proc ellipseColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16,
|
||||
ry: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc ellipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16,
|
||||
ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# AA Ellipse
|
||||
proc aaellipseColor*(dst: PSDL_Surface, xc: Sint16, yc: Sint16, rx: Sint16,
|
||||
ry: Sint16, color: Uint32): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
proc aaellipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16,
|
||||
ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Filled Ellipse
|
||||
proc filledEllipseColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16,
|
||||
ry: Sint16, color: Uint32): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
proc filledEllipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16,
|
||||
ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Pie
|
||||
proc pieColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
|
||||
start: Sint16, finish: Sint16, color: Uint32): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
proc pieRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
|
||||
start: Sint16, finish: Sint16, r: Uint8, g: Uint8, b: Uint8,
|
||||
a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Filled Pie
|
||||
proc filledPieColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
|
||||
start: Sint16, finish: Sint16, color: Uint32): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
proc filledPieRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
|
||||
start: Sint16, finish: Sint16, r: Uint8, g: Uint8, b: Uint8,
|
||||
a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Trigon
|
||||
proc trigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc trigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8,
|
||||
b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# AA-Trigon
|
||||
proc aatrigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc aatrigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8,
|
||||
b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Filled Trigon
|
||||
proc filledTrigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc filledTrigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8,
|
||||
b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Polygon
|
||||
proc polygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc polygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# AA-Polygon
|
||||
proc aapolygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc aapolygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# Filled Polygon
|
||||
proc filledPolygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc filledPolygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# Bezier
|
||||
# s = number of steps
|
||||
proc bezierColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, s: int,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc bezierRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, s: int,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# Characters/Strings
|
||||
proc characterColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: char,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc characterRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: char, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
proc stringColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: cstring,
|
||||
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc stringRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: cstring, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
proc gfxPrimitivesSetFont*(fontdata: Pointer, cw: int, ch: int){.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
#
|
||||
#
|
||||
# SDL_imageFilter - bytes-image "filter" routines
|
||||
# (uses inline x86 MMX optimizations if available)
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
# Comments:
|
||||
# 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary.
|
||||
# 2.) Data that is not within an 8 byte boundary is processed using the C routine.
|
||||
# 3.) Convolution routines do not have C routines at this time.
|
||||
# Detect MMX capability in CPU
|
||||
proc SDL_imageFilterMMXdetect*(): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Force use of MMX off (or turn possible use back on)
|
||||
proc SDL_imageFilterMMXoff*(){.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc SDL_imageFilterMMXon*(){.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
#
|
||||
# All routines return:
|
||||
# 0 OK
|
||||
# -1 Error (internal error, parameter error)
|
||||
#
|
||||
# SDL_imageFilterAdd: D = saturation255(S1 + S2)
|
||||
proc SDL_imageFilterAdd*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterMean: D = S1/2 + S2/2
|
||||
proc SDL_imageFilterMean*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterSub: D = saturation0(S1 - S2)
|
||||
proc SDL_imageFilterSub*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterAbsDiff: D = | S1 - S2 |
|
||||
proc SDL_imageFilterAbsDiff*(Src1: cstring, Src2: cstring, Dest: cstring,
|
||||
len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterMult: D = saturation(S1 * S2)
|
||||
proc SDL_imageFilterMult*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterMultNor: D = S1 * S2 (non-MMX)
|
||||
proc SDL_imageFilterMultNor*(Src1: cstring, Src2: cstring, Dest: cstring,
|
||||
len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
|
||||
proc SDL_imageFilterMultDivby2*(Src1: cstring, Src2: cstring, Dest: cstring,
|
||||
len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
|
||||
proc SDL_imageFilterMultDivby4*(Src1: cstring, Src2: cstring, Dest: cstring,
|
||||
len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterBitAnd: D = S1 & S2
|
||||
proc SDL_imageFilterBitAnd*(Src1: cstring, Src2: cstring, Dest: cstring,
|
||||
len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterBitOr: D = S1 | S2
|
||||
proc SDL_imageFilterBitOr*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterDiv: D = S1 / S2 (non-MMX)
|
||||
proc SDL_imageFilterDiv*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterBitNegation: D = !S
|
||||
proc SDL_imageFilterBitNegation*(Src1: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterAddByte: D = saturation255(S + C)
|
||||
proc SDL_imageFilterAddByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
|
||||
proc SDL_imageFilterAddUint*(Src1: cstring, Dest: cstring, len: int, C: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
|
||||
proc SDL_imageFilterAddByteToHalf*(Src1: cstring, Dest: cstring, len: int,
|
||||
C: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterSubByte: D = saturation0(S - C)
|
||||
proc SDL_imageFilterSubByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
|
||||
proc SDL_imageFilterSubUint*(Src1: cstring, Dest: cstring, len: int, C: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterShiftRight: D = saturation0(S >> N)
|
||||
proc SDL_imageFilterShiftRight*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
|
||||
proc SDL_imageFilterShiftRightUint*(Src1: cstring, Dest: cstring, len: int,
|
||||
N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterMultByByte: D = saturation255(S * C)
|
||||
proc SDL_imageFilterMultByByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
|
||||
proc SDL_imageFilterShiftRightAndMultByByte*(Src1: cstring, Dest: cstring,
|
||||
len: int, N: char, C: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterShiftLeftByte: D = (S << N)
|
||||
proc SDL_imageFilterShiftLeftByte*(Src1: cstring, Dest: cstring, len: int,
|
||||
N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
|
||||
proc SDL_imageFilterShiftLeftUint*(Src1: cstring, Dest: cstring, len: int,
|
||||
N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterShiftLeft: D = saturation255(S << N)
|
||||
proc SDL_imageFilterShiftLeft*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
|
||||
proc SDL_imageFilterBinarizeUsingThreshold*(Src1: cstring, Dest: cstring,
|
||||
len: int, T: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
|
||||
proc SDL_imageFilterClipToRange*(Src1: cstring, Dest: cstring, len: int,
|
||||
Tmin: int8, Tmax: int8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
|
||||
proc SDL_imageFilterNormalizeLinear*(Src1: cstring, Dest: cstring, len: int,
|
||||
Cmin: int, Cmax: int, Nmin: int, Nmax: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!!
|
||||
# SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
|
||||
proc SDL_imageFilterConvolveKernel3x3Divide*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
|
||||
proc SDL_imageFilterConvolveKernel5x5Divide*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
|
||||
proc SDL_imageFilterConvolveKernel7x7Divide*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
|
||||
proc SDL_imageFilterConvolveKernel9x9Divide*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
|
||||
proc SDL_imageFilterConvolveKernel3x3ShiftRight*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
|
||||
proc SDL_imageFilterConvolveKernel5x5ShiftRight*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
|
||||
proc SDL_imageFilterConvolveKernel7x7ShiftRight*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
|
||||
proc SDL_imageFilterConvolveKernel9x9ShiftRight*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterSobelX: Dij = saturation255( ... )
|
||||
proc SDL_imageFilterSobelX*(Src: cstring, Dest: cstring, rows: int, columns: int): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
|
||||
proc SDL_imageFilterSobelXShiftRight*(Src: cstring, Dest: cstring, rows: int,
|
||||
columns: int, NRightShift: char): int{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Align/restore stack to 32 byte boundary -- Functionality untested! --
|
||||
proc SDL_imageFilterAlignStack*(){.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc SDL_imageFilterRestoreStack*(){.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
#
|
||||
#
|
||||
# SDL_rotozoom - rotozoomer
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# rotozoomSurface()
|
||||
#
|
||||
# Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
|
||||
# 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1
|
||||
# then the destination 32bit surface is anti-aliased. If the surface is not 8bit
|
||||
# or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
|
||||
#
|
||||
#
|
||||
proc rotozoomSurface*(src: PSDL_Surface, angle: float64, zoom: float64,
|
||||
smooth: int): PSDL_Surface{.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc rotozoomSurfaceXY*(src: PSDL_Surface, angle: float64, zoomx: float64,
|
||||
zoomy: float64, smooth: int): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# Returns the size of the target surface for a rotozoomSurface() call
|
||||
proc rotozoomSurfaceSize*(width: int, height: int, angle: float64,
|
||||
zoom: float64, dstwidth: var int, dstheight: var int){.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
proc rotozoomSurfaceSizeXY*(width: int, height: int, angle: float64,
|
||||
zoomx: float64, zoomy: float64, dstwidth: var int,
|
||||
dstheight: var int){.cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
#
|
||||
#
|
||||
# zoomSurface()
|
||||
#
|
||||
# Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
|
||||
# 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1
|
||||
# then the destination 32bit surface is anti-aliased. If the surface is not 8bit
|
||||
# or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
|
||||
#
|
||||
#
|
||||
proc zoomSurface*(src: PSDL_Surface, zoomx: float64, zoomy: float64, smooth: int): PSDL_Surface{.
|
||||
cdecl, importc, dynlib: SDLgfxLibName.}
|
||||
# Returns the size of the target surface for a zoomSurface() call
|
||||
proc zoomSurfaceSize*(width: int, height: int, zoomx: float64, zoomy: float64,
|
||||
dstwidth: var int, dstheight: var int){.cdecl,
|
||||
importc, dynlib: SDLgfxLibName.}
|
||||
# implementation
|
||||
227
lib/base/sdl/sdl_image.nim
Normal file
227
lib/base/sdl/sdl_image.nim
Normal file
@@ -0,0 +1,227 @@
|
||||
|
||||
#
|
||||
# $Id: sdl_image.pas,v 1.14 2007/05/29 21:31:13 savage Exp $
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
#
|
||||
# Borland Delphi SDL_Image - An example image loading library for use
|
||||
# with SDL
|
||||
# Conversion of the Simple DirectMedia Layer Image Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_image.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Portions created by Matthias Thoma are
|
||||
# Copyright (C) 2000 - 2001 Matthias Thoma.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Dominique Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
# A simple library to load images of various formats as SDL surfaces
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# SDL.pas in your search path.
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
# See the Aliens Demo on how to make use of this libaray
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# April 02 2001 - MT : Initial Translation
|
||||
#
|
||||
# May 08 2001 - DL : Added ExternalSym derectives and copyright header
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_image.pas,v $
|
||||
# Revision 1.14 2007/05/29 21:31:13 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.13 2007/05/20 20:30:54 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.12 2006/12/02 00:14:40 savage
|
||||
# Updated to latest version
|
||||
#
|
||||
# Revision 1.11 2005/04/10 18:22:59 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.10 2005/04/10 11:48:33 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.9 2005/01/05 01:47:07 savage
|
||||
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
|
||||
#
|
||||
# Revision 1.8 2005/01/04 23:14:44 savage
|
||||
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
|
||||
#
|
||||
# Revision 1.7 2005/01/01 02:03:12 savage
|
||||
# Updated to v1.2.4
|
||||
#
|
||||
# Revision 1.6 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.5 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.4 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.3 2004/04/01 20:53:23 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/14 23:35:42 savage
|
||||
# version 1 of sdl_image, sdl_mixer and smpeg.
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const SDL_ImageLibName = "SDL_Image.dll"
|
||||
elif defined(macosx):
|
||||
const SDL_ImageLibName = "libSDL_image-1.2.0.dylib"
|
||||
else:
|
||||
const SDL_ImageLibName = "libSDL_image.so"
|
||||
|
||||
const
|
||||
SDL_IMAGE_MAJOR_VERSION* = 1'i8
|
||||
SDL_IMAGE_MINOR_VERSION* = 2'i8
|
||||
SDL_IMAGE_PATCHLEVEL* = 5'i8
|
||||
|
||||
# This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_image library.
|
||||
|
||||
proc SDL_IMAGE_VERSION*(X: var TSDL_Version)
|
||||
# This function gets the version of the dynamically linked SDL_image library.
|
||||
# it should NOT be used to fill a version structure, instead you should
|
||||
# use the SDL_IMAGE_VERSION() macro.
|
||||
#
|
||||
proc IMG_Linked_Version*(): PSDL_version{.importc, dynlib: SDL_ImageLibName.}
|
||||
# Load an image from an SDL data source.
|
||||
# The 'type' may be one of: "BMP", "GIF", "PNG", etc.
|
||||
#
|
||||
# If the image format supports a transparent pixel, SDL will set the
|
||||
# colorkey for the surface. You can enable RLE acceleration on the
|
||||
# surface afterwards by calling:
|
||||
# SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey);
|
||||
#
|
||||
proc IMG_LoadTyped_RW*(src: PSDL_RWops, freesrc: int, theType: cstring): PSDL_Surface{.
|
||||
cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
# Convenience functions
|
||||
proc IMG_Load*(theFile: cstring): PSDL_Surface{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_Load_RW*(src: PSDL_RWops, freesrc: int): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
# Invert the alpha of a surface for use with OpenGL
|
||||
# This function is now a no-op, and only provided for backwards compatibility.
|
||||
proc IMG_InvertAlpha*(theOn: int): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
# Functions to detect a file type, given a seekable source
|
||||
proc IMG_isBMP*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_isGIF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_isJPG*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_isLBM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_isPCX*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_isPNG*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_isPNM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_isTIF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_isXCF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_isXPM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_isXV*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
|
||||
# Individual loading functions
|
||||
proc IMG_LoadBMP_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadGIF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadJPG_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadLBM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadPCX_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadPNM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadPNG_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadTGA_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadTIF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadXCF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadXPM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_LoadXV_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
proc IMG_ReadXPMFromArray*(xpm: cstringArray): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDL_ImageLibName.}
|
||||
# Error Macros
|
||||
# We'll use SDL for reporting errors
|
||||
proc IMG_SetError*(fmt: cstring)
|
||||
proc IMG_GetError*(): cstring
|
||||
# implementation
|
||||
|
||||
proc SDL_IMAGE_VERSION(X: var TSDL_Version) =
|
||||
X.major = SDL_IMAGE_MAJOR_VERSION
|
||||
X.minor = SDL_IMAGE_MINOR_VERSION
|
||||
X.patch = SDL_IMAGE_PATCHLEVEL
|
||||
|
||||
proc IMG_SetError(fmt: cstring) =
|
||||
SDL_SetError(fmt)
|
||||
|
||||
proc IMG_GetError(): cstring =
|
||||
result = SDL_GetError()
|
||||
742
lib/base/sdl/sdl_mixer.nim
Normal file
742
lib/base/sdl/sdl_mixer.nim
Normal file
@@ -0,0 +1,742 @@
|
||||
|
||||
#******************************************************************************
|
||||
#
|
||||
# $Id: sdl_mixer.pas,v 1.18 2007/05/29 21:31:44 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library
|
||||
# Conversion of the Simple DirectMedia Layer Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_mixer.h
|
||||
# music_cmd.h
|
||||
# wavestream.h
|
||||
# timidity.h
|
||||
# playmidi.h
|
||||
# music_ogg.h
|
||||
# mikmod.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Portions created by Dominqiue Louis are
|
||||
# Copyright (C) 2000 - 2001 Dominqiue Louis.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# SDL.pas & SMPEG.pas somewhere within your search path.
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
# See the Aliens Demo to see how this library is used
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# April 02 2001 - DL : Initial Translation
|
||||
#
|
||||
# February 02 2002 - DL : Update to version 1.2.1
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_mixer.pas,v $
|
||||
# Revision 1.18 2007/05/29 21:31:44 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.17 2007/05/20 20:31:17 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.16 2006/12/02 00:16:17 savage
|
||||
# Updated to latest version
|
||||
#
|
||||
# Revision 1.15 2005/04/10 11:48:33 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.14 2005/02/24 20:20:07 savage
|
||||
# Changed definition of MusicType and added GetMusicType function
|
||||
#
|
||||
# Revision 1.13 2005/01/05 01:47:09 savage
|
||||
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
|
||||
#
|
||||
# Revision 1.12 2005/01/04 23:14:56 savage
|
||||
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
|
||||
#
|
||||
# Revision 1.11 2005/01/01 02:05:19 savage
|
||||
# Updated to v1.2.6
|
||||
#
|
||||
# Revision 1.10 2004/09/12 21:45:17 savage
|
||||
# Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added.
|
||||
#
|
||||
# Revision 1.9 2004/08/27 21:48:24 savage
|
||||
# IFDEFed out Smpeg support on MacOS X
|
||||
#
|
||||
# Revision 1.8 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.7 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.6 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.5 2004/04/01 20:53:23 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.4 2004/03/31 22:20:02 savage
|
||||
# Windows unit not used in this file, so it was removed to keep the code tidy.
|
||||
#
|
||||
# Revision 1.3 2004/03/31 10:05:08 savage
|
||||
# Better defines for Endianess under FreePascal and Borland compilers.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/14 23:35:42 savage
|
||||
# version 1 of sdl_image, sdl_mixer and smpeg.
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
sdl, smpeg
|
||||
|
||||
when defined(windows):
|
||||
const SDL_MixerLibName = "SDL_mixer.dll"
|
||||
elif defined(macosx):
|
||||
const SDL_MixerLibName = "libSDL_mixer-1.2.0.dylib"
|
||||
else:
|
||||
const SDL_MixerLibName = "libSDL_mixer.so"
|
||||
|
||||
const
|
||||
SDL_MIXER_MAJOR_VERSION* = 1'i8
|
||||
SDL_MIXER_MINOR_VERSION* = 2'i8
|
||||
SDL_MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility
|
||||
MIX_MAJOR_VERSION* = SDL_MIXER_MAJOR_VERSION
|
||||
MIX_MINOR_VERSION* = SDL_MIXER_MINOR_VERSION
|
||||
MIX_PATCHLEVEL* = SDL_MIXER_PATCHLEVEL # SDL_Mixer.h constants
|
||||
# The default mixer has 8 simultaneous mixing channels
|
||||
MIX_CHANNELS* = 8 # Good default values for a PC soundcard
|
||||
MIX_DEFAULT_FREQUENCY* = 22050
|
||||
|
||||
when defined(IA32):
|
||||
const
|
||||
MIX_DEFAULT_FORMAT* = AUDIO_S16LSB
|
||||
else:
|
||||
const
|
||||
MIX_DEFAULT_FORMAT* = AUDIO_S16MSB
|
||||
const
|
||||
MIX_DEFAULT_CHANNELS* = 2
|
||||
MIX_MAX_VOLUME* = 128 # Volume of a chunk
|
||||
PATH_MAX* = 255 # mikmod.h constants
|
||||
#*
|
||||
# * Library version
|
||||
# *
|
||||
LIBMIKMOD_VERSION_MAJOR* = 3
|
||||
LIBMIKMOD_VERSION_MINOR* = 1
|
||||
LIBMIKMOD_REVISION* = 8
|
||||
LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
|
||||
(LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
|
||||
|
||||
type #music_cmd.h types
|
||||
PMusicCMD* = ptr TMusicCMD
|
||||
TMusicCMD*{.final.} = object #wavestream.h types
|
||||
filename*: array[0..PATH_MAX - 1, char]
|
||||
cmd*: array[0..PATH_MAX - 1, char]
|
||||
pid*: TSYS_ThreadHandle
|
||||
|
||||
PWAVStream* = ptr TWAVStream
|
||||
TWAVStream*{.final.} = object #playmidi.h types
|
||||
wavefp*: Pointer
|
||||
start*: int32
|
||||
stop*: int32
|
||||
cvt*: TSDL_AudioCVT
|
||||
|
||||
PMidiEvent* = ptr TMidiEvent
|
||||
TMidiEvent*{.final.} = object
|
||||
time*: int32
|
||||
channel*: uint8
|
||||
type_*: uint8
|
||||
a*: uint8
|
||||
b*: uint8
|
||||
|
||||
PMidiSong* = ptr TMidiSong
|
||||
TMidiSong*{.final.} = object #music_ogg.h types
|
||||
samples*: int32
|
||||
events*: PMidiEvent
|
||||
|
||||
POGG_Music* = ptr TOGG_Music
|
||||
TOGG_Music*{.final.} = object # mikmod.h types
|
||||
#*
|
||||
# * Error codes
|
||||
# *
|
||||
playing*: int
|
||||
volume*: int #vf: OggVorbis_File;
|
||||
section*: int
|
||||
cvt*: TSDL_AudioCVT
|
||||
len_available*: int
|
||||
snd_available*: PUint8
|
||||
|
||||
TErrorEnum* = enum
|
||||
MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING,
|
||||
MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE,
|
||||
MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER,
|
||||
MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM,
|
||||
MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE,
|
||||
MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO,
|
||||
MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW,
|
||||
MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT,
|
||||
MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS,
|
||||
MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED,
|
||||
MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC,
|
||||
MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE,
|
||||
MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT,
|
||||
MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT,
|
||||
MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD,
|
||||
MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY,
|
||||
MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE,
|
||||
MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT,
|
||||
MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
|
||||
PMODULE* = ptr TMODULE
|
||||
TMODULE*{.final.} = object
|
||||
PUNIMOD* = ptr TUNIMOD
|
||||
TUNIMOD* = TMODULE #SDL_mixer.h types
|
||||
# The internal format for an audio chunk
|
||||
PMix_Chunk* = ptr TMix_Chunk
|
||||
TMix_Chunk*{.final.} = object
|
||||
allocated*: int
|
||||
abuf*: PUint8
|
||||
alen*: Uint32
|
||||
volume*: Uint8 # Per-sample volume, 0-128
|
||||
|
||||
Mix_Chunk* = TMix_Chunk # The different fading types supported
|
||||
TMix_Fading* = enum
|
||||
MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
|
||||
Mix_Fading* = TMix_Fading
|
||||
TMix_MusicType* = enum
|
||||
MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3
|
||||
Mix_MusicType* = TMix_MusicType #
|
||||
# TMusicUnion = record
|
||||
# case XXX: Byte of
|
||||
# 0 : ( cmd : PMusicCMD );
|
||||
# 1 : ( wave : PWAVStream );
|
||||
# 2 : ( module : PUNIMOD );
|
||||
# 3 : ( midi : TMidiSong );
|
||||
# 4 : ( ogg : POGG_music );
|
||||
# {$IFNDEF DARWIN}
|
||||
# 5 : ( mp3 : PSMPEG );
|
||||
# {$ENDIF}
|
||||
# end;
|
||||
PMix_Music* = ptr TMix_Music
|
||||
TMix_Music*{.final.} = object # The internal format for a music chunk interpreted via mikmod
|
||||
type_*: TMix_MusicType # other fields are not aviable
|
||||
# data : TMusicUnion;
|
||||
# fading : TMix_Fading;
|
||||
# fade_volume : integer;
|
||||
# fade_step : integer;
|
||||
# fade_steps : integer;
|
||||
# error : integer;
|
||||
|
||||
TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{.
|
||||
cdecl.} # This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_mixer library.
|
||||
|
||||
proc SDL_MIXER_VERSION*(X: var TSDL_Version)
|
||||
# This function gets the version of the dynamically linked SDL_mixer library.
|
||||
# It should NOT be used to fill a version structure, instead you should use the
|
||||
# SDL_MIXER_VERSION() macro.
|
||||
proc Mix_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Open the mixer with a certain audio format
|
||||
proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int,
|
||||
chunksize: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Dynamically change the number of channels managed by the mixer.
|
||||
# If decreasing the number of channels, the upper channels are
|
||||
# stopped.
|
||||
# This function returns the new number of allocated channels.
|
||||
#
|
||||
proc Mix_AllocateChannels*(numchannels: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Find out what the actual audio device parameters are.
|
||||
# This function returns 1 if the audio has been opened, 0 otherwise.
|
||||
#
|
||||
proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{.
|
||||
cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Load a wave file or a music (.mod .s3m .it .xm) file
|
||||
proc Mix_LoadWAV_RW*(src: PSDL_RWops, freesrc: int): PMix_Chunk{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_LoadWAV*(filename: cstring): PMix_Chunk
|
||||
proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
##if 0 { This hasn't been hooked into music.c yet }
|
||||
#{ Load a music file from an SDL_RWop object (MikMod-specific currently)
|
||||
# Matt Campbell (matt@campbellhome.dhs.org) April 2000 }
|
||||
#function Mix_LoadMUS_RW(SDL_RWops *rw) : PMix_Music; cdecl;
|
||||
##endif
|
||||
# Load a wave file of the mixer format from a memory buffer
|
||||
proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Free an audio chunk previously loaded
|
||||
proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Find out the music format of a mixer music, or the currently playing
|
||||
# music, if 'music' is NULL.
|
||||
proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Set a function that is called after all mixing is performed.
|
||||
# This can be used to provide real-time visual display of the audio stream
|
||||
# or add a custom mixer filter for the stream data.
|
||||
#
|
||||
proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Add your own music player or additional mixer function.
|
||||
# If 'mix_func' is NULL, the default music player is re-enabled.
|
||||
#
|
||||
proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Add your own callback when the music has finished playing.
|
||||
#
|
||||
proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Get a pointer to the user data for the current music hook
|
||||
proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
#* Add your own callback when a channel has finished playing. NULL
|
||||
# * to disable callback.*
|
||||
type
|
||||
TChannel_finished* = proc (channel: int){.cdecl.}
|
||||
|
||||
proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
const
|
||||
MIX_CHANNEL_POST* = - 2
|
||||
# This is the format of a special effect callback:
|
||||
# myeffect(int chan, void *stream, int len, void *udata);
|
||||
#
|
||||
# (chan) is the channel number that your effect is affecting. (stream) is
|
||||
# the buffer of data to work upon. (len) is the size of (stream), and
|
||||
# (udata) is a user-defined bit of data, which you pass as the last arg of
|
||||
# Mix_RegisterEffect(), and is passed back unmolested to your callback.
|
||||
# Your effect changes the contents of (stream) based on whatever parameters
|
||||
# are significant, or just leaves it be, if you prefer. You can do whatever
|
||||
# you like to the buffer, though, and it will continue in its changed state
|
||||
# down the mixing pipeline, through any other effect functions, then finally
|
||||
# to be mixed with the rest of the channels and music for the final output
|
||||
# stream.
|
||||
#
|
||||
|
||||
type
|
||||
TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int,
|
||||
udata: Pointer): Pointer{.cdecl.}
|
||||
# * This is a callback that signifies that a channel has finished all its
|
||||
# * loops and has completed playback. This gets called if the buffer
|
||||
# * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
|
||||
# * a channel via Mix_AllocateChannels(), or unregister a callback while
|
||||
# * it's still playing.
|
||||
TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.}
|
||||
#* Register a special effect function. At mixing time, the channel data is
|
||||
# * copied into a buffer and passed through each registered effect function.
|
||||
# * After it passes through all the functions, it is mixed into the final
|
||||
# * output stream. The copy to buffer is performed once, then each effect
|
||||
# * function performs on the output of the previous effect. Understand that
|
||||
# * this extra copy to a buffer is not performed if there are no effects
|
||||
# * registered for a given chunk, which saves CPU cycles, and any given
|
||||
# * effect will be extra cycles, too, so it is crucial that your code run
|
||||
# * fast. Also note that the data that your function is given is in the
|
||||
# * format of the sound device, and not the format you gave to Mix_OpenAudio(),
|
||||
# * although they may in reality be the same. This is an unfortunate but
|
||||
# * necessary speed concern. Use Mix_QuerySpec() to determine if you can
|
||||
# * handle the data before you register your effect, and take appropriate
|
||||
# * actions.
|
||||
# * You may also specify a callback (Mix_EffectDone_t) that is called when
|
||||
# * the channel finishes playing. This gives you a more fine-grained control
|
||||
# * than Mix_ChannelFinished(), in case you need to free effect-specific
|
||||
# * resources, etc. If you don't need this, you can specify NULL.
|
||||
# * You may set the callbacks before or after calling Mix_PlayChannel().
|
||||
# * Things like Mix_SetPanning() are just internal special effect functions,
|
||||
# * so if you are using that, you've already incurred the overhead of a copy
|
||||
# * to a separate buffer, and that these effects will be in the queue with
|
||||
# * any functions you've registered. The list of registered effects for a
|
||||
# * channel is reset when a chunk finishes playing, so you need to explicitly
|
||||
# * set them with each call to Mix_PlayChannel*().
|
||||
# * You may also register a special effect function that is to be run after
|
||||
# * final mixing occurs. The rules for these callbacks are identical to those
|
||||
# * in Mix_RegisterEffect, but they are run after all the channels and the
|
||||
# * music have been mixed into a single stream, whereas channel-specific
|
||||
# * effects run on a given channel before any other mixing occurs. These
|
||||
# * global effect callbacks are call "posteffects". Posteffects only have
|
||||
# * their Mix_EffectDone_t function called when they are unregistered (since
|
||||
# * the main output stream is never "done" in the same sense as a channel).
|
||||
# * You must unregister them manually when you've had enough. Your callback
|
||||
# * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
|
||||
# * processing is considered a posteffect.
|
||||
# *
|
||||
# * After all these effects have finished processing, the callback registered
|
||||
# * through Mix_SetPostMix() runs, and then the stream goes to the audio
|
||||
# * device.
|
||||
# *
|
||||
# * returns zero if error (no such channel), nonzero if added.
|
||||
# * Error messages can be retrieved from Mix_GetError().
|
||||
# *
|
||||
|
||||
proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone,
|
||||
arg: Pointer): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
#* You may not need to call this explicitly, unless you need to stop an
|
||||
# * effect from processing in the middle of a chunk's playback.
|
||||
# * Posteffects are never implicitly unregistered as they are for channels,
|
||||
# * but they may be explicitly unregistered through this function by
|
||||
# * specifying MIX_CHANNEL_POST for a channel.
|
||||
# * returns zero if error (no such channel or effect), nonzero if removed.
|
||||
# * Error messages can be retrieved from Mix_GetError().
|
||||
# *
|
||||
proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
#* You may not need to call this explicitly, unless you need to stop all
|
||||
# * effects from processing in the middle of a chunk's playback. Note that
|
||||
# * this will also shut off some internal effect processing, since
|
||||
# * Mix_SetPanning( ) and others may use this API under the hood.This is
|
||||
# * called internally when a channel completes playback.
|
||||
# * Posteffects are never implicitly unregistered as they are for channels,
|
||||
# * but they may be explicitly unregistered through this function by
|
||||
# * specifying MIX_CHANNEL_POST for a channel.
|
||||
# * returns zero if error( no such channel ), nonzero if all effects removed.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
const
|
||||
MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
|
||||
# * These are the internally - defined mixing effects.They use the same API that
|
||||
# * effects defined in the application use, but are provided here as a
|
||||
# * convenience.Some effects can reduce their quality or use more memory in
|
||||
# * the name of speed; to enable this, make sure the environment variable
|
||||
# * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
|
||||
# * Mix_OpenAudio( ).
|
||||
# *
|
||||
#* set the panning of a channel.The left and right channels are specified
|
||||
# * as integers between 0 and 255, quietest to loudest, respectively.
|
||||
# *
|
||||
# * Technically, this is just individual volume control for a sample with
|
||||
# * two( stereo )channels, so it can be used for more than just panning.
|
||||
# * if you want real panning, call it like this :
|
||||
# *
|
||||
# * Mix_SetPanning( channel, left, 255 - left );
|
||||
# *
|
||||
# * ...which isn't so hard.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the panning will be done to the final mixed stream before passing it on
|
||||
# * to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally, and returns without
|
||||
# * registering the effect function if the audio device is not configured
|
||||
# * for stereo output.Setting both( left ) and ( right ) to 255 causes this
|
||||
# * effect to be unregistered, since that is the data's normal state.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if panning effect enabled.Note that an audio device in mono
|
||||
# * mode is a no - op, but this call will return successful in that case .
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
|
||||
proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# * set the position ofa channel.( angle ) is an integer from 0 to 360, that
|
||||
# * specifies the location of the sound in relation to the listener.( angle )
|
||||
# * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
|
||||
# * Angle 0 is due north, and rotates clockwise as the value increases.
|
||||
# * for efficiency, the precision of this effect may be limited( angles 1
|
||||
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
|
||||
# * ( distance ) is an integer between 0 and 255 that specifies the space
|
||||
# * between the sound and the listener.The larger the number, the further
|
||||
# * away the sound is .Using 255 does not guarantee that the channel will be
|
||||
# * culled from the mixing process or be completely silent.For efficiency,
|
||||
# * the precision of this effect may be limited( distance 0 through 5 might
|
||||
# * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
|
||||
# * and ( distance ) to 0 unregisters this effect, since the data would be
|
||||
# * unchanged.
|
||||
# *
|
||||
# * if you need more precise positional audio, consider using OpenAL for
|
||||
# * spatialized effects instead of SDL_mixer.This is only meant to be a
|
||||
# * basic effect for simple "3D" games.
|
||||
# *
|
||||
# * if the audio device is configured for mono output, then you won't get
|
||||
# * any effectiveness from the angle; however, distance attenuation on the
|
||||
# * channel will still occur.While this effect will function with stereo
|
||||
# * voices, it makes more sense to use voices with only one channel of sound,
|
||||
# * so when they are mixed through this effect, the positioning will sound
|
||||
# * correct.You can convert them to mono through SDL before giving them to
|
||||
# * the mixer in the first place if you like.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the positioning will be done to the final mixed stream before passing it
|
||||
# * on to the audio device.
|
||||
# *
|
||||
# * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if position effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
#* set the "distance" of a channel.( distance ) is an integer from 0 to 255
|
||||
# * that specifies the location of the sound in relation to the listener.
|
||||
# * Distance 0 is overlapping the listener, and 255 is as far away as possible
|
||||
# * A distance of 255 does not guarantee silence; in such a case , you might
|
||||
# * want to try changing the chunk's volume, or just cull the sample from the
|
||||
# * mixing process with Mix_HaltChannel( ).
|
||||
# * for efficiency, the precision of this effect may be limited( distances 1
|
||||
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
|
||||
# * ( distance ) is an integer between 0 and 255 that specifies the space
|
||||
# * between the sound and the listener.The larger the number, the further
|
||||
# * away the sound is .
|
||||
# * Setting( distance ) to 0 unregisters this effect, since the data would be
|
||||
# * unchanged.
|
||||
# * if you need more precise positional audio, consider using OpenAL for
|
||||
# * spatialized effects instead of SDL_mixer.This is only meant to be a
|
||||
# * basic effect for simple "3D" games.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the distance attenuation will be done to the final mixed stream before
|
||||
# * passing it on to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if position effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# *
|
||||
# * !!! FIXME : Haven't implemented, since the effect goes past the
|
||||
# * end of the sound buffer.Will have to think about this.
|
||||
# * - -ryan.
|
||||
# * /
|
||||
# { if 0
|
||||
# { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
|
||||
# * of echo to mix.0 is no echo, 255 is infinite( and probably not
|
||||
# * what you want ).
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the reverbing will be done to the final mixed stream before passing it on
|
||||
# * to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
|
||||
# * of zero, the effect is unregistered, as the data is already in that state.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if reversing effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
# extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
|
||||
# #E ndif
|
||||
# * Causes a channel to reverse its stereo.This is handy if the user has his
|
||||
# * speakers hooked up backwards, or you would like to have a minor bit of
|
||||
# * psychedelia in your sound code. : )Calling this function with ( flip )
|
||||
# * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
|
||||
# * the effect is unregistered.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally, and thus is probably
|
||||
# * more CPU intensive than having the user just plug in his speakers
|
||||
# * correctly.Mix_SetReverseStereo( )returns without registering the effect
|
||||
# * function if the audio device is not configured for stereo output.
|
||||
# *
|
||||
# * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
|
||||
# * on the final mixed stream before sending it on to the audio device( a
|
||||
# * posteffect ).
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if reversing effect is enabled.Note that an audio device in mono
|
||||
# * mode is a no - op, but this call will return successful in that case .
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# end of effects API. - -ryan. *
|
||||
# Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
|
||||
# them dynamically to the next sample if requested with a -1 value below.
|
||||
# Returns the number of reserved channels.
|
||||
#
|
||||
proc Mix_ReserveChannels*(num: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Channel grouping functions
|
||||
# Attach a tag to a channel. A tag can be assigned to several mixer
|
||||
# channels, to form groups of channels.
|
||||
# If 'tag' is -1, the tag is removed (actually -1 is the tag used to
|
||||
# represent the group of all the channels).
|
||||
# Returns true if everything was OK.
|
||||
#
|
||||
proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Assign several consecutive channels to a group
|
||||
proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Finds the first available channel in a group of channels
|
||||
proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Returns the number of channels in a group. This is also a subtle
|
||||
# way to get the total number of channels when 'tag' is -1
|
||||
#
|
||||
proc Mix_GroupCount*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Finds the "oldest" sample playing in a group of channels
|
||||
proc Mix_GroupOldest*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Finds the "most recent" (i.e. last) sample playing in a group of channels
|
||||
proc Mix_GroupNewer*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# The same as above, but the sound is played at most 'ticks' milliseconds
|
||||
proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
|
||||
ticks: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Play an audio chunk on a specific channel.
|
||||
# If the specified channel is -1, play on the first free channel.
|
||||
# If 'loops' is greater than zero, loop the sound that many times.
|
||||
# If 'loops' is -1, loop inifinitely (~65000 times).
|
||||
# Returns which channel was used to play the sound.
|
||||
#
|
||||
proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int
|
||||
proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions
|
||||
proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
|
||||
ms: int, ticks: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int
|
||||
# Set the volume in the range of 0-128 of a specific channel or chunk.
|
||||
# If the specified channel is -1, set volume for all channels.
|
||||
# Returns the original volume.
|
||||
# If the specified volume is -1, just return the current volume.
|
||||
#
|
||||
proc Mix_Volume*(channel: int, volume: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Halt playing of a particular channel
|
||||
proc Mix_HaltChannel*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_HaltGroup*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_HaltMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Change the expiration delay for a particular channel.
|
||||
# The sample will stop playing after the 'ticks' milliseconds have elapsed,
|
||||
# or remove the expiration if 'ticks' is -1
|
||||
#
|
||||
proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Halt a channel, fading it out progressively till it's silent
|
||||
# The ms parameter indicates the number of milliseconds the fading
|
||||
# will take.
|
||||
#
|
||||
proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Query the fading status of a channel
|
||||
proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Pause/Resume a particular channel
|
||||
proc Mix_Pause*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_Resume*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_Paused*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Pause/Resume the music stream
|
||||
proc Mix_PauseMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_ResumeMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_RewindMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_PausedMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Set the current position in the music stream.
|
||||
# This returns 0 if successful, or -1 if it failed or isn't implemented.
|
||||
# This function is only implemented for MOD music formats (set pattern
|
||||
# order number) and for OGG music (set position in seconds), at the
|
||||
# moment.
|
||||
#
|
||||
proc Mix_SetMusicPosition*(position: float64): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Check the status of a specific channel.
|
||||
# If the specified channel is -1, check all channels.
|
||||
#
|
||||
proc Mix_Playing*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_PlayingMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Stop music and set external music playback command
|
||||
proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Synchro value is set by MikMod from modules while playing
|
||||
proc Mix_SetSynchroValue*(value: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_GetSynchroValue*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
#
|
||||
# Get the Mix_Chunk currently associated with a mixer channel
|
||||
# Returns nil if it's an invalid channel, or there's no chunk associated.
|
||||
#
|
||||
proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Close the mixer, halting all playing audio
|
||||
proc Mix_CloseAudio*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# We'll use SDL for reporting errors
|
||||
proc Mix_SetError*(fmt: cstring)
|
||||
proc Mix_GetError*(): cstring
|
||||
# implementation
|
||||
|
||||
proc SDL_MIXER_VERSION(X: var TSDL_version) =
|
||||
X.major = SDL_MIXER_MAJOR_VERSION
|
||||
X.minor = SDL_MIXER_MINOR_VERSION
|
||||
X.patch = SDL_MIXER_PATCHLEVEL
|
||||
|
||||
proc Mix_LoadWAV(filename: cstring): PMix_Chunk =
|
||||
result = Mix_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1)
|
||||
|
||||
proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int =
|
||||
result = Mix_PlayChannelTimed(channel, chunk, loops, - 1)
|
||||
|
||||
proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int =
|
||||
result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1)
|
||||
|
||||
proc Mix_SetError(fmt: cstring) =
|
||||
SDL_SetError(fmt)
|
||||
|
||||
proc Mix_GetError(): cstring =
|
||||
result = SDL_GetError()
|
||||
572
lib/base/sdl/sdl_mixer_nosmpeg.nim
Normal file
572
lib/base/sdl/sdl_mixer_nosmpeg.nim
Normal file
@@ -0,0 +1,572 @@
|
||||
|
||||
#******************************************************************************
|
||||
# Copy of SDL_Mixer without smpeg dependency and mp3 support
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const SDL_MixerLibName = "SDL_mixer.dll"
|
||||
elif defined(macosx):
|
||||
const SDL_MixerLibName = "libSDL_mixer-1.2.0.dylib"
|
||||
else:
|
||||
const SDL_MixerLibName = "libSDL_mixer.so"
|
||||
|
||||
const
|
||||
SDL_MIXER_MAJOR_VERSION* = 1'i8
|
||||
SDL_MIXER_MINOR_VERSION* = 2'i8
|
||||
SDL_MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility
|
||||
MIX_MAJOR_VERSION* = SDL_MIXER_MAJOR_VERSION
|
||||
MIX_MINOR_VERSION* = SDL_MIXER_MINOR_VERSION
|
||||
MIX_PATCHLEVEL* = SDL_MIXER_PATCHLEVEL # SDL_Mixer.h constants
|
||||
# The default mixer has 8 simultaneous mixing channels
|
||||
MIX_CHANNELS* = 8 # Good default values for a PC soundcard
|
||||
MIX_DEFAULT_FREQUENCY* = 22050
|
||||
|
||||
when defined(IA32):
|
||||
const
|
||||
MIX_DEFAULT_FORMAT* = AUDIO_S16LSB
|
||||
else:
|
||||
const
|
||||
MIX_DEFAULT_FORMAT* = AUDIO_S16MSB
|
||||
const
|
||||
MIX_DEFAULT_CHANNELS* = 2
|
||||
MIX_MAX_VOLUME* = 128 # Volume of a chunk
|
||||
PATH_MAX* = 255 # mikmod.h constants
|
||||
#*
|
||||
# * Library version
|
||||
# *
|
||||
LIBMIKMOD_VERSION_MAJOR* = 3
|
||||
LIBMIKMOD_VERSION_MINOR* = 1
|
||||
LIBMIKMOD_REVISION* = 8
|
||||
LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
|
||||
(LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
|
||||
|
||||
type #music_cmd.h types
|
||||
PMusicCMD* = ptr TMusicCMD
|
||||
TMusicCMD*{.final.} = object #wavestream.h types
|
||||
filename*: array[0..PATH_MAX - 1, char]
|
||||
cmd*: array[0..PATH_MAX - 1, char]
|
||||
pid*: TSYS_ThreadHandle
|
||||
|
||||
PWAVStream* = ptr TWAVStream
|
||||
TWAVStream*{.final.} = object #playmidi.h types
|
||||
wavefp*: Pointer
|
||||
start*: int32
|
||||
stop*: int32
|
||||
cvt*: TSDL_AudioCVT
|
||||
|
||||
PMidiEvent* = ptr TMidiEvent
|
||||
TMidiEvent*{.final.} = object
|
||||
time*: int32
|
||||
channel*: uint8
|
||||
type_*: uint8
|
||||
a*: uint8
|
||||
b*: uint8
|
||||
|
||||
PMidiSong* = ptr TMidiSong
|
||||
TMidiSong*{.final.} = object #music_ogg.h types
|
||||
samples*: int32
|
||||
events*: PMidiEvent
|
||||
|
||||
POGG_Music* = ptr TOGG_Music
|
||||
TOGG_Music*{.final.} = object # mikmod.h types
|
||||
#*
|
||||
# * Error codes
|
||||
# *
|
||||
playing*: int
|
||||
volume*: int #vf: OggVorbis_File;
|
||||
section*: int
|
||||
cvt*: TSDL_AudioCVT
|
||||
len_available*: int
|
||||
snd_available*: PUint8
|
||||
|
||||
TErrorEnum* = enum
|
||||
MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING,
|
||||
MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE,
|
||||
MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER,
|
||||
MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM,
|
||||
MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE,
|
||||
MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO,
|
||||
MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW,
|
||||
MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT,
|
||||
MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS,
|
||||
MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED,
|
||||
MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC,
|
||||
MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE,
|
||||
MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT,
|
||||
MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT,
|
||||
MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD,
|
||||
MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY,
|
||||
MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE,
|
||||
MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT,
|
||||
MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
|
||||
PMODULE* = ptr TMODULE
|
||||
TMODULE*{.final.} = object
|
||||
PUNIMOD* = ptr TUNIMOD
|
||||
TUNIMOD* = TMODULE #SDL_mixer.h types
|
||||
# The internal format for an audio chunk
|
||||
PMix_Chunk* = ptr TMix_Chunk
|
||||
TMix_Chunk*{.final.} = object
|
||||
allocated*: int
|
||||
abuf*: PUint8
|
||||
alen*: Uint32
|
||||
volume*: Uint8 # Per-sample volume, 0-128
|
||||
|
||||
Mix_Chunk* = TMix_Chunk # The different fading types supported
|
||||
TMix_Fading* = enum
|
||||
MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
|
||||
Mix_Fading* = TMix_Fading
|
||||
TMix_MusicType* = enum
|
||||
MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG
|
||||
PMix_Music* = ptr TMix_Music
|
||||
TMix_Music*{.final.} = object
|
||||
type_*: TMix_MusicType
|
||||
|
||||
TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{.
|
||||
cdecl.} # This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_mixer library.
|
||||
|
||||
proc SDL_MIXER_VERSION*(X: var TSDL_Version)
|
||||
# This function gets the version of the dynamically linked SDL_mixer library.
|
||||
# It should NOT be used to fill a version structure, instead you should use the
|
||||
# SDL_MIXER_VERSION() macro.
|
||||
proc Mix_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Open the mixer with a certain audio format
|
||||
proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int,
|
||||
chunksize: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Dynamically change the number of channels managed by the mixer.
|
||||
# If decreasing the number of channels, the upper channels are
|
||||
# stopped.
|
||||
# This function returns the new number of allocated channels.
|
||||
#
|
||||
proc Mix_AllocateChannels*(numchannels: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Find out what the actual audio device parameters are.
|
||||
# This function returns 1 if the audio has been opened, 0 otherwise.
|
||||
#
|
||||
proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{.
|
||||
cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Load a wave file or a music (.mod .s3m .it .xm) file
|
||||
proc Mix_LoadWAV_RW*(src: PSDL_RWops, freesrc: int): PMix_Chunk{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_LoadWAV*(filename: cstring): PMix_Chunk
|
||||
proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Load a wave file of the mixer format from a memory buffer
|
||||
proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Free an audio chunk previously loaded
|
||||
proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Find out the music format of a mixer music, or the currently playing
|
||||
# music, if 'music' is NULL.
|
||||
proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Set a function that is called after all mixing is performed.
|
||||
# This can be used to provide real-time visual display of the audio stream
|
||||
# or add a custom mixer filter for the stream data.
|
||||
#
|
||||
proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Add your own music player or additional mixer function.
|
||||
# If 'mix_func' is NULL, the default music player is re-enabled.
|
||||
#
|
||||
proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Add your own callback when the music has finished playing.
|
||||
#
|
||||
proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Get a pointer to the user data for the current music hook
|
||||
proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
#* Add your own callback when a channel has finished playing. NULL
|
||||
# * to disable callback.*
|
||||
type
|
||||
TChannel_finished* = proc (channel: int){.cdecl.}
|
||||
|
||||
proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
const
|
||||
MIX_CHANNEL_POST* = - 2 #* This is the format of a special effect callback:
|
||||
# *
|
||||
# * myeffect(int chan, void *stream, int len, void *udata);
|
||||
# *
|
||||
# * (chan) is the channel number that your effect is affecting. (stream) is
|
||||
# * the buffer of data to work upon. (len) is the size of (stream), and
|
||||
# * (udata) is a user-defined bit of data, which you pass as the last arg of
|
||||
# * Mix_RegisterEffect(), and is passed back unmolested to your callback.
|
||||
# * Your effect changes the contents of (stream) based on whatever parameters
|
||||
# * are significant, or just leaves it be, if you prefer. You can do whatever
|
||||
# * you like to the buffer, though, and it will continue in its changed state
|
||||
# * down the mixing pipeline, through any other effect functions, then finally
|
||||
# * to be mixed with the rest of the channels and music for the final output
|
||||
# * stream.
|
||||
# *
|
||||
|
||||
type
|
||||
TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int,
|
||||
udata: Pointer): Pointer{.cdecl.}
|
||||
# * This is a callback that signifies that a channel has finished all its
|
||||
# * loops and has completed playback. This gets called if the buffer
|
||||
# * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
|
||||
# * a channel via Mix_AllocateChannels(), or unregister a callback while
|
||||
# * it's still playing.
|
||||
TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.}
|
||||
#* Register a special effect function. At mixing time, the channel data is
|
||||
# * copied into a buffer and passed through each registered effect function.
|
||||
# * After it passes through all the functions, it is mixed into the final
|
||||
# * output stream. The copy to buffer is performed once, then each effect
|
||||
# * function performs on the output of the previous effect. Understand that
|
||||
# * this extra copy to a buffer is not performed if there are no effects
|
||||
# * registered for a given chunk, which saves CPU cycles, and any given
|
||||
# * effect will be extra cycles, too, so it is crucial that your code run
|
||||
# * fast. Also note that the data that your function is given is in the
|
||||
# * format of the sound device, and not the format you gave to Mix_OpenAudio(),
|
||||
# * although they may in reality be the same. This is an unfortunate but
|
||||
# * necessary speed concern. Use Mix_QuerySpec() to determine if you can
|
||||
# * handle the data before you register your effect, and take appropriate
|
||||
# * actions.
|
||||
# * You may also specify a callback (Mix_EffectDone_t) that is called when
|
||||
# * the channel finishes playing. This gives you a more fine-grained control
|
||||
# * than Mix_ChannelFinished(), in case you need to free effect-specific
|
||||
# * resources, etc. If you don't need this, you can specify NULL.
|
||||
# * You may set the callbacks before or after calling Mix_PlayChannel().
|
||||
# * Things like Mix_SetPanning() are just internal special effect functions,
|
||||
# * so if you are using that, you've already incurred the overhead of a copy
|
||||
# * to a separate buffer, and that these effects will be in the queue with
|
||||
# * any functions you've registered. The list of registered effects for a
|
||||
# * channel is reset when a chunk finishes playing, so you need to explicitly
|
||||
# * set them with each call to Mix_PlayChannel*().
|
||||
# * You may also register a special effect function that is to be run after
|
||||
# * final mixing occurs. The rules for these callbacks are identical to those
|
||||
# * in Mix_RegisterEffect, but they are run after all the channels and the
|
||||
# * music have been mixed into a single stream, whereas channel-specific
|
||||
# * effects run on a given channel before any other mixing occurs. These
|
||||
# * global effect callbacks are call "posteffects". Posteffects only have
|
||||
# * their Mix_EffectDone_t function called when they are unregistered (since
|
||||
# * the main output stream is never "done" in the same sense as a channel).
|
||||
# * You must unregister them manually when you've had enough. Your callback
|
||||
# * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
|
||||
# * processing is considered a posteffect.
|
||||
# *
|
||||
# * After all these effects have finished processing, the callback registered
|
||||
# * through Mix_SetPostMix() runs, and then the stream goes to the audio
|
||||
# * device.
|
||||
# *
|
||||
# * returns zero if error (no such channel), nonzero if added.
|
||||
# * Error messages can be retrieved from Mix_GetError().
|
||||
|
||||
proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone,
|
||||
arg: Pointer): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
#* You may not need to call this explicitly, unless you need to stop an
|
||||
# * effect from processing in the middle of a chunk's playback.
|
||||
# * Posteffects are never implicitly unregistered as they are for channels,
|
||||
# * but they may be explicitly unregistered through this function by
|
||||
# * specifying MIX_CHANNEL_POST for a channel.
|
||||
# * returns zero if error (no such channel or effect), nonzero if removed.
|
||||
# * Error messages can be retrieved from Mix_GetError().
|
||||
# *
|
||||
proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
#* You may not need to call this explicitly, unless you need to stop all
|
||||
# * effects from processing in the middle of a chunk's playback. Note that
|
||||
# * this will also shut off some internal effect processing, since
|
||||
# * Mix_SetPanning( ) and others may use this API under the hood.This is
|
||||
# * called internally when a channel completes playback.
|
||||
# * Posteffects are never implicitly unregistered as they are for channels,
|
||||
# * but they may be explicitly unregistered through this function by
|
||||
# * specifying MIX_CHANNEL_POST for a channel.
|
||||
# * returns zero if error( no such channel ), nonzero if all effects removed.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
const
|
||||
MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
|
||||
# * These are the internally - defined mixing effects.They use the same API that
|
||||
# * effects defined in the application use, but are provided here as a
|
||||
# * convenience.Some effects can reduce their quality or use more memory in
|
||||
# * the name of speed; to enable this, make sure the environment variable
|
||||
# * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
|
||||
# * Mix_OpenAudio( ).
|
||||
# *
|
||||
#* set the panning of a channel.The left and right channels are specified
|
||||
# * as integers between 0 and 255, quietest to loudest, respectively.
|
||||
# *
|
||||
# * Technically, this is just individual volume control for a sample with
|
||||
# * two( stereo )channels, so it can be used for more than just panning.
|
||||
# * if you want real panning, call it like this :
|
||||
# *
|
||||
# * Mix_SetPanning( channel, left, 255 - left );
|
||||
# *
|
||||
# * ...which isn't so hard.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the panning will be done to the final mixed stream before passing it on
|
||||
# * to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally, and returns without
|
||||
# * registering the effect function if the audio device is not configured
|
||||
# * for stereo output.Setting both( left ) and ( right ) to 255 causes this
|
||||
# * effect to be unregistered, since that is the data's normal state.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if panning effect enabled.Note that an audio device in mono
|
||||
# * mode is a no - op, but this call will return successful in that case .
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
|
||||
|
||||
proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# * set the position ofa channel.( angle ) is an integer from 0 to 360, that
|
||||
# * specifies the location of the sound in relation to the listener.( angle )
|
||||
# * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
|
||||
# * Angle 0 is due north, and rotates clockwise as the value increases.
|
||||
# * for efficiency, the precision of this effect may be limited( angles 1
|
||||
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
|
||||
# * ( distance ) is an integer between 0 and 255 that specifies the space
|
||||
# * between the sound and the listener.The larger the number, the further
|
||||
# * away the sound is .Using 255 does not guarantee that the channel will be
|
||||
# * culled from the mixing process or be completely silent.For efficiency,
|
||||
# * the precision of this effect may be limited( distance 0 through 5 might
|
||||
# * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
|
||||
# * and ( distance ) to 0 unregisters this effect, since the data would be
|
||||
# * unchanged.
|
||||
# *
|
||||
# * if you need more precise positional audio, consider using OpenAL for
|
||||
# * spatialized effects instead of SDL_mixer.This is only meant to be a
|
||||
# * basic effect for simple "3D" games.
|
||||
# *
|
||||
# * if the audio device is configured for mono output, then you won't get
|
||||
# * any effectiveness from the angle; however, distance attenuation on the
|
||||
# * channel will still occur.While this effect will function with stereo
|
||||
# * voices, it makes more sense to use voices with only one channel of sound,
|
||||
# * so when they are mixed through this effect, the positioning will sound
|
||||
# * correct.You can convert them to mono through SDL before giving them to
|
||||
# * the mixer in the first place if you like.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the positioning will be done to the final mixed stream before passing it
|
||||
# * on to the audio device.
|
||||
# *
|
||||
# * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if position effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
#* set the "distance" of a channel.( distance ) is an integer from 0 to 255
|
||||
# * that specifies the location of the sound in relation to the listener.
|
||||
# * Distance 0 is overlapping the listener, and 255 is as far away as possible
|
||||
# * A distance of 255 does not guarantee silence; in such a case , you might
|
||||
# * want to try changing the chunk's volume, or just cull the sample from the
|
||||
# * mixing process with Mix_HaltChannel( ).
|
||||
# * for efficiency, the precision of this effect may be limited( distances 1
|
||||
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
|
||||
# * ( distance ) is an integer between 0 and 255 that specifies the space
|
||||
# * between the sound and the listener.The larger the number, the further
|
||||
# * away the sound is .
|
||||
# * Setting( distance ) to 0 unregisters this effect, since the data would be
|
||||
# * unchanged.
|
||||
# * if you need more precise positional audio, consider using OpenAL for
|
||||
# * spatialized effects instead of SDL_mixer.This is only meant to be a
|
||||
# * basic effect for simple "3D" games.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the distance attenuation will be done to the final mixed stream before
|
||||
# * passing it on to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if position effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# *
|
||||
# * !!! FIXME : Haven't implemented, since the effect goes past the
|
||||
# * end of the sound buffer.Will have to think about this.
|
||||
# * - -ryan.
|
||||
# * /
|
||||
# { if 0
|
||||
# { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
|
||||
# * of echo to mix.0 is no echo, 255 is infinite( and probably not
|
||||
# * what you want ).
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the reverbing will be done to the final mixed stream before passing it on
|
||||
# * to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
|
||||
# * of zero, the effect is unregistered, as the data is already in that state.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if reversing effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
# extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
|
||||
# #E ndif
|
||||
# * Causes a channel to reverse its stereo.This is handy if the user has his
|
||||
# * speakers hooked up backwards, or you would like to have a minor bit of
|
||||
# * psychedelia in your sound code. : )Calling this function with ( flip )
|
||||
# * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
|
||||
# * the effect is unregistered.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally, and thus is probably
|
||||
# * more CPU intensive than having the user just plug in his speakers
|
||||
# * correctly.Mix_SetReverseStereo( )returns without registering the effect
|
||||
# * function if the audio device is not configured for stereo output.
|
||||
# *
|
||||
# * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
|
||||
# * on the final mixed stream before sending it on to the audio device( a
|
||||
# * posteffect ).
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if reversing effect is enabled.Note that an audio device in mono
|
||||
# * mode is a no - op, but this call will return successful in that case .
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# end of effects API. - -ryan. *
|
||||
# Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
|
||||
# them dynamically to the next sample if requested with a -1 value below.
|
||||
# Returns the number of reserved channels.
|
||||
#
|
||||
proc Mix_ReserveChannels*(num: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Channel grouping functions
|
||||
# Attach a tag to a channel. A tag can be assigned to several mixer
|
||||
# channels, to form groups of channels.
|
||||
# If 'tag' is -1, the tag is removed (actually -1 is the tag used to
|
||||
# represent the group of all the channels).
|
||||
# Returns true if everything was OK.
|
||||
#
|
||||
proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Assign several consecutive channels to a group
|
||||
proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Finds the first available channel in a group of channels
|
||||
proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Returns the number of channels in a group. This is also a subtle
|
||||
# way to get the total number of channels when 'tag' is -1
|
||||
#
|
||||
proc Mix_GroupCount*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Finds the "oldest" sample playing in a group of channels
|
||||
proc Mix_GroupOldest*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Finds the "most recent" (i.e. last) sample playing in a group of channels
|
||||
proc Mix_GroupNewer*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# The same as above, but the sound is played at most 'ticks' milliseconds
|
||||
proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
|
||||
ticks: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Play an audio chunk on a specific channel.
|
||||
# If the specified channel is -1, play on the first free channel.
|
||||
# If 'loops' is greater than zero, loop the sound that many times.
|
||||
# If 'loops' is -1, loop inifinitely (~65000 times).
|
||||
# Returns which channel was used to play the sound.
|
||||
#
|
||||
proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int
|
||||
proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions
|
||||
proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
|
||||
ms: int, ticks: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int
|
||||
# Set the volume in the range of 0-128 of a specific channel or chunk.
|
||||
# If the specified channel is -1, set volume for all channels.
|
||||
# Returns the original volume.
|
||||
# If the specified volume is -1, just return the current volume.
|
||||
#
|
||||
proc Mix_Volume*(channel: int, volume: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Halt playing of a particular channel
|
||||
proc Mix_HaltChannel*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_HaltGroup*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_HaltMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Change the expiration delay for a particular channel.
|
||||
# The sample will stop playing after the 'ticks' milliseconds have elapsed,
|
||||
# or remove the expiration if 'ticks' is -1
|
||||
#
|
||||
proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Halt a channel, fading it out progressively till it's silent
|
||||
# The ms parameter indicates the number of milliseconds the fading
|
||||
# will take.
|
||||
#
|
||||
proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Query the fading status of a channel
|
||||
proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Pause/Resume a particular channel
|
||||
proc Mix_Pause*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_Resume*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_Paused*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Pause/Resume the music stream
|
||||
proc Mix_PauseMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_ResumeMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_RewindMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_PausedMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Set the current position in the music stream.
|
||||
# This returns 0 if successful, or -1 if it failed or isn't implemented.
|
||||
# This function is only implemented for MOD music formats (set pattern
|
||||
# order number) and for OGG music (set position in seconds), at the
|
||||
# moment.
|
||||
#
|
||||
proc Mix_SetMusicPosition*(position: float64): int{.cdecl,
|
||||
importc, dynlib: SDL_MixerLibName.}
|
||||
# Check the status of a specific channel.
|
||||
# If the specified channel is -1, check all channels.
|
||||
#
|
||||
proc Mix_Playing*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_PlayingMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Stop music and set external music playback command
|
||||
proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Synchro value is set by MikMod from modules while playing
|
||||
proc Mix_SetSynchroValue*(value: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
proc Mix_GetSynchroValue*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
#
|
||||
# Get the Mix_Chunk currently associated with a mixer channel
|
||||
# Returns nil if it's an invalid channel, or there's no chunk associated.
|
||||
#
|
||||
proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# Close the mixer, halting all playing audio
|
||||
proc Mix_CloseAudio*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
|
||||
# We'll use SDL for reporting errors
|
||||
proc Mix_SetError*(fmt: cstring)
|
||||
proc Mix_GetError*(): cstring
|
||||
# implementation
|
||||
|
||||
proc SDL_MIXER_VERSION(X: var TSDL_version) =
|
||||
X.major = SDL_MIXER_MAJOR_VERSION
|
||||
X.minor = SDL_MIXER_MINOR_VERSION
|
||||
X.patch = SDL_MIXER_PATCHLEVEL
|
||||
|
||||
proc Mix_LoadWAV(filename: cstring): PMix_Chunk =
|
||||
result = Mix_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1)
|
||||
|
||||
proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int =
|
||||
result = Mix_PlayChannelTimed(channel, chunk, loops, - 1)
|
||||
|
||||
proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int =
|
||||
result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1)
|
||||
|
||||
proc Mix_SetError(fmt: cstring) =
|
||||
SDL_SetError(fmt)
|
||||
|
||||
proc Mix_GetError(): cstring =
|
||||
result = SDL_GetError()
|
||||
431
lib/base/sdl/sdl_net.nim
Normal file
431
lib/base/sdl/sdl_net.nim
Normal file
@@ -0,0 +1,431 @@
|
||||
|
||||
#******************************************************************************
|
||||
#
|
||||
# $Id: sdl_net.pas,v 1.7 2005/01/01 02:14:21 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# Borland Delphi SDL_Net - A x-platform network library for use with SDL.
|
||||
# Conversion of the Simple DirectMedia Layer Network Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_net.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Portions created by Dominqiue Louis are
|
||||
# Copyright (C) 2000 - 2001 Dominqiue Louis.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# SDL.pas somehere in your search path
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# April 09 2001 - DL : Initial Translation
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_net.pas,v $
|
||||
# Revision 1.7 2005/01/01 02:14:21 savage
|
||||
# Updated to v1.2.5
|
||||
#
|
||||
# Revision 1.6 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.5 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.4 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.3 2004/04/01 20:53:23 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/16 22:16:40 savage
|
||||
# v1.0 changes
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const SDLNetLibName = "SDL_net.dll"
|
||||
elif defined(macosx):
|
||||
const SDLNetLibName = "libSDL_net.dylib"
|
||||
else:
|
||||
const SDLNetLibName = "libSDL_net.so"
|
||||
|
||||
const #* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *
|
||||
SDL_NET_MAJOR_VERSION* = 1'i8
|
||||
SDL_NET_MINOR_VERSION* = 2'i8
|
||||
SDL_NET_PATCHLEVEL* = 5'i8 # SDL_Net.h constants
|
||||
#* Resolve a host name and port to an IP address in network form.
|
||||
# If the function succeeds, it will return 0.
|
||||
# If the host couldn't be resolved, the host portion of the returned
|
||||
# address will be INADDR_NONE, and the function will return -1.
|
||||
# If 'host' is NULL, the resolved host will be set to INADDR_ANY.
|
||||
# *
|
||||
INADDR_ANY* = 0x00000000
|
||||
INADDR_NONE* = 0xFFFFFFFF #***********************************************************************
|
||||
#* UDP network API *
|
||||
#***********************************************************************
|
||||
#* The maximum channels on a a UDP socket *
|
||||
SDLNET_MAX_UDPCHANNELS* = 32 #* The maximum addresses bound to a single UDP socket channel *
|
||||
SDLNET_MAX_UDPADDRESSES* = 4
|
||||
|
||||
type # SDL_net.h types
|
||||
#***********************************************************************
|
||||
#* IPv4 hostname resolution API *
|
||||
#***********************************************************************
|
||||
PIPAddress* = ptr TIPAddress
|
||||
TIPAddress*{.final.} = object #* TCP network API
|
||||
host*: Uint32 # 32-bit IPv4 host address */
|
||||
port*: Uint16 # 16-bit protocol port */
|
||||
|
||||
PTCPSocket* = ptr TTCPSocket
|
||||
TTCPSocket*{.final.} = object #***********************************************************************
|
||||
#* UDP network API *
|
||||
#***********************************************************************
|
||||
ready*: int
|
||||
channel*: int
|
||||
remoteAddress*: TIPaddress
|
||||
localAddress*: TIPaddress
|
||||
sflag*: int
|
||||
|
||||
PUDP_Channel* = ptr TUDP_Channel
|
||||
TUDP_Channel*{.final.} = object
|
||||
numbound*: int
|
||||
address*: array[0..SDLNET_MAX_UDPADDRESSES - 1, TIPAddress]
|
||||
|
||||
PUDPSocket* = ptr TUDPSocket
|
||||
TUDPSocket*{.final.} = object
|
||||
ready*: int
|
||||
channel*: int
|
||||
address*: TIPAddress
|
||||
binding*: array[0..SDLNET_MAX_UDPCHANNELS - 1, TUDP_Channel]
|
||||
|
||||
PUDPpacket* = ptr TUDPpacket
|
||||
PPUDPpacket* = ptr PUDPpacket
|
||||
TUDPpacket*{.final.} = object #***********************************************************************
|
||||
#* Hooks for checking sockets for available data *
|
||||
#***********************************************************************
|
||||
channel*: int #* The src/dst channel of the packet *
|
||||
data*: PUint8 #* The packet data *
|
||||
length*: int #* The length of the packet data *
|
||||
maxlen*: int #* The size of the data buffer *
|
||||
status*: int #* packet status after sending *
|
||||
address*: TIPAddress #* The source/dest address of an incoming/outgoing packet *
|
||||
|
||||
PSDLNet_Socket* = ptr TSDLNet_Socket
|
||||
TSDLNet_Socket*{.final.} = object
|
||||
ready*: int
|
||||
channel*: int
|
||||
|
||||
PSDLNet_SocketSet* = ptr TSDLNet_SocketSet
|
||||
TSDLNet_SocketSet*{.final.} = object #* Any network socket can be safely cast to this socket type *
|
||||
numsockets*: int
|
||||
maxsockets*: int
|
||||
sockets*: PSDLNet_Socket
|
||||
|
||||
PSDLNet_GenericSocket* = ptr TSDLNet_GenericSocket
|
||||
TSDLNet_GenericSocket*{.final.} = object # This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_net library.
|
||||
ready*: int
|
||||
|
||||
|
||||
proc SDL_NET_VERSION*(X: var TSDL_version)
|
||||
#* Initialize/Cleanup the network API
|
||||
# SDL must be initialized before calls to functions in this library,
|
||||
# because this library uses utility functions from the SDL library.
|
||||
#*
|
||||
proc SDLNet_Init*(): int{.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
proc SDLNet_Quit*(){.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* Resolve a host name and port to an IP address in network form.
|
||||
# If the function succeeds, it will return 0.
|
||||
# If the host couldn't be resolved, the host portion of the returned
|
||||
# address will be INADDR_NONE, and the function will return -1.
|
||||
# If 'host' is NULL, the resolved host will be set to INADDR_ANY.
|
||||
# *
|
||||
proc SDLNet_ResolveHost*(address: var TIPaddress, host: cstring, port: Uint16): int{.
|
||||
cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* Resolve an ip address to a host name in canonical form.
|
||||
# If the ip couldn't be resolved, this function returns NULL,
|
||||
# otherwise a pointer to a static buffer containing the hostname
|
||||
# is returned. Note that this function is not thread-safe.
|
||||
#*
|
||||
proc SDLNet_ResolveIP*(ip: var TIPaddress): cstring{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#***********************************************************************
|
||||
#* TCP network API *
|
||||
#***********************************************************************
|
||||
#* Open a TCP network socket
|
||||
# If ip.host is INADDR_NONE, this creates a local server socket on the
|
||||
# given port, otherwise a TCP connection to the remote host and port is
|
||||
# attempted. The address passed in should already be swapped to network
|
||||
# byte order (addresses returned from SDLNet_ResolveHost() are already
|
||||
# in the correct form).
|
||||
# The newly created socket is returned, or NULL if there was an error.
|
||||
#*
|
||||
proc SDLNet_TCP_Open*(ip: var TIPaddress): PTCPSocket{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#* Accept an incoming connection on the given server socket.
|
||||
# The newly created socket is returned, or NULL if there was an error.
|
||||
#*
|
||||
proc SDLNet_TCP_Accept*(server: PTCPsocket): PTCPSocket{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#* Get the IP address of the remote system associated with the socket.
|
||||
# If the socket is a server socket, this function returns NULL.
|
||||
#*
|
||||
proc SDLNet_TCP_GetPeerAddress*(sock: PTCPsocket): PIPAddress{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#* Send 'len' bytes of 'data' over the non-server socket 'sock'
|
||||
# This function returns the actual amount of data sent. If the return value
|
||||
# is less than the amount of data sent, then either the remote connection was
|
||||
# closed, or an unknown socket error occurred.
|
||||
#*
|
||||
proc SDLNet_TCP_Send*(sock: PTCPsocket, data: Pointer, length: int): int{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
|
||||
# and store them in the buffer pointed to by 'data'.
|
||||
# This function returns the actual amount of data received. If the return
|
||||
# value is less than or equal to zero, then either the remote connection was
|
||||
# closed, or an unknown socket error occurred.
|
||||
#*
|
||||
proc SDLNet_TCP_Recv*(sock: PTCPsocket, data: Pointer, maxlen: int): int{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#* Close a TCP network socket *
|
||||
proc SDLNet_TCP_Close*(sock: PTCPsocket){.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#***********************************************************************
|
||||
#* UDP network API *
|
||||
#***********************************************************************
|
||||
#* Allocate/resize/free a single UDP packet 'size' bytes long.
|
||||
# The new packet is returned, or NULL if the function ran out of memory.
|
||||
# *
|
||||
proc SDLNet_AllocPacket*(size: int): PUDPpacket{.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
proc SDLNet_ResizePacket*(packet: PUDPpacket, newsize: int): int{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
proc SDLNet_FreePacket*(packet: PUDPpacket){.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
|
||||
# each 'size' bytes long.
|
||||
# A pointer to the first packet in the array is returned, or NULL if the
|
||||
# function ran out of memory.
|
||||
# *
|
||||
proc SDLNet_AllocPacketV*(howmany: int, size: int): PUDPpacket{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
proc SDLNet_FreePacketV*(packetV: PUDPpacket){.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* Open a UDP network socket
|
||||
# If 'port' is non-zero, the UDP socket is bound to a local port.
|
||||
# This allows other systems to send to this socket via a known port.
|
||||
#*
|
||||
proc SDLNet_UDP_Open*(port: Uint16): PUDPsocket{.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* Bind the address 'address' to the requested channel on the UDP socket.
|
||||
# If the channel is -1, then the first unbound channel will be bound with
|
||||
# the given address as it's primary address.
|
||||
# If the channel is already bound, this new address will be added to the
|
||||
# list of valid source addresses for packets arriving on the channel.
|
||||
# If the channel is not already bound, then the address becomes the primary
|
||||
# address, to which all outbound packets on the channel are sent.
|
||||
# This function returns the channel which was bound, or -1 on error.
|
||||
#*
|
||||
proc SDLNet_UDP_Bind*(sock: PUDPsocket, channel: int, address: var TIPaddress): int{.
|
||||
cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* Unbind all addresses from the given channel *
|
||||
proc SDLNet_UDP_Unbind*(sock: PUDPsocket, channel: int){.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#* Get the primary IP address of the remote system associated with the
|
||||
# socket and channel. If the channel is -1, then the primary IP port
|
||||
# of the UDP socket is returned -- this is only meaningful for sockets
|
||||
# opened with a specific port.
|
||||
# If the channel is not bound and not -1, this function returns NULL.
|
||||
# *
|
||||
proc SDLNet_UDP_GetPeerAddress*(sock: PUDPsocket, channel: int): PIPAddress{.
|
||||
cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* Send a vector of packets to the the channels specified within the packet.
|
||||
# If the channel specified in the packet is -1, the packet will be sent to
|
||||
# the address in the 'src' member of the packet.
|
||||
# Each packet will be updated with the status of the packet after it has
|
||||
# been sent, -1 if the packet send failed.
|
||||
# This function returns the number of packets sent.
|
||||
#*
|
||||
proc SDLNet_UDP_SendV*(sock: PUDPsocket, packets: PPUDPpacket, npackets: int): int{.
|
||||
cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* Send a single packet to the specified channel.
|
||||
# If the channel specified in the packet is -1, the packet will be sent to
|
||||
# the address in the 'src' member of the packet.
|
||||
# The packet will be updated with the status of the packet after it has
|
||||
# been sent.
|
||||
# This function returns 1 if the packet was sent, or 0 on error.
|
||||
#*
|
||||
proc SDLNet_UDP_Send*(sock: PUDPsocket, channel: int, packet: PUDPpacket): int{.
|
||||
cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* Receive a vector of pending packets from the UDP socket.
|
||||
# The returned packets contain the source address and the channel they arrived
|
||||
# on. If they did not arrive on a bound channel, the the channel will be set
|
||||
# to -1.
|
||||
# The channels are checked in highest to lowest order, so if an address is
|
||||
# bound to multiple channels, the highest channel with the source address
|
||||
# bound will be returned.
|
||||
# This function returns the number of packets read from the network, or -1
|
||||
# on error. This function does not block, so can return 0 packets pending.
|
||||
#*
|
||||
proc SDLNet_UDP_RecvV*(sock: PUDPsocket, packets: PPUDPpacket): int{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#* Receive a single packet from the UDP socket.
|
||||
# The returned packet contains the source address and the channel it arrived
|
||||
# on. If it did not arrive on a bound channel, the the channel will be set
|
||||
# to -1.
|
||||
# The channels are checked in highest to lowest order, so if an address is
|
||||
# bound to multiple channels, the highest channel with the source address
|
||||
# bound will be returned.
|
||||
# This function returns the number of packets read from the network, or -1
|
||||
# on error. This function does not block, so can return 0 packets pending.
|
||||
#*
|
||||
proc SDLNet_UDP_Recv*(sock: PUDPsocket, packet: PUDPpacket): int{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#* Close a UDP network socket *
|
||||
proc SDLNet_UDP_Close*(sock: PUDPsocket){.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#***********************************************************************
|
||||
#* Hooks for checking sockets for available data *
|
||||
#***********************************************************************
|
||||
#* Allocate a socket set for use with SDLNet_CheckSockets()
|
||||
# This returns a socket set for up to 'maxsockets' sockets, or NULL if
|
||||
# the function ran out of memory.
|
||||
# *
|
||||
proc SDLNet_AllocSocketSet*(maxsockets: int): PSDLNet_SocketSet{.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#* Add a socket to a set of sockets to be checked for available data *
|
||||
proc SDLNet_AddSocket*(theSet: PSDLNet_SocketSet, sock: PSDLNet_GenericSocket): int{.
|
||||
cdecl, importc, dynlib: SDLNetLibName.}
|
||||
proc SDLNet_TCP_AddSocket*(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int
|
||||
proc SDLNet_UDP_AddSocket*(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int
|
||||
#* Remove a socket from a set of sockets to be checked for available data *
|
||||
proc SDLNet_DelSocket*(theSet: PSDLNet_SocketSet, sock: PSDLNet_GenericSocket): int{.
|
||||
cdecl, importc, dynlib: SDLNetLibName.}
|
||||
proc SDLNet_TCP_DelSocket*(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int
|
||||
# SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
|
||||
proc SDLNet_UDP_DelSocket*(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int
|
||||
#SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
|
||||
#* This function checks to see if data is available for reading on the
|
||||
# given set of sockets. If 'timeout' is 0, it performs a quick poll,
|
||||
# otherwise the function returns when either data is available for
|
||||
# reading, or the timeout in milliseconds has elapsed, which ever occurs
|
||||
# first. This function returns the number of sockets ready for reading,
|
||||
# or -1 if there was an error with the select() system call.
|
||||
#*
|
||||
proc SDLNet_CheckSockets*(theSet: PSDLNet_SocketSet, timeout: Sint32): int{.
|
||||
cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* After calling SDLNet_CheckSockets(), you can use this function on a
|
||||
# socket that was in the socket set, to find out if data is available
|
||||
# for reading.
|
||||
#*
|
||||
proc SDLNet_SocketReady*(sock: PSDLNet_GenericSocket): bool
|
||||
#* Free a set of sockets allocated by SDL_NetAllocSocketSet() *
|
||||
proc SDLNet_FreeSocketSet*(theSet: PSDLNet_SocketSet){.cdecl,
|
||||
importc, dynlib: SDLNetLibName.}
|
||||
#***********************************************************************
|
||||
#* Platform-independent data conversion functions *
|
||||
#***********************************************************************
|
||||
#* Write a 16/32 bit value to network packet buffer *
|
||||
proc SDLNet_Write16*(value: Uint16, area: Pointer){.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
proc SDLNet_Write32*(value: Uint32, area: Pointer){.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#* Read a 16/32 bit value from network packet buffer *
|
||||
proc SDLNet_Read16*(area: Pointer): Uint16{.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
proc SDLNet_Read32*(area: Pointer): Uint32{.cdecl, importc, dynlib: SDLNetLibName.}
|
||||
#***********************************************************************
|
||||
#* Error reporting functions *
|
||||
#***********************************************************************
|
||||
#* We'll use SDL's functions for error reporting *
|
||||
proc SDLNet_SetError*(fmt: cstring)
|
||||
proc SDLNet_GetError*(): cstring
|
||||
# implementation
|
||||
|
||||
proc SDL_NET_VERSION(X: var TSDL_version) =
|
||||
X.major = SDL_NET_MAJOR_VERSION
|
||||
X.minor = SDL_NET_MINOR_VERSION
|
||||
X.patch = SDL_NET_PATCHLEVEL
|
||||
|
||||
proc SDLNet_TCP_AddSocket(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int =
|
||||
result = SDLNet_AddSocket(theSet, cast[PSDLNet_GenericSocket](sock))
|
||||
|
||||
proc SDLNet_UDP_AddSocket(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int =
|
||||
result = SDLNet_AddSocket(theSet, cast[PSDLNet_GenericSocket](sock))
|
||||
|
||||
proc SDLNet_TCP_DelSocket(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int =
|
||||
result = SDLNet_DelSocket(theSet, cast[PSDLNet_GenericSocket](sock))
|
||||
|
||||
proc SDLNet_UDP_DelSocket(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int =
|
||||
result = SDLNet_DelSocket(theSet, cast[PSDLNet_GenericSocket](sock))
|
||||
|
||||
proc SDLNet_SocketReady(sock: PSDLNet_GenericSocket): bool =
|
||||
result = ((sock != nil) and (sock.ready == 1))
|
||||
|
||||
proc SDLNet_SetError(fmt: cstring) =
|
||||
SDL_SetError(fmt)
|
||||
|
||||
proc SDLNet_GetError(): cstring =
|
||||
result = SDL_GetError()
|
||||
346
lib/base/sdl/sdl_ttf.nim
Normal file
346
lib/base/sdl/sdl_ttf.nim
Normal file
@@ -0,0 +1,346 @@
|
||||
|
||||
#
|
||||
# $Id: sdl_ttf.pas,v 1.18 2007/06/01 11:16:33 savage Exp $
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
#
|
||||
# JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer
|
||||
# Conversion of the Simple DirectMedia Layer Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_ttf.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Portions created by Dominqiue Louis are
|
||||
# Copyright (C) 2000 - 2001 Dominqiue Louis.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so
|
||||
# They are available from...
|
||||
# http://www.libsdl.org .
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# December 08 2002 - DL : Fixed definition of TTF_RenderUnicode_Solid
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_ttf.pas,v $
|
||||
# Revision 1.18 2007/06/01 11:16:33 savage
|
||||
# Added IFDEF UNIX for Workaround.
|
||||
#
|
||||
# Revision 1.17 2007/06/01 08:38:21 savage
|
||||
# Added TTF_RenderText_Solid workaround as suggested by Michalis Kamburelis
|
||||
#
|
||||
# Revision 1.16 2007/05/29 21:32:14 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.15 2007/05/20 20:32:45 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.14 2006/12/02 00:19:01 savage
|
||||
# Updated to latest version
|
||||
#
|
||||
# Revision 1.13 2005/04/10 11:48:33 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.12 2005/01/05 01:47:14 savage
|
||||
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
|
||||
#
|
||||
# Revision 1.11 2005/01/04 23:14:57 savage
|
||||
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
|
||||
#
|
||||
# Revision 1.10 2005/01/02 19:07:32 savage
|
||||
# Slight bug fix to use LongInt instead of Long ( Thanks Michalis Kamburelis )
|
||||
#
|
||||
# Revision 1.9 2005/01/01 02:15:20 savage
|
||||
# Updated to v2.0.7
|
||||
#
|
||||
# Revision 1.8 2004/10/07 21:02:32 savage
|
||||
# Fix for FPC
|
||||
#
|
||||
# Revision 1.7 2004/09/30 22:39:50 savage
|
||||
# Added a true type font class which contains a wrap text function.
|
||||
# Changed the sdl_ttf.pas header to reflect the future of jedi-sdl.
|
||||
#
|
||||
# Revision 1.6 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.5 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.4 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.3 2004/04/01 20:53:24 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/16 22:16:40 savage
|
||||
# v1.0 changes
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
#
|
||||
# Define this to workaround a known bug in some freetype versions.
|
||||
# The error manifests as TTF_RenderGlyph_Solid returning nil (error)
|
||||
# and error message (in SDL_Error) is
|
||||
# "Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable"
|
||||
# See [http://lists.libsdl.org/pipermail/sdl-libsdl.org/2007-March/060459.html]
|
||||
#
|
||||
|
||||
import sdl
|
||||
|
||||
when defined(windows):
|
||||
const SDLttfLibName = "SDL_ttf.dll"
|
||||
elif defined(macosx):
|
||||
const SDLttfLibName = "libSDL_ttf-2.0.0.dylib"
|
||||
else:
|
||||
const SDLttfLibName = "libSDL_ttf.so"
|
||||
|
||||
const
|
||||
SDL_TTF_MAJOR_VERSION* = 2'i8
|
||||
SDL_TTF_MINOR_VERSION* = 0'i8
|
||||
SDL_TTF_PATCHLEVEL* = 8'i8 # Backwards compatibility
|
||||
TTF_MAJOR_VERSION* = SDL_TTF_MAJOR_VERSION
|
||||
TTF_MINOR_VERSION* = SDL_TTF_MINOR_VERSION
|
||||
TTF_PATCHLEVEL* = SDL_TTF_PATCHLEVEL #*
|
||||
# Set and retrieve the font style
|
||||
# This font style is implemented by modifying the font glyphs, and
|
||||
# doesn't reflect any inherent properties of the truetype font file.
|
||||
#*
|
||||
TTF_STYLE_NORMAL* = 0x00000000
|
||||
TTF_STYLE_BOLD* = 0x00000001
|
||||
TTF_STYLE_ITALIC* = 0x00000002
|
||||
TTF_STYLE_UNDERLINE* = 0x00000004 # ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
|
||||
UNICODE_BOM_NATIVE* = 0x0000FEFF
|
||||
UNICODE_BOM_SWAPPED* = 0x0000FFFE
|
||||
|
||||
type
|
||||
PTTF_Font* = ptr TTTF_font
|
||||
TTTF_Font*{.final.} = object # This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_ttf library.
|
||||
|
||||
proc SDL_TTF_VERSION*(X: var TSDL_version)
|
||||
# This function gets the version of the dynamically linked SDL_ttf library.
|
||||
# It should NOT be used to fill a version structure, instead you should use the
|
||||
# SDL_TTF_VERSION() macro.
|
||||
proc TTF_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# This function tells the library whether UNICODE text is generally
|
||||
# byteswapped. A UNICODE BOM character in a string will override
|
||||
# this setting for the remainder of that string.
|
||||
#
|
||||
proc TTF_ByteSwappedUNICODE*(swapped: int){.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
#returns 0 on succes, -1 if error occurs
|
||||
proc TTF_Init*(): int{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
#
|
||||
# Open a font file and create a font of the specified point size.
|
||||
# Some .fon fonts will have several sizes embedded in the file, so the
|
||||
# point size becomes the index of choosing which size. If the value
|
||||
# is too high, the last indexed size will be the default.
|
||||
#
|
||||
proc TTF_OpenFont*(filename: cstring, ptsize: int): PTTF_Font{.cdecl,
|
||||
importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_OpenFontIndex*(filename: cstring, ptsize: int, index: int32): PTTF_Font{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_OpenFontRW*(src: PSDL_RWops, freesrc: int, ptsize: int): PTTF_Font{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_OpenFontIndexRW*(src: PSDL_RWops, freesrc: int, ptsize: int,
|
||||
index: int32): PTTF_Font{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_GetFontStyle*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_SetFontStyle*(font: PTTF_Font, style: int){.cdecl,
|
||||
importc, dynlib: SDLttfLibName.}
|
||||
# Get the total height of the font - usually equal to point size
|
||||
proc TTF_FontHeight*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# Get the offset from the baseline to the top of the font
|
||||
# This is a positive value, relative to the baseline.
|
||||
#
|
||||
proc TTF_FontAscent*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# Get the offset from the baseline to the bottom of the font
|
||||
# This is a negative value, relative to the baseline.
|
||||
#
|
||||
proc TTF_FontDescent*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# Get the recommended spacing between lines of text for this font
|
||||
proc TTF_FontLineSkip*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# Get the number of faces of the font
|
||||
proc TTF_FontFaces*(font: PTTF_Font): int32{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# Get the font face attributes, if any
|
||||
proc TTF_FontFaceIsFixedWidth*(font: PTTF_Font): int{.cdecl,
|
||||
importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_FontFaceFamilyName*(font: PTTF_Font): cstring{.cdecl,
|
||||
importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_FontFaceStyleName*(font: PTTF_Font): cstring{.cdecl,
|
||||
importc, dynlib: SDLttfLibName.}
|
||||
# Get the metrics (dimensions) of a glyph
|
||||
proc TTF_GlyphMetrics*(font: PTTF_Font, ch: Uint16, minx: var int,
|
||||
maxx: var int, miny: var int, maxy: var int,
|
||||
advance: var int): int{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# Get the dimensions of a rendered string of text
|
||||
proc TTF_SizeText*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_SizeUTF8*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_SizeUNICODE*(font: PTTF_Font, text: PUint16, w: var int, y: var int): int{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given text at
|
||||
# fast quality with the given font and color. The 0 pixel is the
|
||||
# colorkey, giving a transparent background, and the 1 pixel is set
|
||||
# to the text color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderUTF8_Solid*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_RenderUNICODE_Solid*(font: PTTF_Font, text: PUint16, fg: TSDL_Color): PSDL_Surface{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
#
|
||||
#Create an 8-bit palettized surface and render the given glyph at
|
||||
# fast quality with the given font and color. The 0 pixel is the
|
||||
# colorkey, giving a transparent background, and the 1 pixel is set
|
||||
# to the text color. The glyph is rendered without any padding or
|
||||
# centering in the X direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderGlyph_Solid*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color): PSDL_Surface{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given text at
|
||||
# high quality with the given font and colors. The 0 pixel is background,
|
||||
# while other pixels have varying degrees of the foreground color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderText_Shaded*(font: PTTF_Font, text: cstring, fg: TSDL_Color,
|
||||
bg: TSDL_Color): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_RenderUTF8_Shaded*(font: PTTF_Font, text: cstring, fg: TSDL_Color,
|
||||
bg: TSDL_Color): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_RenderUNICODE_Shaded*(font: PTTF_Font, text: PUint16, fg: TSDL_Color,
|
||||
bg: TSDL_Color): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDLttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given glyph at
|
||||
# high quality with the given font and colors. The 0 pixel is background,
|
||||
# while other pixels have varying degrees of the foreground color.
|
||||
# The glyph is rendered without any padding or centering in the X
|
||||
# direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderGlyph_Shaded*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color,
|
||||
bg: TSDL_Color): PSDL_Surface{.cdecl,
|
||||
importc, dynlib: SDLttfLibName.}
|
||||
# Create a 32-bit ARGB surface and render the given text at high quality,
|
||||
# using alpha blending to dither the font with the given color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderText_Blended*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_RenderUTF8_Blended*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
proc TTF_RenderUNICODE_Blended*(font: PTTF_Font, text: PUint16, fg: TSDL_Color): PSDL_Surface{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# Create a 32-bit ARGB surface and render the given glyph at high quality,
|
||||
# using alpha blending to dither the font with the given color.
|
||||
# The glyph is rendered without any padding or centering in the X
|
||||
# direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderGlyph_Blended*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color): PSDL_Surface{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# For compatibility with previous versions, here are the old functions
|
||||
##define TTF_RenderText(font, text, fg, bg)
|
||||
# TTF_RenderText_Shaded(font, text, fg, bg)
|
||||
##define TTF_RenderUTF8(font, text, fg, bg)
|
||||
# TTF_RenderUTF8_Shaded(font, text, fg, bg)
|
||||
##define TTF_RenderUNICODE(font, text, fg, bg)
|
||||
# TTF_RenderUNICODE_Shaded(font, text, fg, bg)
|
||||
# Close an opened font file
|
||||
proc TTF_CloseFont*(font: PTTF_Font){.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
#De-initialize TTF engine
|
||||
proc TTF_Quit*(){.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# Check if the TTF engine is initialized
|
||||
proc TTF_WasInit*(): int{.cdecl, importc, dynlib: SDLttfLibName.}
|
||||
# We'll use SDL for reporting errors
|
||||
proc TTF_SetError*(fmt: cstring)
|
||||
proc TTF_GetError*(): cstring
|
||||
# implementation
|
||||
|
||||
proc SDL_TTF_VERSION(X: var TSDL_version) =
|
||||
X.major = SDL_TTF_MAJOR_VERSION
|
||||
X.minor = SDL_TTF_MINOR_VERSION
|
||||
X.patch = SDL_TTF_PATCHLEVEL
|
||||
|
||||
proc TTF_SetError(fmt: cstring) =
|
||||
SDL_SetError(fmt)
|
||||
|
||||
proc TTF_GetError(): cstring =
|
||||
result = SDL_GetError()
|
||||
|
||||
when not(defined(Workaround_TTF_RenderText_Solid)):
|
||||
proc TTF_RenderText_Solid*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
|
||||
cdecl, importc, dynlib: SDLttfLibName.}
|
||||
else:
|
||||
proc TTF_RenderText_Solid(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface =
|
||||
var Black: TSDL_Color # initialized to zero
|
||||
Result = TTF_RenderText_Shaded(font, text, fg, Black)
|
||||
4354
lib/base/sdl/sdlutils.pas
Normal file
4354
lib/base/sdl/sdlutils.pas
Normal file
File diff suppressed because it is too large
Load Diff
319
lib/base/sdl/smpeg.nim
Normal file
319
lib/base/sdl/smpeg.nim
Normal file
@@ -0,0 +1,319 @@
|
||||
|
||||
#******************************************************************************
|
||||
#
|
||||
# $Id: smpeg.pas,v 1.7 2004/08/14 22:54:30 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# Borland Delphi SMPEG - SDL MPEG Player Library
|
||||
# Conversion of the SMPEG - SDL MPEG Player Library
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : smpeg.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Portions created by Matthias Thoma are
|
||||
# Copyright (C) 2000 - 2001 Matthias Thoma.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL-1.2.so.0
|
||||
# They are available from...
|
||||
# http://www.libsdl.org .
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# May 08 2001 - MT : Initial conversion
|
||||
#
|
||||
# October 12 2001 - DA : Various changes as suggested by David Acklam
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support
|
||||
# Fixed all invalid calls to DLL.
|
||||
# Changed constant names to:
|
||||
# const
|
||||
# STATUS_SMPEG_ERROR = -1;
|
||||
# STATUS_SMPEG_STOPPED = 0;
|
||||
# STATUS_SMPEG_PLAYING = 1;
|
||||
# because SMPEG_ERROR is a function (_SMPEG_error
|
||||
# isn't correct), and cannot be two elements with the
|
||||
# same name
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: smpeg.pas,v $
|
||||
# Revision 1.7 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.6 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.5 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.4 2004/04/02 10:40:55 savage
|
||||
# Changed Linux Shared Object name so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.3 2004/03/31 22:20:02 savage
|
||||
# Windows unit not used in this file, so it was removed to keep the code tidy.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/14 23:35:42 savage
|
||||
# version 1 of sdl_image, sdl_mixer and smpeg.
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const SmpegLibName = "smpeg.dll"
|
||||
elif defined(macosx):
|
||||
const SmpegLibName = "libsmpeg.dylib"
|
||||
else:
|
||||
const SmpegLibName = "libsmpeg.so"
|
||||
|
||||
const
|
||||
SMPEG_FILTER_INFO_MB_ERROR* = 1
|
||||
SMPEG_FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG
|
||||
|
||||
type
|
||||
SMPEG_FilterInfo*{.final.} = object
|
||||
yuv_mb_square_error*: PUint16
|
||||
yuv_pixel_square_error*: PUint16
|
||||
|
||||
TSMPEG_FilterInfo* = SMPEG_FilterInfo
|
||||
PSMPEG_FilterInfo* = ptr SMPEG_FilterInfo # MPEG filter definition
|
||||
PSMPEG_Filter* = ptr TSMPEG_Filter # Callback functions for the filter
|
||||
TSMPEG_FilterCallback* = proc (dest, source: PSDL_Overlay, region: PSDL_Rect,
|
||||
filter_info: PSMPEG_FilterInfo, data: Pointer): Pointer{.
|
||||
cdecl.}
|
||||
TSMPEG_FilterDestroy* = proc (Filter: PSMPEG_Filter): Pointer{.cdecl.} # The filter
|
||||
# definition itself
|
||||
TSMPEG_Filter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay.
|
||||
flags*: Uint32
|
||||
data*: Pointer
|
||||
callback*: TSMPEG_FilterCallback
|
||||
destroy*: TSMPEG_FilterDestroy
|
||||
|
||||
|
||||
proc SMPEGfilter_null*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# The bilinear filter. A basic low-pass filter that will produce a smoother image.
|
||||
proc SMPEGfilter_bilinear*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness
|
||||
proc SMPEGfilter_deblocking*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
|
||||
#------------------------------------------------------------------------------
|
||||
# SMPEG.h
|
||||
#------------------------------------------------------------------------------
|
||||
const
|
||||
SMPEG_MAJOR_VERSION* = 0'i8
|
||||
SMPEG_MINOR_VERSION* = 4'i8
|
||||
SMPEG_PATCHLEVEL* = 2'i8
|
||||
|
||||
type
|
||||
SMPEG_version*{.final.} = object
|
||||
major*: UInt8
|
||||
minor*: UInt8
|
||||
patch*: UInt8
|
||||
|
||||
TSMPEG_version* = SMPEG_version
|
||||
PSMPEG_version* = ptr TSMPEG_version # This is the actual SMPEG object
|
||||
TSMPEG*{.final.} = object
|
||||
PSMPEG* = ptr TSMPEG # Used to get information about the SMPEG object
|
||||
TSMPEG_Info*{.final.} = object
|
||||
has_audio*: int
|
||||
has_video*: int
|
||||
width*: int
|
||||
height*: int
|
||||
current_frame*: int
|
||||
current_fps*: float64
|
||||
audio_string*: array[0..79, char]
|
||||
audio_current_frame*: int
|
||||
current_offset*: UInt32
|
||||
total_size*: UInt32
|
||||
current_time*: float64
|
||||
total_time*: float64
|
||||
|
||||
PSMPEG_Info* = ptr TSMPEG_Info # Possible MPEG status codes
|
||||
|
||||
const
|
||||
STATUS_SMPEG_ERROR* = - 1
|
||||
STATUS_SMPEG_STOPPED* = 0
|
||||
STATUS_SMPEG_PLAYING* = 1
|
||||
|
||||
type
|
||||
TSMPEGstatus* = int
|
||||
PSMPEGstatus* = ptr int # Matches the declaration of SDL_UpdateRect()
|
||||
TSMPEG_DisplayCallback* = proc (dst: PSDL_Surface, x, y: int, w, h: int): Pointer{.
|
||||
cdecl.} # Create a new SMPEG object from an MPEG file.
|
||||
# On return, if 'info' is not NULL, it will be filled with information
|
||||
# about the MPEG object.
|
||||
# This function returns a new SMPEG object. Use SMPEG_error() to find out
|
||||
# whether or not there was a problem building the MPEG stream.
|
||||
# The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
|
||||
# subsystem. If not, you will have to use the SMPEG_playaudio() function below
|
||||
# to extract the decoded data.
|
||||
|
||||
proc SMPEG_new*(theFile: cstring, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
|
||||
cdecl, importc, dynlib: SmpegLibName.}
|
||||
# The same as above for a file descriptor
|
||||
proc SMPEG_new_descr*(theFile: int, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
|
||||
cdecl, importc, dynlib: SmpegLibName.}
|
||||
# The same as above but for a raw chunk of data. SMPEG makes a copy of the
|
||||
# data, so the application is free to delete after a successful call to this
|
||||
# function.
|
||||
proc SMPEG_new_data*(data: Pointer, size: int, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
|
||||
cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Get current information about an SMPEG object
|
||||
proc SMPEG_getinfo*(mpeg: PSMPEG, info: PSMPEG_Info){.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
#procedure SMPEG_getinfo(mpeg: PSMPEG; info: Pointer);
|
||||
#cdecl; external SmpegLibName;
|
||||
# Enable or disable audio playback in MPEG stream
|
||||
proc SMPEG_enableaudio*(mpeg: PSMPEG, enable: int){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Enable or disable video playback in MPEG stream
|
||||
proc SMPEG_enablevideo*(mpeg: PSMPEG, enable: int){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Delete an SMPEG object
|
||||
proc SMPEG_delete*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Get the current status of an SMPEG object
|
||||
proc SMPEG_status*(mpeg: PSMPEG): TSMPEGstatus{.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# status
|
||||
# Set the audio volume of an MPEG stream, in the range 0-100
|
||||
proc SMPEG_setvolume*(mpeg: PSMPEG, volume: int){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Set the destination surface for MPEG video playback
|
||||
# 'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL.
|
||||
# 'callback' is a function called when an area of 'dst' needs to be updated.
|
||||
# If 'callback' is NULL, the default function (SDL_UpdateRect) will be used.
|
||||
proc SMPEG_setdisplay*(mpeg: PSMPEG, dst: PSDL_Surface, surfLock: PSDL_mutex,
|
||||
callback: TSMPEG_DisplayCallback){.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
# Set or clear looping play on an SMPEG object
|
||||
proc SMPEG_loop*(mpeg: PSMPEG, repeat_: int){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Scale pixel display on an SMPEG object
|
||||
proc SMPEG_scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
proc SMPEG_scale*(mpeg: PSMPEG, scale: int){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
proc SMPEG_Double*(mpeg: PSMPEG, doubleit: bool)
|
||||
# Move the video display area within the destination surface
|
||||
proc SMPEG_move*(mpeg: PSMPEG, x, y: int){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Set the region of the video to be shown
|
||||
proc SMPEG_setdisplayregion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
# Play an SMPEG object
|
||||
proc SMPEG_play*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Pause/Resume playback of an SMPEG object
|
||||
proc SMPEG_pause*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Stop playback of an SMPEG object
|
||||
proc SMPEG_stop*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Rewind the play position of an SMPEG object to the beginning of the MPEG
|
||||
proc SMPEG_rewind*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Seek 'bytes' bytes in the MPEG stream
|
||||
proc SMPEG_seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Skip 'seconds' seconds in the MPEG stream
|
||||
proc SMPEG_skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Render a particular frame in the MPEG video
|
||||
# API CHANGE: This function no longer takes a target surface and position.
|
||||
# Use SMPEG_setdisplay() and SMPEG_move() to set this information.
|
||||
proc SMPEG_renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
# Render the last frame of an MPEG video
|
||||
proc SMPEG_renderFinal*(mpeg: PSMPEG, dst: PSDL_Surface, x, y: int){.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
# Set video filter
|
||||
proc SMPEG_filter*(mpeg: PSMPEG, filter: PSMPEG_Filter): PSMPEG_Filter{.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
# Return NULL if there is no error in the MPEG stream, or an error message
|
||||
# if there was a fatal error in the MPEG stream for the SMPEG object.
|
||||
proc SMPEG_error*(mpeg: PSMPEG): cstring{.cdecl, importc, dynlib: SmpegLibName.}
|
||||
# Exported callback function for audio playback.
|
||||
# The function takes a buffer and the amount of data to fill, and returns
|
||||
# the amount of data in bytes that was actually written. This will be the
|
||||
# amount requested unless the MPEG audio has finished.
|
||||
#
|
||||
proc SMPEG_playAudio*(mpeg: PSMPEG, stream: PUInt8, length: int): int{.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
# Wrapper for SMPEG_playAudio() that can be passed to SDL and SDL_mixer
|
||||
proc SMPEG_playAudioSDL*(mpeg: Pointer, stream: PUInt8, length: int){.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
# Get the best SDL audio spec for the audio stream
|
||||
proc SMPEG_wantedSpec*(mpeg: PSMPEG, wanted: PSDL_AudioSpec): int{.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
# Inform SMPEG of the actual SDL audio spec used for sound playback
|
||||
proc SMPEG_actualSpec*(mpeg: PSMPEG, spec: PSDL_AudioSpec){.cdecl,
|
||||
importc, dynlib: SmpegLibName.}
|
||||
# This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL library.
|
||||
proc SMPEG_GETVERSION*(X: var TSMPEG_version)
|
||||
# implementation
|
||||
|
||||
proc SMPEG_double(mpeg: PSMPEG, doubleit: bool) =
|
||||
if doubleit: SMPEG_scale(mpeg, 2)
|
||||
else: SMPEG_scale(mpeg, 1)
|
||||
|
||||
proc SMPEG_GETVERSION(X: var TSMPEG_version) =
|
||||
X.major = SMPEG_MAJOR_VERSION
|
||||
X.minor = SMPEG_MINOR_VERSION
|
||||
X.patch = SMPEG_PATCHLEVEL
|
||||
110
lib/base/x11/cursorfont.nim
Normal file
110
lib/base/x11/cursorfont.nim
Normal file
@@ -0,0 +1,110 @@
|
||||
# $Xorg: cursorfont.h,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $
|
||||
#
|
||||
#
|
||||
#Copyright 1987, 1998 The Open Group
|
||||
#
|
||||
#Permission to use, copy, modify, distribute, and sell this software and its
|
||||
#documentation for any purpose is hereby granted without fee, provided that
|
||||
#the above copyright notice appear in all copies and that both that
|
||||
#copyright notice and this permission notice appear in supporting
|
||||
#documentation.
|
||||
#
|
||||
#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 OPEN GROUP 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.
|
||||
#
|
||||
#Except as contained in this notice, the name of The Open Group shall
|
||||
#not be used in advertising or otherwise to promote the sale, use or
|
||||
#other dealings in this Software without prior written authorization
|
||||
#from The Open Group.
|
||||
#
|
||||
#
|
||||
|
||||
const
|
||||
XC_num_glyphs* = 154
|
||||
XC_X_cursor* = 0
|
||||
XC_arrow* = 2
|
||||
XC_based_arrow_down* = 4
|
||||
XC_based_arrow_up* = 6
|
||||
XC_boat* = 8
|
||||
XC_bogosity* = 10
|
||||
XC_bottom_left_corner* = 12
|
||||
XC_bottom_right_corner* = 14
|
||||
XC_bottom_side* = 16
|
||||
XC_bottom_tee* = 18
|
||||
XC_box_spiral* = 20
|
||||
XC_center_ptr* = 22
|
||||
XC_circle* = 24
|
||||
XC_clock* = 26
|
||||
XC_coffee_mug* = 28
|
||||
XC_cross* = 30
|
||||
XC_cross_reverse* = 32
|
||||
XC_crosshair* = 34
|
||||
XC_diamond_cross* = 36
|
||||
XC_dot* = 38
|
||||
XC_dotbox* = 40
|
||||
XC_double_arrow* = 42
|
||||
XC_draft_large* = 44
|
||||
XC_draft_small* = 46
|
||||
XC_draped_box* = 48
|
||||
XC_exchange* = 50
|
||||
XC_fleur* = 52
|
||||
XC_gobbler* = 54
|
||||
XC_gumby* = 56
|
||||
XC_hand1* = 58
|
||||
XC_hand2* = 60
|
||||
XC_heart* = 62
|
||||
XC_icon* = 64
|
||||
XC_iron_cross* = 66
|
||||
XC_left_ptr* = 68
|
||||
XC_left_side* = 70
|
||||
XC_left_tee* = 72
|
||||
XC_leftbutton* = 74
|
||||
XC_ll_angle* = 76
|
||||
XC_lr_angle* = 78
|
||||
XC_man* = 80
|
||||
XC_middlebutton* = 82
|
||||
XC_mouse* = 84
|
||||
XC_pencil* = 86
|
||||
XC_pirate* = 88
|
||||
XC_plus* = 90
|
||||
XC_question_arrow* = 92
|
||||
XC_right_ptr* = 94
|
||||
XC_right_side* = 96
|
||||
XC_right_tee* = 98
|
||||
XC_rightbutton* = 100
|
||||
XC_rtl_logo* = 102
|
||||
XC_sailboat* = 104
|
||||
XC_sb_down_arrow* = 106
|
||||
XC_sb_h_double_arrow* = 108
|
||||
XC_sb_left_arrow* = 110
|
||||
XC_sb_right_arrow* = 112
|
||||
XC_sb_up_arrow* = 114
|
||||
XC_sb_v_double_arrow* = 116
|
||||
XC_shuttle* = 118
|
||||
XC_sizing* = 120
|
||||
XC_spider* = 122
|
||||
XC_spraycan* = 124
|
||||
XC_star* = 126
|
||||
XC_target* = 128
|
||||
XC_tcross* = 130
|
||||
XC_top_left_arrow* = 132
|
||||
XC_top_left_corner* = 134
|
||||
XC_top_right_corner* = 136
|
||||
XC_top_side* = 138
|
||||
XC_top_tee* = 140
|
||||
XC_trek* = 142
|
||||
XC_ul_angle* = 144
|
||||
XC_umbrella* = 146
|
||||
XC_ur_angle* = 148
|
||||
XC_watch* = 150
|
||||
XC_xterm* = 152
|
||||
|
||||
# implementation
|
||||
1900
lib/base/x11/keysym.nim
Normal file
1900
lib/base/x11/keysym.nim
Normal file
File diff suppressed because it is too large
Load Diff
399
lib/base/x11/x.nim
Normal file
399
lib/base/x11/x.nim
Normal file
@@ -0,0 +1,399 @@
|
||||
|
||||
#
|
||||
# Automatically converted by H2Pas 0.99.15 from x.h
|
||||
# The following command line parameters were used:
|
||||
# -p
|
||||
# -T
|
||||
# -S
|
||||
# -d
|
||||
# -c
|
||||
# x.h
|
||||
#
|
||||
# Pointers to basic pascal types, inserted by h2pas conversion program.
|
||||
|
||||
const
|
||||
X_PROTOCOL* = 11
|
||||
X_PROTOCOL_REVISION* = 0
|
||||
|
||||
type
|
||||
culong* = int
|
||||
cuchar* = char
|
||||
PXID* = ptr TXID
|
||||
TXID* = culong
|
||||
PMask* = ptr TMask
|
||||
TMask* = culong
|
||||
PPAtom* = ptr PAtom
|
||||
PAtom* = ptr TAtom
|
||||
TAtom* = culong
|
||||
PVisualID* = ptr TVisualID
|
||||
TVisualID* = culong
|
||||
PTime* = ptr TTime
|
||||
TTime* = culong
|
||||
PPWindow* = ptr PWindow
|
||||
PWindow* = ptr TWindow
|
||||
TWindow* = TXID
|
||||
PDrawable* = ptr TDrawable
|
||||
TDrawable* = TXID
|
||||
PFont* = ptr TFont
|
||||
TFont* = TXID
|
||||
PPixmap* = ptr TPixmap
|
||||
TPixmap* = TXID
|
||||
PCursor* = ptr TCursor
|
||||
TCursor* = TXID
|
||||
PColormap* = ptr TColormap
|
||||
TColormap* = TXID
|
||||
PGContext* = ptr TGContext
|
||||
TGContext* = TXID
|
||||
PKeySym* = ptr TKeySym
|
||||
TKeySym* = TXID
|
||||
PKeyCode* = ptr TKeyCode
|
||||
TKeyCode* = cuchar
|
||||
|
||||
const
|
||||
None* = 0
|
||||
ParentRelative* = 1
|
||||
CopyFromParent* = 0
|
||||
PointerWindow* = 0
|
||||
InputFocus* = 1
|
||||
PointerRoot* = 1
|
||||
AnyPropertyType* = 0
|
||||
AnyKey* = 0
|
||||
AnyButton* = 0
|
||||
AllTemporary* = 0
|
||||
CurrentTime* = 0
|
||||
NoSymbol* = 0
|
||||
NoEventMask* = 0
|
||||
KeyPressMask* = 1 shl 0
|
||||
KeyReleaseMask* = 1 shl 1
|
||||
ButtonPressMask* = 1 shl 2
|
||||
ButtonReleaseMask* = 1 shl 3
|
||||
EnterWindowMask* = 1 shl 4
|
||||
LeaveWindowMask* = 1 shl 5
|
||||
PointerMotionMask* = 1 shl 6
|
||||
PointerMotionHintMask* = 1 shl 7
|
||||
Button1MotionMask* = 1 shl 8
|
||||
Button2MotionMask* = 1 shl 9
|
||||
Button3MotionMask* = 1 shl 10
|
||||
Button4MotionMask* = 1 shl 11
|
||||
Button5MotionMask* = 1 shl 12
|
||||
ButtonMotionMask* = 1 shl 13
|
||||
KeymapStateMask* = 1 shl 14
|
||||
ExposureMask* = 1 shl 15
|
||||
VisibilityChangeMask* = 1 shl 16
|
||||
StructureNotifyMask* = 1 shl 17
|
||||
ResizeRedirectMask* = 1 shl 18
|
||||
SubstructureNotifyMask* = 1 shl 19
|
||||
SubstructureRedirectMask* = 1 shl 20
|
||||
FocusChangeMask* = 1 shl 21
|
||||
PropertyChangeMask* = 1 shl 22
|
||||
ColormapChangeMask* = 1 shl 23
|
||||
OwnerGrabButtonMask* = 1 shl 24
|
||||
KeyPress* = 2
|
||||
KeyRelease* = 3
|
||||
ButtonPress* = 4
|
||||
ButtonRelease* = 5
|
||||
MotionNotify* = 6
|
||||
EnterNotify* = 7
|
||||
LeaveNotify* = 8
|
||||
FocusIn* = 9
|
||||
FocusOut* = 10
|
||||
KeymapNotify* = 11
|
||||
Expose* = 12
|
||||
GraphicsExpose* = 13
|
||||
NoExpose* = 14
|
||||
VisibilityNotify* = 15
|
||||
CreateNotify* = 16
|
||||
DestroyNotify* = 17
|
||||
UnmapNotify* = 18
|
||||
MapNotify* = 19
|
||||
MapRequest* = 20
|
||||
ReparentNotify* = 21
|
||||
ConfigureNotify* = 22
|
||||
ConfigureRequest* = 23
|
||||
GravityNotify* = 24
|
||||
ResizeRequest* = 25
|
||||
CirculateNotify* = 26
|
||||
CirculateRequest* = 27
|
||||
PropertyNotify* = 28
|
||||
SelectionClear* = 29
|
||||
SelectionRequest* = 30
|
||||
SelectionNotify* = 31
|
||||
ColormapNotify* = 32
|
||||
ClientMessage* = 33
|
||||
MappingNotify* = 34
|
||||
LASTEvent* = 35
|
||||
ShiftMask* = 1 shl 0
|
||||
LockMask* = 1 shl 1
|
||||
ControlMask* = 1 shl 2
|
||||
Mod1Mask* = 1 shl 3
|
||||
Mod2Mask* = 1 shl 4
|
||||
Mod3Mask* = 1 shl 5
|
||||
Mod4Mask* = 1 shl 6
|
||||
Mod5Mask* = 1 shl 7
|
||||
ShiftMapIndex* = 0
|
||||
LockMapIndex* = 1
|
||||
ControlMapIndex* = 2
|
||||
Mod1MapIndex* = 3
|
||||
Mod2MapIndex* = 4
|
||||
Mod3MapIndex* = 5
|
||||
Mod4MapIndex* = 6
|
||||
Mod5MapIndex* = 7
|
||||
Button1Mask* = 1 shl 8
|
||||
Button2Mask* = 1 shl 9
|
||||
Button3Mask* = 1 shl 10
|
||||
Button4Mask* = 1 shl 11
|
||||
Button5Mask* = 1 shl 12
|
||||
AnyModifier* = 1 shl 15
|
||||
Button1* = 1
|
||||
Button2* = 2
|
||||
Button3* = 3
|
||||
Button4* = 4
|
||||
Button5* = 5
|
||||
NotifyNormal* = 0
|
||||
NotifyGrab* = 1
|
||||
NotifyUngrab* = 2
|
||||
NotifyWhileGrabbed* = 3
|
||||
NotifyHint* = 1
|
||||
NotifyAncestor* = 0
|
||||
NotifyVirtual* = 1
|
||||
NotifyInferior* = 2
|
||||
NotifyNonlinear* = 3
|
||||
NotifyNonlinearVirtual* = 4
|
||||
NotifyPointer* = 5
|
||||
NotifyPointerRoot* = 6
|
||||
NotifyDetailNone* = 7
|
||||
VisibilityUnobscured* = 0
|
||||
VisibilityPartiallyObscured* = 1
|
||||
VisibilityFullyObscured* = 2
|
||||
PlaceOnTop* = 0
|
||||
PlaceOnBottom* = 1
|
||||
FamilyInternet* = 0
|
||||
FamilyDECnet* = 1
|
||||
FamilyChaos* = 2
|
||||
FamilyInternet6* = 6
|
||||
FamilyServerInterpreted* = 5
|
||||
PropertyNewValue* = 0
|
||||
PropertyDelete* = 1
|
||||
ColormapUninstalled* = 0
|
||||
ColormapInstalled* = 1
|
||||
GrabModeSync* = 0
|
||||
GrabModeAsync* = 1
|
||||
GrabSuccess* = 0
|
||||
AlreadyGrabbed* = 1
|
||||
GrabInvalidTime* = 2
|
||||
GrabNotViewable* = 3
|
||||
GrabFrozen* = 4
|
||||
AsyncPointer* = 0
|
||||
SyncPointer* = 1
|
||||
ReplayPointer* = 2
|
||||
AsyncKeyboard* = 3
|
||||
SyncKeyboard* = 4
|
||||
ReplayKeyboard* = 5
|
||||
AsyncBoth* = 6
|
||||
SyncBoth* = 7
|
||||
RevertToNone* = None
|
||||
RevertToPointerRoot* = PointerRoot
|
||||
RevertToParent* = 2
|
||||
Success* = 0
|
||||
BadRequest* = 1
|
||||
BadValue* = 2
|
||||
BadWindow* = 3
|
||||
BadPixmap* = 4
|
||||
BadAtom* = 5
|
||||
BadCursor* = 6
|
||||
BadFont* = 7
|
||||
BadMatch* = 8
|
||||
BadDrawable* = 9
|
||||
BadAccess* = 10
|
||||
BadAlloc* = 11
|
||||
BadColor* = 12
|
||||
BadGC* = 13
|
||||
BadIDChoice* = 14
|
||||
BadName* = 15
|
||||
BadLength* = 16
|
||||
BadImplementation* = 17
|
||||
FirstExtensionError* = 128
|
||||
LastExtensionError* = 255
|
||||
InputOutput* = 1
|
||||
InputOnly* = 2
|
||||
CWBackPixmap* = 1 shl 0
|
||||
CWBackPixel* = 1 shl 1
|
||||
CWBorderPixmap* = 1 shl 2
|
||||
CWBorderPixel* = 1 shl 3
|
||||
CWBitGravity* = 1 shl 4
|
||||
CWWinGravity* = 1 shl 5
|
||||
CWBackingStore* = 1 shl 6
|
||||
CWBackingPlanes* = 1 shl 7
|
||||
CWBackingPixel* = 1 shl 8
|
||||
CWOverrideRedirect* = 1 shl 9
|
||||
CWSaveUnder* = 1 shl 10
|
||||
CWEventMask* = 1 shl 11
|
||||
CWDontPropagate* = 1 shl 12
|
||||
CWColormap* = 1 shl 13
|
||||
CWCursor* = 1 shl 14
|
||||
CWX* = 1 shl 0
|
||||
CWY* = 1 shl 1
|
||||
CWWidth* = 1 shl 2
|
||||
CWHeight* = 1 shl 3
|
||||
CWBorderWidth* = 1 shl 4
|
||||
CWSibling* = 1 shl 5
|
||||
CWStackMode* = 1 shl 6
|
||||
ForgetGravity* = 0
|
||||
NorthWestGravity* = 1
|
||||
NorthGravity* = 2
|
||||
NorthEastGravity* = 3
|
||||
WestGravity* = 4
|
||||
CenterGravity* = 5
|
||||
EastGravity* = 6
|
||||
SouthWestGravity* = 7
|
||||
SouthGravity* = 8
|
||||
SouthEastGravity* = 9
|
||||
StaticGravity* = 10
|
||||
UnmapGravity* = 0
|
||||
NotUseful* = 0
|
||||
WhenMapped* = 1
|
||||
Always* = 2
|
||||
IsUnmapped* = 0
|
||||
IsUnviewable* = 1
|
||||
IsViewable* = 2
|
||||
SetModeInsert* = 0
|
||||
SetModeDelete* = 1
|
||||
DestroyAll* = 0
|
||||
RetainPermanent* = 1
|
||||
RetainTemporary* = 2
|
||||
Above* = 0
|
||||
Below* = 1
|
||||
TopIf* = 2
|
||||
BottomIf* = 3
|
||||
Opposite* = 4
|
||||
RaiseLowest* = 0
|
||||
LowerHighest* = 1
|
||||
PropModeReplace* = 0
|
||||
PropModePrepend* = 1
|
||||
PropModeAppend* = 2
|
||||
GXclear* = 0x00000000
|
||||
GXand* = 0x00000001
|
||||
GXandReverse* = 0x00000002
|
||||
GXcopy* = 0x00000003
|
||||
GXandInverted* = 0x00000004
|
||||
GXnoop* = 0x00000005
|
||||
GXxor* = 0x00000006
|
||||
GXor* = 0x00000007
|
||||
GXnor* = 0x00000008
|
||||
GXequiv* = 0x00000009
|
||||
GXinvert* = 0x0000000A
|
||||
GXorReverse* = 0x0000000B
|
||||
GXcopyInverted* = 0x0000000C
|
||||
GXorInverted* = 0x0000000D
|
||||
GXnand* = 0x0000000E
|
||||
GXset* = 0x0000000F
|
||||
LineSolid* = 0
|
||||
LineOnOffDash* = 1
|
||||
LineDoubleDash* = 2
|
||||
CapNotLast* = 0
|
||||
CapButt* = 1
|
||||
CapRound* = 2
|
||||
CapProjecting* = 3
|
||||
JoinMiter* = 0
|
||||
JoinRound* = 1
|
||||
JoinBevel* = 2
|
||||
FillSolid* = 0
|
||||
FillTiled* = 1
|
||||
FillStippled* = 2
|
||||
FillOpaqueStippled* = 3
|
||||
EvenOddRule* = 0
|
||||
WindingRule* = 1
|
||||
ClipByChildren* = 0
|
||||
IncludeInferiors* = 1
|
||||
Unsorted* = 0
|
||||
YSorted* = 1
|
||||
YXSorted* = 2
|
||||
YXBanded* = 3
|
||||
CoordModeOrigin* = 0
|
||||
CoordModePrevious* = 1
|
||||
Complex* = 0
|
||||
Nonconvex* = 1
|
||||
Convex* = 2
|
||||
ArcChord* = 0
|
||||
ArcPieSlice* = 1
|
||||
GCFunction* = 1 shl 0
|
||||
GCPlaneMask* = 1 shl 1
|
||||
GCForeground* = 1 shl 2
|
||||
GCBackground* = 1 shl 3
|
||||
GCLineWidth* = 1 shl 4
|
||||
GCLineStyle* = 1 shl 5
|
||||
GCCapStyle* = 1 shl 6
|
||||
GCJoinStyle* = 1 shl 7
|
||||
GCFillStyle* = 1 shl 8
|
||||
GCFillRule* = 1 shl 9
|
||||
GCTile* = 1 shl 10
|
||||
GCStipple* = 1 shl 11
|
||||
GCTileStipXOrigin* = 1 shl 12
|
||||
GCTileStipYOrigin* = 1 shl 13
|
||||
GCFont* = 1 shl 14
|
||||
GCSubwindowMode* = 1 shl 15
|
||||
GCGraphicsExposures* = 1 shl 16
|
||||
GCClipXOrigin* = 1 shl 17
|
||||
GCClipYOrigin* = 1 shl 18
|
||||
GCClipMask* = 1 shl 19
|
||||
GCDashOffset* = 1 shl 20
|
||||
GCDashList* = 1 shl 21
|
||||
GCArcMode* = 1 shl 22
|
||||
GCLastBit* = 22
|
||||
FontLeftToRight* = 0
|
||||
FontRightToLeft* = 1
|
||||
FontChange* = 255
|
||||
XYBitmap* = 0
|
||||
XYPixmap* = 1
|
||||
ZPixmap* = 2
|
||||
AllocNone* = 0
|
||||
AllocAll* = 1
|
||||
DoRed* = 1 shl 0
|
||||
DoGreen* = 1 shl 1
|
||||
DoBlue* = 1 shl 2
|
||||
CursorShape* = 0
|
||||
TileShape* = 1
|
||||
StippleShape* = 2
|
||||
AutoRepeatModeOff* = 0
|
||||
AutoRepeatModeOn* = 1
|
||||
AutoRepeatModeDefault* = 2
|
||||
LedModeOff* = 0
|
||||
LedModeOn* = 1
|
||||
KBKeyClickPercent* = 1 shl 0
|
||||
KBBellPercent* = 1 shl 1
|
||||
KBBellPitch* = 1 shl 2
|
||||
KBBellDuration* = 1 shl 3
|
||||
KBLed* = 1 shl 4
|
||||
KBLedMode* = 1 shl 5
|
||||
KBKey* = 1 shl 6
|
||||
KBAutoRepeatMode* = 1 shl 7
|
||||
MappingSuccess* = 0
|
||||
MappingBusy* = 1
|
||||
MappingFailed* = 2
|
||||
MappingModifier* = 0
|
||||
MappingKeyboard* = 1
|
||||
MappingPointer* = 2
|
||||
DontPreferBlanking* = 0
|
||||
PreferBlanking* = 1
|
||||
DefaultBlanking* = 2
|
||||
DisableScreenSaver* = 0
|
||||
DisableScreenInterval* = 0
|
||||
DontAllowExposures* = 0
|
||||
AllowExposures* = 1
|
||||
DefaultExposures* = 2
|
||||
ScreenSaverReset* = 0
|
||||
ScreenSaverActive* = 1
|
||||
HostInsert* = 0
|
||||
HostDelete* = 1
|
||||
EnableAccess* = 1
|
||||
DisableAccess* = 0
|
||||
StaticGray* = 0
|
||||
GrayScale* = 1
|
||||
StaticColor* = 2
|
||||
PseudoColor* = 3
|
||||
TrueColor* = 4
|
||||
DirectColor* = 5
|
||||
LSBFirst* = 0
|
||||
MSBFirst* = 1
|
||||
|
||||
# implementation
|
||||
81
lib/base/x11/xatom.nim
Normal file
81
lib/base/x11/xatom.nim
Normal file
@@ -0,0 +1,81 @@
|
||||
#
|
||||
# THIS IS A GENERATED FILE
|
||||
#
|
||||
# Do not change! Changing this file implies a protocol change!
|
||||
#
|
||||
|
||||
import
|
||||
X
|
||||
|
||||
const
|
||||
XA_PRIMARY* = TAtom(1)
|
||||
XA_SECONDARY* = TAtom(2)
|
||||
XA_ARC* = TAtom(3)
|
||||
XA_ATOM* = TAtom(4)
|
||||
XA_BITMAP* = TAtom(5)
|
||||
XA_CARDINAL* = TAtom(6)
|
||||
XA_COLORMAP* = TAtom(7)
|
||||
XA_CURSOR* = TAtom(8)
|
||||
XA_CUT_BUFFER0* = TAtom(9)
|
||||
XA_CUT_BUFFER1* = TAtom(10)
|
||||
XA_CUT_BUFFER2* = TAtom(11)
|
||||
XA_CUT_BUFFER3* = TAtom(12)
|
||||
XA_CUT_BUFFER4* = TAtom(13)
|
||||
XA_CUT_BUFFER5* = TAtom(14)
|
||||
XA_CUT_BUFFER6* = TAtom(15)
|
||||
XA_CUT_BUFFER7* = TAtom(16)
|
||||
XA_DRAWABLE* = TAtom(17)
|
||||
XA_FONT* = TAtom(18)
|
||||
XA_INTEGER* = TAtom(19)
|
||||
XA_PIXMAP* = TAtom(20)
|
||||
XA_POINT* = TAtom(21)
|
||||
XA_RECTANGLE* = TAtom(22)
|
||||
XA_RESOURCE_MANAGER* = TAtom(23)
|
||||
XA_RGB_COLOR_MAP* = TAtom(24)
|
||||
XA_RGB_BEST_MAP* = TAtom(25)
|
||||
XA_RGB_BLUE_MAP* = TAtom(26)
|
||||
XA_RGB_DEFAULT_MAP* = TAtom(27)
|
||||
XA_RGB_GRAY_MAP* = TAtom(28)
|
||||
XA_RGB_GREEN_MAP* = TAtom(29)
|
||||
XA_RGB_RED_MAP* = TAtom(30)
|
||||
XA_STRING* = TAtom(31)
|
||||
XA_VISUALID* = TAtom(32)
|
||||
XA_WINDOW* = TAtom(33)
|
||||
XA_WM_COMMAND* = TAtom(34)
|
||||
XA_WM_HINTS* = TAtom(35)
|
||||
XA_WM_CLIENT_MACHINE* = TAtom(36)
|
||||
XA_WM_ICON_NAME* = TAtom(37)
|
||||
XA_WM_ICON_SIZE* = TAtom(38)
|
||||
XA_WM_NAME* = TAtom(39)
|
||||
XA_WM_NORMAL_HINTS* = TAtom(40)
|
||||
XA_WM_SIZE_HINTS* = TAtom(41)
|
||||
XA_WM_ZOOM_HINTS* = TAtom(42)
|
||||
XA_MIN_SPACE* = TAtom(43)
|
||||
XA_NORM_SPACE* = TAtom(44)
|
||||
XA_MAX_SPACE* = TAtom(45)
|
||||
XA_END_SPACE* = TAtom(46)
|
||||
XA_SUPERSCRIPT_X* = TAtom(47)
|
||||
XA_SUPERSCRIPT_Y* = TAtom(48)
|
||||
XA_SUBSCRIPT_X* = TAtom(49)
|
||||
XA_SUBSCRIPT_Y* = TAtom(50)
|
||||
XA_UNDERLINE_POSITION* = TAtom(51)
|
||||
XA_UNDERLINE_THICKNESS* = TAtom(52)
|
||||
XA_STRIKEOUT_ASCENT* = TAtom(53)
|
||||
XA_STRIKEOUT_DESCENT* = TAtom(54)
|
||||
XA_ITALIC_ANGLE* = TAtom(55)
|
||||
XA_X_HEIGHT* = TAtom(56)
|
||||
XA_QUAD_WIDTH* = TAtom(57)
|
||||
XA_WEIGHT* = TAtom(58)
|
||||
XA_POINT_SIZE* = TAtom(59)
|
||||
XA_RESOLUTION* = TAtom(60)
|
||||
XA_COPYRIGHT* = TAtom(61)
|
||||
XA_NOTICE* = TAtom(62)
|
||||
XA_FONT_NAME* = TAtom(63)
|
||||
XA_FAMILY_NAME* = TAtom(64)
|
||||
XA_FULL_NAME* = TAtom(65)
|
||||
XA_CAP_HEIGHT* = TAtom(66)
|
||||
XA_WM_CLASS* = TAtom(67)
|
||||
XA_WM_TRANSIENT_FOR* = TAtom(68)
|
||||
XA_LAST_PREDEFINED* = TAtom(68)
|
||||
|
||||
# implementation
|
||||
396
lib/base/x11/xcms.nim
Normal file
396
lib/base/x11/xcms.nim
Normal file
@@ -0,0 +1,396 @@
|
||||
|
||||
import
|
||||
x, xlib
|
||||
|
||||
#const
|
||||
# libX11* = "X11"
|
||||
|
||||
#
|
||||
# Automatically converted by H2Pas 0.99.15 from xcms.h
|
||||
# The following command line parameters were used:
|
||||
# -p
|
||||
# -T
|
||||
# -S
|
||||
# -d
|
||||
# -c
|
||||
# xcms.h
|
||||
#
|
||||
|
||||
const
|
||||
XcmsFailure* = 0
|
||||
XcmsSuccess* = 1
|
||||
XcmsSuccessWithCompression* = 2
|
||||
|
||||
type
|
||||
PXcmsColorFormat* = ptr TXcmsColorFormat
|
||||
TXcmsColorFormat* = int32
|
||||
|
||||
proc XcmsUndefinedFormat*(): TXcmsColorFormat
|
||||
proc XcmsCIEXYZFormat*(): TXcmsColorFormat
|
||||
proc XcmsCIEuvYFormat*(): TXcmsColorFormat
|
||||
proc XcmsCIExyYFormat*(): TXcmsColorFormat
|
||||
proc XcmsCIELabFormat*(): TXcmsColorFormat
|
||||
proc XcmsCIELuvFormat*(): TXcmsColorFormat
|
||||
proc XcmsTekHVCFormat*(): TXcmsColorFormat
|
||||
proc XcmsRGBFormat*(): TXcmsColorFormat
|
||||
proc XcmsRGBiFormat*(): TXcmsColorFormat
|
||||
const
|
||||
XcmsInitNone* = 0x00000000
|
||||
XcmsInitSuccess* = 0x00000001
|
||||
XcmsInitFailure* = 0x000000FF
|
||||
|
||||
when defined(MACROS):
|
||||
proc DisplayOfCCC*(ccc: int32): int32
|
||||
proc ScreenNumberOfCCC*(ccc: int32): int32
|
||||
proc VisualOfCCC*(ccc: int32): int32
|
||||
proc ClientWhitePointOfCCC*(ccc: int32): int32
|
||||
proc ScreenWhitePointOfCCC*(ccc: int32): int32
|
||||
proc FunctionSetOfCCC*(ccc: int32): int32
|
||||
type
|
||||
PXcmsFloat* = ptr TXcmsFloat
|
||||
TXcmsFloat* = float64
|
||||
PXcmsRGB* = ptr TXcmsRGB
|
||||
TXcmsRGB*{.final.} = object
|
||||
red*: int16
|
||||
green*: int16
|
||||
blue*: int16
|
||||
|
||||
PXcmsRGBi* = ptr TXcmsRGBi
|
||||
TXcmsRGBi*{.final.} = object
|
||||
red*: TXcmsFloat
|
||||
green*: TXcmsFloat
|
||||
blue*: TXcmsFloat
|
||||
|
||||
PXcmsCIEXYZ* = ptr TXcmsCIEXYZ
|
||||
TXcmsCIEXYZ*{.final.} = object
|
||||
X*: TXcmsFloat
|
||||
Y*: TXcmsFloat
|
||||
Z*: TXcmsFloat
|
||||
|
||||
PXcmsCIEuvY* = ptr TXcmsCIEuvY
|
||||
TXcmsCIEuvY*{.final.} = object
|
||||
u_prime*: TXcmsFloat
|
||||
v_prime*: TXcmsFloat
|
||||
Y*: TXcmsFloat
|
||||
|
||||
PXcmsCIExyY* = ptr TXcmsCIExyY
|
||||
TXcmsCIExyY*{.final.} = object
|
||||
x*: TXcmsFloat
|
||||
y*: TXcmsFloat
|
||||
theY*: TXcmsFloat
|
||||
|
||||
PXcmsCIELab* = ptr TXcmsCIELab
|
||||
TXcmsCIELab*{.final.} = object
|
||||
L_star*: TXcmsFloat
|
||||
a_star*: TXcmsFloat
|
||||
b_star*: TXcmsFloat
|
||||
|
||||
PXcmsCIELuv* = ptr TXcmsCIELuv
|
||||
TXcmsCIELuv*{.final.} = object
|
||||
L_star*: TXcmsFloat
|
||||
u_star*: TXcmsFloat
|
||||
v_star*: TXcmsFloat
|
||||
|
||||
PXcmsTekHVC* = ptr TXcmsTekHVC
|
||||
TXcmsTekHVC*{.final.} = object
|
||||
H*: TXcmsFloat
|
||||
V*: TXcmsFloat
|
||||
C*: TXcmsFloat
|
||||
|
||||
PXcmsPad* = ptr TXcmsPad
|
||||
TXcmsPad*{.final.} = object
|
||||
pad0*: TXcmsFloat
|
||||
pad1*: TXcmsFloat
|
||||
pad2*: TXcmsFloat
|
||||
pad3*: TXcmsFloat
|
||||
|
||||
PXcmsColor* = ptr TXcmsColor
|
||||
TXcmsColor*{.final.} = object # spec : record
|
||||
# case longint of
|
||||
# 0 : ( RGB : TXcmsRGB );
|
||||
# 1 : ( RGBi : TXcmsRGBi );
|
||||
# 2 : ( CIEXYZ : TXcmsCIEXYZ );
|
||||
# 3 : ( CIEuvY : TXcmsCIEuvY );
|
||||
# 4 : ( CIExyY : TXcmsCIExyY );
|
||||
# 5 : ( CIELab : TXcmsCIELab );
|
||||
# 6 : ( CIELuv : TXcmsCIELuv );
|
||||
# 7 : ( TekHVC : TXcmsTekHVC );
|
||||
# 8 : ( Pad : TXcmsPad );
|
||||
# end;
|
||||
pad*: TXcmsPad
|
||||
pixel*: int32
|
||||
format*: TXcmsColorFormat
|
||||
|
||||
PXcmsPerScrnInfo* = ptr TXcmsPerScrnInfo
|
||||
TXcmsPerScrnInfo*{.final.} = object
|
||||
screenWhitePt*: TXcmsColor
|
||||
functionSet*: TXPointer
|
||||
screenData*: TXPointer
|
||||
state*: int8
|
||||
pad*: array[0..2, char]
|
||||
|
||||
PXcmsCCC* = ptr TXcmsCCC
|
||||
TXcmsCompressionProc* = proc (para1: PXcmsCCC, para2: PXcmsColor,
|
||||
para3: int32, para4: int32, para5: PBool): TStatus{.
|
||||
cdecl.}
|
||||
TXcmsWhiteAdjustProc* = proc (para1: PXcmsCCC, para2: PXcmsColor,
|
||||
para3: PXcmsColor, para4: TXcmsColorFormat,
|
||||
para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
|
||||
cdecl.}
|
||||
TXcmsCCC*{.final.} = object
|
||||
dpy*: PDisplay
|
||||
screenNumber*: int32
|
||||
visual*: PVisual
|
||||
clientWhitePt*: TXcmsColor
|
||||
gamutCompProc*: TXcmsCompressionProc
|
||||
gamutCompClientData*: TXPointer
|
||||
whitePtAdjProc*: TXcmsWhiteAdjustProc
|
||||
whitePtAdjClientData*: TXPointer
|
||||
pPerScrnInfo*: PXcmsPerScrnInfo
|
||||
|
||||
TXcmsCCCRec* = TXcmsCCC
|
||||
PXcmsCCCRec* = ptr TXcmsCCCRec
|
||||
TXcmsScreenInitProc* = proc (para1: PDisplay, para2: int32,
|
||||
para3: PXcmsPerScrnInfo): TStatus{.cdecl.}
|
||||
TXcmsScreenFreeProc* = proc (para1: TXPointer){.cdecl.}
|
||||
TXcmsConversionProc* = proc (){.cdecl.}
|
||||
PXcmsFuncListPtr* = ptr TXcmsFuncListPtr
|
||||
TXcmsFuncListPtr* = TXcmsConversionProc
|
||||
TXcmsParseStringProc* = proc (para1: cstring, para2: PXcmsColor): int32{.cdecl.}
|
||||
PXcmsColorSpace* = ptr TXcmsColorSpace
|
||||
TXcmsColorSpace*{.final.} = object
|
||||
prefix*: cstring
|
||||
id*: TXcmsColorFormat
|
||||
parseString*: TXcmsParseStringProc
|
||||
to_CIEXYZ*: TXcmsFuncListPtr
|
||||
from_CIEXYZ*: TXcmsFuncListPtr
|
||||
inverse_flag*: int32
|
||||
|
||||
PXcmsFunctionSet* = ptr TXcmsFunctionSet
|
||||
TXcmsFunctionSet*{.final.} = object # error
|
||||
#extern Status XcmsAddColorSpace (
|
||||
#in declaration at line 323
|
||||
DDColorSpaces*: ptr PXcmsColorSpace
|
||||
screenInitProc*: TXcmsScreenInitProc
|
||||
screenFreeProc*: TXcmsScreenFreeProc
|
||||
|
||||
|
||||
proc XcmsAddFunctionSet*(para1: PXcmsFunctionSet): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsAllocColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor,
|
||||
para4: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsAllocNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring,
|
||||
para4: PXcmsColor, para5: PXcmsColor,
|
||||
para6: TXcmsColorFormat): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsCCCOfColormap*(para1: PDisplay, para2: TColormap): TXcmsCCC{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsCIELabClipab*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsCIELabClipL*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsCIELabClipLab*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsCIELabQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsCIELabQueryMaxL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsCIELabQueryMaxLC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIELabQueryMinL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsCIELabToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIELabWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor,
|
||||
para3: PXcmsColor, para4: TXcmsColorFormat,
|
||||
para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIELuvClipL*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsCIELuvClipLuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsCIELuvClipuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsCIELuvQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsCIELuvQueryMaxL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsCIELuvQueryMaxLC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIELuvQueryMinL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsCIELuvToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIELuvWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor,
|
||||
para3: PXcmsColor, para4: TXcmsColorFormat,
|
||||
para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIEXYZToCIELab*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIEXYZToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIEXYZToCIExyY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIEXYZToRGBi*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIEuvYToCIELuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIEuvYToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIEuvYToTekHVC*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsCIExyYToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsClientWhitePointOfCCC*(para1: TXcmsCCC): PXcmsColor{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsConvertColors*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: TXcmsColorFormat, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsCreateCCC*(para1: PDisplay, para2: int32, para3: PVisual,
|
||||
para4: PXcmsColor, para5: TXcmsCompressionProc,
|
||||
para6: TXPointer, para7: TXcmsWhiteAdjustProc,
|
||||
para8: TXPointer): TXcmsCCC{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsDefaultCCC*(para1: PDisplay, para2: int32): TXcmsCCC{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsDisplayOfCCC*(para1: TXcmsCCC): PDisplay{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsFormatOfPrefix*(para1: cstring): TXcmsColorFormat{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsFreeCCC*(para1: TXcmsCCC){.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsLookupColor*(para1: PDisplay, para2: TColormap, para3: cstring,
|
||||
para4: PXcmsColor, para5: PXcmsColor,
|
||||
para6: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsPrefixOfFormat*(para1: TXcmsColorFormat): cstring{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsQueryBlack*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsQueryBlue*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsQueryColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor,
|
||||
para4: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsQueryColors*(para1: PDisplay, para2: TColormap, para3: PXcmsColor,
|
||||
para4: int32, para5: TXcmsColorFormat): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsQueryGreen*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsQueryRed*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsQueryWhite*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsRGBiToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsRGBiToRGB*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsRGBToRGBi*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsScreenNumberOfCCC*(para1: TXcmsCCC): int32{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsScreenWhitePointOfCCC*(para1: TXcmsCCC): PXcmsColor{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsSetCCCOfColormap*(para1: PDisplay, para2: TColormap, para3: TXcmsCCC): TXcmsCCC{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsSetCompressionProc*(para1: TXcmsCCC, para2: TXcmsCompressionProc,
|
||||
para3: TXPointer): TXcmsCompressionProc{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsSetWhiteAdjustProc*(para1: TXcmsCCC, para2: TXcmsWhiteAdjustProc,
|
||||
para3: TXPointer): TXcmsWhiteAdjustProc{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsSetWhitePoint*(para1: TXcmsCCC, para2: PXcmsColor): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsStoreColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsStoreColors*(para1: PDisplay, para2: TColormap, para3: PXcmsColor,
|
||||
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsTekHVCClipC*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsTekHVCClipV*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsTekHVCClipVC*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XcmsTekHVCQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsTekHVCQueryMaxV*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsTekHVCQueryMaxVC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsTekHVCQueryMaxVSamples*(para1: TXcmsCCC, para2: TXcmsFloat,
|
||||
para3: PXcmsColor, para4: int32): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsTekHVCQueryMinV*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XcmsTekHVCToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsTekHVCWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor,
|
||||
para3: PXcmsColor, para4: TXcmsColorFormat,
|
||||
para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XcmsVisualOfCCC*(para1: TXcmsCCC): PVisual{.cdecl, dynlib: libX11, importc.}
|
||||
# implementation
|
||||
|
||||
proc XcmsUndefinedFormat(): TXcmsColorFormat =
|
||||
result = TXcmsColorFormat(0x00000000)
|
||||
|
||||
proc XcmsCIEXYZFormat(): TXcmsColorFormat =
|
||||
result = TXcmsColorFormat(0x00000001)
|
||||
|
||||
proc XcmsCIEuvYFormat(): TXcmsColorFormat =
|
||||
result = TXcmsColorFormat(0x00000002)
|
||||
|
||||
proc XcmsCIExyYFormat(): TXcmsColorFormat =
|
||||
result = TXcmsColorFormat(0x00000003)
|
||||
|
||||
proc XcmsCIELabFormat(): TXcmsColorFormat =
|
||||
result = TXcmsColorFormat(0x00000004)
|
||||
|
||||
proc XcmsCIELuvFormat(): TXcmsColorFormat =
|
||||
result = TXcmsColorFormat(0x00000005)
|
||||
|
||||
proc XcmsTekHVCFormat(): TXcmsColorFormat =
|
||||
result = TXcmsColorFormat(0x00000006)
|
||||
|
||||
proc XcmsRGBFormat(): TXcmsColorFormat =
|
||||
result = TXcmsColorFormat(0x80000000)
|
||||
|
||||
proc XcmsRGBiFormat(): TXcmsColorFormat =
|
||||
result = TXcmsColorFormat(0x80000001)
|
||||
|
||||
when defined(MACROS):
|
||||
proc DisplayOfCCC(ccc: int32): int32 =
|
||||
result = ccc.dpy
|
||||
|
||||
proc ScreenNumberOfCCC(ccc: int32): int32 =
|
||||
result = ccc.screenNumber
|
||||
|
||||
proc VisualOfCCC(ccc: int32): int32 =
|
||||
result = ccc.visual
|
||||
|
||||
proc ClientWhitePointOfCCC(ccc: int32): int32 =
|
||||
result = addr(ccc.clientWhitePt)
|
||||
|
||||
proc ScreenWhitePointOfCCC(ccc: int32): int32 =
|
||||
result = addr(ccc.pPerScrnInfo.screenWhitePt)
|
||||
|
||||
proc FunctionSetOfCCC(ccc: int32): int32 =
|
||||
result = ccc.pPerScrnInfo.functionSet
|
||||
235
lib/base/x11/xf86dga.nim
Normal file
235
lib/base/x11/xf86dga.nim
Normal file
@@ -0,0 +1,235 @@
|
||||
#
|
||||
# Copyright (c) 1999 XFree86 Inc
|
||||
#
|
||||
# $XFree86: xc/include/extensions/xf86dga.h,v 3.20 1999/10/13 04:20:48 dawes Exp $
|
||||
|
||||
import
|
||||
x, xlib
|
||||
|
||||
const
|
||||
libXxf86dga* = "libXxf86dga.so"
|
||||
|
||||
#type
|
||||
# cfloat* = float32
|
||||
|
||||
# $XFree86: xc/include/extensions/xf86dga1.h,v 1.2 1999/04/17 07:05:41 dawes Exp $
|
||||
#
|
||||
#
|
||||
#Copyright (c) 1995 Jon Tombs
|
||||
#Copyright (c) 1995 XFree86 Inc
|
||||
#
|
||||
#
|
||||
#************************************************************************
|
||||
#
|
||||
# THIS IS THE OLD DGA API AND IS OBSOLETE. PLEASE DO NOT USE IT ANYMORE
|
||||
#
|
||||
#************************************************************************
|
||||
|
||||
type
|
||||
PPcchar* = ptr ptr cstring
|
||||
|
||||
const
|
||||
X_XF86DGAQueryVersion* = 0
|
||||
X_XF86DGAGetVideoLL* = 1
|
||||
X_XF86DGADirectVideo* = 2
|
||||
X_XF86DGAGetViewPortSize* = 3
|
||||
X_XF86DGASetViewPort* = 4
|
||||
X_XF86DGAGetVidPage* = 5
|
||||
X_XF86DGASetVidPage* = 6
|
||||
X_XF86DGAInstallColormap* = 7
|
||||
X_XF86DGAQueryDirectVideo* = 8
|
||||
X_XF86DGAViewPortChanged* = 9
|
||||
XF86DGADirectPresent* = 0x00000001
|
||||
XF86DGADirectGraphics* = 0x00000002
|
||||
XF86DGADirectMouse* = 0x00000004
|
||||
XF86DGADirectKeyb* = 0x00000008
|
||||
XF86DGAHasColormap* = 0x00000100
|
||||
XF86DGADirectColormap* = 0x00000200
|
||||
|
||||
proc XF86DGAQueryVersion*(dpy: PDisplay, majorVersion: Pcint,
|
||||
minorVersion: Pcint): TBool{.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGAQueryExtension*(dpy: PDisplay, event_base: Pcint, error_base: Pcint): TBool{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGAGetVideoLL*(dpy: PDisplay, screen: cint, base_addr: Pcint,
|
||||
width: Pcint, bank_size: Pcint, ram_size: Pcint): TStatus{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGAGetVideo*(dpy: PDisplay, screen: cint, base_addr: PPcchar,
|
||||
width: Pcint, bank_size: Pcint, ram_size: Pcint): TStatus{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGADirectVideo*(dpy: PDisplay, screen: cint, enable: cint): TStatus{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGADirectVideoLL*(dpy: PDisplay, screen: cint, enable: cint): TStatus{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGAGetViewPortSize*(dpy: PDisplay, screen: cint, width: Pcint,
|
||||
height: Pcint): TStatus{.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGASetViewPort*(dpy: PDisplay, screen: cint, x: cint, y: cint): TStatus{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGAGetVidPage*(dpy: PDisplay, screen: cint, vid_page: Pcint): TStatus{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGASetVidPage*(dpy: PDisplay, screen: cint, vid_page: cint): TStatus{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGAInstallColormap*(dpy: PDisplay, screen: cint, Colormap: TColormap): TStatus{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGAForkApp*(screen: cint): cint{.CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGAQueryDirectVideo*(dpy: PDisplay, screen: cint, flags: Pcint): TStatus{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XF86DGAViewPortChanged*(dpy: PDisplay, screen: cint, n: cint): TBool{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
const
|
||||
X_XDGAQueryVersion* = 0 # 1 through 9 are in xf86dga1.pp
|
||||
# 10 and 11 are reserved to avoid conflicts with rogue DGA extensions
|
||||
X_XDGAQueryModes* = 12
|
||||
X_XDGASetMode* = 13
|
||||
X_XDGASetViewport* = 14
|
||||
X_XDGAInstallColormap* = 15
|
||||
X_XDGASelectInput* = 16
|
||||
X_XDGAFillRectangle* = 17
|
||||
X_XDGACopyArea* = 18
|
||||
X_XDGACopyTransparentArea* = 19
|
||||
X_XDGAGetViewportStatus* = 20
|
||||
X_XDGASync* = 21
|
||||
X_XDGAOpenFramebuffer* = 22
|
||||
X_XDGACloseFramebuffer* = 23
|
||||
X_XDGASetClientVersion* = 24
|
||||
X_XDGAChangePixmapMode* = 25
|
||||
X_XDGACreateColormap* = 26
|
||||
XDGAConcurrentAccess* = 0x00000001
|
||||
XDGASolidFillRect* = 0x00000002
|
||||
XDGABlitRect* = 0x00000004
|
||||
XDGABlitTransRect* = 0x00000008
|
||||
XDGAPixmap* = 0x00000010
|
||||
XDGAInterlaced* = 0x00010000
|
||||
XDGADoublescan* = 0x00020000
|
||||
XDGAFlipImmediate* = 0x00000001
|
||||
XDGAFlipRetrace* = 0x00000002
|
||||
XDGANeedRoot* = 0x00000001
|
||||
XF86DGANumberEvents* = 7
|
||||
XDGAPixmapModeLarge* = 0
|
||||
XDGAPixmapModeSmall* = 1
|
||||
XF86DGAClientNotLocal* = 0
|
||||
XF86DGANoDirectVideoMode* = 1
|
||||
XF86DGAScreenNotActive* = 2
|
||||
XF86DGADirectNotActivated* = 3
|
||||
XF86DGAOperationNotSupported* = 4
|
||||
XF86DGANumberErrors* = (XF86DGAOperationNotSupported + 1)
|
||||
|
||||
type
|
||||
PXDGAMode* = ptr TXDGAMode
|
||||
TXDGAMode*{.final.} = object
|
||||
num*: cint # A unique identifier for the mode (num > 0)
|
||||
name*: cstring # name of mode given in the XF86Config
|
||||
verticalRefresh*: cfloat
|
||||
flags*: cint # DGA_CONCURRENT_ACCESS, etc...
|
||||
imageWidth*: cint # linear accessible portion (pixels)
|
||||
imageHeight*: cint
|
||||
pixmapWidth*: cint # Xlib accessible portion (pixels)
|
||||
pixmapHeight*: cint # both fields ignored if no concurrent access
|
||||
bytesPerScanline*: cint
|
||||
byteOrder*: cint # MSBFirst, LSBFirst
|
||||
depth*: cint
|
||||
bitsPerPixel*: cint
|
||||
redMask*: culong
|
||||
greenMask*: culong
|
||||
blueMask*: culong
|
||||
visualClass*: cshort
|
||||
viewportWidth*: cint
|
||||
viewportHeight*: cint
|
||||
xViewportStep*: cint # viewport position granularity
|
||||
yViewportStep*: cint
|
||||
maxViewportX*: cint # max viewport origin
|
||||
maxViewportY*: cint
|
||||
viewportFlags*: cint # types of page flipping possible
|
||||
reserved1*: cint
|
||||
reserved2*: cint
|
||||
|
||||
PXDGADevice* = ptr TXDGADevice
|
||||
TXDGADevice*{.final.} = object
|
||||
mode*: TXDGAMode
|
||||
data*: Pcuchar
|
||||
pixmap*: TPixmap
|
||||
|
||||
PXDGAButtonEvent* = ptr TXDGAButtonEvent
|
||||
TXDGAButtonEvent*{.final.} = object
|
||||
theType*: cint
|
||||
serial*: culong
|
||||
display*: PDisplay
|
||||
screen*: cint
|
||||
time*: TTime
|
||||
state*: cuint
|
||||
button*: cuint
|
||||
|
||||
PXDGAKeyEvent* = ptr TXDGAKeyEvent
|
||||
TXDGAKeyEvent*{.final.} = object
|
||||
theType*: cint
|
||||
serial*: culong
|
||||
display*: PDisplay
|
||||
screen*: cint
|
||||
time*: TTime
|
||||
state*: cuint
|
||||
keycode*: cuint
|
||||
|
||||
PXDGAMotionEvent* = ptr TXDGAMotionEvent
|
||||
TXDGAMotionEvent*{.final.} = object
|
||||
theType*: cint
|
||||
serial*: culong
|
||||
display*: PDisplay
|
||||
screen*: cint
|
||||
time*: TTime
|
||||
state*: cuint
|
||||
dx*: cint
|
||||
dy*: cint
|
||||
|
||||
PXDGAEvent* = ptr TXDGAEvent
|
||||
TXDGAEvent*{.final.} = object
|
||||
pad*: array[0..23, clong] # sorry you have to cast if you want access
|
||||
#Case LongInt Of
|
||||
# 0 : (_type : cint);
|
||||
# 1 : (xbutton : TXDGAButtonEvent);
|
||||
# 2 : (xkey : TXDGAKeyEvent);
|
||||
# 3 : (xmotion : TXDGAMotionEvent);
|
||||
# 4 : (pad : Array[0..23] Of clong);
|
||||
|
||||
|
||||
proc XDGAQueryExtension*(dpy: PDisplay, eventBase: Pcint, erroBase: Pcint): TBool{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XDGAQueryVersion*(dpy: PDisplay, majorVersion: Pcint, minorVersion: Pcint): TBool{.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XDGAQueryModes*(dpy: PDisplay, screen: cint, num: Pcint): PXDGAMode{.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XDGASetMode*(dpy: PDisplay, screen: cint, mode: cint): PXDGADevice{.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XDGAOpenFramebuffer*(dpy: PDisplay, screen: cint): TBool{.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XDGACloseFramebuffer*(dpy: PDisplay, screen: cint){.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XDGASetViewport*(dpy: PDisplay, screen: cint, x: cint, y: cint, flags: cint){.
|
||||
CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XDGAInstallColormap*(dpy: PDisplay, screen: cint, cmap: TColormap){.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XDGACreateColormap*(dpy: PDisplay, screen: cint, device: PXDGADevice,
|
||||
alloc: cint): TColormap{.CDecl, dynlib: libXxf86dga,
|
||||
importc.}
|
||||
proc XDGASelectInput*(dpy: PDisplay, screen: cint, event_mask: clong){.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XDGAFillRectangle*(dpy: PDisplay, screen: cint, x: cint, y: cint,
|
||||
width: cuint, height: cuint, color: culong){.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XDGACopyArea*(dpy: PDisplay, screen: cint, srcx: cint, srcy: cint,
|
||||
width: cuint, height: cuint, dstx: cint, dsty: cint){.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XDGACopyTransparentArea*(dpy: PDisplay, screen: cint, srcx: cint,
|
||||
srcy: cint, width: cuint, height: cuint,
|
||||
dstx: cint, dsty: cint, key: culong){.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XDGAGetViewportStatus*(dpy: PDisplay, screen: cint): cint{.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
proc XDGASync*(dpy: PDisplay, screen: cint){.CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XDGASetClientVersion*(dpy: PDisplay): TBool{.CDecl, dynlib: libXxf86dga,
|
||||
importc.}
|
||||
proc XDGAChangePixmapMode*(dpy: PDisplay, screen: cint, x: Pcint, y: Pcint,
|
||||
mode: cint){.CDecl, dynlib: libXxf86dga, importc.}
|
||||
proc XDGAKeyEventToXKeyEvent*(dk: PXDGAKeyEvent, xk: PXKeyEvent){.CDecl,
|
||||
dynlib: libXxf86dga, importc.}
|
||||
# implementation
|
||||
229
lib/base/x11/xf86vmode.nim
Normal file
229
lib/base/x11/xf86vmode.nim
Normal file
@@ -0,0 +1,229 @@
|
||||
# $XFree86: xc/include/extensions/xf86vmode.h,v 3.30 2001/05/07 20:09:50 mvojkovi Exp $
|
||||
#
|
||||
#
|
||||
#Copyright 1995 Kaleb S. KEITHLEY
|
||||
#
|
||||
#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 Kaleb S. KEITHLEY 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.
|
||||
#
|
||||
#Except as contained in this notice, the name of Kaleb S. KEITHLEY
|
||||
#shall not be used in advertising or otherwise to promote the sale, use
|
||||
#or other dealings in this Software without prior written authorization
|
||||
#from Kaleb S. KEITHLEY
|
||||
#
|
||||
#
|
||||
# $Xorg: xf86vmode.h,v 1.3 2000/08/18 04:05:46 coskrey Exp $
|
||||
# THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION
|
||||
|
||||
import
|
||||
x, xlib
|
||||
|
||||
const
|
||||
libXxf86vm* = "libXxf86vm.so"
|
||||
|
||||
type
|
||||
PINT32* = ptr int32
|
||||
|
||||
const
|
||||
X_XF86VidModeQueryVersion* = 0
|
||||
X_XF86VidModeGetModeLine* = 1
|
||||
X_XF86VidModeModModeLine* = 2
|
||||
X_XF86VidModeSwitchMode* = 3
|
||||
X_XF86VidModeGetMonitor* = 4
|
||||
X_XF86VidModeLockModeSwitch* = 5
|
||||
X_XF86VidModeGetAllModeLines* = 6
|
||||
X_XF86VidModeAddModeLine* = 7
|
||||
X_XF86VidModeDeleteModeLine* = 8
|
||||
X_XF86VidModeValidateModeLine* = 9
|
||||
X_XF86VidModeSwitchToMode* = 10
|
||||
X_XF86VidModeGetViewPort* = 11
|
||||
X_XF86VidModeSetViewPort* = 12 # new for version 2.x of this extension
|
||||
X_XF86VidModeGetDotClocks* = 13
|
||||
X_XF86VidModeSetClientVersion* = 14
|
||||
X_XF86VidModeSetGamma* = 15
|
||||
X_XF86VidModeGetGamma* = 16
|
||||
X_XF86VidModeGetGammaRamp* = 17
|
||||
X_XF86VidModeSetGammaRamp* = 18
|
||||
X_XF86VidModeGetGammaRampSize* = 19
|
||||
X_XF86VidModeGetPermissions* = 20
|
||||
CLKFLAG_PROGRAMABLE* = 1
|
||||
|
||||
when defined(XF86VIDMODE_EVENTS):
|
||||
const
|
||||
XF86VidModeNotify* = 0
|
||||
XF86VidModeNumberEvents* = (XF86VidModeNotify + 1)
|
||||
XF86VidModeNotifyMask* = 0x00000001
|
||||
XF86VidModeNonEvent* = 0
|
||||
XF86VidModeModeChange* = 1
|
||||
else:
|
||||
const
|
||||
XF86VidModeNumberEvents* = 0
|
||||
const
|
||||
XF86VidModeBadClock* = 0
|
||||
XF86VidModeBadHTimings* = 1
|
||||
XF86VidModeBadVTimings* = 2
|
||||
XF86VidModeModeUnsuitable* = 3
|
||||
XF86VidModeExtensionDisabled* = 4
|
||||
XF86VidModeClientNotLocal* = 5
|
||||
XF86VidModeZoomLocked* = 6
|
||||
XF86VidModeNumberErrors* = (XF86VidModeZoomLocked + 1)
|
||||
XF86VM_READ_PERMISSION* = 1
|
||||
XF86VM_WRITE_PERMISSION* = 2
|
||||
|
||||
type
|
||||
PXF86VidModeModeLine* = ptr TXF86VidModeModeLine
|
||||
TXF86VidModeModeLine*{.final.} = object
|
||||
hdisplay*: cushort
|
||||
hsyncstart*: cushort
|
||||
hsyncend*: cushort
|
||||
htotal*: cushort
|
||||
hskew*: cushort
|
||||
vdisplay*: cushort
|
||||
vsyncstart*: cushort
|
||||
vsyncend*: cushort
|
||||
vtotal*: cushort
|
||||
flags*: cuint
|
||||
privsize*: cint
|
||||
c_private*: PINT32
|
||||
|
||||
PPPXF86VidModeModeInfo* = ptr PPXF86VidModeModeInfo
|
||||
PPXF86VidModeModeInfo* = ptr PXF86VidModeModeInfo
|
||||
PXF86VidModeModeInfo* = ptr TXF86VidModeModeInfo
|
||||
TXF86VidModeModeInfo*{.final.} = object
|
||||
dotclock*: cuint
|
||||
hdisplay*: cushort
|
||||
hsyncstart*: cushort
|
||||
hsyncend*: cushort
|
||||
htotal*: cushort
|
||||
hskew*: cushort
|
||||
vdisplay*: cushort
|
||||
vsyncstart*: cushort
|
||||
vsyncend*: cushort
|
||||
vtotal*: cushort
|
||||
flags*: cuint
|
||||
privsize*: cint
|
||||
c_private*: PINT32
|
||||
|
||||
PXF86VidModeSyncRange* = ptr TXF86VidModeSyncRange
|
||||
TXF86VidModeSyncRange*{.final.} = object
|
||||
hi*: cfloat
|
||||
lo*: cfloat
|
||||
|
||||
PXF86VidModeMonitor* = ptr TXF86VidModeMonitor
|
||||
TXF86VidModeMonitor*{.final.} = object
|
||||
vendor*: cstring
|
||||
model*: cstring
|
||||
EMPTY*: cfloat
|
||||
nhsync*: cuchar
|
||||
hsync*: PXF86VidModeSyncRange
|
||||
nvsync*: cuchar
|
||||
vsync*: PXF86VidModeSyncRange
|
||||
|
||||
PXF86VidModeNotifyEvent* = ptr TXF86VidModeNotifyEvent
|
||||
TXF86VidModeNotifyEvent*{.final.} = object
|
||||
theType*: cint # of event
|
||||
serial*: culong # # of last request processed by server
|
||||
send_event*: TBool # true if this came from a SendEvent req
|
||||
display*: PDisplay # Display the event was read from
|
||||
root*: TWindow # root window of event screen
|
||||
state*: cint # What happened
|
||||
kind*: cint # What happened
|
||||
forced*: TBool # extents of new region
|
||||
time*: TTime # event timestamp
|
||||
|
||||
PXF86VidModeGamma* = ptr TXF86VidModeGamma
|
||||
TXF86VidModeGamma*{.final.} = object
|
||||
red*: cfloat # Red Gamma value
|
||||
green*: cfloat # Green Gamma value
|
||||
blue*: cfloat # Blue Gamma value
|
||||
|
||||
|
||||
when defined(MACROS):
|
||||
proc XF86VidModeSelectNextMode*(disp: PDisplay, scr: cint): TBool
|
||||
proc XF86VidModeSelectPrevMode*(disp: PDisplay, scr: cint): TBool
|
||||
proc XF86VidModeQueryVersion*(dpy: PDisplay, majorVersion: Pcint,
|
||||
minorVersion: Pcint): TBool{.CDecl,
|
||||
dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeQueryExtension*(dpy: PDisplay, event_base: Pcint,
|
||||
error_base: Pcint): TBool{.CDecl,
|
||||
dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeSetClientVersion*(dpy: PDisplay): TBool{.CDecl,
|
||||
dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeGetModeLine*(dpy: PDisplay, screen: cint, dotclock: Pcint,
|
||||
modeline: PXF86VidModeModeLine): TBool{.CDecl,
|
||||
dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeGetAllModeLines*(dpy: PDisplay, screen: cint, modecount: Pcint,
|
||||
modelinesPtr: PPPXF86VidModeModeInfo): TBool{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeAddModeLine*(dpy: PDisplay, screen: cint,
|
||||
new_modeline: PXF86VidModeModeInfo,
|
||||
after_modeline: PXF86VidModeModeInfo): TBool{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeDeleteModeLine*(dpy: PDisplay, screen: cint,
|
||||
modeline: PXF86VidModeModeInfo): TBool{.CDecl,
|
||||
dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeModModeLine*(dpy: PDisplay, screen: cint,
|
||||
modeline: PXF86VidModeModeLine): TBool{.CDecl,
|
||||
dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeValidateModeLine*(dpy: PDisplay, screen: cint,
|
||||
modeline: PXF86VidModeModeInfo): TStatus{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeSwitchMode*(dpy: PDisplay, screen: cint, zoom: cint): TBool{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeSwitchToMode*(dpy: PDisplay, screen: cint,
|
||||
modeline: PXF86VidModeModeInfo): TBool{.CDecl,
|
||||
dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeLockModeSwitch*(dpy: PDisplay, screen: cint, lock: cint): TBool{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeGetMonitor*(dpy: PDisplay, screen: cint,
|
||||
monitor: PXF86VidModeMonitor): TBool{.CDecl,
|
||||
dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeGetViewPort*(dpy: PDisplay, screen: cint, x_return: Pcint,
|
||||
y_return: Pcint): TBool{.CDecl, dynlib: libXxf86vm,
|
||||
importc.}
|
||||
proc XF86VidModeSetViewPort*(dpy: PDisplay, screen: cint, x: cint, y: cint): TBool{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeGetDotClocks*(dpy: PDisplay, screen: cint, flags_return: Pcint,
|
||||
number_of_clocks_return: Pcint,
|
||||
max_dot_clock_return: Pcint, clocks_return: PPcint): TBool{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeGetGamma*(dpy: PDisplay, screen: cint, Gamma: PXF86VidModeGamma): TBool{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeSetGamma*(dpy: PDisplay, screen: cint, Gamma: PXF86VidModeGamma): TBool{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeSetGammaRamp*(dpy: PDisplay, screen: cint, size: cint,
|
||||
red_array: Pcushort, green_array: Pcushort,
|
||||
blue_array: Pcushort): TBool{.CDecl,
|
||||
dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeGetGammaRamp*(dpy: PDisplay, screen: cint, size: cint,
|
||||
red_array: Pcushort, green_array: Pcushort,
|
||||
blue_array: Pcushort): TBool{.CDecl,
|
||||
dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeGetGammaRampSize*(dpy: PDisplay, screen: cint, size: Pcint): TBool{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
proc XF86VidModeGetPermissions*(dpy: PDisplay, screen: cint, permissions: Pcint): TBool{.
|
||||
CDecl, dynlib: libXxf86vm, importc.}
|
||||
# implementation
|
||||
|
||||
when defined(MACROS):
|
||||
proc XF86VidModeSelectNextMode(disp: PDisplay, scr: cint): TBool =
|
||||
XF86VidModeSelectNextMode = XF86VidModeSwitchMode(disp, scr, 1)
|
||||
|
||||
proc XF86VidModeSelectPrevMode(disp: PDisplay, scr: cint): TBool =
|
||||
XF86VidModeSelectPrevMode = XF86VidModeSwitchMode(disp, scr, - 1)
|
||||
307
lib/base/x11/xi.nim
Normal file
307
lib/base/x11/xi.nim
Normal file
@@ -0,0 +1,307 @@
|
||||
#
|
||||
# $Xorg: XI.h,v 1.4 2001/02/09 02:03:23 xorgcvs Exp $
|
||||
#
|
||||
#************************************************************
|
||||
#
|
||||
#Copyright 1989, 1998 The Open Group
|
||||
#
|
||||
#Permission to use, copy, modify, distribute, and sell this software and its
|
||||
#documentation for any purpose is hereby granted without fee, provided that
|
||||
#the above copyright notice appear in all copies and that both that
|
||||
#copyright notice and this permission notice appear in supporting
|
||||
#documentation.
|
||||
#
|
||||
#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
|
||||
#OPEN GROUP 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.
|
||||
#
|
||||
#Except as contained in this notice, the name of The Open Group shall not be
|
||||
#used in advertising or otherwise to promote the sale, use or other dealings
|
||||
#in this Software without prior written authorization from The Open Group.
|
||||
#
|
||||
#Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
#Permission to use, copy, modify, and distribute this software and its
|
||||
#documentation for any purpose and without fee is hereby granted,
|
||||
#provided that the above copyright notice appear in all copies and that
|
||||
#both that copyright notice and this permission notice appear in
|
||||
#supporting documentation, and that the name of Hewlett-Packard not be
|
||||
#used in advertising or publicity pertaining to distribution of the
|
||||
#software without specific, written prior permission.
|
||||
#
|
||||
#HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
#HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
#SOFTWARE.
|
||||
#
|
||||
#********************************************************/
|
||||
# $XFree86: xc/include/extensions/XI.h,v 1.5 2001/12/14 19:53:28 dawes Exp $
|
||||
#
|
||||
# Definitions used by the server, library and client
|
||||
#
|
||||
# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
|
||||
#
|
||||
#Histroy:
|
||||
# 2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and chnaged it to
|
||||
# "reocrd" only.
|
||||
# 2004/10/07 - Removed the "uses X;" line. The unit does not need it.
|
||||
# 2004/10/03 - Conversion from C header to Pascal unit.
|
||||
#
|
||||
|
||||
const
|
||||
sz_xGetExtensionVersionReq* = 8
|
||||
sz_xGetExtensionVersionReply* = 32
|
||||
sz_xListInputDevicesReq* = 4
|
||||
sz_xListInputDevicesReply* = 32
|
||||
sz_xOpenDeviceReq* = 8
|
||||
sz_xOpenDeviceReply* = 32
|
||||
sz_xCloseDeviceReq* = 8
|
||||
sz_xSetDeviceModeReq* = 8
|
||||
sz_xSetDeviceModeReply* = 32
|
||||
sz_xSelectExtensionEventReq* = 12
|
||||
sz_xGetSelectedExtensionEventsReq* = 8
|
||||
sz_xGetSelectedExtensionEventsReply* = 32
|
||||
sz_xChangeDeviceDontPropagateListReq* = 12
|
||||
sz_xGetDeviceDontPropagateListReq* = 8
|
||||
sz_xGetDeviceDontPropagateListReply* = 32
|
||||
sz_xGetDeviceMotionEventsReq* = 16
|
||||
sz_xGetDeviceMotionEventsReply* = 32
|
||||
sz_xChangeKeyboardDeviceReq* = 8
|
||||
sz_xChangeKeyboardDeviceReply* = 32
|
||||
sz_xChangePointerDeviceReq* = 8
|
||||
sz_xChangePointerDeviceReply* = 32
|
||||
sz_xGrabDeviceReq* = 20
|
||||
sz_xGrabDeviceReply* = 32
|
||||
sz_xUngrabDeviceReq* = 12
|
||||
sz_xGrabDeviceKeyReq* = 20
|
||||
sz_xGrabDeviceKeyReply* = 32
|
||||
sz_xUngrabDeviceKeyReq* = 16
|
||||
sz_xGrabDeviceButtonReq* = 20
|
||||
sz_xGrabDeviceButtonReply* = 32
|
||||
sz_xUngrabDeviceButtonReq* = 16
|
||||
sz_xAllowDeviceEventsReq* = 12
|
||||
sz_xGetDeviceFocusReq* = 8
|
||||
sz_xGetDeviceFocusReply* = 32
|
||||
sz_xSetDeviceFocusReq* = 16
|
||||
sz_xGetFeedbackControlReq* = 8
|
||||
sz_xGetFeedbackControlReply* = 32
|
||||
sz_xChangeFeedbackControlReq* = 12
|
||||
sz_xGetDeviceKeyMappingReq* = 8
|
||||
sz_xGetDeviceKeyMappingReply* = 32
|
||||
sz_xChangeDeviceKeyMappingReq* = 8
|
||||
sz_xGetDeviceModifierMappingReq* = 8
|
||||
sz_xSetDeviceModifierMappingReq* = 8
|
||||
sz_xSetDeviceModifierMappingReply* = 32
|
||||
sz_xGetDeviceButtonMappingReq* = 8
|
||||
sz_xGetDeviceButtonMappingReply* = 32
|
||||
sz_xSetDeviceButtonMappingReq* = 8
|
||||
sz_xSetDeviceButtonMappingReply* = 32
|
||||
sz_xQueryDeviceStateReq* = 8
|
||||
sz_xQueryDeviceStateReply* = 32
|
||||
sz_xSendExtensionEventReq* = 16
|
||||
sz_xDeviceBellReq* = 8
|
||||
sz_xSetDeviceValuatorsReq* = 8
|
||||
sz_xSetDeviceValuatorsReply* = 32
|
||||
sz_xGetDeviceControlReq* = 8
|
||||
sz_xGetDeviceControlReply* = 32
|
||||
sz_xChangeDeviceControlReq* = 8
|
||||
sz_xChangeDeviceControlReply* = 32
|
||||
|
||||
const
|
||||
INAME* = "XInputExtension"
|
||||
|
||||
const
|
||||
XI_KEYBOARD* = "KEYBOARD"
|
||||
XI_MOUSE* = "MOUSE"
|
||||
XI_TABLET* = "TABLET"
|
||||
XI_TOUCHSCREEN* = "TOUCHSCREEN"
|
||||
XI_TOUCHPAD* = "TOUCHPAD"
|
||||
XI_BARCODE* = "BARCODE"
|
||||
XI_BUTTONBOX* = "BUTTONBOX"
|
||||
XI_KNOB_BOX* = "KNOB_BOX"
|
||||
XI_ONE_KNOB* = "ONE_KNOB"
|
||||
XI_NINE_KNOB* = "NINE_KNOB"
|
||||
XI_TRACKBALL* = "TRACKBALL"
|
||||
XI_QUADRATURE* = "QUADRATURE"
|
||||
XI_ID_MODULE* = "ID_MODULE"
|
||||
XI_SPACEBALL* = "SPACEBALL"
|
||||
XI_DATAGLOVE* = "DATAGLOVE"
|
||||
XI_EYETRACKER* = "EYETRACKER"
|
||||
XI_CURSORKEYS* = "CURSORKEYS"
|
||||
XI_FOOTMOUSE* = "FOOTMOUSE"
|
||||
|
||||
const
|
||||
Dont_Check* = 0
|
||||
XInput_Initial_Release* = 1
|
||||
XInput_Add_XDeviceBell* = 2
|
||||
XInput_Add_XSetDeviceValuators* = 3
|
||||
XInput_Add_XChangeDeviceControl* = 4
|
||||
|
||||
const
|
||||
XI_Absent* = 0
|
||||
XI_Present* = 1
|
||||
|
||||
const
|
||||
XI_Initial_Release_Major* = 1
|
||||
XI_Initial_Release_Minor* = 0
|
||||
|
||||
const
|
||||
XI_Add_XDeviceBell_Major* = 1
|
||||
XI_Add_XDeviceBell_Minor* = 1
|
||||
|
||||
const
|
||||
XI_Add_XSetDeviceValuators_Major* = 1
|
||||
XI_Add_XSetDeviceValuators_Minor* = 2
|
||||
|
||||
const
|
||||
XI_Add_XChangeDeviceControl_Major* = 1
|
||||
XI_Add_XChangeDeviceControl_Minor* = 3
|
||||
|
||||
const
|
||||
DEVICE_RESOLUTION* = 1
|
||||
|
||||
const
|
||||
NoSuchExtension* = 1
|
||||
|
||||
const
|
||||
COUNT* = 0
|
||||
CREATE* = 1
|
||||
|
||||
const
|
||||
NewPointer* = 0
|
||||
NewKeyboard* = 1
|
||||
|
||||
const
|
||||
XPOINTER* = 0
|
||||
XKEYBOARD* = 1
|
||||
|
||||
const
|
||||
UseXKeyboard* = 0x000000FF
|
||||
|
||||
const
|
||||
IsXPointer* = 0
|
||||
IsXKeyboard* = 1
|
||||
IsXExtensionDevice* = 2
|
||||
|
||||
const
|
||||
AsyncThisDevice* = 0
|
||||
SyncThisDevice* = 1
|
||||
ReplayThisDevice* = 2
|
||||
AsyncOtherDevices* = 3
|
||||
AsyncAll* = 4
|
||||
SyncAll* = 5
|
||||
|
||||
const
|
||||
FollowKeyboard* = 3
|
||||
RevertToFollowKeyboard* = 3
|
||||
|
||||
const
|
||||
DvAccelNum* = int(1) shl 0
|
||||
DvAccelDenom* = int(1) shl 1
|
||||
DvThreshold* = int(1) shl 2
|
||||
|
||||
const
|
||||
DvKeyClickPercent* = int(1) shl 0
|
||||
DvPercent* = int(1) shl 1
|
||||
DvPitch* = int(1) shl 2
|
||||
DvDuration* = int(1) shl 3
|
||||
DvLed* = int(1) shl 4
|
||||
DvLedMode* = int(1) shl 5
|
||||
DvKey* = int(1) shl 6
|
||||
DvAutoRepeatMode* = int(1) shl 7
|
||||
|
||||
const
|
||||
DvString* = int(1) shl 0
|
||||
|
||||
const
|
||||
DvInteger* = int(1) shl 0
|
||||
|
||||
const
|
||||
DeviceMode* = int(1) shl 0
|
||||
Relative* = 0
|
||||
Absolute* = 1 # Merged from Metrolink tree for XINPUT stuff
|
||||
TS_Raw* = 57
|
||||
TS_Scaled* = 58
|
||||
SendCoreEvents* = 59
|
||||
DontSendCoreEvents* = 60 # End of merged section
|
||||
|
||||
const
|
||||
ProximityState* = int(1) shl 1
|
||||
InProximity* = int(0) shl 1
|
||||
OutOfProximity* = int(1) shl 1
|
||||
|
||||
const
|
||||
AddToList* = 0
|
||||
DeleteFromList* = 1
|
||||
|
||||
const
|
||||
KeyClass* = 0
|
||||
ButtonClass* = 1
|
||||
ValuatorClass* = 2
|
||||
FeedbackClass* = 3
|
||||
ProximityClass* = 4
|
||||
FocusClass* = 5
|
||||
OtherClass* = 6
|
||||
|
||||
const
|
||||
KbdFeedbackClass* = 0
|
||||
PtrFeedbackClass* = 1
|
||||
StringFeedbackClass* = 2
|
||||
IntegerFeedbackClass* = 3
|
||||
LedFeedbackClass* = 4
|
||||
BellFeedbackClass* = 5
|
||||
|
||||
const
|
||||
devicePointerMotionHint* = 0
|
||||
deviceButton1Motion* = 1
|
||||
deviceButton2Motion* = 2
|
||||
deviceButton3Motion* = 3
|
||||
deviceButton4Motion* = 4
|
||||
deviceButton5Motion* = 5
|
||||
deviceButtonMotion* = 6
|
||||
deviceButtonGrab* = 7
|
||||
deviceOwnerGrabButton* = 8
|
||||
noExtensionEvent* = 9
|
||||
|
||||
const
|
||||
XI_BadDevice* = 0
|
||||
XI_BadEvent* = 1
|
||||
XI_BadMode* = 2
|
||||
XI_DeviceBusy* = 3
|
||||
XI_BadClass* = 4 # Make XEventClass be a CARD32 for 64 bit servers. Don't affect client
|
||||
# definition of XEventClass since that would be a library interface change.
|
||||
# See the top of X.h for more _XSERVER64 magic.
|
||||
#
|
||||
|
||||
when defined(XSERVER64):
|
||||
type
|
||||
XEventClass* = CARD32
|
||||
else:
|
||||
type
|
||||
XEventClass* = int32
|
||||
#******************************************************************
|
||||
# *
|
||||
# * Extension version structure.
|
||||
# *
|
||||
#
|
||||
|
||||
type
|
||||
PXExtensionVersion* = ptr TXExtensionVersion
|
||||
TXExtensionVersion*{.final.} = object
|
||||
present*: int16
|
||||
major_version*: int16
|
||||
minor_version*: int16
|
||||
|
||||
|
||||
# implementation
|
||||
25
lib/base/x11/xinerama.nim
Normal file
25
lib/base/x11/xinerama.nim
Normal file
@@ -0,0 +1,25 @@
|
||||
# Converted from X11/Xinerama.h
|
||||
import
|
||||
xlib
|
||||
|
||||
const
|
||||
xineramaLib = "libXinerama.so"
|
||||
|
||||
type
|
||||
PXineramaScreenInfo* = ptr TXineramaScreenInfo
|
||||
TXineramaScreenInfo*{.final.} = object
|
||||
screen_number*: cint
|
||||
x_org*: int16
|
||||
y_org*: int16
|
||||
width*: int16
|
||||
height*: int16
|
||||
|
||||
|
||||
proc XineramaQueryExtension*(dpy: PDisplay, event_base: Pcint, error_base: Pcint): TBool{.
|
||||
cdecl, dynlib: xineramaLib, importc.}
|
||||
proc XineramaQueryVersion*(dpy: PDisplay, major: Pcint, minor: Pcint): TStatus{.
|
||||
cdecl, dynlib: xineramaLib, importc.}
|
||||
proc XineramaIsActive*(dpy: PDisplay): TBool{.cdecl, dynlib: xineramaLib, importc.}
|
||||
proc XineramaQueryScreens*(dpy: PDisplay, number: Pcint): PXineramaScreenInfo{.
|
||||
cdecl, dynlib: xineramaLib, importc.}
|
||||
|
||||
2409
lib/base/x11/xkb.nim
Normal file
2409
lib/base/x11/xkb.nim
Normal file
File diff suppressed because it is too large
Load Diff
699
lib/base/x11/xkblib.nim
Normal file
699
lib/base/x11/xkblib.nim
Normal file
@@ -0,0 +1,699 @@
|
||||
# $Xorg: XKBlib.h,v 1.6 2000/08/17 19:45:03 cpqbld Exp $
|
||||
#************************************************************
|
||||
#Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
|
||||
#
|
||||
#Permission to use, copy, modify, and distribute this
|
||||
#software and its documentation for any purpose and without
|
||||
#fee is hereby granted, provided that the above copyright
|
||||
#notice appear in all copies and that both that copyright
|
||||
#notice and this permission notice appear in supporting
|
||||
#documentation, and that the name of Silicon Graphics not be
|
||||
#used in advertising or publicity pertaining to distribution
|
||||
#of the software without specific prior written permission.
|
||||
#Silicon Graphics makes no representation about the suitability
|
||||
#of this software for any purpose. It is provided "as is"
|
||||
#without any express or implied warranty.
|
||||
#
|
||||
#SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
#SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
#AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||
#GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
||||
#DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING `from` LOSS OF USE,
|
||||
#DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
#OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
|
||||
#THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
#********************************************************/
|
||||
# $XFree86: xc/lib/X11/XKBlib.h,v 3.3 2001/08/01 00:44:38 tsi Exp $
|
||||
#
|
||||
# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
|
||||
#
|
||||
#Thanks:
|
||||
# I want to thanks to oliebol for putting up with all of the problems that was found
|
||||
# while translating this code. ;)
|
||||
#
|
||||
# I want to thanks #fpc channel in freenode irc, for helping me, and to put up with my
|
||||
# wierd questions ;)
|
||||
#
|
||||
# Thanks for mmc in #xlib on freenode irc And so for the channel itself for the helping me to
|
||||
# understanding some of the problems I had converting this headers and pointing me to resources
|
||||
# that helped translating this headers.
|
||||
#
|
||||
# Ido
|
||||
#
|
||||
#History:
|
||||
# 2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and
|
||||
# chnaged it to "reocrd" only.
|
||||
# 2004/10/10 - Added to TXkbGetAtomNameFunc and TXkbInternAtomFunc the cdecl call.
|
||||
# 2004/10/06 - 09 - Convertion `from` the c header of XKBlib.h
|
||||
#
|
||||
#
|
||||
|
||||
import
|
||||
X, Xlib, XKB
|
||||
|
||||
type
|
||||
PXkbAnyEvent* = ptr TXkbAnyEvent
|
||||
TXkbAnyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds;
|
||||
xkb_type*: int16 # XKB event minor code
|
||||
device*: int16 # device ID
|
||||
|
||||
|
||||
type
|
||||
PXkbNewKeyboardNotifyEvent* = ptr TXkbNewKeyboardNotifyEvent
|
||||
TXkbNewKeyboardNotifyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbNewKeyboardNotify
|
||||
device*: int16 # device ID
|
||||
old_device*: int16 # device ID of previous keyboard
|
||||
min_key_code*: int16 # minimum key code
|
||||
max_key_code*: int16 # maximum key code
|
||||
old_min_key_code*: int16 # min key code of previous kbd
|
||||
old_max_key_code*: int16 # max key code of previous kbd
|
||||
changed*: int16 # changed aspects of the keyboard
|
||||
req_major*: int8 # major and minor opcode of req
|
||||
req_minor*: int8 # that caused change, if applicable
|
||||
|
||||
|
||||
type
|
||||
PXkbMapNotifyEvent* = ptr TXkbMapNotifyEvent
|
||||
TXkbMapNotifyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbMapNotify
|
||||
device*: int16 # device ID
|
||||
changed*: int16 # fields which have been changed
|
||||
flags*: int16 # reserved
|
||||
first_type*: int16 # first changed key type
|
||||
num_types*: int16 # number of changed key types
|
||||
min_key_code*: TKeyCode
|
||||
max_key_code*: TKeyCode
|
||||
first_key_sym*: TKeyCode
|
||||
first_key_act*: TKeyCode
|
||||
first_key_behavior*: TKeyCode
|
||||
first_key_explicit*: TKeyCode
|
||||
first_modmap_key*: TKeyCode
|
||||
first_vmodmap_key*: TKeyCode
|
||||
num_key_syms*: int16
|
||||
num_key_acts*: int16
|
||||
num_key_behaviors*: int16
|
||||
num_key_explicit*: int16
|
||||
num_modmap_keys*: int16
|
||||
num_vmodmap_keys*: int16
|
||||
vmods*: int16 # mask of changed virtual mods
|
||||
|
||||
|
||||
type
|
||||
PXkbStateNotifyEvent* = ptr TXkbStateNotifyEvent
|
||||
TXkbStateNotifyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbStateNotify
|
||||
device*: int16 # device ID
|
||||
changed*: int16 # mask of changed state components
|
||||
group*: int16 # keyboard group
|
||||
base_group*: int16 # base keyboard group
|
||||
latched_group*: int16 # latched keyboard group
|
||||
locked_group*: int16 # locked keyboard group
|
||||
mods*: int16 # modifier state
|
||||
base_mods*: int16 # base modifier state
|
||||
latched_mods*: int16 # latched modifiers
|
||||
locked_mods*: int16 # locked modifiers
|
||||
compat_state*: int16 # compatibility state
|
||||
grab_mods*: int8 # mods used for grabs
|
||||
compat_grab_mods*: int8 # grab mods for non-XKB clients
|
||||
lookup_mods*: int8 # mods sent to clients
|
||||
compat_lookup_mods*: int8 # mods sent to non-XKB clients
|
||||
ptr_buttons*: int16 # pointer button state
|
||||
keycode*: TKeyCode # keycode that caused the change
|
||||
event_type*: int8 # KeyPress or KeyRelease
|
||||
req_major*: int8 # Major opcode of request
|
||||
req_minor*: int8 # Minor opcode of request
|
||||
|
||||
|
||||
type
|
||||
PXkbControlsNotifyEvent* = ptr TXkbControlsNotifyEvent
|
||||
TXkbControlsNotifyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbControlsNotify
|
||||
device*: int16 # device ID
|
||||
changed_ctrls*: int16 # controls with changed sub-values
|
||||
enabled_ctrls*: int16 # controls currently enabled
|
||||
enabled_ctrl_changes*: int16 # controls just {en,dis}abled
|
||||
num_groups*: int16 # total groups on keyboard
|
||||
keycode*: TKeyCode # key that caused change or 0
|
||||
event_type*: int8 # type of event that caused change
|
||||
req_major*: int8 # if keycode==0, major and minor
|
||||
req_minor*: int8 # opcode of req that caused change
|
||||
|
||||
|
||||
type
|
||||
PXkbIndicatorNotifyEvent* = ptr TXkbIndicatorNotifyEvent
|
||||
TXkbIndicatorNotifyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbIndicatorNotify
|
||||
device*: int16 # device
|
||||
changed*: int16 # indicators with new state or map
|
||||
state*: int16 # current state of all indicators
|
||||
|
||||
|
||||
type
|
||||
PXkbNamesNotifyEvent* = ptr TXkbNamesNotifyEvent
|
||||
TXkbNamesNotifyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbNamesNotify
|
||||
device*: int16 # device ID
|
||||
changed*: int32 # names that have changed
|
||||
first_type*: int16 # first key type with new name
|
||||
num_types*: int16 # number of key types with new names
|
||||
first_lvl*: int16 # first key type new new level names
|
||||
num_lvls*: int16 # # of key types w/new level names
|
||||
num_aliases*: int16 # total number of key aliases
|
||||
num_radio_groups*: int16 # total number of radio groups
|
||||
changed_vmods*: int16 # virtual modifiers with new names
|
||||
changed_groups*: int16 # groups with new names
|
||||
changed_indicators*: int16 # indicators with new names
|
||||
first_key*: int16 # first key with new name
|
||||
num_keys*: int16 # number of keys with new names
|
||||
|
||||
|
||||
type
|
||||
PXkbCompatMapNotifyEvent* = ptr TXkbCompatMapNotifyEvent
|
||||
TXkbCompatMapNotifyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbCompatMapNotify
|
||||
device*: int16 # device ID
|
||||
changed_groups*: int16 # groups with new compat maps
|
||||
first_si*: int16 # first new symbol interp
|
||||
num_si*: int16 # number of new symbol interps
|
||||
num_total_si*: int16 # total # of symbol interps
|
||||
|
||||
|
||||
type
|
||||
PXkbBellNotifyEvent* = ptr TXkbBellNotifyEvent
|
||||
TXkbBellNotifyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbBellNotify
|
||||
device*: int16 # device ID
|
||||
percent*: int16 # requested volume as a % of maximum
|
||||
pitch*: int16 # requested pitch in Hz
|
||||
duration*: int16 # requested duration in useconds
|
||||
bell_class*: int16 # (input extension) feedback class
|
||||
bell_id*: int16 # (input extension) ID of feedback
|
||||
name*: TAtom # "name" of requested bell
|
||||
window*: TWindow # window associated with event
|
||||
event_only*: bool # "event only" requested
|
||||
|
||||
|
||||
type
|
||||
PXkbActionMessageEvent* = ptr TXkbActionMessageEvent
|
||||
TXkbActionMessageEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbActionMessage
|
||||
device*: int16 # device ID
|
||||
keycode*: TKeyCode # key that generated the event
|
||||
press*: bool # true if act caused by key press
|
||||
key_event_follows*: bool # true if key event also generated
|
||||
group*: int16 # effective group
|
||||
mods*: int16 # effective mods
|
||||
message*: array[0..XkbActionMessageLength, Char] # message -- leave space for NUL
|
||||
|
||||
|
||||
type
|
||||
PXkbAccessXNotifyEvent* = ptr TXkbAccessXNotifyEvent
|
||||
TXkbAccessXNotifyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbAccessXNotify
|
||||
device*: int16 # device ID
|
||||
detail*: int16 # XkbAXN_*
|
||||
keycode*: int16 # key of event
|
||||
sk_delay*: int16 # current slow keys delay
|
||||
debounce_delay*: int16 # current debounce delay
|
||||
|
||||
|
||||
type
|
||||
PXkbExtensionDeviceNotifyEvent* = ptr TXkbExtensionDeviceNotifyEvent
|
||||
TXkbExtensionDeviceNotifyEvent*{.final.} = object
|
||||
theType*: int16 # XkbAnyEvent
|
||||
serial*: int32 # of last req processed by server
|
||||
send_event*: bool # is this `from` a SendEvent request?
|
||||
display*: PDisplay # Display the event was read `from`
|
||||
time*: TTime # milliseconds
|
||||
xkb_type*: int16 # XkbExtensionDeviceNotify
|
||||
device*: int16 # device ID
|
||||
reason*: int16 # reason for the event
|
||||
supported*: int16 # mask of supported features
|
||||
unsupported*: int16 # mask of unsupported features
|
||||
# that some app tried to use
|
||||
first_btn*: int16 # first button that changed
|
||||
num_btns*: int16 # range of buttons changed
|
||||
leds_defined*: int16 # indicators with names or maps
|
||||
led_state*: int16 # current state of the indicators
|
||||
led_class*: int16 # feedback class for led changes
|
||||
led_id*: int16 # feedback id for led changes
|
||||
|
||||
|
||||
type
|
||||
PXkbEvent* = ptr TXkbEvent
|
||||
TXkbEvent*{.final.} = object
|
||||
theType*: int16
|
||||
any*: TXkbAnyEvent
|
||||
new_kbd*: TXkbNewKeyboardNotifyEvent
|
||||
map*: TXkbMapNotifyEvent
|
||||
state*: TXkbStateNotifyEvent
|
||||
ctrls*: TXkbControlsNotifyEvent
|
||||
indicators*: TXkbIndicatorNotifyEvent
|
||||
names*: TXkbNamesNotifyEvent
|
||||
compat*: TXkbCompatMapNotifyEvent
|
||||
bell*: TXkbBellNotifyEvent
|
||||
message*: TXkbActionMessageEvent
|
||||
accessx*: TXkbAccessXNotifyEvent
|
||||
device*: TXkbExtensionDeviceNotifyEvent
|
||||
core*: TXEvent
|
||||
|
||||
|
||||
type
|
||||
PXkbKbdDpyStatePtr* = ptr TXkbKbdDpyStateRec
|
||||
TXkbKbdDpyStateRec*{.final.} = object # XkbOpenDisplay error codes
|
||||
|
||||
const
|
||||
XkbOD_Success* = 0
|
||||
XkbOD_BadLibraryVersion* = 1
|
||||
XkbOD_ConnectionRefused* = 2
|
||||
XkbOD_NonXkbServer* = 3
|
||||
XkbOD_BadServerVersion* = 4 # Values for XlibFlags
|
||||
|
||||
const
|
||||
XkbLC_ForceLatin1Lookup* = 1 shl 0
|
||||
XkbLC_ConsumeLookupMods* = 1 shl 1
|
||||
XkbLC_AlwaysConsumeShiftAndLock* = 1 shl 2
|
||||
XkbLC_IgnoreNewKeyboards* = 1 shl 3
|
||||
XkbLC_ControlFallback* = 1 shl 4
|
||||
XkbLC_ConsumeKeysOnComposeFail* = 1 shl 29
|
||||
XkbLC_ComposeLED* = 1 shl 30
|
||||
XkbLC_BeepOnComposeFail* = 1 shl 31
|
||||
XkbLC_AllComposeControls* = 0xC0000000
|
||||
XkbLC_AllControls* = 0xC000001F
|
||||
|
||||
proc XkbIgnoreExtension*(ignore: bool): bool{.cdecl, dynlib: libX11,
|
||||
importc: "XkbIgnoreExtension".}
|
||||
proc XkbOpenDisplay*(name: cstring, ev_rtrn, err_rtrn, major_rtrn, minor_rtrn,
|
||||
reason: ptr int16): PDisplay{.cdecl,
|
||||
dynlib: libX11, importc: "XkbOpenDisplay".}
|
||||
proc XkbQueryExtension*(dpy: PDisplay, opcodeReturn, eventBaseReturn,
|
||||
errorBaseReturn, majorRtrn, minorRtrn: ptr int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbQueryExtension".}
|
||||
proc XkbUseExtension*(dpy: PDisplay, major_rtrn, minor_rtrn: ptr int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbUseExtension".}
|
||||
proc XkbLibraryVersion*(libMajorRtrn, libMinorRtrn: ptr int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbLibraryVersion".}
|
||||
proc XkbSetXlibControls*(dpy: PDisplay, affect, values: int16): int16{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetXlibControls".}
|
||||
proc XkbGetXlibControls*(dpy: PDisplay): int16{.cdecl, dynlib: libX11,
|
||||
importc: "XkbGetXlibControls".}
|
||||
type
|
||||
TXkbInternAtomFunc* = proc (dpy: PDisplay, name: cstring, only_if_exists: bool): TAtom{.
|
||||
cdecl.}
|
||||
|
||||
type
|
||||
TXkbGetAtomNameFunc* = proc (dpy: PDisplay, atom: TAtom): cstring{.cdecl.}
|
||||
|
||||
proc XkbSetAtomFuncs*(getAtom: TXkbInternAtomFunc, getName: TXkbGetAtomNameFunc){.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetAtomFuncs".}
|
||||
proc XkbKeycodeToKeysym*(dpy: PDisplay, kc: TKeyCode, group, level: int16): TKeySym{.
|
||||
cdecl, dynlib: libX11, importc: "XkbKeycodeToKeysym".}
|
||||
proc XkbKeysymToModifiers*(dpy: PDisplay, ks: TKeySym): int16{.cdecl,
|
||||
dynlib: libX11, importc: "XkbKeysymToModifiers".}
|
||||
proc XkbLookupKeySym*(dpy: PDisplay, keycode: TKeyCode,
|
||||
modifiers, modifiers_return: int16, keysym_return: PKeySym): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbLookupKeySym".}
|
||||
proc XkbLookupKeyBinding*(dpy: PDisplay, sym_rtrn: TKeySym, mods: int16,
|
||||
buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
|
||||
cdecl, dynlib: libX11, importc: "XkbLookupKeyBinding".}
|
||||
proc XkbTranslateKeyCode*(xkb: PXkbDescPtr, keycode: TKeyCode,
|
||||
modifiers, modifiers_return: int16,
|
||||
keysym_return: PKeySym): bool{.cdecl, dynlib: libX11,
|
||||
importc: "XkbTranslateKeyCode".}
|
||||
proc XkbTranslateKeySym*(dpy: PDisplay, sym_return: TKeySym, modifiers: int16,
|
||||
buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
|
||||
cdecl, dynlib: libX11, importc: "XkbTranslateKeySym".}
|
||||
proc XkbSetAutoRepeatRate*(dpy: PDisplay, deviceSpec, delay, interval: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetAutoRepeatRate".}
|
||||
proc XkbGetAutoRepeatRate*(dpy: PDisplay, deviceSpec: int16,
|
||||
delayRtrn, intervalRtrn: PWord): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetAutoRepeatRate".}
|
||||
proc XkbChangeEnabledControls*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbChangeEnabledControls".}
|
||||
proc XkbDeviceBell*(dpy: PDisplay, win: TWindow,
|
||||
deviceSpec, bellClass, bellID, percent: int16, name: TAtom): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbDeviceBell".}
|
||||
proc XkbForceDeviceBell*(dpy: PDisplay,
|
||||
deviceSpec, bellClass, bellID, percent: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbForceDeviceBell".}
|
||||
proc XkbDeviceBellEvent*(dpy: PDisplay, win: TWindow,
|
||||
deviceSpec, bellClass, bellID, percent: int16,
|
||||
name: TAtom): bool{.cdecl, dynlib: libX11,
|
||||
importc: "XkbDeviceBellEvent".}
|
||||
proc XkbBell*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbBell".}
|
||||
proc XkbForceBell*(dpy: PDisplay, percent: int16): bool{.cdecl, dynlib: libX11,
|
||||
importc: "XkbForceBell".}
|
||||
proc XkbBellEvent*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbBellEvent".}
|
||||
proc XkbSelectEvents*(dpy: PDisplay, deviceID, affect, values: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSelectEvents".}
|
||||
proc XkbSelectEventDetails*(dpy: PDisplay, deviceID, eventType: int16,
|
||||
affect, details: int32): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSelectEventDetails".}
|
||||
proc XkbNoteMapChanges*(old: PXkbMapChangesPtr, new: PXkbMapNotifyEvent,
|
||||
wanted: int16){.cdecl, dynlib: libX11,
|
||||
importc: "XkbNoteMapChanges".}
|
||||
proc XkbNoteNameChanges*(old: PXkbNameChangesPtr, new: PXkbNamesNotifyEvent,
|
||||
wanted: int16){.cdecl, dynlib: libX11,
|
||||
importc: "XkbNoteNameChanges".}
|
||||
proc XkbGetIndicatorState*(dpy: PDisplay, deviceSpec: int16, pStateRtrn: PWord): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetIndicatorState".}
|
||||
proc XkbGetDeviceIndicatorState*(dpy: PDisplay,
|
||||
deviceSpec, ledClass, ledID: int16,
|
||||
pStateRtrn: PWord): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetDeviceIndicatorState".}
|
||||
proc XkbGetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetIndicatorMap".}
|
||||
proc XkbSetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetIndicatorMap".}
|
||||
proc XkbNoteIndicatorMapChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
|
||||
proc XkbNoteIndicatorStateChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
|
||||
proc XkbGetIndicatorMapChanges*(d: PDisplay, x: PXkbDescPtr,
|
||||
c: PXkbIndicatorChangesPtr): TStatus
|
||||
proc XkbChangeIndicatorMaps*(d: PDisplay, x: PXkbDescPtr,
|
||||
c: PXkbIndicatorChangesPtr): bool
|
||||
proc XkbGetNamedIndicator*(dpy: PDisplay, name: TAtom, pNdxRtrn: ptr int16,
|
||||
pStateRtrn: ptr bool, pMapRtrn: PXkbIndicatorMapPtr,
|
||||
pRealRtrn: ptr bool): bool{.cdecl, dynlib: libX11,
|
||||
importc: "XkbGetNamedIndicator".}
|
||||
proc XkbGetNamedDeviceIndicator*(dpy: PDisplay,
|
||||
deviceSpec, ledClass, ledID: int16,
|
||||
name: TAtom, pNdxRtrn: ptr int16,
|
||||
pStateRtrn: ptr bool,
|
||||
pMapRtrn: PXkbIndicatorMapPtr,
|
||||
pRealRtrn: ptr bool): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetNamedDeviceIndicator".}
|
||||
proc XkbSetNamedIndicator*(dpy: PDisplay, name: TAtom,
|
||||
changeState, state, createNewMap: bool,
|
||||
pMap: PXkbIndicatorMapPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetNamedIndicator".}
|
||||
proc XkbSetNamedDeviceIndicator*(dpy: PDisplay,
|
||||
deviceSpec, ledClass, ledID: int16,
|
||||
name: TAtom,
|
||||
changeState, state, createNewMap: bool,
|
||||
pMap: PXkbIndicatorMapPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetNamedDeviceIndicator".}
|
||||
proc XkbLockModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbLockModifiers".}
|
||||
proc XkbLatchModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbLatchModifiers".}
|
||||
proc XkbLockGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbLockGroup".}
|
||||
proc XkbLatchGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbLatchGroup".}
|
||||
proc XkbSetServerInternalMods*(dpy: PDisplay, deviceSpec, affectReal,
|
||||
realValues, affectVirtual, virtualValues: int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetServerInternalMods".}
|
||||
proc XkbSetIgnoreLockMods*(dpy: PDisplay, deviceSpec, affectReal, realValues,
|
||||
affectVirtual, virtualValues: int16): bool{.cdecl, dynlib: libX11,
|
||||
importc: "XkbSetIgnoreLockMods".}
|
||||
proc XkbVirtualModsToReal*(dpy: PDisplay, virtual_mask: int16, mask_rtrn: PWord): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbVirtualModsToReal".}
|
||||
proc XkbComputeEffectiveMap*(xkb: PXkbDescPtr, theType: PXkbKeyTypePtr,
|
||||
map_rtrn: PByte): bool{.cdecl, dynlib: libX11,
|
||||
importc: "XkbComputeEffectiveMap".}
|
||||
proc XkbInitCanonicalKeyTypes*(xkb: PXkbDescPtr, which: int16, keypadVMod: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbInitCanonicalKeyTypes".}
|
||||
proc XkbAllocKeyboard*(): PXkbDescPtr{.cdecl, dynlib: libX11,
|
||||
importc: "XkbAllocKeyboard".}
|
||||
proc XkbFreeKeyboard*(xkb: PXkbDescPtr, which: int16, freeDesc: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeKeyboard".}
|
||||
proc XkbAllocClientMap*(xkb: PXkbDescPtr, which, nTypes: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocClientMap".}
|
||||
proc XkbAllocServerMap*(xkb: PXkbDescPtr, which, nActions: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocServerMap".}
|
||||
proc XkbFreeClientMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeClientMap".}
|
||||
proc XkbFreeServerMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeServerMap".}
|
||||
proc XkbAddKeyType*(xkb: PXkbDescPtr, name: TAtom, map_count: int16,
|
||||
want_preserve: bool, num_lvls: int16): PXkbKeyTypePtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddKeyType".}
|
||||
proc XkbAllocIndicatorMaps*(xkb: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11,
|
||||
importc: "XkbAllocIndicatorMaps".}
|
||||
proc XkbFreeIndicatorMaps*(xkb: PXkbDescPtr){.cdecl, dynlib: libX11,
|
||||
importc: "XkbFreeIndicatorMaps".}
|
||||
proc XkbGetMap*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetMap".}
|
||||
proc XkbGetUpdatedMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetUpdatedMap".}
|
||||
proc XkbGetMapChanges*(dpy: PDisplay, xkb: PXkbDescPtr,
|
||||
changes: PXkbMapChangesPtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetMapChanges".}
|
||||
proc XkbRefreshKeyboardMapping*(event: PXkbMapNotifyEvent): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbRefreshKeyboardMapping".}
|
||||
proc XkbGetKeyTypes*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetKeyTypes".}
|
||||
proc XkbGetKeySyms*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetKeySyms".}
|
||||
proc XkbGetKeyActions*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetKeyActions".}
|
||||
proc XkbGetKeyBehaviors*(dpy: PDisplay, firstKey, nKeys: int16,
|
||||
desc: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11,
|
||||
importc: "XkbGetKeyBehaviors".}
|
||||
proc XkbGetVirtualMods*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetVirtualMods".}
|
||||
proc XkbGetKeyExplicitComponents*(dpy: PDisplay, firstKey, nKeys: int16,
|
||||
desc: PXkbDescPtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetKeyExplicitComponents".}
|
||||
proc XkbGetKeyModifierMap*(dpy: PDisplay, firstKey, nKeys: int16,
|
||||
desc: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11,
|
||||
importc: "XkbGetKeyModifierMap".}
|
||||
proc XkbAllocControls*(xkb: PXkbDescPtr, which: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocControls".}
|
||||
proc XkbFreeControls*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeControls".}
|
||||
proc XkbGetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetControls".}
|
||||
proc XkbSetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetControls".}
|
||||
proc XkbNoteControlsChanges*(old: PXkbControlsChangesPtr,
|
||||
new: PXkbControlsNotifyEvent, wanted: int16){.
|
||||
cdecl, dynlib: libX11, importc: "XkbNoteControlsChanges".}
|
||||
proc XkbGetControlsChanges*(d: PDisplay, x: PXkbDescPtr,
|
||||
c: PXkbControlsChangesPtr): TStatus
|
||||
proc XkbChangeControls*(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool
|
||||
proc XkbAllocCompatMap*(xkb: PXkbDescPtr, which, nInterpret: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocCompatMap".}
|
||||
proc XkbFreeCompatMap*(xkib: PXkbDescPtr, which: int16, freeMap: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeCompatMap".}
|
||||
proc XkbGetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetCompatMap".}
|
||||
proc XkbSetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr,
|
||||
updateActions: bool): bool{.cdecl, dynlib: libX11,
|
||||
importc: "XkbSetCompatMap".}
|
||||
proc XkbAddSymInterpret*(xkb: PXkbDescPtr, si: PXkbSymInterpretPtr,
|
||||
updateMap: bool, changes: PXkbChangesPtr): PXkbSymInterpretPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddSymInterpret".}
|
||||
proc XkbAllocNames*(xkb: PXkbDescPtr, which: int16,
|
||||
nTotalRG, nTotalAliases: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocNames".}
|
||||
proc XkbGetNames*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetNames".}
|
||||
proc XkbSetNames*(dpy: PDisplay, which, firstType, nTypes: int16,
|
||||
desc: PXkbDescPtr): bool{.cdecl, dynlib: libX11,
|
||||
importc: "XkbSetNames".}
|
||||
proc XkbChangeNames*(dpy: PDisplay, xkb: PXkbDescPtr,
|
||||
changes: PXkbNameChangesPtr): bool{.cdecl, dynlib: libX11,
|
||||
importc: "XkbChangeNames".}
|
||||
proc XkbFreeNames*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeNames".}
|
||||
proc XkbGetState*(dpy: PDisplay, deviceSpec: int16, rtrnState: PXkbStatePtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetState".}
|
||||
proc XkbSetMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetMap".}
|
||||
proc XkbChangeMap*(dpy: PDisplay, desc: PXkbDescPtr, changes: PXkbMapChangesPtr): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbChangeMap".}
|
||||
proc XkbSetDetectableAutoRepeat*(dpy: PDisplay, detectable: bool,
|
||||
supported: ptr bool): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetDetectableAutoRepeat".}
|
||||
proc XkbGetDetectableAutoRepeat*(dpy: PDisplay, supported: ptr bool): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetDetectableAutoRepeat".}
|
||||
proc XkbSetAutoResetControls*(dpy: PDisplay, changes: int16,
|
||||
auto_ctrls, auto_values: PWord): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetAutoResetControls".}
|
||||
proc XkbGetAutoResetControls*(dpy: PDisplay, auto_ctrls, auto_ctrl_values: PWord): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetAutoResetControls".}
|
||||
proc XkbSetPerClientControls*(dpy: PDisplay, change: int16, values: PWord): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetPerClientControls".}
|
||||
proc XkbGetPerClientControls*(dpy: PDisplay, ctrls: PWord): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetPerClientControls".}
|
||||
proc XkbCopyKeyType*(`from`, into: PXkbKeyTypePtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbCopyKeyType".}
|
||||
proc XkbCopyKeyTypes*(`from`, into: PXkbKeyTypePtr, num_types: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbCopyKeyTypes".}
|
||||
proc XkbResizeKeyType*(xkb: PXkbDescPtr, type_ndx, map_count: int16,
|
||||
want_preserve: bool, new_num_lvls: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbResizeKeyType".}
|
||||
proc XkbResizeKeySyms*(desc: PXkbDescPtr, forKey, symsNeeded: int16): PKeySym{.
|
||||
cdecl, dynlib: libX11, importc: "XkbResizeKeySyms".}
|
||||
proc XkbResizeKeyActions*(desc: PXkbDescPtr, forKey, actsNeeded: int16): PXkbAction{.
|
||||
cdecl, dynlib: libX11, importc: "XkbResizeKeyActions".}
|
||||
proc XkbChangeTypesOfKey*(xkb: PXkbDescPtr, key, num_groups: int16,
|
||||
groups: int16, newTypes: ptr int16,
|
||||
pChanges: PXkbMapChangesPtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbChangeTypesOfKey".}
|
||||
|
||||
proc XkbListComponents*(dpy: PDisplay, deviceSpec: int16,
|
||||
ptrns: PXkbComponentNamesPtr, max_inout: ptr int16): PXkbComponentListPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbListComponents".}
|
||||
proc XkbFreeComponentList*(list: PXkbComponentListPtr){.cdecl, dynlib: libX11,
|
||||
importc: "XkbFreeComponentList".}
|
||||
proc XkbGetKeyboard*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetKeyboard".}
|
||||
proc XkbGetKeyboardByName*(dpy: PDisplay, deviceSpec: int16,
|
||||
names: PXkbComponentNamesPtr, want, need: int16,
|
||||
load: bool): PXkbDescPtr{.cdecl, dynlib: libX11,
|
||||
importc: "XkbGetKeyboardByName".}
|
||||
|
||||
proc XkbKeyTypesForCoreSymbols*(xkb: PXkbDescPtr,
|
||||
map_width: int16, # keyboard device
|
||||
core_syms: PKeySym, # always mapWidth symbols
|
||||
protected: int16, # explicit key types
|
||||
types_inout: ptr int16, # always four type indices
|
||||
xkb_syms_rtrn: PKeySym): int16{.cdecl,
|
||||
dynlib: libX11, importc: "XkbKeyTypesForCoreSymbols".}
|
||||
# must have enough space
|
||||
proc XkbApplyCompatMapToKey*(xkb: PXkbDescPtr,
|
||||
key: TKeyCode, # key to be updated
|
||||
changes: PXkbChangesPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbApplyCompatMapToKey".}
|
||||
# resulting changes to map
|
||||
proc XkbUpdateMapFromCore*(xkb: PXkbDescPtr,
|
||||
first_key: TKeyCode, # first changed key
|
||||
num_keys,
|
||||
map_width: int16,
|
||||
core_keysyms: PKeySym, # symbols `from` core keymap
|
||||
changes: PXkbChangesPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbUpdateMapFromCore".}
|
||||
|
||||
proc XkbAddDeviceLedInfo*(devi: PXkbDeviceInfoPtr, ledClass, ledId: int16): PXkbDeviceLedInfoPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddDeviceLedInfo".}
|
||||
proc XkbResizeDeviceButtonActions*(devi: PXkbDeviceInfoPtr, newTotal: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbResizeDeviceButtonActions".}
|
||||
proc XkbAllocDeviceInfo*(deviceSpec, nButtons, szLeds: int16): PXkbDeviceInfoPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocDeviceInfo".}
|
||||
proc XkbFreeDeviceInfo*(devi: PXkbDeviceInfoPtr, which: int16, freeDevI: bool){.
|
||||
cdecl, dynlib: libX11, importc: "XkbFreeDeviceInfo".}
|
||||
proc XkbNoteDeviceChanges*(old: PXkbDeviceChangesPtr,
|
||||
new: PXkbExtensionDeviceNotifyEvent, wanted: int16){.
|
||||
cdecl, dynlib: libX11, importc: "XkbNoteDeviceChanges".}
|
||||
proc XkbGetDeviceInfo*(dpy: PDisplay, which, deviceSpec, ledClass, ledID: int16): PXkbDeviceInfoPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetDeviceInfo".}
|
||||
proc XkbGetDeviceInfoChanges*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||
changes: PXkbDeviceChangesPtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetDeviceInfoChanges".}
|
||||
proc XkbGetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||
all: bool, first, nBtns: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetDeviceButtonActions".}
|
||||
proc XkbGetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||
ledClass, ledId, which: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetDeviceLedInfo".}
|
||||
proc XkbSetDeviceInfo*(dpy: PDisplay, which: int16, devi: PXkbDeviceInfoPtr): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetDeviceInfo".}
|
||||
proc XkbChangeDeviceInfo*(dpy: PDisplay, desc: PXkbDeviceInfoPtr,
|
||||
changes: PXkbDeviceChangesPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbChangeDeviceInfo".}
|
||||
proc XkbSetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||
ledClass, ledID, which: int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetDeviceLedInfo".}
|
||||
proc XkbSetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||
first, nBtns: int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetDeviceButtonActions".}
|
||||
|
||||
proc XkbToControl*(c: int8): int8{.cdecl, dynlib: libX11,
|
||||
importc: "XkbToControl".}
|
||||
|
||||
proc XkbSetDebuggingFlags*(dpy: PDisplay, mask, flags: int16, msg: cstring,
|
||||
ctrls_mask, ctrls, rtrn_flags, rtrn_ctrls: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetDebuggingFlags".}
|
||||
proc XkbApplyVirtualModChanges*(xkb: PXkbDescPtr, changed: int16,
|
||||
changes: PXkbChangesPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbApplyVirtualModChanges".}
|
||||
|
||||
# implementation
|
||||
|
||||
proc XkbNoteIndicatorMapChanges(o, n: PXkbIndicatorChangesPtr, w: int16) =
|
||||
##define XkbNoteIndicatorMapChanges(o,n,w) ((o)->map_changes|=((n)->map_changes&(w)))
|
||||
o.map_changes = o.map_changes or (n.map_changes and w)
|
||||
|
||||
proc XkbNoteIndicatorStateChanges(o, n: PXkbIndicatorChangesPtr, w: int16) =
|
||||
##define XkbNoteIndicatorStateChanges(o,n,w) ((o)->state_changes|=((n)->state_changes&(w)))
|
||||
o.state_changes = o.state_changes or (n.state_changes and (w))
|
||||
|
||||
proc XkbGetIndicatorMapChanges(d: PDisplay, x: PXkbDescPtr,
|
||||
c: PXkbIndicatorChangesPtr): TStatus =
|
||||
##define XkbGetIndicatorMapChanges(d,x,c) (XkbGetIndicatorMap((d),(c)->map_changes,x)
|
||||
Result = XkbGetIndicatorMap(d, c.map_changes, x)
|
||||
|
||||
proc XkbChangeIndicatorMaps(d: PDisplay, x: PXkbDescPtr,
|
||||
c: PXkbIndicatorChangesPtr): bool =
|
||||
##define XkbChangeIndicatorMaps(d,x,c) (XkbSetIndicatorMap((d),(c)->map_changes,x))
|
||||
Result = XkbSetIndicatorMap(d, c.map_changes, x)
|
||||
|
||||
proc XkbGetControlsChanges(d: PDisplay, x: PXkbDescPtr,
|
||||
c: PXkbControlsChangesPtr): TStatus =
|
||||
##define XkbGetControlsChanges(d,x,c) XkbGetControls(d,(c)->changed_ctrls,x)
|
||||
Result = XkbGetControls(d, c.changed_ctrls, x)
|
||||
|
||||
proc XkbChangeControls(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool =
|
||||
##define XkbChangeControls(d,x,c) XkbSetControls(d,(c)->changed_ctrls,x)
|
||||
Result = XkbSetControls(d, c.changed_ctrls, x)
|
||||
2218
lib/base/x11/xlib.nim
Normal file
2218
lib/base/x11/xlib.nim
Normal file
File diff suppressed because it is too large
Load Diff
194
lib/base/x11/xrandr.nim
Normal file
194
lib/base/x11/xrandr.nim
Normal file
@@ -0,0 +1,194 @@
|
||||
#
|
||||
# $XFree86: xc/lib/Xrandr/Xrandr.h,v 1.9 2002/09/29 23:39:44 keithp Exp $
|
||||
#
|
||||
# Copyright (C) 2000 Compaq Computer Corporation, Inc.
|
||||
# Copyright (C) 2002 Hewlett-Packard Company, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of Compaq not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. HP makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ
|
||||
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
# Author: Jim Gettys, HP Labs, HP.
|
||||
#
|
||||
|
||||
import
|
||||
x, xlib
|
||||
|
||||
const
|
||||
libXrandr* = "libXrandr.so"
|
||||
|
||||
# * $XFree86: xc/include/extensions/randr.h,v 1.4 2001/11/24 07:24:58 keithp Exp $
|
||||
# *
|
||||
# * Copyright (C) 2000, Compaq Computer Corporation,
|
||||
# * Copyright (C) 2002, Hewlett Packard, Inc.
|
||||
# *
|
||||
# * Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# * documentation for any purpose is hereby granted without fee, provided that
|
||||
# * the above copyright notice appear in all copies and that both that
|
||||
# * copyright notice and this permission notice appear in supporting
|
||||
# * documentation, and that the name of Compaq or HP not be used in advertising
|
||||
# * or publicity pertaining to distribution of the software without specific,
|
||||
# * written prior permission. HP makes no representations about the
|
||||
# * suitability of this software for any purpose. It is provided "as is"
|
||||
# * without express or implied warranty.
|
||||
# *
|
||||
# * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
# * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP
|
||||
# * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
# * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
# * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
# *
|
||||
# * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc.
|
||||
# *
|
||||
|
||||
type
|
||||
PRotation* = ptr TRotation
|
||||
TRotation* = cushort
|
||||
PSizeID* = ptr TSizeID
|
||||
TSizeID* = cushort
|
||||
PSubpixelOrder* = ptr TSubpixelOrder
|
||||
TSubpixelOrder* = cushort
|
||||
|
||||
const
|
||||
RANDR_NAME* = "RANDR"
|
||||
RANDR_MAJOR* = 1
|
||||
RANDR_MINOR* = 1
|
||||
RRNumberErrors* = 0
|
||||
RRNumberEvents* = 1
|
||||
constX_RRQueryVersion* = 0 # we skip 1 to make old clients fail pretty immediately
|
||||
X_RROldGetScreenInfo* = 1
|
||||
X_RR1_0SetScreenConfig* = 2 # V1.0 apps share the same set screen config request id
|
||||
constX_RRSetScreenConfig* = 2
|
||||
X_RROldScreenChangeSelectInput* = 3 # 3 used to be ScreenChangeSelectInput; deprecated
|
||||
constX_RRSelectInput* = 4
|
||||
constX_RRGetScreenInfo* = 5 # used in XRRSelectInput
|
||||
RRScreenChangeNotifyMask* = 1 shl 0
|
||||
RRScreenChangeNotify* = 0 # used in the rotation field; rotation and reflection in 0.1 proto.
|
||||
RR_Rotate_0* = 1
|
||||
RR_Rotate_90* = 2
|
||||
RR_Rotate_180* = 4
|
||||
RR_Rotate_270* = 8 # new in 1.0 protocol, to allow reflection of screen
|
||||
RR_Reflect_X* = 16
|
||||
RR_Reflect_Y* = 32
|
||||
RRSetConfigSuccess* = 0
|
||||
RRSetConfigInvalidConfigTime* = 1
|
||||
RRSetConfigInvalidTime* = 2
|
||||
RRSetConfigFailed* = 3
|
||||
|
||||
type
|
||||
PXRRScreenSize* = ptr TXRRScreenSize
|
||||
TXRRScreenSize*{.final.} = object #
|
||||
# Events.
|
||||
#
|
||||
width*, height*: cint
|
||||
mwidth*, mheight*: cint
|
||||
|
||||
TXRRScreenChangeNotifyEvent*{.final.} = object # internal representation is private to the library
|
||||
type_*: cint # event base
|
||||
serial*: culong # # of last request processed by server
|
||||
send_event*: TBool # true if this came from a SendEvent request
|
||||
display*: PDisplay # Display the event was read from
|
||||
window*: TWindow # window which selected for this event
|
||||
root*: TWindow # Root window for changed screen
|
||||
timestamp*: TTime # when the screen change occurred
|
||||
config_timestamp*: TTime # when the last configuration change
|
||||
size_index*: TSizeID
|
||||
subpixel_order*: TSubpixelOrder
|
||||
rotation*: TRotation
|
||||
width*: cint
|
||||
height*: cint
|
||||
mwidth*: cint
|
||||
mheight*: cint
|
||||
|
||||
PXRRScreenConfiguration* = ptr TXRRScreenConfiguration
|
||||
TXRRScreenConfiguration*{.final.} = object
|
||||
|
||||
proc XRRQueryExtension*(dpy: PDisplay, event_basep, error_basep: Pcint): TBool{.
|
||||
cdecl, dynlib: libXrandr, importc.}
|
||||
proc XRRQueryVersion*(dpy: PDisplay, major_versionp: Pcint,
|
||||
minor_versionp: Pcint): TStatus{.cdecl, dynlib: libXrandr,
|
||||
importc.}
|
||||
proc XRRGetScreenInfo*(dpy: PDisplay, draw: TDrawable): PXRRScreenConfiguration{.
|
||||
cdecl, dynlib: libXrandr, importc.}
|
||||
proc XRRFreeScreenConfigInfo*(config: PXRRScreenConfiguration){.cdecl,
|
||||
dynlib: libXrandr, importc.}
|
||||
#
|
||||
# Note that screen configuration changes are only permitted if the client can
|
||||
# prove it has up to date configuration information. We are trying to
|
||||
# insist that it become possible for screens to change dynamically, so
|
||||
# we want to ensure the client knows what it is talking about when requesting
|
||||
# changes.
|
||||
#
|
||||
proc XRRSetScreenConfig*(dpy: PDisplay, config: PXRRScreenConfiguration,
|
||||
draw: TDrawable, size_index: cint, rotation: TRotation,
|
||||
timestamp: TTime): TStatus{.cdecl, dynlib: libXrandr,
|
||||
importc.}
|
||||
# added in v1.1, sorry for the lame name
|
||||
proc XRRSetScreenConfigAndRate*(dpy: PDisplay, config: PXRRScreenConfiguration,
|
||||
draw: TDrawable, size_index: cint,
|
||||
rotation: TRotation, rate: cshort,
|
||||
timestamp: TTime): TStatus{.cdecl,
|
||||
dynlib: libXrandr, importc.}
|
||||
proc XRRConfigRotations*(config: PXRRScreenConfiguration,
|
||||
current_rotation: PRotation): TRotation{.cdecl,
|
||||
dynlib: libXrandr, importc.}
|
||||
proc XRRConfigTimes*(config: PXRRScreenConfiguration, config_timestamp: PTime): TTime{.
|
||||
cdecl, dynlib: libXrandr, importc.}
|
||||
proc XRRConfigSizes*(config: PXRRScreenConfiguration, nsizes: Pcint): PXRRScreenSize{.
|
||||
cdecl, dynlib: libXrandr, importc.}
|
||||
proc XRRConfigRates*(config: PXRRScreenConfiguration, sizeID: cint,
|
||||
nrates: Pcint): ptr int16{.cdecl, dynlib: libXrandr, importc.}
|
||||
proc XRRConfigCurrentConfiguration*(config: PXRRScreenConfiguration,
|
||||
rotation: PRotation): TSizeID{.cdecl,
|
||||
dynlib: libXrandr, importc.}
|
||||
proc XRRConfigCurrentRate*(config: PXRRScreenConfiguration): cshort{.cdecl,
|
||||
dynlib: libXrandr, importc.}
|
||||
proc XRRRootToScreen*(dpy: PDisplay, root: TWindow): cint{.cdecl,
|
||||
dynlib: libXrandr, importc.}
|
||||
#
|
||||
# returns the screen configuration for the specified screen; does a lazy
|
||||
# evalution to delay getting the information, and caches the result.
|
||||
# These routines should be used in preference to XRRGetScreenInfo
|
||||
# to avoid unneeded round trips to the X server. These are new
|
||||
# in protocol version 0.1.
|
||||
#
|
||||
proc XRRScreenConfig*(dpy: PDisplay, screen: cint): PXRRScreenConfiguration{.
|
||||
cdecl, dynlib: libXrandr, importc.}
|
||||
proc XRRConfig*(screen: PScreen): PXRRScreenConfiguration{.cdecl,
|
||||
dynlib: libXrandr, importc.}
|
||||
proc XRRSelectInput*(dpy: PDisplay, window: TWindow, mask: cint){.cdecl,
|
||||
dynlib: libXrandr, importc.}
|
||||
#
|
||||
# the following are always safe to call, even if RandR is not implemented
|
||||
# on a screen
|
||||
#
|
||||
proc XRRRotations*(dpy: PDisplay, screen: cint, current_rotation: PRotation): TRotation{.
|
||||
cdecl, dynlib: libXrandr, importc.}
|
||||
proc XRRSizes*(dpy: PDisplay, screen: cint, nsizes: Pcint): PXRRScreenSize{.
|
||||
cdecl, dynlib: libXrandr, importc.}
|
||||
proc XRRRates*(dpy: PDisplay, screen: cint, sizeID: cint, nrates: Pcint): ptr int16{.
|
||||
cdecl, dynlib: libXrandr, importc.}
|
||||
proc XRRTimes*(dpy: PDisplay, screen: cint, config_timestamp: PTime): TTime{.
|
||||
cdecl, dynlib: libXrandr, importc.}
|
||||
#
|
||||
# intended to take RRScreenChangeNotify, or
|
||||
# ConfigureNotify (on the root window)
|
||||
# returns 1 if it is an event type it understands, 0 if not
|
||||
#
|
||||
proc XRRUpdateConfiguration*(event: PXEvent): cint{.cdecl, dynlib: libXrandr,
|
||||
importc.}
|
||||
# implementation
|
||||
231
lib/base/x11/xrender.nim
Normal file
231
lib/base/x11/xrender.nim
Normal file
@@ -0,0 +1,231 @@
|
||||
|
||||
import
|
||||
x, xlib
|
||||
|
||||
#const
|
||||
# libX11* = "libX11.so"
|
||||
|
||||
#
|
||||
# Automatically converted by H2Pas 0.99.15 from xrender.h
|
||||
# The following command line parameters were used:
|
||||
# -p
|
||||
# -T
|
||||
# -S
|
||||
# -d
|
||||
# -c
|
||||
# xrender.h
|
||||
#
|
||||
|
||||
type
|
||||
PGlyph* = ptr TGlyph
|
||||
TGlyph* = int32
|
||||
PGlyphSet* = ptr TGlyphSet
|
||||
TGlyphSet* = int32
|
||||
PPicture* = ptr TPicture
|
||||
TPicture* = int32
|
||||
PPictFormat* = ptr TPictFormat
|
||||
TPictFormat* = int32
|
||||
|
||||
const
|
||||
RENDER_NAME* = "RENDER"
|
||||
RENDER_MAJOR* = 0
|
||||
RENDER_MINOR* = 0
|
||||
constX_RenderQueryVersion* = 0
|
||||
X_RenderQueryPictFormats* = 1
|
||||
X_RenderQueryPictIndexValues* = 2
|
||||
X_RenderQueryDithers* = 3
|
||||
constX_RenderCreatePicture* = 4
|
||||
constX_RenderChangePicture* = 5
|
||||
X_RenderSetPictureClipRectangles* = 6
|
||||
constX_RenderFreePicture* = 7
|
||||
constX_RenderComposite* = 8
|
||||
X_RenderScale* = 9
|
||||
X_RenderTrapezoids* = 10
|
||||
X_RenderTriangles* = 11
|
||||
X_RenderTriStrip* = 12
|
||||
X_RenderTriFan* = 13
|
||||
X_RenderColorTrapezoids* = 14
|
||||
X_RenderColorTriangles* = 15
|
||||
X_RenderTransform* = 16
|
||||
constX_RenderCreateGlyphSet* = 17
|
||||
constX_RenderReferenceGlyphSet* = 18
|
||||
constX_RenderFreeGlyphSet* = 19
|
||||
constX_RenderAddGlyphs* = 20
|
||||
constX_RenderAddGlyphsFromPicture* = 21
|
||||
constX_RenderFreeGlyphs* = 22
|
||||
constX_RenderCompositeGlyphs8* = 23
|
||||
constX_RenderCompositeGlyphs16* = 24
|
||||
constX_RenderCompositeGlyphs32* = 25
|
||||
BadPictFormat* = 0
|
||||
BadPicture* = 1
|
||||
BadPictOp* = 2
|
||||
BadGlyphSet* = 3
|
||||
BadGlyph* = 4
|
||||
RenderNumberErrors* = BadGlyph + 1
|
||||
PictTypeIndexed* = 0
|
||||
PictTypeDirect* = 1
|
||||
PictOpClear* = 0
|
||||
PictOpSrc* = 1
|
||||
PictOpDst* = 2
|
||||
PictOpOver* = 3
|
||||
PictOpOverReverse* = 4
|
||||
PictOpIn* = 5
|
||||
PictOpInReverse* = 6
|
||||
PictOpOut* = 7
|
||||
PictOpOutReverse* = 8
|
||||
PictOpAtop* = 9
|
||||
PictOpAtopReverse* = 10
|
||||
PictOpXor* = 11
|
||||
PictOpAdd* = 12
|
||||
PictOpSaturate* = 13
|
||||
PictOpMaximum* = 13
|
||||
PolyEdgeSharp* = 0
|
||||
PolyEdgeSmooth* = 1
|
||||
PolyModePrecise* = 0
|
||||
PolyModeImprecise* = 1
|
||||
CPRepeat* = 1 shl 0
|
||||
CPAlphaMap* = 1 shl 1
|
||||
CPAlphaXOrigin* = 1 shl 2
|
||||
CPAlphaYOrigin* = 1 shl 3
|
||||
CPClipXOrigin* = 1 shl 4
|
||||
CPClipYOrigin* = 1 shl 5
|
||||
CPClipMask* = 1 shl 6
|
||||
CPGraphicsExposure* = 1 shl 7
|
||||
CPSubwindowMode* = 1 shl 8
|
||||
CPPolyEdge* = 1 shl 9
|
||||
CPPolyMode* = 1 shl 10
|
||||
CPDither* = 1 shl 11
|
||||
CPLastBit* = 11
|
||||
|
||||
type
|
||||
PXRenderDirectFormat* = ptr TXRenderDirectFormat
|
||||
TXRenderDirectFormat*{.final.} = object
|
||||
red*: int16
|
||||
redMask*: int16
|
||||
green*: int16
|
||||
greenMask*: int16
|
||||
blue*: int16
|
||||
blueMask*: int16
|
||||
alpha*: int16
|
||||
alphaMask*: int16
|
||||
|
||||
PXRenderPictFormat* = ptr TXRenderPictFormat
|
||||
TXRenderPictFormat*{.final.} = object
|
||||
id*: TPictFormat
|
||||
thetype*: int32
|
||||
depth*: int32
|
||||
direct*: TXRenderDirectFormat
|
||||
colormap*: TColormap
|
||||
|
||||
|
||||
const
|
||||
PictFormatID* = 1 shl 0
|
||||
PictFormatType* = 1 shl 1
|
||||
PictFormatDepth* = 1 shl 2
|
||||
PictFormatRed* = 1 shl 3
|
||||
PictFormatRedMask* = 1 shl 4
|
||||
PictFormatGreen* = 1 shl 5
|
||||
PictFormatGreenMask* = 1 shl 6
|
||||
PictFormatBlue* = 1 shl 7
|
||||
PictFormatBlueMask* = 1 shl 8
|
||||
PictFormatAlpha* = 1 shl 9
|
||||
PictFormatAlphaMask* = 1 shl 10
|
||||
PictFormatColormap* = 1 shl 11
|
||||
|
||||
type
|
||||
PXRenderVisual* = ptr TXRenderVisual
|
||||
TXRenderVisual*{.final.} = object
|
||||
visual*: PVisual
|
||||
format*: PXRenderPictFormat
|
||||
|
||||
PXRenderDepth* = ptr TXRenderDepth
|
||||
TXRenderDepth*{.final.} = object
|
||||
depth*: int32
|
||||
nvisuals*: int32
|
||||
visuals*: PXRenderVisual
|
||||
|
||||
PXRenderScreen* = ptr TXRenderScreen
|
||||
TXRenderScreen*{.final.} = object
|
||||
depths*: PXRenderDepth
|
||||
ndepths*: int32
|
||||
fallback*: PXRenderPictFormat
|
||||
|
||||
PXRenderInfo* = ptr TXRenderInfo
|
||||
TXRenderInfo*{.final.} = object
|
||||
format*: PXRenderPictFormat
|
||||
nformat*: int32
|
||||
screen*: PXRenderScreen
|
||||
nscreen*: int32
|
||||
depth*: PXRenderDepth
|
||||
ndepth*: int32
|
||||
visual*: PXRenderVisual
|
||||
nvisual*: int32
|
||||
|
||||
PXRenderPictureAttributes* = ptr TXRenderPictureAttributes
|
||||
TXRenderPictureAttributes*{.final.} = object
|
||||
repeat_*: TBool
|
||||
alpha_map*: TPicture
|
||||
alpha_x_origin*: int32
|
||||
alpha_y_origin*: int32
|
||||
clip_x_origin*: int32
|
||||
clip_y_origin*: int32
|
||||
clip_mask*: TPixmap
|
||||
graphics_exposures*: TBool
|
||||
subwindow_mode*: int32
|
||||
poly_edge*: int32
|
||||
poly_mode*: int32
|
||||
dither*: TAtom
|
||||
|
||||
PXGlyphInfo* = ptr TXGlyphInfo
|
||||
TXGlyphInfo*{.final.} = object
|
||||
width*: int16
|
||||
height*: int16
|
||||
x*: int16
|
||||
y*: int16
|
||||
xOff*: int16
|
||||
yOff*: int16
|
||||
|
||||
|
||||
proc XRenderQueryExtension*(dpy: PDisplay, event_basep: ptr int32,
|
||||
error_basep: ptr int32): TBool{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XRenderQueryVersion*(dpy: PDisplay, major_versionp: ptr int32,
|
||||
minor_versionp: ptr int32): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XRenderQueryFormats*(dpy: PDisplay): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XRenderFindVisualFormat*(dpy: PDisplay, visual: PVisual): PXRenderPictFormat{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XRenderFindFormat*(dpy: PDisplay, mask: int32,
|
||||
`template`: PXRenderPictFormat, count: int32): PXRenderPictFormat{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XRenderCreatePicture*(dpy: PDisplay, drawable: TDrawable,
|
||||
format: PXRenderPictFormat, valuemask: int32,
|
||||
attributes: PXRenderPictureAttributes): TPicture{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XRenderChangePicture*(dpy: PDisplay, picture: TPicture, valuemask: int32,
|
||||
attributes: PXRenderPictureAttributes){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XRenderFreePicture*(dpy: PDisplay, picture: TPicture){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XRenderComposite*(dpy: PDisplay, op: int32, src: TPicture, mask: TPicture,
|
||||
dst: TPicture, src_x: int32, src_y: int32, mask_x: int32,
|
||||
mask_y: int32, dst_x: int32, dst_y: int32, width: int32,
|
||||
height: int32){.cdecl, dynlib: libX11, importc.}
|
||||
proc XRenderCreateGlyphSet*(dpy: PDisplay, format: PXRenderPictFormat): TGlyphSet{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XRenderReferenceGlyphSet*(dpy: PDisplay, existing: TGlyphSet): TGlyphSet{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XRenderFreeGlyphSet*(dpy: PDisplay, glyphset: TGlyphSet){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XRenderAddGlyphs*(dpy: PDisplay, glyphset: TGlyphSet, gids: PGlyph,
|
||||
glyphs: PXGlyphInfo, nglyphs: int32, images: cstring,
|
||||
nbyte_images: int32){.cdecl, dynlib: libX11, importc.}
|
||||
proc XRenderFreeGlyphs*(dpy: PDisplay, glyphset: TGlyphSet, gids: PGlyph,
|
||||
nglyphs: int32){.cdecl, dynlib: libX11, importc.}
|
||||
proc XRenderCompositeString8*(dpy: PDisplay, op: int32, src: TPicture,
|
||||
dst: TPicture, maskFormat: PXRenderPictFormat,
|
||||
glyphset: TGlyphSet, xSrc: int32, ySrc: int32,
|
||||
xDst: int32, yDst: int32, str: cstring,
|
||||
nchar: int32){.cdecl, dynlib: libX11, importc.}
|
||||
# implementation
|
||||
200
lib/base/x11/xresource.nim
Normal file
200
lib/base/x11/xresource.nim
Normal file
@@ -0,0 +1,200 @@
|
||||
|
||||
import
|
||||
x, xlib
|
||||
|
||||
#const
|
||||
# libX11* = "libX11.so"
|
||||
|
||||
#
|
||||
# Automatically converted by H2Pas 0.99.15 from xresource.h
|
||||
# The following command line parameters were used:
|
||||
# -p
|
||||
# -T
|
||||
# -S
|
||||
# -d
|
||||
# -c
|
||||
# xresource.h
|
||||
#
|
||||
|
||||
proc Xpermalloc*(para1: int32): cstring{.cdecl, dynlib: libX11, importc.}
|
||||
type
|
||||
PXrmQuark* = ptr TXrmQuark
|
||||
TXrmQuark* = int32
|
||||
TXrmQuarkList* = PXrmQuark
|
||||
PXrmQuarkList* = ptr TXrmQuarkList
|
||||
|
||||
proc NULLQUARK*(): TXrmQuark
|
||||
type
|
||||
PXrmString* = ptr TXrmString
|
||||
TXrmString* = ptr char
|
||||
|
||||
proc NULLSTRING*(): TXrmString
|
||||
proc XrmStringToQuark*(para1: cstring): TXrmQuark{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XrmPermStringToQuark*(para1: cstring): TXrmQuark{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XrmQuarkToString*(para1: TXrmQuark): TXrmString{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XrmUniqueQuark*(): TXrmQuark{.cdecl, dynlib: libX11, importc.}
|
||||
when defined(MACROS):
|
||||
proc XrmStringsEqual*(a1, a2: cstring): bool
|
||||
type
|
||||
PXrmBinding* = ptr TXrmBinding
|
||||
TXrmBinding* = enum
|
||||
XrmBindTightly, XrmBindLoosely
|
||||
TXrmBindingList* = PXrmBinding
|
||||
PXrmBindingList* = ptr TXrmBindingList
|
||||
|
||||
proc XrmStringToQuarkList*(para1: cstring, para2: TXrmQuarkList){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XrmStringToBindingQuarkList*(para1: cstring, para2: TXrmBindingList,
|
||||
para3: TXrmQuarkList){.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
type
|
||||
PXrmName* = ptr TXrmName
|
||||
TXrmName* = TXrmQuark
|
||||
PXrmNameList* = ptr TXrmNameList
|
||||
TXrmNameList* = TXrmQuarkList
|
||||
|
||||
when defined(MACROS):
|
||||
proc XrmNameToString*(name: int32): TXrmString
|
||||
proc XrmStringToName*(str: cstring): int32
|
||||
proc XrmStringToNameList*(str: cstring, name: PXrmQuark)
|
||||
type
|
||||
PXrmClass* = ptr TXrmClass
|
||||
TXrmClass* = TXrmQuark
|
||||
PXrmClassList* = ptr TXrmClassList
|
||||
TXrmClassList* = TXrmQuarkList
|
||||
|
||||
when defined(MACROS):
|
||||
proc XrmClassToString*(c_class: int32): TXrmString
|
||||
proc XrmStringToClass*(c_class: cstring): int32
|
||||
proc XrmStringToClassList*(str: cstring, c_class: PXrmQuark)
|
||||
type
|
||||
PXrmRepresentation* = ptr TXrmRepresentation
|
||||
TXrmRepresentation* = TXrmQuark
|
||||
|
||||
when defined(MACROS):
|
||||
proc XrmStringToRepresentation*(str: cstring): int32
|
||||
proc XrmRepresentationToString*(thetype: int32): TXrmString
|
||||
type
|
||||
PXrmValue* = ptr TXrmValue
|
||||
TXrmValue*{.final.} = object
|
||||
size*: int32
|
||||
address*: TXPointer
|
||||
|
||||
TXrmValuePtr* = PXrmValue
|
||||
PXrmValuePtr* = ptr TXrmValuePtr
|
||||
PXrmHashBucketRec* = ptr TXrmHashBucketRec
|
||||
TXrmHashBucketRec*{.final.} = object
|
||||
TXrmHashBucket* = PXrmHashBucketRec
|
||||
PXrmHashBucket* = ptr TXrmHashBucket
|
||||
PXrmHashTable* = ptr TXrmHashTable
|
||||
TXrmHashTable* = ptr TXrmHashBucket
|
||||
TXrmDatabase* = PXrmHashBucketRec
|
||||
PXrmDatabase* = ptr TXrmDatabase
|
||||
|
||||
proc XrmDestroyDatabase*(para1: TXrmDatabase){.cdecl, dynlib: libX11, importc.}
|
||||
proc XrmQPutResource*(para1: PXrmDatabase, para2: TXrmBindingList,
|
||||
para3: TXrmQuarkList, para4: TXrmRepresentation,
|
||||
para5: PXrmValue){.cdecl, dynlib: libX11, importc.}
|
||||
proc XrmPutResource*(para1: PXrmDatabase, para2: cstring, para3: cstring,
|
||||
para4: PXrmValue){.cdecl, dynlib: libX11, importc.}
|
||||
proc XrmQPutStringResource*(para1: PXrmDatabase, para2: TXrmBindingList,
|
||||
para3: TXrmQuarkList, para4: cstring){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XrmPutStringResource*(para1: PXrmDatabase, para2: cstring, para3: cstring){.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XrmPutLineResource*(para1: PXrmDatabase, para2: cstring){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XrmQGetResource*(para1: TXrmDatabase, para2: TXrmNameList,
|
||||
para3: TXrmClassList, para4: PXrmRepresentation,
|
||||
para5: PXrmValue): TBool{.cdecl, dynlib: libX11, importc.}
|
||||
proc XrmGetResource*(para1: TXrmDatabase, para2: cstring, para3: cstring,
|
||||
para4: PPchar, para5: PXrmValue): TBool{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
# There is no definition of TXrmSearchList
|
||||
#function XrmQGetSearchList(para1:TXrmDatabase; para2:TXrmNameList; para3:TXrmClassList; para4:TXrmSearchList; para5:longint):TBool;cdecl;external libX11;
|
||||
#function XrmQGetSearchResource(para1:TXrmSearchList; para2:TXrmName; para3:TXrmClass; para4:PXrmRepresentation; para5:PXrmValue):TBool;cdecl;external libX11;
|
||||
proc XrmSetDatabase*(para1: PDisplay, para2: TXrmDatabase){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XrmGetDatabase*(para1: PDisplay): TXrmDatabase{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XrmGetFileDatabase*(para1: cstring): TXrmDatabase{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XrmCombineFileDatabase*(para1: cstring, para2: PXrmDatabase, para3: TBool): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XrmGetStringDatabase*(para1: cstring): TXrmDatabase{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XrmPutFileDatabase*(para1: TXrmDatabase, para2: cstring){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XrmMergeDatabases*(para1: TXrmDatabase, para2: PXrmDatabase){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XrmCombineDatabase*(para1: TXrmDatabase, para2: PXrmDatabase, para3: TBool){.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
const
|
||||
XrmEnumAllLevels* = 0
|
||||
XrmEnumOneLevel* = 1
|
||||
|
||||
type
|
||||
funcbool* = proc (): TBool
|
||||
|
||||
proc XrmEnumerateDatabase*(para1: TXrmDatabase, para2: TXrmNameList,
|
||||
para3: TXrmClassList, para4: int32, para5: funcbool,
|
||||
para6: TXPointer): TBool{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XrmLocaleOfDatabase*(para1: TXrmDatabase): cstring{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
type
|
||||
PXrmOptionKind* = ptr TXrmOptionKind
|
||||
TXrmOptionKind* = enum
|
||||
XrmoptionNoArg, XrmoptionIsArg, XrmoptionStickyArg, XrmoptionSepArg,
|
||||
XrmoptionResArg, XrmoptionSkipArg, XrmoptionSkipLine, XrmoptionSkipNArgs
|
||||
PXrmOptionDescRec* = ptr TXrmOptionDescRec
|
||||
TXrmOptionDescRec*{.final.} = object
|
||||
option*: cstring
|
||||
specifier*: cstring
|
||||
argKind*: TXrmOptionKind
|
||||
value*: TXPointer
|
||||
|
||||
TXrmOptionDescList* = PXrmOptionDescRec
|
||||
PXrmOptionDescList* = ptr TXrmOptionDescList
|
||||
|
||||
proc XrmParseCommand*(para1: PXrmDatabase, para2: TXrmOptionDescList,
|
||||
para3: int32, para4: cstring, para5: ptr int32,
|
||||
para6: PPchar){.cdecl, dynlib: libX11, importc.}
|
||||
# implementation
|
||||
|
||||
proc NULLQUARK(): TXrmQuark =
|
||||
result = TXrmQuark(0)
|
||||
|
||||
proc NULLSTRING(): TXrmString =
|
||||
result = nil
|
||||
|
||||
when defined(MACROS):
|
||||
proc XrmStringsEqual(a1, a2: cstring): bool =
|
||||
result = (strcomp(a1, a2)) == 0
|
||||
|
||||
proc XrmNameToString(name: int32): TXrmString =
|
||||
result = XrmQuarkToString(name)
|
||||
|
||||
proc XrmStringToName(str: cstring): int32 =
|
||||
result = XrmStringToQuark(str)
|
||||
|
||||
proc XrmStringToNameList(str: cstring, name: PXrmQuark) =
|
||||
XrmStringToQuarkList(str, name)
|
||||
|
||||
proc XrmClassToString(c_class: int32): TXrmString =
|
||||
result = XrmQuarkToString(c_class)
|
||||
|
||||
proc XrmStringToClass(c_class: cstring): int32 =
|
||||
result = XrmStringToQuark(c_class)
|
||||
|
||||
proc XrmStringToClassList(str: cstring, c_class: PXrmQuark) =
|
||||
XrmStringToQuarkList(str, c_class)
|
||||
|
||||
proc XrmStringToRepresentation(str: cstring): int32 =
|
||||
result = XrmStringToQuark(str)
|
||||
|
||||
proc XrmRepresentationToString(thetype: int32): TXrmString =
|
||||
result = XrmQuarkToString(thetype)
|
||||
77
lib/base/x11/xshm.nim
Normal file
77
lib/base/x11/xshm.nim
Normal file
@@ -0,0 +1,77 @@
|
||||
|
||||
import
|
||||
x, xlib
|
||||
|
||||
#const
|
||||
# libX11* = "libX11.so"
|
||||
|
||||
#
|
||||
# Automatically converted by H2Pas 0.99.15 from xshm.h
|
||||
# The following command line parameters were used:
|
||||
# -p
|
||||
# -T
|
||||
# -S
|
||||
# -d
|
||||
# -c
|
||||
# xshm.h
|
||||
#
|
||||
|
||||
const
|
||||
constX_ShmQueryVersion* = 0
|
||||
constX_ShmAttach* = 1
|
||||
constX_ShmDetach* = 2
|
||||
constX_ShmPutImage* = 3
|
||||
constX_ShmGetImage* = 4
|
||||
constX_ShmCreatePixmap* = 5
|
||||
ShmCompletion* = 0
|
||||
ShmNumberEvents* = ShmCompletion + 1
|
||||
BadShmSeg* = 0
|
||||
ShmNumberErrors* = BadShmSeg + 1
|
||||
|
||||
type
|
||||
PShmSeg* = ptr TShmSeg
|
||||
TShmSeg* = culong
|
||||
PXShmCompletionEvent* = ptr TXShmCompletionEvent
|
||||
TXShmCompletionEvent*{.final.} = object
|
||||
theType*: cint
|
||||
serial*: culong
|
||||
send_event*: TBool
|
||||
display*: PDisplay
|
||||
drawable*: TDrawable
|
||||
major_code*: cint
|
||||
minor_code*: cint
|
||||
shmseg*: TShmSeg
|
||||
offset*: culong
|
||||
|
||||
PXShmSegmentInfo* = ptr TXShmSegmentInfo
|
||||
TXShmSegmentInfo*{.final.} = object
|
||||
shmseg*: TShmSeg
|
||||
shmid*: cint
|
||||
shmaddr*: cstring
|
||||
readOnly*: TBool
|
||||
|
||||
|
||||
proc XShmQueryExtension*(para1: PDisplay): TBool{.cdecl, dynlib: libX11, importc.}
|
||||
proc XShmGetEventBase*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
|
||||
proc XShmQueryVersion*(para1: PDisplay, para2: Pcint, para3: Pcint, para4: PBool): TBool{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XShmPixmapFormat*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
|
||||
proc XShmAttach*(para1: PDisplay, para2: PXShmSegmentInfo): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XShmDetach*(para1: PDisplay, para2: PXShmSegmentInfo): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XShmPutImage*(para1: PDisplay, para2: TDrawable, para3: TGC,
|
||||
para4: PXImage, para5: cint, para6: cint, para7: cint,
|
||||
para8: cint, para9: cuint, para10: cuint, para11: TBool): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XShmGetImage*(para1: PDisplay, para2: TDrawable, para3: PXImage,
|
||||
para4: cint, para5: cint, para6: culong): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XShmCreateImage*(para1: PDisplay, para2: PVisual, para3: cuint,
|
||||
para4: cint, para5: cstring, para6: PXShmSegmentInfo,
|
||||
para7: cuint, para8: cuint): PXImage{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XShmCreatePixmap*(para1: PDisplay, para2: TDrawable, para3: cstring,
|
||||
para4: PXShmSegmentInfo, para5: cuint, para6: cuint,
|
||||
para7: cuint): TPixmap{.cdecl, dynlib: libX11, importc.}
|
||||
# implementation
|
||||
412
lib/base/x11/xutil.nim
Normal file
412
lib/base/x11/xutil.nim
Normal file
@@ -0,0 +1,412 @@
|
||||
|
||||
import
|
||||
x, xlib, keysym
|
||||
|
||||
#const
|
||||
# libX11* = "libX11.so"
|
||||
|
||||
#
|
||||
# Automatically converted by H2Pas 0.99.15 from xutil.h
|
||||
# The following command line parameters were used:
|
||||
# -p
|
||||
# -T
|
||||
# -S
|
||||
# -d
|
||||
# -c
|
||||
# xutil.h
|
||||
#
|
||||
|
||||
const
|
||||
NoValue* = 0x00000000
|
||||
XValue* = 0x00000001
|
||||
YValue* = 0x00000002
|
||||
WidthValue* = 0x00000004
|
||||
HeightValue* = 0x00000008
|
||||
AllValues* = 0x0000000F
|
||||
XNegative* = 0x00000010
|
||||
YNegative* = 0x00000020
|
||||
|
||||
type
|
||||
TCPoint*{.final.} = object
|
||||
x*: cint
|
||||
y*: cint
|
||||
|
||||
PXSizeHints* = ptr TXSizeHints
|
||||
TXSizeHints*{.final.} = object
|
||||
flags*: clong
|
||||
x*, y*: cint
|
||||
width*, height*: cint
|
||||
min_width*, min_height*: cint
|
||||
max_width*, max_height*: cint
|
||||
width_inc*, height_inc*: cint
|
||||
min_aspect*, max_aspect*: TCPoint
|
||||
base_width*, base_height*: cint
|
||||
win_gravity*: cint
|
||||
|
||||
|
||||
const
|
||||
USPosition* = 1 shl 0
|
||||
USSize* = 1 shl 1
|
||||
PPosition* = 1 shl 2
|
||||
PSize* = 1 shl 3
|
||||
PMinSize* = 1 shl 4
|
||||
PMaxSize* = 1 shl 5
|
||||
PResizeInc* = 1 shl 6
|
||||
PAspect* = 1 shl 7
|
||||
PBaseSize* = 1 shl 8
|
||||
PWinGravity* = 1 shl 9
|
||||
PAllHints* = PPosition or PSize or PMinSize or PMaxSize or PResizeInc or
|
||||
PAspect
|
||||
|
||||
type
|
||||
PXWMHints* = ptr TXWMHints
|
||||
TXWMHints*{.final.} = object
|
||||
flags*: clong
|
||||
input*: TBool
|
||||
initial_state*: cint
|
||||
icon_pixmap*: TPixmap
|
||||
icon_window*: TWindow
|
||||
icon_x*, icon_y*: cint
|
||||
icon_mask*: TPixmap
|
||||
window_group*: TXID
|
||||
|
||||
|
||||
const
|
||||
InputHint* = 1 shl 0
|
||||
StateHint* = 1 shl 1
|
||||
IconPixmapHint* = 1 shl 2
|
||||
IconWindowHint* = 1 shl 3
|
||||
IconPositionHint* = 1 shl 4
|
||||
IconMaskHint* = 1 shl 5
|
||||
WindowGroupHint* = 1 shl 6
|
||||
AllHints* = InputHint or StateHint or IconPixmapHint or IconWindowHint or
|
||||
IconPositionHint or IconMaskHint or WindowGroupHint
|
||||
XUrgencyHint* = 1 shl 8
|
||||
WithdrawnState* = 0
|
||||
NormalState* = 1
|
||||
IconicState* = 3
|
||||
DontCareState* = 0
|
||||
ZoomState* = 2
|
||||
InactiveState* = 4
|
||||
|
||||
type
|
||||
PXTextProperty* = ptr TXTextProperty
|
||||
TXTextProperty*{.final.} = object
|
||||
value*: pcuchar
|
||||
encoding*: TAtom
|
||||
format*: cint
|
||||
nitems*: culong
|
||||
|
||||
|
||||
const
|
||||
XNoMemory* = - 1
|
||||
XLocaleNotSupported* = - 2
|
||||
XConverterNotFound* = - 3
|
||||
|
||||
type
|
||||
PXICCEncodingStyle* = ptr TXICCEncodingStyle
|
||||
TXICCEncodingStyle* = enum
|
||||
XStringStyle, XCompoundTextStyle, XTextStyle, XStdICCTextStyle,
|
||||
XUTF8StringStyle
|
||||
PPXIconSize* = ptr PXIconSize
|
||||
PXIconSize* = ptr TXIconSize
|
||||
TXIconSize*{.final.} = object
|
||||
min_width*, min_height*: cint
|
||||
max_width*, max_height*: cint
|
||||
width_inc*, height_inc*: cint
|
||||
|
||||
PXClassHint* = ptr TXClassHint
|
||||
TXClassHint*{.final.} = object
|
||||
res_name*: cstring
|
||||
res_class*: cstring
|
||||
|
||||
|
||||
type
|
||||
PXComposeStatus* = ptr TXComposeStatus
|
||||
TXComposeStatus*{.final.} = object
|
||||
compose_ptr*: TXPointer
|
||||
chars_matched*: cint
|
||||
|
||||
|
||||
type
|
||||
PXRegion* = ptr TXRegion
|
||||
TXRegion*{.final.} = object
|
||||
TRegion* = PXRegion
|
||||
PRegion* = ptr TRegion
|
||||
|
||||
const
|
||||
RectangleOut* = 0
|
||||
RectangleIn* = 1
|
||||
RectanglePart* = 2
|
||||
|
||||
type
|
||||
PXVisualInfo* = ptr TXVisualInfo
|
||||
TXVisualInfo*{.final.} = object
|
||||
visual*: PVisual
|
||||
visualid*: TVisualID
|
||||
screen*: cint
|
||||
depth*: cint
|
||||
class_*: cint
|
||||
red_mask*: culong
|
||||
green_mask*: culong
|
||||
blue_mask*: culong
|
||||
colormap_size*: cint
|
||||
bits_per_rgb*: cint
|
||||
|
||||
|
||||
const
|
||||
VisualNoMask* = 0x00000000
|
||||
VisualIDMask* = 0x00000001
|
||||
VisualScreenMask* = 0x00000002
|
||||
VisualDepthMask* = 0x00000004
|
||||
VisualClassMask* = 0x00000008
|
||||
VisualRedMaskMask* = 0x00000010
|
||||
VisualGreenMaskMask* = 0x00000020
|
||||
VisualBlueMaskMask* = 0x00000040
|
||||
VisualColormapSizeMask* = 0x00000080
|
||||
VisualBitsPerRGBMask* = 0x00000100
|
||||
VisualAllMask* = 0x000001FF
|
||||
|
||||
type
|
||||
PPXStandardColormap* = ptr PXStandardColormap
|
||||
PXStandardColormap* = ptr TXStandardColormap
|
||||
TXStandardColormap*{.final.} = object
|
||||
colormap*: TColormap
|
||||
red_max*: culong
|
||||
red_mult*: culong
|
||||
green_max*: culong
|
||||
green_mult*: culong
|
||||
blue_max*: culong
|
||||
blue_mult*: culong
|
||||
base_pixel*: culong
|
||||
visualid*: TVisualID
|
||||
killid*: TXID
|
||||
|
||||
|
||||
const
|
||||
BitmapSuccess* = 0
|
||||
BitmapOpenFailed* = 1
|
||||
BitmapFileInvalid* = 2
|
||||
BitmapNoMemory* = 3
|
||||
XCSUCCESS* = 0
|
||||
XCNOMEM* = 1
|
||||
XCNOENT* = 2
|
||||
ReleaseByFreeingColormap*: TXID = TXID(1)
|
||||
|
||||
type
|
||||
PXContext* = ptr TXContext
|
||||
TXContext* = cint
|
||||
|
||||
proc XAllocClassHint*(): PXClassHint{.cdecl, dynlib: libX11, importc.}
|
||||
proc XAllocIconSize*(): PXIconSize{.cdecl, dynlib: libX11, importc.}
|
||||
proc XAllocSizeHints*(): PXSizeHints{.cdecl, dynlib: libX11, importc.}
|
||||
proc XAllocStandardColormap*(): PXStandardColormap{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XAllocWMHints*(): PXWMHints{.cdecl, dynlib: libX11, importc.}
|
||||
proc XClipBox*(para1: TRegion, para2: PXRectangle): cint{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XCreateRegion*(): TRegion{.cdecl, dynlib: libX11, importc.}
|
||||
proc XDefaultString*(): cstring{.cdecl, dynlib: libX11, importc.}
|
||||
proc XDeleteContext*(para1: PDisplay, para2: TXID, para3: TXContext): cint{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XDestroyRegion*(para1: TRegion): cint{.cdecl, dynlib: libX11, importc.}
|
||||
proc XEmptyRegion*(para1: TRegion): cint{.cdecl, dynlib: libX11, importc.}
|
||||
proc XEqualRegion*(para1: TRegion, para2: TRegion): cint{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XFindContext*(para1: PDisplay, para2: TXID, para3: TXContext,
|
||||
para4: PXPointer): cint{.cdecl, dynlib: libX11, importc.}
|
||||
proc XGetClassHint*(para1: PDisplay, para2: TWindow, para3: PXClassHint): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XGetIconSizes*(para1: PDisplay, para2: TWindow, para3: PPXIconSize,
|
||||
para4: Pcint): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XGetNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XGetRGBColormaps*(para1: PDisplay, para2: TWindow,
|
||||
para3: PPXStandardColormap, para4: Pcint, para5: TAtom): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XGetSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints,
|
||||
para4: TAtom): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XGetStandardColormap*(para1: PDisplay, para2: TWindow,
|
||||
para3: PXStandardColormap, para4: TAtom): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XGetTextProperty*(para1: PDisplay, para2: TWindow, para3: PXTextProperty,
|
||||
para4: TAtom): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XGetVisualInfo*(para1: PDisplay, para2: clong, para3: PXVisualInfo,
|
||||
para4: Pcint): PXVisualInfo{.cdecl, dynlib: libX11, importc.}
|
||||
proc XGetWMClientMachine*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XGetWMHints*(para1: PDisplay, para2: TWindow): PXWMHints{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XGetWMIconName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XGetWMName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XGetWMNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints,
|
||||
para4: ptr int): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||
proc XGetWMSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints,
|
||||
para4: ptr int, para5: TAtom): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XGetZoomHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): TStatus{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XIntersectRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XConvertCase*(para1: TKeySym, para2: PKeySym, para3: PKeySym){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XLookupString*(para1: PXKeyEvent, para2: cstring, para3: cint,
|
||||
para4: PKeySym, para5: PXComposeStatus): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XMatchVisualInfo*(para1: PDisplay, para2: cint, para3: cint, para4: cint,
|
||||
para5: PXVisualInfo): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XOffsetRegion*(para1: TRegion, para2: cint, para3: cint): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XPointInRegion*(para1: TRegion, para2: cint, para3: cint): TBool{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XPolygonRegion*(para1: PXPoint, para2: cint, para3: cint): TRegion{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XRectInRegion*(para1: TRegion, para2: cint, para3: cint, para4: cuint,
|
||||
para5: cuint): cint{.cdecl, dynlib: libX11, importc.}
|
||||
proc XSaveContext*(para1: PDisplay, para2: TXID, para3: TXContext,
|
||||
para4: cstring): cint{.cdecl, dynlib: libX11, importc.}
|
||||
proc XSetClassHint*(para1: PDisplay, para2: TWindow, para3: PXClassHint): cint{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XSetIconSizes*(para1: PDisplay, para2: TWindow, para3: PXIconSize,
|
||||
para4: cint): cint{.cdecl, dynlib: libX11, importc.}
|
||||
proc XSetNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): cint{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XSetRGBColormaps*(para1: PDisplay, para2: TWindow,
|
||||
para3: PXStandardColormap, para4: cint, para5: TAtom){.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XSetSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints,
|
||||
para4: TAtom): cint{.cdecl, dynlib: libX11, importc.}
|
||||
proc XSetStandardProperties*(para1: PDisplay, para2: TWindow, para3: cstring,
|
||||
para4: cstring, para5: TPixmap, para6: PPchar,
|
||||
para7: cint, para8: PXSizeHints): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XSetTextProperty*(para1: PDisplay, para2: TWindow, para3: PXTextProperty,
|
||||
para4: TAtom){.cdecl, dynlib: libX11, importc.}
|
||||
proc XSetWMClientMachine*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XSetWMHints*(para1: PDisplay, para2: TWindow, para3: PXWMHints): cint{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XSetWMIconName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XSetWMName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XSetWMNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints){.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XSetWMProperties*(para1: PDisplay, para2: TWindow, para3: PXTextProperty,
|
||||
para4: PXTextProperty, para5: PPchar, para6: cint,
|
||||
para7: PXSizeHints, para8: PXWMHints, para9: PXClassHint){.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XmbSetWMProperties*(para1: PDisplay, para2: TWindow, para3: cstring,
|
||||
para4: cstring, para5: PPchar, para6: cint,
|
||||
para7: PXSizeHints, para8: PXWMHints,
|
||||
para9: PXClassHint){.cdecl, dynlib: libX11, importc.}
|
||||
proc Xutf8SetWMProperties*(para1: PDisplay, para2: TWindow, para3: cstring,
|
||||
para4: cstring, para5: PPchar, para6: cint,
|
||||
para7: PXSizeHints, para8: PXWMHints,
|
||||
para9: PXClassHint){.cdecl, dynlib: libX11, importc.}
|
||||
proc XSetWMSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints,
|
||||
para4: TAtom){.cdecl, dynlib: libX11, importc.}
|
||||
proc XSetRegion*(para1: PDisplay, para2: TGC, para3: TRegion): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XSetStandardColormap*(para1: PDisplay, para2: TWindow,
|
||||
para3: PXStandardColormap, para4: TAtom){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XSetZoomHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): cint{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XShrinkRegion*(para1: TRegion, para2: cint, para3: cint): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XStringListToTextProperty*(para1: PPchar, para2: cint,
|
||||
para3: PXTextProperty): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XSubtractRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XmbTextListToTextProperty*(para1: PDisplay, para2: PPchar, para3: cint,
|
||||
para4: TXICCEncodingStyle, para5: PXTextProperty): cint{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XwcTextListToTextProperty*(para1: PDisplay, para2: ptr ptr int16, para3: cint,
|
||||
para4: TXICCEncodingStyle, para5: PXTextProperty): cint{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc Xutf8TextListToTextProperty*(para1: PDisplay, para2: PPchar, para3: cint,
|
||||
para4: TXICCEncodingStyle,
|
||||
para5: PXTextProperty): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XwcFreeStringList*(para1: ptr ptr int16){.cdecl, dynlib: libX11, importc.}
|
||||
proc XTextPropertyToStringList*(para1: PXTextProperty, para2: PPPchar,
|
||||
para3: Pcint): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
proc XmbTextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty,
|
||||
para3: PPPchar, para4: Pcint): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XwcTextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty,
|
||||
para3: ptr ptr ptr int16, para4: Pcint): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc Xutf8TextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty,
|
||||
para3: PPPchar, para4: Pcint): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XUnionRectWithRegion*(para1: PXRectangle, para2: TRegion, para3: TRegion): cint{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XUnionRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XWMGeometry*(para1: PDisplay, para2: cint, para3: cstring, para4: cstring,
|
||||
para5: cuint, para6: PXSizeHints, para7: Pcint, para8: Pcint,
|
||||
para9: Pcint, para10: Pcint, para11: Pcint): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XXorRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
when defined(MACROS):
|
||||
proc XDestroyImage*(ximage: PXImage): cint
|
||||
proc XGetPixel*(ximage: PXImage, x, y: cint): culong
|
||||
proc XPutPixel*(ximage: PXImage, x, y: cint, pixel: culong): cint
|
||||
proc XSubImage*(ximage: PXImage, x, y: cint, width, height: cuint): PXImage
|
||||
proc XAddPixel*(ximage: PXImage, value: clong): cint
|
||||
proc IsKeypadKey*(keysym: TKeySym): bool
|
||||
proc IsPrivateKeypadKey*(keysym: TKeySym): bool
|
||||
proc IsCursorKey*(keysym: TKeySym): bool
|
||||
proc IsPFKey*(keysym: TKeySym): bool
|
||||
proc IsFunctionKey*(keysym: TKeySym): bool
|
||||
proc IsMiscFunctionKey*(keysym: TKeySym): bool
|
||||
proc IsModifierKey*(keysym: TKeySym): bool
|
||||
#function XUniqueContext : TXContext;
|
||||
#function XStringToContext(_string : Pchar) : TXContext;
|
||||
# implementation
|
||||
|
||||
when defined(MACROS):
|
||||
proc XDestroyImage(ximage: PXImage): cint =
|
||||
XDestroyImage = ximage^ .f.destroy_image(ximage)
|
||||
|
||||
proc XGetPixel(ximage: PXImage, x, y: cint): culong =
|
||||
XGetPixel = ximage^ .f.get_pixel(ximage, x, y)
|
||||
|
||||
proc XPutPixel(ximage: PXImage, x, y: cint, pixel: culong): cint =
|
||||
XPutPixel = ximage^ .f.put_pixel(ximage, x, y, pixel)
|
||||
|
||||
proc XSubImage(ximage: PXImage, x, y: cint, width, height: cuint): PXImage =
|
||||
XSubImage = ximage^ .f.sub_image(ximage, x, y, width, height)
|
||||
|
||||
proc XAddPixel(ximage: PXImage, value: clong): cint =
|
||||
XAddPixel = ximage^ .f.add_pixel(ximage, value)
|
||||
|
||||
proc IsKeypadKey(keysym: TKeySym): bool =
|
||||
IsKeypadKey = (keysym >= XK_KP_Space) and (keysym <= XK_KP_Equal)
|
||||
|
||||
proc IsPrivateKeypadKey(keysym: TKeySym): bool =
|
||||
IsPrivateKeypadKey = (keysym >= 0x11000000) and (keysym <= 0x1100FFFF)
|
||||
|
||||
proc IsCursorKey(keysym: TKeySym): bool =
|
||||
IsCursorKey = (keysym >= XK_Home) and (keysym < XK_Select)
|
||||
|
||||
proc IsPFKey(keysym: TKeySym): bool =
|
||||
IsPFKey = (keysym >= XK_KP_F1) and (keysym <= XK_KP_F4)
|
||||
|
||||
proc IsFunctionKey(keysym: TKeySym): bool =
|
||||
IsFunctionKey = (keysym >= XK_F1) and (keysym <= XK_F35)
|
||||
|
||||
proc IsMiscFunctionKey(keysym: TKeySym): bool =
|
||||
IsMiscFunctionKey = (keysym >= XK_Select) and (keysym <= XK_Break)
|
||||
|
||||
proc IsModifierKey(keysym: TKeySym): bool =
|
||||
IsModifierKey = ((keysym >= XK_Shift_L) And (keysym <= XK_Hyper_R)) Or
|
||||
(keysym == XK_Mode_switch) Or (keysym == XK_Num_Lock)
|
||||
84
lib/base/x11/xv.nim
Normal file
84
lib/base/x11/xv.nim
Normal file
@@ -0,0 +1,84 @@
|
||||
#***********************************************************
|
||||
#Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
|
||||
#and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
#Permission to use, copy, modify, and distribute this software and its
|
||||
#documentation for any purpose and without fee is hereby granted,
|
||||
#provided that the above copyright notice appear in all copies and that
|
||||
#both that copyright notice and this permission notice appear in
|
||||
#supporting documentation, and that the names of Digital or MIT not be
|
||||
#used in advertising or publicity pertaining to distribution of the
|
||||
#software without specific, written prior permission.
|
||||
#
|
||||
#DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
#DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
#SOFTWARE.
|
||||
#
|
||||
#******************************************************************
|
||||
# $XFree86: xc/include/extensions/Xv.h,v 1.3 1999/05/23 06:33:22 dawes Exp $
|
||||
|
||||
import
|
||||
x
|
||||
|
||||
const
|
||||
XvName* = "libXVideo.so"
|
||||
XvVersion* = 2
|
||||
XvRevision* = 2 # Symbols
|
||||
|
||||
type
|
||||
TXvPortID* = TXID
|
||||
TXvEncodingID* = TXID
|
||||
|
||||
const
|
||||
XvNone* = 0
|
||||
XvInput* = 0
|
||||
XvOutput* = 1
|
||||
XvInputMask* = 1 shl XvInput
|
||||
XvOutputMask* = 1 shl XvOutput
|
||||
XvVideoMask* = 0x00000004
|
||||
XvStillMask* = 0x00000008
|
||||
XvImageMask* = 0x00000010 # These two are not client viewable
|
||||
XvPixmapMask* = 0x00010000
|
||||
XvWindowMask* = 0x00020000
|
||||
XvGettable* = 0x00000001
|
||||
XvSettable* = 0x00000002
|
||||
XvRGB* = 0
|
||||
XvYUV* = 1
|
||||
XvPacked* = 0
|
||||
XvPlanar* = 1
|
||||
XvTopToBottom* = 0
|
||||
XvBottomToTop* = 1 # Events
|
||||
XvVideoNotify* = 0
|
||||
XvPortNotify* = 1
|
||||
XvNumEvents* = 2 # Video Notify Reasons
|
||||
XvStarted* = 0
|
||||
XvStopped* = 1
|
||||
XvBusy* = 2
|
||||
XvPreempted* = 3
|
||||
XvHardError* = 4
|
||||
XvLastReason* = 4
|
||||
XvNumReasons* = XvLastReason + 1
|
||||
XvStartedMask* = 1 shl XvStarted
|
||||
XvStoppedMask* = 1 shl XvStopped
|
||||
XvBusyMask* = 1 shl XvBusy
|
||||
XvPreemptedMask* = 1 shl XvPreempted
|
||||
XvHardErrorMask* = 1 shl XvHardError
|
||||
XvAnyReasonMask* = (1 shl XvNumReasons) - 1
|
||||
XvNoReasonMask* = 0 # Errors
|
||||
XvBadPort* = 0
|
||||
XvBadEncoding* = 1
|
||||
XvBadControl* = 2
|
||||
XvNumErrors* = 3 # Status
|
||||
XvBadExtension* = 1
|
||||
XvAlreadyGrabbed* = 2
|
||||
XvInvalidTime* = 3
|
||||
XvBadReply* = 4
|
||||
XvBadAlloc* = 5
|
||||
|
||||
# implementation
|
||||
234
lib/base/x11/xvlib.nim
Normal file
234
lib/base/x11/xvlib.nim
Normal file
@@ -0,0 +1,234 @@
|
||||
#***********************************************************
|
||||
#Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
|
||||
#and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
#Permission to use, copy, modify, and distribute this software and its
|
||||
#documentation for any purpose and without fee is hereby granted,
|
||||
#provided that the above copyright notice appear in all copies and that
|
||||
#both that copyright notice and this permission notice appear in
|
||||
#supporting documentation, and that the names of Digital or MIT not be
|
||||
#used in advertising or publicity pertaining to distribution of the
|
||||
#software without specific, written prior permission.
|
||||
#
|
||||
#DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
#DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
#SOFTWARE.
|
||||
#
|
||||
#******************************************************************
|
||||
# $XFree86: xc/include/extensions/Xvlib.h,v 1.3 1999/12/11 19:28:48 mvojkovi Exp $
|
||||
#*
|
||||
#** File:
|
||||
#**
|
||||
#** Xvlib.h --- Xv library public header file
|
||||
#**
|
||||
#** Author:
|
||||
#**
|
||||
#** David Carver (Digital Workstation Engineering/Project Athena)
|
||||
#**
|
||||
#** Revisions:
|
||||
#**
|
||||
#** 26.06.91 Carver
|
||||
#** - changed XvFreeAdaptors to XvFreeAdaptorInfo
|
||||
#** - changed XvFreeEncodings to XvFreeEncodingInfo
|
||||
#**
|
||||
#** 11.06.91 Carver
|
||||
#** - changed SetPortControl to SetPortAttribute
|
||||
#** - changed GetPortControl to GetPortAttribute
|
||||
#** - changed QueryBestSize
|
||||
#**
|
||||
#** 05.15.91 Carver
|
||||
#** - version 2.0 upgrade
|
||||
#**
|
||||
#** 01.24.91 Carver
|
||||
#** - version 1.4 upgrade
|
||||
#**
|
||||
#*
|
||||
|
||||
import
|
||||
x, xlib, xshm, xv
|
||||
|
||||
const
|
||||
libXv* = "libXv.so"
|
||||
|
||||
type
|
||||
PXvRational* = ptr TXvRational
|
||||
TXvRational*{.final.} = object
|
||||
numerator*: cint
|
||||
denominator*: cint
|
||||
|
||||
PXvAttribute* = ptr TXvAttribute
|
||||
TXvAttribute*{.final.} = object
|
||||
flags*: cint # XvGettable, XvSettable
|
||||
min_value*: cint
|
||||
max_value*: cint
|
||||
name*: cstring
|
||||
|
||||
PPXvEncodingInfo* = ptr PXvEncodingInfo
|
||||
PXvEncodingInfo* = ptr TXvEncodingInfo
|
||||
TXvEncodingInfo*{.final.} = object
|
||||
encoding_id*: TXvEncodingID
|
||||
name*: cstring
|
||||
width*: culong
|
||||
height*: culong
|
||||
rate*: TXvRational
|
||||
num_encodings*: culong
|
||||
|
||||
PXvFormat* = ptr TXvFormat
|
||||
TXvFormat*{.final.} = object
|
||||
depth*: cchar
|
||||
visual_id*: culong
|
||||
|
||||
PPXvAdaptorInfo* = ptr PXvAdaptorInfo
|
||||
PXvAdaptorInfo* = ptr TXvAdaptorInfo
|
||||
TXvAdaptorInfo*{.final.} = object
|
||||
base_id*: TXvPortID
|
||||
num_ports*: culong
|
||||
thetype*: cchar
|
||||
name*: cstring
|
||||
num_formats*: culong
|
||||
formats*: PXvFormat
|
||||
num_adaptors*: culong
|
||||
|
||||
PXvVideoNotifyEvent* = ptr TXvVideoNotifyEvent
|
||||
TXvVideoNotifyEvent*{.final.} = object
|
||||
theType*: cint
|
||||
serial*: culong # # of last request processed by server
|
||||
send_event*: TBool # true if this came from a SendEvent request
|
||||
display*: PDisplay # Display the event was read from
|
||||
drawable*: TDrawable # drawable
|
||||
reason*: culong # what generated this event
|
||||
port_id*: TXvPortID # what port
|
||||
time*: TTime # milliseconds
|
||||
|
||||
PXvPortNotifyEvent* = ptr TXvPortNotifyEvent
|
||||
TXvPortNotifyEvent*{.final.} = object
|
||||
theType*: cint
|
||||
serial*: culong # # of last request processed by server
|
||||
send_event*: TBool # true if this came from a SendEvent request
|
||||
display*: PDisplay # Display the event was read from
|
||||
port_id*: TXvPortID # what port
|
||||
time*: TTime # milliseconds
|
||||
attribute*: TAtom # atom that identifies attribute
|
||||
value*: clong # value of attribute
|
||||
|
||||
PXvEvent* = ptr TXvEvent
|
||||
TXvEvent*{.final.} = object
|
||||
pad*: array[0..23, clong] #case longint of
|
||||
# 0 : (
|
||||
# theType : cint;
|
||||
# );
|
||||
# 1 : (
|
||||
# xvvideo : TXvVideoNotifyEvent;
|
||||
# );
|
||||
# 2 : (
|
||||
# xvport : TXvPortNotifyEvent;
|
||||
# );
|
||||
# 3 : (
|
||||
#
|
||||
# );
|
||||
|
||||
PXvImageFormatValues* = ptr TXvImageFormatValues
|
||||
TXvImageFormatValues*{.final.} = object
|
||||
id*: cint # Unique descriptor for the format
|
||||
theType*: cint # XvRGB, XvYUV
|
||||
byte_order*: cint # LSBFirst, MSBFirst
|
||||
guid*: array[0..15, cchar] # Globally Unique IDentifier
|
||||
bits_per_pixel*: cint
|
||||
format*: cint # XvPacked, XvPlanar
|
||||
num_planes*: cint # for RGB formats only
|
||||
depth*: cint
|
||||
red_mask*: cuint
|
||||
green_mask*: cuint
|
||||
blue_mask*: cuint # for YUV formats only
|
||||
y_sample_bits*: cuint
|
||||
u_sample_bits*: cuint
|
||||
v_sample_bits*: cuint
|
||||
horz_y_period*: cuint
|
||||
horz_u_period*: cuint
|
||||
horz_v_period*: cuint
|
||||
vert_y_period*: cuint
|
||||
vert_u_period*: cuint
|
||||
vert_v_period*: cuint
|
||||
component_order*: array[0..31, char] # eg. UYVY
|
||||
scanline_order*: cint # XvTopToBottom, XvBottomToTop
|
||||
|
||||
PXvImage* = ptr TXvImage
|
||||
TXvImage*{.final.} = object
|
||||
id*: cint
|
||||
width*, height*: cint
|
||||
data_size*: cint # bytes
|
||||
num_planes*: cint
|
||||
pitches*: pcint # bytes
|
||||
offsets*: pcint # bytes
|
||||
data*: pointer
|
||||
obdata*: TXPointer
|
||||
|
||||
|
||||
proc XvQueryExtension*(display: PDisplay, p_version, p_revision, p_requestBase,
|
||||
p_eventBase, p_errorBase: pcuint): cint{.cdecl, dynlib: libXv, importc.}
|
||||
proc XvQueryAdaptors*(display: PDisplay, window: TWindow, p_nAdaptors: pcuint,
|
||||
p_pAdaptors: PPXvAdaptorInfo): cint{.cdecl, dynlib: libXv,
|
||||
importc.}
|
||||
proc XvQueryEncodings*(display: PDisplay, port: TXvPortID, p_nEncoding: pcuint,
|
||||
p_pEncoding: PPXvEncodingInfo): cint{.cdecl,
|
||||
dynlib: libXv, importc.}
|
||||
proc XvPutVideo*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC,
|
||||
vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
|
||||
cdecl, dynlib: libXv, importc.}
|
||||
proc XvPutStill*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC,
|
||||
vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
|
||||
cdecl, dynlib: libXv, importc.}
|
||||
proc XvGetVideo*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC,
|
||||
vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
|
||||
cdecl, dynlib: libXv, importc.}
|
||||
proc XvGetStill*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC,
|
||||
vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
|
||||
cdecl, dynlib: libXv, importc.}
|
||||
proc XvStopVideo*(display: PDisplay, port: TXvPortID, drawable: TDrawable): cint{.
|
||||
cdecl, dynlib: libXv, importc.}
|
||||
proc XvGrabPort*(display: PDisplay, port: TXvPortID, time: TTime): cint{.cdecl,
|
||||
dynlib: libXv, importc.}
|
||||
proc XvUngrabPort*(display: PDisplay, port: TXvPortID, time: TTime): cint{.
|
||||
cdecl, dynlib: libXv, importc.}
|
||||
proc XvSelectVideoNotify*(display: PDisplay, drawable: TDrawable, onoff: TBool): cint{.
|
||||
cdecl, dynlib: libXv, importc.}
|
||||
proc XvSelectPortNotify*(display: PDisplay, port: TXvPortID, onoff: TBool): cint{.
|
||||
cdecl, dynlib: libXv, importc.}
|
||||
proc XvSetPortAttribute*(display: PDisplay, port: TXvPortID, attribute: TAtom,
|
||||
value: cint): cint{.cdecl, dynlib: libXv, importc.}
|
||||
proc XvGetPortAttribute*(display: PDisplay, port: TXvPortID, attribute: TAtom,
|
||||
p_value: pcint): cint{.cdecl, dynlib: libXv, importc.}
|
||||
proc XvQueryBestSize*(display: PDisplay, port: TXvPortID, motion: TBool,
|
||||
vid_w, vid_h, drw_w, drw_h: cuint,
|
||||
p_actual_width, p_actual_height: pcuint): cint{.cdecl,
|
||||
dynlib: libXv, importc.}
|
||||
proc XvQueryPortAttributes*(display: PDisplay, port: TXvPortID, number: pcint): PXvAttribute{.
|
||||
cdecl, dynlib: libXv, importc.}
|
||||
proc XvFreeAdaptorInfo*(adaptors: PXvAdaptorInfo){.cdecl, dynlib: libXv, importc.}
|
||||
proc XvFreeEncodingInfo*(encodings: PXvEncodingInfo){.cdecl, dynlib: libXv,
|
||||
importc.}
|
||||
proc XvListImageFormats*(display: PDisplay, port_id: TXvPortID,
|
||||
count_return: pcint): PXvImageFormatValues{.cdecl,
|
||||
dynlib: libXv, importc.}
|
||||
proc XvCreateImage*(display: PDisplay, port: TXvPortID, id: cint, data: pointer,
|
||||
width, height: cint): PXvImage{.cdecl, dynlib: libXv,
|
||||
importc.}
|
||||
proc XvPutImage*(display: PDisplay, id: TXvPortID, d: TDrawable, gc: TGC,
|
||||
image: PXvImage, src_x, src_y: cint, src_w, src_h: cuint,
|
||||
dest_x, dest_y: cint, dest_w, dest_h: cuint): cint{.cdecl,
|
||||
dynlib: libXv, importc.}
|
||||
proc XvShmPutImage*(display: PDisplay, id: TXvPortID, d: TDrawable, gc: TGC,
|
||||
image: PXvImage, src_x, src_y: cint, src_w, src_h: cuint,
|
||||
dest_x, dest_y: cint, dest_w, dest_h: cuint,
|
||||
send_event: TBool): cint{.cdecl, dynlib: libXv, importc.}
|
||||
proc XvShmCreateImage*(display: PDisplay, port: TXvPortID, id: cint,
|
||||
data: pointer, width, height: cint,
|
||||
shminfo: PXShmSegmentInfo): PXvImage{.cdecl,
|
||||
dynlib: libXv, importc.}
|
||||
# implementation
|
||||
241
lib/base/zip/libzip.nim
Normal file
241
lib/base/zip/libzip.nim
Normal file
@@ -0,0 +1,241 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2008 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## Interface to the `libzip <http://www.nih.at/libzip/index.html>`_ library by
|
||||
## Dieter Baron and Thomas Klausner. However, this does not need any external
|
||||
## library (DLL, lib*.so), as the source for this library is included and
|
||||
## compiled with this interface.
|
||||
|
||||
#
|
||||
# zip.h -- exported declarations.
|
||||
# Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
|
||||
#
|
||||
# This file is part of libzip, a library to manipulate ZIP archives.
|
||||
# The authors can be contacted at <libzip@nih.at>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. The names of the authors may not be used to endorse or promote
|
||||
# products derived from this software without specific prior
|
||||
# written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import times
|
||||
|
||||
{.compile: "libzip_all.c".}
|
||||
when defined(unix):
|
||||
{.passl: "-lz".}
|
||||
|
||||
type
|
||||
Tzip_source_cmd* = int32
|
||||
|
||||
Tzip_source_callback* = proc (state: pointer, data: pointer, length: int,
|
||||
cmd: Tzip_source_cmd): int {.cdecl.}
|
||||
Pzip_stat* = ptr Tzip_stat
|
||||
Tzip_stat* {.final, pure.} = object
|
||||
name*: cstring ## name of the file
|
||||
index*: int32 ## index within archive
|
||||
crc*: int32 ## crc of file data
|
||||
mtime*: TTime ## modification time
|
||||
size*: int ## size of file (uncompressed)
|
||||
comp_size*: int ## size of file (compressed)
|
||||
comp_method*: int16 ## compression method used
|
||||
encryption_method*: int16 ## encryption method used
|
||||
|
||||
Tzip {.final, pure.} = object
|
||||
Tzip_source {.final, pure.} = object
|
||||
Tzip_file {.final, pure.} = object
|
||||
|
||||
Pzip* = ptr Tzip ## represents a zip archive
|
||||
Pzip_file* = ptr Tzip_file ## represents a file within an archive
|
||||
Pzip_source* = ptr Tzip_source ## represents a source for an archive
|
||||
|
||||
|
||||
# flags for zip_name_locate, zip_fopen, zip_stat, ...
|
||||
const
|
||||
ZIP_CREATE* = 1'i32
|
||||
ZIP_EXCL* = 2'i32
|
||||
ZIP_CHECKCONS* = 4'i32
|
||||
ZIP_FL_NOCASE* = 1'i32 ## ignore case on name lookup
|
||||
ZIP_FL_NODIR* = 2'i32 ## ignore directory component
|
||||
ZIP_FL_COMPRESSED* = 4'i32 ## read compressed data
|
||||
ZIP_FL_UNCHANGED* = 8'i32 ## use original data, ignoring changes
|
||||
ZIP_FL_RECOMPRESS* = 16'i32 ## force recompression of data
|
||||
|
||||
const # archive global flags flags
|
||||
ZIP_AFL_TORRENT* = 1'i32 ## torrent zipped
|
||||
|
||||
const # libzip error codes
|
||||
ZIP_ER_OK* = 0'i32 ## N No error
|
||||
ZIP_ER_MULTIDISK* = 1'i32 ## N Multi-disk zip archives not supported
|
||||
ZIP_ER_RENAME* = 2'i32 ## S Renaming temporary file failed
|
||||
ZIP_ER_CLOSE* = 3'i32 ## S Closing zip archive failed
|
||||
ZIP_ER_SEEK* = 4'i32 ## S Seek error
|
||||
ZIP_ER_READ* = 5'i32 ## S Read error
|
||||
ZIP_ER_WRITE* = 6'i32 ## S Write error
|
||||
ZIP_ER_CRC* = 7'i32 ## N CRC error
|
||||
ZIP_ER_ZIPCLOSED* = 8'i32 ## N Containing zip archive was closed
|
||||
ZIP_ER_NOENT* = 9'i32 ## N No such file
|
||||
ZIP_ER_EXISTS* = 10'i32 ## N File already exists
|
||||
ZIP_ER_OPEN* = 11'i32 ## S Can't open file
|
||||
ZIP_ER_TMPOPEN* = 12'i32 ## S Failure to create temporary file
|
||||
ZIP_ER_ZLIB* = 13'i32 ## Z Zlib error
|
||||
ZIP_ER_MEMORY* = 14'i32 ## N Malloc failure
|
||||
ZIP_ER_CHANGED* = 15'i32 ## N Entry has been changed
|
||||
ZIP_ER_COMPNOTSUPP* = 16'i32 ## N Compression method not supported
|
||||
ZIP_ER_EOF* = 17'i32 ## N Premature EOF
|
||||
ZIP_ER_INVAL* = 18'i32 ## N Invalid argument
|
||||
ZIP_ER_NOZIP* = 19'i32 ## N Not a zip archive
|
||||
ZIP_ER_INTERNAL* = 20'i32 ## N Internal error
|
||||
ZIP_ER_INCONS* = 21'i32 ## N Zip archive inconsistent
|
||||
ZIP_ER_REMOVE* = 22'i32 ## S Can't remove file
|
||||
ZIP_ER_DELETED* = 23'i32 ## N Entry has been deleted
|
||||
|
||||
const # type of system error value
|
||||
ZIP_ET_NONE* = 0'i32 ## sys_err unused
|
||||
ZIP_ET_SYS* = 1'i32 ## sys_err is errno
|
||||
ZIP_ET_ZLIB* = 2'i32 ## sys_err is zlib error code
|
||||
|
||||
const # compression methods
|
||||
ZIP_CM_DEFAULT* = -1'i32 ## better of deflate or store
|
||||
ZIP_CM_STORE* = 0'i32 ## stored (uncompressed)
|
||||
ZIP_CM_SHRINK* = 1'i32 ## shrunk
|
||||
ZIP_CM_REDUCE_1* = 2'i32 ## reduced with factor 1
|
||||
ZIP_CM_REDUCE_2* = 3'i32 ## reduced with factor 2
|
||||
ZIP_CM_REDUCE_3* = 4'i32 ## reduced with factor 3
|
||||
ZIP_CM_REDUCE_4* = 5'i32 ## reduced with factor 4
|
||||
ZIP_CM_IMPLODE* = 6'i32 ## imploded
|
||||
## 7 - Reserved for Tokenizing compression algorithm
|
||||
ZIP_CM_DEFLATE* = 8'i32 ## deflated
|
||||
ZIP_CM_DEFLATE64* = 9'i32 ## deflate64
|
||||
ZIP_CM_PKWARE_IMPLODE* = 10'i32 ## PKWARE imploding
|
||||
## 11 - Reserved by PKWARE
|
||||
ZIP_CM_BZIP2* = 12'i32 ## compressed using BZIP2 algorithm
|
||||
## 13 - Reserved by PKWARE
|
||||
ZIP_CM_LZMA* = 14'i32 ## LZMA (EFS)
|
||||
## 15-17 - Reserved by PKWARE
|
||||
ZIP_CM_TERSE* = 18'i32 ## compressed using IBM TERSE (new)
|
||||
ZIP_CM_LZ77* = 19'i32 ## IBM LZ77 z Architecture (PFS)
|
||||
ZIP_CM_WAVPACK* = 97'i32 ## WavPack compressed data
|
||||
ZIP_CM_PPMD* = 98'i32 ## PPMd version I, Rev 1
|
||||
|
||||
const # encryption methods
|
||||
ZIP_EM_NONE* = 0'i32 ## not encrypted
|
||||
ZIP_EM_TRAD_PKWARE* = 1'i32 ## traditional PKWARE encryption
|
||||
|
||||
const
|
||||
ZIP_EM_UNKNOWN* = 0x0000FFFF'i32 ## unknown algorithm
|
||||
|
||||
const
|
||||
ZIP_SOURCE_OPEN* = 0'i32 ## prepare for reading
|
||||
ZIP_SOURCE_READ* = 1'i32 ## read data
|
||||
ZIP_SOURCE_CLOSE* = 2'i32 ## reading is done
|
||||
ZIP_SOURCE_STAT* = 3'i32 ## get meta information
|
||||
ZIP_SOURCE_ERROR* = 4'i32 ## get error information
|
||||
constZIP_SOURCE_FREE* = 5'i32 ## cleanup and free resources
|
||||
|
||||
proc zip_add*(para1: Pzip, para2: cstring, para3: Pzip_source): int32 {.cdecl,
|
||||
importc: "zip_add".}
|
||||
proc zip_add_dir*(para1: Pzip, para2: cstring): int32 {.cdecl,
|
||||
importc: "zip_add_dir".}
|
||||
proc zip_close*(para1: Pzip) {.cdecl, importc: "zip_close".}
|
||||
proc zip_delete*(para1: Pzip, para2: int32): int32 {.cdecl,
|
||||
importc: "zip_delete".}
|
||||
proc zip_error_clear*(para1: Pzip) {.cdecl, importc: "zip_error_clear".}
|
||||
proc zip_error_get*(para1: Pzip, para2: ptr int32, para3: ptr int32) {.cdecl,
|
||||
importc: "zip_error_get".}
|
||||
proc zip_error_get_sys_type*(para1: int32): int32 {.cdecl,
|
||||
importc: "zip_error_get_sys_type".}
|
||||
proc zip_error_to_str*(para1: cstring, para2: int, para3: int32,
|
||||
para4: int32): int32 {.cdecl,
|
||||
importc: "zip_error_to_str".}
|
||||
proc zip_fclose*(para1: Pzip_file) {.cdecl,
|
||||
importc: "zip_fclose".}
|
||||
proc zip_file_error_clear*(para1: Pzip_file) {.cdecl,
|
||||
importc: "zip_file_error_clear".}
|
||||
proc zip_file_error_get*(para1: Pzip_file, para2: ptr int32, para3: ptr int32) {.
|
||||
cdecl, importc: "zip_file_error_get".}
|
||||
proc zip_file_strerror*(para1: Pzip_file): cstring {.cdecl,
|
||||
importc: "zip_file_strerror".}
|
||||
proc zip_fopen*(para1: Pzip, para2: cstring, para3: int32): Pzip_file {.cdecl,
|
||||
importc: "zip_fopen".}
|
||||
proc zip_fopen_index*(para1: Pzip, para2: int32, para3: int32): Pzip_file {.
|
||||
cdecl, importc: "zip_fopen_index".}
|
||||
proc zip_fread*(para1: Pzip_file, para2: pointer, para3: int): int {.
|
||||
cdecl, importc: "zip_fread".}
|
||||
proc zip_get_archive_comment*(para1: Pzip, para2: ptr int32, para3: int32): cstring {.
|
||||
cdecl, importc: "zip_get_archive_comment".}
|
||||
proc zip_get_archive_flag*(para1: Pzip, para2: int32, para3: int32): int32 {.
|
||||
cdecl, importc: "zip_get_archive_flag".}
|
||||
proc zip_get_file_comment*(para1: Pzip, para2: int32, para3: ptr int32,
|
||||
para4: int32): cstring {.cdecl,
|
||||
importc: "zip_get_file_comment".}
|
||||
proc zip_get_name*(para1: Pzip, para2: int32, para3: int32): cstring {.cdecl,
|
||||
importc: "zip_get_name".}
|
||||
proc zip_get_num_files*(para1: Pzip): int32 {.cdecl,
|
||||
importc: "zip_get_num_files".}
|
||||
proc zip_name_locate*(para1: Pzip, para2: cstring, para3: int32): int32 {.cdecl,
|
||||
importc: "zip_name_locate".}
|
||||
proc zip_open*(para1: cstring, para2: int32, para3: ptr int32): Pzip {.cdecl,
|
||||
importc: "zip_open".}
|
||||
proc zip_rename*(para1: Pzip, para2: int32, para3: cstring): int32 {.cdecl,
|
||||
importc: "zip_rename".}
|
||||
proc zip_replace*(para1: Pzip, para2: int32, para3: Pzip_source): int32 {.cdecl,
|
||||
importc: "zip_replace".}
|
||||
proc zip_set_archive_comment*(para1: Pzip, para2: cstring, para3: int32): int32 {.
|
||||
cdecl, importc: "zip_set_archive_comment".}
|
||||
proc zip_set_archive_flag*(para1: Pzip, para2: int32, para3: int32): int32 {.
|
||||
cdecl, importc: "zip_set_archive_flag".}
|
||||
proc zip_set_file_comment*(para1: Pzip, para2: int32, para3: cstring,
|
||||
para4: int32): int32 {.cdecl,
|
||||
importc: "zip_set_file_comment".}
|
||||
proc zip_source_buffer*(para1: Pzip, para2: pointer, para3: int, para4: int32): Pzip_source {.
|
||||
cdecl, importc: "zip_source_buffer".}
|
||||
proc zip_source_file*(para1: Pzip, para2: cstring, para3: int, para4: int): Pzip_source {.
|
||||
cdecl, importc: "zip_source_file".}
|
||||
proc zip_source_filep*(para1: Pzip, para2: TFile, para3: int, para4: int): Pzip_source {.
|
||||
cdecl, importc: "zip_source_filep".}
|
||||
proc zip_source_free*(para1: Pzip_source) {.cdecl,
|
||||
importc: "zip_source_free".}
|
||||
proc zip_source_function*(para1: Pzip, para2: Tzip_source_callback,
|
||||
para3: pointer): Pzip_source {.cdecl,
|
||||
importc: "zip_source_function".}
|
||||
proc zip_source_zip*(para1: Pzip, para2: Pzip, para3: int32, para4: int32,
|
||||
para5: int, para6: int): Pzip_source {.cdecl,
|
||||
importc: "zip_source_zip".}
|
||||
proc zip_stat*(para1: Pzip, para2: cstring, para3: int32, para4: Pzip_stat): int32 {.
|
||||
cdecl, importc: "zip_stat".}
|
||||
proc zip_stat_index*(para1: Pzip, para2: int32, para3: int32, para4: Pzip_stat): int32 {.
|
||||
cdecl, importc: "zip_stat_index".}
|
||||
proc zip_stat_init*(para1: Pzip_stat) {.cdecl, importc: "zip_stat_init".}
|
||||
proc zip_strerror*(para1: Pzip): cstring {.cdecl, importc: "zip_strerror".}
|
||||
proc zip_unchange*(para1: Pzip, para2: int32): int32 {.cdecl,
|
||||
importc: "zip_unchange".}
|
||||
proc zip_unchange_all*(para1: Pzip): int32 {.cdecl, importc: "zip_unchange_all".}
|
||||
proc zip_unchange_archive*(para1: Pzip): int32 {.cdecl,
|
||||
importc: "zip_unchange_archive".}
|
||||
4189
lib/base/zip/libzip_all.c
Normal file
4189
lib/base/zip/libzip_all.c
Normal file
File diff suppressed because it is too large
Load Diff
144
lib/base/zip/zipfiles.nim
Normal file
144
lib/base/zip/zipfiles.nim
Normal file
@@ -0,0 +1,144 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2008 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implements a zip archive creator/reader/modifier.
|
||||
|
||||
import
|
||||
streams, libzip, times, os
|
||||
|
||||
type
|
||||
TZipArchive* = object of TObject ## represents a zip archive
|
||||
mode: TFileMode
|
||||
w: PZip
|
||||
|
||||
|
||||
proc zipError(z: var TZipArchive) =
|
||||
var e: ref EIO
|
||||
new(e)
|
||||
e.msg = zip_strerror(z.w)
|
||||
raise e
|
||||
|
||||
proc open*(z: var TZipArchive, filename: string, mode: TFileMode = fmRead): bool =
|
||||
## Opens a zip file for reading, writing or appending. All file modes are
|
||||
## supported. Returns true iff successful, false otherwise.
|
||||
var err, flags: int32
|
||||
case mode
|
||||
of fmRead, fmReadWriteExisting, fmAppend: flags = 0
|
||||
of fmWrite:
|
||||
if existsFile(filename): removeFile(filename)
|
||||
flags = ZIP_CREATE or ZIP_EXCL
|
||||
of fmReadWrite: flags = ZIP_CREATE
|
||||
z.w = zip_open(filename, flags, addr(err))
|
||||
z.mode = mode
|
||||
result = z.w != nil
|
||||
|
||||
proc close*(z: var TZipArchive) =
|
||||
## Closes a zip file.
|
||||
zip_close(z.w)
|
||||
|
||||
proc createDir*(z: var TZipArchive, dir: string) =
|
||||
## Creates a directory within the `z` archive. This does not fails if the
|
||||
## directory already exists. Note that for adding a file like
|
||||
## ``"path1/path2/filename"`` it is not necessary
|
||||
## to create the ``"path/path2"`` subdirectories - it will be done
|
||||
## automatically by ``addFile``.
|
||||
assert(z.mode != fmRead)
|
||||
discard zip_add_dir(z.w, dir)
|
||||
zip_error_clear(z.w)
|
||||
|
||||
proc addFile*(z: var TZipArchive, dest, src: string) =
|
||||
## Adds the file `src` to the archive `z` with the name `dest`. `dest`
|
||||
## may contain a path that will be created.
|
||||
assert(z.mode != fmRead)
|
||||
var zipsrc = zip_source_file(z.w, src, 0, -1)
|
||||
if zipsrc == nil:
|
||||
echo("Dest: " & dest)
|
||||
echo("Src: " & src)
|
||||
zipError(z)
|
||||
if zip_add(z.w, dest, zipsrc) < 0'i32:
|
||||
zip_source_free(zipsrc)
|
||||
zipError(z)
|
||||
|
||||
proc addFile*(z: var TZipArchive, file: string) =
|
||||
## A shortcut for ``addFile(z, file, file)``, i.e. the name of the source is
|
||||
## the name of the destination.
|
||||
addFile(z, file, file)
|
||||
|
||||
proc mySourceCallback(state, data: pointer, len: int,
|
||||
cmd: Tzip_source_cmd): int {.cdecl.} =
|
||||
var src = cast[PStream](state)
|
||||
case cmd
|
||||
of ZIP_SOURCE_OPEN:
|
||||
if src.setPosition != nil: src.setPosition(src, 0) # reset
|
||||
of ZIP_SOURCE_READ:
|
||||
result = src.readData(src, data, len)
|
||||
of ZIP_SOURCE_CLOSE: src.close(src)
|
||||
of ZIP_SOURCE_STAT:
|
||||
var stat = cast[PZipStat](data)
|
||||
zip_stat_init(stat)
|
||||
stat.size = high(int32)-1 # we don't know the size
|
||||
stat.mtime = getTime()
|
||||
result = sizeof(TZipStat)
|
||||
of ZIP_SOURCE_ERROR:
|
||||
var err = cast[ptr array[0..1, cint]](data)
|
||||
err[0] = ZIP_ER_INTERNAL
|
||||
err[1] = 0
|
||||
result = 2*sizeof(cint)
|
||||
of constZIP_SOURCE_FREE: GC_unref(src)
|
||||
else: assert(false)
|
||||
|
||||
proc addFile*(z: var TZipArchive, dest: string, src: PStream) =
|
||||
## Adds a file named with `dest` to the archive `z`. `dest`
|
||||
## may contain a path. The file's content is read from the `src` stream.
|
||||
assert(z.mode != fmRead)
|
||||
GC_ref(src)
|
||||
var zipsrc = zip_source_function(z.w, mySourceCallback, cast[pointer](src))
|
||||
if zipsrc == nil: zipError(z)
|
||||
if zip_add(z.w, dest, zipsrc) < 0'i32:
|
||||
zip_source_free(zipsrc)
|
||||
zipError(z)
|
||||
|
||||
# -------------- zip file stream ---------------------------------------------
|
||||
|
||||
type
|
||||
TZipFileStream = object of TStream
|
||||
f: Pzip_file
|
||||
|
||||
PZipFileStream* =
|
||||
ref TZipFileStream ## a reader stream of a file within a zip archive
|
||||
|
||||
proc fsClose(s: PZipFileStream) = zip_fclose(s.f)
|
||||
proc fsReadData(s: PZipFileStream, buffer: pointer, bufLen: int): int =
|
||||
result = zip_fread(s.f, buffer, bufLen)
|
||||
|
||||
proc newZipFileStream(f: PZipFile): PZipFileStream =
|
||||
new(result)
|
||||
result.f = f
|
||||
result.close = fsClose
|
||||
result.readData = fsReadData
|
||||
# other methods are nil!
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
proc getStream*(z: var TZipArchive, filename: string): PZipFileStream =
|
||||
## returns a stream that can be used to read the file named `filename`
|
||||
## from the archive `z`. Returns nil in case of an error.
|
||||
## The returned stream does not support the `setPosition`, `getPosition`,
|
||||
## `writeData` or `atEnd` methods.
|
||||
var x = zip_fopen(z.w, filename, 0'i32)
|
||||
if x != nil: result = newZipFileStream(x)
|
||||
|
||||
iterator walkFiles*(z: var TZipArchive): string =
|
||||
## walks over all files in the archive `z` and returns the filename
|
||||
## (including the path).
|
||||
var i = 0
|
||||
var num = int(zip_get_num_files(z.w))
|
||||
while i < num:
|
||||
yield $zip_get_name(z.w, i, 0'i32)
|
||||
inc(i)
|
||||
181
lib/base/zip/zlib.nim
Normal file
181
lib/base/zip/zlib.nim
Normal file
@@ -0,0 +1,181 @@
|
||||
# Converted from Pascal
|
||||
|
||||
## Interface to the zlib http://www.zlib.net/ compression library.
|
||||
|
||||
when defined(windows):
|
||||
const libz = "zlib1.dll"
|
||||
elif defined(macosx):
|
||||
const libz = "libz.dylib"
|
||||
else:
|
||||
const libz = "libz.so"
|
||||
|
||||
type
|
||||
Uint* = int32
|
||||
Ulong* = int
|
||||
Ulongf* = int
|
||||
Pulongf* = ptr Ulongf
|
||||
z_off_t* = int32
|
||||
pbyte* = cstring
|
||||
pbytef* = cstring
|
||||
TAllocfunc* = proc (p: pointer, items: uInt, size: uInt): pointer{.cdecl.}
|
||||
TFreeFunc* = proc (p: pointer, address: pointer){.cdecl.}
|
||||
TInternalState*{.final, pure.} = object
|
||||
PInternalState* = ptr TInternalstate
|
||||
TZStream*{.final, pure.} = object
|
||||
next_in*: pbytef
|
||||
avail_in*: uInt
|
||||
total_in*: uLong
|
||||
next_out*: pbytef
|
||||
avail_out*: uInt
|
||||
total_out*: uLong
|
||||
msg*: pbytef
|
||||
state*: PInternalState
|
||||
zalloc*: TAllocFunc
|
||||
zfree*: TFreeFunc
|
||||
opaque*: pointer
|
||||
data_type*: int32
|
||||
adler*: uLong
|
||||
reserved*: uLong
|
||||
|
||||
TZStreamRec* = TZStream
|
||||
PZstream* = ptr TZStream
|
||||
gzFile* = pointer
|
||||
|
||||
const
|
||||
Z_NO_FLUSH* = 0
|
||||
Z_PARTIAL_FLUSH* = 1
|
||||
Z_SYNC_FLUSH* = 2
|
||||
Z_FULL_FLUSH* = 3
|
||||
Z_FINISH* = 4
|
||||
Z_OK* = 0
|
||||
Z_STREAM_END* = 1
|
||||
Z_NEED_DICT* = 2
|
||||
Z_ERRNO* = -1
|
||||
Z_STREAM_ERROR* = -2
|
||||
Z_DATA_ERROR* = -3
|
||||
Z_MEM_ERROR* = -4
|
||||
Z_BUF_ERROR* = -5
|
||||
Z_VERSION_ERROR* = -6
|
||||
Z_NO_COMPRESSION* = 0
|
||||
Z_BEST_SPEED* = 1
|
||||
Z_BEST_COMPRESSION* = 9
|
||||
Z_DEFAULT_COMPRESSION* = -1
|
||||
Z_FILTERED* = 1
|
||||
Z_HUFFMAN_ONLY* = 2
|
||||
Z_DEFAULT_STRATEGY* = 0
|
||||
Z_BINARY* = 0
|
||||
Z_ASCII* = 1
|
||||
Z_UNKNOWN* = 2
|
||||
Z_DEFLATED* = 8
|
||||
Z_NULL* = 0
|
||||
|
||||
proc zlibVersion*(): cstring{.cdecl, dynlib: libz, importc: "zlibVersion".}
|
||||
proc deflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflate".}
|
||||
proc deflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateEnd".}
|
||||
proc inflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflate".}
|
||||
proc inflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateEnd".}
|
||||
proc deflateSetDictionary*(strm: var TZStream, dictionary: pbytef,
|
||||
dictLength: uInt): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateSetDictionary".}
|
||||
proc deflateCopy*(dest, source: var TZstream): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateCopy".}
|
||||
proc deflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateReset".}
|
||||
proc deflateParams*(strm: var TZStream, level: int32, strategy: int32): int32{.
|
||||
cdecl, dynlib: libz, importc: "deflateParams".}
|
||||
proc inflateSetDictionary*(strm: var TZStream, dictionary: pbytef,
|
||||
dictLength: uInt): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateSetDictionary".}
|
||||
proc inflateSync*(strm: var TZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateSync".}
|
||||
proc inflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateReset".}
|
||||
proc compress*(dest: pbytef, destLen: puLongf, source: pbytef, sourceLen: uLong): cint{.
|
||||
cdecl, dynlib: libz, importc: "compress".}
|
||||
proc compress2*(dest: pbytef, destLen: puLongf, source: pbytef,
|
||||
sourceLen: uLong, level: cint): cint{.cdecl, dynlib: libz,
|
||||
importc: "compress2".}
|
||||
proc uncompress*(dest: pbytef, destLen: puLongf, source: pbytef,
|
||||
sourceLen: uLong): cint{.cdecl, dynlib: libz,
|
||||
importc: "uncompress".}
|
||||
proc gzopen*(path: cstring, mode: cstring): gzFile{.cdecl, dynlib: libz,
|
||||
importc: "gzopen".}
|
||||
proc gzdopen*(fd: int32, mode: cstring): gzFile{.cdecl, dynlib: libz,
|
||||
importc: "gzdopen".}
|
||||
proc gzsetparams*(thefile: gzFile, level: int32, strategy: int32): int32{.cdecl,
|
||||
dynlib: libz, importc: "gzsetparams".}
|
||||
proc gzread*(thefile: gzFile, buf: pointer, length: int): int32{.cdecl,
|
||||
dynlib: libz, importc: "gzread".}
|
||||
proc gzwrite*(thefile: gzFile, buf: pointer, length: int): int32{.cdecl,
|
||||
dynlib: libz, importc: "gzwrite".}
|
||||
proc gzprintf*(thefile: gzFile, format: pbytef): int32{.varargs, cdecl,
|
||||
dynlib: libz, importc: "gzprintf".}
|
||||
proc gzputs*(thefile: gzFile, s: pbytef): int32{.cdecl, dynlib: libz,
|
||||
importc: "gzputs".}
|
||||
proc gzgets*(thefile: gzFile, buf: pbytef, length: int32): pbytef{.cdecl,
|
||||
dynlib: libz, importc: "gzgets".}
|
||||
proc gzputc*(thefile: gzFile, c: char): char{.cdecl, dynlib: libz,
|
||||
importc: "gzputc".}
|
||||
proc gzgetc*(thefile: gzFile): char{.cdecl, dynlib: libz, importc: "gzgetc".}
|
||||
proc gzflush*(thefile: gzFile, flush: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "gzflush".}
|
||||
proc gzseek*(thefile: gzFile, offset: z_off_t, whence: int32): z_off_t{.cdecl,
|
||||
dynlib: libz, importc: "gzseek".}
|
||||
proc gzrewind*(thefile: gzFile): int32{.cdecl, dynlib: libz, importc: "gzrewind".}
|
||||
proc gztell*(thefile: gzFile): z_off_t{.cdecl, dynlib: libz, importc: "gztell".}
|
||||
proc gzeof*(thefile: gzFile): int {.cdecl, dynlib: libz, importc: "gzeof".}
|
||||
proc gzclose*(thefile: gzFile): int32{.cdecl, dynlib: libz, importc: "gzclose".}
|
||||
proc gzerror*(thefile: gzFile, errnum: var int32): pbytef{.cdecl, dynlib: libz,
|
||||
importc: "gzerror".}
|
||||
proc adler32*(adler: uLong, buf: pbytef, length: uInt): uLong{.cdecl,
|
||||
dynlib: libz, importc: "adler32".}
|
||||
proc crc32*(crc: uLong, buf: pbytef, length: uInt): uLong{.cdecl, dynlib: libz,
|
||||
importc: "crc32".}
|
||||
proc deflateInitu*(strm: var TZStream, level: int32, version: cstring,
|
||||
stream_size: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateInit_".}
|
||||
proc inflateInitu*(strm: var TZStream, version: cstring,
|
||||
stream_size: int32): int32 {.
|
||||
cdecl, dynlib: libz, importc: "inflateInit_".}
|
||||
proc deflateInit*(strm: var TZStream, level: int32): int32
|
||||
proc inflateInit*(strm: var TZStream): int32
|
||||
proc deflateInit2u*(strm: var TZStream, level: int32, `method`: int32,
|
||||
windowBits: int32, memLevel: int32, strategy: int32,
|
||||
version: cstring, stream_size: int32): int32 {.cdecl,
|
||||
dynlib: libz, importc: "deflateInit2_".}
|
||||
proc inflateInit2u*(strm: var TZStream, windowBits: int32, version: cstring,
|
||||
stream_size: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateInit2_".}
|
||||
proc deflateInit2*(strm: var TZStream,
|
||||
level, `method`, windowBits, memLevel,
|
||||
strategy: int32): int32
|
||||
proc inflateInit2*(strm: var TZStream, windowBits: int32): int32
|
||||
proc zError*(err: int32): cstring{.cdecl, dynlib: libz, importc: "zError".}
|
||||
proc inflateSyncPoint*(z: PZstream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateSyncPoint".}
|
||||
proc get_crc_table*(): pointer{.cdecl, dynlib: libz, importc: "get_crc_table".}
|
||||
|
||||
proc deflateInit(strm: var TZStream, level: int32): int32 =
|
||||
result = deflateInitu(strm, level, ZLIB_VERSION(), sizeof(TZStream))
|
||||
|
||||
proc inflateInit(strm: var TZStream): int32 =
|
||||
result = inflateInitu(strm, ZLIB_VERSION(), sizeof(TZStream))
|
||||
|
||||
proc deflateInit2(strm: var TZStream,
|
||||
level, `method`, windowBits, memLevel,
|
||||
strategy: int32): int32 =
|
||||
result = deflateInit2u(strm, level, `method`, windowBits, memLevel,
|
||||
strategy, ZLIB_VERSION(), sizeof(TZStream))
|
||||
|
||||
proc inflateInit2(strm: var TZStream, windowBits: int32): int32 =
|
||||
result = inflateInit2u(strm, windowBits, ZLIB_VERSION(), sizeof(TZStream))
|
||||
|
||||
proc zlibAllocMem*(AppData: Pointer, Items, Size: int): Pointer {.cdecl.} =
|
||||
result = Alloc(Items * Size)
|
||||
|
||||
proc zlibFreeMem*(AppData, `Block`: Pointer) {.cdecl.} =
|
||||
dealloc(`Block`)
|
||||
172
lib/base/zip/zzip.nim
Normal file
172
lib/base/zip/zzip.nim
Normal file
@@ -0,0 +1,172 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2008 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module is an interface to the zzip library.
|
||||
|
||||
# Author:
|
||||
# Guido Draheim <guidod@gmx.de>
|
||||
# Tomi Ollila <Tomi.Ollila@iki.fi>
|
||||
# Copyright (c) 1999,2000,2001,2002,2003,2004 Guido Draheim
|
||||
# All rights reserved,
|
||||
# usage allowed under the restrictions of the
|
||||
# Lesser GNU General Public License
|
||||
# or alternatively the restrictions
|
||||
# of the Mozilla Public License 1.1
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
dllname = "zzip.dll"
|
||||
else:
|
||||
const
|
||||
dllname = "libzzip.so"
|
||||
|
||||
type
|
||||
TZZipError* = int32
|
||||
const
|
||||
ZZIP_ERROR* = -4096'i32
|
||||
ZZIP_NO_ERROR* = 0'i32 # no error, may be used if user sets it.
|
||||
ZZIP_OUTOFMEM* = ZZIP_ERROR - 20'i32 # out of memory
|
||||
ZZIP_DIR_OPEN* = ZZIP_ERROR - 21'i32 # failed to open zipfile, see errno for details
|
||||
ZZIP_DIR_STAT* = ZZIP_ERROR - 22'i32 # failed to fstat zipfile, see errno for details
|
||||
ZZIP_DIR_SEEK* = ZZIP_ERROR - 23'i32 # failed to lseek zipfile, see errno for details
|
||||
ZZIP_DIR_READ* = ZZIP_ERROR - 24'i32 # failed to read zipfile, see errno for details
|
||||
ZZIP_DIR_TOO_SHORT* = ZZIP_ERROR - 25'i32
|
||||
ZZIP_DIR_EDH_MISSING* = ZZIP_ERROR - 26'i32
|
||||
ZZIP_DIRSIZE* = ZZIP_ERROR - 27'i32
|
||||
ZZIP_ENOENT* = ZZIP_ERROR - 28'i32
|
||||
ZZIP_UNSUPP_COMPR* = ZZIP_ERROR - 29'i32
|
||||
ZZIP_CORRUPTED* = ZZIP_ERROR - 31'i32
|
||||
ZZIP_UNDEF* = ZZIP_ERROR - 32'i32
|
||||
ZZIP_DIR_LARGEFILE* = ZZIP_ERROR - 33'i32
|
||||
|
||||
ZZIP_CASELESS* = 1'i32 shl 12'i32
|
||||
ZZIP_NOPATHS* = 1'i32 shl 13'i32
|
||||
ZZIP_PREFERZIP* = 1'i32 shl 14'i32
|
||||
ZZIP_ONLYZIP* = 1'i32 shl 16'i32
|
||||
ZZIP_FACTORY* = 1'i32 shl 17'i32
|
||||
ZZIP_ALLOWREAL* = 1'i32 shl 18'i32
|
||||
ZZIP_THREADED* = 1'i32 shl 19'i32
|
||||
|
||||
type
|
||||
TZZipDir* {.final, pure.} = object
|
||||
TZZipFile* {.final, pure.} = object
|
||||
TZZipPluginIO* {.final, pure.} = object
|
||||
|
||||
TZZipDirent* {.final, pure.} = object
|
||||
d_compr*: int32 ## compression method
|
||||
d_csize*: int32 ## compressed size
|
||||
st_size*: int32 ## file size / decompressed size
|
||||
d_name*: cstring ## file name / strdupped name
|
||||
|
||||
TZZipStat* = TZZipDirent
|
||||
|
||||
proc zzip_strerror*(errcode: int32): cstring {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_strerror".}
|
||||
proc zzip_strerror_of*(dir: ptr TZZipDir): cstring {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_strerror_of".}
|
||||
proc zzip_errno*(errcode: int32): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_errno".}
|
||||
|
||||
proc zzip_geterror*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_error".}
|
||||
proc zzip_seterror*(dir: ptr TZZipDir, errcode: int32) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_seterror".}
|
||||
proc zzip_compr_str*(compr: int32): cstring {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_compr_str".}
|
||||
proc zzip_dirhandle*(fp: ptr TZZipFile): ptr TZZipDir {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dirhandle".}
|
||||
proc zzip_dirfd*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dirfd".}
|
||||
proc zzip_dir_real*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_real".}
|
||||
proc zzip_file_real*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_file_real".}
|
||||
proc zzip_realdir*(dir: ptr TZZipDir): pointer {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_realdir".}
|
||||
proc zzip_realfd*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_realfd".}
|
||||
|
||||
proc zzip_dir_alloc*(fileext: cstringArray): ptr TZZipDir {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_dir_alloc".}
|
||||
proc zzip_dir_free*(para1: ptr TZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_free".}
|
||||
|
||||
proc zzip_dir_fdopen*(fd: int32, errcode_p: ptr TZZipError): ptr TZZipDir {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_dir_fdopen".}
|
||||
proc zzip_dir_open*(filename: cstring, errcode_p: ptr TZZipError): ptr TZZipDir {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_dir_open".}
|
||||
proc zzip_dir_close*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_close".}
|
||||
proc zzip_dir_read*(dir: ptr TZZipDir, dirent: ptr TZZipDirent): int32 {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_dir_read".}
|
||||
|
||||
proc zzip_opendir*(filename: cstring): ptr TZZipDir {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_opendir".}
|
||||
proc zzip_closedir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_closedir".}
|
||||
proc zzip_readdir*(dir: ptr TZZipDir): ptr TZZipDirent {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_readdir".}
|
||||
proc zzip_rewinddir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_rewinddir".}
|
||||
proc zzip_telldir*(dir: ptr TZZipDir): int {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_telldir".}
|
||||
proc zzip_seekdir*(dir: ptr TZZipDir, offset: int) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_seekdir".}
|
||||
|
||||
proc zzip_file_open*(dir: ptr TZZipDir, name: cstring, flags: int32): ptr TZZipFile {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_file_open".}
|
||||
proc zzip_file_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_file_close".}
|
||||
proc zzip_file_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_file_read".}
|
||||
proc zzip_open*(name: cstring, flags: int32): ptr TZZipFile {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_open".}
|
||||
proc zzip_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_close".}
|
||||
proc zzip_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_read".}
|
||||
|
||||
proc zzip_freopen*(name: cstring, mode: cstring, para3: ptr TZZipFile): ptr TZZipFile {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_freopen".}
|
||||
proc zzip_fopen*(name: cstring, mode: cstring): ptr TZZipFile {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_fopen".}
|
||||
proc zzip_fread*(p: pointer, size: int, nmemb: int,
|
||||
file: ptr TZZipFile): int {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_fread".}
|
||||
proc zzip_fclose*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_fclose".}
|
||||
|
||||
proc zzip_rewind*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_rewind".}
|
||||
proc zzip_seek*(fp: ptr TZZipFile, offset: int, whence: int32): int {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_seek".}
|
||||
proc zzip_tell*(fp: ptr TZZipFile): int {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_tell".}
|
||||
|
||||
proc zzip_dir_stat*(dir: ptr TZZipDir, name: cstring, zs: ptr TZZipStat,
|
||||
flags: int32): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_stat".}
|
||||
proc zzip_file_stat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_file_stat".}
|
||||
proc zzip_fstat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_fstat".}
|
||||
|
||||
proc zzip_open_shared_io*(stream: ptr TZZipFile, name: cstring,
|
||||
o_flags: int32, o_modes: int32, ext: cstringArray,
|
||||
io: ptr TZZipPluginIO): ptr TZZipFile {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_open_shared_io".}
|
||||
proc zzip_open_ext_io*(name: cstring, o_flags: int32, o_modes: int32,
|
||||
ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipFile {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_open_ext_io".}
|
||||
proc zzip_opendir_ext_io*(name: cstring, o_modes: int32,
|
||||
ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_opendir_ext_io".}
|
||||
proc zzip_dir_open_ext_io*(filename: cstring, errcode_p: ptr TZZipError,
|
||||
ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_dir_open_ext_io".}
|
||||
Reference in New Issue
Block a user