FireInDark

Members
  • Content count

    38
  • Joined

  • Last visited

Community Reputation

148 Neutral

About FireInDark

  • Rank
    Member
  1. Freetype/GL/VBO/shaders

    great job
  2. [attachment=10653:???.jpg] Now ,I render text with FreeType and it goes well . At last I got the RBGA data like this: for(int h = 0;h < bitmap_height;h++) { for(int w = 0;w < bitmap_width; w++) { paper_buffer[((pen_y + h) * paper_width + pen_x + w + char_advance)*4 + 0] = buffer[bitmap_width * h + w] * color[0] / 256; paper_buffer[((pen_y + h) * paper_width + pen_x + w + char_advance)*4 + 1] = buffer[bitmap_width * h + w] * color[1] / 256; paper_buffer[((pen_y + h) * paper_width + pen_x + w + char_advance)*4 + 2] = buffer[bitmap_width * h + w] * color[2] / 256; if( buffer[bitmap_width * h + w] == 0) paper_buffer[((pen_y + h) * paper_width + pen_x + w + char_advance)*4 + 3] = 0;//if the gray data is zero set the alpha be zero else paper_buffer[((pen_y + h) * paper_width + pen_x + w + char_advance)*4 + 3] = 255; } } paper_buffer save the RGBA data and buffer means the gray data in FT_Bitmap . And I send the RGBA data to GPU as a texture. And I code GLSL like this: "void main() { gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex; }" "uniform sampler2D normal_tex; uniform sampler2D text_tex; void main() { vec4 text_color; vec4 normal_color; normal_color = texture2D(normal_tex,gl_TexCoord[0].st); text_color = texture2D(text_tex, gl_TexCoord[0].st); if(text_color.w == 0) gl_FragColor = normal_color * 0.8 + text_color * 0.2; else gl_FragColor = text_color * 0.8 + normal_color * 0.2; } so the result is the image above..seems not so smooth . And I want to know how do you do when you do this thing?
  3. [quote name='Ignifex' timestamp='1344610547' post='4968092'] If you only need information from your alpha channel, after your first render of A, then it might be sufficient to use some properly set up alpha blending. Try using the destination alpha to blend with in glBlendFunc. If that is not sufficient, I see several other options. The problem is mainly that you cannot read from and write to the same FBO. Several workarounds: - As you mentioned, copy the data to another texture and use this texture during the render of B. Not really fast imo. - Use 2 FBO's. You use a separate renderpass where you render A's "alpha" as a greyvalue to the second FBO. Then you can use this data while rendering A and B to the first FBO. - Use one FBO with two color targets. This works, is probably the fastest if simple blending is not sufficient, but is a bit difficult to set up properly. Apart from these, I don't see a fast way to get what you want. However, I believe you should be able to achieve what you want using alpha blending. [/quote] Maybe I understand now ,let me have a try. Thank you very much.
  4. It is this: There are two elemets A and B . 1.We render A to the Frame Buffer - yes then the Frame Buffer contains pixel of A , some pixels's alpha are zero and some are not.. 2.We render B to the Frame Buffer - and how ever - if the alpha in Frame Buffer is zero ,the pixels at the same position(2D) of B will be draw to the FrameBuffer else not. May be we can use stencil values but there are some reason I don't want to do like this. Any way ?
  5. [quote name='Ignifex' timestamp='1344513077' post='4967736'] What do you mean by visiting the data of the Frame Buffer? Do you wish to use the data on the CPU? [/quote] No I don't use the datas in CPU but GPU -GLSL I need control if the right pixel of an element such as a triangle will be draw to the frame buffer.
  6. Yes I render text with FreeType and it's goes well . [attachment=10597:???.jpg] Yes seems every thing all right.. But see here: view.setFontColor(255,255,255,255); Yes I do want to set the font_color be white,but it show me the black text.. It's quite sure that the color of the pixels rendered by FreeType are all right: for(int h = 0;h < bitmap_height;h++) { for(int w = 0;w < bitmap_width; w++) { paper_buffer[((pen_y + h) * paper_width + pen_x + w + char_advance)*4 + 0] = buffer[bitmap_width * h + w] * color[0] / 256; paper_buffer[((pen_y + h) * paper_width + pen_x + w + char_advance)*4 + 1] = buffer[bitmap_width * h + w] * color[1] / 256; paper_buffer[((pen_y + h) * paper_width + pen_x + w + char_advance)*4 + 2] = buffer[bitmap_width * h + w] * color[2] / 256; paper_buffer[((pen_y + h) * paper_width + pen_x + w + char_advance)*4 + 3] = 255; } } and when : glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);//first texture glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); //text texture view.setFontColor(255,255,255,255); [attachment=10598:???.jpg] seems well. but then: view.setFontColor(255,0,0,255); [attachment=10599:???.jpg] yes ,it's red but not pure red one.. then what I want to do is see the text color as what I set. there must be the reason of glTexEnvi [url=http://www.freeimage.us/share-BF9E_5024D0C5.html][img]http://www.freeimage.us/thumb-BF9E_5024D0C5.jpg[/img][/url]
  7. Think about that : If copy the datas to a texture with glCopyTexImage2D every time an element rendered ,wouldn't it'll take a long time?
  8. And that :if I can visit the datas from Frame Buffer there would be no problem.. But seems it's not possible..
  9. [quote name='Ignifex' timestamp='1344422418' post='4967333'] Is it also used with an FBO? [/quote] No ,it's just a common texture. To be honest ,What I want to do is blending all the objects rendered by it's depth ,stencil ,alpha and some thing else. my self. I got a way to do what I want to do ,But there are extra works to do ,not so directly ..
  10. A FBO connect with a RenderTexture ,depth buffer,and other buffers.. Now I create a new Texture ,I want to copy the data from depth buffer to this texture. Any way ?
  11. About MRT

    [quote name='Ashaman73' timestamp='1344235839' post='4966578'] Here's a practical approach: [/quote] Thank you very much ,I'll try it.
  12. About MRT

    [quote name='Ashaman73' timestamp='1344230381' post='4966559'] Then you need to assign your render materials to one or more render passes. [/quote] Seems it the right way .But wouldn't it be slowly ? If the elments are in a "Tree" it'll take many times to change the target ..
  13. About MRT

    Think about that ,in case MRT,we have two render target (All are textures ): texture A and texture B. Now the first element has been rendered ,texture A save the image and texture B save other datas.. then wen need to render another element ,but here , I need the datas in texture B to juge if the right pixel should be wirte or not..and the same time ,I also need to write texture B in some case when rendering the second element; Any way ? if i just bind the texture B as the GL_TEXTURE1 or GL_TEXTURE2 or somthing..
  14. OpenGL Question about GLEW.

    [quote name='wolfscaptain' timestamp='1343903779' post='4965478'] If you don't want it showing, just set it to be hidden. [/quote] To be honest ,I done it like this... But it's such a rolling ..I'm rolling in the deep..
  15. I use GLEW on MS-Windows. It's helpful and do many works .. But ,till now,I can't find a way to init GLEW without creating a HGLRC and it also means I should create a window first.. Without the help of GLEW I can't use the the new functions newer than OpenGL 1.1 on MS-Windows such a glGenBuffers or others.. But I really don't want to create a window before I render to the FBOs,any way ? May be we can find the functions from the driver's dll file of display card but I thinks it's not a right way to me..