1
질감이있는 큐브가 있습니다. 데이터 배열을 VBO (glGen 등)로 변경했을 때 내 큐브가 회색 color.But로 렌더링되지만 glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, 0, myBuf);
과 같은 것을 사용하면 모두 괜찮습니다. 무슨 일 이니? 도와주세요.왜 텍스처가 적용되지 않습니까?
- (void)render:(CADisplayLink*)displayLink {
glClearColor(0.0f, 1.0f,0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
CC3GLMatrix *projection = [CC3GLMatrix matrix];
float h = 4.0f * self.frame.size.height/self.frame.size.width;
[projection populateFromFrustumLeft:-2 andRight:2 andBottom:-h/2 andTop:h/2 andNear:2 andFar:4];
glUniformMatrix4fv(_projectionUniform, 1, 0, projection.glMatrix);
CC3GLMatrix *modelView = [CC3GLMatrix matrix];
[modelView populateFromTranslation:CC3VectorMake(sin(CACurrentMediaTime()), 0, -2)];
_currentRotation += displayLink.duration * 90;
[modelView rotateBy:CC3VectorMake(_currentRotation, _currentRotation, -1)];
glUniformMatrix4fv(_modelViewUniform, 1, 0, modelView.glMatrix);
// 1
glViewport(0, 0, self.frame.size.width, self.frame.size.height);
// 2
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture[0].texID);
glUniform1i(uniformTexture, 0);
glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(_positionSlot);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cubeIndexes);
glVertexAttribPointer(ATTRIB_TEXCOORD, 2, GL_FLOAT, 0, 0, texCoord);
glEnableVertexAttribArray(ATTRIB_TEXCOORD);
glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, (void*)0);
//glBindTexture(GL_TEXTURE_2D, 0);
glBindBuffer(GL_ARRAY_BUFFER,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
[_context presentRenderbuffer:GL_RENDERBUFFER];
}
오류 : 선언되지 않은 식별자 'GL_VERTEX_ARRAY'사용 [3] – SevenDays