Why does the triangle rendered by OpenGL ES 2.0 , with SDL 2.0 context, vanishes after a single render, if events are not polled?

I was experimenting with OpenGL ES 2.0 and being new to OpenGL, I was trying to render a simple triangle. But I was shocked to see that, if I do not call SDL_PollEvent(...) after glDrawArrays(...) in the game loop, I see the triangle render on the screen for a split second and then it vanishes altogether ! But, if I call SDL_PollEvent then everything is fine ! Can anyone explain to me the reason for this abnormal behavior???

However, this is the interesting part of my code:

This code works perfectly, if I uncomment the commented block of code:

uint32_t vbo;  glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);  glEnableVertexAttribArray(pos); glVertexAttribPointer(pos, 3, GL_FLOAT, GL_FALSE, 3*sizeof(float), (void*)0);  bool run = true; SDL_Event e; while (run) {     glDrawArrays(GL_TRIANGLES, 0, 3);   SDL_GL_SwapWindow(window);   /*while(SDL_PollEvent(&e)) {       switch(e.type)       {            case SDL_QUIT:                 run = false;                 break;        } } */ 

}

Vertex Shader:

precision mediump float;  attribute vec3 pos; void main() {     gl_Position = vec4(pos.xyz, 1.0);  } 

Fragment Shader:

precision mediump float;  void main() {       gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);  } 

Every help will be greatly appreciated, Thankyou everyone in advance !