All non-3rdparty warnings cleared.
This commit is contained in:
@@ -309,7 +309,7 @@ void KRAudioManager::renderReverb()
|
|||||||
for(unordered_map<std::string, siren_reverb_zone_weight_info>::iterator zone_itr=m_reverb_zone_weights.begin(); zone_itr != m_reverb_zone_weights.end(); zone_itr++) {
|
for(unordered_map<std::string, siren_reverb_zone_weight_info>::iterator zone_itr=m_reverb_zone_weights.begin(); zone_itr != m_reverb_zone_weights.end(); zone_itr++) {
|
||||||
siren_reverb_zone_weight_info zi = (*zone_itr).second;
|
siren_reverb_zone_weight_info zi = (*zone_itr).second;
|
||||||
if(zi.reverb_sample) {
|
if(zi.reverb_sample) {
|
||||||
int zone_sample_blocks = KRMIN(zi.reverb_sample->getFrameCount(), (int)(m_reverb_max_length * 44100.0f)) / KRENGINE_AUDIO_BLOCK_LENGTH + 1;
|
int zone_sample_blocks = KRMIN((int)zi.reverb_sample->getFrameCount(), (int)(m_reverb_max_length * 44100.0f)) / KRENGINE_AUDIO_BLOCK_LENGTH + 1;
|
||||||
impulse_response_blocks = KRMAX(impulse_response_blocks, zone_sample_blocks);
|
impulse_response_blocks = KRMAX(impulse_response_blocks, zone_sample_blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ int KRAudioSample::getChannelCount()
|
|||||||
return m_channelsPerFrame;
|
return m_channelsPerFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KRAudioSample::getFrameCount()
|
__int64_t KRAudioSample::getFrameCount()
|
||||||
{
|
{
|
||||||
loadInfo();
|
loadInfo();
|
||||||
//return (int)((__int64_t)m_totalFrames * (__int64_t)frame_rate / (__int64_t)m_frameRate);
|
//return (int)((__int64_t)m_totalFrames * (__int64_t)frame_rate / (__int64_t)m_frameRate);
|
||||||
@@ -113,7 +113,7 @@ float KRAudioSample::sample(int frame_offset, int frame_rate, int channel)
|
|||||||
if(buffer_index >= m_bufferCount) {
|
if(buffer_index >= m_bufferCount) {
|
||||||
return 0.0f; // Past the end of the recording
|
return 0.0f; // Past the end of the recording
|
||||||
} else {
|
} else {
|
||||||
int buffer_offset = frame_offset - buffer_index * maxFramesPerBuffer;
|
__int64_t buffer_offset = frame_offset - buffer_index * maxFramesPerBuffer;
|
||||||
|
|
||||||
KRAudioBuffer *buffer = getContext().getAudioManager()->getBuffer(*this, buffer_index);
|
KRAudioBuffer *buffer = getContext().getAudioManager()->getBuffer(*this, buffer_index);
|
||||||
if(buffer == NULL) {
|
if(buffer == NULL) {
|
||||||
@@ -132,12 +132,12 @@ void KRAudioSample::sample(__int64_t frame_offset, int frame_count, int channel,
|
|||||||
{
|
{
|
||||||
loadInfo();
|
loadInfo();
|
||||||
|
|
||||||
m_last_frame_used = getContext().getAudioManager()->getAudioFrame();
|
m_last_frame_used = (int)getContext().getAudioManager()->getAudioFrame();
|
||||||
|
|
||||||
if(loop) {
|
if(loop) {
|
||||||
int buffer_offset = 0;
|
int buffer_offset = 0;
|
||||||
int frames_left = frame_count;
|
int frames_left = frame_count;
|
||||||
int sample_length = getFrameCount();
|
int sample_length = (int)getFrameCount();
|
||||||
while(frames_left) {
|
while(frames_left) {
|
||||||
int next_frame = (int)(((__int64_t)frame_offset + (__int64_t)buffer_offset) % sample_length);
|
int next_frame = (int)(((__int64_t)frame_offset + (__int64_t)buffer_offset) % sample_length);
|
||||||
if(next_frame + frames_left >= sample_length) {
|
if(next_frame + frames_left >= sample_length) {
|
||||||
@@ -160,8 +160,8 @@ void KRAudioSample::sample(__int64_t frame_offset, int frame_count, int channel,
|
|||||||
// Range is entirely after the sample
|
// Range is entirely after the sample
|
||||||
memset(buffer, 0, frame_count * sizeof(float));
|
memset(buffer, 0, frame_count * sizeof(float));
|
||||||
} else {
|
} else {
|
||||||
int start_frame = frame_offset < 0 ? 0 : frame_offset;
|
int start_frame = (int)(frame_offset < 0 ? 0 : frame_offset);
|
||||||
int prefix_frames = frame_offset < 0 ? -frame_offset : 0;
|
int prefix_frames = (int)(frame_offset < 0 ? -frame_offset : 0);
|
||||||
if(prefix_frames > 0) {
|
if(prefix_frames > 0) {
|
||||||
// Prefix with padding of 0's
|
// Prefix with padding of 0's
|
||||||
memset(buffer, 0, prefix_frames * sizeof(float));
|
memset(buffer, 0, prefix_frames * sizeof(float));
|
||||||
@@ -386,7 +386,7 @@ KRAudioBuffer *KRAudioSample::getBuffer(int index)
|
|||||||
void KRAudioSample::_endFrame()
|
void KRAudioSample::_endFrame()
|
||||||
{
|
{
|
||||||
const __int64_t AUDIO_SAMPLE_EXPIRY_FRAMES = 500;
|
const __int64_t AUDIO_SAMPLE_EXPIRY_FRAMES = 500;
|
||||||
long current_frame = getContext().getAudioManager()->getAudioFrame();
|
__int64_t current_frame = getContext().getAudioManager()->getAudioFrame();
|
||||||
if(current_frame > m_last_frame_used + AUDIO_SAMPLE_EXPIRY_FRAMES) {
|
if(current_frame > m_last_frame_used + AUDIO_SAMPLE_EXPIRY_FRAMES) {
|
||||||
closeFile();
|
closeFile();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,113 +1,113 @@
|
|||||||
//
|
//
|
||||||
// KRAudioSample.h
|
// KRAudioSample.h
|
||||||
// KREngine
|
// KREngine
|
||||||
//
|
//
|
||||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
//
|
//
|
||||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
// conditions and the following disclaimer.
|
// conditions and the following disclaimer.
|
||||||
//
|
//
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
// 2. 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
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
// provided with the distribution.
|
// provided with the distribution.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
// 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
|
// 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
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
// The views and conclusions contained in the software and documentation are those of the
|
// The views and conclusions contained in the software and documentation are those of the
|
||||||
// authors and should not be interpreted as representing official policies, either expressed
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef KRAUDIOSAMPLE_H
|
#ifndef KRAUDIOSAMPLE_H
|
||||||
#define KRAUDIOSAMPLE_H
|
#define KRAUDIOSAMPLE_H
|
||||||
|
|
||||||
#include "KREngine-common.h"
|
#include "KREngine-common.h"
|
||||||
#include "KRContextObject.h"
|
#include "KRContextObject.h"
|
||||||
#include "KRDataBlock.h"
|
#include "KRDataBlock.h"
|
||||||
#include "KRResource.h"
|
#include "KRResource.h"
|
||||||
|
|
||||||
class KRAudioBuffer;
|
class KRAudioBuffer;
|
||||||
|
|
||||||
class KRAudioSample : public KRResource {
|
class KRAudioSample : public KRResource {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KRAudioSample(KRContext &context, std::string name, std::string extension);
|
KRAudioSample(KRContext &context, std::string name, std::string extension);
|
||||||
KRAudioSample(KRContext &context, std::string name, std::string extension, KRDataBlock *data);
|
KRAudioSample(KRContext &context, std::string name, std::string extension, KRDataBlock *data);
|
||||||
virtual ~KRAudioSample();
|
virtual ~KRAudioSample();
|
||||||
|
|
||||||
virtual std::string getExtension();
|
virtual std::string getExtension();
|
||||||
|
|
||||||
virtual bool save(KRDataBlock &data);
|
virtual bool save(KRDataBlock &data);
|
||||||
|
|
||||||
float getDuration();
|
float getDuration();
|
||||||
KRAudioBuffer *getBuffer(int index);
|
KRAudioBuffer *getBuffer(int index);
|
||||||
int getBufferCount();
|
int getBufferCount();
|
||||||
|
|
||||||
// Siren audio engine interface
|
// Siren audio engine interface
|
||||||
int getChannelCount();
|
int getChannelCount();
|
||||||
int getFrameCount();
|
__int64_t getFrameCount();
|
||||||
float sample(int frame_offset, int frame_rate, int channel);
|
float sample(int frame_offset, int frame_rate, int channel);
|
||||||
void sample(__int64_t frame_offset, int frame_count, int channel, float *buffer, float amplitude, bool loop);
|
void sample(__int64_t frame_offset, int frame_count, int channel, float *buffer, float amplitude, bool loop);
|
||||||
|
|
||||||
void _endFrame();
|
void _endFrame();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
long m_last_frame_used;
|
__int64_t m_last_frame_used;
|
||||||
|
|
||||||
std::string m_extension;
|
std::string m_extension;
|
||||||
KRDataBlock *m_pData;
|
KRDataBlock *m_pData;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// Apple Audio Toolbox
|
// Apple Audio Toolbox
|
||||||
AudioFileID m_audio_file_id;
|
AudioFileID m_audio_file_id;
|
||||||
ExtAudioFileRef m_fileRef;
|
ExtAudioFileRef m_fileRef;
|
||||||
|
|
||||||
static OSStatus ReadProc( // AudioFile_ReadProc
|
static OSStatus ReadProc( // AudioFile_ReadProc
|
||||||
void * inClientData,
|
void * inClientData,
|
||||||
SInt64 inPosition,
|
SInt64 inPosition,
|
||||||
UInt32 requestCount,
|
UInt32 requestCount,
|
||||||
void * buffer,
|
void * buffer,
|
||||||
UInt32 * actualCount);
|
UInt32 * actualCount);
|
||||||
|
|
||||||
static OSStatus WriteProc( // AudioFile_WriteProc
|
static OSStatus WriteProc( // AudioFile_WriteProc
|
||||||
void * inClientData,
|
void * inClientData,
|
||||||
SInt64 inPosition,
|
SInt64 inPosition,
|
||||||
UInt32 requestCount,
|
UInt32 requestCount,
|
||||||
const void *buffer,
|
const void *buffer,
|
||||||
UInt32 * actualCount);
|
UInt32 * actualCount);
|
||||||
|
|
||||||
static SInt64 GetSizeProc( // AudioFile_GetSizeProc
|
static SInt64 GetSizeProc( // AudioFile_GetSizeProc
|
||||||
void * inClientData);
|
void * inClientData);
|
||||||
|
|
||||||
|
|
||||||
static OSStatus SetSizeProc( // AudioFile_SetSizeProc
|
static OSStatus SetSizeProc( // AudioFile_SetSizeProc
|
||||||
void * inClientData,
|
void * inClientData,
|
||||||
SInt64 inSize);
|
SInt64 inSize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int m_bufferCount;
|
int m_bufferCount;
|
||||||
|
|
||||||
__int64_t m_totalFrames;
|
__int64_t m_totalFrames;
|
||||||
int m_frameRate;
|
int m_frameRate;
|
||||||
int m_bytesPerFrame;
|
int m_bytesPerFrame;
|
||||||
int m_channelsPerFrame;
|
int m_channelsPerFrame;
|
||||||
|
|
||||||
void openFile();
|
void openFile();
|
||||||
void closeFile();
|
void closeFile();
|
||||||
void loadInfo();
|
void loadInfo();
|
||||||
|
|
||||||
static void PopulateBuffer(KRAudioSample *sound, int index, void *data);
|
static void PopulateBuffer(KRAudioSample *sound, int index, void *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(KRAUDIOSAMPLE_H) */
|
#endif /* defined(KRAUDIOSAMPLE_H) */
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ KRBundle::KRBundle(KRContext &context, std::string name, KRDataBlock *pData) : K
|
|||||||
m_pData = pData;
|
m_pData = pData;
|
||||||
|
|
||||||
__int64_t file_pos = 0;
|
__int64_t file_pos = 0;
|
||||||
while(file_pos < m_pData->getSize()) {
|
while(file_pos < (__int64_t)m_pData->getSize()) {
|
||||||
tar_header_type file_header;
|
tar_header_type file_header;
|
||||||
m_pData->copy(&file_header, file_pos, sizeof(file_header));
|
m_pData->copy(&file_header, (int)file_pos, sizeof(file_header));
|
||||||
size_t file_size = strtol(file_header.file_size, NULL, 8);
|
size_t file_size = strtol(file_header.file_size, NULL, 8);
|
||||||
file_pos += 512; // Skip past the header to the file contents
|
file_pos += 512; // Skip past the header to the file contents
|
||||||
if(file_header.file_name[0] != '\0' && file_header.file_name[0] != '.') {
|
if(file_header.file_name[0] != '\0' && file_header.file_name[0] != '.') {
|
||||||
// We ignore the last two records in the tar file, which are zero'ed out tar_header structures
|
// We ignore the last two records in the tar file, which are zero'ed out tar_header structures
|
||||||
KRDataBlock *pFileData = pData->getSubBlock(file_pos, file_size);
|
KRDataBlock *pFileData = pData->getSubBlock((int)file_pos, (int)file_size);
|
||||||
context.loadResource(file_header.file_name, pFileData);
|
context.loadResource(file_header.file_name, pFileData);
|
||||||
}
|
}
|
||||||
file_pos += RoundUpSize(file_size);
|
file_pos += RoundUpSize(file_size);
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
|
|
||||||
//Matrix4 viewMatrix = Matrix4::Invert(getModelMatrix());
|
//Matrix4 viewMatrix = Matrix4::Invert(getModelMatrix());
|
||||||
|
|
||||||
settings.setViewportSize(Vector2::Create(m_backingWidth, m_backingHeight));
|
settings.setViewportSize(Vector2::Create((float)m_backingWidth, (float)m_backingHeight));
|
||||||
Matrix4 projectionMatrix;
|
Matrix4 projectionMatrix;
|
||||||
projectionMatrix.perspective(settings.perspective_fov, settings.m_viewportSize.x / settings.m_viewportSize.y, settings.perspective_nearz, settings.perspective_farz);
|
projectionMatrix.perspective(settings.perspective_fov, settings.m_viewportSize.x / settings.m_viewportSize.y, settings.perspective_nearz, settings.perspective_farz);
|
||||||
m_viewport = KRViewport(settings.getViewportSize(), viewMatrix, projectionMatrix);
|
m_viewport = KRViewport(settings.getViewportSize(), viewMatrix, projectionMatrix);
|
||||||
@@ -132,7 +132,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
GL_PUSH_GROUP_MARKER("Generate Shadowmaps");
|
GL_PUSH_GROUP_MARKER("Generate Shadowmaps");
|
||||||
|
|
||||||
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_GENERATE_SHADOWMAPS, false /*settings.bEnableDeferredLighting*/);
|
scene.render(this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_GENERATE_SHADOWMAPS, false /*settings.bEnableDeferredLighting*/);
|
||||||
GLDEBUG(glViewport(0, 0, m_viewport.getSize().x, m_viewport.getSize().y));
|
GLDEBUG(glViewport(0, 0, (GLsizei)m_viewport.getSize().x, (GLsizei)m_viewport.getSize().y));
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
// Set render target
|
// Set render target
|
||||||
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, lightAccumulationBuffer));
|
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, lightAccumulationBuffer));
|
||||||
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, compositeDepthTexture, 0));
|
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, compositeDepthTexture, 0));
|
||||||
GLDEBUG(glViewport(0, 0, m_viewport.getSize().x * m_downsample.x, m_viewport.getSize().y * m_downsample.y));
|
GLDEBUG(glViewport(0, 0, (GLsizei)(m_viewport.getSize().x * m_downsample.x), (GLsizei)(m_viewport.getSize().y * m_downsample.y)));
|
||||||
GLDEBUG(glClearColor(0.0f, 0.0f, 0.0f, 0.0f));
|
GLDEBUG(glClearColor(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
GLDEBUG(glClear(GL_COLOR_BUFFER_BIT));
|
GLDEBUG(glClear(GL_COLOR_BUFFER_BIT));
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
// Set render target
|
// Set render target
|
||||||
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, compositeFramebuffer));
|
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, compositeFramebuffer));
|
||||||
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, compositeDepthTexture, 0));
|
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, compositeDepthTexture, 0));
|
||||||
GLDEBUG(glViewport(0, 0, m_viewport.getSize().x * m_downsample.x, m_viewport.getSize().y * m_downsample.y));
|
GLDEBUG(glViewport(0, 0, (GLsizei)(m_viewport.getSize().x * m_downsample.x), (GLsizei)(m_viewport.getSize().y * m_downsample.y)));
|
||||||
|
|
||||||
// Disable alpha blending
|
// Disable alpha blending
|
||||||
GLDEBUG(glDisable(GL_BLEND));
|
GLDEBUG(glDisable(GL_BLEND));
|
||||||
@@ -419,7 +419,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
|
|
||||||
GL_PUSH_GROUP_MARKER("Volumetric Lighting");
|
GL_PUSH_GROUP_MARKER("Volumetric Lighting");
|
||||||
|
|
||||||
KRViewport volumetricLightingViewport = KRViewport(Vector2::Create(volumetricBufferWidth, volumetricBufferHeight), m_viewport.getViewMatrix(), m_viewport.getProjectionMatrix());
|
KRViewport volumetricLightingViewport = KRViewport(Vector2::Create((float)volumetricBufferWidth, (float)volumetricBufferHeight), m_viewport.getViewMatrix(), m_viewport.getProjectionMatrix());
|
||||||
|
|
||||||
if(settings.volumetric_environment_downsample != 0) {
|
if(settings.volumetric_environment_downsample != 0) {
|
||||||
// Set render target
|
// Set render target
|
||||||
@@ -431,7 +431,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||||
m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 0, compositeDepthTexture);
|
m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 0, compositeDepthTexture);
|
||||||
|
|
||||||
GLDEBUG(glViewport(0, 0, volumetricLightingViewport.getSize().x, volumetricLightingViewport.getSize().y));
|
GLDEBUG(glViewport(0, 0, (GLsizei)volumetricLightingViewport.getSize().x, (GLsizei)volumetricLightingViewport.getSize().y));
|
||||||
} else {
|
} else {
|
||||||
// Enable z-buffer test
|
// Enable z-buffer test
|
||||||
GLDEBUG(glEnable(GL_DEPTH_TEST));
|
GLDEBUG(glEnable(GL_DEPTH_TEST));
|
||||||
@@ -446,7 +446,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
|
|||||||
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, compositeFramebuffer));
|
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, compositeFramebuffer));
|
||||||
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, compositeDepthTexture, 0));
|
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, compositeDepthTexture, 0));
|
||||||
|
|
||||||
GLDEBUG(glViewport(0, 0, m_viewport.getSize().x, m_viewport.getSize().y));
|
GLDEBUG(glViewport(0, 0, (GLsizei)m_viewport.getSize().x, (GLsizei)m_viewport.getSize().y));
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_POP_GROUP_MARKER;
|
GL_POP_GROUP_MARKER;
|
||||||
@@ -690,7 +690,7 @@ void KRCamera::renderPost()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
GLDEBUG(glViewport(0, 0, m_viewport.getSize().x, m_viewport.getSize().y));
|
GLDEBUG(glViewport(0, 0, (GLsizei)m_viewport.getSize().x, (GLsizei)m_viewport.getSize().y));
|
||||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||||
KRShader *postShader = m_pContext->getShaderManager()->getShader("PostShader", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
KRShader *postShader = m_pContext->getShaderManager()->getShader("PostShader", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
|
|
||||||
@@ -809,7 +809,7 @@ void KRCamera::renderPost()
|
|||||||
int iTexRow = 15 - (iChar - iTexCol) / 16;
|
int iTexRow = 15 - (iChar - iTexCol) / 16;
|
||||||
|
|
||||||
Vector2 top_left_pos = Vector2::Create(-1.0f + dScaleX * iCol, dScaleY * iRow - 1.0f);
|
Vector2 top_left_pos = Vector2::Create(-1.0f + dScaleX * iCol, dScaleY * iRow - 1.0f);
|
||||||
Vector2 bottom_right_pos = Vector2::Create(-1.0 + dScaleX * (iCol + 1), dScaleY * iRow + dScaleY - 1.0f);
|
Vector2 bottom_right_pos = Vector2::Create(-1.0f + dScaleX * (iCol + 1), dScaleY * iRow + dScaleY - 1.0f);
|
||||||
top_left_pos += Vector2::Create(1.0f / 2048.0f * 0.5f, 1.0f / 1536.0f * 0.5f);
|
top_left_pos += Vector2::Create(1.0f / 2048.0f * 0.5f, 1.0f / 1536.0f * 0.5f);
|
||||||
bottom_right_pos += Vector2::Create(1.0f / 2048.0f * 0.5f, 1.0f / 1536.0f * 0.5f);
|
bottom_right_pos += Vector2::Create(1.0f / 2048.0f * 0.5f, 1.0f / 1536.0f * 0.5f);
|
||||||
Vector2 top_left_uv = Vector2::Create(dTexScale * iTexCol, dTexScale * iTexRow);
|
Vector2 top_left_uv = Vector2::Create(dTexScale * iTexCol, dTexScale * iTexRow);
|
||||||
@@ -967,13 +967,13 @@ std::string KRCamera::getDebugText()
|
|||||||
#endif // defined(__APPLE__)
|
#endif // defined(__APPLE__)
|
||||||
|
|
||||||
// ---- GPU Memory ----
|
// ---- GPU Memory ----
|
||||||
int texture_count_active = m_pContext->getTextureManager()->getActiveTextures().size();
|
size_t texture_count_active = m_pContext->getTextureManager()->getActiveTextures().size();
|
||||||
int texture_count = texture_count_active;
|
size_t texture_count = texture_count_active;
|
||||||
long texture_mem_active = m_pContext->getTextureManager()->getMemActive();
|
long texture_mem_active = m_pContext->getTextureManager()->getMemActive();
|
||||||
long texture_mem_used = m_pContext->getTextureManager()->getMemUsed();
|
long texture_mem_used = m_pContext->getTextureManager()->getMemUsed();
|
||||||
long texture_mem_throughput = m_pContext->getTextureManager()->getMemoryTransferedThisFrame();
|
long texture_mem_throughput = m_pContext->getTextureManager()->getMemoryTransferedThisFrame();
|
||||||
|
|
||||||
int vbo_count_active = m_pContext->getMeshManager()->getActiveVBOCount();
|
size_t vbo_count_active = m_pContext->getMeshManager()->getActiveVBOCount();
|
||||||
long vbo_mem_active = m_pContext->getMeshManager()->getMemActive();
|
long vbo_mem_active = m_pContext->getMeshManager()->getMemActive();
|
||||||
long vbo_mem_used = m_pContext->getMeshManager()->getMemUsed();
|
long vbo_mem_used = m_pContext->getMeshManager()->getMemUsed();
|
||||||
long vbo_mem_throughput = m_pContext->getMeshManager()->getMemoryTransferedThisFrame();
|
long vbo_mem_throughput = m_pContext->getMeshManager()->getMemoryTransferedThisFrame();
|
||||||
|
|||||||
@@ -81,13 +81,13 @@ void FFTForward(const FFTWorkspace &workspace, SplitComplex *src, size_t count)
|
|||||||
assert((count & (count - 1)) == 0);
|
assert((count & (count - 1)) == 0);
|
||||||
|
|
||||||
unsigned int levels = 0;
|
unsigned int levels = 0;
|
||||||
while (1 << levels <= count) {
|
while (1 << levels <= (int)count) {
|
||||||
levels++;
|
levels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
for (int k = 0; k < levels; k++) {
|
for (int k = 0; k < (int)levels; k++) {
|
||||||
j <<= 1;
|
j <<= 1;
|
||||||
j |= ((i >> k) & 1);
|
j |= ((i >> k) & 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ bool KRDataBlock::load(const std::string &path)
|
|||||||
bool success = false;
|
bool success = false;
|
||||||
unload();
|
unload();
|
||||||
|
|
||||||
struct stat statbuf;
|
|
||||||
m_bReadOnly = true;
|
m_bReadOnly = true;
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
@@ -160,6 +159,7 @@ bool KRDataBlock::load(const std::string &path)
|
|||||||
if(m_fdPackFile >= 0) {
|
if(m_fdPackFile >= 0) {
|
||||||
m_fileOwnerDataBlock = this;
|
m_fileOwnerDataBlock = this;
|
||||||
m_fileName = KRResource::GetFileBase(path);
|
m_fileName = KRResource::GetFileBase(path);
|
||||||
|
struct stat statbuf;
|
||||||
if(fstat(m_fdPackFile, &statbuf) >= 0) {
|
if(fstat(m_fdPackFile, &statbuf) >= 0) {
|
||||||
m_data_size = statbuf.st_size;
|
m_data_size = statbuf.st_size;
|
||||||
m_data_offset = 0;
|
m_data_offset = 0;
|
||||||
@@ -269,7 +269,7 @@ void KRDataBlock::append(void *data, size_t size) {
|
|||||||
|
|
||||||
// Copy the entire data block to the destination pointer
|
// Copy the entire data block to the destination pointer
|
||||||
void KRDataBlock::copy(void *dest) {
|
void KRDataBlock::copy(void *dest) {
|
||||||
copy(dest, 0, m_data_size);
|
copy(dest, 0, (int)m_data_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy a range of data to the destination pointer
|
// Copy a range of data to the destination pointer
|
||||||
|
|||||||
@@ -121,12 +121,12 @@ KRNode::LodVisibility KRLODGroup::calcLODVisibility(const KRViewport &viewport)
|
|||||||
if(m_use_world_units) {
|
if(m_use_world_units) {
|
||||||
Vector3 world_reference_point = localToWorld(local_reference_point);
|
Vector3 world_reference_point = localToWorld(local_reference_point);
|
||||||
sqr_distance = (world_camera_position - world_reference_point).sqrMagnitude() * (lod_bias * lod_bias);
|
sqr_distance = (world_camera_position - world_reference_point).sqrMagnitude() * (lod_bias * lod_bias);
|
||||||
sqr_prestream_distance = getContext().KRENGINE_PRESTREAM_DISTANCE * getContext().KRENGINE_PRESTREAM_DISTANCE;
|
sqr_prestream_distance = (float)(getContext().KRENGINE_PRESTREAM_DISTANCE * getContext().KRENGINE_PRESTREAM_DISTANCE);
|
||||||
} else {
|
} else {
|
||||||
sqr_distance = (local_camera_position - local_reference_point).sqrMagnitude() * (lod_bias * lod_bias);
|
sqr_distance = (local_camera_position - local_reference_point).sqrMagnitude() * (lod_bias * lod_bias);
|
||||||
|
|
||||||
Vector3 world_reference_point = localToWorld(local_reference_point);
|
Vector3 world_reference_point = localToWorld(local_reference_point);
|
||||||
sqr_prestream_distance = worldToLocal(Vector3::Normalize(world_reference_point - world_camera_position) * getContext().KRENGINE_PRESTREAM_DISTANCE).sqrMagnitude(); // TODO, FINDME - Optimize with precalc?
|
sqr_prestream_distance = worldToLocal(Vector3::Normalize(world_reference_point - world_camera_position) * (float)getContext().KRENGINE_PRESTREAM_DISTANCE).sqrMagnitude(); // TODO, FINDME - Optimize with precalc?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ void KRLight::allocateShadowBuffers(int cBuffers) {
|
|||||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_EXT, GL_COMPARE_REF_TO_TEXTURE_EXT)); // TODO - Detect GL_EXT_shadow_samplers and only activate if available
|
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_EXT, GL_COMPARE_REF_TO_TEXTURE_EXT)); // TODO - Detect GL_EXT_shadow_samplers and only activate if available
|
||||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_EXT, GL_LEQUAL)); // TODO - Detect GL_EXT_shadow_samplers and only activate if available
|
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_EXT, GL_LEQUAL)); // TODO - Detect GL_EXT_shadow_samplers and only activate if available
|
||||||
#endif
|
#endif
|
||||||
GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, viewportSize.x, viewportSize.y, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL));
|
GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, (GLsizei)viewportSize.x, (GLsizei)viewportSize.y, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL));
|
||||||
|
|
||||||
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, shadowDepthTexture[iShadow], 0));
|
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, shadowDepthTexture[iShadow], 0));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ bool KRMaterial::bind(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
|
|||||||
bool bAlphaTest = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_TEST) && bDiffuseMap;
|
bool bAlphaTest = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_TEST) && bDiffuseMap;
|
||||||
bool bAlphaBlend = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE) || (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
bool bAlphaBlend = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE) || (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
||||||
|
|
||||||
KRShader *pShader = getContext().getShaderManager()->getShader("ObjectShader", pCamera, point_lights, directional_lights, spot_lights, bones.size(), bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, m_diffuseMapScale != default_scale && bDiffuseMap, m_specularMapScale != default_scale && bSpecMap, m_normalMapScale != default_scale && bNormalMap, m_reflectionMapScale != default_scale && bReflectionMap, m_diffuseMapOffset != default_offset && bDiffuseMap, m_specularMapOffset != default_offset && bSpecMap, m_normalMapOffset != default_offset && bNormalMap, m_reflectionMapOffset != default_offset && bReflectionMap, bAlphaTest, bAlphaBlend, renderPass, rim_power != 0.0f);
|
KRShader *pShader = getContext().getShaderManager()->getShader("ObjectShader", pCamera, point_lights, directional_lights, spot_lights, (int)bones.size(), bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, m_diffuseMapScale != default_scale && bDiffuseMap, m_specularMapScale != default_scale && bSpecMap, m_normalMapScale != default_scale && bNormalMap, m_reflectionMapScale != default_scale && bReflectionMap, m_diffuseMapOffset != default_offset && bDiffuseMap, m_specularMapOffset != default_offset && bSpecMap, m_normalMapOffset != default_offset && bNormalMap, m_reflectionMapOffset != default_offset && bReflectionMap, bAlphaTest, bAlphaBlend, renderPass, rim_power != 0.0f);
|
||||||
|
|
||||||
|
|
||||||
Vector4 fade_color;
|
Vector4 fade_color;
|
||||||
@@ -356,7 +356,7 @@ bool KRMaterial::bind(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_BONE_TRANSFORMS] != -1) {
|
if(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_BONE_TRANSFORMS] != -1) {
|
||||||
glUniformMatrix4fv(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_BONE_TRANSFORMS], bones.size(), GL_FALSE, bone_mats);
|
glUniformMatrix4fv(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_BONE_TRANSFORMS], (GLsizei)bones.size(), GL_FALSE, bone_mats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ KRMeshCube::KRMeshCube(KRContext &context) : KRMesh(context, "__cube")
|
|||||||
|
|
||||||
|
|
||||||
mi.submesh_starts.push_back(0);
|
mi.submesh_starts.push_back(0);
|
||||||
mi.submesh_lengths.push_back(mi.vertices.size());
|
mi.submesh_lengths.push_back((int)mi.vertices.size());
|
||||||
mi.material_names.push_back("");
|
mi.material_names.push_back("");
|
||||||
mi.format = KRENGINE_MODEL_FORMAT_STRIP;
|
mi.format = KRENGINE_MODEL_FORMAT_STRIP;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ KRMeshQuad::KRMeshQuad(KRContext &context) : KRMesh(context, "__quad")
|
|||||||
|
|
||||||
|
|
||||||
mi.submesh_starts.push_back(0);
|
mi.submesh_starts.push_back(0);
|
||||||
mi.submesh_lengths.push_back(mi.vertices.size());
|
mi.submesh_lengths.push_back((int)mi.vertices.size());
|
||||||
mi.material_names.push_back("");
|
mi.material_names.push_back("");
|
||||||
mi.format = KRENGINE_MODEL_FORMAT_STRIP;
|
mi.format = KRENGINE_MODEL_FORMAT_STRIP;
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ KRMeshSphere::KRMeshSphere(KRContext &context) : KRMesh(context, "__sphere")
|
|||||||
// Based on algorithm from Paul Bourke: http://paulbourke.net/miscellaneous/sphere_cylinder/
|
// Based on algorithm from Paul Bourke: http://paulbourke.net/miscellaneous/sphere_cylinder/
|
||||||
|
|
||||||
int iterations = 3;
|
int iterations = 3;
|
||||||
int facet_count = pow(4, iterations) * 8;
|
int facet_count = (int)(pow(4, iterations) * 8.0f);
|
||||||
|
|
||||||
class Facet3 {
|
class Facet3 {
|
||||||
public:
|
public:
|
||||||
@@ -74,7 +74,7 @@ KRMeshSphere::KRMeshSphere(KRContext &context) : KRMesh(context, "__sphere")
|
|||||||
int nt = 0,ntold;
|
int nt = 0,ntold;
|
||||||
|
|
||||||
/* Create the level 0 object */
|
/* Create the level 0 object */
|
||||||
a = 1 / sqrt(2.0);
|
a = 1.0f / sqrtf(2.0f);
|
||||||
for (i=0;i<6;i++) {
|
for (i=0;i<6;i++) {
|
||||||
p[i].x *= a;
|
p[i].x *= a;
|
||||||
p[i].y *= a;
|
p[i].y *= a;
|
||||||
@@ -121,7 +121,7 @@ KRMeshSphere::KRMeshSphere(KRContext &context) : KRMesh(context, "__sphere")
|
|||||||
}
|
}
|
||||||
|
|
||||||
mi.submesh_starts.push_back(0);
|
mi.submesh_starts.push_back(0);
|
||||||
mi.submesh_lengths.push_back(mi.vertices.size());
|
mi.submesh_lengths.push_back((int)mi.vertices.size());
|
||||||
mi.material_names.push_back("");
|
mi.material_names.push_back("");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void KRParticleSystemNewtonian::render(KRCamera *pCamera, std::vector<KRPointLig
|
|||||||
|
|
||||||
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
|
||||||
Vector3 rim_color; Vector4 fade_color;
|
// Vector3 rim_color; Vector4 fade_color;
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
|
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
|
||||||
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f);
|
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f);
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ void KRPointLight::generateMesh() {
|
|||||||
// Based on algorithm from Paul Bourke: http://paulbourke.net/miscellaneous/sphere_cylinder/
|
// Based on algorithm from Paul Bourke: http://paulbourke.net/miscellaneous/sphere_cylinder/
|
||||||
|
|
||||||
int iterations = 3;
|
int iterations = 3;
|
||||||
int facet_count = pow(4, iterations) * 8;
|
int facet_count = (int)(pow(4, iterations) * 8);
|
||||||
|
|
||||||
if(m_cVertices != facet_count * 3) {
|
if(m_cVertices != facet_count * 3) {
|
||||||
if(m_sphereVertices) {
|
if(m_sphereVertices) {
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ std::vector<KRResource *> KRResource::LoadObj(KRContext &context, const std::str
|
|||||||
} else if(strcmp(szSymbol[0], "usemtl") == 0) {
|
} else if(strcmp(szSymbol[0], "usemtl") == 0) {
|
||||||
// Use Material (usemtl)
|
// Use Material (usemtl)
|
||||||
if(pFace - pMaterialFaces > 1) {
|
if(pFace - pMaterialFaces > 1) {
|
||||||
*pMaterialFaces = pFace - pMaterialFaces - 1;
|
*pMaterialFaces = (int)(pFace - pMaterialFaces - 1);
|
||||||
pMaterialFaces = pFace++;
|
pMaterialFaces = pFace++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ std::vector<KRResource *> KRResource::LoadObj(KRContext &context, const std::str
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
*pMaterialFaces = pFace - pMaterialFaces - 1;
|
*pMaterialFaces = (int)(pFace - pMaterialFaces - 1);
|
||||||
*pFace++ = 0;
|
*pFace++ = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ void KRShader::setUniform(int location, float value)
|
|||||||
int value_index = m_uniform_value_index[location];
|
int value_index = m_uniform_value_index[location];
|
||||||
bool needs_update = true;
|
bool needs_update = true;
|
||||||
if(value_index == -1) {
|
if(value_index == -1) {
|
||||||
m_uniform_value_index[location] = m_uniform_value_float.size();
|
m_uniform_value_index[location] = (int)m_uniform_value_float.size();
|
||||||
m_uniform_value_float.push_back(value);
|
m_uniform_value_float.push_back(value);
|
||||||
} else if(m_uniform_value_float[value_index] == value) {
|
} else if(m_uniform_value_float[value_index] == value) {
|
||||||
needs_update = false;
|
needs_update = false;
|
||||||
@@ -264,7 +264,7 @@ void KRShader::setUniform(int location, int value)
|
|||||||
int value_index = m_uniform_value_index[location];
|
int value_index = m_uniform_value_index[location];
|
||||||
bool needs_update = true;
|
bool needs_update = true;
|
||||||
if(value_index == -1) {
|
if(value_index == -1) {
|
||||||
m_uniform_value_index[location] = m_uniform_value_int.size();
|
m_uniform_value_index[location] = (int)m_uniform_value_int.size();
|
||||||
m_uniform_value_int.push_back(value);
|
m_uniform_value_int.push_back(value);
|
||||||
} else if(m_uniform_value_int[value_index] == value) {
|
} else if(m_uniform_value_int[value_index] == value) {
|
||||||
needs_update = false;
|
needs_update = false;
|
||||||
@@ -283,7 +283,7 @@ void KRShader::setUniform(int location, const Vector2 &value)
|
|||||||
int value_index = m_uniform_value_index[location];
|
int value_index = m_uniform_value_index[location];
|
||||||
bool needs_update = true;
|
bool needs_update = true;
|
||||||
if(value_index == -1) {
|
if(value_index == -1) {
|
||||||
m_uniform_value_index[location] = m_uniform_value_vector2.size();
|
m_uniform_value_index[location] = (int)m_uniform_value_vector2.size();
|
||||||
m_uniform_value_vector2.push_back(value);
|
m_uniform_value_vector2.push_back(value);
|
||||||
} else if(m_uniform_value_vector2[value_index] == value) {
|
} else if(m_uniform_value_vector2[value_index] == value) {
|
||||||
needs_update = false;
|
needs_update = false;
|
||||||
@@ -301,7 +301,7 @@ void KRShader::setUniform(int location, const Vector3 &value)
|
|||||||
int value_index = m_uniform_value_index[location];
|
int value_index = m_uniform_value_index[location];
|
||||||
bool needs_update = true;
|
bool needs_update = true;
|
||||||
if(value_index == -1) {
|
if(value_index == -1) {
|
||||||
m_uniform_value_index[location] = m_uniform_value_vector3.size();
|
m_uniform_value_index[location] = (int)m_uniform_value_vector3.size();
|
||||||
m_uniform_value_vector3.push_back(value);
|
m_uniform_value_vector3.push_back(value);
|
||||||
} else if(m_uniform_value_vector3[value_index] == value) {
|
} else if(m_uniform_value_vector3[value_index] == value) {
|
||||||
needs_update = false;
|
needs_update = false;
|
||||||
@@ -319,7 +319,7 @@ void KRShader::setUniform(int location, const Vector4 &value)
|
|||||||
int value_index = m_uniform_value_index[location];
|
int value_index = m_uniform_value_index[location];
|
||||||
bool needs_update = true;
|
bool needs_update = true;
|
||||||
if(value_index == -1) {
|
if(value_index == -1) {
|
||||||
m_uniform_value_index[location] = m_uniform_value_vector4.size();
|
m_uniform_value_index[location] = (int)m_uniform_value_vector4.size();
|
||||||
m_uniform_value_vector4.push_back(value);
|
m_uniform_value_vector4.push_back(value);
|
||||||
} else if(m_uniform_value_vector4[value_index] == value) {
|
} else if(m_uniform_value_vector4[value_index] == value) {
|
||||||
needs_update = false;
|
needs_update = false;
|
||||||
@@ -338,7 +338,7 @@ void KRShader::setUniform(int location, const Matrix4 &value)
|
|||||||
int value_index = m_uniform_value_index[location];
|
int value_index = m_uniform_value_index[location];
|
||||||
bool needs_update = true;
|
bool needs_update = true;
|
||||||
if(value_index == -1) {
|
if(value_index == -1) {
|
||||||
m_uniform_value_index[location] = m_uniform_value_mat4.size();
|
m_uniform_value_index[location] = (int)m_uniform_value_mat4.size();
|
||||||
m_uniform_value_mat4.push_back(value);
|
m_uniform_value_mat4.push_back(value);
|
||||||
} else if(m_uniform_value_mat4[value_index] == value) {
|
} else if(m_uniform_value_mat4[value_index] == value) {
|
||||||
needs_update = false;
|
needs_update = false;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ void KRTexture::resize(int max_dim)
|
|||||||
m_iNewHandle = 0;
|
m_iNewHandle = 0;
|
||||||
} else {
|
} else {
|
||||||
int target_dim = max_dim;
|
int target_dim = max_dim;
|
||||||
if(target_dim < m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
if(target_dim < (int)m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
||||||
|
|
||||||
if(m_new_lod_max_dim != target_dim || (m_iHandle == 0 && m_iNewHandle == 0)) {
|
if(m_new_lod_max_dim != target_dim || (m_iHandle == 0 && m_iNewHandle == 0)) {
|
||||||
assert(m_newTextureMemUsed == 0);
|
assert(m_newTextureMemUsed == 0);
|
||||||
@@ -116,9 +116,9 @@ kraken_stream_level KRTexture::getStreamLevel(KRTexture::texture_usage_t texture
|
|||||||
{
|
{
|
||||||
if(m_current_lod_max_dim == 0) {
|
if(m_current_lod_max_dim == 0) {
|
||||||
return kraken_stream_level::STREAM_LEVEL_OUT;
|
return kraken_stream_level::STREAM_LEVEL_OUT;
|
||||||
} else if(m_current_lod_max_dim == KRMIN(getContext().KRENGINE_MAX_TEXTURE_DIM, m_max_lod_max_dim)) {
|
} else if(m_current_lod_max_dim == KRMIN(getContext().KRENGINE_MAX_TEXTURE_DIM, (int)m_max_lod_max_dim)) {
|
||||||
return kraken_stream_level::STREAM_LEVEL_IN_HQ;
|
return kraken_stream_level::STREAM_LEVEL_IN_HQ;
|
||||||
} else if(m_current_lod_max_dim >= KRMAX(getContext().KRENGINE_MIN_TEXTURE_DIM, m_min_lod_max_dim)) {
|
} else if(m_current_lod_max_dim >= KRMAX(getContext().KRENGINE_MIN_TEXTURE_DIM, (int)m_min_lod_max_dim)) {
|
||||||
return kraken_stream_level::STREAM_LEVEL_IN_LQ;
|
return kraken_stream_level::STREAM_LEVEL_IN_LQ;
|
||||||
} else {
|
} else {
|
||||||
return kraken_stream_level::STREAM_LEVEL_OUT;
|
return kraken_stream_level::STREAM_LEVEL_OUT;
|
||||||
|
|||||||
@@ -43,13 +43,13 @@ KRTextureAnimated::KRTextureAnimated(KRContext &context, std::string name) : KRT
|
|||||||
// - yy is the framerate
|
// - yy is the framerate
|
||||||
|
|
||||||
// TODO - Add error handling for mal-formatted animated texture formats
|
// TODO - Add error handling for mal-formatted animated texture formats
|
||||||
int first_comma_pos = name.find(",");
|
size_t first_comma_pos = name.find(",");
|
||||||
int second_comma_pos = name.find(",", first_comma_pos + 1);
|
size_t second_comma_pos = name.find(",", first_comma_pos + 1);
|
||||||
|
|
||||||
|
|
||||||
m_texture_base_name = name.substr(8, first_comma_pos - 8);
|
m_texture_base_name = name.substr(8, first_comma_pos - 8);
|
||||||
m_frame_count = atoi(name.substr(first_comma_pos+1, second_comma_pos - first_comma_pos -1).c_str());
|
m_frame_count = atoi(name.substr(first_comma_pos+1, second_comma_pos - first_comma_pos -1).c_str());
|
||||||
m_frame_rate = atof(name.substr(second_comma_pos+1).c_str());
|
m_frame_rate = (float)atof(name.substr(second_comma_pos+1).c_str());
|
||||||
|
|
||||||
m_max_lod_max_dim = 2048;
|
m_max_lod_max_dim = 2048;
|
||||||
m_min_lod_max_dim = 64;
|
m_min_lod_max_dim = 64;
|
||||||
@@ -57,8 +57,8 @@ KRTextureAnimated::KRTextureAnimated(KRContext &context, std::string name) : KRT
|
|||||||
for(int i=0; i<m_frame_count; i++) {
|
for(int i=0; i<m_frame_count; i++) {
|
||||||
KRTexture2D *frame_texture = textureForFrame(i);
|
KRTexture2D *frame_texture = textureForFrame(i);
|
||||||
if(frame_texture) {
|
if(frame_texture) {
|
||||||
if(frame_texture->getMaxMipMap() < m_max_lod_max_dim) m_max_lod_max_dim = frame_texture->getMaxMipMap();
|
if(frame_texture->getMaxMipMap() < (int)m_max_lod_max_dim) m_max_lod_max_dim = frame_texture->getMaxMipMap();
|
||||||
if(frame_texture->getMinMipMap() > m_min_lod_max_dim) m_min_lod_max_dim = frame_texture->getMinMipMap();
|
if(frame_texture->getMinMipMap() > (int)m_min_lod_max_dim) m_min_lod_max_dim = frame_texture->getMinMipMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ void KRTextureAnimated::bind(GLuint texture_unit)
|
|||||||
{
|
{
|
||||||
resetPoolExpiry(0.0f, TEXTURE_USAGE_NONE); // TODO - Need to set parameters here for streaming priority?
|
resetPoolExpiry(0.0f, TEXTURE_USAGE_NONE); // TODO - Need to set parameters here for streaming priority?
|
||||||
KRTexture::bind(texture_unit);
|
KRTexture::bind(texture_unit);
|
||||||
int frame_number = (int)floor(fmodf(getContext().getAbsoluteTime() * m_frame_rate,m_frame_count));
|
int frame_number = (int)floor(fmodf(getContext().getAbsoluteTime() * m_frame_rate, (float)m_frame_count));
|
||||||
KRTexture2D *frame_texture = textureForFrame(frame_number);
|
KRTexture2D *frame_texture = textureForFrame(frame_number);
|
||||||
if(frame_texture) {
|
if(frame_texture) {
|
||||||
frame_texture->bind(texture_unit);
|
frame_texture->bind(texture_unit);
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ KRTextureCube::KRTextureCube(KRContext &context, std::string name) : KRTexture(c
|
|||||||
std::string faceName = getName() + SUFFIXES[i];
|
std::string faceName = getName() + SUFFIXES[i];
|
||||||
m_textures[i] = (KRTexture2D *)getContext().getTextureManager()->getTexture(faceName);
|
m_textures[i] = (KRTexture2D *)getContext().getTextureManager()->getTexture(faceName);
|
||||||
if(m_textures[i]) {
|
if(m_textures[i]) {
|
||||||
if(m_textures[i]->getMaxMipMap() < m_max_lod_max_dim) m_max_lod_max_dim = m_textures[i]->getMaxMipMap();
|
if(m_textures[i]->getMaxMipMap() < (int)m_max_lod_max_dim) m_max_lod_max_dim = m_textures[i]->getMaxMipMap();
|
||||||
if(m_textures[i]->getMinMipMap() > m_min_lod_max_dim) m_min_lod_max_dim = m_textures[i]->getMinMipMap();
|
if(m_textures[i]->getMinMipMap() > (int)m_min_lod_max_dim) m_min_lod_max_dim = m_textures[i]->getMinMipMap();
|
||||||
} else {
|
} else {
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ bool KRTextureCube::createGLTexture(int lod_max_dim)
|
|||||||
long KRTextureCube::getMemRequiredForSize(int max_dim)
|
long KRTextureCube::getMemRequiredForSize(int max_dim)
|
||||||
{
|
{
|
||||||
int target_dim = max_dim;
|
int target_dim = max_dim;
|
||||||
if(target_dim < m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
if(target_dim < (int)m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
||||||
|
|
||||||
long memoryRequired = 0;
|
long memoryRequired = 0;
|
||||||
for(int i=0; i<6; i++) {
|
for(int i=0; i<6; i++) {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ KRTextureKTX::KRTextureKTX(KRContext &context, KRDataBlock *data, std::string na
|
|||||||
uint32_t blockStart = sizeof(KTXHeader) + m_header.bytesOfKeyValueData;
|
uint32_t blockStart = sizeof(KTXHeader) + m_header.bytesOfKeyValueData;
|
||||||
uint32_t width = m_header.pixelWidth, height = m_header.pixelHeight;
|
uint32_t width = m_header.pixelWidth, height = m_header.pixelHeight;
|
||||||
|
|
||||||
for(int mipmap_level=0; mipmap_level < KRMAX(m_header.numberOfMipmapLevels, 1); mipmap_level++) {
|
for(int mipmap_level=0; mipmap_level < (int)KRMAX(m_header.numberOfMipmapLevels, 1); mipmap_level++) {
|
||||||
uint32_t blockLength;
|
uint32_t blockLength;
|
||||||
data->copy(&blockLength, blockStart, 4);
|
data->copy(&blockLength, blockStart, 4);
|
||||||
blockStart += 4;
|
blockStart += 4;
|
||||||
@@ -126,7 +126,7 @@ KRTextureKTX::~KRTextureKTX() {
|
|||||||
long KRTextureKTX::getMemRequiredForSize(int max_dim)
|
long KRTextureKTX::getMemRequiredForSize(int max_dim)
|
||||||
{
|
{
|
||||||
int target_dim = max_dim;
|
int target_dim = max_dim;
|
||||||
if(target_dim < m_min_lod_max_dim) target_dim = target_dim;
|
if(target_dim < (int)m_min_lod_max_dim) target_dim = target_dim;
|
||||||
|
|
||||||
// Determine how much memory will be consumed
|
// Determine how much memory will be consumed
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ long KRTextureKTX::getMemRequiredForSize(int max_dim)
|
|||||||
for(std::list<KRDataBlock *>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
for(std::list<KRDataBlock *>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
||||||
KRDataBlock *block = *itr;
|
KRDataBlock *block = *itr;
|
||||||
if(width <= target_dim && height <= target_dim) {
|
if(width <= target_dim && height <= target_dim) {
|
||||||
memoryRequired += block->getSize();
|
memoryRequired += (long)block->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
width = width >> 1;
|
width = width >> 1;
|
||||||
@@ -156,7 +156,7 @@ long KRTextureKTX::getMemRequiredForSize(int max_dim)
|
|||||||
bool KRTextureKTX::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress, bool premultiply_alpha)
|
bool KRTextureKTX::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress, bool premultiply_alpha)
|
||||||
{
|
{
|
||||||
int target_dim = lod_max_dim;
|
int target_dim = lod_max_dim;
|
||||||
if(target_dim < m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
if(target_dim < (int)m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
||||||
|
|
||||||
if(m_blocks.size() == 0) {
|
if(m_blocks.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -239,9 +239,9 @@ bool KRTextureKTX::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
|||||||
GLDEBUG(glCompressedTexImage2D(target, destination_level, (GLenum)m_header.glInternalFormat, width, height, 0, (GLsizei)block->getSize(), block->getStart()));
|
GLDEBUG(glCompressedTexImage2D(target, destination_level, (GLenum)m_header.glInternalFormat, width, height, 0, (GLsizei)block->getSize(), block->getStart()));
|
||||||
#endif
|
#endif
|
||||||
block->unlock();
|
block->unlock();
|
||||||
memoryTransferred += block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE
|
memoryTransferred += (long)block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE
|
||||||
#endif
|
#endif
|
||||||
memoryRequired += block->getSize();
|
memoryRequired += (long)block->getSize();
|
||||||
//
|
//
|
||||||
// err = glGetError();
|
// err = glGetError();
|
||||||
// if (err != GL_NO_ERROR) {
|
// if (err != GL_NO_ERROR) {
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ KRTexturePVR::~KRTexturePVR() {
|
|||||||
long KRTexturePVR::getMemRequiredForSize(int max_dim)
|
long KRTexturePVR::getMemRequiredForSize(int max_dim)
|
||||||
{
|
{
|
||||||
int target_dim = max_dim;
|
int target_dim = max_dim;
|
||||||
if(target_dim < m_min_lod_max_dim) target_dim = target_dim;
|
if(target_dim < (int)m_min_lod_max_dim) target_dim = target_dim;
|
||||||
|
|
||||||
// Determine how much memory will be consumed
|
// Determine how much memory will be consumed
|
||||||
int width = m_iWidth;
|
int width = m_iWidth;
|
||||||
@@ -157,7 +157,7 @@ long KRTexturePVR::getMemRequiredForSize(int max_dim)
|
|||||||
for(std::list<KRDataBlock *>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
for(std::list<KRDataBlock *>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
||||||
KRDataBlock *block = *itr;
|
KRDataBlock *block = *itr;
|
||||||
if(width <= target_dim && height <= target_dim) {
|
if(width <= target_dim && height <= target_dim) {
|
||||||
memoryRequired += block->getSize();
|
memoryRequired += (long)block->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
width = width >> 1;
|
width = width >> 1;
|
||||||
@@ -176,7 +176,7 @@ long KRTexturePVR::getMemRequiredForSize(int max_dim)
|
|||||||
bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress, bool premultiply_alpha)
|
bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress, bool premultiply_alpha)
|
||||||
{
|
{
|
||||||
int target_dim = lod_max_dim;
|
int target_dim = lod_max_dim;
|
||||||
if(target_dim < m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
if(target_dim < (int)m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
||||||
|
|
||||||
if(m_blocks.size() == 0) {
|
if(m_blocks.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -256,12 +256,12 @@ bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
|||||||
#if GL_EXT_texture_storage
|
#if GL_EXT_texture_storage
|
||||||
GLDEBUG(glCompressedTexSubImage2D(target, destination_level, 0, 0, width, height, m_internalFormat, block->getSize(), block->getStart()));
|
GLDEBUG(glCompressedTexSubImage2D(target, destination_level, 0, 0, width, height, m_internalFormat, block->getSize(), block->getStart()));
|
||||||
#else
|
#else
|
||||||
GLDEBUG(glCompressedTexImage2D(target, destination_level, m_internalFormat, width, height, 0, block->getSize(), block->getStart()));
|
GLDEBUG(glCompressedTexImage2D(target, destination_level, m_internalFormat, width, height, 0, (GLsizei)block->getSize(), block->getStart()));
|
||||||
#endif
|
#endif
|
||||||
block->unlock();
|
block->unlock();
|
||||||
memoryTransferred += block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE
|
memoryTransferred += (long)block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE
|
||||||
#endif
|
#endif
|
||||||
memoryRequired += block->getSize();
|
memoryRequired += (long)block->getSize();
|
||||||
//
|
//
|
||||||
// err = glGetError();
|
// err = glGetError();
|
||||||
// if (err != GL_NO_ERROR) {
|
// if (err != GL_NO_ERROR) {
|
||||||
|
|||||||
Reference in New Issue
Block a user