Created
May 28, 2013 16:53
-
-
Save miho/5664242 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sun.prism.jogl; | |
public class JOGLPipeline extends org.dejay.prism.opengl.JOGLPipeline { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.dejay.prism.opengl; | |
import com.sun.glass.ui.Screen; | |
import com.sun.javafx.geom.Rectangle; | |
import com.sun.javafx.geom.transform.BaseTransform; | |
import com.sun.javafx.logging.PlatformLogger; | |
import com.sun.prism.CompositeMode; | |
import com.sun.prism.RenderTarget; | |
import com.sun.prism.Texture; | |
import com.sun.prism.camera.PrismCameraImpl; | |
import com.sun.prism.impl.VertexBuffer; | |
import com.sun.prism.impl.ps.BaseShaderContext; | |
import com.sun.prism.ps.Shader; | |
import com.sun.prism.ps.ShaderFactory; | |
public class JOGLContext extends BaseShaderContext { | |
public static final PlatformLogger log = PlatformLogger.getLogger(JOGLContext.class.getName()); | |
GLState state = new GLState(); | |
protected JOGLContext(Screen screen, ShaderFactory shaderFactory, VertexBuffer vertexBuffer) { | |
super(screen, shaderFactory, vertexBuffer); | |
} | |
@Override | |
protected State updateRenderTarget(RenderTarget paramRenderTarget, PrismCameraImpl paramPrismCameraImpl, boolean paramBoolean) { | |
log.info(""); | |
return state; | |
} | |
@Override | |
protected void updateTexture(int paramInt, Texture paramTexture) { | |
log.info(""); | |
} | |
@Override | |
protected void updateShaderTransform(Shader paramShader, BaseTransform paramBaseTransform) { | |
log.info(""); | |
} | |
@Override | |
protected void updateClipRect(Rectangle paramRectangle) { | |
log.info(""); | |
} | |
@Override | |
protected void updateCompositeMode(CompositeMode paramCompositeMode) { | |
log.info(""); | |
} | |
static class GLState extends State { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.dejay.prism.opengl; | |
import com.jogamp.newt.Window; | |
import com.jogamp.newt.opengl.GLWindow; | |
import com.sun.javafx.logging.PlatformLogger; | |
import com.sun.prism.RenderTarget; | |
import com.sun.prism.impl.ps.BaseShaderContext; | |
import com.sun.prism.impl.ps.BaseShaderGraphics; | |
import com.sun.prism.paint.Color; | |
public class JOGLGraphics extends BaseShaderGraphics { | |
public static final PlatformLogger log = PlatformLogger.getLogger(JOGLGraphics.class.getName()); | |
protected JOGLGraphics(JOGLContext context, RenderTarget renderTarget) { | |
super(context, renderTarget); | |
log.info("GLGraphics"); | |
// Display.create(pixel_format, shared_drawable) | |
// renderTarget.getNativeDestHandle() | |
} | |
@Override | |
public void clear(Color paramColor) { | |
log.info("Color: " + paramColor); | |
} | |
@Override | |
public void clearQuad(float x, float y, float w, float h) { | |
log.info("clearQuad: " + x + " " + y + " " + w + " " + h); | |
} | |
@Override | |
public void sync() { | |
log.info(""); | |
} | |
@Override | |
public void reset() { | |
log.info(""); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.dejay.prism.opengl; | |
import java.util.List; | |
import java.util.logging.Logger; | |
import com.sun.glass.ui.Screen; | |
import com.sun.javafx.logging.PlatformLogger; | |
import com.sun.prism.GraphicsPipeline; | |
import com.sun.prism.ResourceFactory; | |
public class JOGLPipeline extends GraphicsPipeline { | |
// private Logger log = Logger.getLogger(GLPipeline.class.getName()); | |
public static final PlatformLogger log = PlatformLogger.getLogger(JOGLPipeline.class.getName()); | |
JOGLResourceFactory factory; | |
private static JOGLPipeline pipe; | |
public JOGLPipeline() { | |
} | |
public static JOGLPipeline getInstance() { | |
if (pipe == null) | |
pipe = new JOGLPipeline(); | |
return pipe; | |
} | |
@Override | |
public boolean init() { | |
log.info("-"); | |
return true; | |
} | |
@Override | |
public ResourceFactory getResourceFactory(Screen screen) { | |
log.info("screen: " + screen); | |
return factory; | |
} | |
@Override | |
public ResourceFactory getDefaultResourceFactory(List<Screen> screenList) { | |
log.info("screens: " + screenList.size()); | |
if (factory == null) | |
factory = new JOGLResourceFactory(screenList.get(0), null); | |
return factory; | |
} | |
@Override | |
public boolean is3DSupported() { | |
return true; | |
} | |
@Override | |
public boolean isVsyncSupported() { | |
return true; | |
} | |
@Override | |
public boolean supportsShaderType(ShaderType paramShaderType) { | |
return paramShaderType == ShaderType.GLSL; | |
} | |
@Override | |
public boolean supportsShaderModel(ShaderModel paramShaderModel) { | |
return paramShaderModel == ShaderModel.SM3; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.dejay.prism.opengl; | |
import javax.media.nativewindow.CapabilitiesImmutable; | |
import javax.media.nativewindow.NativeWindowFactory; | |
import javax.media.opengl.GLCapabilities; | |
import javax.media.opengl.GLProfile; | |
import jogamp.newt.DisplayImpl; | |
import jogamp.newt.ScreenImpl; | |
import com.jogamp.nativewindow.WrappedSurface; | |
import com.jogamp.newt.Display; | |
import com.jogamp.newt.NewtFactory; | |
import com.jogamp.newt.Screen; | |
import com.jogamp.newt.Window; | |
import com.jogamp.newt.opengl.GLWindow; | |
import com.jogamp.opengl.swt.GLCanvas; | |
import com.sun.glass.ui.View; | |
import com.sun.javafx.geom.Rectangle; | |
import com.sun.javafx.logging.PlatformLogger; | |
import com.sun.prism.Graphics; | |
import com.sun.prism.GraphicsResource; | |
import com.sun.prism.Presentable; | |
public class JOGLPresentable implements Presentable, GraphicsResource { | |
public static final PlatformLogger log = PlatformLogger.getLogger(JOGLResourceFactory.class.getName()); | |
JOGLContext context; | |
View view; | |
private Screen screen; | |
private Window window; | |
private GLWindow glWindow; | |
public JOGLPresentable(View view, JOGLContext context) { | |
log.info("context: " + context + " view.getNativeView: " + view.getNativeView()); | |
this.context = context; | |
this.view = view; | |
// javax.media.opengl.GLContext.getCurrent() | |
// NativeWindowFactory.getDefaultFactory(). | |
GLWindow tempWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault())); | |
// log.info("tempWindow: " + tempWindow); | |
screen = tempWindow.getScreen(); | |
tempWindow.destroy(); | |
// System.out.println("screen: " + screen); | |
window = NewtFactory.createWindow(view.getNativeView(), screen, new GLCapabilities(GLProfile.getDefault())); | |
glWindow = GLWindow.create(window); | |
// window.setSize(20, 20); | |
// new WrappedSurface(arg0, arg1). | |
log.info("glWindow: " + glWindow); | |
} | |
@Override | |
public void dispose() { | |
log.info(""); | |
} | |
@Override | |
public long getNativeDestHandle() { | |
log.info(""); | |
return 0; | |
} | |
@Override | |
public com.sun.glass.ui.Screen getAssociatedScreen() { | |
log.info(""); | |
return null; | |
} | |
@Override | |
public Graphics createGraphics() { | |
log.info(""); | |
return new JOGLGraphics(context, this); | |
} | |
@Override | |
public boolean isOpaque() { | |
log.info(""); | |
return false; | |
} | |
@Override | |
public void setOpaque(boolean paramBoolean) { | |
log.info(""); | |
} | |
@Override | |
public int getPhysicalWidth() { | |
log.info(""); | |
return 0; | |
} | |
@Override | |
public int getPhysicalHeight() { | |
log.info(""); | |
return 0; | |
} | |
@Override | |
public int getContentX() { | |
log.info(""); | |
return 0; | |
} | |
@Override | |
public int getContentY() { | |
log.info(""); | |
return 0; | |
} | |
@Override | |
public int getContentWidth() { | |
log.info(""); | |
return 0; | |
} | |
@Override | |
public int getContentHeight() { | |
log.info(""); | |
return 0; | |
} | |
@Override | |
public boolean prepare(Rectangle paramRectangle) { | |
log.info("" + paramRectangle); | |
return true; | |
} | |
@Override | |
public boolean present() { | |
log.info(""); | |
return true; | |
} | |
@Override | |
public boolean recreateOnResize() { | |
log.info(""); | |
return false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.dejay.prism.opengl; | |
import java.io.InputStream; | |
import java.util.Map; | |
import com.sun.glass.ui.Screen; | |
import com.sun.glass.ui.View; | |
import com.sun.glass.ui.Window; | |
import com.sun.javafx.logging.PlatformLogger; | |
import com.sun.prism.MediaFrame; | |
import com.sun.prism.PixelFormat; | |
import com.sun.prism.Presentable; | |
import com.sun.prism.RTTexture; | |
import com.sun.prism.RenderingContext; | |
import com.sun.prism.Texture; | |
import com.sun.prism.Texture.Usage; | |
import com.sun.prism.impl.BaseRenderingContext; | |
import com.sun.prism.impl.VertexBuffer; | |
import com.sun.prism.impl.ps.BaseShaderFactory; | |
import com.sun.prism.ps.Shader; | |
import com.sun.prism.ps.ShaderFactory; | |
public class JOGLResourceFactory extends BaseShaderFactory { | |
public static final PlatformLogger log = PlatformLogger.getLogger(JOGLResourceFactory.class.getName()); | |
JOGLContext context; | |
Screen screen; | |
public JOGLResourceFactory(Screen screen, ShaderFactory shaderFactory) { | |
context = new JOGLContext(screen, this, createVertexBuffer(256)); | |
this.screen = screen; | |
} | |
@Override | |
public Shader createShader(InputStream paramInputStream, Map<String, Integer> paramMap1, Map<String, Integer> paramMap2, int paramInt, boolean paramBoolean1, boolean paramBoolean2) { | |
log.info(""); | |
return null; | |
} | |
@Override | |
public Shader createStockShader(String paramString) { | |
log.info("" + paramString); | |
return new JOGLShader(); | |
} | |
@Override | |
public Texture createTexture(PixelFormat paramPixelFormat, Usage paramUsage, int paramInt1, int paramInt2, boolean paramBoolean) { | |
log.info(""); | |
return null; | |
} | |
@Override | |
public Texture createTexture(MediaFrame paramMediaFrame) { | |
log.info(""); | |
return null; | |
} | |
@Override | |
public boolean isFormatSupported(PixelFormat paramPixelFormat) { | |
log.info(""); | |
return false; | |
} | |
@Override | |
public int getMaximumTextureSize() { | |
log.info(""); | |
return 0; | |
} | |
@Override | |
public RTTexture createRTTexture(int paramInt1, int paramInt2) { | |
log.info(""); | |
return null; | |
} | |
@Override | |
public Presentable createPresentable(View view) { | |
log.info("view: " + view); | |
return new JOGLPresentable(view, context); | |
} | |
@Override | |
public VertexBuffer createVertexBuffer(int quads) { | |
log.info(""); | |
return new JOGLVertexBuffer(quads); | |
} | |
@Override | |
public RenderingContext createRenderingContext(View paramView) { | |
log.info(""); | |
return new BaseRenderingContext(); | |
} | |
@Override | |
public void dispose() { | |
log.info(""); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.dejay.prism.opengl; | |
import java.nio.FloatBuffer; | |
import java.nio.IntBuffer; | |
import com.sun.javafx.logging.PlatformLogger; | |
import com.sun.prism.ps.Shader; | |
public class JOGLShader implements Shader { | |
public static final PlatformLogger log = PlatformLogger.getLogger(JOGLShader.class.getName()); | |
public JOGLShader() { | |
log.info(""); | |
} | |
@Override | |
public void dispose() { | |
log.info(""); | |
} | |
@Override | |
public void enable() { | |
log.info(""); | |
} | |
@Override | |
public void disable() { | |
log.info(""); | |
} | |
@Override | |
public boolean isValid() { | |
log.info(""); | |
return true; | |
} | |
@Override | |
public void setConstant(String paramString, int paramInt) { | |
log.info(""); | |
} | |
@Override | |
public void setConstant(String paramString, int paramInt1, int paramInt2) { | |
log.info(""); | |
} | |
@Override | |
public void setConstant(String paramString, int paramInt1, int paramInt2, int paramInt3) { | |
log.info(""); | |
} | |
@Override | |
public void setConstant(String paramString, int paramInt1, int paramInt2, int paramInt3, int paramInt4) { | |
log.info(""); | |
} | |
@Override | |
public void setConstants(String paramString, IntBuffer paramIntBuffer, int paramInt1, int paramInt2) { | |
log.info(""); | |
} | |
@Override | |
public void setConstant(String paramString, float paramFloat) { | |
log.info(""); | |
} | |
@Override | |
public void setConstant(String paramString, float paramFloat1, float paramFloat2) { | |
log.info(""); | |
} | |
@Override | |
public void setConstant(String paramString, float paramFloat1, float paramFloat2, float paramFloat3) { | |
log.info(""); | |
} | |
@Override | |
public void setConstant(String paramString, float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) { | |
log.info(""); | |
} | |
@Override | |
public void setConstants(String paramString, FloatBuffer paramFloatBuffer, int paramInt1, int paramInt2) { | |
log.info(""); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.dejay.prism.opengl; | |
import com.sun.javafx.logging.PlatformLogger; | |
import com.sun.prism.impl.VertexBuffer; | |
import com.sun.prism.paint.Color; | |
public class JOGLVertexBuffer extends VertexBuffer { | |
public static final PlatformLogger log = PlatformLogger.getLogger(JOGLContext.class.getName()); | |
protected JOGLVertexBuffer(int quads) { | |
super(quads); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sun.prism.jogl; | |
import javafx.application.Application; | |
import javafx.scene.Group; | |
import javafx.scene.Scene; | |
import javafx.scene.shape.Rectangle; | |
import javafx.stage.Stage; | |
import com.sun.prism.impl.PrismSettings; | |
public class TestJOGLPipeline extends Application { | |
@Override | |
public void start(Stage primaryStage) throws Exception { | |
try { | |
primaryStage.setWidth(200); | |
primaryStage.setHeight(200); | |
// primaryStage.setScene(new Scene(new Group())); | |
primaryStage.setScene(new Scene(new Group(new Rectangle(50, 50)))); | |
primaryStage.show(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
public static void main(String[] args) { | |
try { | |
PrismSettings.verbose = true; | |
PrismSettings.tryOrder = new String[] { "jogl" }; | |
Application.launch(args); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment