gdrv: simplified bitmap, fixed blit, improved SDL present.
Removed some Windows dependencies.
This commit is contained in:
1 parent
a09ea75d80
commit
9a10d72e1f
20 files changed
+254
-493
No files matched your search
+106
-329
@@ -1,50 +1,36 @@
|
||||
#include "pch.h"
|
||||
#include "gdrv.h"
|
||||
|
||||
#include "fullscrn.h"
|
||||
#include "memory.h"
|
||||
#include "pinball.h"
|
||||
#include "render.h"
|
||||
#include "winmain.h"
|
||||
|
||||
HPALETTE gdrv::palette_handle = nullptr;
|
||||
SDL_Renderer* gdrv::renderer;
|
||||
int gdrv::sequence_handle;
|
||||
HDC gdrv::sequence_hdc;
|
||||
int gdrv::use_wing = 0;
|
||||
int gdrv::grtext_blue = 0;
|
||||
int gdrv::grtext_green = 0;
|
||||
int gdrv::grtext_red = -1;
|
||||
SDL_Texture* gdrv::vScreenTex = nullptr;
|
||||
char* gdrv::vScreenPixels = nullptr;
|
||||
int gdrv::vScreenWidth, gdrv::vScreenHeight;
|
||||
ColorRgba gdrv::current_palette[256]{};
|
||||
|
||||
HWND hwnd = 0;
|
||||
SDL_Texture* vScreenTex = nullptr;
|
||||
char* pixels = nullptr;
|
||||
int Width, Height;
|
||||
LOGPALETTEx256 current_palette{};
|
||||
|
||||
int gdrv::init(SDL_Renderer* render, int width, int height)
|
||||
int gdrv::init(int width, int height)
|
||||
{
|
||||
renderer = render;
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
|
||||
vScreenTex = SDL_CreateTexture
|
||||
(
|
||||
renderer,
|
||||
winmain::Renderer,
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
width, height
|
||||
);
|
||||
pixels = memory::allocate(width * height * 4);
|
||||
Width = width;
|
||||
Height = height;
|
||||
|
||||
if (!palette_handle)
|
||||
palette_handle = CreatePalette(¤t_palette);
|
||||
vScreenPixels = memory::allocate(width * height * 4);
|
||||
vScreenWidth = width;
|
||||
vScreenHeight = height;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gdrv::uninit()
|
||||
{
|
||||
if (palette_handle)
|
||||
DeleteObject(palette_handle);
|
||||
memory::free(pixels);
|
||||
SDL_DestroyTexture(vScreenTex);
|
||||
memory::free(vScreenPixels);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -52,97 +38,8 @@ void gdrv::get_focus()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BITMAPINFO* gdrv::DibCreate(int16_t bpp, int width, int height)
|
||||
int gdrv::create_bitmap(gdrv_bitmap8* bmp, int width, int height)
|
||||
{
|
||||
auto sizeBytes = height * (width * bpp / 8 + 3 & (~3));
|
||||
auto dib = memory::allocate<BITMAPINFO>(1, (256 - 1) * sizeof(RGBQUAD) + sizeBytes);
|
||||
if (!dib)
|
||||
return nullptr;
|
||||
|
||||
dib->bmiHeader.biSizeImage = sizeBytes;
|
||||
dib->bmiHeader.biWidth = width;
|
||||
dib->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
dib->bmiHeader.biHeight = height;
|
||||
dib->bmiHeader.biPlanes = 1;
|
||||
dib->bmiHeader.biBitCount = bpp;
|
||||
dib->bmiHeader.biCompression = 0;
|
||||
dib->bmiHeader.biXPelsPerMeter = 0;
|
||||
dib->bmiHeader.biYPelsPerMeter = 0;
|
||||
dib->bmiHeader.biClrUsed = 0;
|
||||
dib->bmiHeader.biClrImportant = 0;
|
||||
if (bpp == 4)
|
||||
{
|
||||
dib->bmiHeader.biClrUsed = 16;
|
||||
}
|
||||
else if (bpp == 8)
|
||||
{
|
||||
dib->bmiHeader.biClrUsed = 256;
|
||||
}
|
||||
|
||||
|
||||
uint32_t paletteColors[]
|
||||
{
|
||||
0, 0x800000, 0x8000, 8421376, 128, 8388736, 32896, 12632256,
|
||||
8421504, 16711680, 65280, 16776960, 255, 16711935, 0xFFFF, 0xFFFFFF,
|
||||
};
|
||||
for (auto index = 0u; index < dib->bmiHeader.biClrUsed; index += 16)
|
||||
{
|
||||
memcpy(&dib->bmiColors[index], paletteColors, sizeof paletteColors);
|
||||
}
|
||||
return dib;
|
||||
}
|
||||
|
||||
|
||||
void gdrv::DibSetUsage(BITMAPINFO* dib, HPALETTE hpal, int someFlag)
|
||||
{
|
||||
tagPALETTEENTRY pPalEntries[256];
|
||||
|
||||
if (!hpal)
|
||||
hpal = static_cast<HPALETTE>(GetStockObject(DEFAULT_PALETTE));
|
||||
if (!dib)
|
||||
return;
|
||||
int numOfColors = dib->bmiHeader.biClrUsed;
|
||||
if (!numOfColors)
|
||||
{
|
||||
auto bpp = dib->bmiHeader.biBitCount;
|
||||
if (bpp <= 8u)
|
||||
numOfColors = 1 << bpp;
|
||||
}
|
||||
if (numOfColors > 0 && (dib->bmiHeader.biCompression != 3 || numOfColors == 3))
|
||||
{
|
||||
if (someFlag && someFlag <= 2)
|
||||
{
|
||||
auto pltPtr = reinterpret_cast<short*>(dib->bmiColors);
|
||||
for (auto i = 0; i < numOfColors; ++i)
|
||||
{
|
||||
*pltPtr++ = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (numOfColors >= 256)
|
||||
numOfColors = 256;
|
||||
GetPaletteEntries(hpal, 0, numOfColors, pPalEntries);
|
||||
for (auto index = 0; index < numOfColors; index++)
|
||||
{
|
||||
dib->bmiColors[index].rgbRed = pPalEntries[index].peRed;
|
||||
dib->bmiColors[index].rgbGreen = pPalEntries[index].peGreen;
|
||||
dib->bmiColors[index].rgbBlue = pPalEntries[index].peBlue;
|
||||
dib->bmiColors[index].rgbReserved = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int gdrv::create_bitmap_dib(gdrv_bitmap8* bmp, int width, int height)
|
||||
{
|
||||
char* bmpBufPtr;
|
||||
auto dib = DibCreate(8, width, height);
|
||||
DibSetUsage(dib, palette_handle, 1);
|
||||
|
||||
bmp->Dib = dib;
|
||||
bmp->Width = width;
|
||||
bmp->Stride = width;
|
||||
if (width % 4)
|
||||
@@ -150,24 +47,12 @@ int gdrv::create_bitmap_dib(gdrv_bitmap8* bmp, int width, int height)
|
||||
|
||||
bmp->Height = height;
|
||||
bmp->BitmapType = BitmapType::DibBitmap;
|
||||
|
||||
if (dib->bmiHeader.biCompression == 3)
|
||||
bmpBufPtr = (char*)&dib->bmiHeader.biPlanes + dib->bmiHeader.biSize;
|
||||
else
|
||||
bmpBufPtr = reinterpret_cast<char*>(&dib->bmiColors[dib->bmiHeader.biClrUsed]);
|
||||
bmp->BmpBufPtr1 = bmpBufPtr;
|
||||
bmp->BmpBufPtr2 = bmpBufPtr;
|
||||
bmp->BmpBufPtr1 = memory::allocate(bmp->Height * bmp->Stride);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gdrv::create_bitmap(gdrv_bitmap8* bmp, int width, int height)
|
||||
{
|
||||
return create_bitmap_dib(bmp, width, height);
|
||||
}
|
||||
|
||||
int gdrv::create_raw_bitmap(gdrv_bitmap8* bmp, int width, int height, int flag)
|
||||
{
|
||||
bmp->Dib = nullptr;
|
||||
bmp->Width = width;
|
||||
bmp->Stride = width;
|
||||
if (flag && width % 4)
|
||||
@@ -179,13 +64,11 @@ int gdrv::create_raw_bitmap(gdrv_bitmap8* bmp, int width, int height, int flag)
|
||||
bmp->BmpBufPtr1 = buf;
|
||||
if (!buf)
|
||||
return -1;
|
||||
bmp->BmpBufPtr2 = buf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gdrv::create_spliced_bitmap(gdrv_bitmap8* bmp, int width, int height, int size)
|
||||
{
|
||||
bmp->Dib = nullptr;
|
||||
bmp->Width = width;
|
||||
bmp->Stride = width;
|
||||
bmp->BitmapType = BitmapType::Spliced;
|
||||
@@ -194,54 +77,51 @@ int gdrv::create_spliced_bitmap(gdrv_bitmap8* bmp, int width, int height, int si
|
||||
bmp->BmpBufPtr1 = buf;
|
||||
if (!buf)
|
||||
return -1;
|
||||
bmp->BmpBufPtr2 = bmp->BmpBufPtr1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gdrv::display_palette(PALETTEENTRY* plt)
|
||||
int gdrv::display_palette(ColorRgba* plt)
|
||||
{
|
||||
if (palette_handle)
|
||||
DeleteObject(palette_handle);
|
||||
palette_handle = CreatePalette(¤t_palette);
|
||||
auto windowHandle = GetDesktopWindow();
|
||||
auto dc = winmain::_GetDC(windowHandle);
|
||||
SetSystemPaletteUse(dc, 2u);
|
||||
SetSystemPaletteUse(dc, 1u);
|
||||
auto originalPalette = SelectPalette(dc, palette_handle, 0);
|
||||
RealizePalette(dc);
|
||||
SelectPalette(dc, originalPalette, 0);
|
||||
GetSystemPaletteEntries(dc, 0, 256, current_palette.palPalEntry);
|
||||
const uint32_t sysPaletteColors[]
|
||||
{
|
||||
0x00000000,
|
||||
0x00000080,
|
||||
0x00008000,
|
||||
0x00008080,
|
||||
0x00800000,
|
||||
0x00800080,
|
||||
0x00808000,
|
||||
0x00C0C0C0,
|
||||
0x00C0DCC0,
|
||||
0x00F0CAA6
|
||||
};
|
||||
|
||||
memcpy(current_palette, sysPaletteColors, sizeof sysPaletteColors);
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
current_palette.palPalEntry[i].peFlags = 0;
|
||||
current_palette[i].rgba.peFlags = 0;
|
||||
}
|
||||
|
||||
auto pltSrc = &plt[10];
|
||||
auto pltDst = ¤t_palette.palPalEntry[10];
|
||||
auto pltDst = ¤t_palette[10];
|
||||
for (int index = 236; index > 0; --index)
|
||||
{
|
||||
if (plt)
|
||||
{
|
||||
pltDst->peRed = pltSrc->peRed;
|
||||
pltDst->peGreen = pltSrc->peGreen;
|
||||
pltDst->peBlue = pltSrc->peBlue;
|
||||
pltDst->rgba.peRed = pltSrc->rgba.peRed;
|
||||
pltDst->rgba.peGreen = pltSrc->rgba.peGreen;
|
||||
pltDst->rgba.peBlue = pltSrc->rgba.peBlue;
|
||||
}
|
||||
pltDst->peFlags = 4;
|
||||
pltDst->rgba.peFlags = 4;
|
||||
pltSrc++;
|
||||
pltDst++;
|
||||
}
|
||||
|
||||
if (!(GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE))
|
||||
{
|
||||
current_palette.palPalEntry[255].peBlue = -1;
|
||||
current_palette.palPalEntry[255].peGreen = -1;
|
||||
current_palette.palPalEntry[255].peRed = -1;
|
||||
}
|
||||
current_palette[255].rgba.peBlue = -1;
|
||||
current_palette[255].rgba.peGreen = -1;
|
||||
current_palette[255].rgba.peRed = -1;
|
||||
|
||||
ResizePalette(palette_handle, 256);
|
||||
SetPaletteEntries(palette_handle, 0, 256, current_palette.palPalEntry);
|
||||
windowHandle = GetDesktopWindow();
|
||||
ReleaseDC(windowHandle, dc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -250,102 +130,47 @@ int gdrv::destroy_bitmap(gdrv_bitmap8* bmp)
|
||||
{
|
||||
if (!bmp)
|
||||
return -1;
|
||||
if (bmp->BitmapType == BitmapType::RawBitmap || bmp->BitmapType == BitmapType::Spliced)
|
||||
|
||||
if (bmp->BitmapType != BitmapType::None)
|
||||
{
|
||||
memory::free(bmp->BmpBufPtr1);
|
||||
}
|
||||
else if (bmp->BitmapType == BitmapType::DibBitmap)
|
||||
{
|
||||
memory::free(bmp->Dib);
|
||||
}
|
||||
memset(bmp, 0, sizeof(gdrv_bitmap8));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gdrv::start_blit_sequence()
|
||||
{
|
||||
HDC dc = winmain::_GetDC(hwnd);
|
||||
sequence_handle = 0;
|
||||
sequence_hdc = dc;
|
||||
SelectPalette(dc, palette_handle, 0);
|
||||
RealizePalette(sequence_hdc);
|
||||
SetStretchBltMode(dc, stretchMode);
|
||||
}
|
||||
|
||||
void gdrv::blit_sequence(gdrv_bitmap8* bmp, int xSrc, int ySrcOff, int xDest, int yDest, int DestWidth, int DestHeight)
|
||||
{
|
||||
if (!use_wing)
|
||||
StretchDIBitsScaled(
|
||||
sequence_hdc,
|
||||
xDest,
|
||||
yDest,
|
||||
DestWidth,
|
||||
DestHeight,
|
||||
xSrc,
|
||||
bmp->Height - ySrcOff - DestHeight,
|
||||
DestWidth,
|
||||
DestHeight,
|
||||
bmp,
|
||||
DIB_PAL_COLORS,
|
||||
SRCCOPY
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void gdrv::end_blit_sequence()
|
||||
{
|
||||
ReleaseDC(hwnd, sequence_hdc);
|
||||
}
|
||||
|
||||
void gdrv::blit(gdrv_bitmap8* bmp, int xSrc, int ySrcOff, int xDest, int yDest, int DestWidth, int DestHeight)
|
||||
void gdrv::blit(gdrv_bitmap8* bmp, int xSrc, int ySrc, int xDest, int yDest, int width, int height)
|
||||
{
|
||||
HDC dc = winmain::_GetDC(hwnd);
|
||||
SetStretchBltMode(dc, stretchMode);
|
||||
if (dc)
|
||||
{
|
||||
SelectPalette(dc, palette_handle, 0);
|
||||
RealizePalette(dc);
|
||||
if (!use_wing)
|
||||
StretchDIBitsScaled(
|
||||
dc,
|
||||
xDest,
|
||||
yDest,
|
||||
DestWidth,
|
||||
DestHeight,
|
||||
xSrc,
|
||||
bmp->Height - ySrcOff - DestHeight,
|
||||
DestWidth,
|
||||
DestHeight,
|
||||
bmp,
|
||||
DIB_PAL_COLORS,
|
||||
SRCCOPY
|
||||
);
|
||||
ReleaseDC(hwnd, dc);
|
||||
}
|
||||
StretchDIBitsScaled(
|
||||
xSrc,
|
||||
ySrc ,
|
||||
xDest,
|
||||
yDest,
|
||||
width,
|
||||
height,
|
||||
bmp
|
||||
);
|
||||
}
|
||||
|
||||
void gdrv::blat(gdrv_bitmap8* bmp, int xDest, int yDest)
|
||||
{
|
||||
HDC dc = winmain::_GetDC(hwnd);
|
||||
SelectPalette(dc, palette_handle, 0);
|
||||
RealizePalette(dc);
|
||||
SetStretchBltMode(dc, stretchMode);
|
||||
if (!use_wing)
|
||||
StretchDIBitsScaled(
|
||||
dc,
|
||||
xDest,
|
||||
yDest,
|
||||
bmp->Width,
|
||||
bmp->Height,
|
||||
0,
|
||||
0,
|
||||
bmp->Width,
|
||||
bmp->Height,
|
||||
bmp,
|
||||
DIB_PAL_COLORS,
|
||||
SRCCOPY
|
||||
);
|
||||
ReleaseDC(hwnd, dc);
|
||||
StretchDIBitsScaled(
|
||||
0,
|
||||
0,
|
||||
xDest,
|
||||
yDest,
|
||||
bmp->Width,
|
||||
bmp->Height,
|
||||
bmp
|
||||
);
|
||||
}
|
||||
|
||||
void gdrv::fill_bitmap(gdrv_bitmap8* bmp, int width, int height, int xOff, int yOff, char fillChar)
|
||||
@@ -405,106 +230,63 @@ void gdrv::copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int heigh
|
||||
|
||||
|
||||
void gdrv::grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width, int height, int a6)
|
||||
{
|
||||
tagRECT rc{};
|
||||
|
||||
HDC dc = GetDC(hwnd);
|
||||
rc.left = xOff;
|
||||
rc.right = width + xOff;
|
||||
rc.top = yOff;
|
||||
rc.bottom = height + yOff;
|
||||
if (grtext_red < 0)
|
||||
{
|
||||
grtext_blue = 255;
|
||||
grtext_green = 255;
|
||||
grtext_red = 255;
|
||||
const char* fontColor = pinball::get_rc_string(189, 0);
|
||||
if (fontColor)
|
||||
sscanf_s(fontColor, "%d %d %d", &grtext_red, &grtext_green, &grtext_blue);
|
||||
}
|
||||
int prevMode = SetBkMode(dc, 1);
|
||||
COLORREF color = SetTextColor(dc, grtext_red | grtext_green << 8 | grtext_blue << 16);
|
||||
DrawTextA(dc, text, lstrlenA(text), &rc, 0x810u);
|
||||
SetBkMode(dc, prevMode);
|
||||
SetTextColor(dc, color);
|
||||
ReleaseDC(hwnd, dc);
|
||||
{
|
||||
}
|
||||
|
||||
int gdrv::StretchDIBitsScaled(HDC hdc, int xDest, int yDest, int DestWidth, int DestHeight, int xSrc, int ySrc,
|
||||
int SrcWidth, int SrcHeight, gdrv_bitmap8* bmp, UINT iUsage,
|
||||
DWORD rop)
|
||||
int gdrv::StretchDIBitsScaled(int xSrc, int ySrc, int xDst, int yDst,
|
||||
int width, int height, gdrv_bitmap8* bmp)
|
||||
{
|
||||
/*Scaled partial updates may leave 1px border artifacts around update area.
|
||||
* Pad update area to compensate.*/
|
||||
/*const int pad = 1, padX2 = pad * 2;
|
||||
if (fullscrn::ScaleX > 1 && xSrc > pad && xSrc + pad < bmp->Width)
|
||||
{
|
||||
xSrc -= pad;
|
||||
xDest -= pad;
|
||||
SrcWidth += padX2;
|
||||
DestWidth += padX2;
|
||||
// Y is inverted, X normal left to right
|
||||
ySrc = max(0, min(bmp->Height - height, bmp->Height)) - ySrc;
|
||||
yDst = max(0, min(vScreenHeight - height, vScreenHeight)) - yDst;
|
||||
|
||||
// Negative dst == positive src offset
|
||||
if (xDst < 0)
|
||||
{
|
||||
xSrc -= xDst;
|
||||
xDst = 0;
|
||||
}
|
||||
|
||||
if (fullscrn::ScaleY > 1 && ySrc > pad && ySrc + pad < bmp->Height)
|
||||
if (yDst < 0)
|
||||
{
|
||||
ySrc -= pad;
|
||||
yDest -= pad;
|
||||
SrcHeight += padX2;
|
||||
DestHeight += padX2;
|
||||
ySrc -= yDst;
|
||||
yDst = 0;
|
||||
}
|
||||
|
||||
StretchDIBits(
|
||||
hdc,
|
||||
static_cast<int>(round(xDest * fullscrn::ScaleX + fullscrn::OffsetX)),
|
||||
static_cast<int>(round(yDest * fullscrn::ScaleY + fullscrn::OffsetY)),
|
||||
static_cast<int>(round(DestWidth * fullscrn::ScaleX)),
|
||||
static_cast<int>(round(DestHeight * fullscrn::ScaleY)),
|
||||
xSrc,
|
||||
ySrc,
|
||||
SrcWidth,
|
||||
SrcHeight,
|
||||
bmp->BmpBufPtr1,
|
||||
bmp->Dib,
|
||||
iUsage,
|
||||
rop);*/
|
||||
|
||||
//auto srcPtr = reinterpret_cast<uint8_t*>(bmp->BmpBufPtr1);
|
||||
//auto dstPtr = reinterpret_cast<uint32_t*>(pixels);
|
||||
//for (int y = Height; y > 0; --y)
|
||||
//{
|
||||
// for (int x = Width; x > 0; --x)
|
||||
// *dstPtr++ = *(uint32_t*)¤t_palette.palPalEntry[*srcPtr++];
|
||||
|
||||
// //srcPtr += srcBmp->Stride - width;
|
||||
// //dstPtr += dstBmp->Stride - width;
|
||||
//}
|
||||
|
||||
// Clamp out of bounds rectangles
|
||||
xSrc = max(0, min(xSrc, bmp->Width));
|
||||
ySrc = max(0, min(ySrc, bmp->Height));
|
||||
xSrc = max(0, min(xSrc, bmp->Height));
|
||||
if (ySrc + SrcHeight > Height)
|
||||
SrcHeight = Height - ySrc;
|
||||
if (xSrc + SrcWidth > Width)
|
||||
SrcWidth = Width - xSrc;
|
||||
if (xSrc + width > bmp->Width)
|
||||
width = bmp->Width - xSrc;
|
||||
if (ySrc + height > bmp->Height)
|
||||
height = bmp->Height - ySrc;
|
||||
|
||||
auto srcPtr = reinterpret_cast<uint8_t*>(&bmp->BmpBufPtr1[bmp->Stride * (ySrc)+xSrc]);
|
||||
auto dstPtr = &reinterpret_cast<uint32_t*>(pixels)[Width * (ySrc)+xSrc];
|
||||
for (int y = SrcHeight; y > 0; --y)
|
||||
xDst = max(0, min(xDst, vScreenWidth));
|
||||
yDst = max(0, min(yDst, vScreenHeight));
|
||||
if (xDst + width > vScreenWidth)
|
||||
width = vScreenWidth - xDst;
|
||||
if (yDst + height > vScreenHeight)
|
||||
height = vScreenHeight - yDst;
|
||||
|
||||
auto srcPtr = reinterpret_cast<uint8_t*>(&bmp->BmpBufPtr1[bmp->Stride * ySrc + xSrc]);
|
||||
auto dstPtr = &reinterpret_cast<uint32_t*>(vScreenPixels)[vScreenWidth * yDst + xDst];
|
||||
for (int y = height; y > 0; --y)
|
||||
{
|
||||
for (int x = SrcWidth; x > 0; --x)
|
||||
for (int x = width; x > 0; --x)
|
||||
{
|
||||
if ((char*)dstPtr >= (pixels + Width * Height * 4) || (char*)srcPtr >= (bmp->BmpBufPtr1 + bmp->Stride * bmp->Width))
|
||||
{
|
||||
dstPtr = dstPtr;
|
||||
}
|
||||
|
||||
*dstPtr++ = *(uint32_t*)¤t_palette.palPalEntry[*srcPtr++];
|
||||
*dstPtr++ = current_palette[*srcPtr++].Color;
|
||||
}
|
||||
|
||||
srcPtr += bmp->Stride - SrcWidth;
|
||||
dstPtr += Width - SrcWidth;
|
||||
srcPtr += bmp->Stride - width;
|
||||
dstPtr += vScreenWidth - width;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gdrv::BlitScreen()
|
||||
{
|
||||
auto bmp = &render::vscreen;
|
||||
unsigned char* lockedPixels = nullptr;
|
||||
int pitch = 0;
|
||||
SDL_LockTexture
|
||||
@@ -514,12 +296,7 @@ int gdrv::StretchDIBitsScaled(HDC hdc, int xDest, int yDest, int DestWidth, int
|
||||
reinterpret_cast<void**>(&lockedPixels),
|
||||
&pitch
|
||||
);
|
||||
std::memcpy(lockedPixels, pixels, Width * Height * 4);
|
||||
SDL_UnlockTexture(vScreenTex);
|
||||
|
||||
SDL_Rect dstRect
|
||||
{ xDest,yDest,Width,Height };
|
||||
SDL_RenderCopyEx(renderer, vScreenTex, nullptr, nullptr, 0, 0, SDL_FLIP_VERTICAL);
|
||||
|
||||
return 0;
|
||||
std::memcpy(lockedPixels, vScreenPixels, vScreenWidth * vScreenHeight * 4);
|
||||
SDL_UnlockTexture(vScreenTex);
|
||||
SDL_RenderCopyEx(winmain::Renderer, vScreenTex, nullptr, nullptr, 0, nullptr, SDL_FLIP_VERTICAL);
|
||||
}
|
||||
Reference in new issue
Block a user