Note that there are some explanatory texts on larger screens.

plurals
  1. POopenGL ES how to get perspective view?
    primarykey
    data
    text
    <p>I'm trying to draw a simple cube, rotated 45 deg about y-axis. My drawing code looks like this:</p> <pre><code>- (void) Draw: { // Set the viewport //glFrustumf( -1.0, 1.0, -1.0/(backingWidth/backingHeight), 1.0/(backingWidth/backingHeight), 0.01, 10.0 ); glViewport ( 0, 0, backingWidth, backingHeight ); // Clear the color buffer glClear ( GL_COLOR_BUFFER_BIT ); if( [context API] == kEAGLRenderingAPIOpenGLES2 ) [self DrawES2]; else [self DrawES1]; glDrawElements(GL_TRIANGLES, sizeof(indices)/sizeof(GLubyte), GL_UNSIGNED_BYTE, indices); } - (void) DrawES2 { // Use the program object glUseProgram ( programObject ); // Load the vertex data glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, vVertices ); glEnableVertexAttribArray ( 0 ); // Load transformation matrix GLint mvpLoc = glGetUniformLocation( programObject, "u_mvpMatrix" ); glUniformMatrix4fv( mvpLoc, 1, GL_FALSE, yRotation ); } - (void) DrawES1 { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef( 45, 0, 1, 0 ); glVertexPointer(3, GL_FLOAT, 0, vVertices); glEnableClientState(GL_VERTEX_ARRAY); glColor4f(1.0, 0.0, 0.0, 1.0); } </code></pre> <p>What I get is something like this: <a href="http://img828.imageshack.us/img828/5319/wrongl.png" rel="nofollow">enter link description here</a></p> <p>What I want is something like this: <a href="http://img141.imageshack.us/img141/577/rightc.png" rel="nofollow">enter link description here</a></p> <p>When I uncomment the glFrustum line I get no change in ES1 version and app crashes in ES2 version. I'm new to OpenGL so I guess I could be doing something really wrong, but how do I get a perspective view so that the cube looks right?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload