INLINE calls

Previous topic - Next topic

bigsofty

Code (glbasic) Select
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...?

Also...

Where do I put my...
Code (glbasic) Select
#include // Header File For Standard Input / Output
Cheers,

Ian.

"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)

Kitty Hello

If you want to include some file, be warned, that you must provide it. I don't provide any std files with GLBasic SDK.
The easiest way is to put all inline stuff in a seperate file. That way you are sure, that at the top of this file you're not in the main function anymore.

Code (glbasic) Select
INLINE
} // close current namespace
include

namespace __GLBASIC__ { // restore namespace
ENDINLINE
For calling a function I suggest this:

Code (glbasic) Select
FUNCTION LoadFile: file$
INLINE
bool good=true;
FILE* pF = fopen(file_Str . c_str(), "rb");
fputs(pF, ....

return good;
ENDINLINE

bigsofty

Aha, so thats how its done! :)

Thanks Gernot, Im learning C as need be for GLBasic... do I need the standard .h file that is supplied with GCC or will anyone do? If so, does it need to specific to the compiler version?

Many thanks,
Cheers,

Ian.

"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)

Kitty Hello

I think any std file will do. Getting a copy from a GCC compiler is a good choice, though.

bigsofty

:( I cant get this to work, no matter what headers I try, I've tried djgpp,mingw (gcc), PelleC, etc... stdio.h but they all throw up errors on compilation... each header has different errors.

I placed them in ..."\Program Files\GLBasic\Compiler\platform\Include"...
Cheers,

Ian.

"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)

bigsofty

Removed some bits and edited the headers... down to a few errors... Ill continue to try and fix them tomorrow...
Cheers,

Ian.

"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)

Kitty Hello

Best is to copy/paste the function declarations you need only.

bigsofty

My biggest problem is that GLBasic seems to do an automatic type conversion mystring_Str and DGInt for example, which makes them incompatible with these system calls?
Cheers,

Ian.

"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)

Kitty Hello

Code (glbasic) Select
mystring_Str.c_str()gives a const char*

Code (glbasic) Select
mystring_Str.GetStr(minimum_length);
...
mystring_Str.CalcLen();
gives a char* (not very wise, though)

DGInt is simply a double, so you can cast to e.g. int
Code (glbasic) Select
DGInt mynumber=1.23;
int n = (int) mynumber;

bigsofty

P.S. I've been getting this error quite a bit over the last couple of days, when posting Gernot...

"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, service@webmailer.de and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log."
Cheers,

Ian.

"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)

bigsofty

Small question... where to you store your textures Gernot(array of GLuint), I would like to load my own textures and use the OpenGL texture ID from within GLBasic?
Cheers,

Ian.

"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)

Kitty Hello

try get_sprite_texture() command. See an example here:
http://www.glbasic.com/forum/viewtopic.php?pid=4031#p4031

bigsofty

Ah, thank you, I forgotten about that example! :D

EDIT: Ah, its actually  new one... doh! ...thanks again bud ;)
Cheers,

Ian.

"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)

bigsofty

Quote from: bigsoftyRemoved some bits and edited the headers... down to a few errors... Ill continue to try and fix them tomorrow...
Not happy with my current headers... they work but I'm not happy with there compatibility (lots of edits t get working)... does anyone have a zip file handy with all the headers for C99? What worries me is that the headers may not be cross platform compatible, since some headers I've looked at seem to have different Defines for different O.S. and my will be on at least 3 platforms...

Also...

Im using standard OpenGL types... GLuint, GLbyte, etc... via typedefs inline, is this OK, I noticed you dont use them Gernot (maybe because you know them off by heart ;))?
Cheers,

Ian.

"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)

bigsofty

OK, time to stop and take stock...

First why go to the bother, I could easily just compile a DLL BUT as said I wanted my program to work across various platforms... a DLL does not work in linux for example, so, inline, with the game... seemed the best idea...

The headers I need, are..., and

Ive ran into a few problems (or potential problems)...

1) Standard C99 headers seem to be quite incompatible... I tried many.

2) Some of these headers are for win32 only, so compilation on one platform does not guarantee it will run on another.

Interfacing with GLBasic variables via type casting was working fine.

Gernot, any advice how to proceed?
Cheers,

Ian.

"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)