本文整理汇总了C++中GGLContext::blendFunc方法的典型用法代码示例。如果您正苦于以下问题:C++ GGLContext::blendFunc方法的具体用法?C++ GGLContext::blendFunc怎么用?C++ GGLContext::blendFunc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GGLContext
的用法示例。
在下文中一共展示了GGLContext::blendFunc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gr_init
int gr_init(void)
{
gglInit(&gr_context);
GGLContext *gl = gr_context;
gr_init_font();
gr_vt_fd = open("/dev/tty0", O_RDWR | O_SYNC);
if (gr_vt_fd < 0) {
// This is non-fatal; post-Cupcake kernels don't have tty0.
} else if (ioctl(gr_vt_fd, KDSETMODE, (void*) KD_GRAPHICS)) {
// However, if we do open tty0, we expect the ioctl to work.
perror("failed KDSETMODE to KD_GRAPHICS on tty0");
gr_exit();
return -1;
}
gr_fb_fd = get_framebuffer(gr_framebuffer);
if (gr_fb_fd < 0) {
perror("Unable to get framebuffer.\n");
gr_exit();
return -1;
}
get_memory_surface(&gr_mem_surface);
fprintf(stderr, "framebuffer: fd %d (%d x %d)\n",
gr_fb_fd, gr_framebuffer[0].width, gr_framebuffer[0].height);
/* start with 0 as front (displayed) and 1 as back (drawing) */
gr_active_fb = 0;
if (!has_overlay)
set_active_framebuffer(0);
gl->colorBuffer(gl, &gr_mem_surface);
gl->activeTexture(gl, 0);
gl->enable(gl, GGL_BLEND);
gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA);
#ifdef TW_SCREEN_BLANK_ON_BOOT
printf("TW_SCREEN_BLANK_ON_BOOT := true\n");
gr_fb_blank(true);
gr_fb_blank(false);
#endif
if (!alloc_ion_mem(fi.line_length * vi.yres))
allocate_overlay(gr_fb_fd, gr_framebuffer);
return 0;
}
示例2: gr_init
int gr_init(void)
{
GGLContext *gl;
int fd;
gglInit(&gr_context);
gl = gr_context;
gr_init_font();
fd = open("/dev/tty0", O_RDWR | O_SYNC);
if(fd < 0) return -1;
if(ioctl(fd, KDSETMODE, (void*) KD_GRAPHICS)) {
close(fd);
return -1;
}
gr_fb_fd = get_framebuffer(gr_framebuffer);
if(gr_fb_fd < 0) {
ioctl(fd, KDSETMODE, (void*) KD_TEXT);
close(fd);
return -1;
}
gr_vt_fd = fd;
/* start with 0 as front (displayed) and 1 as back (drawing) */
gr_active_fb = 0;
set_active_framebuffer(0);
gl->colorBuffer(gl, gr_framebuffer + 1);
gl->activeTexture(gl, 0);
gl->enable(gl, GGL_BLEND);
gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA);
return 0;
}
示例3: res_scale_surface
// Scale image function
int res_scale_surface(gr_surface source, gr_surface* destination, float scale_w, float scale_h) {
GGLContext *gl = NULL;
GGLSurface* sc_mem_surface = NULL;
*destination = NULL;
GGLSurface *surface = (GGLSurface*)source;
int w = gr_get_width(source), h = gr_get_height(source);
int sx = 0, sy = 0, dx = 0, dy = 0;
float dw = (float)w * scale_w;
float dh = (float)h * scale_h;
// Create a new surface that is the appropriate size
sc_mem_surface = init_display_surface((int)dw, (int)dh);
if (!sc_mem_surface) {
printf("gr_scale_surface failed to init_display_surface\n");
return -1;
}
sc_mem_surface->format = surface->format;
// Initialize the context
gglInit(&gl);
gl->colorBuffer(gl, sc_mem_surface);
gl->activeTexture(gl, 0);
// Enable or disable blending based on source surface format
if (surface->format == GGL_PIXEL_FORMAT_RGBX_8888) {
gl->disable(gl, GGL_BLEND);
} else {
gl->enable(gl, GGL_BLEND);
gl->blendFunc(gl, GGL_ONE, GGL_ZERO);
}
// Bind our source surface to the context
gl->bindTexture(gl, surface);
// Deal with the scaling
gl->texParameteri(gl, GGL_TEXTURE_2D, GGL_TEXTURE_MIN_FILTER, GGL_LINEAR);
gl->texParameteri(gl, GGL_TEXTURE_2D, GGL_TEXTURE_MAG_FILTER, GGL_LINEAR);
gl->texParameteri(gl, GGL_TEXTURE_2D, GGL_TEXTURE_WRAP_S, GGL_CLAMP);
gl->texParameteri(gl, GGL_TEXTURE_2D, GGL_TEXTURE_WRAP_T, GGL_CLAMP);
gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE);
gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_AUTOMATIC);
gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_AUTOMATIC);
gl->enable(gl, GGL_TEXTURE_2D);
int32_t grad[8];
memset(grad, 0, sizeof(grad));
// s, dsdx, dsdy, scale, t, dtdx, dtdy, tscale <- this is wrong!
// This api uses block floating-point for S and T texture coordinates.
// All values are given in 16.16, scaled by 'scale'. In other words,
// set scale to 0, for 16.16 values.
// s, dsdx, dsdy, t, dtdx, dtdy, sscale, tscale
float dsdx = (float)w / dw;
float dtdy = (float)h / dh;
grad[0] = ((float)sx - (dsdx * dx)) * 65536;
grad[1] = dsdx * 65536;
grad[3] = ((float)sy - (dtdy * dy)) * 65536;
grad[5] = dtdy * 65536;
// printf("blit: w=%d h=%d dx=%d dy=%d dw=%f dh=%f dsdx=%f dtdy=%f s0=%x dsdx=%x t0=%x dtdy=%x\n",
// w, h, dx, dy, dw, dh, dsdx, dtdy, grad[0], grad[1], grad[3], grad[5]);
gl->texCoordGradScale8xv(gl, 0 /*tmu*/, grad);
// draw / scale the source surface to our target context
gl->recti(gl, dx, dy, dx + dw, dy + dh);
gglUninit(gl);
gl = NULL;
// put the scaled surface in our destination
*destination = (gr_surface*) sc_mem_surface;
// free memory used in the source
res_free_surface(source);
source = NULL;
return 0;
}