aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp130
1 files changed, 0 insertions, 130 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f3fdb77..d872106 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -75,28 +75,7 @@ void ThreadSleep( unsigned long nMilliseconds )
usleep( nMilliseconds * 1000 );
}
-class CGLRenderModel
-{
-public:
- CGLRenderModel( const std::string & sRenderModelName );
- ~CGLRenderModel();
-
- bool BInit( const vr::RenderModel_t & vrModel, const vr::RenderModel_TextureMap_t & vrDiffuseTexture );
- void Cleanup();
- void Draw();
- const std::string & GetName() const { return m_sModelName; }
-
-private:
- GLuint m_glVertBuffer;
- GLuint m_glIndexBuffer;
- GLuint m_glVertArray;
- GLuint m_glTexture;
- GLsizei m_unVertexCount;
- std::string m_sModelName;
-};
-
static bool g_bPrintf = true;
-static const float half_pi = 1.5707963267948f;
//-----------------------------------------------------------------------------
// Purpose:
@@ -144,8 +123,6 @@ public:
GLuint CompileGLShader( const char *pchShaderName, const char *pchVertexShader, const char *pchFragmentShader );
bool CreateAllShaders();
- CGLRenderModel *FindOrLoadRenderModel( const char *pchRenderModelName );
-
private:
bool m_bDebugOpenGL;
bool m_bVerbose;
@@ -2086,113 +2063,6 @@ glm::mat4 CMainApplication::ConvertSteamVRMatrixToMatrix4( const vr::HmdMatrix34
return matrixObj;
}
-//-----------------------------------------------------------------------------
-// Purpose: Create/destroy GL Render Models
-//-----------------------------------------------------------------------------
-CGLRenderModel::CGLRenderModel( const std::string & sRenderModelName )
- : m_sModelName( sRenderModelName )
-{
- m_glIndexBuffer = 0;
- m_glVertArray = 0;
- m_glVertBuffer = 0;
- m_glTexture = 0;
-}
-
-
-CGLRenderModel::~CGLRenderModel()
-{
- Cleanup();
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Allocates and populates the GL resources for a render model
-//-----------------------------------------------------------------------------
-bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel, const vr::RenderModel_TextureMap_t & vrDiffuseTexture )
-{
- // create and bind a VAO to hold state for this model
- glGenVertexArrays( 1, &m_glVertArray );
- glBindVertexArray( m_glVertArray );
-
- // Populate a vertex buffer
- glGenBuffers( 1, &m_glVertBuffer );
- glBindBuffer( GL_ARRAY_BUFFER, m_glVertBuffer );
- glBufferData( GL_ARRAY_BUFFER, sizeof( vr::RenderModel_Vertex_t ) * vrModel.unVertexCount, vrModel.rVertexData, GL_STATIC_DRAW );
-
- // Identify the components in the vertex buffer
- glEnableVertexAttribArray( 0 );
- glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, sizeof( vr::RenderModel_Vertex_t ), (void *)offsetof( vr::RenderModel_Vertex_t, vPosition ) );
- glEnableVertexAttribArray( 1 );
- glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, sizeof( vr::RenderModel_Vertex_t ), (void *)offsetof( vr::RenderModel_Vertex_t, vNormal ) );
- glEnableVertexAttribArray( 2 );
- glVertexAttribPointer( 2, 2, GL_FLOAT, GL_FALSE, sizeof( vr::RenderModel_Vertex_t ), (void *)offsetof( vr::RenderModel_Vertex_t, rfTextureCoord ) );
-
- // Create and populate the index buffer
- glGenBuffers( 1, &m_glIndexBuffer );
- glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_glIndexBuffer );
- glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof( uint16_t ) * vrModel.unTriangleCount * 3, vrModel.rIndexData, GL_STATIC_DRAW );
-
- glBindVertexArray( 0 );
-
- // create and populate the texture
- glGenTextures(1, &m_glTexture );
- glBindTexture( GL_TEXTURE_2D, m_glTexture );
-
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, vrDiffuseTexture.unWidth, vrDiffuseTexture.unHeight,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, vrDiffuseTexture.rubTextureMapData );
-
- // If this renders black ask McJohn what's wrong.
- glGenerateMipmap(GL_TEXTURE_2D);
-
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
-
- GLfloat fLargest;
- glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest );
-
- glBindTexture( GL_TEXTURE_2D, 0 );
-
- m_unVertexCount = vrModel.unTriangleCount * 3;
-
- return true;
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Frees the GL resources for a render model
-//-----------------------------------------------------------------------------
-void CGLRenderModel::Cleanup()
-{
- if( m_glVertBuffer )
- {
- glDeleteBuffers(1, &m_glIndexBuffer);
- glDeleteVertexArrays( 1, &m_glVertArray );
- glDeleteBuffers(1, &m_glVertBuffer);
- m_glIndexBuffer = 0;
- m_glVertArray = 0;
- m_glVertBuffer = 0;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Draws the render model
-//-----------------------------------------------------------------------------
-void CGLRenderModel::Draw()
-{
- glBindVertexArray( m_glVertArray );
-
- glActiveTexture( GL_TEXTURE0 );
- glBindTexture( GL_TEXTURE_2D, m_glTexture );
-
- glDrawElements( GL_TRIANGLES, m_unVertexCount, GL_UNSIGNED_SHORT, 0 );
-
- glBindVertexArray( 0 );
-}
-
CMainApplication *pMainApplication;
void reset_position(int signum)