|
Post by Darkjester on Dec 12, 2008 7:55:26 GMT -5
How can i add those blue constants so that i can use them in dll's?
|
|
|
Post by DJLinux on Dec 12, 2008 8:20:43 GMT -5
i use maros register int RIC(NameofTheIntegerConst,123) register float RFC(NameofTheFloatConst,1.23) register string RSC(NameofTheStringConst,"123") Joshy here are my macros /* * File: PluginMacros.h * Author: Joshy (d.j.peters) * * Created on 14. November 2008, 03:52 */
#ifndef _PLUGINMACROS_H #define _PLUGINMACROS_H /* registry helper */ // register int,float,string constant #define RIC(n,v) registry.RegisterIntConstant(#n,v) #define RFC(n,v) registry.RegisterFloatConstant(#n,v) #define RSC(n,v) registry.RegisterStringConstant(#n,v)
// register void int float string function #define RVF(name) registry.RegisterVoidFunction(#name,__##name) //#define RVF2(b4glname,realname) registry.RegisterVoidFunction(#b4glname,__##realname) #define RIF(name) registry.RegisterFunction(#name,__##name, DLL_BASIC4GL_INT) #define RFF(name) registry.RegisterFunction(#name,__##name, DLL_BASIC4GL_FLOAT) #define RSF(name) registry.RegisterFunction(#name,__##name, DLL_BASIC4GL_STRING)
// register int,float,string array function by dimension #define RIAI(name,d) registry.RegisterArrayFunction(#name,__##name,DLL_BASIC4GL_INT,d) #define RFAF(name,d) registry.RegisterArrayFunction(#name,__##name,DLL_BASIC4GL_FLOAT,d) #define RSAF(name,d) registry.RegisterArrayFunction(#name,__##name,DLL_BASIC4GL_STRING,d) // add int float string param #define AIP registry.AddParam(DLL_BASIC4GL_INT) #define AFP registry.AddParam(DLL_BASIC4GL_FLOAT) #define ASP registry.AddParam(DLL_BASIC4GL_STRING) // register int,float,string,struct param as reference #define AIPR registry.AddParam(DLL_BASIC4GL_INT);registry.ModParamReference() #define AFPR registry.AddParam(DLL_BASIC4GL_FLOAT);registry.ModParamReference() #define ASPR registry.AddParam(DLL_BASIC4GL_STRING);registry.ModParamReference() #define ATPR(h) registry.AddStrucParam(_registry,h);registry.ModParamReference() // add int,float,string array param by dimensions #define AIAP(d) registry.AddArrayParam(DLL_BASIC4GL_INT ,d) #define AFAP(d) registry.AddArrayParam(DLL_BASIC4GL_FLOAT ,d) #define ASAP(d) registry.AddArrayParam(DLL_BASIC4GL_STRING,d)
// runtime helper // get int float string parameter #define GI(n) basic4gl.GetIntParam(n) #define GF(n) basic4gl.GetFloatParam(n) #define GS(n) basic4gl.GetStringParam(n)
// declare plugin function #define DPF(name) void DLLFUNC __##name(IDLL_Basic4GL_Runtime &basic4gl)
// get int float array param array() #define GIA(n,pArray,n1) basic4gl.GetIntArrayParam(n,pArray,1,n1) #define GFA(n,pArray,n1) basic4gl.GetFloatArrayParam(n,pArray,1,n1)
// 2 dimensions array()() #define GIA2(n,pArray,n1,n2) basic4gl.GetIntArrayParam(n,pArray,2,n1,n2) #define GFA2(n,pArray,n1,n2) basic4gl.GetFloatArrayParam(n,pArray,2,n1,n2)
// set byte,word,int,float,string param (byref) #define SB(n,v) basic4gl.SetType(DLL_BASIC4GL_EXT_BYTE);basic4gl.ModTypeReference(); basic4gl.SetParam(n,v) #define SW(n,v) basic4gl.SetType(DLL_BASIC4GL_EXT_WORD);basic4gl.ModTypeReference(); basic4gl.SetParam(n,v) #define SI(n,v) basic4gl.SetType(DLL_BASIC4GL_EXT_INT);basic4gl.ModTypeReference(); basic4gl.SetParam(n,v) #define SF(n,v) basic4gl.SetType(DLL_BASIC4GL_EXT_FLOAT);basic4gl.ModTypeReference(); basic4gl.SetParam(n,v) #define SS(n,s,v) basic4gl.SetStringType(s);basic4gl.ModTypeReference();basic4gl.SetParam(n,v) // set int,float array() param byref #define SIA(n,p,n1) basic4gl.SetType(DLL_BASIC4GL_EXT_INT);basic4gl.ModTypeArray(2,n1);basic4gl.SetParam(n,p); #define SFA(n,p,n1) basic4gl.SetType(DLL_BASIC4GL_EXT_FLOAT);basic4gl.ModTypeArray(2,n1);basic4gl.SetParam(n,p); // 2 dimension array()()= ... #define SIA2(n,p,n1,n2) basic4gl.SetType(DLL_BASIC4GL_EXT_INT);basic4gl.ModTypeArray(2,n1,n2);basic4gl.SetParam(n,p); #define SFA2(n,p,n1,n2) basic4gl.SetType(DLL_BASIC4GL_EXT_FLOAT);basic4gl.ModTypeArray(2,n1,n2);basic4gl.SetParam(n,p);
// set int float string result #define SIR(r) basic4gl.SetIntResult((int) r) #define SFR(r) basic4gl.SetFloatResult(r) #define SSR(r) basic4gl.SetStringResult(r)
// set int float array() result #define SIAR(p,n1) basic4gl.SetFloatArrayResult(p,1,n1); #define SFAR(p,n1) basic4gl.SetFloatArrayResult(p,1,n1); // set int float array()() result #define SIAR2(p,n1,n2) basic4gl.SetFloatArrayResult(p,2,n1,n2); #define SFAR2(p,n1,n2) basic4gl.SetFloatArrayResult(p,2,n1,n2);
#endif /* _PLUGINMACROS_H */
|
|
|
Post by Darkjester on Dec 12, 2008 8:22:03 GMT -5
So I just Call the Include when i comp the plugin and call these functions? Very Useful thnx Djlinux  -Darkjester
|
|
|
Post by Nicky Peter Hollyoake on Dec 12, 2008 8:29:24 GMT -5
So I just Call the Include when i comp the plugin and call these functions? Very Useful thnx Djlinux  -Darkjester if you mean in c++ how do you make a const its like ... const int a; const float a; ... if you mean how can you create a const in Basic4GL through a plugin where the registry part is do ... registry.RegisterIntConstant("Name", Value) registry.RegisterFloatConstant("Name", Value) registry.RegisterStringConstant("Name", Value) - Nicky
|
|
|
Post by Darkjester on Dec 12, 2008 8:31:32 GMT -5
Yea but what about what you do for the subroutine?
|
|
|
Post by Nicky Peter Hollyoake on Dec 12, 2008 8:36:49 GMT -5
You mean like Sub ... End, Function ... EndFunction? If so I don't think its possible.
|
|
|
Post by Darkjester on Dec 12, 2008 8:39:15 GMT -5
What i mean is im trying to make const params for functions (like default varible values) and sort like glenable(enable something) does that make sense?
|
|
|
Post by Nicky Peter Hollyoake on Dec 12, 2008 8:44:53 GMT -5
What i mean is im trying to make const params for functions (like default varible values) and sort like glenable(enable something) does that make sense? Yes. This does that ... registry.RegisterIntConstant("Name", Value) registry.RegisterFloatConstant("Name", Value) registry.RegisterStringConstant("Name", Value) Example: registry.RegisterIntConstant("NewTRUE", 1) I just make an integer constant named "Newtrue" which returns 1, instead of the normal -1 we get. So now we can use it in a program ... Player.Alive = NewTRUE if Player.Alive = NewTRUE Then '... Endif - Nicky
|
|
|
Post by Darkjester on Dec 12, 2008 8:47:24 GMT -5
oh ok  Makes sense now. Is how OpenGL Parameters work?
|
|
|
Post by smc44 on Dec 12, 2008 11:53:31 GMT -5
hmmm i was thinking of that but didnt want to ask lol
|
|
|
Post by DJLinux on Dec 12, 2008 15:19:19 GMT -5
if you will use opengl extension
first search in the opengl ext string the name of the extension (if you call a none exist extension it will crash)
define your ext consts and function POINTERS!!!
funcptr = getprocadress("nameof of the function")
make it for B4GL useable via your plugin
google for an opengl extension example or tutorial
Joshy
|
|
|
Post by Darkjester on Dec 12, 2008 16:09:26 GMT -5
Very Helpful Thnx for all yoru help guys  -Darkjester
|
|
|
Post by DJLinux on Dec 12, 2008 19:43:55 GMT -5
|
|
|
Post by Darkjester on Dec 14, 2008 16:14:39 GMT -5
Very Usefull Djlinux 
|
|
|
Post by DJLinux on Dec 14, 2008 17:58:23 GMT -5
Very Usefull Djlinux  i know ;D  (spam)
|
|