## 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;        } } */ 

}

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

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 !

## Unity: How can I find the center position of a particular triangle?

I need to face an object from a central point directly through any one of many triangles which are faces on an icosphere whose position is centered on that point. Is there a way to get the center position of the triangle itself, even though its position is the position of the larger object of which it is a part?

## Drawing two altitudes of a triangle

I am trying to construct a triangle with 2 altitudes. It worked for ‘All’ vertices.

a = {5, 0}; b = {0, 0}; c = {3, 6}; tri = {a, b, c}; alt = TriangleConstruct[tri, {"Altitude", All}]; Graphics[{Style[Triangle[tri], Opacity[0.2]], alt}] 

But when I tried to specify two vertices,

alt = TriangleConstruct[tri, {"Altitude", {a, b}}]

The following message came out:

TriangleConstruct is not a Graphics primitive or directive.

How do I specify two vertices to draw the altitudes?

## How to calculate consistent signed Normal of Triangle?

I am currently calculating normals for 3 point coplanar triangles like P1, P2, P3

$$N = (P1 – P2) \times (P2 – P3)$$

This equation will give me different negative or positive Normal depending on the order of the points.

  const N = getNormalForTriPoints(p1,p2,p3); //1   const N = getNormalForTriPoints(p2,p1,p3); // -1 

I am using this function in a collision detection algorithm and feeding it a set of world space triangles. The normal calculation is causing unexpected results like falling through objects because the normals are reversed. If I can’t calculate a normal reliably what alternatives do I have to handle this? How do I know what order to feed in the triangles? Or what methods are available to sort the triangles?

## Calculate number of triangle that can be formed by joining special nodes in a tree

Problem source : CHGORAM2 Problem : A tree is given to us and it’s nodes are marked as 1 or 0 . We need to calculate how many triplets (x,y,z) can be formed such that node x,y,z are marked as 1 and distance(x,y) = distance(y,z) = distance(z,x) .Here distance(x,y) denotes distance between node x and y.Also x,y,z need to be distinct.

I am only able to solve it using brute force . But Editorial mentions some O(n) solution which i did not understood.

## triangle inequality TSP is NP-complete?

I have been reading online source and it mentioned triangle inequality TSP is NP-complete but without proof. In general, the reduction from HAM-cycle problem to TSP works for asymmetric and symmetric TSP problem. So, I wonder how to start a basic approach to prove triangle inequality TSP is NP-complete.

## Counter example to Zooko’s triangle? [on hold]

So Zokoo’s triangle is a conjecture that is often explained by this trilemma:

Names:

-secure

-distributed

-human-meaningful

pick two

But what if we hash the public key of an user and turn it into a meaningful identifier?

For example, we can use the hash as an input to get an unique profile picture with Gravatar (the default profile picture generator of Stack Exchange). We can also pass the hash as a seed to a neural network that generates profile pictures with people, animals, landscapes, etc.

But that’s not good, we can’t fetch an user identified by their profile picture, so we have to create meaningful character strings. I call it the “exquisite corpse” method: Let’s say the hash contains 6 alphanumerical characters, we can divide it into 3 parts of 2 characters each. The first part identifies an adverb in a dictionary of 3844 words ((26*2+10)²), the second part identifies an adjective is a dictionary of 3844 words and the third part a noun in a dictionary of 3844 words. This way, we obtain usernames like Extremely Metaphorical Chicken.

Maybe you would say that relying on a common arbitrary dictionary of words makes it not distributed, but in this case the arbitrary choice of the hash function would also make it not distributed. The ‘distributed’ criterion means that every peer on the network can do name resolve by themselves, not that we can’t rely on a common standard. Every peer can download the dictionary and/or the Gravatar generator (although I concede installing a whole neural network would be too much).

Is it a proper counter-example to Zooko’s triangle or I am mistaken? If so, should we change “human-meaningful” to “human-choosable”?

## to do a triangle [on hold]

this is my code

class Pattern {     public static void main (String [] args)         {         int STAR = "*";         int SPACE = " ";         int HEIGHT = 5;          {              Display();              console.ReadLine();              {               static public void  Display()                  {                      for (int i = 0; i < HEIGHT; i++)                      {                          for (int j = 0; j < i; j++)                          console.write(SPACE);                           for (int j = 0; j < HEIGHT; j++)                          console.Write(STAR);                          console.WriteLine();                      }                  }              }          }     } } 

my errors are this

Pattern.java:12: error: illegal start of expression static public void Display()

Pattern.java:25: error: class, interface, or enum expected }

## Triangle solutions by projection on plane!

I have a little question. how many solutions has a triangle by the projection on the plane? Like the Patenoth problem but in 3d space.

## Find a length in an equilateral triangle [on hold]

I have an equilateral triangle ABC. There is a point D in the triangle. And AD=3, BD=4 and I want to find the length of CD. I tried law of cosines that didn’t help me and I tried to find area for those 3 little triangles. No result. Do you have any suggestions? I’ll appreciate it