Skip to content

Commit

Permalink
Fix/silence most warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hesiod committed Sep 25, 2018
1 parent 46681e0 commit 6ad0473
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 60 deletions.
6 changes: 3 additions & 3 deletions src/game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void Game::initializeImGui()
style.Colors[ImGuiCol_PopupBg] = windowBg;

//Window elements
style.Colors[ImGuiCol_Text] = ImVec4(.2, .2, .2, 1);
style.Colors[ImGuiCol_Text] = ImVec4(.2f, .2f, .2f, 1.0f);
style.Colors[ImGuiCol_Button] = buttonBg;
style.Colors[ImGuiCol_ButtonHovered] = highlightColor;
style.Colors[ImGuiCol_ButtonActive] = activeColor;
Expand Down Expand Up @@ -190,9 +190,9 @@ void Game::drawDebug(double timeElapsed)
{
width = ImGui::GetWindowWidth();
height = ImGui::GetWindowHeight();
ImGui::TextColored(ImVec4(0.7, 0.1, 0.1, 0.5), "Leon");
ImGui::TextColored(ImVec4(0.7f, 0.1f, 0.1f, 0.5f), "Leon");
ImGui::Separator();
ImGui::TextColored(ImVec4(0.8, 0.8, 0.8, 0.5), "My Fancy chat window!");
ImGui::TextColored(ImVec4(0.8f, 0.8f, 0.8f, 0.5f), "My Fancy chat window!");
}
ImGui::End();

Expand Down
10 changes: 5 additions & 5 deletions src/gamestate/ChatSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void ChatSystem::draw(Renderer& renderer)

float ChatSystem::calculateAlpha(Camera &camera)
{
return 1.0 - glm::smoothstep(8.f, 10.f, camera.getHeight());
return 1.0f - glm::smoothstep(8.f, 10.f, camera.getHeight());
}

void ChatSystem::drawChatIcons(Renderer& renderer)
Expand All @@ -156,7 +156,7 @@ void ChatSystem::drawChats(Renderer& renderer)
glm::vec2 cameraPosition = glm::vec2(camera.getX(), camera.getY());
glm::vec2 cameraView = glm::vec2(camera.getWidth(), camera.getHeight());

float alpha = calculateAlpha(renderer.camera());
const float alpha = calculateAlpha(renderer.camera());

for (size_t i = 0; i < m_chats.size(); i++)
{
Expand All @@ -171,7 +171,7 @@ void ChatSystem::drawChats(Renderer& renderer)
//flip y
position.y = displaySize.y - position.y;

ImGui::SetNextWindowBgAlpha(alpha * 0.7);
ImGui::SetNextWindowBgAlpha(alpha * 0.7f);
ImGui::SetNextWindowPos(ImVec2(position.x, position.y), ImGuiCond_Always);
if (ImGui::Begin((std::string("ChatWindow") + to_string(i)).data(),
nullptr,
Expand All @@ -182,9 +182,9 @@ void ChatSystem::drawChats(Renderer& renderer)
| ImGuiWindowFlags_NoSavedSettings
| ImGuiWindowFlags_NoInputs))
{
ImGui::TextColored(ImVec4(0.2, 0.2, 0.2, alpha), chat.m_user.data());
ImGui::TextColored(ImVec4(0.2f, 0.2f, 0.2f, alpha), chat.m_user.data());
ImGui::Separator();
ImGui::TextColored(ImVec4(.4, .4, .4, alpha), chat.m_text.data());
ImGui::TextColored(ImVec4(.4f, .4f, .4f, alpha), chat.m_text.data());
}
ImGui::End();
}
Expand Down
10 changes: 5 additions & 5 deletions src/gamestate/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ void Map::draw(class Renderer& renderer)
void Map::drawRoundProgress()
{
ImVec2 imGuiDisplaySize = ImGui::GetIO().DisplaySize;
ImVec2 position(imGuiDisplaySize.x / 2.0, imGuiDisplaySize.y - 30);
ImGui::SetNextWindowPos(position, ImGuiCond_Always, ImVec2(0.5, 1.0));
ImGui::SetNextWindowSize(ImVec2(imGuiDisplaySize.x / 2.0, 0.0f), ImGuiCond_Always);
ImVec2 position(imGuiDisplaySize.x / 2.0f, imGuiDisplaySize.y - 30.0f);
ImGui::SetNextWindowPos(position, ImGuiCond_Always, ImVec2(0.5f, 1.0f));
ImGui::SetNextWindowSize(ImVec2(imGuiDisplaySize.x / 2.0f, 0.0f), ImGuiCond_Always);
if (ImGui::Begin("RoundProgressWindow", nullptr,
ImGuiWindowFlags_NoTitleBar
| ImGuiWindowFlags_NoCollapse
Expand All @@ -232,12 +232,12 @@ void Map::drawRoundProgress()
{
ImGui::TextUnformatted("Round Progress");

ImGui::ProgressBar(static_cast<double>(m_numberOfGivenCommands) / m_maxNumberOfCommands, ImVec2(-1, 0), "");
ImGui::ProgressBar(static_cast<double>(m_numberOfGivenCommands) / m_maxNumberOfCommands, ImVec2(-1.0f, 0.0f), "");
ImGui::SameLine(ImGui::GetTextLineHeightWithSpacing());
ImGui::TextUnformatted("Commands");


ImGui::ProgressBar((glfwGetTime() - m_lastUpdate) / m_roundDuration, ImVec2(-1, 0), "");
ImGui::ProgressBar((glfwGetTime() - m_lastUpdate) / m_roundDuration, ImVec2(-1.0f, 0.0f), "");
ImGui::SameLine(ImGui::GetTextLineHeightWithSpacing());
ImGui::TextUnformatted("Time");
}
Expand Down
8 changes: 4 additions & 4 deletions src/input/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ float Input::cameraMovementSpeed() {
void Input::moveCamera(double deltaTime)
{
if (isActionPressed(MoveCameraDown)) {
_camera->setCamera(_camera->getX(), _camera->getY() - cameraMovementSpeed() * deltaTime, _camera->getHeight());
_camera->setCamera(_camera->getX(), _camera->getY() - cameraMovementSpeed() * (float)deltaTime, _camera->getHeight());
}
if (isActionPressed(MoveCameraUp)) {
_camera->setCamera(_camera->getX(), _camera->getY() + cameraMovementSpeed() * deltaTime, _camera->getHeight());
_camera->setCamera(_camera->getX(), _camera->getY() + cameraMovementSpeed() * (float)deltaTime, _camera->getHeight());
}
if (isActionPressed(MoveCameraRight)) {
_camera->setCamera(_camera->getX() + cameraMovementSpeed() * deltaTime, _camera->getY(), _camera->getHeight());
_camera->setCamera(_camera->getX() + cameraMovementSpeed() * (float)deltaTime, _camera->getY(), _camera->getHeight());
}
if (isActionPressed(MoveCameraLeft)) {
_camera->setCamera(_camera->getX() - cameraMovementSpeed() * deltaTime, _camera->getY(), _camera->getHeight());
_camera->setCamera(_camera->getX() - cameraMovementSpeed() * (float)deltaTime, _camera->getY(), _camera->getHeight());
}


Expand Down
44 changes: 22 additions & 22 deletions src/renderer/ParticleRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ void ParticleRenderer::initializeStaticData()
glGenTextures(1, &staticParticleData);
glBindTexture(GL_TEXTURE_2D, staticParticleData);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, textureSize, textureSize, 0, GL_RGBA, GL_FLOAT, nullptr);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, (GLsizei)textureSize, (GLsizei)textureSize, 0, GL_RGBA, GL_FLOAT, nullptr);
setTextureParameters();


glGenTextures(1, &particleColor);
glBindTexture(GL_TEXTURE_2D, particleColor);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, textureSize, textureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)textureSize, (GLsizei)textureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
setTextureParameters();
}

void ParticleRenderer::initializeDynamicData(unsigned int index)
{
glBindTexture(GL_TEXTURE_2D, dynamicParticleData[index]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, textureSize, textureSize, 0, GL_RGBA, GL_FLOAT, nullptr);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, (GLsizei)textureSize, (GLsizei)textureSize, 0, GL_RGBA, GL_FLOAT, nullptr);
setTextureParameters();

glBindFramebuffer(GL_FRAMEBUFFER, frameBuffers[index]);
Expand Down Expand Up @@ -143,7 +143,7 @@ void ParticleRenderer::intializeUniforms()

glUseProgram(particleDrawingProgram);
GLuint textureSizeUniform = glGetUniformLocation(particleDrawingProgram, "particleTextureSize");
glUniform1ui(textureSizeUniform, textureSize);
glUniform1ui(textureSizeUniform, (GLuint)textureSize);
GLuint particleColorSampler = glGetUniformLocation(particleDrawingProgram, "particleColorSampler");
glUniform1i(particleColorSampler, 1);

Expand Down Expand Up @@ -172,7 +172,7 @@ void ParticleRenderer::setFrameBufferTextures(int index)
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dynamicParticleData[index], 0);

std::array<GLenum, 1> drawBuffers = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(drawBuffers.size(), drawBuffers.data());
glDrawBuffers((GLsizei)drawBuffers.size(), drawBuffers.data());
}

void ParticleRenderer::addParticlesFromQueue()
Expand All @@ -189,11 +189,11 @@ void ParticleRenderer::updateParticles(double deltaTime)
{
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glViewport(0, 0, textureSize, textureSize);
glViewport(0, 0, (GLsizei)textureSize, (GLsizei)textureSize);
glUseProgram(particleUpdateProgram);
glBindVertexArray(updateVao);

glUniform1f(deltaTimeUniform, deltaTime);
glUniform1f(deltaTimeUniform, (GLfloat)deltaTime);

glBindFramebuffer(GL_FRAMEBUFFER, frameBuffers[back]);
glActiveTexture(GL_TEXTURE1);
Expand Down Expand Up @@ -229,7 +229,7 @@ void ParticleRenderer::drawParticles()
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, dynamicParticleData[front]);

glDrawArraysInstanced(GL_TRIANGLES, 0, 6, textureSize * textureSize);
glDrawArraysInstanced(GL_TRIANGLES, 0, 6, (GLsizei)(textureSize * textureSize));

glDepthMask(GL_TRUE);
}
Expand All @@ -256,31 +256,31 @@ void ParticleRenderer::addParticles(ParticleSystem particles)
assert(particles.dynamicData.size() == particles.staticData.size());
assert(particles.dynamicData.size() == particles.color.size());

unsigned int dataOffset = 0;
unsigned int dataSize = particles.dynamicData.size() / 4;
size_t dataOffset = 0;
size_t dataSize = particles.dynamicData.size() / 4;
while (dataOffset < dataSize)
{
//write the particle data, one row at a time
unsigned int xOffset = textureOffset % textureSize;
unsigned int yOffset = textureOffset / textureSize ;
unsigned int remainingWidth = std::min(textureSize - xOffset, dataSize - dataOffset);
size_t xOffset = textureOffset % textureSize;
size_t yOffset = textureOffset / textureSize ;
size_t remainingWidth = std::min(textureSize - xOffset, dataSize - dataOffset);

glBindTexture(GL_TEXTURE_2D, dynamicParticleData[front]);
glTexSubImage2D(GL_TEXTURE_2D,
0,
xOffset,
yOffset,
remainingWidth,
(GLint)xOffset,
(GLint)yOffset,
(GLsizei)remainingWidth,
1,
GL_RGBA, GL_FLOAT,
particles.dynamicData.data() + dataOffset * 4);

glBindTexture(GL_TEXTURE_2D, staticParticleData);
glTexSubImage2D(GL_TEXTURE_2D,
0,
xOffset,
yOffset,
remainingWidth,
(GLint)xOffset,
(GLint)yOffset,
(GLsizei)remainingWidth,
1,
GL_RGBA,
GL_FLOAT,
Expand All @@ -289,9 +289,9 @@ void ParticleRenderer::addParticles(ParticleSystem particles)
glBindTexture(GL_TEXTURE_2D, particleColor);
glTexSubImage2D(GL_TEXTURE_2D,
0,
xOffset,
yOffset,
remainingWidth,
(GLint)xOffset,
(GLint)yOffset,
(GLsizei)remainingWidth,
1,
GL_RGBA,
GL_UNSIGNED_BYTE,
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/ParticleRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class ParticleRenderer
void addParticles(ParticleSystem particles);

private:
unsigned int particleCount;
unsigned int textureSize = 256;
GLfloat particleSize = 0.04;
size_t particleCount;
size_t textureSize = 256;
GLfloat particleSize = 0.04f;

unsigned int front = 0;
unsigned int back = 1;
Expand All @@ -44,7 +44,7 @@ class ParticleRenderer

GLuint deltaTimeUniform;

unsigned int textureOffset = 0;
size_t textureOffset = 0;

//setup
void initializeStaticData();
Expand Down
34 changes: 18 additions & 16 deletions src/renderer/ParticleSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ void ParticleSystem::spawnBloodParticles(glm::vec2 position, glm::vec2 direction
offset = glm::normalize(offset);
glm::vec2 particleDirection = offset + direction * randomFloatBetween(1.f, 2.f);

offset *= randomFloatBetween(0, 0.3);
particleDirection *= randomFloatBetween(0.5, 1);
offset *= randomFloatBetween(0, 0.3f);
particleDirection *= randomFloatBetween(0.5f, 1.0f);

GLfloat lifeTime = randomFloatBetween(0.2, 0.7);
GLfloat lifeTime = randomFloatBetween(0.2f, 0.7f);

GLubyte r = 200, g = 10, b = 20;
randomizeColor(r, g, b, 30);
Expand All @@ -70,13 +70,13 @@ void ParticleSystem::spawnShootParticles(glm::vec2 position, glm::vec2 direction
//Muzzle flash
for (size_t i = 0; i < 200; i++)
{
float angle = randomFloatBetween(-10, 10);
float angle = randomFloatBetween(-10.0f, 10.0f);
glm::vec2 randomizedDirection = glm::rotate(direction, glm::radians(angle));
glm::vec2 velocity = randomizedDirection * randomFloatBetween(0.2f, 1.f);
glm::vec2 offset = glm::normalize(glm::vec2(randomFloatBetween(-1.f, -1.f), randomFloatBetween(-1.f, 1.f))) * randomFloatBetween(0, 0.2f);
offset += randomizedDirection * randomFloatBetween(0.f, 0.3f);

GLfloat lifeTime = randomFloatBetween(0.2, 0.7);
GLfloat lifeTime = randomFloatBetween(0.2f, 0.7f);

glm::vec4 color(1.f, 0.64f, 0.f, 0.5f);
color = randomizeColor(color, 0.2f, true);
Expand All @@ -91,12 +91,12 @@ void ParticleSystem::mouseDragParticles(glm::vec2 mousePosition, glm::vec2 targe
{
ParticleSystem particles;
for (size_t i = 0; i <= 100 * deltaTime; i++) {
glm::vec2 offset(randomFloatBetween(-1, 1), randomFloatBetween(-1, 1));
glm::vec2 offset(randomFloatBetween(-1.0f, 1.0f), randomFloatBetween(-1.0f, 1.0f));
offset = glm::normalize(offset) * randomFloatBetween(0.f, 0.2f);

glm::vec2 position = offset + mousePosition;
glm::vec2 velocity = target - position;
float lifeTime = randomFloatBetween(0.3, 0.7);
float lifeTime = randomFloatBetween(0.3f, 0.7f);
particles.addParticle(position, velocity, lifeTime, color);
}
addParticles(particles);
Expand All @@ -111,12 +111,12 @@ void ParticleSystem::spawnAcknowledgeParticles(glm::vec2 position)
offset = glm::normalize(offset);
glm::vec2 direction = offset;

offset *= randomFloatBetween(0, 0.1);
direction *= randomFloatBetween(0.5, 1);
offset *= randomFloatBetween(0.0f, 0.1f);
direction *= randomFloatBetween(0.5f, 1.0f);

GLfloat lifeTime = randomFloatBetween(0.1, 0.5);
GLfloat lifeTime = randomFloatBetween(0.1f, 0.5f);

particles.addParticle(offset + position, direction, lifeTime, glm::vec4(1 , 0.8f, 0.f, 0.8));
particles.addParticle(offset + position, direction, lifeTime, glm::vec4(1.0f, 0.8f, 0.f, 0.8f));
}
addParticles(particles);
}
Expand All @@ -135,9 +135,11 @@ float ParticleSystem::randomFloat()

void ParticleSystem::randomizeColor(GLubyte& r, GLubyte& g, GLubyte b, GLubyte maximumDeviation)
{
r = clamp(r + randomFloatBetween(-maximumDeviation, maximumDeviation), 0.f, 255.f);
g = clamp(g + randomFloatBetween(-maximumDeviation, maximumDeviation), 0.f, 255.f);
b = clamp(b + randomFloatBetween(-maximumDeviation, maximumDeviation), 0.f, 255.f);
const float from = (float)-maximumDeviation;
const float to = (float)maximumDeviation;
r = (GLubyte)clamp((float)r + randomFloatBetween(from, to), 0.f, 255.f);
g = (GLubyte)clamp((float)g + randomFloatBetween(from, to), 0.f, 255.f);
b = (GLubyte)clamp((float)b + randomFloatBetween(from, to), 0.f, 255.f);
}

glm::vec4 ParticleSystem::randomizeColor(glm::vec4 color, float maximumDeviation, bool randomizeAlpha /*= false*/)
Expand All @@ -162,11 +164,11 @@ void ParticleSystem::addParticle(GLfloat x, GLfloat y, GLfloat xVelocity, GLfloa
dynamicData.push_back(x);
dynamicData.push_back(y);
dynamicData.push_back(lifetime);
dynamicData.push_back(0);
dynamicData.push_back(0.0f);

staticData.push_back(xVelocity);
staticData.push_back(yVelocity);
staticData.push_back(0);
staticData.push_back(0.0f);
staticData.push_back(0);

color.push_back(r);
Expand Down
2 changes: 1 addition & 1 deletion src/sound/Sounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void Sounds::play(SoundEnum soundName) {
sf::SoundBuffer& Sounds::selectRandom(SoundEnum soundName) {
const auto range = m_buffers.equal_range(soundName);
std::uniform_int_distribution<std::multimap<SoundEnum, sf::SoundBuffer>::iterator::difference_type> dist{ 0, std::distance(range.first, range.second)-1 };
unsigned int advance = dist(random);
auto advance = dist(random);
auto it = range.first;
while (advance--) it++;
return it->second;
Expand Down

0 comments on commit 6ad0473

Please sign in to comment.