DLL aus diesem Code



  • Ich beginne gerade erst mit C++, und mach auch kleinere Sachen.
    Momentan komme ich aber nicht drumherum eine DLL schreiben zu müssen.

    Ich habe etwas code kopiert und hoffe ist alles notwendige drin.
    Also ich würde gern jemanden von Euch bitten sich das mal anzuschauen, und DLL syntaktisch zu editieren.

    Also ich brauch das nur als Ableitung, für den Ganzen Rest.
    Nur der Befehl LoadImageF soll exportiert werden.

    Achja und wenn jemand mag, .... würde gern wissen wie dieser code funktioniert...WAS TUT ER????
    (weiter unten die .h und .cpp für die dll)

    //---------------------------------------------------------------------
    cFIXorsBridge* cFIXorsBridge::vsSelf = NULL;
    //---------------------------------------------------------------------
    int cFIXorsBridge::vsRefcount = 0;
    //---------------------------------------------------------------------
    cFIXorsBridge::cFIXorsBridge() {
    
    	HandleDLL = 0;
    
    	FontProperty.Chars = new int[256];
    }
    //---------------------------------------------------------------------
    cFIXorsBridge::~cFIXorsBridge() {
    
    	vsSelf = NULL;
    
    	if (HandleDLL) FreeLibrary( (HMODULE)HandleDLL );
    
    	delete[] FontProperty.Chars;
    }
    //---------------------------------------------------------------------
    cFIXorsBridge* cFIXorsBridge::Initiate(bool initDraw) {
    
    	if (!vsSelf) {
    
    		vsSelf = new cFIXorsBridge;
    
    		if ( !vsSelf->LoadFastImage() ) {
    			delete vsSelf;
    			return NULL;
    		}
    	}
    
    	if (initDraw) vsSelf->InitDraw();
    
    	vsRefcount++;
    
    	return vsSelf;
    }
    //---------------------------------------------------------------------
    

    so und hier die *.h für die DLL ....

    #ifndef __FIXORSBRIDGE__
    #define __FIXORSBRIDGE__
    
    //##################################################
    //						Defines
    //##################################################
    
    #define FIXCALL _stdcall
    
    //	CreateImageEx Flags
    #define FI_AUTOFLAGS -1
    #define FI_NONE 0
    #define FI_MIDHANDLE 1
    #define FI_FILTEREDIMAGE 2
    #define FI_FILTERED 2
    
    //	SetBlend Flags
    #define FI_SOLIDBLEND 0
    #define FI_ALPHABLEND 1
    #define FI_LIGHTBLEND 2
    #define FI_SHADEBLEND 3
    #define FI_MASKBLEND 4
    #define FI_MASKBLEND2 5
    #define FI_INVALPHABLEND 6
    
    //	ImageFonts Flags
    #define FI_SMOOTHFONT 1
    
    //	DrawImagePart Wrap Flags
    #define FI_NOWRAP 0
    #define FI_WRAPU 1
    #define FI_MIRRORU 2
    #define FI_WRAPV 4
    #define FI_MORRORV 8
    #define FI_WRAPUV 5
    #define FI_MIRRORUV 10
    
    //	DrawPoly consts
    #define FI_POINTLIST 1
    #define FI_LINELIST 2
    #define FI_LINESTRIP 3
    #define FI_TRIANGLELIST 4
    #define FI_TRIANGLESTRIP 5
    #define FI_TRIANGLEFAN 6
    
    #define FI_COLOROVERLAY 1
    
    struct sFI_Surfaces {
    	int Count;
    	int* Array;
    	int Texture;
    };
    
    struct sFI_FontProperty {
    	int Width,Height,FirstChar,Kerning;
    	int Image,FrameWidth,FrameHeight,FrameCount;
    	int* Chars;
    
    	//sFI_FontProperty() { Chars = new int[256]; }
    	//~sFI_FontProperty() { delete Chars; }
    };
    
    class cFIXorsBridge {
    private:
    	/* Singleton -  */
    	static cFIXorsBridge* vsSelf;
    	/* Singleton -  */
    	static int vsRefcount;
    
    	/*  FastImageXors.dll */
    	void* HandleDLL;
    
    	/*  FastImageXors.dll */
    	bool LoadFastImage();
    
    	protected:
    
    	cFIXorsBridge();
    
    	virtual ~cFIXorsBridge();
    
    public:
    	/*  FastImage */
    	static cFIXorsBridge* Initiate(bool initDraw = true);
    
    	static cFIXorsBridge& GetSingleton() { return *vsSelf; }
    	static cFIXorsBridge* GetSingletonPtr() { return vsSelf; }
    
    	/* FastImage */
    	void FreeSingleton() { if(--vsRefcount==0) delete this; }
    
    	sFI_ImageProperty ImageProperty;
    
    	int CreateImage(int texture, int width, int height, int imageFlags = FI_AUTOFLAGS);
    	int LoadImageF(const char* fileName, int textureFlags = 0, int imageFlags = FI_AUTOFLAGS);
    
    	};
    
    #endif /*__FIXORSBRIDGE__*/
    

    UND HIER DIE *.cpp

    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    #include <fstream>
    #include "FIXorsBridge.h"
    
    using namespace std;
    
    //---------------------------------------------------------------------
    cFIXorsBridge* cFIXorsBridge::vsSelf = NULL;
    //---------------------------------------------------------------------
    int cFIXorsBridge::vsRefcount = 0;
    //---------------------------------------------------------------------
    cFIXorsBridge::cFIXorsBridge() {
    
    	HandleDLL = 0;
    
    	FontProperty.Chars = new int[256];
    }
    //---------------------------------------------------------------------
    cFIXorsBridge::~cFIXorsBridge() {
    
    	vsSelf = NULL;
    
    	if (HandleDLL) FreeLibrary( (HMODULE)HandleDLL );
    
    	delete[] FontProperty.Chars;
    }
    //---------------------------------------------------------------------
    cFIXorsBridge* cFIXorsBridge::Initiate(bool initDraw) {
    
    	if (!vsSelf) {
    
    		vsSelf = new cFIXorsBridge;
    
    		if ( !vsSelf->LoadFastImage() ) {
    			delete vsSelf;
    			return NULL;
    		}
    	}
    
    	if (initDraw) vsSelf->InitDraw();
    
    	vsRefcount++;
    
    	return vsSelf;
    }
    //---------------------------------------------------------------------
    
    bool cFIXorsBridge::LoadFastImage() {
    	HMODULE hLib = LoadLibrary("FastImageXors.dll");
    	if (hLib == NULL) { return(false); }
    	HandleDLL = (void*)hLib;
    
    	(FARPROC &)pCreateImageEx = GetProcAddress(hLib, "CreateImageEx_");
    	if (!pCreateImageEx) { FreeLibrary(hLib); return(false); }
    
    	return(true);
    }
    
    int cFIXorsBridge::CreateImage(int texture, int width, int height, int imageFlags) {
    	if (texture) {
    		int Array[256];
    		sFI_Surfaces surf;
    		surf.Texture = texture;
    		surf.Array = Array;
    		surf.Count = xGetTextureFrames(texture);
    		if (surf.Count>0) {
    			if (surf.Count>256) surf.Count=256;
    			for(register int i=0; i<surf.Count; i++) {
    				surf.Array[i] = xGetTextureSurface(texture, i);
    			}
    			return(pCreateImageEx(&surf, width, height, imageFlags));
    		}
    	}
    	return(0);
    }
    //---------------------------------------------------------------------
    
    int cFIXorsBridge::LoadImageF(const char* fileName, int textureFlags, int imageFlags) {
    	if (ImageInfo_ReadFile(fileName)) {
    		return( CreateImage(xLoadTexture(fileName, textureFlags), ImgInfo.Width, ImgInfo.Height, imageFlags) );
    	}
    	return(0);
    }
    

    Wäre echt cool, wenn mir das jemand DLL konform schreiben könnte.





  • das ist mir schon klar, aber da sind auch teile drin, wo ich nicht weiß, was wie und wohin genau gehört, da ja in der dll eine weitere dll gewrappt wird.


Anmelden zum Antworten