本文整理汇总了Java中com.badlogic.gdx.graphics.glutils.ShaderProgram.isCompiled方法的典型用法代码示例。如果您正苦于以下问题:Java ShaderProgram.isCompiled方法的具体用法?Java ShaderProgram.isCompiled怎么用?Java ShaderProgram.isCompiled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.glutils.ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram.isCompiled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
@Override
public ShaderProgram loadShader(String vsFilePath)
{
if(!Game.isSupportOpenGL20)
return null;
String fsProcess = vsFilePath.substring(0, vsFilePath.length()-7);
fsProcess += "fs.glsl";
ShaderProgram shader = new ShaderProgram(Gdx.files.internal(vsFilePath),
Gdx.files.internal(fsProcess));
if(shader.isCompiled())
return shader;
else
throw new GdxRuntimeException("Cannot compile the shader");
}
示例2: preRender
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
/**
* Call right before starting render stage of Scene 3D
*/
protected void preRender() {
//Create default member for managers if the managers don't have any member.
if(camera.count() == 0)
{
camera.add("default", new FreeCamera(70, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), new Vector3(0, 5, 5), 0,135));
camera.setActiveCamera("default");
}
if(light.count() == 0 && Game.isSupportOpenGL20)
{
light.addBaseLight("default", new DirectionLight(new Vector3(1, 1, 1), new Vector3(1, 1, -1)));
}
if(shader.count() == 0 && Game.isSupportOpenGL20)
{
String vs = loadShaderFile("effect/default-vs.glsl");
String fs = loadShaderFile("effect/default-fs.glsl");
ShaderProgram s = new ShaderProgram(vs , fs);
if(!s.isCompiled())
{
throw new GdxRuntimeException("Cannot compile default shader");
}
shader.add("default", s);
shader.setActiveShader("default");
}
}
示例3: getShaderIf
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
private void getShaderIf(int shader, Renderable renderable, boolean fogFlag, boolean aoFlag) {
if (shaders[shader] == null) {
if (shader == 0) {
shaders[shader] = new CubesShader(renderable);
} else {
ArrayList<Feature> f = new ArrayList<Feature>();
if (fogFlag)
f.add(new FogFeature());
if (aoFlag)
f.add(new AmbientOcclusionFeature());
shaders[shader] = new FeatureShader(renderable, f);
}
ShaderProgram program = shaders[shader].program;
if (!program.isCompiled()) {
Log.error("Failed to compile shader");
Log.error("Shader log: \n" + program.getLog());
Log.error("Fragment shader source: \n" + program.getFragmentShaderSource());
Log.error("Vertex shader source: \n" + program.getVertexShaderSource());
throw new CubesException("Failed to compile shader");
}
shaders[shader].init();
}
}
示例4: CompliantBatch
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
/** Constructs a CompliantQuadBatch with a specified capacity and optional default shader.
* @param maxVertices The number of vertices this FlexBatch can batch at once. Maximum of 32767.
* @param generateDefaultShader Whether a default shader should be created. The default shader is owned by the
* CompliantQuadBatch, so it is disposed when the CompliantQuadBatch is disposed. If an alternate shader has been
* applied with {@link #setShader(ShaderProgram)}, the default can be used again by setting the shader to null.
* @param supportPolygons Whether Poly2Ds are supported for drawing. The FlexBatch will not be optimized for
* FixedSizeBatchables. */
public CompliantBatch (Class<T> batchableType, int maxVertices, boolean generateDefaultShader, boolean supportPolygons) {
super(batchableType, maxVertices, supportPolygons ? maxVertices * 2 : 0);
try {
tmp = batchableType.newInstance();
} catch (Exception e) {
throw new IllegalArgumentException("Batchable classes must be public and have an empty constructor.", e);
}
if (generateDefaultShader) {
defaultShader = new ShaderProgram(BatchablePreparation.generateGenericVertexShader(1),
BatchablePreparation.generateGenericFragmentShader(1));
if (defaultShader.isCompiled() == false)
throw new IllegalArgumentException("Error compiling shader: " + defaultShader.getLog());
setShader(defaultShader);
} else {
defaultShader = null;
}
}
示例5: RenderSystem
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
public RenderSystem(DecalBatch decalBatch, AssetManager assetManager, float worldDegree, Assets.LevelAssets assets) {
super(Aspect.all(RenderComponent.class, PositionComponent.class));
this.levelAssets = assets;
decalMap = new ObjectMap<>();
uiMap = new ObjectMap<>();
this.decalBatch = decalBatch;
this.assetManager = assetManager;
buffers = new ObjectMap<>();
this.spriteBatch = new SpriteBatch();
this.font = assets.uifont;
font.setColor(Color.BLACK);
this.uiCamera = new OrthographicCamera();
Viewport viewportUi = new FitViewport(levelAssets.health_bar_gradient.getWidth(), levelAssets.health_bar_gradient.getHeight(), uiCamera);
viewportUi.update(viewportUi.getScreenWidth(), viewportUi.getScreenHeight(), true);
stateTime = 0;
this.worldDegree = worldDegree;
gradientShader = new ShaderProgram(Shaders.GradientShader.vertexShader, Shaders.GradientShader.fragmentShader);
if (gradientShader.isCompiled() == false)
throw new IllegalArgumentException("couldn't compile shader: " + gradientShader.getLog());
shaderBatch = new SpriteBatch(10, gradientShader);
}
示例6: createShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
static final public ShaderProgram createShader(String vertexName,
String fragmentName) {
/*String vertexShader = Gdx.files.classpath(
"bloom/bloomshaders/" + vertexName
+ ".vertex.glsl").readString();
String fragmentShader = Gdx.files.classpath(
"bloom/bloomshaders/" + fragmentName
+ ".fragment.glsl").readString();*/
String vertexShader = Gdx.files.internal(
"data/bloomshaders/" + vertexName
+ ".vertex.glsl").readString();
String fragmentShader = Gdx.files.internal(
"data/bloomshaders/" + fragmentName
+ ".fragment.glsl").readString();
ShaderProgram.pedantic = false;
ShaderProgram shader = new ShaderProgram(vertexShader, fragmentShader);
if (!shader.isCompiled()) {
System.out.println(shader.getLog());
Gdx.app.exit();
} else
Gdx.app.log("shader compiled", shader.getLog());
return shader;
}
示例7: init
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
/** Adds GLES specifics (if needed) and compiles shaders.
*
* @param key - shader identifier
* @param vert - vertex shader source
* @param frag - fragment shader source
* @return whether the shaders compiled correctly */
protected boolean init (String key, String vert, String frag) {
if (frag == null || vert == null)
return false;
frag = appendGLESPrecisions(frag);
vert = appendGLESPrecisions(vert);
sourcesVert.put(key, vert);
sourcesFrag.put(key, frag);
ShaderProgram sp = new ShaderProgram(vert, frag);
if (!sp.isCompiled()) {
Gdx.app.log("ShaderManager", "Error while loading shader '" + key + "':\n" + sp.getLog());
Gdx.app.log("ShaderManager", "--------------------------------");
Gdx.app.log("ShaderManager", "Vertex shader source: \n" + vert);
Gdx.app.log("ShaderManager", "--------------------------------");
Gdx.app.log("ShaderManager", "Fragment shader source: \n" + frag);
Gdx.app.log("ShaderManager", "--------------------------------");
return false;
}
shaders.put(key, sp);
Gdx.app.log("ShaderManager", "Shader '" + key + "' loaded");
return true;
}
示例8: init
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
@Override
public void init() {
loadReflection("rnl_phong_m00");
String vert = Gdx.files.internal("Shaders/VS_ShaderPlain.vsh").readString();
String frag = Gdx.files.internal("Shaders/ShaderPlain.fsh").readString();
program = new ShaderProgram(vert, frag);
if (!program.isCompiled()){
throw new GdxRuntimeException(program.getLog());
}
u_worldTrans = program.getUniformLocation("u_worldTrans");
u_projTrans = program.getUniformLocation("u_projTrans");
vLight0 = program.getUniformLocation("vLight0");
albedo = program.getUniformLocation("albedo");
metallic = program.getUniformLocation("metallic");
sCubemapTexture = program.getUniformLocation("sCubemapTexture");
vRoughness = program.getUniformLocation("vRoughness");
ambientOcclusion = program.getUniformLocation("ambientOcclusion");
}
示例9: init
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
@Override
public void init() {
loadReflection("rnl_phong_m00");
String vert = Gdx.files.internal("Shaders/VS_PBR_ShaderTexture.vsh").readString();
String frag = Gdx.files.internal("Shaders/PBR_ShaderTexture.fsh").readString();
program = new ShaderProgram(vert, frag);
if (!program.isCompiled()){
throw new GdxRuntimeException(program.getLog());
}
u_worldTrans = program.getUniformLocation("u_worldTrans");
u_projTrans = program.getUniformLocation("u_projTrans");
vLight0 = program.getUniformLocation("vLight0");
albedoTexture = program.getUniformLocation("albedoTexture");
metallicTexture = program.getUniformLocation("metallicTexture");
sCubemapTexture = program.getUniformLocation("sCubemapTexture");
roughnessTexture = program.getUniformLocation("roughnessTexture");
ambientOcclusionTexture = program.getUniformLocation("ambientOcclusionTexture");
normalTexture = program.getUniformLocation("normalTexture");
heightTexture = program.getUniformLocation("heightTexture");
}
示例10: create
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
@Override
public void create() {
//Load UI
gameHud = new GameHud(this, world);
ShaderProgram.pedantic = false;
program = new ShaderProgram(Gdx.files.internal("shaders/sepia.vsh"), Gdx.files.internal("shaders/sepia.fsh"));
if (!program.isCompiled()) {
System.out.println(program.getLog());
}
camera = new OrthoCamera();
Timer.startGameTime();
resize(Settings.getWidth(), Settings.getHeight());
}
示例11: Planet
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
public Planet(Sprite sprite, Pixmap pixmap, int direction) {
super(sprite);
this.pixmap = pixmap;
this.direction = direction;
rotationSpeed = 1/50f;
radius = sprite.getWidth()/2;
planetShader = new ShaderProgram(Gdx.files.internal("shaders/planet.vsh"), Gdx.files.internal("shaders/planet.fsh"));
if(!planetShader.isCompiled()) {
Gdx.app.error("Planet Shader Error", "\n" + planetShader.getLog());
}
}
示例12: getShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
@Override
public Shader getShader(Renderable renderable) {
int shader = 0;
boolean fogFlag = Settings.getBooleanSettingValue(Settings.GRAPHICS_FOG);
if (renderable.userData instanceof RenderingSettings) fogFlag &= ((RenderingSettings) renderable.userData).fogEnabled;
if (fogFlag) shader |= FEATURE_FOG;
boolean aoFlag = renderable.meshPart.mesh.getVertexAttributes() == CubesVertexAttributes.VERTEX_ATTRIBUTES_AO;
if (aoFlag) shader |= FEATURE_AO;
if (shaders[shader] == null) {
if (shader == 0) {
shaders[shader] = new CubesShader(renderable);
} else {
ArrayList<Feature> f = new ArrayList<Feature>();
if (fogFlag) f.add(new FogFeature());
if (aoFlag) f.add(new AmbientOcclusionFeature());
shaders[shader] = new FeatureShader(renderable, f);
}
ShaderProgram program = shaders[shader].program;
if (!program.isCompiled()) {
Log.error("Failed to compile shader");
Log.error("Shader log: \n" + program.getLog());
Log.error("Fragment shader source: \n" + program.getFragmentShaderSource());
Log.error("Vertex shader source: \n" + program.getVertexShaderSource());
throw new CubesException("Failed to compile shader");
}
shaders[shader].init();
}
return shaders[shader];
}
示例13: createShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
/**
* Compiles a new instance of the default shader for this batch and returns it. If compilation
* was unsuccessful, GdxRuntimeException will be thrown.
* @return the default shader
*/
public static ShaderProgram createShader(String vert, String frag) {
ShaderProgram prog = new ShaderProgram(vert, frag);
if (!prog.isCompiled())
throw new GdxRuntimeException("could not compile shader: " + prog.getLog());
if (prog.getLog().length() != 0)
Gdx.app.log("com.mygdx.pmd.desktop.GpuShadows", prog.getLog());
return prog;
}
示例14: createShadowShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
static final public ShaderProgram createShadowShader() {
final String vertexShader = "attribute vec4 a_position;\n" //
+ "attribute vec2 a_texCoord;\n" //
+ "varying vec2 v_texCoords;\n" //
+ "\n" //
+ "void main()\n" //
+ "{\n" //
+ " v_texCoords = a_texCoord;\n" //
+ " gl_Position = a_position;\n" //
+ "}\n";
final String fragmentShader = "#ifdef GL_ES\n" //
+ "precision lowp float;\n" //
+ "#define MED mediump\n"
+ "#else\n"
+ "#define MED \n"
+ "#endif\n" //
+ "varying MED vec2 v_texCoords;\n" //
+ "uniform sampler2D u_texture;\n" //
+ "void main()\n"//
+ "{\n" //
+ "gl_FragColor = texture2D(u_texture, v_texCoords);\n"
+ "}\n";
ShaderProgram.pedantic = false;
ShaderProgram woShadowShader = new ShaderProgram(vertexShader,
fragmentShader);
if (woShadowShader.isCompiled() == false) {
Gdx.app.log("ERROR", woShadowShader.getLog());
}
return woShadowShader;
}
示例15: createLightShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
static final public ShaderProgram createLightShader() {
String gamma = "";
if (RayHandler.getGammaCorrection())
gamma = "sqrt";
final String vertexShader =
"attribute vec4 vertex_positions;\n" //
+ "attribute vec4 quad_colors;\n" //
+ "attribute float s;\n"
+ "uniform mat4 u_projTrans;\n" //
+ "varying vec4 v_color;\n" //
+ "void main()\n" //
+ "{\n" //
+ " v_color = s * quad_colors;\n" //
+ " gl_Position = u_projTrans * vertex_positions;\n" //
+ "}\n";
final String fragmentShader = "#ifdef GL_ES\n" //
+ "precision lowp float;\n" //
+ "#define MED mediump\n"
+ "#else\n"
+ "#define MED \n"
+ "#endif\n" //
+ "varying vec4 v_color;\n" //
+ "void main()\n"//
+ "{\n" //
+ " gl_FragColor = "+gamma+"(v_color);\n" //
+ "}";
ShaderProgram.pedantic = false;
ShaderProgram lightShader = new ShaderProgram(vertexShader,
fragmentShader);
if (lightShader.isCompiled() == false) {
Gdx.app.log("ERROR", lightShader.getLog());
}
return lightShader;
}