|
|
|
|
@@ -46,6 +46,9 @@ static GLuint texcoordBufferName = UNINITIALIZED_GL;
|
|
|
|
|
static GLuint elementBufferName = UNINITIALIZED_GL;
|
|
|
|
|
static GLModel *crtModel = NULL;
|
|
|
|
|
|
|
|
|
|
static GLuint vertexShader = UNINITIALIZED_GL;
|
|
|
|
|
static GLuint fragShader = UNINITIALIZED_GL;
|
|
|
|
|
|
|
|
|
|
static video_backend_s glvideo_backend = { 0 };
|
|
|
|
|
|
|
|
|
|
#if USE_GLUT
|
|
|
|
|
@@ -323,7 +326,7 @@ static GLuint _build_program(demoSource *vertexSource, demoSource *fragmentSourc
|
|
|
|
|
sprintf(sourceString, "%s", vertexSource->string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
|
|
|
|
|
vertexShader = glCreateShader(GL_VERTEX_SHADER);
|
|
|
|
|
glShaderSource(vertexShader, 1, (const GLchar **)&(sourceString), NULL);
|
|
|
|
|
glCompileShader(vertexShader);
|
|
|
|
|
glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &logLength);
|
|
|
|
|
@@ -362,7 +365,7 @@ static GLuint _build_program(demoSource *vertexSource, demoSource *fragmentSourc
|
|
|
|
|
sprintf(sourceString, "%s", fragmentSource->string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GLuint fragShader = glCreateShader(GL_FRAGMENT_SHADER);
|
|
|
|
|
fragShader = glCreateShader(GL_FRAGMENT_SHADER);
|
|
|
|
|
glShaderSource(fragShader, 1, (const GLchar **)&(sourceString), NULL);
|
|
|
|
|
glCompileShader(fragShader);
|
|
|
|
|
glGetShaderiv(fragShader, GL_INFO_LOG_LENGTH, &logLength);
|
|
|
|
|
@@ -398,17 +401,6 @@ static GLuint _build_program(demoSource *vertexSource, demoSource *fragmentSourc
|
|
|
|
|
free(log);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glDetachShader(prgName, vertexShader);
|
|
|
|
|
glDetachShader(prgName, fragShader);
|
|
|
|
|
|
|
|
|
|
// Delete the vertex shader since it is now attached and linked
|
|
|
|
|
// to the program, which will retain a reference to it
|
|
|
|
|
glDeleteShader(vertexShader);
|
|
|
|
|
|
|
|
|
|
// Delete the fragment shader since it is now attached and linked
|
|
|
|
|
// to the program, which will retain a reference to it
|
|
|
|
|
glDeleteShader(fragShader);
|
|
|
|
|
|
|
|
|
|
glGetProgramiv(prgName, GL_LINK_STATUS, &status);
|
|
|
|
|
if (status == 0) {
|
|
|
|
|
LOG("Failed to link program");
|
|
|
|
|
@@ -641,15 +633,13 @@ static void gldriver_init_common(void) {
|
|
|
|
|
// ----------------------------
|
|
|
|
|
// setup static OpenGL state
|
|
|
|
|
|
|
|
|
|
// Depth test will always be enabled
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
|
|
|
|
|
// We will always cull back faces for better performance
|
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
|
|
// Always use this clear color
|
|
|
|
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
|
|
// Set up to do blending of texture quads. Disabling DEPTH/CULL appears to fix blended quad/texture rendering on
|
|
|
|
|
// finicky Tegra 2. This generally appears to be the correct way to do it accoring to NVIDIA forums and:
|
|
|
|
|
// http://www.learnopengles.com/android-lesson-five-an-introduction-to-blending/
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
|
|
|
|
@@ -687,6 +677,17 @@ static void _gldriver_shutdown(void) {
|
|
|
|
|
|
|
|
|
|
mdlDestroyModel(&crtModel);
|
|
|
|
|
|
|
|
|
|
// detach and delete the main shaders
|
|
|
|
|
// 2015/11/06 NOTE : Tegra 2 for mobile has a bug whereby you cannot detach/delete shaders immediately after
|
|
|
|
|
// creating the program. So we delete them during the shutdown sequence instead.
|
|
|
|
|
// https://code.google.com/p/android/issues/detail?id=61832
|
|
|
|
|
glDetachShader(mainShaderProgram, vertexShader);
|
|
|
|
|
glDetachShader(mainShaderProgram, fragShader);
|
|
|
|
|
glDeleteShader(vertexShader);
|
|
|
|
|
glDeleteShader(fragShader);
|
|
|
|
|
vertexShader = UNINITIALIZED_GL;
|
|
|
|
|
fragShader = UNINITIALIZED_GL;
|
|
|
|
|
|
|
|
|
|
glUseProgram(0);
|
|
|
|
|
if (mainShaderProgram != UNINITIALIZED_GL) {
|
|
|
|
|
glDeleteProgram(mainShaderProgram);
|
|
|
|
|
@@ -749,7 +750,7 @@ static void gldriver_render(void) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
#if MOBILE_DEVICE
|
|
|
|
|
glViewport(viewportX, viewportY, viewportWidth, viewportHeight);
|
|
|
|
|
#endif
|
|
|
|
|
@@ -903,7 +904,7 @@ static void gldriver_reshape(int w, int h) {
|
|
|
|
|
#if USE_GLUT
|
|
|
|
|
static void gldriver_init_glut(GLuint fbo) {
|
|
|
|
|
glutInit(&argc, argv);
|
|
|
|
|
glutInitDisplayMode(/*GLUT_DOUBLE|*/GLUT_RGBA|GLUT_DEPTH);
|
|
|
|
|
glutInitDisplayMode(/*GLUT_DOUBLE|*/GLUT_RGBA);
|
|
|
|
|
glutInitWindowSize(windowWidth, windowHeight);
|
|
|
|
|
//glutInitContextVersion(4, 0); -- Is this needed?
|
|
|
|
|
glutInitContextProfile(GLUT_CORE_PROFILE);
|
|
|
|
|
|