【Note】2012.10.3-----

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Oct 3 2012<<<<<<<<<<<<<<<<<<<<<<<<<<<<

1. Bresenham's line algorithm(网上找的一个实现)

 1 void PlotLine(int x1,int x2,int y1,int y2, char r, char g, char b)
 2 {
 3     int xinc1,yinc1;
 4     int xinc2,yinc2;
 5     int deltax = abs(x2 - x1);        // The difference between the x's
 6     int deltay = abs(y2 - y1);        // The difference between the y's
 7     int x = x1;                       // Start x off at the first pixel
 8     int y = y1;
 9     int den=0,num=0,numadd=0,numpixels=0,curpixel=0;                       // Start y off at the first pixel
10 
11 
12     if (x2 >= x1)                 // The x-values are increasing
13     {
14         xinc1 = 1;
15         xinc2 = 1;
16     }
17     else                          // The x-values are decreasing
18     {
19         xinc1 = -1;
20         xinc2 = -1;
21     }                                                        
22 
23     if (y2 >= y1)                 // The y-values are increasing
24     {
25         yinc1 = 1;
26         yinc2 = 1;
27     }
28     else                          // The y-values are decreasing
29     {
30         yinc1 = -1;
31         yinc2 = -1;
32     }
33 
34     if (deltax >= deltay)         // There is at least one x-value for every y-value
35     {
36         xinc1 = 0;                  // Don't change the x when numerator >= denominator
37         yinc2 = 0;                  // Don't change the y for every iteration
38         den = deltax;
39         num = deltax >>1;
40         numadd = deltay;
41         numpixels = deltax;         // There are more x-values than y-values
42     }
43     else                          // There is at least one y-value for every x-value
44     {
45         xinc2 = 0;                  // Don't change the x for every iteration
46         yinc1 = 0;                  // Don't change the y when numerator >= denominator
47         den = deltay;
48         num = deltay >>1;
49         numadd = deltax;
50         numpixels = deltay;         // There are more y-values than x-values
51     }
52 
53 
54     for (curpixel = 0; curpixel <= numpixels; curpixel++)
55     {
56         DrawPixel(screen, x, y, r, g, b);
57         num += numadd;              // Increase the numerator by the top of the fraction
58         if (num >= den)             // Check if numerator >= denominator
59         {
60             num -= den;               // Calculate the new numerator value
61         x += xinc1;               // Change the x as appropriate
62             y += yinc1;               // Change the y as appropriate
63         }
64 
65         x += xinc2;                 // Change the x as appropriate
66         y += yinc2;                 // Change the y as appropriate
67     }
68 }

2. Reyes(Rendering everything you ever see)渲染架构,分为下面几个步骤:

  • Bound,求包围盒
  • Split,大的物体划分出小物体,方便将看不到的部分扔掉,同时一个细分网格不会包含太多细分面
  • Dice,细分,存储到细分网格中
  • Shade
  • Sample

参考:http://www.steckles.com/reyes1.html

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Oct 10 2012<<<<<<<<<<<<<<<<<<<<<<<<<<<<

1. error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types

     问题原因在于使用clr选项编译时,编译规则要比纯C++严格。当一个类型有个定义,但是内部结构不一致、大小不一致,就会出现该错误提示。

     问题解决:出现该问题是使用了一个第三方库的一个类型MString,在有些问题中使用时没问题,有些就报错,后来发现是有几个头文件没加进来导致的

     参考:http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/079a2b60-951d-4e84-affc-8d8bfaf87cab

2. 调用第三方库函数,同一个类,有些函数可以调用,有些函数却报link错误,找不到符号,怀疑是类实现在多个lib中

    dumpbin发现,该类确实在多个lib中,引入lib,问题解决

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Oct 12 2012<<<<<<<<<<<<<<<<<<<<<<<<<<<<

1. Autoconf是linux上用来生成自动编译、安装脚本的工具

框架图如下:

下面介绍使用autoconf自动生成编译脚本的流程:

  1. 运行autoscan命令,生成configure.scan
  2. 将configure.scan 文件重命名为configure.in,并修改configure.in文件
    主要修改AM_INIT_AUTOMAKE(package, version [, no-define])(第一个参数生成的程序名,第二个为版本)与AC_OUTPUT(对每一个要输出的Makefile都要添加)
    示例:
    #                                -*- Autoconf -*-
    # Process this file with autoconf to produce a configure script.
    
    AC_PREREQ(2.59)
    AC_INIT(test, 1.0, normalnotebook@126.com)
    AC_CONFIG_SRCDIR([src/ModuleA/apple/core/test.c])
    AM_CONFIG_HEADER(config.h)
    AM_INIT_AUTOMAKE(test,1.0)
    
    # Checks for programs.
    AC_PROG_CC
    # Checks for libraries.
    # FIXME: Replace `main' with a function in `-lpthread':
    AC_CHECK_LIB([pthread], [pthread_rwlock_init])
    AC_PROG_RANLIB
    # Checks for header files.
    # Checks for typedefs, structures, and compiler characteristics.
    # Checks for library functions.
    AC_OUTPUT([Makefile
            src/lib/Makefile
            src/ModuleA/apple/core/Makefile
            src/ModuleA/apple/shell/Makefile
            ])
            
  3. 在工程目录下新建Makefile.am文件,并在需要编译的子目录也新建makefile.am文件(以下是一个示例文件)
    AM_CFLAGS = $(X_CFLAGS)
    ## Add warnings for gcc-3.4
    AM_CFLAGS += -Wall -Wunused -Wimplicit -Wreturn-type
    AM_CFLAGS += -Wdeclaration-after-statement -Wno-unknown-pragmas
    AM_CFLAGS += -Wmissing-prototypes -Wmissing-declarations -Wparentheses
    AM_CFLAGS += -Wswitch -Wtrigraphs -Wpointer-arith -Wcast-qual
    AM_CFLAGS += -Wcast-align -Wwrite-strings -Wold-style-definition
    
    LDADD = $(X_LIBS) -lX11 -lXmu $(X_EXTRA_LIBS)
    
    EXTRA_DIST = pdfopen-AR-7-and-8.c
    
    bin_PROGRAMS = pdfopen pdfclose
    
    pdfopen_SOURCES = pdfopen.c sendx.c utils.c sendx.h xpdfopen.h utils.h
    
    pdfclose_SOURCES = pdfclose.c sendx.c utils.c sendx.h xpdfopen.h utils.h
  4. 在工程目录下新建NEWS、 README、 ChangeLog 、AUTHORS文件
  5. 将/usr/share/automake-1.X/目录下的depcomp和complie文件拷贝到本目录下
  6. 运行aclocal命令
  7. 运行autoconf命令
  8. 运行automake -a命令,生成Makefile.in
  9. 运行autoheader命令,生成config.h.in
  10. 运行./confiugre脚本

2. 前缀树:trie或者prefix tree(前缀树),是一种有序树数据结构,它通常被存储在一个以字符串为关键字的联合数组中。于二叉搜索树不同,在树里没有结点存储与结点相关联的关键字。它是用它在树中的位置展示与它相关的关键字。

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Oct 19 2012<<<<<<<<<<<<<<<<<<<<<<<<<<<<

1. 编译boost时发现,boost使用jam来编译整个工程,而不是使用make。jam简单,而且跨平台。

参考:http://www.freetype.org/jam/index.html

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Oct 24 2012<<<<<<<<<<<<<<<<<<<<<<<<<<<<

1. Consider the "right-end" of curve f(b) and the "left-end" of curve g(m). If f(b) and g(m) are equal as shown in the above figure, we shall say curves f() and g() are C0continuous at f(b)=g(m). If for all i <= k, the i-th derivatives at f(b) and g(m) are equal, we shall say that the curves are Ck continuous at point f(b)=g(m).

posted @ 2012-10-03 15:09  D3猎人  阅读(316)  评论(0编辑  收藏  举报