mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 23:29:39 +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);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glUseProgramObjectARB(::oculusProgramID);
|
||||
glUniform1fARB(textureLocation, 0);
|
||||
glUniform1iARB(textureLocation, 0);
|
||||
glUniform2fARB(lensCenterLocation, 0.287994, 0.5); // see SDK docs, p. 29
|
||||
glUniform2fARB(screenCenterLocation, 0.25, 0.5);
|
||||
glUniform2fARB(scaleLocation, 0.25 * scaleFactor, 0.5 * scaleFactor * aspectRatio);
|
||||
glUniform2fARB(scaleInLocation, 4, 2 / aspectRatio);
|
||||
glUniform4fARB(hmdWarpParamLocation, 1.0, 0.22, 0.24, 0);
|
||||
|
||||
|
||||
glColor3f(1, 0, 1);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
|
|
|
@ -459,11 +459,6 @@ namespace starfield {
|
|||
|
||||
private: // gl API handling
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define glBindVertexArray glBindVertexArrayAPPLE
|
||||
# define glGenVertexArrays glGenVertexArraysAPPLE
|
||||
# define glDeleteVertexArrays glDeleteVertexArraysAPPLE
|
||||
#endif
|
||||
void glAlloc() {
|
||||
|
||||
GLchar const* const VERTEX_SHADER =
|
||||
|
@ -487,26 +482,21 @@ namespace starfield {
|
|||
_objProgram.addShader(GL_FRAGMENT_SHADER, FRAGMENT_SHADER);
|
||||
_objProgram.link();
|
||||
|
||||
glGenVertexArrays(1, & _hndVertexArray);
|
||||
glGenBuffersARB(1, & _hndVertexArray);
|
||||
}
|
||||
|
||||
void glFree() {
|
||||
|
||||
glDeleteVertexArrays(1, & _hndVertexArray);
|
||||
glDeleteBuffersARB(1, & _hndVertexArray);
|
||||
}
|
||||
|
||||
void glUpload(GLsizei n) {
|
||||
|
||||
GLuint vbo;
|
||||
glGenBuffers(1, & vbo);
|
||||
|
||||
glBindVertexArray(_hndVertexArray);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER, _hndVertexArray);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
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) {
|
||||
|
@ -538,14 +528,15 @@ namespace starfield {
|
|||
|
||||
// select shader and vertex array
|
||||
_objProgram.activate();
|
||||
glBindVertexArray(_hndVertexArray);
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER, _hndVertexArray);
|
||||
glInterleavedArrays(GL_C4UB_V3F, sizeof(GpuVertex), 0l);
|
||||
|
||||
// render
|
||||
glMultiDrawArrays(GL_POINTS,
|
||||
_arrBatchOffs, _arrBatchCount, n_ranges);
|
||||
|
||||
// restore state
|
||||
glBindVertexArray(0);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER, 0);
|
||||
glUseProgram(0);
|
||||
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
|
@ -553,11 +544,6 @@ namespace starfield {
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
# undef glBindVertexArray
|
||||
# undef glGenVertexArrays
|
||||
# undef glDeleteVertexArrays
|
||||
#endif
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -103,4 +103,4 @@ int main(int argc, const char* argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue