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