Example #1
0
static GLboolean
framebuffer_srgb_fbo(void)
{
	GLboolean pass = GL_TRUE;
	int fbo_width = FBO_SIZE;
	int fbo_height = FBO_SIZE;
	GLuint fbo;

	fbo = make_fbo(fbo_width, fbo_height);
	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
	glViewport(0, 0, fbo_width, fbo_height);

	piglit_ortho_projection(fbo_width, fbo_height, GL_FALSE);

	pass = test_srgb();

	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

	draw_fbo(0, 0);
	piglit_present_results();
	glDeleteFramebuffersEXT(1, &fbo);
	return pass;
}
static GLboolean
run_test(void)
{
	GLboolean pass = GL_TRUE;
	GLuint fbo;
	int fbo_width = FBO_SIZE;
	int fbo_height = FBO_SIZE;
	int x0 = PAD;
	int y0 = PAD;
	int y1 = PAD * 2 + SIZE;
	int y2 = PAD * 3 + SIZE * 2;
	GLint win_depth_bits, fbo_depth_bits, win_stencil_bits, fbo_stencil_bits;

	glViewport(0, 0, piglit_width, piglit_height);
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_ALWAYS);
	glDepthMask(GL_TRUE);

	glClearColor(0.5, 0.5, 0.5, 0.5);
	glClearDepth(0.12345);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	/* Draw the color rect in the window system window */
	draw_depth_rect(x0, y0, SIZE, SIZE);

	fbo = make_fbo(fbo_width, fbo_height);

	/* query depth/stencil sizes */
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);
	glGetIntegerv(GL_DEPTH_BITS, &win_depth_bits);
	glGetIntegerv(GL_STENCIL_BITS, &win_stencil_bits);

	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
	glGetIntegerv(GL_DEPTH_BITS, &fbo_depth_bits);
	glGetIntegerv(GL_STENCIL_BITS, &fbo_stencil_bits);

	if (win_depth_bits != fbo_depth_bits ||
	    win_stencil_bits != fbo_stencil_bits) {
		/* The spec doesn't allow blitting between depth/blitting surfaces
		 * of different formats.
		 */
		piglit_report_result(PIGLIT_SKIP);
	}

	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, piglit_winsys_fbo);
	glViewport(0, 0, fbo_width, fbo_height);
	piglit_ortho_projection(fbo_width, fbo_height, GL_FALSE);
	glClearDepth(0.54321);
	glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	/* Draw the color rect in the FBO */
	draw_depth_rect(x0, y0, SIZE, SIZE);

	/* Now that we have correct samples, blit things around.
	 * FBO(bottom) -> WIN(middle)
	 *
	 * Also blit with stencil to exercise this path.
	 * Not that we need it for this test.
	 */
	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, piglit_winsys_fbo);
	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
	copy(x0, y0, x0 + SIZE, y0 + SIZE,
	     x0, y1, x0 + SIZE, y1 + SIZE,
	     GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	if (!piglit_check_gl_error(GL_NO_ERROR))
		piglit_report_result(PIGLIT_FAIL);

	/* WIN(bottom) -> FBO(middle) */
	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, piglit_winsys_fbo);
	copy(x0, y0, x0 + SIZE, y0 + SIZE,
	     x0, y1, x0 + SIZE, y1 + SIZE,
	     GL_DEPTH_BUFFER_BIT);

	/* FBO(middle) -> WIN(top) back to verify WIN -> FBO */
	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, piglit_winsys_fbo);
	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
	copy(x0, y1, x0 + SIZE, y1 + SIZE,
	     x0, y2, x0 + SIZE, y2 + SIZE,
	     GL_DEPTH_BUFFER_BIT);

	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);
	assert(glGetError() == 0);

	printf("Verify 1\n");
	pass = verify_depth_rect(PAD, y0, SIZE, SIZE) && pass;
	printf("Verify 2\n");
	pass = verify_depth_rect(PAD, y1, SIZE, SIZE) && pass;
	printf("Verify 3\n");
	pass = verify_depth_rect(PAD, y2, SIZE, SIZE) && pass;
	printf("Verify 4 (FBO)\n");
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
	pass = verify_depth_rect(PAD, y0, SIZE, SIZE) && pass;
	printf("Verify 5 (FBO)\n");
	pass = verify_depth_rect(PAD, y1, SIZE, SIZE) && pass;
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);
	assert(glGetError() == 0);

	piglit_present_results();

	return pass;
}
Example #3
0
		PlayState(Game* game) : m_game(game) {

			window_sub = Window::currentContext()->onResize.subscribe([=](const gecom::window_size_event &e) {
				if (e.size.w > 0 && e.size.h > 0) {
					make_fbo(e.size);
				}
				return false;
			});

			make_fbo(Window::currentContext()->size());

			m_scene = new Scene2D();
			last_update = gecom::really_high_resolution_clock().now();

			gecom::image img_bg(gecom::image::type_png(), "./res/textures/bg.png", true);

			glGenTextures(1, &m_tex_bg);
			glBindTexture(GL_TEXTURE_2D, m_tex_bg);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, img_bg.width(), img_bg.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, img_bg.data());
			glGenerateMipmap(GL_TEXTURE_2D);

			world = game->getGCM().get<Box2DGameComponent>()->addWorld(i3d::vec3d(0.0, -20.0, 0.0));

			player = std::make_shared<PlayerEntity>(world);

			m_scene->add(player);
			player->setPosition(player->getPosition() + i3d::vec3d::j() * 64);

			auto drone = std::make_shared<DroneEntity>(world, player);
			m_scene->add(drone);

			//box = std::make_shared<Entity>();
			//box->setPosition(i3d::vec3d(5, 50, 0));
			//box->addComponent<DrawableComponent>(std::make_shared<ProtagonistDrawable>(box));
			//box->addComponent<DrawableComponent>(std::make_shared<UnitSquare>(box, 1, 1.5));
			//player_phs = std::make_shared<B2PhysicsComponent>(box);
			//player_phs->registerWithWorld(world);
			//box->addComponent<B2PhysicsComponent>(player_phs);

			/*auto ground = std::make_shared<Entity>(world);
			ground->setPosition(i3d::vec3d(0, -20, 0));
			auto gphs = std::make_shared<B2PhysicsStatic>(ground, 200, 1);
			gphs->registerWithWorld(world);
			ground->addComponent<B2PhysicsComponent>(gphs);

			m_scene->add(ground);*/

			//shared_ptr<SteadyFocusCamera> cameraEntity(make_shared<SteadyFocusCamera>(player));
			auto cameraEntity = std::make_shared<SteadyFocusCamera>(world, player);
			m_scene->add(cameraEntity);

			auto camera = std::make_shared<Camera>(cameraEntity);
			//shared_ptr<Camera> camera(make_shared<Camera>(cameraEntity));
			m_scene->setCamera(camera);

			pxljm::LevelGenerator lg;
			auto level = lg.getTestLevel(world);
			level->load(*m_scene, world);
		}
Example #4
0
static GLboolean
run_test(void)
{
	GLboolean pass = GL_TRUE;
	GLuint fbo;
	int fbo_width = FBO_SIZE;
	int fbo_height = FBO_SIZE;
	int x0 = PAD;
	int y0 = PAD;
	int y1 = PAD * 2 + SIZE;
	int y2 = PAD * 3 + SIZE * 2;

	glViewport(0, 0, piglit_width, piglit_height);
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glClearColor(0.5, 0.5, 0.5, 0.5);
	glClear(GL_COLOR_BUFFER_BIT);

	/* Draw the color rect in the window system window */
	draw_color_rect(x0, y0, SIZE, SIZE);

	fbo = make_fbo(fbo_width, fbo_height);

	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
	glViewport(0, 0, fbo_width, fbo_height);
	piglit_ortho_projection(fbo_width, fbo_height, GL_FALSE);
	glClearColor(1.0, 0.0, 1.0, 0.0);
	glClear(GL_COLOR_BUFFER_BIT);

	/* Draw the color rect in the FBO */
	draw_color_rect(x0, y0, SIZE, SIZE);

	/* Now that we have correct samples, blit things around.
	 * FBO(bottom) -> WIN(middle)
	 */
	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
 	copy(x0, y0, x0 + SIZE, y0 + SIZE,
 	     x0, y1, x0 + SIZE, y1 + SIZE);

	/* WIN(bottom) -> FBO(middle) */
	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
 	copy(x0, y0, x0 + SIZE, y0 + SIZE,
 	     x0, y1, x0 + SIZE, y1 + SIZE);

	/* FBO(middle) -> WIN(top) back to verify WIN -> FBO */
	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo);
 	copy(x0, y1, x0 + SIZE, y1 + SIZE,
 	     x0, y2, x0 + SIZE, y2 + SIZE);

	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

	pass = verify_color_rect(PAD, y0, SIZE, SIZE) && pass;
	pass = verify_color_rect(PAD, y1, SIZE, SIZE) && pass;
	pass = verify_color_rect(PAD, y2, SIZE, SIZE) && pass;
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
	pass = verify_color_rect(PAD, y0, SIZE, SIZE) && pass;
	pass = verify_color_rect(PAD, y1, SIZE, SIZE) && pass;
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

	glutSwapBuffers();

	return pass;
}
enum piglit_result
piglit_display(void)
{
	GLboolean pass = GL_TRUE;
	GLuint fbo, tex, pbo;
	uint32_t *addr;

	make_fbo(&fbo, &tex);

	glClear(GL_COLOR_BUFFER_BIT);

	glGenBuffersARB(1, &pbo);
	glBindBufferARB(GL_PIXEL_PACK_BUFFER, pbo);
	glBufferDataARB(GL_PIXEL_PACK_BUFFER, 4 * 4, NULL, GL_STREAM_DRAW_ARB);
	glPixelStorei(GL_PACK_ALIGNMENT, 1);

	glViewport(0, 0, 2, 2);
	piglit_ortho_projection(2, 2, GL_FALSE);

	/* bottom: green.  top: blue. */
	glColor4f(0.0, 1.0, 0.0, 0.0);
	piglit_draw_rect(0, 0, 2, 1);
	glColor4f(0.0, 0.0, 1.0, 0.0);
	piglit_draw_rect(0, 1, 2, 1);

	/* Read the whole buffer. */
	glReadPixels(0, 0, 2, 2,
		     GL_BGRA, GL_UNSIGNED_BYTE, (void *)(uintptr_t)0);
	addr = glMapBufferARB(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY_ARB);
	pass &= probe(0, 0, 0x0000ff00, addr[0]);
	pass &= probe(1, 0, 0x0000ff00, addr[1]);
	pass &= probe(0, 1, 0x000000ff, addr[2]);
	pass &= probe(1, 1, 0x000000ff, addr[3]);
	glUnmapBufferARB(GL_PIXEL_PACK_BUFFER);

	/* Read with an offset. */
	glReadPixels(1, 0, 1, 1,
		     GL_BGRA, GL_UNSIGNED_BYTE, (void *)(uintptr_t)4);
	addr = glMapBufferARB(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY_ARB);
	pass &= probe(1, 0, 0x0000ff00, addr[1]);
	glUnmapBufferARB(GL_PIXEL_PACK_BUFFER);

	/* Read with an offset. */
	glReadPixels(1, 1, 1, 1,
		     GL_BGRA, GL_UNSIGNED_BYTE, (void *)(uintptr_t)4);
	addr = glMapBufferARB(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY_ARB);
	pass &= probe(1, 1, 0x000000ff, addr[1]);
	glUnmapBufferARB(GL_PIXEL_PACK_BUFFER);

	glDeleteBuffersARB(1, &pbo);

	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

	glViewport(0, 0, piglit_width, piglit_height);
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glBindTexture(GL_TEXTURE_2D, tex);
	glEnable(GL_TEXTURE_2D);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	piglit_draw_rect_tex(0, 0, piglit_width, piglit_height,
			     0, 0, 1, 1);
	glDisable(GL_TEXTURE_2D);

	glDeleteFramebuffersEXT(1, &fbo);
	glDeleteTextures(1, &tex);

	glutSwapBuffers();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}