Removed Boost dependency, WIP Android (Vulkan) support
This commit is contained in:
@@ -28,8 +28,6 @@
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "KRAnimation.h"
|
||||
#include "KRAnimationManager.h"
|
||||
#include "KRContext.h"
|
||||
@@ -291,7 +289,7 @@ KRAnimation *KRAnimation::split(const std::string &name, float start_time, float
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(getContext());
|
||||
KRAnimationCurve *new_curve = curve;
|
||||
if(clone_curves) {
|
||||
std::string new_curve_name = name + "_curve" + boost::lexical_cast<std::string>(++new_curve_count);
|
||||
std::string new_curve_name = name + "_curve" + std::to_string(++new_curve_count);
|
||||
new_curve = curve->split(new_curve_name, start_time, duration);
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ private:
|
||||
unordered_map<std::string, siren_reverb_zone_weight_info> m_reverb_zone_weights;
|
||||
float m_reverb_zone_total_weight = 0.0f; // For normalizing zone weights
|
||||
|
||||
boost::signals2::mutex m_mutex;
|
||||
std::mutex m_mutex;
|
||||
#ifdef __APPLE__
|
||||
mach_timebase_info_data_t m_timebase_info;
|
||||
#endif
|
||||
|
||||
@@ -553,7 +553,7 @@ void KRCamera::createBuffers(GLint renderBufferWidth, GLint renderBufferHeight)
|
||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); // This is necessary for non-power-of-two textures
|
||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); // This is necessary for non-power-of-two textures
|
||||
GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_backingWidth, m_backingHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL));
|
||||
GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_backingWidth, m_backingHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
|
||||
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, compositeColorTexture, 0));
|
||||
|
||||
// ----- Create Depth Texture for compositeFramebuffer -----
|
||||
@@ -579,7 +579,7 @@ void KRCamera::createBuffers(GLint renderBufferWidth, GLint renderBufferHeight)
|
||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); // This is necessary for non-power-of-two textures
|
||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); // This is necessary for non-power-of-two textures
|
||||
GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_backingWidth, m_backingHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL));
|
||||
GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_backingWidth, m_backingHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
|
||||
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, lightAccumulationTexture, 0));
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ void KRCamera::createBuffers(GLint renderBufferWidth, GLint renderBufferHeight)
|
||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); // This is necessary for non-power-of-two textures
|
||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); // This is necessary for non-power-of-two textures
|
||||
GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, volumetricBufferWidth, volumetricBufferHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL));
|
||||
GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, volumetricBufferWidth, volumetricBufferHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
|
||||
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, volumetricLightAccumulationTexture, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
#include "KRAudioManager.h"
|
||||
#include "KRAudioSample.h"
|
||||
|
||||
#if defined(ANDROID)
|
||||
#include <chrono>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
@@ -33,6 +38,8 @@ int KRContext::KRENGINE_SYS_PAGE_SIZE;
|
||||
|
||||
#elif defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#elif defined(ANDROID)
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported Platform
|
||||
@@ -83,7 +90,7 @@ KRContext::KRContext()
|
||||
KRENGINE_SYS_ALLOCATION_GRANULARITY = winSysInfo.dwAllocationGranularity;
|
||||
KRENGINE_SYS_PAGE_SIZE = winSysInfo.dwPageSize;
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(ANDROID)
|
||||
|
||||
KRENGINE_SYS_PAGE_SIZE = getpagesize();
|
||||
KRENGINE_SYS_ALLOCATION_GRANULARITY = KRENGINE_SYS_PAGE_SIZE;
|
||||
@@ -348,7 +355,10 @@ float KRContext::getAbsoluteTime() const
|
||||
|
||||
long KRContext::getAbsoluteTimeMilliseconds()
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
#if defined(ANDROID)
|
||||
return std::chrono::duration_cast< std::chrono::milliseconds >(
|
||||
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
#elif defined(__APPLE__)
|
||||
return (long)(mach_absolute_time() / 1000 * m_timebase_info.numer / m_timebase_info.denom); // Division done first to avoid potential overflow
|
||||
#else
|
||||
return (long)GetTickCount64();
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
#include "KRContext.h"
|
||||
|
||||
#include <errno.h>
|
||||
#if defined(__APPLE__) || defined(ANDROID)
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#define KRAKEN_MEM_ROUND_DOWN_PAGE(x) ((x) & ~(KRContext::KRENGINE_SYS_ALLOCATION_GRANULARITY - 1))
|
||||
#define KRAKEN_MEM_ROUND_UP_PAGE(x) ((((x) - 1) & ~(KRContext::KRENGINE_SYS_ALLOCATION_GRANULARITY - 1)) + KRContext::KRENGINE_SYS_ALLOCATION_GRANULARITY)
|
||||
@@ -179,7 +183,7 @@ KRDataBlock *KRDataBlock::getSubBlock(int start, int length)
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if(m_hPackFile) {
|
||||
new_block->m_hPackFile = m_hPackFile;
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(ANDROID)
|
||||
if (m_fdPackFile) {
|
||||
new_block->m_fdPackFile = m_fdPackFile;
|
||||
#else
|
||||
@@ -217,7 +221,7 @@ void KRDataBlock::expand(size_t size)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if(m_data == NULL && m_hPackFile == 0) {
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(ANDROID)
|
||||
if (m_data == NULL && m_fdPackFile == 0) {
|
||||
#else
|
||||
#error Unsupported
|
||||
@@ -290,7 +294,7 @@ void KRDataBlock::copy(void *dest, int start, int count) {
|
||||
bytes_remaining -= bytes_read;
|
||||
}
|
||||
assert(bytes_remaining == 0);
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(ANDROID)
|
||||
if(m_lockCount == 0 && m_fdPackFile != 0) {
|
||||
// Optimization: If we haven't mmap'ed or malloced the data already, pread() it directly from the file into the buffer
|
||||
ssize_t r = pread(m_fdPackFile, dest, count, start + m_data_offset);
|
||||
@@ -365,7 +369,7 @@ bool KRDataBlock::save(const std::string& path) {
|
||||
|
||||
return success;
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(ANDROID)
|
||||
int fdNewFile = open(path.c_str(), O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
|
||||
if(fdNewFile == -1) {
|
||||
return false;
|
||||
@@ -418,7 +422,7 @@ void KRDataBlock::lock()
|
||||
// Memory mapped file; ensure data is mapped to ram
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if(m_hFileMapping) {
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(ANDROID)
|
||||
if(m_fdPackFile) {
|
||||
#else
|
||||
#error Unsupported
|
||||
@@ -436,7 +440,7 @@ void KRDataBlock::lock()
|
||||
|
||||
m_mmapData = MapViewOfFileFromApp(m_hPackFile, m_bReadOnly ? FILE_MAP_READ : FILE_MAP_WRITE, m_data_offset - alignment_offset, m_data_size + alignment_offset);
|
||||
assert(m_mmapData != NULL);
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(ANDROID)
|
||||
//fprintf(stderr, "KRDataBlock::lock - \"%s\" (%i)\n", m_fileOwnerDataBlock->m_fileName.c_str(), m_lockCount);
|
||||
// Round m_data_offset down to the next memory page, as required by mmap
|
||||
|
||||
@@ -496,7 +500,7 @@ void KRDataBlock::unlock()
|
||||
// Memory mapped file; ensure data is unmapped from ram
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if (m_hPackFile) {
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(ANDROID)
|
||||
if(m_fdPackFile) {
|
||||
#else
|
||||
#error Undefined
|
||||
@@ -514,7 +518,7 @@ void KRDataBlock::unlock()
|
||||
CloseHandle(m_hFileMapping);
|
||||
m_hFileMapping = NULL;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(ANDROID)
|
||||
munmap(m_mmapData, m_data_size);
|
||||
#else
|
||||
#error Undefined
|
||||
|
||||
@@ -106,7 +106,7 @@ private:
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
HANDLE m_hPackFile;
|
||||
HANDLE m_hFileMapping;
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(ANDROID)
|
||||
int m_fdPackFile;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -47,10 +47,6 @@ using namespace kraken;
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/signals2/mutex.hpp>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@@ -104,8 +100,19 @@ using std::unordered_multimap;
|
||||
using std::hash;
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#if defined(ANDROID)
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl3ext.h>
|
||||
// OpenGL ES 2.0 mapping to OpenGL ES 3.2
|
||||
#define glDeleteQueriesEXT glDeleteQueries
|
||||
#define glGenQueriesEXT glGenQueries
|
||||
#define glBeginQueryEXT glBeginQuery
|
||||
#define glEndQueryEXT glEndQuery
|
||||
#define glGetQueryObjectuivEXT glGetQueryObjectuiv
|
||||
#define glTexStorage2DEXT glTexStorage2D
|
||||
#define GL_ANY_SAMPLES_PASSED_EXT GL_ANY_SAMPLES_PASSED
|
||||
#define GL_QUERY_RESULT_EXT GL_QUERY_RESULT
|
||||
#elif defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#include <mutex>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -5,9 +5,12 @@
|
||||
#include "vector3.h"
|
||||
#include "matrix4.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#if defined(ANDROID)
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl3ext.h>
|
||||
#elif defined(_WIN32) || defined(_WIN64)
|
||||
#include <glad/glad.h>
|
||||
#elif defined(__linux__) || defined(__unix__) || defined(__posix__)
|
||||
#elif (defined(__linux__) || defined(__unix__) || defined(__posix__))
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
@@ -287,7 +287,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
||||
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, occlusion_test_sphere_matrix, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
|
||||
|
||||
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
||||
#if TARGET_OS_IPHONE
|
||||
#if TARGET_OS_IPHONE || defined(ANDROID)
|
||||
GLDEBUG(glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, m_occlusionQuery));
|
||||
#else
|
||||
GLDEBUG(glBeginQuery(GL_SAMPLES_PASSED, m_occlusionQuery));
|
||||
@@ -300,7 +300,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#if TARGET_OS_IPHONE || defined(ANDROID)
|
||||
GLDEBUG(glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT));
|
||||
#else
|
||||
GLDEBUG(glEndQuery(GL_SAMPLES_PASSED));
|
||||
|
||||
@@ -34,7 +34,22 @@ void KRLocator::loadXML(tinyxml2::XMLElement *e)
|
||||
KRNode::loadXML(e);
|
||||
}
|
||||
|
||||
unordered_map<std::string, boost::variant<int, double, bool, std::string> > &KRLocator::getUserAttributes()
|
||||
unordered_map<std::string, int> &KRLocator::getUserIntAttributes()
|
||||
{
|
||||
return m_userAttributes;
|
||||
}
|
||||
return m_userIntAttributes;
|
||||
}
|
||||
|
||||
unordered_map<std::string, double> &KRLocator::getUserDoubleAttributes()
|
||||
{
|
||||
return m_userDoubleAttributes;
|
||||
}
|
||||
|
||||
unordered_map<std::string, bool> &KRLocator::getUserBoolAttributes()
|
||||
{
|
||||
return m_userBoolAttributes;
|
||||
}
|
||||
|
||||
unordered_map<std::string, std::string> &KRLocator::getUserStringAttributes()
|
||||
{
|
||||
return m_userStringAttributes;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include "KRNode.h"
|
||||
#include "KRTexture.h"
|
||||
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
class KRLocator : public KRNode {
|
||||
public:
|
||||
KRLocator(KRScene &scene, std::string name);
|
||||
@@ -22,10 +20,16 @@ public:
|
||||
virtual std::string getElementName();
|
||||
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||
unordered_map<std::string, boost::variant<int, double, bool, std::string> > &getUserAttributes();
|
||||
unordered_map<std::string, int> &getUserIntAttributes();
|
||||
unordered_map<std::string, double> &getUserDoubleAttributes();
|
||||
unordered_map<std::string, bool> &getUserBoolAttributes();
|
||||
unordered_map<std::string, std::string> &getUserStringAttributes();
|
||||
|
||||
private:
|
||||
unordered_map<std::string, boost::variant<int, double, bool, std::string> > m_userAttributes;
|
||||
unordered_map<std::string, int> m_userIntAttributes;
|
||||
unordered_map<std::string, double> m_userDoubleAttributes;
|
||||
unordered_map<std::string, bool> m_userBoolAttributes;
|
||||
unordered_map<std::string, std::string> m_userStringAttributes;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ void KROctreeNode::beginOcclusionQuery()
|
||||
{
|
||||
if(!m_occlusionTested){
|
||||
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
||||
#if TARGET_OS_IPHONE
|
||||
#if TARGET_OS_IPHONE || defined(ANDROID)
|
||||
GLDEBUG(glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, m_occlusionQuery));
|
||||
#else
|
||||
GLDEBUG(glBeginQuery(GL_SAMPLES_PASSED, m_occlusionQuery));
|
||||
@@ -67,7 +67,7 @@ void KROctreeNode::endOcclusionQuery()
|
||||
{
|
||||
if(m_activeQuery) {
|
||||
// Only end a query if we started one
|
||||
#if TARGET_OS_IPHONE
|
||||
#if TARGET_OS_IPHONE || defined(ANDROID)
|
||||
GLDEBUG(glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT));
|
||||
#else
|
||||
GLDEBUG(glEndQuery(GL_SAMPLES_PASSED));
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
//
|
||||
|
||||
#include "KREngine-common.h"
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
#include "fbxsdk.h"
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,9 @@ KRStreamer::~KRStreamer()
|
||||
void KRStreamer::run()
|
||||
{
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#if defined(ANDROID)
|
||||
// TODO - Set thread names on Android
|
||||
#elif defined(_WIN32) || defined(_WIN64)
|
||||
// TODO - Set thread names on windows
|
||||
#else
|
||||
pthread_setname_np("Kraken - Streamer");
|
||||
|
||||
@@ -90,11 +90,13 @@ void KRTextureManager::_setWrapModeS(GLuint i, GLuint wrap_mode)
|
||||
|
||||
void KRTextureManager::_setMaxAnisotropy(int i, float max_anisotropy)
|
||||
{
|
||||
#if !defined(ANDROID)
|
||||
if(m_maxAnisotropy[i] != max_anisotropy) {
|
||||
_setActiveTexture(i);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy);
|
||||
m_maxAnisotropy[i] = max_anisotropy;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void KRTextureManager::setMaxAnisotropy(float max_anisotropy)
|
||||
|
||||
@@ -98,7 +98,7 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
|
||||
GLenum internal_format = GL_RGBA;
|
||||
|
||||
#if !TARGET_OS_IPHONE
|
||||
#if !TARGET_OS_IPHONE && !defined(ANDROID)
|
||||
if(compress) {
|
||||
internal_format = pHeader->bitsperpixel == 24 ? GL_COMPRESSED_RGB_S3TC_DXT1_EXT : GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
}
|
||||
@@ -124,15 +124,15 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
unsigned char *pDest = converted_image;
|
||||
unsigned char *pEnd = pData + pHeader->height * pHeader->width * 3;
|
||||
while(pSource < pEnd) {
|
||||
*pDest++ = pSource[0];
|
||||
*pDest++ = pSource[1];
|
||||
*pDest++ = pSource[2];
|
||||
*pDest++ = pSource[1];
|
||||
*pDest++ = pSource[0];
|
||||
*pDest++ = 0xff;
|
||||
pSource += 3;
|
||||
}
|
||||
assert(pSource <= m_pData->getEnd());
|
||||
//#endif
|
||||
GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image));
|
||||
GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image));
|
||||
GLDEBUG(glFinish());
|
||||
free(converted_image);
|
||||
|
||||
@@ -148,20 +148,34 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
unsigned char *pDest = converted_image;
|
||||
unsigned char *pEnd = pData + pHeader->height * pHeader->width * 3;
|
||||
while(pSource < pEnd) {
|
||||
*pDest++ = (__uint32_t)pSource[0] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[1] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[2] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[1] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[0] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = pSource[3];
|
||||
pSource += 4;
|
||||
}
|
||||
assert(pSource <= m_pData->getEnd());
|
||||
|
||||
GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image));
|
||||
GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image));
|
||||
GLDEBUG(glFinish());
|
||||
free(converted_image);
|
||||
} else {
|
||||
GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)pData));
|
||||
unsigned char *converted_image = (unsigned char *)malloc(pHeader->width * pHeader->height * 4);
|
||||
|
||||
unsigned char *pSource = pData;
|
||||
unsigned char *pDest = converted_image;
|
||||
unsigned char *pEnd = pData + pHeader->height * pHeader->width * 3;
|
||||
while(pSource < pEnd) {
|
||||
*pDest++ = (__uint32_t)pSource[2];
|
||||
*pDest++ = (__uint32_t)pSource[1];
|
||||
*pDest++ = (__uint32_t)pSource[0];
|
||||
*pDest++ = pSource[3];
|
||||
pSource += 4;
|
||||
}
|
||||
assert(pSource <= m_pData->getEnd());
|
||||
GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)pData));
|
||||
GLDEBUG(glFinish());
|
||||
free(converted_image);
|
||||
}
|
||||
|
||||
current_lod_max_dim = m_max_lod_max_dim;
|
||||
@@ -187,9 +201,9 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
// RLE Packet
|
||||
pSource++;
|
||||
while(count--) {
|
||||
*pDest++ = (__uint32_t)pSource[0] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[1] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[2] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[1] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[0] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = pSource[3];
|
||||
}
|
||||
pSource += 4;
|
||||
@@ -197,9 +211,9 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
// RAW Packet
|
||||
pSource++;
|
||||
while(count--) {
|
||||
*pDest++ = (__uint32_t)pSource[0] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[1] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[2] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[1] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = (__uint32_t)pSource[0] * (__uint32_t)pSource[3] / 0xff;
|
||||
*pDest++ = pSource[3];
|
||||
pSource += 4;
|
||||
}
|
||||
@@ -214,9 +228,9 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
// RLE Packet
|
||||
pSource++;
|
||||
while(count--) {
|
||||
*pDest++ = pSource[0];
|
||||
*pDest++ = pSource[1];
|
||||
*pDest++ = pSource[2];
|
||||
*pDest++ = pSource[1];
|
||||
*pDest++ = pSource[0];
|
||||
*pDest++ = pSource[3];
|
||||
}
|
||||
pSource += 4;
|
||||
@@ -224,9 +238,9 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
// RAW Packet
|
||||
pSource++;
|
||||
while(count--) {
|
||||
*pDest++ = pSource[0];
|
||||
*pDest++ = pSource[1];
|
||||
*pDest++ = pSource[2];
|
||||
*pDest++ = pSource[1];
|
||||
*pDest++ = pSource[0];
|
||||
*pDest++ = pSource[3];
|
||||
pSource += 4;
|
||||
}
|
||||
@@ -235,7 +249,7 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
assert(pSource <= m_pData->getEnd());
|
||||
assert(pDest == pEnd);
|
||||
}
|
||||
GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image));
|
||||
GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image));
|
||||
GLDEBUG(glFinish());
|
||||
free(converted_image);
|
||||
current_lod_max_dim = m_max_lod_max_dim;
|
||||
@@ -253,9 +267,9 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
// RLE Packet
|
||||
pSource++;
|
||||
while(count--) {
|
||||
*pDest++ = pSource[0];
|
||||
*pDest++ = pSource[1];
|
||||
*pDest++ = pSource[2];
|
||||
*pDest++ = pSource[1];
|
||||
*pDest++ = pSource[0];
|
||||
*pDest++ = 0xff;
|
||||
}
|
||||
pSource += 3;
|
||||
@@ -263,9 +277,9 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
// RAW Packet
|
||||
pSource++;
|
||||
while(count--) {
|
||||
*pDest++ = pSource[0];
|
||||
*pDest++ = pSource[1];
|
||||
*pDest++ = pSource[2];
|
||||
*pDest++ = pSource[1];
|
||||
*pDest++ = pSource[0];
|
||||
*pDest++ = 0xff;
|
||||
pSource += 3;
|
||||
}
|
||||
@@ -273,7 +287,7 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
}
|
||||
assert(pSource <= m_pData->getEnd());
|
||||
assert(pDest == pEnd);
|
||||
GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image));
|
||||
GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image));
|
||||
GLDEBUG(glFinish());
|
||||
free(converted_image);
|
||||
current_lod_max_dim = m_max_lod_max_dim;
|
||||
@@ -293,7 +307,7 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !TARGET_OS_IPHONE
|
||||
#if !TARGET_OS_IPHONE && !defined(ANDROID)
|
||||
|
||||
KRTexture *KRTextureTGA::compress(bool premultiply_alpha)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
|
||||
bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress = false, bool premultiply_alpha = false);
|
||||
|
||||
#if !TARGET_OS_IPHONE
|
||||
#if !TARGET_OS_IPHONE && !defined(ANDROID)
|
||||
virtual KRTexture *compress(bool premultiply_alpha = false);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user