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#include "absl/log/log.h"
26
30
31namespace gfxstream {
32
33#define CHECK_GL_ERROR() \
34 do { \
35 if (GLenum error = gles->glGetError(); error != GL_NO_ERROR) { \
36 LOG(ERROR) << __FILE__ << ":" << __LINE__ << ":" << __PRETTY_FUNCTION__ \
37 << " found error: " << error; \
38 } \
39 } while (0);
40
41class Gles {
42 public:
45
46 Gles(const Gles&) = delete;
47 Gles& operator=(const Gles&) = delete;
48
49 Gles(Gles&&) = default;
50 Gles& operator=(Gles&&) = default;
51
52 std::optional<GLuint> CreateShader(GLenum shader_type,
53 const std::string& shader_source);
54
55 std::optional<GLuint> CreateProgram(const std::string& vert_shader_source,
56 const std::string& frag_shader_source);
57
58#define DECLARE_GLES_FUNCTION_MEMBER_POINTER(return_type, function_name, \
59 signature, args) \
60 return_type(*function_name) signature = nullptr;
61
63
64 private:
65 Gles() = default;
66
67 void Init();
68
70};
71
72} // namespace gfxstream
Definition: egl.h:30
Definition: gles.h:41
Lib lib_
Definition: gles.h:69
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:58
Definition: egl.cpp:21