2013年11月12日 星期二

halo effect and stencil buffer



         glEnable(GL_STENCIL_TEST);

         glStencilFunc(GL_ALWAYS, 1, 0xFF); // Set any stencil to 1
         glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
         glStencilMask(0xFF); // Write to stencil buffer
         glDepthMask(GL_FALSE); // Don't write to depth buffer
         glClear(GL_STENCIL_BUFFER_BIT); // Clear stencil buffer (0 by default)
glDisable(GL_BLEND);

//draw原來物件

         glStencilFunc(GL_EQUAL, 0, 0xFF); // Pass test if stencil value is 1
         glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);      
         glStencilMask(0x00); // Don't write anything to stencil buffer

glEnable(GL_BLEND);
//draw halo object
         glDepthMask(GL_TRUE);







2013年10月23日 星期三

compiler第九章Machine-Independent Optimization

code optimization分成兩種 local和global

local code optimization在section 8.5

大多數的global optimization是data-flow analysis

9.1 The Principal Sources of Optimization

Semantics-Preserving Transformations
1)common-subexpression elimation
2)copy propagation
3)dead-code elimination
4)constant folding
5)code motion
6)induction variables and reduction in strength

2013年9月8日 星期日

GL_TRIANGLES和GL_TRIANGLE_FAN

有六個點
{ 0.0, 0.0 }, { 1.0, 0.0 }, { 1.0, 1.0 } ,{0.0,1.0},{2.0,1.0},{2.0,2.0}

GL_TRIANGLES

 glDrawArrays(GL_TRIANGLES, 0, 6);

畫兩個三角形



GL_TRIANGLE_FAN
glDrawArrays(GL_TRIANGLE_FAN, 0, 6);

第三個點共點

2013年9月5日 星期四

動態改變glsl uniform的time值

Uniforms[4].value[0]+=0.01;    //time
SetUniformValue(Uniforms);

glUseProgram(p,Uniforms);