Commits

Michael Ludwig  committed 6f5ef2b

Check for null enums

  • Participants
  • Parent commits 30c5050

Comments (0)

Files changed (13)

File src/com/ferox/core/scene/states/Fog.java

 	/**
 	 * Set the fog equation that calculates intermediate fog values between start and end depths.
 	 */
-	public void setFogEquation(FogFunction eq) {
+	public void setFogEquation(FogFunction eq) throws NullPointerException {
+		if (eq == null)
+			throw new NullPointerException("Can't have a null fog function");
 		this.eq = eq;
 	}
 
 	/**
 	 * Set the quality of the fog algorithm for the fog.
 	 */
-	public void setQuality(Quality qual) {
+	public void setQuality(Quality qual) throws NullPointerException {
+		if (qual == null)
+			throw new NullPointerException("Can't have a null quality");
 		this.qual = qual;
 	}
 	

File src/com/ferox/core/states/StateManager.java

 	}
 	
 	public void setMergeMode(MergeMode mode) {
+		if (mode == null)
+			throw new NullPointerException("Merge mode can't be null");
 		this.mergeMode = mode;
 	}
 	

File src/com/ferox/core/states/atoms/AlphaState.java

 		return this.alphaTest;
 	}
 
-	public void setAlphaTest(FragmentTest alphaTest) {
+	public void setAlphaTest(FragmentTest alphaTest) throws NullPointerException {
+		if (alphaTest == null)
+			throw new NullPointerException("Alpha test can't be null");
 		this.alphaTest = alphaTest;
 	}
 

File src/com/ferox/core/states/atoms/BlendState.java

 		return this.blendFunc;
 	}
 
-	public void setBlendFunction(BlendFunction blendFunc) {
+	public void setBlendFunction(BlendFunction blendFunc) throws NullPointerException {
+		if (blendFunc == null)
+			throw new NullPointerException("Blend function can't be null");
 		this.blendFunc = blendFunc;
 	}
 
 		return this.srcBlendFactor;
 	}
 
-	public void setSourceBlendFactor(BlendFactor srcBlendFactor) {
+	public void setSourceBlendFactor(BlendFactor srcBlendFactor) throws NullPointerException {
+		if (srcBlendFactor == null)
+			throw new NullPointerException("Source blend factor can't be null");
 		this.srcBlendFactor = srcBlendFactor;
 	}
 
 		return this.dstBlendFactor;
 	}
 
-	public void setDestBlendFactor(BlendFactor dstBlendFactor) {
+	public void setDestBlendFactor(BlendFactor dstBlendFactor) throws NullPointerException {
+		if (dstBlendFactor == null)
+			throw new NullPointerException("Dest blend factor can't be null");
 		this.dstBlendFactor = dstBlendFactor;
 	}
 

File src/com/ferox/core/states/atoms/BufferData.java

 	
 	public BufferData(Buffer data, DataType dataType, int capacity, BufferTarget expectedTarget, boolean isVBO, UsageHint usageHint) {
 		super();
+		if (usageHint == null)
+			usageHint = UsageHint.STATIC;
+		if (expectedTarget == null)
+			expectedTarget = BufferTarget.ARRAY_BUFFER;
 		this.hint = usageHint;
 		this.primaryTarget = expectedTarget;
 		this.setBufferData(data, dataType, capacity);
 		return this.hint;
 	}
 	
-	public void setBufferData(Buffer data, DataType dataType, int capacity) throws FeroxException {
+	public void setBufferData(Buffer data, DataType dataType, int capacity) throws IllegalArgumentException {
 		Buffer oldData = this.data;
 		DataType oldType = this.dataType;
 		int oldCapacity = this.capacity;
 		
 		try {
 			if (!BufferData.isBufferValid(data, dataType, capacity)) 
-				throw new FeroxException("Can't create an invalid buffer");
+				throw new IllegalArgumentException("Can't create an invalid buffer: " + dataType + " " + capacity);
 			this.data = data;
 			this.dataType = dataType;
 			this.byteSize = dataType.getByteSize();
 			return true;
 		if (data.capacity() != capacity)
 			return false;
+		if (dataType == null)
+			return false;
 		return dataType.isTypeValid(data);
 	}
 	

File src/com/ferox/core/states/atoms/DrawMode.java

 		return this.frontMode;
 	}
 
-	public void setFrontMode(DrawStyle frontMode) {
+	public void setFrontMode(DrawStyle frontMode) throws NullPointerException {
+		if (frontMode == null)
+			throw new NullPointerException("Draw style can't be null");
 		this.frontMode = frontMode;
 	}
 
 		return this.backMode;
 	}
 
-	public void setBackMode(DrawStyle backMode) {
+	public void setBackMode(DrawStyle backMode) throws NullPointerException {
+		if (backMode == null)
+			throw new NullPointerException("Draw style can't be null");
 		this.backMode = backMode;
 	}
 
 		return this.drawFace;
 	}
 
-	public void setDrawFace(DrawFace drawFace) {
+	public void setDrawFace(DrawFace drawFace) throws NullPointerException {
+		if (drawFace == null)
+			throw new NullPointerException("Draw face can't be null");
 		this.drawFace = drawFace;
 	}
 
 		return this.winding;
 	}
 
-	public void setWinding(Winding winding) {
+	public void setWinding(Winding winding) throws NullPointerException {
+		if (winding == null)
+			throw new NullPointerException("Winding can't be null");
 		this.winding = winding;
 	}
 	
 	public void readChunk(InputChunk in) {
 		super.readChunk(in);
 		
-		
 		this.backMode = in.getEnum("backMode", DrawStyle.class);
 		this.drawFace = in.getEnum("drawFace", DrawFace.class);
 		this.frontMode = in.getEnum("frontMode", DrawStyle.class);

File src/com/ferox/core/states/atoms/GLSLShaderObject.java

 	 * the source code in the array of strings (source is concatentation of the elements, which
 	 * shouldn't be null strings).
 	 */
-	public GLSLShaderObject(String[] source, GLSLType type) {
+	public GLSLShaderObject(String[] source, GLSLType type) throws NullPointerException {
 		this();
+		if (type == null)
+			throw new NullPointerException("Can't have a null glsl shader object type");
 		this.setSource(source);
 		this.type = type;
 		this.infoLog = "";

File src/com/ferox/core/states/atoms/StencilState.java

 		return this.stencilFunc;
 	}
 	
-	public void setStencilFunction(FragmentTest stencilFunc) {
+	public void setStencilFunction(FragmentTest stencilFunc) throws NullPointerException {
+		if (stencilFunc == null)
+			throw new NullPointerException("Stencil func can't be null");
 		this.stencilFunc = stencilFunc;
 	}
 
 		return this.stencilFail;
 	}
 
-	public void setStencilFailOp(StencilOp stencilFail) {
+	public void setStencilFailOp(StencilOp stencilFail) throws NullPointerException {
+		if (stencilFail == null)
+			throw new NullPointerException("StencilOp can't be null");
 		this.stencilFail = stencilFail;
 	}
 
 		return this.depthFail;
 	}
 
-	public void setDepthFailOp(StencilOp depthFail) {
+	public void setDepthFailOp(StencilOp depthFail) throws NullPointerException {
+		if (depthFail == null)
+			throw new NullPointerException("StencilOp can't be null");
 		this.depthFail = depthFail;
 	}
 
 		return this.depthPass;
 	}
 
-	public void setDepthPassOp(StencilOp depthPass) {
+	public void setDepthPassOp(StencilOp depthPass) throws NullPointerException {
+		if (depthPass == null)
+			throw new NullPointerException("StencilOp can't be null");
 		this.depthPass = depthPass;
 	}
 

File src/com/ferox/core/states/atoms/Texture.java

 		return this.combineRGBFunc;
 	}
 
-	public void setCombineRGBFunc(CombineRGBFunc combineRGBFunc) {
+	public void setCombineRGBFunc(CombineRGBFunc combineRGBFunc) throws NullPointerException {
+		if (combineRGBFunc == null)
+			throw new NullPointerException("combine func can't be null");
 		this.combineRGBFunc = combineRGBFunc;
 	}
 
 		return this.combineAlphaFunc;
 	}
 
-	public void setCombineAlphaFunc(CombineAlphaFunc combineAlphaFunc) {
+	public void setCombineAlphaFunc(CombineAlphaFunc combineAlphaFunc) throws NullPointerException {
+		if (combineAlphaFunc == null)
+			throw new NullPointerException("combine func can't be null");
 		this.combineAlphaFunc = combineAlphaFunc;
 	}
 	
 		return this.sourceRGB0;
 	}
 
-	public void setSourceRGB0(CombineSource sourceRGB0) {
+	public void setSourceRGB0(CombineSource sourceRGB0) throws NullPointerException {
+		if (sourceRGB0 == null)
+			throw new NullPointerException("Combine source can't be null");
 		this.sourceRGB0 = sourceRGB0;
 	}
 
 		return this.sourceRGB1;
 	}
 
-	public void setSourceRGB1(CombineSource sourceRGB1) {
+	public void setSourceRGB1(CombineSource sourceRGB1) throws NullPointerException {
+		if (sourceRGB1 == null)
+			throw new NullPointerException("Combine source can't be null");
 		this.sourceRGB1 = sourceRGB1;
 	}
 
 		return this.sourceRGB2;
 	}
 
-	public void setSourceRGB2(CombineSource sourceRGB2) {
+	public void setSourceRGB2(CombineSource sourceRGB2) throws NullPointerException {
+		if (sourceRGB2 == null)
+			throw new NullPointerException("Combine source can't be null");
 		this.sourceRGB2 = sourceRGB2;
 	}
 
 		return this.sourceAlpha0;
 	}
 
-	public void setSourceAlpha0(CombineSource sourceAlpha0) {
+	public void setSourceAlpha0(CombineSource sourceAlpha0) throws NullPointerException {
+		if (sourceAlpha0 == null)
+			throw new NullPointerException("Combine source can't be null");
 		this.sourceAlpha0 = sourceAlpha0;
 	}
 
 		return this.sourceAlpha1;
 	}
 
-	public void setSourceAlpha1(CombineSource sourceAlpha1) {
+	public void setSourceAlpha1(CombineSource sourceAlpha1) throws NullPointerException {
+		if (sourceAlpha1 == null)
+			throw new NullPointerException("Combine source can't be null");
 		this.sourceAlpha1 = sourceAlpha1;
 	}
 
 		return this.sourceAlpha2;
 	}
 
-	public void setSourceAlpha2(CombineSource sourceAlpha2) {
+	public void setSourceAlpha2(CombineSource sourceAlpha2) throws NullPointerException {
+		if (sourceAlpha2 == null)
+			throw new NullPointerException("Combine source can't be null");
 		this.sourceAlpha2 = sourceAlpha2;
 	}
 	
 		return this.operandRGB0;
 	}
 
-	public void setOperandRGB0(CombineOp operandRGB0) {
+	public void setOperandRGB0(CombineOp operandRGB0) throws NullPointerException {
+		if (operandRGB0 == null)
+			throw new NullPointerException("Combine op can't be null");
 		this.operandRGB0 = operandRGB0;
 	}
 
 		return this.operandRGB0;
 	}
 
-	public void setOperandRGB1(CombineOp operandRGB1) {
+	public void setOperandRGB1(CombineOp operandRGB1) throws NullPointerException {
+		if (operandRGB1 == null)
+			throw new NullPointerException("Combine op can't be null");
 		this.operandRGB1 = operandRGB1;
 	}
 
 		return this.operandRGB2;
 	}
 
-	public void setOperandRGB2(CombineOp operandRGB2) {
+	public void setOperandRGB2(CombineOp operandRGB2) throws NullPointerException {
+		if (operandRGB2 == null)
+			throw new NullPointerException("Combine op can't be null");
 		this.operandRGB2 = operandRGB2;
 	}
 
 		return this.operandAlpha0;
 	}
 
-	public void setOperandAlpha0(CombineOp operandAlpha0) {
+	public void setOperandAlpha0(CombineOp operandAlpha0) throws NullPointerException {
+		if (operandAlpha0 == null)
+			throw new NullPointerException("Combine op can't be null");
 		this.operandAlpha0 = operandAlpha0;
 	}
 
 		return this.operandAlpha1;
 	}
 
-	public void setOperandAlpha1(CombineOp operandAlpha1) {
+	public void setOperandAlpha1(CombineOp operandAlpha1) throws NullPointerException {
+		if (operandAlpha1 == null)
+			throw new NullPointerException("Combine op can't be null");
 		this.operandAlpha1 = operandAlpha1;
 	}
 
 		return this.operandAlpha2;
 	}
 
-	public void setOperandAlpha2(CombineOp operandAlpha2) {
+	public void setOperandAlpha2(CombineOp operandAlpha2) throws NullPointerException {
+		if (operandAlpha2 == null)
+			throw new NullPointerException("Combine op can't be null");
 		this.operandAlpha2 = operandAlpha2;
 	}
 	
 		return this.texEnvMode;
 	}
 
-	public void setTexEnvMode(EnvMode texEnvMode) {
+	public void setTexEnvMode(EnvMode texEnvMode) throws NullPointerException {
+		if (texEnvMode == null)
+			throw new NullPointerException("Env mode can't be null");
 		this.texEnvMode = texEnvMode;
 	}
 
 		return this.texEnvColor;
 	}
 
-	public void setTexEnvColor(float[] texEnvColor) {
+	public void setTexEnvColor(float[] texEnvColor) throws IllegalArgumentException {
 		if (texEnvColor.length != 4)
 			throw new IllegalArgumentException("Texture env color must have 4 elements"); 
 		this.texEnvColor = texEnvColor;
 		return this.rCoordGen;
 	}
 
-	public void setRCoordGen(AutoTCGen coordGen) {
+	public void setRCoordGen(AutoTCGen coordGen) throws NullPointerException {
+		if (coordGen == null)
+			throw new NullPointerException("AutoTCGen can't be null");
 		this.rCoordGen = coordGen;
 	}
 
 		return this.sCoordGen;
 	}
 
-	public void setSCoordGen(AutoTCGen coordGen) {
+	public void setSCoordGen(AutoTCGen coordGen) throws NullPointerException {
+		if (coordGen == null)
+			throw new NullPointerException("AutoTCGen can't be null");
 		this.sCoordGen = coordGen;
 	}
 
 		return this.tCoordGen;
 	}
 
-	public void setTCoordGen(AutoTCGen coordGen) {
+	public void setTCoordGen(AutoTCGen coordGen) throws NullPointerException {
+		if (coordGen == null)
+			throw new NullPointerException("AutoTCGen can't be null");
 		this.tCoordGen = coordGen;
 	}
 	

File src/com/ferox/core/states/atoms/TextureData.java

 		super();
 		this.setTextureFormat(dataFormat, dataType, comp);
 		
-		this.aniso = 0f;
-		
+		this.setAnisotropicFilterLevel(1f);
 		this.setTexClampSTR(clampS, clampR, clampT);
 		
 		this.setMinFilter(min);
 		this.aniso = Math.max(0f, Math.min(1f, l));
 	}
 	
-	protected void setTextureFormat(TextureFormat format, TextureType type, TextureCompression comp) {
+	protected void setTextureFormat(TextureFormat format, TextureType type, TextureCompression comp) throws NullPointerException {
+		if (format == null || type == null || comp == null)
+			throw new NullPointerException("Format, type, and compression can't be null: " + format + " " + type + " " + comp);
 		this.dataType = type;
 		this.dataFormat = format;
 		this.dataCompress = comp;
 		return this.wrapS;
 	}
 
-	public void setTexClampS(TexClamp s) {
+	public void setTexClampS(TexClamp s) throws NullPointerException {
+		if (s == null)
+			throw new NullPointerException("TexClamp can't be null");
 		this.wrapS = s;
 	}
 
 		return this.wrapT;
 	}
 
-	public void setTexClampT(TexClamp t) {
+	public void setTexClampT(TexClamp t) throws NullPointerException {
+		if (t == null)
+			throw new NullPointerException("TexClamp can't be null");
 		this.wrapT = t;
 	}
 	
 		return this.wrapR;
 	}
 
-	public void setTexClampR(TexClamp r) {
+	public void setTexClampR(TexClamp r) throws NullPointerException {
+		if (r == null)
+			throw new NullPointerException("TexClamp can't be null");
 		this.wrapR = r;
 	}
 	
 		return this.minFilter;
 	}
 
-	public void setMinFilter(MinFilter minFilter) {
+	public void setMinFilter(MinFilter minFilter) throws NullPointerException {
+		if (minFilter == null)
+			throw new NullPointerException("MinFilter can't be null");
 		this.minFilter = minFilter;
 	}
 
 		return this.magFilter;
 	}
 	
-	public void setMagFilter(MagFilter magFilter) {
+	public void setMagFilter(MagFilter magFilter) throws NullPointerException {
+		if (magFilter == null)
+			throw new NullPointerException("MagFilter can't be null");
 		this.magFilter = magFilter;
 	}
 
 		return this.depthMode;
 	}
 
-	public void setDepthMode(DepthMode depthMode) {
+	public void setDepthMode(DepthMode depthMode) throws NullPointerException {
+		if (depthMode == null)
+			throw new NullPointerException("DepthMode can't be null");
 		this.depthMode = depthMode;
 	}
 
 		return this.compareMode;
 	}
 
-	public void setCompareMode(DepthCompare compareMode) {
+	public void setCompareMode(DepthCompare compareMode) throws NullPointerException {
+		if (compareMode == null)
+			throw new NullPointerException("compare mode can't be null");
 		this.compareMode = compareMode;
 	}
 
 		return this.compareFunction;
 	}
 
-	public void setCompareFunction(FragmentTest compareFunction) {
+	public void setCompareFunction(FragmentTest compareFunction) throws NullPointerException {
+		if (compareFunction == null)
+			throw new NullPointerException("CompareFunction can't be null");
 		this.compareFunction = compareFunction;
 	}
 	
 	}
 	
 	public static boolean isBufferValid(TextureType type, TextureFormat format, TextureCompression comp, int width, int height, int depth, Buffer data) {
+		if (type == null || format == null || comp == null || data == null)
+			return false;
 		if ((format.isClientCompressed() || comp != TextureCompression.NONE) && depth != 1)
 			return false;
 		if (width <= 0 || height <= 0 || depth <= 0)

File src/com/ferox/core/states/atoms/ZBuffer.java

 		return this.zTestFunction;
 	}
 
-	public void setDepthTest(FragmentTest testFunction) {
+	public void setDepthTest(FragmentTest testFunction) throws NullPointerException {
+		if (testFunction == null)
+			throw new NullPointerException("FragmentTest can't be null");
 		this.zTestFunction = testFunction;
 	}
 

File src/com/ferox/core/states/manager/Geometry.java

 	/**
 	 * Set the connectivity for this Geometry, see above for valid arguments.
 	 */
-	public void setConnectivity(PolygonType connectivity) {
+	public void setConnectivity(PolygonType connectivity) throws NullPointerException {
+		if (connectivity == null)
+			throw new NullPointerException("Can't have null connectivity");
 		this.connectivity = connectivity;
 	}
 	

File src/com/ferox/core/states/manager/TextureManager.java

 		return this.filter;
 	}
 	
-	public void setTextureFilterHint(Quality hint) {
+	public void setTextureFilterHint(Quality hint) throws NullPointerException {
+		if (hint == null)
+			throw new NullPointerException("Can't have a null quality");
 		if (hint != this.filter) {
 			this.filter = hint;
 			this.invalidateAssociatedStateTrees();