Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: remoting/client/gl_helpers.cc

Issue 2045963004: [Remoting] OpenGL Rendering Layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/client/gl_helpers.h ('k') | remoting/client/gl_render_layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/client/gl_helpers.h"
6
7 #include "base/logging.h"
8
9 namespace remoting {
10
11 GLuint CompileShader(GLenum shader_type, const char* shader_source) {
12 GLuint shader = glCreateShader(shader_type);
13
14 if (shader != 0) {
15 int shader_source_length = strlen(shader_source);
16 // Pass in the shader source.
17 glShaderSource(shader, 1, &shader_source, &shader_source_length);
18
19 // Compile the shader.
20 glCompileShader(shader);
21
22 // Get the compilation status.
23 GLint compile_status;
24 glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);
25
26 // If the compilation failed, delete the shader.
27 if (compile_status == GL_FALSE) {
28 LOG(ERROR) << "Error compiling shader: \n" << shader_source;
29 glDeleteShader(shader);
30 shader = 0;
31 }
32 }
33
34 if (shader == 0) {
35 LOG(FATAL) << "Error creating shader.";
36 }
37
38 return shader;
39 }
40
41 GLuint CreateProgram(GLuint vertex_shader, GLuint fragment_shader) {
42 GLuint program = glCreateProgram();
43
44 if (program != 0) {
45 glAttachShader(program, vertex_shader);
46 glAttachShader(program, fragment_shader);
47 glLinkProgram(program);
48
49 // Get the link status.
50 GLint link_status;
51 glGetProgramiv(program, GL_LINK_STATUS, &link_status);
52 // If the link failed, delete the program.
53 if (link_status == GL_FALSE) {
54 LOG(ERROR) << "Error compiling program.";
55 glDeleteProgram(program);
56 program = 0;
57 }
58 }
59
60 if (program == 0) {
61 LOG(FATAL) << "Error creating program.";
62 }
63
64 return program;
65 }
66
67 GLuint CreateTexture() {
68 GLuint texture;
69 glGenTextures(1, &texture);
70 if (texture == 0) {
71 LOG(FATAL) << "Error creating texture.";
72 }
73 return texture;
74 }
75
76 GLuint CreateBuffer(const void* data, int size) {
77 GLuint buffer;
78 glGenBuffers(1, &buffer);
79 glBindBuffer(GL_ARRAY_BUFFER, buffer);
80 glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW);
81 glBindBuffer(GL_ARRAY_BUFFER, 0);
82 return buffer;
83 }
84
85 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/gl_helpers.h ('k') | remoting/client/gl_render_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698