使用AndEngine for Android,我想让我的场景看起来像这样:

例如,红色框是世界,必须限制在给定的大小2000px*450px.
蓝色框是Camera,也是有限的(通常),例如750px*450px.
对于整个场景,我的背景图像非常450px高.所以我Camera可以缩放到适当的大小,但背景必须完全适合高度.宽度Camera可以是可变的.
玩家(圈子)必须始终位于中心(水平),但可能不会离开世界的边界.
为此,我尝试添加两种尺寸:
CAMERA_WIDTH,CAMERA_HEIGHT)WORLD_WIDTH,WORLD_HEIGHT)而这个功能是为世界添加边界,以便物理引擎阻止玩家离开这些边界:
private void createWorldBoundaries() {
Body body;
final Rectangle wall_top = new Rectangle(0, WORLD_HEIGHT-5, WORLD_WIDTH, 10, mVertexManager);
final Rectangle wall_bottom = new Rectangle(0, 5, WORLD_WIDTH, 10, mVertexManager);
final Rectangle wall_left = new Rectangle(5, 0, 10, WORLD_HEIGHT, mVertexManager);
final Rectangle wall_right = new Rectangle(WORLD_WIDTH-5, 0, 10, WORLD_HEIGHT, mVertexManager);
body = PhysicsFactory.createBoxBody(mPhysicsWorld, …Run Code Online (Sandbox Code Playgroud) 如何对整个渲染中的三角形进行抗锯齿处理?我应该把它放在fragmentShader上吗?有没有其他好的解决方案来改善这种事情?
这是我的"视图",边缘非常脆(不是很好).

我试图弄清楚如何采用如下的typdef结构:
typedef struct {
float Position[3];
float Color[4];
float TexCoord[2];
} const Vertex;
Run Code Online (Sandbox Code Playgroud)
并将其转换为单独的数组.
我有以下作为我的转换数组:
+ (...)arrayConverter: (Vertex *) v
{
// Turn typeDef struct into seperate arrays
NSMutableArray *position = [[NSMutableArray alloc] init];
NSMutableArray *color = [[NSMutableArray alloc] init];
NSMutableArray *texcord = [[NSMutableArray alloc] init];
const NSMutableArray *vertexdata = [[NSMutableArray alloc] init];
for (int p=0; p<(sizeof(v->Position)/sizeof(v)); p++) {
[position addObject:[NSNumber numberWithFloat:v->Position[p]]];
}
for (int c=0; c<(sizeof(v->Color)/sizeof(v)); c++) {
[color addObject:[NSNumber numberWithFloat:v->Color[c]]];
}
for (int t=0; t<(sizeof(v->TexCoord)/sizeof(v)); t++) {
[texcord …Run Code Online (Sandbox Code Playgroud) 我对OpenGL上的一个纹理有一个可怕的行为.
删除纹理后,我创建一个新纹理,它生成与以前相同的tex编号,但纹理不正确.glGetError也会在每一行返回0!我尝试在glDeleteTextures之后添加glFlush/glFinish,但它没有改变任何东西!纹理编号似乎锁定在某处......为什么?
它是单线程的,这里的行为:
//myTexture == 24 is loaded and works correctly
GLboolean bIsTexture = glIsTexture(myTexture); //returns 1 = > ok
glDeleteTextures(1,&myTexture);
bIsTexture = glIsTexture(myTexture); //returns 0 => ok
//Let's create a new texture
glGenTextures(1,&myTexture);//myTexture == 24 (as the glDelete was ok)
glBindTexture(GL_TEXTURE_2D,myTexture);
bIsTexture = glIsTexture(myTexture); //returns 0 => FAILS
Run Code Online (Sandbox Code Playgroud) 我正在为Android制作应用程序,我画了一个三角形,我可以旋转它但不动它!我的问题为什么?
如果您需要更多信息,请说
package com.uraniumdevs.projectx;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.Matrix;
import android.util.Log;
public class MyGL20Renderer implements GLSurfaceView.Renderer {
private static final String TAG = "MyGLRenderer";
private Triangle mTriangle;
private Square mSquare;
private final float[] mMVPMatrix = new float[16];
private final float[] mProjMatrix = new float[16];
private final float[] mVMatrix = new float[16];
private final float[] mRotationMatrix = new float[16];
private final float[] mTranslationMatrix = new float[16];
// …Run Code Online (Sandbox Code Playgroud) 我想这样,当网格A(角色)位于网格B(墙壁)后面时,它仍然呈现但是具有纯灰色.
我正在开始使用opengles 2.0,我仍然不确定是否会这样做.根据我的理解深度缓冲区允许网格战斗谁将在他们所包含的片段中看到,也有各种可能涉及的混合函数,最后模板缓冲区看起来它也将具有这种理想的功能.
那么有没有办法根据失败的深度测试通过着色器输出不同的颜色?有没有办法通过混合来做到这一点?或者我必须如何使用模板缓冲区?
什么是这种技术需要将来参考?我已经看到它用在很多电子游戏中.
注意:
在挖掘之后,事实证明它glCreateProgram()一直在返回0.一旦我搞清楚了,我会发布一个修复程序.如果你们知道可能导致它的原因,请发表评论^^
context 是正确创建的.
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
谢谢.
正确加载此文件.它保存为cl.vsh
它加载正常,但在编译阶段失败.
这是cl.vsh中的代码
attribute vec4 position;
attribute vec3 normal;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 modelViewMatrix;
uniform mat3 normalMatrix;
uniform float time;
varying vec3 eyespaceNormal;
varying vec4 eyespacePosition;
varying vec3 noiseVector;
void main()
{
int i = 0;
// vec3 translation = vec3(1.0, 1.0, 1.0) * time / 20.0;
// noiseVector = position.xyz + translation;
//
// eyespaceNormal = normalMatrix * normal;
// eyespacePosition = modelViewMatrix * position;
// …Run Code Online (Sandbox Code Playgroud) 我对使用这行代码自动生成的mipmap获得的质量不满意:
glTexParameterf(GL10.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL10.GL_TRUE);
Run Code Online (Sandbox Code Playgroud)
我想为我的游戏中使用的每个纹理创建(使用Gimp)我的纹理的各种缩放版本.例如,对于球的纹理,我将:
ball256.png 256x256像素
ball128.png 128x128像素
ball64.png 64x64像素
ball32.png 32x32像素
ball16.png 16x16像素
1.你认为这是一个好主意吗?
2.如何从所有这些图像创建单个mipmap纹理?
我找不到使用光线追踪方法在3D中拾取的正确和可理解的表达方式.有没有人用任何语言实现这个算法?直接共享工作代码,因为由于伪代码无法编译,所以它们通常用缺少的部分编写.
我有一个UI应用程序,它分别将输出呈现为16,24或32 bpp的屏幕外帧缓冲.
我需要计算音高,我的理解是音高是一条扫描线中的字节数,它是否等于screenx*bitsperpixel?虽然显然它没有产生正确的结果.
我们可以用公式(通用)来计算音高吗?
opengl-es ×10
android ×4
c++ ×3
iphone ×2
objective-c ×2
opengl ×2
shader ×2
2d ×1
3d ×1
andengine ×1
antialiasing ×1
c ×1
glsl ×1
ios ×1
java ×1
ray-picking ×1
rendering ×1
textures ×1
translation ×1
xcode ×1