World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
RenderOpenGL.cpp
См. документацию.
1 #ifdef _WINDOWS
2  #pragma comment(lib, "opengl32.lib")
3  #pragma comment(lib, "glu32.lib")
4 
5  // on windows, this is required in gl/glu.h
6  #if !defined(APIENTRY)
7  #define APIENTRY __stdcall
8  #endif
9 
10  #if !defined(WINGDIAPI)
11  #define WINGDIAPI
12  #endif
13 
14  #if !defined(CALLBACK)
15  #define CALLBACK __stdcall
16  #endif
17 #endif
18 
19 #include <GL/glu.h>
20 #include <GL/gl.h>
21 
22 
23 #include <SDL.h>
24 #include <SDL_opengl_glext.h>
25 
26 #include <algorithm>
27 
28 #include "Engine/Engine.h"
29 #include "Engine/OurMath.h"
30 #include "Engine/Party.h"
31 #include "Engine/SpellFxRenderer.h"
32 
33 #include "Engine/Graphics/Image.h"
38 #include "Engine/Graphics/Lights.h"
41 
46 
47 #include "Engine/Objects/Actor.h"
48 
49 #include "Platform/Api.h"
50 #include "Platform/OSWindow.h"
51 
52 std::shared_ptr<IRender> render;
55 unsigned int uNumBillboardsToDraw;
57 
59 
60 // sky billboard stuff
61 
62 void SkyBillboardStruct::CalcSkyFrustumVec(int x1, int y1, int z1, int x2, int y2, int z2) {
63  // 6 0 0 0 6 0
64 
65  int cosy = pIndoorCameraD3D->int_cosine_y;
66  int cosx = pIndoorCameraD3D->int_cosine_x;
67  int siny = pIndoorCameraD3D->int_sine_y;
68  int sinx = pIndoorCameraD3D->int_sine_x;
69 
70  // positions all minus ?
71  int v11 = cosy * -pIndoorCameraD3D->vPartyPos.x +
72  siny * -pIndoorCameraD3D->vPartyPos.y;
73  int v24 = cosy * -pIndoorCameraD3D->vPartyPos.y -
74  siny * -pIndoorCameraD3D->vPartyPos.x;
75 
76  // cam position transform
78  this->field_0_party_dir_x = fixpoint_mul(v11, cosx) +
79  fixpoint_mul((-pIndoorCameraD3D->vPartyPos.z) << 16, sinx);
80  this->field_4_party_dir_y = v24;
81  this->field_8_party_dir_z =
82  fixpoint_mul((-pIndoorCameraD3D->vPartyPos.z) << 16, cosx) /*-*/ +
83  fixpoint_mul(v11, sinx);
84  }
85  else {
86  this->field_0_party_dir_x = v11;
87  this->field_4_party_dir_y = v24;
89  }
90 
91  // set 1 position transfrom (6 0 0) looks like cam left vector
93  int v17 = fixpoint_mul(x1, cosy) + fixpoint_mul(y1, siny);
94 
95  this->CamVecLeft_Z = fixpoint_mul(v17, cosx) + fixpoint_mul(z1, sinx); // dz
96  this->CamVecLeft_X = fixpoint_mul(y1, cosy) - fixpoint_mul(x1, siny); // dx
97  this->CamVecLeft_Y = fixpoint_mul(z1, cosx) /*-*/ + fixpoint_mul(v17, sinx); // dy
98  }
99  else {
100  this->CamVecLeft_Z = fixpoint_mul(x1, cosy) + fixpoint_mul(y1, siny); // dz
101  this->CamVecLeft_X = fixpoint_mul(y1, cosy) - fixpoint_mul(x1, siny); // dx
102  this->CamVecLeft_Y = z1; // dy
103  }
104 
105  // set 2 position transfrom (0 6 0) looks like cam front vector
107  int v19 = fixpoint_mul(x2, cosy) + fixpoint_mul(y2, siny);
108 
109  this->CamVecFront_Z = fixpoint_mul(v19, cosx) + fixpoint_mul(z2, sinx); // dz
110  this->CamVecFront_X = fixpoint_mul(y2, cosy) - fixpoint_mul(x2, siny); // dx
111  this->CamVecFront_Y = fixpoint_mul(z2, cosx) /*-*/ + fixpoint_mul(v19, sinx); // dy
112  }
113  else {
114  this->CamVecFront_Z = fixpoint_mul(x2, cosy) + fixpoint_mul(y2, siny); // dz
115  this->CamVecFront_X = fixpoint_mul(y2, cosy) - fixpoint_mul(x2, siny); // dx
116  this->CamVecFront_Y = z2; // dy
117  }
118 
119  this->CamLeftDot = fixpoint_dot(
120  this->CamVecLeft_Z, this->field_0_party_dir_x,
121  this->CamVecLeft_X, this->field_4_party_dir_y,
122  this->CamVecLeft_Y, this->field_8_party_dir_z);
123  this->CamFrontDot = fixpoint_dot(
124  this->CamVecFront_Z, this->field_0_party_dir_x,
125  this->CamVecFront_X, this->field_4_party_dir_y,
126  this->CamVecFront_Y, this->field_8_party_dir_z);
127 }
128 
130  : RenderBase() {
131 }
132 
133 RenderOpenGL::~RenderOpenGL() { /*__debugbreak();*/ }
134 
136 
138 
140  __debugbreak();
141  return 0;
142 }
143 
144 unsigned int RenderOpenGL::GetActorTintColor(int DimLevel, int tint, float WorldViewX, int a5, RenderBillboard *Billboard) {
145  __debugbreak();
146  return 0;
147 }
148 
149 
150 // when losing and regaining window focus - not required for OGL??
151 void RenderOpenGL::RestoreFrontBuffer() { /*__debugbreak();*/ }
152 void RenderOpenGL::RestoreBackBuffer() { /*__debugbreak();*/ }
153 
154 void RenderOpenGL::BltBackToFontFast(int a2, int a3, Rect *a4) {
155  __debugbreak(); // never called anywhere
156 }
157 
158 
159 
160 unsigned int RenderOpenGL::GetRenderWidth() const { return window->GetWidth(); }
161 unsigned int RenderOpenGL::GetRenderHeight() const { return window->GetHeight(); }
162 
163 void RenderOpenGL::ClearBlack() { // used only in game over win
164  ClearZBuffer(0, 479); // dummy params
165  ClearTarget(0);
166 }
167 
168 void RenderOpenGL::ClearTarget(unsigned int uColor) {
169  memset32(render_target_rgb, Color32(uColor), 0x4B000);
170 }
171 
173  // parameter alwyas 0 + 479 but never used
174  memset32(this->pActiveZBuffer, -65536, 0x4B000);
175 }
176 
178  pActiveZBuffer = (int *)malloc(window->GetWidth() * window->GetHeight() * sizeof(int)); // 640 * 480 * 4
179  memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // inlined Render::ClearActiveZBuffer (mm8::004A085B)
180 }
181 
182 void RenderOpenGL::RasterLine2D(signed int uX, signed int uY, signed int uZ,
183  signed int uW, unsigned __int16 uColor) {
184  unsigned int b = (uColor & 0x1F)*8;
185  unsigned int g = ((uColor >> 5) & 0x3F)*4;
186  unsigned int r = ((uColor >> 11) & 0x1F)*8;
187 
188  glDisable(GL_TEXTURE_2D);
189  glLineWidth(1);
190  glColor3ub(r, g, b);
191 
192  // pixel centers around 0.5 so tweak to avoid gaps and squashing
193  if (uZ == uX) {
194  uW += 1;
195  }
196 
197  glBegin(GL_LINES);
198  glVertex3f(uX, uY, 0);
199  glVertex3f(uZ+.5, uW+.5, 0);
200  glEnd();
201 }
202 
204  // Setup for 3D
205 
206  glDepthMask(GL_TRUE);
207  glEnable(GL_DEPTH_TEST);
208 
209  glClearColor(0.9f, 0.5f, 0.1f, 1.0f);
210  glClearDepth(1.0f);
211  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
212 
213  render->uNumBillboardsToDraw = 0; // moved from drawbillboards - cant reset this until mouse picking finished
214 }
215 
216 extern unsigned int BlendColors(unsigned int a1, unsigned int a2);
217 
219  RenderBillboard *billboard) {
220  int v11; // eax@9
221  int v12; // eax@9
222  double v15; // st5@12
223  double v16; // st4@12
224  double v17; // st3@12
225  double v18; // st2@12
226  int v19; // ecx@14
227  double v20; // st3@14
228  int v21; // ecx@16
229  double v22; // st3@16
230  float v27; // [sp+24h] [bp-Ch]@5
231  float v29; // [sp+2Ch] [bp-4h]@5
232  float v31; // [sp+3Ch] [bp+Ch]@5
233  float a1; // [sp+40h] [bp+10h]@5
234 
235  // if (this->uNumD3DSceneBegins == 0) {
236  // return;
237  //}
238 
239  Sprite *pSprite = billboard->hwsprite;
240  int dimming_level = billboard->dimming_level;
241 
242  // v4 = pSoftBillboard;
243  // v5 = (double)pSoftBillboard->zbuffer_depth;
244  // pSoftBillboarda = pSoftBillboard->zbuffer_depth;
245  // v6 = pSoftBillboard->zbuffer_depth;
247  pSoftBillboard->screen_space_z);
248  // v8 = dimming_level;
249  // device_caps = v7;
250  int v28 = dimming_level & 0xFF000000;
251  if (dimming_level & 0xFF000000) {
253  } else {
255  }
256  // v10 = a3;
257  pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44;
259  pBillboardRenderListD3D[v7].object_pid = pSoftBillboard->object_pid;
261  pSoftBillboard->sParentBillboardID;
262  // v25 = pSoftBillboard->uScreenSpaceX;
263  // v24 = pSoftBillboard->uScreenSpaceY;
264  a1 = pSoftBillboard->screenspace_projection_factor_x;
265  v29 = pSoftBillboard->screenspace_projection_factor_y;
266  v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX);
267  v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY);
268  if (pSoftBillboard->uFlags & 4) {
269  v31 = v31 * -1.0;
270  }
271  if (config->is_tinting && pSoftBillboard->sTintColor) {
272  v11 = ::GetActorTintColor(dimming_level, 0,
273  pSoftBillboard->screen_space_z, 0, 0);
274  v12 = BlendColors(pSoftBillboard->sTintColor, v11);
275  if (v28)
276  v12 =
277  (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) &
278  ((unsigned int)v12 >> 1);
279  } else {
280  v12 = ::GetActorTintColor(dimming_level, 0,
281  pSoftBillboard->screen_space_z, 0, 0);
282  }
283  // v13 = (double)v25;
287  pSoftBillboard->screen_space_x - v31 * a1;
288  // v14 = (double)v24;
289  // v32 = v14;
291  pSoftBillboard->screen_space_y - v27 * v29;
292  v15 = 1.0 - 1.0 / (pSoftBillboard->screen_space_z * 0.061758894);
293  pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15;
294  v16 = 1.0 / pSoftBillboard->screen_space_z;
296  1.0 / pSoftBillboard->screen_space_z;
297  pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0;
298  pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0;
299  v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX);
300  v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY -
301  pSprite->uAreaHeight);
302  if (pSoftBillboard->uFlags & 4) {
303  v17 = v17 * -1.0;
304  }
308  pSoftBillboard->screen_space_x - v17 * a1;
310  pSoftBillboard->screen_space_y - v18 * v29;
311  pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15;
312  pBillboardRenderListD3D[v7].pQuads[1].rhw = v16;
313  pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0;
314  pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0;
315  v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight;
316  v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth +
317  (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth);
318  if (pSoftBillboard->uFlags & 4) {
319  v20 = v20 * -1.0;
320  }
324  v20 * a1 + pSoftBillboard->screen_space_x;
326  pSoftBillboard->screen_space_y - (double)v19 * v29;
327  pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15;
328  pBillboardRenderListD3D[v7].pQuads[2].rhw = v16;
329  pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0;
330  pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0;
331  v21 = pSprite->uBufferHeight - pSprite->uAreaY;
332  v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth +
333  (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth);
334  if (pSoftBillboard->uFlags & 4) {
335  v22 = v22 * -1.0;
336  }
340  v22 * a1 + pSoftBillboard->screen_space_x;
342  pSoftBillboard->screen_space_y - (double)v21 * v29;
343  pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15;
344  pBillboardRenderListD3D[v7].pQuads[3].rhw = v16;
345  pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0;
346  pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0;
347  // v23 = pSprite->pTexture;
349  pBillboardRenderListD3D[v7].z_order = pSoftBillboard->screen_space_z;
350  pBillboardRenderListD3D[v7].texture = pSprite->texture;
351 }
352 
354  struct SpellFX_Billboard *a1, int diffuse) {
355  __debugbreak();
356 }
357 
359  SoftwareBillboard soft_billboard = { 0 };
360  soft_billboard.sParentBillboardID = -1;
361  // soft_billboard.pTarget = pBLVRenderParams->pRenderTarget;
362  soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer;
363  // soft_billboard.uTargetPitch = uTargetSurfacePitch;
364  soft_billboard.uViewportX = pBLVRenderParams->uViewportX;
365  soft_billboard.uViewportY = pBLVRenderParams->uViewportY;
366  soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1;
367  soft_billboard.uViewportW = pBLVRenderParams->uViewportW;
368 
370  for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) {
372  if (p->hwsprite) {
373  soft_billboard.screen_space_x = p->screen_space_x;
374  soft_billboard.screen_space_y = p->screen_space_y;
375  soft_billboard.screen_space_z = p->screen_space_z;
376  soft_billboard.sParentBillboardID = i;
377  soft_billboard.screenspace_projection_factor_x =
378  p->screenspace_projection_factor_x;
379  soft_billboard.screenspace_projection_factor_y =
380  p->screenspace_projection_factor_y;
381  soft_billboard.object_pid = p->object_pid;
382  soft_billboard.uFlags = p->field_1E;
383  soft_billboard.sTintColor = p->sTintColor;
384 
385  DrawBillboard_Indoor(&soft_billboard, p);
386  }
387  }
388 }
389 
390 
391 void RenderOpenGL::DrawProjectile(float srcX, float srcY, float a3, float a4,
392  float dstX, float dstY, float a7, float a8,
393  Texture *texture) {
394  __debugbreak();
395 }
396 void RenderOpenGL::ScreenFade(unsigned int color, float t) { __debugbreak(); }
397 
398 
399 void RenderOpenGL::DrawTextureOffset(int pX, int pY, int move_X, int move_Y,
400  Image *pTexture) {
401  DrawTextureNew((pX - move_X)/640., (pY - move_Y)/480., pTexture);
402 }
403 
404 
405 void RenderOpenGL::DrawImage(Image *img, const Rect &rect) {
406  glEnable(GL_TEXTURE_2D);
407  glColor3f(1, 1, 1);
408  bool blendFlag = 1;
409 
410  // check if loaded
411  auto texture = (TextureOpenGL *)img;
412  glBindTexture(GL_TEXTURE_2D, texture->GetOpenGlTexture());
413 
414  if (blendFlag) {
415  glEnable(GL_BLEND);
416  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
417  }
418 
419  float depth = 0;
420 
421  GLfloat Vertices[] = { (float)rect.x, (float)rect.y, depth,
422  (float)rect.z, (float)rect.y, depth,
423  (float)rect.z, (float)rect.w, depth,
424  (float)rect.x, (float)rect.w, depth };
425 
426  GLfloat TexCoord[] = { 0, 0,
427  1, 0,
428  1, 1,
429  0, 1 };
430 
431  GLubyte indices[] = { 0, 1, 2, // first triangle (bottom left - top left - top right)
432  0, 2, 3 }; // second triangle (bottom left - top right - bottom right)
433 
434  glEnableClientState(GL_VERTEX_ARRAY);
435  glVertexPointer(3, GL_FLOAT, 0, Vertices);
436 
437  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
438  glTexCoordPointer(2, GL_FLOAT, 0, TexCoord);
439 
440  glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);
441 
442  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
443  glDisableClientState(GL_VERTEX_ARRAY);
444 
445  glDisable(GL_BLEND);
446 
447  GLenum err;
448  while ((err = glGetError()) != GL_NO_ERROR) {
449  log->Warning(L"OpenGL error: (%u)", err);
450  }
451 }
452 
453 
454 void RenderOpenGL::ZBuffer_Fill_2(signed int a2, signed int a3, Image *pTexture,
455  int a5) {
456  // __debugbreak();
457  // blank in d3d
458 }
459 
460 
461 void RenderOpenGL::ZDrawTextureAlpha(float u, float v, Image *img, int zVal) {
462  if (!img) return;
463 
464  int uOutX = u * this->window->GetWidth();
465  int uOutY = v * this->window->GetHeight();
466  unsigned int imgheight = img->GetHeight();
467  unsigned int imgwidth = img->GetWidth();
468  auto pixels = (uint32_t *)img->GetPixels(IMAGE_FORMAT_A8R8G8B8);
469 
470  for (int xs = 0; xs < imgwidth; xs++) {
471  for (int ys = 0; ys < imgheight; ys++) {
472  if (pixels[xs + imgwidth * ys] & 0xFF000000) {
473  this->pActiveZBuffer[uOutX + xs + window->GetWidth() * (uOutY + ys)] = zVal;
474  }
475  }
476  }
477 }
478 
479 
480 
481 
482 void RenderOpenGL::BlendTextures(int a2, int a3, Image *a4, Image *a5, int t,
483  int start_opacity, int end_opacity) {
484  __debugbreak();
485 }
486 
487 
488 void RenderOpenGL::TexturePixelRotateDraw(float u, float v, Image *img, int time) {
489  if (img) {
490  auto pixelpoint = (const uint32_t *)img->GetPixels(IMAGE_FORMAT_A8R8G8B8);
491  int width = img->GetWidth();
492  int height = img->GetHeight();
493 
494  int brightloc = -1;
495  int brightval = 0;
496  int darkloc = -1;
497  int darkval = 765;
498 
499  for (int x = 0; x < width; x++) {
500  for (int y = 0; y < height; y++) {
501  int nudge = x + y * width;
502  // Test the brightness against the threshold
503  int bright = (*(pixelpoint + nudge) & 0xFF) + ((*(pixelpoint + nudge) >> 8) & 0xFF) + ((*(pixelpoint + nudge) >> 16) & 0xFF);
504  if (bright == 0) continue;
505 
506  if (bright > brightval) {
507  brightval = bright;
508  brightloc = nudge;
509  }
510  if (bright < darkval) {
511  darkval = bright;
512  darkloc = nudge;
513  }
514  }
515  }
516 
517  // find brightest
518  unsigned int bmax = (*(pixelpoint + brightloc) & 0xFF);
519  unsigned int gmax = ((*(pixelpoint + brightloc) >> 8) & 0xFF);
520  unsigned int rmax = ((*(pixelpoint + brightloc) >> 16) & 0xFF);
521 
522  // find darkest not black
523  unsigned int bmin = (*(pixelpoint + darkloc) & 0xFF);
524  unsigned int gmin = ((*(pixelpoint + darkloc) >> 8) & 0xFF);
525  unsigned int rmin = ((*(pixelpoint + darkloc) >> 16) & 0xFF);
526 
527  // steps pixels
528  float bstep = (bmax - bmin) / 128.;
529  float gstep = (gmax - gmin) / 128.;
530  float rstep = (rmax - rmin) / 128.;
531 
532  int timestep = time % 256;
533 
534  // loop through
535  for (int ydraw = 0; ydraw < height; ++ydraw) {
536  for (int xdraw = 0; xdraw < width; ++xdraw) {
537  if (*pixelpoint) { // check orig item not got blakc pixel
538  unsigned int bcur = (*(pixelpoint) & 0xFF);
539  unsigned int gcur = ((*(pixelpoint) >> 8) & 0xFF);
540  unsigned int rcur = ((*(pixelpoint) >> 16) & 0xFF);
541  int pixstepb = (bcur - bmin) / bstep + timestep;
542  if (pixstepb > 255) pixstepb = pixstepb - 256;
543  if (pixstepb >= 0 && pixstepb < 128) // 0-127
544  bcur = bmin + pixstepb * bstep;
545  if (pixstepb >= 128 && pixstepb < 256) { // 128-255
546  pixstepb = pixstepb - 128;
547  bcur = bmax - pixstepb * bstep;
548  }
549  int pixstepr = (rcur - rmin) / rstep + timestep;
550  if (pixstepr > 255) pixstepr = pixstepr - 256;
551  if (pixstepr >= 0 && pixstepr < 128) // 0-127
552  rcur = rmin + pixstepr * rstep;
553  if (pixstepr >= 128 && pixstepr < 256) { // 128-255
554  pixstepr = pixstepr - 128;
555  rcur = rmax - pixstepr * rstep;
556  }
557  int pixstepg = (gcur - gmin) / gstep + timestep;
558  if (pixstepg > 255) pixstepg = pixstepg - 256;
559  if (pixstepg >= 0 && pixstepg < 128) // 0-127
560  gcur = gmin + pixstepg * gstep;
561  if (pixstepg >= 128 && pixstepg < 256) { // 128-255
562  pixstepg = pixstepg - 128;
563  gcur = gmax - pixstepg * gstep;
564  }
565  // out pixel
566  // temppix[xdraw + ydraw * width] = (rcur << 24) | (gcur << 16) | (bcur << 8) | 0xFF;//Color32(rcur, gcur, bcur);
567  render_target_rgb[int((u*640)+xdraw + 640 *(v*480+ydraw))] = Color32(rcur, gcur, bcur);
568  }
569  pixelpoint++;
570  }
571  }
572  // draw image
573  // render->Update_Texture(img);
574  // render->DrawTextureAlphaNew(u, v, img);
575  // temp->Release();
576  }
577 }
578 
579 
580 
581 void RenderOpenGL::DrawMonsterPortrait(Rect rc, SpriteFrame *Portrait, int Y_Offset) {
582  Rect rct;
583  rct.x = rc.x + 64 + Portrait->hw_sprites[0]->uAreaX - Portrait->hw_sprites[0]->uBufferWidth / 2;
584  rct.y = rc.y + Y_Offset + Portrait->hw_sprites[0]->uAreaY;
585  rct.z = rct.x + Portrait->hw_sprites[0]->uAreaWidth;
586  rct.w = rct.y + Portrait->hw_sprites[0]->uAreaHeight;
587 
588  render->SetUIClipRect(rc.x, rc.y, rc.z, rc.w);
589  render->DrawImage(Portrait->hw_sprites[0]->texture, rct);
590  render->ResetUIClipRect();
591 }
592 
593 void RenderOpenGL::DrawTransparentRedShade(float u, float v, Image *a4) {
594  DrawMasked(u, v, a4, 0, 0xF800);
595 }
596 
597 void RenderOpenGL::DrawTransparentGreenShade(float u, float v, Image *pTexture) {
598  DrawMasked(u, v, pTexture, 0, 0x07E0);
599 }
600 
602  unsigned int num_vertices) {
603  __debugbreak();
604 }
605 
606 void RenderOpenGL::DrawMasked(float u, float v, Image *pTexture, unsigned int color_dimming_level,
607  unsigned __int16 mask) {
608  if (!pTexture) {
609  return;
610  }
611  uint32_t width = pTexture->GetWidth();
613  // Image *temp = Image::Create(width, pTexture->GetHeight(), IMAGE_FORMAT_A8R8G8B8);
614  // uint32_t *temppix = (uint32_t *)temp->GetPixels(IMAGE_FORMAT_A8R8G8B8);
615  int x = 640 * u;
616  int y = 480 * v;
617 
618  for (unsigned int dy = 0; dy < pTexture->GetHeight(); ++dy) {
619  for (unsigned int dx = 0; dx < width; ++dx) {
620  if (*pixels & 0xFF000000)
621  /*temppix[dx + dy * width] = Color32((((*pixels >> 16) & 0xFF) >> color_dimming_level),
622  (((*pixels >> 8) & 0xFF) >> color_dimming_level), ((*pixels & 0xFF) >> color_dimming_level))
623  & Color32(mask);*/
624  render_target_rgb[x+dx + 640*(y+dy)] = Color32((((*pixels >> 16) & 0xFF) >> color_dimming_level),
625  (((*pixels >> 8) & 0xFF) >> color_dimming_level), ((*pixels & 0xFF) >> color_dimming_level))
626  & Color32(mask);
627  ++pixels;
628  }
629  }
630  // render->DrawTextureAlphaNew(u, v, temp);
631  // temp->Release();;
632 }
633 
634 void RenderOpenGL::DrawTextureGrayShade(float a2, float a3, Image *a4) {
635  __debugbreak();
636 }
637 void RenderOpenGL::DrawIndoorSky(unsigned int uNumVertices,
638  unsigned int uFaceID) {
639  __debugbreak();
640 }
641 void RenderOpenGL::DrawIndoorSkyPolygon(signed int uNumVertices,
642  struct Polygon *pSkyPolygon) {
643  __debugbreak();
644 }
645 
646 Image *RenderOpenGL::TakeScreenshot(unsigned int width, unsigned int height) { return nullptr; }
647 bool RenderOpenGL::AreRenderSurfacesOk() { return true; }
648 void RenderOpenGL::SaveScreenshot(const String &filename, unsigned int width,
649  unsigned int height) {
650  // __debugbreak();
651 }
654  __debugbreak();
655  return 0;
656 }
661 
662 bool RenderOpenGL::DrawLightmap(struct Lightmap *pLightmap,
663  struct Vec3_float_ *pColorMult, float z_bias) {
664  __debugbreak();
665  return 0;
666 }
669 void RenderOpenGL::DrawDecal(struct Decal *pDecal, float z_bias) {
670  __debugbreak();
671 }
673  signed int sDiffuseBegin,
674  const RenderVertexD3D3 *pLineEnd,
675  signed int sDiffuseEnd,
676  float z_stuff) {
677  __debugbreak();
678 }
680  unsigned int num_vertices) {
681  __debugbreak();
682 }
684  Texture *texture) {
685  __debugbreak();
686 }
687 
688 void RenderOpenGL::am_Blt_Chroma(Rect *pSrcRect, Point *pTargetPoint, int a3,
689  int blend_mode) {
690  __debugbreak();
691 }
692 
693 
694 
696  unsigned int v6; // edi@9
697  int v7; // eax@9
698  SpriteFrame *frame; // eax@9
699  unsigned __int16 *v10; // eax@9
700  int v13; // ecx@9
701  char r; // ecx@20
702  char g; // dl@20
703  char b_; // eax@20
704  Particle_sw local_0; // [sp+Ch] [bp-98h]@7
705  unsigned __int16 *v37; // [sp+84h] [bp-20h]@9
706  int v38; // [sp+88h] [bp-1Ch]@9
707 
708  for (unsigned int i = 0; i < uNumLevelDecorations; ++i) {
709  // LevelDecoration* decor = &pLevelDecorations[i];
711  pLevelDecorations[i].IsObeliskChestActive()) &&
713  DecorationDesc *decor_desc = pDecorationList->GetDecoration(pLevelDecorations[i].uDecorationDescID);
714  if (!(decor_desc->uFlags & 0x80)) {
715  if (!(decor_desc->uFlags & 0x22)) {
717  v7 = abs(pLevelDecorations[i].vPosition.x +
718  pLevelDecorations[i].vPosition.y);
719 
720  frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID,
721  v6 + v7);
722 
723  if (engine->config->seasons_change) {
724  frame = LevelDecorationChangeSeason(decor_desc, v6 + v7, pParty->uCurrentMonth);
725  }
726 
727  if (!frame) {
728  continue;
729  }
730 
731  // v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID,
732  // v6 + v7);
733 
734  v10 = (unsigned __int16 *)stru_5C6E00->Atan2(
735  pLevelDecorations[i].vPosition.x -
737  pLevelDecorations[i].vPosition.y -
739  v38 = 0;
740  v13 = ((signed int)(stru_5C6E00->uIntegerPi +
741  ((signed int)stru_5C6E00->uIntegerPi >>
742  3) +
743  pLevelDecorations[i].field_10_y_rot -
744  (signed int)v10) >>
745  8) &
746  7;
747  v37 = (unsigned __int16 *)v13;
748  if (frame->uFlags & 2) v38 = 2;
749  if ((256 << v13) & frame->uFlags) v38 |= 4;
750  if (frame->uFlags & 0x40000) v38 |= 0x40;
751  if (frame->uFlags & 0x20000) v38 |= 0x80;
752 
753  // for light
754  if (frame->uGlowRadius) {
755  r = 255;
756  g = 255;
757  b_ = 255;
758  if (render->config->is_using_colored_lights) {
759  r = decor_desc->uColoredLightRed;
760  g = decor_desc->uColoredLightGreen;
761  b_ = decor_desc->uColoredLightBlue;
762  }
764  pLevelDecorations[i].vPosition.x,
765  pLevelDecorations[i].vPosition.y,
766  pLevelDecorations[i].vPosition.z +
767  decor_desc->uDecorationHeight / 2,
768  frame->uGlowRadius, r, g, b_, _4E94D0_light_type);
769  } // for light
770 
771  // v17 = (pLevelDecorations[i].vPosition.x -
772  // pIndoorCameraD3D->vPartyPos.x) << 16; v40 =
773  // (pLevelDecorations[i].vPosition.y -
774  // pIndoorCameraD3D->vPartyPos.y) << 16;
775  int party_to_decor_x = pLevelDecorations[i].vPosition.x -
777  int party_to_decor_y = pLevelDecorations[i].vPosition.y -
779  int party_to_decor_z = pLevelDecorations[i].vPosition.z -
781 
782  int view_x = 0;
783  int view_y = 0;
784  int view_z = 0;
785  bool visible = pIndoorCameraD3D->ViewClip(
786  pLevelDecorations[i].vPosition.x,
787  pLevelDecorations[i].vPosition.y,
788  pLevelDecorations[i].vPosition.z, &view_x, &view_y,
789  &view_z);
790 
791  if (visible) {
792  if (2 * abs(view_x) >= abs(view_y)) {
793  int projected_x = 0;
794  int projected_y = 0;
795  pIndoorCameraD3D->Project(view_x, view_y, view_z,
796  &projected_x,
797  &projected_y);
798 
799  auto _v41 =
800  frame->scale *
802  fixed::FromInt(view_x);
803 
804  int screen_space_half_width = 0;
805  screen_space_half_width =
806  _v41.GetInt() *
807  frame->hw_sprites[(int)v37]->uBufferWidth / 2;
808 
809  if (projected_x + screen_space_half_width >=
810  (signed int)pViewport->uViewportTL_X &&
811  projected_x - screen_space_half_width <=
812  (signed int)pViewport->uViewportBR_X) {
813  if (::uNumBillboardsToDraw >= 500) return;
816 
818  .hwsprite = frame->hw_sprites[(int)v37];
820  .world_x = pLevelDecorations[i].vPosition.x;
822  .world_y = pLevelDecorations[i].vPosition.y;
824  .world_z = pLevelDecorations[i].vPosition.z;
826  .screen_space_x = projected_x;
828  .screen_space_y = projected_y;
830  .screen_space_z = view_x;
832  .screenspace_projection_factor_x = _v41.GetFloat();
834  .screenspace_projection_factor_y = _v41.GetFloat();
836  .uPalette = frame->uPaletteIndex;
838  .field_1E = v38 | 0x200;
840  .uIndoorSectorID = 0;
842  .object_pid = PID(OBJECT_Decoration, i);
844  .dimming_level = 0;
846  .pSpriteFrame = frame;
848  .sTintColor = 0;
849  }
850  }
851  }
852  }
853  } else {
854  memset(&local_0, 0, 0x68);
857  local_0.uDiffuse = 0xFF3C1E;
858  local_0.x = (double)pLevelDecorations[i].vPosition.x;
859  local_0.y = (double)pLevelDecorations[i].vPosition.y;
860  local_0.z = (double)pLevelDecorations[i].vPosition.z;
861  local_0.r = 0.0;
862  local_0.g = 0.0;
863  local_0.b = 0.0;
864  local_0.particle_size = 1.0;
865  local_0.timeToLive = (rand() & 0x80) + 128;
867  particle_engine->AddParticle(&local_0);
868  }
869  }
870  }
871 }
872 
873 /*#pragma pack(push, 1)
874 typedef struct {
875  char idlength;
876  char colourmaptype;
877  char datatypecode;
878  short int colourmaporigin;
879  short int colourmaplength;
880  char colourmapdepth;
881  short int x_origin;
882  short int y_origin;
883  short width;
884  short height;
885  char bitsperpixel;
886  char imagedescriptor;
887 } tga;
888 #pragma pack(pop)
889 
890 FILE *CreateTga(const char *filename, int image_width, int image_height)
891 {
892  auto f = fopen(filename, "w+b");
893 
894  tga tga_header;
895  memset(&tga_header, 0, sizeof(tga_header));
896 
897  tga_header.colourmaptype = 0;
898  tga_header.datatypecode = 2;
899  //tga_header.colourmaporigin = 0;
900  //tga_header.colourmaplength = image_width * image_height;
901  //tga_header.colourmapdepth = 32;
902  tga_header.x_origin = 0;
903  tga_header.y_origin = 0;
904  tga_header.width = image_width;
905  tga_header.height = image_height;
906  tga_header.bitsperpixel = 32;
907  tga_header.imagedescriptor = 32; // top-down
908  fwrite(&tga_header, 1, sizeof(tga_header), f);
909 
910  return f;
911 }*/
912 
915 }
916 
919 }
920 
923 }
924 
927 }
928 
931 }
932 
935 }
936 
938  IMAGE_FORMAT format, const void *pixels) {
939 
941 }
942 
943 
946 }
947 
948 Texture *RenderOpenGL::CreateSprite(const String &name, unsigned int palette_id,
949  /*refactor*/ unsigned int lod_sprite_id) {
950  return TextureOpenGL::Create(
951  new Sprites_LOD_Loader(pSprites_LOD, palette_id, name, lod_sprite_id));
952 }
953 
955  // takes care of endian flip from literals here - hence BGRA
956 
957  auto t = (TextureOpenGL *)texture;
958  glBindTexture(GL_TEXTURE_2D, t->GetOpenGlTexture());
959  glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, t->GetWidth(), t->GetHeight(), GL_BGRA, GL_UNSIGNED_BYTE, t->GetPixels(IMAGE_FORMAT_A8R8G8B8));
960  glBindTexture(GL_TEXTURE_2D, NULL);
961 
962  GLenum err;
963  while ((err = glGetError()) != GL_NO_ERROR) {
964  log->Warning(L"OpenGL error: (%u)", err);
965  }
966 }
967 
969  // crash here when assets not loaded as texture
970 
971  auto t = (TextureOpenGL *)texture;
972  GLuint texid = t->GetOpenGlTexture();
973  if (texid != -1) {
974  glDeleteTextures(1, &texid);
975  }
976 }
977 
979 
981  auto t = (TextureOpenGL *)texture;
982  /* return false;
983  }
984 
985  bool RenderOpenGL::LoadTextureOpenGL(const String &name, bool mipmaps, int
986  *out_texture)
987  {*/
988  /*String filename = name;
989  std::transform(filename.begin(), filename.end(), filename.begin(),
990  ::tolower);
991 
992  HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(filename.c_str(),
993  mipmaps); if (!pHWLTexture) return false;
994 
995  auto rgb = new unsigned char[pHWLTexture->uWidth * pHWLTexture->uHeight *
996  4]; for (unsigned int i = 0; i < pHWLTexture->uWidth * pHWLTexture->uHeight;
997  ++i)
998  {
999  rgb[i * 4 + 3] = pHWLTexture->pPixels[i] & 0x8000 ? 0xFF : 0x00;
1000  rgb[i * 4 + 2] = 8 * ((pHWLTexture->pPixels[i] >> 0) & 0x1F);
1001  rgb[i * 4 + 1] = 8 * ((pHWLTexture->pPixels[i] >> 5) & 0x1F);
1002  rgb[i * 4 + 0] = 8 * ((pHWLTexture->pPixels[i] >> 10) & 0x1F);
1003  }*/
1004 
1005  /*if (filename == "plansky3")
1006  {
1007  if (auto f = CreateTga((name + ".tga").c_str(), pHWLTexture->uWidth,
1008  pHWLTexture->uHeight))
1009  {
1010  for (unsigned int i = 0; i < pHWLTexture->uWidth * pHWLTexture->uHeight;
1011  ++i)
1012  {
1013  int r = rgb[i * 4 + 0];
1014  int g = rgb[i * 4 + 1];
1015  int b = rgb[i * 4 + 2];
1016  int a = rgb[i * 4 + 2];
1017  int c = (a << 24 ) | (r << 16) | (g << 8) | b;
1018 
1019  fwrite(&c, 4, 1, f);
1020  }
1021  fclose(f);
1022  }
1023  }*/
1024 
1025  auto native_format = t->GetFormat();
1026  int gl_format = GL_RGB;
1027  // native_format == IMAGE_FORMAT_A1R5G5B5 ? GL_RGBA : GL_RGB;
1028 
1029  unsigned __int8 *pixels = nullptr;
1030  if (native_format == IMAGE_FORMAT_R5G6B5) {
1031  pixels = (unsigned __int8 *)t->GetPixels(IMAGE_FORMAT_R8G8B8);
1032  } else if (native_format == IMAGE_FORMAT_A1R5G5B5 || native_format == IMAGE_FORMAT_A8R8G8B8) {
1033  pixels = (unsigned __int8 *)t->GetPixels(IMAGE_FORMAT_R8G8B8A8); // rgba
1034  gl_format = GL_RGBA;
1035  } else {
1036  log->Warning(L"Image not loaded!");
1037  }
1038 
1039  if (pixels) {
1040  GLuint texid;
1041  glGenTextures(1, &texid);
1042  t->SetOpenGlTexture(texid);
1043 
1044  glBindTexture(GL_TEXTURE_2D, texid);
1045  glTexImage2D(GL_TEXTURE_2D, 0, gl_format, t->GetWidth(), t->GetHeight(),
1046  0, gl_format, GL_UNSIGNED_BYTE, pixels);
1047  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1048  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1049  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1050  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
1051 
1052  glBindTexture(GL_TEXTURE_2D, 0);
1053 
1054  return true;
1055  }
1056  return false;
1057 }
1058 
1060  float near_clip = pIndoorCameraD3D->GetNearClip();
1061  float far_clip = pIndoorCameraD3D->GetFarClip();
1062 
1063  glMatrixMode(GL_PROJECTION);
1064  glLoadIdentity();
1065 
1066 
1067  // outdoors 60 - should be 75?
1068  // indoors 65?/
1069  // something to do with ratio of screenwidth to viewport width
1070 
1071 
1072  gluPerspective(65, double(game_viewport_width/double(game_viewport_height)) // 65.0f
1073  /*(GLfloat)window->GetWidth() / (GLfloat)window->GetHeight()*/,
1074  near_clip, far_clip);
1075 }
1076 
1078  glMatrixMode(GL_MODELVIEW);
1079  glLoadIdentity();
1080  glScalef(1.0f, 1.0f, -1.0f);
1081 
1082  int camera_x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * pi_double * pParty->sRotationY / 2048.0);
1083  int camera_z = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * pi_double * pParty->sRotationY / 2048.0);
1084  int camera_y = pParty->vPosition.z + pParty->sEyelevel;
1085 
1086  gluLookAt(camera_x, camera_y, camera_z,
1087 
1088  camera_x - pParty->y_rotation_granularity *
1089  cosf(2 * 3.14159 * pParty->sRotationY / 2048.0) /*- 5*/,
1090  camera_y - pParty->y_rotation_granularity *
1091  sinf(2 * 3.14159 * (pParty->sRotationX/*-25*/) / 2048.0),
1092  camera_z - pParty->y_rotation_granularity *
1093  sinf(2 * 3.14159 * pParty->sRotationY / 2048.0),
1094 
1095  0, 1, 0);
1096 }
1097 
1098 void _set_ortho_projection(bool gameviewport = false) {
1099  if (!gameviewport) { // project over entire window
1100  glViewport(0, 0, window->GetWidth(), window->GetHeight());
1101 
1102  glMatrixMode(GL_PROJECTION);
1103  glLoadIdentity();
1104  glOrtho(0, window->GetWidth(), window->GetHeight(), 0, -1, 1);
1105  } else { // project to game viewport
1107 
1108  glMatrixMode(GL_PROJECTION);
1109  glLoadIdentity();
1110  glOrtho(game_viewport_x, game_viewport_z, game_viewport_w, game_viewport_y, 1, -1); // far = 1 but ogl looks down -z
1111  }
1112 }
1113 
1115  glMatrixMode(GL_MODELVIEW);
1116  glLoadIdentity();
1117 }
1118 
1119 const int terrain_block_scale = 512;
1120 const int terrain_height_scale = 32;
1122  glEnable(GL_TEXTURE_2D);
1123  glEnable(GL_CULL_FACE);
1124  glCullFace(GL_BACK);
1125  glFrontFace(GL_CCW);
1126 
1129 
1130  GLint lasttex = -1; // keeps track of which tile texture is loaded
1131 
1132  // tile culling maths
1135  int tilerange = (pIndoorCameraD3D->GetFarClip() / terrain_block_scale)+1;
1136 
1137  int camfacing = 2048 - pIndoorCameraD3D->sRotationY;
1138  int right = int(camfacing - (stru_5C6E00->uIntegerPi / 2));
1139  int left = int(camfacing + (stru_5C6E00->uIntegerPi / 2));
1140  if (left > 2048) left -= 2048;
1141  if (right < 0) right += 2048;
1142 
1143  float Light_tile_dist;
1144 
1145 
1146  for (int z = 0; z < 128 - 1; ++z) {
1147  for (int x = 0; x < 128 - 1; ++x) {
1148  // tile culling
1149  int xdist = camx - x;
1150  int zdist = camz - z;
1151 
1152  if (xdist > tilerange || zdist > tilerange) continue;
1153 
1154  int dist = sqrt((xdist)*(xdist) + (zdist)*(zdist));
1155  if (dist > tilerange) continue; // crude distance culling
1156 
1157  // could do further x + z culling by camera direction see dx
1158 
1159  int tiledir = stru_5C6E00->Atan2(xdist, zdist)+1024;
1160  if (tiledir > 2048) {
1161  tiledir -= 2048;
1162  }
1163 
1164  if (dist > 2) { // dont cull near feet
1165  if (left > right) { // crude fov culling
1166  if ((tiledir > left) || (tiledir < right)) continue;
1167  } else {
1168  if (!(tiledir < left || tiledir > right)) continue;
1169  }
1170  }
1171 
1172  // draw tile
1173  auto tile = pOutdoor->DoGetTile(x, z);
1174  if (!tile) continue;
1175 
1176  struct Polygon p;
1177  auto *poly = &p;
1178 
1179  poly->texture = tile->GetTexture();
1180  if (tile->IsWaterTile()) {
1181  poly->texture =
1183  }
1184 
1185  //Генерация местоположения
1186  //вершин-------------------------------------------------------------------------
1187  //решётка вершин делится на две части от -64 до 0 и от 0 до 64
1188  //
1189  // X
1190  // -64 0 64
1191  // --------------- 64
1192  // | | |
1193  // | | |
1194  // | | |
1195  // 0|------+------| Z
1196  // | | |
1197  // | | |
1198  // | | |
1199  // ---------------
1200  // -64
1201 
1202  int x1 = x;
1203  int x2 = x + 1;
1204  int z1 = z;
1205  int z2 = z + 1;
1206  int y11 = pOutdoor->pTerrain.pHeightmap[z1 * 128 + x1];
1207  int y21 = pOutdoor->pTerrain.pHeightmap[z1 * 128 + x2];
1208  int y12 = pOutdoor->pTerrain.pHeightmap[z2 * 128 + x1];
1209  int y22 = pOutdoor->pTerrain.pHeightmap[z2 * 128 + x2];
1210 
1211  // terrain normal had problems
1212  /*uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1];
1213  assert(norm_idx < uNumTerrainNormals);
1214 
1215  Vec3_float_ *norm = &pTerrainNormals[norm_idx];
1216  float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) -
1217  (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) -
1218  (norm->z * (float)pOutdoor->vSunlight.z / 65536.0));
1219  pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f);*/
1220 
1221  uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1];
1222  assert(norm_idx < uNumTerrainNormals);
1223 
1224  auto norm = &pTerrainNormals[norm_idx];
1225  float dim =
1226  ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) -
1227  (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) -
1228  (norm->z * (float)pOutdoor->vSunlight.z / 65536.0));
1229 
1230  // x start -65536 -> 65536
1231  // y always 0
1232  // z start -1 -> -65536 -> -1
1233 
1234  // poly->dimming_level = 20.0 - floorf(20.0 * dim + 0.5f);
1235 
1236 
1237  // adjusts sun dimming - needs better distance supplied
1238  poly->dimming_level = ::GetActorTintColor(
1239  (20.0 - floorf(20.0 * dim + 0.5f)), 0, /*lightdist*/((dist+1) * terrain_block_scale),
1240  0, 0);
1241 
1242 
1243 
1244 
1245  if (norm_idx < 0 || norm_idx > uNumTerrainNormals - 1)
1246  norm = 0;
1247  else
1248  norm = &pTerrainNormals[norm_idx];
1249 
1250  // if (false) {
1251  // // if (engine->config->allow_lightmaps) {
1252  // // Ritor1: significant fps slowdown
1253  // lightmap_builder->StackLights_TerrainFace(
1254  // norm, &Light_tile_dist, VertexRenderList, 4,
1255  // 1);
1256  // decal_builder->ApplyBloodSplatToTerrain(pTilePolygon, norm,
1257  // &Light_tile_dist, VertexRenderList, 4, 1);
1258  //}
1259 
1260 
1261  poly->uEdgeList1Size = x;
1262  poly->uEdgeList2Size = z;
1263 
1264  // draw animated water under shore
1265  bool water_border_tile = false;
1266  if (tile->IsWaterBorderTile()) {
1267  glDepthMask(GL_FALSE);
1268  {
1269  poly->texture =
1271 
1272  auto texturew = (TextureOpenGL *)poly->texture;
1273  GLint thistexw = texturew->GetOpenGlTexture();
1274 
1275  // avoid rebinding same tex if we can
1276  if (lasttex != thistexw) {
1277  glBindTexture(GL_TEXTURE_2D, thistexw);
1278  lasttex = thistexw;
1279  }
1280 
1281  this->DrawTerrainPolygon(poly, true, true);
1282  poly->texture = tile->GetTexture();
1283  }
1284  glDepthMask(GL_TRUE);
1285 
1286  water_border_tile = true;
1287  }
1288 
1289  auto texture = (TextureOpenGL *)poly->texture;
1290  GLint thistex = texture->GetOpenGlTexture();
1291 
1292  // avoid rebinding same tex if we can
1293  if (lasttex != thistex) {
1294  glBindTexture(GL_TEXTURE_2D, thistex);
1295  lasttex = thistex;
1296  }
1297 
1298  this->DrawTerrainPolygon(poly, water_border_tile, true);
1299  }
1300  }
1301 }
1302 
1303 void RenderOpenGL::DrawTerrainPolygon(struct Polygon *poly, bool transparent,
1304  bool clampAtTextureBorders) {
1305  auto texture = (TextureOpenGL *)poly->texture;
1306  GLint thistex = texture->GetOpenGlTexture();
1307 
1308  // clamping doesnt really help here in opengl so had to alter texture
1309  // coordinates a bit
1310  float clamp_fix_u = 1.0f / texture->GetWidth();
1311  float clamp_fix_v = 1.0f / texture->GetHeight();
1312 
1313  // if (clampAtTextureBorders) {
1314  // //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1315  // //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1316  // } else {
1317  // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1318  // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
1319  // }
1320 
1321  if (transparent) {
1322  glEnable(GL_BLEND);
1323  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1324  }
1325 
1326  float dim = (poly->dimming_level & 0xFF)/255.; // 1 - (poly->dimming_level / 20.0f);
1327  int x1 = poly->uEdgeList1Size;
1328  int z1 = poly->uEdgeList2Size;
1329  int x2 = x1 + 1;
1330  int z2 = z1 + 1;
1331 
1332  int y11 = pOutdoor->pTerrain.pHeightmap[z1 * 128 + x1];
1333  int y21 = pOutdoor->pTerrain.pHeightmap[z1 * 128 + x2];
1334  int y12 = pOutdoor->pTerrain.pHeightmap[z2 * 128 + x1];
1335  int y22 = pOutdoor->pTerrain.pHeightmap[z2 * 128 + x2];
1336 
1337  glBegin(GL_TRIANGLES);
1338  {
1339  glTexCoord2f(0.0f + clamp_fix_u, 0.0f + clamp_fix_v);
1340  glColor3f(dim, dim, dim);
1342  (64 - z1) * terrain_block_scale);
1343 
1344  glTexCoord2f(0.0f + clamp_fix_u, 1.0f - clamp_fix_v);
1345  glColor3f(dim, dim, dim);
1347  (64 - z2) * terrain_block_scale);
1348 
1349  glTexCoord2f(1.0f - clamp_fix_u, 1.0f - clamp_fix_v);
1350  glColor3f(dim, dim, dim);
1352  (64 - z2) * terrain_block_scale);
1353 
1354  // ---
1355 
1356  glTexCoord2f(0.0f + clamp_fix_u, 0.0f + clamp_fix_v);
1357  glColor3f(dim, dim, dim);
1359  (64 - z1) * terrain_block_scale);
1360 
1361  glTexCoord2f(1.0f - clamp_fix_u, 1.0f - clamp_fix_v);
1362  glColor3f(dim, dim, dim);
1364  (64 - z2) * terrain_block_scale);
1365 
1366  glTexCoord2f(1.0f - clamp_fix_u, 0.0f + clamp_fix_v);
1367  glColor3f(dim, dim, dim);
1369  (64 - z1) * terrain_block_scale);
1370  }
1371  glEnd();
1372 
1373  if (transparent) {
1374  glDisable(GL_BLEND);
1375  }
1376 }
1377 
1379  int v9; // eax@4
1380  int top_y_proj; // ebx@4
1381  int v13; // edi@6
1382  int v14; // ecx@6
1383  int v15; // eax@8
1384  int v16; // eax@12
1385  signed __int64 v17; // qtt@13
1386  signed int v18; // ecx@13
1387  struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1
1388  int horizon_height_offset; // [sp+134h] [bp-30h]@1
1389  int v32; // [sp+13Ch] [bp-28h]@6
1390  int v33; // [sp+140h] [bp-24h]@2
1391  signed __int64 v34; // [sp+144h] [bp-20h]@1
1392  int v35; // [sp+148h] [bp-1Ch]@4
1393  int v36; // [sp+14Ch] [bp-18h]@2
1394  int v37; // [sp+154h] [bp-10h]@8
1395  int bot_y_proj; // [sp+158h] [bp-Ch]@1
1396  int v39; // [sp+15Ch] [bp-8h]@4
1397 
1398  double rot_to_rads = ((2 * pi_double) / 2048);
1399 
1400  // lowers clouds as party goes up
1401  horizon_height_offset =
1402  (signed __int64)((double)(pODMRenderParams->int_fov_rad *
1404  ((double)pODMRenderParams->int_fov_rad + 8192.0) +
1405  (double)(pViewport->uScreenCenterY));
1406 
1407  // magnitude in up direction
1408  v34 = cos((double)pIndoorCameraD3D->sRotationX * rot_to_rads) *
1410 
1411  bot_y_proj = (signed __int64)((double)(pViewport->uScreenCenterY) -
1412  (double)pODMRenderParams->int_fov_rad /
1413  (v34 + 0.0000001) *
1414  (sin((double)pIndoorCameraD3D->sRotationX * rot_to_rads)
1415  *
1417  (double)pIndoorCameraD3D->vPartyPos.z));
1418 
1419  // pSkyPolygon.Create_48607B(&SkyBillboard); //заполняется ptr_38
1420  // pSkyPolygon.ptr_38->_48694B_frustum_sky();
1421  pSkyPolygon.texture = nullptr;
1422  pSkyPolygon.ptr_38 = &SkyBillboard;
1423 
1424  // if ( pParty->uCurrentHour > 20 || pParty->uCurrentHour < 5 )
1425  // pSkyPolygon.uTileBitmapID = pOutdoor->New_SKY_NIGHT_ID;
1426  // else
1427  // pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166)
1428  // pSkyPolygon.pTexture = (Texture_MM7 *)(pSkyPolygon.uTileBitmapID != -1 ?
1429  // (int)&pBitmaps_LOD->pTextures[pSkyPolygon.uTileBitmapID] : 0);
1430  pSkyPolygon.texture = pOutdoor->sky_texture;
1431  if (pSkyPolygon.texture) {
1432  pSkyPolygon.dimming_level = 0;
1433  pSkyPolygon.uNumVertices = 4;
1434  // centering(центруем)-----------------------------------------------------------------
1435  pSkyPolygon.v_18.x =
1437  pSkyPolygon.v_18.y = 0;
1438  pSkyPolygon.v_18.z =
1440 
1441  // sky wiew position(положение неба на
1442  // экране)------------------------------------------
1443  // X
1444  // 0._____________________________.3
1445  // |8,8 468,8 |
1446  // | |
1447  // | |
1448  // Y| |
1449  // | |
1450  // |8,351 468,351 |
1451  // 1._____________________________.2
1452  //
1454  (double)(signed int)pViewport->uViewportTL_X; // 8
1456  (double)(signed int)pViewport->uViewportTL_Y; // 8
1457 
1459  (double)(signed int)pViewport->uViewportTL_X; // 8
1460  VertexRenderList[1].vWorldViewProjY = (double)bot_y_proj; // 247
1461 
1463  (double)(signed int)pViewport->uViewportBR_X; // 468
1464  VertexRenderList[2].vWorldViewProjY = (double)bot_y_proj; // 247
1465 
1467  (double)(signed int)pViewport->uViewportBR_X; // 468
1469  (double)(signed int)pViewport->uViewportTL_Y; // 8
1470 
1471  pSkyPolygon.sTextureDeltaU =
1472  224 * pMiscTimer->uTotalGameTimeElapsed; // 7168
1473  pSkyPolygon.sTextureDeltaV =
1474  224 * pMiscTimer->uTotalGameTimeElapsed; // 7168
1475 
1476  pSkyPolygon.field_24 = 0x2000000; // maybe attributes
1477 
1478  double half_fov_angle_rads = ((pODMRenderParams->uCameraFovInDegrees - 1) * pi_double) / 360;
1479 
1480  // far width per pixel??
1481  v33 = 65536 /
1482  (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2)
1483  / tan(half_fov_angle_rads) +
1484  0.5);
1485  for (uint i = 0; i < pSkyPolygon.uNumVertices; ++i) {
1486  // rotate skydome(вращение купола
1487  // неба)--------------------------------------
1488  // В игре принята своя система измерения углов. Полный угол (180).
1489  // Значению угла 0 соответствует направление на север и/или юг (либо
1490  // на восток и/или запад), значению 65536 еденицам(0х10000)
1491  // соответствует угол 90. две переменные хранят данные по углу
1492  // обзора. field_14 по западу и востоку. field_20 по югу и северу от
1493  // -25080 до 25080
1494  v39 = fixpoint_mul(
1495  pSkyPolygon.ptr_38->CamVecLeft_Y,
1496  v33 * (horizon_height_offset - floor(VertexRenderList[i].vWorldViewProjY + 0.5)));
1497  v35 = v39 + pSkyPolygon.ptr_38->CamVecLeft_Z;
1498 
1499  v39 = fixpoint_mul(
1500  pSkyPolygon.ptr_38->CamVecFront_Y,
1501  v33 * (horizon_height_offset - floor(VertexRenderList[i].vWorldViewProjY + 0.f)));
1502  v36 = v39 + pSkyPolygon.ptr_38->CamVecFront_Z;
1503 
1504  v9 = fixpoint_mul(
1505  pSkyPolygon.v_18.z,
1506  v33 * (horizon_height_offset - floor(VertexRenderList[i].vWorldViewProjY + 0.5)));
1507  top_y_proj = pSkyPolygon.v_18.x + v9;
1508  if (top_y_proj > 0) top_y_proj = 0;
1509  v13 = v33 * (pViewport->uScreenCenterX -
1510  (signed __int64)VertexRenderList[i].vWorldViewProjX);
1511  v34 = -pSkyPolygon.field_24;
1512  v32 = (signed __int64)VertexRenderList[i].vWorldViewProjY - 1.0;
1513  v14 = v33 * (horizon_height_offset - v32);
1514  while (1) {
1515  if (top_y_proj) {
1516  v37 = abs((int)v34 >> 14);
1517  v15 = abs(top_y_proj);
1518  if (v37 <= v15 ||
1519  v32 <= (signed int)pViewport->uViewportTL_Y) {
1520  if (top_y_proj <= 0) break;
1521  }
1522  }
1523  v16 = fixpoint_mul(pSkyPolygon.v_18.z, v14);
1524  --v32;
1525  v14 += v33;
1526  top_y_proj = pSkyPolygon.v_18.x + v16;
1527  }
1528  HEXRAYS_LODWORD(v17) = HEXRAYS_LODWORD(v34) << 16;
1529  HEXRAYS_HIDWORD(v17) = v34 >> 16;
1530  v18 = v17 / top_y_proj;
1531  if (v18 < 0) v18 = pIndoorCameraD3D->GetFarClip();
1532  v37 = v35 + fixpoint_mul(pSkyPolygon.ptr_38->CamVecLeft_X, v13);
1533  v35 = 224 * pMiscTimer->uTotalGameTimeElapsed +
1534  ((signed int)fixpoint_mul(v37, v18) >> 3);
1535  VertexRenderList[i].u =
1536  (double)v35 /
1537  ((double)pSkyPolygon.texture->GetWidth() * 65536.0);
1538 
1539  v36 = v36 + fixpoint_mul(pSkyPolygon.ptr_38->CamVecFront_X, v13);
1540  v35 = 224 * pMiscTimer->uTotalGameTimeElapsed +
1541  ((signed int)fixpoint_mul(v36, v18) >> 3);
1542  VertexRenderList[i].v =
1543  (double)v35 /
1544  ((double)pSkyPolygon.texture->GetHeight() * 65536.0);
1545 
1547  VertexRenderList[i]._rhw = 1.0 / (double)(v18 >> 16);
1548  }
1549 
1552 
1557 
1558  this->DrawOutdoorSkyPolygon(&pSkyPolygon);
1559 
1560  VertexRenderList[0].vWorldViewProjY = (double)top_y_proj;
1565  VertexRenderList[3].vWorldViewProjY = (double)top_y_proj;
1566 
1567  // this->DrawOutdoorSkyPolygon(&pSkyPolygon);
1568  }
1569 }
1570 
1571 //----- (004A2DA3) --------------------------------------------------------
1573  auto texture = (TextureOpenGL *)pSkyPolygon->texture;
1574 
1575  glEnable(GL_TEXTURE_2D);
1576  glBindTexture(GL_TEXTURE_2D, texture->GetOpenGlTexture());
1577  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1578  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
1579 
1580  VertexRenderList[0].u = 0 - (float)pParty->sRotationY / 512;
1581  VertexRenderList[1].u = 0 - (float)pParty->sRotationY / 512;
1582  VertexRenderList[2].u = 1 - (float)pParty->sRotationY / 512;
1583  VertexRenderList[3].u = 1 - (float)pParty->sRotationY / 512;
1584 
1585  if (pParty->sRotationX > 0) {
1586  VertexRenderList[0].v = 0 - (float)pParty->sRotationX / 1024;
1587  VertexRenderList[1].v = 1 - (float)pParty->sRotationX / 1024;
1588  VertexRenderList[2].v = 1 - (float)pParty->sRotationX / 1024;
1589  VertexRenderList[3].v = 0 - (float)pParty->sRotationX / 1024;
1590  } else {
1591  VertexRenderList[0].v = 0 - (float)pParty->sRotationX / 256;
1592  VertexRenderList[1].v = 1 - (float)pParty->sRotationX / 256;
1593  VertexRenderList[2].v = 1 - (float)pParty->sRotationX / 256;
1594  VertexRenderList[3].v = 0 - (float)pParty->sRotationX / 256;
1595  }
1596 
1597  glBegin(GL_QUADS);
1598  {
1599  for (int i = 0; i < pSkyPolygon->uNumVertices; ++i) {
1600  unsigned int diffuse = ::GetActorTintColor(
1601  31, 0, VertexRenderList[i].vWorldViewPosition.x, 1, 0);
1602 
1603  glColor4f(((diffuse >> 16) & 0xFF) / 255.0f,
1604  ((diffuse >> 8) & 0xFF) / 255.0f,
1605  (diffuse & 0xFF) / 255.0f, 1.0f);
1606 
1608  /*max_v*/ -VertexRenderList[i].v);
1609 
1610  glVertex3f(VertexRenderList[i].vWorldViewProjX,
1611  VertexRenderList[i].vWorldViewProjY,
1612  0.99989998); // z is negative in OpenGL
1613  }
1614  }
1615  glEnd();
1616 }
1617 
1619  engine->draw_debug_outlines();
1620  this->DoRenderBillboards_D3D();
1622 }
1623 
1624 //----- (004A1C1E) --------------------------------------------------------
1626  glEnable(GL_BLEND);
1627  glDepthMask(GL_TRUE);
1628  glDisable(GL_CULL_FACE); // some quads are reversed to reuse sprites opposite hand
1629  glEnable(GL_TEXTURE_2D);
1630 
1633 
1634  for (int i = uNumBillboardsToDraw - 1; i >= 0; --i) {
1637  }
1638 
1640  glBindTexture(GL_TEXTURE_2D, texture->GetOpenGlTexture());
1641 
1642  glBegin(GL_TRIANGLE_FAN);
1643  {
1644  auto billboard = &pBillboardRenderListD3D[i];
1645  auto b = &pBillboardRenderList[i];
1646 
1647  // since OpenGL 1.0 can't mirror texture borders, we should offset
1648  // UV to avoid black edges
1649  billboard->pQuads[0].texcoord.x += 0.5f / texture->GetWidth();
1650  billboard->pQuads[0].texcoord.y += 0.5f / texture->GetHeight();
1651  billboard->pQuads[1].texcoord.x += 0.5f / texture->GetWidth();
1652  billboard->pQuads[1].texcoord.y -= 0.5f / texture->GetHeight();
1653  billboard->pQuads[2].texcoord.x -= 0.5f / texture->GetWidth();
1654  billboard->pQuads[2].texcoord.y -= 0.5f / texture->GetHeight();
1655  billboard->pQuads[3].texcoord.x -= 0.5f / texture->GetWidth();
1656  billboard->pQuads[3].texcoord.y += 0.5f / texture->GetHeight();
1657 
1658  for (unsigned int j = 0; j < billboard->uNumVertices; ++j) {
1659  glColor4f(
1660  ((billboard->pQuads[j].diffuse >> 16) & 0xFF) / 255.0f,
1661  ((billboard->pQuads[j].diffuse >> 8) & 0xFF) / 255.0f,
1662  ((billboard->pQuads[j].diffuse >> 0) & 0xFF) / 255.0f,
1663  1.0f);
1664 
1665  glTexCoord2f(billboard->pQuads[j].texcoord.x,
1666  billboard->pQuads[j].texcoord.y);
1667 
1668  float oneoz = 1. / (billboard->screen_space_z);
1669  float oneon = 1. / (pIndoorCameraD3D->GetNearClip()+5);
1670  float oneof = 1. / pIndoorCameraD3D->GetFarClip();
1671 
1672  glVertex3f(
1673  billboard->pQuads[j].pos.x,
1674  billboard->pQuads[j].pos.y,
1675  (oneoz - oneon)/(oneof - oneon) ); // depth is non linear proportional to reciprocal of distance
1676  }
1677  }
1678  glEnd();
1679  }
1680 
1681  // uNumBillboardsToDraw = 0;
1682 
1683 
1684  if (config->is_using_fog) {
1685  SetUsingFog(false);
1686  glEnable(GL_FOG);
1687  glFogi(GL_FOG_MODE, GL_EXP);
1688 
1689  GLfloat fog_color[] = {((GetLevelFogColor() >> 16) & 0xFF) / 255.0f,
1690  ((GetLevelFogColor() >> 8) & 0xFF) / 255.0f,
1691  ((GetLevelFogColor() >> 0) & 0xFF) / 255.0f,
1692  1.0f};
1693  glFogfv(GL_FOG_COLOR, fog_color);
1694  }
1695 
1696  glDisable(GL_BLEND);
1697  glDepthMask(GL_TRUE);
1698 }
1699 
1700 //----- (004A1DA8) --------------------------------------------------------
1703  switch (a1) {
1705  if (config->is_using_fog) {
1706  SetUsingFog(false);
1707  glEnable(GL_FOG);
1708  glFogi(GL_FOG_MODE, GL_EXP);
1709 
1710  GLfloat fog_color[] = {
1711  ((GetLevelFogColor() >> 16) & 0xFF) / 255.0f,
1712  ((GetLevelFogColor() >> 8) & 0xFF) / 255.0f,
1713  ((GetLevelFogColor() >> 0) & 0xFF) / 255.0f, 1.0f};
1714  glFogfv(GL_FOG_COLOR, fog_color);
1715  }
1716 
1717  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1718  } break;
1719 
1723  if (config->is_using_specular) {
1724  if (!config->is_using_fog) {
1725  SetUsingFog(true);
1726  glDisable(GL_FOG);
1727  }
1728  }
1729 
1730  glBlendFunc(GL_ONE, GL_ZERO);
1731  } break;
1732 
1733  default:
1734  log->Warning(
1735  L"SetBillboardBlendOptions: invalid opacity type (%u)", a1);
1736  assert(false);
1737  break;
1738  }
1739 }
1740 
1741 void RenderOpenGL::PackScreenshot(unsigned int width, unsigned int height,
1742  void *out_data, unsigned int data_size,
1743  unsigned int *screenshot_size) {
1744  /*auto pixels = MakeScreenshot(150, 112);
1745  PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size);
1746  free(pixels);*/
1747 }
1748 
1749 void RenderOpenGL::SetUIClipRect(unsigned int x, unsigned int y, unsigned int z,
1750  unsigned int w) {
1751  this->clip_x = x;
1752  this->clip_y = y;
1753  this->clip_z = z;
1754  this->clip_w = w;
1755  glScissor(x, 480-w, z-x, w-y); // invert glscissor co-ords 0,0 is BL
1756 }
1757 
1759  this->SetUIClipRect(0, 0, this->window->GetWidth(), this->window->GetHeight());
1760 }
1761 
1763  BeginScene();
1764  ClearBlack();
1765  EndScene();
1766  Present();
1767 }
1768 
1770  // Setup for 2D
1771 
1772  glDepthMask(GL_FALSE);
1773  glDisable(GL_DEPTH_TEST);
1774  glDisable(GL_CULL_FACE);
1775 
1778 }
1779 
1781  // blank in d3d
1782 }
1783 
1784 
1785 
1787  DrawTextureNew(u, v, img);
1788  return;
1789 }
1790 
1791 void RenderOpenGL::DrawTextureNew(float u, float v, Image *tex) {
1792  if (!tex) __debugbreak();
1793 
1794  glEnable(GL_TEXTURE_2D);
1795  glColor3f(1, 1, 1);
1796  glEnable(GL_BLEND);
1797  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1798 
1799  auto texture = (TextureOpenGL *)tex;
1800  glBindTexture(GL_TEXTURE_2D, texture->GetOpenGlTexture());
1801 
1802  int clipx = this->clip_x;
1803  int clipy = this->clip_y;
1804  int clipw = this->clip_w;
1805  int clipz = this->clip_z;
1806 
1807  int width = tex->GetWidth();
1808  int height = tex->GetHeight();
1809 
1810  int x = u * 640;
1811  int y = v * 480;
1812  int z = x + width;
1813  int w = y + height;
1814 
1815  // check bounds
1816  if (x >= 640 || x >= clipz || y >= 480 || y >= clipw) return;
1817  // check for overlap
1818  if ((clipx < z && clipz > x && clipy > w && clipw < y)) return;
1819 
1820  int drawx = std::max(x, clipx);
1821  int drawy = std::max(y, clipy);
1822  int draww = std::min(w, clipw);
1823  int drawz = std::min(z, clipz);
1824 
1825  float depth = 0;
1826 
1827  GLfloat Vertices[] = { (float)drawx, (float)drawy, depth,
1828  (float)drawz, (float)drawy, depth,
1829  (float)drawz, (float)draww, depth,
1830  (float)drawx, (float)draww, depth };
1831 
1832  float texx = (drawx - x) / float(width);
1833  float texy = (drawy - y) / float(height);
1834  float texz = (width - (z - drawz)) / float(width);
1835  float texw = (height - (w - draww)) / float(height);
1836 
1837  GLfloat TexCoord[] = { texx, texy,
1838  texz, texy,
1839  texz, texw,
1840  texx, texw,
1841  };
1842 
1843  GLubyte indices[] = { 0, 1, 2, // first triangle (bottom left - top left - top right)
1844  0, 2, 3 }; // second triangle (bottom left - top right - bottom right)
1845 
1846  glEnableClientState(GL_VERTEX_ARRAY);
1847  glVertexPointer(3, GL_FLOAT, 0, Vertices);
1848 
1849  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
1850  glTexCoordPointer(2, GL_FLOAT, 0, TexCoord);
1851 
1852  glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);
1853 
1854  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1855  glDisableClientState(GL_VERTEX_ARRAY);
1856 
1857  glDisable(GL_BLEND);
1858 
1859  GLenum err;
1860  while ((err = glGetError()) != GL_NO_ERROR) {
1861  log->Warning(L"OpenGL error: (%u)", err);
1862  }
1863 
1864  // blank over same bit of this render_target_rgb to stop text overlaps
1865  for (int ys = drawy; ys < draww; ys++) {
1866  memset(this->render_target_rgb +(ys * 640 + drawx), 0x00000000, (drawz - drawx) * 4);
1867  }
1868 }
1869 
1870 void RenderOpenGL::DrawTextureCustomHeight(float u, float v, class Image *img,
1871  int custom_height) {
1872  unsigned __int16 *v6; // esi@3
1873  unsigned int v8; // eax@5
1874  unsigned int v11; // eax@7
1875  unsigned int v12; // ebx@8
1876  unsigned int v15; // eax@14
1877  int v19; // [sp+10h] [bp-8h]@3
1878 
1879  if (!img) return;
1880 
1881  unsigned int uOutX = 640 * u;
1882  unsigned int uOutY = 480 * v;
1883 
1884  int width = img->GetWidth();
1885  int height = std::min((int)img->GetHeight(), custom_height);
1886  v6 = (unsigned __int16 *)img->GetPixels(IMAGE_FORMAT_R5G6B5);
1887 
1888  // v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
1889  v19 = width;
1890  // if (this->bClip)
1891  {
1892  if ((signed int)uOutX < (signed int)this->clip_x) {
1893  v8 = this->clip_x - uOutX;
1894  unsigned int v9 = uOutX - this->clip_x;
1895  v8 *= 2;
1896  width += v9;
1897  v6 = (unsigned __int16 *)((char *)v6 + v8);
1898  // v5 = (unsigned __int16 *)((char *)v5 + v8);
1899  }
1900  if ((signed int)uOutY < (signed int)this->clip_y) {
1901  v11 = this->clip_y - uOutY;
1902  v6 += v19 * v11;
1903  height += uOutY - this->clip_y;
1904  // v5 += this->uTargetSurfacePitch * v11;
1905  }
1906  v12 = std::max((unsigned int)this->clip_x, uOutX);
1907  if ((signed int)(width + v12) > (signed int)this->clip_z) {
1908  width = this->clip_z - std::max(this->clip_x, (int)uOutX);
1909  }
1910  v15 = std::max((unsigned int)this->clip_y, uOutY);
1911  if ((signed int)(v15 + height) > (signed int)this->clip_w) {
1912  height = this->clip_w - std::max(this->clip_y, (int)uOutY);
1913  }
1914  }
1915 
1916  for (int y = 0; y < height; y++) {
1917  for (int x = 0; x < width; x++) {
1918  WritePixel16(uOutX + x, uOutY + y, *v6);
1919  // *v5 = *v6;
1920  // ++v5;
1921  ++v6;
1922  }
1923  v6 += v19 - width;
1924  // v5 += this->uTargetSurfacePitch - v4;
1925  }
1926 }
1927 
1928 void RenderOpenGL::DrawText(int uOutX, int uOutY, uint8_t *pFontPixels,
1929  unsigned int uCharWidth, unsigned int uCharHeight,
1930  uint8_t *pFontPalette, unsigned __int16 uFaceColor,
1931  unsigned __int16 uShadowColor) {
1932  // needs limits checks adding
1933 
1934  // Image *fonttemp = Image::Create(uCharWidth, uCharHeight, IMAGE_FORMAT_A8R8G8B8);
1935  // uint32_t *fontpix = (uint32_t*)fonttemp->GetPixels(IMAGE_FORMAT_A8R8G8B8);
1936 
1937  for (uint y = 0; y < uCharHeight; ++y) {
1938  for (uint x = 0; x < uCharWidth; ++x) {
1939  if (*pFontPixels) {
1940  uint16_t color = uShadowColor;
1941  if (*pFontPixels != 1) {
1942  color = uFaceColor;
1943  }
1944  // fontpix[x + y * uCharWidth] = Color32(color);
1945  this->render_target_rgb[(uOutX+x)+(uOutY+y)*640] = Color32(color);
1946  }
1947  ++pFontPixels;
1948  }
1949  }
1950  // render->DrawTextureAlphaNew(uOutX / 640., uOutY / 480., fonttemp);
1951  // fonttemp->Release();
1952 }
1953 
1954 void RenderOpenGL::DrawTextAlpha(int x, int y, unsigned char *font_pixels,
1955  int uCharWidth, unsigned int uFontHeight,
1956  uint8_t *pPalette,
1957  bool present_time_transparency) {
1958  // needs limits checks adding
1959 
1960  // Image *fonttemp = Image::Create(uCharWidth, uFontHeight, IMAGE_FORMAT_A8R8G8B8);
1961  // uint32_t *fontpix = (uint32_t *)fonttemp->GetPixels(IMAGE_FORMAT_A8R8G8B8);
1962 
1963  if (present_time_transparency) {
1964  for (unsigned int dy = 0; dy < uFontHeight; ++dy) {
1965  for (unsigned int dx = 0; dx < uCharWidth; ++dx) {
1966  uint16_t color = (*font_pixels)
1967  ? pPalette[*font_pixels]
1968  : 0x7FF; // transparent color 16bit
1969  // render->uTargetGMask |
1970  // render->uTargetBMask;
1971  this->render_target_rgb[(x + dx) + (y + dy) * 640] = Color32(color);
1972  // fontpix[dx + dy * uCharWidth] = Color32(color);
1973  ++font_pixels;
1974  }
1975  }
1976  } else {
1977  for (unsigned int dy = 0; dy < uFontHeight; ++dy) {
1978  for (unsigned int dx = 0; dx < uCharWidth; ++dx) {
1979  if (*font_pixels) {
1980  uint8_t index = *font_pixels;
1981  uint8_t r = pPalette[index * 3 + 0];
1982  uint8_t g = pPalette[index * 3 + 1];
1983  uint8_t b = pPalette[index * 3 + 2];
1984  this->render_target_rgb[(x + dx) + (y + dy) * 640] = Color32(r, g, b);
1985  // fontpix[dx + dy * uCharWidth] = Color32(r, g, b);
1986  }
1987  ++font_pixels;
1988  }
1989  }
1990  }
1991  // render->DrawTextureAlphaNew(x / 640., y / 480., fonttemp);
1992  // fonttemp->Release();
1993 }
1994 
1996  // screen overlay holds all text and changing images at the moment
1997 
1998  static Texture *screen_text_overlay = 0;
1999  if (!screen_text_overlay) {
2000  screen_text_overlay = render->CreateTexture_Blank(640, 480, IMAGE_FORMAT_A8R8G8B8);
2001  }
2002 
2003  uint32_t *pix = (uint32_t*)screen_text_overlay->GetPixels(IMAGE_FORMAT_A8R8G8B8);
2004  unsigned int num_pixels = screen_text_overlay->GetWidth() * screen_text_overlay->GetHeight();
2005  unsigned int num_pixels_bytes = num_pixels * IMAGE_FORMAT_BytesPerPixel(IMAGE_FORMAT_A8R8G8B8);
2006 
2007  // update pixels
2008  memcpy(pix, this->render_target_rgb, num_pixels_bytes);
2009  // update texture
2010  render->Update_Texture(screen_text_overlay);
2011  // draw
2012  render->DrawTextureAlphaNew(0, 0, screen_text_overlay);
2013 
2014  window->OpenGlSwapBuffers();
2015 }
2016 
2019  // int v27; // eax@57
2020  int v49; // [sp+2Ch] [bp-2Ch]@10
2021  int v50; // [sp+30h] [bp-28h]@34
2022  int v51; // [sp+34h] [bp-24h]@35
2023  int v52; // [sp+38h] [bp-20h]@36
2024  int v53; // [sp+3Ch] [bp-1Ch]@8
2025 
2028 
2029  for (BSPModel &model : pOutdoor->pBModels) {
2030  int reachable;
2031  if (IsBModelVisible(&model, &reachable)) {
2032  model.field_40 |= 1;
2033  if (!model.pFaces.empty()) {
2034  for (ODMFace &face : model.pFaces) {
2035  if (!face.Invisible()) {
2036  v53 = 0;
2037  auto poly =
2039 
2040  poly->flags = 0;
2041  poly->field_32 = 0;
2042  poly->texture = face.GetTexture();
2043 
2044  if (face.uAttributes & FACE_FLUID) poly->flags |= 2;
2045  if (face.uAttributes & FACE_INDOOR_SKY)
2046  poly->flags |= 0x400;
2047 
2048  if (face.uAttributes & FACE_FLOW_DIAGONAL)
2049  poly->flags |= 0x400;
2050  else if (face.uAttributes & FACE_FLOW_VERTICAL)
2051  poly->flags |= 0x800;
2052 
2053  if (face.uAttributes & FACE_FLOW_HORIZONTAL)
2054  poly->flags |= 0x2000;
2055  else if (face.uAttributes & FACE_DONT_CACHE_TEXTURE)
2056  poly->flags |= 0x1000;
2057 
2058  poly->sTextureDeltaU = face.sTextureDeltaU;
2059  poly->sTextureDeltaV = face.sTextureDeltaV;
2060 
2061  unsigned int flow_anim_timer = OS_GetTime() >> 4;
2062  unsigned int flow_u_mod = poly->texture->GetWidth() - 1;
2063  unsigned int flow_v_mod =
2064  poly->texture->GetHeight() - 1;
2065 
2066  if (face.pFacePlane.vNormal.z &&
2067  abs(face.pFacePlane.vNormal.z) >= 59082) {
2068  if (poly->flags & 0x400)
2069  poly->sTextureDeltaV +=
2070  flow_anim_timer & flow_v_mod;
2071  if (poly->flags & 0x800)
2072  poly->sTextureDeltaV -=
2073  flow_anim_timer & flow_v_mod;
2074  } else {
2075  if (poly->flags & 0x400)
2076  poly->sTextureDeltaV -=
2077  flow_anim_timer & flow_v_mod;
2078  if (poly->flags & 0x800)
2079  poly->sTextureDeltaV +=
2080  flow_anim_timer & flow_v_mod;
2081  }
2082 
2083  if (poly->flags & 0x1000)
2084  poly->sTextureDeltaU -=
2085  flow_anim_timer & flow_u_mod;
2086  else if (poly->flags & 0x2000)
2087  poly->sTextureDeltaU +=
2088  flow_anim_timer & flow_u_mod;
2089 
2090  v50 = 0;
2091  v49 = 0;
2092 
2093  for (uint vertex_id = 1; vertex_id <= face.uNumVertices;
2094  vertex_id++) {
2095  array_73D150[vertex_id - 1].vWorldPosition.x =
2096  model.pVertices
2097  .pVertices[face.pVertexIDs[vertex_id - 1]]
2098  .x;
2099  array_73D150[vertex_id - 1].vWorldPosition.y =
2100  model.pVertices
2101  .pVertices[face.pVertexIDs[vertex_id - 1]]
2102  .y;
2103  array_73D150[vertex_id - 1].vWorldPosition.z =
2104  model.pVertices
2105  .pVertices[face.pVertexIDs[vertex_id - 1]]
2106  .z;
2107  array_73D150[vertex_id - 1].u =
2108  (poly->sTextureDeltaU +
2109  (__int16)face.pTextureUIDs[vertex_id - 1]) *
2110  (1.0 / (double)poly->texture->GetWidth());
2111  array_73D150[vertex_id - 1].v =
2112  (poly->sTextureDeltaV +
2113  (__int16)face.pTextureVIDs[vertex_id - 1]) *
2114  (1.0 / (double)poly->texture->GetHeight());
2115  }
2117  sizeof(array_73D150));
2118 
2119  /*for (uint i = 1; i <= face.uNumVertices; i++) {
2120  if (model.pVertices.pVertices[face.pVertexIDs[0]]
2121  .z == array_73D150[i - 1].vWorldPosition.z)
2122  ++v53;
2123  pIndoorCameraD3D->ViewTransform(
2124  &array_73D150[i - 1], 1);
2125  if (array_73D150[i - 1].vWorldViewPosition.x <
2126  pIndoorCameraD3D->GetNearClip() ||
2127  array_73D150[i - 1].vWorldViewPosition.x >
2128  pIndoorCameraD3D->GetFarClip()) {
2129  if (array_73D150[i - 1].vWorldViewPosition.x >=
2130  pIndoorCameraD3D->GetNearClip())
2131  v49 = 1;
2132  else
2133  v50 = 1;
2134  } else {
2135  pIndoorCameraD3D->Project(&array_73D150[i - 1],
2136  1, 0);
2137  }
2138  }*/
2139 
2140  if (v53 == face.uNumVertices) {
2141  poly->field_32 |= 1;
2142  }
2143  poly->pODMFace = &face;
2144  poly->uNumVertices = face.uNumVertices;
2145  poly->field_59 = 5;
2146  v51 = fixpoint_mul(-pOutdoor->vSunlight.x,
2147  face.pFacePlane.vNormal.x);
2148  v53 = fixpoint_mul(-pOutdoor->vSunlight.y,
2149  face.pFacePlane.vNormal.y);
2150  v52 = fixpoint_mul(-pOutdoor->vSunlight.z,
2151  face.pFacePlane.vNormal.z);
2152  poly->dimming_level =
2153  20 - fixpoint_mul(20, v51 + v53 + v52);
2154  if (poly->dimming_level < 0) poly->dimming_level = 0;
2155  if (poly->dimming_level > 31) poly->dimming_level = 31;
2156  if (pODMRenderParams->uNumPolygons >= 1999 + 5000)
2157  return;
2159  face.bVisible = 1;
2160  poly->uBModelFaceID = face.index;
2161  poly->uBModelID = model.index;
2162  poly->pid = PID(OBJECT_BModel,
2163  face.index | (model.index << 6));
2164  for (int vertex_id = 0;
2165  vertex_id < face.uNumVertices; ++vertex_id) {
2166  memcpy(&VertexRenderList[vertex_id],
2167  &array_73D150[vertex_id],
2168  sizeof(VertexRenderList[vertex_id]));
2169  VertexRenderList[vertex_id]._rhw =
2170  1.0 / (array_73D150[vertex_id]
2172  0.0000001);
2173  }
2174 
2175 
2176  // this does not work for ogl - fix?
2177  /*if (v50) {
2178  poly->uNumVertices = ODM_NearClip(face.uNumVertices);
2179  ODM_Project(poly->uNumVertices);
2180  }
2181  if (v49) {
2182  poly->uNumVertices = ODM_FarClip(face.uNumVertices);
2183  ODM_Project(poly->uNumVertices);
2184  }*/
2185 
2186  if (poly->uNumVertices) {
2187  if (poly->IsWater()) {
2188  if (poly->IsWaterAnimDisabled())
2189  poly->texture =
2190  render->hd_water_tile_anim[0];
2191  else
2192  poly->texture =
2193  render->hd_water_tile_anim
2194  [render
2195  ->hd_water_current_frame];
2196  }
2197 
2198  render->DrawPolygon(poly);
2199  }
2200  }
2201  }
2202  }
2203  }
2204  }
2205  }
2206 }
2207 
2209  if (poly->uNumVertices < 3) {
2210  return;
2211  }
2212 
2213  auto texture = (TextureOpenGL *)poly->texture;
2214  auto a4 = poly->pODMFace;
2215  auto uNumVertices = poly->uNumVertices;
2216 
2217  unsigned int a2 = 0xFFFFFFFF;
2218  engine->AlterGamma_ODM(a4, &a2);
2219 
2221  _4D864C_force_sw_render_rules && engine->config->Flag1_2()) {
2222  glEnable(GL_TEXTURE_2D);
2223  glDisable(GL_BLEND);
2224  glBindTexture(GL_TEXTURE_2D, texture->GetOpenGlTexture());
2225 
2226  glBegin(GL_TRIANGLE_FAN); // GL_TRIANGLE_FAN
2227 
2228  int outline_color;
2229  if (OS_GetTime() % 300 >= 150)
2230  outline_color = 0xFFFF2020;
2231  else
2232  outline_color = 0xFF901010;
2233 
2234  for (uint i = 0; i < uNumVertices; ++i) {
2237  d3d_vertex_buffer[i].pos.z =
2238  1.0 - 1.0 / ((VertexRenderList[i].vWorldViewPosition.x * 1000) /
2240  d3d_vertex_buffer[i].rhw =
2241  1.0 / (VertexRenderList[i].vWorldViewPosition.x + 0.0000001);
2243  poly->dimming_level, 0,
2245  engine->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse);
2246 
2247  if (a4->uAttributes & FACE_OUTLINED) {
2248  d3d_vertex_buffer[i].diffuse = outline_color;
2249  }
2250 
2251  if (config->is_using_specular)
2253  0, 0, VertexRenderList[i].vWorldViewPosition.x);
2254  else
2255  d3d_vertex_buffer[i].specular = 0;
2258 
2261 
2262  glColor4f(
2263  ((d3d_vertex_buffer[i].diffuse >> 16) & 0xFF) / 255.0f,
2264  ((d3d_vertex_buffer[i].diffuse >> 8) & 0xFF) / 255.0f,
2265  ((d3d_vertex_buffer[i].diffuse >> 0) & 0xFF) / 255.0f,
2266  config->is_using_specular
2267  ? ((d3d_vertex_buffer[i].diffuse >> 24) & 0xFF) / 255.0f
2268  : 1.0f);
2269 
2270  glVertex3f(ogl_draw_buildings_vertices[i].vWorldPosition.x,
2273  }
2274 
2275  glEnd();
2276 
2277  GLenum err;
2278  while ((err = glGetError()) != GL_NO_ERROR) {
2279  log->Warning(L"OpenGL error: (%u)", err);
2280  }
2281 
2282  } else {
2283  /*for (uint i = 0; i < uNumVertices; ++i)
2284  {
2285 
2286  d3d_vertex_buffer[i].pos.x = VertexRenderList[i].vWorldViewProjX;
2287  d3d_vertex_buffer[i].pos.y = VertexRenderList[i].vWorldViewProjY;
2288  d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 /
2289  ((VertexRenderList[i].vWorldViewPosition.x * 1000) /
2290  (double)pODMRenderParams->shading_dist_mist); d3d_vertex_buffer[i].rhw
2291  = 1.0 / (VertexRenderList[i].vWorldViewPosition.x + 0.0000001);
2292  d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0,
2293  VertexRenderList[i].vWorldViewPosition.x, 0, 0); if
2294  (this->bUsingSpecular) d3d_vertex_buffer[i].specular =
2295  sub_47C3D7_get_fog_specular(0, 0,
2296  VertexRenderList[i].vWorldViewPosition.x); else
2297  d3d_vertex_buffer[i].specular = 0;
2298  d3d_vertex_buffer[i].texcoord.x = VertexRenderList[i].u;
2299  d3d_vertex_buffer[i].texcoord.y = VertexRenderList[i].v;
2300 
2301  }
2302 
2303  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE,
2304  FALSE)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0,
2305  D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); if (bUsingSpecular)
2306  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE,
2307  FALSE));
2308 
2309  ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
2310  ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
2311  D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
2312  d3d_vertex_buffer,
2313  uNumVertices,
2314  D3DDP_DONOTLIGHT));
2315  //v50 = (const char *)v5->pRenderD3D->pDevice;
2316  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE,
2317  D3DCULL_NONE));
2318  //(*(void (**)(void))(*(int *)v50 + 88))();
2319  lightmap_builder->DrawLightmaps(-1);
2320  for (uint i = 0; i < uNumVertices; ++i)
2321  {
2322  d3d_vertex_buffer[i].diffuse = a2;
2323  }
2324  ErrD3D(pRenderD3D->pDevice->SetTexture(0,
2325  texture->GetDirect3DTexture()));
2326  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS,
2327  D3DTADDRESS_WRAP)); if (!render->bUsingSpecular)
2328  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE,
2329  TRUE));
2330 
2331  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,
2332  TRUE));
2333  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,
2334  D3DBLEND_ZERO));
2335  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,
2336  D3DBLEND_SRCCOLOR));
2337  ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
2338  D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
2339  d3d_vertex_buffer,
2340  uNumVertices,
2341  D3DDP_DONOTLIGHT));
2342  if (bUsingSpecular)
2343  {
2344  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE,
2345  TRUE));
2346 
2347  for (uint i = 0; i < uNumVertices; ++i)
2348  {
2349  d3d_vertex_buffer[i].diffuse = render->uFogColor |
2350  d3d_vertex_buffer[i].specular & 0xFF000000;
2351  d3d_vertex_buffer[i].specular = 0;
2352  }
2353 
2354  ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
2355  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,
2356  D3DBLEND_INVSRCALPHA));
2357  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,
2358  D3DBLEND_SRCALPHA));
2359  ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
2360  D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
2361  d3d_vertex_buffer,
2362  uNumVertices,
2363  D3DDP_DONOTLIGHT));
2364  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE,
2365  TRUE));
2366  //v40 = render->pRenderD3D->pDevice->lpVtbl;
2367  v41 = GetLevelFogColor();
2368  pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR,
2369  GetLevelFogColor() & 0xFFFFFF); v6 = 0;
2370  pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0);
2371  }
2372  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,
2373  D3DBLEND_ONE));
2374  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,
2375  D3DBLEND_ZERO));
2376  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,
2377  v6));*/
2378  }
2379 }
2380 
2382  int uPackedID, unsigned int uColor,
2383  int a8) {
2384  if (uNumVertices < 3) {
2385  return;
2386  }
2387 
2390 
2391  unsigned int sCorrectedColor = uColor;
2392 
2394 
2395  if (lightmap_builder->StationaryLightsCount) sCorrectedColor = -1;
2396  engine->AlterGamma_BLV(pFace, &sCorrectedColor);
2397 
2398  if (pFace->uAttributes & FACE_OUTLINED) {
2399  if (OS_GetTime() % 300 >= 150)
2400  uColor = sCorrectedColor = 0xFF20FF20;
2401  else
2402  uColor = sCorrectedColor = 0xFF109010;
2403  }
2404 
2405  if (_4D864C_force_sw_render_rules && engine->config->Flag1_1()) {
2406  /*
2407  __debugbreak();
2408  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE,
2409  false)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0,
2410  D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); for (uint i = 0; i <
2411  uNumVertices; ++i)
2412  {
2413  d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
2414  d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
2415  d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 /
2416  (array_507D30[i].vWorldViewPosition.x * 0.061758894);
2417  d3d_vertex_buffer[i].rhw = 1.0 /
2418  array_507D30[i].vWorldViewPosition.x; d3d_vertex_buffer[i].diffuse =
2419  sCorrectedColor; d3d_vertex_buffer[i].specular = 0;
2420  d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u /
2421  (double)pFace->GetTexture()->GetWidth();
2422  d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v /
2423  (double)pFace->GetTexture()->GetHeight();
2424  }
2425 
2426  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS,
2427  D3DTADDRESS_WRAP)); ErrD3D(pRenderD3D->pDevice->SetTexture(0,
2428  nullptr));
2429  ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
2430  D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
2431  d3d_vertex_buffer, uNumVertices, 28));
2432  lightmap_builder->DrawLightmaps(-1);
2433  */
2434  } else {
2436  _4D864C_force_sw_render_rules && engine->config->Flag1_2()) {
2437  glEnable(GL_TEXTURE_2D);
2438  glDisable(GL_BLEND);
2439  glBindTexture(GL_TEXTURE_2D, texture->GetOpenGlTexture());
2440 
2441  // glDisable(GL_CULL_FACE); // testing
2442  // glDisable(GL_DEPTH_TEST);
2443 
2444  // if (uNumVertices != 3 ) return; //3 ,4, 5 ,6
2445 
2446  glBegin(GL_TRIANGLE_FAN);
2447 
2448  for (uint i = 0; i < uNumVertices; ++i) {
2451  d3d_vertex_buffer[i].pos.z =
2452  1.0 -
2453  1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
2454 
2455  d3d_vertex_buffer[i].rhw =
2457  d3d_vertex_buffer[i].diffuse = sCorrectedColor;
2458  d3d_vertex_buffer[i].specular = 0;
2460  array_507D30[i].u / (double)pFace->GetTexture()->GetWidth();
2462  array_507D30[i].v /
2463  (double)pFace->GetTexture()->GetHeight();
2464 
2465 
2466  /*glTexCoord2f(d3d_vertex_buffer[i].texcoord.x,
2467  d3d_vertex_buffer[i].texcoord.y);*/
2468 
2469  glTexCoord2f((pFace->pVertexUIDs[i]/ (double)pFace->GetTexture()->GetWidth()), (pFace->pVertexVIDs[i]/ (double)pFace->GetTexture()->GetHeight()));
2470 
2471 
2472  /*glColor4f(
2473  ((d3d_vertex_buffer[i].diffuse >> 16) & 0xFF) / 255.0f,
2474  ((d3d_vertex_buffer[i].diffuse >> 8) & 0xFF) / 255.0f,
2475  ((d3d_vertex_buffer[i].diffuse >> 0) & 0xFF) / 255.0f,
2476  config->is_using_specular
2477  ? ((d3d_vertex_buffer[i].diffuse >> 24) & 0xFF) / 255.0f
2478  : 1.0f);*/
2479 
2480  glColor4f(1, 1, 1, 1);
2481 
2482  /*glVertex3f(d3d_vertex_buffer[i].pos.x,
2483  d3d_vertex_buffer[i].pos.z,
2484  d3d_vertex_buffer[i].pos.y);*/
2485 
2486 
2487 
2488  glVertex3f(pIndoor->pVertices[pFace->pVertexIDs[i]].x,
2489  pIndoor->pVertices[pFace->pVertexIDs[i]].z,
2490  pIndoor->pVertices[pFace->pVertexIDs[i]].y);
2491  }
2492 
2493  glEnd();
2494  } else {
2495  /*
2496  glEnable(GL_TEXTURE_2D);
2497  glDisable(GL_BLEND);
2498  glBindTexture(GL_TEXTURE_2D, texture->GetOpenGlTexture());
2499 
2500  glBegin(GL_TRIANGLE_FAN);
2501 
2502  for (uint i = 0; i < uNumVertices; ++i) {
2503  d3d_vertex_buffer[i].pos.x =
2504  array_507D30[i].vWorldViewProjX; d3d_vertex_buffer[i].pos.y =
2505  array_507D30[i].vWorldViewProjY; d3d_vertex_buffer[i].pos.z = 1.0
2506  - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
2507  d3d_vertex_buffer[i].rhw = 1.0 /
2508  array_507D30[i].vWorldViewPosition.x;
2509  d3d_vertex_buffer[i].diffuse = uColor;
2510  d3d_vertex_buffer[i].specular = 0;
2511  d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u /
2512  (double)pFace->GetTexture()->GetWidth();
2513  d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v /
2514  (double)pFace->GetTexture()->GetHeight();
2515  }
2516  glBindTexture(GL_TEXTURE_2D,
2517  face_texture->GetOpenGlTexture());
2518  ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
2519  D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR |
2520  D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 28));
2521 
2522  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE,
2523  D3DCULL_NONE)); lightmap_builder->DrawLightmaps(-1);
2524 
2525  for (uint i = 0; i < uNumVertices; ++i)
2526  d3d_vertex_buffer[i].diffuse = sCorrectedColor;
2527 
2528  glBindTexture(GL_TEXTURE_2D,
2529  face_texture->GetOpenGlTexture());
2530  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE,
2531  TRUE));
2532  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,
2533  TRUE));
2534  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,
2535  D3DBLEND_ZERO));
2536  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,
2537  D3DBLEND_SRCCOLOR));
2538  ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
2539  D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR |
2540  D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 28));
2541  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,
2542  D3DBLEND_ONE));
2543  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,
2544  D3DBLEND_ZERO));
2545  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,
2546  FALSE));
2547  */
2548  }
2549  }
2550 }
2551 
2553  // pParty->uFlags |= PARTY_FLAGS_1_0002;
2555  CreateZBuffer();
2556 
2557  return true;
2558 }
2559 
2560 
2562  if (!RenderBase::Initialize(window_)) {
2563  return false;
2564  }
2565 
2566  if (window != nullptr) {
2567  window->OpenGlCreate();
2568 
2569 
2570  glShadeModel(GL_SMOOTH);
2571  glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Black Background
2572  glClearDepth(1.0f);
2573  glEnable(GL_DEPTH_TEST);
2574  glDepthFunc(GL_LEQUAL);
2575  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
2576 
2577  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
2578 
2579  glViewport(0, 0, window->GetWidth(), window->GetHeight());
2580  glScissor(0, 0, window->GetWidth(), window->GetHeight());
2581 
2582  glEnable(GL_SCISSOR_TEST);
2583 
2584  glMatrixMode(GL_PROJECTION);
2585  glLoadIdentity();
2586 
2587  // Calculate The Aspect Ratio Of The Window
2588  gluPerspective(45.0f,
2589  (GLfloat)window->GetWidth() / (GLfloat)window->GetHeight(),
2590  0.1f, 100.0f);
2591 
2592  glMatrixMode(GL_MODELVIEW);
2593  glLoadIdentity();
2594 
2595  // Swap Buffers (Double Buffering)
2596  window->OpenGlSwapBuffers();
2597 
2598  this->clip_x = this->clip_y = 0;
2599  this->clip_z = window->GetWidth();
2600  this->clip_w = window->GetHeight();
2601  this->render_target_rgb =
2602  new uint32_t[window->GetWidth() *
2603  window->GetHeight()];
2604 
2606 
2607  return true;
2608  }
2609 
2610  return false;
2611 }
2612 
2614  // render target now 32 bit - format A8R8G8B8
2615  render_target_rgb[x + window->GetWidth() * y] = Color32(color);
2616 }
2617 
2618 void RenderOpenGL::FillRectFast(unsigned int uX, unsigned int uY,
2619  unsigned int uWidth, unsigned int uHeight,
2620  unsigned int uColor16) {
2621  // uint32_t col = Color32(uColor16);
2622  // for (unsigned int dy = 0; dy < uHeight; ++dy) {
2623  // memset32(this->render_target_rgb + ((uY+dy) * window->GetWidth() + uX), col, uWidth);
2624  // }
2625 
2626  glDisable(GL_TEXTURE_2D);
2627  glDisable(GL_BLEND);
2628 
2629  unsigned int b = (uColor16 & 0x1F) * 8;
2630  unsigned int g = ((uColor16 >> 5) & 0x3F) * 4;
2631  unsigned int r = ((uColor16 >> 11) & 0x1F) * 8;
2632  glColor3ub(r, g, b);
2633 
2634  float depth = 0;
2635 
2636  GLfloat Vertices[] = { (float)uX, (float)uY, depth,
2637  (float)(uX+uWidth), (float)uY, depth,
2638  (float)(uX + uWidth), (float)(uY+uHeight), depth,
2639  (float)uX, (float)(uY + uHeight), depth };
2640 
2641  GLubyte indices[] = { 0, 1, 2, // first triangle (bottom left - top left - top right)
2642  0, 2, 3 }; // second triangle (bottom left - top right - bottom right)
2643 
2644  glEnableClientState(GL_VERTEX_ARRAY);
2645  glVertexPointer(3, GL_FLOAT, 0, Vertices);
2646  glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);
2647  glDisableClientState(GL_VERTEX_ARRAY);
2648 
2649  GLenum err;
2650  while ((err = glGetError()) != GL_NO_ERROR) {
2651  log->Warning(L"OpenGL error: (%u)", err);
2652  }
2653 }
2654 
2655 
SDL.h
OSWindow.h
uint16_t
unsigned __int16 uint16_t
Definition: SDL_config.h:37
RenderBillboardD3D::Opaque_2
@ Opaque_2
Definition: IRender.h:152
RenderOpenGL::DrawIndoorSky
virtual void DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID)
Definition: RenderOpenGL.cpp:637
Particle_sw::z
float z
Definition: ParticleEngine.h:22
OutdoorLocationTerrain::pHeightmap
uint8_t * pHeightmap
Definition: Outdoor.h:55
SkyBillboardStruct::field_0_party_dir_x
int field_0_party_dir_x
Definition: IRender.h:468
RenderOpenGL::Release
virtual void Release()
Definition: RenderOpenGL.cpp:135
Vec3_float_
Definition: VectorTypes.h:74
ParticleEngine.h
LevelDecorationChangeSeason
SpriteFrame * LevelDecorationChangeSeason(DecorationDesc *desc, int t, int month)
Definition: Sprites.cpp:614
Party::vPosition
Vec3_int_ vPosition
Definition: Party.h:250
BSPModel::pVertices
struct BSPVertexBuffer pVertices
Definition: BSPModel.h:189
face
GLenum GLuint GLint GLenum face
Definition: SDL_opengl_glext.h:3022
pNew_LOD
LOD::WriteableFile * pNew_LOD
Definition: LOD.cpp:24
glDisableClientState
GLAPI void GLAPIENTRY glDisableClientState(GLenum cap)
RenderOpenGL::DrawIndoorPolygon
virtual void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, int uPackedID, unsigned int uColor, int a8)
Definition: RenderOpenGL.cpp:2381
SpriteFrame::hw_sprites
Sprite * hw_sprites[8]
Definition: Sprites.h:46
pLevelDecorations
std::array< LevelDecoration, 3000 > pLevelDecorations
Definition: Decoration.cpp:8
Party::y_rotation_granularity
int y_rotation_granularity
Definition: Party.h:242
SpellFX_Billboard
Definition: SpellFxRenderer.h:13
glEnd
GLAPI void GLAPIENTRY glEnd(void)
DecorationDesc_mm6::uFlags
int16_t uFlags
Definition: DecorationList.h:44
mask
GLenum GLint GLuint mask
Definition: SDL_opengl_glext.h:660
RenderBillboard::hwsprite
Sprite * hwsprite
Definition: IRender.h:32
RenderOpenGL::DrawTerrainPolygon
virtual void DrawTerrainPolygon(struct Polygon *a4, bool transparent, bool clampAtTextureBorders)
Definition: RenderOpenGL.cpp:1303
Viewport.h
Particle_sw::b
float b
Definition: ParticleEngine.h:25
SDL_opengl_glext.h
IndoorCameraD3D::sRotationY
int sRotationY
Definition: IndoorCameraD3D.h:247
v
const GLdouble * v
Definition: SDL_opengl.h:2064
glDeleteTextures
GLAPI void GLAPIENTRY glDeleteTextures(GLsizei n, const GLuint *textures)
Party::uCurrentMonth
unsigned int uCurrentMonth
Definition: Party.h:272
terrain_block_scale
const int terrain_block_scale
Definition: RenderOpenGL.cpp:1119
Polygon::sTextureDeltaU
int sTextureDeltaU
Definition: Polygon.h:33
Image::GetHeight
unsigned int GetHeight()
Definition: Image.cpp:230
DecorationList::GetDecoration
DecorationDesc * GetDecoration(unsigned int index)
Definition: DecorationList.h:65
RenderOpenGL::DrawLightmap
virtual bool DrawLightmap(struct Lightmap *pLightmap, struct Vec3_float_ *pColorMult, float z_bias)
Definition: RenderOpenGL.cpp:662
RenderBillboard::screen_space_x
int16_t screen_space_x
Definition: IRender.h:39
SkyBillboardStruct::CamVecLeft_Y
int CamVecLeft_Y
Definition: IRender.h:473
Vec2::x
T x
Definition: VectorTypes.h:12
SpriteFrame::uGlowRadius
int uGlowRadius
Definition: Sprites.h:49
ODMRenderParams::uNumBillboards
unsigned int uNumBillboards
Definition: IRender.h:90
RenderOpenGL::~RenderOpenGL
virtual ~RenderOpenGL()
Definition: RenderOpenGL.cpp:133
DecorationList.h
Rect::x
int x
Definition: Rect.h:4
right
GLdouble GLdouble right
Definition: SDL_opengl_glext.h:6106
RenderOpenGL::SaveScreenshot
virtual void SaveScreenshot(const String &filename, unsigned int width, unsigned int height)
Definition: RenderOpenGL.cpp:648
dstX
GLenum GLint GLint GLint GLint GLuint GLenum GLint GLint dstX
Definition: SDL_opengl_glext.h:2453
pSpriteFrameTable
struct SpriteFrameTable * pSpriteFrameTable
Definition: Sprites.cpp:22
OutdoorLocation::pBModels
BSPModelList pBModels
Definition: Outdoor.h:119
pSprites_LOD
LODFile_Sprites * pSprites_LOD
Definition: LOD.cpp:20
BLVFace::pVertexIDs
uint16_t * pVertexIDs
Definition: Indoor.h:476
Viewport::uViewportTL_Y
int uViewportTL_Y
Definition: Viewport.h:23
RenderOpenGL::clip_y
int clip_y
Definition: RenderOpenGL.h:183
RenderBillboard::uIndoorSectorID
int16_t uIndoorSectorID
Definition: IRender.h:34
RenderOpenGL::clip_x
int clip_x
Definition: RenderOpenGL.h:183
Polygon
Definition: Polygon.h:14
DecorationDesc::uColoredLightRed
uint8_t uColoredLightRed
Definition: DecorationList.h:50
Sprites_LOD_Loader
Definition: ImageLoader.h:137
Vec3_float_::x
float x
Definition: VectorTypes.h:89
BSPModel::index
unsigned int index
Definition: BSPModel.h:167
glDepthMask
GLAPI void GLAPIENTRY glDepthMask(GLboolean flag)
RenderBase::Initialize
virtual bool Initialize(OSWindow *window)
Definition: RenderBase.cpp:22
uNumTerrainNormals
uint32_t uNumTerrainNormals
Definition: mm7_data.cpp:755
RenderOpenGL::DrawText
virtual void DrawText(int uOutX, int uOutY, uint8_t *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, uint8_t *pFontPalette, uint16_t uFaceColor, uint16_t uShadowColor)
Definition: RenderOpenGL.cpp:1928
RenderOpenGL::DrawTextureAlphaNew
virtual void DrawTextureAlphaNew(float u, float v, class Image *)
Definition: RenderOpenGL.cpp:1786
glDepthFunc
GLAPI void GLAPIENTRY glDepthFunc(GLenum func)
Party::sRotationX
int sRotationX
Definition: Party.h:252
glGetError
GLAPI GLenum GLAPIENTRY glGetError(void)
RenderBillboardD3D::Opaque_1
@ Opaque_1
Definition: IRender.h:151
IMAGE_FORMAT_R8G8B8A8
@ IMAGE_FORMAT_R8G8B8A8
Definition: Image.h:9
RenderOpenGL::DrawOutdoorSkyPolygon
void DrawOutdoorSkyPolygon(struct Polygon *pSkyPolygon)
Definition: RenderOpenGL.cpp:1572
RenderVertexD3D3::pos
Vec3_float_ pos
Definition: IRender.h:130
RenderOpenGL::ScreenFade
virtual void ScreenFade(unsigned int color, float t)
Definition: RenderOpenGL.cpp:396
Rect::w
int w
Definition: Rect.h:7
z
GLdouble GLdouble z
Definition: SDL_opengl_glext.h:407
pBLVRenderParams
BLVRenderParams * pBLVRenderParams
Definition: Indoor.cpp:50
RenderVertexSoft::u
float u
Definition: IRender.h:121
height
EGLSurface EGLint EGLint EGLint EGLint height
Definition: SDL_egl.h:1596
glClear
GLAPI void GLAPIENTRY glClear(GLbitfield mask)
ODMRenderParams::uNumPolygons
int uNumPolygons
Definition: IRender.h:86
RenderOpenGL::DrawProjectile
virtual void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, Texture *texture)
Definition: RenderOpenGL.cpp:391
OutdoorLocation::sky_texture
Texture * sky_texture
Definition: Outdoor.h:123
Party::sEyelevel
int sEyelevel
Definition: Party.h:239
Decal
Definition: DecalBuilder.h:98
RenderOpenGL::CreateTexture_Blank
virtual Texture * CreateTexture_Blank(unsigned int width, unsigned int height, IMAGE_FORMAT format, const void *pixels=nullptr)
Definition: RenderOpenGL.cpp:937
WorldPosToGridCellX
unsigned int WorldPosToGridCellX(int sWorldPosX)
Definition: Outdoor.cpp:3955
RenderOpenGL::TexturePixelRotateDraw
virtual void TexturePixelRotateDraw(float u, float v, Image *img, int time)
Definition: RenderOpenGL.cpp:488
engine
std::shared_ptr< Engine > engine
Definition: Engine.cpp:130
SpriteFrame::scale
fixed scale
Definition: Sprites.h:47
RenderOpenGL::DrawTextureCustomHeight
virtual void DrawTextureCustomHeight(float u, float v, class Image *, int height)
Definition: RenderOpenGL.cpp:1870
glVertex3f
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
RenderOpenGL::SetBillboardBlendOptions
void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1)
Definition: RenderOpenGL.cpp:1701
Rect::z
int z
Definition: Rect.h:6
Texture
Definition: Texture.h:4
game_viewport_width
unsigned int game_viewport_width
Definition: mm7_data.cpp:194
RenderBillboard::dimming_level
uint16_t dimming_level
Definition: IRender.h:43
SoftwareBillboard::screenspace_projection_factor_y
float screenspace_projection_factor_y
Definition: IRender.h:177
Alpha_LOD_Loader
Definition: ImageLoader.h:57
RenderBillboardD3D::OpacityType
OpacityType
Definition: IRender.h:149
RenderOpenGL::EndLightmaps
virtual void EndLightmaps()
Definition: RenderOpenGL.cpp:658
srcX
GLenum GLint GLint srcX
Definition: SDL_opengl_glext.h:2453
_set_ortho_modelview
void _set_ortho_modelview()
Definition: RenderOpenGL.cpp:1114
game_viewport_x
int game_viewport_x
Definition: mm7_data.cpp:196
BlendColors
unsigned int BlendColors(unsigned int a1, unsigned int a2)
Definition: RenderBase.cpp:265
RenderOpenGL::DrawBillboard_Indoor
virtual void DrawBillboard_Indoor(SoftwareBillboard *pSoftBillboard, RenderBillboard *)
Definition: RenderOpenGL.cpp:218
IndoorCameraD3D::sRotationX
int sRotationX
Definition: IndoorCameraD3D.h:248
RenderBillboardD3D::field_90
int field_90
Definition: IRender.h:163
IMAGE_FORMAT_BytesPerPixel
unsigned int IMAGE_FORMAT_BytesPerPixel(IMAGE_FORMAT format)
Definition: Image.cpp:46
pBillboardRenderList
RenderBillboard pBillboardRenderList[500]
Definition: RenderOpenGL.cpp:54
RenderOpenGL::BeginDecals
virtual void BeginDecals()
Definition: RenderOpenGL.cpp:667
RenderVertexD3D3
Definition: IRender.h:129
LightmapBuilder.h
RenderBillboard::screen_space_z
int16_t screen_space_z
Definition: IRender.h:41
Color32
uint32_t Color32(uint16_t color16)
Definition: Engine.cpp:135
RenderOpenGL::ZBuffer_Fill_2
virtual void ZBuffer_Fill_2(signed int a2, signed int a3, Image *pTexture, int a5)
Definition: RenderOpenGL.cpp:454
SkyBillboardStruct::field_4_party_dir_y
int field_4_party_dir_y
Definition: IRender.h:469
SoftwareBillboard::screenspace_projection_factor_x
float screenspace_projection_factor_x
Definition: IRender.h:176
glBindTexture
GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture)
RenderBillboard::world_z
int16_t world_z
Definition: IRender.h:38
RenderBillboardD3D::Transparent
@ Transparent
Definition: IRender.h:150
SkyBillboardStruct::CamVecLeft_Z
int CamVecLeft_Z
Definition: IRender.h:471
Sprite::uBufferHeight
int uBufferHeight
Definition: Sprites.h:32
RenderOpenGL::CreateTexture
virtual Texture * CreateTexture(const String &name)
Definition: RenderOpenGL.cpp:944
SpriteFrame::uPaletteIndex
int uPaletteIndex
Definition: Sprites.h:51
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:734
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1181
SpellFxRenderer.h
RenderOpenGL::RasterLine2D
virtual void RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor)
Definition: RenderOpenGL.cpp:182
Particle_sw::r
float r
Definition: ParticleEngine.h:23
OBJECT_Decoration
@ OBJECT_Decoration
Definition: Actor.h:69
ImageLoader.h
RenderBillboardD3D::z_order
float z_order
Definition: IRender.h:161
Lightmap
Definition: LightmapBuilder.h:12
WorldPosToGridCellZ
unsigned int WorldPosToGridCellZ(int sWorldPosZ)
Definition: Outdoor.cpp:3962
SoftwareBillboard::field_44
int field_44
Definition: IRender.h:187
Sprite::texture
Texture * texture
Definition: Sprites.h:28
RenderBillboard::pSpriteFrame
SpriteFrame * pSpriteFrame
Definition: IRender.h:45
glShadeModel
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
Vec3_float_::y
float y
Definition: VectorTypes.h:90
Vec3_float_::z
float z
Definition: VectorTypes.h:91
index
GLuint index
Definition: SDL_opengl_glext.h:663
RenderVertexSoft::vWorldViewProjY
float vWorldViewProjY
Definition: IRender.h:119
RenderOpenGL::CreateTexture_PCXFromFile
virtual Texture * CreateTexture_PCXFromFile(const String &name)
Definition: RenderOpenGL.cpp:933
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8586
game_viewport_height
unsigned int game_viewport_height
Definition: mm7_data.cpp:195
PCX_LOD_Loader
Definition: ImageLoader.h:108
glTexSubImage2D
GLAPI void GLAPIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
GLubyte
unsigned char GLubyte
Definition: SDL_opengl.h:183
glClearColor
GLAPI void GLAPIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
pIndoor
IndoorLocation * pIndoor
Definition: Indoor.cpp:49
RenderBase::Billboard_ProbablyAddToListAndSortByZOrder
unsigned int Billboard_ProbablyAddToListAndSortByZOrder(float z)
Definition: RenderBase.cpp:49
Engine.h
Lights.h
Image.h
Sprite
Definition: Sprites.h:10
glDisable
GLAPI void GLAPIENTRY glDisable(GLenum cap)
glTexParameteri
GLAPI void GLAPIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
Polygon::field_24
int field_24
Definition: Polygon.h:32
RenderVertexD3D3::texcoord
Vec2_float_ texcoord
Definition: IRender.h:134
RenderOpenGL::BeginSceneD3D
virtual void BeginSceneD3D()
Definition: RenderOpenGL.cpp:203
OutdoorLocation::DoGetTile
TileDesc * DoGetTile(int uX, int uZ)
Definition: Outdoor.cpp:1389
RenderBillboard::field_1E
int16_t field_1E
Definition: IRender.h:35
BLVRenderParams::uViewportZ
unsigned int uViewportZ
Definition: Indoor.h:698
fixed::FromInt
static fixed FromInt(int value)
Definition: OurMath.h:29
_set_3d_modelview_matrix
void _set_3d_modelview_matrix()
Definition: RenderOpenGL.cpp:1077
IndoorCameraD3D::int_cosine_x
int int_cosine_x
Definition: IndoorCameraD3D.h:263
Actor.h
RenderOpenGL::Present
virtual void Present()
Definition: RenderOpenGL.cpp:1995
game_viewport_y
int game_viewport_y
Definition: mm7_data.cpp:197
RenderOpenGL::PackScreenshot
virtual void PackScreenshot(unsigned int width, unsigned int height, void *out_data, unsigned int data_size, unsigned int *screenshot_size)
Definition: RenderOpenGL.cpp:1741
glFrontFace
GLAPI void GLAPIENTRY glFrontFace(GLenum mode)
IMAGE_FORMAT_A8R8G8B8
@ IMAGE_FORMAT_A8R8G8B8
Definition: Image.h:7
_4E94D0_light_type
char _4E94D0_light_type
Definition: mm7_data.cpp:305
OSWindow
Definition: OSWindow.h:12
Particle_sw::type
unsigned int type
Definition: ParticleEngine.h:19
_set_ortho_projection
void _set_ortho_projection(bool gameviewport=false)
Definition: RenderOpenGL.cpp:1098
Sprite::uAreaY
int uAreaY
Definition: Sprites.h:30
RenderVertexSoft::vWorldViewPosition
Vec3_float_ vWorldViewPosition
Definition: IRender.h:117
format
SDL_AudioFormat format
Definition: SDL_audio.h:194
Bitmaps_LOD_Loader
Definition: ImageLoader.h:122
y
EGLSurface EGLint EGLint y
Definition: SDL_egl.h:1596
RenderVertexD3D3::rhw
float rhw
Definition: IRender.h:131
glGenTextures
GLAPI void GLAPIENTRY glGenTextures(GLsizei n, GLuint *textures)
Image::GetWidth
unsigned int GetWidth()
Definition: Image.cpp:217
glFogfv
GLAPI void GLAPIENTRY glFogfv(GLenum pname, const GLfloat *params)
IMAGE_FORMAT_R8G8B8
@ IMAGE_FORMAT_R8G8B8
Definition: Image.h:8
array_73D150
RenderVertexSoft array_73D150[20]
Definition: Render.cpp:53
IndoorCameraD3D::vPartyPos
Vec3< int > vPartyPos
Definition: IndoorCameraD3D.h:253
IRender::log
Log * log
Definition: IRender.h:431
RenderOpenGL::GetActorsInViewport
virtual int GetActorsInViewport(int pDepth)
Definition: RenderOpenGL.cpp:653
Vec2::y
T y
Definition: VectorTypes.h:13
RenderOpenGL::clip_w
int clip_w
Definition: RenderOpenGL.h:184
Sprite::uBufferWidth
int uBufferWidth
Definition: Sprites.h:31
array_507D30
RenderVertexSoft array_507D30[50]
Definition: RenderOpenGL.cpp:58
srcY
GLenum GLint GLint GLint srcY
Definition: SDL_opengl_glext.h:2453
RenderBase
Definition: RenderBase.h:6
Polygon::dimming_level
char dimming_level
Definition: Polygon.h:48
pParty
Party * pParty
Definition: Party.cpp:30
Image
Definition: Image.h:19
Polygon::texture
Texture * texture
Definition: Polygon.h:39
glVertexPointer
GLAPI void GLAPIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
RenderVertexSoft::vWorldViewProjX
float vWorldViewProjX
Definition: IRender.h:118
RenderOpenGL::BeginLightmaps2
virtual void BeginLightmaps2()
Definition: RenderOpenGL.cpp:659
SoftwareBillboard
Definition: IRender.h:170
Polygon::uNumVertices
unsigned int uNumVertices
Definition: Polygon.h:30
RenderOpenGL::SwitchToWindow
virtual bool SwitchToWindow()
Definition: RenderOpenGL.cpp:2552
BLVRenderParams::uViewportW
unsigned int uViewportW
Definition: Indoor.h:699
LEVEL_DECORATION_INVISIBLE
@ LEVEL_DECORATION_INVISIBLE
Definition: Decoration.h:14
RenderBillboard::uPalette
int16_t uPalette
Definition: IRender.h:33
RenderBillboard
Definition: IRender.h:26
RenderOpenGL::GetActorTintColor
virtual unsigned int GetActorTintColor(int DimLevel, int tint, float WorldViewX, int a5, RenderBillboard *Billboard)
Definition: RenderOpenGL.cpp:144
glFogi
GLAPI void GLAPIENTRY glFogi(GLenum pname, GLint param)
p
GLfloat GLfloat p
Definition: SDL_opengl_glext.h:11093
RenderOpenGL::DrawTextAlpha
virtual void DrawTextAlpha(int x, int y, unsigned char *font_pixels, int a5, unsigned int uFontHeight, uint8_t *pPalette, bool present_time_transparency)
Definition: RenderOpenGL.cpp:1954
RenderBillboard::object_pid
uint16_t object_pid
Definition: IRender.h:42
RenderOpenGL::DrawLines
virtual void DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices)
Definition: RenderOpenGL.cpp:679
terrain_height_scale
const int terrain_height_scale
Definition: RenderOpenGL.cpp:1120
pTerrainNormals
struct Vec3_float_ * pTerrainNormals
Definition: mm7_data.cpp:756
RenderOpenGL::DrawPolygon
virtual void DrawPolygon(struct Polygon *a3)
Definition: RenderOpenGL.cpp:2208
fixpoint_dot
__int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2)
Definition: OurMath.cpp:142
OBJECT_BModel
@ OBJECT_BModel
Definition: Actor.h:70
x
EGLSurface EGLint x
Definition: SDL_egl.h:1596
RenderOpenGL::InitializeFullscreen
virtual bool InitializeFullscreen()
Definition: RenderOpenGL.cpp:139
glScissor
GLAPI void GLAPIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
color
GLuint color
Definition: SDL_opengl_glext.h:1151
SkyBillboardStruct::CalcSkyFrustumVec
void CalcSkyFrustumVec(int a2, int a3, int a4, int a5, int a6, int a7)
Definition: RenderOpenGL.cpp:62
IRender::lightmap_builder
LightmapBuilder * lightmap_builder
Definition: IRender.h:434
Particle_sw::timeToLive
int timeToLive
Definition: ParticleEngine.h:27
SpriteFrameTable::GetFrame
SpriteFrame * GetFrame(unsigned int uSpriteID, unsigned int uTime)
Definition: Sprites.cpp:277
glLoadIdentity
GLAPI void GLAPIENTRY glLoadIdentity(void)
IndoorCameraD3D::int_cosine_y
int int_cosine_y
Definition: IndoorCameraD3D.h:259
OS_GetTime
unsigned int OS_GetTime()
Definition: Lin.cpp:12
RenderOpenGL::DrawOutdoorSkyD3D
virtual void DrawOutdoorSkyD3D()
Definition: RenderOpenGL.cpp:1378
IRender::particle_engine
ParticleEngine * particle_engine
Definition: IRender.h:435
IRender::SetUsingFog
void SetUsingFog(bool is_using_fog)
Definition: IRender.h:409
Viewport::SetFOV
void SetFOV(float fov)
Definition: Viewport.cpp:62
RenderOpenGL::DrawMonsterPortrait
virtual void DrawMonsterPortrait(Rect rc, SpriteFrame *Portrait_Sprite, int Y_Offset)
Definition: RenderOpenGL.cpp:581
RenderOpenGL::DrawTextureOffset
virtual void DrawTextureOffset(int x, int y, int offset_x, int offset_y, Image *)
Definition: RenderOpenGL.cpp:399
Polygon::v_18
Vec3_int_ v_18
Definition: Polygon.h:31
SoftwareBillboard::screen_space_z
short screen_space_z
Definition: IRender.h:175
RenderBase::PostInitialization
void PostInitialization()
Definition: RenderBase.cpp:38
ODMRenderParams::uCameraFovInDegrees
unsigned int uCameraFovInDegrees
Definition: IRender.h:78
uNumSpritesDrawnThisFrame
int uNumSpritesDrawnThisFrame
Definition: RenderOpenGL.cpp:56
RenderOpenGL::ClearTarget
virtual void ClearTarget(unsigned int uColor)
Definition: RenderOpenGL.cpp:168
IMAGE_FORMAT_R5G6B5
@ IMAGE_FORMAT_R5G6B5
Definition: Image.h:5
BLVFace
Definition: Indoor.h:424
RenderOpenGL::ZDrawTextureAlpha
virtual void ZDrawTextureAlpha(float u, float v, Image *pTexture, int zVal)
Definition: RenderOpenGL.cpp:461
RenderOpenGL::DrawMasked
virtual void DrawMasked(float u, float v, class Image *img, unsigned int color_dimming_level, unsigned __int16 mask)
Definition: RenderOpenGL.cpp:606
RenderOpenGL::SaveWinnersCertificate
virtual void SaveWinnersCertificate(const char *a1)
Definition: RenderOpenGL.cpp:137
glViewport
GLAPI void GLAPIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
SkyBillboardStruct::field_8_party_dir_z
int field_8_party_dir_z
Definition: IRender.h:470
IndoorCameraD3D::ViewClip
bool ViewClip(int x, int y, int z, int *transformed_x, int *transformed_y, int *transformed_z, bool dont_show=false)
Definition: IndoorCameraD3D.cpp:172
RenderOpenGL::am_Blt_Chroma
virtual void am_Blt_Chroma(Rect *pSrcRect, Point *pTargetPoint, int a3, int blend_mode)
Definition: RenderOpenGL.cpp:688
Sprite::uAreaWidth
int uAreaWidth
Definition: Sprites.h:33
BLVFace::pVertexVIDs
int16_t * pVertexVIDs
Definition: Indoor.h:481
width
EGLSurface EGLint EGLint EGLint width
Definition: SDL_egl.h:1596
RenderOpenGL::DrawIndoorSkyPolygon
void DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon)
Definition: RenderOpenGL.cpp:641
RenderOpenGL::do_draw_debug_line_d3d
virtual void do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff)
Definition: RenderOpenGL.cpp:672
Log::Warning
void Warning(const wchar_t *pFormat,...)
Definition: Log.cpp:28
RenderOpenGL::DoRenderBillboards_D3D
void DoRenderBillboards_D3D()
Definition: RenderOpenGL.cpp:1625
PCX_File_Loader
Definition: ImageLoader.h:77
pIcons_LOD
LODFile_IconsBitmaps * pIcons_LOD
Definition: LOD.cpp:12
RenderVertexD3D3::diffuse
unsigned int diffuse
Definition: IRender.h:132
IRender::pBillboardRenderListD3D
RenderBillboardD3D pBillboardRenderListD3D[1000]
Definition: IRender.h:428
IndoorCameraD3D::Project
void Project(int x, int y, int z, int *screenspace_x, int *screenspace_y)
Definition: IndoorCameraD3D.cpp:1137
ogl_draw_buildings_vertices
RenderVertexSoft ogl_draw_buildings_vertices[20]
Definition: RenderOpenGL.cpp:2017
fixpoint_mul
__int64 fixpoint_mul(int a1, int a2)
Definition: OurMath.cpp:138
SkyBillboardStruct::CamVecFront_Z
int CamVecFront_Z
Definition: IRender.h:474
glScalef
GLAPI void GLAPIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z)
Party.h
Particle_sw
Definition: ParticleEngine.h:18
Viewport::uViewportBR_X
int uViewportBR_X
Definition: Viewport.h:24
uNumLevelDecorations
size_t uNumLevelDecorations
Definition: Decoration.cpp:9
window
EGLSurface EGLNativeWindowType * window
Definition: SDL_egl.h:1580
RenderOpenGL.h
BLVRenderParams::uViewportX
unsigned int uViewportX
Definition: Indoor.h:696
RenderOpenGL::AreRenderSurfacesOk
virtual bool AreRenderSurfacesOk()
Definition: RenderOpenGL.cpp:647
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
RenderOpenGL::DrawTransparentRedShade
virtual void DrawTransparentRedShade(float u, float v, class Image *a4)
Definition: RenderOpenGL.cpp:593
RenderOpenGL::BeginScene
virtual void BeginScene()
Definition: RenderOpenGL.cpp:1769
RenderOpenGL::DrawFansTransparent
virtual void DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices)
Definition: RenderOpenGL.cpp:601
glColor4f
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
RenderOpenGL::GetRenderHeight
virtual unsigned int GetRenderHeight() const
Definition: RenderOpenGL.cpp:161
glColor3ub
GLAPI void GLAPIENTRY glColor3ub(GLubyte red, GLubyte green, GLubyte blue)
RenderOpenGL::render_target_rgb
uint32_t * render_target_rgb
Definition: RenderOpenGL.h:185
RenderBillboardD3D::uNumVertices
unsigned int uNumVertices
Definition: IRender.h:159
IndoorCameraD3D::int_sine_x
int int_sine_x
Definition: IndoorCameraD3D.h:261
Particle_sw::y
float y
Definition: ParticleEngine.h:21
Viewport::uScreenCenterY
int uScreenCenterY
Definition: Viewport.h:29
Rect
Definition: Rect.h:3
Particle_sw::g
float g
Definition: ParticleEngine.h:24
TextureOpenGL
Definition: TextureOpenGL.h:4
ODMFace::IsBackfaceNotCulled
static bool IsBackfaceNotCulled(struct RenderVertexSoft *a2, struct Polygon *polygon)
Definition: Outdoor.cpp:522
RenderOpenGL::Update_Texture
virtual void Update_Texture(Texture *texture)
Definition: RenderOpenGL.cpp:954
SoftwareBillboard::screen_space_x
int screen_space_x
Definition: IRender.h:173
glBlendFunc
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
BLVRenderParams::pTargetZBuffer
int * pTargetZBuffer
Definition: Indoor.h:701
RenderBillboardD3D::opacity
OpacityType opacity
Definition: IRender.h:162
RenderOpenGL::CreateTexture_Solid
virtual Texture * CreateTexture_Solid(const String &name)
Definition: RenderOpenGL.cpp:917
depth
GLint GLint GLsizei GLsizei GLsizei depth
Definition: SDL_opengl.h:1572
IRender::pActiveZBuffer
int * pActiveZBuffer
Definition: IRender.h:421
LEVEL_DECORATION_OBELISK_CHEST
@ LEVEL_DECORATION_OBELISK_CHEST
Definition: Decoration.h:15
glHint
GLAPI void GLAPIENTRY glHint(GLenum target, GLenum mode)
OutdoorLocation::vSunlight
Vec3_int_ vSunlight
Definition: Outdoor.h:163
d3d_vertex_buffer
RenderVertexD3D3 d3d_vertex_buffer[50]
Definition: Render.cpp:55
ParticleEngine::AddParticle
void AddParticle(Particle_sw *a2)
Definition: ParticleEngine.cpp:65
SkyBillboardStruct::CamVecFront_Y
int CamVecFront_Y
Definition: IRender.h:476
pMiscTimer
Timer * pMiscTimer
Definition: Time.cpp:7
t
GLdouble GLdouble t
Definition: SDL_opengl.h:2071
game_viewport_w
int game_viewport_w
Definition: mm7_data.cpp:199
RenderBillboardD3D::texture
Texture * texture
Definition: IRender.h:158
SoftwareBillboard::uViewportY
unsigned int uViewportY
Definition: IRender.h:184
RenderBillboard::screenspace_projection_factor_y
float screenspace_projection_factor_y
Definition: IRender.h:28
Outdoor.h
RenderBillboardD3D::object_pid
unsigned short object_pid
Definition: IRender.h:165
IMAGE_FORMAT
IMAGE_FORMAT
Definition: Image.h:4
SoftwareBillboard::uViewportX
unsigned int uViewportX
Definition: IRender.h:183
SkyBillboard
SkyBillboardStruct SkyBillboard
Definition: Outdoor.cpp:51
TextureOpenGL::Create
static Texture * Create(unsigned int width, unsigned int height, IMAGE_FORMAT format, const void *pixels)
Definition: TextureOpenGL.cpp:6
RenderOpenGL::PrepareDecorationsRenderList_ODM
virtual void PrepareDecorationsRenderList_ODM()
Definition: RenderOpenGL.cpp:695
SkyBillboardStruct::CamVecLeft_X
int CamVecLeft_X
Definition: IRender.h:472
ColorKey_LOD_Loader
Definition: ImageLoader.h:25
memset32
void memset32(void *ptr, uint32_t value, int count)
Definition: MM7.h:14
RenderOpenGL::DeleteTexture
virtual void DeleteTexture(Texture *texture)
Definition: RenderOpenGL.cpp:968
RenderOpenGL::CreateTexture_PCXFromIconsLOD
virtual Texture * CreateTexture_PCXFromIconsLOD(const String &name)
Definition: RenderOpenGL.cpp:925
RenderBillboard::screen_space_y
int16_t screen_space_y
Definition: IRender.h:40
RenderOpenGL::ClearBlack
virtual void ClearBlack()
Definition: RenderOpenGL.cpp:163
SoftwareBillboard::screen_space_y
int screen_space_y
Definition: IRender.h:174
pViewport
struct Viewport * pViewport
Definition: mm7_data.cpp:21
RenderOpenGL::DrawDecal
virtual void DrawDecal(struct Decal *pDecal, float z_bias)
Definition: RenderOpenGL.cpp:669
RenderOpenGL::clip_z
int clip_z
Definition: RenderOpenGL.h:184
glBegin
GLAPI void GLAPIENTRY glBegin(GLenum mode)
_4D864C_force_sw_render_rules
char _4D864C_force_sw_render_rules
Definition: mm7_data.cpp:208
uint8_t
unsigned __int8 uint8_t
Definition: SDL_config.h:35
RenderOpenGL::DrawTextureNew
virtual void DrawTextureNew(float u, float v, class Image *)
Definition: RenderOpenGL.cpp:1791
GetLevelFogColor
unsigned int GetLevelFogColor()
Definition: Outdoor.cpp:3871
pODMRenderParams
ODMRenderParams * pODMRenderParams
Definition: Outdoor.cpp:49
IRender::uNumBillboardsToDraw
unsigned int uNumBillboardsToDraw
Definition: IRender.h:429
glColor3f
GLAPI void GLAPIENTRY glColor3f(GLfloat red, GLfloat green, GLfloat blue)
glLineWidth
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
RenderBillboardD3D::Opaque_3
@ Opaque_3
Definition: IRender.h:153
Polygon::uEdgeList2Size
unsigned int uEdgeList2Size
Definition: Polygon.h:59
IRender::spell_fx_renderer
SpellFxRenderer * spell_fx_renderer
Definition: IRender.h:433
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1112
stru193_math::Atan2
unsigned int Atan2(int x, int y)
Definition: OurMath.cpp:46
dstY
GLenum GLint GLint GLint GLint GLuint GLenum GLint GLint GLint dstY
Definition: SDL_opengl_glext.h:2453
RenderOpenGL::EndScene
virtual void EndScene()
Definition: RenderOpenGL.cpp:1780
VertexRenderList
RenderVertexSoft VertexRenderList[50]
Definition: Render.cpp:52
RenderOpenGL::CreateTexture_ColorKey
virtual Texture * CreateTexture_ColorKey(const String &name, uint16_t colorkey)
Definition: RenderOpenGL.cpp:913
glEnableClientState
GLAPI void GLAPIENTRY glEnableClientState(GLenum cap)
name
EGLImageKHR EGLint * name
Definition: SDL_egl.h:1497
Rect::y
int y
Definition: Rect.h:5
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
Sprite::uAreaX
int uAreaX
Definition: Sprites.h:29
RenderBillboard::world_y
int16_t world_y
Definition: IRender.h:37
Polygon::sTextureDeltaV
int sTextureDeltaV
Definition: Polygon.h:34
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4586
SoftwareBillboard::uViewportW
unsigned int uViewportW
Definition: IRender.h:186
ParticleType_8
@ ParticleType_8
Definition: ParticleEngine.h:9
Particle_sw::texture
Texture * texture
Definition: ParticleEngine.h:28
Viewport::uScreenCenterX
int uScreenCenterX
Definition: Viewport.h:28
DecorationDesc_mm6::uSpriteID
uint16_t uSpriteID
Definition: DecorationList.h:43
IsBModelVisible
bool IsBModelVisible(BSPModel *model, int *reachable)
Definition: Render.cpp:5516
SpriteFrame
Definition: Sprites.h:39
RenderVertexSoft::v
float v
Definition: IRender.h:122
IRender::hd_water_current_frame
int hd_water_current_frame
Definition: IRender.h:424
Polygon::pODMFace
ODMFace * pODMFace
Definition: Polygon.h:47
uNumDecorationsDrawnThisFrame
int uNumDecorationsDrawnThisFrame
Definition: RenderOpenGL.cpp:53
RenderVertexSoft::_rhw
float _rhw
Definition: IRender.h:120
uint
unsigned int uint
Definition: MM7.h:4
RenderBillboardD3D::NoBlend
@ NoBlend
Definition: IRender.h:154
glMatrixMode
GLAPI void GLAPIENTRY glMatrixMode(GLenum mode)
array_77EC08
std::array< struct Polygon, 2000+18000 > array_77EC08
Definition: Outdoor.cpp:52
RenderOpenGL::GetRenderWidth
virtual unsigned int GetRenderWidth() const
Definition: RenderOpenGL.cpp:160
SoftwareBillboard::uViewportZ
unsigned int uViewportZ
Definition: IRender.h:185
pStationaryLightsStack
LightsStack_StationaryLight_ * pStationaryLightsStack
Definition: LightmapBuilder.cpp:11
SoftwareBillboard::uFlags
unsigned int uFlags
Definition: IRender.h:181
SoftwareBillboard::sParentBillboardID
int sParentBillboardID
Definition: IRender.h:188
__debugbreak
void __cdecl __debugbreak(void)
DecorationDesc_mm6::uDecorationHeight
uint16_t uDecorationHeight
Definition: DecorationList.h:40
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4586
OutdoorLocation::pTerrain
struct OutdoorLocationTerrain pTerrain
Definition: Outdoor.h:117
_set_3d_projection_matrix
void _set_3d_projection_matrix()
Definition: RenderOpenGL.cpp:1059
RenderOpenGL::CreateTexture_Alpha
virtual Texture * CreateTexture_Alpha(const String &name)
Definition: RenderOpenGL.cpp:921
IMAGE_FORMAT_A1R5G5B5
@ IMAGE_FORMAT_A1R5G5B5
Definition: Image.h:6
GLenum
unsigned int GLenum
Definition: SDL_opengl.h:176
SkyBillboardStruct::CamVecFront_X
int CamVecFront_X
Definition: IRender.h:475
BSPModel::pFaces
std::vector< ODMFace > pFaces
Definition: BSPModel.h:190
RenderOpenGL::RenderTerrainD3D
virtual void RenderTerrainD3D()
Definition: RenderOpenGL.cpp:1121
RenderVertexSoft::vWorldPosition
Vec3_float_ vWorldPosition
Definition: IRender.h:116
_6BE3A0_fov
float _6BE3A0_fov
Definition: mm7_data.cpp:715
ODMFace
Definition: BSPModel.h:93
RenderOpenGL::DrawBillboardList_BLV
virtual void DrawBillboardList_BLV()
Definition: RenderOpenGL.cpp:358
RenderOpenGL::WritePixel16
virtual void WritePixel16(int x, int y, uint16_t color)
Definition: RenderOpenGL.cpp:2613
pBitmaps_LOD
LODFile_IconsBitmaps * pBitmaps_LOD
Definition: LOD.cpp:16
Image::GetPixels
const void * GetPixels(IMAGE_FORMAT format)
Definition: Image.cpp:270
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4586
TextureOpenGL.h
Particle_sw::particle_size
float particle_size
Definition: ParticleEngine.h:30
stru193_math::Cos
int Cos(int angle)
Definition: OurMath.cpp:28
ParticleType_Rotating
@ ParticleType_Rotating
Definition: ParticleEngine.h:8
RenderOpenGL::DrawImage
virtual void DrawImage(Image *, const Rect &rect)
Definition: RenderOpenGL.cpp:405
Decoration.h
stru_5C6E00
struct stru193_math * stru_5C6E00
Definition: mm7_data.cpp:19
RenderOpenGL::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene
virtual void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene()
Definition: RenderOpenGL.cpp:1618
RenderOpenGL::_4A4CC9_AddSomeBillboard
virtual void _4A4CC9_AddSomeBillboard(struct SpellFX_Billboard *a1, int diffuse)
Definition: RenderOpenGL.cpp:353
RenderOpenGL::Initialize
virtual bool Initialize(OSWindow *window)
Definition: RenderOpenGL.cpp:2561
IRender::hd_water_tile_anim
Texture * hd_water_tile_anim[7]
Definition: IRender.h:426
BLVFace::GetTexture
Texture * GetTexture()
Definition: Indoor.cpp:738
RenderOpenGL::DrawSpecialEffectsQuad
virtual void DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, Texture *texture)
Definition: RenderOpenGL.cpp:683
BSPVertexBuffer::pVertices
Vec3_int_ * pVertices
Definition: BSPModel.h:53
IndoorLocation::pVertices
struct Vec3_short_ * pVertices
Definition: Indoor.h:628
RenderOpenGL::MoveTextureToDevice
virtual bool MoveTextureToDevice(Texture *texture)
Definition: RenderOpenGL.cpp:980
DecorationDesc
Definition: DecorationList.h:49
Particle_sw::x
float x
Definition: ParticleEngine.h:20
sub_47C3D7_get_fog_specular
int sub_47C3D7_get_fog_specular(int a1, int a2, float a3)
Definition: Outdoor.cpp:3898
RenderOpenGL::TakeScreenshot
virtual Image * TakeScreenshot(unsigned int width, unsigned int height)
Definition: RenderOpenGL.cpp:646
OurMath.h
RenderOpenGL::EndLightmaps2
virtual void EndLightmaps2()
Definition: RenderOpenGL.cpp:660
glCullFace
GLAPI void GLAPIENTRY glCullFace(GLenum mode)
RenderOpenGL::BltBackToFontFast
virtual void BltBackToFontFast(int a2, int a3, Rect *pSrcRect)
Definition: RenderOpenGL.cpp:154
pTerrainNormalIndices
std::array< unsigned short, 128 *128 *2 > pTerrainNormalIndices
Definition: mm7_data.cpp:757
ODMRenderParams::int_fov_rad
int int_fov_rad
Definition: IRender.h:79
RenderOpenGL::BeginLightmaps
virtual void BeginLightmaps()
Definition: RenderOpenGL.cpp:657
BSPModel::field_40
int32_t field_40
Definition: BSPModel.h:170
IndoorCameraD3D::GetFarClip
float GetFarClip() const
Definition: IndoorCameraD3D.cpp:159
Polygon::ptr_38
struct SkyBillboardStruct * ptr_38
Definition: Polygon.h:38
RenderBillboard::screenspace_projection_factor_x
float screenspace_projection_factor_x
Definition: IRender.h:27
RenderOpenGL::RenderOpenGL
RenderOpenGL()
Definition: RenderOpenGL.cpp:129
stru193_math::Sin
int Sin(int angle)
Definition: OurMath.cpp:133
LightsStack_StationaryLight_::AddLight
bool AddLight(int16_t x, int16_t y, int16_t z, int16_t a5, unsigned char r, unsigned char g, unsigned char b, char uLightType)
Definition: LightsStack.cpp:30
GLuint
unsigned int GLuint
Definition: SDL_opengl.h:185
BSPModel
Definition: BSPModel.h:163
RenderOpenGL::RestoreFrontBuffer
virtual void RestoreFrontBuffer()
Definition: RenderOpenGL.cpp:151
RenderOpenGL::EndDecals
virtual void EndDecals()
Definition: RenderOpenGL.cpp:668
Point
Definition: Point.h:3
RenderVertexSoft
Definition: IRender.h:113
ParticleType_Bitmap
@ ParticleType_Bitmap
Definition: ParticleEngine.h:12
IndoorCameraD3D::GetNearClip
float GetNearClip() const
Definition: IndoorCameraD3D.cpp:146
RenderOpenGL::FillRectFast
virtual void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16)
Definition: RenderOpenGL.cpp:2618
RenderOpenGL::CreateSprite
virtual Texture * CreateSprite(const String &name, unsigned int palette_id, unsigned int lod_sprite_id)
Definition: RenderOpenGL.cpp:948
RenderBillboardD3D::sParentBillboardID
int sParentBillboardID
Definition: IRender.h:167
uNumBillboardsToDraw
unsigned int uNumBillboardsToDraw
Definition: RenderOpenGL.cpp:55
DecorationDesc::uColoredLightBlue
uint8_t uColoredLightBlue
Definition: DecorationList.h:52
Polygon::uEdgeList1Size
unsigned int uEdgeList1Size
Definition: Polygon.h:57
indices
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: SDL_opengl.h:1571
LightmapBuilder::StationaryLightsCount
unsigned int StationaryLightsCount
Definition: LightmapBuilder.h:83
pOutdoor
OutdoorLocation * pOutdoor
Definition: Outdoor.cpp:48
glDrawElements
GLAPI void GLAPIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
SkyBillboardStruct::CamLeftDot
int CamLeftDot
Definition: IRender.h:477
RenderOpenGL::DrawTextureGrayShade
virtual void DrawTextureGrayShade(float u, float v, class Image *a4)
Definition: RenderOpenGL.cpp:634
RenderOpenGL::DrawTransparentGreenShade
virtual void DrawTransparentGreenShade(float u, float v, class Image *pTexture)
Definition: RenderOpenGL.cpp:597
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52
SkyBillboardStruct::CamFrontDot
int CamFrontDot
Definition: IRender.h:478
SpellFxRenderer::RenderSpecialEffects
void RenderSpecialEffects()
Definition: SpellFxRenderer.cpp:1239
RenderBillboardD3D::screen_space_z
short screen_space_z
Definition: IRender.h:166
RenderVertexD3D3::specular
unsigned int specular
Definition: IRender.h:133
Image16bit_LOD_Loader
Definition: ImageLoader.h:42
RenderOpenGL::SavePCXScreenshot
virtual void SavePCXScreenshot()
Definition: RenderOpenGL.cpp:652
RenderOpenGL::ResetUIClipRect
virtual void ResetUIClipRect()
Definition: RenderOpenGL.cpp:1758
RenderBillboardD3D::pQuads
RenderVertexD3D3 pQuads[4]
Definition: IRender.h:160
glTexCoord2f
GLAPI void GLAPIENTRY glTexCoord2f(GLfloat s, GLfloat t)
SoftwareBillboard::pTargetZ
int * pTargetZ
Definition: IRender.h:172
pIndoorCameraD3D
IndoorCameraD3D * pIndoorCameraD3D
Definition: IndoorCameraD3D.cpp:21
RenderOpenGL::CreateZBuffer
virtual void CreateZBuffer()
Definition: RenderOpenGL.cpp:177
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1112
Viewport::uViewportTL_X
int uViewportTL_X
Definition: Viewport.h:22
game_viewport_z
int game_viewport_z
Definition: mm7_data.cpp:198
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
uint32_t
unsigned __int32 uint32_t
Definition: SDL_config.h:39
BLVRenderParams::uViewportY
unsigned int uViewportY
Definition: Indoor.h:697
left
GLint left
Definition: SDL_opengl_glext.h:1952
Party::sRotationY
int sRotationY
Definition: Party.h:251
IndoorCameraD3D::int_sine_y
int int_sine_y
Definition: IndoorCameraD3D.h:257
Timer::uTotalGameTimeElapsed
unsigned int uTotalGameTimeElapsed
Definition: Time.h:135
stru193_math::uIntegerPi
static const unsigned int uIntegerPi
Definition: OurMath.h:88
glClearDepth
GLAPI void GLAPIENTRY glClearDepth(GLclampd depth)
String
std::string String
Definition: Strings.h:10
SoftwareBillboard::sTintColor
int sTintColor
Definition: IRender.h:189
BLVFace::uAttributes
unsigned int uAttributes
Definition: Indoor.h:475
Sprites.h
BLVFace::pVertexUIDs
int16_t * pVertexUIDs
Definition: Indoor.h:480
RenderBillboard::world_x
int16_t world_x
Definition: IRender.h:36
RenderOpenGL::ClearZBuffer
virtual void ClearZBuffer(int a2, int a3)
Definition: RenderOpenGL.cpp:172
config
EGLConfig config
Definition: SDL_egl.h:1149
Sprite::uAreaHeight
int uAreaHeight
Definition: Sprites.h:34
GLint
int GLint
Definition: SDL_opengl.h:182
DecorationDesc::uColoredLightGreen
uint8_t uColoredLightGreen
Definition: DecorationList.h:51
SpriteFrame::uFlags
int uFlags
Definition: Sprites.h:48
GLfloat
float GLfloat
Definition: SDL_opengl.h:187
RenderOpenGL::CreateTexture_PCXFromNewLOD
virtual Texture * CreateTexture_PCXFromNewLOD(const String &name)
Definition: RenderOpenGL.cpp:929
Vec3::z
T z
Definition: VectorTypes.h:27
RenderBillboard::sTintColor
unsigned int sTintColor
Definition: IRender.h:44
RenderOpenGL::PresentBlackScreen
virtual void PresentBlackScreen()
Definition: RenderOpenGL.cpp:1762
glTexImage2D
GLAPI void GLAPIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
glOrtho
GLAPI void GLAPIENTRY glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val)
img
GLint GLvoid * img
Definition: SDL_opengl.h:1980
RenderOpenGL::DrawBuildingsD3D
virtual void DrawBuildingsD3D()
Definition: RenderOpenGL.cpp:2018
glEnable
GLAPI void GLAPIENTRY glEnable(GLenum cap)
Api.h
SoftwareBillboard::object_pid
unsigned short object_pid
Definition: IRender.h:190
RenderOpenGL::RestoreBackBuffer
virtual void RestoreBackBuffer()
Definition: RenderOpenGL.cpp:152
pDecorationList
struct DecorationList * pDecorationList
Definition: DecorationList.cpp:11
glTexCoordPointer
GLAPI void GLAPIENTRY glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
RenderOpenGL::RemoveTextureFromDevice
virtual void RemoveTextureFromDevice(Texture *texture)
Definition: RenderOpenGL.cpp:978
RenderOpenGL::SetUIClipRect
virtual void SetUIClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
Definition: RenderOpenGL.cpp:1749
RenderOpenGL::BlendTextures
virtual void BlendTextures(int a2, int a3, Image *a4, Image *a5, int t, int start_opacity, int end_opacity)
Definition: RenderOpenGL.cpp:482
SpellFxRenderer::effpar01
Texture * effpar01
Definition: SpellFxRenderer.h:166
Particle_sw::uDiffuse
unsigned int uDiffuse
Definition: ParticleEngine.h:26