diff --git a/Demos3/GpuDemos/premake4.lua b/Demos3/GpuDemos/premake4.lua index 5d3076077..406ed119a 100644 --- a/Demos3/GpuDemos/premake4.lua +++ b/Demos3/GpuDemos/premake4.lua @@ -56,6 +56,8 @@ function createProject(vendor) "../../btgui/OpenGLWindow/LoadShader.h", "../../btgui/OpenGLWindow/TwFonts.cpp", "../../btgui/OpenGLWindow/TwFonts.h", + "../../btgui/OpenGLWindow/GLRenderToTexture.cpp", + "../../btgui/OpenGLWindow/GLRenderToTexture.h", "../../btgui/OpenGLTrueTypeFont/fontstash.cpp", "../../btgui/OpenGLTrueTypeFont/fontstash.h", "../../btgui/OpenGLTrueTypeFont/opengl_fontstashcallbacks.cpp", diff --git a/btgui/OpenGLTrueTypeFont/main.cpp b/btgui/OpenGLTrueTypeFont/main.cpp index 84a8a369f..1dca192ae 100644 --- a/btgui/OpenGLTrueTypeFont/main.cpp +++ b/btgui/OpenGLTrueTypeFont/main.cpp @@ -32,7 +32,7 @@ subject to the following restrictions: #include "opengl_fontstashcallbacks.h" -#include "Bullet3Common/b3Quickprof.h" +//#include "Bullet3Common/b3Quickprof.h" #include "Bullet3Common/b3Quaternion.h" #include "Bullet3Common/b3CommandLineArgs.h" #include "../OpenGLWindow/LoadShader.h" @@ -471,7 +471,6 @@ int main(int argc, char* argv[]) while (!window->requestedExit()) { - b3ProfileManager::Reset(); GLint err = glGetError(); b3Assert(err==GL_NO_ERROR); @@ -633,11 +632,9 @@ int main(int argc, char* argv[]) b3Assert(err==GL_NO_ERROR); { - B3_PROFILE("glFinish"); glFinish(); } - b3ProfileManager::Increment_Frame_Counter(); static bool printStats = true; diff --git a/btgui/OpenGLTrueTypeFont/premake4.lua b/btgui/OpenGLTrueTypeFont/premake4.lua index c941569c4..76dc31007 100644 --- a/btgui/OpenGLTrueTypeFont/premake4.lua +++ b/btgui/OpenGLTrueTypeFont/premake4.lua @@ -24,6 +24,7 @@ "../OpenGLWindow/LoadShader.cpp", "../OpenGLWindow/LoadShader.h", "../../src/Bullet3Common/b3AlignedAllocator.cpp", + "../../src/Bullet3Common/b3Logging.cpp", "../Timing/b3Quickprof.cpp", "../Timing/b3Quickprof.h" , "../Timing/b3Clock.cpp", diff --git a/btgui/OpenGLWindow/GLRenderToTexture.cpp b/btgui/OpenGLWindow/GLRenderToTexture.cpp new file mode 100644 index 000000000..f7c2652af --- /dev/null +++ b/btgui/OpenGLWindow/GLRenderToTexture.cpp @@ -0,0 +1,78 @@ + +///See http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-14-render-to-texture/ + +#include "GLRenderToTexture.h" + +GLRenderToTexture::GLRenderToTexture() +:m_framebufferName(0) +{ +} + +void GLRenderToTexture::init(int width, int height) +{ + glGenFramebuffers(1, &m_framebufferName); + glBindFramebuffer(GL_FRAMEBUFFER, m_framebufferName); + + GLuint m_renderedTexture; + glGenTextures(1, &m_renderedTexture); + + // "Bind" the newly created texture : all future texture functions will modify this texture + glBindTexture(GL_TEXTURE_2D, m_renderedTexture); + + // Give an empty image to OpenGL ( the last "0" ) + glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, width, height, 0,GL_RGB, GL_UNSIGNED_BYTE, 0); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + + + // The depth buffer + glGenRenderbuffers(1, &m_depthrenderbuffer); + glBindRenderbuffer(GL_RENDERBUFFER, m_depthrenderbuffer); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthrenderbuffer); + + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_renderedTexture, 0); + +} + +bool GLRenderToTexture::enable() +{ + bool status = false; + + // Set the list of draw buffers. + GLenum drawBuffers[2] = {GL_COLOR_ATTACHMENT0,0}; + glDrawBuffers(1, drawBuffers); + + // Always check that our framebuffer is ok + if(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) + { + status = true; + } + + return status; + +} + +void GLRenderToTexture::disable() +{ + glBindFramebuffer( GL_FRAMEBUFFER, 0 ); + glBindTexture(GL_TEXTURE_2D, 0); +} + +GLRenderToTexture::~GLRenderToTexture() +{ + glBindFramebuffer( GL_FRAMEBUFFER, 0 ); + + if (m_depthrenderbuffer) + glDeleteRenderbuffers(1,&m_depthrenderbuffer); + + if(m_renderedTexture) + glDeleteTextures(1, &m_renderedTexture); + + if( m_framebufferName) + { + glDeleteFramebuffers(1, &m_framebufferName); + } +} + diff --git a/btgui/OpenGLWindow/GLRenderToTexture.h b/btgui/OpenGLWindow/GLRenderToTexture.h new file mode 100644 index 000000000..adc31a5f7 --- /dev/null +++ b/btgui/OpenGLWindow/GLRenderToTexture.h @@ -0,0 +1,28 @@ + +#ifndef GL_RENDER_TO_TEXTURE_H +#define GL_RENDER_TO_TEXTURE_H + +///See http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-14-render-to-texture/ +#include "OpenGLInclude.h" + +struct GLRenderToTexture +{ + GLuint m_framebufferName; + GLuint m_renderedTexture; + GLuint m_depthrenderbuffer; + bool m_initialized; +public: + + GLRenderToTexture(); + + void init(int width, int height); + bool enable(); + void disable(); + + virtual ~GLRenderToTexture(); + +}; + + +#endif //GL_RENDER_TO_TEXTURE_H + diff --git a/build3/premake4.lua b/build3/premake4.lua index 2fa0b8666..73a9d628a 100644 --- a/build3/premake4.lua +++ b/build3/premake4.lua @@ -130,7 +130,7 @@ -- include "../demo/gpu_initialize" -- include "../opencl/lds_bank_conflict" -- include "../opencl/reduce" --- include "../btgui/OpenGLTrueTypeFont" + include "../btgui/OpenGLTrueTypeFont" -- include "../btgui/OpenGLWindow" -- include "../demo/ObjLoader" diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3Generic6DofConstraint.h b/src/Bullet3Dynamics/ConstraintSolver/b3Generic6DofConstraint.h index dffd76e5d..1c95d52c0 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3Generic6DofConstraint.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3Generic6DofConstraint.h @@ -137,19 +137,19 @@ public: b3Vector3 m_accumulatedImpulse; //! Linear_Limit_parameters //!@{ - b3Scalar m_limitSoftness;//!< Softness for linear limit - b3Scalar m_damping;//!< Damping for linear limit - b3Scalar m_restitution;//! Bounce parameter for linear limit b3Vector3 m_normalCFM;//!< Constraint force mixing factor b3Vector3 m_stopERP;//!< Error tolerance factor when joint is at limit b3Vector3 m_stopCFM;//!< Constraint force mixing factor when joint is at limit - //!@} - bool m_enableMotor[3]; b3Vector3 m_targetVelocity;//!< target motor velocity b3Vector3 m_maxMotorForce;//!< max force on motor b3Vector3 m_currentLimitError;//! How much is violated this limit b3Vector3 m_currentLinearDiff;//! Current relative offset of constraint frames - int m_currentLimit[3];//!< 0=free, 1=at lower limit, 2=at upper limit + b3Scalar m_limitSoftness;//!< Softness for linear limit + b3Scalar m_damping;//!< Damping for linear limit + b3Scalar m_restitution;//! Bounce parameter for linear limit + //!@} + bool m_enableMotor[3]; + int m_currentLimit[3];//!< 0=free, 1=at lower limit, 2=at upper limit b3TranslationalLimitMotor() { @@ -280,8 +280,8 @@ protected: //! Jacobians //!@{ - b3JacobianEntry m_jacLinear[3];//!< 3 orthogonal linear constraints - b3JacobianEntry m_jacAng[3];//!< 3 orthogonal angular constraints +// b3JacobianEntry m_jacLinear[3];//!< 3 orthogonal linear constraints +// b3JacobianEntry m_jacAng[3];//!< 3 orthogonal angular constraints //!@} //! Linear_Limit_parameters