mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:09:52 +02:00
Merge pull request #194 from ey6es/master
Fix for starfield rendering on OS X.
This commit is contained in:
commit
33b4159a95
3 changed files with 12 additions and 26 deletions
|
@ -849,13 +849,13 @@ void displayOculus(Camera& whichCamera) {
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glUseProgramObjectARB(::oculusProgramID);
|
glUseProgramObjectARB(::oculusProgramID);
|
||||||
glUniform1fARB(textureLocation, 0);
|
glUniform1iARB(textureLocation, 0);
|
||||||
glUniform2fARB(lensCenterLocation, 0.287994, 0.5); // see SDK docs, p. 29
|
glUniform2fARB(lensCenterLocation, 0.287994, 0.5); // see SDK docs, p. 29
|
||||||
glUniform2fARB(screenCenterLocation, 0.25, 0.5);
|
glUniform2fARB(screenCenterLocation, 0.25, 0.5);
|
||||||
glUniform2fARB(scaleLocation, 0.25 * scaleFactor, 0.5 * scaleFactor * aspectRatio);
|
glUniform2fARB(scaleLocation, 0.25 * scaleFactor, 0.5 * scaleFactor * aspectRatio);
|
||||||
glUniform2fARB(scaleInLocation, 4, 2 / aspectRatio);
|
glUniform2fARB(scaleInLocation, 4, 2 / aspectRatio);
|
||||||
glUniform4fARB(hmdWarpParamLocation, 1.0, 0.22, 0.24, 0);
|
glUniform4fARB(hmdWarpParamLocation, 1.0, 0.22, 0.24, 0);
|
||||||
|
|
||||||
glColor3f(1, 0, 1);
|
glColor3f(1, 0, 1);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
|
|
|
@ -459,11 +459,6 @@ namespace starfield {
|
||||||
|
|
||||||
private: // gl API handling
|
private: // gl API handling
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
# define glBindVertexArray glBindVertexArrayAPPLE
|
|
||||||
# define glGenVertexArrays glGenVertexArraysAPPLE
|
|
||||||
# define glDeleteVertexArrays glDeleteVertexArraysAPPLE
|
|
||||||
#endif
|
|
||||||
void glAlloc() {
|
void glAlloc() {
|
||||||
|
|
||||||
GLchar const* const VERTEX_SHADER =
|
GLchar const* const VERTEX_SHADER =
|
||||||
|
@ -487,26 +482,21 @@ namespace starfield {
|
||||||
_objProgram.addShader(GL_FRAGMENT_SHADER, FRAGMENT_SHADER);
|
_objProgram.addShader(GL_FRAGMENT_SHADER, FRAGMENT_SHADER);
|
||||||
_objProgram.link();
|
_objProgram.link();
|
||||||
|
|
||||||
glGenVertexArrays(1, & _hndVertexArray);
|
glGenBuffersARB(1, & _hndVertexArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glFree() {
|
void glFree() {
|
||||||
|
|
||||||
glDeleteVertexArrays(1, & _hndVertexArray);
|
glDeleteBuffersARB(1, & _hndVertexArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glUpload(GLsizei n) {
|
void glUpload(GLsizei n) {
|
||||||
|
glBindBufferARB(GL_ARRAY_BUFFER, _hndVertexArray);
|
||||||
GLuint vbo;
|
|
||||||
glGenBuffers(1, & vbo);
|
|
||||||
|
|
||||||
glBindVertexArray(_hndVertexArray);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER,
|
glBufferData(GL_ARRAY_BUFFER,
|
||||||
n * sizeof(GpuVertex), _arrData, GL_STATIC_DRAW);
|
n * sizeof(GpuVertex), _arrData, GL_STATIC_DRAW);
|
||||||
glInterleavedArrays(GL_C4UB_V3F, sizeof(GpuVertex), 0l);
|
//glInterleavedArrays(GL_C4UB_V3F, sizeof(GpuVertex), 0l);
|
||||||
|
|
||||||
glBindVertexArray(0);
|
glBindBufferARB(GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glBatch(GLfloat const* matrix, GLsizei n_ranges) {
|
void glBatch(GLfloat const* matrix, GLsizei n_ranges) {
|
||||||
|
@ -538,14 +528,15 @@ namespace starfield {
|
||||||
|
|
||||||
// select shader and vertex array
|
// select shader and vertex array
|
||||||
_objProgram.activate();
|
_objProgram.activate();
|
||||||
glBindVertexArray(_hndVertexArray);
|
glBindBufferARB(GL_ARRAY_BUFFER, _hndVertexArray);
|
||||||
|
glInterleavedArrays(GL_C4UB_V3F, sizeof(GpuVertex), 0l);
|
||||||
|
|
||||||
// render
|
// render
|
||||||
glMultiDrawArrays(GL_POINTS,
|
glMultiDrawArrays(GL_POINTS,
|
||||||
_arrBatchOffs, _arrBatchCount, n_ranges);
|
_arrBatchOffs, _arrBatchCount, n_ranges);
|
||||||
|
|
||||||
// restore state
|
// restore state
|
||||||
glBindVertexArray(0);
|
glBindBufferARB(GL_ARRAY_BUFFER, 0);
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
|
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
|
||||||
glDisable(GL_POINT_SMOOTH);
|
glDisable(GL_POINT_SMOOTH);
|
||||||
|
@ -553,11 +544,6 @@ namespace starfield {
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
#ifdef __APPLE__
|
|
||||||
# undef glBindVertexArray
|
|
||||||
# undef glGenVertexArrays
|
|
||||||
# undef glDeleteVertexArrays
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
|
@ -103,4 +103,4 @@ int main(int argc, const char* argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue