1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include <windows.h>
#include <stdint.h>
#include <emmintrin.h>
..
...
....
typedef struct GAMEBITMAP
{
BITMAPINFO BitmapInfo; // 44 Bytes
void* Memory; // 4 Bytes
} GAMEBITMAP;
typedef struct PIXEL32
{
uint8_t Blue;
uint8_t Green;
uint8_t Red;
uint8_t Alpha;
} PIXEL32;
...
..
..
void RenderFrameGraphics(void)
{
/*PIXEL32 Pixel = {0};
Pixel.Blue = 0x7f;
Pixel.Green = 0;
Pixel.Red = 0;
Pixel.Alpha = 0xff;*/ --> this is working
__m128i QuadPixel = {0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff};
for(int i = 0; i < GAME_RES_WIDTH * GAME_RES_HEIGHT; i += 4)
{
_mm_store_si128((__m128i)BackBuffer.Memory + i, QuadPixel); //NOT working
//this is working..
//memcpy((PIXEL32*)BackBuffer.Memory + i, &Pixel, sizeof(PIXEL32));
}
HDC DeviceContext = GetDC(gameWindow);
StretchDIBits(DeviceContext, 0, 0, PerformanceData.MonitorWidth, PerformanceData.MonitorHeight, 0, 0, GAME_RES_WIDTH, GAME_RES_HEIGHT,
BackBuffer.Memory, &BackBuffer.BitmapInfo, DIB_RGB_COLORS, SRCCOPY);
ReleaseDC(gameWindow, DeviceContext);
}
|