作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
当我运行我的 OpenGL 应用程序时,出现以下错误:
我用谷歌搜索但无法获得任何有用的信息。
这是一段源代码:
- (void)render:(CADisplayLink*)displayLink {
[self.canvas clear];
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
NSInteger mLength = mParticles.count;
NSInteger drawCount = 0;
NSInteger drawIndex = 0;
WQParticle* drawParticle;
CGFloat drawX,drawY,drawScale,drawAngle;
GLKMatrix4 changeColorMatrix;
if (mLength > 0){
glBindFramebuffer(GL_FRAMEBUFFER, FBO);
glViewport(0,0,width,height);
drawCount = 0;
drawIndex = -1;
while ( drawCount < mLength){
drawParticle = mParticles[drawCount];
if(!(drawParticle.flg && random > 0.5)){
if (drawIndex != drawParticle.texIndex) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, (GLuint)(texture[drawParticle.texIndex]));
glUniform1i((GLint)uniLocation[1], 0);
drawIndex = drawParticle.texIndex;
}
if(drawParticle.flg){
drawX = drawParticle.posX + (random * 1 - 0.5) * drawParticle.scale * 0.06;
drawY = drawParticle.posY + (random * 1 - 0.5) * drawParticle.scale * 0.06;
drawScale = drawParticle.scale * (random * 0.4 + 0.8);
changeColorMatrix = [self setChangeColorWithDp:drawParticle n:random];
drawX = drawX / drawScale;
drawY = drawY / drawScale;
}else{
drawX = drawParticle.posX / drawParticle.scale;
drawY = drawParticle.posY / drawParticle.scale;
drawScale = drawParticle.scale;
changeColorMatrix = [self setChangeColorWithDp:drawParticle n:1];
}
glUniformMatrix4fv((GLint)uniLocation[2], 1, 0, changeColorMatrix.m);
drawAngle = drawParticle.angle;
CGFloat drawR = sqrt(drawX * drawX + drawY * drawY);
CGFloat oa = 2 * M_PI - acos(drawX / drawR);
drawX = cos(oa - drawAngle) * drawR;
drawY = sin(oa - drawAngle) * drawR;
mMatrix = GLKMatrix4Identity;
mMatrix = GLKMatrix4Rotate(mMatrix, drawAngle, 0, 0, 1);
mMatrix = GLKMatrix4Scale(mMatrix, drawScale, drawScale, drawScale);
mMatrix = GLKMatrix4Translate(mMatrix, drawX, drawY, 0);
mvpMatrix = GLKMatrix4Multiply(f_tmpMatrix, mMatrix);
glUniform1i((GLint)uniLocation[3], YES);
glUniformMatrix4fv((GLint)uniLocation[0], 1, 0, mvpMatrix.m);
glDrawElements(GL_TRIANGLES, sizeof(indices), GL_UNSIGNED_BYTE, 0);
}
if (drawParticle.life > 0) {
[mVF getForceFromPosWithPx:drawParticle.posX Py:drawParticle.posY];
[drawParticle setVFupdateWithOutX:mVF.outX OutY:mVF.outY];
drawCount++;
continue;
}
[mParticles removeObjectAtIndex:drawCount];
mLength = mLength - 1;
}
glBindFramebuffer(GL_FRAMEBUFFER,0);
}
glBindTexture(GL_TEXTURE_2D, FBOTexture);
mMatrix = GLKMatrix4Identity;
mvpMatrix = GLKMatrix4Multiply(tmpMatrix, mMatrix);
glUniformMatrix4fv((GLint)uniLocation[0], 1, 0, mvpMatrix.m);
glUniform1i((GLint)uniLocation[3], NO);
glDrawElements(GL_TRIANGLES, sizeof(indices), GL_UNSIGNED_BYTE, 0);
[self.canvas.glContext presentRenderbuffer:GL_RENDERBUFFER];
}
我该如何解决这个问题?
最佳答案
检查 glViewport() 是否设置了您要渲染到的 renderpass 的大小,以及 glScissor() 是否也设置为该大小,或者通过 glDisable() 禁用了 scissor 测试。
关于ios - 存在未初始化的颜色附件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32746960/
我有 json 数据: { "products": [ { "productId" : 0, "productImg" : "../img/product-ph
我是一名优秀的程序员,十分优秀!