我正在寻找一种启发式方法,用于确定哪些iPhone/iPad开发的主要图形方法对于给定问题最合适的解决方案.
我试图使用着色器管道(OpenGL ES 2.0)将我的固定管道代码(OpenGL ES 1.1)转换为一个.但是只有一个纹理似乎工作,我得到错误:
Validation Failed: Sampler error:
Samplers of different types use the same texture image unit.
- or -
A sampler's texture unit is out of range (greater than max allowed or negative).
Run Code Online (Sandbox Code Playgroud)
在我的片段着色器中,我有一个统一的纹理ID和从我的顶点着色器传来的纹理坐标:
varying lowp vec4 colorVarying;
varying lowp vec2 texCoordsVarying;
uniform sampler2D texID;
void main()
{
lowp vec4 colour = texture2D(texID, texCoordsVarying);
gl_FragColor = colour * colorVarying;
}
Run Code Online (Sandbox Code Playgroud)
据我了解,因为我只使用一个纹理,我只需要一个活动的纹理单元.因此,在我的管道中,我通过激活适当的纹理单元,绑定当前纹理并将纹理ID的统一值设置为纹理单元来设置纹理.然后我继续绘制顶点.
这是我的管道的纹理部分:
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, ((MNTexturedRect*)object).texID);
glUniform1i(uniforms[UNIFORM_TEXTURE], GL_TEXTURE0);
glVertexAttribPointer(ATTRIB_TEXTURE_COORDS, 2, GL_FLOAT, GL_FALSE, object.dataPerPoint*sizeof(GLfloat), &points[((MNTexturedRect*)object).texCoordOffset]);
glEnableVertexAttribArray(ATTRIB_TEXTURE_COORDS);
Run Code Online (Sandbox Code Playgroud)
我有一个想法,纹理ID是统一的是导致问题,但不知道如何解决它.我有几个对象,看起来只有第一个纹理加载实际上似乎工作.我只有取样器而且不太确定为什么它会抱怨使用相同的纹理单元,而我的纹理单元在范围内,因为它只是GL_TEXTURE0.
任何有关为什么会发生这种情况的想法?
我不熟悉在图形环境中制作动画的想法,所以我想澄清一下正确的方法是什么.
(只是为了设置场景,虽然它与问题不是特别相关:我在iphone上使用opengl es)
如果我去看一位艺术家,并告诉他们给我创建一个行走矮人的三维模型动画,它不会动态,他们会如何给我数据?它们是否会:a)创建一个3d骨骼模型,在路径列表中为骨骼路径设置动画以及时间戳和插值类型,然后简单地定义每个骨骼的三维模型?即一个行走的矮人将是一个脊椎,手,手臂,腿,脚,脖子,头部,然后建模师为每个骨骼创建部分,并给我动画路径......?
或b)建模者创建一个完整的模型然后使其变形并以某种方式保存变形
!c)我假设没有人会实际存储相同物体的30个模型然后只是呈现那些,除非它是一个非常低的多聚体模型?还是我错了?3d动画的最佳对象格式是什么?
关于技术,机制等的任何其他建议/提示将不胜感激!
有谁知道在Android的OpenGL ES渲染器上是否可以使用NPOT纹理?
我正在开发一个小的OpenGL Activity,它由这个布局组成:
<RelativeLayout
android:id="@+id/vt_layout_opengl"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
>
<android.opengl.GLSurfaceView
android:id="@+id/surface_vt"
android:layout_width="900dp"
android:layout_height="285dp"
/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/surface_vt"
android:layout_marginTop="5dp"
android:background="@drawable/barra_menu_vt"
>
<ImageButton android:id="@+id/vt_left_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:background="@drawable/prev_a"
android:onClick="prec"
/>
<ImageButton android:id="@+id/vt_right_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/next_a"
android:layout_toRightOf="@+id/vt_left_arrow"
android:layout_marginLeft="20dp"
android:onClick="next"
/>
<TextView
android:id="@+id/vt_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/vt_right_arrow"
android:layout_marginLeft="30dp"
android:maxLength="30"
android:singleLine="true"
android:ellipsize="marquee"
/>
<ImageButton android:id="@+id/vt_information"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/vt_addbookmarks"
android:layout_marginRight="20dp"
android:background="@drawable/info_a"
android:onClick="info"
/>
<ImageButton android:id="@+id/vt_addbookmarks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/vt_preferences"
android:layout_marginRight="20dp"
android:background="@drawable/book_a"
android:onClick="bookmark"
/>
<ImageButton android:id="@+id/vt_preferences"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:background="@drawable/sett_a"
android:onClick="settings"
/>
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
它显示了这样的视图:

但当我按下主页按钮并返回我的应用程序时,我只能看到黑屏,GLSurfaceView和RelativeLayout都没有显示! …
我从这个来源 C中有这个代码:
#import <Foundation/Foundation.h>
#import "OpenGLCommon.h"
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableString *result = [NSMutableString string];
static const Vertex3D vertices[]= {
{0, -0.525731, 0.850651}, // vertices[0]
{0.850651, 0, 0.525731}, // vertices[1]
{0.850651, 0, -0.525731}, // vertices[2]
{-0.850651, 0, -0.525731}, // vertices[3]
{-0.850651, 0, 0.525731}, // vertices[4]
{-0.525731, 0.850651, 0}, // vertices[5]
{0.525731, 0.850651, 0}, // vertices[6]
{0.525731, -0.850651, 0}, // vertices[7]
{-0.525731, -0.850651, 0}, // vertices[8]
{0, -0.525731, …Run Code Online (Sandbox Code Playgroud) 您究竟如何拦截Android中OpenGL ES游戏的触摸屏事件?此外,如果游戏是3D,你怎么知道用户是否触摸了背景中的物体?谢谢.
我的程序绘制一个对象,然后进行翻译,旋转和缩放,然后重绘它等等.要设置翻译我会做:
gl.glTranslatef(2,4,666);
Run Code Online (Sandbox Code Playgroud)
然后清除它gl.glTranslatef(-2,-4,-666);
我想知道是否有内置功能这样做?
我有一个没有此扩展程序的平台(非NVIDIA).我怎么能模仿这个功能?我需要它来解决使用z-fail算法渲染模板阴影卷时的远平面剪裁问题.