MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / DrawFrameBuffer

Function DrawFrameBuffer

Source/HLEGraphics/uCodes/Ucode_FB.h:65–93  ·  view source on GitHub ↗

Borrowed from StrmnNrmn's N64js

Source from the content-addressed store, hash-verified

63
64//Borrowed from StrmnNrmn's N64js
65static inline void DrawFrameBuffer(u32 origin, const CNativeTexture * texture)
66{
67
68 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.
69 u32 src_offset = 0;
70
71 for (u32 y = 0; y < FB_HEIGHT; ++y)
72 {
73 u32 dst_row_offset = y * FB_WIDTH;
74 u32 dst_offset = dst_row_offset;
75
76 for (u32 x = 0; x < FB_WIDTH; ++x)
77 {
78 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
79 dst_offset += 1;
80 src_offset += 2;
81 }
82 }
83 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, FB_WIDTH, FB_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, pixels);
84
85 //ToDO: Implement me PSP
86 //Doesn't work
87 //sceGuTexMode( GU_PSM_5551, 0, 0, 1 ); // maxmips/a2/swizzle = 0
88 //sceGuTexImage(0, texture->GetCorrectedWidth(), texture->GetCorrectedHeight(), texture->GetBlockWidth(), pixels);
89
90 gRenderer->Draw2DTexture(0, 0, FB_WIDTH, FB_HEIGHT, 0, 0, FB_WIDTH, FB_HEIGHT, texture);
91
92 free(pixels);
93}
94
95
96void RenderFrameBuffer(u32 origin)

Callers 1

RenderFrameBufferFunction · 0.70

Calls 1

Draw2DTextureMethod · 0.45

Tested by

no test coverage detected