FPLBase
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
debug_markers.h
Go to the documentation of this file.
1 // Copyright 2016 Google Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef FPLBASE_DEBUG_MARKERS_H
16 #define FPLBASE_DEBUG_MARKERS_H
17 
18 /// @file fplbase/debug_markers.h
19 /// @brief Functions for inserting GL debug markers.
20 ///
21 /// To enable, \#define FPLBASE_ENABLE_DEBUG_MARKERS
22 
23 #include "fplbase/config.h" // Must come first.
24 #include "fplbase/glplatform.h"
25 
26 #if defined(PLATFORM_MOBILE) || defined(PLATFORM_OSX)
27 #define FPLBASE_DEBUG_MARKER_NOLENGTH 0
28 #else
29 #define FPLBASE_DEBUG_MARKER_NOLENGTH -1
30 #endif
31 
32 inline void PushDebugMarker(const char *marker,
33  int length = FPLBASE_DEBUG_MARKER_NOLENGTH) {
34  (void)marker;
35  (void)length;
36 #ifdef FPLBASE_ENABLE_DEBUG_MARKERS
37 #if defined(PLATFORM_MOBILE) || defined(PLATFORM_OSX)
38 // TODO(jsanmiya): Get glPushGroupMarker working for all iOS builds
39 // if (glPushGroupMarker) {
40 // GL_CALL(glPushGroupMarker(length, marker));
41 // }
42 #else
43 // if (glPushDebugGroup) {
44 // GL_CALL(glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, length, marker));
45 // }
46 #endif // PLATFORM_MOBILE || PLATFORM_OSX
47 #endif // FPLBASE_ENABLE_DEBUG_MARKERS
48 }
49 
50 inline void PushDebugMarker(const std::string& marker) {
51  (void)marker;
52 #ifdef FPLBASE_ENABLE_DEBUG_MARKERS
53  PushDebugMarker(marker.c_str(), marker.length());
54 #endif
55 }
56 
57 inline void PopDebugMarker() {
58 #ifdef FPLBASE_ENABLE_DEBUG_MARKERS
59 #if defined(PLATFORM_MOBILE) || defined(PLATFORM_OSX)
60 // TODO(jsanmiya): Get glPushGroupMarker working for all iOS builds
61 // if (glPopGroupMarker) {
62 // GL_CALL(glPopGroupMarker());
63 // }
64 #else
65 // if (glPopDebugGroup) {
66 // GL_CALL(glPopDebugGroup());
67 // }
68 #endif // PLATFORM_MOBILE || PLATFORM_OSX
69 #endif // FPLBASE_ENABLE_DEBUG_MARKERS
70 }
71 
72 #endif