- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 OpenGL ES 1.0 创建游戏。我最近将我的平板电脑更新到 android 4.0.3,现在我所有的纹理都显示为黑色。我尝试打开和关闭硬件加速,但似乎没有什么不同。
这是我加载纹理的代码。
public void loadTexture(GL10 gl, Context context, int image, boolean has_alpha) {
m_alpha = has_alpha;
int [] textures = new int[1];
gl.glDeleteTextures(1, textures, 0);
gl.glGenTextures(1, textures, 0);
m_textureid = textures[0];
gl.glBindTexture(GL10.GL_TEXTURE_2D, m_textureid);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT);
Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), image);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
bmp.recycle();
}
这是我渲染它们的代码。
public void render(GL10 gl, float rotation) {
gl.glPushMatrix();
gl.glEnable(GL10.GL_TEXTURE_2D);
// Tell OpenGL where our texture is located.
gl.glBindTexture(GL10.GL_TEXTURE_2D, m_textureid);
// Tell OpenGL to enable the use of UV coordinates.
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
// Telling OpenGL where our UV coordinates are.
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureVB);
if(m_3d) {
// Counter-clockwise winding.
gl.glFrontFace(GL10.GL_CCW);
// Enable face culling.
gl.glEnable(GL10.GL_CULL_FACE);
// What faces to remove with the face culling.
gl.glCullFace(GL10.GL_BACK);
}
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
// Specifies the location and data format of an array of vertex
// coordinates to use when rendering.
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexVB);
// Set flat color
gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
// Smooth color
if (colorVB != null) {
if(m_alpha) {
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
}
// Enable the color array buffer to be used during rendering.
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorVB);
}
gl.glTranslatef(m_a.m_pos.x + m_dist_x, m_a.m_pos.y + m_dist_y, m_a.m_pos.z + m_dist_z);
gl.glRotatef(rotation, 0.0f, 0.0f, 1.0f);
// Point out the where the color buffer is.
gl.glDrawElements(GL10.GL_TRIANGLES, indicies.length,
GL10.GL_UNSIGNED_SHORT, indexVB);
// Disable the vertices buffer.
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
if(m_alpha) {
gl.glDisable(GL10.GL_BLEND);
}
if(m_3d) {
// Disable face culling.
gl.glDisable(GL10.GL_CULL_FACE);
}
// Disable the use of UV coordinates.
gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
// Disable the use of textures.
gl.glDisable(GL10.GL_TEXTURE_2D);
//gl.glPopMatrix();
gl.glPopMatrix();
}
最佳答案
我已经解决了这个问题。我正在使用以下代码加载位图
位图 bmp = BitmapFactory.decodeResource(context.getResources(), image);
我把它换成了
Bitmap bmp = null;
InputStream is = context.getResources().openRawResource(image);
try {
bmp = BitmapFactory.decodeStream(is);
} finally {
try {
is.close();
is = null;
} catch(IOException e) {
}
}
这允许渲染所有大小为 2 的幂的纹理。任何不是 2 次幂大小的纹理都不会渲染。 OpenGL ES 1.0/1.1 似乎无法处理 2 纹理的非幂。我仍然不确定为什么我的平板电脑运行 honeycomb 时能够渲染它们。
编辑:
我找到了一种使用 OpenGL ES 1.0 获得非 2 次方纹理渲染的方法。您必须将以下功能设置为 GL_CLAMP_TO_EDGE
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
关于android - Ice Cream Sandwich 上的 OpenGL 黑色纹理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9474540/
刚读 this article ,这让我很想知道加快谈判阶段的好处。我正在开发一个应用程序,其中我使用的是仅使用 ICE 的第三方实用程序,但最终将在下一个版本中升级为涓流 ICE。升级需要相当多的代
您好,我使用 Zeroc Ice 通信库 (v3.4.2) 编写了一个 C# 客户端/服务器应用程序。 我正在从服务器传输一系列对象,然后以表格格式在客户端中显示它们。很简单。 我定义了以下切片类型
未捕获的 DOMException:构建“RTCPeerConnection”失败:当 URL 方案为“turn”或“turns”时,需要用户名和凭据。 我收到这个错误是因为我使用的是 ice 服务器
我的本地计算机上的 WiX 遇到一些奇怪的问题。该问题是间歇性的,但在对解决方案进行几次重建后,WiX 项目开始抛出 ICE 验证错误。 如果我进入 AppData\Local\Temp 文件夹并
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 5 个月前。 Improve this q
我使用 WiX 3.5 构建了一个安装程序。安装程序使用 VB6 合并模块。我总是从与此类似的灯光中收到很多错误消息: error LGHT0204: ICE03: Table: Class Colu
我正在尝试使用 TFS 将 WiX 集成到我的自动构建解决方案中2010 运行于 Windows Server 2008 R2。一切似乎都很简单,然后我明白了: light.exe: Error ex
我正在遵循 Licode page 上的指南 我已经在 Ubuntu 14.04 上安装了所有内容。 我已经在 licode_config.js 中为 licode 和 erizo Controlle
我正在使用 WebRTC API 在运行在 chrome 浏览器上的两台 PC 之间进行视频通话。我的观察是只有当我连接到互联网时才会生成 ICE 候选者,否则不会生成 ICE 候选者。为什么会这样?
我的树表中有很多命令链接,我动态构建它们,如果我想在单击一个命令链接时更改它的颜色,所有命令链接都会更改它们的颜色,我不知道如何做更改此指定链接的颜色,因为我不知道她的号码或 ID,如果有人知道答案,
假设我有这样的功能(在 Javascript 中): 功能乐趣(success_cb,error_cb){ 变量结果; 尝试 { 结果 = function_that_calculates_resul
不要在 safari 中工作示例 https://github.com/Kurento/kurento-tutorial-node/tree/master/kurento-one2many-call
视频通话在同一网络内工作正常。问题是在其他网络上调用计算机时,远程视频不显示。在 chrome 上,我在控制台中没有收到任何错误,但在 firefox 控制台上,我收到了“ICE Failure”。
我遇到了 ZeroC ICE 字典语法的新手问题。这是我尝试过的方法,但似乎没有任何效果。 /*What I want to make >*/ dictionary> FlightSchedule;
此菜单不适用于任何 IE 版本。我怎样才能让它工作? 我也想添加过渡,有没有办法添加它以便从顶部缓慢打开? http://tinyurl.com/7rxskdj #nmenu {width:700px
我正在开发两个对等点之间的信号系统,并注意到 RTCPeerConnection.onicecandidate 事件没有触发。我检查了 iceGatheringState,它总是返回"new",这意味
我想利用 ICE Faces fileInput 控件根据用户选择的文件为网页上的输入字段输入文件路径和文件名。如何在不实际执行任何文件传输操作的情况下捕获这些属性? 最佳答案 我相信真正的答案是你不
我已经阅读了 RFC 5389 和 RFC 5245 以及更新的 RFC 8445。我了解 STUN 如何返回服务器反身地址或中继地址。请求被发送到 STUN 服务器。 我的基本问题是关于使用 STU
我正在开发一个 iOS 应用程序,使用 WebRTC 与 RTCDataChannel 进行点对点数据通信。当两个设备都在同一个 wifi 网络上时,我已经设法让一切正常工作,但是当我将 1 放在移动
我正在尝试建立 b/w 两个对等点的 p2p 音频/视频连接。以下:Getting started with WebRTC . 它在我家的两台 PC 之间的 LAN 环境中运行良好,但在运行时抛出错误
我是一名优秀的程序员,十分优秀!