Click here to Skip to main content
15,896,207 members
Articles / Multimedia / OpenGL

Drawing nearly perfect 2D line segments in OpenGL

Rate me:
Please Sign up or sign in to vote.
4.80/5 (29 votes)
18 Jul 2011CPOL5 min read 245.9K   8.4K   87  
With premium quality anti- aliasing, color, thickness, and minimum CPU overhead.
<html>
<body>

<div style="position:relative">
<img id="i1" src="test6_99.png" style="position:relative;"/>
<img id="i2" src="test7.png" style="position:absolute; left:0px; top:0px; visibility:hidden;" /><br />
<script>var shown=[0,2,0,0,0,0,0,0,0,0]</script>
<button style="width:806px;" onClick="
if ( !shown[0]) {
document.getElementById('i2').style.visibility='visible';
shown[0]=true;
} else {
document.getElementById('i2').style.visibility='hidden';
shown[0]=false;
}
">flip</button>
</div>

<div style="position:relative">
<img id="ib2" src="test6_4.png" style="position:relative;"/>
<img id="ib1" src="test6_99.png" style="position:absolute; left:0px; top:0px; visibility:hidden;"/>
<img id="ib3" src="test7.png" style="position:absolute; left:0px; top:0px; visibility:hidden;" /><br />
<button style="width:403px;" onClick="
if ( shown[1]==3) {
document.getElementById('ib1').style.visibility='hidden';
document.getElementById('ib2').style.visibility='visible';
document.getElementById('ib3').style.visibility='hidden';
shown[1]=2;
} else if ( shown[1]==2) {
document.getElementById('ib1').style.visibility='visible';
document.getElementById('ib2').style.visibility='hidden';
document.getElementById('ib3').style.visibility='hidden';
shown[1]=1;
}
"><</button>
<button style="width:403px;" onClick="
if ( shown[1]==1) {
document.getElementById('ib1').style.visibility='hidden';
document.getElementById('ib2').style.visibility='visible';
document.getElementById('ib3').style.visibility='hidden';
shown[1]=2;
} else if ( shown[1]==2) {
document.getElementById('ib1').style.visibility='hidden';
document.getElementById('ib2').style.visibility='hidden';
document.getElementById('ib3').style.visibility='visible';
shown[1]=3;
}
">></button>
</div>

<div style="position:relative">
<img id="ic1" src="test6_7.png" style="position:relative;"/>
<img id="ic2" src="test7_1.png" style="position:absolute; left:0px; top:0px; visibility:hidden;" /><br />
<button style="width:806px;" onClick="
if ( !shown[2]) {
document.getElementById('ic2').style.visibility='visible';
shown[2]=true;
} else {
document.getElementById('ic2').style.visibility='hidden';
shown[2]=false;
}
">flip</button>
</div>

</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Hong Kong Hong Kong
Chris H.F. Tsang
tyt2y3@gmail.com

Comments and Discussions