aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp277
1 files changed, 221 insertions, 56 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fc75397..3931e74 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -70,6 +70,7 @@ void ThreadSleep( unsigned long nMilliseconds )
}
static bool g_bPrintf = true;
+static constexpr auto SPHERE_RADIUS = 1.0f;
//-----------------------------------------------------------------------------
// Purpose:
@@ -98,7 +99,7 @@ public:
void MouseButton(int button, bool down);
void SetupScene();
- void AddCubeToScene( const glm::mat4 &mat, std::vector<float> &vertdata );
+ void CreateProjectionSurface(const glm::mat4 &mat, std::vector<float> &vertdata, std::vector<GLushort> &indices);
bool SetupStereoRenderTargets();
void SetupCompanionWindow();
@@ -122,7 +123,7 @@ public:
// Get focused window or None
Window get_focused_window();
-private:
+private:
bool m_bDebugOpenGL;
bool m_bVerbose;
bool m_bPerf;
@@ -156,15 +157,17 @@ private: // OpenGL bookkeeping
int m_iSceneVolumeDepth;
float m_fScaleSpacing;
float m_fScale;
-
+
int m_iSceneVolumeInit; // if you want something other than the default 20x20x20
-
+
float m_fNearClip;
float m_fFarClip;
unsigned int m_uiVertcount;
+ GLushort m_nbIndices;
GLuint m_glSceneVertBuffer;
+ GLuint m_glSceneIndexBuffer;
GLuint m_unSceneVAO;
GLuint m_unCompanionWindowVAO;
GLuint m_glCompanionWindowIDVertBuffer;
@@ -225,7 +228,7 @@ private: // OpenGL bookkeeping
FramebufferDesc rightEyeDesc;
bool CreateFrameBuffer( int nWidth, int nHeight, FramebufferDesc &framebufferDesc );
-
+
uint32_t m_nRenderWidth;
uint32_t m_nRenderHeight;
@@ -251,7 +254,7 @@ private: // X compositor
int window_height;
Uint32 window_resize_time;
bool window_resized = false;
-
+
bool zoom_resize = false;
int x_fixes_event_base;
@@ -264,14 +267,16 @@ private: // X compositor
LEFT_RIGHT,
RIGHT_LEFT,
PLANE,
- SPHERE360
+ SPHERE360,
+ SPHERE360N
};
enum class ProjectionMode {
SPHERE,
FLAT,
CYLINDER, /* aka plane */
- SPHERE360
+ SPHERE360,
+ SPHERE360N
};
ProjectionMode projection_mode = ProjectionMode::SPHERE;
@@ -513,6 +518,19 @@ CMainApplication::CMainApplication( int argc, char *argv[] )
projection_mode = ProjectionMode::SPHERE360;
projection_arg = argv[i];
view_mode_arg = argv[i];
+ } else if(strcmp(argv[i], "--sphere360n") == 0) {
+ if(projection_arg) {
+ fprintf(stderr, "Error: --sphere360n option can't be used together with the %s option\n", projection_arg);
+ exit(1);
+ }
+ if(view_mode_arg) {
+ fprintf(stderr, "Error: --sphere360n option can't be used together with the %s option\n", view_mode_arg);
+ exit(1);
+ }
+ view_mode = ViewMode::SPHERE360N;
+ projection_mode = ProjectionMode::SPHERE360N;
+ projection_arg = argv[i];
+ view_mode_arg = argv[i];
} else if(strcmp(argv[i], "--stretch") == 0) {
stretch = true;
} else if(strcmp(argv[i], "--no-stretch") == 0) {
@@ -565,7 +583,7 @@ CMainApplication::CMainApplication( int argc, char *argv[] )
cursor_wrap = false;
}
- if(projection_mode == ProjectionMode::SPHERE360) {
+ if((projection_mode == ProjectionMode::SPHERE360) || (projection_mode == ProjectionMode::SPHERE360N)) {
zoom = 0.0f;
cursor_scale = 0.001f;
}
@@ -633,14 +651,14 @@ static void grabkeys(Display *display) {
for(int i = 0; i < 8; ++i) {
for(int j = 0; j < modmap->max_keypermod; ++j) {
if(modmap->modifiermap[i * modmap->max_keypermod + j] == numlock_keycode)
- numlockmask = (1 << i);
+ numlockmask = (1 << i);
}
}
XFreeModifiermap(modmap);
const int num_keys = 3;
int keys[num_keys] = { XK_F1, XK_q, XK_e };
-
+
Window root_window = DefaultRootWindow(display);
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
for(int i = 0; i < 4; ++i) {
@@ -753,18 +771,18 @@ bool CMainApplication::BInit()
m_iSceneVolumeWidth = m_iSceneVolumeInit;
m_iSceneVolumeHeight = m_iSceneVolumeInit;
m_iSceneVolumeDepth = m_iSceneVolumeInit;
-
+
m_fScale = 1.0f;
m_fScaleSpacing = 2.0f;
-
+
m_fNearClip = 0.01f;
m_fFarClip = 30.0f;
-
+
m_uiVertcount = 0;
-
+
// m_MillisecondsTimer.start(1, this);
// m_SecondsTimer.start(1000, this);
-
+
if (!BInitGL())
{
printf("%s - Unable to initialize OpenGL!\n", __FUNCTION__);
@@ -821,7 +839,7 @@ void DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsiz
// Purpose: Initialize OpenGL. Returns true if OpenGL has been successfully
// initialized, false if shaders could not be created.
// If failure occurred in a module other than shaders, the function
-// may return true or throw an error.
+// may return true or throw an error.
//-----------------------------------------------------------------------------
bool CMainApplication::BInitGL()
{
@@ -858,6 +876,7 @@ bool CMainApplication::BInitGL()
glGenVertexArrays( 1, &m_unSceneVAO );
glGenBuffers( 1, &m_glSceneVertBuffer );
+ glGenBuffers(1, &m_glSceneIndexBuffer);
SetupScene();
SetupCameras();
@@ -897,7 +916,7 @@ void CMainApplication::Shutdown()
vr::VR_Shutdown();
m_pHMD = NULL;
}
-
+
if( m_pContext )
{
if( m_bDebugOpenGL )
@@ -906,6 +925,7 @@ void CMainApplication::Shutdown()
glDebugMessageCallback(nullptr, nullptr);
}
glDeleteBuffers(1, &m_glSceneVertBuffer);
+ glDeleteBuffers(1, &m_glSceneIndexBuffer);
if ( m_unSceneProgramID )
{
@@ -959,9 +979,11 @@ void CMainApplication::Shutdown()
}
void CMainApplication::zoom_in() {
- if(projection_mode == ProjectionMode::SPHERE360)
+ if(projection_mode == ProjectionMode::SPHERE360) {
zoom -= 1.0f;
- else
+ } else if(projection_mode == ProjectionMode::SPHERE360N) {
+ zoom -= 1.0f;
+ } else
zoom -= 0.01f;
zoom_resize = true;
@@ -971,13 +993,15 @@ void CMainApplication::zoom_in() {
else
strstr << "/tmp/vr-video-player_" << src_window_id;
std::ofstream zoomstate(strstr.str());
- zoomstate << zoom;
+ zoomstate << zoom;
}
void CMainApplication::zoom_out() {
- if(projection_mode == ProjectionMode::SPHERE360)
+ if(projection_mode == ProjectionMode::SPHERE360) {
zoom += 1.0f;
- else
+ } if(projection_mode == ProjectionMode::SPHERE360N) {
+ zoom -= 1.0f;
+ } else
zoom += 0.01f;
zoom_resize = true;
@@ -1027,7 +1051,7 @@ bool CMainApplication::HandleInput()
}
XEvent xev;
-
+
if(XCheckTypedEvent(x_display, MappingNotify, &xev)) {
XMappingEvent *mapping_ev = &xev.xmapping;
XRefreshKeyboardMapping(mapping_ev);
@@ -1036,7 +1060,7 @@ bool CMainApplication::HandleInput()
grabkeys(x_display);
}
}
-
+
if (XCheckTypedEvent(x_display, KeyPress, &xev) && (xev.xkey.state & Mod1Mask)) {
KeySym keysym = XLookupKeysym(&xev.xkey, 0);
if(keysym == XK_F1)
@@ -1152,7 +1176,7 @@ bool CMainApplication::HandleInput()
m_reset_rotation = glm::inverse(hmd_rot);
}
- if(projection_mode == ProjectionMode::SPHERE || projection_mode == ProjectionMode::SPHERE360 || !free_camera) {
+ if(projection_mode == ProjectionMode::SPHERE || projection_mode == ProjectionMode::SPHERE360 || projection_mode == ProjectionMode::SPHERE360N || !free_camera) {
hmd_pos = current_pos;
}
@@ -1266,7 +1290,7 @@ void CMainApplication::RenderFrame()
{
m_iValidPoseCount_Last = m_iValidPoseCount;
m_iTrackedControllerCount_Last = m_iTrackedControllerCount;
-
+
dprintf( "PoseCount:%d(%s) Controllers:%d\n", m_iValidPoseCount, m_strPoseClasses.c_str(), m_iTrackedControllerCount );
}
@@ -1362,7 +1386,7 @@ GLuint CMainApplication::CompileGLShader( const char *pchShaderName, const char
dprintf("%s - Unable to compile fragment shader %d!\n", pchShaderName, nSceneFragmentShader );
glDeleteProgram( unProgramID );
glDeleteShader( nSceneFragmentShader );
- return 0;
+ return 0;
}
glAttachShader( unProgramID, nSceneFragmentShader );
@@ -1391,7 +1415,7 @@ GLuint CMainApplication::CompileGLShader( const char *pchShaderName, const char
//-----------------------------------------------------------------------------
bool CMainApplication::CreateAllShaders()
{
- m_unSceneProgramID = CompileGLShader(
+ m_unSceneProgramID = CompileGLShader(
"Scene",
// Vertex Shader
@@ -1501,14 +1525,14 @@ bool CMainApplication::CreateAllShaders()
"}\n"
);
- return m_unSceneProgramID != 0
+ return m_unSceneProgramID != 0
&& m_unCompanionWindowProgramID != 0;
}
bool CMainApplication::SetCursorFromX11CursorImage(XFixesCursorImage *x11_cursor_image) {
if(!x11_cursor_image)
return false;
-
+
if(!x11_cursor_image->pixels) {
XFree(x11_cursor_image);
return false;
@@ -1578,6 +1602,28 @@ Window CMainApplication::get_focused_window() {
return None;
}
+// void
+// vlc_gl_picture_ToTexCoords(const struct vlc_gl_picture *pic,
+// unsigned coords_count, const float *pic_coords,
+// float *tex_coords_out)
+// {
+// const float *mtx = pic->mtx;
+// assert(mtx);
+//
+// #define MTX(ROW,COL) mtx[(COL)*2+(ROW)]
+// for (unsigned i = 0; i < coords_count; ++i)
+// {
+// /* Store the coordinates, in case the transform must be applied in
+// * place (i.e. with pic_coords == tex_coords_out) */
+// float x = pic_coords[0];
+// float y = pic_coords[1];
+// tex_coords_out[0] = MTX(0,0) * x + MTX(0,1) * y + MTX(0,2);
+// tex_coords_out[1] = MTX(1,0) * x + MTX(1,1) * y + MTX(1,2);
+// pic_coords += 2;
+// tex_coords_out += 2;
+// }
+// }
+
//-----------------------------------------------------------------------------
// Purpose: create a sea of cubes
@@ -1588,6 +1634,7 @@ void CMainApplication::SetupScene()
return;
std::vector<float> vertdataarray;
+ std::vector<GLushort> indices;
#if 0
glm::mat4 matScale =glm::scale(glm::mat4(1.0f), glm::vec3(m_fScale, m_fScale, m_fScale));
glm::mat4 matTransform = glm::translate(glm::mat4(1.0f),
@@ -1596,7 +1643,7 @@ void CMainApplication::SetupScene()
-( (float)m_iSceneVolumeHeight * m_fScaleSpacing ) / 2.f,
-( (float)m_iSceneVolumeDepth * m_fScaleSpacing ) / 2.f)
);
-
+
glm::mat4 mat = matScale * matTransform;
for( int z = 0; z< m_iSceneVolumeDepth; z++ )
@@ -1605,7 +1652,7 @@ void CMainApplication::SetupScene()
{
for( int x = 0; x< m_iSceneVolumeWidth; x++ )
{
- AddCubeToScene( mat, vertdataarray );
+ CreateProjectionSurface( mat, vertdataarray, indices );
mat = mat * glm::translate(glm::mat4(1.0f), glm::vec3(m_fScaleSpacing, 0, 0 ));
}
mat = mat * glm::translate(glm::mat4(1.0f), glm::vec3(-((float)m_iSceneVolumeWidth) * m_fScaleSpacing, m_fScaleSpacing, 0 ));
@@ -1622,29 +1669,33 @@ void CMainApplication::SetupScene()
glm::vec3(-m_fScale*0.5f, -m_fScale*0.5f, 0.5f)
);
*/
-
+
glm::mat4 mat = matScale * matTransform;
- AddCubeToScene( mat, vertdataarray );
+ CreateProjectionSurface( mat, vertdataarray, indices );
#endif
m_uiVertcount = vertdataarray.size()/5;
-
+ m_nbIndices = indices.size();
+
glBindVertexArray( m_unSceneVAO );
glBindBuffer( GL_ARRAY_BUFFER, m_glSceneVertBuffer );
glBufferData( GL_ARRAY_BUFFER, sizeof(float) * vertdataarray.size(), &vertdataarray[0], GL_STATIC_DRAW);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_glSceneIndexBuffer);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort) * indices.size(), &indices[0], GL_STATIC_DRAW);
+
GLsizei stride = sizeof(VertexDataScene);
uintptr_t offset = 0;
glEnableVertexAttribArray( 0 );
- glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, stride , (const void *)offset);
+ glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, stride, (const void *)offset);
offset += sizeof(glm::vec3);
glEnableVertexAttribArray( 1 );
glVertexAttribPointer( 1, 2, GL_FLOAT, GL_FALSE, stride, (const void *)offset);
glBindVertexArray( 0 );
- glDisableVertexAttribArray(0);
- glDisableVertexAttribArray(1);
+ // glDisableVertexAttribArray(0);
+ // glDisableVertexAttribArray(1);
}
@@ -1755,7 +1806,7 @@ static void vertices_rotate(float *vertices, size_t num_vertices, float angle, g
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
-void CMainApplication::AddCubeToScene( const glm::mat4 &mat, std::vector<float> &vertdata )
+void CMainApplication::CreateProjectionSurface( const glm::mat4 &mat, std::vector<float> &vertdata, std::vector<GLushort> &indices )
{
double width_ratio = (double)pixmap_texture_width / (double)pixmap_texture_height;
arrow_ratio = width_ratio;
@@ -1943,6 +1994,113 @@ void CMainApplication::AddCubeToScene( const glm::mat4 &mat, std::vector<float>
vertices_rotate(&vertdata[plane_vertices_start], num_vertex_data, -glm::half_pi<float>(), glm::vec3(0.0f, 0.0f, 1.0f));
vertices_rotate(&vertdata[plane_vertices_start], num_vertex_data, -glm::half_pi<float>() - i * glm::half_pi<float>(), glm::vec3(1.0f, 0.0f, 0.0f));
}
+ } else if (projection_mode == ProjectionMode::SPHERE360N) {
+ unsigned nbLatBands = 64;
+ unsigned nbLonBands = 64;
+
+ unsigned nbVertices = (nbLatBands + 1) * (nbLonBands + 1);
+ unsigned nbIndices = nbLatBands * nbLonBands * 3 * 2;
+
+ vertdata.reserve(nbVertices * 5);
+ indices.reserve(nbIndices);
+
+ // *vertexCoord = vlc_alloc(*nbVertices * 3, sizeof(GLfloat));
+ // if (*vertexCoord == NULL)
+ // return VLC_ENOMEM;
+ // *textureCoord = vlc_alloc(*nbVertices * 2, sizeof(GLfloat));
+ // if (*textureCoord == NULL)
+ // {
+ // free(*vertexCoord);
+ // return VLC_ENOMEM;
+ // }
+ // *indices = vlc_alloc(*nbIndices, sizeof(GLushort));
+ // if (*indices == NULL)
+ // {
+ // free(*textureCoord);
+ // free(*vertexCoord);
+ // return VLC_ENOMEM;
+ // }
+
+ for (unsigned lat = 0; lat <= nbLatBands; lat++) {
+ float theta = lat * glm::pi<float>() / nbLatBands;
+ float sinTheta, cosTheta;
+
+ sincosf(theta, &sinTheta, &cosTheta);
+
+ for (unsigned int lon = 0; lon <= nbLonBands; lon++) {
+ float phi = 2.f * glm::pi<float>() * ((float)lon / nbLonBands);
+ float sinPhi, cosPhi;
+
+ sincosf(phi, &sinPhi, &cosPhi);
+
+ /* The camera is centered on the Z axis when yaw = 0, while the
+ * front part of the equirectangular texture is located at u=0.5.
+ * To have the camera at the correct location, phi is
+ * shifted +pi/2 to have u=0.5 fall at the correct location.
+ *
+ * Another way to interpret the shift is to interpret the shift
+ * as a shift in texture coordinate. Considering the initial
+ * orientation of the camera to Z which accounts as a pi/2
+ * rotation, adding pi/2 maps the first and last coordinate to the
+ * meridian, pi radians after the camera, so that u=0 amd u=1, ie.
+ * the back face, is mapped to the back of the initial orientation
+ * of the camera. */
+ float x = -sinPhi * sinTheta;
+ float y = cosTheta;
+ float z = cosPhi * sinTheta;
+ float u = (float)lon / nbLonBands;
+ /* In OpenGL, the texture coordinates start at bottom left */
+ float v = 1.0f - (float)lat / nbLatBands;
+
+ // unsigned off = (lat * (nbLonBands + 1) + lon) * 5
+ // vertdata[off + 0] = SPHERE_RADIUS * x;
+ // vertdata[off + 1] = SPHERE_RADIUS * y;
+ // vertdata[off + 2] = SPHERE_RADIUS * z;
+ // vertdata[off + 3] = u;
+ // vertdata[off + 4] = v;
+ vertdata.push_back(SPHERE_RADIUS * x);
+ vertdata.push_back(SPHERE_RADIUS * y);
+ vertdata.push_back(SPHERE_RADIUS * z);
+ vertdata.push_back(u);
+ vertdata.push_back(v);
+ }
+ }
+
+ // for (unsigned int i = 0; i < (nbLatBands * nbLonBands) + nbLonBands; ++i)
+ // {
+ // indices.push_back(i);
+ // indices.push_back(i + nbLonBands + 1);
+ // indices.push_back(i + nbLonBands);
+ //
+ // indices.push_back(i + nbLonBands + 1);
+ // indices.push_back(i);
+ // indices.push_back(i + 1);
+ // }
+
+ for (unsigned lat = 0; lat < nbLatBands; lat++) {
+ for (unsigned lon = 0; lon < nbLonBands; lon++) {
+ unsigned first = (lat * (nbLonBands + 1)) + lon;
+ unsigned second = first + nbLonBands + 1;
+
+ // unsigned off = (lat * nbLatBands + lon) * 3 * 2
+ //
+ // (*indices)[off] = first;
+ // (*indices)[off + 1] = second;
+ // (*indices)[off + 2] = first + 1;
+ //
+ // (*indices)[off + 3] = second;
+ // (*indices)[off + 4] = second + 1;
+ // (*indices)[off + 5] = first + 1;
+
+ indices.push_back(first);
+ indices.push_back(second);
+ indices.push_back(first + 1);
+ indices.push_back(second);
+ indices.push_back(second + 1);
+ indices.push_back(first + 1);
+ }
+ }
+
}
cursor_scale_uniform[0] = 0.01 * cursor_scale;
@@ -2019,7 +2177,7 @@ bool CMainApplication::SetupStereoRenderTargets()
CreateFrameBuffer( m_nRenderWidth, m_nRenderHeight, leftEyeDesc );
CreateFrameBuffer( m_nRenderWidth, m_nRenderHeight, rightEyeDesc );
-
+
return true;
}
@@ -2089,18 +2247,18 @@ void CMainApplication::RenderStereoTargets()
glViewport(0, 0, m_nRenderWidth, m_nRenderHeight );
RenderScene( vr::Eye_Left );
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
-
+
glDisable( GL_MULTISAMPLE );
-
+
glBindFramebuffer(GL_READ_FRAMEBUFFER, leftEyeDesc.m_nRenderFramebufferId);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, leftEyeDesc.m_nResolveFramebufferId );
- glBlitFramebuffer( 0, 0, m_nRenderWidth, m_nRenderHeight, 0, 0, m_nRenderWidth, m_nRenderHeight,
+ glBlitFramebuffer( 0, 0, m_nRenderWidth, m_nRenderHeight, 0, 0, m_nRenderWidth, m_nRenderHeight,
GL_COLOR_BUFFER_BIT,
GL_LINEAR );
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0 );
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0 );
glEnable( GL_MULTISAMPLE );
@@ -2109,13 +2267,13 @@ void CMainApplication::RenderStereoTargets()
glViewport(0, 0, m_nRenderWidth, m_nRenderHeight );
RenderScene( vr::Eye_Right );
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
-
+
glDisable( GL_MULTISAMPLE );
glBindFramebuffer(GL_READ_FRAMEBUFFER, rightEyeDesc.m_nRenderFramebufferId );
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, rightEyeDesc.m_nResolveFramebufferId );
-
- glBlitFramebuffer( 0, 0, m_nRenderWidth, m_nRenderHeight, 0, 0, m_nRenderWidth, m_nRenderHeight,
+
+ glBlitFramebuffer( 0, 0, m_nRenderWidth, m_nRenderHeight, 0, 0, m_nRenderWidth, m_nRenderHeight,
GL_COLOR_BUFFER_BIT,
GL_LINEAR );
@@ -2133,7 +2291,7 @@ void CMainApplication::RenderScene( vr::Hmd_Eye nEye )
{
if(!src_window_id)
return;
-
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
@@ -2157,7 +2315,7 @@ void CMainApplication::RenderScene( vr::Hmd_Eye nEye )
float scale = 0.5f;
if(view_mode == ViewMode::RIGHT_LEFT) {
offset = 0.5f;
- } else if(view_mode == ViewMode::PLANE || view_mode == ViewMode::SPHERE360) {
+ } else if(view_mode == ViewMode::PLANE || view_mode == ViewMode::SPHERE360 || view_mode == ViewMode::SPHERE360N) {
offset = 0.0f;
scale = 1.0f;
}
@@ -2173,7 +2331,7 @@ void CMainApplication::RenderScene( vr::Hmd_Eye nEye )
float scale = 0.5f;
if (view_mode == ViewMode::RIGHT_LEFT) {
offset = 0.0f;
- } else if (view_mode == ViewMode::PLANE || view_mode == ViewMode::SPHERE360) {
+ } else if (view_mode == ViewMode::PLANE || view_mode == ViewMode::SPHERE360 || view_mode == ViewMode::SPHERE360N) {
offset = 0.0f;
scale = 1.0f;
}
@@ -2195,12 +2353,19 @@ void CMainApplication::RenderScene( vr::Hmd_Eye nEye )
glUniform2fv(m_nCursorLocation, 1, &m[0]);
+ // vt->EnableVertexAttribArray(renderer->aloc.PicCoordsIn);
+ // vt->VertexAttribPointer(renderer->aloc.PicCoordsIn, 2, GL_FLOAT, 0, 0, 0);
+
+
glBindVertexArray( m_unSceneVAO );
glActiveTexture(GL_TEXTURE0);
glBindTexture( GL_TEXTURE_2D, window_texture_get_opengl_texture_id(&window_texture) );
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, arrow_image_texture_id);
- glDrawArrays( GL_TRIANGLES, 0, m_uiVertcount );
+ //glDrawArrays( GL_TRIANGLES, 0, m_uiVertcount );
+ //glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_glSceneIndexBuffer);
+ glDrawElements(GL_TRIANGLES, m_nbIndices, GL_UNSIGNED_SHORT, 0);
+
glBindVertexArray( 0 );
glActiveTexture(GL_TEXTURE0);
@@ -2280,8 +2445,8 @@ glm::mat4 CMainApplication::GetHMDMatrixProjectionEye( vr::Hmd_Eye nEye )
return glm::mat4(
mat.m[0][0], mat.m[1][0], mat.m[2][0], mat.m[3][0],
- mat.m[0][1], mat.m[1][1], mat.m[2][1], mat.m[3][1],
- mat.m[0][2], mat.m[1][2], mat.m[2][2], mat.m[3][2],
+ mat.m[0][1], mat.m[1][1], mat.m[2][1], mat.m[3][1],
+ mat.m[0][2], mat.m[1][2], mat.m[2][2], mat.m[3][2],
mat.m[0][3], mat.m[1][3], mat.m[2][3], mat.m[3][3]
);
}
@@ -2297,7 +2462,7 @@ glm::mat4 CMainApplication::GetHMDMatrixPoseEye( vr::Hmd_Eye nEye )
vr::HmdMatrix34_t matEyeRight = m_pHMD->GetEyeToHeadTransform( nEye );
glm::mat4 matrixObj(
- matEyeRight.m[0][0], matEyeRight.m[1][0], matEyeRight.m[2][0], 0.0,
+ matEyeRight.m[0][0], matEyeRight.m[1][0], matEyeRight.m[2][0], 0.0,
matEyeRight.m[0][1], matEyeRight.m[1][1], matEyeRight.m[2][1], 0.0,
matEyeRight.m[0][2], matEyeRight.m[1][2], matEyeRight.m[2][2], 0.0,
matEyeRight.m[0][3], matEyeRight.m[1][3], matEyeRight.m[2][3], 1.0f
@@ -2367,7 +2532,7 @@ void CMainApplication::UpdateHMDMatrixPose()
glm::mat4 *mat = (glm::mat4*)&m_rTrackedDevicePose[nDevice].mDeviceToAbsoluteTracking;
hmd_rot = glm::quat_cast(*mat);
-
+
m_rDevClassChar[nDevice] = 'H';
break;
}