|
1 | 1 |
|
2 | 2 | #include "graphics/render.h" |
| 3 | + |
3 | 4 | #include "graphics/material.h" |
4 | 5 | #include "graphics/matrix.h" |
5 | | -#include "graphics/software/font_internal.h" |
| 6 | +#include "graphics/paths/PathRenderer.h" |
6 | 7 | #include "graphics/software/FSFont.h" |
7 | 8 | #include "graphics/software/NVGFont.h" |
8 | 9 | #include "graphics/software/VFNTFont.h" |
9 | | -#include "graphics/paths/PathRenderer.h" |
10 | | - |
11 | | -#include "mod_table/mod_table.h" |
| 10 | +#include "graphics/software/font_internal.h" |
12 | 11 | #include "localization/localize.h" |
13 | | -#include "matrix.h" |
| 12 | +#include "mod_table/mod_table.h" |
| 13 | +#include "render/3d.h" |
14 | 14 |
|
15 | | -static void gr_flash_internal(int r, int g, int b, int a, bool alpha_flash) { |
| 15 | +static void gr_flash_internal(int r, int g, int b, int a, bool alpha_flash) |
| 16 | +{ |
16 | 17 | CLAMP(r, 0, 255); |
17 | 18 | CLAMP(g, 0, 255); |
18 | 19 | CLAMP(b, 0, 255); |
@@ -1148,14 +1149,130 @@ void gr_render_primitives_immediate(material* material_info, |
1148 | 1149 | } |
1149 | 1150 |
|
1150 | 1151 | void gr_render_primitives_2d_immediate(material* material_info, |
1151 | | - primitive_type prim_type, |
1152 | | - vertex_layout* layout, |
1153 | | - int n_verts, |
1154 | | - void* data, |
1155 | | - size_t size) { |
| 1152 | + primitive_type prim_type, |
| 1153 | + vertex_layout* layout, |
| 1154 | + int n_verts, |
| 1155 | + void* data, |
| 1156 | + size_t size) |
| 1157 | +{ |
1156 | 1158 | gr_set_2d_matrix(); |
1157 | 1159 |
|
1158 | 1160 | gr_render_primitives_immediate(material_info, prim_type, layout, n_verts, data, size); |
1159 | 1161 |
|
1160 | 1162 | gr_end_2d_matrix(); |
1161 | 1163 | } |
| 1164 | + |
| 1165 | +// _->NEW<-_ NEW new bitmap functions -Bobboau |
| 1166 | +// takes a list of rectangles that have assosiated rectangles in a texture |
| 1167 | +static void draw_bitmap_list(bitmap_rect_list* list, int n_bm, int resize_mode, material* render_mat) |
| 1168 | +{ |
| 1169 | + GR_DEBUG_SCOPE("2D Bitmap list"); |
| 1170 | + |
| 1171 | + // adapted from g3_draw_2d_poly_bitmap_list |
| 1172 | + |
| 1173 | + for (int i = 0; i < n_bm; i++) { |
| 1174 | + bitmap_2d_list* l = &list[i].screen_rect; |
| 1175 | + |
| 1176 | + // if no valid hight or width values were given get some from the bitmap |
| 1177 | + if ((l->w <= 0) || (l->h <= 0)) { |
| 1178 | + bm_get_info(gr_screen.current_bitmap, &l->w, &l->h, nullptr, nullptr, nullptr); |
| 1179 | + } |
| 1180 | + |
| 1181 | + if (resize_mode != GR_RESIZE_NONE && (gr_screen.custom_size || (gr_screen.rendering_to_texture != -1))) { |
| 1182 | + gr_resize_screen_pos(&l->x, &l->y, &l->w, &l->h, resize_mode); |
| 1183 | + } |
| 1184 | + } |
| 1185 | + |
| 1186 | + auto vert_list = new vertex[6 * n_bm]; |
| 1187 | + float sw = 0.1f; |
| 1188 | + |
| 1189 | + for (int i = 0; i < n_bm; i++) { |
| 1190 | + // stuff coords |
| 1191 | + |
| 1192 | + bitmap_2d_list* b = &list[i].screen_rect; |
| 1193 | + texture_rect_list* t = &list[i].texture_rect; |
| 1194 | + // tri one |
| 1195 | + vertex* V = &vert_list[i * 6]; |
| 1196 | + V->screen.xyw.x = (float)b->x; |
| 1197 | + V->screen.xyw.y = (float)b->y; |
| 1198 | + V->screen.xyw.w = sw; |
| 1199 | + V->texture_position.u = (float)t->u0; |
| 1200 | + V->texture_position.v = (float)t->v0; |
| 1201 | + V->flags = PF_PROJECTED; |
| 1202 | + V->codes = 0; |
| 1203 | + |
| 1204 | + V++; |
| 1205 | + V->screen.xyw.x = (float)(b->x + b->w); |
| 1206 | + V->screen.xyw.y = (float)b->y; |
| 1207 | + V->screen.xyw.w = sw; |
| 1208 | + V->texture_position.u = (float)t->u1; |
| 1209 | + V->texture_position.v = (float)t->v0; |
| 1210 | + V->flags = PF_PROJECTED; |
| 1211 | + V->codes = 0; |
| 1212 | + |
| 1213 | + V++; |
| 1214 | + V->screen.xyw.x = (float)(b->x + b->w); |
| 1215 | + V->screen.xyw.y = (float)(b->y + b->h); |
| 1216 | + V->screen.xyw.w = sw; |
| 1217 | + V->texture_position.u = (float)t->u1; |
| 1218 | + V->texture_position.v = (float)t->v1; |
| 1219 | + V->flags = PF_PROJECTED; |
| 1220 | + V->codes = 0; |
| 1221 | + |
| 1222 | + // tri two |
| 1223 | + V++; |
| 1224 | + V->screen.xyw.x = (float)b->x; |
| 1225 | + V->screen.xyw.y = (float)b->y; |
| 1226 | + V->screen.xyw.w = sw; |
| 1227 | + V->texture_position.u = (float)t->u0; |
| 1228 | + V->texture_position.v = (float)t->v0; |
| 1229 | + V->flags = PF_PROJECTED; |
| 1230 | + V->codes = 0; |
| 1231 | + |
| 1232 | + V++; |
| 1233 | + V->screen.xyw.x = (float)(b->x + b->w); |
| 1234 | + V->screen.xyw.y = (float)(b->y + b->h); |
| 1235 | + V->screen.xyw.w = sw; |
| 1236 | + V->texture_position.u = (float)t->u1; |
| 1237 | + V->texture_position.v = (float)t->v1; |
| 1238 | + V->flags = PF_PROJECTED; |
| 1239 | + V->codes = 0; |
| 1240 | + |
| 1241 | + V++; |
| 1242 | + V->screen.xyw.x = (float)b->x; |
| 1243 | + V->screen.xyw.y = (float)(b->y + b->h); |
| 1244 | + V->screen.xyw.w = sw; |
| 1245 | + V->texture_position.u = (float)t->u0; |
| 1246 | + V->texture_position.v = (float)t->v1; |
| 1247 | + V->flags = PF_PROJECTED; |
| 1248 | + V->codes = 0; |
| 1249 | + } |
| 1250 | + |
| 1251 | + g3_render_primitives_textured(render_mat, vert_list, 6 * n_bm, PRIM_TYPE_TRIS, true); |
| 1252 | + |
| 1253 | + delete[] vert_list; |
| 1254 | +} |
| 1255 | + |
| 1256 | +void gr_bitmap_list(bitmap_rect_list* list, int n_bm, int resize_mode) |
| 1257 | +{ |
| 1258 | + material mat_params; |
| 1259 | + material_set_interface(&mat_params, |
| 1260 | + gr_screen.current_bitmap, |
| 1261 | + gr_screen.current_alphablend_mode == GR_ALPHABLEND_FILTER, |
| 1262 | + gr_screen.current_alpha); |
| 1263 | + |
| 1264 | + draw_bitmap_list(list, n_bm, resize_mode, &mat_params); |
| 1265 | +} |
| 1266 | + |
| 1267 | +void gr_aabitmap_list(bitmap_rect_list* list, int n_bm, int resize_mode) |
| 1268 | +{ |
| 1269 | + material render_mat; |
| 1270 | + render_mat.set_blend_mode(ALPHA_BLEND_ALPHA_BLEND_ALPHA); |
| 1271 | + render_mat.set_depth_mode(ZBUFFER_TYPE_NONE); |
| 1272 | + render_mat.set_texture_map(TM_BASE_TYPE, gr_screen.current_bitmap); |
| 1273 | + render_mat.set_color(gr_screen.current_color); |
| 1274 | + render_mat.set_cull_mode(false); |
| 1275 | + render_mat.set_texture_type(material::TEX_TYPE_AABITMAP); |
| 1276 | + |
| 1277 | + draw_bitmap_list(list, n_bm, resize_mode, &render_mat); |
| 1278 | +} |
0 commit comments