<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi Brian,<div><br></div><div>Thank you so much for your time and help along, up to this point, the code make much more sense to me.</div><div>However, I have a few more questions here, hope that you will be able to help me out.</div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;"> I am wondering</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">Where the aa_general_rgba_line() and aa_rgba_line() functions defined?</span></div><div>When and where the functions in s_aalinetemp.h and s_aaline.c are called/used?</div><div>Are the draw_line, draw_triangle, draw_point functions in OSMesa some how connected with src/mesa/main/line.c or point.c?</div><div>Is it possible to take out some required functions for example <span style="font-size: 12pt;">aa_rgba_line(), gl_context, etc. </span><span style="font-size: 12pt;">and compile it on my system so that I can draw a line into the framebuffer? (Or since there are too many functions linked together, you would not recommend me to do that?)</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">Thanks </span></div><div><br></div><div>Andy.</div><div><br></div><div><br><div>> Date: Mon, 15 Jul 2013 08:24:58 -0600<br>> From: brianp@vmware.com<br>> To: lilapkiu@hotmail.com<br>> CC: mesa-dev@lists.freedesktop.org<br>> Subject: Re: [Mesa-dev] OSMesa Help<br>> <br>> On 07/14/2013 09:34 PM, Andy Li wrote:<br>> > Hi,<br>> > <br>> > I have some questions on the OSMesa code.<br>> > As you suggested, I have continue looking into the swrast code.<br>> > However, I have trouble figuring out how the code works exactly.<br>> > Now I am now only focusing on the functions which draw lines.<br>> > As I look into s_lines.c, I saw the _swrast_choose_line().<br>> > And depends on different cases, it will call<br>> > <br>> > _swrast_choose_aa_line_function(ctx)<br>> > or<br>> >   USE(general_line)<br>> > or<br>> > USE(rgba_line)<br>> > or<br>> > USE(simple_no_z_rgba_line)<br>> > etc.<br>> > <br>> > The first thing I did is looking into the <br>> > _swrast_choose_aa_line_function() and it direct me to s_aaline.c<br>> > In that file, I saw the struct of LineInfo and other computation <br>> > functions for plane.<br>> > Then I looked at the _swrast_choose_aa_line_function()<br>> > <br>> > and when I saw the code:<br>> > swrast->Line = aa_general_rgba_line;<br>> > and<br>> > swrast->Line = aa_rgba_line;<br>> > <br>> > I am not sure what do they mean. And I won't be able to continue finding <br>> > useful info.<br>> <br>> aa_rgba_line() drawns a "simple" RGBA antialiased line while<br>> aa_general_rgba_line() also computes texture coords, fog coord, etc.<br>> <br>> <br>> <br>> > I think the main problem I am having is I am not sure what are the steps <br>> > OSMesa have to take in order to draw a line into the frame buffer.<br>> > Would you be able to explain a bit on that? (what are the steps OSMesa <br>> > have to take in order to draw a line into the frame buffer?)<br>> > Does drawing a line involve computing the plane?<br>> <br>> AA lines are drawn by drawing a quadrilateral and computing pixel<br>> coverage involves computing plane equations.<br>> <br>> > What do s_aaline.c and s_aalinetemp.h actually mean?<br>> <br>> the "temp" files contain template code that's re-used multiple times in<br>> the .c file.<br>> <br>> <br>> > What is USE(general_line) ? Where is USE() define?<br>> <br>> grep "define USE" src/mesa/swrast/*.[ch]<br>> <br>> <br>> > What is swrast->Line = aa_general_rgba_line;?<br>> <br>> swrast->Line is a function pointer that points to the current line<br>> drawing function.  The function is chosen by examining current GL<br>> rasterization state.<br>> <br>> <br>> > Would you suggest any debugging tool for me so that I can trace which <br>> > functions are called while the program is running?<br>> > For example I have the code below:<br>> > glBegin(GL_LINES);<br>> > glVertex3f(0.0, 0.0, 0.0);<br>> > glVertex3f(15, 0, 0);<br>> > glEnd();<br>> > Is there any debugging tool which can trace glVertex3f back in the <br>> > library and see how OSMesa works?<br>> > I have tried using gdb, however, it would only by-pass the call the go <br>> > to the next command.<br>> <br>> You'll need to build mesa for debugging (CFLAGS="-g -O0"<br>> --enable-debug).  But I don't really have time to explain all the<br>> nuances of debugging/tracing in Mesa.  I'm not sure that'd really help<br>> you anyway.<br>> <br>> In general, when you drawing points/lines/triangles the s_points.c or<br>> s_lines.c or s_triangle.c code winds up calling _swrast_write_rgba()<br>> span.  This function does Z testing, texturing, stippling, etc before<br>> calling a "put_pixels" or "put_row" function.  Those functions call a<br>> "pack" function to pack an array of RGBA ubyte/float values into the<br>> framebuffer.  Packing involves converting a canonical RGBA format into a<br>> specific pixel format, like RGBA8888, or RGB565, etc.  The color buffer<br>> address, stride, etc. is obtained earlier through a call to<br>> ctx->Driver.MapRenderbuffer().  In the case of OSMesa, the color buffer<br>> is ordinary malloc'd memory that the user allocated.<br>> <br>> -Brian<br>> <br>> <br>> <br></div></div>                                      </div></body>
</html>