Removing mutexes because threading is going to be implemented differently.(#6)

This commit is contained in:
Faerbit 2015-04-25 22:38:44 +02:00
parent 40dfbf33d9
commit 9b89007674
4 changed files with 0 additions and 364 deletions

View File

@ -35,231 +35,7 @@ Graphics::Graphics(glm::uvec2 windowSize, float nearPlane,
Graphics::Graphics() {
}
Graphics::Graphics(const Graphics &other) {
std::lock_guard<std::mutex> lock(other.init_mutex);
lastLightUpdate = other.lastLightUpdate;
lastWindUpdate = other.lastWindUpdate;
windTarget = other.windTarget;
wind = other.wind;
windDirection = other.windDirection;
windDirectionTarget = other.windDirectionTarget;
textureMovementPosition = other.textureMovementPosition;
windowSize = other.windowSize;
nearPlane = other.nearPlane;
farPlane = other.farPlane;
loadingScreenPath = other.loadingScreenPath;
loadingScreenContinuePath = other.loadingScreenContinuePath;
loadingScreen = other.loadingScreen;
loadingContinueScreen = other.loadingContinueScreen;
closestLights = other.closestLights;
closestFlames = other.closestFlames;
loadingShader = other.loadingShader;
lightingShader = other.lightingShader;
skydomeShader = other.skydomeShader;
depthCubeShader = other.depthCubeShader;
depthShader = other.depthShader;
flameShader = other.flameShader;
flamePostShader = other.flamePostShader;
depth_directionalMaps = other.depth_directionalMaps;
framebuffer_directional = other.framebuffer_directional;
depth_cubeMaps = other.depth_cubeMaps;
framebuffer_cube = other.framebuffer_cube;
framebuffer_light = other.framebuffer_light;
light_fbo_color_texture = other.light_fbo_color_texture;
light_fbo_depth_texture = other.light_fbo_depth_texture;
fullscreen_quad = other.fullscreen_quad;
fullscreen_quad_ab = other.fullscreen_quad_ab;
fullscreen_quad_loading = other.fullscreen_quad_loading;
fullscreen_quad_ab_loading = other.fullscreen_quad_ab_loading;
cube_size = other.cube_size;
maxShadowRenderCount = other.maxShadowRenderCount;
level = other.level;
number_of_texture_units = other.number_of_texture_units;
gameStart = other.gameStart;
loadingScreenWidth = other.loadingScreenWidth;
loadingScreenHeight = other.loadingScreenHeight;
renderShadows = other.renderShadows;
renderFlames = other.renderFlames;
renderDebug = other.renderDebug;
renderWorld = other.renderWorld;
debugDrawer = other.debugDrawer;
debug_ab = other.debug_ab;
debug_vao = other.debug_vao;
debugShader = other.debugShader;
renderQueue = other.renderQueue;
}
Graphics::Graphics(Graphics &&other) {
std::lock_guard<std::mutex> lock(other.init_mutex);
lastLightUpdate = std::move(other.lastLightUpdate);
lastWindUpdate = std::move(other.lastWindUpdate);
windTarget = std::move(other.windTarget);
wind = std::move(other.wind);
windDirection = std::move(other.windDirection);
windDirectionTarget = std::move(other.windDirectionTarget);
textureMovementPosition = std::move(other.textureMovementPosition);
windowSize = std::move(other.windowSize);
nearPlane = std::move(other.nearPlane);
farPlane = std::move(other.farPlane);
loadingScreenPath = std::move(other.loadingScreenPath);
loadingScreenContinuePath = std::move(other.loadingScreenContinuePath);
loadingScreen = std::move(other.loadingScreen);
loadingContinueScreen = std::move(other.loadingContinueScreen);
closestLights = std::move(other.closestLights);
closestFlames = std::move(other.closestFlames);
loadingShader = std::move(other.loadingShader);
lightingShader = std::move(other.lightingShader);
skydomeShader = std::move(other.skydomeShader);
depthCubeShader = std::move(other.depthCubeShader);
depthShader = std::move(other.depthShader);
flameShader = std::move(other.flameShader);
flamePostShader = std::move(other.flamePostShader);
depth_directionalMaps = std::move(other.depth_directionalMaps);
framebuffer_directional = std::move(other.framebuffer_directional);
depth_cubeMaps = std::move(other.depth_cubeMaps);
framebuffer_cube = std::move(other.framebuffer_cube);
framebuffer_light = std::move(other.framebuffer_light);
light_fbo_color_texture = std::move(other.light_fbo_color_texture);
light_fbo_depth_texture = std::move(other.light_fbo_depth_texture);
fullscreen_quad = std::move(other.fullscreen_quad);
fullscreen_quad_ab = std::move(other.fullscreen_quad_ab);
fullscreen_quad_loading = std::move(other.fullscreen_quad_loading);
fullscreen_quad_ab_loading = std::move(other.fullscreen_quad_ab_loading);
cube_size = std::move(other.cube_size);
maxShadowRenderCount = std::move(other.maxShadowRenderCount);
level = std::move(other.level);
number_of_texture_units = std::move(other.number_of_texture_units);
gameStart = std::move(other.gameStart);
loadingScreenWidth = std::move(other.loadingScreenWidth);
loadingScreenHeight = std::move(other.loadingScreenHeight);
renderShadows = std::move(other.renderShadows);
renderFlames = std::move(other.renderFlames);
renderDebug = std::move(other.renderDebug);
renderWorld = std::move(other.renderWorld);
debugDrawer = std::move(other.debugDrawer);
debug_ab = std::move(other.debug_ab);
debug_vao = std::move(other.debug_vao);
debugShader = std::move(other.debugShader);
renderQueue = std::move(other.renderQueue);
}
Graphics& Graphics::operator= (const Graphics &other) {
std::lock(init_mutex, other.init_mutex);
std::lock_guard<std::mutex> self_lock(init_mutex, std::adopt_lock);
std::lock_guard<std::mutex> other_lock(other.init_mutex, std::adopt_lock);
lastLightUpdate = other.lastLightUpdate;
lastWindUpdate = other.lastWindUpdate;
windTarget = other.windTarget;
wind = other.wind;
windDirection = other.windDirection;
windDirectionTarget = other.windDirectionTarget;
textureMovementPosition = other.textureMovementPosition;
windowSize = other.windowSize;
nearPlane = other.nearPlane;
farPlane = other.farPlane;
loadingScreenPath = other.loadingScreenPath;
loadingScreenContinuePath = other.loadingScreenContinuePath;
loadingScreen = other.loadingScreen;
loadingContinueScreen = other.loadingContinueScreen;
closestLights = other.closestLights;
closestFlames = other.closestFlames;
loadingShader = other.loadingShader;
lightingShader = other.lightingShader;
skydomeShader = other.skydomeShader;
depthCubeShader = other.depthCubeShader;
depthShader = other.depthShader;
flameShader = other.flameShader;
flamePostShader = other.flamePostShader;
depth_directionalMaps = other.depth_directionalMaps;
framebuffer_directional = other.framebuffer_directional;
depth_cubeMaps = other.depth_cubeMaps;
framebuffer_cube = other.framebuffer_cube;
framebuffer_light = other.framebuffer_light;
light_fbo_color_texture = other.light_fbo_color_texture;
light_fbo_depth_texture = other.light_fbo_depth_texture;
fullscreen_quad = other.fullscreen_quad;
fullscreen_quad_ab = other.fullscreen_quad_ab;
fullscreen_quad_loading = other.fullscreen_quad_loading;
fullscreen_quad_ab_loading = other.fullscreen_quad_ab_loading;
cube_size = other.cube_size;
maxShadowRenderCount = other.maxShadowRenderCount;
level = other.level;
number_of_texture_units = other.number_of_texture_units;
gameStart = other.gameStart;
loadingScreenWidth = other.loadingScreenWidth;
loadingScreenHeight = other.loadingScreenHeight;
renderShadows = other.renderShadows;
renderFlames = other.renderFlames;
renderDebug = other.renderDebug;
renderWorld = other.renderWorld;
debugDrawer = other.debugDrawer;
debug_ab = other.debug_ab;
debug_vao = other.debug_vao;
debugShader = other.debugShader;
renderQueue = other.renderQueue;
return *this;
}
Graphics& Graphics::operator= (Graphics &&other) {
std::lock(init_mutex, other.init_mutex);
std::lock_guard<std::mutex> self_lock(init_mutex, std::adopt_lock);
std::lock_guard<std::mutex> other_lock(other.init_mutex, std::adopt_lock);
lastLightUpdate = std::move(other.lastLightUpdate);
lastWindUpdate = std::move(other.lastWindUpdate);
windTarget = std::move(other.windTarget);
wind = std::move(other.wind);
windDirection = std::move(other.windDirection);
windDirectionTarget = std::move(other.windDirectionTarget);
textureMovementPosition = std::move(other.textureMovementPosition);
windowSize = std::move(other.windowSize);
nearPlane = std::move(other.nearPlane);
farPlane = std::move(other.farPlane);
loadingScreenPath = std::move(other.loadingScreenPath);
loadingScreenContinuePath = std::move(other.loadingScreenContinuePath);
loadingScreen = std::move(other.loadingScreen);
loadingContinueScreen = std::move(other.loadingContinueScreen);
closestLights = std::move(other.closestLights);
closestFlames = std::move(other.closestFlames);
loadingShader = std::move(other.loadingShader);
lightingShader = std::move(other.lightingShader);
skydomeShader = std::move(other.skydomeShader);
depthCubeShader = std::move(other.depthCubeShader);
depthShader = std::move(other.depthShader);
flameShader = std::move(other.flameShader);
flamePostShader = std::move(other.flamePostShader);
depth_directionalMaps = std::move(other.depth_directionalMaps);
framebuffer_directional = std::move(other.framebuffer_directional);
depth_cubeMaps = std::move(other.depth_cubeMaps);
framebuffer_cube = std::move(other.framebuffer_cube);
framebuffer_light = std::move(other.framebuffer_light);
light_fbo_color_texture = std::move(other.light_fbo_color_texture);
light_fbo_depth_texture = std::move(other.light_fbo_depth_texture);
fullscreen_quad = std::move(other.fullscreen_quad);
fullscreen_quad_ab = std::move(other.fullscreen_quad_ab);
fullscreen_quad_loading = std::move(other.fullscreen_quad_loading);
fullscreen_quad_ab_loading = std::move(other.fullscreen_quad_ab_loading);
cube_size = std::move(other.cube_size);
maxShadowRenderCount = std::move(other.maxShadowRenderCount);
level = std::move(other.level);
number_of_texture_units = std::move(other.number_of_texture_units);
gameStart = std::move(other.gameStart);
loadingScreenWidth = std::move(other.loadingScreenWidth);
loadingScreenHeight = std::move(other.loadingScreenHeight);
renderShadows = std::move(other.renderShadows);
renderFlames = std::move(other.renderFlames);
renderDebug = std::move(other.renderDebug);
renderWorld = std::move(other.renderWorld);
debugDrawer = std::move(other.debugDrawer);
debug_ab = std::move(other.debug_ab);
debug_vao = std::move(other.debug_vao);
debugShader = std::move(other.debugShader);
renderQueue = std::move(other.renderQueue);
return *this;
}
void Graphics::init(Level* level) {
std::lock_guard<std::mutex> lock(init_mutex);
// save Level
this->level = level;
@ -474,7 +250,6 @@ void Graphics::bindTextureUnits(){
}
void Graphics::renderLoadingScreen() {
std::lock_guard<std::mutex> lock(init_mutex);
loadingScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenPath));
loadingScreen->generateMipmaps();
loadingScreen->setMinFilter(GL_NEAREST_MIPMAP_LINEAR);
@ -540,7 +315,6 @@ glm::uvec2 Graphics::getWindowSize() {
void Graphics::render(double time)
{
if (!gameStart) {
std::lock_guard<std::mutex> lock(init_mutex);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
loadingShader->use();
@ -854,7 +628,6 @@ void Graphics::updateLights() {
}
void Graphics::resize(glm::uvec2 windowSize) {
std::lock_guard<std::mutex> lock(init_mutex);
this->windowSize = windowSize;
if (gameStart) {
for (unsigned int i = 0; i<depth_directionalMaps.size(); i++) {

View File

@ -92,7 +92,6 @@ class Graphics {
SharedVertexArrayObject debug_vao;
SharedShaderProgram debugShader;
std::vector<std::vector<std::vector<Object*>>*> renderQueue;
mutable std::mutex init_mutex;
};
#endif

View File

@ -10,136 +10,6 @@ Level::Level(std::string xmlFilePath) {
this->xmlFilePath = xmlFilePath;
}
Level::Level(const Level &&other) {
std::lock_guard<std::mutex> lock(other.light_mutex);
luaState = std::move(other.luaState);
crossChunkObjects = std::move(other.crossChunkObjects);
sortedCrossChunkObjects = std::move(other.sortedCrossChunkObjects);
allObjects = std::move(other.allObjects);
physicsObjects = std::move(other.physicsObjects);
chunks = std::move(other.chunks);
lights = std::move(other.lights);
closestLights = std::move(other.closestLights);
triggers = std::move(other.triggers);
waterPlane = std::move(other.waterPlane);
ambientLight = std::move(other.ambientLight);
fogColourDay = std::move(other.fogColourDay);
fogColourRise = std::move(other.fogColourRise);
fogColourNight = std::move(other.fogColourNight);
directionalLight = std::move(other.directionalLight);
cameraCenter = std::move(other.cameraCenter);
playerIndex = std::move(other.playerIndex);
skydome = std::move(other.skydome);
physics = std::move(other.physics);
camera = std::move(other.camera);
terrain = std::move(other.terrain);
skydomeSize = std::move(other.skydomeSize);
strength = std::move(other.strength);
xmlFilePath = std::move(other.xmlFilePath);
nextLightPosition = std::move(other.nextLightPosition);
chunkSize = std::move(other.chunkSize);
farPlane = std::move(other.farPlane);
}
Level::Level(const Level &other) {
std::lock_guard<std::mutex> lock(other.light_mutex);
luaState = other.luaState;
crossChunkObjects = other.crossChunkObjects;
sortedCrossChunkObjects = other.sortedCrossChunkObjects;
allObjects = other.allObjects;
physicsObjects = other.physicsObjects;
chunks = other.chunks;
lights = other.lights;
closestLights = other.closestLights;
triggers = other.triggers;
waterPlane = other.waterPlane;
ambientLight = other.ambientLight;
fogColourDay = other.fogColourDay;
fogColourRise = other.fogColourRise;
fogColourNight = other.fogColourNight;
directionalLight = other.directionalLight;
cameraCenter = other.cameraCenter;
playerIndex = other.playerIndex;
skydome = other.skydome;
physics = other.physics;
camera = other.camera;
terrain = other.terrain;
skydomeSize = other.skydomeSize;
strength = other.strength;
xmlFilePath = other.xmlFilePath;
nextLightPosition = other.nextLightPosition;
chunkSize = other.chunkSize;
farPlane = other.farPlane;
}
Level& Level::operator= (const Level &other) {
std::lock(light_mutex, other.light_mutex);
std::lock_guard<std::mutex> self_lock(light_mutex, std::adopt_lock);
std::lock_guard<std::mutex> other_lock(other.light_mutex, std::adopt_lock);
luaState = other.luaState;
crossChunkObjects = other.crossChunkObjects;
sortedCrossChunkObjects = other.sortedCrossChunkObjects;
allObjects = other.allObjects;
physicsObjects = other.physicsObjects;
chunks = other.chunks;
lights = other.lights;
closestLights = other.closestLights;
triggers = other.triggers;
waterPlane = other.waterPlane;
ambientLight = other.ambientLight;
fogColourDay = other.fogColourDay;
fogColourRise = other.fogColourRise;
fogColourNight = other.fogColourNight;
directionalLight = other.directionalLight;
cameraCenter = other.cameraCenter;
playerIndex = other.playerIndex;
skydome = other.skydome;
physics = other.physics;
camera = other.camera;
terrain = other.terrain;
skydomeSize = other.skydomeSize;
strength = other.strength;
xmlFilePath = other.xmlFilePath;
nextLightPosition = other.nextLightPosition;
chunkSize = other.chunkSize;
farPlane = other.farPlane;
return *this;
}
Level& Level::operator= (const Level &&other) {
std::lock(light_mutex, other.light_mutex);
std::lock_guard<std::mutex> self_lock(light_mutex, std::adopt_lock);
std::lock_guard<std::mutex> other_lock(other.light_mutex, std::adopt_lock);
luaState = std::move(other.luaState);
crossChunkObjects = std::move(other.crossChunkObjects);
sortedCrossChunkObjects = std::move(other.sortedCrossChunkObjects);
allObjects = std::move(other.allObjects);
physicsObjects = std::move(other.physicsObjects);
chunks = std::move(other.chunks);
lights = std::move(other.lights);
closestLights = std::move(other.closestLights);
triggers = std::move(other.triggers);
waterPlane = std::move(other.waterPlane);
ambientLight = std::move(other.ambientLight);
fogColourDay = std::move(other.fogColourDay);
fogColourRise = std::move(other.fogColourRise);
fogColourNight = std::move(other.fogColourNight);
directionalLight = std::move(other.directionalLight);
cameraCenter = std::move(other.cameraCenter);
playerIndex = std::move(other.playerIndex);
skydome = std::move(other.skydome);
physics = std::move(other.physics);
camera = std::move(other.camera);
terrain = std::move(other.terrain);
skydomeSize = std::move(other.skydomeSize);
strength = std::move(other.strength);
xmlFilePath = std::move(other.xmlFilePath);
nextLightPosition = std::move(other.nextLightPosition);
chunkSize = std::move(other.chunkSize);
farPlane = std::move(other.farPlane);
return *this;
}
Level::Level() {
}
@ -372,7 +242,6 @@ glm::vec3 Level::getAmbientLight() {
}
std::vector<Light*>* Level::getLights() {
std::lock_guard<std::mutex> lock(light_mutex);
return &lights;
}
@ -509,7 +378,6 @@ void Level::setCameraCenter(Object* object) {
}
void Level::addLight(Light light) {
std::lock_guard<std::mutex> lock(light_mutex);
Light *add_light = new Light(light);
this->lights.push_back(add_light);
}
@ -519,13 +387,11 @@ void Level::preloadLightPosition(float xPos, float yPos, float zPos){
}
void Level::addLightByParameters(float redColour, float greenColour, float blueColour, float intensity, float flameYOffset, float flameHeight, float flameWidth){
std::lock_guard<std::mutex> lock(light_mutex);
glm::vec3 colour = glm::vec3(redColour, greenColour, blueColour);
this->lights.push_back(new Light(nextLightPosition, colour, intensity, flameYOffset, flameHeight, flameWidth));
}
void Level::deleteFourLights(){
std::lock_guard<std::mutex> lock(light_mutex);
int indice = lights.size()-4;
lights.erase(lights.begin() + indice);
lights.erase(lights.begin() + indice);
@ -616,7 +482,6 @@ bool Level::compareLightDistances(Light* a, Light* b) {
}
std::vector<Light*>* Level::getClosestLights() {
std::lock_guard<std::mutex> lock(light_mutex);
closestLights = std::vector<Light*>(lights);
std::sort(closestLights.begin(),
closestLights.end(),

View File

@ -118,7 +118,6 @@ class Level {
int chunkSize;
float farPlane;
bool compareLightDistances(Light* a, Light* b);
mutable std::mutex light_mutex;
};
#endif