EscapeTimeVisualWidget.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. #include "EscapeTimeVisualWidget.h"
  2. #include "Bitmap.h"
  3. #include <QOpenGLShaderProgram>
  4. #include <QOpenGLContext>
  5. #include <QOpenGLFunctions>
  6. #include <QOpenGLExtraFunctions>
  7. #include <QOpenGLFunctions_3_0>
  8. #include <QOpenGLFunctions_4_0_Core>
  9. #include <vector>
  10. ETVImage::ETVImage(EscapeTimeVisualWidget& owner,
  11. const Bitmap<float>& img) :
  12. owner{ owner }
  13. {
  14. auto& gl = *owner.context()->functions();
  15. gl.glGenTextures(1, &textureId);
  16. gl.glActiveTexture(GL_TEXTURE0);
  17. gl.glBindTexture(GL_TEXTURE_2D, textureId);
  18. gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, int(img.width), int(img.height), 0, GL_RED, GL_FLOAT, img.pixels.get());
  19. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  20. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  21. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  22. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  23. gl.glBindTexture(GL_TEXTURE_2D, 0);
  24. }
  25. ETVImage::~ETVImage(void)
  26. {
  27. auto& gl = *owner.context()->functions();
  28. gl.glDeleteTextures(1, &textureId);
  29. }
  30. void ETVImage::draw(float x, float y, float w, float h,
  31. float tx, float ty, float tw, float th)
  32. {
  33. auto& gl = *owner.context()->functions();
  34. auto& gle = *owner.context()->extraFunctions();
  35. GLfloat const fbVertices[] = {
  36. 0, 0, 0.0f,
  37. 0, 256, 0.0f,
  38. 256, 0, 0.0f,
  39. 256, 256, 0.0f,
  40. };
  41. GLfloat const vertices[] = {
  42. x, y, 0.0f,
  43. x, y + h, 0.0f,
  44. x + w, y, 0.0f,
  45. x + w, y + h, 0.0f,
  46. };
  47. GLfloat const texCoords[] = {
  48. tx, ty,
  49. tx, ty + th,
  50. tx + tw, ty,
  51. tx + tw, ty + th,
  52. };
  53. GLfloat const fullTexCoords[] = {
  54. 0, 0,
  55. 0, 1,
  56. 1, 0,
  57. 1, 1,
  58. };
  59. QColor color{ 255, 255, 255 };
  60. auto& program = owner.program;
  61. int vertexLoc = program->attributeLocation("vertex");
  62. int texCoordsLoc = program->attributeLocation("texCoord");
  63. int colorLocation = program->uniformLocation("color");
  64. int texLoc = program->uniformLocation("tex");
  65. int gradLoc = program->uniformLocation("gradient");
  66. int gradientScaler = program->uniformLocation("gradientScaler");
  67. int maxIterations = program->uniformLocation("maxIterations");
  68. program->setAttributeArray(vertexLoc, vertices, 3);
  69. program->setAttributeArray(texCoordsLoc, texCoords, 2);
  70. program->enableAttributeArray(vertexLoc);
  71. program->enableAttributeArray(texCoordsLoc);
  72. program->setUniformValue(colorLocation, color);
  73. program->setUniformValue(gradientScaler, 1.0f / float(owner.gradientTextureMax));
  74. program->setUniformValue(maxIterations, float(owner.maxIterations));
  75. gl.glEnable(GL_TEXTURE_2D);
  76. owner.program->bind();
  77. //GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0 };
  78. //gle.glDrawBuffers(1, drawBuffers);
  79. gl.glBindFramebuffer(GL_FRAMEBUFFER, owner.tileFramebuffer);
  80. gl.glDisable(GL_DEPTH_TEST);
  81. if(gl.glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
  82. printf("error intitializing framebuffer\n");
  83. }
  84. gl.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, owner.tileTexture, 0);
  85. //gl.glViewport(0, 0, 256, 256);
  86. gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
  87. gl.glUniform1i(texLoc, 0);
  88. gl.glUniform1i(gradLoc, 2);
  89. gl.glActiveTexture(GL_TEXTURE0);
  90. gl.glBindTexture(GL_TEXTURE_2D, textureId);
  91. gl.glActiveTexture(GL_TEXTURE2);
  92. gl.glBindTexture(GL_TEXTURE_2D, owner.gradientTextureId);
  93. gl.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  94. program->disableAttributeArray(vertexLoc);
  95. program->disableAttributeArray(texCoordsLoc);
  96. /*owner.renderTextures->bind();
  97. gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
  98. //gl.glViewport(0, 0, owner.getResolutionX(), owner.getResolutionY());
  99. int rtVertexLoc = owner.renderTextures->attributeLocation("vertex");
  100. int rtTexCoordsLoc = owner.renderTextures->attributeLocation("texCoord");
  101. int rtTexLoc = owner.renderTextures->attributeLocation("tex");
  102. gl.glActiveTexture(GL_TEXTURE0);
  103. gl.glUniform1i(rtTexLoc, 0);
  104. owner.renderTextures->setAttributeArray(rtVertexLoc, vertices, 3);
  105. owner.renderTextures->setAttributeArray(rtTexCoordsLoc, fullTexCoords, 2);
  106. owner.renderTextures->enableAttributeArray(rtVertexLoc);
  107. owner.renderTextures->enableAttributeArray(rtTexCoordsLoc);
  108. gl.glBindTexture(GL_TEXTURE_2D, owner.tileTexture);
  109. //if (rand() % 2)
  110. //gl.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  111. owner.renderTextures->disableAttributeArray(rtVertexLoc);
  112. owner.renderTextures->disableAttributeArray(rtTexCoordsLoc);
  113. */
  114. gl.glActiveTexture(GL_TEXTURE0);
  115. }
  116. EscapeTimeVisualWidget::EscapeTimeVisualWidget(QWidget* parent) :
  117. QOpenGLWidget{ parent },
  118. gradientTextureId{ 0 },
  119. gradientTextureMax{ 1.0f },
  120. gradientNeedsUpdate{ false }
  121. {
  122. }
  123. void EscapeTimeVisualWidget::setGradient(Gradient newGradient)
  124. {
  125. this->gradient = newGradient;
  126. gradientNeedsUpdate = true;
  127. update();
  128. }
  129. const Gradient& EscapeTimeVisualWidget::getGradient(void)
  130. {
  131. return gradient;
  132. }
  133. void EscapeTimeVisualWidget::initializeGL(void)
  134. {
  135. auto& gl = *this->context()->functions();
  136. gl.glClearColor(0, 0, 0, 0);
  137. gl.glDisable(GL_DEPTH_TEST);
  138. // looks not even better
  139. //gl.glEnable(GL_FRAMEBUFFER_SRGB);
  140. //glShadeModel(GL_SMOOTH);
  141. renderTextures = new QOpenGLShaderProgram{ this->context() };
  142. renderTextures->addShaderFromSourceCode(QOpenGLShader::Vertex,
  143. "attribute highp vec4 vertex;\n"
  144. "attribute highp vec2 texCoord;\n"
  145. "uniform highp mat4 matrix;\n"
  146. "varying highp vec2 texc;\n"
  147. "void main(void)\n"
  148. "{\n"
  149. " gl_Position = matrix * vertex;\n"
  150. " texc = texCoord;\n"
  151. "}");
  152. renderTextures->addShaderFromSourceCode(QOpenGLShader::Fragment,
  153. "#version 110\n"
  154. "uniform sampler2D tex;\n"
  155. "varying highp vec2 texc;\n"
  156. "void main(void)\n"
  157. "{\n"
  158. " gl_FragColor = texture2D(tex, texc);\n"
  159. "}");
  160. renderTextures->link();
  161. juliaPreviewer = new QOpenGLShaderProgram{ this->context() };
  162. juliaPreviewer->addShaderFromSourceCode(QOpenGLShader::Vertex,
  163. "attribute highp vec4 vertex;\n"
  164. "attribute highp vec2 texCoord;\n"
  165. "uniform highp mat4 matrix;\n"
  166. "varying highp vec2 texc;\n"
  167. "void main(void)\n"
  168. "{\n"
  169. " gl_Position = matrix * vertex;\n"
  170. " texc = texCoord;\n"
  171. "}");
  172. juliaPreviewer->addShaderFromSourceCode(QOpenGLShader::Fragment,
  173. "#version 110\n"
  174. "uniform sampler2D gradient;\n"
  175. "uniform highp float gradientScaler;\n"
  176. "uniform highp float maxIterations;\n"
  177. "varying highp vec2 texc;\n"
  178. "uniform highp float juliaX;\n"
  179. "uniform highp float juliaY;\n"
  180. "const highp float left = -1.5;\n"
  181. "const highp float right = 1.5;\n"
  182. "const highp float top = -1.5;\n"
  183. "const highp float bottom = 1.5;\n"
  184. "float map(float a, float b, float v) {\n"
  185. " return (1.0 - v) * a + b * v;\n"
  186. "}\n"
  187. "float iterate(float x, float y, float ca, float cb) {\n"
  188. " int k = 0;\n"
  189. " float a = x;\n"
  190. " float b = y;\n"
  191. " while(k <= 250) {\n"
  192. " float aa = a * a;\n"
  193. " float bb = b * b;\n"
  194. " float abab = 2 * a * b;\n"
  195. " a = aa - bb + ca;\n"
  196. " b = abab + cb;\n"
  197. " if (aa + bb >= 16.0f) break;\n"
  198. " k = k + 1;\n"
  199. " }\n"
  200. " return float(k);\n"
  201. "}\n"
  202. "void main(void)\n"
  203. "{\n"
  204. " float x = map(left, right, texc.x);\n"
  205. " float y = map(top, bottom, texc.y);\n"
  206. " float v = iterate(x, y, juliaX, juliaY);\n"
  207. // " if (v >= maxIterations) { v = 0.0; }\n"
  208. " float vnorm = v * gradientScaler;\n"
  209. " gl_FragColor = texture2D(gradient, vec2(vnorm, 0.0));\n"
  210. //" gl_FragColor = vec4(vnorm, 0.0, 0.0, 0.0);\n"
  211. "}");
  212. juliaPreviewer->link();
  213. program = new QOpenGLShaderProgram{ this->context() };
  214. bool vert = program->addShaderFromSourceCode(QOpenGLShader::Vertex,
  215. "attribute highp vec4 vertex;\n"
  216. "attribute highp vec2 texCoord;\n"
  217. "uniform highp mat4 matrix;\n"
  218. "varying highp vec2 texc;\n"
  219. "void main(void)\n"
  220. "{\n"
  221. " gl_Position = matrix * vertex;\n"
  222. " texc = texCoord;\n"
  223. "}");
  224. // TODO rewrite this monster
  225. if (context()->versionFunctions<QOpenGLFunctions_4_0_Core>() != nullptr) {
  226. bool frag = program->addShaderFromSourceCode(QOpenGLShader::Fragment,
  227. "#version 400\n"
  228. "uniform sampler2D gradient;\n"
  229. "uniform sampler2D tex;\n"
  230. "uniform mediump vec4 color;\n"
  231. "uniform highp float gradientScaler;\n"
  232. "uniform highp float maxIterations;\n"
  233. "varying highp vec2 texc;\n"
  234. "vec4 colorize(float pos) {\n"
  235. " if (pos >= maxIterations) {\n"
  236. " return vec4(0.0, 0.0, 0.0, 1.0);\n"
  237. " } else {\n"
  238. " return texture2D(gradient, vec2(pos * gradientScaler, 0.0));\n"
  239. " }\n"
  240. "}\n"
  241. "void main(void)\n"
  242. "{\n"
  243. " vec2 size = textureSize(tex, 0);\n"
  244. " size = vec2(256.0, 256.0);\n"
  245. " vec2 accPoint = texc * size;\n"
  246. " vec2 ip = floor(accPoint);\n"
  247. " vec2 fp = fract(accPoint);\n"
  248. " vec4 inter = textureGather(tex, ip / size, 0);\n"
  249. " vec4 col1 = colorize(inter.x);\n"
  250. " vec4 col2 = colorize(inter.y);\n"
  251. " vec4 col3 = colorize(inter.z);\n"
  252. " vec4 col4 = colorize(inter.w);\n"
  253. " vec4 col = mix(mix(col4, col3, fp.x), mix(col1, col2, fp.x), fp.y);\n"
  254. " gl_FragColor = col;\n"
  255. // " gl_FragColor = gl_FragColor * texture2D(tex, texc);\n"
  256. // " float v = texture2D(tex, texc).r;\n"
  257. // " gl_FragColor = vec4(v, 1.0 - v, v*v, 1);\n"
  258. // " gl_FragColor.g = 0.3;\n"
  259. "}");
  260. }
  261. else {
  262. bool frag = program->addShaderFromSourceCode(QOpenGLShader::Fragment,
  263. "#version 110\n"
  264. "uniform sampler2D gradient;\n"
  265. "uniform sampler2D tex;\n"
  266. "uniform mediump vec4 color;\n"
  267. "uniform highp float gradientScaler;\n"
  268. "uniform highp float maxIterations;\n"
  269. "varying highp vec2 texc;\n"
  270. "void main(void)\n"
  271. "{\n"
  272. " float v = texture2D(tex, texc).r;\n"
  273. " if (v >= maxIterations) {\n"
  274. " gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n"
  275. " } else {\n"
  276. " gl_FragColor = texture2D(gradient, vec2(v * gradientScaler, 0.0));\n"
  277. " }\n"
  278. // " gl_FragColor = gl_FragColor * texture2D(tex, texc);\n"
  279. // " float v = texture2D(tex, texc).r;\n"
  280. // " gl_FragColor = vec4(v, 1.0 - v, v*v, 1);\n"
  281. // " gl_FragColor.g = 0.3;\n"
  282. "}");
  283. }
  284. //program.link();
  285. bool bound = program->bind();
  286. bound = renderTextures->bind();
  287. int vertexLoc = program->attributeLocation("vertex");
  288. int texCoordsLoc = program->attributeLocation("texCoord");
  289. int colorLocation = program->uniformLocation("color");
  290. int texLoc = program->uniformLocation("tex");
  291. int gradLoc = program->uniformLocation("gradient");
  292. int gradientScaler = program->uniformLocation("gradientScaler");
  293. int maxIterations = program->uniformLocation("maxIterations");
  294. program->setUniformValue(gradientScaler, 0.005f);
  295. program->setUniformValue(maxIterations, 250.0f);
  296. auto& gle = *this->context()->extraFunctions();
  297. gl.glGenTextures(1, &tileTexture);
  298. gl.glBindTexture(GL_TEXTURE_2D, tileTexture);
  299. gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
  300. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  301. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  302. gl.glBindTexture(GL_TEXTURE_2D, 0);
  303. gl.glGenFramebuffers(1, &tileFramebuffer);
  304. gl.glBindFramebuffer(GL_FRAMEBUFFER, tileFramebuffer);
  305. gl.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tileTexture, 0);
  306. GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0 };
  307. gle.glDrawBuffers(1, drawBuffers);
  308. if(gl.glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
  309. printf("error intitializing framebuffer\n");
  310. }
  311. gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
  312. unsigned char pix[] = { 255, 0, 0, 0, 255, 0, 0, 0, 255 };
  313. GLuint id;
  314. gl.glEnable(GL_TEXTURE_2D);
  315. gl.glGenTextures(1, &id);
  316. gl.glBindTexture(GL_TEXTURE_2D, id);
  317. gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 3, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, reinterpret_cast<char*> (pix));
  318. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  319. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  320. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  321. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  322. gl.glBindTexture(GL_TEXTURE_2D, 0);
  323. gradientTextureId = id;
  324. gl.glDisable(GL_DEPTH_TEST);
  325. //gl3.glBindSampler(0, id);
  326. }
  327. void EscapeTimeVisualWidget::resizeGL(int w, int h)
  328. {
  329. auto& gl = *this->context()->functions();
  330. float pixelRatio = this->devicePixelRatioF();
  331. //pixelRatio = 1.0 / 32;
  332. float newW = w * pixelRatio;
  333. float newH = h * pixelRatio;
  334. setResolutionX(newW);
  335. setResolutionY(newH);
  336. gl.glViewport(0, 0, newW, newH);
  337. QMatrix4x4 pmvMatrix;
  338. pmvMatrix.ortho(QRectF{ 0, 0, newW, newH });
  339. int matrixLocation = program->uniformLocation("matrix");
  340. int rtMatrixLocation = renderTextures->uniformLocation("matrix");
  341. int jMatrixLocation = juliaPreviewer->uniformLocation("matrix");
  342. program->setUniformValue(matrixLocation, pmvMatrix);
  343. renderTextures->setUniformValue(rtMatrixLocation, pmvMatrix);
  344. juliaPreviewer->setUniformValue(jMatrixLocation, pmvMatrix);
  345. }
  346. void EscapeTimeVisualWidget::paintGL(void)
  347. {
  348. if (gradientNeedsUpdate)
  349. updateGradient();
  350. /*ETVImage etvi{ *this };
  351. auto& gl = *this->context()->functions();
  352. gl.glClearColor(0.0, 0.2, 0.0, 1.0);
  353. gl.glClear(GL_COLOR_BUFFER_BIT);
  354. etvi.draw(100, 100, 700, 700);*/
  355. }
  356. void EscapeTimeVisualWidget::drawJulia(float jx, float jy)
  357. {
  358. int gradLoc = juliaPreviewer->uniformLocation("gradient");
  359. int gradientScaler = juliaPreviewer->uniformLocation("gradientScaler");
  360. int juliaX = juliaPreviewer->uniformLocation("juliaX");
  361. int juliaY = juliaPreviewer->uniformLocation("juliaY");
  362. int vertexLoc = juliaPreviewer->attributeLocation("vertex");
  363. int texCoordsLoc = juliaPreviewer->attributeLocation("texCoord");
  364. int maxIterLoc = juliaPreviewer->attributeLocation("maxIterations");
  365. const float x = 100;
  366. const float y = 100;
  367. const float w = 200;
  368. const float h = 200;
  369. GLfloat const vertices[] = {
  370. x, y, 0.0f,
  371. x, y + h, 0.0f,
  372. x + w, y, 0.0f,
  373. x + w, y + h, 0.0f,
  374. };
  375. GLfloat const texCoords[] = {
  376. 0, 0,
  377. 0, 1,
  378. 1, 0,
  379. 1, 1,
  380. };
  381. auto& gl = *this->context()->functions();
  382. gl.glEnable(GL_TEXTURE_2D);
  383. gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
  384. juliaPreviewer->setAttributeArray(vertexLoc, vertices, 3);
  385. juliaPreviewer->setAttributeArray(texCoordsLoc, texCoords, 2);
  386. juliaPreviewer->enableAttributeArray(vertexLoc);
  387. juliaPreviewer->enableAttributeArray(texCoordsLoc);
  388. juliaPreviewer->setUniformValue(gradientScaler, 1.0f / float(gradientTextureMax));
  389. juliaPreviewer->setUniformValue(maxIterLoc, float(250));
  390. juliaPreviewer->setUniformValue(juliaX, float(jx));
  391. juliaPreviewer->setUniformValue(juliaY, float(jy));
  392. juliaPreviewer->bind();
  393. gl.glUniform1i(gradLoc, 0);
  394. gl.glActiveTexture(GL_TEXTURE0);
  395. gl.glBindTexture(GL_TEXTURE_2D, gradientTextureId);
  396. gl.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  397. juliaPreviewer->disableAttributeArray(vertexLoc);
  398. juliaPreviewer->disableAttributeArray(texCoordsLoc);
  399. //juliaPreviewer->release();
  400. //program->bind();
  401. }
  402. void EscapeTimeVisualWidget::setMaxIterationCutoff(float maxIter)
  403. {
  404. this->maxIterations = maxIter;
  405. }
  406. void EscapeTimeVisualWidget::updateGradient(void)
  407. {
  408. auto& gl = *this->context()->functions();
  409. const int len = 1024;
  410. std::unique_ptr<uint8_t[]> pixels = std::make_unique<uint8_t[]>(len * 3);
  411. for (int i = 0; i < len; i++) {
  412. RGBColor c = gradient.get(gradient.getMax() * i / len);
  413. pixels[i * 3] = c.r;
  414. pixels[i * 3 + 1] = c.g;
  415. pixels[i * 3 + 2] = c.b;
  416. }
  417. gl.glEnable(GL_TEXTURE_2D);
  418. gl.glBindTexture(GL_TEXTURE_2D, gradientTextureId);
  419. gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, len, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, reinterpret_cast<unsigned char*> (pixels.get()));
  420. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  421. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  422. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  423. gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  424. gl.glBindTexture(GL_TEXTURE_2D, 0);
  425. this->gradientTextureMax = gradient.getMax();
  426. gradientNeedsUpdate = false;
  427. }
  428. void EscapeTimeVisualWidget::setResolutionX(int w)
  429. {
  430. resolutionX = w;
  431. }
  432. void EscapeTimeVisualWidget::setResolutionY(int h)
  433. {
  434. resolutionY = h;
  435. }
  436. int EscapeTimeVisualWidget::getResolutionX(void) const
  437. {
  438. return resolutionX;
  439. }
  440. int EscapeTimeVisualWidget::getResolutionY(void) const
  441. {
  442. return resolutionY;
  443. }