1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef WEBGLBINDABLENAME_H_
7 #define WEBGLBINDABLENAME_H_
9 #include "WebGLTypes.h"
12 #include "mozilla/TypeTraits.h"
13 #include "mozilla/Assertions.h"
17 /** Represents a binding to a GL binding point
23 WebGLBindable() : mTarget(LOCAL_GL_NONE
) { }
24 bool HasEverBeenBound() const { return mTarget
!= LOCAL_GL_NONE
; }
26 void BindTo(T target
) {
27 MOZ_ASSERT(target
!= LOCAL_GL_NONE
, "Can't bind to GL_NONE.");
28 MOZ_ASSERT(!HasEverBeenBound() || mTarget
== target
, "Rebinding is illegal.");
30 bool targetChanged
= (target
!= mTarget
);
37 MOZ_ASSERT(HasEverBeenBound());
42 //! Called after mTarget has been changed by BindTo(target).
43 virtual void OnTargetChanged() {}
49 /** Represents a GL name that can be bound to a target.
52 class WebGLBindableName
53 : public WebGLBindable
<T
>
57 explicit WebGLBindableName(GLuint aName
)
61 GLuint
GLName() const { return mGLName
; }
68 } // namespace mozilla
70 #endif // !WEBGLBINDABLENAME_H_