Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hesiod committed Aug 31, 2018
2 parents 1cdac5c + 82636ef commit 0da7392
Show file tree
Hide file tree
Showing 223 changed files with 33,585 additions and 1,621 deletions.
82 changes: 27 additions & 55 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ image:
configuration:
- Release
- Debug
environment:
GLFW_VER: 3.2.1
GLM_VER: 0.9.9.0
GLBINDING_VER: 3.0.2
cache:
- C:\projects\glfw
- C:\projects\glbinding
Expand All @@ -21,91 +25,59 @@ install:
- if not exist build-glbinding mkdir build-glbinding
- if not exist build-sioclient mkdir build-sioclient

- if not exist "C:\projects\glfw" \
git clone --depth 1 --no-checkout \
https://github.com/glfw/glfw.git C:\projects\glfw
- if not exist "C:\projects\glfw" git clone --depth 1 --no-checkout https://github.com/glfw/glfw.git C:\projects\glfw
- cd C:\projects\glfw
- git fetch --depth 1 --tags
- git checkout 3.2.1
- git checkout %GLFW_VER%
- cd ../build-glfw
- cmake \
-DCMAKE_BUILD_TYPE=%CONFIGURATION% \
-DCMAKE_INSTALL_PREFIX=C:\deps\glfw \
-DGLFW_BUILD_EXAMPLES=OFF \
-DGLFW_BUILD_TESTS=OFF \
-G "Visual Studio 15 2017 Win64" \
../glfw
- cmake -DCMAKE_INSTALL_PREFIX=C:\deps\glfw -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -G "Visual Studio 15 2017 Win64" ../glfw
- cmake --build . --config %CONFIGURATION%
- cmake --build . --config %CONFIGURATION% --target install

- if not exist "C:\projects\glm" \
git clone --depth 1 --no-checkout \
https://github.com/g-truc/glm.git C:\projects\glm
- if not exist "C:\projects\glm" git clone --depth 1 --no-checkout https://github.com/g-truc/glm.git C:\projects\glm
- cd C:\projects\glm
- git fetch --depth 1 --tags
- git checkout 0.9.9.0
- git checkout %GLM_VER%
- cd ../build-glm
- cmake \
-DCMAKE_BUILD_TYPE=%CONFIGURATION% \
-DCMAKE_INSTALL_PREFIX=C:\deps\glm \
-DGLM_INSTALL_ENABLE=true \
-G "Visual Studio 15 2017 Win64" \
../glm
- cmake -DCMAKE_INSTALL_PREFIX=C:\deps\glm -DGLM_INSTALL_ENABLE=true -G "Visual Studio 15 2017 Win64" ../glm
- cmake --build . --config %CONFIGURATION%
- cmake --build . --config %CONFIGURATION% --target install

- if not exist "C:\projects\glbinding" \
git clone --depth 1 --no-checkout \
https://github.com/cginternals/glbinding C:\projects\glbinding
- if not exist "C:\projects\glbinding" git clone --depth 1 --no-checkout https://github.com/cginternals/glbinding C:\projects\glbinding
- cd C:\projects\glbinding
- git fetch --depth 1 --tags
- git checkout v2.1.4
- git checkout v%GLBINDING_VER%
- cd ../build-glbinding
- cmake \
-DCMAKE_BUILD_TYPE=%CONFIGURATION% \
-DCMAKE_INSTALL_PREFIX=C:\deps\glbinding \
-DCMAKE_CXX_FLAGS="/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING /EHsc" \
-DCMAKE_PREFIX_PATH=C:\deps\glfw \
-DBUILD_SHARED_LIBS=OFF \
-DOPTION_BUILD_TESTS=OFF \
-DOPTION_BUILD_GPU_TESTS=OFF \
-DOPTION_BUILD_TOOLS=OFF \
-G "Visual Studio 15 2017 Win64" \
../glbinding
- cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_INSTALL_PREFIX=C:\deps\glbinding -DCMAKE_CXX_FLAGS="/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING /EHsc" -DCMAKE_PREFIX_PATH=C:\deps\glfw -DBUILD_SHARED_LIBS=OFF -DOPTION_BUILD_TESTS=OFF -DOPTION_BUILD_GPU_TESTS=OFF -DOPTION_BUILD_TOOLS=OFF -G "Visual Studio 15 2017 Win64" ../glbinding
- cmake --build . --config %CONFIGURATION%
- cmake --build . --config %CONFIGURATION% --target install

- if not exist "C:\projects\sioclient" \
git clone --depth 1 --no-checkout --branch fixes \
https://github.com/SwarmMind/socket.io-client-cpp.git C:\projects\sioclient
- if not exist "C:\projects\sioclient" git clone --depth 1 --branch fixes https://github.com/SwarmMind/socket.io-client-cpp.git C:\projects\sioclient
- cd C:\projects\sioclient
- git fetch --depth 1 --tags
- cd ../build-sioclient
- cmake \
-DCMAKE_BUILD_TYPE=%CONFIGURATION% \
-DCMAKE_INSTALL_PREFIX=C:\deps\sioclient \
-DCMAKE_CXX_FLAGS="/D_SCL_SECURE_NO_WARNINGS /EHsc" \
-DBOOST_ROOT=C:\Libraries\boost_1_67_0 \
-DBOOST_VER=1.67.0 \
-G "Visual Studio 15 2017 Win64" \
../sioclient
- cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_INSTALL_PREFIX=C:\deps\sioclient -DCMAKE_CXX_FLAGS="/D_SCL_SECURE_NO_WARNINGS /EHsc" -DBOOST_ROOT=C:\Libraries\boost_1_67_0 -DBOOST_VER=1.67.0 -G "Visual Studio 15 2017 Win64" ../sioclient
- cmake --build . --config %CONFIGURATION%
- cmake --build . --config %CONFIGURATION% --target install

before_build:
- cd C:\projects\swarmmind-client
- mkdir build && cd build
- cmake \
-DCMAKE_BUILD_TYPE=%CONFIGURATION% \
-DCMAKE_PREFIX_PATH=C:\deps\glfw;C:\deps\glbinding;C:\deps\sioclient \
-DSIOCLIENT_USE_FIND_PACKAGE=ON \
-G "Visual Studio 15 2017 Win64" \
..
- cmake -DCMAKE_BUILD_TYPE=$env:CONFIGURATION -DCMAKE_PREFIX_PATH=C:\deps\glfw;C:\deps\glbinding;C:\deps\sioclient -DSIOCLIENT_USE_FIND_PACKAGE=ON -G "Visual Studio 15 2017 Win64" ..
build:
project: build\SwarmMind-Client.sln
verbosity: minimal
parallel: true

after_build:
- ps: cd C:\projects\swarmmind-client
- mkdir package
- ps: cp build\src\$env:CONFIGURATION\SwarmMind-Client.exe package
- ps: cp -r -v fonts package
- ps: cp -r -v shaders package
- ps: cp -r -v res package

artifacts:
- path: build
name: Build output
- path: package
name: SwarmMind_Client
type: zip
Binary file modified res/gridSpriteSheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions shaders/ParticleRendering.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#version 400 core

uniform sampler2D particleColorSampler;

out vec4 f_color;

in vec2 v_uv;
flat in ivec2 v_particleCoord;
in vec4 v_dynamicParticleData;

void main()
{
float zz = 1.0 - dot(v_uv, v_uv);
float lifeTime = v_dynamicParticleData.z;
if(zz < 0 || lifeTime <= 0)
discard;

//smoothly fade out the particles at the end of their lifetime
float alpha = zz * smoothstep(0.0, 0.3, lifeTime);

vec4 color = texelFetch(particleColorSampler, v_particleCoord, 0);

f_color = vec4(color.rgb, color.a * alpha);
}
36 changes: 36 additions & 0 deletions shaders/ParticleRendering.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#version 400 core

uniform sampler2D dynamicDataSampler;
uniform uint particleTextureSize;

uniform vec2 cameraPosition;
uniform vec2 cameraSize;

layout (location = 0) in vec2 basePosition;
layout (location = 1) in vec2 uv;

out vec2 v_uv;
flat out ivec2 v_particleCoord;
out vec4 v_dynamicParticleData;

void main()
{
v_uv = uv;

ivec2 particleCoord = ivec2(gl_InstanceID / particleTextureSize, mod(gl_InstanceID, particleTextureSize));
v_particleCoord = particleCoord;
vec4 dynamicParticleData = texelFetch(dynamicDataSampler, particleCoord, 0);
v_dynamicParticleData = dynamicParticleData;

float lifeTime = dynamicParticleData.z;
if(lifeTime <= 0.0)
{
gl_Position = vec4(0, 0, 0, 1);
return;
}

vec2 offset = dynamicParticleData.xy;
vec2 position = basePosition + offset;
position = (position - cameraPosition) / cameraSize;
gl_Position = vec4(position, 0.5, 1);
}
16 changes: 16 additions & 0 deletions shaders/Passthrough.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#version 400 core

layout (location = 0) in vec2 position;

void main()
{
/*vec2 positions[6] = vec2[](
vec2(-1, -1),
vec2(1, -1),
vec2(1, 1),
vec2(-1, -1),
vec2(1, 1),
vec2(-1, 1)
);*/
gl_Position = vec4(position, 1, 1.0);
}
4 changes: 3 additions & 1 deletion shaders/frag.glsl → shaders/Sprite.frag
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ out vec4 outputColor;
void main(void)
{
vec4 color = texture(textureSampler, v_uv);
gl_FragDepth = color.a * gl_FragCoord.z;
if(color.a == 0)
discard;

outputColor = color;
}
File renamed without changes.
28 changes: 28 additions & 0 deletions shaders/UpdateParticles.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#version 400 core

uniform sampler2D particleSampler;
uniform sampler2D staticDataSampler;
uniform float deltaTime;

layout(pixel_center_integer) in vec4 gl_FragCoord;

layout (location = 0) out vec4 particleData;

void main()
{
ivec2 textureCoords = ivec2(gl_FragCoord.xy);
vec4 currentData = texelFetch(particleSampler, textureCoords, 0);
float lifeTime = currentData.z;
if(lifeTime <= 0.0)
{
particleData = vec4(0, 0, 0, 0);
return;
}

vec2 position = currentData.xy;

vec4 staticData = texelFetch(staticDataSampler, textureCoords, 0);
vec2 velocity = staticData.xy;

particleData = vec4(position + velocity * deltaTime, lifeTime - deltaTime, 0);
}
56 changes: 56 additions & 0 deletions shaders/commandVisualization.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#version 400 core

uniform sampler2D textureSampler;

in vec4 v_color;
in float v_distanceToCenter;

out vec4 outputColor;

float calculateAlpha()
{
float commandsAlpha = (-40 * pow(v_distanceToCenter - 0.9, 2) + 1.5) * v_color.a;
//float circleAlpha = max(-128 * pow(v_distanceToCenter - 1.0, 2) + 0.5, 0.0);
//return min(commandsAlpha + circleAlpha, 1.0);
return commandsAlpha;
//float curveValue = sin(2.5 * pow(v_distanceToCenter, 2));
//return curveValue * pow(mix(v_color.a, 1.0, curveValue), 10);
}

void main(void)
{
float alpha = calculateAlpha();
if(alpha <= 0)
discard;

outputColor = vec4(v_color.rgb, alpha);
}


/*float restoredAlpha()
{
return v_color.a / v_distanceToCenter;
}
float calculateAlpha()
{
float alpha = restoredAlpha();
float circleRadius = 0.7;
float circleAlpha;
if(v_distanceToCenter <= circleRadius)
circleAlpha = max(-64 * pow(v_distanceToCenter - circleRadius, 2) + 0.5, 0.0);
else
circleAlpha = 1 - step(alpha, (v_distanceToCenter - circleRadius)/(1-circleRadius));
return circleAlpha;
}
void main(void)
{
if(v_distanceToCenter == 0)
discard;
float alpha = calculateAlpha();
if(alpha <= 0)
discard;
outputColor = vec4(v_color.rgb, alpha);
}*/
19 changes: 19 additions & 0 deletions shaders/commandVisualization.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#version 400 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec4 color;
layout (location = 2) in float distanceToCenter;

out vec4 v_color;
out float v_distanceToCenter;

uniform vec2 camPosition;
uniform vec2 camSize;

void main(void)
{
v_color = color;
v_distanceToCenter = distanceToCenter;
vec3 screenPosition = vec3((position.xy - camPosition) / camSize, position.z);
gl_Position = vec4(screenPosition, 1.0);
}
12 changes: 8 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
find_package(glfw3 REQUIRED)
find_package(glbinding REQUIRED)
find_package(glm REQUIRED)

set(sources "main.cpp")

add_subdirectory(renderer)
Expand All @@ -8,9 +12,12 @@ add_subdirectory(gamestate)
add_subdirectory(input)
add_subdirectory(game)
add_subdirectory(menu)
add_subdirectory(events)

add_executable(SwarmMind-Client ${sources})

target_link_libraries(SwarmMind-Client PRIVATE imgui)

#Replicate the directory structure in Visual Studio filters
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${sources})

Expand Down Expand Up @@ -49,11 +56,8 @@ else()
endif()
endif()

target_link_libraries(SwarmMind-Client PUBLIC glbinding::glbinding glbinding::glbinding-aux glfw glm)

find_package(glfw3 REQUIRED)
find_package(glbinding REQUIRED)

target_link_libraries(SwarmMind-Client PUBLIC glbinding::glbinding glfw)
if(MSVC)
target_compile_options(SwarmMind-Client PRIVATE /wd4251)
endif()
Expand Down
26 changes: 26 additions & 0 deletions src/events/AccumulatedCommandsEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once
#include <events/Event.h>

#include <vector>
#include <glm/vec2.hpp>

struct AccumulatedCommands {
uint32_t ID;
std::vector<glm::vec2> attackDirections;
std::vector<glm::vec2> moveDirections;
};

class AccumulatedCommandsEvent : public Event
{
public:
AccumulatedCommandsEvent() = default;
virtual ~AccumulatedCommandsEvent() = default;

std::vector<AccumulatedCommands> commands;

size_t numberOfGivenCommands = 0;
size_t maxNumberOfCommands = 1;
protected:

private:
};
Loading

0 comments on commit 0da7392

Please sign in to comment.