Hi Matthew,
Op di 07-11-2006, om 17:47 schreef Matthew Kille:
> Hi All,
>
> I'm trying to build a GAPI application using cegcc. As there doesn't
> seem to be a import library ready made for this, I have attempting to
> make one, but without much success.
--snip--
> Where am I going wrong? Or am I barking up completely the wrong tree? :)
>
> Hope someone can help.
>
> Cheers,
>
> --
> Matt.
>
this has been a problem since cegcc or previous versions have been
around. The easiest way of getting GAPI in your program is to do it via
this hack:
File: gapi_help.h
#include <windows.h>
#define GETRAWFRAMEBUFFER 0x00020001
#define SHFS_SHOWTASKBAR 0x0001
#define SHFS_HIDETASKBAR 0x0002
#define SHFS_SHOWSIPBUTTON 0x0004
#define SHFS_HIDESIPBUTTON 0x0008
#define SHFS_SHOWSTARTICON 0x0010
#define SHFS_HIDESTARTICON 0x0020
typedef struct _RawFrameBufferInfo
{
WORD wFormat;
WORD wBPP;
VOID *pFramePointer;
int cxStride;
int cyStride;
int cxPixels;
int cyPixels;
} RawFrameBufferInfo;
#define false 0
#define true 1
typedef
struct GXDisplayProperties {
DWORD cxWidth;
DWORD cyHeight; // notice lack of 'th' in the word height.
long cbxPitch; // number of bytes to move right one x pixel
- can be negative.
long cbyPitch; // number of bytes to move down one y pixel
- can be negative.
long cBPP; // # of bits in each pixel
DWORD ffFormat; // format flags.
}GXDisplayProperties;
struct GXKeyList {
short vkUp; // key for up
POINT ptUp; // x,y position of key/button. Not on
screen but in screen coordinates.
short vkDown;
POINT ptDown;
short vkLeft;
POINT ptLeft;
short vkRight;
POINT ptRight;
short vkA;
POINT ptA;
short vkB;
POINT ptB;
short vkC;
POINT ptC;
short vkStart;
POINT ptStart;
};
#define kfLandscape 0x8 // Screen is rotated 270 degrees
#define kfPalette 0x10 // Pixel values are indexes into a palette
#define kfDirect 0x20 // Pixel values contain actual level information
#define kfDirect555 0x40 // 5 bits each for red, green and blue values
in a pixel.
#define kfDirect565 0x80 // 5 red bits, 6 green bits and 5 blue bits
per pixel
#define kfDirect888 0x100 // 8 bits each for red, green and blue
values in a pixel.
#define kfDirect444 0x200 // 4 red, 4 green, 4 blue
#define kfDirectInverted 0x400
#define GX_FULLSCREEN 0x01 // for OpenDisplay()
typedef GXDisplayProperties (*tGXDisplayProperties)(void);
typedef int (*tGXOpenDisplay)(HWND, unsigned long);
typedef void* (*tGXBeginDraw)(void);
typedef int (*tGXEndDraw)(void);
typedef int (*tGXCloseDisplay)(void);
typedef int (*tGXSuspend)(void);
typedef int (*tGXResume)(void);
typedef int (*tGXCloseInput)(void);
typedef int (*tGXOpenInput)(void);
struct GAPI_funcs {
tGXDisplayProperties dynamicGXGetDisplayProperties;
tGXOpenDisplay dynamicGXOpenDisplay;
tGXCloseDisplay dynamicGXCloseDisplay;
tGXBeginDraw dynamicGXBeginDraw;
tGXEndDraw dynamicGXEndDraw;
tGXSuspend dynamicGXSuspend;
tGXResume dynamicGXResume;
};
struct GAPI_properties {
unsigned char invert;
int colorscale;
int dstPixelstep;
int dstLinestep;
int startOffset;
int videoMode;
};
// for importing entries from dll's..
#define IMPORT(Handle,Variable,Type,Function, Store) \
printf( "get %s\n",Function ); \
Variable = GetProcAddress(Handle, TEXT(Function)); \
printf("store %s\n", Function ); \
if (!Variable) { \
FreeLibrary(Handle); \
return NULL; \
} \
if (Store) \
Store = (Type)Variable;
------------------------------------------
and in your main application do:
#include "gapi_help.h"
int setup_gapi()
{
HMODULE gapiLibrary;
FARPROC proc;
printf("open gapi dll \n");
gapiLibrary = LoadLibrary(TEXT("gx.dll"));
printf(" returned %08x",(unsigned int)gapiLibrary);
IMPORT(gapiLibrary, proc, tGXDisplayProperties,
"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ",
GXGetDisplayProperties)
IMPORT(gapiLibrary, proc, tGXOpenDisplay,
"?GXOpenDisplay@@YAHPAUHWND__@@[EMAIL PROTECTED]", GXOpenDisplay)
IMPORT(gapiLibrary, proc, tGXCloseDisplay,
"?GXCloseDisplay@@YAHXZ",GXCloseDisplay)
IMPORT(gapiLibrary, proc, tGXBeginDraw,
"?GXBeginDraw@@YAPAXXZ",GXBeginDraw)
IMPORT(gapiLibrary, proc, tGXEndDraw,
"?GXEndDraw@@YAHXZ",GXEndDraw)
IMPORT(gapiLibrary, proc, tGXSuspend,
"?GXSuspend@@YAHXZ",GXSuspend)
IMPORT(gapiLibrary, proc, tGXResume, "?GXResume@@YAHXZ",
GXResume)
IMPORT(gapiLibrary, proc,
tGXCloseInput,"?GXCloseInput@@YAHXZ",GXCloseInput)
IMPORT(gapiLibrary, proc,
tGXOpenInput,"?GXOpenInput@@YAHXZ",GXOpenInput)
return 1;
}
--------
After a call to setup_gapi() you can use the Gapi calls from C.
If you want to use them from c++ follow the hint that Pedro gave about
the include file.
It works for me. The printf statements I use to check the validity of
all the steps involved.
Jan Rinze.
P.S. I did not invent this, there are a couple of articles on the web
that have similair solutions.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Cegcc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cegcc-devel