Skip to content

Commit

Permalink
Merge pull request #1251 from lairworks/demoGraphics
Browse files Browse the repository at this point in the history
Rename project to `demoGraphics`
  • Loading branch information
DanRStevens authored Feb 28, 2025
2 parents 06c9166 + 5328c90 commit e7e2ea1
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ commands:
- run: make --keep-going --jobs 16 CXXFLAGS_EXTRA="-Werror"
- run: make --keep-going --jobs 16 CXXFLAGS_EXTRA="-Werror" test
- run: make --keep-going --jobs 16 CXXFLAGS_EXTRA="-Werror" check
- run: make --keep-going --jobs 16 CXXFLAGS_EXTRA="-Werror" test-graphics
- run: make --keep-going --jobs 16 CXXFLAGS_EXTRA="-Werror" demoGraphics
- run: make package
- store_artifacts:
path: .build/package/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@ jobs:
- run: make --keep-going --jobs 16 CXXFLAGS_EXTRA="-Werror"
- run: make --keep-going --jobs 16 CXXFLAGS_EXTRA="-Werror" test
- run: make --keep-going --jobs 16 CXXFLAGS_EXTRA="-Werror" check
- run: make --keep-going --jobs 16 CXXFLAGS_EXTRA="-Werror" test-graphics
- run: make --keep-going --jobs 16 CXXFLAGS_EXTRA="-Werror" demoGraphics
- run: make package
2 changes: 1 addition & 1 deletion NAS2D.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NAS2D", "NAS2D\NAS2D.vcxpro
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{78F02848-BACB-4AD3-985E-0EB0D5B3DD53}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-graphics", "test-graphics\test-graphics.vcxproj", "{BC10CE9A-9BDA-4922-8C1F-F91C1E389483}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demoGraphics", "demoGraphics\demoGraphics.vcxproj", "{BC10CE9A-9BDA-4922-8C1F-F91C1E389483}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
31 changes: 15 additions & 16 deletions test-graphics/TestGraphics.cpp → demoGraphics/DemoGraphics.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "TestGraphics.h"
#include "DemoGraphics.h"

#include <NAS2D/EnumKeyCode.h>
#include <NAS2D/Utility.h>
Expand All @@ -8,7 +8,6 @@
#include <NAS2D/Math/Rectangle.h>
#include "NAS2D/Math/Angle.h"

#include <functional>
#include <random>


Expand Down Expand Up @@ -42,28 +41,28 @@ namespace
}


TestGraphics::TestGraphics() :
DemoGraphics::DemoGraphics() :
mTimer{},
mGear{"Gear.png"},
mDxImage{"Test_DirectX.png"},
mOglImage{"Test_OpenGL.png"}
{}

TestGraphics::~TestGraphics()
DemoGraphics::~DemoGraphics()
{
auto& eventHandler = NAS2D::Utility<NAS2D::EventHandler>::get();
eventHandler.mouseMotion().disconnect({this, &TestGraphics::onMouseMove});
eventHandler.mouseButtonDown().disconnect({this, &TestGraphics::onMouseDown});
eventHandler.keyDown().disconnect({this, &TestGraphics::onKeyDown});
eventHandler.mouseMotion().disconnect({this, &DemoGraphics::onMouseMove});
eventHandler.mouseButtonDown().disconnect({this, &DemoGraphics::onMouseDown});
eventHandler.keyDown().disconnect({this, &DemoGraphics::onKeyDown});

}

void TestGraphics::initialize()
void DemoGraphics::initialize()
{
auto& eventHandler = NAS2D::Utility<NAS2D::EventHandler>::get();
eventHandler.mouseMotion().connect({this, &TestGraphics::onMouseMove});
eventHandler.mouseButtonDown().connect({this, &TestGraphics::onMouseDown});
eventHandler.keyDown().connect({this, &TestGraphics::onKeyDown});
eventHandler.mouseMotion().connect({this, &DemoGraphics::onMouseMove});
eventHandler.mouseButtonDown().connect({this, &DemoGraphics::onMouseDown});
eventHandler.keyDown().connect({this, &DemoGraphics::onKeyDown});

auto& renderer = NAS2D::Utility<NAS2D::Renderer>::get();
renderer.showSystemPointer(true);
Expand All @@ -72,7 +71,7 @@ void TestGraphics::initialize()
renderer.size(minSize);
}

NAS2D::State* TestGraphics::update()
NAS2D::State* DemoGraphics::update()
{
NAS2D::Renderer& r = NAS2D::Utility<NAS2D::Renderer>::get();

Expand Down Expand Up @@ -126,7 +125,7 @@ NAS2D::State* TestGraphics::update()
return this;
}

void TestGraphics::onKeyDown(NAS2D::KeyCode key, NAS2D::KeyModifier /*mod*/, bool /*repeat*/)
void DemoGraphics::onKeyDown(NAS2D::KeyCode key, NAS2D::KeyModifier /*mod*/, bool /*repeat*/)
{
switch (key)
{
Expand All @@ -150,11 +149,11 @@ void TestGraphics::onKeyDown(NAS2D::KeyCode key, NAS2D::KeyModifier /*mod*/, boo
}
}

void TestGraphics::onMouseMove(NAS2D::Point<int> /*position*/, NAS2D::Vector<int> /*change*/)
void DemoGraphics::onMouseMove(NAS2D::Point<int> /*position*/, NAS2D::Vector<int> /*change*/)
{}

void TestGraphics::onMouseDown(NAS2D::MouseButton /*button*/, NAS2D::Point<int> /*position*/)
void DemoGraphics::onMouseDown(NAS2D::MouseButton /*button*/, NAS2D::Point<int> /*position*/)
{}

void TestGraphics::onWindowResized(int /*w*/, int /*h*/)
void DemoGraphics::onWindowResized(int /*w*/, int /*h*/)
{}
6 changes: 3 additions & 3 deletions test-graphics/TestGraphics.h → demoGraphics/DemoGraphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#include "NAS2D/Resource/Image.h"


class TestGraphics : public NAS2D::State
class DemoGraphics : public NAS2D::State
{
public:
TestGraphics();
~TestGraphics() override;
DemoGraphics();
~DemoGraphics() override;

protected:
void initialize() override;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{BC10CE9A-9BDA-4922-8C1F-F91C1E389483}</ProjectGuid>
<RootNamespace>testgraphics</RootNamespace>
<RootNamespace>demographics</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Expand Down Expand Up @@ -172,11 +172,11 @@
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="SdlVersionInfo.cpp" />
<ClCompile Include="TestGraphics.cpp" />
<ClCompile Include="DemoGraphics.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="SdlVersionInfo.h" />
<ClInclude Include="TestGraphics.h" />
<ClInclude Include="DemoGraphics.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NAS2D\NAS2D.vcxproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="SdlVersionInfo.cpp" />
<ClCompile Include="TestGraphics.cpp" />
<ClCompile Include="DemoGraphics.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="SdlVersionInfo.h" />
<ClInclude Include="TestGraphics.h" />
<ClInclude Include="DemoGraphics.h" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test-graphics/main.cpp → demoGraphics/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// ==================================================================================

#include "SdlVersionInfo.h"
#include "TestGraphics.h"
#include "DemoGraphics.h"

#include <NAS2D/Game.h>
#include <NAS2D/Utility.h>
Expand All @@ -27,7 +27,7 @@ int main()
try
{
NAS2D::Game game("NAS2D Graphics Test", "NAS2D_GraphicsTest", "LairWorks");
game.go(new TestGraphics());
game.go(new DemoGraphics());
}
catch(std::exception& e)
{
Expand Down
38 changes: 19 additions & 19 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ BUILDDIRPREFIX := $(ROOTBUILDDIR)/$(CONFIG)_Linux_
.DEFAULT_GOAL := nas2d

.PHONY: all
all: nas2d test test-graphics
all: nas2d test demoGraphics


## NAS2D project ##
Expand Down Expand Up @@ -101,32 +101,32 @@ check: | test
cd test && $(RunPrefix) ../$(TESTOUTPUT) $(GTEST_OPTIONS)


## Graphics test project ##
## Graphics demo project ##

TESTGRAPHICSDIR := test-graphics
TESTGRAPHICSINTDIR := $(BUILDDIRPREFIX)testGraphics/intermediate
TESTGRAPHICSOUTPUT := $(BUILDDIRPREFIX)testGraphics/testGraphics$(ExeSuffix)
TESTGRAPHICSSRCS := $(shell find $(TESTGRAPHICSDIR) -name '*.cpp')
TESTGRAPHICSOBJS := $(patsubst $(TESTGRAPHICSDIR)/%.cpp,$(TESTGRAPHICSINTDIR)/%.o,$(TESTGRAPHICSSRCS))
DEMOGRAPHICSDIR := demoGraphics
DEMOGRAPHICSINTDIR := $(BUILDDIRPREFIX)demoGraphics/intermediate
DEMOGRAPHICSOUTPUT := $(BUILDDIRPREFIX)demoGraphics/demoGraphics$(ExeSuffix)
DEMOGRAPHICSSRCS := $(shell find $(DEMOGRAPHICSDIR) -name '*.cpp')
DEMOGRAPHICSOBJS := $(patsubst $(DEMOGRAPHICSDIR)/%.cpp,$(DEMOGRAPHICSINTDIR)/%.o,$(DEMOGRAPHICSSRCS))

TESTGRAPHICSPROJECT_FLAGS = $(TESTCPPFLAGS) $(CXXFLAGS)
TESTGRAPHICSPROJECT_LINKFLAGS = $(TESTLDFLAGS) $(LDLIBS)
DEMOGRAPHICSPROJECT_FLAGS = $(TESTCPPFLAGS) $(CXXFLAGS)
DEMOGRAPHICSPROJECT_LINKFLAGS = $(TESTLDFLAGS) $(LDLIBS)

.PHONY: test-graphics
test-graphics: $(TESTGRAPHICSOUTPUT)
.PHONY: demoGraphics
demoGraphics: $(DEMOGRAPHICSOUTPUT)

$(TESTGRAPHICSOUTPUT): PROJECT_LINKFLAGS = $(TESTGRAPHICSPROJECT_LINKFLAGS)
$(TESTGRAPHICSOUTPUT): $(TESTGRAPHICSOBJS) $(OUTPUT)
$(DEMOGRAPHICSOUTPUT): PROJECT_LINKFLAGS = $(DEMOGRAPHICSPROJECT_LINKFLAGS)
$(DEMOGRAPHICSOUTPUT): $(DEMOGRAPHICSOBJS) $(OUTPUT)

$(TESTGRAPHICSOBJS): PROJECT_FLAGS = $(TESTGRAPHICSPROJECT_FLAGS)
$(TESTGRAPHICSOBJS): $(TESTGRAPHICSINTDIR)/%.o : $(TESTGRAPHICSDIR)/%.cpp $(TESTGRAPHICSINTDIR)/%.dep
$(DEMOGRAPHICSOBJS): PROJECT_FLAGS = $(DEMOGRAPHICSPROJECT_FLAGS)
$(DEMOGRAPHICSOBJS): $(DEMOGRAPHICSINTDIR)/%.o : $(DEMOGRAPHICSDIR)/%.cpp $(DEMOGRAPHICSINTDIR)/%.dep

-include $(patsubst %.o,%.dep,$(TESTGRAPHICSOBJS))
-include $(patsubst %.o,%.dep,$(DEMOGRAPHICSOBJS))


.PHONY: run-test-graphics
run-test-graphics: | test-graphics
cd test-graphics/ && $(RunPrefix) ../$(TESTGRAPHICSOUTPUT) ; cd ..
.PHONY: run-demoGraphics
run-demoGraphics: | demoGraphics
cd demoGraphics/ && $(RunPrefix) ../$(DEMOGRAPHICSOUTPUT) ; cd ..


## Compile rules ##
Expand Down

0 comments on commit e7e2ea1

Please sign in to comment.