Goodbye, OpenGL1

experimental
shadowislord 10 years ago
parent c2b9b8a2e1
commit 4717e7006f
  1. 85
      jme3-core/src/main/java/com/jme3/material/FixedFuncBinding.java
  2. 23
      jme3-core/src/main/java/com/jme3/material/MatParam.java
  3. 4
      jme3-core/src/main/java/com/jme3/material/MatParamTexture.java
  4. 7
      jme3-core/src/main/java/com/jme3/material/Material.java
  5. 5
      jme3-core/src/main/java/com/jme3/material/MaterialDef.java
  6. 57
      jme3-core/src/main/java/com/jme3/renderer/GL1Renderer.java
  7. 18
      jme3-core/src/main/java/com/jme3/system/AppSettings.java
  8. 10
      jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java
  9. 1261
      jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglGL1Renderer.java
  10. 1208
      jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGL1Renderer.java
  11. 30
      jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java
  12. 3
      sdk/jme3-core/src/com/jme3/gde/core/editor/SceneApplication.java
  13. 3
      sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java

@ -1,85 +0,0 @@
/*
* Copyright (c) 2009-2012 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme3.material;
/**
* Fixed function binding is used to specify a binding for a {@link MatParam}
* in case that shaders are not supported on the system.
*
* @author Kirill Vainer
*/
public enum FixedFuncBinding {
/**
* Specifies the material ambient color.
* Same as GL_AMBIENT for OpenGL.
*/
MaterialAmbient,
/**
* Specifies the material diffuse color.
* Same as GL_DIFFUSE for OpenGL.
*/
MaterialDiffuse,
/**
* Specifies the material specular color.
* Same as GL_SPECULAR for OpenGL
*/
MaterialSpecular,
/**
* Specifies the color of the object.
* <p>
* Used only for non-lit materials.
*/
Color,
/**
* Specifies the material shininess value.
*
* Same as GL_SHININESS for OpenGL.
*/
MaterialShininess,
/**
* Use vertex color as an additional diffuse color, if lighting is enabled.
* If lighting is disabled, vertex color is modulated with
* {@link #Color material color}.
*/
UseVertexColor,
/**
* Set the alpha threshold to discard pixels.
* @see RenderState#setAlphaFallOff
*/
AlphaTestFallOff
}

@ -34,7 +34,6 @@ package com.jme3.material;
import com.jme3.asset.TextureKey;
import com.jme3.export.*;
import com.jme3.math.*;
import com.jme3.renderer.GL1Renderer;
import com.jme3.renderer.Renderer;
import com.jme3.shader.VarType;
import com.jme3.texture.Texture;
@ -53,17 +52,15 @@ public class MatParam implements Savable, Cloneable {
protected String name;
protected String prefixedName;
protected Object value;
protected FixedFuncBinding ffBinding;
/**
* Create a new material parameter. For internal use only.
*/
public MatParam(VarType type, String name, Object value, FixedFuncBinding ffBinding) {
public MatParam(VarType type, String name, Object value) {
this.type = type;
this.name = name;
this.prefixedName = "m_" + name;
this.value = value;
this.ffBinding = ffBinding;
}
/**
@ -72,15 +69,6 @@ public class MatParam implements Savable, Cloneable {
public MatParam() {
}
/**
* Returns the fixed function binding.
*
* @return the fixed function binding.
*/
public FixedFuncBinding getFixedFuncBinding() {
return ffBinding;
}
/**
* Returns the material parameter type.
*
@ -146,9 +134,6 @@ public class MatParam implements Savable, Cloneable {
if (techDef.isUsingShaders()) {
technique.updateUniformParam(getPrefixedName(), getVarType(), getValue());
}
if (ffBinding != null && r instanceof GL1Renderer) {
((GL1Renderer) r).setFixedFuncBinding(ffBinding, getValue());
}
}
/**
@ -290,7 +275,6 @@ When arrays can be inserted in J3M files
OutputCapsule oc = ex.getCapsule(this);
oc.write(type, "varType", null);
oc.write(name, "name", null);
oc.write(ffBinding, "ff_binding", null);
if (value instanceof Savable) {
Savable s = (Savable) value;
oc.write(s, "value_savable", null);
@ -311,7 +295,6 @@ When arrays can be inserted in J3M files
type = ic.readEnum("varType", VarType.class, null);
name = ic.readString("name", null);
prefixedName = "m_" + name;
ffBinding = ic.readEnum("ff_binding", FixedFuncBinding.class, null);
switch (getVarType()) {
case Boolean:
value = ic.readBoolean("value_bool", false);
@ -346,9 +329,6 @@ When arrays can be inserted in J3M files
if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) {
return false;
}
if (this.ffBinding != other.ffBinding) {
return false;
}
return true;
}
@ -358,7 +338,6 @@ When arrays can be inserted in J3M files
hash = 59 * hash + (this.type != null ? this.type.hashCode() : 0);
hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 59 * hash + (this.value != null ? this.value.hashCode() : 0);
hash = 59 * hash + (this.ffBinding != null ? this.ffBinding.hashCode() : 0);
return hash;
}

@ -48,13 +48,13 @@ public class MatParamTexture extends MatParam {
private ColorSpace colorSpace;
public MatParamTexture(VarType type, String name, Texture texture, int unit) {
super(type, name, texture, null);
super(type, name, texture);
this.texture = texture;
this.unit = unit;
}
public MatParamTexture(VarType type, String name, Texture texture, int unit, ColorSpace colorSpace) {
super(type, name, texture, null);
super(type, name, texture);
this.texture = texture;
this.unit = unit;
this.colorSpace = colorSpace;

@ -480,7 +480,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
MatParam val = getParam(name);
if (val == null) {
MatParam paramDef = def.getMaterialParam(name);
paramValues.put(name, new MatParam(type, name, value, paramDef.getFixedFuncBinding()));
paramValues.put(name, new MatParam(type, name, value));
} else {
val.setValue(value);
}
@ -1089,10 +1089,15 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
for (int i = 0; i < size; i++) {
Uniform u = uniforms.getValue(i);
if (!u.isSetByCurrentMaterial()) {
if (u.getName().charAt(0) != 'g') {
// Don't reset world globals!
// The benefits gained from this are very minimal
// and cause lots of matrix -> FloatBuffer conversions.
u.clearValue();
}
}
}
}
/**
* Called by {@link RenderManager} to render the geometry by

@ -119,10 +119,9 @@ public class MaterialDef {
* @param type Type of the parameter
* @param name Name of the parameter
* @param value Default value of the parameter
* @param ffBinding Fixed function binding for the parameter
*/
public void addMaterialParam(VarType type, String name, Object value, FixedFuncBinding ffBinding) {
matParams.put(name, new MatParam(type, name, value, ffBinding));
public void addMaterialParam(VarType type, String name, Object value) {
matParams.put(name, new MatParam(type, name, value));
}
/**

@ -1,57 +0,0 @@
/*
* Copyright (c) 2009-2012 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme3.renderer;
import com.jme3.material.FixedFuncBinding;
/**
* Renderer sub-interface that is used for non-shader based renderers.
* <p>
* The <code>GL1Renderer</code> provides a single call,
* {@link #setFixedFuncBinding(com.jme3.material.FixedFuncBinding, java.lang.Object) }
* which allows to set fixed functionality state.
*
* @author Kirill Vainer
*/
public interface GL1Renderer extends Renderer {
/**
* Set the fixed functionality state.
* <p>
* See {@link FixedFuncBinding} for various values that
* can be set.
*
* @param ffBinding The binding to set
* @param val The value
*/
public void setFixedFuncBinding(FixedFuncBinding ffBinding, Object val);
}

@ -56,13 +56,6 @@ public final class AppSettings extends HashMap<String, Object> {
private static final AppSettings defaults = new AppSettings(false);
/**
* Use LWJGL as the display system and force using the OpenGL1.1 renderer.
*
* @see AppSettings#setRenderer(java.lang.String)
*/
public static final String LWJGL_OPENGL1 = "LWJGL-OPENGL1";
/**
* Use LWJGL as the display system and force using the OpenGL2.0 renderer.
* <p>
@ -87,17 +80,6 @@ public final class AppSettings extends HashMap<String, Object> {
*/
public static final String LWJGL_OPENGL3 = "LWJGL-OpenGL3";
/**
* Use LWJGL as the display system and allow the context
* to choose an appropriate renderer based on system capabilities.
* <p>
* If the GPU supports OpenGL2 or later, then the OpenGL2.0 renderer will
* be used, otherwise, the OpenGL1.1 renderer is used.
*
* @see AppSettings#setRenderer(java.lang.String)
*/
public static final String LWJGL_OPENGL_ANY = "LWJGL-OpenGL-Any";
/**
* Use the LWJGL OpenAL based renderer for audio capabilities.
*

@ -221,7 +221,6 @@ public class J3MLoader implements AssetLoader {
private void readParam(String statement) throws IOException{
String name;
String defaultVal = null;
FixedFuncBinding ffBinding = null;
ColorSpace colorSpace = null;
String[] split = statement.split("-");
@ -251,12 +250,7 @@ public class J3MLoader implements AssetLoader {
// get content inside parentheses
int endParen = statement.indexOf(")", startParen);
String bindingStr = statement.substring(startParen+1, endParen).trim();
try {
ffBinding = FixedFuncBinding.valueOf(bindingStr);
} catch (IllegalArgumentException ex){
throw new IOException("FixedFuncBinding '" +
split[1] + "' does not exist!");
}
// don't care about bindingStr
statement = statement.substring(0, startParen);
}
@ -282,7 +276,7 @@ public class J3MLoader implements AssetLoader {
if(type.isTextureType()){
materialDef.addMaterialParamTexture(type, name, colorSpace);
}else{
materialDef.addMaterialParam(type, name, defaultValObj, ffBinding);
materialDef.addMaterialParam(type, name, defaultValObj);
}
}

@ -35,9 +35,8 @@ package com.jme3.system.lwjgl;
import com.jme3.input.lwjgl.JInputJoyInput;
import com.jme3.input.lwjgl.LwjglKeyInput;
import com.jme3.input.lwjgl.LwjglMouseInput;
import com.jme3.math.FastMath;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.lwjgl.LwjglGL1Renderer;
import com.jme3.renderer.RendererException;
import com.jme3.renderer.lwjgl.LwjglRenderer;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext;
@ -199,30 +198,19 @@ public abstract class LwjglContext implements JmeContext {
}
protected void initContextFirstTime(){
if (!GLContext.getCapabilities().OpenGL20) {
throw new RendererException("OpenGL 2.0 or higher is " +
"required for jMonkeyEngine");
}
if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL2)
|| settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)){
|| settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) {
renderer = new LwjglRenderer();
}else if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL1)){
renderer = new LwjglGL1Renderer();
}else if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL_ANY)){
// Choose an appropriate renderer based on capabilities
if (GLContext.getCapabilities().OpenGL20){
renderer = new LwjglRenderer();
}else{
renderer = new LwjglGL1Renderer();
}
}else{
((LwjglRenderer) renderer).initialize();
} else {
throw new UnsupportedOperationException("Unsupported renderer: " + settings.getRenderer());
}
// Init renderer
if (renderer instanceof LwjglRenderer){
((LwjglRenderer)renderer).initialize();
}else if (renderer instanceof LwjglGL1Renderer){
((LwjglGL1Renderer)renderer).initialize();
}else{
assert false;
}
renderer.setMainFrameBufferSrgb(settings.getGammaCorrection());
renderer.setLinearizeSrgbImages(settings.getGammaCorrection());

@ -25,9 +25,6 @@ public class SceneApplication extends SimpleApplication {
super(new StatsAppState());
AppSettings newSetting = new AppSettings(true);
newSetting.setFrameRate(30);
if ("true".equals(NbPreferences.forModule(Installer.class).get("use_opengl_1", "false"))) {
newSetting.setRenderer(AppSettings.LWJGL_OPENGL1);
}
newSetting.setCustomRenderer(AwtPanelsContext.class);
setSettings(newSetting);
setPauseOnLostFocus(false);

@ -144,9 +144,6 @@ public class SceneApplication extends Application implements LookupProvider {
try {
AppSettings newSetting = new AppSettings(true);
newSetting.setFrameRate(30);
if ("true".equals(NbPreferences.forModule(Installer.class).get("use_opengl_1", "false"))) {
newSetting.setRenderer(AppSettings.LWJGL_OPENGL1);
}
if (!useCanvas) {
newSetting.setCustomRenderer(AwtPanelsContext.class);
}

Loading…
Cancel
Save