Display images in open gl es 2.0 on iPhone

So, I just started working on something in Open GL ES 2.0. I get the general impression that the transition from template 1.1 to template 2.0 in Xcode caused some confusion for everyone, so as a result, 2.0 2.0 is not very useful (if there is something really good and informative there, like 71squared video in template 1.1, with the exception of 2.0, your invitation to post a link to it).

My problem displays the image on the screen.

Right now, I have this in my drawFrame method.

[(EAGLView *)self.view setFramebuffer];

// Replace the implementation of this method to do your own custom drawing.
    static float transY = 0.0f;

glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
 [playerCube drawAtPoint:CGPointMake(160.0f, 240.0f)];


if ([context API] == kEAGLRenderingAPIOpenGLES2)
{
    // Use shader program.
    glUseProgram(program);

    // Update uniform value.
    glUniform1f(uniforms[UNIFORM_TRANSLATE], (GLfloat)transY);
    transY += 0.075f; 


    // Validate program before drawing. This is a good check, but only really necessary in a debug build.
    // DEBUG macro must be defined in your debug configurations if that not already the case.

    if (![self validateProgram:program])
    {
        NSLog(@"Failed to validate program: %d", program);
        return;
    }
}
else
{
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0.0f, (GLfloat)(sinf(transY)/2.0f), 0.0f);
    transY += 0.075f;
 }

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);



[(EAGLView *)self.view presentFramebuffer];

, . , ViewController.m. . . Texture2D Apple, , , .

playerCube = [[Texture2D alloc] initWithImage:[UIImage imageNamed:@"Cubix.png"]];, , , , , [playerCube drawAtPoint:CGPointMake(160.0f, 240.0f)];.

, , ? , . , - image.frame = CGRectMake (); Texture 2D? , , ?

, - . StackOverflow .

+3
2

, OpenGL ES 2.0 iPhone , , , PVR . .

, , , OpenGL ES 2.0, iOS iTunes U. , OpenGL ES 2.0.

, , , :

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, myTexture);
glUniform1i(myTextureUniform, 0);   

:

uniform sampler2D myTexture;

:

gl_FragColor = texture2D(myTexture, textureCoordinate);

, , .

+2

Texture2D, Crash Landing, ES 2.x. , drawAtPoint: drawInRect: . GL glVertexPointer glTexCoordPointer; ES 2.x. , ES 1.x , ( glVertexPointer), ( glTexCoordPointer) , . ES 2.x , , , .. , , , , , .

, . , - , .

ES 2.x . , . , GL, Gouraud, .

, , , ES 2.x . - , . , 2d, .

, :

  • Texture2D, , , .
  • , GL, , .
  • , - , .

ES 1.x, , ES 2.x , , lighthouse3d GLSL - OpenGL 2.0. GL 2.0 , GLSL . ES 2.x. , , .. , ES 2.x.

+2

Source: https://habr.com/ru/post/1776948/


All Articles