Use GLTexture in TextureTest for RAII goodness.

Change-Id: I2a9fd5ddeacb9f7947a8090748b2e1cbbabb4fe6
Bug: angleproject:7266
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3623862
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/TextureTest.cpp b/src/tests/gl_tests/TextureTest.cpp
index aae3d31..d84f2c4 100644
--- a/src/tests/gl_tests/TextureTest.cpp
+++ b/src/tests/gl_tests/TextureTest.cpp
@@ -299,9 +299,7 @@
             GL_RGBA,
         };
 
-        GLuint textures[2];
-
-        glGenTextures(2, textures);
+        GLTexture textures[2];
 
         GLfloat *imageData         = sourceImageData[sourceImageChannels - 1];
         GLenum sourceImageFormat   = imageFormats[sourceImageChannels - 1];
@@ -368,7 +366,6 @@
         }
 
         glDeleteFramebuffers(1, &fbo);
-        glDeleteTextures(2, textures);
 
         ASSERT_GL_NO_ERROR();
     }
@@ -2168,8 +2165,7 @@
     int width  = getWindowWidth();
     int height = getWindowHeight();
 
-    GLuint tex2D;
-    glGenTextures(1, &tex2D);
+    GLTexture tex2D;
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_2D, tex2D);
 
@@ -2205,7 +2201,6 @@
     glUseProgram(mProgram);
     glUniform1i(mTexture2DUniformLocation, 0);
     drawQuad(mProgram, "position", 0.5f);
-    glDeleteTextures(1, &tex2D);
     EXPECT_GL_NO_ERROR();
     EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255);
 
@@ -2241,8 +2236,7 @@
     const size_t pixelCount  = width * height;
     const int componentCount = 3;
 
-    GLuint tex2D;
-    glGenTextures(1, &tex2D);
+    GLTexture tex2D;
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_2D, tex2D);
 
@@ -2279,7 +2273,6 @@
     glUseProgram(mProgram);
     glUniform1i(mTexture2DUniformLocation, 0);
     drawQuad(mProgram, "position", 0.5f);
-    glDeleteTextures(1, &tex2D);
     glDeleteBuffers(1, &pbo);
     EXPECT_GL_NO_ERROR();
     EXPECT_PIXEL_EQ(3 * width / 4, 3 * height / 4, 0, 0, 0, 255);
@@ -2409,8 +2402,7 @@
     int width  = getWindowWidth();
     int height = getWindowHeight();
 
-    GLuint tex2D;
-    glGenTextures(1, &tex2D);
+    GLTexture tex2D;
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_2D, tex2D);
 
@@ -2453,7 +2445,6 @@
     glUseProgram(mProgram);
     glUniform1i(mTexture2DUniformLocation, 0);
     drawQuad(mProgram, "position", 0.5f);
-    glDeleteTextures(1, &tex2D);
     glDeleteBuffers(1, &pbo);
     EXPECT_GL_NO_ERROR();
     EXPECT_PIXEL_EQ(3 * width / 4, 3 * height / 4, 0, 0, 0, 255);
@@ -2470,8 +2461,7 @@
     int width  = getWindowWidth();
     int height = getWindowHeight();
 
-    GLuint tex2D;
-    glGenTextures(1, &tex2D);
+    GLTexture tex2D;
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_2D, tex2D);
 
@@ -2508,7 +2498,6 @@
     glUseProgram(mProgram);
     glUniform1i(mTexture2DUniformLocation, 0);
     drawQuad(mProgram, "position", 0.5f);
-    glDeleteTextures(1, &tex2D);
     glDeleteBuffers(1, &pbo);
     EXPECT_GL_NO_ERROR();
     EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 255, 255, 255);
@@ -2525,8 +2514,7 @@
     int width  = getWindowWidth();
     int height = getWindowHeight();
 
-    GLuint tex2D;
-    glGenTextures(1, &tex2D);
+    GLTexture tex2D;
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_2D, tex2D);
 
@@ -2563,7 +2551,6 @@
     glUseProgram(mProgram);
     glUniform1i(mTexture2DUniformLocation, 0);
     drawQuad(mProgram, "position", 0.5f);
-    glDeleteTextures(1, &tex2D);
     glDeleteBuffers(1, &pbo);
     EXPECT_GL_NO_ERROR();
     EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255);
@@ -2580,8 +2567,7 @@
     int width  = getWindowWidth();
     int height = getWindowHeight();
 
-    GLuint tex2D;
-    glGenTextures(1, &tex2D);
+    GLTexture tex2D;
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_2D, tex2D);
 
@@ -2618,7 +2604,6 @@
     glUseProgram(mProgram);
     glUniform1i(mTexture2DUniformLocation, 0);
     drawQuad(mProgram, "position", 0.5f);
-    glDeleteTextures(1, &tex2D);
     glDeleteBuffers(1, &pbo);
     EXPECT_GL_NO_ERROR();
     EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255);
@@ -2635,8 +2620,7 @@
     int width  = getWindowWidth();
     int height = getWindowHeight();
 
-    GLuint tex2D;
-    glGenTextures(1, &tex2D);
+    GLTexture tex2D;
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_2D, tex2D);
 
@@ -2672,7 +2656,6 @@
     glUseProgram(mProgram);
     glUniform1i(mTexture2DUniformLocation, 0);
     drawQuad(mProgram, "position", 0.5f);
-    glDeleteTextures(1, &tex2D);
     glDeleteBuffers(1, &pbo);
     EXPECT_GL_NO_ERROR();
     EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255);
@@ -2694,8 +2677,7 @@
     const int rowLength  = getWindowWidth();
     const int bufferSize = rowLength * height;
 
-    GLuint tex2D;
-    glGenTextures(1, &tex2D);
+    GLTexture tex2D;
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_2D, tex2D);
 
@@ -2728,7 +2710,6 @@
     glUseProgram(mProgram);
     glUniform1i(mTexture2DUniformLocation, 0);
     drawQuad(mProgram, "position", 0.5f);
-    glDeleteTextures(1, &tex2D);
     glDeleteBuffers(1, &pbo);
     EXPECT_GL_NO_ERROR();
     EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
@@ -3249,7 +3230,7 @@
 {
     const int npotTexSize = 5;
     const int potTexSize  = 4;  // Should be less than npotTexSize
-    GLuint tex2D;
+    GLTexture tex2D;
 
     if (IsGLExtensionEnabled("GL_OES_texture_npot"))
     {
@@ -3265,7 +3246,6 @@
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
 
     glActiveTexture(GL_TEXTURE0);
-    glGenTextures(1, &tex2D);
     glBindTexture(GL_TEXTURE_2D, tex2D);
 
     const std::vector<GLubyte> pixels(1 * npotTexSize * npotTexSize, 64);
@@ -5811,8 +5791,7 @@
 {
     ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_rgbx_internal_format"));
 
-    GLuint texture2D;
-    glGenTextures(1, &texture2D);
+    GLTexture texture2D;
     glBindTexture(GL_TEXTURE_2D, texture2D);
     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBX8_ANGLE, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
     glActiveTexture(GL_TEXTURE0);
@@ -6215,8 +6194,7 @@
     int width  = getWindowWidth();
     int height = getWindowHeight();
 
-    GLuint tex2D;
-    glGenTextures(1, &tex2D);
+    GLTexture tex2D;
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_2D, tex2D);
 
@@ -6246,7 +6224,6 @@
     std::array<Vector3, 6> quadVertices = ANGLETestBase::GetQuadVertices();
     ppoDrawQuad(quadVertices, "position", 0.5f, 1.0f);
 
-    glDeleteTextures(1, &tex2D);
     EXPECT_GL_NO_ERROR();
     EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255);
 
@@ -8477,8 +8454,7 @@
         ASSERT_GL_NO_ERROR();
 
         // try adding a color buffer.
-        GLuint colorTex = 0;
-        glGenTextures(1, &colorTex);
+        GLTexture colorTex;
         glBindTexture(GL_TEXTURE_2D, colorTex);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);