Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(int i = 0; i < game->available_maps_count; i++)
- {
- char* map_path = format_text("assets/%s", game->available_maps[i]);
- s_map map = load_map(&game->client_rng, map_path, &arenas->frame_arena);
- rendering->map_thumbnail_fbo[i].width = (int)c_base_window_size.x;
- rendering->map_thumbnail_fbo[i].height = (int)c_base_window_size.y;
- // This doesn't call gl funcs
- draw_map(&map, rendering, 0, false);
- gl(glGenFramebuffers(1, &rendering->map_thumbnail_fbo[i].fbo));
- gl(glBindFramebuffer(GL_FRAMEBUFFER, rendering->map_thumbnail_fbo[i].fbo));
- gl(glGenTextures(1, &rendering->map_thumbnail_fbo[i].color[0]));
- gl(glBindTexture(GL_TEXTURE_2D, rendering->map_thumbnail_fbo[i].color[0]));
- gl(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rendering->map_thumbnail_fbo[i].width, rendering->map_thumbnail_fbo[i].height, 0, GL_RGBA, GL_FLOAT, NULL));
- gl(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
- gl(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
- // gl(glBindTexture(GL_TEXTURE_2D, 0));
- gl(glGenTextures(1, &rendering->map_thumbnail_fbo[i].depth));
- gl(glBindTexture(GL_TEXTURE_2D, rendering->map_thumbnail_fbo[i].depth));
- gl(glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, rendering->map_thumbnail_fbo[i].width, rendering->map_thumbnail_fbo[i].height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL));
- // gl(glBindTexture(GL_TEXTURE_2D, 0));
- gl(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rendering->map_thumbnail_fbo[i].color[0], 0));
- gl(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rendering->map_thumbnail_fbo[i].depth, 0));
- if(!(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE))
- {
- assert(false);
- }
- gl(glViewport(0, 0, rendering->map_thumbnail_fbo[i].width, rendering->map_thumbnail_fbo[i].height));
- gl(glEnable(GL_DEPTH_TEST));
- gl(glClearColor(1, 0.0f, 1, 0.0f));
- gl(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
- // This calls `glBufferSubdata` and `glDrawArraysInstanced`
- solid_render_pass(0, rendering->view, rendering->projection, rendering->meshes, rendering->textures, rendering->shaders);
- rendering->textures[e_texture_map_thumbnail_000 + i].id = rendering->map_thumbnail_fbo[i].color[0];
- rendering->textures[e_texture_map_thumbnail_000 + i].w = rendering->map_thumbnail_fbo[i].width;
- rendering->textures[e_texture_map_thumbnail_000 + i].h = rendering->map_thumbnail_fbo[i].height;
- gl(glBindFramebuffer(GL_FRAMEBUFFER, 0));
- // @Hack(tkap): This prevents "delete_framebuffer" from deleting the texture. We want to keep the texture to draw it as a map thumbnail
- rendering->map_thumbnail_fbo[i].color[0] = 0;
- delete_framebuffer(&rendering->map_thumbnail_fbo[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement