[MetaHook] Quake Bink function

If you want to play Bink video in game, maybe you need this code.

QBink.h

 1 #ifndef QBINK_H
 2 #define QBINK_H
 3
 4 #include "bink.h"
 5
 6 extern void PTR4* (RADEXPLINK *qBinkLogoAddress)(void);
 7 extern void (RADEXPLINK *qBinkSetError)(const char PTR4* err);
 8 extern char PTR4* (RADEXPLINK *qBinkGetError)(void);
 9 extern HBINK (RADEXPLINK *qBinkOpen)(const char PTR4* name,U32 flags);
10 extern void (RADEXPLINK *qBinkGetFrameBuffersInfo)( HBINK bink, BINKFRAMEBUFFERS * fbset );
11 extern void (RADEXPLINK *qBinkRegisterFrameBuffers)( HBINK bink, BINKFRAMEBUFFERS * fbset );
12 extern S32  (RADEXPLINK *qBinkDoFrame)(HBINK bnk);
13 extern void (RADEXPLINK *qBinkNextFrame)(HBINK bnk);
14 extern S32  (RADEXPLINK *qBinkWait)(HBINK bnk);
15 extern void (RADEXPLINK *qBinkClose)(HBINK bnk);
16 extern S32  (RADEXPLINK *qBinkPause)(HBINK bnk,S32 pause);
17 extern S32  (RADEXPLINK *qBinkCopyToBuffer)(HBINK bnk,void* dest,S32 destpitch,U32 destheight,U32 destx,U32 desty,U32 flags);
18 extern S32  (RADEXPLINK *qBinkCopyToBufferRect)(HBINK bnk,void* dest,S32 destpitch,U32 destheight,U32 destx,U32 desty,U32 srcx, U32 srcy, U32 srcw, U32 srch, U32 flags);
19 extern S32  (RADEXPLINK *qBinkGetRects)(HBINK bnk,U32 flags);
20 extern void (RADEXPLINK *qBinkGoto)(HBINK bnk,U32 frame,S32 flags);  // use 1 for the first frame
21 extern U32  (RADEXPLINK *qBinkGetKeyFrame)(HBINK bnk,U32 frame,S32 flags);
22 extern S32  (RADEXPLINK *qBinkSetVideoOnOff)(HBINK bnk,S32 onoff);
23 extern S32  (RADEXPLINK *qBinkSetSoundOnOff)(HBINK bnk,S32 onoff);
24 extern void (RADEXPLINK *qBinkFreeGlocalMemory)( void );
25 extern void (RADEXPLINK *qBinkSetVolume)(HBINK bnk, U32 trackid, S32 volume);
26 extern void (RADEXPLINK *qBinkSetPan)(HBINK bnk,U32 trackid, S32 pan);
27 extern void (RADEXPLINK *qBinkSetMixBins)(HBINK bnk,U32 trackid, U32 PTR4* mix_bins, U32 total);
28 extern void (RADEXPLINK *qBinkSetMixBinVolumes)(HBINK bnk,U32 trackid, U32 PTR4* vol_mix_bins, S32 PTR4* volumes, U32 total);
29 extern void (RADEXPLINK *qBinkService)(HBINK bink);
30 extern S32  (RADEXPLINK *qBinkShouldSkip)(HBINK bink);
31 extern void (RADEXPLINK *qBinkGetPalette)( void * out_pal );
32 extern S32  (RADEXPLINK *qBinkControlBackgroundIO)(HBINK bink,U32 control);
33 extern HBINKTRACK (RADEXPLINK *qBinkOpenTrack)(HBINK bnk,U32 trackindex);
34 extern void (RADEXPLINK *qBinkCloseTrack)(HBINKTRACK bnkt);
35 extern U32  (RADEXPLINK *qBinkGetTrackData)(HBINKTRACK bnkt,void PTR4* dest);
36 extern U32  (RADEXPLINK *qBinkGetTrackType)(HBINK bnk,U32 trackindex);
37 extern U32  (RADEXPLINK *qBinkGetTrackMaxSize)(HBINK bnk,U32 trackindex);
38 extern U32  (RADEXPLINK *qBinkGetTrackID)(HBINK bnk,U32 trackindex);
39 extern void (RADEXPLINK *qBinkGetSummary)(HBINK bnk,BINKSUMMARY PTR4* sum);
40 extern void (RADEXPLINK *qBinkGetRealtime)(HBINK bink,BINKREALTIME PTR4* run,U32 frames);
41 extern void (RADEXPLINK *qBinkSetSoundTrack)(U32 total_tracks, U32 PTR4* tracks);
42 extern void (RADEXPLINK *qBinkSetIO)(BINKIOOPEN io);
43 extern void (RADEXPLINK *qBinkSetFrameRate)(U32 forcerate,U32 forceratediv);
44 extern void (RADEXPLINK *qBinkSetSimulate)(U32 sim);
45 extern void (RADEXPLINK *qBinkSetIOSize)(U32 iosize);
46 extern S32  (RADEXPLINK *qBinkSetSoundSystem)(BINKSNDSYSOPEN open, U32 param);
47 extern void (RADEXPLINK *qBinkControlCPUFeatures)( S32 use, S32 dont_use );
48 extern BINKSNDOPEN (RADEXPLINK *qBinkOpenDirectSound)(U32 param); // don‘t call directly
49 extern BINKSNDOPEN (RADEXPLINK *qBinkOpenWaveOut)(U32 param); // don‘t call directly
50 extern BINKSNDOPEN (RADEXPLINK *qBinkOpenMiles)(U32 param); // don‘t call directly
51 extern S32 (RADEXPLINK *qBinkDX8SurfaceType)(void* lpD3Ds);
52 extern S32 (RADEXPLINK *qBinkDX9SurfaceType)(void* lpD3Ds);
53 extern HBINKBUFFER (RADEXPLINK *qBinkBufferOpen)( void* /*HWND*/ wnd, U32 width, U32 height, U32 bufferflags);
54 extern S32 (RADEXPLINK *qBinkBufferSetHWND)( HBINKBUFFER buf, void* /*HWND*/ newwnd);
55 extern S32 (RADEXPLINK *qBinkDDSurfaceType)(void PTR4* lpDDS);
56 extern S32 (RADEXPLINK *qBinkIsSoftwareCursor)(void PTR4* lpDDSP, void* /*HCURSOR*/ cur);
57 extern S32 (RADEXPLINK *qBinkCheckCursor)(void* /*HWND*/ wnd,S32 x,S32 y,S32 w,S32 h);
58 extern S32 (RADEXPLINK *qBinkBufferSetDirectDraw)(void PTR4* lpDirectDraw, void PTR4* lpPrimary);
59 extern void (RADEXPLINK *qBinkBufferClose)( HBINKBUFFER buf);
60 extern S32 (RADEXPLINK *qBinkBufferLock)( HBINKBUFFER buf);
61 extern S32 (RADEXPLINK *qBinkBufferUnlock)( HBINKBUFFER buf);
62 extern void (RADEXPLINK *qBinkBufferSetResolution)( S32 w, S32 h, S32 bits);
63 extern void (RADEXPLINK *qBinkBufferCheckWinPos)( HBINKBUFFER buf, S32 PTR4* NewWindowX, S32 PTR4* NewWindowY);
64 extern S32 (RADEXPLINK *qBinkBufferSetOffset)( HBINKBUFFER buf, S32 destx, S32 desty);
65 extern void (RADEXPLINK *qBinkBufferBlit)( HBINKBUFFER buf, BINKRECT PTR4* rects, U32 numrects );
66 extern S32 (RADEXPLINK *qBinkBufferSetScale)( HBINKBUFFER buf, U32 w, U32 h);
67 extern char PTR4* (RADEXPLINK *qBinkBufferGetDescription)( HBINKBUFFER buf);
68 extern char PTR4* (RADEXPLINK *qBinkBufferGetError)();
69 extern void (RADEXPLINK *qBinkRestoreCursor)(S32 checkcount);
70 extern S32 (RADEXPLINK *qBinkBufferClear)(HBINKBUFFER buf, U32 RGB);
71 extern void (RADEXPLINK *qBinkSetMemory)(BINKMEMALLOC a,BINKMEMFREE f);
72
73 void QBink_Init(void);
74 void QBink_Shutdown(void);
75
76 #endif

QBink.cpp

  1 #include <metahook.h>
  2
  3 #include "bink.h"
  4
  5 static HMODULE hBink = NULL;
  6
  7 void PTR4* (RADEXPLINK *qBinkLogoAddress)(void) = 0;
  8 void (RADEXPLINK *qBinkSetError)(const char PTR4* err) = 0;
  9 char PTR4* (RADEXPLINK *qBinkGetError)(void) = 0;
 10 HBINK (RADEXPLINK *qBinkOpen)(const char PTR4* name,U32 flags) = 0;
 11 void (RADEXPLINK *qBinkGetFrameBuffersInfo)( HBINK bink, BINKFRAMEBUFFERS * fbset ) = 0;
 12 void (RADEXPLINK *qBinkRegisterFrameBuffers)( HBINK bink, BINKFRAMEBUFFERS * fbset ) = 0;
 13 S32  (RADEXPLINK *qBinkDoFrame)(HBINK bnk) = 0;
 14 void (RADEXPLINK *qBinkNextFrame)(HBINK bnk) = 0;
 15 S32  (RADEXPLINK *qBinkWait)(HBINK bnk) = 0;
 16 void (RADEXPLINK *qBinkClose)(HBINK bnk) = 0;
 17 S32  (RADEXPLINK *qBinkPause)(HBINK bnk,S32 pause) = 0;
 18 S32  (RADEXPLINK *qBinkCopyToBuffer)(HBINK bnk,void* dest,S32 destpitch,U32 destheight,U32 destx,U32 desty,U32 flags) = 0;
 19 S32  (RADEXPLINK *qBinkCopyToBufferRect)(HBINK bnk,void* dest,S32 destpitch,U32 destheight,U32 destx,U32 desty,U32 srcx, U32 srcy, U32 srcw, U32 srch, U32 flags) = 0;
 20 S32  (RADEXPLINK *qBinkGetRects)(HBINK bnk,U32 flags) = 0;
 21 void (RADEXPLINK *qBinkGoto)(HBINK bnk,U32 frame,S32 flags) = 0;  // use 1 for the first frame
 22 U32  (RADEXPLINK *qBinkGetKeyFrame)(HBINK bnk,U32 frame,S32 flags) = 0;
 23 S32  (RADEXPLINK *qBinkSetVideoOnOff)(HBINK bnk,S32 onoff) = 0;
 24 S32  (RADEXPLINK *qBinkSetSoundOnOff)(HBINK bnk,S32 onoff) = 0;
 25 void (RADEXPLINK *qBinkSetVolume)(HBINK bnk, U32 trackid, S32 volume) = 0;
 26 void (RADEXPLINK *qBinkSetPan)(HBINK bnk,U32 trackid, S32 pan) = 0;
 27 void (RADEXPLINK *qBinkSetMixBins)(HBINK bnk,U32 trackid, U32 PTR4* mix_bins, U32 total) = 0;
 28 void (RADEXPLINK *qBinkSetMixBinVolumes)(HBINK bnk,U32 trackid, U32 PTR4* vol_mix_bins, S32 PTR4* volumes, U32 total) = 0;
 29 void (RADEXPLINK *qBinkService)(HBINK bink) = 0;
 30 S32  (RADEXPLINK *qBinkShouldSkip)(HBINK bink) = 0;
 31 void (RADEXPLINK *qBinkGetPalette)( void * out_pal ) = 0;
 32 S32  (RADEXPLINK *qBinkControlBackgroundIO)(HBINK bink,U32 control) = 0;
 33 HBINKTRACK (RADEXPLINK *qBinkOpenTrack)(HBINK bnk,U32 trackindex) = 0;
 34 void (RADEXPLINK *qBinkCloseTrack)(HBINKTRACK bnkt) = 0;
 35 U32  (RADEXPLINK *qBinkGetTrackData)(HBINKTRACK bnkt,void PTR4* dest) = 0;
 36 U32  (RADEXPLINK *qBinkGetTrackType)(HBINK bnk,U32 trackindex) = 0;
 37 U32  (RADEXPLINK *qBinkGetTrackMaxSize)(HBINK bnk,U32 trackindex) = 0;
 38 U32  (RADEXPLINK *qBinkGetTrackID)(HBINK bnk,U32 trackindex) = 0;
 39 void (RADEXPLINK *qBinkGetSummary)(HBINK bnk,BINKSUMMARY PTR4* sum) = 0;
 40 void (RADEXPLINK *qBinkGetRealtime)(HBINK bink,BINKREALTIME PTR4* run,U32 frames) = 0;
 41 void (RADEXPLINK *qBinkSetSoundTrack)(U32 total_tracks, U32 PTR4* tracks) = 0;
 42 void (RADEXPLINK *qBinkSetIO)(BINKIOOPEN io) = 0;
 43 void (RADEXPLINK *qBinkSetFrameRate)(U32 forcerate,U32 forceratediv) = 0;
 44 void (RADEXPLINK *qBinkSetSimulate)(U32 sim) = 0;
 45 void (RADEXPLINK *qBinkSetIOSize)(U32 iosize) = 0;
 46 S32  (RADEXPLINK *qBinkSetSoundSystem)(BINKSNDSYSOPEN open, U32 param) = 0;
 47 BINKSNDOPEN (RADEXPLINK *qBinkOpenDirectSound)(U32 param) = 0; // don‘t call directly
 48 BINKSNDOPEN (RADEXPLINK *qBinkOpenWaveOut)(U32 param) = 0; // don‘t call directly
 49 BINKSNDOPEN (RADEXPLINK *qBinkOpenMiles)(U32 param) = 0; // don‘t call directly
 50 S32 (RADEXPLINK *qBinkDX8SurfaceType)(void* lpD3Ds) = 0;
 51 S32 (RADEXPLINK *qBinkDX9SurfaceType)(void* lpD3Ds) = 0;
 52 HBINKBUFFER (RADEXPLINK *qBinkBufferOpen)( void* /*HWND*/ wnd, U32 width, U32 height, U32 bufferflags) = 0;
 53 S32 (RADEXPLINK *qBinkBufferSetHWND)( HBINKBUFFER buf, void* /*HWND*/ newwnd) = 0;
 54 S32 (RADEXPLINK *qBinkDDSurfaceType)(void PTR4* lpDDS) = 0;
 55 S32 (RADEXPLINK *qBinkIsSoftwareCursor)(void PTR4* lpDDSP, void* /*HCURSOR*/ cur) = 0;
 56 S32 (RADEXPLINK *qBinkCheckCursor)(void* /*HWND*/ wnd,S32 x,S32 y,S32 w,S32 h) = 0;
 57 S32 (RADEXPLINK *qBinkBufferSetDirectDraw)(void PTR4* lpDirectDraw, void PTR4* lpPrimary) = 0;
 58 void (RADEXPLINK *qBinkBufferClose)( HBINKBUFFER buf) = 0;
 59 S32 (RADEXPLINK *qBinkBufferLock)( HBINKBUFFER buf) = 0;
 60 S32 (RADEXPLINK *qBinkBufferUnlock)( HBINKBUFFER buf) = 0;
 61 void (RADEXPLINK *qBinkBufferSetResolution)( S32 w, S32 h, S32 bits) = 0;
 62 void (RADEXPLINK *qBinkBufferCheckWinPos)( HBINKBUFFER buf, S32 PTR4* NewWindowX, S32 PTR4* NewWindowY) = 0;
 63 S32 (RADEXPLINK *qBinkBufferSetOffset)( HBINKBUFFER buf, S32 destx, S32 desty) = 0;
 64 void (RADEXPLINK *qBinkBufferBlit)( HBINKBUFFER buf, BINKRECT PTR4* rects, U32 numrects ) = 0;
 65 S32 (RADEXPLINK *qBinkBufferSetScale)( HBINKBUFFER buf, U32 w, U32 h) = 0;
 66 char PTR4* (RADEXPLINK *qBinkBufferGetDescription)( HBINKBUFFER buf) = 0;
 67 char PTR4* (RADEXPLINK *qBinkBufferGetError)() = 0;
 68 void (RADEXPLINK *qBinkRestoreCursor)(S32 checkcount) = 0;
 69 S32 (RADEXPLINK *qBinkBufferClear)(HBINKBUFFER buf, U32 RGB) = 0;
 70 void (RADEXPLINK *qBinkSetMemory)(BINKMEMALLOC a,BINKMEMFREE f) = 0;
 71
 72 void QBink_Init(void)
 73 {
 74     hBink = LoadLibrary("binkw32.dll");
 75
 76     if (hBink)
 77     {
 78         qBinkLogoAddress = (void PTR4* (RADEXPLINK *)(void))GetProcAddress(hBink, "[email protected]");
 79         qBinkSetError = (void (RADEXPLINK *)(const char PTR4*))GetProcAddress(hBink, "[email protected]");
 80         qBinkGetError = (char PTR4* (RADEXPLINK *)(void))GetProcAddress(hBink, "[email protected]");
 81         qBinkOpen = (HBINK (RADEXPLINK *)(const char PTR4*,U32))GetProcAddress(hBink, "[email protected]");
 82         qBinkGetFrameBuffersInfo = (void (RADEXPLINK *)( HBINK, BINKFRAMEBUFFERS *))GetProcAddress(hBink, "[email protected]");
 83         qBinkRegisterFrameBuffers = (void (RADEXPLINK *)( HBINK, BINKFRAMEBUFFERS *))GetProcAddress(hBink, "[email protected]");
 84         qBinkDoFrame = (S32  (RADEXPLINK *)(HBINK))GetProcAddress(hBink, "[email protected]");
 85         qBinkNextFrame = (void (RADEXPLINK *)(HBINK))GetProcAddress(hBink, "[email protected]");
 86         qBinkWait = (S32  (RADEXPLINK *)(HBINK))GetProcAddress(hBink, "[email protected]");
 87         qBinkClose = (void (RADEXPLINK *)(HBINK))GetProcAddress(hBink, "[email protected]");
 88         qBinkPause = (S32  (RADEXPLINK *)(HBINK,S32))GetProcAddress(hBink, "[email protected]");
 89         qBinkCopyToBuffer = (S32  (RADEXPLINK *)(HBINK,void*,S32,U32,U32,U32,U32))GetProcAddress(hBink, "[email protected]");
 90         qBinkCopyToBufferRect = (S32  (RADEXPLINK *)(HBINK,void*,S32,U32,U32,U32,U32, U32, U32, U32, U32))GetProcAddress(hBink, "[email protected]");
 91         qBinkGetRects = (S32  (RADEXPLINK *)(HBINK,U32))GetProcAddress(hBink, "[email protected]");
 92         qBinkGoto = (void (RADEXPLINK *)(HBINK,U32,S32))GetProcAddress(hBink, "[email protected]");  // use 1 for the first frame
 93         qBinkGetKeyFrame = (U32  (RADEXPLINK *)(HBINK,U32,S32))GetProcAddress(hBink, "[email protected]");
 94         qBinkSetVideoOnOff = (S32  (RADEXPLINK *)(HBINK,S32))GetProcAddress(hBink, "[email protected]");
 95         qBinkSetSoundOnOff = (S32  (RADEXPLINK *)(HBINK,S32))GetProcAddress(hBink, "[email protected]");
 96         qBinkSetVolume = (void (RADEXPLINK *)(HBINK, U32, S32))GetProcAddress(hBink, "[email protected]");
 97         qBinkSetPan = (void (RADEXPLINK *)(HBINK,U32, S32))GetProcAddress(hBink, "[email protected]");
 98         qBinkSetMixBins = (void (RADEXPLINK *)(HBINK,U32, U32 PTR4*, U32))GetProcAddress(hBink, "[email protected]");
 99         qBinkSetMixBinVolumes = (void (RADEXPLINK *)(HBINK,U32, U32 PTR4*, S32 PTR4*, U32))GetProcAddress(hBink, "[email protected]");
100         qBinkService = (void (RADEXPLINK *)(HBINK))GetProcAddress(hBink, "[email protected]");
101         qBinkShouldSkip = (S32  (RADEXPLINK *)(HBINK))GetProcAddress(hBink, "[email protected]");
102         qBinkGetPalette = (void (RADEXPLINK *)( void * ))GetProcAddress(hBink, "[email protected]");
103         qBinkControlBackgroundIO = (S32  (RADEXPLINK *)(HBINK,U32))GetProcAddress(hBink, "[email protected]");
104         qBinkOpenTrack = (HBINKTRACK (RADEXPLINK *)(HBINK,U32))GetProcAddress(hBink, "[email protected]");
105         qBinkCloseTrack = (void (RADEXPLINK *)(HBINKTRACK))GetProcAddress(hBink, "[email protected]");
106         qBinkGetTrackData = (U32  (RADEXPLINK *)(HBINKTRACK,void PTR4*))GetProcAddress(hBink, "[email protected]");
107         qBinkGetTrackType = (U32  (RADEXPLINK *)(HBINK,U32))GetProcAddress(hBink, "[email protected]");
108         qBinkGetTrackMaxSize = (U32  (RADEXPLINK *)(HBINK,U32))GetProcAddress(hBink, "[email protected]");
109         qBinkGetTrackID = (U32  (RADEXPLINK *)(HBINK,U32))GetProcAddress(hBink, "[email protected]");
110         qBinkGetSummary = (void (RADEXPLINK *)(HBINK,BINKSUMMARY PTR4*))GetProcAddress(hBink, "[email protected]");
111         qBinkGetRealtime = (void (RADEXPLINK *)(HBINK,BINKREALTIME PTR4*,U32))GetProcAddress(hBink, "[email protected]");
112         qBinkSetSoundTrack = (void (RADEXPLINK *)(U32, U32 PTR4*))GetProcAddress(hBink, "[email protected]");
113         qBinkSetIO = (void (RADEXPLINK *)(BINKIOOPEN))GetProcAddress(hBink, "[email protected]");
114         qBinkSetFrameRate = (void (RADEXPLINK *)(U32,U32))GetProcAddress(hBink, "[email protected]");
115         qBinkSetSimulate = (void (RADEXPLINK *)(U32))GetProcAddress(hBink, "[email protected]");
116         qBinkSetIOSize = (void (RADEXPLINK *)(U32))GetProcAddress(hBink, "[email protected]");
117         qBinkSetSoundSystem = (S32  (RADEXPLINK *)(BINKSNDSYSOPEN, U32))GetProcAddress(hBink, "[email protected]");
118         qBinkOpenDirectSound = (BINKSNDOPEN (RADEXPLINK *)(U32))GetProcAddress(hBink, "[email protected]"); // don‘t call directly
119         qBinkOpenWaveOut = (BINKSNDOPEN (RADEXPLINK *)(U32))GetProcAddress(hBink, "[email protected]"); // don‘t call directly
120         qBinkOpenMiles = (BINKSNDOPEN (RADEXPLINK *)(U32))GetProcAddress(hBink, "[email protected]"); // don‘t call directly
121         qBinkDX8SurfaceType = (S32 (RADEXPLINK *)(void*))GetProcAddress(hBink, "[email protected]");
122         qBinkDX9SurfaceType = (S32 (RADEXPLINK *)(void*))GetProcAddress(hBink, "[email protected]");
123         qBinkBufferOpen = (HBINKBUFFER (RADEXPLINK *)( void* /*HWND*/, U32, U32, U32))GetProcAddress(hBink, "[email protected]");
124         qBinkBufferSetHWND = (S32 (RADEXPLINK *)( HBINKBUFFER, void* /*HWND*/))GetProcAddress(hBink, "[email protected]");
125         qBinkDDSurfaceType = (S32 (RADEXPLINK *)(void PTR4*))GetProcAddress(hBink, "[email protected]");
126         qBinkIsSoftwareCursor = (S32 (RADEXPLINK *)(void PTR4*, void* /*HCURSOR*/))GetProcAddress(hBink, "[email protected]");
127         qBinkCheckCursor = (S32 (RADEXPLINK *)(void* /*HWND*/,S32,S32,S32,S32))GetProcAddress(hBink, "[email protected]");
128         qBinkBufferSetDirectDraw = (S32 (RADEXPLINK *)(void PTR4*, void PTR4*))GetProcAddress(hBink, "[email protected]");
129         qBinkBufferClose = (void (RADEXPLINK *)( HBINKBUFFER))GetProcAddress(hBink, "[email protected]");
130         qBinkBufferLock = (S32 (RADEXPLINK *)( HBINKBUFFER))GetProcAddress(hBink, "[email protected]");
131         qBinkBufferUnlock = (S32 (RADEXPLINK *)( HBINKBUFFER))GetProcAddress(hBink, "[email protected]");
132         qBinkBufferSetResolution = (void (RADEXPLINK *)( S32, S32, S32))GetProcAddress(hBink, "[email protected]");
133         qBinkBufferCheckWinPos = (void (RADEXPLINK *)( HBINKBUFFER, S32 PTR4*, S32 PTR4*))GetProcAddress(hBink, "[email protected]");
134         qBinkBufferSetOffset = (S32 (RADEXPLINK *)( HBINKBUFFER, S32, S32))GetProcAddress(hBink, "[email protected]");
135         qBinkBufferBlit = (void (RADEXPLINK *)( HBINKBUFFER, BINKRECT PTR4*, U32 ))GetProcAddress(hBink, "[email protected]");
136         qBinkBufferSetScale = (S32 (RADEXPLINK *)( HBINKBUFFER, U32, U32))GetProcAddress(hBink, "[email protected]");
137         qBinkBufferGetDescription = (char PTR4* (RADEXPLINK *)( HBINKBUFFER))GetProcAddress(hBink, "[email protected]");
138         qBinkBufferGetError = (char PTR4* (RADEXPLINK *)())GetProcAddress(hBink, "[email protected]");
139         qBinkRestoreCursor = (void (RADEXPLINK *)(S32))GetProcAddress(hBink, "[email protected]");
140         qBinkBufferClear = (S32 (RADEXPLINK *)(HBINKBUFFER, U32))GetProcAddress(hBink, "[email protected]");
141         qBinkSetMemory = (void (RADEXPLINK *)(BINKMEMALLOC,BINKMEMFREE))GetProcAddress(hBink, "[email protected]");
142     }
143 }
144
145 void QBink_Shutdown(void)
146 {
147     if (hBink)
148         FreeLibrary(hBink);
149 }

How to play a Bink video file? Look here.

CBink.h

 1 #ifndef CBINK_H
 2 #define CBINK_H
 3
 4 #include "bink.h"
 5
 6 class CBink
 7 {
 8 public:
 9     CBink();
10     ~CBink();
11 public:
12     BOOL Load(char *pszFileName);
13     void SetPos(Vector vec1, Vector vec2, Vector vec3, Vector vec4);
14     void Draw(void);
15     bool IsValid(void);
16     char *GetName(void);
17     void Play(void);
18     void Pause(void);
19     void Stop(void);
20     void Free(void);
21 private:
22     int m_iTexID;
23     HBINK m_hBink;
24     char *m_pszName;
25     int m_iWidth;
26     int m_iHeight;
27     BYTE *m_pBuffer;
28     Vector m_vecRect[4];
29     bool m_bPlay;
30     float m_flStartTime;
31     int m_iCurFrame;
32     int m_iLastFrame;
33 };
34
35 #endif

CBink.cpp

  1 #include <metahook.h>
  2
  3 #include "qbink.h"
  4 #include "surface.h"
  5 #include "qgl.h"
  6
  7 #include <math.h>
  8 #include <vector.h>
  9
 10 #include "cbink.h"
 11
 12 CBink::CBink()
 13 {
 14     m_iTexID = 0;
 15     m_hBink = NULL;
 16     m_pszName = NULL;
 17     m_iWidth = 0;
 18     m_iHeight = 0;
 19     m_pBuffer = NULL;
 20     m_bPlay = false;
 21     m_flStartTime = 0.0f;
 22     m_iCurFrame = 0;
 23     m_iLastFrame = 0;
 24 }
 25
 26 CBink::~CBink()
 27 {
 28     Free();
 29 }
 30
 31 BOOL CBink::Load(char *pszFileName)
 32 {
 33     if (IsValid())
 34         return FALSE;
 35
 36     BINKSNDSYSOPEN pSoundSystem = (BINKSNDSYSOPEN)qBinkOpenWaveOut;
 37     qBinkSetSoundSystem(pSoundSystem, NULL);
 38
 39     m_hBink = qBinkOpen(pszFileName, NULL);
 40
 41     if (!m_hBink)
 42         return FALSE;
 43
 44     if (!m_pszName)
 45         m_pszName = (char *)malloc(strlen(pszFileName) * sizeof(char) + 1);
 46
 47     strcpy(m_pszName, pszFileName);
 48
 49     if (!m_iTexID)
 50         m_iTexID = g_pSurface->CreateNewTextureID();
 51
 52     m_iWidth = m_hBink->Width;
 53     m_iHeight = m_hBink->Height;
 54
 55     DWORD dwBufferSize = m_iWidth * m_iHeight * 3;
 56
 57     m_pBuffer = (BYTE *)malloc(dwBufferSize);
 58     m_bPlay = false;
 59     m_flStartTime = 0.0f;
 60     m_iCurFrame = 0;
 61     m_iLastFrame = 0;
 62
 63     qglBindTexture(GL_TEXTURE_2D, m_iTexID);
 64     qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 65     qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 66
 67     memset(m_pBuffer, 0, dwBufferSize);
 68     qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_iWidth, m_iHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, m_pBuffer);
 69
 70     qBinkGoto(m_hBink, 1, 0);
 71
 72     return TRUE;
 73 }
 74
 75 void CBink::SetPos(Vector vec1, Vector vec2, Vector vec3, Vector vec4)
 76 {
 77     if (!IsValid())
 78         return;
 79
 80     m_vecRect[0] = vec1;
 81     m_vecRect[1] = vec2;
 82     m_vecRect[2] = vec3;
 83     m_vecRect[3] = vec4;
 84 }
 85
 86 void CBink::Draw(void)
 87 {
 88     if (!IsValid())
 89         return;
 90
 91     if (!m_bPlay)
 92         return;
 93
 94     float flCurTime = gEngfuncs.GetClientTime();
 95
 96     if (m_iLastFrame < m_iCurFrame)
 97     {
 98         int iSub = m_iCurFrame - m_iLastFrame;
 99
100         for (int i = 0; i < iSub; ++i)
101         {
102             qBinkDoFrame(m_hBink);
103             qBinkNextFrame(m_hBink);
104         }
105
106         qBinkCopyToBuffer(m_hBink, m_pBuffer, m_iWidth * 3, m_iHeight, 0, 0, BINKSURFACE24R);
107
108         qglBindTexture(GL_TEXTURE_2D, m_iTexID);
109         qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_iWidth, m_iHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, m_pBuffer);
110
111         m_iLastFrame = m_iCurFrame;
112     }
113
114     if (m_iCurFrame > 0)
115     {
116         qglEnable(GL_TEXTURE_2D);
117         qglDisable(GL_CULL_FACE);
118
119         qglEnable(GL_BLEND);
120         qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
121
122         qglBindTexture(GL_TEXTURE_2D, m_iTexID);
123         qglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
124
125         qglBegin(GL_QUADS);
126         qglTexCoord2f(0.0f, 0.0f);
127         qglVertex3f(m_vecRect[0].x, m_vecRect[0].y, m_vecRect[0].z);
128         qglTexCoord2f(1.0f, 0.0f);
129         qglVertex3f(m_vecRect[1].x, m_vecRect[1].y, m_vecRect[1].z);
130         qglTexCoord2f(1.0f, 1.0f);
131         qglVertex3f(m_vecRect[2].x, m_vecRect[2].y, m_vecRect[2].z);
132         qglTexCoord2f(0.0f, 1.0f);
133         qglVertex3f(m_vecRect[3].x, m_vecRect[3].y, m_vecRect[3].z);
134         qglEnd();
135
136         qglEnable(GL_CULL_FACE);
137     }
138
139     float flPlayTime, flSubTime, flRot;
140     int iDoFrame;
141
142     flPlayTime = m_hBink->Frames * ((float)m_hBink->FrameRateDiv / (float)m_hBink->FrameRate);
143     flSubTime = flCurTime - m_flStartTime;
144     flRot = flSubTime / flPlayTime;
145
146     iDoFrame = (int)((float)m_hBink->Frames * flRot);
147
148     m_iCurFrame = iDoFrame;
149
150     if (m_iCurFrame > (int)m_hBink->Frames)
151         Stop();
152 }
153
154 bool CBink::IsValid(void)
155 {
156     return m_pBuffer != NULL;
157 }
158
159 char *CBink::GetName(void)
160 {
161     return m_pszName;
162 }
163
164 void CBink::Play(void)
165 {
166     if (!IsValid())
167         return;
168
169     m_bPlay = true;
170     m_flStartTime = gEngfuncs.GetClientTime();
171     m_iCurFrame = 0;
172     m_iLastFrame = 0;
173 }
174
175 void CBink::Pause(void)
176 {
177     if (!IsValid())
178         return;
179 }
180
181 void CBink::Stop(void)
182 {
183     if (!IsValid())
184         return;
185
186     m_bPlay = false;
187 }
188
189 void CBink::Free(void)
190 {
191     if (!IsValid())
192         return;
193
194     Stop();
195
196     if (m_hBink)
197         qBinkClose(m_hBink);
198
199     if (m_pszName)
200         free(m_pszName);
201
202     if (m_pBuffer)
203         free(m_pBuffer);
204
205     m_hBink = NULL;
206     m_pszName = NULL;
207     m_iWidth = 0;
208     m_iHeight = 0;
209     m_pBuffer = NULL;
210 }
时间: 2024-10-27 12:15:27

[MetaHook] Quake Bink function的相关文章

[MetaHook] Quake OpenGL function

Quake OpenGL function for MetaHook plugin. Thank hzqst :D QGL.h 1 #ifndef QGL_H 2 #define QGL_H 3 4 #include <gl/gl.h> 5 #include <gl/glext.h> 6 7 extern void (APIENTRY *qglAccum)(GLenum op, GLfloat value); 8 extern void (APIENTRY *qglAlphaFun

[MetaHook] Find a function signature

Find a non-public function signature, we need a tool "IDA Pro" ( You can open picture in a new window :D ) Step 1 Load your PE file in IDA Step 2 Find your function, you can use F5 to decompile a function You can refer to the string and function

[MetaHook] Quake FMOD player demo

CFMOD.h 1 #ifndef CFMOD_H 2 #define CFMOD_H 3 4 #include "qfmod.h" 5 6 struct Sound_t 7 { 8 char *pszName; 9 FMOD_SOUND *pSound; 10 FMOD_CHANNEL *pChannel; 11 Sound_t *pNext; 12 }; 13 14 #ifdef PlaySound 15 #undef PlaySound 16 #endif 17 18 class

RxJS入门(9)----调度(Bending Time with Schedulers)

如题,感觉题目没有翻译好,见英文知其义. 我一知道RxJS,我们开始把它用到我的项目中了.在一段时间后,我想,我知道能如何有效的使用它了,但是这里有一个令人心烦的问题:我如何知道使用的操作符是异步的还是同步的?换句话说,什么时候利用操作符准确的发送通知?这看起来是正确使用RxJs的机器重要的部分,但是这让我感觉很模糊. interval很明显是异步的,所以它必须在像setTimeout内部使用来发射值.但是如果使用range了?它也发射异步的?它是否阻止事件循环?from了?我曾经处处使用这些操

通过百度echarts实现数据图表展示功能

现在我们在工作中,在开发中都会或多或少的用到图表统计数据显示给用户.通过图表可以很直观的,直接的将数据呈现出来.这里我就介绍说一下利用百度开源的echarts图表技术实现的具体功能. 1.对于不太理解echarts是个怎样技术的开发者来说,可以到echarts官网进行学习了解,官网有详细的API文档和实例供大家参考学习. 2.以下是我在工作中实现整理出来的实例源码: 公用的支持js文件 echarts.js.echarts.min.js,还有其他的图表需要支持的js文件也可以到官网下载 echa

帮同学做的大一大作业:《我的家乡—郑州》

---恢复内容开始--- 最近在上海上学的一个高中同学让我帮忙,帮她做她们的计算机课程大作业. 由于关系不错我也不好意思拒绝就帮忙做了,因为这个学期刚刚开始接触HTML5和css,所以制作过程中有很多不懂的,而且由于HTML5是选修课,一星期只有一节,所以做这个花费了比较多的时间,这个网站是我制作的第一个网站,比较有纪念意义,所以发在博客上,作为纪念. 通过去做这个作业,我了解到很多课上学不到的东西.因为没有美工,从头到尾,都是我一个人在臆想,刚开始的时候,根本无从下手,我去参考别人做的家乡网站

[MetaHook] SearchPattern function

By Nagi 1 void *SearchPattern(void *pStartSearch, DWORD dwSearchLen, char *pPattern, DWORD dwPatternLen) 2 { 3 DWORD dwStartAddr = (DWORD)pStartSearch; 4 DWORD dwEndAddr = dwStartAddr + dwSearchLen - dwPatternLen; 5 6 while (dwStartAddr < dwEndAddr)

[MetaHook] Load large texture from model

We need hook "GL_LoadTexture" engine function. GL_LOADTEXTURE_SIG from hw.dll(3266) engine, can not use for other engine version. 1 #include <metahook.h> 2 #include "qgl.h" 3 #include "surface.h" 4 5 extern DWORD g_dwEn

[MetaHook] Surface hook

Hook ISurface function. 1 #include <metahook.h> 2 #include <vgui/ISurface.h> 3 4 using namespace vgui; 5 6 ISurface *g_pSurface = 0; 7 8 void (__fastcall *g_pfnCSurface_Shutdown)(void *pthis, int edx) = 0; 9 void (__fastcall *g_pfnCSurface_Run