1

I want to port a little game from OpenGL 2.0 to the more current version 4.6 of OpenGL. In the code a few quads are draw like this:

  glBegin(GL_QUADS);

  glTexCoord2f(0.0f, 0.0f);
  glVertex3f(x, y + (float)height, 0.0f);

  glTexCoord2f(1.0f, 0.0f);
  glVertex3f(x + (float)width, y + (float)height, 0.0f);

  glTexCoord2f(1.0f, 1.0f);
  glVertex3f(x + (float)width, y, 0.0f);

  glTexCoord2f(0.0f, 1.0f);
  glVertex3f(x, y, 0.0f);

  glEnd();

As far as I know this is not possible anymore in OpenGL 4.6. Strangely Googling that topic did not yield any results. Also here on StackOverflow I could not find any examples how to draw a simple quad in OpenGL 4.6.

Can anyone show me how to achieve that (simple?) task in OpenGL 4.6?

Boris
  • 8,551
  • 25
  • 67
  • 120
  • 1
    If you use a compatibility profile [OpenGL Context](https://www.khronos.org/opengl/wiki/OpenGL_Context), then you can still use the deprecated [Legacy OpenGL](https://www.khronos.org/opengl/wiki/Legacy_OpenGL) `glBegin`/`glEnd` sequencis. To explain how "modern" OpenGL works, is to broad for an answer t to a question. I recommend to read a tutorial like [LearnOpenGL](https://learnopengl.com/), from the begin to the end. At least you've to read about [Vertex Specification](https://www.khronos.org/opengl/wiki/Vertex_Specification) and [Shader](https://www.khronos.org/opengl/wiki/Shader). – Rabbid76 Sep 07 '19 at 19:33
  • Google can find you a plenty of tutorials how to draw a quad by drawing two adjacent triangles.(Using TRIANGLE_FAN is the best IMO) Modern OpenGL doesn't support QUAD primitive.In fact,in the old OpenGL QUAD was still rendered as two triangles behind the scene.That's the base geometry GPU works with. – Michael IV Sep 08 '19 at 19:18
  • See [complete GL+GLSL+VAO/VBO C++ example](https://stackoverflow.com/a/31913542/2521214) look for `vao_???` prefixed functions ... – Spektre Sep 09 '19 at 07:44

0 Answers0