Skip to content

Commit 9f3dcd5

Browse files
committed
wip
1 parent 467c700 commit 9f3dcd5

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed

drivers/glrend/devpixmp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,10 @@ br_error BR_CMETHOD(br_device_pixelmap_gl, rectangleStretchCopyTo)(br_device_pix
510510
fmt = DeviceGLGetFormatDetails(src->type);
511511
}
512512

513-
clut = self->screen->asFront.tex_white;
513+
clut = self->asBack.clut->gl_tex ? self->asBack.clut->gl_tex : self->screen->asFront.tex_white;
514514
if(fmt->indexed && src->map != NULL) {
515515
if(src->map->stored != NULL) {
516-
clut = BufferStoredGLGetCLUTTexture(stored, self->screen->asFront.tex_white);
516+
clut = BufferStoredGLGetCLUTTexture(stored, self, clut);
517517
} else {
518518
clut = DeviceGLPixelmapToGLTexture(src->map);
519519
clut_tmp = BR_TRUE;

drivers/glrend/drv_ip.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct br_buffer_stored *BufferStoredGLAllocate(br_renderer *renderer, br_token
7979
br_token_value *tv);
8080

8181
GLenum BufferStoredGLGetTexture(br_buffer_stored *self);
82-
GLuint BufferStoredGLGetCLUTTexture(br_buffer_stored *self, GLuint fallback);
82+
GLuint BufferStoredGLGetCLUTTexture(br_buffer_stored *self, br_device_pixelmap *target, GLuint fallback);
8383

8484
/*
8585
* gv1buckt.c

drivers/glrend/sbuffer.c

+40-4
Original file line numberDiff line numberDiff line change
@@ -214,21 +214,57 @@ GLuint BufferStoredGLGetTexture(br_buffer_stored *self)
214214
return self->gl_tex;
215215
}
216216

217-
GLuint BufferStoredGLGetCLUTTexture(br_buffer_stored *self, GLuint fallback)
217+
GLuint BufferStoredGLGetCLUTTexture(br_buffer_stored *self, br_device_pixelmap *target, GLuint fallback)
218218
{
219+
GLuint clut;
220+
219221
if(self == NULL)
220222
return fallback;
221223

224+
/*
225+
* If we have a CLUT, use it.
226+
*/
222227
if(self->source == NULL)
223-
return fallback;
228+
goto use_target;
224229

225230
if(self->source->map == NULL)
226-
return fallback;
231+
goto use_target;
227232

228233
if(self->source->map->stored == NULL)
234+
goto use_target;
235+
236+
if((clut = BufferStoredGLGetTexture(self->source->map->stored)) != 0)
237+
return clut;
238+
239+
use_target:
240+
/*
241+
* If there's no target pixelmap, see if our renderer's current state has one.
242+
*/
243+
if(target == NULL) {
244+
const state_output *output;
245+
246+
if(!(self->renderer->state.current->valid & BR_STATE_OUTPUT))
247+
return fallback;
248+
249+
target = self->renderer->state.current->output.colour;
250+
}
251+
252+
/*
253+
* Try to use the target's CLUT.
254+
*/
255+
if(target == NULL)
256+
return fallback;
257+
258+
if(target->use_type != BRT_OFFSCREEN)
259+
return fallback;
260+
261+
if(target->asBack.clut == NULL)
262+
return fallback;
263+
264+
if(target->asBack.clut->gl_tex == 0)
229265
return fallback;
230266

231-
return BufferStoredGLGetTexture(self->source->map->stored);
267+
return target->asBack.clut->gl_tex;
232268
}
233269

234270
/*

drivers/glrend/v1model.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static void apply_stored_properties(HVIDEO hVideo, state_stack *state, uint32_t
200200

201201
if(model->is_indexed) {
202202
glActiveTexture(GL_TEXTURE0);
203-
glBindTexture(GL_TEXTURE_2D, BufferStoredGLGetCLUTTexture(stored, tex_default));
203+
glBindTexture(GL_TEXTURE_2D, BufferStoredGLGetCLUTTexture(stored, NULL, tex_default));
204204
glUniform1i(hVideo->brenderProgram.uniforms.main_texture, hVideo->brenderProgram.mainTextureBinding);
205205

206206
glActiveTexture(GL_TEXTURE1);

examples/devpmtest/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ int main(int argc, char **argv)
11751175
BRT_HIDPI_B, BR_TRUE,
11761176
/* Set these if you dare... */
11771177
BRT_RESIZABLE_B, BR_TRUE,
1178-
BRT_OPENGL_B, BR_FALSE,
1178+
BRT_OPENGL_B, BR_TRUE,
11791179
BR_NULL_TOKEN);
11801180
// clang-format on
11811181

0 commit comments

Comments
 (0)