1 /*------------------------------------------------------------------------- 2 * drawElements Quality Program EGL Module 3 * --------------------------------------- 4 * 5 * Copyright 2014 The Android Open Source Project 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 * 19 *//*! 20 * \file 21 * \brief GLES2 render utils. 22 *//*--------------------------------------------------------------------*/ 23 24 #include "teglGLES2RenderUtil.hpp" 25 26 #if defined(DEQP_SUPPORT_GLES2) || defined(DEQP_SUPPORT_GLES3) 27 # include "gluDefs.hpp" 28 # include "gluPixelTransfer.hpp" 29 # if !defined(DEQP_SUPPORT_GLES2) 30 # include <GLES3/gl3.h> 31 # else 32 # include <GLES2/gl2.h> 33 # endif 34 #endif 35 36 namespace deqp 37 { 38 namespace egl 39 { 40 namespace gles2 41 { 42 43 #if defined(DEQP_SUPPORT_GLES2) || defined(DEQP_SUPPORT_GLES3) 44 45 void clear (int x, int y, int width, int height, const tcu::Vec4& color) 46 { 47 glEnable(GL_SCISSOR_TEST); 48 glScissor(x, y, width, height); 49 glClearColor(color.x(), color.y(), color.z(), color.w()); 50 glClear(GL_COLOR_BUFFER_BIT); 51 glDisable(GL_SCISSOR_TEST); 52 } 53 54 void readPixels (tcu::Surface& dst, int x, int y, int width, int height) 55 { 56 dst.setSize(width, height); 57 glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr()); 58 } 59 60 #else // DEQP_SUPPORT_GLES2 || DEQP_SUPPORT_GLES3 61 62 void clear (int x, int y, int width, int height, const tcu::Vec4& color) 63 { 64 DE_UNREF(x && y && width && height); 65 DE_UNREF(color); 66 throw tcu::NotSupportedError("OpenGL ES 2 is not supported", "", __FILE__, __LINE__); 67 } 68 69 void readPixels (tcu::Surface& dst, int x, int y, int width, int height) 70 { 71 DE_UNREF(x && y && width && height); 72 DE_UNREF(dst); 73 throw tcu::NotSupportedError("OpenGL ES 2 is not supported", "", __FILE__, __LINE__); 74 } 75 76 #endif // DEQP_SUPPORT_GLES2 || DEQP_SUPPORT_GLES3 77 78 } // gles2 79 } // egl 80 } // deqp 81