Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid NDK Native Activity OpenGL ES 1.1 triangle won't show up
    primarykey
    data
    text
    <p>I'm new to Android NDK and Native Activity, I liked to create a triangle in the middle of the screen but no matter how I tried I wouldn't show up!</p> <p>Here is my initialize method: </p> <pre><code>void Engine::initialize() { LOGI("Engine::initialize fired!"); const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_NONE }; EGLint w, h, dummy, format; EGLint numConfigs; EGLConfig config; EGLSurface surface; EGLContext context; EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(display, 0, 0); eglChooseConfig(display, attribs, &amp;config, 1, &amp;numConfigs); eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &amp;format); ANativeWindow_setBuffersGeometry(this-&gt;app-&gt;window, 0, 0, format); surface = eglCreateWindowSurface(display, config, this-&gt;app-&gt;window, NULL); context = eglCreateContext(display, config, NULL, NULL); if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) { LOGW("Unable to eglMakeCurrent"); return; } eglQuerySurface(display, surface, EGL_WIDTH, &amp;w); eglQuerySurface(display, surface, EGL_HEIGHT, &amp;h); this-&gt;display = display; this-&gt;context = context; this-&gt;surface = surface; this-&gt;width = w; this-&gt;height = h; // Initialize GL state. glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); glEnable(GL_CULL_FACE); glShadeModel(GL_SMOOTH); glDisable(GL_DEPTH_TEST); this-&gt;animating = true; } </code></pre> <p>And here is my render method:</p> <pre><code> void Engine::onRender() { glClearColor(0.7, 0.1, 0.5, 1); glClear(GL_COLOR_BUFFER_BIT); glViewport(0, 0, this-&gt;width, this-&gt;height); //glMatrixMode(GL_PROJECTION); //glLoadIdentity(); //glFrustumf(-this-&gt;width / 2, this-&gt;width / 2, -this-&gt;height / 2, this-&gt;height / 2, 1, 3); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, 0); GLfloat triangle[] = { 0, 0, 0, 0, 100, 0, 100, -100, 0 }; glPushMatrix(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glTranslatef(0, 0, 0); glColor4f(1.0f, 0.3f, 0.0f, .5f); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, triangle); glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); glDisableClientState(GL_VERTEX_ARRAY); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -10); eglSwapBuffers(this-&gt;display, this-&gt;surface); } </code></pre> <p>Anyone can help?</p> <p>All I can see the pink/purple background but know any other pixel :| No errors in console.</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.
 

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