WebGL2ContextTransformFeedback.cpp (2792B)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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 "GLContext.h" 7 #include "WebGL2Context.h" 8 #include "WebGLProgram.h" 9 #include "WebGLTransformFeedback.h" 10 11 namespace mozilla { 12 13 // ------------------------------------------------------------------------- 14 // Transform Feedback 15 16 RefPtr<WebGLTransformFeedback> WebGL2Context::CreateTransformFeedback() { 17 const FuncScope funcScope(*this, "createTransformFeedback"); 18 if (IsContextLost()) return nullptr; 19 20 GLuint tf = 0; 21 gl->fGenTransformFeedbacks(1, &tf); 22 23 return new WebGLTransformFeedback(this, tf); 24 } 25 26 void WebGL2Context::BindTransformFeedback(WebGLTransformFeedback* tf) { 27 FuncScope funcScope(*this, "bindTransformFeedback"); 28 if (IsContextLost()) return; 29 funcScope.mBindFailureGuard = true; 30 31 if (tf && !ValidateObject("tf", *tf)) return; 32 33 if (mBoundTransformFeedback->mIsActive && 34 !mBoundTransformFeedback->mIsPaused) { 35 ErrorInvalidOperation( 36 "Currently bound transform feedback is active and not" 37 " paused."); 38 return; 39 } 40 41 //// 42 43 mBoundTransformFeedback = (tf ? tf : mDefaultTransformFeedback.get()); 44 45 gl->fBindTransformFeedback(LOCAL_GL_TRANSFORM_FEEDBACK, 46 mBoundTransformFeedback->mGLName); 47 48 if (mBoundTransformFeedback) { 49 mBoundTransformFeedback->mHasBeenBound = true; 50 } 51 52 funcScope.mBindFailureGuard = false; 53 } 54 55 void WebGL2Context::BeginTransformFeedback(GLenum primMode) { 56 const FuncScope funcScope(*this, "beginTransformFeedback"); 57 if (IsContextLost()) return; 58 59 mBoundTransformFeedback->BeginTransformFeedback(primMode); 60 } 61 62 void WebGL2Context::EndTransformFeedback() { 63 const FuncScope funcScope(*this, "endTransformFeedback"); 64 if (IsContextLost()) return; 65 66 mBoundTransformFeedback->EndTransformFeedback(); 67 } 68 69 void WebGL2Context::PauseTransformFeedback() { 70 const FuncScope funcScope(*this, "pauseTransformFeedback"); 71 if (IsContextLost()) return; 72 73 mBoundTransformFeedback->PauseTransformFeedback(); 74 } 75 76 void WebGL2Context::ResumeTransformFeedback() { 77 const FuncScope funcScope(*this, "resumeTransformFeedback"); 78 if (IsContextLost()) return; 79 80 mBoundTransformFeedback->ResumeTransformFeedback(); 81 } 82 83 void WebGL2Context::TransformFeedbackVaryings( 84 WebGLProgram& program, const std::vector<std::string>& varyings, 85 GLenum bufferMode) const { 86 const FuncScope funcScope(*this, "transformFeedbackVaryings"); 87 if (IsContextLost()) return; 88 89 if (!ValidateObject("program", program)) return; 90 91 program.TransformFeedbackVaryings(varyings, bufferMode); 92 } 93 94 } // namespace mozilla