Example #1
0
	window::window(int w, int h, int cmdShow) : width(w), height(h), nCmdShow(cmdShow), a(255) {
		LARGE_INTEGER lpFrequency;
		QueryPerformanceFrequency(&lpFrequency);
		pcFrequency = static_cast<double>(lpFrequency.QuadPart);
		min_frame_length = 0.0;
		frame_rate = 0.0;
		load_identity();
		yume_register_window();
		hwnd = CreateWindowEx(0, L"yumewindow", L"хдв Software Renderer", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width, height, nullptr, nullptr, GetModuleHandle(nullptr), this);
		if (hwnd == nullptr) {
			panic(L"Couldn't create window.", nullptr);
		}
	}
Example #2
0
void draw_objects(simulation_t *simulation, buffer_t *buffer, shader_t *shader, GLfloat camera[16]) {
    GLfloat modelview[16];
    for (unsigned int i = 0; i < simulation->count; i++) {
        particle_t particle = simulation->src_buf[i];
        vec3f p = particle.position;
        load_identity(modelview);
        translate(modelview, p.x, p.y, p.z);
        scale(modelview, particle.radius, particle.radius, particle.radius);
        multiply_matrix(modelview, camera, modelview);
        set_matrix(shader, MODELVIEW_MATRIX, modelview);
        glColor3f(particle.r, particle.g, particle.b);
        draw_vbo(buffer);
    }
}
Example #3
0
static int
draw_init(struct render_command * __rcmd)
{
	struct rcmd_draw * rcmd =
		container_of(__rcmd, struct rcmd_draw, base);
	FORCE(SYSTEM, "Draw init\n");

	rcmd->vertex_shader = compile_shader(GL_VERTEX_SHADER,
			sizeof(vertex_shader) / sizeof(char*), vertex_shader);
	rcmd->fragment_shader = compile_shader(GL_FRAGMENT_SHADER,
			sizeof(fragment_shader) / sizeof(char*), fragment_shader);
	rcmd->program = init_program(
			rcmd->vertex_shader,
			rcmd->fragment_shader);

	GL_POP_ERROR();
	rcmd->idx_mv = glGetUniformLocation(rcmd->program, "iModelView");
	GL_POP_ERROR();
	rcmd->idx_tex = glGetUniformLocation(rcmd->program, "inTex");
	GL_POP_ERROR();
	rcmd->idx_position = glGetAttribLocation(rcmd->program, "iPosition");
	GL_POP_ERROR();
	rcmd->idx_texcoord = glGetAttribLocation(rcmd->program, "texCoord");
	GL_POP_ERROR();

//	rcmd->idx_color = glGetAttribLocation(rcmd->program, "iColor");
//	GL_POP_ERROR();
//	glVertexAttrib3f(rcmd->idx_color, 1.0f, 0.0f, 0.1f);
//	GL_POP_ERROR();

	load_identity(&rcmd->modelview);


	glGenBuffers(1, &rcmd->buffer);
	glBindBuffer(GL_ARRAY_BUFFER, rcmd->buffer);

	const GLfloat varray[] = {
		0.0, 0.0, 0.0, 0.0, 0.0,
		0.0, 1.0, 0.0, 0.0, 1.0,
		1.0, 1.0, 0.0, 1.0, 1.0,
		1.0, 0.0, 0.0, 1.0, 0.0,

		0.0, 0.0, 0.0, 0.0, 0.0,
		0.0, 1.0, 0.0, 0.0, 1.0,
		1.0, 1.0, 1.0, 1.0, 1.0,
		1.0, 0.0, 1.0, 1.0, 0.0,
	};

	glBufferData(GL_ARRAY_BUFFER, sizeof(varray), varray, GL_STATIC_DRAW);

	GL_POP_ERROR();

	res_id_t texres;
	char * fn = "common/rgb.png";
	texres = (uint64_t)(uint32_t)fn;
	struct rectangle rect = {
		0, 0, 64, 64
	};

	struct texture_params params = TEXTURE_PARAM_INIT;
	params.pin = TRUE;

	rcmd->tex = texgl_create(texres, rect, &params, NULL);
	GL_POP_ERROR();

	WARNING(SYSTEM, "tex->bitmap=%p\n", rcmd->tex->base.bitmap);
	if (rcmd->tex->base.bitmap != NULL)
		WARNING(SYSTEM, "tex->bitmap.refcount=%d\n", rcmd->tex->base.bitmap->base.ref_count);


	res_id_t texres2;
	char * fn2 = "common/rgb.png";
	texres2 = (uint64_t)(uint32_t)fn2;
	struct rectangle rect2 = {
		0, 0, 64, 64
	};
	struct texture_params params2 = TEXTURE_PARAM_INIT;
	struct texture_gl_params gl_params = TEXTURE_GL_PARAM_INIT;
	gl_params.mag_filter = GL_NEAREST;
	gl_params.min_filter = GL_NEAREST;
	rcmd->tex2 = texgl_create(texres, rect2, &params, &gl_params);
	GL_POP_ERROR();
	WARNING(SYSTEM, "tex2->bitmap=%p\n", rcmd->tex2->base.bitmap);
	if (rcmd->tex2->base.bitmap != NULL)
		WARNING(SYSTEM, "tex2->bitmap.refcount=%d\n", rcmd->tex2->base.bitmap->base.ref_count);
	return 0;
}