瀏覽代碼

Updated code samples

Christophe Riccio 15 年之前
父節點
當前提交
31857276cf
共有 6 個文件被更改,包括 966 次插入362 次删除
  1. 102 0
      doc/common/style.css
  2. 0 13
      doc/src/code.xsl
  3. 607 202
      doc/src/data.xml
  4. 38 0
      doc/src/dummy.cpp
  5. 4 16
      doc/src/news.xsl
  6. 215 131
      doc/src/util.xsl

+ 102 - 0
doc/common/style.css

@@ -12,6 +12,12 @@ table
 	margin-right:auto;
 }
 
+ul
+{
+	padding:0px;
+	margin:0px;
+}
+
 table.principale
 {
 	background-color:#ff8000;
@@ -200,3 +206,99 @@ div.issue-title
 {
     font-weight:bold;    
 }
+
+span.progword
+{
+	color:#000000;
+	font-family:"Courier New";
+	font-size:11px;	
+}
+
+span.bold
+{
+	font-weight:bold;	
+}
+
+span.code-title
+{
+	padding-left:0px;
+	color:#803300;
+}
+
+span.code-line-content
+{
+	display:inline;
+	color:#000000;
+	border-left-style:solid;
+	border-left-width:1px;
+	border-left-color:#ffdac1;
+	margin-left:0px;
+	padding-left:8px;
+}
+
+ul.code-list
+{
+	border-style:solid;
+	border-width:1px;
+	border-color:#ffdac1;
+	color:#803300;
+	margin-bottom:16px;
+	margin-left:0px;
+	margin-right:0px;
+}
+
+li.code-line
+{
+	color:#008080;
+	font-family:"Courier New";
+	font-size:11px;
+	clear:both;
+	width:100%;
+	list-style-position:inside;
+	list-style-type:decimal-leading-zero;
+	margin:0px;
+	padding:0px;
+	padding-left:0px;
+}
+
+li.code-line:after
+{
+	clear:both;
+}
+
+span.code-line-content
+{
+	display:inline;
+	color:#000000;
+	border-left-style:solid;
+	border-left-width:1px;
+	border-left-color:#ffdac1;
+	margin-left:0px;
+	padding-left:8px;
+}
+
+span.userword
+{
+	color:#ff8000;	
+}
+
+span.keyword
+{
+	color:#0000ff;
+}
+
+span.comment
+{
+	color:#008000;
+}
+
+span.string
+{
+	color:#800000;
+}
+
+span.codeword
+{
+	color:#000000;
+	font-family:"Courier New";
+}

+ 0 - 13
doc/src/code.xsl

@@ -35,19 +35,6 @@
     </html>
   </xsl:template>
 
-  <xsl:template match="code">
-    <div>
-      <div class="title4">
-        <xsl:value-of select="./@date" /> | <xsl:value-of select="./@title" />
-      </div>
-      <div>
-        <xsl:apply-templates />
-      </div>
-      <div class="news-separator">_________________</div>
-      <br />
-    </div>
-  </xsl:template>
-  
 <!--
   <xsl:template match="code">
     <div>

文件差異過大導致無法顯示
+ 607 - 202
doc/src/data.xml


+ 38 - 0
doc/src/dummy.cpp

@@ -1,4 +1,42 @@
+#include "../../glm/glm.hpp" // glm::vec3, glm::vec4, glm::ivec4, glm::mat4
+
+struct triangle
+{
+	glm::vec3 Position[3];
+	glm::vec3 Normal;
+};
+
+void computeNormal(triangle & Triangle)
+{
+	glm::vec3 const & a = Triangle.Position[0];
+	glm::vec3 const & b = Triangle.Position[1];
+	glm::vec3 const & c = Triangle.Position[2];
+	Triangle.Normal = glm::normalize(glm::cross(c - a, b - a));
+}
+
+#include "../../glm/gtc/matrix_projection.hpp" // glm::perspective
+#include "../../glm/gtc/matrix_transform.hpp" // glm::translate, glm::rotate, glm::scale
+#include "../../glm/gtc/type_ptr.hpp" // glm::value_ptr
+
+glm::vec4 const ClearColor = glm::vec4(glm::vec3(0.0f), 1.0f);
+glm::ivec4 const Viewport = glm::ivec4(0, 0, 640, 480);
+
+void glUniformMatrix4fv(int location, int count, bool transpose, const float * value);
+
 int main()
 {
+	//triangle Triangle;
+	//computeNormal(Triangle);
+
+	float Translate = 1.0f;
+	glm::vec2 Rotate;
 
+	glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f);
+	glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate));
+	glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f));
+	glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f));
+	glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f));
+	glm::mat4 MVP = Projection * View * Model;
+	
+	glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP));
 }

+ 4 - 16
doc/src/news.xsl

@@ -53,24 +53,12 @@
         <xsl:if test="./list">
           <xsl:apply-templates select="./list" />
         </xsl:if>
+		  <xsl:if test="./code">
+			  <xsl:apply-templates select="./code" />
+		  </xsl:if>
         <xsl:apply-templates select="./source" />
 
-        <!--table style="width:100%;">
-        <tr style="width:100%;">
-          <td>
-            <xsl:if test="./paragraph">
-              <xsl:apply-templates select="./paragraph" />
-            </xsl:if>
-            <xsl:if test="./list">
-              <xsl:apply-templates select="./list" />
-            </xsl:if>
-            <xsl:apply-templates select="./source" />
-          </td>
-          <td style="text-align:right;">
-            <a ref="{./@image}"><img src="{./@image-mini}" alt=" " /></a>
-          </td>
-        </tr>
-      </table-->
+		<!--xsl:apply-templates select="/" /-->
 
       </div>
       <div class="news-separator">_________________</div>

+ 215 - 131
doc/src/util.xsl

@@ -1,140 +1,224 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
-<xsl:strip-space elements="*" />
-
-<xsl:output 
-	method="xml"
-	media-type="application/xhtml+xml; charset=iso-8859-1"
-	version="1.0"
-	encoding="iso-8859-1"
-	standalone="no"
-	omit-xml-declaration="no"
-	doctype-public="-//W3C//DTD XHTML 1.1//EN" 
-	doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
-	indent="no" />
-
-<xsl:template match="link">
-	<a href="{./@href}"><xsl:value-of select="." /></a>
-</xsl:template>
-
-<xsl:template match="image">
-	<xsl:choose>
-		<xsl:when test="./@href">
-			<xsl:element name="a">
-				<xsl:attribute name="class">menu-titre2</xsl:attribute>
-				<xsl:attribute name="href"><xsl:value-of select="./@href" /></xsl:attribute>
+	<xsl:strip-space elements="*" />
+
+	<xsl:output 
+		method="xml"
+		media-type="application/xhtml+xml; charset=iso-8859-1"
+		version="1.0"
+		encoding="iso-8859-1"
+		standalone="no"
+		omit-xml-declaration="no"
+		doctype-public="-//W3C//DTD XHTML 1.1//EN" 
+		doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
+		indent="no" />
+
+	<xsl:template match="link">
+		<a href="{./@href}"><xsl:value-of select="." /></a>
+	</xsl:template>
+
+	<xsl:template match="image">
+		<xsl:choose>
+			<xsl:when test="./@href">
+				<xsl:element name="a">
+					<xsl:attribute name="class">menu-titre2</xsl:attribute>
+					<xsl:attribute name="href"><xsl:value-of select="./@href" /></xsl:attribute>
+					<xsl:element name="img">
+						<xsl:attribute name="src"><xsl:value-of select="@file" /></xsl:attribute>
+						<xsl:attribute name="alt"><xsl:value-of select="@file" /></xsl:attribute>
+					</xsl:element>
+				</xsl:element>
+			</xsl:when>
+			<xsl:otherwise>
 				<xsl:element name="img">
 					<xsl:attribute name="src"><xsl:value-of select="@file" /></xsl:attribute>
 					<xsl:attribute name="alt"><xsl:value-of select="@file" /></xsl:attribute>
 				</xsl:element>
-			</xsl:element>
-		</xsl:when>
-		<xsl:otherwise>
-			<xsl:element name="img">
-				<xsl:attribute name="src"><xsl:value-of select="@file" /></xsl:attribute>
-				<xsl:attribute name="alt"><xsl:value-of select="@file" /></xsl:attribute>
-			</xsl:element>
-		</xsl:otherwise>
-	</xsl:choose>
-</xsl:template>
-
-  <xsl:template match="image-list">
-    <div class="news-image">
-      <xsl:apply-templates select="./image-element" />
-    </div>
-  </xsl:template>
-
-  <xsl:template match="image-element">
-    <a href="{./@normal}">
-      <img src="{./@small}" alt="{./@title}" />
-    </a>
-  </xsl:template>
-
-<xsl:template match="list">
-	<xsl:value-of select="./@nom" /><br />
-	<xsl:apply-templates select="./element"/>
-	<br />
-</xsl:template>
-
-<xsl:template match="element">
-	<xsl:apply-templates /><br />
-</xsl:template>
-
-<xsl:template match="paragraph">
-	<div class="paragraph"><xsl:text /><xsl:apply-templates /><xsl:text /></div><br />
-</xsl:template>
-
-<xsl:template match="about-short">
-  <div class="title3">
-    <xsl:apply-templates select="./element" />
-  </div>
-  <br />
-</xsl:template>
-  
-<xsl:template match="source">
-	<xsl:value-of select="./@type"/>: <a href="{./@adresse}"><xsl:value-of select="."/></a><br />
-</xsl:template>
-
-<xsl:template match="menu">
-  <div class="menu1">
-    <br />
-    <div>
-      <a href="./goodies/logo1920x1200.png">
-        <img class="menu-img" src="./common/logo.png" alt="GLM Logo"/>
-      </a>
-    </div>
-    <br />
-    <div>
-      <a class="menu" href="{/glm/downloads/section/download/@link}">
-        Download <xsl:value-of select="/glm/downloads/section/download/@name" />
-      </a>
-    </div>
-  </div>
-  <br />
-  <xsl:apply-templates select="./menu-group"/>
-  <br />
-  <xsl:apply-templates select="./menu-link"/>
-  <br />
-  <!--div>
-    <script type="text/javascript" src="http://feedjit.com/map/?bc=FFFFFF&amp;tc=494949&amp;brd1=FFFFFF&amp;lnk=494949&amp;hc=FF8000&amp;dot=FF8000"></script>
-    <noscript>
-      <a href="http://feedjit.com/">Feedjit Live Blog Stats</a>
-    </noscript>
-  </div-->
-</xsl:template>
-
-<xsl:template match="menu-pic">
-  <div class="menu2">
-    <a href="{@href}">
-      <img class="menu-img" src="{@image}" alt="{@name}"/>
-    </a>
-  </div>
-</xsl:template>
-
-<xsl:template match="menu-link">
-  <xsl:apply-templates select="./menu-pic"/>
-</xsl:template>
-  
-<xsl:template match="menu-image">
-  <div class="menu2">
-    <a href="./common/glm.jpg">
-      <img class="menu-img" src="./common/logo.jpg" alt="G-Truc"/>
-    </a>
-  </div>
-</xsl:template>
-  
-<xsl:template match="menu-group">
-  <xsl:apply-templates select="./menu-entry"/>
-  <br />
-</xsl:template>
-
-<xsl:template match="menu-entry">
-  <div class="menu2">
-    <a href="{./@href}">
-      <xsl:value-of select="./@name"/>
-    </a>
-  </div>
-</xsl:template>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+
+	  <xsl:template match="image-list">
+		<div class="news-image">
+		  <xsl:apply-templates select="./image-element" />
+		</div>
+	  </xsl:template>
+
+	  <xsl:template match="image-element">
+		<a href="{./@normal}">
+		  <img src="{./@small}" alt="{./@title}" />
+		</a>
+	  </xsl:template>
+
+	<xsl:template match="list">
+		<xsl:value-of select="./@nom" /><br />
+		<xsl:apply-templates select="./element"/>
+		<br />
+	</xsl:template>
+
+	<xsl:template match="element">
+		<xsl:apply-templates /><br />
+	</xsl:template>
+
+	<xsl:template match="paragraph">
+		<div class="paragraph"><xsl:text /><xsl:apply-templates /><xsl:text /></div><br />
+	</xsl:template>
+
+	<xsl:template match="about-short">
+	  <div class="title3">
+		<xsl:apply-templates select="./element" />
+	  </div>
+	  <br />
+	</xsl:template>
+	  
+	<xsl:template match="source">
+		<xsl:value-of select="./@type"/>: <a href="{./@href}"><xsl:value-of select="."/></a><br />
+	</xsl:template>
+
+	<xsl:template match="menu">
+	  <div class="menu1">
+		<br />
+		<div>
+		  <a href="./goodies/logo1920x1200.png">
+			<img class="menu-img" src="./common/logo.png" alt="GLM Logo"/>
+		  </a>
+		</div>
+		<br />
+		<div>
+		  <a class="menu" href="{/glm/downloads/section/download/@link}">
+			Download <xsl:value-of select="/glm/downloads/section/download/@name" />
+		  </a>
+		</div>
+	  </div>
+	  <br />
+	  <xsl:apply-templates select="./menu-group"/>
+	  <br />
+	  <xsl:apply-templates select="./menu-link"/>
+	  <br />
+	  <!--div>
+		<script type="text/javascript" src="http://feedjit.com/map/?bc=FFFFFF&amp;tc=494949&amp;brd1=FFFFFF&amp;lnk=494949&amp;hc=FF8000&amp;dot=FF8000"></script>
+		<noscript>
+		  <a href="http://feedjit.com/">Feedjit Live Blog Stats</a>
+		</noscript>
+	  </div-->
+	</xsl:template>
+
+	<xsl:template match="menu-pic">
+	  <div class="menu2">
+		<a href="{@href}">
+		  <img class="menu-img" src="{@image}" alt="{@name}"/>
+		</a>
+	  </div>
+	</xsl:template>
+
+	<xsl:template match="menu-link">
+	  <xsl:apply-templates select="./menu-pic"/>
+	</xsl:template>
+	  
+	<xsl:template match="menu-image">
+	  <div class="menu2">
+		<a href="./common/glm.jpg">
+		  <img class="menu-img" src="./common/logo.jpg" alt="G-Truc"/>
+		</a>
+	  </div>
+	</xsl:template>
+	  
+	<xsl:template match="menu-group">
+	  <xsl:apply-templates select="./menu-entry"/>
+	  <br />
+	</xsl:template>
+
+	<xsl:template match="menu-entry">
+	  <div class="menu2">
+		<a href="{./@href}">
+		  <xsl:value-of select="./@name"/>
+		</a>
+	  </div>
+	</xsl:template>
+
+	<xsl:template match="code">
+		<xsl:choose>
+			<xsl:when test="./@href">
+				<span xmlns="http://www.w3.org/1999/xhtml" class="code-title">
+					<a href="{./@href}">
+						<xsl:value-of select="./@author" />
+					</a>
+				</span>
+			</xsl:when>
+			<xsl:otherwise>
+				<span xmlns="http://www.w3.org/1999/xhtml" class="code-title">
+					<xsl:value-of select="./@title" />
+				</span>
+			</xsl:otherwise>
+		</xsl:choose>
+		<ul xmlns="http://www.w3.org/1999/xhtml" class="code-list">
+			<xsl:apply-templates select="./line" />
+		</ul>
+	</xsl:template>
+
+	<xsl:template match="line">
+		<li xmlns="http://www.w3.org/1999/xhtml" class="code-line">
+			<xsl:choose>
+				<xsl:when test="@align">
+					<span class="code-line-content" style="padding-left:{@align}">
+						<xsl:apply-templates />
+					</span>
+				</xsl:when>
+				<xsl:otherwise>
+					<span class="code-line-content">
+						<xsl:apply-templates />
+					</span>
+				</xsl:otherwise>
+			</xsl:choose>
+		</li>
+	</xsl:template>
+
+	<xsl:template match="progword">
+		<xsl:choose>
+			<xsl:when test="./@href">
+				<span xmlns="http://www.w3.org/1999/xhtml" class="progword">
+					<a href="{./@href}">
+						<xsl:apply-templates />
+					</a>
+				</span>
+			</xsl:when>
+			<xsl:otherwise>
+				<span xmlns="http://www.w3.org/1999/xhtml" class="progword">
+					<xsl:apply-templates />
+				</span>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+
+	<xsl:template match="keyword">
+		<span xmlns="http://www.w3.org/1999/xhtml" class="keyword">
+			<xsl:apply-templates />
+		</span>
+	</xsl:template>
+
+	<xsl:template match="userword">
+		<span xmlns="http://www.w3.org/1999/xhtml" class="userword">
+			<xsl:apply-templates />
+		</span>
+	</xsl:template>
+
+	<xsl:template match="codeword">
+		<span xmlns="http://www.w3.org/1999/xhtml" class="codeword">
+			<xsl:apply-templates />
+		</span>
+	</xsl:template>
+
+	<xsl:template match="string">
+		<span xmlns="http://www.w3.org/1999/xhtml" class="string">
+			<xsl:apply-templates />
+		</span>
+	</xsl:template>
 
+	<xsl:template match="comment">
+		<span xmlns="http://www.w3.org/1999/xhtml" class="comment">
+			<xsl:apply-templates />
+		</span>
+	</xsl:template>
+	
 </xsl:stylesheet>

部分文件因文件數量過多而無法顯示