赞 | 1 |
VIP | 357 |
好人卡 | 24 |
积分 | 1 |
经验 | 14896 |
最后登录 | 2022-12-23 |
在线时间 | 1641 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 66
- 在线时间
- 1641 小时
- 注册时间
- 2011-9-26
- 帖子
- 313
|
我意思是在帧缓存模式下把文字贴图render上去
SetClipping就是render文字贴图的时候分割出文字贴图在目标贴图上显示的区域
下面的是opengl的两个函数,dx应该也是可以实现的
BOOL BeginTarget(image_p _img,uint8_t clear){ static int cacheid = 0; if(!_img) return FALSE; BIND_AND_TEST_CACHE(_img); target_w = _img->w; target_h = _img->h; //reset to target_clip target_clip = 1; ResetClip(); glBlendEquationSeparate(GL_FUNC_ADD, GL_MAX); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, cacheid, 0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0,_img->w,0,_img->h, -1, 1); glMatrixMode(GL_MODELVIEW); glPushAttrib(GL_VIEWPORT_BIT); glViewport(0,0,_img->w, _img->h); if(clear){ glClearColor( COLOR_T_R(screen_c), COLOR_T_G(screen_c), COLOR_T_B(screen_c), COLOR_T_A(screen_c) ); glClear( GL_COLOR_BUFFER_BIT); } return TRUE; } void EndTarget(){ glViewport(0,0, nge_screen.width, nge_screen.height); glPopAttrib(); glBindFramebuffer(GL_FRAMEBUFFER, 0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0,nge_screen.ori_width,nge_screen.ori_height,0, -1, 1); glMatrixMode(GL_MODELVIEW); glBlendEquation(GL_FUNC_ADD); //reset to screen clip target_clip = 0; ResetClip(); }
BOOL BeginTarget(image_p _img,uint8_t clear){
static int cacheid = 0;
if(!_img)
return FALSE;
BIND_AND_TEST_CACHE(_img);
target_w = _img->w;
target_h = _img->h;
//reset to target_clip
target_clip = 1;
ResetClip();
glBlendEquationSeparate(GL_FUNC_ADD, GL_MAX);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, cacheid, 0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,_img->w,0,_img->h, -1, 1);
glMatrixMode(GL_MODELVIEW);
glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0,0,_img->w, _img->h);
if(clear){
glClearColor( COLOR_T_R(screen_c), COLOR_T_G(screen_c), COLOR_T_B(screen_c), COLOR_T_A(screen_c) );
glClear( GL_COLOR_BUFFER_BIT);
}
return TRUE;
}
void EndTarget(){
glViewport(0,0, nge_screen.width, nge_screen.height);
glPopAttrib();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,nge_screen.ori_width,nge_screen.ori_height,0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glBlendEquation(GL_FUNC_ADD);
//reset to screen clip
target_clip = 0;
ResetClip();
}
PS:楼上这是引用里的删除线控制符影响到正文了,算是dz的bug么
|
|