mirror of
https://gitee.com/openharmony/third_party_mesa3d
synced 2024-11-25 00:09:54 +00:00
fix convolutions test to consistanty use the ARB shader extension functions
Was using a mix of the ARB functions and the OpenGL 2.0 shader functions.
This commit is contained in:
parent
7970b2a908
commit
35479fd4b4
@ -1,3 +1,10 @@
|
||||
/**
|
||||
* Convolution with GLSL.
|
||||
* Note: uses GL_ARB_shader_objects, GL_ARB_vertex_shader, GL_ARB_fragment_shader,
|
||||
* not the OpenGL 2.0 shader API.
|
||||
* Author: Zack Rusin
|
||||
*/
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include "readtex.h"
|
||||
|
||||
@ -54,15 +61,15 @@ static void loadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource(shader, 1, (const GLchar **) &text, NULL);
|
||||
glShaderSourceARB(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader(shader);
|
||||
glCompileShaderARB(shader);
|
||||
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
|
||||
glGetObjectParameterivARB(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog(shader, 1000, &len, log);
|
||||
glGetInfoLogARB(shader, 1000, &len, log);
|
||||
fprintf(stderr, "Problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
@ -98,11 +105,11 @@ static void
|
||||
checkLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv(prog, GL_LINK_STATUS, &stat);
|
||||
glGetObjectParameterivARB(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog(prog, 1000, &len, log);
|
||||
glGetInfoLogARB(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
@ -193,12 +200,12 @@ static void setupConvolution()
|
||||
}
|
||||
|
||||
loc = glGetUniformLocationARB(program, "KernelValue");
|
||||
glUniform4fv(loc, 9, vecKer);
|
||||
glUniform4fvARB(loc, 9, vecKer);
|
||||
loc = glGetUniformLocationARB(program, "ScaleFactor");
|
||||
glUniform4f(loc, scale, scale, scale, scale);
|
||||
glUniform4fARB(loc, scale, scale, scale, scale);
|
||||
loc = glGetUniformLocationARB(program, "BaseColor");
|
||||
glUniform4f(loc, baseColor[0], baseColor[1],
|
||||
baseColor[2], baseColor[3]);
|
||||
glUniform4fARB(loc, baseColor[0], baseColor[1],
|
||||
baseColor[2], baseColor[3]);
|
||||
|
||||
free(vecKer);
|
||||
free(kernel);
|
||||
@ -222,14 +229,16 @@ static void createProgram(const char *vertProgFile,
|
||||
glAttachShader(program, fragShader);
|
||||
}
|
||||
|
||||
glLinkProgram(program);
|
||||
glLinkProgramARB(program);
|
||||
checkLink(program);
|
||||
|
||||
glUseProgram(program);
|
||||
glUseProgramObjectARB(program);
|
||||
|
||||
/*
|
||||
assert(glIsProgram(program));
|
||||
assert(glIsShader(fragShader));
|
||||
assert(glIsShader(vertShader));
|
||||
*/
|
||||
|
||||
checkError(__LINE__);
|
||||
{/*texture*/
|
||||
@ -247,7 +256,7 @@ static void createProgram(const char *vertProgFile,
|
||||
0.0 , -1.0 / texture.height,
|
||||
-1.0 / texture.width, -1.0 / texture.height };
|
||||
GLuint offsetLoc = glGetUniformLocationARB(program, "Offset");
|
||||
glUniform2fv(offsetLoc, 9, offsets);
|
||||
glUniform2fvARB(offsetLoc, 9, offsets);
|
||||
}
|
||||
setupConvolution();
|
||||
|
||||
@ -316,6 +325,12 @@ static void menuInit()
|
||||
|
||||
static void init()
|
||||
{
|
||||
if (!glutExtensionSupported("GL_ARB_shader_objects") ||
|
||||
!glutExtensionSupported("GL_ARB_vertex_shader") ||
|
||||
!glutExtensionSupported("GL_ARB_fragment_shader")) {
|
||||
fprintf(stderr, "Sorry, this program requires GL_ARB_shader_objects, GL_ARB_vertex_shader, and GL_ARB_fragment_shader\n");
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
|
Loading…
Reference in New Issue
Block a user