本帖最后由 shane007 于 2023-9-4 18:48 编辑 , f8 r! a- A5 Y! g
5 A( t+ u1 g7 I! F这是个opengl引擎的游戏,对opengl的初始化是在scream.exe里边完成的。
2 W1 ~. A9 r/ {5 N) F5 J5 ^! @对于opengl的游戏我们主要关注glGenLists和glCallList这2个函数
# @5 K( a! m5 I5 r! K* O
+ N, K6 P" L% f3 l- @
6 y( W# H/ M; X/ |/ t4 o- ^glGenLists的调用有4处,前3处参数为1,应该不是。7 B; ?5 [/ z s1 h6 w
一下是第四处代码,这里应该就是生成字体的地方。6 X" N* M& r) f$ V# P7 h' [8 ?
从代码里可以看出,字体材质长宽各是16各字符,共256个字符,此处要修改。- V# M1 s" I; q+ Q- y9 r
- int sub_40BEB0()
1 [+ E/ V7 m3 R+ t1 q+ p4 h" _ - {5 `! D9 A5 `* M t
- signed int v0; // ebx
) @) n9 Z/ S: G& ^) [/ _ - int v1; // ecx
' i4 Q! M+ v0 \- P. s) v6 } - float v2; // ST18_4
( ?7 r5 c8 j1 v$ b( g% v - float v3; // ST1C_4
! ] w/ N5 G& R) Q' A( Y: ?# u - float v4; // ST20_4: O, r8 R7 J1 C" [ z7 w
- float v5; // ST24_4
3 V- Q6 Y& m) C' e - int result; // eax( B' ?& f/ I2 m9 L8 p# _6 i
& _+ L0 b9 |* x( _; E1 e) I- v0 = 0;5 G: ]% o- X, u: D5 L, D
- dword_4DF5130 = glGenLists(272);
# |- N# @- e7 W - do
1 f9 D) z* R9 z L/ g2 W; w8 a - {
( H* u" \# Z- c* r, o1 M4 }" z3 m: ?/ V - v2 = (double)(v0 % -16) * flt_483450;, ^; c! e8 S8 I* r( ^
- v3 = (double)(v0 / 16) * flt_483450;
) i+ H2 b5 d9 K2 W1 W8 Z/ W; F - glNewList(v1, v0 % 16, v0 + dword_4DF5130, 4864);
( j: d( ?7 o+ n i7 E1 w - glBegin(7);- q. y6 T& F: Y* q
- glTexCoord2f(LODWORD(v2), LODWORD(v3));
U( _. s4 s0 F2 o - glVertex2i(0, 0);' s- E- _4 ] o8 l- P! `
- v4 = v2 + flt_483450;( k. p4 Z* y G: o5 z
- glTexCoord2f(LODWORD(v4), LODWORD(v3));- b3 `8 Z/ d/ S& Z
- glVertex2i(16, 0);
! J9 W" X; Z! Z, {7 G - v5 = v3 + flt_483454;6 l; @! ]8 W" v2 H9 }7 a$ q. k
- glTexCoord2f(LODWORD(v4), LODWORD(v5));
- F* H0 M) z( P. W/ B5 _8 ?4 I - glVertex2i(16, 16);2 b0 ~8 s" ^- |1 K N
- glTexCoord2f(LODWORD(v2), LODWORD(v5));
! ?& L* M2 |( _# N# a; C3 p - glVertex2i(0, 16);
# S1 h* s) n/ u% z2 I7 z - glEnd();2 _+ E- f5 \/ i, f& U W, Q
- ++v0;
& H' r9 j- o$ W0 y& X& J - glTranslated(0, 1076101120, 0, 0, 0, 0);
$ I3 a: R. p+ U - result = glEndList();
, @0 s; u& p; i# M/ s: q - }
2 Q! K' o* @* ] - while ( v0 < 272 );
i+ s% t M; ^+ q& G& I - return result;
' X5 N8 i# _* [ - }
复制代码
% |: Z8 ?& Z1 P' j5 p
1 `: L; r; p8 C8 Z( r, i对glCallList的调用只有以下一处,2 h0 m8 X5 y6 r2 P1 x
这是显示单个字符还是字符串的方法,待以后再确认。
7 E0 _, h& P8 ]* h" G glCallLists(strlen(&v7), 5121, &v7);1 F6 T5 c: @6 k3 _! l
5121为0x1401 ,即 GL_UNSIGNED_BYTE ,是单字节。
8 h7 B. [( E& O; G- u. \
3 _$ a% A/ Z! s, K' t9 R" u4 f- #define GL_BYTE 0x1400 d* a, v5 h! N% Y K
- #define GL_UNSIGNED_BYTE 0x14016 _6 m0 a5 w7 `) N6 K
- #define GL_SHORT 0x1402
: e h" t$ `6 N! z5 O+ \ - #define GL_UNSIGNED_SHORT 0x1403/ X# X* s `+ W) v* a
- #define GL_INT 0x1404+ i, m/ A" g: e4 ]
- #define GL_UNSIGNED_INT 0x1405
+ S6 |9 }9 P9 v3 u+ S - #define GL_FLOAT 0x1406
; D8 e& x2 h D - #define GL_2_BYTES 0x1407
7 `& e0 Y- _* f2 B, A& g - #define GL_3_BYTES 0x1408
8 f$ E e6 Z) B/ G' N, t { - #define GL_4_BYTES 0x14096 A; r" y0 N2 i: O
- #define GL_DOUBLE 0x140A
复制代码
( B! N5 M. d( D# k& n! M- x R( n* \
- # _4 o9 _4 I O/ E! m, l
- int __cdecl sub_40BFD0(signed int a1, int a2, int a3, int a4, char a5)* Y8 P5 a( R: ]: ]4 U
- { U" |3 ]8 f$ h- H- e
- int v5; // ecx
7 E. _& S- m) Z - int result; // eax
/ Q3 T. r+ ? z8 _' q, g - char v7; // [esp+18h] [ebp-118h]
" z- l- Y3 f% _- @( \% @0 [ - char *v8; // [esp+118h] [ebp-18h]
1 k: b9 z' G' o- a - int v9; // [esp+11Ch] [ebp-14h]; C1 ]) ^3 x7 b' r$ t
- int v10; // [esp+128h] [ebp-8h]
. V2 N# d! c5 H - ( h) a% i9 c$ o" V, ~7 l
- v10 = v5;
* ^5 m5 q: ?& }( j2 u5 T# E2 J8 L7 R - if ( a4 )
% a$ b' R0 j6 H1 G, D - {2 w& O( L( L4 G! q
- v8 = &a5;; ]8 d( V* Y+ I3 Z" ~3 K0 U8 g
- sub_41BA00(v5, a4);4 d4 T9 i' u# X( z/ _% P. D+ O
- v8 = 0;
' R. t5 r4 ]+ k) ]5 p% p - glBlendFunc(770, 771);! r- | _7 G* l2 s/ {/ c
- glBindTexture(3553, dword_4DF3BC4[8 * a3]);
0 z) N* k% Y# l - glPushMatrix();6 E% P1 ~" L/ S* C! N# l
- glLoadIdentity();
9 ?* t( N6 X% u6 B' h0 b - v9 = a1;
^+ v5 h: t1 C - glTranslated(
6 T/ h6 X7 m+ [ - COERCE_UNSIGNED_INT64((double)a1),( \* V2 i; i d- Q$ D* B
- COERCE_UNSIGNED_INT64((double)a1) >> 32,: Q6 i3 ]) q8 F, W& x
- COERCE_UNSIGNED_INT64((double)(dword_4DF8B68 - a2)),1 I4 M' J3 }: R' `5 q# z
- COERCE_UNSIGNED_INT64((double)(dword_4DF8B68 - a2)) >> 32,0 E& {/ H* z v1 g% e R5 I3 ]" z
- 0,
5 H0 Q7 Q" Z" p4 F! `% y - 0); k: E$ i8 E* g4 X! ]& `& C& T; g# Y
- glPushAttrib(0x20000);
6 d1 F1 X7 y) `2 w W - glListBase(dword_4DF5130 + 16);
- `: P) H7 S4 b; G# ^4 U' L0 z - glCallLists(strlen(&v7), 5121, &v7);8 @! P7 ^* S7 P& M
- glPopAttrib();2 g' j# @( ~1 k+ o$ m4 K+ }+ c
- result = glPopMatrix();! y( _: z& ^* Q7 y
- }
& e' [8 ~, u' v" e, [ - return result;4 L9 j( Y8 `. K% q" y7 a; \' D
- }
+ S3 W4 S! r! F* B4 Y0 F
复制代码
) S- Q r6 ^3 W9 D: }7 K
( d% S; P4 |; E1 p7 d- d; P1 v2 w1 j( R3 I1 w
|