Updated initialization code in PGL for android and java, changed vertex indices to short in android

This commit is contained in:
codeanticode
2012-01-24 00:54:28 +00:00
parent 8475a45b1d
commit a56751beca
10 changed files with 235 additions and 466 deletions

View File

@@ -227,7 +227,7 @@ public class PGL {
GLProfile.shutdown();
}
public void updateGLPrimary() {
public void updatePrimary() {
gl = context.getGL();
if (pipeline == PROG_GL4) {
@@ -258,7 +258,7 @@ public class PGL {
} catch (GLException e) {}
}
public void updateGLOffscreen(PGL primary) {
public void updateOffscreen(PGL primary) {
gl = primary.gl;
gl4p = primary.gl4p;
gl3p = primary.gl3p;
@@ -267,7 +267,7 @@ public class PGL {
}
public void initPrimary(int antialias) {
public void initPrimarySurface(int antialias) {
if (pg.parent.online) {
// RCP Application (Applet's, Webstart, Netbeans, ..) using JOGL may not
// be able to initialize JOGL before the first UI action, so initSingleton()
@@ -351,14 +351,14 @@ public class PGL {
initialized = true;
}
public void initOffscreen(PGL primary) {
public void initOffscreenSurface(PGL primary) {
context = primary.context;
capabilities = primary.capabilities;
drawable = null;
initialized = true;
}
public void updateOffscreen(PGL primary) {
public void updateOffscreenSurface(PGL primary) {
context = primary.context;
capabilities = primary.capabilities;
drawable = null;
@@ -393,7 +393,7 @@ public class PGL {
return other.same(context);
}
public boolean beginOnscreenDraw() {
public boolean initOnscreenDraw() {
if (drawable != null) {
// Call setRealized() after addNotify() has been called
drawable.setRealized(pg.parent.isDisplayable());
@@ -404,7 +404,11 @@ public class PGL {
return false; // Should have called canDraw() anyway
}
}
return false;
return false;
}
public void beginOnscreenDraw() {
}
public void endOnscreenDraw() {
@@ -425,6 +429,10 @@ public class PGL {
return pg.parent.isDisplayable();
}
public void requestDraw() {
}
///////////////////////////////////////////////////////////////////////////////////
// Caps query

View File

@@ -512,33 +512,6 @@ public class PGraphicsOpenGL extends PGraphics {
currentLightSpecular = new float[4];
lightsAllocated = true;
}
if (primarySurface) {
// Allocation of the main renderer, which mainly involves initializing OpenGL.
// if (context == null) {
// initPrimary();
// } else {
// reapplySettings();
// }
if (pgl.initialized) {
reapplySettings();
}
} else {
// Allocation of an offscreen renderer.
// if (context == null) {
// initOffscreen();
// } else {
// // Updating OpenGL context associated to this offscreen
// // surface, to take into account a context recreation situation.
// updateOffscreenContext();
// reapplySettings();
// }
if (pgl.initialized) {
updateOffscreenContext();
reapplySettings();
}
}
}
@@ -1147,7 +1120,7 @@ public class PGraphicsOpenGL extends PGraphics {
pgl.destroyContext();
restartSurface();
pgl.detainContext();
updateGLInterfaces();
updatePGL();
}
protected void createFillBuffers() {
@@ -1290,6 +1263,11 @@ public class PGraphicsOpenGL extends PGraphics {
}
public void requestDraw() {
}
public void beginDraw() {
if (drawing) {
showWarning("P3D: Already called beginDraw().");
@@ -1299,9 +1277,11 @@ public class PGraphicsOpenGL extends PGraphics {
if (primarySurface) {
if (!pgl.initialized) {
initPrimary();
}
boolean res = pgl.beginOnscreenDraw();
if (!res) return;
}
if (!pgl.initOnscreenDraw()) {
return;
}
pgl.detainContext();
} else {
if (!pgl.initialized) {
@@ -1319,7 +1299,7 @@ public class PGraphicsOpenGL extends PGraphics {
pgl.beginOffscreenDraw();
}
updateGLInterfaces();
updatePGL();
if (!glParamsRead) {
getGLParameters();
@@ -1429,27 +1409,16 @@ public class PGraphicsOpenGL extends PGraphics {
normalX = normalY = 0;
normalZ = 0;
/*
if (primarySurface) {
// This instance of PGraphicsOpenGL is the primary (onscreen) drawing surface.
// Nothing else needs setup here.
} else {
pushFramebuffer();
if (offscreenMultisample) {
setFramebuffer(offscreenFramebufferMultisample);
pgl.setDrawBuffer(0);
} else {
setFramebuffer(offscreenFramebuffer);
}
}
*/
// Clear depth and stencil buffers.
pgl.setClearColor(0, 0, 0, 0);
pgl.clearDepthAndStencilBuffers();
if (primarySurface) {
pgl.beginOnscreenDraw();
} else {
pgl.beginOffscreenDraw();
}
drawing = true;
report("bot beginDraw()");
@@ -1517,9 +1486,9 @@ public class PGraphicsOpenGL extends PGraphics {
}
public void updateGLInterfaces() {
public void updatePGL() {
if (primarySurface) {
pgl.updateGLPrimary();
pgl.updatePrimary();
} else {
pgl.updateOffscreen(pg.pgl);
}
@@ -1655,7 +1624,7 @@ public class PGraphicsOpenGL extends PGraphics {
// buffer.
protected void beginGLOp() {
pgl.detainContext();
updateGLInterfaces();
updatePGL();
}
@@ -5891,16 +5860,16 @@ public class PGraphicsOpenGL extends PGraphics {
}
protected void initPrimary() {
pgl.initPrimary(antialias);
pgl.initPrimarySurface(antialias);
pg = this;
}
protected void initOffscreen() {
// Getting the context and capabilities from the main renderer.
pg = (PGraphicsOpenGL)parent.g;
pgl.initOffscreen(pg.pgl);
pgl.initOffscreenSurface(pg.pgl);
updateGLInterfaces();
updatePGL();
loadTextureImpl(BILINEAR);
// In case of reinitialization (for example, when the smooth level
@@ -5943,8 +5912,8 @@ public class PGraphicsOpenGL extends PGraphics {
}
protected void updateOffscreenContext() {
pgl.updateOffscreen(pg.pgl);
updateGLInterfaces();
pgl.updateOffscreenSurface(pg.pgl);
updatePGL();
}
protected void getGLParameters() {

View File

@@ -3789,7 +3789,7 @@ public class PShape3D extends PShape {
pg.stroke = false;
// Normals are automatically computed if not specified in the OBJ file.
pg.autoNormal(true);
//pg.autoNormal(true);
// Using normal mode for texture coordinates (i.e.: normalized between 0 and 1).
pg.textureMode = NORMAL;
@@ -3827,7 +3827,7 @@ public class PShape3D extends PShape {
pg.beginShape();
}
pg.shapeName(face.name);
//pg.shapeName(face.name);
for (int j = 0; j < face.vertIdx.size(); j++){
int vertIdx, normIdx;