예제 #1
0
void PS3Graphics::SetAspectRatio(bool keep_aspect)
{
	if (keep_aspect)
		m_ratio = SCREEN_4_3_ASPECT_RATIO;
	else
		m_ratio = SCREEN_16_9_ASPECT_RATIO;
	SetViewports();
}
예제 #2
0
D3DContext::D3DContext(ApplicationWindow* targetWindow, const Description& description)
    : mTargetWindow(targetWindow)
{
    if (!CreateDeviceAndSwapChain(description))
        throw std::runtime_error("Failed to create device and swap chain");
    if (!CreateBackBufferView())
        throw std::runtime_error("Failed to create a back buffer view");
    if (!CreateDepthStencilBuffer(description.DepthBuffer))
        throw std::runtime_error("Failed to create a depth/stencil buffer");

    mDevice->OMSetRenderTargets(1, &mBackBufferView, mDepthStencilView);

    SetViewports(description.Viewports);
    SetActiveViewport(0);
}
예제 #3
0
	D3DWrapper::D3DWrapper(Window* targetWindow, const Description& description)
		: m_targetWindow(targetWindow)
	{
		HRESULT result = S_OK;

		m_targetWindow->AddEventListener(this);

		result = CreateDeviceAndSwapChain(description.m_displayMode, description.m_fullscreen);
		if (FAILED(result))
			throw DirectXErrorM(result, "Failed to create device and swap chain");

		result = CreateBackBufferView();
		if (FAILED(result))
			throw DirectXErrorM(result, "Failed to create back buffer view");

		result = CreateDepthStencilBuffer(description.m_displayMode.m_width, description.m_displayMode.m_height);
		if (FAILED(result))
			throw DirectXErrorM(result, "Failed to create depth stencil buffer/view");

		m_deviceContext->OMSetRenderTargets(1, &m_backBufferView.Resource(), m_depthStencilView.Resource());

		SetViewports(description.m_viewports);
	}
예제 #4
0
void PS3Graphics::SetOverscan(bool will_overscan, float amount)
{
	m_overscan_amount = amount;
	m_overscan = will_overscan;
	SetViewports();
}
예제 #5
0
int32_t PS3Graphics::PSGLInit()
{
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_SCISSOR_TEST);
	glDisable(GL_CULL_FACE);
	glDisable(GL_LIGHTING);
	glDisable(GL_FOG);
	glDisable(GL_DITHER);
	glShadeModel(GL_FLAT);
	glEnable(GL_VSYNC_SCE);
	glEnable(GL_TEXTURE_2D);

	/*
	//glEnable(GL_BLEND);
	//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
	//glBlendColor(0, 0, 0, 0);
	//glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	 */

	context_width = SCREEN_RENDER_TEXTURE_WIDTH;
	context_height = SCREEN_RENDER_TEXTURE_HEIGHT;

	InitCg();

	SetViewports();

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glGenBuffers(2, vbo);

	glBindBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, vbo[0]);
	glBufferData(GL_TEXTURE_REFERENCE_BUFFER_SCE, SCREEN_RENDER_TEXTURE_HEIGHT * SCREEN_RENDER_TEXTURE_PITCH, NULL, GL_STREAM_DRAW);
	glTextureReferenceSCE(GL_TEXTURE_2D, 1, SCREEN_RENDER_TEXTURE_WIDTH, SCREEN_RENDER_TEXTURE_HEIGHT, 0, GL_RGB5_A1, SCREEN_RENDER_TEXTURE_PITCH, 0);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

	SetSmooth(m_smooth);

	// PSGL doesn't clear the screen on startup, so let's do that here.
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glColor4f(1.0, 1.0, 1.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);
	psglSwap();

	// Use some initial values for the screen quad.
	GLfloat vertexes[] = {
		0, 0, 0,
		0, 1, 0,
		1, 1, 0,
		1, 0, 0,
		0, 1,
		0, 0,
		1, 0,
		1, 1
	};

	GLfloat vertex_buf[128];
	__builtin_memcpy(vertex_buf, vertexes, 12 * sizeof(GLfloat));
	__builtin_memcpy(vertex_buf + 32, vertexes + 12, 8 * sizeof(GLfloat));
	__builtin_memcpy(vertex_buf + 32 * 3, vertexes + 12, 8 * sizeof(GLfloat));

	glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
	glBufferData(GL_ARRAY_BUFFER, 256, vertex_buf, GL_STATIC_DRAW);

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, 0);
	glTexCoordPointer(2, GL_FLOAT, 0, (void*)128);

	return CELL_OK;
}