src/gl/gridprogram.cpp

changeset 167
c1ff4f107569
parent 156
65b75beed7e0
child 216
c7241f504117
--- a/src/gl/gridprogram.cpp	Sat Mar 05 13:59:54 2022 +0200
+++ b/src/gl/gridprogram.cpp	Sat Mar 05 15:40:43 2022 +0200
@@ -18,7 +18,6 @@
 
 #include "gridprogram.h"
 
-// Based on https://stackoverflow.com/q/30842755
 const char vertexShaderSource[] = R"(
 #version 330 core
 
@@ -56,16 +55,17 @@
 GridProgram::GridProgram(QObject *parent) :
 	AbstractBasicShaderProgram{parent}
 {
-	this->gridData.reserve(8004);
-	for (int i = -1000; i < 1000; i += 1)
+	constexpr int extent = 50;
+	this->gridData.reserve(8 * extent + 4);
+	for (int i = -extent; i <= extent; i += 1)
 	{
-		this->gridData.push_back({i, -1000});
-		this->gridData.push_back({i, 1000});
+		this->gridData.push_back({i, -extent});
+		this->gridData.push_back({i, extent});
 	}
-	for (int i = -1000; i < 1000; i += 1)
+	for (int i = -extent; i <= extent; i += 1)
 	{
-		this->gridData.push_back({-1000, i});
-		this->gridData.push_back({1000, i});
+		this->gridData.push_back({-extent, i});
+		this->gridData.push_back({extent, i});
 	}
 }
 

mercurial