Exemplo n.º 1
0
int __glXDisp_GetPixelMapusv(__GLXclientState *cl, GLbyte *pc)
{
	GLenum map;
	GLint compsize;
	__GLXcontext *cx;
	ClientPtr client = cl->client;
	int error;
	GLushort answerBuffer[200];
	char *answer;

	cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
	if (!cx) {
		return error;
	}
	pc += __GLX_SINGLE_HDR_SIZE;
	map = *(GLenum *)(pc + 0);
	compsize = __glGetPixelMapusv_size(map);
	if (compsize < 0) compsize = 0;

	__GLX_GET_ANSWER_BUFFER(answer,cl,compsize*2,2);
	__glXClearErrorOccured();
	glGetPixelMapusv( 
		*(GLenum   *)(pc + 0),
		(GLushort *) answer
	);
	if (__glXErrorOccured()) {
	    __GLX_BEGIN_REPLY(0);
	    __GLX_PUT_SIZE(0);
	    __GLX_SEND_HEADER();
	} else if (compsize == 1) {
	    __GLX_BEGIN_REPLY(0);
	    __GLX_PUT_SIZE(1);
	    __GLX_PUT_SHORT();
	    __GLX_SEND_HEADER();
	} else {
	    __GLX_BEGIN_REPLY(compsize*2);
	    __GLX_PUT_SIZE(compsize);
	    __GLX_SEND_HEADER();
	    __GLX_SEND_SHORT_ARRAY(compsize);
	}
	return Success;
}
Exemplo n.º 2
0
enum piglit_result
test_pixel_map(void *null)
{
	int use_unpack;
	int use_pack;
	GLuint pb_pack[1];
	GLuint pb_unpack[1];
	int i;
	int size;
	int max;
	GLushort *pbo_mem;

	glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
	glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);

	glGetIntegerv(GL_MAX_PIXEL_MAP_TABLE, &max);

	for (use_pack = 0; use_pack < 2; use_pack++) {
		for (use_unpack = 0; use_unpack < 2;
		   use_unpack++) {
			glClearColor(0.0, 0.0, 0.0, 1.0);
			glClear(GL_COLOR_BUFFER_BIT);
			if (use_unpack) {
				glGenBuffersARB(1, pb_unpack);
				glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,
						pb_unpack[0]);
				glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,
						max * sizeof(GLushort), NULL,
						GL_STREAM_DRAW);
			}
			pbo_mem = NULL;
			if (use_unpack) {
				pbo_mem = (GLushort *) glMapBufferARB(
						GL_PIXEL_UNPACK_BUFFER_ARB,
						GL_WRITE_ONLY);
			}
			else {
				pbo_mem = (GLushort *)
					malloc(sizeof(GLushort) * max);
			}
			for (i = 0; i < max; i++)
				pbo_mem[i] = max - i - 1;

			if (use_unpack) {
				glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);
				glPixelMapusv(GL_PIXEL_MAP_R_TO_R, max, NULL);
				glPixelMapusv(GL_PIXEL_MAP_G_TO_G, max, NULL);
				glPixelMapusv(GL_PIXEL_MAP_B_TO_B, max, NULL);
				glPixelMapusv(GL_PIXEL_MAP_A_TO_A, max, NULL);
				glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,
						0);
			}
			else {
				glPixelMapusv(GL_PIXEL_MAP_R_TO_R, max,
					      pbo_mem);
				glPixelMapusv(GL_PIXEL_MAP_G_TO_G, max,
					      pbo_mem);
				glPixelMapusv(GL_PIXEL_MAP_B_TO_B, max,
					      pbo_mem);
				glPixelMapusv(GL_PIXEL_MAP_A_TO_A, max,
					      pbo_mem);
				free(pbo_mem);
			}


			glGetIntegerv(GL_PIXEL_MAP_R_TO_R_SIZE, &size);
			if (size != max) {
				REPORT_FAILURE("glPixelMap failed");
				return PIGLIT_FAIL;
			}
			glPixelTransferi(GL_MAP_COLOR, GL_FALSE);

			/* Read back pixel map */
			if (use_pack) {
				glGenBuffersARB(1, pb_pack);
				glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,
						pb_pack[0]);
				glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB,
						max * sizeof(GLushort),
						NULL, GL_STREAM_DRAW);
				glGetPixelMapusv(GL_PIXEL_MAP_R_TO_R, NULL);
				pbo_mem = (GLushort *) glMapBufferARB(
						GL_PIXEL_PACK_BUFFER_ARB,
						GL_READ_ONLY);
			}
			else {
				pbo_mem = (GLushort *)
					malloc(sizeof(GLushort) * max);
				glGetPixelMapusv(GL_PIXEL_MAP_R_TO_R, pbo_mem);
			}

			for (i = 0; i < max; i++) {
				if (pbo_mem[i] != max - i - 1) {
					REPORT_FAILURE("get PixelMap failed");
					return PIGLIT_FAIL;
				}
			}


			if (use_pack) {
				glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);
				glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
				glDeleteBuffersARB(1, pb_pack);
			}
			else {
				free(pbo_mem);
			}

			if (use_unpack) {
				glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,
						0);
				glDeleteBuffersARB(1, pb_unpack);
			}

			if (!piglit_automatic)
				piglit_present_results();

		}
	}

	return PIGLIT_PASS;
}
Exemplo n.º 3
0
M(void, glGetPixelMapusv, jint map, jobject values) {
	glGetPixelMapusv(map, BUFF(GLushort, values));
}