MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / refresh

Method refresh

src/Engine/OpenGL.cpp:139–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137 }
138
139 void OpenGL::refresh(bool smooth, unsigned inwidth, unsigned inheight, unsigned outwidth, unsigned outheight, int topBlackBand, int bottomBlackBand, int leftBlackBand, int rightBlackBand) {
140 while (glGetError() != GL_NO_ERROR); // clear possible error from who knows where
141 clear();
142 if(shader_support && (fragmentshader || vertexshader)) {
143 glUseProgram(glprogram);
144 GLint location;
145
146 float inputSize[2] = { (float)inwidth, (float)inheight };
147 location = glGetUniformLocation(glprogram, "rubyInputSize");
148 glUniform2fv(location, 1, inputSize);
149
150 float outputSize[2] = { (float)outwidth, (float)outheight };
151 location = glGetUniformLocation(glprogram, "rubyOutputSize");
152 glUniform2fv(location, 1, outputSize);
153
154 float textureSize[2] = { (float)iwidth, (float)iheight };
155 location = glGetUniformLocation(glprogram, "rubyTextureSize");
156 glUniform2fv(location, 1, textureSize);
157 }
158
159 glErrorCheck();
160
161 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
162 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
163 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, smooth ? GL_LINEAR : GL_NEAREST);
164 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, smooth ? GL_LINEAR : GL_NEAREST);
165
166 glErrorCheck();
167
168 glMatrixMode(GL_PROJECTION);
169 glLoadIdentity();
170 glOrtho(0, outwidth, 0, outheight, -1.0, 1.0);
171 glViewport(0, 0, outwidth, outheight);
172
173 glMatrixMode(GL_MODELVIEW);
174 glLoadIdentity();
175
176 glErrorCheck();
177
178 glPixelStorei(GL_UNPACK_ROW_LENGTH, buffer_surface->getSurface()->pitch / buffer_surface->getSurface()->format->BytesPerPixel);
179
180 glErrorCheck();
181
182 glTexSubImage2D(GL_TEXTURE_2D,
183 /* mip-map level = */ 0, /* x = */ 0, /* y = */ 0,
184 iwidth, iheight, GL_BGRA, iformat, buffer);
185
186
187 //OpenGL projection sets 0,0 as *bottom-left* of screen.
188 //therefore, below vertices flip image to support top-left source.
189 //texture range = x1:0.0, y1:0.0, x2:1.0, y2:1.0
190 //vertex range = x1:0, y1:0, x2:width, y2:height
191 double w = double(inwidth) / double(iwidth);
192 double h = double(inheight) / double(iheight);
193 int u1 = leftBlackBand;
194 int u2 = outwidth - rightBlackBand;
195 int v1 = outheight - topBlackBand;
196 int v2 = bottomBlackBand;

Callers 1

flipWithZoomMethod · 0.80

Calls 1

getSurfaceMethod · 0.45

Tested by

no test coverage detected