本帖最后由 shane007 于 2023-9-4 18:48 编辑 - i- Q9 C, ?) u4 S: N+ ^7 S
: S& x3 p" `: S* V1 c/ W
这是个opengl引擎的游戏,对opengl的初始化是在scream.exe里边完成的。
8 u3 W. J1 c; ~+ a* h- @对于opengl的游戏我们主要关注glGenLists和glCallList这2个函数) ~) K& Z' P. R8 u" o& ^+ ] r
) Y% W! R0 h$ k# t7 z, k M; D9 g
glGenLists的调用有4处,前3处参数为1,应该不是。
7 ^3 t/ }* w0 G; a0 W7 o' _一下是第四处代码,这里应该就是生成字体的地方。) h/ G( |; Z, E8 f+ {( Q
从代码里可以看出,字体材质长宽各是16各字符,共256个字符,此处要修改。
5 C$ s1 y0 I, b2 p' [* K: C. L) Z8 C9 I- int sub_40BEB0()
' D0 W6 D) @$ b: E# U - {
( K; i2 D, U/ z% \ - signed int v0; // ebx, i- \! s3 v0 P+ \5 I
- int v1; // ecx
! N [4 X2 T; x - float v2; // ST18_4
3 O2 e: c x% L- `5 T# d. Q - float v3; // ST1C_4
3 v6 c$ |6 |6 g5 O5 f F; D$ w - float v4; // ST20_4
6 V9 I3 x& L+ \. x - float v5; // ST24_46 l# {6 ~- ]( G1 [( m1 L
- int result; // eax# s4 C+ c$ a% K) J9 G+ b! w, E: `
" j- ~6 B3 n- `9 p6 k9 ~- v0 = 0;9 V8 G# e& z. ~
- dword_4DF5130 = glGenLists(272);
6 m! @% T% \* J0 ^ P+ F - do7 v# R- F8 ^1 A$ j
- {0 H, a- s) W" [) \ e8 Q
- v2 = (double)(v0 % -16) * flt_483450;+ t: t K8 _! [: i5 `- C% Y2 w2 q
- v3 = (double)(v0 / 16) * flt_483450;- _6 Y7 B; f; q4 ^6 z
- glNewList(v1, v0 % 16, v0 + dword_4DF5130, 4864);
$ n, |( b1 ]" b5 Y3 P: i |! ~ - glBegin(7);4 r& N) Z1 ]$ ?! g) a0 K' u
- glTexCoord2f(LODWORD(v2), LODWORD(v3));
4 R1 T6 H! C: b! {( p - glVertex2i(0, 0);+ b- Q* \& f' l0 Z& _; P
- v4 = v2 + flt_483450;
1 ?2 @0 M2 y0 e$ q) A/ Z - glTexCoord2f(LODWORD(v4), LODWORD(v3));
! M; W) g; P, y2 d - glVertex2i(16, 0);
% M& K8 w: k8 K' u6 ?0 w - v5 = v3 + flt_483454;7 m) W& R" u9 r* Q# x7 r
- glTexCoord2f(LODWORD(v4), LODWORD(v5));% J; b( v* g. z) ~6 i
- glVertex2i(16, 16);
) A8 V* a8 r" e: w' j9 k- D - glTexCoord2f(LODWORD(v2), LODWORD(v5));
% [7 h( L! O" e+ d - glVertex2i(0, 16);
9 E8 u8 O8 E; P& [/ ^8 R/ V - glEnd();
- T5 {0 y; ?2 Y6 [. v: R* i: q6 g' t - ++v0;
, U" X, [3 k9 V2 z9 R - glTranslated(0, 1076101120, 0, 0, 0, 0);
( J+ k c" ]0 e4 v% i - result = glEndList();. Q, X/ {1 e9 h
- }+ k/ M B( s4 u
- while ( v0 < 272 );
+ _5 l; w6 Y9 y) p- Y D8 f - return result;
( O" W0 S W/ V% n/ o* p' W - }
复制代码
6 J4 G+ `& m! @* y( I
1 T0 b8 |+ l9 N5 Y2 x6 ^对glCallList的调用只有以下一处,
' O5 E: | R. e* S D4 V) @这是显示单个字符还是字符串的方法,待以后再确认。
# C& a, i# k. e% ]& J+ v glCallLists(strlen(&v7), 5121, &v7);
( I- R/ |- s7 e5121为0x1401 ,即 GL_UNSIGNED_BYTE ,是单字节。8 T' Q5 ^9 d M, N, N
0 P4 l5 Z6 \2 r- W, h: C& ^
- #define GL_BYTE 0x1400
0 M2 z3 B% d* q7 l - #define GL_UNSIGNED_BYTE 0x1401; F2 p: I" {5 `- k
- #define GL_SHORT 0x14025 [7 v' y, x: s _
- #define GL_UNSIGNED_SHORT 0x1403& _+ G* G- n- Y% l1 t$ f9 L) f
- #define GL_INT 0x1404
# |8 U/ H5 p& y$ T! o - #define GL_UNSIGNED_INT 0x14051 \4 f% ~8 H+ d3 y% l
- #define GL_FLOAT 0x14064 f- j m7 s' R+ U- N5 |; m h
- #define GL_2_BYTES 0x1407
7 Q" a! a( D5 Y5 n - #define GL_3_BYTES 0x14083 b8 s% I( U$ T( v1 Z. ?
- #define GL_4_BYTES 0x1409
I* n( C2 n9 ]) | - #define GL_DOUBLE 0x140A
复制代码 / }4 h# T3 A& X4 B$ q( i
5 f/ J! l; y& Z4 a, Y* q! N$ H7 n
- & b) Q3 w, ^- d, D4 t
- int __cdecl sub_40BFD0(signed int a1, int a2, int a3, int a4, char a5): F3 r5 R, |1 E6 M; e7 K
- {
. V3 g. t* T! ? - int v5; // ecx
- X0 V& S) C0 m: |. H* A - int result; // eax
1 L$ u9 i" N2 [9 y) E- H - char v7; // [esp+18h] [ebp-118h]/ z% K$ t1 w5 W. }/ s
- char *v8; // [esp+118h] [ebp-18h]3 g$ F2 L$ Y, R0 b* I6 S
- int v9; // [esp+11Ch] [ebp-14h]* m* z, K7 V* o
- int v10; // [esp+128h] [ebp-8h]* G* @% X- i0 V5 [+ `6 k
- , ^, B1 h- ~2 N, F7 i# X
- v10 = v5;( w& T7 k& J i/ I* j2 y
- if ( a4 )
9 o- Z$ x4 u9 V4 c - {
4 R& M4 o/ y0 U* ?- h - v8 = &a5;
3 q ~8 \! a" Z. J# J5 l- o8 R+ ~ - sub_41BA00(v5, a4);
0 t. n9 q0 G- k( {' n& K( k - v8 = 0;2 a) l: N( c' d: C7 ~& {- o
- glBlendFunc(770, 771);7 B# o4 F6 a0 }: n: o2 Q$ g* A; l
- glBindTexture(3553, dword_4DF3BC4[8 * a3]);
1 @' E' ?4 ~1 W& o+ a# n - glPushMatrix();
H* P) H5 {; J {' E) I5 f - glLoadIdentity(); ~3 w+ X3 a8 H8 `/ I6 y# _$ F
- v9 = a1;% y8 T! R6 w* u
- glTranslated(
9 A4 `2 I3 }) x3 f* Z: x3 v; n - COERCE_UNSIGNED_INT64((double)a1),
& |2 S/ u# D, o7 F+ [) u& N - COERCE_UNSIGNED_INT64((double)a1) >> 32,
3 |, w0 _0 J6 u0 i - COERCE_UNSIGNED_INT64((double)(dword_4DF8B68 - a2)),4 A- V. K, z' [- y _8 d
- COERCE_UNSIGNED_INT64((double)(dword_4DF8B68 - a2)) >> 32,
5 X2 W, r, L0 Y* K& Q; n. X - 0,+ I' X& {) I3 N
- 0);& k3 k& d3 _; X+ S E$ x& D+ n
- glPushAttrib(0x20000);9 u' w' R' y) P1 J2 J3 S# ^2 g
- glListBase(dword_4DF5130 + 16);+ h1 p/ V+ `8 w, \: C
- glCallLists(strlen(&v7), 5121, &v7);
4 {: l8 S. K* i - glPopAttrib();( _+ s& h) y- f- Y
- result = glPopMatrix();7 X6 Z: O, w( A
- }3 Z. {+ u% T+ h
- return result;+ w# V8 g' O- J$ F. U% A
- }
2 `. v; G+ D* K9 w4 |! F
复制代码
( X$ Y# o' U! R* w: |3 Q+ ?* p& Z, Q4 X1 I/ g
3 t0 t% s- L( G7 |7 G! {0 e |