• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Main repository of MikuMikuStudio


Commit MetaInfo

Revisione9a605974100af99c1f34f4533f8d73c031ad03a (tree)
Time2013-07-06 10:37:51
AuthorKazuhiko Kobayashi <chototsu_moushinp@yaho...>
Commiterkobayasi

Log Message

Update renderer.

Change Summary

Incremental Difference

--- a/engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java
+++ b/engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java
@@ -75,7 +75,7 @@ import java.util.logging.Level;
7575 import java.util.logging.Logger;
7676 import javax.microedition.khronos.opengles.GL10;
7777
78-public class OGLESShaderRenderer implements Renderer {
78+public final class OGLESShaderRenderer implements Renderer {
7979
8080 private static final Logger logger = Logger.getLogger(OGLESShaderRenderer.class.getName());
8181 private static final boolean VALIDATE_SHADER = false;
@@ -1691,6 +1691,7 @@ public class OGLESShaderRenderer implements Renderer {
16911691
16921692 public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) {
16931693 logger.warning("readFrameBuffer is not supported.");
1694+ GLES20.glReadPixels(vpX, vpY, vpW, vpH, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, byteBuf);
16941695 }
16951696 /*
16961697 public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf){
@@ -2017,20 +2018,18 @@ public class OGLESShaderRenderer implements Renderer {
20172018 Image[] textures = context.boundTextures;
20182019
20192020 int type = convertTextureType(tex.getType());
2020- if (!context.textureIndexList.moveToNew(unit)) {
2021+// if (!context.textureIndexList.moveToNew(unit)) {
20212022 // if (context.boundTextureUnit != unit){
20222023 // glActiveTexture(GL_TEXTURE0 + unit);
20232024 // context.boundTextureUnit = unit;
20242025 // }
20252026 // glEnable(type);
2026- }
2027+// }
20272028
20282029 if (context.boundTextureUnit != unit) {
20292030 if (verboseLogging) {
20302031 logger.info("GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + " + unit + ")");
20312032 }
2032- GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + unit);
2033- context.boundTextureUnit = unit;
20342033 }
20352034 if (textures[unit] != image) {
20362035
@@ -2038,6 +2037,8 @@ public class OGLESShaderRenderer implements Renderer {
20382037 logger.info("GLES20.glBindTexture(" + type + ", " + texId + ")");
20392038 }
20402039
2040+ GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + unit);
2041+ context.boundTextureUnit = unit;
20412042 GLES20.glBindTexture(type, texId);
20422043 textures[unit] = image;
20432044
@@ -2050,18 +2051,18 @@ public class OGLESShaderRenderer implements Renderer {
20502051 }
20512052
20522053 public void clearTextureUnits() {
2053- IDList textureList = context.textureIndexList;
2054- Image[] textures = context.boundTextures;
2055- for (int i = 0; i < textureList.oldLen; i++) {
2056- int idx = textureList.oldList[i];
2054+// IDList textureList = context.textureIndexList;
2055+// Image[] textures = context.boundTextures;
2056+// for (int i = 0; i < textureList.oldLen; i++) {
2057+// int idx = textureList.oldList[i];
20572058 // if (context.boundTextureUnit != idx){
2058-// glActiveTexture(GL_TEXTURE0 + idx);
2059+// GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + idx);
20592060 // context.boundTextureUnit = idx;
20602061 // }
2061-// glDisable(convertTextureType(textures[idx].getType()));
2062- textures[idx] = null;
2063- }
2064- context.textureIndexList.copyNewToOld();
2062+// GLES20.glDisable(GLES20.GL_TEXTURE_2D/*convertTextureType(textures[idx].getType())*/);
2063+// textures[idx] = null;
2064+// }
2065+// context.textureIndexList.copyNewToOld();
20652066 }
20662067
20672068 public void deleteImage(Image image) {
@@ -2345,15 +2346,17 @@ public class OGLESShaderRenderer implements Renderer {
23452346
23462347 public void clearVertexAttribs() {
23472348 IDList attribList = context.attribIndexList;
2348- for (int i = 0; i < attribList.oldLen; i++) {
2349+ int oldLen = attribList.oldLen;
2350+ for (int i = 0; i < oldLen; i++) {
23492351 int idx = attribList.oldList[i];
23502352
23512353 if (verboseLogging) {
23522354 logger.info("GLES20.glDisableVertexAttribArray(" + idx + ")");
23532355 }
2354-
2355- GLES20.glDisableVertexAttribArray(idx);
2356- context.boundAttribs[idx] = null;
2356+ if (idx != -1) {
2357+ GLES20.glDisableVertexAttribArray(idx);
2358+ context.boundAttribs[idx] = null;
2359+ }
23572360 }
23582361 context.attribIndexList.copyNewToOld();
23592362 }
@@ -2704,6 +2707,8 @@ public class OGLESShaderRenderer implements Renderer {
27042707 } else {
27052708 indices = mesh.getBuffer(Type.Index);//buffers.get(Type.Index.ordinal());
27062709 }
2710+ clearVertexAttribs();
2711+// clearTextureUnits();
27072712 if (indices != null) {
27082713 drawTriangleList_Array(indices, mesh, count);
27092714 } else {
@@ -2714,8 +2719,6 @@ public class OGLESShaderRenderer implements Renderer {
27142719
27152720 GLES20.glDrawArrays(convertElementMode(mesh.getMode()), 0, mesh.getVertexCount());
27162721 }
2717- clearVertexAttribs();
2718- clearTextureUnits();
27192722 }
27202723
27212724 private void renderMeshDefault(Mesh mesh, int lod, int count) {
@@ -2754,6 +2757,8 @@ public class OGLESShaderRenderer implements Renderer {
27542757 setVertexAttrib(vb, interleavedData);
27552758 }
27562759 }
2760+ clearVertexAttribs();
2761+// clearTextureUnits();
27572762 if (indices != null) {
27582763 drawTriangleList(indices, mesh, count);
27592764 } else {
@@ -2765,8 +2770,6 @@ public class OGLESShaderRenderer implements Renderer {
27652770
27662771 GLES20.glDrawArrays(convertElementMode(mesh.getMode()), 0, mesh.getVertexCount());
27672772 }
2768- clearVertexAttribs();
2769- clearTextureUnits();
27702773 }
27712774
27722775 public void renderMesh(Mesh mesh, int lod, int count) {
@@ -3002,4 +3005,35 @@ public class OGLESShaderRenderer implements Renderer {
30023005 boundShader = null;
30033006 lastFb = null;
30043007 }
3008+ public void resetBoundsTexture() {
3009+ context.boundTextures[0] = null;
3010+ if (context.boundTextureUnit != 0) {
3011+ GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
3012+ context.boundTextureUnit = 0;
3013+ }
3014+// GLES20.glDisable(GLES20.GL_TEXTURE_2D);
3015+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
3016+ // context.boundTextureUnit = -2;
3017+// context.boundElementArrayVBO = -2;
3018+// context.boundShaderProgram = -1;
3019+// context.boundArrayVBO = -1;
3020+// context.boundElementArrayVBO = -1;
3021+
3022+ if (context.boundElementArrayVBO != 0) {
3023+
3024+
3025+ GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
3026+ context.boundElementArrayVBO = 0;
3027+ }
3028+ if (context.boundArrayVBO != 0) {
3029+ GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
3030+ context.boundArrayVBO = 0;
3031+ }
3032+ if (context.boundShaderProgram != 0) {
3033+ GLES20.glUseProgram(0);
3034+ checkGLError();
3035+ boundShader = null;
3036+ context.boundShaderProgram = 0;
3037+ }
3038+ }
30053039 }
--- a/engine/src/core/com/jme3/renderer/IDList.java
+++ b/engine/src/core/com/jme3/renderer/IDList.java
@@ -75,10 +75,11 @@ public class IDList {
7575 if (oldList[i] == idx){
7676 // found index in slot i
7777 // delete index from old list
78- oldLen --;
79- for (int j = i; j < oldLen; j++){
80- oldList[j] = oldList[j+1];
81- }
78+// oldLen --;
79+// for (int j = i; j < oldLen; j++){
80+// oldList[j] = oldList[j+1];
81+// }
82+ oldList[i] = -1;
8283 return true;
8384 }
8485 }
--- a/engine/src/lwjgl-ogl/com/jme3/renderer/lwjgl/LwjglRenderer.java
+++ b/engine/src/lwjgl-ogl/com/jme3/renderer/lwjgl/LwjglRenderer.java
@@ -2191,8 +2191,10 @@ public class LwjglRenderer implements Renderer {
21912191 IDList attribList = context.attribIndexList;
21922192 for (int i = 0; i < attribList.oldLen; i++) {
21932193 int idx = attribList.oldList[i];
2194- glDisableVertexAttribArray(idx);
2195- context.boundAttribs[idx] = null;
2194+ if (idx >= 0) {
2195+ glDisableVertexAttribArray(idx);
2196+ context.boundAttribs[idx] = null;
2197+ }
21962198 }
21972199 context.attribIndexList.copyNewToOld();
21982200 }