Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/cxong/cdogs-sdl
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Feb 20, 2020
2 parents b1c2218 + e83d538 commit 7a2e8ed
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 458 deletions.
24 changes: 7 additions & 17 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,15 @@ environment:
VERSION: 0.7.3

install:
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\SDL2-devel-%SDL2_VERSION%-VC.tar.gz appveyor DownloadFile http://libsdl.org/release/SDL2-devel-%SDL2_VERSION%-VC.zip
- 7z x SDL2-devel-%SDL2_VERSION%-VC.zip -oC:\
- xcopy C:\SDL2-%SDL2_VERSION%\* %SDLDIR%\ /S /Y
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\SDL2_mixer-devel-%SDL2_MIXER_VERSION%-VC.zip appveyor DownloadFile https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-%SDL2_MIXER_VERSION%-VC.zip
- 7z x SDL2_mixer-devel-%SDL2_MIXER_VERSION%-VC.zip -oC:\
- xcopy C:\SDL2_mixer-%SDL2_MIXER_VERSION%\* %SDLDIR%\ /S /Y
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\SDL2_image-devel-%SDL2_IMAGE_VERSION%-VC.zip appveyor DownloadFile https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-%SDL2_IMAGE_VERSION%-VC.zip
- 7z x SDL2_image-devel-%SDL2_IMAGE_VERSION%-VC.zip -oC:\
- xcopy C:\SDL2_image-%SDL2_IMAGE_VERSION%\* %SDLDIR%\ /S /Y
- xcopy %SDLDIR%\lib\x86\* %SDLDIR%\lib\ /S
- cd C:\Tools\vcpkg
- git pull
- .\bootstrap-vcpkg.bat
- cd %APPVEYOR_BUILD_FOLDER%
- vcpkg install sdl2 sdl2-image sdl2-mixer

before_build:
- .\build\windows\get-sdl2-dlls.bat dll "appveyor DownloadFile"
- cmake -DCMAKE_PREFIX_PATH="%SDLDIR%" -G "Visual Studio 16 2019" -A Win32 .
- cmake -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 16 2019" -A Win32 .

build:
project: c:\projects\cdogs-sdl\cdogs-sdl.sln
Expand All @@ -45,12 +40,7 @@ after_build:
- dir

cache:
- SDL2-devel-%SDL2_VERSION%-VC.zip
- SDL2_image-devel-%SDL2_IMAGE_VERSION%-VC.zip
- SDL2_mixer-devel-%SDL2_MIXER_VERSION%-VC.zip
- dir\SDL2-%SDL2_VERSION%-win32-x86.zip
- dir\SDL2_image-%SDL2_IMAGE_VERSION%-win32-x86.zip
- dir\SDL2_mixer-%SDL2_MIXER_VERSION%-win32-x86.zip
- c:\tools\vcpkg\installed\

artifacts:
- path: /.\C-Dogs*.exe/
Expand Down
24 changes: 7 additions & 17 deletions appveyor.yml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,15 @@ environment:
VERSION: @VERSION@

install:
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\SDL2-devel-%SDL2_VERSION%-VC.tar.gz appveyor DownloadFile http://libsdl.org/release/SDL2-devel-%SDL2_VERSION%-VC.zip
- 7z x SDL2-devel-%SDL2_VERSION%-VC.zip -oC:\
- xcopy C:\SDL2-%SDL2_VERSION%\* %SDLDIR%\ /S /Y
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\SDL2_mixer-devel-%SDL2_MIXER_VERSION%-VC.zip appveyor DownloadFile https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-%SDL2_MIXER_VERSION%-VC.zip
- 7z x SDL2_mixer-devel-%SDL2_MIXER_VERSION%-VC.zip -oC:\
- xcopy C:\SDL2_mixer-%SDL2_MIXER_VERSION%\* %SDLDIR%\ /S /Y
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\SDL2_image-devel-%SDL2_IMAGE_VERSION%-VC.zip appveyor DownloadFile https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-%SDL2_IMAGE_VERSION%-VC.zip
- 7z x SDL2_image-devel-%SDL2_IMAGE_VERSION%-VC.zip -oC:\
- xcopy C:\SDL2_image-%SDL2_IMAGE_VERSION%\* %SDLDIR%\ /S /Y
- xcopy %SDLDIR%\lib\x86\* %SDLDIR%\lib\ /S
- cd C:\Tools\vcpkg
- git pull
- .\bootstrap-vcpkg.bat
- cd %APPVEYOR_BUILD_FOLDER%
- vcpkg install sdl2 sdl2-image sdl2-mixer

before_build:
- .\build\windows\get-sdl2-dlls.bat dll "appveyor DownloadFile"
- cmake -DCMAKE_PREFIX_PATH="%SDLDIR%" -G "Visual Studio 16 2019" -A Win32 .
- cmake -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 16 2019" -A Win32 .

build:
project: c:\projects\cdogs-sdl\cdogs-sdl.sln
Expand All @@ -45,12 +40,7 @@ after_build:
- dir

cache:
- SDL2-devel-%SDL2_VERSION%-VC.zip
- SDL2_image-devel-%SDL2_IMAGE_VERSION%-VC.zip
- SDL2_mixer-devel-%SDL2_MIXER_VERSION%-VC.zip
- dir\SDL2-%SDL2_VERSION%-win32-x86.zip
- dir\SDL2_image-%SDL2_IMAGE_VERSION%-win32-x86.zip
- dir\SDL2_mixer-%SDL2_MIXER_VERSION%-win32-x86.zip
- c:\tools\vcpkg\installed\

artifacts:
- path: /.\C-Dogs*.exe/
Expand Down
66 changes: 34 additions & 32 deletions src/cdogs/events.c
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/*
C-Dogs SDL
A port of the legendary (and fun) action/arcade cdogs.
Copyright (c) 2013-2016, 2018-2019 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
C-Dogs SDL
A port of the legendary (and fun) action/arcade cdogs.
Copyright (c) 2013-2016, 2018-2020 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "events.h"

Expand Down Expand Up @@ -64,7 +64,8 @@ void EventReset(EventHandlers *handlers, Pic *mouseCursor, Pic *mouseTrail)
&handlers->mouse, mouseCursor, mouseTrail, handlers->mouse.hideMouse);
}

void EventPoll(EventHandlers *handlers, Uint32 ticks)
void EventPoll(
EventHandlers *handlers, const Uint32 ticks, int (*onEvent)(SDL_Event *))
{
SDL_Event e;
handlers->HasResolutionChanged = false;
Expand Down Expand Up @@ -218,10 +219,7 @@ void EventPoll(EventHandlers *handlers, Uint32 ticks)
}
break;
case SDL_WINDOWEVENT_CLOSE:
if (!gGraphicsDevice.cachedConfig.IsEditor)
{
handlers->HasQuit = true;
}
handlers->HasQuit = true;
break;
default:
// do nothing
Expand All @@ -237,6 +235,10 @@ void EventPoll(EventHandlers *handlers, Uint32 ticks)
default:
break;
}
if (onEvent)
{
onEvent(&e);
}
}
KeyPostPoll(&handlers->keyboard, ticks);
MousePostPoll(&handlers->mouse, ticks);
Expand Down Expand Up @@ -563,7 +565,7 @@ SDL_Scancode GetKey(EventHandlers *handlers)
SDL_Scancode k = SDL_SCANCODE_UNKNOWN;
do
{
EventPoll(handlers, SDL_GetTicks());
EventPoll(handlers, SDL_GetTicks(), NULL);
k = KeyGetPressed(&handlers->keyboard);
SDL_Delay(10);
} while (k == SDL_SCANCODE_UNKNOWN);
Expand All @@ -572,7 +574,7 @@ SDL_Scancode GetKey(EventHandlers *handlers)

SDL_Scancode EventWaitKeyOrText(EventHandlers *handlers)
{
EventPoll(handlers, SDL_GetTicks());
EventPoll(handlers, SDL_GetTicks(), NULL);
const SDL_Scancode k = KeyGetPressed(&handlers->keyboard);
SDL_Delay(10);
return k;
Expand Down
49 changes: 26 additions & 23 deletions src/cdogs/events.h
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
/*
C-Dogs SDL
A port of the legendary (and fun) action/arcade cdogs.
Copyright (c) 2013-2017 Cong Xu
All rights reserved.
C-Dogs SDL
A port of the legendary (and fun) action/arcade cdogs.
Copyright (c) 2013-2017, 2020 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once

#include <SDL_events.h>

#include "joystick.h"
#include "keyboard.h"
#include "mouse.h"
Expand All @@ -53,7 +55,8 @@ void EventInit(
void EventTerminate(EventHandlers *handlers);
void EventReset(EventHandlers *handlers, Pic *mouseCursor, Pic *mouseTrail);

void EventPoll(EventHandlers *handlers, Uint32 ticks);
void EventPoll(
EventHandlers* handlers, const Uint32 ticks, int (*onEvent)(SDL_Event *));

int GetOnePlayerCmd(
EventHandlers *handlers, const bool isPressed,
Expand Down
42 changes: 21 additions & 21 deletions src/cdogs/font.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/*
Copyright (c) 2014-2017, 2019 Cong Xu
All rights reserved.
Copyright (c) 2014-2017, 2019 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "font.h"

Expand Down Expand Up @@ -63,6 +63,7 @@ void FontLoad(
SDL_RWops *rwops = SDL_RWFromFile(buf, "rb");
CASSERT(IMG_isPNG(rwops), "Error: font file is not PNG");
SDL_Surface *image = IMG_Load_RW(rwops, 0);
rwops->close(rwops);
if (!image)
{
fprintf(stderr, "Cannot load font image: %s\n", IMG_GetError());
Expand Down Expand Up @@ -125,7 +126,6 @@ void FontLoad(

bail:
SDL_FreeSurface(image);
rwops->close(rwops);
}
void FontTerminate(Font *f)
{
Expand Down
48 changes: 28 additions & 20 deletions src/cdogs/pic.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/*
Copyright (c) 2013-2016, 2018-2019 Cong Xu
All rights reserved.
Copyright (c) 2013-2016, 2018-2019 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "pic.h"

Expand Down Expand Up @@ -65,6 +65,10 @@ void PicLoad(
p->size = size;
p->offset = svec2i_zero();
CMALLOC(p->Data, size.x * size.y * sizeof *((Pic *)0)->Data);
if (p->Data == NULL)
{
return;
}
// Manually copy the pixels and replace the alpha component,
// since our gfx device format has no alpha
int srcI = offset.y*image->w + offset.x;
Expand Down Expand Up @@ -260,6 +264,10 @@ void PicShrink(Pic *pic, const struct vec2i size, const struct vec2i offset)
// Trim by copying pixels
Uint32 *newData;
CMALLOC(newData, size.x * size.y * sizeof *newData);
if (newData == NULL)
{
return;
}
for (struct vec2i pos = svec2i_zero(); pos.y < size.y; pos.y++)
{
for (pos.x = 0; pos.x < size.x; pos.x++)
Expand Down
Loading

0 comments on commit 7a2e8ed

Please sign in to comment.