Пример #1
0
void opengl_impl::resize(int w, int h) {
	gl_viewport(0, 0, w, h);
	gl_matrix_mode(GL_PROJECTION);
	gl_load_identity();
	gl_ortho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);
	gl_matrix_mode(GL_MODELVIEW);
	gl_load_identity();
}
Пример #2
0
Файл: ctx.c Проект: cloudhead/px
void ctx_present(struct context *ctx)
{
	glBindFramebuffer(GL_FRAMEBUFFER, 0);

	gl_viewport(ctx->winw, ctx->winh);
	gl_clear(0.f, 0.f, 0.f, 1.f);

	if (ctx->hidpi)
		ctx_scale(ctx, 2, 2);

	framebuffer_draw(ctx->screen, ctx);
	glfwSwapBuffers(ctx->win);
}
Пример #3
0
    void render_target::end(ui8* data)
    {
        if(data)
        {
#if defined(__PBO__)
            
            glReadBuffer(GL_COLOR_ATTACHMENT0);
            gl_bind_buffer(GL_PIXEL_PACK_BUFFER, m_pixel_buffer);
            glReadPixels(0, 0, m_size.x, m_size.y, m_format, GL_UNSIGNED_BYTE, NULL);
            
            ui8* pointer = static_cast<ui8*>(glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY));
            if (pointer)
            {
                ui32 size = m_size.x * m_size.y;
                if(m_format == GL_RGBA)
                {
                    size *= 4;
                }
                else if(m_format == GL_RGB)
                {
                    size *= 3;
                }
                
                memcpy(data, pointer, size);
                glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
            }
            
#else
            
            glReadPixels(0, 0, m_size.x, m_size.y, m_format, GL_UNSIGNED_BYTE, data);
            
            
#endif
        }
        
        assert(m_graphics_context != nullptr);
        
        gl_bind_frame_buffer(GL_FRAMEBUFFER, m_graphics_context->get_frame_buffer());
        gl_viewport(0, 0, m_graphics_context->get_width(), m_graphics_context->get_height());
    }
Пример #4
0
 void render_technique_ss::bind(void)
 {
     gl_bind_frame_buffer(GL_FRAMEBUFFER, m_frame_buffer);
     gl_viewport(0, 0, m_frame_width, m_frame_height);
     
     gl_disable(GL_DEPTH_TEST);
     material::get_cached_parameters()->m_is_depth_test = false;
     gl_depth_mask(GL_FALSE);
     material::get_cached_parameters()->m_is_depth_mask = false;
     gl_disable(GL_STENCIL_TEST);
     material::get_cached_parameters()->m_is_stencil_test = false;
     
     gl_clear_color(m_clear_color.r, m_clear_color.g, m_clear_color.b, m_clear_color.a);
     gl_clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
     if(m_material->get_shader()->is_loaded() &&
        m_material->get_shader()->is_commited())
     {
         m_material->bind();
         m_quad->bind(m_material->get_shader()->get_guid(), m_material->get_shader()->get_attributes());
     }
 }
Пример #5
0
Файл: ctx.c Проект: cloudhead/px
static void framebuffer_size_callback(GLFWwindow *win, int w, int h)
{
	struct context *ctx = glfwGetWindowUserPointer(win);

	infof("ctx", "resizing context to %dx%d", w, h);

	framebuffer_free(ctx->screen);

	ctx->width   = ctx->hidpi ? w / 2 : w;
	ctx->height  = ctx->hidpi ? h / 2 : h;
	ctx->screen  = framebuffer_screen(ctx->width, ctx->height, NULL);
	ctx->winw    = w;
	ctx->winh    = h;
	ctx->ortho   = mat4ortho(w, h);

	gl_viewport(w, h);

	ctx_setup_ortho(ctx);
	ctx_update_cursor_pos(ctx);

	if (ctx->on_resize)
		ctx->on_resize(ctx, ctx->width, ctx->height);
}
Пример #6
0
/**
 * @brief Resets viewport to default
 */
void gl_defViewport (void)
{
   gl_viewport( gl_view_x, gl_view_y, gl_view_w, gl_view_h );
}
Пример #7
0
 void render_target::begin()
 {
     gl_bind_frame_buffer(GL_FRAMEBUFFER, m_frame_buffer);
     gl_viewport(0, 0, m_size.x, m_size.y);
 }