本帖最后由 shane007 于 2023-9-4 18:48 编辑 $ j$ `1 \7 i0 t0 d7 i% N
0 [6 {9 B4 p0 S: h* W, H: D" P这是个opengl引擎的游戏,对opengl的初始化是在scream.exe里边完成的。
+ n, D' K0 w6 Z- W% Z" P" I* h$ D对于opengl的游戏我们主要关注glGenLists和glCallList这2个函数, X7 _2 j2 w N9 d; l
7 w' C# \3 N/ k% T! }$ B2 g
) J& W4 c6 w3 C# Y7 u
glGenLists的调用有4处,前3处参数为1,应该不是。/ y2 V- j' X# D" s2 @7 U- ~: u0 p
一下是第四处代码,这里应该就是生成字体的地方。
d5 a3 {+ \2 f" w* k- E+ `从代码里可以看出,字体材质长宽各是16各字符,共256个字符,此处要修改。8 R2 T5 v) c2 O% Y( d
- int sub_40BEB0()3 Y: N& o: C% x* o
- {7 M2 F( U1 A: p9 t7 [' \( S3 x
- signed int v0; // ebx
. Z* G" V& ^% K7 O( w - int v1; // ecx
& P4 k" \2 A: U - float v2; // ST18_4
; Z; r# W* T' p5 W) t - float v3; // ST1C_4' \8 Y! b) ~/ I
- float v4; // ST20_40 D( ]$ K! ]) C6 Q+ O
- float v5; // ST24_4
" |# i. l, V) { - int result; // eax3 l- ^; g% l& ^" y0 @( O
- " j% K/ {9 z; @& d' \
- v0 = 0;8 W' F2 Z, ]# H% E; f% m: d$ h
- dword_4DF5130 = glGenLists(272);
* R' P1 R; E) f5 S) f - do# o6 t4 g" p5 b* n1 v. [
- {
( c/ N3 D- @; O9 C - v2 = (double)(v0 % -16) * flt_483450;' Y" i y8 y4 |/ z. q& W7 c3 [
- v3 = (double)(v0 / 16) * flt_483450;% Z" m/ Y* p7 S6 u- h
- glNewList(v1, v0 % 16, v0 + dword_4DF5130, 4864);+ a" s6 g* E- j4 |/ y7 P
- glBegin(7);
( O7 _: H A2 Y$ T, s - glTexCoord2f(LODWORD(v2), LODWORD(v3));
7 f; q# w! m5 F; K4 k% Y" d - glVertex2i(0, 0);
- `" \, r8 f( C+ S; O2 n! l j/ R - v4 = v2 + flt_483450;4 u" ^) ]: Y+ N! d. a
- glTexCoord2f(LODWORD(v4), LODWORD(v3));
- i" m7 H _$ A6 e1 L% \4 X - glVertex2i(16, 0);9 I, s( F- k; L+ C
- v5 = v3 + flt_483454;
& C8 m5 Q. h! z0 _' t - glTexCoord2f(LODWORD(v4), LODWORD(v5));
) \0 d/ ^' T; C$ s8 L8 ^ - glVertex2i(16, 16);2 q1 c0 L8 K. l" e0 r( H
- glTexCoord2f(LODWORD(v2), LODWORD(v5));
9 y' V1 C0 B& t - glVertex2i(0, 16);" n9 Q" F# u/ M" X4 } U9 h1 {
- glEnd();
9 R' q9 f3 P" _1 a; ]/ c - ++v0;
9 D m. R$ E( a' B$ U8 n - glTranslated(0, 1076101120, 0, 0, 0, 0);
. p- N: u e6 d( o4 O9 k2 d+ l - result = glEndList();( p c. @/ ?* J; a8 W1 o- |4 l4 P
- }
/ J# n& l4 h- v! L2 m - while ( v0 < 272 );0 a! a* S; N2 Q8 ?9 r: H
- return result;- h; e& E1 o- E
- }
复制代码 ' s5 ]3 q( Z$ s/ Y U' C
4 l9 Z* I/ V6 W( m: @' w) n+ ?
对glCallList的调用只有以下一处,
5 W: c5 d/ ~+ w. V! Y; k这是显示单个字符还是字符串的方法,待以后再确认。 N6 E0 h' B; n' x! }* O$ g3 j" }
glCallLists(strlen(&v7), 5121, &v7);
+ K4 C- F q" ^/ ]! Z5 @2 [5121为0x1401 ,即 GL_UNSIGNED_BYTE ,是单字节。7 V! G5 Z- i& E5 X
* Z* T V7 c' J0 U- #define GL_BYTE 0x14009 }. [/ N4 R5 b, j# G3 P2 y8 [
- #define GL_UNSIGNED_BYTE 0x1401' A2 L7 R# A$ C1 N
- #define GL_SHORT 0x1402* r& w6 V0 W6 s1 h% H" ]
- #define GL_UNSIGNED_SHORT 0x1403
8 k5 w- b8 Z, [ - #define GL_INT 0x1404: d$ c/ p& H1 Z$ ~5 ]5 _ ~
- #define GL_UNSIGNED_INT 0x1405
% |0 S1 r5 I! G - #define GL_FLOAT 0x1406# L5 T' w l" W% D
- #define GL_2_BYTES 0x1407
K6 S' E! ]- Z; t - #define GL_3_BYTES 0x1408
2 t. d: L; Z0 O; q4 C - #define GL_4_BYTES 0x1409
0 S; E, }3 G, [# V - #define GL_DOUBLE 0x140A
复制代码 % o# ?, C& X/ e4 l% u
3 Y# `" ~. ]- L- 4 K! U" r' T+ g8 D# N2 C5 I
- int __cdecl sub_40BFD0(signed int a1, int a2, int a3, int a4, char a5)
# C/ w8 Q6 ^, ~8 h - {
/ F7 a2 A6 V9 G0 S$ z - int v5; // ecx
4 t9 t$ T' f# I) {# f - int result; // eax9 b0 h" b$ ]4 V
- char v7; // [esp+18h] [ebp-118h]
$ D# q; p1 s3 [/ X( _! W+ y - char *v8; // [esp+118h] [ebp-18h]+ U/ H! w7 t: I1 f
- int v9; // [esp+11Ch] [ebp-14h]9 L% d9 s2 y! K4 r9 r1 z1 |5 P
- int v10; // [esp+128h] [ebp-8h]* q9 X8 l5 Z2 q# A
- - Q$ O2 V% D: S4 r) U4 \- z% i1 e1 B
- v10 = v5;# k6 [" w4 C( `9 i1 G
- if ( a4 )
2 q" V9 p8 t; V5 K* E - {
9 z* l# A( {' Y0 i5 C - v8 = &a5;2 j3 L; l% m7 B
- sub_41BA00(v5, a4);" a* M) W6 ^# B7 r7 W
- v8 = 0;( L7 o5 v% A# \" C; D
- glBlendFunc(770, 771);
1 Y* j' L% e$ t# V5 y% q - glBindTexture(3553, dword_4DF3BC4[8 * a3]);
, n1 @7 }5 y( e - glPushMatrix();/ ^% q- h7 w6 n
- glLoadIdentity();
' J% S5 q! E% u$ M) ~. N8 u - v9 = a1;6 A2 f) T, B p7 U: x
- glTranslated(
5 F# F7 u" p6 \" Y - COERCE_UNSIGNED_INT64((double)a1),
9 c- S `6 o6 v7 s9 W' l" p2 V - COERCE_UNSIGNED_INT64((double)a1) >> 32,
8 O( c$ z( n; X( @ - COERCE_UNSIGNED_INT64((double)(dword_4DF8B68 - a2)),& r: q" Z3 F; w
- COERCE_UNSIGNED_INT64((double)(dword_4DF8B68 - a2)) >> 32,
: Q. a: Q i. H& b7 P) n - 0,! C: N. D& \6 M$ o4 V8 J
- 0);
$ K( l, ~/ P w+ R2 ? - glPushAttrib(0x20000);
. y8 x+ x' H' ^" C( W - glListBase(dword_4DF5130 + 16);% O B2 O5 C, k' U% H/ J
- glCallLists(strlen(&v7), 5121, &v7);% Q8 D. R* F' K3 T4 |; A7 M
- glPopAttrib();
4 m, z2 K( [4 `$ [3 Q( C- ?, T - result = glPopMatrix();' `3 e" x5 m9 \' _0 ?1 \3 @
- }
1 ]7 E9 A. L) b$ F: `1 K - return result;
+ G! q) M1 E, k: b2 F. `4 B u {* x - }6 v# y; D( s* A# m
复制代码
- r9 L7 e- X" m! r3 M
4 x2 G' ^: x ?3 w# z* k6 h, w7 S$ C( W$ B+ s# w+ c, ^/ s) z* E
|