Ejemplo n.º 1
0
GLfloat getFloat(const GLenum pname, const GLuint index)
{
    GLfloat value;

    glGetFloati_v(pname, index, &value);

    return value;
}
Ejemplo n.º 2
0
Archivo: get.c Proyecto: stetre/moongl
static int GetFloat4Index(lua_State *L, GLenum pname)
    {
    GLfloat data[4];
    GLuint index;
    index = luaL_checkinteger(L, 2);
    glGetFloati_v(pname, index, data);
    CheckError(L);
    lua_pushnumber(L, data[0]);
    lua_pushnumber(L, data[1]);
    lua_pushnumber(L, data[2]);
    lua_pushnumber(L, data[3]);
    return 4;
    }
Ejemplo n.º 3
0
Archivo: get.c Proyecto: stetre/moongl
static int GetFloat4OptIndex(lua_State *L, GLenum pname) /* index is optional */
    {
    GLfloat data[4];
    GLuint index;
    if(!lua_isnoneornil(L, 2))
        {
        index = luaL_checkinteger(L, 2);
        glGetFloati_v(pname, index, data);
        }
    else
        glGetFloatv(pname, data);
    CheckError(L);
    lua_pushnumber(L, data[0]);
    lua_pushnumber(L, data[1]);
    lua_pushnumber(L, data[2]);
    lua_pushnumber(L, data[3]);
    return 4;
    }
Ejemplo n.º 4
0
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL41_nglGetFloati_v(JNIEnv *env, jclass clazz, jint target, jint index, jlong data, jlong function_pointer) {
	GLfloat *data_address = (GLfloat *)(intptr_t)data;
	glGetFloati_vPROC glGetFloati_v = (glGetFloati_vPROC)((intptr_t)function_pointer);
	glGetFloati_v(target, index, data_address);
}
Ejemplo n.º 5
0
Archivo: bounds.c Proyecto: RAOF/piglit
PIGLIT_GL_TEST_CONFIG_END

/**
 * Test clamping for viewport x,y, width, height. They should be clamped
 * to VIEWPORT_BOUNDS_RANGE and MAX_VIEWPORT_DIMS.  INVALID_VALUE for
 * negative w,h. Test default values of x,y,w,h.
 * OpenGL 4.3 Core section 13.6.1 ref:
 *    "The location of the viewport’s bottom-left corner, given by (x, y),
 *    are clamped to be within the implementation-dependent viewport bounds
 *    range. The viewport bounds range [min, max] tuple may be determined by
 *    calling GetFloatv with the symbolic constant VIEWPORT_BOUNDS_RANGE (see
 *    section 22)."
 *
 *    "Viewport width and height are clamped to implementation-dependent
 *    maximums when specified. The maximum width and height may be found by
 *    calling GetFloatv with the symbolic constant MAX_VIEWPORT_DIMS."
 *
 *    "An INVALID_VALUE error is generated if either w or h is negative."
 *
 *    "In the initial state, w and h for each viewport are set to the width
 *    and height, respectively, of the window into which the GL is to do its
 *    rendering. If the default framebuffer is bound but no default framebuffer
 *    is associated with the GL context (see chapter 9), then w and h are
 *    initially set to zero. ox, oy , n, and f are set to w/2 , h/2, 0.0, and
 *    1.0, respectively."
 */
static bool
viewport_bounds(GLint maxVP)
{
	GLfloat maxDims[2];
	GLfloat range[2];
	GLfloat vp[4], vpGet[4];
	bool pass = true;
	int i;

	/* intial values for x,y,w,h */
	for (i = 0; i < maxVP; i++) {
		glGetFloati_v(GL_VIEWPORT, i, vp);
		if (vp[0] != 0.0 || vp[1] != 0.0 ||
		    vp[2] != (GLfloat) piglit_width ||
		    vp[3] != (GLfloat) piglit_height) {
			printf("viewport default value wrong for idx %d\n", i);
			pass = false;
		}
	}
	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

	/* test clamping of viewport values */
	glGetFloatv(GL_MAX_VIEWPORT_DIMS, maxDims);
	glGetFloatv(GL_VIEWPORT_BOUNDS_RANGE, range);
	vp[0] = range[0] - 2.0;
	vp[1] = range[1] + 2.0;
	vp[2] = maxDims[0] + 1.0;
	vp[3] = maxDims[1] + 1.0;
	glViewportArrayv(0, 1, vp);
	glGetFloati_v(GL_VIEWPORT, 0, vpGet);
	if (vpGet[0] != range[0] || vpGet[1] != range[1] ||
	    vpGet[2] != maxDims[0] || vpGet[3] != maxDims[1]) {
		printf("viewport clamping failed glViewportArrayv\n");
		pass = false;
	}
	glViewportIndexedf(1, vp[0], vp[1], vp[2], vp[3]);
	glGetFloati_v(GL_VIEWPORT, 1, vpGet);
	if (vpGet[0] != range[0] || vpGet[1] != range[1] ||
	    vpGet[2] != maxDims[0] || vpGet[3] != maxDims[1]) {
		printf("viewport clamping failed glViewportIndexedf\n");
		pass = false;
	}
	glViewportIndexedfv(2, vp);
	glGetFloati_v(GL_VIEWPORT, 2, vpGet);
	if (vpGet[0] != range[0] || vpGet[1] != range[1] ||
	    vpGet[2] != maxDims[0] || vpGet[3] != maxDims[1]) {
		printf("viewport clamping failed glViewportIndexedfv\n");
		pass = false;
	}

	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

	/* negative width, height gives gl error */
	vp[2] = -10.3;
	vp[3] = 0.0;
	for (i = 0; i < 2; i++) {
		glViewportArrayv(0, 1, vp);
		pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
		glViewportIndexedf(1, vp[0], vp[1], vp[2], vp[3]);
		pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
		glViewportIndexedfv(2, vp);
		pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
		vp[2] = 5.0;
		vp[3] = -12345.7;
	}

	return pass;
}
Ejemplo n.º 6
0
Archivo: grid.c Proyecto: Jul13t/piglit
bool
draw_grid(const struct grid_info grid, GLuint prog)
{
        static GLuint lprog;

        if (lprog != prog) {
                glUseProgram(prog);
                lprog = prog;
        }

        if (grid.stages & GL_COMPUTE_SHADER_BIT) {
                set_uniform_int(prog, "ret_img", 7);
                glDispatchCompute(1, grid.size.y, 1);

        } else if (grid.stages & (GL_TESS_CONTROL_SHADER_BIT |
                                  GL_TESS_EVALUATION_SHADER_BIT)) {
                static struct image_extent size;
                static GLuint vao, vbo;

                if (size.x != grid.size.x || size.y != grid.size.y) {
                        size = grid.size;

                        if (!generate_grid_arrays(
                                    &vao, &vbo,
                                    1.0 / size.x - 1.0, 1.0 / size.y - 1.0,
                                    2.0 / size.x, 2.0 / size.y,
                                    size.x, size.y))
                                return false;
                }

                glBindVertexArray(vao);
                glPatchParameteri(GL_PATCH_VERTICES, 4);
                glDrawArrays(GL_PATCHES, 0, product(size));

        } else if (grid.stages & (GL_VERTEX_SHADER_BIT |
                                  GL_GEOMETRY_SHADER_BIT)) {
                static struct image_extent size;
                static GLuint vao, vbo;

                if (size.x != grid.size.x || size.y != grid.size.y) {
                        size = grid.size;

                        if (!generate_grid_arrays(
                                    &vao, &vbo,
                                    1.0 / size.x - 1.0, 1.0 / size.y - 1.0,
                                    2.0 / size.x, 2.0 / size.y,
                                    size.x, size.y))
                                return false;
                }

                glBindVertexArray(vao);
                glDrawArrays(GL_POINTS, 0, product(size));

        } else {
                static struct image_extent size;
                static GLuint vao, vbo;

                if (size.x != grid.size.x || size.y != grid.size.y) {
                        float vp[4];

                        glGetFloati_v(GL_VIEWPORT, 0, vp);
                        size = grid.size;

                        if (!generate_grid_arrays(
                                    &vao, &vbo, -1.0, -1.0,
                                    2.0 * size.x / vp[2], 2.0 * size.y / vp[3],
                                    2, 2))
                                return false;
                }


                glBindVertexArray(vao);
                glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
        }

        return piglit_check_gl_error(GL_NO_ERROR);
}