70000339 Better text display when aligntoview is true and opengl render is active

Article 70000339
Type Wish
Product Engine
Version 7003
Date Added 2/26/2015 12:00:00 AM
Fixed (3/14/2015 12:00:00 AM)
Submitted by Alessio

Summary

Better text display when aligntoview is true and opengl render is active

Solution

In version 7004 a new pair of methods UnlockTovdRender and LockTovdRender was added for IvdOpenGLRender 
By using the UnlockTovdRender when openglrender is active we can apply transparency and high quality TrueType text draw ,
without depth buffer test, but always in the view plane.
UnlockTovdRender : De-activates opengl render and activates default VectorDraw rendering engine. Depth buffer is also disabled and transparency (Alphablend of Penstyle) is applied for each drawing pixel in relation to existing destination. This method must be called after the vdRender.StartDraw and before vdRender.EndDraw, usually inside DrawAfter event of vdDocument. LockTovdRender: Re-activates opengl render that previous was de-activated by UnlockTovdRender call After this call all render properties will be restored to state before UnlockTovdRender method call. Example: Draw a transparency box and a text after draw all elements. By using the UnlockTovdRender when openglrender is active we can apply transparency and high quality TrueType text draw , without depth buffer test, but always in the view plane. //add a drawafter event for the vdDocument object doc.OnDrawAfter += new vdDocument.DrawAfterEventHandler(doc_OnDrawAfter); // Draw a transparency box and a text after draw all elements // By using the UnlockTovdRender when openglrender is active we can apply transparency and high quality TrueType text draw ,without depth buffer test, but always in the view plane. void doc_OnDrawAfter(object sender, vdRender render) { //Apply this only on Layout Render and not for viewports if (render.OwnerObject is vdViewport) return; //disable depth buffer test, so drawing elements are overlapped, depend on draw order. bool enableDepthBuffer = render.EnableDepthBuffer(false); //De-activates opengl render and activates default vectorDraw rendering engine. if (render.IsOpenGLRender) render.OpenGLRender.UnlockTovdRender(); //temporary create a text to draw.Initialize it to the center of the view and height 5 percent of the view size. vdText text = new vdText(doc, "VectorDraw Test", render.ViewCenter, render.ViewSize * 0.05, VdConstHorJust.VdTextHorCenter, VdConstVerJust.VdTextVerCen, doc.TextStyles.Standard); //make the elements to be drawn always on view plane. render.PushToViewMatrix(); //translate the drawing elements from text ECS matrix to current render matrix render.PushMatrix(text.ECSMatrix); //draw a blue transparent box that completely enclose the text. render.PushPenstyle(Color.Blue, false, 100); render.DrawSolidBoundBox(this,text.TextBox); render.PopPenstyle(); //draw the text string render.PushPenstyle(Color.Red, false, 255); render.DrawString(this, text.Style.GrTextStyle, null, text.TextString, text.TextBox); render.PopPenstyle(); //pop previous pushed matrixes render.PopMatrix(); render.PopMatrix(); //Re-activates opengl render that previous was de-activated by UnlockTovdRender call if (render.IsOpenGLRender) render.OpenGLRender.LockTovdRender(); //restore depth buffer test property. render.EnableDepthBuffer(enableDepthBuffer); }

Send comments on this topic.