C++ version of GLBasic

Previous topic - Next topic



This is really a suggestion for a new product rather than a new feature.

I want to have a go at writing an (Initially) Android game in C++. There are lots of reasons I want to use C++, the classes, inheritance, operator overloading but also the ease of use and availability of almost an infinite number of open source libraries, to name but a few.

I also realise that you can use C++ as inline code but its not ideal for larger projects. There's no C++ debugger, no syntax highlighting in the editor, the GLB library has no official C++ interface etc...

I have looked at GCC+Eclipse+Android NDK. It works but its a bit of a PITA to set up and then you gotta deal with OpenGLES/OpenAL and/or SDL.

Or there are more professional ( costly too, see http://www.madewithmarmalade.com/ ) alternatives like Marmalade SDK+Visual Studio.

But what I really want is just GLBasic but with C++ as the the main language, same IDE, same GLB runtime lib, same ease of compile without messing around with build options and esp. the same multi-platform support.

Don't get me wrong, I love GLBasic and have no intentions of dropping it all, this is a side project for me and maybe I am the only one interested in it but as Marmalade has proven there is a large market for cross-platform C++ game development utilities and I personally would buy this as a second product.

GLBasic has its place and in no way would I want it replaced by this, this is just a (mad?) suggestion for the future.


"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)


For me the great troubles of this things like Unity (for me it's better than this for the 3D), it's the license for year... really if I buy a product, it's mine not it's somthing a number or something in a server... it's only my opnion...

About marmelade, I think you have better choices and free... I realluy I think seriously buy Shiva (very cheaper about 180€, and for me not license) and a lot of platoforms... but the great problem here it's I can do a 3D complex game, the awnser it's not... I'm only a guy, and I think can't be rentable...

Another thing it's I feel something extrange when I think about buy another soft (similar if you are married and you have a lover  =D, well this it's not bad in all  =D =D), but really it's an extrange feeling, GLBasic show me to do things, better or worts than another people, but I'm sure, If I don't pay 60€ make 3 o 4 years , today I don't know what I doing yet...

Another point I think use GLbasic and another things can be interesting... I in 3D software, use about 2 or 3 or more programs, and PS , and AFX and a lot of soft of audio... if it's compatible and you can use and benefit from both, not all projects need the same rquerimets or time for develop...


I also once thought that it would be really cool to have the GLBasic libraries available for a purely c++ SDK, until I discovered, it is not really needed. Everything is there already in the GLB editor. Sure c++ syntax highlighting and dot-lookups such as in Netbeans/Eclipse would be awesome. but I'm ok with Alt-Tab for references.

It take a little while to get used to the GLB data types for c++, but then you have the same thing in Java. So after a few inline tests, and getting used to the data types, I feel right at home using 100% c++ code in the GLB environment. You have to use 2 inline blocks, with a GLB function in between them, and also declare your functions in the first inline block. But once you've done it a couple of times, you do not even notice the few lines of extra code.

What's also really very handy, is the c++ output for a GLB file in c++ in the directory \Users\<user>\AppData\Local\Temp\glbasic, since is a great reference to see what the c++ commands must look like for compiling. You also pick up such functions as CGStr. If you really think about it, you use advanced data types in c++ anyway for such things as buffered strings, so it's a small step to accept the GLB data types, and you are well on your way.

Here's the default demo for the BoxPrint project redone for c++. One of my first tries. If you compare it to the GLB source, you can see that there is almost no shift in thinking between the two languages.

This is my opinion anyway. I am not saying everyone should go this route, but I am quite happy to play with the cool GLB libraries in c++, using a Basic language IDE.

Code (glbasic) Select

//Declare functions
DGInt BoxPrint2(DGStr str_Str, DGInt x, DGInt y, DGInt wx);

DRAWRECT (300, 100, 200, 300, RGB(20,20,120));
BoxPrint2("This is a long Text, which has to be wrapped twice or thrice to fit the box", 300, 100, 200);

//You need an empty GLBasic function before your c++ functions

DGInt BoxPrint2(DGStr str_Str, DGInt x, DGInt y, DGInt wx)
DGInt tx, ty, cx, cy, cpos;
DGStr word_Str, c_Str;

cy = y;
str_Str = str_Str + CGStr(" ");
cx = x;

while(cpos < LEN(str_Str)){
c_Str = MID_Str(str_Str, cpos, 1);

word_Str = word_Str + c_Str;

if(c_Str == CGStr(" ")){
if(cx - x + (LEN(word_Str) - 1) * tx > wx){
cx = x; cy = cy + ty;
PRINT(word_Str, cx, cy);


I came, I saw, I coded.