tests: Trim .nim files trailing whitespace
via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
This commit is contained in:
parent
ac9c1cd6b9
commit
e80465dacf
372 changed files with 4486 additions and 4486 deletions
|
|
@ -1,15 +1,15 @@
|
|||
# Copyright (c) 2007 Scott Lembcke
|
||||
#
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
#
|
||||
|
||||
const Lib = "libchipmunk.so.6.1.1"
|
||||
|
||||
|
|
@ -30,12 +30,12 @@ when defined(CpUseFloat):
|
|||
type CpFloat* = cfloat
|
||||
else:
|
||||
type CpFloat* = cdouble
|
||||
const
|
||||
CP_BUFFER_BYTES* = (32 * 1024)
|
||||
const
|
||||
CP_BUFFER_BYTES* = (32 * 1024)
|
||||
CP_MAX_CONTACTS_PER_ARBITER* = 4
|
||||
CpInfinity*: CpFloat = 1.0/0
|
||||
{.pragma: pf, pure, final.}
|
||||
type
|
||||
type
|
||||
Bool32* = cint #replace one day with cint-compatible bool
|
||||
CpDataPointer* = pointer
|
||||
TVector* {.final, pure.} = object
|
||||
|
|
@ -44,12 +44,12 @@ type
|
|||
TBodyVelocityFunc* = proc(body: PBody, gravity: TVector,
|
||||
damping: CpFloat; dt: CpFloat){.cdecl.}
|
||||
TBodyPositionFunc* = proc(body: PBody; dt: CpFloat){.cdecl.}
|
||||
TComponentNode*{.pf.} = object
|
||||
TComponentNode*{.pf.} = object
|
||||
root*: PBody
|
||||
next*: PBody
|
||||
idleTime*: CpFloat
|
||||
|
||||
THashValue = cuint # uintptr_t
|
||||
|
||||
THashValue = cuint # uintptr_t
|
||||
TCollisionType* = cuint #uintptr_t
|
||||
TGroup * = cuint #uintptr_t
|
||||
TLayers* = cuint
|
||||
|
|
@ -60,9 +60,9 @@ type
|
|||
PContact* = ptr TContact
|
||||
TContact*{.pure,final.} = object
|
||||
PArbiter* = ptr TArbiter
|
||||
TArbiter*{.pf.} = object
|
||||
TArbiter*{.pf.} = object
|
||||
e*: CpFloat
|
||||
u*: CpFloat
|
||||
u*: CpFloat
|
||||
surface_vr*: TVector
|
||||
a*: PShape
|
||||
b*: PShape
|
||||
|
|
@ -77,7 +77,7 @@ type
|
|||
swappedColl*: Bool32
|
||||
state*: TArbiterState
|
||||
PCollisionHandler* = ptr TCollisionHandler
|
||||
TCollisionHandler*{.pf.} = object
|
||||
TCollisionHandler*{.pf.} = object
|
||||
a*: TCollisionType
|
||||
b*: TCollisionType
|
||||
begin*: TCollisionBeginFunc
|
||||
|
|
@ -85,26 +85,26 @@ type
|
|||
postSolve*: TCollisionPostSolveFunc
|
||||
separate*: TCollisionSeparateFunc
|
||||
data*: pointer
|
||||
TArbiterState*{.size: sizeof(cint).} = enum
|
||||
TArbiterState*{.size: sizeof(cint).} = enum
|
||||
ArbiterStateFirstColl, # Arbiter is active and its not the first collision.
|
||||
ArbiterStateNormal, # Collision has been explicitly ignored.
|
||||
# Either by returning false from a begin collision handler or calling cpArbiterIgnore().
|
||||
ArbiterStateIgnore, # Collison is no longer active. A space will cache an arbiter for up to cpSpace.collisionPersistence more steps.
|
||||
ArbiterStateCached
|
||||
TArbiterThread*{.pf.} = object
|
||||
TArbiterThread*{.pf.} = object
|
||||
next*: PArbiter # Links to next and previous arbiters in the contact graph.
|
||||
prev*: PArbiter
|
||||
|
||||
TContactPoint*{.pf.} = object
|
||||
|
||||
TContactPoint*{.pf.} = object
|
||||
point*: TVector #/ The position of the contact point.
|
||||
normal*: TVector #/ The normal of the contact point.
|
||||
dist*: CpFloat #/ The depth of the contact point.
|
||||
#/ A struct that wraps up the important collision data for an arbiter.
|
||||
PContactPointSet* = ptr TContactPointSet
|
||||
TContactPointSet*{.pf.} = object
|
||||
TContactPointSet*{.pf.} = object
|
||||
count*: cint #/ The number of contact points in the set.
|
||||
points*: array[0..CP_MAX_CONTACTS_PER_ARBITER - 1, TContactPoint] #/ The array of contact points.
|
||||
|
||||
|
||||
#/ Collision begin event function callback type.
|
||||
#/ Returning false from a begin callback causes the collision to be ignored until
|
||||
#/ the the separate callback is called when the objects stop colliding.
|
||||
|
|
@ -112,35 +112,35 @@ type
|
|||
cdecl.}
|
||||
#/ Collision pre-solve event function callback type.
|
||||
#/ Returning false from a pre-step callback causes the collision to be ignored until the next step.
|
||||
TCollisionPreSolveFunc* = proc (arb: PArbiter; space: PSpace;
|
||||
TCollisionPreSolveFunc* = proc (arb: PArbiter; space: PSpace;
|
||||
data: pointer): bool {.cdecl.}
|
||||
#/ Collision post-solve event function callback type.
|
||||
TCollisionPostSolveFunc* = proc (arb: PArbiter; space: PSpace;
|
||||
TCollisionPostSolveFunc* = proc (arb: PArbiter; space: PSpace;
|
||||
data: pointer){.cdecl.}
|
||||
#/ Collision separate event function callback type.
|
||||
TCollisionSeparateFunc* = proc (arb: PArbiter; space: PSpace;
|
||||
TCollisionSeparateFunc* = proc (arb: PArbiter; space: PSpace;
|
||||
data: pointer){.cdecl.}
|
||||
|
||||
|
||||
#/ Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top)
|
||||
PBB* = ptr TBB
|
||||
TBB* {.pf.} = object
|
||||
TBB* {.pf.} = object
|
||||
l*, b*, r*, t*: CpFloat
|
||||
|
||||
|
||||
#/ Spatial index bounding box callback function type.
|
||||
#/ The spatial index calls this function and passes you a pointer to an object you added
|
||||
#/ when it needs to get the bounding box associated with that object.
|
||||
TSpatialIndexBBFunc* = proc (obj: pointer): TBB{.cdecl.}
|
||||
#/ Spatial index/object iterator callback function type.
|
||||
TSpatialIndexIteratorFunc* = proc (obj: pointer; data: pointer){.cdecl.}
|
||||
#/ Spatial query callback function type.
|
||||
#/ Spatial query callback function type.
|
||||
TSpatialIndexQueryFunc* = proc (obj1: pointer; obj2: pointer; data: pointer){.
|
||||
cdecl.}
|
||||
#/ Spatial segment query callback function type.
|
||||
TSpatialIndexSegmentQueryFunc* = proc (obj1: pointer; obj2: pointer;
|
||||
TSpatialIndexSegmentQueryFunc* = proc (obj1: pointer; obj2: pointer;
|
||||
data: pointer): CpFloat {.cdecl.}
|
||||
#/ private
|
||||
PSpatialIndex = ptr TSpatialIndex
|
||||
TSpatialIndex{.pf.} = object
|
||||
TSpatialIndex{.pf.} = object
|
||||
klass: PSpatialIndexClass
|
||||
bbfun: TSpatialIndexBBFunc
|
||||
staticIndex: PSpatialIndex
|
||||
|
|
@ -148,31 +148,31 @@ type
|
|||
|
||||
TSpatialIndexDestroyImpl* = proc (index: PSpatialIndex){.cdecl.}
|
||||
TSpatialIndexCountImpl* = proc (index: PSpatialIndex): cint{.cdecl.}
|
||||
TSpatialIndexEachImpl* = proc (index: PSpatialIndex;
|
||||
TSpatialIndexEachImpl* = proc (index: PSpatialIndex;
|
||||
fun: TSpatialIndexIteratorFunc; data: pointer){.
|
||||
cdecl.}
|
||||
TSpatialIndexContainsImpl* = proc (index: PSpatialIndex; obj: pointer;
|
||||
TSpatialIndexContainsImpl* = proc (index: PSpatialIndex; obj: pointer;
|
||||
hashid: THashValue): Bool32 {.cdecl.}
|
||||
TSpatialIndexInsertImpl* = proc (index: PSpatialIndex; obj: pointer;
|
||||
TSpatialIndexInsertImpl* = proc (index: PSpatialIndex; obj: pointer;
|
||||
hashid: THashValue){.cdecl.}
|
||||
TSpatialIndexRemoveImpl* = proc (index: PSpatialIndex; obj: pointer;
|
||||
TSpatialIndexRemoveImpl* = proc (index: PSpatialIndex; obj: pointer;
|
||||
hashid: THashValue){.cdecl.}
|
||||
TSpatialIndexReindexImpl* = proc (index: PSpatialIndex){.cdecl.}
|
||||
TSpatialIndexReindexObjectImpl* = proc (index: PSpatialIndex;
|
||||
TSpatialIndexReindexObjectImpl* = proc (index: PSpatialIndex;
|
||||
obj: pointer; hashid: THashValue){.cdecl.}
|
||||
TSpatialIndexReindexQueryImpl* = proc (index: PSpatialIndex;
|
||||
TSpatialIndexReindexQueryImpl* = proc (index: PSpatialIndex;
|
||||
fun: TSpatialIndexQueryFunc; data: pointer){.cdecl.}
|
||||
TSpatialIndexPointQueryImpl* = proc (index: PSpatialIndex; point: TVector;
|
||||
fun: TSpatialIndexQueryFunc;
|
||||
TSpatialIndexPointQueryImpl* = proc (index: PSpatialIndex; point: TVector;
|
||||
fun: TSpatialIndexQueryFunc;
|
||||
data: pointer){.cdecl.}
|
||||
TSpatialIndexSegmentQueryImpl* = proc (index: PSpatialIndex; obj: pointer;
|
||||
a: TVector; b: TVector; t_exit: CpFloat; fun: TSpatialIndexSegmentQueryFunc;
|
||||
TSpatialIndexSegmentQueryImpl* = proc (index: PSpatialIndex; obj: pointer;
|
||||
a: TVector; b: TVector; t_exit: CpFloat; fun: TSpatialIndexSegmentQueryFunc;
|
||||
data: pointer){.cdecl.}
|
||||
TSpatialIndexQueryImpl* = proc (index: PSpatialIndex; obj: pointer;
|
||||
bb: TBB; fun: TSpatialIndexQueryFunc;
|
||||
TSpatialIndexQueryImpl* = proc (index: PSpatialIndex; obj: pointer;
|
||||
bb: TBB; fun: TSpatialIndexQueryFunc;
|
||||
data: pointer){.cdecl.}
|
||||
PSpatialIndexClass* = ptr TSpatialIndexClass
|
||||
TSpatialIndexClass*{.pf.} = object
|
||||
TSpatialIndexClass*{.pf.} = object
|
||||
destroy*: TSpatialIndexDestroyImpl
|
||||
count*: TSpatialIndexCountImpl
|
||||
each*: TSpatialIndexEachImpl
|
||||
|
|
@ -185,32 +185,32 @@ type
|
|||
pointQuery*: TSpatialIndexPointQueryImpl
|
||||
segmentQuery*: TSpatialIndexSegmentQueryImpl
|
||||
query*: TSpatialIndexQueryImpl
|
||||
|
||||
|
||||
PSpaceHash* = ptr TSpaceHash
|
||||
TSpaceHash* {.pf.} = object
|
||||
PBBTree* = ptr TBBTree
|
||||
TBBTree* {.pf.} = object
|
||||
PSweep1D* = ptr TSweep1D
|
||||
TSweep1D* {.pf.} = object
|
||||
|
||||
|
||||
#/ Bounding box tree velocity callback function.
|
||||
#/ This function should return an estimate for the object's velocity.
|
||||
TBBTreeVelocityFunc* = proc (obj: pointer): TVector {.cdecl.}
|
||||
|
||||
|
||||
PContactBufferHeader* = ptr TContentBufferHeader
|
||||
TContentBufferHeader* {.pf.} = object
|
||||
TSpaceArbiterApplyImpulseFunc* = proc (arb: PArbiter){.cdecl.}
|
||||
|
||||
|
||||
PSpace* = ptr TSpace
|
||||
TSpace* {.pf.} = object
|
||||
iterations*: cint
|
||||
iterations*: cint
|
||||
gravity*: TVector
|
||||
damping*: CpFloat
|
||||
idleSpeedThreshold*: CpFloat
|
||||
sleepTimeThreshold*: CpFloat
|
||||
collisionSlop*: CpFloat
|
||||
idleSpeedThreshold*: CpFloat
|
||||
sleepTimeThreshold*: CpFloat
|
||||
collisionSlop*: CpFloat
|
||||
collisionBias*: CpFloat
|
||||
collisionPersistence*: TTimestamp
|
||||
collisionPersistence*: TTimestamp
|
||||
enableContactGraph*: cint ##BOOL
|
||||
data*: pointer
|
||||
staticBody*: PBody
|
||||
|
|
@ -232,24 +232,24 @@ type
|
|||
defaultHandler: TCollisionHandler
|
||||
postStepCallbacks: PHashSet
|
||||
arbiterApplyImpulse: TSpaceArbiterApplyImpulseFunc
|
||||
staticBody2: TBody #_staticBody
|
||||
staticBody2: TBody #_staticBody
|
||||
PBody* = ptr TBody
|
||||
TBody*{.pf.} = object
|
||||
velocityFunc*: TBodyVelocityFunc
|
||||
positionFunc*: TBodyPositionFunc
|
||||
m*: CpFloat
|
||||
mInv*: CpFloat
|
||||
i*: CpFloat
|
||||
iInv*: CpFloat
|
||||
p*: TVector
|
||||
v*: TVector
|
||||
f*: TVector
|
||||
a*: CpFloat
|
||||
w*: CpFloat
|
||||
t*: CpFloat
|
||||
rot*: TVector
|
||||
TBody*{.pf.} = object
|
||||
velocityFunc*: TBodyVelocityFunc
|
||||
positionFunc*: TBodyPositionFunc
|
||||
m*: CpFloat
|
||||
mInv*: CpFloat
|
||||
i*: CpFloat
|
||||
iInv*: CpFloat
|
||||
p*: TVector
|
||||
v*: TVector
|
||||
f*: TVector
|
||||
a*: CpFloat
|
||||
w*: CpFloat
|
||||
t*: CpFloat
|
||||
rot*: TVector
|
||||
data*: pointer
|
||||
vLimit*: CpFloat
|
||||
vLimit*: CpFloat
|
||||
wLimit*: CpFloat
|
||||
vBias*: TVector
|
||||
wBias*: CpFloat
|
||||
|
|
@ -258,51 +258,51 @@ type
|
|||
arbiterList*: PArbiter
|
||||
constraintList*: PConstraint
|
||||
node*: TComponentNode
|
||||
#/ Body/shape iterator callback function type.
|
||||
TBodyShapeIteratorFunc* = proc (body: PBody; shape: PShape;
|
||||
#/ Body/shape iterator callback function type.
|
||||
TBodyShapeIteratorFunc* = proc (body: PBody; shape: PShape;
|
||||
data: pointer) {.cdecl.}
|
||||
#/ Body/constraint iterator callback function type.
|
||||
TBodyConstraintIteratorFunc* = proc (body: PBody;
|
||||
constraint: PConstraint;
|
||||
#/ Body/constraint iterator callback function type.
|
||||
TBodyConstraintIteratorFunc* = proc (body: PBody;
|
||||
constraint: PConstraint;
|
||||
data: pointer) {.cdecl.}
|
||||
#/ Body/arbiter iterator callback function type.
|
||||
TBodyArbiterIteratorFunc* = proc (body: PBody; arbiter: PArbiter;
|
||||
#/ Body/arbiter iterator callback function type.
|
||||
TBodyArbiterIteratorFunc* = proc (body: PBody; arbiter: PArbiter;
|
||||
data: pointer) {.cdecl.}
|
||||
|
||||
|
||||
PNearestPointQueryInfo* = ptr TNearestPointQueryInfo
|
||||
#/ Nearest point query info struct.
|
||||
TNearestPointQueryInfo*{.pf.} = object
|
||||
shape: PShape #/ The nearest shape, NULL if no shape was within range.
|
||||
p: TVector #/ The closest point on the shape's surface. (in world space coordinates)
|
||||
d: CpFloat #/ The distance to the point. The distance is negative if the point is inside the shape.
|
||||
|
||||
|
||||
PSegmentQueryInfo* = ptr TSegmentQueryInfo
|
||||
#/ Segment query info struct.
|
||||
TSegmentQueryInfo*{.pf.} = object
|
||||
TSegmentQueryInfo*{.pf.} = object
|
||||
shape*: PShape #/ The shape that was hit, NULL if no collision occurred.
|
||||
t*: CpFloat #/ The normalized distance along the query segment in the range [0, 1].
|
||||
n*: TVector #/ The normal of the surface hit.
|
||||
TShapeType*{.size: sizeof(cint).} = enum
|
||||
TShapeType*{.size: sizeof(cint).} = enum
|
||||
CP_CIRCLE_SHAPE, CP_SEGMENT_SHAPE, CP_POLY_SHAPE, CP_NUM_SHAPES
|
||||
TShapeCacheDataImpl* = proc (shape: PShape; p: TVector; rot: TVector): TBB{.cdecl.}
|
||||
TShapeDestroyImpl* = proc (shape: PShape){.cdecl.}
|
||||
TShapePointQueryImpl* = proc (shape: PShape; p: TVector): Bool32 {.cdecl.}
|
||||
TShapeSegmentQueryImpl* = proc (shape: PShape; a: TVector; b: TVector;
|
||||
TShapeSegmentQueryImpl* = proc (shape: PShape; a: TVector; b: TVector;
|
||||
info: PSegmentQueryInfo){.cdecl.}
|
||||
PShapeClass* = ptr TShapeClass
|
||||
TShapeClass*{.pf.} = object
|
||||
TShapeClass*{.pf.} = object
|
||||
kind*: TShapeType
|
||||
cacheData*: TShapeCacheDataImpl
|
||||
destroy*: TShapeDestroyImpl
|
||||
pointQuery*: TShapePointQueryImpl
|
||||
segmentQuery*: TShapeSegmentQueryImpl
|
||||
PShape* = ptr TShape
|
||||
TShape*{.pf.} = object
|
||||
TShape*{.pf.} = object
|
||||
klass: PShapeClass #/ PRIVATE
|
||||
body*: PBody #/ The rigid body this collision shape is attached to.
|
||||
bb*: TBB #/ The current bounding box of the shape.
|
||||
bb*: TBB #/ The current bounding box of the shape.
|
||||
sensor*: Bool32 #/ Sensor flag.
|
||||
#/ Sensor shapes call collision callbacks but don't produce collisions.
|
||||
#/ Sensor shapes call collision callbacks but don't produce collisions.
|
||||
e*: CpFloat #/ Coefficient of restitution. (elasticity)
|
||||
u*: CpFloat #/ Coefficient of friction.
|
||||
surface_v*: TVector #/ Surface velocity used when solving for friction.
|
||||
|
|
@ -336,29 +336,29 @@ type
|
|||
TSplittingPlane*{.pf.} = object
|
||||
n: TVector
|
||||
d: CpFloat
|
||||
|
||||
|
||||
#/ Post Step callback function type.
|
||||
TPostStepFunc* = proc (space: PSpace; obj: pointer; data: pointer){.cdecl.}
|
||||
#/ Point query callback function type.
|
||||
TSpacePointQueryFunc* = proc (shape: PShape; data: pointer){.cdecl.}
|
||||
#/ Segment query callback function type.
|
||||
TSpaceSegmentQueryFunc* = proc (shape: PShape; t: CpFloat; n: TVector;
|
||||
TSpaceSegmentQueryFunc* = proc (shape: PShape; t: CpFloat; n: TVector;
|
||||
data: pointer){.cdecl.}
|
||||
#/ Rectangle Query callback function type.
|
||||
TSpaceBBQueryFunc* = proc (shape: PShape; data: pointer){.cdecl.}
|
||||
#/ Shape query callback function type.
|
||||
TSpaceShapeQueryFunc* = proc (shape: PShape; points: PContactPointSet;
|
||||
TSpaceShapeQueryFunc* = proc (shape: PShape; points: PContactPointSet;
|
||||
data: pointer){.cdecl.}
|
||||
#/ Space/body iterator callback function type.
|
||||
TSpaceBodyIteratorFunc* = proc (body: PBody; data: pointer){.cdecl.}
|
||||
#/ Space/body iterator callback function type.
|
||||
TSpaceShapeIteratorFunc* = proc (shape: PShape; data: pointer){.cdecl.}
|
||||
#/ Space/constraint iterator callback function type.
|
||||
TSpaceConstraintIteratorFunc* = proc (constraint: PConstraint;
|
||||
TSpaceConstraintIteratorFunc* = proc (constraint: PConstraint;
|
||||
data: pointer){.cdecl.}
|
||||
#/ Opaque cpConstraint struct.
|
||||
PConstraint* = ptr TConstraint
|
||||
TConstraint*{.pf.} = object
|
||||
TConstraint*{.pf.} = object
|
||||
klass: PConstraintClass #/PRIVATE
|
||||
a*: PBody #/ The first body connected to this constraint.
|
||||
b*: PBody #/ The second body connected to this constraint.
|
||||
|
|
@ -367,7 +367,7 @@ type
|
|||
next_b: PConstraint #/PRIVATE
|
||||
maxForce*: CpFloat #/ The maximum force that this constraint is allowed to use. Defaults to infinity.
|
||||
errorBias*: CpFloat #/ The rate at which joint error is corrected. Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
|
||||
maxBias*: CpFloat #/ The maximum rate at which joint error is corrected. Defaults to infinity.
|
||||
maxBias*: CpFloat #/ The maximum rate at which joint error is corrected. Defaults to infinity.
|
||||
preSolve*: TConstraintPreSolveFunc #/ Function called before the solver runs. Animate your joint anchors, update your motor torque, etc.
|
||||
postSolve*: TConstraintPostSolveFunc #/ Function called after the solver runs. Use the applied impulse to perform effects like breakable joints.
|
||||
data*: CpDataPointer # User definable data pointer. Generally this points to your the game object class so you can access it when given a cpConstraint reference in a callback.
|
||||
|
|
@ -376,7 +376,7 @@ type
|
|||
TConstraintApplyImpulseImpl = proc (constraint: PConstraint){.cdecl.}
|
||||
TConstraintGetImpulseImpl = proc (constraint: PConstraint): CpFloat{.cdecl.}
|
||||
PConstraintClass = ptr TConstraintClass
|
||||
TConstraintClass{.pf.} = object
|
||||
TConstraintClass{.pf.} = object
|
||||
preStep*: TConstraintPreStepImpl
|
||||
applyCachedImpulse*: TConstraintApplyCachedImpulseImpl
|
||||
applyImpulse*: TConstraintApplyImpulseImpl
|
||||
|
|
@ -427,29 +427,29 @@ defGetter(PSpace, CpFloat, currDt, CurrentTimeStep)
|
|||
|
||||
|
||||
#/ returns true from inside a callback and objects cannot be added/removed.
|
||||
proc isLocked*(space: PSpace): bool{.inline.} =
|
||||
proc isLocked*(space: PSpace): bool{.inline.} =
|
||||
result = space.locked.bool
|
||||
|
||||
#/ Set a default collision handler for this space.
|
||||
#/ The default collision handler is invoked for each colliding pair of shapes
|
||||
#/ that isn't explicitly handled by a specific collision handler.
|
||||
#/ You can pass NULL for any function you don't want to implement.
|
||||
proc setDefaultCollisionHandler*(space: PSpace; begin: TCollisionBeginFunc;
|
||||
preSolve: TCollisionPreSolveFunc;
|
||||
postSolve: TCollisionPostSolveFunc;
|
||||
separate: TCollisionSeparateFunc;
|
||||
proc setDefaultCollisionHandler*(space: PSpace; begin: TCollisionBeginFunc;
|
||||
preSolve: TCollisionPreSolveFunc;
|
||||
postSolve: TCollisionPostSolveFunc;
|
||||
separate: TCollisionSeparateFunc;
|
||||
data: pointer){.
|
||||
cdecl, importc: "cpSpaceSetDefaultCollisionHandler", dynlib: Lib.}
|
||||
#/ Set a collision handler to be used whenever the two shapes with the given collision types collide.
|
||||
#/ You can pass NULL for any function you don't want to implement.
|
||||
proc addCollisionHandler*(space: PSpace; a, b: TCollisionType;
|
||||
begin: TCollisionBeginFunc;
|
||||
preSolve: TCollisionPreSolveFunc;
|
||||
postSolve: TCollisionPostSolveFunc;
|
||||
proc addCollisionHandler*(space: PSpace; a, b: TCollisionType;
|
||||
begin: TCollisionBeginFunc;
|
||||
preSolve: TCollisionPreSolveFunc;
|
||||
postSolve: TCollisionPostSolveFunc;
|
||||
separate: TCollisionSeparateFunc; data: pointer){.
|
||||
cdecl, importc: "cpSpaceAddCollisionHandler", dynlib: Lib.}
|
||||
#/ Unset a collision handler.
|
||||
proc removeCollisionHandler*(space: PSpace; a: TCollisionType;
|
||||
proc removeCollisionHandler*(space: PSpace; a: TCollisionType;
|
||||
b: TCollisionType){.
|
||||
cdecl, importc: "cpSpaceRemoveCollisionHandler", dynlib: Lib.}
|
||||
#/ Add a collision shape to the simulation.
|
||||
|
|
@ -489,34 +489,34 @@ proc containsConstraint*(space: PSpace; constraint: PConstraint): bool{.
|
|||
cdecl, importc: "cpSpaceContainsConstraint", dynlib: Lib.}
|
||||
#/ Schedule a post-step callback to be called when cpSpaceStep() finishes.
|
||||
#/ @c obj is used a key, you can only register one callback per unique value for @c obj
|
||||
proc addPostStepCallback*(space: PSpace; fun: TPostStepFunc;
|
||||
proc addPostStepCallback*(space: PSpace; fun: TPostStepFunc;
|
||||
obj: pointer; data: pointer){.
|
||||
cdecl, importc: "cpSpaceAddPostStepCallback", dynlib: Lib.}
|
||||
|
||||
|
||||
#/ Query the space at a point and call @c func for each shape found.
|
||||
proc pointQuery*(space: PSpace; point: TVector; layers: TLayers;
|
||||
proc pointQuery*(space: PSpace; point: TVector; layers: TLayers;
|
||||
group: TGroup; fun: TSpacePointQueryFunc; data: pointer){.
|
||||
cdecl, importc: "cpSpacePointQuery", dynlib: Lib.}
|
||||
|
||||
#/ Query the space at a point and return the first shape found. Returns NULL if no shapes were found.
|
||||
proc pointQueryFirst*(space: PSpace; point: TVector; layers: TLayers;
|
||||
proc pointQueryFirst*(space: PSpace; point: TVector; layers: TLayers;
|
||||
group: TGroup): PShape{.
|
||||
cdecl, importc: "cpSpacePointQueryFirst", dynlib: Lib.}
|
||||
|
||||
#/ Perform a directed line segment query (like a raycast) against the space calling @c func for each shape intersected.
|
||||
proc segmentQuery*(space: PSpace; start: TVector; to: TVector;
|
||||
layers: TLayers; group: TGroup;
|
||||
proc segmentQuery*(space: PSpace; start: TVector; to: TVector;
|
||||
layers: TLayers; group: TGroup;
|
||||
fun: TSpaceSegmentQueryFunc; data: pointer){.
|
||||
cdecl, importc: "cpSpaceSegmentQuery", dynlib: Lib.}
|
||||
#/ Perform a directed line segment query (like a raycast) against the space and return the first shape hit. Returns NULL if no shapes were hit.
|
||||
proc segmentQueryFirst*(space: PSpace; start: TVector; to: TVector;
|
||||
layers: TLayers; group: TGroup;
|
||||
proc segmentQueryFirst*(space: PSpace; start: TVector; to: TVector;
|
||||
layers: TLayers; group: TGroup;
|
||||
res: PSegmentQueryInfo): PShape{.
|
||||
cdecl, importc: "cpSpaceSegmentQueryFirst", dynlib: Lib.}
|
||||
|
||||
#/ Perform a fast rectangle query on the space calling @c func for each shape found.
|
||||
#/ Only the shape's bounding boxes are checked for overlap, not their full shape.
|
||||
proc BBQuery*(space: PSpace; bb: TBB; layers: TLayers; group: TGroup;
|
||||
proc BBQuery*(space: PSpace; bb: TBB; layers: TLayers; group: TGroup;
|
||||
fun: TSpaceBBQueryFunc; data: pointer){.
|
||||
cdecl, importc: "cpSpaceBBQuery", dynlib: Lib.}
|
||||
|
||||
|
|
@ -532,11 +532,11 @@ proc eachBody*(space: PSpace; fun: TSpaceBodyIteratorFunc; data: pointer){.
|
|||
cdecl, importc: "cpSpaceEachBody", dynlib: Lib.}
|
||||
|
||||
#/ Call @c func for each shape in the space.
|
||||
proc eachShape*(space: PSpace; fun: TSpaceShapeIteratorFunc;
|
||||
proc eachShape*(space: PSpace; fun: TSpaceShapeIteratorFunc;
|
||||
data: pointer){.
|
||||
cdecl, importc: "cpSpaceEachShape", dynlib: Lib.}
|
||||
#/ Call @c func for each shape in the space.
|
||||
proc eachConstraint*(space: PSpace; fun: TSpaceConstraintIteratorFunc;
|
||||
proc eachConstraint*(space: PSpace; fun: TSpaceConstraintIteratorFunc;
|
||||
data: pointer){.
|
||||
cdecl, importc: "cpSpaceEachConstraint", dynlib: Lib.}
|
||||
#/ Update the collision detection info for the static shapes in the space.
|
||||
|
|
@ -566,7 +566,7 @@ proc newVector*(x, y: CpFloat): TVector {.inline.} =
|
|||
var VectorZero* = newVector(0.0, 0.0)
|
||||
|
||||
#/ Vector dot product.
|
||||
proc dot*(v1, v2: TVector): CpFloat {.inline.} =
|
||||
proc dot*(v1, v2: TVector): CpFloat {.inline.} =
|
||||
result = v1.x * v2.x + v1.y * v2.y
|
||||
|
||||
#/ Returns the length of v.
|
||||
|
|
@ -613,7 +613,7 @@ proc `-=`*(v1: var TVector; v2: TVector) =
|
|||
v1.y = v1.y - v2.y
|
||||
|
||||
#/ Negate a vector.
|
||||
proc `-`*(v: TVector): TVector {.inline.} =
|
||||
proc `-`*(v: TVector): TVector {.inline.} =
|
||||
result = newVector(- v.x, - v.y)
|
||||
|
||||
#/ Scalar multiplication.
|
||||
|
|
@ -627,54 +627,54 @@ proc `*=`*(v: var TVector; s: CpFloat) =
|
|||
#/ 2D vector cross product analog.
|
||||
#/ The cross product of 2D vectors results in a 3D vector with only a z component.
|
||||
#/ This function returns the magnitude of the z value.
|
||||
proc cross*(v1, v2: TVector): CpFloat {.inline.} =
|
||||
proc cross*(v1, v2: TVector): CpFloat {.inline.} =
|
||||
result = v1.x * v2.y - v1.y * v2.x
|
||||
|
||||
#/ Returns a perpendicular vector. (90 degree rotation)
|
||||
proc perp*(v: TVector): TVector {.inline.} =
|
||||
proc perp*(v: TVector): TVector {.inline.} =
|
||||
result = newVector(- v.y, v.x)
|
||||
|
||||
#/ Returns a perpendicular vector. (-90 degree rotation)
|
||||
proc rperp*(v: TVector): TVector {.inline.} =
|
||||
proc rperp*(v: TVector): TVector {.inline.} =
|
||||
result = newVector(v.y, - v.x)
|
||||
|
||||
#/ Returns the vector projection of v1 onto v2.
|
||||
proc project*(v1,v2: TVector): TVector {.inline.} =
|
||||
proc project*(v1,v2: TVector): TVector {.inline.} =
|
||||
result = v2 * (v1.dot(v2) / v2.dot(v2))
|
||||
|
||||
#/ Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a unit vector.
|
||||
|
||||
proc rotate*(v1, v2: TVector): TVector {.inline.} =
|
||||
proc rotate*(v1, v2: TVector): TVector {.inline.} =
|
||||
result = newVector(v1.x * v2.x - v1.y * v2.y, v1.x * v2.y + v1.y * v2.x)
|
||||
#/ Inverse of cpvrotate().
|
||||
proc unrotate*(v1, v2: TVector): TVector {.inline.} =
|
||||
proc unrotate*(v1, v2: TVector): TVector {.inline.} =
|
||||
result = newVector(v1.x * v2.x + v1.y * v2.y, v1.y * v2.x - v1.x * v2.y)
|
||||
#/ Returns the squared length of v. Faster than cpvlength() when you only need to compare lengths.
|
||||
proc lenSq*(v: TVector): CpFloat {.inline.} =
|
||||
proc lenSq*(v: TVector): CpFloat {.inline.} =
|
||||
result = v.dot(v)
|
||||
#/ Linearly interpolate between v1 and v2.
|
||||
proc lerp*(v1, v2: TVector; t: CpFloat): TVector {.inline.} =
|
||||
proc lerp*(v1, v2: TVector; t: CpFloat): TVector {.inline.} =
|
||||
result = (v1 * (1.0 - t)) + (v2 * t)
|
||||
#/ Returns a normalized copy of v.
|
||||
proc normalize*(v: TVector): TVector {.inline.} =
|
||||
proc normalize*(v: TVector): TVector {.inline.} =
|
||||
result = v * (1.0 / v.len)
|
||||
#/ Returns a normalized copy of v or cpvzero if v was already cpvzero. Protects against divide by zero errors.
|
||||
proc normalizeSafe*(v: TVector): TVector {.inline.} =
|
||||
proc normalizeSafe*(v: TVector): TVector {.inline.} =
|
||||
result = if v.x == 0.0 and v.y == 0.0: VectorZero else: v.normalize
|
||||
#/ Clamp v to length len.
|
||||
proc clamp*(v: TVector; len: CpFloat): TVector {.inline.} =
|
||||
proc clamp*(v: TVector; len: CpFloat): TVector {.inline.} =
|
||||
result = if v.dot(v) > len * len: v.normalize * len else: v
|
||||
#/ Linearly interpolate between v1 towards v2 by distance d.
|
||||
proc lerpconst*(v1, v2: TVector; d: CpFloat): TVector {.inline.} =
|
||||
proc lerpconst*(v1, v2: TVector; d: CpFloat): TVector {.inline.} =
|
||||
result = v1 + clamp(v2 - v1, d) #vadd(v1 + vclamp(vsub(v2, v1), d))
|
||||
#/ Returns the distance between v1 and v2.
|
||||
proc dist*(v1, v2: TVector): CpFloat {.inline.} =
|
||||
proc dist*(v1, v2: TVector): CpFloat {.inline.} =
|
||||
result = (v1 - v2).len #vlength(vsub(v1, v2))
|
||||
#/ Returns the squared distance between v1 and v2. Faster than cpvdist() when you only need to compare distances.
|
||||
proc distsq*(v1, v2: TVector): CpFloat {.inline.} =
|
||||
proc distsq*(v1, v2: TVector): CpFloat {.inline.} =
|
||||
result = (v1 - v2).lenSq #vlengthsq(vsub(v1, v2))
|
||||
#/ Returns true if the distance between v1 and v2 is less than dist.
|
||||
proc near*(v1, v2: TVector; dist: CpFloat): bool{.inline.} =
|
||||
proc near*(v1, v2: TVector; dist: CpFloat): bool{.inline.} =
|
||||
result = v1.distSq(v2) < dist * dist
|
||||
|
||||
|
||||
|
|
@ -706,13 +706,13 @@ proc Sleep*(body: PBody){.importc: "cpBodySleep", dynlib: Lib.}
|
|||
proc SleepWithGroup*(body: PBody; group: PBody){.
|
||||
importc: "cpBodySleepWithGroup", dynlib: Lib.}
|
||||
#/ Returns true if the body is sleeping.
|
||||
proc isSleeping*(body: PBody): bool {.inline.} =
|
||||
proc isSleeping*(body: PBody): bool {.inline.} =
|
||||
return body.node.root != nil
|
||||
#/ Returns true if the body is static.
|
||||
proc isStatic*(body: PBody): bool {.inline.} =
|
||||
proc isStatic*(body: PBody): bool {.inline.} =
|
||||
return body.node.idleTime == CpInfinity
|
||||
#/ Returns true if the body has not been added to a space.
|
||||
proc isRogue*(body: PBody): bool {.inline.} =
|
||||
proc isRogue*(body: PBody): bool {.inline.} =
|
||||
return body.space == nil
|
||||
|
||||
# #define CP_DefineBodyStructGetter(type, member, name) \
|
||||
|
|
@ -740,7 +740,7 @@ defGetter(PBody, CpFloat, i, Moment)
|
|||
#/ Set the moment of a body.
|
||||
when defined(MoreNim):
|
||||
defSetter(PBody, CpFloat, i, Moment)
|
||||
else:
|
||||
else:
|
||||
proc SetMoment*(body: PBody; i: CpFloat) {.
|
||||
cdecl, importc: "cpBodySetMoment", dynlib: Lib.}
|
||||
|
||||
|
|
@ -775,10 +775,10 @@ proc UpdateVelocity*(body: PBody; gravity: TVector; damping: CpFloat; dt: CpFloa
|
|||
proc UpdatePosition*(body: PBody; dt: CpFloat){.
|
||||
cdecl, importc: "cpBodyUpdatePosition", dynlib: Lib.}
|
||||
#/ Convert body relative/local coordinates to absolute/world coordinates.
|
||||
proc Local2World*(body: PBody; v: TVector): TVector{.inline.} =
|
||||
proc Local2World*(body: PBody; v: TVector): TVector{.inline.} =
|
||||
result = body.p + v.rotate(body.rot) ##return cpvadd(body.p, cpvrotate(v, body.rot))
|
||||
#/ Convert body absolute/world coordinates to relative/local coordinates.
|
||||
proc world2Local*(body: PBody; v: TVector): TVector{.inline.} =
|
||||
proc world2Local*(body: PBody; v: TVector): TVector{.inline.} =
|
||||
result = (v - body.p).unrotate(body.rot)
|
||||
#/ Set the forces and torque or a body to zero.
|
||||
proc resetForces*(body: PBody){.
|
||||
|
|
@ -808,26 +808,26 @@ proc kineticEnergy*(body: PBOdy): CpFloat =
|
|||
result = (body.v.dot(body.v) * body.m) + (body.w * body.w * body.i)
|
||||
|
||||
#/ Call @c func once for each shape attached to @c body and added to the space.
|
||||
proc eachShape*(body: PBody; fun: TBodyShapeIteratorFunc;
|
||||
proc eachShape*(body: PBody; fun: TBodyShapeIteratorFunc;
|
||||
data: pointer){.
|
||||
cdecl, importc: "cpBodyEachShape", dynlib: Lib.}
|
||||
#/ Call @c func once for each constraint attached to @c body and added to the space.
|
||||
proc eachConstraint*(body: PBody; fun: TBodyConstraintIteratorFunc;
|
||||
proc eachConstraint*(body: PBody; fun: TBodyConstraintIteratorFunc;
|
||||
data: pointer) {.
|
||||
cdecl, importc: "cpBodyEachConstraint", dynlib: Lib.}
|
||||
#/ Call @c func once for each arbiter that is currently active on the body.
|
||||
proc eachArbiter*(body: PBody; fun: TBodyArbiterIteratorFunc;
|
||||
proc eachArbiter*(body: PBody; fun: TBodyArbiterIteratorFunc;
|
||||
data: pointer){.
|
||||
cdecl, importc: "cpBodyEachArbiter", dynlib: Lib.}
|
||||
#/ Allocate a spatial hash.
|
||||
proc SpaceHashAlloc*(): PSpaceHash{.
|
||||
cdecl, importc: "cpSpaceHashAlloc", dynlib: Lib.}
|
||||
#/ Initialize a spatial hash.
|
||||
proc SpaceHashInit*(hash: PSpaceHash; celldim: CpFloat; numcells: cint;
|
||||
#/ Initialize a spatial hash.
|
||||
proc SpaceHashInit*(hash: PSpaceHash; celldim: CpFloat; numcells: cint;
|
||||
bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{.
|
||||
cdecl, importc: "cpSpaceHashInit", dynlib: Lib.}
|
||||
#/ Allocate and initialize a spatial hash.
|
||||
proc SpaceHashNew*(celldim: CpFloat; cells: cint; bbfun: TSpatialIndexBBFunc;
|
||||
proc SpaceHashNew*(celldim: CpFloat; cells: cint; bbfun: TSpatialIndexBBFunc;
|
||||
staticIndex: PSpatialIndex): PSpatialIndex{.
|
||||
cdecl, importc: "cpSpaceHashNew", dynlib: Lib.}
|
||||
#/ Change the cell dimensions and table size of the spatial hash to tune it.
|
||||
|
|
@ -842,8 +842,8 @@ proc SpaceHashResize*(hash: PSpaceHash; celldim: CpFloat; numcells: cint){.
|
|||
#/ Allocate a bounding box tree.
|
||||
proc BBTreeAlloc*(): PBBTree{.cdecl, importc: "cpBBTreeAlloc", dynlib: Lib.}
|
||||
#/ Initialize a bounding box tree.
|
||||
proc BBTreeInit*(tree: PBBTree; bbfun: TSpatialIndexBBFunc;
|
||||
staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl,
|
||||
proc BBTreeInit*(tree: PBBTree; bbfun: TSpatialIndexBBFunc;
|
||||
staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl,
|
||||
importc: "cpBBTreeInit", dynlib: Lib.}
|
||||
#/ Allocate and initialize a bounding box tree.
|
||||
proc BBTreeNew*(bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{.
|
||||
|
|
@ -860,12 +860,12 @@ proc BBTreeSetVelocityFunc*(index: PSpatialIndex; fun: TBBTreeVelocityFunc){.
|
|||
|
||||
#/ Allocate a 1D sort and sweep broadphase.
|
||||
|
||||
proc Sweep1DAlloc*(): ptr TSweep1D{.cdecl, importc: "cpSweep1DAlloc",
|
||||
proc Sweep1DAlloc*(): ptr TSweep1D{.cdecl, importc: "cpSweep1DAlloc",
|
||||
dynlib: Lib.}
|
||||
#/ Initialize a 1D sort and sweep broadphase.
|
||||
|
||||
proc Sweep1DInit*(sweep: ptr TSweep1D; bbfun: TSpatialIndexBBFunc;
|
||||
staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl,
|
||||
proc Sweep1DInit*(sweep: ptr TSweep1D; bbfun: TSpatialIndexBBFunc;
|
||||
staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl,
|
||||
importc: "cpSweep1DInit", dynlib: Lib.}
|
||||
#/ Allocate and initialize a 1D sort and sweep broadphase.
|
||||
|
||||
|
|
@ -878,7 +878,7 @@ defProp(PArbiter, CpFloat, e, Elasticity)
|
|||
defProp(PArbiter, CpFloat, u, Friction)
|
||||
defProp(PArbiter, TVector, surface_vr, SurfaceVelocity)
|
||||
|
||||
#/ Calculate the total impulse that was applied by this
|
||||
#/ Calculate the total impulse that was applied by this
|
||||
#/ This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback.
|
||||
proc totalImpulse*(obj: PArbiter): TVector {.cdecl, importc: "cpArbiterTotalImpulse", dynlib: Lib.}
|
||||
|
||||
|
|
@ -917,7 +917,7 @@ template getShapes*(arb: PArbiter, name1, name2: expr): stmt {.immediate.} =
|
|||
#/ Return the colliding bodies involved for this arbiter.
|
||||
#/ The order of the cpSpace.collision_type the bodies are associated with values will match
|
||||
#/ the order set when the collision handler was registered.
|
||||
#proc getBodies*(arb: PArbiter, a, b: var PBody) {.inline.} =
|
||||
#proc getBodies*(arb: PArbiter, a, b: var PBody) {.inline.} =
|
||||
# getShapes(arb, shape1, shape2)
|
||||
# a = shape1.body
|
||||
# b = shape2.body
|
||||
|
|
@ -981,7 +981,7 @@ proc segmentQuery*(shape: PShape, a, b: TVector, info: PSegmentQueryInfo): bool
|
|||
cdecl, importc: "cpShapeSegmentQuery", dynlib: Lib.}
|
||||
|
||||
#/ Get the hit point for a segment query.
|
||||
## Possibly change; info to PSegmentQueryInfo
|
||||
## Possibly change; info to PSegmentQueryInfo
|
||||
proc queryHitPoint*(start, to: TVector, info: TSegmentQueryInfo): TVector {.inline.} =
|
||||
result = start.lerp(to, info.t)
|
||||
|
||||
|
|
@ -1035,7 +1035,7 @@ proc init*(poly: PPolyShape; body: PBody, numVerts: cint;
|
|||
cdecl, importc: "cpPolyShapeInit", dynlib: Lib.}
|
||||
#/ Allocate and initialize a polygon shape.
|
||||
#/ A convex hull will be created from the vertexes.
|
||||
proc newPolyShape*(body: PBody; numVerts: cint; verts: ptr TVector;
|
||||
proc newPolyShape*(body: PBody; numVerts: cint; verts: ptr TVector;
|
||||
offset: TVector): PShape {.
|
||||
cdecl, importc: "cpPolyShapeNew", dynlib: Lib.}
|
||||
#/ Initialize a box shaped polygon shape.
|
||||
|
|
@ -1129,11 +1129,11 @@ proc MomentForBox2*(m: CpFloat; box: TBB): CpFloat {.
|
|||
|
||||
|
||||
##constraints
|
||||
type
|
||||
type
|
||||
#TODO: all these are private
|
||||
#TODO: defConstraintProp()
|
||||
PPinJoint = ptr TPinJoint
|
||||
TPinJoint{.pf.} = object
|
||||
TPinJoint{.pf.} = object
|
||||
constraint: PConstraint
|
||||
anchr1: TVector
|
||||
anchr2: TVector
|
||||
|
|
@ -1146,7 +1146,7 @@ type
|
|||
jnMax: CpFloat
|
||||
bias: CpFloat
|
||||
PSlideJoint = ptr TSlideJoint
|
||||
TSlideJoint{.pf.} = object
|
||||
TSlideJoint{.pf.} = object
|
||||
constraint: PConstraint
|
||||
anchr1: TVector
|
||||
anchr2: TVector
|
||||
|
|
@ -1160,7 +1160,7 @@ type
|
|||
jnMax: CpFloat
|
||||
bias: CpFloat
|
||||
PPivotJoint = ptr TPivotJoint
|
||||
TPivotJoint{.pf.} = object
|
||||
TPivotJoint{.pf.} = object
|
||||
constraint: PConstraint
|
||||
anchr1: TVector
|
||||
anchr2: TVector
|
||||
|
|
@ -1172,7 +1172,7 @@ type
|
|||
jMaxLen: CpFloat
|
||||
bias: TVector
|
||||
PGrooveJoint = ptr TGrooveJoint
|
||||
TGrooveJoint{.pf.} = object
|
||||
TGrooveJoint{.pf.} = object
|
||||
constraint: PConstraint
|
||||
grv_n: TVector
|
||||
grv_a: TVector
|
||||
|
|
@ -1188,7 +1188,7 @@ type
|
|||
jMaxLen: CpFloat
|
||||
bias: TVector
|
||||
PDampedSpring = ptr TDampedSpring
|
||||
TDampedSpring{.pf.} = object
|
||||
TDampedSpring{.pf.} = object
|
||||
constraint: PConstraint
|
||||
anchr1: TVector
|
||||
anchr2: TVector
|
||||
|
|
@ -1203,7 +1203,7 @@ type
|
|||
nMass: CpFloat
|
||||
n: TVector
|
||||
PDampedRotarySpring = ptr TDampedRotarySpring
|
||||
TDampedRotarySpring{.pf.} = object
|
||||
TDampedRotarySpring{.pf.} = object
|
||||
constraint: PConstraint
|
||||
restAngle: CpFloat
|
||||
stiffness: CpFloat
|
||||
|
|
@ -1213,7 +1213,7 @@ type
|
|||
w_coef: CpFloat
|
||||
iSum: CpFloat
|
||||
PRotaryLimitJoint = ptr TRotaryLimitJoint
|
||||
TRotaryLimitJoint{.pf.} = object
|
||||
TRotaryLimitJoint{.pf.} = object
|
||||
constraint: PConstraint
|
||||
min: CpFloat
|
||||
max: CpFloat
|
||||
|
|
@ -1222,7 +1222,7 @@ type
|
|||
jAcc: CpFloat
|
||||
jMax: CpFloat
|
||||
PRatchetJoint = ptr TRatchetJoint
|
||||
TRatchetJoint{.pf.} = object
|
||||
TRatchetJoint{.pf.} = object
|
||||
constraint: PConstraint
|
||||
angle: CpFloat
|
||||
phase: CpFloat
|
||||
|
|
@ -1232,7 +1232,7 @@ type
|
|||
jAcc: CpFloat
|
||||
jMax: CpFloat
|
||||
PGearJoint = ptr TGearJoint
|
||||
TGearJoint{.pf.} = object
|
||||
TGearJoint{.pf.} = object
|
||||
constraint: PConstraint
|
||||
phase: CpFloat
|
||||
ratio: CpFloat
|
||||
|
|
@ -1242,7 +1242,7 @@ type
|
|||
jAcc: CpFloat
|
||||
jMax: CpFloat
|
||||
PSimpleMotor = ptr TSimpleMotor
|
||||
TSimpleMotor{.pf.} = object
|
||||
TSimpleMotor{.pf.} = object
|
||||
constraint: PConstraint
|
||||
rate: CpFloat
|
||||
iSum: CpFloat
|
||||
|
|
@ -1250,7 +1250,7 @@ type
|
|||
jMax: CpFloat
|
||||
TDampedSpringForceFunc* = proc (spring: PConstraint; dist: CpFloat): CpFloat{.
|
||||
cdecl.}
|
||||
TDampedRotarySpringTorqueFunc* = proc (spring: PConstraint;
|
||||
TDampedRotarySpringTorqueFunc* = proc (spring: PConstraint;
|
||||
relativeAngle: CpFloat): CpFloat {.cdecl.}
|
||||
#/ Destroy a constraint.
|
||||
proc destroy*(constraint: PConstraint){.
|
||||
|
|
@ -1260,7 +1260,7 @@ proc free*(constraint: PConstraint){.
|
|||
cdecl, importc: "cpConstraintFree", dynlib: Lib.}
|
||||
|
||||
#/ @private
|
||||
proc activateBodies(constraint: PConstraint) {.inline.} =
|
||||
proc activateBodies(constraint: PConstraint) {.inline.} =
|
||||
if not constraint.a.isNil: constraint.a.activate()
|
||||
if not constraint.b.isNil: constraint.b.activate()
|
||||
|
||||
|
|
@ -1291,7 +1291,7 @@ defGetter(PConstraint, TConstraintPreSolveFunc, preSolve, PreSolveFunc)
|
|||
defGetter(PConstraint, TConstraintPostSolveFunc, postSolve, PostSolveFunc)
|
||||
defGetter(PConstraint, CpDataPointer, data, UserData)
|
||||
# Get the last impulse applied by this constraint.
|
||||
proc getImpulse*(constraint: PConstraint): CpFloat {.inline.} =
|
||||
proc getImpulse*(constraint: PConstraint): CpFloat {.inline.} =
|
||||
return constraint.klass.getImpulse(constraint)
|
||||
|
||||
# #define cpConstraintCheckCast(constraint, struct) \
|
||||
|
|
@ -1309,7 +1309,7 @@ proc getImpulse*(constraint: PConstraint): CpFloat {.inline.} =
|
|||
# }
|
||||
template constraintCheckCast(constraint: PConstraint, ctype: expr): stmt {.immediate.} =
|
||||
assert(constraint.klass == `ctype getClass`(), "Constraint is the wrong class")
|
||||
template defCGetter(ctype: expr, memberType: typedesc, member: expr, name: expr): stmt {.immediate.} =
|
||||
template defCGetter(ctype: expr, memberType: typedesc, member: expr, name: expr): stmt {.immediate.} =
|
||||
proc `get ctype name`*(constraint: PConstraint): memberType {.cdecl.} =
|
||||
constraintCheckCast(constraint, ctype)
|
||||
result = cast[`P ctype`](constraint).member
|
||||
|
|
@ -1330,7 +1330,7 @@ proc PinJointGetClass*(): PConstraintClass{.
|
|||
proc AllocPinJoint*(): PPinJoint{.
|
||||
cdecl, importc: "cpPinJointAlloc", dynlib: Lib.}
|
||||
#/ Initialize a pin joint.
|
||||
proc PinJointInit*(joint: PPinJoint; a: PBody; b: PBody; anchr1: TVector;
|
||||
proc PinJointInit*(joint: PPinJoint; a: PBody; b: PBody; anchr1: TVector;
|
||||
anchr2: TVector): PPinJoint{.
|
||||
cdecl, importc: "cpPinJointInit", dynlib: Lib.}
|
||||
#/ Allocate and initialize a pin joint.
|
||||
|
|
@ -1411,7 +1411,7 @@ proc init*(joint: PDampedSpring; a, b: PBody; anchr1, anchr2: TVector;
|
|||
restLength, stiffness, damping: CpFloat): PDampedSpring{.
|
||||
cdecl, importc: "cpDampedSpringInit", dynlib: Lib.}
|
||||
#/ Allocate and initialize a damped spring.
|
||||
proc newDampedSpring*(a, b: PBody; anchr1, anchr2: TVector;
|
||||
proc newDampedSpring*(a, b: PBody; anchr1, anchr2: TVector;
|
||||
restLength, stiffness, damping: CpFloat): PConstraint{.
|
||||
cdecl, importc: "cpDampedSpringNew", dynlib: Lib.}
|
||||
|
||||
|
|
@ -1431,7 +1431,7 @@ proc DampedRotarySpringGetClass*(): PConstraintClass{.
|
|||
proc DampedRotarySpringAlloc*(): PDampedRotarySpring{.
|
||||
cdecl, importc: "cpDampedRotarySpringAlloc", dynlib: Lib.}
|
||||
#/ Initialize a damped rotary spring.
|
||||
proc init*(joint: PDampedRotarySpring; a, b: PBody;
|
||||
proc init*(joint: PDampedRotarySpring; a, b: PBody;
|
||||
restAngle, stiffness, damping: CpFloat): PDampedRotarySpring{.
|
||||
cdecl, importc: "cpDampedRotarySpringInit", dynlib: Lib.}
|
||||
#/ Allocate and initialize a damped rotary spring.
|
||||
|
|
@ -1477,7 +1477,7 @@ defCProp(RatchetJoint, CpFloat, phase, Phase)
|
|||
defCProp(RatchetJoint, CpFloat, ratchet, Ratchet)
|
||||
|
||||
|
||||
proc GearJointGetClass*(): PConstraintClass{.cdecl,
|
||||
proc GearJointGetClass*(): PConstraintClass{.cdecl,
|
||||
importc: "cpGearJointGetClass", dynlib: Lib.}
|
||||
#/ Allocate a gear joint.
|
||||
proc AllocGearJoint*(): PGearJoint{.
|
||||
|
|
@ -1502,7 +1502,7 @@ proc SimpleMotorGetClass*(): PConstraintClass{.
|
|||
proc AllocSimpleMotor*(): PSimpleMotor{.
|
||||
cdecl, importc: "cpSimpleMotorAlloc", dynlib: Lib.}
|
||||
#/ initialize a simple motor.
|
||||
proc init*(joint: PSimpleMotor; a, b: PBody;
|
||||
proc init*(joint: PSimpleMotor; a, b: PBody;
|
||||
rate: CpFloat): PSimpleMotor{.
|
||||
cdecl, importc: "cpSimpleMotorInit", dynlib: Lib.}
|
||||
#/ Allocate and initialize a simple motor.
|
||||
|
|
|
|||
|
|
@ -1,52 +1,52 @@
|
|||
discard """Copyright (c) 2002-2012 Lee Salzman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
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
|
||||
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
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
const Lib = "libenet.so.1(|.0.3)"
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
const
|
||||
const
|
||||
ENET_VERSION_MAJOR* = 1
|
||||
ENET_VERSION_MINOR* = 3
|
||||
ENET_VERSION_PATCH* = 3
|
||||
template ENET_VERSION_CREATE(major, minor, patch: expr): expr =
|
||||
template ENET_VERSION_CREATE(major, minor, patch: expr): expr =
|
||||
(((major) shl 16) or ((minor) shl 8) or (patch))
|
||||
|
||||
const
|
||||
ENET_VERSION* = ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR,
|
||||
const
|
||||
ENET_VERSION* = ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR,
|
||||
ENET_VERSION_PATCH)
|
||||
type
|
||||
type
|
||||
TVersion* = cuint
|
||||
TSocketType*{.size: sizeof(cint).} = enum
|
||||
TSocketType*{.size: sizeof(cint).} = enum
|
||||
ENET_SOCKET_TYPE_STREAM = 1, ENET_SOCKET_TYPE_DATAGRAM = 2
|
||||
TSocketWait*{.size: sizeof(cint).} = enum
|
||||
ENET_SOCKET_WAIT_NONE = 0, ENET_SOCKET_WAIT_SEND = (1 shl 0),
|
||||
TSocketWait*{.size: sizeof(cint).} = enum
|
||||
ENET_SOCKET_WAIT_NONE = 0, ENET_SOCKET_WAIT_SEND = (1 shl 0),
|
||||
ENET_SOCKET_WAIT_RECEIVE = (1 shl 1)
|
||||
TSocketOption*{.size: sizeof(cint).} = enum
|
||||
ENET_SOCKOPT_NONBLOCK = 1, ENET_SOCKOPT_BROADCAST = 2,
|
||||
ENET_SOCKOPT_RCVBUF = 3, ENET_SOCKOPT_SNDBUF = 4,
|
||||
TSocketOption*{.size: sizeof(cint).} = enum
|
||||
ENET_SOCKOPT_NONBLOCK = 1, ENET_SOCKOPT_BROADCAST = 2,
|
||||
ENET_SOCKOPT_RCVBUF = 3, ENET_SOCKOPT_SNDBUF = 4,
|
||||
ENET_SOCKOPT_REUSEADDR = 5
|
||||
const
|
||||
const
|
||||
ENET_HOST_ANY* = 0
|
||||
ENET_HOST_BROADCAST* = 0xFFFFFFFF
|
||||
ENET_PORT_ANY* = 0
|
||||
|
||||
|
||||
ENET_PROTOCOL_MINIMUM_MTU* = 576
|
||||
ENET_PROTOCOL_MAXIMUM_MTU* = 4096
|
||||
ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS* = 32
|
||||
|
|
@ -57,29 +57,29 @@ const
|
|||
ENET_PROTOCOL_MAXIMUM_PEER_ID* = 0x00000FFF
|
||||
type
|
||||
PAddress* = ptr TAddress
|
||||
TAddress*{.pure, final.} = object
|
||||
TAddress*{.pure, final.} = object
|
||||
host*: cuint
|
||||
port*: cushort
|
||||
|
||||
TPacketFlag*{.size: sizeof(cint).} = enum
|
||||
FlagReliable = (1 shl 0),
|
||||
FlagUnsequenced = (1 shl 1),
|
||||
NoAllocate = (1 shl 2),
|
||||
|
||||
TPacketFlag*{.size: sizeof(cint).} = enum
|
||||
FlagReliable = (1 shl 0),
|
||||
FlagUnsequenced = (1 shl 1),
|
||||
NoAllocate = (1 shl 2),
|
||||
UnreliableFragment = (1 shl 3)
|
||||
|
||||
TENetListNode*{.pure, final.} = object
|
||||
|
||||
TENetListNode*{.pure, final.} = object
|
||||
next*: ptr T_ENetListNode
|
||||
previous*: ptr T_ENetListNode
|
||||
|
||||
PENetListIterator* = ptr TENetListNode
|
||||
TENetList*{.pure, final.} = object
|
||||
TENetList*{.pure, final.} = object
|
||||
sentinel*: TENetListNode
|
||||
|
||||
T_ENetPacket*{.pure, final.} = object
|
||||
|
||||
T_ENetPacket*{.pure, final.} = object
|
||||
TPacketFreeCallback* = proc (a2: ptr T_ENetPacket){.cdecl.}
|
||||
|
||||
|
||||
PPacket* = ptr TPacket
|
||||
TPacket*{.pure, final.} = object
|
||||
TPacket*{.pure, final.} = object
|
||||
referenceCount: csize
|
||||
flags*: cint
|
||||
data*: cstring#ptr cuchar
|
||||
|
|
@ -87,13 +87,13 @@ type
|
|||
freeCallback*: TPacketFreeCallback
|
||||
|
||||
PAcknowledgement* = ptr TAcknowledgement
|
||||
TAcknowledgement*{.pure, final.} = object
|
||||
TAcknowledgement*{.pure, final.} = object
|
||||
acknowledgementList*: TEnetListNode
|
||||
sentTime*: cuint
|
||||
command*: TEnetProtocol
|
||||
|
||||
POutgoingCommand* = ptr TOutgoingCommand
|
||||
TOutgoingCommand*{.pure, final.} = object
|
||||
TOutgoingCommand*{.pure, final.} = object
|
||||
outgoingCommandList*: TEnetListNode
|
||||
reliableSequenceNumber*: cushort
|
||||
unreliableSequenceNumber*: cushort
|
||||
|
|
@ -107,7 +107,7 @@ type
|
|||
packet*: PPacket
|
||||
|
||||
PIncomingCommand* = ptr TIncomingCommand
|
||||
TIncomingCommand*{.pure, final.} = object
|
||||
TIncomingCommand*{.pure, final.} = object
|
||||
incomingCommandList*: TEnetListNode
|
||||
reliableSequenceNumber*: cushort
|
||||
unreliableSequenceNumber*: cushort
|
||||
|
|
@ -117,52 +117,52 @@ type
|
|||
fragments*: ptr cuint
|
||||
packet*: ptr TPacket
|
||||
|
||||
TPeerState*{.size: sizeof(cint).} = enum
|
||||
ENET_PEER_STATE_DISCONNECTED = 0, ENET_PEER_STATE_CONNECTING = 1,
|
||||
ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2,
|
||||
ENET_PEER_STATE_CONNECTION_PENDING = 3,
|
||||
ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4, ENET_PEER_STATE_CONNECTED = 5,
|
||||
ENET_PEER_STATE_DISCONNECT_LATER = 6, ENET_PEER_STATE_DISCONNECTING = 7,
|
||||
TPeerState*{.size: sizeof(cint).} = enum
|
||||
ENET_PEER_STATE_DISCONNECTED = 0, ENET_PEER_STATE_CONNECTING = 1,
|
||||
ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2,
|
||||
ENET_PEER_STATE_CONNECTION_PENDING = 3,
|
||||
ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4, ENET_PEER_STATE_CONNECTED = 5,
|
||||
ENET_PEER_STATE_DISCONNECT_LATER = 6, ENET_PEER_STATE_DISCONNECTING = 7,
|
||||
ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT = 8, ENET_PEER_STATE_ZOMBIE = 9
|
||||
|
||||
TENetProtocolCommand*{.size: sizeof(cint).} = enum
|
||||
ENET_PROTOCOL_COMMAND_NONE = 0, ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1,
|
||||
ENET_PROTOCOL_COMMAND_CONNECT = 2,
|
||||
ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3,
|
||||
ENET_PROTOCOL_COMMAND_DISCONNECT = 4, ENET_PROTOCOL_COMMAND_PING = 5,
|
||||
ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7,
|
||||
ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9,
|
||||
ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10,
|
||||
ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12,
|
||||
|
||||
TENetProtocolCommand*{.size: sizeof(cint).} = enum
|
||||
ENET_PROTOCOL_COMMAND_NONE = 0, ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1,
|
||||
ENET_PROTOCOL_COMMAND_CONNECT = 2,
|
||||
ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3,
|
||||
ENET_PROTOCOL_COMMAND_DISCONNECT = 4, ENET_PROTOCOL_COMMAND_PING = 5,
|
||||
ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7,
|
||||
ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9,
|
||||
ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10,
|
||||
ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12,
|
||||
ENET_PROTOCOL_COMMAND_COUNT = 13, ENET_PROTOCOL_COMMAND_MASK = 0x0000000F
|
||||
TENetProtocolFlag*{.size: sizeof(cint).} = enum
|
||||
TENetProtocolFlag*{.size: sizeof(cint).} = enum
|
||||
ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12,
|
||||
ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 shl 6),
|
||||
ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 shl 7),
|
||||
ENET_PROTOCOL_HEADER_SESSION_MASK = (3 shl 12),
|
||||
ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 shl 14),
|
||||
ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 shl 6),
|
||||
ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 shl 7),
|
||||
ENET_PROTOCOL_HEADER_SESSION_MASK = (3 shl 12),
|
||||
ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 shl 14),
|
||||
ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 shl 15),
|
||||
ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED.cint or
|
||||
ENET_PROTOCOL_HEADER_FLAG_SENT_TIME.cint
|
||||
|
||||
TENetProtocolHeader*{.pure, final.} = object
|
||||
|
||||
TENetProtocolHeader*{.pure, final.} = object
|
||||
peerID*: cushort
|
||||
sentTime*: cushort
|
||||
|
||||
TENetProtocolCommandHeader*{.pure, final.} = object
|
||||
TENetProtocolCommandHeader*{.pure, final.} = object
|
||||
command*: cuchar
|
||||
channelID*: cuchar
|
||||
reliableSequenceNumber*: cushort
|
||||
|
||||
TENetProtocolAcknowledge*{.pure, final.} = object
|
||||
TENetProtocolAcknowledge*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
receivedReliableSequenceNumber*: cushort
|
||||
receivedSentTime*: cushort
|
||||
|
||||
TENetProtocolConnect*{.pure, final.} = object
|
||||
TENetProtocolConnect*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
outgoingPeerID*: cushort
|
||||
incomingSessionID*: cuchar
|
||||
|
|
@ -178,7 +178,7 @@ type
|
|||
connectID*: cuint
|
||||
data*: cuint
|
||||
|
||||
TENetProtocolVerifyConnect*{.pure, final.} = object
|
||||
TENetProtocolVerifyConnect*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
outgoingPeerID*: cushort
|
||||
incomingSessionID*: cuchar
|
||||
|
|
@ -193,39 +193,39 @@ type
|
|||
packetThrottleDeceleration*: cuint
|
||||
connectID*: cuint
|
||||
|
||||
TENetProtocolBandwidthLimit*{.pure, final.} = object
|
||||
TENetProtocolBandwidthLimit*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
incomingBandwidth*: cuint
|
||||
outgoingBandwidth*: cuint
|
||||
|
||||
TENetProtocolThrottleConfigure*{.pure, final.} = object
|
||||
TENetProtocolThrottleConfigure*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
packetThrottleInterval*: cuint
|
||||
packetThrottleAcceleration*: cuint
|
||||
packetThrottleDeceleration*: cuint
|
||||
|
||||
TENetProtocolDisconnect*{.pure, final.} = object
|
||||
TENetProtocolDisconnect*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
data*: cuint
|
||||
|
||||
TENetProtocolPing*{.pure, final.} = object
|
||||
TENetProtocolPing*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
|
||||
TENetProtocolSendReliable*{.pure, final.} = object
|
||||
TENetProtocolSendReliable*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
dataLength*: cushort
|
||||
|
||||
TENetProtocolSendUnreliable*{.pure, final.} = object
|
||||
TENetProtocolSendUnreliable*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
unreliableSequenceNumber*: cushort
|
||||
dataLength*: cushort
|
||||
|
||||
TENetProtocolSendUnsequenced*{.pure, final.} = object
|
||||
TENetProtocolSendUnsequenced*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
unsequencedGroup*: cushort
|
||||
dataLength*: cushort
|
||||
|
||||
TENetProtocolSendFragment*{.pure, final.} = object
|
||||
TENetProtocolSendFragment*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
startSequenceNumber*: cushort
|
||||
dataLength*: cushort
|
||||
|
|
@ -233,12 +233,12 @@ type
|
|||
fragmentNumber*: cuint
|
||||
totalLength*: cuint
|
||||
fragmentOffset*: cuint
|
||||
|
||||
|
||||
## this is incomplete; need helper templates or something
|
||||
## ENetProtocol
|
||||
TENetProtocol*{.pure, final.} = object
|
||||
TENetProtocol*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
const
|
||||
const
|
||||
ENET_BUFFER_MAXIMUM* = (1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS)
|
||||
ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024
|
||||
ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024
|
||||
|
|
@ -270,39 +270,39 @@ when defined(Linux) or true:
|
|||
import posix
|
||||
const
|
||||
ENET_SOCKET_NULL*: cint = -1
|
||||
type
|
||||
type
|
||||
TENetSocket* = cint
|
||||
PEnetBuffer* = ptr object
|
||||
TENetBuffer*{.pure, final.} = object
|
||||
TENetBuffer*{.pure, final.} = object
|
||||
data*: pointer
|
||||
dataLength*: csize
|
||||
TENetSocketSet* = Tfd_set
|
||||
## see if these are different on win32, if not then get rid of these
|
||||
template ENET_HOST_TO_NET_16*(value: expr): expr =
|
||||
template ENET_HOST_TO_NET_16*(value: expr): expr =
|
||||
(htons(value))
|
||||
template ENET_HOST_TO_NET_32*(value: expr): expr =
|
||||
template ENET_HOST_TO_NET_32*(value: expr): expr =
|
||||
(htonl(value))
|
||||
template ENET_NET_TO_HOST_16*(value: expr): expr =
|
||||
template ENET_NET_TO_HOST_16*(value: expr): expr =
|
||||
(ntohs(value))
|
||||
template ENET_NET_TO_HOST_32*(value: expr): expr =
|
||||
template ENET_NET_TO_HOST_32*(value: expr): expr =
|
||||
(ntohl(value))
|
||||
|
||||
template ENET_SOCKETSET_EMPTY*(sockset: expr): expr =
|
||||
template ENET_SOCKETSET_EMPTY*(sockset: expr): expr =
|
||||
FD_ZERO(addr((sockset)))
|
||||
template ENET_SOCKETSET_ADD*(sockset, socket: expr): expr =
|
||||
template ENET_SOCKETSET_ADD*(sockset, socket: expr): expr =
|
||||
FD_SET(socket, addr((sockset)))
|
||||
template ENET_SOCKETSET_REMOVE*(sockset, socket: expr): expr =
|
||||
template ENET_SOCKETSET_REMOVE*(sockset, socket: expr): expr =
|
||||
FD_CLEAR(socket, addr((sockset)))
|
||||
template ENET_SOCKETSET_CHECK*(sockset, socket: expr): expr =
|
||||
template ENET_SOCKETSET_CHECK*(sockset, socket: expr): expr =
|
||||
FD_ISSET(socket, addr((sockset)))
|
||||
|
||||
when defined(Windows):
|
||||
## put the content of win32.h in here
|
||||
|
||||
|
||||
type
|
||||
type
|
||||
PChannel* = ptr TChannel
|
||||
TChannel*{.pure, final.} = object
|
||||
TChannel*{.pure, final.} = object
|
||||
outgoingReliableSequenceNumber*: cushort
|
||||
outgoingUnreliableSequenceNumber*: cushort
|
||||
usedReliableWindows*: cushort
|
||||
|
|
@ -313,7 +313,7 @@ type
|
|||
incomingUnreliableCommands*: TENetList
|
||||
|
||||
PPeer* = ptr TPeer
|
||||
TPeer*{.pure, final.} = object
|
||||
TPeer*{.pure, final.} = object
|
||||
dispatchList*: TEnetListNode
|
||||
host*: ptr THost
|
||||
outgoingPeerID*: cushort
|
||||
|
|
@ -367,25 +367,25 @@ type
|
|||
needsDispatch*: cint
|
||||
incomingUnsequencedGroup*: cushort
|
||||
outgoingUnsequencedGroup*: cushort
|
||||
unsequencedWindow*: array[0..ENET_PEER_UNSEQUENCED_WINDOW_SIZE div 32 - 1,
|
||||
unsequencedWindow*: array[0..ENET_PEER_UNSEQUENCED_WINDOW_SIZE div 32 - 1,
|
||||
cuint]
|
||||
eventData*: cuint
|
||||
|
||||
PCompressor* = ptr TCompressor
|
||||
TCompressor*{.pure, final.} = object
|
||||
TCompressor*{.pure, final.} = object
|
||||
context*: pointer
|
||||
compress*: proc (context: pointer; inBuffers: ptr TEnetBuffer;
|
||||
inBufferCount: csize; inLimit: csize;
|
||||
compress*: proc (context: pointer; inBuffers: ptr TEnetBuffer;
|
||||
inBufferCount: csize; inLimit: csize;
|
||||
outData: ptr cuchar; outLimit: csize): csize{.cdecl.}
|
||||
decompress*: proc (context: pointer; inData: ptr cuchar; inLimit: csize;
|
||||
decompress*: proc (context: pointer; inData: ptr cuchar; inLimit: csize;
|
||||
outData: ptr cuchar; outLimit: csize): csize{.cdecl.}
|
||||
destroy*: proc (context: pointer){.cdecl.}
|
||||
|
||||
TChecksumCallback* = proc (buffers: ptr TEnetBuffer; bufferCount: csize): cuint{.
|
||||
cdecl.}
|
||||
|
||||
|
||||
PHost* = ptr THost
|
||||
THost*{.pure, final.} = object
|
||||
THost*{.pure, final.} = object
|
||||
socket*: TEnetSocket
|
||||
address*: TAddress
|
||||
incomingBandwidth*: cuint
|
||||
|
|
@ -402,14 +402,14 @@ type
|
|||
continueSending*: cint
|
||||
packetSize*: csize
|
||||
headerFlags*: cushort
|
||||
commands*: array[0..ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS - 1,
|
||||
commands*: array[0..ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS - 1,
|
||||
TEnetProtocol]
|
||||
commandCount*: csize
|
||||
buffers*: array[0..ENET_BUFFER_MAXIMUM - 1, TEnetBuffer]
|
||||
bufferCount*: csize
|
||||
checksum*: TChecksumCallback
|
||||
compressor*: TCompressor
|
||||
packetData*: array[0..ENET_PROTOCOL_MAXIMUM_MTU - 1,
|
||||
packetData*: array[0..ENET_PROTOCOL_MAXIMUM_MTU - 1,
|
||||
array[0..2 - 1, cuchar]]
|
||||
receivedAddress*: TAddress
|
||||
receivedData*: ptr cuchar
|
||||
|
|
@ -418,19 +418,19 @@ type
|
|||
totalSentPackets*: cuint
|
||||
totalReceivedData*: cuint
|
||||
totalReceivedPackets*: cuint
|
||||
|
||||
TEventType*{.size: sizeof(cint).} = enum
|
||||
EvtNone = 0, EvtConnect = 1,
|
||||
|
||||
TEventType*{.size: sizeof(cint).} = enum
|
||||
EvtNone = 0, EvtConnect = 1,
|
||||
EvtDisconnect = 2, EvtReceive = 3
|
||||
PEvent* = ptr TEvent
|
||||
TEvent*{.pure, final.} = object
|
||||
TEvent*{.pure, final.} = object
|
||||
kind*: TEventType
|
||||
peer*: ptr TPeer
|
||||
channelID*: cuchar
|
||||
data*: cuint
|
||||
packet*: ptr TPacket
|
||||
|
||||
TENetCallbacks*{.pure, final.} = object
|
||||
TENetCallbacks*{.pure, final.} = object
|
||||
malloc*: proc (size: csize): pointer{.cdecl.}
|
||||
free*: proc (memory: pointer){.cdecl.}
|
||||
no_memory*: proc (){.cdecl.}
|
||||
|
|
@ -473,10 +473,10 @@ proc send*(socket: TEnetSocket; address: var TAddress; buffer: ptr TEnetBuffer;
|
|||
importc: "enet_socket_send", dynlib: Lib.}
|
||||
proc send*(socket: TEnetSocket; address: ptr TAddress; buffer: ptr TEnetBuffer; size: csize): cint{.
|
||||
importc: "enet_socket_send", dynlib: Lib.}
|
||||
proc receive*(socket: TEnetSocket; address: var TAddress;
|
||||
proc receive*(socket: TEnetSocket; address: var TAddress;
|
||||
buffer: ptr TEnetBuffer; size: csize): cint{.
|
||||
importc: "enet_socket_receive", dynlib: Lib.}
|
||||
proc receive*(socket: TEnetSocket; address: ptr TAddress;
|
||||
proc receive*(socket: TEnetSocket; address: ptr TAddress;
|
||||
buffer: ptr TEnetBuffer; size: csize): cint{.
|
||||
importc: "enet_socket_receive", dynlib: Lib.}
|
||||
proc wait*(socket: TEnetSocket; a3: ptr cuint; a4: cuint): cint{.
|
||||
|
|
@ -485,7 +485,7 @@ proc setOption*(socket: TEnetSocket; a3: TSocketOption; a4: cint): cint{.
|
|||
importc: "enet_socket_set_option", dynlib: Lib.}
|
||||
proc destroy*(socket: TEnetSocket){.
|
||||
importc: "enet_socket_destroy", dynlib: Lib.}
|
||||
proc select*(socket: TEnetSocket; a3: ptr TENetSocketSet;
|
||||
proc select*(socket: TEnetSocket; a3: ptr TENetSocketSet;
|
||||
a4: ptr TENetSocketSet; a5: cuint): cint{.
|
||||
importc: "enet_socketset_select", dynlib: Lib.}
|
||||
|
||||
|
|
@ -578,13 +578,13 @@ proc resetQueues*(peer: PPeer){.
|
|||
proc setupOutgoingCommand*(peer: PPeer; outgoingCommand: POutgoingCommand){.
|
||||
importc: "enet_peer_setup_outgoing_command", dynlib: Lib.}
|
||||
|
||||
proc queueOutgoingCommand*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
proc queueOutgoingCommand*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
packet: PPacket; offset: cuint; length: cushort): POutgoingCommand{.
|
||||
importc: "enet_peer_queue_outgoing_command", dynlib: Lib.}
|
||||
proc queueIncomingCommand*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
proc queueIncomingCommand*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
packet: PPacket; fragmentCount: cuint): PIncomingCommand{.
|
||||
importc: "enet_peer_queue_incoming_command", dynlib: Lib.}
|
||||
proc queueAcknowledgement*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
proc queueAcknowledgement*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
sentTime: cushort): PAcknowledgement{.
|
||||
importc: "enet_peer_queue_acknowledgement", dynlib: Lib.}
|
||||
proc dispatchIncomingUnreliableCommands*(peer: PPeer; channel: PChannel){.
|
||||
|
|
@ -596,10 +596,10 @@ proc createRangeCoder*(): pointer{.
|
|||
importc: "enet_range_coder_create", dynlib: Lib.}
|
||||
proc rangeCoderDestroy*(context: pointer){.
|
||||
importc: "enet_range_coder_destroy", dynlib: Lib.}
|
||||
proc rangeCoderCompress*(context: pointer; inBuffers: PEnetBuffer; inLimit,
|
||||
proc rangeCoderCompress*(context: pointer; inBuffers: PEnetBuffer; inLimit,
|
||||
bufferCount: csize; outData: cstring; outLimit: csize): csize{.
|
||||
importc: "enet_range_coder_compress", dynlib: Lib.}
|
||||
proc rangeCoderDecompress*(context: pointer; inData: cstring; inLimit: csize;
|
||||
proc rangeCoderDecompress*(context: pointer; inData: cstring; inLimit: csize;
|
||||
outData: cstring; outLimit: csize): csize{.
|
||||
importc: "enet_range_coder_decompress", dynlib: Lib.}
|
||||
proc protocolCommandSize*(commandNumber: cuchar): csize{.
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ while server.hostService(addr event, 2500) >= 0:
|
|||
case event.kind
|
||||
of EvtConnect:
|
||||
echo "New client from $1:$2".format(event.peer.address.host, event.peer.address.port)
|
||||
|
||||
|
||||
var
|
||||
msg = "hello"
|
||||
msg = "hello"
|
||||
resp = createPacket(cstring(msg), msg.len + 1, FlagReliable)
|
||||
|
||||
|
||||
if event.peer.send(0.cuchar, resp) < 0:
|
||||
echo "FAILED"
|
||||
else:
|
||||
|
|
@ -32,9 +32,9 @@ while server.hostService(addr event, 2500) >= 0:
|
|||
echo "Recvd ($1) $2 ".format(
|
||||
event.packet.dataLength,
|
||||
event.packet.data)
|
||||
|
||||
|
||||
destroy(event.packet)
|
||||
|
||||
|
||||
of EvtDisconnect:
|
||||
echo "Disconnected"
|
||||
event.peer.data = nil
|
||||
|
|
@ -42,4 +42,4 @@ while server.hostService(addr event, 2500) >= 0:
|
|||
discard
|
||||
|
||||
server.destroy()
|
||||
enetDeinit()
|
||||
enetDeinit()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import streams
|
||||
from strutils import repeat
|
||||
|
||||
proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): TaintedString =
|
||||
proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): TaintedString =
|
||||
var lastChr = length
|
||||
result = s.readStr(length)
|
||||
while lastChr >= 0 and result[lastChr - 1] == padChar: dec(lastChr)
|
||||
|
|
@ -26,22 +26,22 @@ proc writeLEStr*(s: PStream, str: string) =
|
|||
|
||||
when isMainModule:
|
||||
var testStream = newStringStream()
|
||||
|
||||
|
||||
testStream.writeLEStr("Hello")
|
||||
doAssert testStream.data == "\5\0Hello"
|
||||
|
||||
|
||||
testStream.setPosition 0
|
||||
var res = testStream.readLEStr()
|
||||
doAssert res == "Hello"
|
||||
|
||||
|
||||
testStream.setPosition 0
|
||||
testStream.writePaddedStr("Sup", 10)
|
||||
echo(repr(testStream), testStream.data.len)
|
||||
doAssert testStream.data == "Sup"&repeat('\0', 7)
|
||||
|
||||
|
||||
testStream.setPosition 0
|
||||
res = testStream.readPaddedStr(10)
|
||||
doAssert res == "Sup"
|
||||
|
||||
|
||||
testStream.close()
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ DO AS THOU WILST PUBLIC LICENSE
|
|||
|
||||
Whoever should stumble upon this document is henceforth and forever
|
||||
entitled to DO AS THOU WILST with aforementioned document and the
|
||||
contents thereof.
|
||||
contents thereof.
|
||||
|
||||
As said in the Olde Country, `Keepe it Gangster'."""
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ type
|
|||
desc*: string
|
||||
action*: TTaskFunction
|
||||
TTaskFunction* = proc() {.closure.}
|
||||
var
|
||||
var
|
||||
tasks* = initTable[string, PTask](16)
|
||||
|
||||
proc newTask*(desc: string; action: TTaskFunction): PTask
|
||||
|
|
@ -61,7 +61,7 @@ when isMainModule:
|
|||
quit(shell("nim", "c", "-r", "nakefile.nim", args))
|
||||
else:
|
||||
addQuitProc(proc() {.noconv.} =
|
||||
var
|
||||
var
|
||||
task: string
|
||||
printTaskList: bool
|
||||
for kind, key, val in getOpt():
|
||||
|
|
@ -70,7 +70,7 @@ else:
|
|||
case key.tolower
|
||||
of "tasks", "t":
|
||||
printTaskList = true
|
||||
else:
|
||||
else:
|
||||
echo "Unknown option: ", key, ": ", val
|
||||
of cmdArgument:
|
||||
task = key
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import
|
||||
import
|
||||
strutils, math
|
||||
when defined(linux):
|
||||
const
|
||||
|
|
@ -27,7 +27,7 @@ type
|
|||
x*, y*, z*: cfloat
|
||||
|
||||
PInputStream* = ptr TInputStream
|
||||
TInputStream* {.pf.} = object
|
||||
TInputStream* {.pf.} = object
|
||||
read*: TInputStreamReadFunc
|
||||
seek*: TInputStreamSeekFunc
|
||||
tell*: TInputStreamTellFunc
|
||||
|
|
@ -52,14 +52,14 @@ type
|
|||
width*: cint
|
||||
height*: cint
|
||||
bitsPerPixel*: cint
|
||||
TEventType*{.size: sizeof(cint).} = enum
|
||||
EvtClosed, EvtResized, EvtLostFocus, EvtGainedFocus,
|
||||
EvtTextEntered, EvtKeyPressed, EvtKeyReleased, EvtMouseWheelMoved,
|
||||
EvtMouseButtonPressed, EvtMouseButtonReleased, EvtMouseMoved,
|
||||
EvtMouseEntered, EvtMouseLeft, EvtJoystickButtonPressed,
|
||||
EvtJoystickButtonReleased, EvtJoystickMoved, EvtJoystickConnected,
|
||||
TEventType*{.size: sizeof(cint).} = enum
|
||||
EvtClosed, EvtResized, EvtLostFocus, EvtGainedFocus,
|
||||
EvtTextEntered, EvtKeyPressed, EvtKeyReleased, EvtMouseWheelMoved,
|
||||
EvtMouseButtonPressed, EvtMouseButtonReleased, EvtMouseMoved,
|
||||
EvtMouseEntered, EvtMouseLeft, EvtJoystickButtonPressed,
|
||||
EvtJoystickButtonReleased, EvtJoystickMoved, EvtJoystickConnected,
|
||||
EvtJoystickDisconnected
|
||||
TKeyEvent*{.pf.} = object
|
||||
TKeyEvent*{.pf.} = object
|
||||
code*: TKeyCode
|
||||
alt* : bool
|
||||
control*: bool
|
||||
|
|
@ -74,7 +74,7 @@ type
|
|||
joystickId*: cint
|
||||
axis*: TJoystickAxis
|
||||
position*: cfloat
|
||||
TMouseWheelEvent*{.pf.} = object
|
||||
TMouseWheelEvent*{.pf.} = object
|
||||
delta*: cint
|
||||
x*: cint
|
||||
y*: cint
|
||||
|
|
@ -90,7 +90,7 @@ type
|
|||
PEvent* = ptr TEvent
|
||||
TEvent*{.pf.} = object
|
||||
case kind*: TEventType
|
||||
of EvtKeyPressed, EvtKeyReleased:
|
||||
of EvtKeyPressed, EvtKeyReleased:
|
||||
key*: TKeyEvent
|
||||
of EvtMouseButtonPressed, EvtMouseButtonReleased:
|
||||
mouseButton*: TMouseButtonEvent
|
||||
|
|
@ -109,16 +109,16 @@ type
|
|||
of EvtMouseWheelMoved:
|
||||
mouseWheel*: TMouseWheelEvent
|
||||
else: nil
|
||||
TJoystickAxis*{.size: sizeof(cint).} = enum
|
||||
JoystickX, JoystickY, JoystickZ, JoystickR,
|
||||
TJoystickAxis*{.size: sizeof(cint).} = enum
|
||||
JoystickX, JoystickY, JoystickZ, JoystickR,
|
||||
JoystickU, JoystickV, JoystickPovX, JoystickPovY
|
||||
TSizeEvent*{.pf.} = object
|
||||
width*: cint
|
||||
height*: cint
|
||||
TMouseButton*{.size: sizeof(cint).} = enum
|
||||
MouseLeft, MouseRight, MouseMiddle,
|
||||
TMouseButton*{.size: sizeof(cint).} = enum
|
||||
MouseLeft, MouseRight, MouseMiddle,
|
||||
MouseXButton1, MouseXButton2, MouseButtonCount
|
||||
TKeyCode*{.size: sizeof(cint).} = enum
|
||||
TKeyCode*{.size: sizeof(cint).} = enum
|
||||
KeyUnknown = - 1, KeyA, KeyB, KeyC, KeyD, KeyE,
|
||||
KeyF, KeyG, KeyH, KeyI, KeyJ, KeyK, KeyL, KeyM, #/< The M key
|
||||
KeyN, KeyO, KeyP, KeyQ, KeyR, KeyS, KeyT, KeyU, #/< The U key
|
||||
|
|
@ -204,11 +204,11 @@ type
|
|||
PConvexShape* = ptr TConvexShape
|
||||
TConvexShape* {.pf.} = object
|
||||
|
||||
TTextStyle*{.size: sizeof(cint).} = enum
|
||||
TextRegular = 0, TextBold = 1 shl 0, TextItalic = 1 shl 1,
|
||||
TTextStyle*{.size: sizeof(cint).} = enum
|
||||
TextRegular = 0, TextBold = 1 shl 0, TextItalic = 1 shl 1,
|
||||
TextUnderlined = 1 shl 2
|
||||
|
||||
TBlendMode*{.size: sizeof(cint).} = enum
|
||||
TBlendMode*{.size: sizeof(cint).} = enum
|
||||
BlendAlpha, BlendAdd, BlendMultiply, BlendNone
|
||||
PRenderStates* = ptr TRenderStates
|
||||
TRenderStates* {.pf.} = object
|
||||
|
|
@ -220,19 +220,19 @@ type
|
|||
PTransform* = ptr TTransform
|
||||
TTransform* {.pf.} = object
|
||||
matrix*: array[0..8, cfloat]
|
||||
TColor* {.pf.} = object
|
||||
TColor* {.pf.} = object
|
||||
r*: uint8
|
||||
g*: uint8
|
||||
b*: uint8
|
||||
a*: uint8
|
||||
PFloatRect* = ptr TFloatRect
|
||||
TFloatRect*{.pf.} = object
|
||||
TFloatRect*{.pf.} = object
|
||||
left*: cfloat
|
||||
top*: cfloat
|
||||
width*: cfloat
|
||||
height*: cfloat
|
||||
PIntRect* = ptr TIntRect
|
||||
TIntRect*{.pf.} = object
|
||||
TIntRect*{.pf.} = object
|
||||
left*: cint
|
||||
top*: cint
|
||||
width*: cint
|
||||
|
|
@ -246,7 +246,7 @@ type
|
|||
position*: TVector2f
|
||||
color*: TColor
|
||||
texCoords*: TVector2f
|
||||
TPrimitiveType*{.size: sizeof(cint).} = enum
|
||||
TPrimitiveType*{.size: sizeof(cint).} = enum
|
||||
Points, #/< List of individual points
|
||||
Lines, #/< List of individual lines
|
||||
LinesStrip, #/< List of connected lines, a point uses the previous point to form a line
|
||||
|
|
@ -381,7 +381,7 @@ proc draw*(window: PRenderWindow, shape: PConvexShape, states: PRenderStates = n
|
|||
cdecl, importc: "sfRenderWindow_drawConvexShape", dynlib: LibG.}
|
||||
proc draw*(window: PRenderWindow, shape: PVertexArray, states: PRenderStates = nil) {.
|
||||
cdecl, importc: "sfRenderWindow_drawVertexArray", dynlib: LibG.}
|
||||
proc draw*(window: PRenderWindow, vertices: PVertex, vertexCount: cint,
|
||||
proc draw*(window: PRenderWindow, vertices: PVertex, vertexCount: cint,
|
||||
vertexType: TPrimitiveType, states: PRenderStates = nil) {.
|
||||
cdecl, importc: "sfRenderWindow_drawPrimitives", dynlib: LibG.}
|
||||
|
||||
|
|
@ -434,20 +434,20 @@ proc draw*(renderTexture: PRenderTexture; text: PText; states: PRenderStates){.
|
|||
cdecl, importc: "sfRenderTexture_drawText", dynlib: LibG.}
|
||||
proc draw*(renderTexture: PRenderTexture; shape: PShape; states: PRenderStates){.
|
||||
cdecl, importc: "sfRenderTexture_drawShape", dynlib: LibG.}
|
||||
proc draw*(renderTexture: PRenderTexture; shape: PCircleShape;
|
||||
proc draw*(renderTexture: PRenderTexture; shape: PCircleShape;
|
||||
states: PRenderStates){.
|
||||
cdecl, importc: "sfRenderTexture_drawCircleShape", dynlib: LibG.}
|
||||
proc draw*(renderTexture: PRenderTexture; shape: PConvexShape;
|
||||
proc draw*(renderTexture: PRenderTexture; shape: PConvexShape;
|
||||
states: PRenderStates){.
|
||||
cdecl, importc: "sfRenderTexture_drawConvexShape", dynlib: LibG.}
|
||||
proc draw*(renderTexture: PRenderTexture; shape: PRectangleShape;
|
||||
proc draw*(renderTexture: PRenderTexture; shape: PRectangleShape;
|
||||
states: PRenderStates){.
|
||||
cdecl, importc: "sfRenderTexture_drawRectangleShape", dynlib: LibG.}
|
||||
proc draw*(renderTexture: PRenderTexture; va: PVertexArray;
|
||||
proc draw*(renderTexture: PRenderTexture; va: PVertexArray;
|
||||
states: PRenderStates){.
|
||||
cdecl, importc: "sfRenderTexture_drawVertexArray", dynlib: LibG.}
|
||||
#Draw primitives defined by an array of vertices to a render texture
|
||||
proc draw*(renderTexture: PRenderTexture; vertices: PVertex; vertexCount: cint;
|
||||
proc draw*(renderTexture: PRenderTexture; vertices: PVertex; vertexCount: cint;
|
||||
primitiveType: TPrimitiveType; states: PRenderStates){.
|
||||
cdecl, importc: "sfRenderTexture_drawPrimitives", dynlib: LibG.}
|
||||
#Save the current OpenGL render states and matrices
|
||||
|
|
@ -500,12 +500,12 @@ proc intRect*(left, top, width, height: cint): TIntRect =
|
|||
result.height = height
|
||||
proc floatRect*(left, top, width, height: cfloat): TFloatRect =
|
||||
result.left = left
|
||||
result.top = top
|
||||
result.top = top
|
||||
result.width = width
|
||||
result.height = height
|
||||
proc contains*(rect: PFloatRect, x, y: cfloat): bool {.
|
||||
cdecl, importc: "sfFloatRect_contains", dynlib: LibG.}
|
||||
proc contains*(rect: PIntRect, x: cint, y: cint): bool{.cdecl,
|
||||
proc contains*(rect: PIntRect, x: cint, y: cint): bool{.cdecl,
|
||||
importc: "sfIntRect_contains", dynlib: LibG.}
|
||||
proc intersects*(rect1, rect2, intersection: PFloatRect): bool {.
|
||||
cdecl, importc: "sfFloatRect_intersects", dynlib: LibG.}
|
||||
|
|
@ -894,7 +894,7 @@ proc setColor*(text: PText, color: TColor) {.
|
|||
cdecl, importc: "sfText_setColor", dynlib: LibG.}
|
||||
proc getString*(text: PText): cstring {.
|
||||
cdecl, importc: "sfText_getString", dynlib: LibG.}
|
||||
proc getUnicodeString*(text: PText): ptr uint32 {.cdecl,
|
||||
proc getUnicodeString*(text: PText): ptr uint32 {.cdecl,
|
||||
importc: "sfText_getUnicodeString", dynlib: LibG.}
|
||||
proc getFont*(text: PText): PFont {.
|
||||
cdecl, importc: "sfText_getFont", dynlib: LibG.}
|
||||
|
|
@ -985,7 +985,7 @@ proc `*`*(color1, color2: TColor): TColor {.
|
|||
cdecl, importc: "sfColor_modulate", dynlib: LibG.}
|
||||
proc newColor*(r,g,b: int): TColor {.inline.} =
|
||||
return color(r,g,b)
|
||||
proc newColor*(r,g,b,a: int): TColor {.inline.} =
|
||||
proc newColor*(r,g,b,a: int): TColor {.inline.} =
|
||||
return color(r,g,b,a)
|
||||
|
||||
proc newClock*(): PClock {.
|
||||
|
|
@ -1022,7 +1022,7 @@ proc newContextSettings*(depthBits: cint = 0,
|
|||
result.majorVersion = majorVersion
|
||||
result.minorVersion = minorVersion
|
||||
|
||||
proc newCircleShape*(radius: cfloat; pointCount: cint = 30): PCircleShape =
|
||||
proc newCircleShape*(radius: cfloat; pointCount: cint = 30): PCircleShape =
|
||||
result = newCircleShape()
|
||||
result.setRadius radius
|
||||
result.setPointCount pointCount
|
||||
|
|
@ -1047,13 +1047,13 @@ proc `[]`*(a: PVertexArray, index: int): PVertex =
|
|||
proc `$` *(a: TContextSettings): string =
|
||||
return "<TContextSettings stencil=$1 aa=$2 major=$3 minor=$4 depth=$5>" % [
|
||||
$a.stencilBits, $a.antialiasingLevel, $a.majorVersion, $a.minorVersion, $a.depthBits]
|
||||
proc `$` *(a: TVideoMode): string =
|
||||
proc `$` *(a: TVideoMode): string =
|
||||
return "<TVideoMode $1x$2 $3bpp>" % [$a.width, $a.height, $a.bitsPerPixel]
|
||||
proc `$` *(a: TFloatRect): string =
|
||||
proc `$` *(a: TFloatRect): string =
|
||||
return "<TFloatRect $1,$2 $3x$4>" % [$a.left, $a.top, $a.width, $a.height]
|
||||
proc `$` *(a: PView): string =
|
||||
proc `$` *(a: PView): string =
|
||||
return $a.getViewport()
|
||||
proc `$` *(a: TVector2f): string =
|
||||
proc `$` *(a: TVector2f): string =
|
||||
return "<TVector2f $1,$2>" % [$a.x, $a.y]
|
||||
|
||||
proc vec2i*(x, y: int): TVector2i =
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ proc newSoundBuffer*(stream: PInputStream): PSoundBuffer{.
|
|||
#/ \return A new sfSoundBuffer object (NULL if failed)
|
||||
#/
|
||||
#//////////////////////////////////////////////////////////
|
||||
proc createFromSamples*(samples: ptr int16; sampleCount: cuint;
|
||||
proc createFromSamples*(samples: ptr int16; sampleCount: cuint;
|
||||
channelCount: cuint; sampleRate: cuint): PSoundBuffer{.
|
||||
cdecl, importc: "sfSoundBuffer_createFromSamples", dynlib: Lib.}
|
||||
#//////////////////////////////////////////////////////////
|
||||
|
|
@ -437,10 +437,10 @@ proc listenerSetDirection*(orientation: TVector3f){.
|
|||
proc listenerGetDirection*(): TVector3f{.
|
||||
cdecl, importc: "sfListener_getDirection", dynlib: Lib.}
|
||||
|
||||
type
|
||||
type
|
||||
TSoundRecorderStartCallback* = proc (a2: pointer): bool {.cdecl.}
|
||||
#/< Type of the callback used when starting a capture
|
||||
TSoundRecorderProcessCallback* = proc(a2: ptr int16; a3: cuint;
|
||||
#/< Type of the callback used when starting a capture
|
||||
TSoundRecorderProcessCallback* = proc(a2: ptr int16; a3: cuint;
|
||||
a4: pointer): bool {.cdecl.}
|
||||
#/< Type of the callback used to process audio data
|
||||
TSoundRecorderStopCallback* = proc (a2: pointer){.cdecl.}
|
||||
|
|
@ -456,9 +456,9 @@ type
|
|||
#/ \return A new sfSoundRecorder object (NULL if failed)
|
||||
#/
|
||||
#//////////////////////////////////////////////////////////
|
||||
proc newSoundRecorder*(onStart: TSoundRecorderStartCallback;
|
||||
onProcess: TSoundRecorderProcessCallback;
|
||||
onStop: TSoundRecorderStopCallback;
|
||||
proc newSoundRecorder*(onStart: TSoundRecorderStartCallback;
|
||||
onProcess: TSoundRecorderProcessCallback;
|
||||
onStop: TSoundRecorderStopCallback;
|
||||
userData: pointer = nil): PSoundRecorder{.
|
||||
cdecl, importc: "sfSoundRecorder_create", dynlib: Lib.}
|
||||
#//////////////////////////////////////////////////////////
|
||||
|
|
@ -595,13 +595,13 @@ proc getBuffer*(soundBufferRecorder: PSoundBufferRecorder): PSoundBuffer{.
|
|||
#/ \brief defines the data to fill by the OnGetData callback
|
||||
#/
|
||||
#//////////////////////////////////////////////////////////
|
||||
type
|
||||
type
|
||||
PSoundStreamChunk* = ptr TSoundStreamChunk
|
||||
TSoundStreamChunk*{.pure, final.} = object
|
||||
TSoundStreamChunk*{.pure, final.} = object
|
||||
samples*: ptr int16 #/< Pointer to the audio samples
|
||||
sampleCount*: cuint #/< Number of samples pointed by Samples
|
||||
|
||||
TSoundStreamGetDataCallback* = proc (a2: PSoundStreamChunk;
|
||||
|
||||
TSoundStreamGetDataCallback* = proc (a2: PSoundStreamChunk;
|
||||
a3: pointer): bool{.cdecl.}
|
||||
#/< Type of the callback used to get a sound stream data
|
||||
TSoundStreamSeekCallback* = proc (a2: TTime; a3: pointer){.cdecl.}
|
||||
|
|
@ -618,7 +618,7 @@ type
|
|||
#/ \return A new sfSoundStream object
|
||||
#/
|
||||
#//////////////////////////////////////////////////////////
|
||||
proc create*(onGetData: TSoundStreamGetDataCallback; onSeek: TSoundStreamSeekCallback;
|
||||
proc create*(onGetData: TSoundStreamGetDataCallback; onSeek: TSoundStreamSeekCallback;
|
||||
channelCount: cuint; sampleRate: cuint; userData: pointer): PSoundStream{.
|
||||
cdecl, importc: "sfSoundStream_create", dynlib: Lib.}
|
||||
#//////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ let
|
|||
Transparent*: TColor = color(0, 0, 0, 0)
|
||||
Gray* = color(84, 84, 84)
|
||||
RoyalBlue* = color(65, 105, 225)
|
||||
##todo: define more colors lul
|
||||
##todo: define more colors lul
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ proc poll(serv: PServer; timeout: cuint = 30) =
|
|||
case event.kind
|
||||
of EvtReceive:
|
||||
var buf = newBuffer(event.packet)
|
||||
|
||||
|
||||
serv.handlePackets(buf)
|
||||
|
||||
|
||||
event.packet.destroy()
|
||||
of EvtDisconnect:
|
||||
of EvtDisconnect:
|
||||
dispMessage "Disconnected"
|
||||
serv.connected = false
|
||||
event.peer.data = nil
|
||||
|
|
@ -111,8 +111,8 @@ proc tryConnect*(b: PButton) =
|
|||
if not dirServer.connected:
|
||||
var error: string
|
||||
if not dirServer.connect(
|
||||
clientSettings.dirServer.host,
|
||||
clientSettings.dirServer.port,
|
||||
clientSettings.dirServer.host,
|
||||
clientSettings.dirServer.port,
|
||||
error):
|
||||
dispError(error)
|
||||
else:
|
||||
|
|
@ -143,16 +143,16 @@ proc lobbyInit*() =
|
|||
clientSettings.website = s["website"].str
|
||||
zonelist.setPosition(vec2f(200.0, 100.0))
|
||||
connectionButtons = @[]
|
||||
|
||||
|
||||
var pos = vec2f(10, 10)
|
||||
u_alias = gui.newTextEntry(
|
||||
if s.hasKey("alias"): s["alias"].str else: "alias",
|
||||
if s.hasKey("alias"): s["alias"].str else: "alias",
|
||||
pos)
|
||||
pos.y += 20
|
||||
u_passwd = gui.newTextEntry("buzz", pos)
|
||||
pos.y += 20
|
||||
connectionButtons.add(gui.newButton(
|
||||
text = "Login",
|
||||
text = "Login",
|
||||
position = pos,
|
||||
onClick = tryLogin,
|
||||
startEnabled = false))
|
||||
|
|
@ -171,16 +171,16 @@ proc lobbyInit*() =
|
|||
connectionButtons.add(gui.newButton(
|
||||
text = "Test Chat",
|
||||
position = pos,
|
||||
onClick = (proc(b: PButton) =
|
||||
onClick = (proc(b: PButton) =
|
||||
var pkt = newCsChat(text = "ohai")
|
||||
dirServer.send HChat, pkt),
|
||||
startEnabled = false))
|
||||
pos.y += 20
|
||||
downloadProgress.setPosition(pos)
|
||||
downloadProgress.setPosition(pos)
|
||||
downloadProgress.bg.setFillColor(color(34, 139, 34))
|
||||
downloadProgress.bg.setSize(vec2f(0, 0))
|
||||
gui.add(downloadProgress)
|
||||
|
||||
|
||||
playBtn = gui.newButton(
|
||||
text = "Play",
|
||||
position = vec2f(680.0, 8.0),
|
||||
|
|
@ -193,20 +193,20 @@ proc lobbyInit*() =
|
|||
discard """gui.newButton(text = "Scrollback + 1", position = vec2f(185, 10), onClick = proc(b: PButton) =
|
||||
messageArea.scrollBack += 1
|
||||
update(messageArea))
|
||||
gui.newButton(text = "Scrollback - 1", position = vec2f(185+160, 10), onClick = proc(b: PButton) =
|
||||
gui.newButton(text = "Scrollback - 1", position = vec2f(185+160, 10), onClick = proc(b: PButton) =
|
||||
messageArea.scrollBack -= 1
|
||||
update(messageArea))
|
||||
gui.newButton(text = "Flood msg area", position = vec2f(185, 30), onClick = proc(b: PButton) =
|
||||
for i in 0.. <30:
|
||||
for i in 0.. <30:
|
||||
dispMessage($i))"""
|
||||
dirServer = newServer()
|
||||
dirServer = newServer()
|
||||
dirServer.addHandler HChat, handleChat
|
||||
dirServer.addHandler HLogin, handlePlayerLogin
|
||||
dirServer.addHandler HFileTransfer, client_helpers.handleFilePartRecv
|
||||
dirServer.addHandler HChallengeResult, client_helpers.handleFileChallengeResult
|
||||
dirServer.addHandler HFileChallenge, client_helpers.handleFileChallenge
|
||||
|
||||
proc lobbyReady*() =
|
||||
proc lobbyReady*() =
|
||||
kc.setActive()
|
||||
gui.setActive(u_alias)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import enet, strutils, idgen, tables, math_helpers,
|
||||
import enet, strutils, idgen, tables, math_helpers,
|
||||
estreams, sg_packets, server_utils, sg_assets, client_helpers
|
||||
when appType == "gui":
|
||||
import sfml, sfml_colors, sg_gui,
|
||||
|
|
@ -14,7 +14,7 @@ var
|
|||
event: enet.TEvent
|
||||
clientID = newIDGen[int32]()
|
||||
clients = initTable[int32, PClient](64)
|
||||
handlers = initTable[char, TCallback](32)
|
||||
handlers = initTable[char, TCallback](32)
|
||||
|
||||
when appType == "gui":
|
||||
var
|
||||
|
|
@ -67,7 +67,7 @@ proc flushPubChat() =
|
|||
|
||||
handlers[HChat] = proc(client: PClient; buffer: PBuffer) =
|
||||
var chat = readCsChat(buffer)
|
||||
|
||||
|
||||
if not client.auth:
|
||||
client.sendError("You are not logged in.")
|
||||
return
|
||||
|
|
@ -75,7 +75,7 @@ handlers[HChat] = proc(client: PClient; buffer: PBuffer) =
|
|||
# if alias2client.hasKey(chat.target):
|
||||
# alias2client[chat.target].forwardPrivate(client, chat.text)
|
||||
#else:
|
||||
|
||||
|
||||
dispmessage("<", client.alias, "> ", chat.text)
|
||||
queuePub(client, chat)
|
||||
|
||||
|
|
@ -104,20 +104,20 @@ handlers[HZoneJoinReq] = proc(client: PClient; buffer: PBuffer) =
|
|||
|
||||
when isMainModule:
|
||||
import parseopt, matchers, os, json
|
||||
|
||||
|
||||
|
||||
|
||||
if enetInit() != 0:
|
||||
quit "Could not initialize ENet"
|
||||
|
||||
|
||||
var address: enet.TAddress
|
||||
|
||||
|
||||
block:
|
||||
var zoneCfgFile = "./server_settings.json"
|
||||
for kind, key, val in getOpt():
|
||||
case kind
|
||||
of cmdShortOption, cmdLongOption:
|
||||
case key
|
||||
of "f", "file":
|
||||
of "f", "file":
|
||||
if existsFile(val):
|
||||
zoneCfgFile = val
|
||||
else:
|
||||
|
|
@ -127,45 +127,45 @@ when isMainModule:
|
|||
else:
|
||||
echo("Unknown option: ", key, " ", val)
|
||||
var jsonSettings = parseFile(zoneCfgFile)
|
||||
let
|
||||
let
|
||||
port = uint16(jsonSettings["port"].num)
|
||||
zoneFile = jsonSettings["settings"].str
|
||||
dirServerInfo = jsonSettings["dirserver"]
|
||||
|
||||
|
||||
address.host = EnetHostAny
|
||||
address.port = port
|
||||
|
||||
|
||||
var path = getAppDir()/../"data"/zoneFile
|
||||
if not existsFile(path):
|
||||
echo("Zone settings file does not exist: ../data/", zoneFile)
|
||||
echo(path)
|
||||
quit(1)
|
||||
|
||||
|
||||
discard """block:
|
||||
var
|
||||
var
|
||||
TestFile: FileChallengePair
|
||||
contents = repeat("abcdefghijklmnopqrstuvwxyz", 2)
|
||||
testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32)
|
||||
testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32)
|
||||
testFile.file = checksumStr(contents)
|
||||
myAssets.add testFile"""
|
||||
|
||||
|
||||
setCurrentDir getAppDir().parentDir()
|
||||
let zonesettings = readFile(path)
|
||||
var
|
||||
var
|
||||
errors: seq[string] = @[]
|
||||
if not loadSettings(zoneSettings, errors):
|
||||
echo("You have errors in your zone settings:")
|
||||
for e in errors: echo("**", e)
|
||||
quit(1)
|
||||
errors.setLen 0
|
||||
|
||||
|
||||
var pair: FileChallengePair
|
||||
pair.challenge.file = zoneFile
|
||||
pair.challenge.assetType = FZoneCfg
|
||||
pair.challenge.fullLen = zoneSettings.len.int32
|
||||
pair.file = checksumStr(zoneSettings)
|
||||
myAssets.add pair
|
||||
|
||||
|
||||
allAssets:
|
||||
if not load(asset):
|
||||
echo "Invalid or missing file ", file
|
||||
|
|
@ -177,11 +177,11 @@ when isMainModule:
|
|||
expandPath(assetType, file)).int32
|
||||
pair.file = asset.contents
|
||||
myAssets.add pair
|
||||
|
||||
|
||||
echo "Zone has ", myAssets.len, " associated assets"
|
||||
|
||||
|
||||
dirServer = newServer()
|
||||
|
||||
|
||||
dirServer.addHandler HDsMsg, proc(serv: PServer; buffer: PBuffer) =
|
||||
var m = readDsMsg(buffer)
|
||||
dispMessage("<DirServer> ", m.msg)
|
||||
|
|
@ -189,20 +189,20 @@ when isMainModule:
|
|||
let loggedIn = readDsZoneLogin(buffer).status
|
||||
if loggedIn:
|
||||
#dirServerConnected = true
|
||||
|
||||
|
||||
if dirServerInfo.kind == JArray:
|
||||
var error: string
|
||||
if not dirServer.connect(dirServerInfo[0].str, dirServerInfo[1].num.int16, error):
|
||||
dispError("<DirServer> "&error)
|
||||
|
||||
|
||||
|
||||
|
||||
server = enet.createHost(address, 32, 2, 0, 0)
|
||||
if server == nil:
|
||||
quit "Could not create the server!"
|
||||
|
||||
|
||||
dispMessage("Listening on port ", address.port)
|
||||
|
||||
var
|
||||
|
||||
var
|
||||
serverRunning = true
|
||||
when appType == "gui":
|
||||
var frameRate = newClock()
|
||||
|
|
@ -210,11 +210,11 @@ when isMainModule:
|
|||
else:
|
||||
var frameRate = epochTime()
|
||||
var pubChatDelay = frameRate
|
||||
|
||||
|
||||
while serverRunning:
|
||||
when appType == "gui":
|
||||
let dt = frameRate.restart.asMilliseconds().float / 1000.0
|
||||
|
||||
|
||||
for event in window.filterEvents():
|
||||
case event.kind
|
||||
of sfml.EvtClosed:
|
||||
|
|
@ -225,7 +225,7 @@ when isMainModule:
|
|||
else:
|
||||
let dt = epochTime() - frameRate ##is this right? probably not
|
||||
frameRate = epochTime()
|
||||
|
||||
|
||||
while server.hostService(event, 10) > 0:
|
||||
case event.kind
|
||||
of EvtConnect:
|
||||
|
|
@ -234,27 +234,27 @@ when isMainModule:
|
|||
|
||||
event.peer.data = addr client.id
|
||||
client.peer = event.peer
|
||||
|
||||
|
||||
dispMessage("New client connected ", client)
|
||||
|
||||
|
||||
var
|
||||
msg = "hello"
|
||||
msg = "hello"
|
||||
resp = createPacket(cstring(msg), msg.len + 1, FlagReliable)
|
||||
|
||||
|
||||
if event.peer.send(0.cuchar, resp) < 0:
|
||||
echo "FAILED"
|
||||
else:
|
||||
echo "Replied"
|
||||
of EvtReceive:
|
||||
let client = clients[cast[ptr int32](event.peer.data)[]]
|
||||
|
||||
let client = clients[cast[ptr int32](event.peer.data)[]]
|
||||
|
||||
var buf = newBuffer(event.packet)
|
||||
let k = buf.readChar()
|
||||
if handlers.hasKey(k):
|
||||
handlers[k](client, buf)
|
||||
else:
|
||||
dispError("Unknown packet from ", client)
|
||||
|
||||
|
||||
destroy(event.packet)
|
||||
of EvtDisconnect:
|
||||
var
|
||||
|
|
@ -267,11 +267,11 @@ when isMainModule:
|
|||
dispMessage(clients[id], " disconnected")
|
||||
GCUnref(clients[id])
|
||||
clients.del id
|
||||
|
||||
|
||||
event.peer.data = nil
|
||||
else:
|
||||
discard
|
||||
|
||||
|
||||
when appType == "gui":
|
||||
fpsText.setString(ff(1.0/dt))
|
||||
if pubChatDelay.getElapsedTime.asSeconds > 0.25:
|
||||
|
|
@ -281,14 +281,14 @@ when isMainModule:
|
|||
pubChatDelay -= dt
|
||||
if frameRate - pubChatDelay > 0.25:
|
||||
flushPubChat()
|
||||
|
||||
|
||||
when appType == "gui":
|
||||
window.clear(Black)
|
||||
window.draw(GUI)
|
||||
window.draw chatbox
|
||||
window.draw mousePos
|
||||
window.draw fpstext
|
||||
window.display()
|
||||
window.display()
|
||||
|
||||
server.destroy()
|
||||
enetDeinit()
|
||||
enetDeinit()
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ type
|
|||
auth*: bool
|
||||
alias*: string
|
||||
peer*: PPeer
|
||||
|
||||
|
||||
FileChallengePair* = tuple[challenge: ScFileChallenge; file: TChecksumFile]
|
||||
PFileChallengeSequence* = ref TFileChallengeSequence
|
||||
PFileChallengeSequence* = ref TFileChallengeSequence
|
||||
TFileChallengeSequence = object
|
||||
index: int #which file is active
|
||||
transfer: ScFileTransfer
|
||||
|
|
@ -73,7 +73,7 @@ proc sendChunk*(challenge: PFileChallengeSequence, client: PClient) =
|
|||
let size = min(FileChunkSize, challenge.transfer.fileSize - challenge.transfer.pos)
|
||||
challenge.transfer.data.setLen size
|
||||
copyMem(
|
||||
addr challenge.transfer.data[0],
|
||||
addr challenge.transfer.data[0],
|
||||
addr challenge.file.file.compressed[challenge.transfer.pos],
|
||||
size)
|
||||
client.send HFileTransfer, challenge.transfer
|
||||
|
|
@ -90,7 +90,7 @@ proc startSend*(challenge: PFileChallengeSequence, client: PClient) =
|
|||
## HFileTransfer
|
||||
proc handleFilePartAck*(client: PClient; buffer: PBuffer) =
|
||||
echo "got filepartack"
|
||||
var
|
||||
var
|
||||
ftrans = readCsFilepartAck(buffer)
|
||||
fcSeq = fileChallenges[client.id]
|
||||
fcSeq.transfer.pos = ftrans.lastPos
|
||||
|
|
@ -99,7 +99,7 @@ proc handleFilePartAck*(client: PClient; buffer: PBuffer) =
|
|||
## HFileCHallenge
|
||||
proc handleFileChallengeResp*(client: PClient; buffer: PBuffer) =
|
||||
echo "got file challenge resp"
|
||||
var
|
||||
var
|
||||
fcResp = readCsFileChallenge(buffer)
|
||||
fcSeq = fileChallenges[client.id]
|
||||
let index = $(fcSeq.index + 1) / $(myAssets.len)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import
|
||||
import
|
||||
os, math, strutils, gl, tables,
|
||||
sfml, sfml_audio, sfml_colors, chipmunk, math_helpers,
|
||||
input_helpers, animations, game_objects, sfml_stuff, map_filter,
|
||||
|
|
@ -29,7 +29,7 @@ type
|
|||
angle*: float
|
||||
PItem* = ref object
|
||||
record: PItemRecord
|
||||
cooldown: float
|
||||
cooldown: float
|
||||
PLiveBullet* = ref TLiveBullet ##represents a live bullet in the arena
|
||||
TLiveBullet* = object
|
||||
lifetime*: float
|
||||
|
|
@ -80,7 +80,7 @@ var
|
|||
delObjects: seq[int] = @[]
|
||||
showShipSelect = false
|
||||
myPosition: array[0..1, TVector3f] ##for audio positioning
|
||||
let
|
||||
let
|
||||
nameTagOffset = vec2f(0.0, 1.0)
|
||||
when defined(escapeMenuTest):
|
||||
import browsers
|
||||
|
|
@ -100,10 +100,10 @@ when defined(escapeMenuTest):
|
|||
when defined(foo):
|
||||
var mouseSprite: sfml.PCircleShape
|
||||
when defined(recordMode):
|
||||
var
|
||||
var
|
||||
snapshots: seq[PImage] = @[]
|
||||
isRecording = false
|
||||
proc startRecording() =
|
||||
proc startRecording() =
|
||||
if snapshots.len > 100: return
|
||||
echo "Started recording"
|
||||
isRecording = true
|
||||
|
|
@ -142,26 +142,26 @@ proc mouseToSpace*(): TVector =
|
|||
|
||||
proc explode*(b: PLiveBullet)
|
||||
## TCollisionBeginFunc
|
||||
proc collisionBulletPlayer(arb: PArbiter; space: PSpace;
|
||||
proc collisionBulletPlayer(arb: PArbiter; space: PSpace;
|
||||
data: pointer): bool{.cdecl.} =
|
||||
var
|
||||
var
|
||||
bullet = cast[PLiveBullet](arb.a.data)
|
||||
target = cast[PVehicle](arb.b.data)
|
||||
if target.occupant.isNil or target.occupant == bullet.fromPlayer: return
|
||||
bullet.explode()
|
||||
|
||||
proc angularDampingSim(body: PBody, gravity: TVector, damping, dt: CpFloat){.cdecl.} =
|
||||
body.w -= (body.w * 0.98 * dt)
|
||||
body.w -= (body.w * 0.98 * dt)
|
||||
body.UpdateVelocity(gravity, damping, dt)
|
||||
|
||||
proc initLevel() =
|
||||
loadAllAssets()
|
||||
|
||||
|
||||
if not space.isNil: space.destroy()
|
||||
space = newSpace()
|
||||
space.addCollisionHandler CTBullet, CTVehicle, collisionBulletPlayer,
|
||||
nil, nil, nil, nil
|
||||
|
||||
|
||||
let levelSettings = getLevelSettings()
|
||||
levelArea.width = levelSettings.size.x
|
||||
levelArea.height= levelSettings.size.y
|
||||
|
|
@ -171,8 +171,8 @@ proc initLevel() =
|
|||
for i in 0..3:
|
||||
var seg = space.addShape(
|
||||
newSegmentShape(
|
||||
space.staticBody,
|
||||
borderSeq[i],
|
||||
space.staticBody,
|
||||
borderSeq[i],
|
||||
borderSeq[(i + 1) mod 4],
|
||||
8.0))
|
||||
seg.setElasticity 0.96
|
||||
|
|
@ -188,8 +188,8 @@ proc initLevel() =
|
|||
for veh in playableVehicles():
|
||||
shipSelect.newButton(
|
||||
veh.name,
|
||||
position = pos,
|
||||
onClick = proc(b: PButton) =
|
||||
position = pos,
|
||||
onClick = proc(b: PButton) =
|
||||
echo "-__-")
|
||||
pos.y += 18.0
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ proc newItem*(record: PItemRecord): PItem =
|
|||
result.record = record
|
||||
proc newItem*(name: string): PItem {.inline.} =
|
||||
return newItem(fetchItm(name))
|
||||
proc canUse*(itm: PItem): bool =
|
||||
proc canUse*(itm: PItem): bool =
|
||||
if itm.cooldown > 0.0: return
|
||||
return true
|
||||
proc update*(itm: PItem; dt: float) =
|
||||
|
|
@ -252,7 +252,7 @@ proc newBullet*(record: PBulletRecord; fromPlayer: PPlayer): PLiveBullet =
|
|||
result.shape.setLayers(LEnemyFire)
|
||||
result.shape.setCollisionType CTBullet
|
||||
result.shape.setUserData(cast[ptr TLiveBullet](result))
|
||||
let
|
||||
let
|
||||
fireAngle = fromPlayer.vehicle.body.getAngle()
|
||||
fireAngleV = vectorForAngle(fireAngle)
|
||||
result.body.setAngle fireAngle
|
||||
|
|
@ -341,14 +341,14 @@ proc update*(obj: PPlayer) =
|
|||
obj.nameTag.setPosition(obj.vehicle.body.getPos.floor + (nameTagOffset * (obj.vehicle.record.physics.radius + 5).cfloat))
|
||||
|
||||
proc draw(window: PRenderWindow, player: PPlayer) {.inline.} =
|
||||
if not player.spectator:
|
||||
if not player.spectator:
|
||||
if player.vehicle != nil:
|
||||
window.draw(player.vehicle.sprite)
|
||||
window.draw(player.nameTag)
|
||||
|
||||
proc setVehicle(p: PPlayer; v: PVehicle) =
|
||||
proc setVehicle(p: PPlayer; v: PVehicle) =
|
||||
p.vehicle = v #sorry mom, this is just how things worked out ;(
|
||||
if not v.isNil:
|
||||
if not v.isNil:
|
||||
v.occupant = p
|
||||
|
||||
proc createBot() =
|
||||
|
|
@ -369,7 +369,7 @@ var inputCursor = newVertexArray(sfml.Lines, 2)
|
|||
inputCursor[0].position = vec2f(10.0, 10.0)
|
||||
inputCursor[1].position = vec2f(50.0, 90.0)
|
||||
|
||||
proc hasVehicle(p: PPlayer): bool {.inline.} =
|
||||
proc hasVehicle(p: PPlayer): bool {.inline.} =
|
||||
result = not p.spectator and not p.vehicle.isNil
|
||||
|
||||
proc setMyVehicle(v: PVehicle) {.inline.} =
|
||||
|
|
@ -396,27 +396,27 @@ proc spec() =
|
|||
localPlayer.spectator = true
|
||||
specInputClient.setActive
|
||||
|
||||
var
|
||||
var
|
||||
specLimiter = newClock()
|
||||
timeBetweenSpeccing = 1.0 #seconds
|
||||
proc toggleSpec() {.inline.} =
|
||||
if specLimiter.getElapsedTime.asSeconds < timeBetweenSpeccing:
|
||||
return
|
||||
specLimiter.restart()
|
||||
if localPlayer.isNil:
|
||||
if localPlayer.isNil:
|
||||
echo("OMG WTF PLAYER IS NILL!!")
|
||||
elif localPlayer.spectator: unspec()
|
||||
else: spec()
|
||||
|
||||
proc addObject*(name: string) =
|
||||
var o = newObject(name)
|
||||
if not o.isNil:
|
||||
if not o.isNil:
|
||||
echo "Adding object ", o
|
||||
discard space.addBody(o.body)
|
||||
discard space.addShape(o.shape)
|
||||
o.shape.setLayers(LGrabbable)
|
||||
objects.add(o)
|
||||
proc explode(obj: PGameObject) =
|
||||
proc explode(obj: PGameObject) =
|
||||
echo obj, " exploded"
|
||||
let ind = objects.find(obj)
|
||||
if ind != -1:
|
||||
|
|
@ -428,7 +428,7 @@ proc update(obj: PGameObject; dt: float) =
|
|||
obj.anim.setPos(obj.body.getPos)
|
||||
obj.anim.setAngle(obj.body.getAngle)
|
||||
|
||||
proc toggleShipSelect() =
|
||||
proc toggleShipSelect() =
|
||||
showShipSelect = not showShipSelect
|
||||
proc handleLClick() =
|
||||
let pos = input_helpers.getMousePos()
|
||||
|
|
@ -459,9 +459,9 @@ when defined(recordMode):
|
|||
snapshots[i].destroy()
|
||||
snapshots.setLen 0)
|
||||
when defined(DebugKeys):
|
||||
ingameClient.registerHandler MouseRight, down, proc() =
|
||||
ingameClient.registerHandler MouseRight, down, proc() =
|
||||
echo($activevehicle.body.getAngle.vectorForAngle())
|
||||
ingameClient.registerHandler KeyBackslash, down, proc() =
|
||||
ingameClient.registerHandler KeyBackslash, down, proc() =
|
||||
createBot()
|
||||
ingameClient.registerHandler(KeyNum1, down, proc() =
|
||||
if localPlayer.items.len == 0:
|
||||
|
|
@ -493,7 +493,7 @@ when defined(DebugKeys):
|
|||
for i, o in pairs(objects):
|
||||
echo i, " ", o)
|
||||
ingameClient.registerHandler(KeyLBracket, down, sound_buffer.report)
|
||||
var
|
||||
var
|
||||
mouseJoint: PConstraint
|
||||
mouseBody = space.addBody(newBody(CpInfinity, CpInfinity))
|
||||
ingameClient.registerHandler(MouseMiddle, down, proc() =
|
||||
|
|
@ -503,7 +503,7 @@ when defined(DebugKeys):
|
|||
space.removeConstraint mouseJoint
|
||||
mouseJoint.destroy()
|
||||
mouseJoint = nil
|
||||
if shape.isNil:
|
||||
if shape.isNil:
|
||||
return
|
||||
let body = shape.getBody()
|
||||
mouseJoint = space.addConstraint(
|
||||
|
|
@ -564,42 +564,42 @@ proc mainUpdate(dt: float) =
|
|||
if keyPressed(KeyD):
|
||||
localPlayer.useItem 6
|
||||
worldView.setCenter(activeVehicle.body.getPos.floor)#cp2sfml)
|
||||
|
||||
if localPlayer != nil:
|
||||
|
||||
if localPlayer != nil:
|
||||
localPlayer.update()
|
||||
localPlayer.updateItems(dt)
|
||||
for b in localBots:
|
||||
b.update()
|
||||
|
||||
|
||||
for o in items(objects):
|
||||
o.update(dt)
|
||||
for i in countdown(high(delObjects), 0):
|
||||
objects.del i
|
||||
delObjects.setLen 0
|
||||
|
||||
|
||||
var i = 0
|
||||
while i < len(liveBullets):
|
||||
if liveBullets[i].update(dt):
|
||||
liveBullets.del i
|
||||
else:
|
||||
else:
|
||||
inc i
|
||||
i = 0
|
||||
while i < len(explosions):
|
||||
if explosions[i].next(dt): inc i
|
||||
else: explosions.del i
|
||||
|
||||
|
||||
when defined(DebugKeys):
|
||||
mouseBody.setPos(mouseToSpace())
|
||||
|
||||
|
||||
space.step(dt)
|
||||
space.eachBody(resetForcesCB, nil)
|
||||
|
||||
|
||||
when defined(foo):
|
||||
var coords = window.convertCoords(vec2i(getMousePos()), worldView)
|
||||
mouseSprite.setPosition(coords)
|
||||
|
||||
|
||||
if localPlayer != nil and localPlayer.vehicle != nil:
|
||||
let
|
||||
let
|
||||
pos = localPlayer.vehicle.body.getPos()
|
||||
ang = localPlayer.vehicle.body.getAngle.vectorForAngle()
|
||||
myPosition[0].x = pos.x
|
||||
|
|
@ -608,7 +608,7 @@ proc mainUpdate(dt: float) =
|
|||
myPosition[1].z = ang.y
|
||||
listenerSetPosition(myPosition[0])
|
||||
listenerSetDirection(myPosition[1])
|
||||
|
||||
|
||||
inc frameCount
|
||||
when defined(showFPS):
|
||||
if frameCount mod 60 == 0:
|
||||
|
|
@ -620,25 +620,25 @@ proc mainUpdate(dt: float) =
|
|||
proc mainRender() =
|
||||
window.clear(Black)
|
||||
window.setView(worldView)
|
||||
|
||||
|
||||
if showStars:
|
||||
for star in stars:
|
||||
window.draw(star.sprite)
|
||||
window.draw(localPlayer)
|
||||
|
||||
|
||||
for b in localBots:
|
||||
window.draw(b)
|
||||
for o in objects:
|
||||
window.draw(o)
|
||||
|
||||
|
||||
for b in explosions: window.draw(b)
|
||||
for b in liveBullets: window.draw(b)
|
||||
|
||||
|
||||
when defined(Foo):
|
||||
window.draw(mouseSprite)
|
||||
|
||||
|
||||
window.setView(guiView)
|
||||
|
||||
|
||||
when defined(EscapeMenuTest):
|
||||
if escMenuOpen:
|
||||
window.draw escMenu
|
||||
|
|
@ -646,12 +646,12 @@ proc mainRender() =
|
|||
window.draw(fpsText)
|
||||
when defined(recordMode):
|
||||
window.draw(recordButton)
|
||||
|
||||
|
||||
if localPlayer.spectator:
|
||||
window.draw(specGui)
|
||||
if showShipSelect: window.draw shipSelect
|
||||
window.display()
|
||||
|
||||
|
||||
when defined(recordMode):
|
||||
if isRecording:
|
||||
if snapshots.len < 100:
|
||||
|
|
@ -664,30 +664,30 @@ proc readyMainState() =
|
|||
|
||||
when isMainModule:
|
||||
import parseopt
|
||||
|
||||
|
||||
localPlayer = newPlayer()
|
||||
lobbyInit()
|
||||
|
||||
|
||||
videoMode = getClientSettings().resolution
|
||||
window = newRenderWindow(videoMode, "sup", sfDefaultStyle)
|
||||
window.setFrameRateLimit 60
|
||||
|
||||
|
||||
worldView = window.getView.copy()
|
||||
guiView = worldView.copy()
|
||||
shipSelect.setPosition vec2f(665.0, 50.0)
|
||||
|
||||
|
||||
when defined(foo):
|
||||
mouseSprite = sfml.newCircleShape(14)
|
||||
mouseSprite.setFillColor Transparent
|
||||
mouseSprite.setOutlineColor RoyalBlue
|
||||
mouseSprite.setOutlineThickness 1.4
|
||||
mouseSprite.setOrigin vec2f(14, 14)
|
||||
|
||||
|
||||
lobbyReady()
|
||||
playBtn = specGui.newButton(
|
||||
"Unspec - F12", position = vec2f(680.0, 8.0), onClick = proc(b: PButton) =
|
||||
toggleSpec())
|
||||
|
||||
|
||||
block:
|
||||
var bPlayOffline = false
|
||||
for kind, key, val in getOpt():
|
||||
|
|
@ -698,7 +698,7 @@ when isMainModule:
|
|||
echo "Invalid argument ", key, " ", val
|
||||
if bPlayOffline:
|
||||
playoffline(nil)
|
||||
|
||||
|
||||
gameRunning = true
|
||||
while gameRunning:
|
||||
for event in window.filterEvents:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import
|
||||
import
|
||||
tables, sg_packets, enet, estreams, sg_gui, sfml,
|
||||
zlib_helpers, md5, sg_assets, os
|
||||
type
|
||||
|
|
@ -17,7 +17,7 @@ type
|
|||
pos: int32
|
||||
data: string
|
||||
readyToSave: bool
|
||||
var
|
||||
var
|
||||
currentFileTransfer: TFileTransfer
|
||||
downloadProgress* = newButton(nil, "", vec2f(0,0), nil)
|
||||
currentFileTransfer.data = ""
|
||||
|
|
@ -73,7 +73,7 @@ proc handleFilePartRecv*(serv: PServer; buffer: PBuffer) {.procvar.} =
|
|||
var
|
||||
f = readScFileTransfer(buffer)
|
||||
updateFileProgress()
|
||||
if not(f.pos == currentFileTransfer.pos):
|
||||
if not(f.pos == currentFileTransfer.pos):
|
||||
echo "returning early from filepartrecv"
|
||||
return ##issues, probably
|
||||
if currentFileTransfer.data.len == 0:
|
||||
|
|
@ -100,7 +100,7 @@ proc handleFilePartRecv*(serv: PServer; buffer: PBuffer) {.procvar.} =
|
|||
|
||||
proc saveCurrentFile() =
|
||||
if not currentFileTransfer.readyToSave: return
|
||||
let
|
||||
let
|
||||
path = expandPath(currentFileTransfer.assetType, currentFileTransfer.fileName)
|
||||
parent = parentDir(path)
|
||||
if not existsDir(parent):
|
||||
|
|
@ -123,7 +123,7 @@ proc handleFileChallengeResult*(serv: PServer; buffer: PBuffer) {.procvar.} =
|
|||
|
||||
## HFileCHallenge
|
||||
proc handleFileChallenge*(serv: PServer; buffer: PBuffer) {.procvar.} =
|
||||
var
|
||||
var
|
||||
challenge = readScFileChallenge(buffer)
|
||||
path = expandPath(challenge)
|
||||
resp: CsFileChallenge
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import endians
|
||||
|
||||
proc swapEndian16*(outp, inp: pointer) =
|
||||
proc swapEndian16*(outp, inp: pointer) =
|
||||
## copies `inp` to `outp` swapping bytes. Both buffers are supposed to
|
||||
## contain at least 2 bytes.
|
||||
var i = cast[cstring](inp)
|
||||
|
|
@ -113,10 +113,10 @@ when isMainModule:
|
|||
echo(repr(b))
|
||||
b.pos = 0
|
||||
echo(repr(b.readStr()))
|
||||
|
||||
|
||||
b.flush()
|
||||
echo "flushed"
|
||||
b.writeC([1,2,3])
|
||||
echo(repr(b))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,24 +5,24 @@
|
|||
# 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
|
||||
# Converted to Delphi by Tom Nuydens (tom@delphi3d.net)
|
||||
# For the latest updates, visit Delphi3D: http://www.delphi3d.net
|
||||
#******************************************************************************
|
||||
|
||||
when defined(windows):
|
||||
when defined(windows):
|
||||
{.push, callconv: stdcall.}
|
||||
else:
|
||||
else:
|
||||
{.push, callconv: cdecl.}
|
||||
when defined(windows):
|
||||
const
|
||||
when defined(windows):
|
||||
const
|
||||
dllname* = "opengl32.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
elif defined(macosx):
|
||||
const
|
||||
dllname* = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
|
||||
else:
|
||||
const
|
||||
else:
|
||||
const
|
||||
dllname* = "libGL.so.1"
|
||||
type
|
||||
type
|
||||
PGLenum* = ptr TGLenum
|
||||
PGLboolean* = ptr TGLboolean
|
||||
PGLbitfield* = ptr TGLbitfield
|
||||
|
|
@ -983,128 +983,128 @@ const # Version
|
|||
GL_TEXTURE_COMPONENTS* = GL_TEXTURE_INTERNAL_FORMAT
|
||||
|
||||
proc glAccum*(op: TGLenum, value: TGLfloat){.dynlib: dllname, importc: "glAccum".}
|
||||
proc glAlphaFunc*(fun: TGLenum, theref: TGLclampf){.dynlib: dllname,
|
||||
proc glAlphaFunc*(fun: TGLenum, theref: TGLclampf){.dynlib: dllname,
|
||||
importc: "glAlphaFunc".}
|
||||
proc glAreTexturesResident*(n: TGLsizei, textures: PGLuint,
|
||||
proc glAreTexturesResident*(n: TGLsizei, textures: PGLuint,
|
||||
residences: PGLboolean): TGLboolean{.
|
||||
dynlib: dllname, importc: "glAreTexturesResident".}
|
||||
proc glArrayElement*(i: TGLint){.dynlib: dllname, importc: "glArrayElement".}
|
||||
proc glBegin*(mode: TGLenum){.dynlib: dllname, importc: "glBegin".}
|
||||
proc glBindTexture*(target: TGLenum, texture: TGLuint){.dynlib: dllname,
|
||||
proc glBindTexture*(target: TGLenum, texture: TGLuint){.dynlib: dllname,
|
||||
importc: "glBindTexture".}
|
||||
proc glBitmap*(width, height: TGLsizei, xorig, yorig: TGLfloat,
|
||||
xmove, ymove: TGLfloat, bitmap: PGLubyte){.dynlib: dllname,
|
||||
proc glBitmap*(width, height: TGLsizei, xorig, yorig: TGLfloat,
|
||||
xmove, ymove: TGLfloat, bitmap: PGLubyte){.dynlib: dllname,
|
||||
importc: "glBitmap".}
|
||||
proc glBlendFunc*(sfactor, dfactor: TGLenum){.dynlib: dllname,
|
||||
proc glBlendFunc*(sfactor, dfactor: TGLenum){.dynlib: dllname,
|
||||
importc: "glBlendFunc".}
|
||||
proc glCallList*(list: TGLuint){.dynlib: dllname, importc: "glCallList".}
|
||||
proc glCallLists*(n: TGLsizei, atype: TGLenum, lists: pointer){.dynlib: dllname,
|
||||
proc glCallLists*(n: TGLsizei, atype: TGLenum, lists: pointer){.dynlib: dllname,
|
||||
importc: "glCallLists".}
|
||||
proc glClear*(mask: TGLbitfield){.dynlib: dllname, importc: "glClear".}
|
||||
proc glClearAccum*(red, green, blue, alpha: TGLfloat){.dynlib: dllname,
|
||||
proc glClearAccum*(red, green, blue, alpha: TGLfloat){.dynlib: dllname,
|
||||
importc: "glClearAccum".}
|
||||
proc glClearColor*(red, green, blue, alpha: TGLclampf){.dynlib: dllname,
|
||||
proc glClearColor*(red, green, blue, alpha: TGLclampf){.dynlib: dllname,
|
||||
importc: "glClearColor".}
|
||||
proc glClearDepth*(depth: TGLclampd){.dynlib: dllname, importc: "glClearDepth".}
|
||||
proc glClearIndex*(c: TGLfloat){.dynlib: dllname, importc: "glClearIndex".}
|
||||
proc glClearStencil*(s: TGLint){.dynlib: dllname, importc: "glClearStencil".}
|
||||
proc glClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname,
|
||||
proc glClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname,
|
||||
importc: "glClipPlane".}
|
||||
proc glColor3b*(red, green, blue: TGlbyte){.dynlib: dllname,
|
||||
proc glColor3b*(red, green, blue: TGlbyte){.dynlib: dllname,
|
||||
importc: "glColor3b".}
|
||||
proc glColor3bv*(v: PGLbyte){.dynlib: dllname, importc: "glColor3bv".}
|
||||
proc glColor3d*(red, green, blue: TGLdouble){.dynlib: dllname,
|
||||
proc glColor3d*(red, green, blue: TGLdouble){.dynlib: dllname,
|
||||
importc: "glColor3d".}
|
||||
proc glColor3dv*(v: PGLdouble){.dynlib: dllname, importc: "glColor3dv".}
|
||||
proc glColor3f*(red, green, blue: TGLfloat){.dynlib: dllname,
|
||||
proc glColor3f*(red, green, blue: TGLfloat){.dynlib: dllname,
|
||||
importc: "glColor3f".}
|
||||
proc glColor3fv*(v: PGLfloat){.dynlib: dllname, importc: "glColor3fv".}
|
||||
proc glColor3i*(red, green, blue: TGLint){.dynlib: dllname, importc: "glColor3i".}
|
||||
proc glColor3iv*(v: PGLint){.dynlib: dllname, importc: "glColor3iv".}
|
||||
proc glColor3s*(red, green, blue: TGLshort){.dynlib: dllname,
|
||||
proc glColor3s*(red, green, blue: TGLshort){.dynlib: dllname,
|
||||
importc: "glColor3s".}
|
||||
proc glColor3sv*(v: PGLshort){.dynlib: dllname, importc: "glColor3sv".}
|
||||
proc glColor3ub*(red, green, blue: TGLubyte){.dynlib: dllname,
|
||||
proc glColor3ub*(red, green, blue: TGLubyte){.dynlib: dllname,
|
||||
importc: "glColor3ub".}
|
||||
proc glColor3ubv*(v: PGLubyte){.dynlib: dllname, importc: "glColor3ubv".}
|
||||
proc glColor3ui*(red, green, blue: TGLuint){.dynlib: dllname,
|
||||
proc glColor3ui*(red, green, blue: TGLuint){.dynlib: dllname,
|
||||
importc: "glColor3ui".}
|
||||
proc glColor3uiv*(v: PGLuint){.dynlib: dllname, importc: "glColor3uiv".}
|
||||
proc glColor3us*(red, green, blue: TGLushort){.dynlib: dllname,
|
||||
proc glColor3us*(red, green, blue: TGLushort){.dynlib: dllname,
|
||||
importc: "glColor3us".}
|
||||
proc glColor3usv*(v: PGLushort){.dynlib: dllname, importc: "glColor3usv".}
|
||||
proc glColor4b*(red, green, blue, alpha: TGlbyte){.dynlib: dllname,
|
||||
proc glColor4b*(red, green, blue, alpha: TGlbyte){.dynlib: dllname,
|
||||
importc: "glColor4b".}
|
||||
proc glColor4bv*(v: PGLbyte){.dynlib: dllname, importc: "glColor4bv".}
|
||||
proc glColor4d*(red, green, blue, alpha: TGLdouble){.dynlib: dllname,
|
||||
proc glColor4d*(red, green, blue, alpha: TGLdouble){.dynlib: dllname,
|
||||
importc: "glColor4d".}
|
||||
proc glColor4dv*(v: PGLdouble){.dynlib: dllname, importc: "glColor4dv".}
|
||||
proc glColor4f*(red, green, blue, alpha: TGLfloat){.dynlib: dllname,
|
||||
proc glColor4f*(red, green, blue, alpha: TGLfloat){.dynlib: dllname,
|
||||
importc: "glColor4f".}
|
||||
proc glColor4fv*(v: PGLfloat){.dynlib: dllname, importc: "glColor4fv".}
|
||||
proc glColor4i*(red, green, blue, alpha: TGLint){.dynlib: dllname,
|
||||
proc glColor4i*(red, green, blue, alpha: TGLint){.dynlib: dllname,
|
||||
importc: "glColor4i".}
|
||||
proc glColor4iv*(v: PGLint){.dynlib: dllname, importc: "glColor4iv".}
|
||||
proc glColor4s*(red, green, blue, alpha: TGLshort){.dynlib: dllname,
|
||||
proc glColor4s*(red, green, blue, alpha: TGLshort){.dynlib: dllname,
|
||||
importc: "glColor4s".}
|
||||
proc glColor4sv*(v: PGLshort){.dynlib: dllname, importc: "glColor4sv".}
|
||||
proc glColor4ub*(red, green, blue, alpha: TGLubyte){.dynlib: dllname,
|
||||
proc glColor4ub*(red, green, blue, alpha: TGLubyte){.dynlib: dllname,
|
||||
importc: "glColor4ub".}
|
||||
proc glColor4ubv*(v: PGLubyte){.dynlib: dllname, importc: "glColor4ubv".}
|
||||
proc glColor4ui*(red, green, blue, alpha: TGLuint){.dynlib: dllname,
|
||||
proc glColor4ui*(red, green, blue, alpha: TGLuint){.dynlib: dllname,
|
||||
importc: "glColor4ui".}
|
||||
proc glColor4uiv*(v: PGLuint){.dynlib: dllname, importc: "glColor4uiv".}
|
||||
proc glColor4us*(red, green, blue, alpha: TGLushort){.dynlib: dllname,
|
||||
proc glColor4us*(red, green, blue, alpha: TGLushort){.dynlib: dllname,
|
||||
importc: "glColor4us".}
|
||||
proc glColor4usv*(v: PGLushort){.dynlib: dllname, importc: "glColor4usv".}
|
||||
proc glColorMask*(red, green, blue, alpha: TGLboolean){.dynlib: dllname,
|
||||
proc glColorMask*(red, green, blue, alpha: TGLboolean){.dynlib: dllname,
|
||||
importc: "glColorMask".}
|
||||
proc glColorMaterial*(face, mode: TGLenum){.dynlib: dllname,
|
||||
proc glColorMaterial*(face, mode: TGLenum){.dynlib: dllname,
|
||||
importc: "glColorMaterial".}
|
||||
proc glColorPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei,
|
||||
p: pointer){.dynlib: dllname,
|
||||
proc glColorPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei,
|
||||
p: pointer){.dynlib: dllname,
|
||||
importc: "glColorPointer".}
|
||||
proc glCopyPixels*(x, y: TGLint, width, height: TGLsizei, atype: TGLenum){.
|
||||
dynlib: dllname, importc: "glCopyPixels".}
|
||||
proc glCopyTexImage1D*(target: TGLenum, level: TGLint, internalFormat: TGLenum,
|
||||
proc glCopyTexImage1D*(target: TGLenum, level: TGLint, internalFormat: TGLenum,
|
||||
x, y: TGLint, width: TGLsizei, border: TGLint){.
|
||||
dynlib: dllname, importc: "glCopyTexImage1D".}
|
||||
proc glCopyTexImage2D*(target: TGLenum, level: TGLint, internalFormat: TGLenum,
|
||||
proc glCopyTexImage2D*(target: TGLenum, level: TGLint, internalFormat: TGLenum,
|
||||
x, y: TGLint, width, height: TGLsizei, border: TGLint){.
|
||||
dynlib: dllname, importc: "glCopyTexImage2D".}
|
||||
proc glCopyTexSubImage1D*(target: TGLenum, level, xoffset, x, y: TGLint,
|
||||
width: TGLsizei){.dynlib: dllname,
|
||||
proc glCopyTexSubImage1D*(target: TGLenum, level, xoffset, x, y: TGLint,
|
||||
width: TGLsizei){.dynlib: dllname,
|
||||
importc: "glCopyTexSubImage1D".}
|
||||
proc glCopyTexSubImage2D*(target: TGLenum,
|
||||
level, xoffset, yoffset, x, y: TGLint,
|
||||
width, height: TGLsizei){.dynlib: dllname,
|
||||
proc glCopyTexSubImage2D*(target: TGLenum,
|
||||
level, xoffset, yoffset, x, y: TGLint,
|
||||
width, height: TGLsizei){.dynlib: dllname,
|
||||
importc: "glCopyTexSubImage2D".}
|
||||
proc glCullFace*(mode: TGLenum){.dynlib: dllname, importc: "glCullFace".}
|
||||
proc glDeleteLists*(list: TGLuint, range: TGLsizei){.dynlib: dllname,
|
||||
proc glDeleteLists*(list: TGLuint, range: TGLsizei){.dynlib: dllname,
|
||||
importc: "glDeleteLists".}
|
||||
proc glDeleteTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname,
|
||||
proc glDeleteTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname,
|
||||
importc: "glDeleteTextures".}
|
||||
proc glDepthFunc*(fun: TGLenum){.dynlib: dllname, importc: "glDepthFunc".}
|
||||
proc glDepthMask*(flag: TGLboolean){.dynlib: dllname, importc: "glDepthMask".}
|
||||
proc glDepthRange*(zNear, zFar: TGLclampd){.dynlib: dllname,
|
||||
proc glDepthRange*(zNear, zFar: TGLclampd){.dynlib: dllname,
|
||||
importc: "glDepthRange".}
|
||||
proc glDisable*(cap: TGLenum){.dynlib: dllname, importc: "glDisable".}
|
||||
proc glDisableClientState*(aarray: TGLenum){.dynlib: dllname,
|
||||
proc glDisableClientState*(aarray: TGLenum){.dynlib: dllname,
|
||||
importc: "glDisableClientState".}
|
||||
proc glDrawArrays*(mode: TGLenum, first: TGLint, count: TGLsizei){.
|
||||
dynlib: dllname, importc: "glDrawArrays".}
|
||||
proc glDrawBuffer*(mode: TGLenum){.dynlib: dllname, importc: "glDrawBuffer".}
|
||||
proc glDrawElements*(mode: TGLenum, count: TGLsizei, atype: TGLenum,
|
||||
indices: pointer){.dynlib: dllname,
|
||||
proc glDrawElements*(mode: TGLenum, count: TGLsizei, atype: TGLenum,
|
||||
indices: pointer){.dynlib: dllname,
|
||||
importc: "glDrawElements".}
|
||||
proc glDrawPixels*(width, height: TGLsizei, format, atype: TGLenum,
|
||||
proc glDrawPixels*(width, height: TGLsizei, format, atype: TGLenum,
|
||||
pixels: pointer){.dynlib: dllname, importc: "glDrawPixels".}
|
||||
proc glEdgeFlag*(flag: TGLboolean){.dynlib: dllname, importc: "glEdgeFlag".}
|
||||
proc glEdgeFlagPointer*(stride: TGLsizei, p: pointer){.dynlib: dllname,
|
||||
proc glEdgeFlagPointer*(stride: TGLsizei, p: pointer){.dynlib: dllname,
|
||||
importc: "glEdgeFlagPointer".}
|
||||
proc glEdgeFlagv*(flag: PGLboolean){.dynlib: dllname, importc: "glEdgeFlagv".}
|
||||
proc glEnable*(cap: TGLenum){.dynlib: dllname, importc: "glEnable".}
|
||||
proc glEnableClientState*(aarray: TGLenum){.dynlib: dllname,
|
||||
proc glEnableClientState*(aarray: TGLenum){.dynlib: dllname,
|
||||
importc: "glEnableClientState".}
|
||||
proc glEnd*(){.dynlib: dllname, importc: "glEnd".}
|
||||
proc glEndList*(){.dynlib: dllname, importc: "glEndList".}
|
||||
|
|
@ -1116,9 +1116,9 @@ proc glEvalCoord2d*(u, v: TGLdouble){.dynlib: dllname, importc: "glEvalCoord2d".
|
|||
proc glEvalCoord2dv*(u: PGLdouble){.dynlib: dllname, importc: "glEvalCoord2dv".}
|
||||
proc glEvalCoord2f*(u, v: TGLfloat){.dynlib: dllname, importc: "glEvalCoord2f".}
|
||||
proc glEvalCoord2fv*(u: PGLfloat){.dynlib: dllname, importc: "glEvalCoord2fv".}
|
||||
proc glEvalMesh1*(mode: TGLenum, i1, i2: TGLint){.dynlib: dllname,
|
||||
proc glEvalMesh1*(mode: TGLenum, i1, i2: TGLint){.dynlib: dllname,
|
||||
importc: "glEvalMesh1".}
|
||||
proc glEvalMesh2*(mode: TGLenum, i1, i2, j1, j2: TGLint){.dynlib: dllname,
|
||||
proc glEvalMesh2*(mode: TGLenum, i1, i2, j1, j2: TGLint){.dynlib: dllname,
|
||||
importc: "glEvalMesh2".}
|
||||
proc glEvalPoint1*(i: TGLint){.dynlib: dllname, importc: "glEvalPoint1".}
|
||||
proc glEvalPoint2*(i, j: TGLint){.dynlib: dllname, importc: "glEvalPoint2".}
|
||||
|
|
@ -1126,75 +1126,75 @@ proc glFeedbackBuffer*(size: TGLsizei, atype: TGLenum, buffer: PGLfloat){.
|
|||
dynlib: dllname, importc: "glFeedbackBuffer".}
|
||||
proc glFinish*(){.dynlib: dllname, importc: "glFinish".}
|
||||
proc glFlush*(){.dynlib: dllname, importc: "glFlush".}
|
||||
proc glFogf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
proc glFogf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
importc: "glFogf".}
|
||||
proc glFogfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
proc glFogfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
importc: "glFogfv".}
|
||||
proc glFogi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glFogi".}
|
||||
proc glFogiv*(pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
proc glFogiv*(pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
importc: "glFogiv".}
|
||||
proc glFrontFace*(mode: TGLenum){.dynlib: dllname, importc: "glFrontFace".}
|
||||
proc glFrustum*(left, right, bottom, top, zNear, zFar: TGLdouble){.
|
||||
dynlib: dllname, importc: "glFrustum".}
|
||||
proc glGenLists*(range: TGLsizei): TGLuint{.dynlib: dllname,
|
||||
proc glGenLists*(range: TGLsizei): TGLuint{.dynlib: dllname,
|
||||
importc: "glGenLists".}
|
||||
proc glGenTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname,
|
||||
proc glGenTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname,
|
||||
importc: "glGenTextures".}
|
||||
proc glGetBooleanv*(pname: TGLenum, params: PGLboolean){.dynlib: dllname,
|
||||
proc glGetBooleanv*(pname: TGLenum, params: PGLboolean){.dynlib: dllname,
|
||||
importc: "glGetBooleanv".}
|
||||
proc glGetClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname,
|
||||
proc glGetClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname,
|
||||
importc: "glGetClipPlane".}
|
||||
proc glGetDoublev*(pname: TGLenum, params: PGLdouble){.dynlib: dllname,
|
||||
proc glGetDoublev*(pname: TGLenum, params: PGLdouble){.dynlib: dllname,
|
||||
importc: "glGetDoublev".}
|
||||
proc glGetError*(): TGLenum{.dynlib: dllname, importc: "glGetError".}
|
||||
proc glGetFloatv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
proc glGetFloatv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
importc: "glGetFloatv".}
|
||||
proc glGetIntegerv*(pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
proc glGetIntegerv*(pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
importc: "glGetIntegerv".}
|
||||
proc glGetLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
proc glGetLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
importc: "glGetLightfv".}
|
||||
proc glGetLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
proc glGetLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
importc: "glGetLightiv".}
|
||||
proc glGetMapdv*(target, query: TGLenum, v: PGLdouble){.dynlib: dllname,
|
||||
proc glGetMapdv*(target, query: TGLenum, v: PGLdouble){.dynlib: dllname,
|
||||
importc: "glGetMapdv".}
|
||||
proc glGetMapfv*(target, query: TGLenum, v: PGLfloat){.dynlib: dllname,
|
||||
proc glGetMapfv*(target, query: TGLenum, v: PGLfloat){.dynlib: dllname,
|
||||
importc: "glGetMapfv".}
|
||||
proc glGetMapiv*(target, query: TGLenum, v: PGLint){.dynlib: dllname,
|
||||
proc glGetMapiv*(target, query: TGLenum, v: PGLint){.dynlib: dllname,
|
||||
importc: "glGetMapiv".}
|
||||
proc glGetMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
proc glGetMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
importc: "glGetMaterialfv".}
|
||||
proc glGetMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
proc glGetMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
importc: "glGetMaterialiv".}
|
||||
proc glGetPixelMapfv*(map: TGLenum, values: PGLfloat){.dynlib: dllname,
|
||||
proc glGetPixelMapfv*(map: TGLenum, values: PGLfloat){.dynlib: dllname,
|
||||
importc: "glGetPixelMapfv".}
|
||||
proc glGetPixelMapuiv*(map: TGLenum, values: PGLuint){.dynlib: dllname,
|
||||
proc glGetPixelMapuiv*(map: TGLenum, values: PGLuint){.dynlib: dllname,
|
||||
importc: "glGetPixelMapuiv".}
|
||||
proc glGetPixelMapusv*(map: TGLenum, values: PGLushort){.dynlib: dllname,
|
||||
proc glGetPixelMapusv*(map: TGLenum, values: PGLushort){.dynlib: dllname,
|
||||
importc: "glGetPixelMapusv".}
|
||||
proc glGetPointerv*(pname: TGLenum, params: pointer){.dynlib: dllname,
|
||||
proc glGetPointerv*(pname: TGLenum, params: pointer){.dynlib: dllname,
|
||||
importc: "glGetPointerv".}
|
||||
proc glGetPolygonStipple*(mask: PGLubyte){.dynlib: dllname,
|
||||
proc glGetPolygonStipple*(mask: PGLubyte){.dynlib: dllname,
|
||||
importc: "glGetPolygonStipple".}
|
||||
proc glGetString*(name: TGLenum): cstring{.dynlib: dllname,
|
||||
proc glGetString*(name: TGLenum): cstring{.dynlib: dllname,
|
||||
importc: "glGetString".}
|
||||
proc glGetTexEnvfv*(target, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
proc glGetTexEnvfv*(target, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
importc: "glGetTexEnvfv".}
|
||||
proc glGetTexEnviv*(target, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
proc glGetTexEnviv*(target, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
importc: "glGetTexEnviv".}
|
||||
proc glGetTexGendv*(coord, pname: TGLenum, params: PGLdouble){.dynlib: dllname,
|
||||
proc glGetTexGendv*(coord, pname: TGLenum, params: PGLdouble){.dynlib: dllname,
|
||||
importc: "glGetTexGendv".}
|
||||
proc glGetTexGenfv*(coord, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
proc glGetTexGenfv*(coord, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
importc: "glGetTexGenfv".}
|
||||
proc glGetTexGeniv*(coord, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
proc glGetTexGeniv*(coord, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
importc: "glGetTexGeniv".}
|
||||
proc glGetTexImage*(target: TGLenum, level: TGLint, format: TGLenum,
|
||||
atype: TGLenum, pixels: pointer){.dynlib: dllname,
|
||||
proc glGetTexImage*(target: TGLenum, level: TGLint, format: TGLenum,
|
||||
atype: TGLenum, pixels: pointer){.dynlib: dllname,
|
||||
importc: "glGetTexImage".}
|
||||
proc glGetTexLevelParameterfv*(target: TGLenum, level: TGLint, pname: TGLenum,
|
||||
params: pointer){.dynlib: dllname,
|
||||
proc glGetTexLevelParameterfv*(target: TGLenum, level: TGLint, pname: TGLenum,
|
||||
params: pointer){.dynlib: dllname,
|
||||
importc: "glGetTexLevelParameterfv".}
|
||||
proc glGetTexLevelParameteriv*(target: TGLenum, level: TGLint, pname: TGLenum,
|
||||
params: PGLint){.dynlib: dllname,
|
||||
proc glGetTexLevelParameteriv*(target: TGLenum, level: TGLint, pname: TGLenum,
|
||||
params: PGLint){.dynlib: dllname,
|
||||
importc: "glGetTexLevelParameteriv".}
|
||||
proc glGetTexParameterfv*(target, pname: TGLenum, params: PGLfloat){.
|
||||
dynlib: dllname, importc: "glGetTexParameterfv".}
|
||||
|
|
@ -1217,28 +1217,28 @@ proc glIndexubv*(c: PGLubyte){.dynlib: dllname, importc: "glIndexubv".}
|
|||
proc glInitNames*(){.dynlib: dllname, importc: "glInitNames".}
|
||||
proc glInterleavedArrays*(format: TGLenum, stride: TGLsizei, p: pointer){.
|
||||
dynlib: dllname, importc: "glInterleavedArrays".}
|
||||
proc glIsEnabled*(cap: TGLenum): TGLboolean{.dynlib: dllname,
|
||||
proc glIsEnabled*(cap: TGLenum): TGLboolean{.dynlib: dllname,
|
||||
importc: "glIsEnabled".}
|
||||
proc glIsList*(list: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsList".}
|
||||
proc glIsTexture*(texture: TGLuint): TGLboolean{.dynlib: dllname,
|
||||
proc glIsTexture*(texture: TGLuint): TGLboolean{.dynlib: dllname,
|
||||
importc: "glIsTexture".}
|
||||
proc glLightModelf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
proc glLightModelf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
importc: "glLightModelf".}
|
||||
proc glLightModelfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
proc glLightModelfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
importc: "glLightModelfv".}
|
||||
proc glLightModeli*(pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
proc glLightModeli*(pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
importc: "glLightModeli".}
|
||||
proc glLightModeliv*(pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
proc glLightModeliv*(pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
importc: "glLightModeliv".}
|
||||
proc glLightf*(light, pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
proc glLightf*(light, pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
importc: "glLightf".}
|
||||
proc glLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
proc glLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
importc: "glLightfv".}
|
||||
proc glLighti*(light, pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
proc glLighti*(light, pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
importc: "glLighti".}
|
||||
proc glLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
proc glLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
importc: "glLightiv".}
|
||||
proc glLineStipple*(factor: TGLint, pattern: TGLushort){.dynlib: dllname,
|
||||
proc glLineStipple*(factor: TGLint, pattern: TGLushort){.dynlib: dllname,
|
||||
importc: "glLineStipple".}
|
||||
proc glLineWidth*(width: TGLfloat){.dynlib: dllname, importc: "glLineWidth".}
|
||||
proc glListBase*(base: TGLuint){.dynlib: dllname, importc: "glListBase".}
|
||||
|
|
@ -1247,36 +1247,36 @@ proc glLoadMatrixd*(m: PGLdouble){.dynlib: dllname, importc: "glLoadMatrixd".}
|
|||
proc glLoadMatrixf*(m: PGLfloat){.dynlib: dllname, importc: "glLoadMatrixf".}
|
||||
proc glLoadName*(name: TGLuint){.dynlib: dllname, importc: "glLoadName".}
|
||||
proc glLogicOp*(opcode: TGLenum){.dynlib: dllname, importc: "glLogicOp".}
|
||||
proc glMap1d*(target: TGLenum, u1, u2: TGLdouble, stride, order: TGLint,
|
||||
proc glMap1d*(target: TGLenum, u1, u2: TGLdouble, stride, order: TGLint,
|
||||
points: PGLdouble){.dynlib: dllname, importc: "glMap1d".}
|
||||
proc glMap1f*(target: TGLenum, u1, u2: TGLfloat, stride, order: TGLint,
|
||||
proc glMap1f*(target: TGLenum, u1, u2: TGLfloat, stride, order: TGLint,
|
||||
points: PGLfloat){.dynlib: dllname, importc: "glMap1f".}
|
||||
proc glMap2d*(target: TGLenum, u1, u2: TGLdouble, ustride, uorder: TGLint,
|
||||
proc glMap2d*(target: TGLenum, u1, u2: TGLdouble, ustride, uorder: TGLint,
|
||||
v1, v2: TGLdouble, vstride, vorder: TGLint, points: PGLdouble){.
|
||||
dynlib: dllname, importc: "glMap2d".}
|
||||
proc glMap2f*(target: TGLenum, u1, u2: TGLfloat, ustride, uorder: TGLint,
|
||||
proc glMap2f*(target: TGLenum, u1, u2: TGLfloat, ustride, uorder: TGLint,
|
||||
v1, v2: TGLfloat, vstride, vorder: TGLint, points: PGLfloat){.
|
||||
dynlib: dllname, importc: "glMap2f".}
|
||||
proc glMapGrid1d*(un: TGLint, u1, u2: TGLdouble){.dynlib: dllname,
|
||||
proc glMapGrid1d*(un: TGLint, u1, u2: TGLdouble){.dynlib: dllname,
|
||||
importc: "glMapGrid1d".}
|
||||
proc glMapGrid1f*(un: TGLint, u1, u2: TGLfloat){.dynlib: dllname,
|
||||
proc glMapGrid1f*(un: TGLint, u1, u2: TGLfloat){.dynlib: dllname,
|
||||
importc: "glMapGrid1f".}
|
||||
proc glMapGrid2d*(un: TGLint, u1, u2: TGLdouble, vn: TGLint, v1, v2: TGLdouble){.
|
||||
dynlib: dllname, importc: "glMapGrid2d".}
|
||||
proc glMapGrid2f*(un: TGLint, u1, u2: TGLfloat, vn: TGLint, v1, v2: TGLfloat){.
|
||||
dynlib: dllname, importc: "glMapGrid2f".}
|
||||
proc glMaterialf*(face, pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
proc glMaterialf*(face, pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
importc: "glMaterialf".}
|
||||
proc glMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
proc glMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
|
||||
importc: "glMaterialfv".}
|
||||
proc glMateriali*(face, pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
proc glMateriali*(face, pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
importc: "glMateriali".}
|
||||
proc glMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
proc glMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname,
|
||||
importc: "glMaterialiv".}
|
||||
proc glMatrixMode*(mode: TGLenum){.dynlib: dllname, importc: "glMatrixMode".}
|
||||
proc glMultMatrixd*(m: PGLdouble){.dynlib: dllname, importc: "glMultMatrixd".}
|
||||
proc glMultMatrixf*(m: PGLfloat){.dynlib: dllname, importc: "glMultMatrixf".}
|
||||
proc glNewList*(list: TGLuint, mode: TGLenum){.dynlib: dllname,
|
||||
proc glNewList*(list: TGLuint, mode: TGLenum){.dynlib: dllname,
|
||||
importc: "glNewList".}
|
||||
proc glNormal3b*(nx, ny, nz: TGlbyte){.dynlib: dllname, importc: "glNormal3b".}
|
||||
proc glNormal3bv*(v: PGLbyte){.dynlib: dllname, importc: "glNormal3bv".}
|
||||
|
|
@ -1299,22 +1299,22 @@ proc glPixelMapuiv*(map: TGLenum, mapsize: TGLsizei, values: PGLuint){.
|
|||
dynlib: dllname, importc: "glPixelMapuiv".}
|
||||
proc glPixelMapusv*(map: TGLenum, mapsize: TGLsizei, values: PGLushort){.
|
||||
dynlib: dllname, importc: "glPixelMapusv".}
|
||||
proc glPixelStoref*(pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
proc glPixelStoref*(pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
importc: "glPixelStoref".}
|
||||
proc glPixelStorei*(pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
proc glPixelStorei*(pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
importc: "glPixelStorei".}
|
||||
proc glPixelTransferf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
proc glPixelTransferf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname,
|
||||
importc: "glPixelTransferf".}
|
||||
proc glPixelTransferi*(pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
proc glPixelTransferi*(pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
importc: "glPixelTransferi".}
|
||||
proc glPixelZoom*(xfactor, yfactor: TGLfloat){.dynlib: dllname,
|
||||
proc glPixelZoom*(xfactor, yfactor: TGLfloat){.dynlib: dllname,
|
||||
importc: "glPixelZoom".}
|
||||
proc glPointSize*(size: TGLfloat){.dynlib: dllname, importc: "glPointSize".}
|
||||
proc glPolygonMode*(face, mode: TGLenum){.dynlib: dllname,
|
||||
proc glPolygonMode*(face, mode: TGLenum){.dynlib: dllname,
|
||||
importc: "glPolygonMode".}
|
||||
proc glPolygonOffset*(factor, units: TGLfloat){.dynlib: dllname,
|
||||
proc glPolygonOffset*(factor, units: TGLfloat){.dynlib: dllname,
|
||||
importc: "glPolygonOffset".}
|
||||
proc glPolygonStipple*(mask: PGLubyte){.dynlib: dllname,
|
||||
proc glPolygonStipple*(mask: PGLubyte){.dynlib: dllname,
|
||||
importc: "glPolygonStipple".}
|
||||
proc glPopAttrib*(){.dynlib: dllname, importc: "glPopAttrib".}
|
||||
proc glPopClientAttrib*(){.dynlib: dllname, importc: "glPopClientAttrib".}
|
||||
|
|
@ -1323,7 +1323,7 @@ proc glPopName*(){.dynlib: dllname, importc: "glPopName".}
|
|||
proc glPrioritizeTextures*(n: TGLsizei, textures: PGLuint, priorities: PGLclampf){.
|
||||
dynlib: dllname, importc: "glPrioritizeTextures".}
|
||||
proc glPushAttrib*(mask: TGLbitfield){.dynlib: dllname, importc: "glPushAttrib".}
|
||||
proc glPushClientAttrib*(mask: TGLbitfield){.dynlib: dllname,
|
||||
proc glPushClientAttrib*(mask: TGLbitfield){.dynlib: dllname,
|
||||
importc: "glPushClientAttrib".}
|
||||
proc glPushMatrix*(){.dynlib: dllname, importc: "glPushMatrix".}
|
||||
proc glPushName*(name: TGLuint){.dynlib: dllname, importc: "glPushName".}
|
||||
|
|
@ -1335,35 +1335,35 @@ proc glRasterPos2i*(x, y: TGLint){.dynlib: dllname, importc: "glRasterPos2i".}
|
|||
proc glRasterPos2iv*(v: PGLint){.dynlib: dllname, importc: "glRasterPos2iv".}
|
||||
proc glRasterPos2s*(x, y: TGLshort){.dynlib: dllname, importc: "glRasterPos2s".}
|
||||
proc glRasterPos2sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos2sv".}
|
||||
proc glRasterPos3d*(x, y, z: TGLdouble){.dynlib: dllname,
|
||||
proc glRasterPos3d*(x, y, z: TGLdouble){.dynlib: dllname,
|
||||
importc: "glRasterPos3d".}
|
||||
proc glRasterPos3dv*(v: PGLdouble){.dynlib: dllname, importc: "glRasterPos3dv".}
|
||||
proc glRasterPos3f*(x, y, z: TGLfloat){.dynlib: dllname,
|
||||
proc glRasterPos3f*(x, y, z: TGLfloat){.dynlib: dllname,
|
||||
importc: "glRasterPos3f".}
|
||||
proc glRasterPos3fv*(v: PGLfloat){.dynlib: dllname, importc: "glRasterPos3fv".}
|
||||
proc glRasterPos3i*(x, y, z: TGLint){.dynlib: dllname, importc: "glRasterPos3i".}
|
||||
proc glRasterPos3iv*(v: PGLint){.dynlib: dllname, importc: "glRasterPos3iv".}
|
||||
proc glRasterPos3s*(x, y, z: TGLshort){.dynlib: dllname,
|
||||
proc glRasterPos3s*(x, y, z: TGLshort){.dynlib: dllname,
|
||||
importc: "glRasterPos3s".}
|
||||
proc glRasterPos3sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos3sv".}
|
||||
proc glRasterPos4d*(x, y, z, w: TGLdouble){.dynlib: dllname,
|
||||
proc glRasterPos4d*(x, y, z, w: TGLdouble){.dynlib: dllname,
|
||||
importc: "glRasterPos4d".}
|
||||
proc glRasterPos4dv*(v: PGLdouble){.dynlib: dllname, importc: "glRasterPos4dv".}
|
||||
proc glRasterPos4f*(x, y, z, w: TGLfloat){.dynlib: dllname,
|
||||
proc glRasterPos4f*(x, y, z, w: TGLfloat){.dynlib: dllname,
|
||||
importc: "glRasterPos4f".}
|
||||
proc glRasterPos4fv*(v: PGLfloat){.dynlib: dllname, importc: "glRasterPos4fv".}
|
||||
proc glRasterPos4i*(x, y, z, w: TGLint){.dynlib: dllname,
|
||||
proc glRasterPos4i*(x, y, z, w: TGLint){.dynlib: dllname,
|
||||
importc: "glRasterPos4i".}
|
||||
proc glRasterPos4iv*(v: PGLint){.dynlib: dllname, importc: "glRasterPos4iv".}
|
||||
proc glRasterPos4s*(x, y, z, w: TGLshort){.dynlib: dllname,
|
||||
proc glRasterPos4s*(x, y, z, w: TGLshort){.dynlib: dllname,
|
||||
importc: "glRasterPos4s".}
|
||||
proc glRasterPos4sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos4sv".}
|
||||
proc glReadBuffer*(mode: TGLenum){.dynlib: dllname, importc: "glReadBuffer".}
|
||||
proc glReadPixels*(x, y: TGLint, width, height: TGLsizei,
|
||||
format, atype: TGLenum, pixels: pointer){.dynlib: dllname,
|
||||
proc glReadPixels*(x, y: TGLint, width, height: TGLsizei,
|
||||
format, atype: TGLenum, pixels: pointer){.dynlib: dllname,
|
||||
importc: "glReadPixels".}
|
||||
proc glRectd*(x1, y1, x2, y2: TGLdouble){.dynlib: dllname, importc: "glRectd".}
|
||||
proc glRectdv*(v1: PGLdouble, v2: PGLdouble){.dynlib: dllname,
|
||||
proc glRectdv*(v1: PGLdouble, v2: PGLdouble){.dynlib: dllname,
|
||||
importc: "glRectdv".}
|
||||
proc glRectf*(x1, y1, x2, y2: TGLfloat){.dynlib: dllname, importc: "glRectf".}
|
||||
proc glRectfv*(v1: PGLfloat, v2: PGLfloat){.dynlib: dllname, importc: "glRectfv".}
|
||||
|
|
@ -1371,22 +1371,22 @@ proc glRecti*(x1, y1, x2, y2: TGLint){.dynlib: dllname, importc: "glRecti".}
|
|||
proc glRectiv*(v1: PGLint, v2: PGLint){.dynlib: dllname, importc: "glRectiv".}
|
||||
proc glRects*(x1, y1, x2, y2: TGLshort){.dynlib: dllname, importc: "glRects".}
|
||||
proc glRectsv*(v1: PGLshort, v2: PGLshort){.dynlib: dllname, importc: "glRectsv".}
|
||||
proc glRenderMode*(mode: TGLint): TGLint{.dynlib: dllname,
|
||||
proc glRenderMode*(mode: TGLint): TGLint{.dynlib: dllname,
|
||||
importc: "glRenderMode".}
|
||||
proc glRotated*(angle, x, y, z: TGLdouble){.dynlib: dllname,
|
||||
proc glRotated*(angle, x, y, z: TGLdouble){.dynlib: dllname,
|
||||
importc: "glRotated".}
|
||||
proc glRotatef*(angle, x, y, z: TGLfloat){.dynlib: dllname, importc: "glRotatef".}
|
||||
proc glScaled*(x, y, z: TGLdouble){.dynlib: dllname, importc: "glScaled".}
|
||||
proc glScalef*(x, y, z: TGLfloat){.dynlib: dllname, importc: "glScalef".}
|
||||
proc glScissor*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname,
|
||||
proc glScissor*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname,
|
||||
importc: "glScissor".}
|
||||
proc glSelectBuffer*(size: TGLsizei, buffer: PGLuint){.dynlib: dllname,
|
||||
proc glSelectBuffer*(size: TGLsizei, buffer: PGLuint){.dynlib: dllname,
|
||||
importc: "glSelectBuffer".}
|
||||
proc glShadeModel*(mode: TGLenum){.dynlib: dllname, importc: "glShadeModel".}
|
||||
proc glStencilFunc*(fun: TGLenum, theref: TGLint, mask: TGLuint){.
|
||||
dynlib: dllname, importc: "glStencilFunc".}
|
||||
proc glStencilMask*(mask: TGLuint){.dynlib: dllname, importc: "glStencilMask".}
|
||||
proc glStencilOp*(fail, zfail, zpass: TGLenum){.dynlib: dllname,
|
||||
proc glStencilOp*(fail, zfail, zpass: TGLenum){.dynlib: dllname,
|
||||
importc: "glStencilOp".}
|
||||
proc glTexCoord1d*(s: TGLdouble){.dynlib: dllname, importc: "glTexCoord1d".}
|
||||
proc glTexCoord1dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord1dv".}
|
||||
|
|
@ -1412,19 +1412,19 @@ proc glTexCoord3i*(s, t, r: TGLint){.dynlib: dllname, importc: "glTexCoord3i".}
|
|||
proc glTexCoord3iv*(v: PGLint){.dynlib: dllname, importc: "glTexCoord3iv".}
|
||||
proc glTexCoord3s*(s, t, r: TGLshort){.dynlib: dllname, importc: "glTexCoord3s".}
|
||||
proc glTexCoord3sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord3sv".}
|
||||
proc glTexCoord4d*(s, t, r, q: TGLdouble){.dynlib: dllname,
|
||||
proc glTexCoord4d*(s, t, r, q: TGLdouble){.dynlib: dllname,
|
||||
importc: "glTexCoord4d".}
|
||||
proc glTexCoord4dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord4dv".}
|
||||
proc glTexCoord4f*(s, t, r, q: TGLfloat){.dynlib: dllname,
|
||||
proc glTexCoord4f*(s, t, r, q: TGLfloat){.dynlib: dllname,
|
||||
importc: "glTexCoord4f".}
|
||||
proc glTexCoord4fv*(v: PGLfloat){.dynlib: dllname, importc: "glTexCoord4fv".}
|
||||
proc glTexCoord4i*(s, t, r, q: TGLint){.dynlib: dllname, importc: "glTexCoord4i".}
|
||||
proc glTexCoord4iv*(v: PGLint){.dynlib: dllname, importc: "glTexCoord4iv".}
|
||||
proc glTexCoord4s*(s, t, r, q: TGLshort){.dynlib: dllname,
|
||||
proc glTexCoord4s*(s, t, r, q: TGLshort){.dynlib: dllname,
|
||||
importc: "glTexCoord4s".}
|
||||
proc glTexCoord4sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord4sv".}
|
||||
proc glTexCoordPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei,
|
||||
p: pointer){.dynlib: dllname,
|
||||
proc glTexCoordPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei,
|
||||
p: pointer){.dynlib: dllname,
|
||||
importc: "glTexCoordPointer".}
|
||||
proc glTexEnvf*(target: TGLenum, pname: TGLenum, param: TGLfloat){.
|
||||
dynlib: dllname, importc: "glTexEnvf".}
|
||||
|
|
@ -1442,16 +1442,16 @@ proc glTexGenf*(coord: TGLenum, pname: TGLenum, param: TGLfloat){.
|
|||
dynlib: dllname, importc: "glTexGenf".}
|
||||
proc glTexGenfv*(coord: TGLenum, pname: TGLenum, params: PGLfloat){.
|
||||
dynlib: dllname, importc: "glTexGenfv".}
|
||||
proc glTexGeni*(coord: TGLenum, pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
proc glTexGeni*(coord: TGLenum, pname: TGLenum, param: TGLint){.dynlib: dllname,
|
||||
importc: "glTexGeni".}
|
||||
proc glTexGeniv*(coord: TGLenum, pname: TGLenum, params: PGLint){.
|
||||
dynlib: dllname, importc: "glTexGeniv".}
|
||||
proc glTexImage1D*(target: TGLenum, level, internalformat: TGLint,
|
||||
width: TGLsizei, border: TGLint, format, atype: TGLenum,
|
||||
proc glTexImage1D*(target: TGLenum, level, internalformat: TGLint,
|
||||
width: TGLsizei, border: TGLint, format, atype: TGLenum,
|
||||
pixels: pointer){.dynlib: dllname, importc: "glTexImage1D".}
|
||||
proc glTexImage2D*(target: TGLenum, level, internalformat: TGLint,
|
||||
width, height: TGLsizei, border: TGLint,
|
||||
format, atype: TGLenum, pixels: pointer){.dynlib: dllname,
|
||||
proc glTexImage2D*(target: TGLenum, level, internalformat: TGLint,
|
||||
width, height: TGLsizei, border: TGLint,
|
||||
format, atype: TGLenum, pixels: pointer){.dynlib: dllname,
|
||||
importc: "glTexImage2D".}
|
||||
proc glTexParameterf*(target: TGLenum, pname: TGLenum, param: TGLfloat){.
|
||||
dynlib: dllname, importc: "glTexParameterf".}
|
||||
|
|
@ -1461,12 +1461,12 @@ proc glTexParameteri*(target: TGLenum, pname: TGLenum, param: TGLint){.
|
|||
dynlib: dllname, importc: "glTexParameteri".}
|
||||
proc glTexParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){.
|
||||
dynlib: dllname, importc: "glTexParameteriv".}
|
||||
proc glTexSubImage1D*(target: TGLenum, level, xoffset: TGLint, width: TGLsizei,
|
||||
format, atype: TGLenum, pixels: pointer){.dynlib: dllname,
|
||||
proc glTexSubImage1D*(target: TGLenum, level, xoffset: TGLint, width: TGLsizei,
|
||||
format, atype: TGLenum, pixels: pointer){.dynlib: dllname,
|
||||
importc: "glTexSubImage1D".}
|
||||
proc glTexSubImage2D*(target: TGLenum, level, xoffset, yoffset: TGLint,
|
||||
width, height: TGLsizei, format, atype: TGLenum,
|
||||
pixels: pointer){.dynlib: dllname,
|
||||
proc glTexSubImage2D*(target: TGLenum, level, xoffset, yoffset: TGLint,
|
||||
width, height: TGLsizei, format, atype: TGLenum,
|
||||
pixels: pointer){.dynlib: dllname,
|
||||
importc: "glTexSubImage2D".}
|
||||
proc glTranslated*(x, y, z: TGLdouble){.dynlib: dllname, importc: "glTranslated".}
|
||||
proc glTranslatef*(x, y, z: TGLfloat){.dynlib: dllname, importc: "glTranslatef".}
|
||||
|
|
@ -1494,42 +1494,42 @@ proc glVertex4i*(x, y, z, w: TGLint){.dynlib: dllname, importc: "glVertex4i".}
|
|||
proc glVertex4iv*(v: PGLint){.dynlib: dllname, importc: "glVertex4iv".}
|
||||
proc glVertex4s*(x, y, z, w: TGLshort){.dynlib: dllname, importc: "glVertex4s".}
|
||||
proc glVertex4sv*(v: PGLshort){.dynlib: dllname, importc: "glVertex4sv".}
|
||||
proc glVertexPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei,
|
||||
p: pointer){.dynlib: dllname,
|
||||
proc glVertexPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei,
|
||||
p: pointer){.dynlib: dllname,
|
||||
importc: "glVertexPointer".}
|
||||
proc glViewport*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname,
|
||||
proc glViewport*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname,
|
||||
importc: "glViewport".}
|
||||
type
|
||||
type
|
||||
PFN_GLARRAY_ELEMENT_EXTPROC* = proc (i: TGLint)
|
||||
PFN_GLDRAW_ARRAYS_EXTPROC* = proc (mode: TGLenum, first: TGLint,
|
||||
PFN_GLDRAW_ARRAYS_EXTPROC* = proc (mode: TGLenum, first: TGLint,
|
||||
count: TGLsizei)
|
||||
PFN_GLVERTEX_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum,
|
||||
stride, count: TGLsizei,
|
||||
PFN_GLVERTEX_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum,
|
||||
stride, count: TGLsizei,
|
||||
p: pointer)
|
||||
PFN_GLNORMAL_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei,
|
||||
PFN_GLNORMAL_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei,
|
||||
p: pointer)
|
||||
PFN_GLCOLOR_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum,
|
||||
PFN_GLCOLOR_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum,
|
||||
stride, count: TGLsizei, p: pointer)
|
||||
PFN_GLINDEX_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei,
|
||||
PFN_GLINDEX_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei,
|
||||
p: pointer)
|
||||
PFN_GLTEXCOORD_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum,
|
||||
PFN_GLTEXCOORD_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum,
|
||||
stride, count: TGLsizei, p: pointer)
|
||||
PFN_GLEDGEFLAG_POINTER_EXTPROC* = proc (stride, count: TGLsizei,
|
||||
PFN_GLEDGEFLAG_POINTER_EXTPROC* = proc (stride, count: TGLsizei,
|
||||
pointer: PGLboolean)
|
||||
PFN_GLGET_POINTER_VEXT_PROC* = proc (pname: TGLenum, params: pointer)
|
||||
PFN_GLARRAY_ELEMENT_ARRAY_EXTPROC* = proc (mode: TGLenum, count: TGLsizei,
|
||||
PFN_GLARRAY_ELEMENT_ARRAY_EXTPROC* = proc (mode: TGLenum, count: TGLsizei,
|
||||
pi: pointer) # WIN_swap_hint
|
||||
PFN_GLADDSWAPHINT_RECT_WINPROC* = proc (x, y: TGLint, width, height: TGLsizei)
|
||||
PFN_GLCOLOR_TABLE_EXTPROC* = proc (target, internalFormat: TGLenum,
|
||||
width: TGLsizei, format, atype: TGLenum,
|
||||
PFN_GLCOLOR_TABLE_EXTPROC* = proc (target, internalFormat: TGLenum,
|
||||
width: TGLsizei, format, atype: TGLenum,
|
||||
data: pointer)
|
||||
PFN_GLCOLOR_SUBTABLE_EXTPROC* = proc (target: TGLenum, start, count: TGLsizei,
|
||||
PFN_GLCOLOR_SUBTABLE_EXTPROC* = proc (target: TGLenum, start, count: TGLsizei,
|
||||
format, atype: TGLenum, data: pointer)
|
||||
PFN_GLGETCOLOR_TABLE_EXTPROC* = proc (target, format, atype: TGLenum,
|
||||
PFN_GLGETCOLOR_TABLE_EXTPROC* = proc (target, format, atype: TGLenum,
|
||||
data: pointer)
|
||||
PFN_GLGETCOLOR_TABLE_PARAMETER_IVEXTPROC* = proc (target, pname: TGLenum,
|
||||
PFN_GLGETCOLOR_TABLE_PARAMETER_IVEXTPROC* = proc (target, pname: TGLenum,
|
||||
params: PGLint)
|
||||
PFN_GLGETCOLOR_TABLE_PARAMETER_FVEXTPROC* = proc (target, pname: TGLenum,
|
||||
PFN_GLGETCOLOR_TABLE_PARAMETER_FVEXTPROC* = proc (target, pname: TGLenum,
|
||||
params: PGLfloat)
|
||||
|
||||
{.pop.}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -4,28 +4,28 @@
|
|||
# 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
|
||||
# Converted to Delphi by Tom Nuydens (tom@delphi3d.net)
|
||||
# For the latest updates, visit Delphi3D: http://www.delphi3d.net
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
import
|
||||
GL
|
||||
|
||||
when defined(windows):
|
||||
when defined(windows):
|
||||
{.push, callconv: stdcall.}
|
||||
else:
|
||||
else:
|
||||
{.push, callconv: cdecl.}
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
when defined(windows):
|
||||
const
|
||||
dllname = "glu32.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
elif defined(macosx):
|
||||
const
|
||||
dllname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib"
|
||||
else:
|
||||
const
|
||||
else:
|
||||
const
|
||||
dllname = "libGLU.so.1"
|
||||
type
|
||||
type
|
||||
TViewPortArray* = array[0..3, TGLint]
|
||||
T16dArray* = array[0..15, TGLdouble]
|
||||
TCallBack* = proc ()
|
||||
|
|
@ -34,12 +34,12 @@ type
|
|||
T4fArray* = array[0..3, TGLfloat]
|
||||
PPointer* = ptr Pointer
|
||||
|
||||
type
|
||||
GLUnurbs*{.final.} = object
|
||||
type
|
||||
GLUnurbs*{.final.} = object
|
||||
PGLUnurbs* = ptr GLUnurbs
|
||||
GLUquadric*{.final.} = object
|
||||
GLUquadric*{.final.} = object
|
||||
PGLUquadric* = ptr GLUquadric
|
||||
GLUtesselator*{.final.} = object
|
||||
GLUtesselator*{.final.} = object
|
||||
PGLUtesselator* = ptr GLUtesselator # backwards compatibility:
|
||||
GLUnurbsObj* = GLUnurbs
|
||||
PGLUnurbsObj* = PGLUnurbs
|
||||
|
|
@ -57,40 +57,40 @@ type
|
|||
TGLUtesselatorObj* = GLUtesselatorObj
|
||||
TGLUtriangulatorObj* = GLUtriangulatorObj
|
||||
|
||||
proc gluErrorString*(errCode: TGLenum): cstring{.dynlib: dllname,
|
||||
proc gluErrorString*(errCode: TGLenum): cstring{.dynlib: dllname,
|
||||
importc: "gluErrorString".}
|
||||
proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname,
|
||||
proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname,
|
||||
importc: "gluErrorUnicodeStringEXT".}
|
||||
proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname,
|
||||
proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname,
|
||||
importc: "gluGetString".}
|
||||
proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname,
|
||||
proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname,
|
||||
importc: "gluOrtho2D".}
|
||||
proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname,
|
||||
proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname,
|
||||
importc: "gluPerspective".}
|
||||
proc gluPickMatrix*(x, y, width, height: TGLdouble, viewport: var TViewPortArray){.
|
||||
dynlib: dllname, importc: "gluPickMatrix".}
|
||||
proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: TGLdouble){.
|
||||
dynlib: dllname, importc: "gluLookAt".}
|
||||
proc gluProject*(objx, objy, objz: TGLdouble,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
proc gluProject*(objx, objy, objz: TGLdouble,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
viewport: var TViewPortArray, winx, winy, winz: PGLdouble): int{.
|
||||
dynlib: dllname, importc: "gluProject".}
|
||||
proc gluUnProject*(winx, winy, winz: TGLdouble,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
proc gluUnProject*(winx, winy, winz: TGLdouble,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
viewport: var TViewPortArray, objx, objy, objz: PGLdouble): int{.
|
||||
dynlib: dllname, importc: "gluUnProject".}
|
||||
proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum,
|
||||
datain: Pointer, widthout, heightout: TGLint,
|
||||
typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname,
|
||||
proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum,
|
||||
datain: Pointer, widthout, heightout: TGLint,
|
||||
typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname,
|
||||
importc: "gluScaleImage".}
|
||||
proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint,
|
||||
proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint,
|
||||
format, atype: TGLenum, data: Pointer): int{.
|
||||
dynlib: dllname, importc: "gluBuild1DMipmaps".}
|
||||
proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint,
|
||||
proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint,
|
||||
format, atype: TGLenum, data: Pointer): int{.
|
||||
dynlib: dllname, importc: "gluBuild2DMipmaps".}
|
||||
proc gluNewQuadric*(): PGLUquadric{.dynlib: dllname, importc: "gluNewQuadric".}
|
||||
proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname,
|
||||
proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname,
|
||||
importc: "gluDeleteQuadric".}
|
||||
proc gluQuadricNormals*(quadObject: PGLUquadric, normals: TGLenum){.
|
||||
dynlib: dllname, importc: "gluQuadricNormals".}
|
||||
|
|
@ -100,12 +100,12 @@ proc gluQuadricOrientation*(quadObject: PGLUquadric, orientation: TGLenum){.
|
|||
dynlib: dllname, importc: "gluQuadricOrientation".}
|
||||
proc gluQuadricDrawStyle*(quadObject: PGLUquadric, drawStyle: TGLenum){.
|
||||
dynlib: dllname, importc: "gluQuadricDrawStyle".}
|
||||
proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble,
|
||||
slices, stacks: TGLint){.dynlib: dllname,
|
||||
proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble,
|
||||
slices, stacks: TGLint){.dynlib: dllname,
|
||||
importc: "gluCylinder".}
|
||||
proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
|
||||
proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
|
||||
slices, loops: TGLint){.dynlib: dllname, importc: "gluDisk".}
|
||||
proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
|
||||
proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
|
||||
slices, loops: TGLint, startAngle, sweepAngle: TGLdouble){.
|
||||
dynlib: dllname, importc: "gluPartialDisk".}
|
||||
proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){.
|
||||
|
|
@ -113,51 +113,51 @@ proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){.
|
|||
proc gluQuadricCallback*(qobj: PGLUquadric, which: TGLenum, fn: TCallBack){.
|
||||
dynlib: dllname, importc: "gluQuadricCallback".}
|
||||
proc gluNewTess*(): PGLUtesselator{.dynlib: dllname, importc: "gluNewTess".}
|
||||
proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluDeleteTess".}
|
||||
proc gluTessBeginPolygon*(tess: PGLUtesselator, polygon_data: Pointer){.
|
||||
dynlib: dllname, importc: "gluTessBeginPolygon".}
|
||||
proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluTessBeginContour".}
|
||||
proc gluTessVertex*(tess: PGLUtesselator, coords: var T3dArray, data: Pointer){.
|
||||
dynlib: dllname, importc: "gluTessVertex".}
|
||||
proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluTessEndContour".}
|
||||
proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluTessEndPolygon".}
|
||||
proc gluTessProperty*(tess: PGLUtesselator, which: TGLenum, value: TGLdouble){.
|
||||
dynlib: dllname, importc: "gluTessProperty".}
|
||||
proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname,
|
||||
proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname,
|
||||
importc: "gluTessNormal".}
|
||||
proc gluTessCallback*(tess: PGLUtesselator, which: TGLenum, fn: TCallBack){.
|
||||
dynlib: dllname, importc: "gluTessCallback".}
|
||||
proc gluGetTessProperty*(tess: PGLUtesselator, which: TGLenum, value: PGLdouble){.
|
||||
dynlib: dllname, importc: "gluGetTessProperty".}
|
||||
proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname,
|
||||
proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname,
|
||||
importc: "gluNewNurbsRenderer".}
|
||||
proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname,
|
||||
proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname,
|
||||
importc: "gluDeleteNurbsRenderer".}
|
||||
proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname,
|
||||
proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname,
|
||||
importc: "gluBeginSurface".}
|
||||
proc gluBeginCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginCurve".}
|
||||
proc gluEndCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndCurve".}
|
||||
proc gluEndSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndSurface".}
|
||||
proc gluBeginTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginTrim".}
|
||||
proc gluEndTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndTrim".}
|
||||
proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat,
|
||||
stride: TGLint, atype: TGLenum){.dynlib: dllname,
|
||||
proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat,
|
||||
stride: TGLint, atype: TGLenum){.dynlib: dllname,
|
||||
importc: "gluPwlCurve".}
|
||||
proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat,
|
||||
stride: TGLint, ctlarray: PGLfloat, order: TGLint,
|
||||
proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat,
|
||||
stride: TGLint, ctlarray: PGLfloat, order: TGLint,
|
||||
atype: TGLenum){.dynlib: dllname, importc: "gluNurbsCurve".}
|
||||
proc gluNurbsSurface*(nobj: PGLUnurbs, sknot_count: TGLint, sknot: PGLfloat,
|
||||
tknot_count: TGLint, tknot: PGLfloat,
|
||||
s_stride, t_stride: TGLint, ctlarray: PGLfloat,
|
||||
sorder, torder: TGLint, atype: TGLenum){.dynlib: dllname,
|
||||
proc gluNurbsSurface*(nobj: PGLUnurbs, sknot_count: TGLint, sknot: PGLfloat,
|
||||
tknot_count: TGLint, tknot: PGLfloat,
|
||||
s_stride, t_stride: TGLint, ctlarray: PGLfloat,
|
||||
sorder, torder: TGLint, atype: TGLenum){.dynlib: dllname,
|
||||
importc: "gluNurbsSurface".}
|
||||
proc gluLoadSamplingMatrices*(nobj: PGLUnurbs,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
viewport: var TViewPortArray){.dynlib: dllname,
|
||||
proc gluLoadSamplingMatrices*(nobj: PGLUnurbs,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
viewport: var TViewPortArray){.dynlib: dllname,
|
||||
importc: "gluLoadSamplingMatrices".}
|
||||
proc gluNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: TGLfloat){.
|
||||
dynlib: dllname, importc: "gluNurbsProperty".}
|
||||
|
|
@ -173,16 +173,16 @@ type # gluQuadricCallback
|
|||
GLUtessVertexProc* = proc (p: Pointer)
|
||||
GLUtessEndProc* = proc ()
|
||||
GLUtessErrorProc* = proc (p: TGLenum)
|
||||
GLUtessCombineProc* = proc (p1: var T3dArray, p2: T4pArray, p3: T4fArray,
|
||||
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) #
|
||||
#
|
||||
GLUtessCombineDataProc* = proc (p1: var T3dArray, p2: var T4pArray,
|
||||
p3: var T4fArray, p4: PPointer, p5: Pointer) #
|
||||
#
|
||||
# gluNurbsCallback
|
||||
GLUnurbsErrorProc* = proc (p: TGLenum) #*** Generic constants ****/
|
||||
|
||||
|
|
@ -226,21 +226,21 @@ const # Version
|
|||
GLU_TESS_COMBINE* = 100105 # void (CALLBACK*)(TGLdouble coords[3],
|
||||
# void *data[4],
|
||||
# TGLfloat weight[4],
|
||||
# void **dataOut)
|
||||
# void **dataOut)
|
||||
GLU_TESS_BEGIN_DATA* = 100106 # void (CALLBACK*)(TGLenum type,
|
||||
# void *polygon_data)
|
||||
# void *polygon_data)
|
||||
GLU_TESS_VERTEX_DATA* = 100107 # void (CALLBACK*)(void *data,
|
||||
# void *polygon_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)
|
||||
# void *polygon_data)
|
||||
GLU_TESS_EDGE_FLAG_DATA* = 100110 # void (CALLBACK*)(TGLboolean boundaryEdge,
|
||||
# void *polygon_data)
|
||||
# void *polygon_data)
|
||||
GLU_TESS_COMBINE_DATA* = 100111 # void (CALLBACK*)(TGLdouble coords[3],
|
||||
# void *data[4],
|
||||
# TGLfloat weight[4],
|
||||
# void **dataOut,
|
||||
# void *polygon_data)
|
||||
# void *polygon_data)
|
||||
# TessError
|
||||
GLU_TESS_ERROR1* = 100151
|
||||
GLU_TESS_ERROR2* = 100152
|
||||
|
|
@ -313,11 +313,11 @@ const # Version
|
|||
GLU_NURBS_ERROR36* = 100286
|
||||
GLU_NURBS_ERROR37* = 100287 #*** Backwards compatibility for old tesselator ****/
|
||||
|
||||
proc gluBeginPolygon*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
proc gluBeginPolygon*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluBeginPolygon".}
|
||||
proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname,
|
||||
proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname,
|
||||
importc: "gluNextContour".}
|
||||
proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluEndPolygon".}
|
||||
const # Contours types -- obsolete!
|
||||
GLU_CW* = 100120
|
||||
|
|
|
|||
|
|
@ -15,17 +15,17 @@
|
|||
# For the latest updates, visit Delphi3D: http://www.delphi3d.net
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
import
|
||||
GL
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
when defined(windows):
|
||||
const
|
||||
dllname = "glut32.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
elif defined(macosx):
|
||||
const
|
||||
dllname = "/System/Library/Frameworks/GLUT.framework/GLUT"
|
||||
else:
|
||||
const
|
||||
else:
|
||||
const
|
||||
dllname = "libglut.so.3"
|
||||
type
|
||||
TGlutVoidCallback* = proc (){.cdecl.}
|
||||
|
|
@ -36,7 +36,7 @@ type
|
|||
TGlut1Char2IntCallback* = proc (c: int8, v1, v2: cint){.cdecl.}
|
||||
TGlut1UInt3IntCallback* = proc (u, v1, v2, v3: cint){.cdecl.}
|
||||
|
||||
const
|
||||
const
|
||||
GLUT_API_VERSION* = 3
|
||||
GLUT_XLIB_IMPLEMENTATION* = 12 # Display mode bit masks.
|
||||
GLUT_RGB* = 0
|
||||
|
|
@ -93,7 +93,7 @@ const
|
|||
GLUT_NORMAL* = 0
|
||||
GLUT_OVERLAY* = 1
|
||||
|
||||
when defined(Windows):
|
||||
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).
|
||||
|
|
@ -104,7 +104,7 @@ when defined(Windows):
|
|||
GLUT_BITMAP_HELVETICA_10* = cast[Pointer](6)
|
||||
GLUT_BITMAP_HELVETICA_12* = cast[Pointer](7)
|
||||
GLUT_BITMAP_HELVETICA_18* = cast[Pointer](8)
|
||||
else:
|
||||
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).
|
||||
|
|
@ -229,7 +229,7 @@ const # glutGet parameters.
|
|||
GLUT_GAME_MODE_REFRESH_RATE* = 5
|
||||
GLUT_GAME_MODE_DISPLAY_CHANGED* = 6 # GLUT initialization sub-API.
|
||||
|
||||
proc glutInit*(argcp: ptr cint, argv: pointer){.dynlib: dllname,
|
||||
proc glutInit*(argcp: ptr cint, argv: pointer){.dynlib: dllname,
|
||||
importc: "glutInit".}
|
||||
|
||||
proc glutInit*() =
|
||||
|
|
@ -239,34 +239,34 @@ proc glutInit*() =
|
|||
cmdCount {.importc: "cmdCount".}: cint
|
||||
glutInit(addr(cmdCount), addr(cmdLine))
|
||||
|
||||
proc glutInitDisplayMode*(mode: int16){.dynlib: dllname,
|
||||
proc glutInitDisplayMode*(mode: int16){.dynlib: dllname,
|
||||
importc: "glutInitDisplayMode".}
|
||||
proc glutInitDisplayString*(str: cstring){.dynlib: dllname,
|
||||
proc glutInitDisplayString*(str: cstring){.dynlib: dllname,
|
||||
importc: "glutInitDisplayString".}
|
||||
proc glutInitWindowPosition*(x, y: int){.dynlib: dllname,
|
||||
proc glutInitWindowPosition*(x, y: int){.dynlib: dllname,
|
||||
importc: "glutInitWindowPosition".}
|
||||
proc glutInitWindowSize*(width, height: int){.dynlib: dllname,
|
||||
proc glutInitWindowSize*(width, height: int){.dynlib: dllname,
|
||||
importc: "glutInitWindowSize".}
|
||||
proc glutMainLoop*(){.dynlib: dllname, importc: "glutMainLoop".}
|
||||
# GLUT window sub-API.
|
||||
proc glutCreateWindow*(title: cstring): int{.dynlib: dllname,
|
||||
proc glutCreateWindow*(title: cstring): int{.dynlib: dllname,
|
||||
importc: "glutCreateWindow".}
|
||||
proc glutCreateSubWindow*(win, x, y, width, height: int): int{.dynlib: dllname,
|
||||
proc glutCreateSubWindow*(win, x, y, width, height: int): int{.dynlib: dllname,
|
||||
importc: "glutCreateSubWindow".}
|
||||
proc glutDestroyWindow*(win: int){.dynlib: dllname, importc: "glutDestroyWindow".}
|
||||
proc glutPostRedisplay*(){.dynlib: dllname, importc: "glutPostRedisplay".}
|
||||
proc glutPostWindowRedisplay*(win: int){.dynlib: dllname,
|
||||
proc glutPostWindowRedisplay*(win: int){.dynlib: dllname,
|
||||
importc: "glutPostWindowRedisplay".}
|
||||
proc glutSwapBuffers*(){.dynlib: dllname, importc: "glutSwapBuffers".}
|
||||
proc glutGetWindow*(): int{.dynlib: dllname, importc: "glutGetWindow".}
|
||||
proc glutSetWindow*(win: int){.dynlib: dllname, importc: "glutSetWindow".}
|
||||
proc glutSetWindowTitle*(title: cstring){.dynlib: dllname,
|
||||
proc glutSetWindowTitle*(title: cstring){.dynlib: dllname,
|
||||
importc: "glutSetWindowTitle".}
|
||||
proc glutSetIconTitle*(title: cstring){.dynlib: dllname,
|
||||
proc glutSetIconTitle*(title: cstring){.dynlib: dllname,
|
||||
importc: "glutSetIconTitle".}
|
||||
proc glutPositionWindow*(x, y: int){.dynlib: dllname,
|
||||
proc glutPositionWindow*(x, y: int){.dynlib: dllname,
|
||||
importc: "glutPositionWindow".}
|
||||
proc glutReshapeWindow*(width, height: int){.dynlib: dllname,
|
||||
proc glutReshapeWindow*(width, height: int){.dynlib: dllname,
|
||||
importc: "glutReshapeWindow".}
|
||||
proc glutPopWindow*(){.dynlib: dllname, importc: "glutPopWindow".}
|
||||
proc glutPushWindow*(){.dynlib: dllname, importc: "glutPushWindow".}
|
||||
|
|
@ -280,107 +280,107 @@ proc glutWarpPointer*(x, y: int){.dynlib: dllname, importc: "glutWarpPointer".}
|
|||
proc glutEstablishOverlay*(){.dynlib: dllname, importc: "glutEstablishOverlay".}
|
||||
proc glutRemoveOverlay*(){.dynlib: dllname, importc: "glutRemoveOverlay".}
|
||||
proc glutUseLayer*(layer: TGLenum){.dynlib: dllname, importc: "glutUseLayer".}
|
||||
proc glutPostOverlayRedisplay*(){.dynlib: dllname,
|
||||
proc glutPostOverlayRedisplay*(){.dynlib: dllname,
|
||||
importc: "glutPostOverlayRedisplay".}
|
||||
proc glutPostWindowOverlayRedisplay*(win: int){.dynlib: dllname,
|
||||
proc glutPostWindowOverlayRedisplay*(win: int){.dynlib: dllname,
|
||||
importc: "glutPostWindowOverlayRedisplay".}
|
||||
proc glutShowOverlay*(){.dynlib: dllname, importc: "glutShowOverlay".}
|
||||
proc glutHideOverlay*(){.dynlib: dllname, importc: "glutHideOverlay".}
|
||||
# GLUT menu sub-API.
|
||||
proc glutCreateMenu*(callback: TGlut1IntCallback): int{.dynlib: dllname,
|
||||
proc glutCreateMenu*(callback: TGlut1IntCallback): int{.dynlib: dllname,
|
||||
importc: "glutCreateMenu".}
|
||||
proc glutDestroyMenu*(menu: int){.dynlib: dllname, importc: "glutDestroyMenu".}
|
||||
proc glutGetMenu*(): int{.dynlib: dllname, importc: "glutGetMenu".}
|
||||
proc glutSetMenu*(menu: int){.dynlib: dllname, importc: "glutSetMenu".}
|
||||
proc glutAddMenuEntry*(caption: cstring, value: int){.dynlib: dllname,
|
||||
proc glutAddMenuEntry*(caption: cstring, value: int){.dynlib: dllname,
|
||||
importc: "glutAddMenuEntry".}
|
||||
proc glutAddSubMenu*(caption: cstring, submenu: int){.dynlib: dllname,
|
||||
proc glutAddSubMenu*(caption: cstring, submenu: int){.dynlib: dllname,
|
||||
importc: "glutAddSubMenu".}
|
||||
proc glutChangeToMenuEntry*(item: int, caption: cstring, value: int){.
|
||||
dynlib: dllname, importc: "glutChangeToMenuEntry".}
|
||||
proc glutChangeToSubMenu*(item: int, caption: cstring, submenu: int){.
|
||||
dynlib: dllname, importc: "glutChangeToSubMenu".}
|
||||
proc glutRemoveMenuItem*(item: int){.dynlib: dllname,
|
||||
proc glutRemoveMenuItem*(item: int){.dynlib: dllname,
|
||||
importc: "glutRemoveMenuItem".}
|
||||
proc glutAttachMenu*(button: int){.dynlib: dllname, importc: "glutAttachMenu".}
|
||||
proc glutDetachMenu*(button: int){.dynlib: dllname, importc: "glutDetachMenu".}
|
||||
# GLUT window callback sub-API.
|
||||
proc glutDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname,
|
||||
proc glutDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname,
|
||||
importc: "glutDisplayFunc".}
|
||||
proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutReshapeFunc".}
|
||||
proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname,
|
||||
proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname,
|
||||
importc: "glutKeyboardFunc".}
|
||||
proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname,
|
||||
proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname,
|
||||
importc: "glutMouseFunc".}
|
||||
proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutMotionFunc".}
|
||||
proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutPassiveMotionFunc".}
|
||||
proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
importc: "glutEntryFunc".}
|
||||
proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
importc: "glutVisibilityFunc".}
|
||||
proc glutIdleFunc*(f: TGlutVoidCallback){.dynlib: dllname,
|
||||
proc glutIdleFunc*(f: TGlutVoidCallback){.dynlib: dllname,
|
||||
importc: "glutIdleFunc".}
|
||||
proc glutTimerFunc*(millis: int16, f: TGlut1IntCallback, value: int){.
|
||||
dynlib: dllname, importc: "glutTimerFunc".}
|
||||
proc glutMenuStateFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
proc glutMenuStateFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
importc: "glutMenuStateFunc".}
|
||||
proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
importc: "glutSpecialFunc".}
|
||||
proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
importc: "glutSpaceballMotionFunc".}
|
||||
proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
importc: "glutSpaceballRotateFunc".}
|
||||
proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutSpaceballButtonFunc".}
|
||||
proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutButtonBoxFunc".}
|
||||
proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutDialsFunc".}
|
||||
proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutTabletMotionFunc".}
|
||||
proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname,
|
||||
proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname,
|
||||
importc: "glutTabletButtonFunc".}
|
||||
proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
importc: "glutMenuStatusFunc".}
|
||||
proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname,
|
||||
proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname,
|
||||
importc: "glutOverlayDisplayFunc".}
|
||||
proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
importc: "glutWindowStatusFunc".}
|
||||
proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname,
|
||||
proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname,
|
||||
importc: "glutKeyboardUpFunc".}
|
||||
proc glutSpecialUpFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
proc glutSpecialUpFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
importc: "glutSpecialUpFunc".}
|
||||
proc glutJoystickFunc*(f: TGlut1UInt3IntCallback, pollInterval: int){.
|
||||
dynlib: dllname, importc: "glutJoystickFunc".}
|
||||
# GLUT color index sub-API.
|
||||
proc glutSetColor*(cell: int, red, green, blue: TGLfloat){.dynlib: dllname,
|
||||
proc glutSetColor*(cell: int, red, green, blue: TGLfloat){.dynlib: dllname,
|
||||
importc: "glutSetColor".}
|
||||
proc glutGetColor*(ndx, component: int): TGLfloat{.dynlib: dllname,
|
||||
proc glutGetColor*(ndx, component: int): TGLfloat{.dynlib: dllname,
|
||||
importc: "glutGetColor".}
|
||||
proc glutCopyColormap*(win: int){.dynlib: dllname, importc: "glutCopyColormap".}
|
||||
# GLUT state retrieval sub-API.
|
||||
proc glutGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutGet".}
|
||||
proc glutDeviceGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutDeviceGet".}
|
||||
# GLUT extension support sub-API
|
||||
proc glutExtensionSupported*(name: cstring): int{.dynlib: dllname,
|
||||
proc glutExtensionSupported*(name: cstring): int{.dynlib: dllname,
|
||||
importc: "glutExtensionSupported".}
|
||||
proc glutGetModifiers*(): int{.dynlib: dllname, importc: "glutGetModifiers".}
|
||||
proc glutLayerGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutLayerGet".}
|
||||
# GLUT font sub-API
|
||||
proc glutBitmapCharacter*(font: pointer, character: int){.dynlib: dllname,
|
||||
proc glutBitmapCharacter*(font: pointer, character: int){.dynlib: dllname,
|
||||
importc: "glutBitmapCharacter".}
|
||||
proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname,
|
||||
proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname,
|
||||
importc: "glutBitmapWidth".}
|
||||
proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname,
|
||||
proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname,
|
||||
importc: "glutStrokeCharacter".}
|
||||
proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname,
|
||||
proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname,
|
||||
importc: "glutStrokeWidth".}
|
||||
proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname,
|
||||
proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname,
|
||||
importc: "glutBitmapLength".}
|
||||
proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname,
|
||||
proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname,
|
||||
importc: "glutStrokeLength".}
|
||||
# GLUT pre-built models sub-API
|
||||
proc glutWireSphere*(radius: TGLdouble, slices, stacks: TGLint){.
|
||||
|
|
@ -399,9 +399,9 @@ proc glutSolidTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){
|
|||
dynlib: dllname, importc: "glutSolidTorus".}
|
||||
proc glutWireDodecahedron*(){.dynlib: dllname, importc: "glutWireDodecahedron".}
|
||||
proc glutSolidDodecahedron*(){.dynlib: dllname, importc: "glutSolidDodecahedron".}
|
||||
proc glutWireTeapot*(size: TGLdouble){.dynlib: dllname,
|
||||
proc glutWireTeapot*(size: TGLdouble){.dynlib: dllname,
|
||||
importc: "glutWireTeapot".}
|
||||
proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname,
|
||||
proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname,
|
||||
importc: "glutSolidTeapot".}
|
||||
proc glutWireOctahedron*(){.dynlib: dllname, importc: "glutWireOctahedron".}
|
||||
proc glutSolidOctahedron*(){.dynlib: dllname, importc: "glutSolidOctahedron".}
|
||||
|
|
@ -410,29 +410,29 @@ proc glutSolidTetrahedron*(){.dynlib: dllname, importc: "glutSolidTetrahedron".}
|
|||
proc glutWireIcosahedron*(){.dynlib: dllname, importc: "glutWireIcosahedron".}
|
||||
proc glutSolidIcosahedron*(){.dynlib: dllname, importc: "glutSolidIcosahedron".}
|
||||
# GLUT video resize sub-API.
|
||||
proc glutVideoResizeGet*(param: TGLenum): int{.dynlib: dllname,
|
||||
proc glutVideoResizeGet*(param: TGLenum): int{.dynlib: dllname,
|
||||
importc: "glutVideoResizeGet".}
|
||||
proc glutSetupVideoResizing*(){.dynlib: dllname,
|
||||
proc glutSetupVideoResizing*(){.dynlib: dllname,
|
||||
importc: "glutSetupVideoResizing".}
|
||||
proc glutStopVideoResizing*(){.dynlib: dllname, importc: "glutStopVideoResizing".}
|
||||
proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname,
|
||||
proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname,
|
||||
importc: "glutVideoResize".}
|
||||
proc glutVideoPan*(x, y, width, height: int){.dynlib: dllname,
|
||||
proc glutVideoPan*(x, y, width, height: int){.dynlib: dllname,
|
||||
importc: "glutVideoPan".}
|
||||
# GLUT debugging sub-API.
|
||||
proc glutReportErrors*(){.dynlib: dllname, importc: "glutReportErrors".}
|
||||
# GLUT device control sub-API.
|
||||
proc glutIgnoreKeyRepeat*(ignore: int){.dynlib: dllname,
|
||||
proc glutIgnoreKeyRepeat*(ignore: int){.dynlib: dllname,
|
||||
importc: "glutIgnoreKeyRepeat".}
|
||||
proc glutSetKeyRepeat*(repeatMode: int){.dynlib: dllname,
|
||||
proc glutSetKeyRepeat*(repeatMode: int){.dynlib: dllname,
|
||||
importc: "glutSetKeyRepeat".}
|
||||
proc glutForceJoystickFunc*(){.dynlib: dllname, importc: "glutForceJoystickFunc".}
|
||||
# GLUT game mode sub-API.
|
||||
#example glutGameModeString('1280x1024:32@75');
|
||||
proc glutGameModeString*(AString: cstring){.dynlib: dllname,
|
||||
proc glutGameModeString*(AString: cstring){.dynlib: dllname,
|
||||
importc: "glutGameModeString".}
|
||||
proc glutEnterGameMode*(): int{.dynlib: dllname, importc: "glutEnterGameMode".}
|
||||
proc glutLeaveGameMode*(){.dynlib: dllname, importc: "glutLeaveGameMode".}
|
||||
proc glutGameModeGet*(mode: TGLenum): int{.dynlib: dllname,
|
||||
proc glutGameModeGet*(mode: TGLenum): int{.dynlib: dllname,
|
||||
importc: "glutGameModeGet".}
|
||||
# implementation
|
||||
|
|
|
|||
|
|
@ -23,19 +23,19 @@
|
|||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
|
||||
import
|
||||
import
|
||||
X, XLib, XUtil, gl
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
when defined(windows):
|
||||
const
|
||||
dllname = "GL.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
elif defined(macosx):
|
||||
const
|
||||
dllname = "/usr/X11R6/lib/libGL.dylib"
|
||||
else:
|
||||
const
|
||||
else:
|
||||
const
|
||||
dllname = "libGL.so"
|
||||
const
|
||||
const
|
||||
GLX_USE_GL* = 1
|
||||
GLX_BUFFER_SIZE* = 2
|
||||
GLX_LEVEL* = 3
|
||||
|
|
@ -98,55 +98,55 @@ type # From XLib:
|
|||
|
||||
proc glXChooseVisual*(dpy: PDisplay, screen: int, attribList: ptr int32): PXVisualInfo{.
|
||||
cdecl, dynlib: dllname, importc: "glXChooseVisual".}
|
||||
proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext,
|
||||
direct: bool): GLXContext{.cdecl, dynlib: dllname,
|
||||
proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext,
|
||||
direct: bool): GLXContext{.cdecl, dynlib: dllname,
|
||||
importc: "glXCreateContext".}
|
||||
proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname,
|
||||
proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname,
|
||||
importc: "glXDestroyContext".}
|
||||
proc glXMakeCurrent*(dpy: PDisplay, drawable: GLXDrawable, ctx: GLXContext): bool{.
|
||||
cdecl, dynlib: dllname, importc: "glXMakeCurrent".}
|
||||
proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl,
|
||||
proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl,
|
||||
dynlib: dllname, importc: "glXCopyContext".}
|
||||
proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl,
|
||||
proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl,
|
||||
dynlib: dllname, importc: "glXSwapBuffers".}
|
||||
proc glXCreateGLXPixmap*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap): GLXPixmap{.
|
||||
cdecl, dynlib: dllname, importc: "glXCreateGLXPixmap".}
|
||||
proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl,
|
||||
proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl,
|
||||
dynlib: dllname, importc: "glXDestroyGLXPixmap".}
|
||||
proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl,
|
||||
proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl,
|
||||
dynlib: dllname, importc: "glXQueryExtension".}
|
||||
proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl,
|
||||
proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl,
|
||||
dynlib: dllname, importc: "glXQueryVersion".}
|
||||
proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname,
|
||||
proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname,
|
||||
importc: "glXIsDirect".}
|
||||
proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int,
|
||||
value: var int): int{.cdecl, dynlib: dllname,
|
||||
proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int,
|
||||
value: var int): int{.cdecl, dynlib: dllname,
|
||||
importc: "glXGetConfig".}
|
||||
proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname,
|
||||
proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname,
|
||||
importc: "glXGetCurrentContext".}
|
||||
proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname,
|
||||
proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname,
|
||||
importc: "glXGetCurrentDrawable".}
|
||||
proc glXWaitGL*(){.cdecl, dynlib: dllname, importc: "glXWaitGL".}
|
||||
proc glXWaitX*(){.cdecl, dynlib: dllname, importc: "glXWaitX".}
|
||||
proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname,
|
||||
proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname,
|
||||
importc: "glXUseXFont".}
|
||||
# GLX 1.1 and later
|
||||
proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl,
|
||||
proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl,
|
||||
dynlib: dllname, importc: "glXQueryExtensionsString".}
|
||||
proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl,
|
||||
proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl,
|
||||
dynlib: dllname, importc: "glXQueryServerString".}
|
||||
proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl,
|
||||
proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl,
|
||||
dynlib: dllname, importc: "glXGetClientString".}
|
||||
# Mesa GLX Extensions
|
||||
proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo,
|
||||
proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo,
|
||||
pixmap: XPixmap, cmap: XColormap): GLXPixmap{.
|
||||
cdecl, dynlib: dllname, importc: "glXCreateGLXPixmapMESA".}
|
||||
proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl,
|
||||
proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl,
|
||||
dynlib: dllname, importc: "glXReleaseBufferMESA".}
|
||||
proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable,
|
||||
x, y, width, height: int){.cdecl, dynlib: dllname,
|
||||
proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable,
|
||||
x, y, width, height: int){.cdecl, dynlib: dllname,
|
||||
importc: "glXCopySubBufferMESA".}
|
||||
proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname,
|
||||
proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname,
|
||||
importc: "glXGetVideoSyncSGI".}
|
||||
proc glXWaitVideoSyncSGI*(divisor, remainder: int, count: var int32): int{.
|
||||
cdecl, dynlib: dllname, importc: "glXWaitVideoSyncSGI".}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ type
|
|||
freeIDs: seq[T]
|
||||
EOutOfIDs* = object of EInvalidKey
|
||||
|
||||
#proc free[T](idg: PIDgen[T]) =
|
||||
#proc free[T](idg: PIDgen[T]) =
|
||||
# result.freeIDs = nil
|
||||
proc newIDGen*[T: Ordinal](): PIDGen[T] =
|
||||
new(result)#, free)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import
|
|||
sfml, tables, hashes
|
||||
type
|
||||
TKeyEventKind* = enum down, up
|
||||
TInputFinishedProc* = proc()
|
||||
TInputFinishedProc* = proc()
|
||||
TKeyCallback = proc()
|
||||
PKeyClient* = ref object
|
||||
onKeyDown: TTable[int32, TKeyCallback]
|
||||
|
|
@ -18,7 +18,7 @@ var
|
|||
activeClient: PKeyClient = nil
|
||||
activeInput: PTextInput = nil
|
||||
|
||||
proc setActive*(client: PKeyClient) =
|
||||
proc setActive*(client: PKeyClient) =
|
||||
activeClient = client
|
||||
echo("** set active client ", client.name)
|
||||
proc newKeyClient*(name: string = "unnamed", setactive = false): PKeyClient =
|
||||
|
|
@ -43,28 +43,28 @@ proc addKeyEvent*(key: TKeyCode, ev: TKeyEventKind) {.inline.} =
|
|||
if activeClient.isNil: return
|
||||
let k = key.int32
|
||||
case ev
|
||||
of down:
|
||||
of down:
|
||||
keyState[k] = true
|
||||
if activeClient.onKeyDown.hasKey(k):
|
||||
activeClient.onKeyDown[k]()
|
||||
else:
|
||||
else:
|
||||
keyState[k] = false
|
||||
if activeClient.onKeyUp.hasKey(k):
|
||||
activeClient.onKeyUp[k]()
|
||||
proc addButtonEvent*(btn: TMouseButton, ev: TKeyEventKind) {.inline.} =
|
||||
if activeClient.isNil: return
|
||||
if activeClient.isNil: return
|
||||
let b = -btn.int32
|
||||
case ev
|
||||
of down:
|
||||
keyState[b] = true
|
||||
of down:
|
||||
keyState[b] = true
|
||||
if activeClient.onKeyDown.hasKey(b):
|
||||
activeClient.onKeyDown[b]()
|
||||
else:
|
||||
else:
|
||||
keyState[b] = false
|
||||
if activeClient.onKeyUp.hasKey(b):
|
||||
activeClient.onKeyUp[b]()
|
||||
proc registerHandler*(client: PKeyClient; key: TKeyCode;
|
||||
ev: TKeyEventKind; fn: TKeyCallback) =
|
||||
ev: TKeyEventKind; fn: TKeyCallback) =
|
||||
case ev
|
||||
of down: client.onKeyDown[key.int32] = fn
|
||||
of up: client.onKeyUp[key.int32] = fn
|
||||
|
|
@ -90,7 +90,7 @@ proc recordText*(i: PTextInput; c: cint) =
|
|||
if c > 127 or i.isNil: return
|
||||
if c in 32..126: ##printable
|
||||
if i.cursor == i.text.len: i.text.add(c.int.chr)
|
||||
else:
|
||||
else:
|
||||
let rem = i.text.substr(i.cursor)
|
||||
i.text.setLen(i.cursor)
|
||||
i.text.add(chr(c.int))
|
||||
|
|
@ -104,7 +104,7 @@ proc recordText*(i: PTextInput; c: cint) =
|
|||
i.text.add(rem)
|
||||
elif c == 10 or c == 13:## \n, \r enter
|
||||
if not i.onEnter.isNil: i.onEnter()
|
||||
proc recordText*(i: PTextInput; e: TTextEvent) {.inline.} =
|
||||
proc recordText*(i: PTextInput; e: TTextEvent) {.inline.} =
|
||||
recordText(i, e.unicode)
|
||||
|
||||
proc setMousePos*(x, y: cint) {.inline.} =
|
||||
|
|
@ -135,4 +135,4 @@ iterator pollEvents*(window: PRenderWindow): PEvent =
|
|||
of EvtTextEntered: recordText(activeInput, event.text)
|
||||
of EvtMouseMoved: setMousePos(event.mouseMove.x, event.mouseMove.y)
|
||||
else: nil
|
||||
yield(addr event)
|
||||
yield(addr event)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ template unless*(condition: expr; body: stmt): stmt {.dirty.} =
|
|||
|
||||
when isMainModule:
|
||||
proc dumpSeq[T](x: seq[T]) =
|
||||
for index, item in x.pairs:
|
||||
for index, item in x.pairs:
|
||||
echo index, " ", item
|
||||
echo "-------"
|
||||
|
||||
|
|
@ -28,13 +28,13 @@ when isMainModule:
|
|||
dumpSeq res
|
||||
|
||||
from strutils import toHex
|
||||
var foocakes = t.map(proc(z: int): string =
|
||||
var foocakes = t.map(proc(z: int): string =
|
||||
result = toHex((z * 23).BiggestInt, 4))
|
||||
dumpSeq foocakes
|
||||
|
||||
t.mapInPlace(proc(z: int): int = result = z * 30)
|
||||
dumpSeq t
|
||||
|
||||
|
||||
var someSeq = @[9,8,7,6,5,4,3,2,1] ## numbers < 6 or even
|
||||
filterIt2 someSeq, it < 6 or (it and 1) == 0:
|
||||
echo(it)
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@ proc radians*(deg: float): float =
|
|||
return deg * PI / 180.0
|
||||
|
||||
## V not math, sue me
|
||||
proc ff*(f: float, precision = 2): string {.inline.} =
|
||||
proc ff*(f: float, precision = 2): string {.inline.} =
|
||||
return formatFloat(f, ffDecimal, precision)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import
|
||||
import
|
||||
math, strutils,
|
||||
sfml, input_helpers
|
||||
when not defined(NoChipmunk):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import
|
||||
re, json, strutils, tables, math, os, math_helpers,
|
||||
re, json, strutils, tables, math, os, math_helpers,
|
||||
sg_packets, md5, zlib_helpers
|
||||
|
||||
when defined(NoSFML):
|
||||
|
|
@ -56,9 +56,9 @@ type
|
|||
energyCost*: float
|
||||
useSound*: PSoundRecord
|
||||
case kind*: TItemKind
|
||||
of Projectile:
|
||||
of Projectile:
|
||||
bullet*: PBulletRecord
|
||||
else:
|
||||
else:
|
||||
nil
|
||||
PBulletRecord* = ref TBulletRecord
|
||||
TBulletRecord* = object
|
||||
|
|
@ -84,7 +84,7 @@ type
|
|||
health*: int
|
||||
TExplosionRecord* = object
|
||||
anim*: PAnimationRecord
|
||||
sound*: PSoundRecord
|
||||
sound*: PSoundRecord
|
||||
PAnimationRecord* = ref TAnimationRecord
|
||||
TAnimationRecord* = object
|
||||
spriteSheet*: PSpriteSheet
|
||||
|
|
@ -96,9 +96,9 @@ type
|
|||
when defined(NoSFML):
|
||||
contents*: TChecksumFile
|
||||
else:
|
||||
soundBuf*: PSoundBuffer
|
||||
soundBuf*: PSoundBuffer
|
||||
PSpriteSheet* = ref TSpriteSheet
|
||||
TSpriteSheet* = object
|
||||
TSpriteSheet* = object
|
||||
file*: string
|
||||
framew*,frameh*: int
|
||||
rows*, cols*: int
|
||||
|
|
@ -112,7 +112,7 @@ type
|
|||
const
|
||||
TAU* = PI * 2.0
|
||||
MomentMult* = 0.62 ## global moment of inertia multiplier
|
||||
var
|
||||
var
|
||||
cfg: PZoneSettings
|
||||
SpriteSheets* = initTable[string, PSpriteSheet](64)
|
||||
SoundCache * = initTable[string, PSoundRecord](64)
|
||||
|
|
@ -151,7 +151,7 @@ proc importSound*(data: PJsonNode; errors: var seq[string]; fieldName: string =
|
|||
## this is the only pipe between lobby and main.nim
|
||||
proc getActiveState*(): TGameState =
|
||||
result = activeState
|
||||
proc transition*() =
|
||||
proc transition*() =
|
||||
assert activeState == Lobby, "Transition() called from a state other than lobby!"
|
||||
activeState = Transitioning
|
||||
proc doneWithSaidTransition*() =
|
||||
|
|
@ -179,7 +179,7 @@ proc free*(obj: PSoundRecord) =
|
|||
echo "Free'd ", obj.file
|
||||
|
||||
proc loadAllAssets*() =
|
||||
var
|
||||
var
|
||||
loaded = 0
|
||||
failed = 0
|
||||
for name, ss in SpriteSheets.pairs():
|
||||
|
|
@ -205,7 +205,7 @@ iterator playableVehicles*(): PVehicleRecord =
|
|||
yield v
|
||||
|
||||
template allAssets*(body: stmt) {.dirty.}=
|
||||
block:
|
||||
block:
|
||||
var assetType = FGraphics
|
||||
for file, asset in pairs(SpriteSheets):
|
||||
body
|
||||
|
|
@ -230,7 +230,7 @@ cacheImpl newSprite, SpriteSheets, PSpriteSheet:
|
|||
if filename =~ re"\S+_(\d+)x(\d+)\.\S\S\S":
|
||||
result.framew = strutils.parseInt(matches[0])
|
||||
result.frameh = strutils.parseInt(matches[1])
|
||||
checkFile("data/gfx"/result.file)
|
||||
checkFile("data/gfx"/result.file)
|
||||
else:
|
||||
errors.add "Bad file: "&filename&" must be in format name_WxH.png"
|
||||
return
|
||||
|
|
@ -260,7 +260,7 @@ when defined(NoSFML):
|
|||
result = true
|
||||
else:
|
||||
proc load*(ss: PSpriteSheet): bool =
|
||||
if not ss.sprite.isNil:
|
||||
if not ss.sprite.isNil:
|
||||
return
|
||||
var image = sfml.newImage("data/gfx/"/ss.file)
|
||||
if image == nil:
|
||||
|
|
@ -335,7 +335,7 @@ proc loadSettings*(rawJson: string, errors: var seq[string]): bool =
|
|||
except EJsonParsingError:
|
||||
errors.add("JSON parsing error: "& getCurrentExceptionMsg())
|
||||
return
|
||||
except:
|
||||
except:
|
||||
errors.add("Unknown exception: "& getCurrentExceptionMsg())
|
||||
return
|
||||
if not validateSettings(settings, errors):
|
||||
|
|
@ -354,7 +354,7 @@ proc loadSettings*(rawJson: string, errors: var seq[string]): bool =
|
|||
nameToItemID = initTable[string, int](32)
|
||||
nameToObjID = initTable[string, int](32)
|
||||
nameToBulletID = initTable[string, int](32)
|
||||
var
|
||||
var
|
||||
vID = 0'i16
|
||||
bID = 0'i16
|
||||
for vehicle in settings["vehicles"].items:
|
||||
|
|
@ -382,7 +382,7 @@ proc loadSettings*(rawJson: string, errors: var seq[string]): bool =
|
|||
errors.add("Projectile #$1 has no bullet!"% $vID)
|
||||
elif itm.bullet.id == -1:
|
||||
## this item has an anonymous bullet, fix the ID and name
|
||||
itm.bullet.id = bID
|
||||
itm.bullet.id = bID
|
||||
itm.bullet.name = itm.name
|
||||
cfg.bullets.add itm.bullet
|
||||
nameToBulletID[itm.bullet.name] = itm.bullet.id
|
||||
|
|
@ -448,7 +448,7 @@ proc importLevel(data: PJsonNode; errors: var seq[string]): PLevelSettings =
|
|||
new(result)
|
||||
result.size = vec2i(5000, 5000)
|
||||
result.starfield = @[]
|
||||
|
||||
|
||||
checkKey(data, "level")
|
||||
var level = data["level"]
|
||||
if level.hasKey("size") and level["size"].kind == JArray and level["size"].len == 2:
|
||||
|
|
@ -460,7 +460,7 @@ proc importLevel(data: PJsonNode; errors: var seq[string]): PLevelSettings =
|
|||
proc importPhys(data: PJsonNode): TPhysicsRecord =
|
||||
result.radius = 20.0
|
||||
result.mass = 10.0
|
||||
|
||||
|
||||
if data.hasKey("physics") and data["physics"].kind == JObject:
|
||||
let phys = data["physics"]
|
||||
phys.getField("radius", result.radius)
|
||||
|
|
@ -473,11 +473,11 @@ proc importHandling(data: PJsonNode): THandlingRecord =
|
|||
result.reverse = 30.0
|
||||
result.strafe = 30.0
|
||||
result.rotation = 2200.0
|
||||
|
||||
|
||||
checkKey(data, "handling")
|
||||
if data["handling"].kind != JObject:
|
||||
return
|
||||
|
||||
|
||||
let hand = data["handling"]
|
||||
hand.getField("thrust", result.thrust)
|
||||
hand.getField("top_speed", result.topSpeed)
|
||||
|
|
@ -489,19 +489,19 @@ proc importAnim(data: PJsonNode, errors: var seq[string]): PAnimationRecord =
|
|||
result.angle = 0.0
|
||||
result.delay = 1000.0
|
||||
result.spriteSheet = nil
|
||||
|
||||
|
||||
if data.hasKey("anim"):
|
||||
let anim = data["anim"]
|
||||
if anim.kind == JObject:
|
||||
if anim.hasKey("file"):
|
||||
result.spriteSheet = newSprite(anim["file"].str, errors)
|
||||
|
||||
|
||||
anim.getField "angle", result.angle
|
||||
anim.getField "delay", result.delay
|
||||
elif data["anim"].kind == JString:
|
||||
result.spriteSheet = newSprite(anim.str, errors)
|
||||
|
||||
result.angle = radians(result.angle) ## comes in as degrees
|
||||
|
||||
result.angle = radians(result.angle) ## comes in as degrees
|
||||
result.delay /= 1000 ## delay comes in as milliseconds
|
||||
proc importSoul(data: PJsonNode): TSoulRecord =
|
||||
result.energy = 10000
|
||||
|
|
@ -525,8 +525,8 @@ proc importSound*(data: PJsonNode; errors: var seq[string]; fieldName: string =
|
|||
proc importVeh(data: PJsonNode; errors: var seq[string]): PVehicleRecord =
|
||||
new(result)
|
||||
result.playable = false
|
||||
if data.kind != JArray or data.len != 2 or
|
||||
(data.kind == JArray and
|
||||
if data.kind != JArray or data.len != 2 or
|
||||
(data.kind == JArray and
|
||||
(data[0].kind != JString or data[1].kind != JObject)):
|
||||
result.name = "(broken)"
|
||||
errors.add "Vehicle record is malformed"
|
||||
|
|
@ -556,13 +556,13 @@ proc importItem(data: PJsonNode; errors: var seq[string]): PItemRecord =
|
|||
result.name = data[0].str
|
||||
result.anim = importAnim(data[2], errors)
|
||||
result.physics = importPhys(data[2])
|
||||
|
||||
result.cooldown = 100.0
|
||||
|
||||
result.cooldown = 100.0
|
||||
data[2].getField("cooldown", result.cooldown)
|
||||
result.cooldown /= 1000.0 ##cooldown is stored in ms
|
||||
|
||||
result.cooldown /= 1000.0 ##cooldown is stored in ms
|
||||
|
||||
result.useSound = importSound(data[2], errors, "useSound")
|
||||
|
||||
|
||||
case data[1].str.toLower
|
||||
of "projectile":
|
||||
result.kind = Projectile
|
||||
|
|
@ -570,7 +570,7 @@ proc importItem(data: PJsonNode; errors: var seq[string]): PItemRecord =
|
|||
result.bullet = fetchBullet(data[2]["bullet"].str)
|
||||
elif data[2]["bullet"].kind == JInt:
|
||||
result.bullet = cfg.bullets[data[2]["bullet"].num.int]
|
||||
elif data[2]["bullet"].kind == JObject:
|
||||
elif data[2]["bullet"].kind == JObject:
|
||||
result.bullet = importBullet(data[2]["bullet"], errors)
|
||||
else:
|
||||
errors.add "UNKNOWN BULLET TYPE for item "& result.name
|
||||
|
|
@ -584,20 +584,20 @@ proc importItem(data: PJsonNode; errors: var seq[string]): PItemRecord =
|
|||
proc importBullet(data: PJsonNode; errors: var seq[string]): PBulletRecord =
|
||||
new(result)
|
||||
result.id = -1
|
||||
|
||||
|
||||
var bdata: PJsonNode
|
||||
if data.kind == JArray:
|
||||
result.name = data[0].str
|
||||
bdata = data[1]
|
||||
elif data.kind == JObject:
|
||||
bdata = data
|
||||
else:
|
||||
else:
|
||||
errors.add "Malformed bullet record"
|
||||
return
|
||||
|
||||
|
||||
result.anim = importAnim(bdata, errors)
|
||||
result.physics = importPhys(bdata)
|
||||
|
||||
|
||||
result.lifetime = 2000.0
|
||||
result.inheritVelocity = 1000.0
|
||||
result.baseVelocity = 30.0
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import
|
||||
sfml, sfml_colors,
|
||||
sfml, sfml_colors,
|
||||
input_helpers, sg_packets
|
||||
from strutils import countlines
|
||||
{.deadCodeElim: on.}
|
||||
|
|
@ -63,7 +63,7 @@ proc click*(b: PButton; p: TVector2f)
|
|||
proc setPosition*(b: PButton; p: TVector2f)
|
||||
proc setString*(b: PButton; s: string) {.inline.}
|
||||
|
||||
proc newButton*(container: PGuiContainer; text: string; position: TVector2f;
|
||||
proc newButton*(container: PGuiContainer; text: string; position: TVector2f;
|
||||
onClick: TButtonClicked; startEnabled: bool = true): PButton {.discardable.}
|
||||
proc init(b: PButton; text: string; position: TVector2f; onClick: TButtonClicked)
|
||||
proc setEnabled*(b: PButton; enabled: bool)
|
||||
|
|
@ -91,7 +91,7 @@ proc newGuiContainer*(): PGuiContainer =
|
|||
proc newGuiContainer*(pos: TVector2f): PGuiContainer =
|
||||
result = newGuiContainer()
|
||||
result.setPosition pos
|
||||
proc free*(container: PGuiContainer) =
|
||||
proc free*(container: PGuiContainer) =
|
||||
container.widgets = nil
|
||||
container.buttons = nil
|
||||
proc add*(container: PGuiContainer; widget: PGuiObject) =
|
||||
|
|
@ -128,9 +128,9 @@ proc newButton*(container: PGuiContainer; text: string;
|
|||
position: TVector2f; onClick: TButtonClicked;
|
||||
startEnabled: bool = true): PButton =
|
||||
new(result, free)
|
||||
init(result,
|
||||
text,
|
||||
if not container.isNil: position + container.position else: position,
|
||||
init(result,
|
||||
text,
|
||||
if not container.isNil: position + container.position else: position,
|
||||
onClick)
|
||||
container.add result
|
||||
if not startEnabled: disable(result)
|
||||
|
|
@ -168,13 +168,13 @@ proc setPosition*(b: PButton, p: TVector2f) =
|
|||
b.bounds = b.text.getGlobalBounds()
|
||||
proc setString*(b: PButton; s: string) =
|
||||
b.text.setString(s)
|
||||
proc click*(b: PButton, p: TVector2f) =
|
||||
if b.enabled and (addr b.bounds).contains(p.x, p.y):
|
||||
proc click*(b: PButton, p: TVector2f) =
|
||||
if b.enabled and (addr b.bounds).contains(p.x, p.y):
|
||||
b.onClick(b)
|
||||
|
||||
proc free(obj: PTextEntry) =
|
||||
free(PButton(obj))
|
||||
proc newTextEntry*(container: PGuiContainer; text: string;
|
||||
proc newTextEntry*(container: PGuiContainer; text: string;
|
||||
position: TVector2F; onEnter: TInputFinishedProc = nil): PTextEntry =
|
||||
new(result, free)
|
||||
init(PButton(result), text, position + container.position, proc(b: PButton) =
|
||||
|
|
@ -210,7 +210,7 @@ proc add*(m: PMessageArea, text: string): PText =
|
|||
pos.y -= 16.0
|
||||
|
||||
proc draw*(window: PRenderWindow; m: PMessageArea) =
|
||||
let nmsgs = len(m.messages)
|
||||
let nmsgs = len(m.messages)
|
||||
if nmsgs == 0: return
|
||||
for i in countdown(nmsgs - 1, max(nmsgs - 30, 0)):
|
||||
window.draw(m.messages[i])
|
||||
|
|
@ -224,11 +224,11 @@ proc newMessageArea*(container: PGuiContainer; position: TVector2f): PMessageAre
|
|||
result.scrollBack = 0
|
||||
result.direction = -1 ## to push old messages up
|
||||
container.add(result)
|
||||
|
||||
|
||||
proc add*(m: PMessageArea, msg: ScChat) =
|
||||
const prependName = {CPub, CPriv}
|
||||
var mmm: TMessage
|
||||
if msg.kind in prependName:
|
||||
if msg.kind in prependName:
|
||||
mmm.text = "<"
|
||||
mmm.text.add msg.fromPlayer
|
||||
mmm.text.add "> "
|
||||
|
|
@ -239,9 +239,9 @@ proc add*(m: PMessageArea, msg: ScChat) =
|
|||
of CPub: mmm.color = RoyalBlue
|
||||
of CPriv, CSystem: mmm.color = Green
|
||||
of CError: mmm.color = Red
|
||||
|
||||
|
||||
mmm.lines = countLines(mmm.text)+1
|
||||
|
||||
|
||||
m.messages.add mmm
|
||||
update m
|
||||
proc add*(m: PMessageArea, msg: string) {.inline.} =
|
||||
|
|
@ -249,7 +249,7 @@ proc add*(m: PMessageArea, msg: string) {.inline.} =
|
|||
add(m, chat)
|
||||
|
||||
proc proctor*(m: PText; msg: ptr TMessage; pos: ptr TVector2f) =
|
||||
m.setString msg.text
|
||||
m.setString msg.text
|
||||
m.setColor msg.color
|
||||
m.setPosition pos[]
|
||||
proc update*(m: PMessageArea) =
|
||||
|
|
@ -263,7 +263,7 @@ proc update*(m: PMessageArea) =
|
|||
for i in m.sizeVisible.. < m.texts.len:
|
||||
m.texts.pop().destroy()
|
||||
let nmsgs = m.messages.len()
|
||||
if m.sizeVisible == 0 or nmsgs == 0:
|
||||
if m.sizeVisible == 0 or nmsgs == 0:
|
||||
echo "no messages? ", m.sizeVisible, ", ", nmsgs
|
||||
return
|
||||
var pos = vec2f(m.pos.x, m.pos.y)
|
||||
|
|
@ -271,7 +271,7 @@ proc update*(m: PMessageArea) =
|
|||
##echo nmsgs - i - 1 - m.scrollBack
|
||||
let msg = addr m.messages[nmsgs - i - 1 - m.scrollBack]
|
||||
proctor(m.texts[i], msg, addr pos)
|
||||
pos.y += (16 * m.direction * msg.lines).cfloat
|
||||
pos.y += (16 * m.direction * msg.lines).cfloat
|
||||
|
||||
proc draw*(window: PRenderWindow; m: PMessageArea) =
|
||||
let nmsgs = len(m.texts)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ defPacket(Poing, tuple[id: int32, time: float32])
|
|||
type ChatType* = enum
|
||||
CPub = 0'i8, CPriv, CSystem, CError
|
||||
forwardPacketT(ChatType, int8)
|
||||
idPacket(Chat, 'C',
|
||||
idPacket(Chat, 'C',
|
||||
tuple[kind: ChatType = CPub; fromPlayer: string = ""; text: string = ""],
|
||||
tuple[target: string = ""; text: string = ""])
|
||||
|
||||
|
|
@ -65,8 +65,8 @@ defPacket(ScSpawn, tuple[
|
|||
|
||||
|
||||
type TAssetType* = enum
|
||||
FDummy,
|
||||
FZoneCfg, FGraphics, FSound
|
||||
FDummy,
|
||||
FZoneCfg, FGraphics, FSound
|
||||
|
||||
forwardPacketT(TAssetType, int8)
|
||||
forwardPacket(MD5Digest, array[0..15, int8])
|
||||
|
|
@ -93,7 +93,7 @@ let HVerifyClient* = 'v'
|
|||
defPacket(SdVerifyClient, tuple[session: ScLogin])
|
||||
|
||||
when isMainModule:
|
||||
|
||||
|
||||
var buf = newBuffer(100)
|
||||
var m = toMd5("hello there")
|
||||
echo(repr(m))
|
||||
|
|
@ -101,7 +101,7 @@ when isMainModule:
|
|||
|
||||
echo(repr(buf.data))
|
||||
echo(len(buf.data))
|
||||
|
||||
|
||||
buf.reset()
|
||||
|
||||
var x = buf.readMD5Digest()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import
|
||||
sfml, chipmunk,
|
||||
sfml, chipmunk,
|
||||
sg_assets, sfml_stuff, keineschweine
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import
|
||||
import
|
||||
gl, windows
|
||||
|
||||
proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname,
|
||||
proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname,
|
||||
importc: "wglGetExtensionsStringARB".}
|
||||
const
|
||||
const
|
||||
WGL_FRONT_COLOR_BUFFER_BIT_ARB* = 0x00000001
|
||||
WGL_BACK_COLOR_BUFFER_BIT_ARB* = 0x00000002
|
||||
WGL_DEPTH_BUFFER_BIT_ARB* = 0x00000004
|
||||
|
|
@ -13,21 +13,21 @@ proc WinChoosePixelFormat*(DC: HDC, p2: PPixelFormatDescriptor): int{.
|
|||
dynlib: "gdi32", importc: "ChoosePixelFormat".}
|
||||
proc wglCreateBufferRegionARB*(hDC: HDC, iLayerPlane: TGLint, uType: TGLuint): THandle{.
|
||||
dynlib: dllname, importc: "wglCreateBufferRegionARB".}
|
||||
proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname,
|
||||
proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname,
|
||||
importc: "wglDeleteBufferRegionARB".}
|
||||
proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
|
||||
proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
|
||||
width: TGLint, height: TGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglSaveBufferRegionARB".}
|
||||
proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
|
||||
width: TGLint, height: TGLint, xSrc: TGLint,
|
||||
ySrc: TGLint): BOOL{.dynlib: dllname,
|
||||
proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
|
||||
width: TGLint, height: TGLint, xSrc: TGLint,
|
||||
ySrc: TGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglRestoreBufferRegionARB".}
|
||||
proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat,
|
||||
proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat,
|
||||
writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{.
|
||||
dynlib: dllname, importc: "wglAllocateMemoryNV".}
|
||||
proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname,
|
||||
proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname,
|
||||
importc: "wglFreeMemoryNV".}
|
||||
const
|
||||
const
|
||||
WGL_IMAGE_BUFFER_MIN_ACCESS_I3D* = 0x00000001
|
||||
WGL_IMAGE_BUFFER_LOCK_I3D* = 0x00000002
|
||||
|
||||
|
|
@ -35,30 +35,30 @@ proc wglCreateImageBufferI3D*(hDC: HDC, dwSize: DWORD, uFlags: UINT): PGLvoid{.
|
|||
dynlib: dllname, importc: "wglCreateImageBufferI3D".}
|
||||
proc wglDestroyImageBufferI3D*(hDC: HDC, pAddress: PGLvoid): BOOL{.
|
||||
dynlib: dllname, importc: "wglDestroyImageBufferI3D".}
|
||||
proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle,
|
||||
pAddress: PGLvoid, pSize: PDWORD,
|
||||
count: UINT): BOOL{.dynlib: dllname,
|
||||
proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle,
|
||||
pAddress: PGLvoid, pSize: PDWORD,
|
||||
count: UINT): BOOL{.dynlib: dllname,
|
||||
importc: "wglAssociateImageBufferEventsI3D".}
|
||||
proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{.
|
||||
dynlib: dllname, importc: "wglReleaseImageBufferEventsI3D".}
|
||||
proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname,
|
||||
proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname,
|
||||
importc: "wglEnableFrameLockI3D".}
|
||||
proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname,
|
||||
proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname,
|
||||
importc: "wglDisableFrameLockI3D".}
|
||||
proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||
proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||
importc: "wglIsEnabledFrameLockI3D".}
|
||||
proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||
proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||
importc: "wglQueryFrameLockMasterI3D".}
|
||||
proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname,
|
||||
proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname,
|
||||
importc: "wglGetFrameUsageI3D".}
|
||||
proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname,
|
||||
proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname,
|
||||
importc: "wglBeginFrameTrackingI3D".}
|
||||
proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname,
|
||||
proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname,
|
||||
importc: "wglEndFrameTrackingI3D".}
|
||||
proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD,
|
||||
proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD,
|
||||
pLastMissedUsage: PGLfloat): BOOL{.
|
||||
dynlib: dllname, importc: "wglQueryFrameTrackingI3D".}
|
||||
const
|
||||
const
|
||||
WGL_NUMBER_PIXEL_FORMATS_ARB* = 0x00002000
|
||||
WGL_DRAW_TO_WINDOW_ARB* = 0x00002001
|
||||
WGL_DRAW_TO_BITMAP_ARB* = 0x00002002
|
||||
|
|
@ -109,27 +109,27 @@ const
|
|||
WGL_TYPE_RGBA_ARB* = 0x0000202B
|
||||
WGL_TYPE_COLORINDEX_ARB* = 0x0000202C
|
||||
|
||||
proc wglGetPixelFormatAttribivARB*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
proc wglGetPixelFormatAttribivARB*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
piAttributes: PGLint, piValues: PGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetPixelFormatAttribivARB".}
|
||||
proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetPixelFormatAttribfvARB".}
|
||||
proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint,
|
||||
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
|
||||
proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint,
|
||||
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
|
||||
piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
|
||||
dynlib: dllname, importc: "wglChoosePixelFormatARB".}
|
||||
const
|
||||
const
|
||||
WGL_ERROR_INVALID_PIXEL_TYPE_ARB* = 0x00002043
|
||||
WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB* = 0x00002054
|
||||
|
||||
proc wglMakeContextCurrentARB*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
|
||||
dynlib: dllname, importc: "wglMakeContextCurrentARB".}
|
||||
proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname,
|
||||
proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname,
|
||||
importc: "wglGetCurrentReadDCARB".}
|
||||
const
|
||||
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
|
||||
|
|
@ -139,22 +139,22 @@ const
|
|||
WGL_PBUFFER_HEIGHT_ARB* = 0x00002035
|
||||
WGL_PBUFFER_LOST_ARB* = 0x00002036
|
||||
|
||||
proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint,
|
||||
proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint,
|
||||
iHeight: TGLint, piAttribList: PGLint): THandle{.
|
||||
dynlib: dllname, importc: "wglCreatePbufferARB".}
|
||||
proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname,
|
||||
proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname,
|
||||
importc: "wglGetPbufferDCARB".}
|
||||
proc wglReleasePbufferDCARB*(hPbuffer: THandle, hDC: HDC): TGLint{.
|
||||
dynlib: dllname, importc: "wglReleasePbufferDCARB".}
|
||||
proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname,
|
||||
proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname,
|
||||
importc: "wglDestroyPbufferARB".}
|
||||
proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglQueryPbufferARB".}
|
||||
proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname,
|
||||
proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglSwapIntervalEXT".}
|
||||
proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname,
|
||||
proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname,
|
||||
importc: "wglGetSwapIntervalEXT".}
|
||||
const
|
||||
const
|
||||
WGL_BIND_TO_TEXTURE_RGB_ARB* = 0x00002070
|
||||
WGL_BIND_TO_TEXTURE_RGBA_ARB* = 0x00002071
|
||||
WGL_TEXTURE_FORMAT_ARB* = 0x00002072
|
||||
|
|
@ -195,13 +195,13 @@ proc wglReleaseTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{.
|
|||
dynlib: dllname, importc: "wglReleaseTexImageARB".}
|
||||
proc wglSetPbufferAttribARB*(hPbuffer: THandle, piAttribList: PGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglSetPbufferAttribARB".}
|
||||
proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname,
|
||||
proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname,
|
||||
importc: "wglGetExtensionsStringEXT".}
|
||||
proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
|
||||
dynlib: dllname, importc: "wglMakeContextCurrentEXT".}
|
||||
proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname,
|
||||
proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname,
|
||||
importc: "wglGetCurrentReadDCEXT".}
|
||||
const
|
||||
const
|
||||
WGL_DRAW_TO_PBUFFER_EXT* = 0x0000202D
|
||||
WGL_MAX_PBUFFER_PIXELS_EXT* = 0x0000202E
|
||||
WGL_MAX_PBUFFER_WIDTH_EXT* = 0x0000202F
|
||||
|
|
@ -212,18 +212,18 @@ const
|
|||
WGL_PBUFFER_WIDTH_EXT* = 0x00002034
|
||||
WGL_PBUFFER_HEIGHT_EXT* = 0x00002035
|
||||
|
||||
proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint,
|
||||
proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint,
|
||||
iHeight: TGLint, piAttribList: PGLint): THandle{.
|
||||
dynlib: dllname, importc: "wglCreatePbufferEXT".}
|
||||
proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname,
|
||||
proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname,
|
||||
importc: "wglGetPbufferDCEXT".}
|
||||
proc wglReleasePbufferDCEXT*(hPbuffer: THandle, hDC: HDC): TGLint{.
|
||||
dynlib: dllname, importc: "wglReleasePbufferDCEXT".}
|
||||
proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname,
|
||||
proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname,
|
||||
importc: "wglDestroyPbufferEXT".}
|
||||
proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglQueryPbufferEXT".}
|
||||
const
|
||||
const
|
||||
WGL_NUMBER_PIXEL_FORMATS_EXT* = 0x00002000
|
||||
WGL_DRAW_TO_WINDOW_EXT* = 0x00002001
|
||||
WGL_DRAW_TO_BITMAP_EXT* = 0x00002002
|
||||
|
|
@ -270,47 +270,47 @@ const
|
|||
WGL_TYPE_RGBA_EXT* = 0x0000202B
|
||||
WGL_TYPE_COLORINDEX_EXT* = 0x0000202C
|
||||
|
||||
proc wglGetPixelFormatAttribivEXT*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
proc wglGetPixelFormatAttribivEXT*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
piAttributes: PGLint, piValues: PGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetPixelFormatAttribivEXT".}
|
||||
proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetPixelFormatAttribfvEXT".}
|
||||
proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint,
|
||||
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
|
||||
proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint,
|
||||
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
|
||||
piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
|
||||
dynlib: dllname, importc: "wglChoosePixelFormatEXT".}
|
||||
const
|
||||
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,
|
||||
proc wglGetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglGetDigitalVideoParametersI3D".}
|
||||
proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglSetDigitalVideoParametersI3D".}
|
||||
const
|
||||
const
|
||||
WGL_GAMMA_TABLE_SIZE_I3D* = 0x0000204E
|
||||
WGL_GAMMA_EXCLUDE_DESKTOP_I3D* = 0x0000204F
|
||||
|
||||
proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglGetGammaTableParametersI3D".}
|
||||
proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglSetGammaTableParametersI3D".}
|
||||
proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
|
||||
proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
|
||||
puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetGammaTableI3D".}
|
||||
proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
|
||||
proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
|
||||
puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
|
||||
dynlib: dllname, importc: "wglSetGammaTableI3D".}
|
||||
const
|
||||
const
|
||||
WGL_GENLOCK_SOURCE_MULTIVIEW_I3D* = 0x00002044
|
||||
WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D* = 0x00002045
|
||||
WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D* = 0x00002046
|
||||
|
|
@ -330,21 +330,21 @@ const
|
|||
WGL_TEXTURE_FLOAT_RGB_NV* = 0x000020B7
|
||||
WGL_TEXTURE_FLOAT_RGBA_NV* = 0x000020B8
|
||||
|
||||
proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname,
|
||||
proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname,
|
||||
importc: "wglEnableGenlockI3D".}
|
||||
proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname,
|
||||
proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname,
|
||||
importc: "wglDisableGenlockI3D".}
|
||||
proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||
proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||
importc: "wglIsEnabledGenlockI3D".}
|
||||
proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname,
|
||||
proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname,
|
||||
importc: "wglGenlockSourceI3D".}
|
||||
proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname,
|
||||
proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname,
|
||||
importc: "wglGetGenlockSourceI3D".}
|
||||
proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname,
|
||||
proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname,
|
||||
importc: "wglGenlockSourceEdgeI3D".}
|
||||
proc wglGetGenlockSourceEdgeI3D*(hDC: HDC, uEdge: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetGenlockSourceEdgeI3D".}
|
||||
proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname,
|
||||
proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname,
|
||||
importc: "wglGenlockSampleRateI3D".}
|
||||
proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetGenlockSampleRateI3D".}
|
||||
|
|
@ -352,15 +352,15 @@ proc wglGenlockSourceDelayI3D*(hDC: HDC, uDelay: TGLuint): BOOL{.
|
|||
dynlib: dllname, importc: "wglGenlockSourceDelayI3D".}
|
||||
proc wglGetGenlockSourceDelayI3D*(hDC: HDC, uDelay: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetGenlockSourceDelayI3D".}
|
||||
proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT,
|
||||
proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT,
|
||||
uMaxPixelDelay: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc: "wglQueryGenlockMaxSourceDelayI3D".}
|
||||
const
|
||||
const
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV* = 0x000020A0
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV* = 0x000020A1
|
||||
WGL_TEXTURE_RECTANGLE_NV* = 0x000020A2
|
||||
|
||||
const
|
||||
const
|
||||
WGL_RGBA_FLOAT_MODE_ATI* = 0x00008820
|
||||
WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI* = 0x00008835
|
||||
WGL_TYPE_RGBA_FLOAT_ATI* = 0x000021A0
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ proc uncompress*(source: string, destLen: var int): string =
|
|||
var res = zlib.uncompress(cstring(result), addr destLen, cstring(source), source.len)
|
||||
if res != Z_OK:
|
||||
echo "Error occurred: ", res
|
||||
|
||||
|
||||
|
||||
when isMainModule:
|
||||
import strutils
|
||||
|
|
@ -37,4 +37,4 @@ when isMainModule:
|
|||
ln = s.len
|
||||
rr = uncompress(r, ln)
|
||||
echo r.len, " -> ", rr.len
|
||||
assert rr == s
|
||||
assert rr == s
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ var
|
|||
## I was high.
|
||||
clients = initTable[TupAddress, PClient](16)
|
||||
alias2client = initTable[string, PClient](32)
|
||||
allClients: seq[PClient] = @[]
|
||||
allClients: seq[PClient] = @[]
|
||||
|
||||
proc findClient*(host: string; port: int16): PClient =
|
||||
let addy: TupAddress = (host, port)
|
||||
|
|
@ -37,7 +37,7 @@ proc loginZone(client: PClient; login: SdZoneLogin): bool =
|
|||
result = true
|
||||
break
|
||||
|
||||
proc sendZoneList(client: PClient) =
|
||||
proc sendZoneList(client: PClient) =
|
||||
echo(">> zonelist ", client, ' ', HZoneList)
|
||||
client.send(HZonelist, zonelist)
|
||||
proc forwardPrivate(rcv: PClient; sender: PClient; txt: string) =
|
||||
|
|
@ -93,7 +93,7 @@ proc sendServMsg(client: PClient; msg: string) =
|
|||
var m = newDsMsg(msg)
|
||||
client.send HDsMsg, m
|
||||
handlers[HZoneLogin] = proc(client: PClient; stream: PStream) =
|
||||
var
|
||||
var
|
||||
login = readSdZoneLogin(stream)
|
||||
if not client.loginZone(login):
|
||||
client.sendServMsg "Invalid login"
|
||||
|
|
@ -110,7 +110,7 @@ handlers[HFileChallenge] = proc(client: PClient; stream: PStream) =
|
|||
var chg = readScFileChallenge(stream)
|
||||
|
||||
proc handlePkt(s: PClient; stream: PStream) =
|
||||
while not stream.atEnd:
|
||||
while not stream.atEnd:
|
||||
var typ = readChar(stream)
|
||||
if not handlers.hasKey(typ):
|
||||
break
|
||||
|
|
@ -128,7 +128,7 @@ var clientIndex = 0
|
|||
var incoming = newIncomingBuffer()
|
||||
proc poll*(timeout: int = 250) =
|
||||
if server.isNil: return
|
||||
var
|
||||
var
|
||||
reads = @[server]
|
||||
writes = @[server]
|
||||
if select(reads, timeout) > 0:
|
||||
|
|
@ -163,7 +163,7 @@ when isMainModule:
|
|||
case kind
|
||||
of cmdShortOption, cmdLongOption:
|
||||
case key
|
||||
of "f", "file":
|
||||
of "f", "file":
|
||||
if existsFile(val):
|
||||
cfgFile = val
|
||||
else:
|
||||
|
|
@ -177,14 +177,14 @@ when isMainModule:
|
|||
zonelist.network = jsonSettings["network"].str
|
||||
for slot in jsonSettings["zones"].items:
|
||||
zoneSlots.add((slot["name"].str, slot["key"].str))
|
||||
|
||||
|
||||
createServer(port)
|
||||
echo("Listening on port ", port, "...")
|
||||
var pubChatTimer = cpuTime() #newClock()
|
||||
const PubChatDelay = 1000/1000
|
||||
while true:
|
||||
poll(15)
|
||||
## TODO sort this type of thing VV into a queue api
|
||||
## TODO sort this type of thing VV into a queue api
|
||||
if cpuTime() - pubChatTimer > PubChatDelay: #.getElapsedTime.asMilliseconds > 100:
|
||||
pubChatTimer -= pubChatDelay
|
||||
if pubChatQueue.getPosition > 0:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import
|
||||
import
|
||||
streams, md5, sockets, unsigned,
|
||||
sg_packets, zlib_helpers, idgen
|
||||
type
|
||||
|
|
@ -54,7 +54,7 @@ proc newClient*(addy: TupAddress): PClient =
|
|||
new(result, free)
|
||||
result.addy = addy
|
||||
result.outputBuf = newStringStream("")
|
||||
result.outputBuf.flushImpl = proc(stream: PStream) =
|
||||
result.outputBuf.flushImpl = proc(stream: PStream) =
|
||||
stream.setPosition 0
|
||||
PStringStream(stream).data.setLen 0
|
||||
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ var
|
|||
## I was high.
|
||||
clients = initTable[TupAddress, PClient](16)
|
||||
alias2client = initTable[string, PClient](32)
|
||||
allClients: seq[PClient] = @[]
|
||||
zonePlayers: seq[PClient] = @[]
|
||||
allClients: seq[PClient] = @[]
|
||||
zonePlayers: seq[PClient] = @[]
|
||||
const
|
||||
PubChatDelay = 100/1000 #100 ms
|
||||
|
||||
import hashes
|
||||
proc hash*(x: uint16): THash {.inline.} =
|
||||
proc hash*(x: uint16): THash {.inline.} =
|
||||
result = int32(x)
|
||||
|
||||
proc findClient*(host: string; port: int16): PClient =
|
||||
|
|
@ -27,7 +27,7 @@ proc findClient*(host: string; port: int16): PClient =
|
|||
allClients.add(result)
|
||||
|
||||
|
||||
proc sendZoneList(client: PClient) =
|
||||
proc sendZoneList(client: PClient) =
|
||||
echo(">> zonelist ", client)
|
||||
#client.send(HZonelist, zonelist)
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ handlers[HZoneQuery] = proc(client: PClient; stream: PStream) =
|
|||
|
||||
handlers[HZoneJoinReq] = proc(client: PClient; stream: PStream) =
|
||||
var req = readCsZoneJoinReq(stream)
|
||||
echo "Join zone request from (",req.session.id,") ", req.session.alias
|
||||
echo "Join zone request from (",req.session.id,") ", req.session.alias
|
||||
if client.auth and client.kind == CPlayer:
|
||||
echo "Client is authenticated, verifying filez"
|
||||
client.startVerifyingFiles()
|
||||
|
|
@ -97,7 +97,7 @@ handlers[HZoneJoinReq] = proc(client: PClient; stream: PStream) =
|
|||
|
||||
|
||||
proc handlePkt(s: PClient; stream: PStream) =
|
||||
while not stream.atEnd:
|
||||
while not stream.atEnd:
|
||||
var typ = readChar(stream)
|
||||
if not handlers.hasKey(typ):
|
||||
break
|
||||
|
|
@ -114,7 +114,7 @@ var clientIndex = 0
|
|||
var incoming = newIncomingBuffer()
|
||||
proc poll*(timeout: int = 250) =
|
||||
if server.isNil: return
|
||||
var
|
||||
var
|
||||
reads = @[server]
|
||||
writes = @[server]
|
||||
if select(reads, timeout) > 0:
|
||||
|
|
@ -148,7 +148,7 @@ when isMainModule:
|
|||
case kind
|
||||
of cmdShortOption, cmdLongOption:
|
||||
case key
|
||||
of "f", "file":
|
||||
of "f", "file":
|
||||
if existsFile(val):
|
||||
zoneCfgFile = val
|
||||
else:
|
||||
|
|
@ -158,45 +158,45 @@ when isMainModule:
|
|||
else:
|
||||
echo("Unknown option: ", key, " ", val)
|
||||
var jsonSettings = parseFile(zoneCfgFile)
|
||||
let
|
||||
let
|
||||
host = jsonSettings["host"].str
|
||||
port = TPort(jsonSettings["port"].num)
|
||||
zoneFile = jsonSettings["settings"].str
|
||||
dirServerInfo = jsonSettings["dirserver"]
|
||||
|
||||
|
||||
var path = getAppDir()/../"data"/zoneFile
|
||||
if not existsFile(path):
|
||||
echo("Zone settings file does not exist: ../data/", zoneFile)
|
||||
echo(path)
|
||||
quit(1)
|
||||
|
||||
|
||||
## Test file
|
||||
block:
|
||||
var
|
||||
var
|
||||
TestFile: FileChallengePair
|
||||
contents = repeat("abcdefghijklmnopqrstuvwxyz", 2)
|
||||
testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32)
|
||||
testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32)
|
||||
testFile.file = checksumStr(contents)
|
||||
myAssets.add testFile
|
||||
|
||||
|
||||
setCurrentDir getAppDir().parentDir()
|
||||
block:
|
||||
let zonesettings = readFile(path)
|
||||
var
|
||||
var
|
||||
errors: seq[string] = @[]
|
||||
if not loadSettings(zoneSettings, errors):
|
||||
echo("You have errors in your zone settings:")
|
||||
for e in errors: echo("**", e)
|
||||
quit(1)
|
||||
errors.setLen 0
|
||||
|
||||
|
||||
var pair: FileChallengePair
|
||||
pair.challenge.file = zoneFile
|
||||
pair.challenge.assetType = FZoneCfg
|
||||
pair.challenge.fullLen = zoneSettings.len.int32
|
||||
pair.file = checksumStr(zoneSettings)
|
||||
myAssets.add pair
|
||||
|
||||
|
||||
allAssets:
|
||||
if not load(asset):
|
||||
echo "Invalid or missing file ", file
|
||||
|
|
@ -208,10 +208,10 @@ when isMainModule:
|
|||
expandPath(assetType, file)).int32
|
||||
pair.file = asset.contents
|
||||
myAssets.add pair
|
||||
|
||||
|
||||
echo "Zone has ", myAssets.len, " associated assets"
|
||||
|
||||
|
||||
|
||||
|
||||
dirServer = newServerConnection(dirServerInfo[0].str, dirServerInfo[1].num.TPort)
|
||||
dirServer.handlers[HDsMsg] = proc(serv: PServer; stream: PStream) =
|
||||
var m = readDsMsg(stream)
|
||||
|
|
@ -221,18 +221,18 @@ when isMainModule:
|
|||
if loggedIn:
|
||||
dirServerConnected = true
|
||||
dirServer.writePkt HZoneLogin, login
|
||||
|
||||
|
||||
thisZone.name = jsonSettings["name"].str
|
||||
thisZone.desc = jsonSettings["desc"].str
|
||||
thisZone.ip = "localhost"
|
||||
thisZone.port = port
|
||||
var login = newSdZoneLogin(
|
||||
dirServerInfo[2].str, dirServerInfo[3].str,
|
||||
thisZone)
|
||||
thisZone)
|
||||
#echo "MY LOGIN: ", $login
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
createServer(port)
|
||||
echo("Listening on port ", port, "...")
|
||||
var pubChatTimer = cpuTime()#newClock()
|
||||
|
|
@ -240,7 +240,7 @@ when isMainModule:
|
|||
discard dirServer.pollServer(15)
|
||||
poll(15)
|
||||
## TODO sort this type of thing VV into a queue api
|
||||
#let now = cpuTime()
|
||||
#let now = cpuTime()
|
||||
if cpuTime() - pubChatTimer > PubChatDelay: #.getElapsedTime.asMilliseconds > 100:
|
||||
pubChatTimer -= pubChatDelay #.restart()
|
||||
if pubChatQueue.getPosition > 0:
|
||||
|
|
@ -250,5 +250,5 @@ when isMainModule:
|
|||
c.outputBuf.writeData(addr pubChatQueue.data[0], sizePubChat)
|
||||
pubChatQueue.flush()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import
|
||||
sockets, streams, tables, times, math, strutils, json, os, md5,
|
||||
sfml, sfml_vector, sfml_colors,
|
||||
sockets, streams, tables, times, math, strutils, json, os, md5,
|
||||
sfml, sfml_vector, sfml_colors,
|
||||
streams_enh, input_helpers, zlib_helpers, client_helpers, sg_packets, sg_assets, sg_gui
|
||||
type
|
||||
TClientSettings = object
|
||||
|
|
@ -33,7 +33,7 @@ var
|
|||
downloadProgress: PButton
|
||||
connectionButtons: seq[PButton] #buttons that depend on connection to function
|
||||
|
||||
template dispmessage(m: expr): stmt =
|
||||
template dispmessage(m: expr): stmt =
|
||||
messageArea.add(m)
|
||||
proc connectZone(host: string; port: TPort)
|
||||
proc connectToDirserv()
|
||||
|
|
@ -63,7 +63,7 @@ proc handleChat(serv: PServer; s: PStream) =
|
|||
proc connectToDirserv() =
|
||||
if dirServer.isNil:
|
||||
dirServer = newServerConnection(clientSettings.dirserver.host, clientSettings.dirserver.port)
|
||||
dirServer.handlers[HHello] = proc(serv: PServer; s: PStream) =
|
||||
dirServer.handlers[HHello] = proc(serv: PServer; s: PStream) =
|
||||
let msg = readScHello(s)
|
||||
dispMessage(msg.resp)
|
||||
setConnected(true)
|
||||
|
|
@ -71,7 +71,7 @@ proc connectToDirserv() =
|
|||
mySession = readScLogin(s)
|
||||
##do something here
|
||||
dirServer.handlers[HZonelist] = proc(serv: PServer; s: PStream) =
|
||||
var
|
||||
var
|
||||
info = readScZonelist(s)
|
||||
zones = info.zones
|
||||
if zones.len > 0:
|
||||
|
|
@ -87,11 +87,11 @@ proc connectToDirserv() =
|
|||
var z = zones[i]
|
||||
zonelist.newButton(
|
||||
text = z.name, position = pos,
|
||||
onClick = proc(b: PButton) =
|
||||
onClick = proc(b: PButton) =
|
||||
setActiveZone(i, z))
|
||||
pos.y += 20
|
||||
showZonelist = true
|
||||
dirServer.handlers[HPoing] = proc(serv: PServer; s: PStream) =
|
||||
dirServer.handlers[HPoing] = proc(serv: PServer; s: PStream) =
|
||||
var ping = readPoing(s)
|
||||
dispmessage("Ping: "& $ping.time)
|
||||
ping.time = epochTime().float32
|
||||
|
|
@ -108,19 +108,19 @@ proc zoneListReq() =
|
|||
writePkt HZonelist, pkt
|
||||
|
||||
##key handlers
|
||||
keyClient.registerHandler(MouseMiddle, down, proc() =
|
||||
keyClient.registerHandler(MouseMiddle, down, proc() =
|
||||
gui.setPosition(getMousePos()))
|
||||
|
||||
keyClient.registerHandler(KeyO, down, proc() =
|
||||
keyClient.registerHandler(KeyO, down, proc() =
|
||||
if keyPressed(KeyRShift): echo(repr(outgoing)))
|
||||
keyClient.registerHandler(KeyTab, down, proc() =
|
||||
activeInput = (activeInput + 1) mod 2) #does this work?
|
||||
keyClient.registerHandler(MouseLeft, down, proc() =
|
||||
keyClient.registerHandler(MouseLeft, down, proc() =
|
||||
let p = getMousePos()
|
||||
gui.click(p)
|
||||
if showZonelist: zonelist.click(p))
|
||||
var mptext = newText("", guiFont, 16)
|
||||
keyClient.registerHandler(MouseRight, down, proc() =
|
||||
keyClient.registerHandler(MouseRight, down, proc() =
|
||||
let p = getMousePos()
|
||||
mptext.setPosition(p)
|
||||
mptext.setString("($1,$2)"%[$p.x.int,$p.y.int]))
|
||||
|
|
@ -133,15 +133,15 @@ proc connectZone(host: string, port: TPort) =
|
|||
zone.handlers[HFileChallenge] = handleFileChallenge
|
||||
zone.handlers[HChallengeResult] = handleFileChallengeResult
|
||||
zone.handlers[HFileTransfer] = handleFileTransfer
|
||||
zone.handlers[HChat] = handleChat
|
||||
zone.handlers[HChat] = handleChat
|
||||
else:
|
||||
zone.sock.connect(host, port)
|
||||
var hello = newCsHello()
|
||||
zone.writePkt HHello, hello
|
||||
|
||||
|
||||
|
||||
proc lobbyReady*() =
|
||||
|
||||
proc lobbyReady*() =
|
||||
keyClient.setActive()
|
||||
gui.setActive(u_alias)
|
||||
|
||||
|
|
@ -186,27 +186,27 @@ proc lobbyInit*() =
|
|||
clientSettings.website = s["website"].str
|
||||
zonelist.setPosition(vec2f(200.0, 100.0))
|
||||
connectionButtons = @[]
|
||||
|
||||
|
||||
downloadProgress = gui.newButton(
|
||||
text = "", position = vec2f(10, 130), onClick = nil)
|
||||
text = "", position = vec2f(10, 130), onClick = nil)
|
||||
downloadProgress.bg.setFillColor(color(34, 139, 34))
|
||||
downloadProgress.bg.setSize(vec2f(0, 0))
|
||||
|
||||
|
||||
var pos = vec2f(10, 10)
|
||||
u_alias = gui.newTextEntry(
|
||||
if s.existsKey("alias"): s["alias"].str else: "alias",
|
||||
if s.existsKey("alias"): s["alias"].str else: "alias",
|
||||
pos)
|
||||
pos.y += 20
|
||||
u_passwd = gui.newTextEntry("buzz", pos)
|
||||
pos.y += 20
|
||||
connectionButtons.add(gui.newButton(
|
||||
text = "Login",
|
||||
text = "Login",
|
||||
position = pos,
|
||||
onClick = tryLogin,
|
||||
startEnabled = false))
|
||||
pos.y += 20
|
||||
fpsText.setPosition(pos)
|
||||
|
||||
|
||||
playBtn = gui.newButton(
|
||||
text = "Play",
|
||||
position = vec2f(680.0, 8.0),
|
||||
|
|
@ -227,7 +227,7 @@ proc lobbyInit*() =
|
|||
connectionButtons.add(gui.newButton(
|
||||
text = "Test Chat",
|
||||
position = vec2f(10.0, 110.0),
|
||||
onClick = (proc(b: PButton) =
|
||||
onClick = (proc(b: PButton) =
|
||||
var pkt = newCsChat(text = "ohai")
|
||||
writePkt HChat, pkt),
|
||||
startEnabled = false))
|
||||
|
|
@ -239,15 +239,15 @@ proc lobbyInit*() =
|
|||
gui.newButton(text = "Scrollback + 1", position = vec2f(185, 10), onClick = proc(b: PButton) =
|
||||
messageArea.scrollBack += 1
|
||||
update(messageArea))
|
||||
gui.newButton(text = "Scrollback - 1", position = vec2f(185+160, 10), onClick = proc(b: PButton) =
|
||||
gui.newButton(text = "Scrollback - 1", position = vec2f(185+160, 10), onClick = proc(b: PButton) =
|
||||
messageArea.scrollBack -= 1
|
||||
update(messageArea))
|
||||
gui.newButton(text = "Flood msg area", position = vec2f(185, 30), onClick = proc(b: PButton) =
|
||||
for i in 0.. <30:
|
||||
for i in 0.. <30:
|
||||
dispMessage($i))
|
||||
|
||||
var i = 0
|
||||
proc lobbyUpdate*(dt: float) =
|
||||
proc lobbyUpdate*(dt: float) =
|
||||
#let res = disp.poll()
|
||||
gui.update(dt)
|
||||
i = (i + 1) mod 60
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ DO AS THOU WILST PUBLIC LICENSE
|
|||
|
||||
Whoever should stumble upon this document is henceforth and forever
|
||||
entitled to DO AS THOU WILST with aforementioned document and the
|
||||
contents thereof.
|
||||
contents thereof.
|
||||
|
||||
As said in the Olde Country, `Keepe it Gangster'."""
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ type
|
|||
desc*: string
|
||||
action*: TTaskFunction
|
||||
TTaskFunction* = proc() {.closure.}
|
||||
var
|
||||
var
|
||||
tasks* = initTable[string, PTask](16)
|
||||
|
||||
proc newTask*(desc: string; action: TTaskFunction): PTask
|
||||
|
|
@ -61,7 +61,7 @@ when isMainModule:
|
|||
quit(shell("nim", "c", "-r", "nakefile.nim", args))
|
||||
else:
|
||||
addQuitProc(proc() {.noconv.} =
|
||||
var
|
||||
var
|
||||
task: string
|
||||
printTaskList: bool
|
||||
for kind, key, val in getOpt():
|
||||
|
|
@ -70,7 +70,7 @@ else:
|
|||
case key.tolower
|
||||
of "tasks", "t":
|
||||
printTaskList = true
|
||||
else:
|
||||
else:
|
||||
echo "Unknown option: ", key, ": ", val
|
||||
of cmdArgument:
|
||||
task = key
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ nakeImports
|
|||
|
||||
randomize()
|
||||
|
||||
const
|
||||
const
|
||||
GameAssets = "http://dl.dropbox.com/u/37533467/data-08-01-2012.7z"
|
||||
BinLibs = "http://dl.dropbox.com/u/37533467/libs-2012-09-12.zip"
|
||||
ExeName = "keineschweine"
|
||||
|
|
@ -60,7 +60,7 @@ task "release", "release build":
|
|||
quit 1
|
||||
else:
|
||||
runTask "clean"
|
||||
## zip up all the files and such or something useful here
|
||||
## zip up all the files and such or something useful here
|
||||
|
||||
task "testskel", "create skeleton test dir for testing":
|
||||
let dirname = "test-"& $random(5000)
|
||||
|
|
@ -103,7 +103,7 @@ task "download", "download game assets":
|
|||
echo "Downloading to ", path
|
||||
downloadFile GameAssets, path
|
||||
echo "Download finished"
|
||||
|
||||
|
||||
let targetDir = parentDir(parentDir(path))
|
||||
when defined(linux):
|
||||
let z7 = findExe("7z")
|
||||
|
|
@ -117,7 +117,7 @@ task "download", "download game assets":
|
|||
else:
|
||||
echo "I do not know how to unpack the data on this system. Perhaps you could ",
|
||||
"fill this part in?"
|
||||
|
||||
|
||||
echo "Download binary libs? Only libs for linux are available currently, enjoy the irony.\n",
|
||||
"[Y]es [N]o Source: ", BinLibs
|
||||
case stdin.readline.toLower
|
||||
|
|
@ -126,11 +126,11 @@ task "download", "download game assets":
|
|||
else:
|
||||
return
|
||||
path = extractFilename(BinLibs)
|
||||
downloadFile BinLibs, path
|
||||
downloadFile BinLibs, path
|
||||
echo "Downloaded dem libs ", path
|
||||
when true: echo "Unpack it yourself, sorry."
|
||||
else: ## this crashes, dunno why
|
||||
var
|
||||
var
|
||||
z: TZipArchive
|
||||
destDir = getCurrentDir()/("unzip"& $random(5000))
|
||||
if not z.open(path, fmRead):
|
||||
|
|
@ -152,4 +152,4 @@ task "zip-lib", "zip up the libs dir":
|
|||
echo "adding file ", file
|
||||
z.addFile(file)
|
||||
z.close()
|
||||
echo "Great success!"
|
||||
echo "Great success!"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue