Beispiel #1
0
static int Scissor(lua_State *L)
    {
    GLint x, y;
    GLsizei width, height;
    GLint v[4];
    GLint index;
    if(lua_isinteger(L, 5))
        {
        v[0] = luaL_checkinteger(L, 1);
        v[1] = luaL_checkinteger(L, 2);
        v[2] = luaL_checkinteger(L, 3);
        v[3] = luaL_checkinteger(L, 4);
        index = luaL_checkinteger(L, 5);
        glScissorIndexedv(index, v);
        }
    else
        {
        x = luaL_checkinteger(L, 1);
        y = luaL_checkinteger(L, 2);
        width = luaL_checkinteger(L, 3);
        height = luaL_checkinteger(L, 4);
        glScissor(x, y, width, height);
        }
    CheckError(L);
    return 0;
    }
Beispiel #2
0
/**
 * Test invalid values for scissor left, bottom, width, height
 * INVALID_VALUE for negative w,h.  Test default values for left, bottom,
 * width, height.
 * OpenGL 4.3 Core section 13.6.1 ref:
 *    "In the initial state, left = bottom = 0, and width and
 *    height are determined by the size of the window into which the GL is
 *    to do its rendering for all viewports. If the default framebuffer is
 *    bound but no default framebuffer is associated with the GL context
 *    (see chapter 4), then width and height are initially set to zero."
 *
 *    "If either width or height is less than zero for any scissor rectangle,
 *    then an INVALID_VALUE error is generated."
 */
static bool
scissor_bounds(GLint maxVP)
{
	GLint sc[4];
	bool pass = true;
	int i;

	/* intial values for left, bottom, width, height */
	for (i = 0; i < maxVP; i++) {
		glGetIntegeri_v(GL_SCISSOR_BOX, i, sc);
		if (sc[0] != 0 || sc[1] != 0 || sc[2] != piglit_width ||
		    sc[3] != piglit_height) {
			printf("scissor box default value wrong for idx %d\n",
			       i);
			pass = false;
		}
	}
	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

	/* make sure large values don't cause gl errors */
	glScissorIndexed(0, 0x8000, 0x80000000, 0x7ffff, 0x7fffffff);
	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

	/* negative width, height gives gl error */
	sc[2] = -10;
	sc[3] = 0;
	for (i = 0; i < 2; i++) {
		glScissorArrayv(0, 1, sc);
		pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
		glScissorIndexed(1, sc[0], sc[1], sc[2], sc[3]);
		pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
		glScissorIndexedv(2, sc);
		pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
		sc[2] = 5;
		sc[3] = -12345;
	}

	return pass;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL41_nglScissorIndexedv(JNIEnv *env, jclass clazz, jint index, jlong v, jlong function_pointer) {
	const GLint *v_address = (const GLint *)(intptr_t)v;
	glScissorIndexedvPROC glScissorIndexedv = (glScissorIndexedvPROC)((intptr_t)function_pointer);
	glScissorIndexedv(index, v_address);
}