Android-cuttlefish cvd tool
gles.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <optional>
20
21#include "GLES/gl.h"
22#include "GLES2/gl2.h"
23#include "GLES2/gl2ext.h"
24#include "GLES3/gl3.h"
25
29
30namespace gfxstream {
31
32#define CHECK_GL_ERROR() \
33 do { \
34 if (GLenum error = gles->glGetError(); error != GL_NO_ERROR) { \
35 LOG(ERROR) << __FILE__ << ":" << __LINE__ << ":" << __PRETTY_FUNCTION__ \
36 << " found error: " << error; \
37 } \
38 } while (0);
39
40class Gles {
41 public:
44
45 Gles(const Gles&) = delete;
46 Gles& operator=(const Gles&) = delete;
47
48 Gles(Gles&&) = default;
49 Gles& operator=(Gles&&) = default;
50
51 std::optional<GLuint> CreateShader(GLenum shader_type,
52 const std::string& shader_source);
53
54 std::optional<GLuint> CreateProgram(const std::string& vert_shader_source,
55 const std::string& frag_shader_source);
56
57#define DECLARE_GLES_FUNCTION_MEMBER_POINTER(return_type, function_name, \
58 signature, args) \
59 return_type(*function_name) signature = nullptr;
60
62
63 private:
64 Gles() = default;
65
66 void Init();
67
69};
70
71} // namespace gfxstream
Definition: egl.h:30
Definition: gles.h:40
Lib lib_
Definition: gles.h:68
static gfxstream::expected< Gles, std::string > Load()
Definition: gles.cpp:34
Gles & operator=(Gles &&)=default
FOR_EACH_GLES_FUNCTION(DECLARE_GLES_FUNCTION_MEMBER_POINTER)
Gles & operator=(const Gles &)=delete
std::optional< GLuint > CreateShader(GLenum shader_type, const std::string &shader_source)
Definition: gles.cpp:106
std::optional< GLuint > CreateProgram(const std::string &vert_shader_source, const std::string &frag_shader_source)
Definition: gles.cpp:131
Gles(Gles &&)=default
static gfxstream::expected< Gles, std::string > LoadFromEgl(Egl *egl)
Definition: gles.cpp:66
Gles()=default
Gles(const Gles &)=delete
void Init()
Definition: gles.cpp:81
Definition: lib.h:26
Definition: expected.h:33
#define DECLARE_GLES_FUNCTION_MEMBER_POINTER(return_type, function_name, signature, args)
Definition: gles.h:57
Definition: egl.cpp:21