Esempio n. 1
0
void display()
{
	{
		// Compute the MVP (Model View Projection matrix)
		float Aspect = (Window.Size.x * 0.50f) / (Window.Size.y * 0.50f);
		glm::mat4 Projection = glm::perspective(45.0f, Aspect, 0.1f, 100.0f);
		glm::mat4 ViewTranslateZ = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Window.TranlationCurrent.y));
		glm::mat4 ViewRotateX = glm::rotate(ViewTranslateZ, Window.RotationCurrent.y, glm::vec3(1.f, 0.f, 0.f));
		glm::mat4 ViewRotateY = glm::rotate(ViewRotateX, Window.RotationCurrent.x, glm::vec3(0.f, 1.f, 0.f));
		glm::mat4 View = ViewRotateY;
		glm::mat4 Model = glm::mat4(1.0f);
		glm::mat4 MVP = Projection * View * Model;

		*UniformPointer = MVP;
	}

	glFlushMappedBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(glm::mat4));

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);

	glViewportIndexedf(0, 0, 0, GLfloat(Window.Size.x), GLfloat(Window.Size.y));

	glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
	float Depth(1.0f);
    glm::u8vec4 ColorClear(255, 127, 0, 255);
    glm::u8vec4 ColorTex(0, 127, 255, 255);
	glClearBufferfv(GL_DEPTH , 0, &Depth);
	glClearTexImage(TextureName[texture::COLORBUFFER], 0, 
		GL_RGBA, GL_UNSIGNED_BYTE, &ColorClear);
	glClearTexSubImage(TextureName[texture::COLORBUFFER], 0, 
		64, 64, 0,
		64, 64, 1,
		GL_RGBA, GL_UNSIGNED_BYTE, &ColorTex);
	glClearTexSubImage(TextureName[texture::COLORBUFFER], 0, 
		256, 0, 0,
		64, 64, 1,
		GL_RGBA, GL_UNSIGNED_BYTE, &ColorTex);
	glClearTexSubImage(TextureName[texture::COLORBUFFER], 0, 
		128, 384, 0,
		64, 64, 1,
		GL_RGBA, GL_UNSIGNED_BYTE, &ColorTex);
	glClearTexSubImage(TextureName[texture::COLORBUFFER], 0, 
		512, 256, 0,
		64, 64, 1,
		GL_RGBA, GL_UNSIGNED_BYTE, &ColorTex);


	// Bind rendering objects
	glBindProgramPipeline(PipelineName[pipeline::TEXTURE]);
	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, TextureName[texture::DIFFUSE]);
	glBindVertexArray(VertexArrayName[pipeline::TEXTURE]);
	glBindVertexBuffer(glf::semantic::buffer::STATIC, BufferName[buffer::VERTEX], 0, GLsizei(sizeof(glf::vertex_v2fv2f)));
	glBindBufferBase(GL_UNIFORM_BUFFER, glf::semantic::uniform::TRANSFORM0, BufferName[buffer::TRANSFORM]);

	glDrawElementsInstancedBaseVertexBaseInstance(
		GL_TRIANGLES, ElementCount, GL_UNSIGNED_SHORT, 0, 2, 0, 0);

	glDisable(GL_DEPTH_TEST);

	glBindFramebuffer(GL_FRAMEBUFFER, 0);

	glBindProgramPipeline(PipelineName[pipeline::SPLASH]);
	glActiveTexture(GL_TEXTURE0);
	glBindVertexArray(VertexArrayName[pipeline::SPLASH]);
	glBindTexture(GL_TEXTURE_2D, TextureName[texture::COLORBUFFER]);

	glDrawArraysInstanced(GL_TRIANGLES, 0, 3, 1);

	glf::swapBuffers();
}
Esempio n. 2
0
CRender::CRender(uint uiInstIdx):
CInstancedObj(uiInstIdx)
{
	_pCoreRenderer = Core()->pCoreRenderer();

	Console()->RegComProc("rnd_list_features", "Prints list of features supported by current Core Renderer implementation.", &_s_ConListFeatures, (void*)this);

	bool b_supported;

	_strFeturesList = "Core Renderer supported features\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_BUILTIN_FULLSCREEN_MODE, b_supported);
	_strFeturesList += std::string("Builtin fullscreen mode: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_BUILTIN_STATE_FILTER, b_supported);
	_strFeturesList += std::string("Builtin state filter: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_MULTISAMPLING, b_supported);
	_strFeturesList += std::string("Multisampling: ") + (b_supported ? "Yes" : "No") + "\n\t";
	
	_pCoreRenderer->IsFeatureSupported(CRFT_VSYNC, b_supported);
	_strFeturesList += std::string("Vertical synchronization: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_PROGRAMMABLE_PIPELINE, b_supported);
	_strFeturesList += std::string("Programmable pipeline: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_LEGACY_FIXED_FUNCTION_PIPELINE_API, b_supported);
	_strFeturesList += std::string("Legacy fixed function pipeline API: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_BGRA_DATA_FORMAT, b_supported);
	_strFeturesList += std::string("BGRA textures: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_TEXTURE_COMPRESSION, b_supported);
	_strFeturesList += std::string("Texture compression: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_NON_POWER_OF_TWO_TEXTURES, b_supported);
	_strFeturesList += std::string("Non power of two textures: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_DEPTH_TEXTURES, b_supported);
	_strFeturesList += std::string("Depth textures: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_TEXTURE_ANISOTROPY, b_supported);
	_strFeturesList += std::string("Texture anisotropy: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_TEXTURE_MIPMAP_GENERATION, b_supported);
	_strFeturesList += std::string("Hardware mipmap generation: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_TEXTURE_MIRRORED_REPEAT, b_supported);
	_strFeturesList += std::string("Texture mirrored repeat: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_TEXTURE_MIRROR_CLAMP, b_supported);
	_strFeturesList += std::string("Texture mirror clamp: ") + (b_supported ? "Yes" : "No") + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_GEOMETRY_BUFFER, b_supported);
	_strFeturesList += std::string("Hardware geometry buffers: ") + (b_supported ? "Yes" : "No") + "\n\t";;
	
	_pCoreRenderer->IsFeatureSupported(CRFT_FRAME_BUFFER, b_supported);
	_strFeturesList += std::string("Hardware frame buffers: ") + (b_supported ? "Yes" : "No");

	// Don't append "\n\t" to the last line!
	assert(_strFeturesList[_strFeturesList.length() - 2] != '\n' && _strFeturesList[_strFeturesList.length() - 1] != '\t');

	LOG(_strFeturesList, LT_INFO);

	for (size_t i = 0; i < _strFeturesList.size(); ++i)
		if (_strFeturesList[i] == '\t')
			_strFeturesList[i] = ' ';

	_strMetricsList = "Core Renderer device metrics\n\t";

	int i_value;

	_pCoreRenderer->GetDeviceMetric(CRMT_MAX_TEXTURE_RESOLUTION, i_value);
	_strMetricsList += "Maximum texture resolution: " + IntToStr(i_value) + "X" + IntToStr(i_value) + "\n\t";

	_pCoreRenderer->IsFeatureSupported(CRFT_TEXTURE_ANISOTROPY, b_supported);
	if (b_supported)
	{
		_pCoreRenderer->GetDeviceMetric(CRMT_MAX_ANISOTROPY_LEVEL, i_value);
		_strMetricsList += "Maximum anisotropy level: " + IntToStr(i_value) + "X\n\t";
	}

	_pCoreRenderer->GetDeviceMetric(CRMT_MAX_TEXTURE_LAYERS, i_value);
	_strMetricsList += "Maximum multitexturing layer: " + IntToStr(i_value);

	// Don't append "\n\t" to the last line!
	assert(_strMetricsList[_strMetricsList.length() - 2] != '\n' && _strMetricsList[_strMetricsList.length() - 1] != '\t');

	LOG(_strMetricsList, LT_INFO);

	for (size_t i = 0; i < _strMetricsList.size(); ++i)
		if (_strMetricsList[i] == '\t')
			_strMetricsList[i] = ' ';

	SetClearColor(ColorClear());

	_pRender2D = new CRender2D(InstIdx());
	_pRender3D = new CRender3D(InstIdx());

	LOG("Render subsystem initialized.", LT_INFO);
}