Borrowed from StrmnNrmn's N64js
| 62 | |
| 63 | //Borrowed from StrmnNrmn's N64js |
| 64 | static inline void DrawFrameBuffer(u32 origin, const CNativeTexture * texture) |
| 65 | { |
| 66 | |
| 67 | u16 * pixels = (u16*)malloc(FB_WIDTH*FB_HEIGHT * sizeof(u16)); // TODO: should cache this, but at some point we'll need to deal with variable framebuffer size, so do this later. |
| 68 | u32 src_offset = 0; |
| 69 | |
| 70 | for (u32 y = 0; y < FB_HEIGHT; ++y) |
| 71 | { |
| 72 | u32 dst_row_offset = y * FB_WIDTH; |
| 73 | u32 dst_offset = dst_row_offset; |
| 74 | |
| 75 | for (u32 x = 0; x < FB_WIDTH; ++x) |
| 76 | { |
| 77 | pixels[dst_offset] = (g_pu8RamBase[(origin + src_offset)^U8_TWIDDLE]<<8) | g_pu8RamBase[(origin + src_offset+ 1)^U8_TWIDDLE] | 1; // NB: or 1 to ensure we have alpha |
| 78 | dst_offset += 1; |
| 79 | src_offset += 2; |
| 80 | } |
| 81 | } |
| 82 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, FB_WIDTH, FB_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, pixels); |
| 83 | |
| 84 | //ToDO: Implement me PSP |
| 85 | //Doesn't work |
| 86 | //sceGuTexMode( GU_PSM_5551, 0, 0, 1 ); // maxmips/a2/swizzle = 0 |
| 87 | //sceGuTexImage(0, texture->GetCorrectedWidth(), texture->GetCorrectedHeight(), texture->GetBlockWidth(), pixels); |
| 88 | |
| 89 | gRenderer->Draw2DTexture(0, 0, FB_WIDTH, FB_HEIGHT, 0, 0, FB_WIDTH, FB_HEIGHT, texture); |
| 90 | |
| 91 | free(pixels); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | void RenderFrameBuffer(u32 origin) |
no test coverage detected