| 1 |
/* Emacs style mode select -*- C -*- |
| 2 |
*----------------------------------------------------------------------------- |
| 3 |
* |
| 4 |
* |
| 5 |
* PrBoom: a Doom port merged with LxDoom and LSDLDoom |
| 6 |
* based on BOOM, a modified and improved DOOM engine |
| 7 |
* Copyright (C) 1999 by |
| 8 |
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman |
| 9 |
* Copyright (C) 1999-2000 by |
| 10 |
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze |
| 11 |
* Copyright 2005, 2006 by |
| 12 |
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko |
| 13 |
* |
| 14 |
* This program is free software; you can redistribute it and/or |
| 15 |
* modify it under the terms of the GNU General Public License |
| 16 |
* as published by the Free Software Foundation; either version 2 |
| 17 |
* of the License, or (at your option) any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 27 |
* 02111-1307, USA. |
| 28 |
* |
| 29 |
* DESCRIPTION: |
| 30 |
* |
| 31 |
*--------------------------------------------------------------------- |
| 32 |
*/ |
| 33 |
|
| 34 |
#ifdef HAVE_CONFIG_H |
| 35 |
#include "config.h" |
| 36 |
#endif |
| 37 |
|
| 38 |
#include "gl_opengl.h" |
| 39 |
|
| 40 |
#include "v_video.h" |
| 41 |
#include "i_video.h" |
| 42 |
#include "gl_intern.h" |
| 43 |
#include "m_random.h" |
| 44 |
#include "lprintf.h" |
| 45 |
#include "e6y.h" |
| 46 |
|
| 47 |
#include "dsda/gl/render_scale.h" |
| 48 |
|
| 49 |
static GLuint wipe_scr_start_tex = 0; |
| 50 |
static GLuint wipe_scr_end_tex = 0; |
| 51 |
|
| 52 |
GLuint CaptureScreenAsTexID(void) |
| 53 |
{ |
| 54 |
GLuint id; |
| 55 |
|
| 56 |
gld_EnableTexture2D(GL_TEXTURE0_ARB, true); |
| 57 |
|
| 58 |
glGenTextures(1, &id); |
| 59 |
glBindTexture(GL_TEXTURE_2D, id); |
| 60 |
|
| 61 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
| 62 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); |
| 63 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 64 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 65 |
|
| 66 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, |
| 67 |
gld_GetTexDimension(viewport_rect.w), gld_GetTexDimension(viewport_rect.h), |
| 68 |
0, GL_RGB, GL_UNSIGNED_BYTE, 0); |
| 69 |
|
| 70 |
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport_rect.x, viewport_rect.y, viewport_rect.w, viewport_rect.h); |
| 71 |
|
| 72 |
return id; |
| 73 |
} |
| 74 |
|
| 75 |
int gld_wipe_doMelt(int ticks, int *y_lookup) |
| 76 |
{ |
| 77 |
int i, scaled_i, scaled_i2; |
| 78 |
int total_w, total_h; |
| 79 |
float fU1, fU2, fV1, fV2; |
| 80 |
int yoffs; |
| 81 |
float tx, tx2; |
| 82 |
int dx = MAX(1, (SCREENWIDTH > SCREENHEIGHT) ? SCREENHEIGHT / 200 : SCREENWIDTH / 200); |
| 83 |
|
| 84 |
total_w = gld_GetTexDimension(viewport_rect.w); |
| 85 |
total_h = gld_GetTexDimension(viewport_rect.h); |
| 86 |
|
| 87 |
fU1 = 0.0f; |
| 88 |
fV1 = (float)viewport_rect.h / (float)total_h; |
| 89 |
fU2 = (float)viewport_rect.w / (float)total_w; |
| 90 |
fV2 = 0.0f; |
| 91 |
|
| 92 |
|
| 93 |
glBindTexture(GL_TEXTURE_2D, wipe_scr_end_tex); |
| 94 |
glColor3f(1.0f, 1.0f, 1.0f); |
| 95 |
|
| 96 |
glBegin(GL_TRIANGLE_STRIP); |
| 97 |
{ |
| 98 |
glTexCoord2f(fU1, fV1); glVertex2f(0.0f, 0.0f); |
| 99 |
glTexCoord2f(fU1, fV2); glVertex2f(0.0f, (float)SCREENHEIGHT); |
| 100 |
glTexCoord2f(fU2, fV1); glVertex2f((float)SCREENWIDTH, 0.0f); |
| 101 |
glTexCoord2f(fU2, fV2); glVertex2f((float)SCREENWIDTH, (float)SCREENHEIGHT); |
| 102 |
} |
| 103 |
glEnd(); |
| 104 |
|
| 105 |
glBindTexture(GL_TEXTURE_2D, wipe_scr_start_tex); |
| 106 |
glColor3f(1.0f, 1.0f, 1.0f); |
| 107 |
|
| 108 |
glBegin(GL_TRIANGLE_STRIP); |
| 109 |
for (i = 0; i < SCREENWIDTH; i += dx) |
| 110 |
{ |
| 111 |
int i2 = (i + dx > SCREENWIDTH ? SCREENWIDTH : i + dx); |
| 112 |
yoffs = MAX(0, y_lookup[i]); |
| 113 |
|
| 114 |
// elim - melt texture is the pixel size of the GL viewport, not the game scene texture size |
| 115 |
scaled_i = MIN(viewport_rect.w, (int)((float)i * gl_scale_x)); |
| 116 |
scaled_i2 = MIN(viewport_rect.w, (int)((float)i2 * gl_scale_x)); |
| 117 |
|
| 118 |
// elim - texel coordinates don't necessarily match texture buffer dimensions, since textures |
| 119 |
// have to be stored in dimensions that are power-of-2 |
| 120 |
tx = (float) MIN(fU2, (float)scaled_i / (float)total_w); |
| 121 |
tx2 = (float) MIN(fU2, (float)scaled_i2 / (float)total_w); |
| 122 |
|
| 123 |
glTexCoord2f(tx, fV1); glVertex2f(i, yoffs); |
| 124 |
glTexCoord2f(tx, fV2); glVertex2f(i, yoffs + SCREENHEIGHT); |
| 125 |
glTexCoord2f(tx2, fV1); glVertex2f(i2, yoffs); |
| 126 |
glTexCoord2f(tx2, fV2); glVertex2f(i2, yoffs + SCREENHEIGHT); |
| 127 |
} |
| 128 |
glEnd(); |
| 129 |
|
| 130 |
return 0; |
| 131 |
} |
| 132 |
|
| 133 |
int gld_wipe_exitMelt(int ticks) |
| 134 |
{ |
| 135 |
if (wipe_scr_start_tex != 0) |
| 136 |
{ |
| 137 |
glDeleteTextures(1, &wipe_scr_start_tex); |
| 138 |
wipe_scr_start_tex = 0; |
| 139 |
} |
| 140 |
if (wipe_scr_end_tex != 0) |
| 141 |
{ |
| 142 |
glDeleteTextures(1, &wipe_scr_end_tex); |
| 143 |
wipe_scr_end_tex = 0; |
| 144 |
} |
| 145 |
|
| 146 |
gld_ResetLastTexture(); |
| 147 |
|
| 148 |
return 0; |
| 149 |
} |
| 150 |
|
| 151 |
int gld_wipe_StartScreen(void) |
| 152 |
{ |
| 153 |
wipe_scr_start_tex = CaptureScreenAsTexID(); |
| 154 |
|
| 155 |
return 0; |
| 156 |
} |
| 157 |
|
| 158 |
int gld_wipe_EndScreen(void) |
| 159 |
{ |
| 160 |
glFlush(); |
| 161 |
wipe_scr_end_tex = CaptureScreenAsTexID(); |
| 162 |
|
| 163 |
return 0; |
| 164 |
} |