Ticket #8251: fb2opengl.patch

File fb2opengl.patch, 4.5 KB (added by SF/luke_br, 21 years ago)

fb2opengl fixes

Line 
198a99,102
2> // No borders
3> glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
4> glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
5> // Bilinear filter
6103a108,111
7> // No borders
8> glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
9> glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
10> // Bilinear filter
11112a121
12> // No borders
13154,161c163,179
14< float xfix = xf / 128.0f; // 128 = 256/2 (half texture => 0.0 to 1.0)
15< float yfix = yf / 128.0f;
16< float texend; // End of 256x256 (from -1.0 to 1.0)
17<
18< if (flags & FB2GL_NO_320)
19< texend = 96.0f / 160.0f; // 160=320/2 (== 0.0), 256-160=96.
20< else
21< texend = 1.0f;
22---
23> GLfloat xfix = xf / 128.0f; // 128 = 256/2 (half texture => 0.0 to 1.0)
24> GLfloat yfix = yf / 128.0f;
25> GLfloat texture1_end; // End of 256x256 texture (from -1.0 to 1.0)
26>
27> if (flags & FB2GL_NO_320) {
28> // Game screen width = 320
29> // GL coordinates (-1.0 <= x <= 1.0, -1.0 <= y <= 1.0)
30> // X axis center: GL => 0.0, Game => 320/2 = 160
31> // GL texture1 width = 256 (texture2 width = 64. 256 + 64 = 320)
32> // 160 = 320/2 (half width). 256 - 160 = 96
33> texture1_end = 96.0f / 160.0f; // between 0.0 (center) and 1.0
34> // Note: wrong value may cause black vertical line (gap
35> // between texture1 and texture2 in the X axis)
36> }
37> else {
38> texture1_end = 1.0f;
39> }
40174,175d191
41< // upper left
42< glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f, -1.0f - yfix);
43176a193,194
44> glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f, -1.0f - yfix);
45> // upper left
46178,179d195
47< // lower right
48< glTexCoord2f(1.0f, 0.0f); glVertex2f(texend + xfix, 1.0f);
49181c197,199
50< glTexCoord2f(1.0f, 1.0f); glVertex2f(texend + xfix, -1.0f - yfix);
51---
52> glTexCoord2f(1.0f, 0.0f); glVertex2f(texture1_end + xfix, 1.0f);
53> // lower right
54> glTexCoord2f(1.0f, 1.0f); glVertex2f(texture1_end + xfix, -1.0f - yfix);
55185c203
56< // 64x256
57---
58> // 64x256 (texture2)
59189,190d206
60< // upper left
61< glTexCoord2f(0.0f, 1.0f); glVertex2f(texend + xfix, -1.0f - yfix);
62192,194c208,210
63< glTexCoord2f(0.0f, 0.0f); glVertex2f(texend + xfix, 1.0f);
64< // lower right
65< glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f + xfix, 1.0f);
66---
67> glTexCoord2f(0.0f, 1.0f); glVertex2f(texture1_end + xfix, -1.0f - yfix);
68> // upper left
69> glTexCoord2f(0.0f, 0.0f); glVertex2f(texture1_end + xfix, 1.0f);
70195a212,213
71> glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f + xfix, 1.0f);
72> // lower right
73255c273
74< int x, y, scr_pitch, byte;
75---
76> int x, y, scr_pitch, _byte;
77259c277
78< byte = 0;
79---
80> _byte = 0;
81262c280
82< byte = pitch; // Bytes perl pixel (for RGBA mode)
83---
84> _byte = pitch; // Bytes perl pixel (for RGBA mode)
85294,296c312,314
86< RGBAFrameBuffer1[(y-yskip)*320*4 + (x-xskip)*4 + 0] = *(tempFrameBuffer+(x*byte));
87< RGBAFrameBuffer1[(y-yskip)*320*4 + (x-xskip)*4 + 1] = *(tempFrameBuffer+(x*byte)+1);
88< RGBAFrameBuffer1[(y-yskip)*320*4 + (x-xskip)*4 + 2] = *(tempFrameBuffer+(x*byte)+2);
89---
90> RGBAFrameBuffer1[(y-yskip)*320*4 + (x-xskip)*4 + 0] = *(tempFrameBuffer+(x*_byte));
91> RGBAFrameBuffer1[(y-yskip)*320*4 + (x-xskip)*4 + 1] = *(tempFrameBuffer+(x*_byte)+1);
92> RGBAFrameBuffer1[(y-yskip)*320*4 + (x-xskip)*4 + 2] = *(tempFrameBuffer+(x*_byte)+2);
93298,300c316,318
94< RGBAFrameBuffer1[(y-yskip)*256*4 + (x-xskip)*4 + 0] = *(tempFrameBuffer+(x*byte));
95< RGBAFrameBuffer1[(y-yskip)*256*4 + (x-xskip)*4 + 1] = *(tempFrameBuffer+(x*byte)+1);
96< RGBAFrameBuffer1[(y-yskip)*256*4 + (x-xskip)*4 + 2] = *(tempFrameBuffer+(x*byte)+2);
97---
98> RGBAFrameBuffer1[(y-yskip)*256*4 + (x-xskip)*4 + 0] = *(tempFrameBuffer+(x*_byte));
99> RGBAFrameBuffer1[(y-yskip)*256*4 + (x-xskip)*4 + 1] = *(tempFrameBuffer+(x*_byte)+1);
100> RGBAFrameBuffer1[(y-yskip)*256*4 + (x-xskip)*4 + 2] = *(tempFrameBuffer+(x*_byte)+2);
101302,304c320,322
102< RGBAFrameBuffer2[(y-yskip)*64*4 + (x-256)*4 + 0] = *(tempFrameBuffer+(x*byte));
103< RGBAFrameBuffer2[(y-yskip)*64*4 + (x-256)*4 + 1] = *(tempFrameBuffer+(x*byte)+1);
104< RGBAFrameBuffer2[(y-yskip)*64*4 + (x-256)*4 + 2] = *(tempFrameBuffer+(x*byte)+2);
105---
106> RGBAFrameBuffer2[(y-yskip)*64*4 + (x-256)*4 + 0] = *(tempFrameBuffer+(x*_byte));
107> RGBAFrameBuffer2[(y-yskip)*64*4 + (x-256)*4 + 1] = *(tempFrameBuffer+(x*_byte)+1);
108> RGBAFrameBuffer2[(y-yskip)*64*4 + (x-256)*4 + 2] = *(tempFrameBuffer+(x*_byte)+2);
109415c433
110< if (x < 256 && tex1_w) {
111---
112> if (tex1_w && x < 256) {
113424c442
114< } else if (x >= 256 && tex2_w) {
115---
116> } else if (tex2_w && x >= 256) {
117505d522
118<