|
|
|
@ -1,9 +1,7 @@
|
|
|
|
|
//original file from https://github.com/Baughn/Dwarf-Fortress--libgraphics-
|
|
|
|
|
#ifndef RENDERER_OPENGL_INCLUDED
|
|
|
|
|
#define RENDERER_OPENGL_INCLUDED
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "tinythread.h"
|
|
|
|
|
#include "fast_mutex.h"
|
|
|
|
|
|
|
|
|
|
#include "Core.h"
|
|
|
|
|
#include <VTableInterpose.h>
|
|
|
|
@ -15,6 +13,7 @@
|
|
|
|
|
#include "df/graphic.h"
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
|
|
using df::renderer;
|
|
|
|
|
using df::init;
|
|
|
|
@ -281,7 +280,7 @@ private:
|
|
|
|
|
}
|
|
|
|
|
void reinitLightGrid(int w,int h)
|
|
|
|
|
{
|
|
|
|
|
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
|
|
|
|
|
std::lock_guard<std::mutex> guard{dataMutex};
|
|
|
|
|
lightGrid.resize(w*h);
|
|
|
|
|
}
|
|
|
|
|
void reinitLightGrid()
|
|
|
|
@ -289,7 +288,7 @@ private:
|
|
|
|
|
reinitLightGrid(df::global::gps->dimy,df::global::gps->dimx);
|
|
|
|
|
}
|
|
|
|
|
public:
|
|
|
|
|
tthread::fast_mutex dataMutex;
|
|
|
|
|
std::mutex dataMutex;
|
|
|
|
|
std::vector<rgbf> lightGrid;
|
|
|
|
|
renderer_test(renderer* parent):renderer_wrap(parent)
|
|
|
|
|
{
|
|
|
|
@ -297,14 +296,14 @@ public:
|
|
|
|
|
}
|
|
|
|
|
virtual void update_tile(int32_t x, int32_t y) {
|
|
|
|
|
renderer_wrap::update_tile(x,y);
|
|
|
|
|
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
|
|
|
|
|
std::lock_guard<std::mutex> guard{dataMutex};
|
|
|
|
|
colorizeTile(x,y);
|
|
|
|
|
//some sort of mutex or sth?
|
|
|
|
|
//and then map read
|
|
|
|
|
};
|
|
|
|
|
virtual void update_all() {
|
|
|
|
|
renderer_wrap::update_all();
|
|
|
|
|
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
|
|
|
|
|
std::lock_guard<std::mutex> guard{dataMutex};
|
|
|
|
|
for (int x = 0; x < df::global::gps->dimx; x++)
|
|
|
|
|
for (int y = 0; y < df::global::gps->dimy; y++)
|
|
|
|
|
colorizeTile(x,y);
|
|
|
|
@ -366,7 +365,7 @@ private:
|
|
|
|
|
}
|
|
|
|
|
void reinitGrids(int w,int h)
|
|
|
|
|
{
|
|
|
|
|
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
|
|
|
|
|
std::lock_guard<std::mutex> guard{dataMutex};
|
|
|
|
|
foreOffset.resize(w*h);
|
|
|
|
|
foreMult.resize(w*h);
|
|
|
|
|
backOffset.resize(w*h);
|
|
|
|
@ -377,7 +376,7 @@ private:
|
|
|
|
|
reinitGrids(df::global::gps->dimy,df::global::gps->dimx);
|
|
|
|
|
}
|
|
|
|
|
public:
|
|
|
|
|
tthread::fast_mutex dataMutex;
|
|
|
|
|
std::mutex dataMutex;
|
|
|
|
|
std::vector<rgbf> foreOffset,foreMult;
|
|
|
|
|
std::vector<rgbf> backOffset,backMult;
|
|
|
|
|
inline int xyToTile(int x, int y)
|
|
|
|
@ -390,14 +389,14 @@ public:
|
|
|
|
|
}
|
|
|
|
|
virtual void update_tile(int32_t x, int32_t y) {
|
|
|
|
|
renderer_wrap::update_tile(x,y);
|
|
|
|
|
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
|
|
|
|
|
std::lock_guard<std::mutex> guard{dataMutex};
|
|
|
|
|
overwriteTile(x,y);
|
|
|
|
|
//some sort of mutex or sth?
|
|
|
|
|
//and then map read
|
|
|
|
|
};
|
|
|
|
|
virtual void update_all() {
|
|
|
|
|
renderer_wrap::update_all();
|
|
|
|
|
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
|
|
|
|
|
std::lock_guard<std::mutex> guard{dataMutex};
|
|
|
|
|
for (int x = 0; x < df::global::gps->dimx; x++)
|
|
|
|
|
for (int y = 0; y < df::global::gps->dimy; y++)
|
|
|
|
|
overwriteTile(x,y);
|
|
|
|
@ -414,4 +413,3 @@ public:
|
|
|
|
|
reinitGrids(w,h);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
#endif
|