History

No need to use a texture for the cursor; we can just use a fragment shader.

Andrzej Kapolka committed 12 years ago

Commit b7b1b011 parent 69301743 files · +18 −47Browse files

Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 3 files). Show all

Unified · Split

interface/src/MetavoxelSystem.cpp+2−38
@@ -31,10 +31,6 @@ REGISTER_META_OBJECT(StaticModelRenderer) · 30 unmodified lines
3131
3232 static int bufferPointVectorMetaTypeId = qRegisterMetaType<BufferPointVector>();
3333
34−MetavoxelSystem::MetavoxelSystem() :
35− _cursorTexture(QOpenGLTexture::Target2D) {
36−}
37−
3834 void MetavoxelSystem::init() {
3935 MetavoxelClientManager::init();
4036 DefaultMetavoxelRendererImplementation::init();
@@ -155,33 +151,6 @@ int HeightfieldCursorRenderVisitor::visit(MetavoxelInfo& info) { · 114 unmodified lines
155151 }
156152
157153 void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float radius) {
158− // create the cursor texture lazily
159− if (!_cursorTexture.isCreated()) {
160− const int CURSOR_TEXTURE_SIZE = 512;
161− QImage cursorImage(CURSOR_TEXTURE_SIZE, CURSOR_TEXTURE_SIZE, QImage::Format_ARGB32_Premultiplied);
162− cursorImage.fill(0x0);
163− {
164− QPainter painter(&cursorImage);
165− const int ELLIPSE_EDGE = 10;
166− const int OUTER_WIDTH = 10;
167− QPen outerPen;
168− outerPen.setWidth(OUTER_WIDTH);
169− painter.setPen(outerPen);
170− const int HALF_TEXTURE_SIZE = CURSOR_TEXTURE_SIZE / 2;
171− painter.drawEllipse(QPoint(HALF_TEXTURE_SIZE, HALF_TEXTURE_SIZE), HALF_TEXTURE_SIZE - ELLIPSE_EDGE,
172− HALF_TEXTURE_SIZE - ELLIPSE_EDGE);
173− QPen innerPen(Qt::white);
174− const int INNER_WIDTH = 6;
175− innerPen.setWidth(INNER_WIDTH);
176− painter.setPen(innerPen);
177− painter.drawEllipse(QPoint(HALF_TEXTURE_SIZE, HALF_TEXTURE_SIZE), HALF_TEXTURE_SIZE - ELLIPSE_EDGE,
178− HALF_TEXTURE_SIZE - ELLIPSE_EDGE);
179− }
180− _cursorTexture.setData(cursorImage, QOpenGLTexture::DontGenerateMipMaps);
181− _cursorTexture.setWrapMode(QOpenGLTexture::ClampToEdge);
182− _cursorTexture.setMinificationFilter(QOpenGLTexture::Linear);
183− }
184−
185154 glDepthFunc(GL_LEQUAL);
186155 glEnable(GL_CULL_FACE);
187156 glEnable(GL_POLYGON_OFFSET_FILL);
@@ -196,21 +165,16 @@ void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float r · 8 unmodified lines
196165
197166 glActiveTexture(GL_TEXTURE4);
198167 float scale = 1.0f / radius;
199− glm::vec4 sCoefficients(scale, 0.0f, 0.0f, 0.5f - scale * position.x);
200− glm::vec4 tCoefficients(0.0f, 0.0f, scale, 0.5f - scale * position.z);
168+ glm::vec4 sCoefficients(scale, 0.0f, 0.0f, -scale * position.x);
169+ glm::vec4 tCoefficients(0.0f, 0.0f, scale, -scale * position.z);
201170 glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&sCoefficients);
202171 glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&tCoefficients);
203−
204− _cursorTexture.bind(1);
205172 glActiveTexture(GL_TEXTURE0);
206173
207174 glm::vec3 extents(radius, radius, radius);
208175 HeightfieldCursorRenderVisitor visitor(getLOD(), Box(position - extents, position + extents));
209176 guideToAugmented(visitor);
210177
211− _cursorTexture.release(1);
212− glActiveTexture(GL_TEXTURE0);
213−
214178 DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().release();
215179
216180 glDisableClientState(GL_TEXTURE_COORD_ARRAY);