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

Function CreateGLTexture1DArray

test_common/gl/helpers.cpp:36–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34#endif
35
36void * CreateGLTexture1DArray(size_t width, size_t length,
37 GLenum target, GLenum glFormat, GLenum internalFormat, GLenum glType,
38 ExplicitType type, GLuint *outTextureID, int *outError,
39 bool allocateMem, MTdata d)
40{
41 *outError = 0;
42 GLenum err = 0;
43
44 char * buffer;
45 unsigned int size = 0;
46
47 // width_in_pixels * pixel_width * number_of_images:
48 if ( (glType == GL_UNSIGNED_INT_2_10_10_10_REV) || (glType == GL_UNSIGNED_INT_10_10_10_2) )
49 {
50 size = width * length;
51 }
52 else
53 {
54 size = width * length * 4;
55 }
56
57 buffer = (char *)CreateRandomData(type, size, d);
58
59 glGenTextures( 1, outTextureID );
60 glBindTexture( get_base_gl_target( target ), *outTextureID );
61 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
62 glTexParameteri( get_base_gl_target( target ), GL_TEXTURE_MIN_FILTER, GL_NEAREST );
63 glTexParameteri( get_base_gl_target( target ), GL_TEXTURE_MAG_FILTER, GL_NEAREST );
64 err = glGetError();
65 if( err != GL_NO_ERROR ) {
66 log_error( "ERROR: Failed to create GL texture object: %s!\n", gluErrorString( err ));
67 *outError = -1;
68 free( buffer );
69 return NULL;
70 }
71
72 // use TexImage2D to pump the 1D array fill of bits:
73 glTexImage2D( get_base_gl_target(target), 0, internalFormat, (GLsizei)width,
74 (GLsizei)length, 0, glFormat, glType, buffer );
75
76 err = glGetError();
77 if( err != GL_NO_ERROR ) {
78 if (err != GL_OUT_OF_MEMORY) {
79 log_error( "ERROR: Unable to load data using glTexImage2D for "
80 "TEXTURE_1D_ARRAY : %s : %s : %d : %d : %s : %s : Error %s\n",
81 GetGLTargetName(target),
82 GetGLFormatName(internalFormat),
83 (int)(width), (int)(length),
84 GetGLFormatName(glFormat),
85 GetGLTypeName(glType),
86 gluErrorString( err ));
87
88 *outError = -1;
89 } else {
90 log_info( "WARNING: Unable to load data using glTexImage2D for "
91 "TEXTURE_1D_ARRAY : %s : %s : %d : %d : %s : %s : Error %s\n",
92 GetGLTargetName(target),
93 GetGLFormatName(internalFormat),

Callers 3

test_image_format_readFunction · 0.85
test_image_format_writeFunction · 0.85

Calls 6

CreateRandomDataFunction · 0.70
get_base_gl_targetFunction · 0.70
gluErrorStringFunction · 0.70
GetGLTargetNameFunction · 0.70
GetGLFormatNameFunction · 0.70
GetGLTypeNameFunction · 0.70

Tested by 3

test_image_format_readFunction · 0.68
test_image_format_writeFunction · 0.68