Ejemplo n.º 1
0
void display_render_io_process(struct s_vm* vm, t_display* display)
{
	t_v4	color_io_process;
	t_v4	color_ambient;
	t_v3	light_direction;
	t_mat4	local;
	t_mat4	translate;
	t_mat4	rotation;
	t_quat	quat;
	int		i;

	v4_set(&color_io_process, 0.4f, 0.4f, 1.0f, 0.0f);
	v4_set(&color_ambient, 0.2f, 0.2f, 0.2f, 1.0f);
	v3_set(&light_direction, 0, 0, -1.0f);


	display_mesh_render_start(display->mesh_renderer, MESH_TYPE_VN);
	display_mesh_set_ambient(display->mesh_renderer, &color_ambient);
	display_mesh_set_light_direction(display->mesh_renderer, &light_direction);
	display_mesh_set_diffuse(display->mesh_renderer, &color_io_process);
	display_mesh_set_projection(display->mesh_renderer, &display->projection_view);
	mat4_ident(&local);

	for (i = 0; i < vm->process_count; ++i)
	{
		t_process* process = vm->processes[i];
		float angle = (float)process->cycle_create + (float)display->frame_last_time ;

		int index = process->pc;
		float x = (float) (index % display->memory_stride);
		float y = (float) (index / display->memory_stride);

		x = x * DISPLAY_CELL_SIZE + DISPLAY_CELL_SIZE * 0.5f;
		y = y * DISPLAY_CELL_SIZE + DISPLAY_CELL_SIZE * 0.5f;

		mat4_ident(&translate);
		mat4_translate(&translate, x, y, DISPLAY_CELL_SIZE * 0.5f);

		quat_from_euler(&quat, angle, angle, angle);
		quat_to_mat4(&quat, &rotation);

		mat4_mul(&translate, &rotation, &local);

		display_mesh_set_local(display->mesh_renderer, &local);

		display_mesh_render(display->process_mesh);
	}
}
Ejemplo n.º 2
0
void display_step(struct s_vm* vm, t_display* display)
{
	t_mat4 screen;

	glfwGetFramebufferSize(display->window, &display->frame_buffer_width, &display->frame_buffer_height);
	display->frame_buffer_ratio =
	(float)display->frame_buffer_width / (float)display->frame_buffer_height;

	mat4_ident(&screen);
	mat4_ortho(&screen, 0.0f,
		(float)display->frame_buffer_width * 0.25f,
		(float)display->frame_buffer_height * 0.25f,
		0.0f, -100.0f, 100.0f);
	display_update_camera(display);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glViewport(0, 0, display->frame_buffer_width, display->frame_buffer_height);
	glEnable(GL_BLEND);
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	display_render_memory(vm, display);

	display_render_io_read(vm, display);
	display_render_io_write(vm, display);
	glDisable(GL_BLEND);
	display_render_io_process(vm, display);
	glEnable(GL_BLEND);
	// display_text_render(display->texts, &screen);
	// display_text_clear(display->texts);
	glfwSwapBuffers(display->window);
	glfwPollEvents();

}
Ejemplo n.º 3
0
void display_gl_jump_render(struct vm_s* vm, struct display_gl_s* display) {
	v4_t	color_diffuse;
	v4_t	color_ambient;
	mat4_t	local;
	mesh_definition_t* 	def = display_gl_mesh_get_definiton(MESH_TYPE_VC);
	int32 						 	vertices_count;


	v4_set(&color_diffuse, 1.f, 1.f, 1.0f, 1.0f);
	v4_set(&color_ambient, 0.0f, 0.0f, 0.0f, 0.0f);
	mat4_ident(&local);

	display_gl_generate_line_count(&vertices_count);
	if (display->jump_count > 0) {
		glDisable(GL_DEPTH_TEST);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE);

		glBindBuffer(GL_ARRAY_BUFFER, display_gl_mesh_get_vb(display->jump_mesh));
		glBufferSubData(GL_ARRAY_BUFFER, 0, display->jump_count * def->stride * vertices_count, display->jump_vertex_buffer);
		glBindBuffer(GL_ARRAY_BUFFER, 0);
		display_gl_mesh_render_start(display->mesh_renderer, MESH_TYPE_VC);
		display_gl_mesh_set_ambient(display->mesh_renderer, &color_ambient);
		display_gl_mesh_set_diffuse(display->mesh_renderer, &color_diffuse);
		display_gl_mesh_set_local(display->mesh_renderer, &local);
		display_gl_mesh_set_projection(display->mesh_renderer, &display->projection_view);
		display_gl_mesh_render_count(display->jump_mesh, display->jump_count * vertices_count);
	}
}
Ejemplo n.º 4
0
void			display_gl_text_render(display_gl_text_t* texts, mat4_t* projection_view)
{
	int32 i;
	int32 vb_index = 0;
	v4_t	color_diffuse;
	v4_t	color_ambient;
	mat4_t	local;
	v4_set(&color_diffuse, 1.f, 1.f, 1.0f, 1.0f);
	v4_set(&color_ambient, 0.0f, 0.0f, 0.0f, 0.0f);
	mat4_ident(&local);

	for (i = 0; i < texts->text_count; ++i)
	{
		t_text* text = &(texts->texts[i]);

		vb_index += stb_easy_font_print(text->position.x,
			text->position.y,
			text->text,
			(uint8*)&text->rgba,
			texts->text_mesh_vb + vb_index,
			texts->text_mesh_vb_size) * 64;
	}
	glDisable(GL_DEPTH_TEST);
	glBindBuffer(GL_ARRAY_BUFFER, display_gl_mesh_get_vb(texts->text_mesh));
	glBufferSubData(GL_ARRAY_BUFFER, 0, vb_index, texts->text_mesh_vb);

	display_gl_mesh_render_start(texts->text_renderer, MESH_TYPE_VC);
	display_gl_mesh_set_ambient(texts->text_renderer, &color_ambient);
	display_gl_mesh_set_diffuse(texts->text_renderer, &color_diffuse);
	display_gl_mesh_set_projection(texts->text_renderer, projection_view);
	display_gl_mesh_set_local(texts->text_renderer, &local);
	display_gl_mesh_render_count(texts->text_mesh, (vb_index / 64) * 6);
}
Ejemplo n.º 5
0
t_mat4			mat4_view_lookat(t_vec3 eye, t_vec3 targ, t_vec3 up)
{
	t_mat4		out;
	t_vec3		zaxis;
	t_vec3		xaxis;
	t_vec3		yaxis;

	zaxis = vec3_normal(vec3_sub(eye, targ));
	xaxis = vec3_normal(vec3_cross(up, zaxis));
	yaxis = vec3_cross(zaxis, xaxis);
	out = mat4_ident();
	out.m[0] = xaxis.x;
	out.m[1] = yaxis.x;
	out.m[2] = zaxis.x;
	out.m[4] = xaxis.y;
	out.m[5] = yaxis.y;
	out.m[6] = zaxis.y;
	out.m[8] = xaxis.z;
	out.m[9] = yaxis.z;
	out.m[10] = zaxis.z;
	out.m[12] = -vec3_dot(xaxis, eye);
	out.m[13] = -vec3_dot(yaxis, eye);
	out.m[14] = -vec3_dot(zaxis, eye);
	return (out);
}
Ejemplo n.º 6
0
void display_update_camera(t_display* display)
{
	float width = display->frame_buffer_width  * display->display_zoom * 0.5f;
	float height = display->frame_buffer_height * display->display_zoom * 0.5f;

	mat4_ident(&display->projection_view);

	mat4_ortho(&display->projection_view,
		display->display_center_x - width,
		display->display_center_x + width,
		display->display_center_y + height,
		display->display_center_y - height,
		0.0f, 100.0f);
}