mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-07-04 18:52:51 +00:00
more responsible texture drawing
This commit is contained in:
parent
a192f40bff
commit
44b26d7de0
35
textures.cpp
35
textures.cpp
@ -60,6 +60,7 @@ struct undo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
vector<pair<unsigned*, unsigned>> undos;
|
vector<pair<unsigned*, unsigned>> undos;
|
||||||
|
vector<tuple<cell*, hyperpoint, int> > pixels_to_draw;
|
||||||
|
|
||||||
template<class T, class U> void scale_colorarray(int origdim, const T& src, const U& dest) {
|
template<class T, class U> void scale_colorarray(int origdim, const T& src, const U& dest) {
|
||||||
int ox = 0, tx = 0, partials[4];
|
int ox = 0, tx = 0, partials[4];
|
||||||
@ -106,6 +107,7 @@ bool whitetexture() {
|
|||||||
undos.clear();
|
undos.clear();
|
||||||
texture_pixels.resize(0);
|
texture_pixels.resize(0);
|
||||||
texture_pixels.resize(twidth * twidth, 0xFFFFFFFF);
|
texture_pixels.resize(twidth * twidth, 0xFFFFFFFF);
|
||||||
|
pixels_to_draw.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,15 +923,6 @@ void showMenu() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
int lastupdate;
|
|
||||||
|
|
||||||
void update() {
|
|
||||||
if(lastupdate && ticks > lastupdate + 50) {
|
|
||||||
loadTextureGL();
|
|
||||||
lastupdate = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef pair<int,int> point;
|
typedef pair<int,int> point;
|
||||||
|
|
||||||
point ptc(hyperpoint h) {
|
point ptc(hyperpoint h) {
|
||||||
@ -1049,8 +1042,7 @@ void fillcircle(hyperpoint h, int col) {
|
|||||||
|
|
||||||
bool texturesym = false;
|
bool texturesym = false;
|
||||||
|
|
||||||
void drawPixel(cell *c, hyperpoint h, int col) {
|
void actDrawPixel(cell *c, hyperpoint h, int col) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
transmatrix M = gmatrix.at(c);
|
transmatrix M = gmatrix.at(c);
|
||||||
auto si = patterns::getpatterninfo0(c);
|
auto si = patterns::getpatterninfo0(c);
|
||||||
@ -1060,12 +1052,15 @@ void drawPixel(cell *c, hyperpoint h, int col) {
|
|||||||
fillcircle(M2 * spin(2 * M_PI * i / c->type) * h, col);
|
fillcircle(M2 * spin(2 * M_PI * i / c->type) * h, col);
|
||||||
if(texturesym)
|
if(texturesym)
|
||||||
fillcircle(M2 * spin(2 * M_PI * i / c->type) * Mirror * h, col);
|
fillcircle(M2 * spin(2 * M_PI * i / c->type) * Mirror * h, col);
|
||||||
lastupdate = ticks;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(out_of_range) {}
|
catch(out_of_range) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawPixel(cell *c, hyperpoint h, int col) {
|
||||||
|
pixels_to_draw.emplace_back(c, h, col);
|
||||||
|
}
|
||||||
|
|
||||||
void remap(eTextureState old_tstate, eTextureState old_tstate_max) {
|
void remap(eTextureState old_tstate, eTextureState old_tstate_max) {
|
||||||
if(!patterns::compatible(texture::cgroup, patterns::cgroup)) return;
|
if(!patterns::compatible(texture::cgroup, patterns::cgroup)) return;
|
||||||
texture_map.clear();
|
texture_map.clear();
|
||||||
@ -1142,8 +1137,22 @@ int textureArgs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto texture_hook =
|
auto texture_hook =
|
||||||
addHook(hooks_args, 100, textureArgs);
|
addHook(hooks_args, 100, textureArgs)
|
||||||
|
+ addHook(clearmemory, 100, [] () { pixels_to_draw.clear(); });
|
||||||
|
|
||||||
|
int lastupdate;
|
||||||
|
|
||||||
|
void update() {
|
||||||
|
if(!pixels_to_draw.empty()) {
|
||||||
|
auto t = SDL_GetTicks();
|
||||||
|
while(SDL_GetTicks() < t + 75 && !pixels_to_draw.empty()) {
|
||||||
|
auto p = pixels_to_draw.back();
|
||||||
|
actDrawPixel(get<0>(p), get<1>(p), get<2>(p));
|
||||||
|
pixels_to_draw.pop_back();
|
||||||
|
}
|
||||||
|
loadTextureGL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user