Fix more warnings in MSVC

This commit is contained in:
2019-01-14 21:07:32 -08:00
parent cdbbd329cb
commit 5096b391de
9 changed files with 121 additions and 116 deletions

View File

@@ -1,7 +1,12 @@
cmake_minimum_required (VERSION 2.6)
set(CMAKE_CXX_STANDARD 11)
cmake_minimum_required (VERSION 2.8)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
else(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
MESSAGE( "64 bits compiler detected" )

View File

@@ -433,7 +433,7 @@ float KRAudioSource::getAudioTime()
void KRAudioSource::setAudioTime(float new_position)
{
// Sets the audio playback position with units of floating point seconds.
setAudioFrame(new_position * 44100.0f);
setAudioFrame((__int64_t)(new_position * 44100.0f));
}
void KRAudioSource::sample(int frame_count, int channel, float *buffer, float gain)

View File

@@ -191,7 +191,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
float particle_range = 600.0f;
int particle_count = m_dust_particle_density * pow(particle_range, 3);
int particle_count = (int)(m_dust_particle_density * pow(particle_range, 3));
if(particle_count > KRMeshManager::KRENGINE_MAX_RANDOM_PARTICLES) particle_count = KRMeshManager::KRENGINE_MAX_RANDOM_PARTICLES;
// Enable z-buffer test
@@ -421,12 +421,12 @@ void KRLight::renderShadowBuffers(KRCamera *pCamera)
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, shadowFramebuffer[iShadow]));
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, shadowDepthTexture[iShadow], 0));
GLDEBUG(glViewport(0, 0, m_shadowViewports[iShadow].getSize().x, m_shadowViewports[iShadow].getSize().y));
GLDEBUG(glViewport(0, 0, (GLsizei)m_shadowViewports[iShadow].getSize().x, (GLsizei)m_shadowViewports[iShadow].getSize().y));
GLDEBUG(glClearDepthf(0.0f));
GLDEBUG(glClear(GL_DEPTH_BUFFER_BIT));
GLDEBUG(glViewport(1, 1, m_shadowViewports[iShadow].getSize().x - 2, m_shadowViewports[iShadow].getSize().y - 2));
GLDEBUG(glViewport(1, 1, (GLsizei)m_shadowViewports[iShadow].getSize().x - 2, (GLsizei)m_shadowViewports[iShadow].getSize().y - 2));
GLDEBUG(glClearDepthf(1.0f));

View File

@@ -1053,15 +1053,15 @@ void KRMesh::updateAttributeOffsets()
{
pack_header *header = getHeader();
int mask = 0;
for(int i=0; i < KRENGINE_NUM_ATTRIBUTES; i++) {
for(size_t i=0; i < KRENGINE_NUM_ATTRIBUTES; i++) {
if(has_vertex_attribute((vertex_attrib_t)i)) {
m_vertex_attribute_offset[i] = VertexSizeForAttributes(header->vertex_attrib_flags & mask);
m_vertex_attribute_offset[i] = (int)VertexSizeForAttributes(header->vertex_attrib_flags & mask);
} else {
m_vertex_attribute_offset[i] = -1;
}
mask = (mask << 1) | 1;
}
m_vertex_size = VertexSizeForAttributes(header->vertex_attrib_flags);
m_vertex_size = (int)VertexSizeForAttributes(header->vertex_attrib_flags);
}
size_t KRMesh::AttributeOffset(__int32_t vertex_attrib, __int32_t vertex_attrib_flags)

View File

@@ -401,32 +401,32 @@ KRDataBlock &KRMeshManager::getVolumetricLightingVertexes()
for(int iPlane=0; iPlane < KRENGINE_MAX_VOLUMETRIC_PLANES; iPlane++) {
vertex_data[iVertex].vertex.x = -1.0f;
vertex_data[iVertex].vertex.y = -1.0f;
vertex_data[iVertex].vertex.z = iPlane;
vertex_data[iVertex].vertex.z = (GLfloat)iPlane;
iVertex++;
vertex_data[iVertex].vertex.x = 1.0f;
vertex_data[iVertex].vertex.y = -1.0f;
vertex_data[iVertex].vertex.z = iPlane;
vertex_data[iVertex].vertex.z = (GLfloat)iPlane;
iVertex++;
vertex_data[iVertex].vertex.x = -1.0f;
vertex_data[iVertex].vertex.y = 1.0f;
vertex_data[iVertex].vertex.z = iPlane;
vertex_data[iVertex].vertex.z = (GLfloat)iPlane;
iVertex++;
vertex_data[iVertex].vertex.x = -1.0f;
vertex_data[iVertex].vertex.y = 1.0f;
vertex_data[iVertex].vertex.z = iPlane;
vertex_data[iVertex].vertex.z = (GLfloat)iPlane;
iVertex++;
vertex_data[iVertex].vertex.x = 1.0f;
vertex_data[iVertex].vertex.y = -1.0f;
vertex_data[iVertex].vertex.z = iPlane;
vertex_data[iVertex].vertex.z = (GLfloat)iPlane;
iVertex++;
vertex_data[iVertex].vertex.x = 1.0f;
vertex_data[iVertex].vertex.y = 1.0f;
vertex_data[iVertex].vertex.z = iPlane;
vertex_data[iVertex].vertex.z = (GLfloat)iPlane;
iVertex++;
}
@@ -481,7 +481,7 @@ long KRMeshManager::getMemoryTransferedThisFrame()
}
int KRMeshManager::getActiveVBOCount()
size_t KRMeshManager::getActiveVBOCount()
{
return m_vbosActive.size();
}

View File

@@ -150,7 +150,7 @@ public:
long getMemoryTransferedThisFrame();
int getActiveVBOCount();
size_t getActiveVBOCount();
struct draw_call_info {
KRNode::RenderPass pass;

View File

@@ -125,13 +125,13 @@ tinyxml2::XMLElement *KRNode::saveXML(tinyxml2::XMLNode *parent) {
e->SetAttribute("name", m_name.c_str());
kraken::setXMLAttribute("translate", e, m_localTranslation, Vector3::Zero());
kraken::setXMLAttribute("scale", e, m_localScale, Vector3::One());
kraken::setXMLAttribute("rotate", e, (m_localRotation * (180.0f / M_PI)), Vector3::Zero());
kraken::setXMLAttribute("rotate", e, (m_localRotation * (180.0f / (float)M_PI)), Vector3::Zero());
kraken::setXMLAttribute("rotate_offset", e, m_rotationOffset, Vector3::Zero());
kraken::setXMLAttribute("scale_offset", e, m_scalingOffset, Vector3::Zero());
kraken::setXMLAttribute("rotate_pivot", e, m_rotationPivot, Vector3::Zero());
kraken::setXMLAttribute("scale_pivot", e, m_scalingPivot, Vector3::Zero());
kraken::setXMLAttribute("pre_rotate", e, (m_preRotation * (180.0f / M_PI)), Vector3::Zero());
kraken::setXMLAttribute("post_rotate", e, (m_postRotation * (180.0f / M_PI)), Vector3::Zero());
kraken::setXMLAttribute("pre_rotate", e, (m_preRotation * (180.0f / (float)M_PI)), Vector3::Zero());
kraken::setXMLAttribute("post_rotate", e, (m_postRotation * (180.0f / (float)M_PI)), Vector3::Zero());
for(std::set<KRNode *>::iterator itr=m_childNodes.begin(); itr != m_childNodes.end(); ++itr) {
KRNode *child = (*itr);
@@ -145,11 +145,11 @@ void KRNode::loadXML(tinyxml2::XMLElement *e) {
m_localTranslation = kraken::getXMLAttribute("translate", e, Vector3::Zero());
m_localScale = kraken::getXMLAttribute("scale", e, Vector3::One());
m_localRotation = kraken::getXMLAttribute("rotate", e, Vector3::Zero());
m_localRotation *= M_PI / 180.0f; // Convert degrees to radians
m_localRotation *= (float)M_PI / 180.0f; // Convert degrees to radians
m_preRotation = kraken::getXMLAttribute("pre_rotate", e, Vector3::Zero());
m_preRotation *= M_PI / 180.0f; // Convert degrees to radians
m_preRotation *= (float)M_PI / 180.0f; // Convert degrees to radians
m_postRotation = kraken::getXMLAttribute("post_rotate", e, Vector3::Zero());
m_postRotation *= M_PI / 180.0f; // Convert degrees to radians
m_postRotation *= (float)M_PI / 180.0f; // Convert degrees to radians
m_rotationOffset = kraken::getXMLAttribute("rotate_offset", e, Vector3::Zero());
m_scalingOffset = kraken::getXMLAttribute("scale_offset", e, Vector3::Zero());
@@ -763,7 +763,7 @@ void KRNode::SetAttribute(node_attribute_type attrib, float v)
{
if(m_animation_mask[attrib]) return;
const float DEGREES_TO_RAD = M_PI / 180.0f;
const float DEGREES_TO_RAD = (float)M_PI / 180.0f;
//printf("%s - ", m_name.c_str());
switch(attrib) {

View File

@@ -57,9 +57,9 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
int light_point_count = 0;
int light_spot_count = 0;
if(renderPass != KRNode::RENDER_PASS_DEFERRED_LIGHTS && renderPass != KRNode::RENDER_PASS_DEFERRED_GBUFFER && renderPass != KRNode::RENDER_PASS_DEFERRED_OPAQUE && renderPass != KRNode::RENDER_PASS_GENERATE_SHADOWMAPS) {
light_directional_count = directional_lights.size();
light_point_count = point_lights.size();
light_spot_count = spot_lights.size();
light_directional_count = (int)directional_lights.size();
light_point_count = (int)point_lights.size();
light_spot_count = (int)spot_lights.size();
for(std::vector<KRDirectionalLight *>::const_iterator light_itr=directional_lights.begin(); light_itr != directional_lights.end(); light_itr++) {
KRDirectionalLight *directional_light =(*light_itr);
iShadowQuality = directional_light->getShadowBufferCount();
@@ -109,13 +109,13 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
key.second.push_back(pCamera->settings.dof_quality);
key.second.push_back(pCamera->settings.bEnableFlash);
key.second.push_back(pCamera->settings.bEnableVignette);
key.second.push_back(pCamera->settings.dof_depth * 1000.0f);
key.second.push_back(pCamera->settings.dof_falloff * 1000.0f);
key.second.push_back(pCamera->settings.flash_depth * 1000.0f);
key.second.push_back(pCamera->settings.flash_falloff * 1000.0f);
key.second.push_back(pCamera->settings.flash_intensity * 1000.0f);
key.second.push_back(pCamera->settings.vignette_radius * 1000.0f);
key.second.push_back(pCamera->settings.vignette_falloff * 1000.0f);
key.second.push_back((int)(pCamera->settings.dof_depth * 1000.0f));
key.second.push_back((int)(pCamera->settings.dof_falloff * 1000.0f));
key.second.push_back((int)(pCamera->settings.flash_depth * 1000.0f));
key.second.push_back((int)(pCamera->settings.flash_falloff * 1000.0f));
key.second.push_back((int)(pCamera->settings.flash_intensity * 1000.0f));
key.second.push_back((int)(pCamera->settings.vignette_radius * 1000.0f));
key.second.push_back((int)(pCamera->settings.vignette_falloff * 1000.0f));
key.second.push_back(bRimColor);
key.second.push_back(bFadeColorEnabled);
@@ -278,6 +278,6 @@ const std::string &KRShaderManager::getVertShaderSource(const std::string &name)
return m_vertShaderSource[name];
}
long KRShaderManager::getShaderHandlesUsed() {
size_t KRShaderManager::getShaderHandlesUsed() {
return m_shaders.size();
}

View File

@@ -64,7 +64,7 @@ public:
bool selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const Matrix4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color);
long getShaderHandlesUsed();
size_t getShaderHandlesUsed();
KRShader *m_active_shader;