MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCL-CTS / CreateGLTexture2DMultisample

Function CreateGLTexture2DMultisample

test_common/gl/helpers.cpp:1038–1299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1036
1037
1038void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples,
1039 GLenum target, GLenum glFormat,
1040 GLenum internalFormat, GLenum glType,
1041 ExplicitType type, GLuint *outTextureID,
1042 int *outError, bool allocateMem, MTdata d , bool fixedSampleLocations)
1043{
1044 // This function creates a multisample texture and renders into each sample
1045 // using a GLSL shader
1046
1047 // Check if the renderer supports enough samples
1048 GLint max_samples = get_gl_max_samples(target, internalFormat);
1049 CHECK_GL_ERROR()
1050
1051 if (max_samples < (GLint)samples)
1052 log_error("GL error: requested samples (%zu) exceeds renderer max "
1053 "samples (%d)\n",
1054 samples, max_samples);
1055
1056 // Setup the GLSL program
1057 const GLchar *vertex_source =
1058 "#version 140\n"
1059 "in vec4 att0;\n"
1060 "void main (void) {\n"
1061 " gl_Position = vec4(att0.xy,0.0,1.0);\n"
1062 "}\n";
1063
1064 const GLchar *fragmentSource =
1065 "#version 140\n"
1066 "out %s out0;\n"
1067 "uniform %s colorVal;\n"
1068 "uniform float depthVal;\n"
1069 "void main (void) {\n"
1070 " out0 = %s(colorVal);\n"
1071 " gl_FragDepth = depthVal;\n"
1072 "}\n";
1073
1074 GLchar fragmentShader[256];
1075 sprintf(fragmentShader, fragmentSource, get_gl_vector_type(internalFormat), get_gl_data_type(internalFormat), get_gl_vector_type(internalFormat));
1076 const GLchar *fragment_source = &fragmentShader[0];
1077
1078 glShaderWrapper vertex_shader = glCreateShader(GL_VERTEX_SHADER);
1079 glShaderSource(vertex_shader, 1, &vertex_source, NULL);
1080 glCompileShader(vertex_shader);
1081 CHECK_GL_ERROR()
1082
1083 glShaderWrapper fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
1084 glShaderSource(fragment_shader, 1, &fragment_source, NULL);
1085 glCompileShader(fragment_shader);
1086 CHECK_GL_ERROR()
1087
1088 GLuint prog = glCreateProgram();
1089 glAttachShader(prog, vertex_shader);
1090 glAttachShader(prog, fragment_shader);
1091 CHECK_GL_ERROR()
1092
1093 glBindAttribLocation(prog, 0, "att0");
1094 glLinkProgram(prog);
1095 CHECK_GL_ERROR()

Callers 2

test_image_format_readFunction · 0.85

Calls 7

get_gl_max_samplesFunction · 0.85
get_gl_vector_typeFunction · 0.85
get_gl_data_typeFunction · 0.85
get_explicit_type_sizeFunction · 0.85
convert_float_to_halfFunction · 0.85
GetGLFormatNameFunction · 0.70

Tested by 2

test_image_format_readFunction · 0.68