Issue #2680 Fixed various OpenGL errors
Change-Id: I7ed70adcb1591a9feb66a4fe80c3249f2e6b339b (cherry picked from commit 431ffa97ae4b1c9159c4607e51dbed23c77b76d2 [formerlyf4765d1577
] [formerly83c600ada9
[formerly 59d4c2b9965a7c208863af8f5a3ba4145ea2bbf4]]) Former-commit-id:0c840cf724
[formerly 6c3817256b4cf6b5deca8d73d0df1d1f89b4ea82] Former-commit-id:d566ed9927
This commit is contained in:
parent
604a4363a3
commit
f5ff746126
7 changed files with 55 additions and 48 deletions
|
@ -11,22 +11,20 @@ uniform float bkgrndGreen;
|
|||
uniform float bkgrndBlue;
|
||||
|
||||
void main(void){
|
||||
sampler1D colorMap = colorMapping.colorMap;
|
||||
float logFactor = colorMapping.logFactor;
|
||||
int applyMask = colorMapping.applyMask;
|
||||
sampler1D alphaMask = colorMapping.alphaMask;
|
||||
|
||||
// Lookup color in colorMap for index
|
||||
float index = gl_TexCoord[0].s;
|
||||
if ( logFactor > 0.0 ) {
|
||||
index = getLogFactorIndex(index, logFactor);
|
||||
}
|
||||
vec4 color = texture1D(colorMap, index).rgba;
|
||||
vec4 color = texture1D(colorMapping.colorMap, index).rgba;
|
||||
|
||||
// Apply alpha mask if set
|
||||
float alpha = color.a;
|
||||
if ( applyMask == 1 ) {
|
||||
if ( texture1D(alphaMask , index ).r != 0.0 ) {
|
||||
if ( texture1D(colorMapping.alphaMask , index ).r != 0.0 ) {
|
||||
color = vec4(bkgrndRed, bkgrndGreen, bkgrndBlue, alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ float valueToLogIndex(float value, float rangeMin, float rangeMax) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
double index = (log(value) - log(rangeMin))
|
||||
float index = (log(value) - log(rangeMin))
|
||||
/ (log(rangeMax) - log(rangeMin));
|
||||
if (reverse != 0) {
|
||||
index = -index;
|
||||
|
|
|
@ -110,8 +110,7 @@ public class GLStats {
|
|||
lowMem |= getSystemStats(output);
|
||||
lowMem |= getImageCacheStats(output);
|
||||
lowMem |= getNvidiaStats(gl, output);
|
||||
// The ATI version is untested, only enable if it has been tested.
|
||||
// lowMem |= getAtiStats(gl, output);
|
||||
lowMem |= getAtiStats(gl, output);
|
||||
|
||||
if (lowMem) {
|
||||
lastPrintTime = curTime;
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.viz.core.gl.ext.imaging;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -41,6 +38,9 @@ import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
|
|||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.AbstractGLMesh;
|
||||
import com.raytheon.viz.core.gl.GLCapabilities;
|
||||
import com.raytheon.viz.core.gl.GLGeometryObject2D;
|
||||
import com.raytheon.viz.core.gl.GLGeometryObject2D.GLGeometryObjectData;
|
||||
import com.raytheon.viz.core.gl.GLGeometryPainter;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.raytheon.viz.core.gl.glsl.GLSLFactory;
|
||||
import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
|
||||
|
@ -57,7 +57,10 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 15, 2011 mschenke Initial creation
|
||||
* Dec 15, 2011 mschenke Initial creation
|
||||
* Jan 9, 2014 2680 mschenke Switched simple PixelCoverage mesh
|
||||
* rendering to use VBOs instead of
|
||||
* deprecated immediate mode rendering
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -206,6 +209,11 @@ public abstract class AbstractGLImagingExtension extends
|
|||
continue;
|
||||
}
|
||||
}
|
||||
// Needed to fix ATI driver bug, after each image render, flush the
|
||||
// GL pipeline to avoid random images being drawn improperly. May be
|
||||
// fixed with driver update or cleaning up how image coverages are
|
||||
// rendered (getting rid of glEnableClientState as it is deprecated)
|
||||
gl.glFlush();
|
||||
}
|
||||
|
||||
if (lastTextureType != -1) {
|
||||
|
@ -258,46 +266,36 @@ public abstract class AbstractGLImagingExtension extends
|
|||
return ((AbstractGLMesh) mesh).paint(target, paintProps);
|
||||
}
|
||||
} else if (coords != null) {
|
||||
FloatBuffer fb = ByteBuffer.allocateDirect(4 * 5 * 4)
|
||||
.order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||
|
||||
Coordinate ul = pc.getUl();
|
||||
Coordinate ur = pc.getUr();
|
||||
Coordinate lr = pc.getLr();
|
||||
Coordinate ll = pc.getLl();
|
||||
|
||||
fb.put(new float[] { coords.left() + corrFactor,
|
||||
coords.bottom() + corrFactor });
|
||||
fb.put(new float[] { (float) ll.x, (float) ll.y, (float) ll.z });
|
||||
int geometryType = GL.GL_TRIANGLE_STRIP;
|
||||
GLGeometryObject2D vertexData = new GLGeometryObject2D(
|
||||
new GLGeometryObjectData(geometryType, GL.GL_VERTEX_ARRAY));
|
||||
vertexData.allocate(4);
|
||||
vertexData.addSegment(new double[][] { { ll.x, ll.y },
|
||||
{ lr.x, lr.y }, { ul.x, ul.y }, { ur.x, ur.y } });
|
||||
vertexData.compile(gl);
|
||||
|
||||
fb.put(new float[] { coords.right() - corrFactor,
|
||||
coords.bottom() + corrFactor });
|
||||
fb.put(new float[] { (float) lr.x, (float) lr.y, (float) lr.z });
|
||||
GLGeometryObject2D textureData = new GLGeometryObject2D(
|
||||
new GLGeometryObjectData(geometryType,
|
||||
GL.GL_TEXTURE_COORD_ARRAY));
|
||||
textureData.allocate(4);
|
||||
textureData.addSegment(new double[][] {
|
||||
{ coords.left(), coords.bottom() },
|
||||
{ coords.right(), coords.bottom() },
|
||||
{ coords.left(), coords.top() },
|
||||
{ coords.right(), coords.top() } });
|
||||
textureData.compile(gl);
|
||||
|
||||
fb.put(new float[] { coords.left() + corrFactor,
|
||||
coords.top() - corrFactor });
|
||||
fb.put(new float[] { (float) ul.x, (float) ul.y, (float) ul.z });
|
||||
GLGeometryPainter.paintGeometries(gl, vertexData, textureData);
|
||||
|
||||
fb.put(new float[] { coords.right() - corrFactor,
|
||||
coords.top() - corrFactor });
|
||||
fb.put(new float[] { (float) ur.x, (float) ur.y, (float) ur.z });
|
||||
vertexData.dispose();
|
||||
textureData.dispose();
|
||||
|
||||
// Clear error bit
|
||||
gl.glGetError();
|
||||
|
||||
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
|
||||
gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
gl.glInterleavedArrays(GL.GL_T2F_V3F, 0, fb.rewind());
|
||||
int error = gl.glGetError();
|
||||
if (error == GL.GL_NO_ERROR) {
|
||||
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
|
||||
} else {
|
||||
target.handleError(error);
|
||||
}
|
||||
|
||||
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
|
||||
gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
|
||||
return PaintStatus.PAINTED;
|
||||
}
|
||||
return PaintStatus.ERROR;
|
||||
|
|
|
@ -280,7 +280,7 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
|||
gl = GLU.getCurrentGL();
|
||||
|
||||
theWidth = width;
|
||||
theHeight = width;
|
||||
theHeight = height;
|
||||
|
||||
float magnificationVal = Activator.getDefault().getPreferenceStore()
|
||||
.getFloat(PreferenceConstants.P_FONT_MAGNIFICATION);
|
||||
|
@ -324,7 +324,7 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
|||
|
||||
gl = GLU.getCurrentGL();
|
||||
theWidth = width;
|
||||
theHeight = width;
|
||||
theHeight = height;
|
||||
|
||||
float magnificationVal = Activator.getDefault().getPreferenceStore()
|
||||
.getFloat(PreferenceConstants.P_FONT_MAGNIFICATION);
|
||||
|
@ -1784,8 +1784,12 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
|||
message = "GL table too large?";
|
||||
break;
|
||||
}
|
||||
case GL.GL_INVALID_FRAMEBUFFER_OPERATION_EXT: {
|
||||
message = "Invalid FrameBuffer operation";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
message = "GL Error" + errorid;
|
||||
message = "GL Error: " + errorid;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@ import com.raytheon.viz.core.gl.GLDisposalManager.GLDisposer;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 13, 2007 chammack Initial Creation.
|
||||
* Jan 9, 2013 2680 mschenke Changed size calculation to longs to
|
||||
* avoid int overflow when using cache
|
||||
* size > 1GB
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -90,14 +93,15 @@ public class ImageCache extends LRUCache<Object, IImageCacheable> implements
|
|||
public static ImageCache getInstance(CacheType type) {
|
||||
if (type == CacheType.MEMORY) {
|
||||
if (memoryCache == null) {
|
||||
memoryCache = new ImageCache(1024 * 1024 * MEMORY_CACHE_SIZE);
|
||||
memoryCache = new ImageCache(1024L * 1024L * MEMORY_CACHE_SIZE);
|
||||
}
|
||||
return memoryCache;
|
||||
}
|
||||
|
||||
if (type == CacheType.TEXTURE) {
|
||||
if (textureCache == null) {
|
||||
textureCache = new ImageCache(1024 * 1024 * TEXTURE_CACHE_SIZE);
|
||||
textureCache = new ImageCache(
|
||||
1024L * 1024L * TEXTURE_CACHE_SIZE);
|
||||
}
|
||||
return textureCache;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ import javax.media.opengl.GL;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 17, 2012 bsteffen Initial creation
|
||||
* Feb 17, 2012 bsteffen Initial creation
|
||||
* Jan 9, 2014 2680 mschenke Added default error message handling
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -113,8 +114,11 @@ public class GLFrameBufferObject extends GLIdWrapper {
|
|||
errorMessage = "Error: Framebuffer not supported by hardware/drivers";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
errorMessage = "Framebuffer is not complete, unknown reason";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue