* Fix compile error in FrameBuffer, setRefreshNeeded() -> setUpdateNeeded()

* LwjglRenderer - Will only upload buffers that are used by a shader 

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9066 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..rd 13 years ago
parent ae451abf52
commit 96bde02de6
  1. 2
      engine/src/core/com/jme3/texture/FrameBuffer.java
  2. 54
      engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java

@ -290,7 +290,7 @@ public class FrameBuffer extends NativeObject {
throw new IllegalArgumentException("The target at " + index + " is not set!");
colorBufIndex = index;
// setRefreshNeeded();
setUpdateNeeded();
}
/**

@ -771,12 +771,8 @@ public class LwjglRenderer implements Renderer {
}
}
protected void updateUniform(Shader shader, Uniform uniform) {
protected void bindProgram(Shader shader){
int shaderId = shader.getId();
assert uniform.getName() != null;
assert shader.getId() > 0;
if (context.boundShaderProgram != shaderId) {
glUseProgram(shaderId);
statistics.onShaderUse(shader, true);
@ -785,6 +781,15 @@ public class LwjglRenderer implements Renderer {
} else {
statistics.onShaderUse(shader, false);
}
}
protected void updateUniform(Shader shader, Uniform uniform) {
int shaderId = shader.getId();
assert uniform.getName() != null;
assert shader.getId() > 0;
bindProgram(shader);
int loc = uniform.getLocation();
if (loc == -1) {
@ -1046,6 +1051,7 @@ public class LwjglRenderer implements Renderer {
}
if (caps.contains(Caps.OpenGL30)) {
// Check if GLSL version is 1.5 for shader
GL30.glBindFragDataLocation(id, 0, "outFragColor");
}
@ -1126,27 +1132,7 @@ public class LwjglRenderer implements Renderer {
assert shader.getId() > 0;
updateShaderUniforms(shader);
if (context.boundShaderProgram != shader.getId()) {
if (VALIDATE_SHADER) {
// check if shader can be used
// with current state
glValidateProgram(shader.getId());
glGetProgram(shader.getId(), GL_VALIDATE_STATUS, intBuf1);
boolean validateOK = intBuf1.get(0) == GL_TRUE;
if (validateOK) {
logger.fine("shader validate success");
} else {
logger.warning("shader validate failure");
}
}
glUseProgram(shader.getId());
statistics.onShaderUse(shader, true);
context.boundShaderProgram = shader.getId();
boundShader = shader;
} else {
statistics.onShaderUse(shader, false);
}
bindProgram(shader);
}
}
@ -2162,10 +2148,6 @@ public class LwjglRenderer implements Renderer {
throw new IllegalArgumentException("Index buffers not allowed to be set to vertex attrib");
}
if (vb.isUpdateNeeded() && idb == null) {
updateBufferData(vb);
}
int programId = context.boundShaderProgram;
if (programId > 0) {
Attribute attrib = boundShader.getAttribute(vb.getBufferType());
@ -2189,6 +2171,10 @@ public class LwjglRenderer implements Renderer {
}
}
if (vb.isUpdateNeeded() && idb == null) {
updateBufferData(vb);
}
VertexBuffer[] attribs = context.boundAttribs;
if (!context.attribIndexList.moveToNew(loc)) {
glEnableVertexAttribArray(loc);
@ -2409,7 +2395,7 @@ public class LwjglRenderer implements Renderer {
updateBufferData(interleavedData);
}
//IntMap<VertexBuffer> buffers = mesh.getBuffers();
// IntMap<VertexBuffer> buffers = mesh.getBuffers();
SafeArrayList<VertexBuffer> buffersList = mesh.getBufferList();
if (mesh.getNumLodLevels() > 0) {
@ -2417,10 +2403,10 @@ public class LwjglRenderer implements Renderer {
} else {
indices = mesh.getBuffer(Type.Index);
}
//for (Entry<VertexBuffer> entry : buffers) {
// VertexBuffer vb = entry.getValue();
for (VertexBuffer vb : mesh.getBufferList().getArray()){
// for (Entry<VertexBuffer> entry : buffers) {
// VertexBuffer vb = entry.getValue();
for (VertexBuffer vb : mesh.getBufferList().getArray()){
if (vb.getBufferType() == Type.InterleavedData
|| vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
|| vb.getBufferType() == Type.Index) {

Loading…
Cancel
Save