OK, Santa's coming, the wifies asking what Id like, the GPX F200 looks like a fun toy... anyone got one and would like to share their experiences before we buy?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuCurrent Version:
5.055000
Opening Internet-Connection
Opening Info-File
Reading Update Information
Version:
4.279
No Update available. GLBasic is up to date.
Ende.
?
DEBUG "MX: "+mx +","
DEBUG "MY: "+my+","
produces...MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,MX: 0,MY: 0,
...with the debug console scrolling continuously DEBUGCLS
DEBUG "MX: "+mx +","
DEBUG "MY: "+my
MX: 0,MY: 0
or DEBUGCLS
DEBUG "Mouse Co-Ordinates"+"\n"
DEBUG "------------------"+"\n"
DEBUG "MX: "+mx +"\n"
DEBUG "MY: "+my+"\n"
produces... Mouse Co-Ordinates
------------------
MX: 0
MY: 0
Just a suggestion
INLINE
bool LoadFile(char *filename)
{
return true;
}
ENDINLINE
ENDFUNCTION
How do I call the above inline C subroutine from GLBasic with the correct parameter and types...?#include // Header File For Standard Input / Output
WHILE TRUE
X_MAKE3D 1,5500,45
X_DRAWAXES 0,0,-100
// X_PRINT "test",0,0,-50,0.3 // Unremark this line to see bug...
X_DRAWAXES 10,10,-100
SHOWSCREEN
WEND
TYPE Tmytype
foo$
ENDTYPE
GLOBAL testvar AS Tmytype
WHILE 1
myfunc(testvar)
WEND
FUNCTION myfunc: BYREF a AS Tmytype
a.foo$ = "Foo!"
ENDFUNCTION
... probably me doing something silly? I want to pass a custom type 'byref'...?*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.2007.095 - 3D, NET
"test.gbas"(14) error : wrong argument type : myfunc, arg no: 1
// View code
TYPE Tvector
x
y
z
magnitude
ENDTYPE
GLOBAL cam_pos AS Tvector; cam_pos.x = 0; cam_pos.y = 0; cam_pos.z = 0 // Camera position
GLOBAL cam_vec AS Tvector; cam_vec.x = 0; cam_vec.y = 0; cam_vec.z = 0 // Camera angle
// Mouse look along vector code...
MOUSESTATE mx, my, b1, b2
cam_vec.x = 0; cam_vec.y = 0; cam_vec.z = -1 // Initial view
mx=(mx/800)*3600 // Get an x rotation value
my=(my/600)*3600 // Get an y rotation value
cam_vec = Vector_RotateAroundY(cam_vec, mx/10) // Rotatate around x axis
cam_vec = Vector_RotateAroundX(cam_vec, my/10) // Rotate around y axis
X_CAMERA cam_pos.x, cam_pos.y, cam_pos.z, cam_vec.x, cam_vec.y, cam_vec.z
Functions from the vector lib.FUNCTION Vector_RotateAroundX AS Tvector: vec1 AS Tvector, angle
LOCAL result AS Tvector
result.x = vec1.x
result.y = COS(angle) * vec1.y - SIN(angle) * vec1.z
result.z = SIN(angle) * vec1.y + COS(angle) * vec1.z
RETURN result
ENDFUNCTION
FUNCTION Vector_RotateAroundY AS Tvector: vec1 AS Tvector, angle
LOCAL result AS Tvector
result.x = COS(angle) * vec1.x + SIN(angle) * vec1.z
result.y = vec1.y
result.z = -SIN(angle) * vec1.x + COS(angle) * vec1.z
RETURN result
ENDFUNCTION
FUNCTION Vector_RotateAroundZ AS Tvector: vec1 AS Tvector, angle
LOCAL result AS Tvector
result.x = COS(angle) * vec1.x - SIN(angle) * vec1.y
result.y = SIN(angle) * vec1.x + COS(angle) * vec1.y
result.z = vec1.z
RETURN result
ENDFUNCTION
TYPE Tvector
x
y
z
magnitude
ENDTYPE
FUNCTION vector_new AS Tvector: x,y,z,m
LOCAL result AS Tvector
result.x=x
result.y=y
result.z=z
result.magnitude=m
RETURN result
ENDFUNCTION
FUNCTION add_to_particles_array: a, b, vec AS Tvector
ENDFUNCTION
FUNCTION testf:
add_to_particles_array(1, 1, vector_new(100,100,0,0))
ENDFUNCTION
produces this error..._______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.2007.083 - 3D, NET
Wordcount:8 commands
compiling:
C:/DOCUME~1/Dad/LOCALS~1/Temp/glbasic/gpc_temp0.cpp: In function `DGInt __GLBASIC__::testf()':
C:/DOCUME~1/Dad/LOCALS~1/Temp/glbasic/gpc_temp0.cpp:35: error: invalid initialization of non-const reference of type '__GLBASIC__::Tvector&' from a temporary of type '__GLBASIC__::Tvector'
C:/DOCUME~1/Dad/LOCALS~1/Temp/glbasic/gpc_temp0.cpp:29: error: in passing argument 3 of `DGInt __GLBASIC__::add_to_particles_array(DGInt, DGInt, __GLBASIC__::Tvector&)'
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Time: 0.8 sec
Build: 0 succeeded
*** 1 FAILED ***
This is a small section of offending code I've tried to cut out of my own program... I must be doing this wrong?// --------------------------------- //
// Project: VectorLIB
// Start: Wednesday, March 28, 2007
// IDE Version: 4.132
FUNCTION setup_veclib:
//used TO normalize vector
GLOBAL vector_tol = 0.0001
ENDFUNCTION
TYPE Tvector
x
y
z
magnitude
ENDTYPE
FUNCTION vector_calcMagnitude: vec AS Tvector
//calc the magnitude of a vector AND stor in vector
vec.magnitude=SQR(vec.x*vec.x + vec.y*vec.y + vec.z*vec.z)
ENDFUNCTION
FUNCTION vector_normalize: vec AS Tvector
LOCAL m
//normalize a vector so it's length = 1 AND apply tolerance based on our constant tolerance value
m=SQR(SQR(vec.x*vec.x + vec.y*vec.y + vec.z*vec.z) )
IF m<= vector_tol THEN m=1
vec.x=vec.x/m
vec.y=vec.y/m
vec.z=vec.z/m
IF ABS(vec.x) IF ABS(vec.y) IF ABS(vec.z)ENDFUNCTION
FUNCTION vector_reverse: vec AS Tvector
//reverse a vector
vec.x=-vec.x
vec.y=-vec.y
vec.z=-vec.z
ENDFUNCTION
FUNCTION vector_add AS Tvector: vec1 AS Tvector, vec2 AS Tvector
//add two vectors together AND RETURN the resulting vector
LOCAL result AS Tvector
result.x=vec1.x+vec2.x
result.y=vec1.y+vec2.y
result.z=vec1.z+vec2.z
RETURN result
ENDFUNCTION
FUNCTION vector_subtract AS Tvector: vec1 AS Tvector, vec2 AS Tvector
//subtract vec1 from vec2 AND RETURN the resulting vector
LOCAL result AS Tvector
result.x=vec1.x-vec2.x
result.y=vec1.y-vec2.y
result.z=vec1.z-vec2.z
RETURN result
ENDFUNCTION
FUNCTION vector_scalarMultiply AS Tvector: vec1 AS Tvector, scale
//scalar multiplication of a vector with result returned AS new vector
//used TO scale a vector by 'scale'
LOCAL result AS Tvector
result.x=vec1.x*scale
result.y=vec1.y*scale
result.z=vec1.z*scale
RETURN result
ENDFUNCTION
FUNCTION vector_scalarDivision AS Tvector: vec1 AS Tvector, scale
//scalar division of a vector with result returned AS new vector
//used TO scale a vector
LOCAL result AS Tvector
result.x=vec1.x/scale
result.y=vec1.y/scale
result.z=vec1.z/scale
RETURN result
ENDFUNCTION
FUNCTION vector_conjugate AS Tvector: vec1 AS Tvector
//conjugate operator takes the negative of each vector component
//can be used when subtracting one vector from another OR FOR
//reversing the direction of a vector.
//applying conjugate is the same AS reversing a vector
//returns a new vector
LOCAL result AS Tvector
result.x=-vec1.x
result.y=-vec1.y
result.z=-vec1.z
RETURN result
ENDFUNCTION
FUNCTION vector_crossProduct AS Tvector: vec1 AS Tvector, vec2 AS Tvector
//takes vec1 AND vec2 AND returns the cross product vec1 X vec2
//the cross product is a vector perpendicular TO both vec1 AND vec2
//this is the normal of 2 vectors
LOCAL result AS Tvector
result.x=(vec1.y*vec2.z) - (vec1.z*vec2.y)
result.y=(vec1.z*vec2.x) - (vec1.x*vec2.z)
result.z=(vec1.x*vec2.y) - (vec1.y*vec2.x)
RETURN result
ENDFUNCTION
FUNCTION vector_dotProduct: vec1 AS Tvector, vec2 AS Tvector
//calculate AND RETURN the dot product of 2 vectors (distance)
LOCAL result
result=(vec1.x*vec2.x)+(vec1.y*vec2.y)+(vec1.z*vec2.z)
RETURN result
ENDFUNCTION
FUNCTION vector_tripleScalarProduct: vec1 AS Tvector, vec2 AS Tvector, vec3 AS Tvector
//calculate the triple scalar FUNCTION AND RETURN it
LOCAL result
result= vec1.x * ( (vec2.y*vec3.z ) - (vec2.z * vec3.y) )
result=result + ( vec1.y * ( (-vec2.x*vec3.z) + (vec2.z * vec3.x) ) )
result=result + ( vec1.z * ( ( vec2.x*vec3.y) + (vec2.y * vec3.x) ) )
RETURN result
ENDFUNCTION
// --------------------------------- //
// Project: VectorLIB
// Start: Wednesday, March 28, 2007
// IDE Version: 4.132
FUNCTION setup_veclib:
//used TO normalize vector
GLOBAL vector_tol = 0.0001
ENDFUNCTION
TYPE Tvector
x
y
z
magnitude
ENDTYPE
FUNCTION vector_calcMagnitude: vec AS Tvector
//calc the magnitude of a vector AND stor in vector
vec.magnitude=SQR(vec.x*vec.x + vec.y*vec.y + vec.z*vec.z)
ENDFUNCTION
FUNCTION vector_normalize: vec AS Tvector
LOCAL m
//normalize a vector so it's length = 1 AND apply tolerance based on our constant tolerance value
m=SQR(SQR(vec.x*vec.x + vec.y*vec.y + vec.z*vec.z) )
IF m<= vector_tol THEN m=1
vec.x=vec.x/m
vec.y=vec.y/m
vec.z=vec.z/m
IF ABS(vec.x) IF ABS(vec.y) IF ABS(vec.z)ENDFUNCTION
FUNCTION vector_reverse: vec AS Tvector
//reverse a vector
vec.x=-vec.x
vec.y=-vec.y
vec.z=-vec.z
ENDFUNCTION
FUNCTION vector_add AS Tvector: vec1 AS Tvector, vec2 AS Tvector
//add two vectors together AND RETURN the resulting vector
LOCAL result AS Tvector
result.x=vec1.x+vec2.x
result.y=vec1.y+vec2.y
result.z=vec1.z+vec2.z
RETURN result
ENDFUNCTION
FUNCTION vector_subtract AS Tvector: vec1 AS Tvector, vec2 AS Tvector
//subtract vec1 from vec2 AND RETURN the resulting vector
LOCAL result AS Tvector
result.x=vec1.x-vec2.x
result.y=vec1.y-vec2.y
result.z=vec1.z-vec2.z
RETURN result
ENDFUNCTION
FUNCTION vector_scalarMultiply AS Tvector: vec1 AS Tvector, scale
//scalar multiplication of a vector with result returned AS new vector
//used TO scale a vector by 'scale'
LOCAL result AS Tvector
result.x=vec1.x*scale
result.y=vec1.y*scale
result.z=vec1.z*scale
RETURN result
ENDFUNCTION
FUNCTION vector_scalarDivision AS Tvector: vec1 AS Tvector, scale
//scalar division of a vector with result returned AS new vector
//used TO scale a vector
LOCAL result AS Tvector
result.x=vec1.x/scale
result.y=vec1.y/scale
result.z=vec1.z/scale
RETURN result
ENDFUNCTION
FUNCTION vector_conjugate AS Tvector: vec1 AS Tvector
//conjugate operator takes the negative of each vector component
//can be used when subtracting one vector from another OR FOR
//reversing the direction of a vector.
//applying conjugate is the same AS reversing a vector
//returns a new vector
LOCAL result AS Tvector
result.x=-vec1.x
result.y=-vec1.y
result.z=-vec1.z
RETURN result
ENDFUNCTION
FUNCTION vector_crossProduct AS Tvector: vec1 AS Tvector, vec2 AS Tvector
//takes vec1 AND vec2 AND returns the cross product vec1 X vec2
//the cross product is a vector perpendicular TO both vec1 AND vec2
//this is the normal of 2 vectors
LOCAL result AS Tvector
result.x=(vec1.y*vec2.z) - (vec1.z*vec2.y)
result.y=(vec1.z*vec2.x) - (vec1.x*vec2.z)
result.z=(vec1.x*vec2.y) - (vec1.y*vec2.x)
RETURN result
ENDFUNCTION
FUNCTION vector_dotProduct: vec1 AS Tvector, vec2 AS Tvector
//calculate AND RETURN the dot product of 2 vectors (distance)
LOCAL result
result=(vec1.x*vec2.x)+(vec1.y*vec2.y)+(vec1.z*vec2.z)
RETURN result
ENDFUNCTION
FUNCTION vector_tripleScalarProduct: vec1 AS Tvector, vec2 AS Tvector, vec3 AS Tvector
//calculate the triple scalar FUNCTION AND RETURN it
LOCAL result
result= vec1.x * ( (vec2.y*vec3.z ) - (vec2.z * vec3.y) )
result=result + ( vec1.y * ( (-vec2.x*vec3.z) + (vec2.z * vec3.x) ) )
result=result + ( vec1.z * ( ( vec2.x*vec3.y) + (vec2.y * vec3.x) ) )
RETURN result
ENDFUNCTION