From 48201a6ea6471eb5951edb735b36156ab3410a15 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 23 Apr 2011 06:12:10 +0200 Subject: Refactored graph: Reduce/remove data copy/recreation; Shader cleanup - Pass the current GL context object where it's required - Introduce RenderState (which has ShaderState) to acquire/change shader related data (Region) - Shader Cleanup: User import for common stuff; use req. version - Reduce/remove data copy/recreation in *Region implementation - UI/RIButton: Use defaults I like :) --- .../com/jogamp/graph/curve/RegionFactory.java | 35 +++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'src/jogl/classes/com/jogamp/graph/curve/RegionFactory.java') diff --git a/src/jogl/classes/com/jogamp/graph/curve/RegionFactory.java b/src/jogl/classes/com/jogamp/graph/curve/RegionFactory.java index 91bbbd787..23b318e8a 100755 --- a/src/jogl/classes/com/jogamp/graph/curve/RegionFactory.java +++ b/src/jogl/classes/com/jogamp/graph/curve/RegionFactory.java @@ -27,36 +27,43 @@ */ package com.jogamp.graph.curve; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; -import com.jogamp.opengl.util.glsl.ShaderState; +import com.jogamp.graph.curve.opengl.RenderState; import jogamp.graph.curve.opengl.VBORegionSPES2; import jogamp.graph.curve.opengl.VBORegion2PES2; - /** RegionFactory to create a Context specific Region implementation. * * @see Region */ public class RegionFactory { - /**Create a Region based on the GLContext attached - * @param context the current {@link GLContext} - * @param st the {@link ShaderState} object - * @param type can be one of Region.SINGLE_PASS or Region.TWO_PASS + /** + * Create a Region using the passed curren GL object. + * + *

In case {@link Region#TWO_PASS} is being requested the default texture unit + * {@link Region#TWO_PASS_DEFAULT_TEXTURE_UNIT} is being used.

+ * @param rs TODO + * @param type can be one of {@link Region#SINGLE_PASS} or {@link Region#TWO_PASS} + * * @return region */ - public static Region create(GLContext context, ShaderState st, int type){ - if( !context.isGL2ES2() ) { - throw new GLException("At least a GL2ES2 GL context is required. Given: " + context); - } + public static Region create(RenderState rs, int type) { if( Region.TWO_PASS == type ){ - return new VBORegion2PES2(context, st); + return new VBORegion2PES2(rs, Region.TWO_PASS_DEFAULT_TEXTURE_UNIT); } else{ - return new VBORegionSPES2(context); + return new VBORegionSPES2(rs); } } + + public static Region createSinglePass(RenderState rs) { + return new VBORegionSPES2(rs); + } + + public static Region createTwoPass(RenderState rs, int textureUnit) { + return new VBORegion2PES2(rs, textureUnit); + } } -- cgit v1.2.3