Line data Source code
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/. */
5 :
6 : #include "WebGLVertexArrayGL.h"
7 :
8 : #include "GLContext.h"
9 : #include "WebGLContext.h"
10 :
11 : namespace mozilla {
12 :
13 0 : WebGLVertexArrayGL::WebGLVertexArrayGL(WebGLContext* webgl)
14 : : WebGLVertexArray(webgl)
15 0 : , mIsVAO(false)
16 0 : { }
17 :
18 0 : WebGLVertexArrayGL::~WebGLVertexArrayGL()
19 : {
20 0 : DeleteOnce();
21 0 : }
22 :
23 : void
24 0 : WebGLVertexArrayGL::DeleteImpl()
25 : {
26 0 : mElementArrayBuffer = nullptr;
27 :
28 0 : mContext->MakeContextCurrent();
29 0 : mContext->gl->fDeleteVertexArrays(1, &mGLName);
30 :
31 0 : mIsVAO = false;
32 0 : }
33 :
34 : void
35 0 : WebGLVertexArrayGL::BindVertexArrayImpl()
36 : {
37 0 : mContext->mBoundVertexArray = this;
38 0 : mContext->gl->fBindVertexArray(mGLName);
39 :
40 0 : mIsVAO = true;
41 0 : }
42 :
43 : void
44 0 : WebGLVertexArrayGL::GenVertexArray()
45 : {
46 0 : mContext->gl->fGenVertexArrays(1, &mGLName);
47 0 : }
48 :
49 : bool
50 0 : WebGLVertexArrayGL::IsVertexArrayImpl() const
51 : {
52 0 : gl::GLContext* gl = mContext->gl;
53 0 : if (gl->WorkAroundDriverBugs())
54 : {
55 0 : return mIsVAO;
56 : }
57 :
58 0 : mContext->MakeContextCurrent();
59 0 : return mContext->gl->fIsVertexArray(mGLName) != 0;
60 : }
61 :
62 : } // namespace mozilla
|