SDK with plain C ?

Archives Forums/Blitz3D SDK Programming/SDK with plain C ?

Seldon(Posted 2007) [#1]
Is it possible to use the SDK with plain C (like Pelles-C for example) ? Or you need C++ support in the compiler ? Thanks.


Who was John Galt?(Posted 2007) [#2]
According to the products page, plain C is fine.


ZJP(Posted 2007) [#3]
Works well with DEvC++ in 'C' mode. The default parameter must be "include"

Example :

BBEntity camera = bbCreateCamera(); // C++
BBEntity camera = bbCreateCamera(0); // C


ninjarat(Posted 2007) [#4]
Yeah I just did a little test to see if it would start and end properly in plain C... it worked fine. I think that's because it's not at all object oriented, a useful feature for people looking to use it with non object oriented languages. All the object handling is internal and all we, the end user coders get, is an integer handle system.


Knotz(Posted 2007) [#5]
I tried some examples with LCC-Win32 for fun. No real problems except for the default parameter stuff.


ZJP(Posted 2007) [#6]
"I tried some examples with LCC-Win32 for fun. No real problems except for the default parameter stuff."

With LCC?. Good news. I'm interesting. A post about these parameters? ;-)

JP


Blitzplotter(Posted 2007) [#7]
@ZJP, so will you post a small example of the complete code you used in your compiler? I'm interested because this would be a great excuse to interface some 'c' with B3D.

Regards, BP.


ZJP(Posted 2007) [#8]
An example from the SDK

extern int WINAPI WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpszArgs,int nWinMode){

    bbBeginBlitz3D();
     
    bbGraphics3D( 640, 480, 0, 2 );

    bbAmbientLight( 64, 64, 64);
    
    BBEntity camera = bbCreateCamera();
    BBEntity light = bbCreateLight();
    BBEntity cube = bbCreateCube();

// move camera back from origin

    bbPositionEntity( camera, 0, 0, -5 );

// tilt default forward facing directional light downwards 
    
    bbRotateEntity( light, 40, 0, 0 );
    
// now rotate the cube slowly infront of the camera until escape key pressed

    while( !bbKeyHit( KEY_ESCAPE ) ) {

        bbTurnEntity( cube, .1, .2, .3 );
        bbUpdateWorld();
        bbRenderWorld();
        bbFlip();
    }

    bbEndBlitz3D();

    return 0;
}



Big&(Posted 2007) [#9]
Works with VisualC 6 also, with the default parameters.


Jazz(Posted 2007) [#10]
[Deleted] Nevermind. :)


gekkonier(Posted 2009) [#11]
2 year old post, I know, but:

Testet with Pelles C 6.0

1. copy blitz3dsdk.h to C:\Program Files (x86)\PellesC\Include
2. copy blitz3dsdk.lib to C:\Program Files (x86)\PellesC\Lib\Win
3. copy b3d.dll to your Project (where the exe will be created)

now, in the project options:

4. in the tab Compiler:
Calling conv: __cdecl
Options: Enable Windows extensions checked
5. in the tab Linker:
add to Library and object files: blitz3dsdk.lib
select Subsytem Type: Windows
6. the Source for main.c:
#include <windows.h>
#include <blitz3dsdk.h>

extern int WINAPI WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpszArgs,int nWinMode){


	bbBeginBlitz3D();

	bbGraphics3D(800,600,0,2);

	BBLight light=bbCreateLight(0,0);
	BBCamera camera=bbCreateCamera(0);
	BBMeshModel cube=bbCreateCube(0);

	bbPositionEntity(camera,0,0,-4,0);

	while (!bbKeyHit(1)){
		bbTurnEntity(cube,.01,.02,.03,0);
		bbRenderWorld(0);
		bbFlip(0);
	}

	bbEndBlitz3D();
	return 0;
}


I modified the C++ example from the html help files provided with blitz3dsdk to explicit provide the standard arguments to the functions as said before in this thread.
// c++ example:
// given function:
int hello(int x = 0) {.....foobar code here....}
// call of it:
hello(); // will provide in hello scope int x = 0 automatically
// but in c you need to do the call that way:
hello(0);
// because c doesnt handle default arguments and dont provide them as parameters to the scope!

You can look into the provided h file to check out whats the default parameter (just rightclick on #include <blitz3dsdk.h> and select open file)