当前位置: 首页>>代码示例>>Java>>正文


Java ShaderProgram类代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.glutils.ShaderProgram的典型用法代码示例。如果您正苦于以下问题:Java ShaderProgram类的具体用法?Java ShaderProgram怎么用?Java ShaderProgram使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ShaderProgram类属于com.badlogic.gdx.graphics.glutils包,在下文中一共展示了ShaderProgram类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCommand

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入依赖的package包/类
@Override
public void onCommand(PolygonSpriteBatch batch) {
   	if(_shaderProgram == null) {
   		ShaderProgram p = GLProgramCache.getInstance().getSpriteBatchDefaultProgram();
   		if(batch.getShader() != p) {
   			batch.setShader(null);
   		}
   	} else {
   		if(batch.getShader() != _shaderProgram) {
   			batch.setShader(_shaderProgram);
   		}
   	}
   	if(_sprite.getTexture() != null) {
   		_sprite.draw(batch);
   	}
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:17,代码来源:Sprite.java

示例2: setupRendering

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入依赖的package包/类
private void setupRendering() {
    ShaderProgram.pedantic = false;

    gameCamera = new OrthographicCamera();
    gameCamera.setToOrtho(false, BUFFER_WIDTH, BUFFER_HEIGHT);
    gameCamera.translate(EDITOR_OFFSET, 0);
    gameCamera.update();

    starCamera = new OrthographicCamera();
    starCamera.setToOrtho(false, BUFFER_WIDTH, BUFFER_HEIGHT);
    starCamera.translate(STAR_EDITOR_OFFSET, 0);
    starCamera.update();

    screenCamera = new OrthographicCamera();
    screenCamera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    screenCamera.update();

    batch = new SpriteBatch();
    pixelBuffer = new PixelBuffer();
}
 
开发者ID:ZKasica,项目名称:Planet-Generator,代码行数:21,代码来源:Scene.java

示例3: 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");
}
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:17,代码来源:DefaultGameAsset.java

示例4: 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");
	}
}
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:28,代码来源:BaseGameScene3D.java

示例5: 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();
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:26,代码来源:WorldShaderProvider.java

示例6: 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;
	}
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:25,代码来源:CompliantBatch.java

示例7: createShader

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入依赖的package包/类
public void createShader(){
    String vertexShaderSrc =  "attribute vec4 a_position;    \n" +
            "void main()                  \n" +
            "{                            \n" +
            "   gl_Position = a_position;  \n" +
            "}                            \n";
    String fragmentShaderSrc = "#ifdef GL_ES\n" +
            "precision mediump float;\n" +
            "#endif\n" +
            "uniform vec4 u_color;    \n" +
            "void main()                                  \n" +
            "{                                            \n" +
            "  gl_FragColor =  u_color;\n" +
            "}                                            \n";

    shader=new ShaderProgram(vertexShaderSrc,fragmentShaderSrc);

    u_color = shader.getUniformLocation("u_color");
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:20,代码来源:FullScreenFader.java

示例8: 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);
}
 
开发者ID:EtherWorks,项目名称:arcadelegends-gg,代码行数:26,代码来源:RenderSystem.java

示例9: GameState

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入依赖的package包/类
public GameState(String name, String tmx, StateManager manager) {
	this.tmx = tmx;
	setManager(manager);
	if(name!=null)
	this.name = name;
	else
		this.name = "";
	sprites = new ObjectMap<String, Sprite>();
	animations = new ObjectMap<String, Animation<String>>();
	fonts = new ObjectMap<String, BitmapFont>(); //TODO: test load to avoid repeats
	particle_effects = new ObjectMap<String, ParticleEffectPool>();
	pvalues = new Array<String>();
	time_scale = 1f;
	shaders = new ObjectMap<String, ShaderProgram>();
	svalues = new Array<String>();
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:17,代码来源:GameState.java

示例10: loadShaders

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入依赖的package包/类
private void loadShaders(TiledMap data) {
	MapObjects objects = data.getLayers().get("preload").getObjects();
	String scheck = "Shader";
	for (MapObject o : objects) {
		String name = o.getName();
		MapProperties properties = o.getProperties();
		String type = properties.get("type", String.class);
		if (type != null && type.equals(scheck)) {
			String file = properties.get("shader_name", String.class);
			if (file != null) {
				game.loadShader(file);
				game.getAssetManager().finishLoading();
				if (!shaders.containsKey(name)) {
					ShaderProgram sp = game.getShader(file);
					shaders.put(name, sp);
					svalues.add(KyperBoxGame.SHADER_FOLDER + KyperBoxGame.FILE_SEPARATOR + file);
				}
			}
		}
	}
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:22,代码来源:GameState.java

示例11: 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;
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:28,代码来源:ShaderManager.java

示例12: initShader

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入依赖的package包/类
private ShaderProgram initShader(Texture colorMapTex, Texture maskMapTex, Texture normalMapTex, TransVec dim,
		float amIntensity, float dirIntensity, float shadIntensity, float sprtSize, float lum, float thresh, ShaderProgram shader) {
	shader.begin();
	{
		maskMapTex.bind(2);
		normalMapTex.bind(1);
		colorMapTex.bind(0);
		super.batcher.setShader(shader);

		shader.setUniformi(maskMap, 2);
		shader.setUniformi(normalMap, 1);
		shader.setUniformi(colorMap, 0);

		shader.setUniformf(fieldSize, dim.x, dim.y);
		shader.setUniformf(ambientIntensity, amIntensity);
		shader.setUniformf(directIntensity, dirIntensity);
		shader.setUniformf(shadowIntensity, shadIntensity);
		shader.setUniformf(spriteSize, sprtSize);
		shader.setUniformf(height, lum);
		shader.setUniformf(threshold, thresh);
	}
	shader.end();
	return shader;
}
 
开发者ID:henryco,项目名称:Escapy,代码行数:25,代码来源:EscapyVolumeRenderer.java

示例13: renderBRDF

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入依赖的package包/类
private Texture renderBRDF() {
    ShaderProgram brdfShader = new ShaderProgram(
            Gdx.files.internal("shaders/brdf_shader.vert"),
            Gdx.files.internal("shaders/brdf_shader.frag"));

    FrameBuffer frameBuffer = FrameBuffer.createFrameBuffer(Pixmap.Format.RGB888, (int) brdfWidth, (int) brdfHeight, true);

    brdfShader.begin();
    frameBuffer.begin();
    Gdx.gl.glViewport(0, 0, (int) brdfWidth, (int) brdfHeight);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    quadMesh.render(brdfShader, GL20.GL_TRIANGLES);
    frameBuffer.end();
    brdfShader.end();
    brdfShader.dispose();

    return frameBuffer.getColorBufferTexture();
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:19,代码来源:LightProbe.java

示例14: create

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入依赖的package包/类
@Override
public void create() {
    super.create();

    geometryPass = new ShaderProgram(
            Gdx.files.internal("shaders/g_buffer.vert"),
            Gdx.files.internal("shaders/g_buffer.frag"));

    lightingPass = new ShaderProgram(
            Gdx.files.internal("shaders/deferred_shader.vert"),
            Gdx.files.internal("shaders/deferred_shader.frag"));

    ModelBuilder mb = new ModelBuilder();
    Model cube = mb.createBox(1, 1, 1, new Material(),
            VertexAttributes.Usage.Position |
                    VertexAttributes.Usage.Normal |
                    VertexAttributes.Usage.TextureCoordinates);
    cubeMesh = cube.meshes.first();
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:20,代码来源:MainDef.java

示例15: 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");
}
 
开发者ID:PWorlds,项目名称:LibGDX-PBR,代码行数:20,代码来源:PBRShader.java


注:本文中的com.badlogic.gdx.graphics.glutils.ShaderProgram类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。