小编fky*_*fky的帖子

LibGDX SpriteBatch Multitexture可能吗?

我很高兴使用LibGDX Framework的SpriteBatch类.我的目标是通过着色器修改精灵的表示.

batch = new SpriteBatch(2, shaderProgram);
Run Code Online (Sandbox Code Playgroud)

我从SpriteBatch类中复制了默认着色器,并添加了另一个统一的Sampler 2d

+ "uniform sampler2D u_Texture2;\n"//
Run Code Online (Sandbox Code Playgroud)

是否有一种工作方式将纹理赋予着色器.这样做,总是在ClearColor屏幕中结束.

batch.begin();
  texture2.bind(1);
  shaderProgram.setUniformi("u_Texture2", 1);
  batch.draw(spriteTexture,positions[0].x,positions[0].y);
  batch.draw(spriteTexture,positions[1].x,positions[1].y);
batch.end();
Run Code Online (Sandbox Code Playgroud)

每个纹理都在工作.在Mesh类的帮助下手动绘制按预期工作.那么我该怎么做才能使用SpriteBatch的便利呢?

THX寻求帮助

android multitexturing opengl-es-2.0 libgdx spritebatch

5
推荐指数
1
解决办法
2904
查看次数

使用 const 时,OSX 上的 Opengl es 2.0 GLSL 编译失败

我有点沮丧。我即将使用 mac(OS X 小牛)进行编码。

我的着色器在 windows 7 和 android 下运行良好。当我在 OS X 下运行我的应用程序时,我在运行时遇到以下编译器错误。

Exception in thread "LWJGL Application" java.lang.IllegalStateException: ERROR: 0:6: Initializer not allowed
ERROR: 0:6: Use of undeclared identifier 'light'
ERROR: 0:6: Use of undeclared identifier 'spec'
ERROR: 0:6: Use of undeclared identifier 'spec'
ERROR: 0:6: Use of undeclared identifier 'spec'
Run Code Online (Sandbox Code Playgroud)

片段着色器片段:

 String fragmentShader =   
                "#ifdef GL_ES\n" +
                "precision mediump float;\n" +
                "#endif\n" +
                "uniform sampler2D cubeMap;\n"+
                "uniform sampler2D normalMap;"+                 
                "varying vec2 v_TexCoords;"+

                "void main() {\n"+

                "   const vec4 …
Run Code Online (Sandbox Code Playgroud)

macos opengl-es glsl libgdx osx-mavericks

2
推荐指数
2
解决办法
1447
查看次数