@@ -24,17 +24,25 @@ int gdrv::init(int width, int height)
24
24
SDL_TEXTUREACCESS_STREAMING,
25
25
width, height
26
26
);
27
- vScreenPixels = memory::allocate<ColorRgba>(width * height);
28
27
vScreenWidth = width;
29
28
vScreenHeight = height;
29
+
30
+ int pitch = 0 ;
31
+ SDL_LockTexture
32
+ (
33
+ vScreenTex,
34
+ nullptr ,
35
+ reinterpret_cast <void **>(&vScreenPixels),
36
+ &pitch
37
+ );
38
+ assertm (pitch = width* sizeof (ColorRgba), " gdrv: wrong pitch of SDL texture" );
30
39
31
40
return 0 ;
32
41
}
33
42
34
43
int gdrv::uninit ()
35
44
{
36
45
SDL_DestroyTexture (vScreenTex);
37
- memory::free (vScreenPixels);
38
46
return 0 ;
39
47
}
40
48
@@ -191,14 +199,6 @@ int gdrv::destroy_bitmap(gdrv_bitmap8* bmp)
191
199
return 0 ;
192
200
}
193
201
194
- void gdrv::start_blit_sequence ()
195
- {
196
- }
197
-
198
- void gdrv::end_blit_sequence ()
199
- {
200
- }
201
-
202
202
void gdrv::blit (gdrv_bitmap8* bmp, int xSrc, int ySrc, int xDest, int yDest, int width, int height)
203
203
{
204
204
StretchDIBitsScaled (
@@ -321,22 +321,20 @@ int gdrv::StretchDIBitsScaled(int xSrc, int ySrc, int xDst, int yDst,
321
321
322
322
void gdrv::BlitScreen ()
323
323
{
324
- unsigned char * lockedPixels = nullptr ;
325
324
int pitch = 0 ;
325
+ SDL_UnlockTexture (vScreenTex);
326
+ SDL_RenderCopy (winmain::Renderer, vScreenTex, nullptr , &DestinationRect);
326
327
SDL_LockTexture
327
328
(
328
329
vScreenTex,
329
330
nullptr ,
330
- reinterpret_cast <void **>(&lockedPixels ),
331
+ reinterpret_cast <void **>(&vScreenPixels ),
331
332
&pitch
332
333
);
333
- std::memcpy (lockedPixels, vScreenPixels, vScreenWidth * vScreenHeight * 4 );
334
- SDL_UnlockTexture (vScreenTex);
335
- SDL_RenderCopyEx (winmain::Renderer, vScreenTex, nullptr , &DestinationRect, 0 , nullptr , SDL_FLIP_NONE);
336
334
}
337
335
338
336
void gdrv::ApplyPalette (gdrv_bitmap8& bmp)
339
- {
337
+ {
340
338
if (bmp.BitmapType == BitmapTypes::None)
341
339
return ;
342
340
assertm (bmp.BitmapType != BitmapTypes::Spliced, " gdrv: wrong bitmap type" );
0 commit comments