From dac4f6fc75119a1952ab7119afa1a683d7e79585 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 14 Aug 2018 09:15:17 +0200 Subject: [PATCH] texture:: vid.stretch parameter applied correctly --- hyper.h | 1 + textures.cpp | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/hyper.h b/hyper.h index 56aba74e..bd3cb484 100644 --- a/hyper.h +++ b/hyper.h @@ -2866,6 +2866,7 @@ namespace texture { void mapTexture2(textureinfo& mi); void finish_mapping(); void remap(eTextureState old_tstate, eTextureState old_tstate_max); + hyperpoint texture_coordinates(hyperpoint); void drawRawTexture(); void saveFullTexture(string tn); diff --git a/textures.cpp b/textures.cpp index 40c292e6..44067dbe 100644 --- a/textures.cpp +++ b/textures.cpp @@ -216,6 +216,18 @@ void texture_data::saveRawTexture(string tn) { addMessage(XLAT("Saved the raw texture to %1", tn)); } +hyperpoint texture_config::texture_coordinates(hyperpoint h) { + hyperpoint inmodel; + applymodel(h, inmodel); + inmodel[0] *= vid.radius * 1. / vid.scrsize; + inmodel[1] *= vid.radius * vid.stretch / vid.scrsize; + inmodel[2] = 1; + inmodel = itt * inmodel; + inmodel[0] = (inmodel[0] + 1) / 2; + inmodel[1] = (inmodel[1] + 1) / 2; + return inmodel; + } + void texture_config::mapTextureTriangle(textureinfo &mi, const array& v, const array& tv, int splits) { if(splits) { @@ -231,11 +243,7 @@ void texture_config::mapTextureTriangle(textureinfo &mi, const array((inmodel[0]+1)/2, (inmodel[1]+1)/2, 0)); + mi.tvertices.push_back(glhr::pointtogl(texture_coordinates(tv[i]))); } // when reading a spherical band in a cylindrical projection, @@ -857,6 +865,7 @@ void init_textureconfig() { addsaver(vid.alpha, "projection", 1); addsaver(vid.scale, "scale", 1); + addsaver(vid.stretch, "stretch", 1); addsaver(config.texturename, "texture filename", ""); addsaver(config.texture_tuner, "texture tuning", ""); @@ -1020,13 +1029,14 @@ void showMagicMenu() { char letter = 'A'; for(auto& am: amp) { hyperpoint h = shmup::ggmatrix(am.c) * am.cell_relative; - display(h); queuechr(h, vid.fsize, letter, 0xC00000, 1); + /* hyperpoint inmodel; applymodel(h, inmodel); inmodel[0] *= vid.radius * 1. / vid.scrsize; inmodel[1] *= vid.radius * 1. / vid.scrsize; + */ queuechr( vid.xcenter + vid.scrsize * am.texture_coords[0], @@ -1288,14 +1298,8 @@ void showMenu() { typedef pair point; point ptc(hyperpoint h) { - hyperpoint inmodel; - applymodel(h, inmodel); - inmodel = config.itt * inmodel; - inmodel[0] *= vid.radius * 1. / vid.scrsize; - inmodel[1] *= vid.radius * 1. / vid.scrsize; - int x = (1 + inmodel[0]) * config.data.twidth / 2; - int y = (1 + inmodel[1]) * config.data.twidth / 2; - return make_pair(x,y); + hyperpoint inmodel = config.texture_coordinates(h); + return make_pair(int(inmodel[0] * config.data.twidth), int(inmodel[1] * config.data.twidth)); } array ptc(const array& h) {