1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 06:52:34 +02:00

Move first of lower level code into rwlib; tear out GLEW.

This commit is contained in:
Daniel Evans 2016-04-07 01:13:46 +01:00
parent e2bd2b704e
commit 14269d8ae5
67 changed files with 7143 additions and 309 deletions

View File

@ -47,7 +47,7 @@ IF(BUILD_OLD_TOOLS)
add_subdirectory(datadump)
ENDIF()
add_subdirectory(rwlib)
add_subdirectory(rwengine)
add_subdirectory(rwgame)
@ -60,4 +60,4 @@ ENDIF()
IF(${BUILD_TESTS})
add_subdirectory(tests)
ENDIF()
ENDIF()

View File

@ -10,9 +10,9 @@ add_library(rwengine
)
target_link_libraries(rwengine
rwlib
sfml-window
sfml-audio
GLEW
mad
${OPENRW_PLATFORM_LIBS})

View File

@ -5,7 +5,7 @@
#include <glm/gtc/quaternion.hpp>
#include <data/PathData.hpp>
#include <array>
#include <engine/RWTypes.hpp>
#include <rw/types.hpp>
struct AIGraphNode;

View File

@ -4,9 +4,9 @@
class Logger;
#include <engine/RWTypes.hpp>
#include <rw/types.hpp>
#include <loaders/LoaderIMG.hpp>
#include <loaders/TextureLoader.hpp>
#include <loaders/LoaderTXD.hpp>
#include <loaders/LoaderDFF.hpp>
#include <loaders/LoaderIDE.hpp>
#include <loaders/LoaderIFP.hpp>
@ -17,8 +17,8 @@ class Logger;
#include <data/ZoneData.hpp>
#include <audio/MADStream.hpp>
#include <render/TextureData.hpp>
#include <core/FileIndex.hpp>
#include <gl/TextureData.hpp>
#include <platform/FileIndex.hpp>
#include <memory>
@ -154,14 +154,6 @@ public:
FileHandle openFile(const std::string& name);
/**
* @brief getAtlas Returns atlas i, creating it if the situation calls for it.
* "the situation" being the last atlas has more than 0 textures packed.
* @param i
* @return
*/
TextureAtlas* getAtlas(size_t i);
TextureData::Handle findTexture( const std::string& name, const std::string& alpha = "" )
{
return textures[{name, alpha}];

View File

@ -5,8 +5,6 @@
class PlayerController;
class Logger;
#include <GL/glew.h>
class GameData;
class GameState;

View File

@ -2,7 +2,7 @@
#ifndef _SAVEGAME_HPP_
#define _SAVEGAME_HPP_
#include <engine/RWTypes.hpp>
#include <rw/types.hpp>
#include <string>
#include <vector>
@ -48,4 +48,4 @@ public:
static std::vector<SaveGameInfo> getAllSaveGameInfo();
};
#endif
#endif

View File

@ -1,8 +1,8 @@
#pragma once
#include <WorkContext.hpp>
#include <job/WorkContext.hpp>
#include <data/ResourceHandle.hpp>
#include <core/FileIndex.hpp>
#include <platform/FileIndex.hpp>
/**
* Implementation of a worker that loads a resource in the background.

View File

@ -1,7 +1,7 @@
#pragma once
#ifndef _LOADERCUTSCENEDAT_HPP_
#define _LOADERCUTSCENEDAT_HPP_
#include <core/FileHandle.hpp>
#include <platform/FileHandle.hpp>
#include <data/CutsceneData.hpp>
class LoaderCutsceneDAT

View File

@ -1,7 +1,7 @@
#pragma once
#ifndef _LOADERGXT_HPP_
#define _LOADERGXT_HPP_
#include <core/FileHandle.hpp>
#include <platform/FileHandle.hpp>
#include <data/GameTexts.hpp>
class LoaderGXT

View File

@ -1,40 +0,0 @@
#pragma once
#ifndef _TEXTURELOADER_HPP_
#define _TEXTURELOADER_HPP_
#define GLEW_STATIC
#include <GL/glew.h>
#include <loaders/rwbinarystream.h>
#include <WorkContext.hpp>
#include <core/FileHandle.hpp>
#include <functional>
#include <string>
#include <map>
class GameData;
class TextureLoader
{
public:
bool loadFromMemory(FileHandle file, GameData* gameData);
};
// TODO: refactor this interface to be more like ModelLoader so they can be rolled into one.
class LoadTextureArchiveJob : public WorkJob
{
private:
GameData* _gameData;
std::string _file;
FileHandle data;
public:
LoadTextureArchiveJob(WorkContext* context, GameData* gd, const std::string& file);
void work();
void complete();
};
#endif

View File

@ -2,7 +2,7 @@
#ifndef _WEATHERLOADER_HPP_
#define _WEATHERLOADER_HPP_
#include <engine/RWTypes.hpp>
#include <rw/types.hpp>
#include <string>
#include <sstream>

View File

@ -2,11 +2,11 @@
#ifndef _GAMEOBJECT_HPP_
#define _GAMEOBJECT_HPP_
#include <engine/RWTypes.hpp>
#include <rw/types.hpp>
#include <objects/ObjectTypes.hpp>
#include <loaders/LoaderIDE.hpp>
#include <loaders/LoaderIPL.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <memory>

View File

@ -2,7 +2,7 @@
#include <LinearMath/btIDebugDraw.h>
#include <render/GameRenderer.hpp>
#include "Model.hpp"
#include <data/Model.hpp>
class DebugDraw : public btIDebugDraw
{

View File

@ -3,8 +3,8 @@
class Logger;
#define GLEW_STATIC
#include <GL/glew.h>
#include <gl/gl_core_3_3.h>
#include <memory>
#include <vector>

View File

@ -2,9 +2,9 @@
#ifndef _OPENGLRENDERER_HPP_
#define _OPENGLRENDERER_HPP_
#include <engine/RWTypes.hpp>
#include <render/DrawBuffer.hpp>
#include <render/GeometryBuffer.hpp>
#include <rw/types.hpp>
#include <gl/DrawBuffer.hpp>
#include <gl/GeometryBuffer.hpp>
// Maximum depth of debug group stack
#define MAX_DEBUG_DEPTH 5

View File

@ -1,56 +0,0 @@
#pragma once
#ifndef _TEXTURE_ATLAS_HPP_
#define _TEXTURE_ATLAS_HPP_
#include <GL/glew.h>
class TextureAtlas
{
/**
* @brief width Width of the backing texture.
*/
size_t width;
/**
* @brief height Height of the backing texture.
*/
size_t height;
GLuint textureName;
size_t X; // X edge of latest texture.
size_t Y; // Y of current row.
size_t rowHeight; // Maximum texture height for the current row.
size_t textureCount;
bool finalized;
public:
TextureAtlas(size_t w, size_t h);
~TextureAtlas();
void packTexture(void* data, size_t w, size_t h, float& s, float& t, float& sX, float& sY);
void packTextureFormat(void* data, GLenum format, GLenum type, size_t w, size_t h, float& s, float& t, float& sX, float& sY);
/**
* @brief canPack Returns true if enough space remains in the atlas
* for the given texture sizes to be packed.
* @param w
* @param h
* @param n
* @return True on success, false on failure.
*/
bool canPack(size_t* w, size_t* h, size_t n) const;
size_t getTextureCount() const;
GLint getName() const;
bool isFinalized() const;
void finalize();
};
#endif

View File

@ -1,7 +1,7 @@
#pragma once
#include <glm/glm.hpp>
#include "TextureData.hpp"
#include <gl/TextureData.hpp>
/**
* Represents a scene effect: lighting, particles etc.

View File

@ -1,6 +1,6 @@
#pragma once
#include <engine/RWTypes.hpp>
#include <rw/types.hpp>
#include <render/OpenGLRenderer.hpp>
class GameRenderer;

View File

@ -2,7 +2,7 @@
#include <objects/CharacterObject.hpp>
#include <objects/VehicleObject.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <engine/Animator.hpp>
#include <items/WeaponItem.hpp>
#include <boost/concept_check.hpp>
@ -390,7 +390,7 @@ bool Activities::ExitVehicle::update(CharacterObject *character, CharacterContro
#include <engine/GameWorld.hpp>
#include <engine/GameData.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
bool Activities::ShootWeapon::update(CharacterObject *character, CharacterController *controller)
{
auto& wepdata = _item->getWeaponData();

View File

@ -1,5 +1,5 @@
#include <data/Skeleton.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <glm/gtc/matrix_transform.hpp>
Skeleton::FrameTransform Skeleton::IdentityTransform = { glm::vec3(0.f), glm::quat() };

View File

@ -1,6 +1,6 @@
#include <engine/Animator.hpp>
#include <loaders/LoaderDFF.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <data/Skeleton.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <iostream>

View File

@ -4,12 +4,11 @@
#include <loaders/LoaderIPL.hpp>
#include <loaders/LoaderDFF.hpp>
#include <loaders/LoaderIDE.hpp>
#include <render/TextureAtlas.hpp>
#include <loaders/LoaderCOL.hpp>
#include <data/ObjectData.hpp>
#include <data/WeaponData.hpp>
#include <script/SCMFile.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <loaders/GenericDATLoader.hpp>
#include <loaders/LoaderGXT.hpp>
@ -423,7 +422,7 @@ void GameData::loadTXD(const std::string& name, bool async)
loadedFiles[name] = true;
auto j = new LoadTextureArchiveJob(workContext, this, name);
auto j = new LoadTextureArchiveJob(workContext, &index, textures, name);
if( async ) {
workContext->queueJob( j );
@ -566,20 +565,6 @@ FileHandle GameData::openFile(const std::string &name)
return file;
}
TextureAtlas* GameData::getAtlas(size_t i)
{
if( i < atlases.size() ) {
return atlases[i];
}
if( i == atlases.size() && (i == 0 || atlases[i-1]->getTextureCount() > 0) ) {
GLint max_texture_size;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
atlases.push_back(new TextureAtlas(max_texture_size/2, max_texture_size/2));
return atlases[i];
}
return nullptr;
}
int GameData::getWaterIndexAt(const glm::vec3 &ws) const
{
auto wX = (int) ((ws.x + WATER_WORLD_SIZE/2.f) / (WATER_WORLD_SIZE/WATER_HQ_DATA_SIZE));

View File

@ -9,9 +9,9 @@
#include <ai/DefaultAIController.hpp>
#include <ai/TrafficDirector.hpp>
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <data/WeaponData.hpp>
#include <WorkContext.hpp>
#include <job/WorkContext.hpp>
// 3 isn't enough to cause a factory.
#include <objects/CharacterObject.hpp>

View File

@ -1,7 +1,7 @@
#include <items/WeaponItem.hpp>
#include <objects/CharacterObject.hpp>
#include <ai/CharacterController.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <engine/Animator.hpp>
#include <engine/GameWorld.hpp>
#include <objects/ProjectileObject.hpp>

View File

@ -5,7 +5,7 @@
#include <dynamics/RaycastCallbacks.hpp>
#include <data/CollisionModel.hpp>
#include <data/Skeleton.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <engine/Animator.hpp>
#include <engine/GameData.hpp>

View File

@ -1,8 +1,5 @@
#include "render/DebugDraw.hpp"
#define GLEW_STATIC
#include <GL/glew.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

View File

@ -2,8 +2,7 @@
#include <engine/GameWorld.hpp>
#include <engine/Animator.hpp>
#include <engine/GameState.hpp>
#include <render/TextureAtlas.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <objects/CharacterObject.hpp>
#include <objects/InstanceObject.hpp>

View File

@ -1,5 +1,4 @@
#include <render/OpenGLRenderer.hpp>
#include <GL/glew.h>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
@ -160,6 +159,9 @@ void OpenGLRenderer::useProgram(Renderer::ShaderProgram* p)
OpenGLRenderer::OpenGLRenderer()
: currentDbuff(nullptr), currentProgram(nullptr), currentDebugDepth(0)
{
// We need to query for some profiling exts.
ogl_CheckExtensions();
glGenBuffers(1, &UBOScene);
glGenBuffers(1, &UBOObject);
@ -327,7 +329,7 @@ void OpenGLRenderer::invalidate()
void OpenGLRenderer::pushDebugGroup(const std::string& title)
{
#if RW_USING(RENDER_PROFILER)
if( GLEW_KHR_debug )
if( ogl_ext_KHR_debug )
{
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, title.c_str());
ProfileInfo& prof = profileInfo[currentDebugDepth];
@ -345,7 +347,7 @@ void OpenGLRenderer::pushDebugGroup(const std::string& title)
const Renderer::ProfileInfo& OpenGLRenderer::popDebugGroup()
{
#if RW_USING(RENDER_PROFILER)
if( GLEW_KHR_debug )
if( ogl_ext_KHR_debug )
{
glPopDebugGroup();
currentDebugDepth--;

View File

@ -1,89 +0,0 @@
#include <render/TextureAtlas.hpp>
#include <algorithm>
TextureAtlas::TextureAtlas(size_t w, size_t h)
: width(w), height(h), textureName(0), X(0), Y(0), rowHeight(0), textureCount(0), finalized(false)
{
glGenTextures(1, &textureName);
glBindTexture(GL_TEXTURE_2D, textureName);
glTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA,
width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, nullptr
);
}
TextureAtlas::~TextureAtlas()
{
glDeleteTextures(1, &textureName);
}
void TextureAtlas::packTexture(void *data, size_t w, size_t h, float &s, float &t, float &sX, float &sY)
{
packTextureFormat(data, GL_RGBA, GL_UNSIGNED_BYTE, w, h, s, t, sX, sY);
}
void TextureAtlas::packTextureFormat(void *data, GLenum format, GLenum type, size_t w, size_t h, float &s, float &t, float &sX, float &sY)
{
// Ignore null pointer data for testing purposes.
if( data != nullptr )
{
glBindTexture(GL_TEXTURE_2D, textureName);
glTexSubImage2D(GL_TEXTURE_2D, 0, X, Y, w, h, format, type, data);
}
s = X/(float)width;
t = Y/(float)height;
sX = w/(float)width;
sY = h/(float)height;
rowHeight = std::max(rowHeight, h);
X += w;
if( X >= width ) {
Y += rowHeight;
X = rowHeight = 0;
}
textureCount++;
}
bool TextureAtlas::canPack(size_t *w, size_t *h, size_t n) const
{
size_t rwHeight = rowHeight;
size_t lX = X, lY = Y;
for(size_t i = 0; i < n; ++i) {
lX += (w[i]);
rwHeight = std::max(rwHeight, h[i]);
if(lX >= width) {
lY += rwHeight;
lX = rwHeight = 0;
}
}
if(lX <= width && lY <= height) {
return true;
}
return false;
}
size_t TextureAtlas::getTextureCount() const
{
return textureCount;
}
GLint TextureAtlas::getName() const
{
return textureName;
}
bool TextureAtlas::isFinalized() const
{
return finalized;
}
void TextureAtlas::finalize()
{
glBindTexture(GL_TEXTURE_2D, textureName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glGenerateMipmap(GL_TEXTURE_2D);
finalized = true;
}

View File

@ -1 +0,0 @@
#include <render/TextureData.hpp>

View File

@ -7,7 +7,7 @@
#include <objects/VehicleObject.hpp>
#include <objects/CharacterObject.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <engine/Animator.hpp>
#include <engine/GameState.hpp>
#include <engine/GameData.hpp>

View File

@ -8,7 +8,7 @@
#include <objects/VehicleObject.hpp>
#include <objects/CharacterObject.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <render/GameRenderer.hpp>
#include <engine/Animator.hpp>
#include <engine/GameState.hpp>

View File

@ -25,7 +25,6 @@ target_link_libraries( rwgame
sfml-network
sfml-system
${OPENGL_LIBRARIES}
GLEW
${BULLET_LIBRARIES})
install(TARGETS rwgame RUNTIME DESTINATION bin)

View File

@ -84,9 +84,6 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
window.setVerticalSyncEnabled(true);
window.setMouseCursorVisible(false);
glewExperimental = GL_TRUE;
glewInit();
log.addReciever(&logPrinter);
log.info("Game", "Game directory: " + gamepath);

View File

@ -8,7 +8,7 @@
#include <objects/CharacterObject.hpp>
#include <objects/VehicleObject.hpp>
#include <objects/ItemPickup.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <items/WeaponItem.hpp>
#include <engine/GameWorld.hpp>
#include <engine/GameState.hpp>

View File

@ -1,6 +1,3 @@
#define GLEW_STATIC
#include <GL/glew.h>
#include "RWGame.hpp"
std::string getGamePath()

51
rwlib/CMakeLists.txt Normal file
View File

@ -0,0 +1,51 @@
###########################################################
## RWLIB
###########################################################
SET(RWLIB_SOURCES
# GL stuff is only here temporarily, hoping to move it back to rwengine
"source/gl/gl_core_3_3.c"
"source/gl/gl_core_3_3.h"
"source/gl/DrawBuffer.hpp"
"source/gl/DrawBuffer.cpp"
"source/gl/GeometryBuffer.hpp"
"source/gl/GeometryBuffer.cpp"
"source/gl/TextureData.hpp"
"source/gl/TextureData.cpp"
"source/rw/types.hpp"
"source/platform/FileHandle.hpp"
"source/platform/FileIndex.hpp"
"source/platform/FileIndex.cpp"
"source/data/ResourceHandle.hpp"
"source/data/Model.hpp"
"source/data/Model.cpp"
"source/loaders/LoaderIMG.hpp"
"source/loaders/LoaderIMG.cpp"
"source/loaders/RWBinaryStream.hpp"
"source/loaders/LoaderDFF.hpp"
"source/loaders/LoaderDFF.cpp"
"source/loaders/LoaderTXD.hpp"
"source/loaders/LoaderTXD.cpp"
"source/job/WorkContext.hpp"
"source/job/WorkContext.cpp"
)
add_library(rwlib
${RWLIB_SOURCES}
)
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/source")
target_include_directories(rwlib
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/source")
target_link_libraries(rwlib
${OPENGL_LIBRARIES}
${OPENRW_PLATFORM_LIBS})

BIN
rwlib/source/a.out Executable file

Binary file not shown.

View File

@ -1,5 +1,4 @@
#include "render/Model.hpp"
#include <GL/glew.h>
#include "data/Model.hpp"
#include <iostream>
#include <glm/gtc/matrix_transform.hpp>

View File

@ -6,13 +6,12 @@
#include <string>
#include <memory>
#include <algorithm>
#include <GL/glew.h>
#include <data/ResourceHandle.hpp>
#include <loaders/rwbinarystream.h>
#include "DrawBuffer.hpp"
#include "GeometryBuffer.hpp"
#include "TextureData.hpp"
#include <loaders/RWBinaryStream.hpp>
#include <gl/DrawBuffer.hpp>
#include <gl/GeometryBuffer.hpp>
#include <gl/TextureData.hpp>
/**
* ModelFrame stores the hierarchy of a model's geometry as well as default

View File

@ -1,5 +1,5 @@
#include <render/DrawBuffer.hpp>
#include <render/GeometryBuffer.hpp>
#include <gl/DrawBuffer.hpp>
#include <gl/GeometryBuffer.hpp>
#include <map>
/* TODO: Come up with a more elegant solution to "WHICH ARRAY IS IT?" */

View File

@ -1,7 +1,7 @@
#pragma once
#ifndef _DRAWBUFFER_HPP_
#define _DRAWBUFFER_HPP_
#include <GL/glew.h>
#include <gl/gl_core_3_3.h>
class GeometryBuffer;

View File

@ -1,4 +1,4 @@
#include <render/GeometryBuffer.hpp>
#include <gl/GeometryBuffer.hpp>
GeometryBuffer::GeometryBuffer()
: vbo(0), num(0)

View File

@ -1,7 +1,7 @@
#pragma once
#ifndef _GEOMETRYBUFFER_HPP_
#define _GEOMETRYBUFFER_HPP_
#include <GL/glew.h>
#include <gl/gl_core_3_3.h>
#include <vector>
/**

View File

@ -0,0 +1 @@
#include <gl/TextureData.hpp>

View File

@ -1,5 +1,5 @@
#pragma once
#include <GL/gl.h>
#include <gl/gl_core_3_3.h>
#include <glm/glm.hpp>
#include <memory>
@ -31,4 +31,4 @@ private:
GLuint texName;
glm::ivec2 size;
bool hasAlpha;
};
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,4 @@
#include <WorkContext.hpp>
#include <loaders/DataLoader.hpp>
#include <job/WorkContext.hpp>
void LoadWorker::start()
{

View File

@ -1,6 +1,5 @@
#include <loaders/LoaderDFF.hpp>
#include <engine/GameData.hpp>
#include <render/Model.hpp>
#include <data/Model.hpp>
#include <iostream>
#include <algorithm>

View File

@ -2,16 +2,11 @@
#ifndef _LOADERDFF_HPP_
#define _LOADERDFF_HPP_
#define GLEW_STATIC
#include <GL/glew.h>
#include <loaders/rwbinarystream.h>
#include <loaders/RWBinaryStream.hpp>
#include <vector>
#include <string>
#include <WorkContext.hpp>
#include <core/FileHandle.hpp>
#include <core/FileIndex.hpp>
#include <platform/FileHandle.hpp>
#include <data/ResourceHandle.hpp>
class Model;

View File

@ -1,7 +1,5 @@
#include <loaders/TextureLoader.hpp>
#include <engine/GameData.hpp>
#include <render/TextureAtlas.hpp>
#include <render/TextureData.hpp>
#include <loaders/LoaderTXD.hpp>
#include <gl/TextureData.hpp>
#include <fstream>
#include <iostream>
@ -184,7 +182,7 @@ TextureData::Handle createTexture(RW::BSTextureNative& texNative, RW::BinaryStre
return TextureData::create( textureName, { texNative.width, texNative.height }, transparent );
}
bool TextureLoader::loadFromMemory(FileHandle file, GameData *gameData)
bool TextureLoader::loadFromMemory(FileHandle file, TextureArchive &inTextures)
{
auto data = file->data;
RW::BinaryStreamSection root(data);
@ -205,26 +203,31 @@ bool TextureLoader::loadFromMemory(FileHandle file, GameData *gameData)
auto texture = createTexture(texNative, rootSection);
gameData->textures[{name, alpha}] = texture;
inTextures[{name, alpha}] = texture;
if( !alpha.empty() ) {
gameData->textures[{name, ""}] = texture;
inTextures[{name, ""}] = texture;
}
}
return true;
}
// TODO Move the Job system out of the loading code
#include <platform/FileIndex.hpp>
LoadTextureArchiveJob::LoadTextureArchiveJob(WorkContext *context, GameData *gd, const std::string &file)
: WorkJob(context), _gameData(gd), _file(file)
LoadTextureArchiveJob::LoadTextureArchiveJob(WorkContext *context, FileIndex* index, TextureArchive &inTextures, const std::string &file)
: WorkJob(context)
, archive(inTextures)
, fileIndex(index)
, _file(file)
{
}
void LoadTextureArchiveJob::work()
{
data = _gameData->openFile(_file);
data = fileIndex->openFile(_file);
}
void LoadTextureArchiveJob::complete()
@ -232,6 +235,6 @@ void LoadTextureArchiveJob::complete()
// TODO error status
if(data) {
TextureLoader loader;
loader.loadFromMemory(data, _gameData);
loader.loadFromMemory(data, archive);
}
}

View File

@ -0,0 +1,42 @@
#pragma once
#ifndef _TEXTURELOADER_HPP_
#define _TEXTURELOADER_HPP_
#include <loaders/RWBinaryStream.hpp>
#include <job/WorkContext.hpp>
#include <platform/FileHandle.hpp>
#include <functional>
#include <string>
#include <map>
// This might suffice
#include <gl/TextureData.hpp>
typedef std::map<std::pair<std::string, std::string>, TextureData::Handle> TextureArchive;
class FileIndex;
class TextureLoader
{
public:
bool loadFromMemory(FileHandle file, TextureArchive& inTextures);
};
// TODO: refactor this interface to be more like ModelLoader so they can be rolled into one.
class LoadTextureArchiveJob : public WorkJob
{
private:
TextureArchive& archive;
FileIndex* fileIndex;
std::string _file;
FileHandle data;
public:
LoadTextureArchiveJob(WorkContext* context, FileIndex* index, TextureArchive& inTextures, const std::string& file);
void work();
void complete();
};
#endif

View File

@ -1,4 +1,4 @@
#include <core/FileIndex.hpp>
#include <platform/FileIndex.hpp>
#include <loaders/LoaderIMG.hpp>
#include <algorithm>

View File

@ -29,7 +29,6 @@ target_link_libraries(rwviewer
sfml-graphics
sfml-system
${OPENGL_LIBRARIES}
GLEW
${BULLET_LIBRARIES})
qt5_use_modules(rwviewer Widgets OpenGL)

View File

@ -41,9 +41,6 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
viewerWidget->context()->makeCurrent();
glewExperimental = 1;
glewInit();
objectViewer = new ObjectViewer(viewerWidget);
connect(this, SIGNAL(loadedData(GameWorld*)), objectViewer, SLOT(showData(GameWorld*)));

View File

@ -9,7 +9,6 @@ sfml-graphics
sfml-window
sfml-system
${OPENGL_LIBRARIES}
GLEW
${BULLET_LIBRARIES})
install(TARGETS ${SCRIPTTOOL} RUNTIME DESTINATION bin)

View File

@ -18,7 +18,6 @@ target_link_libraries(run_tests
sfml-system
sfml-graphics
${OPENGL_LIBRARIES}
GLEW
BulletDynamics
BulletCollision
LinearMath

View File

@ -42,8 +42,6 @@ public:
Global() {
wnd.create(sf::VideoMode(640, 360), "Testing");
glewExperimental = GL_TRUE;
glewInit();
d = new GameData(&log, &work, getGamePath());
e = new GameWorld(&log, &work, d);