2012年9月3日 星期一

Filter4Cam 實作: 29. 影像視窗大小調整

since: 2012/09/03
update: 2012/09/03


A. 說明:
     在 實作 28  中, 於 captureOutput:didOutputSampleBuffer: fromConnection:
     方法裡, 我們利用了 CGRectMake 來建立要畫到 render buffer 的目標矩形大小.
     寬度固定為: self.view.frame.size.width
     高度固定為: self.view.frame.size.height  
     當時並沒有考慮到設備方向改變時的情況, 因此當設備水平擺放時, 就會發生
     寬度被切掉的情況, 因此要做一些調整.
    說明: 影像被切掉的地方顯示為黑色.

------------------------------------------------------------------------

B. 開啟 ViewController.h 檔案, 修改如下:
....
@interface ViewController : GLKViewController <AVCaptureVideoDataOutputSampleBufferDelegate, UITableViewDelegate, UITableViewDataSource>
{
....
    // 目前使用的濾鏡物件
    FilterBase *currentFilter;
   
    //@add: 影像視窗的大小
    CGRect destRect;

}
....


@property (nonatomic, strong) FilterBase *currentFilter;

//@add
@property (assign) CGRect destRect;

....

------------------------------------------------------------------------

C. 開啟 ViewController.m 檔案, 修改如下:
....
// step 01:
@synthesize dataObj = _dataObj;
@synthesize currentFilter = _currentFilter;


//@add
@synthesize destRect = _destRect;


....
// step 02:
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
....
    //@update: comment it
    /*
    //@add
    CGRect destRect = CGRectMake(self.view.frame.origin.x,
                                 self.view.frame.origin.y,
                                 self.view.frame.size.width,
                                 self.view.frame.size.height);
   
    */
   
    //@add: 根據設備擺放方向來設定 "影像視窗大小" 的長寬
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
   
    // 設備垂直擺放
    if (orientation == UIDeviceOrientationPortrait ||
        orientation == UIDeviceOrientationPortraitUpsideDown)
    {
        self.destRect = CGRectMake(self.view.frame.origin.x,
                                   self.view.frame.origin.y,
                                   self.view.frame.size.width,
                                   self.view.frame.size.height);
    }
    // 設備水平擺放
    else if (orientation == UIDeviceOrientationLandscapeRight ||
             orientation == UIDeviceOrientationLandscapeLeft)
    {
        self.destRect = CGRectMake(self.view.frame.origin.x,
                                   self.view.frame.origin.y,
                                   self.view.frame.size.height,
                                   self.view.frame.size.width);
    }

    // 設備: 面朝上, 面朝下, 未知
    else
    {
        // Do Nothing
    }


    // 然後使用 CIContext 物件將其內容畫到 render buffer
    //[self.coreImageContext drawImage:self.ciImage inRect:destRect fromRect:[self.ciImage extent]];
    //@update
    [self.coreImageContext drawImage:self.ciImage inRect:self.destRect fromRect:[self.ciImage extent]];


    // 最後, 在螢幕上呈現出來.
    [self.glContext presentRenderbuffer:GL_RENDERBUFFER];
}

....

// step 03:
- (void)viewDidLoad
{
....
    //@add
    self.destRect = CGRectMake(self.view.frame.origin.x,
                                                         self.view.frame.origin.y,
                                                         self.view.frame.size.width,
                                                         self.view.frame.size.height);

   
    //@add: establish Render
    [self establishRender];

    //@add: establishCamera
    [self establishCamera:kCameraBack];
   
    //@add test for cameraOverlay
    //[self cameraOverlayTest];
   
    //@add for setting camera Overlay
    [self cameraOverlay];
   
    //@add: startRunning
    [self startRunningSession];
   
    //@add for initialize reusableCells
    [self initReusableCells];
}

....

------------------------------------------------------------------------

D. 編譯並執行:

      拍照畫面(水平擺放)

      拍照結果(水平擺放: 720 x 960)

Filter4Cam 實作: 28. 影像解析度調整

since: 2012/09/03
update: 2012/09/03


A. 說明:
     調整內容如下:
     1. 移除濾鏡的顯示範圍限制, 讓濾鏡效果呈現在整個螢幕上.
     2. 相機前置鏡頭的解析度為: 640x480; 後置鏡頭的解析度為: 720 x 960.

--------------------------------------------------------------------------

B. 開啟 ViewController.h 檔案, 修改如下:
....
@interface ViewController : GLKViewController <AVCaptureVideoDataOutputSampleBufferDelegate, UITableViewDelegate, UITableViewDataSource>
{
....
    //@add for Camera Overlay UI
    //@update: comment it
    //UIImageView *filterLensImageView;
    UITableView *filterListTableView;
    UIView *buttonView;       // 用來放所有按鈕的 View
    UIButton *saveButton;     // "拍照" 按鈕
    UIButton *switchButton;   // "鏡頭切換" 按鈕
    UIButton *torchButton;    // "閃光燈切換" 按鈕
    UIButton *observerButton; // "觀察者模式" 按鈕
....
}

....
//@add for Camera Overlay UI
//@update: comment it
//@property (nonatomic, strong) UIImageView *filterLensImageView;
@property (nonatomic, strong) UITableView *filterListTableView;
@property (nonatomic, strong) UIView *buttonView;
@property (nonatomic, strong) UIButton *saveButton;
@property (nonatomic, strong) UIButton *switchButton;
@property (nonatomic, strong) UIButton *torchButton;
@property (nonatomic, strong) UIButton *observerButton;

....
//@add for orientation Transform
- (CIImage *)orientationTransform:(CIImage *)sourceImage;

//@update: comment it
//- (void)drawFilteredImage:(CIImage *)filteredImage;
....

--------------------------------------------------------------------------

C. 移除 "界定濾鏡顯示範圍的圖" (filterLensImageView):
      開啟 ViewController.m 檔案, 修改如下:
 ....
// step 01:
//@add for Camera Overlay UI
//@update: comment it
//@synthesize filterLensImageView = _filterLensImageView;
@synthesize filterListTableView = _filterListTableView;
....


// step 02:
//@update: comment it
/*
//@add for Camera Overlay UI
- (UIImageView *)filterLensImageView
{  
    if (_filterLensImageView == nil) {
        _filterLensImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"filterLens.png"]];
    }
   
    return _filterLensImageView;
}
*/

....

// step 03:
- (void)cameraOverlay
{  
    //@update: comment it
    //[self.filterLensImageView setFrame:CGRectMake(20, 80, 280, 280)];

    //@update: comment it
    //[self.view addSubview:self.filterLensImageView];
....
}
....


// step 04:
- (void)viewDidUnload
{   
....

    //@update: comment it
    //self.filterLensImageView = nil;
....
}

....

// step 05:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
....
        //@update: Tune UI

        //@update: comment it (共有 5 個地方)
        //[self.filterLensImageView setFrame:CGRectMake(20, 120, 280, 280)];
....
}
....


--------------------------------------------------------------------------

D. 相機解析度調整:
      開啟 ViewController.m 檔案, 修改如下:
....
// step 01:
- (void)establishCamera:(uint)whichCamera
{
....   
    // begin
    [self.session beginConfiguration];
    //[self.session setSessionPreset:AVCaptureSessionPreset640x480];
    //[self.session setSessionPreset:AVCaptureSessionPreset1280x720];
    //[self.session setSessionPreset:AVCaptureSessionPresetHigh];

    //@update: 預設後置鏡頭的解析度: 720 x 960
    [self.session setSessionPreset:AVCaptureSessionPresetPhoto];
// 720 x 960
    //[self.session setSessionPreset:AVCaptureSessionPresetiFrame1280x720];
    //[self.session setSessionPreset:AVCaptureSessionPresetiFrame960x540];   
....

....


// step 02:
//@update: comment it
/*
// 畫出 "濾鏡範圍" 內的影像(含方向轉變的調整)
- (void)drawFilteredImage:(CIImage *)filteredImage
{
....
}

*/
....

// step 03:
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
....   
    // 然後使用 CIContext 物件將其內容畫到 render buffer
    //@update: comment it
    //[self.coreImageContext drawImage:self.ciImage atPoint:CGPointZero fromRect:[self.ciImage extent]];
   
    //@update
    if(self.dataObj.isUsingFilter == YES)
    {       
        // check if key "filterID" exists:
        // objectForKey will return nil if a key doesn't exists.
        if (self.currentFilter = [self.dataObj.filterDictionary objectForKey:self.dataObj.filterID])
        {
            self.ciImage = [self.currentFilter filterImage:self.ciImage];
            //@update: comment it
            //[self drawFilteredImage:self.ciImage];
        }
    }
   
    //@add
    CGRect destRect = CGRectMake(self.view.frame.origin.x,
                                                                 self.view.frame.origin.y,
                                                                 self.view.frame.size.width,
                                                                 self.view.frame.size.height);

   
    // 然後使用 CIContext 物件將其內容畫到 render buffer
    [self.coreImageContext drawImage:self.ciImage inRect:destRect fromRect:[self.ciImage extent]];
   
    // 最後, 在螢幕上呈現出來.
    [self.glContext presentRenderbuffer:GL_RENDERBUFFER];
}
....


--------------------------------------------------------------------------

E. 調整 "切換鏡頭" 的解析度:
     開啟 ViewController.m 檔案, 修改如下:
....
- (void)switchCameras
{
....  
    // Change the input
    AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:newDevice error:nil];
    [self.session addInput:captureInput];
   
    //@add
    // 使用前置鏡頭: 640x480
    if (self.isUsingFrontCamera)
    {
        [self.session setSessionPreset:AVCaptureSessionPreset640x480];
    }
    else
    {
        // 使用後置鏡頭: 720 x 960
        [self.session setSessionPreset:AVCaptureSessionPresetPhoto];
    }

   
    [self.session commitConfiguration];
}
....


--------------------------------------------------------------------------

F. 拍照 "影像範圍" 調整:

     開啟 ViewController.m 檔案, 修改如下:
....
//@update: "拍照": 截取相機鏡頭全部範圍的影像
- (void)savePhoto
{   
....
            //cgImage = [self.coreImageContext createCGImage:self.ciImage fromRect:CGRectMake(23, -557.5, 274, 274)];
            //@update (總共有 6 個地方)
            cgImage = [self.coreImageContext createCGImage:self.ciImage fromRect:[self.ciImage extent]];

....
}
....


--------------------------------------------------------------------------

G. 編譯並執行:
      拍照畫面

      拍照結果(720 x 960)

2012年9月2日 星期日

iPod touch 3rd Jailbreak 5.1.1


since: 2012/09/02
update: 2012/09/02

reference:
1.
iOS 5.1.1 Absinthe 2.0.4 全 JB 過程教學
2. I touchs: iPod touch 3rd Jailbreak 4.3.3

A. 說明:
     由於即將到來的 iOS 6 不支援: iPhone 3G, iPad 1iPod touch 3,
     因此決定將手邊已不常用到的(較常用 iPad 2) iPod touch 3rdJB.  

--------------------------------------------------------------------

B. 前置作業:
    1. 確認 iPod touch 目前為最新版本: iOS 5.1.1 .
        => 設定 > 一般 > 關於本機 > 版本: 5.1.1

    2. 備份 ECID:
        a. 在 Mac OS X 下, 連結 iPod touch 並且下載 Umbrella:
             The Firmware Umbrella - TinyUmbrella         
             p.s. 在此下載的檔案為: TinyUmbrella-5.11.01.pkg

        b. (目前版本: 5.11.01). 安裝好 TinyUmbrella 後, 點開進入並選擇你的 iPod touch.

        c. 接著按下右上方的 "Save SHSH" 按鈕.

        d. 儲存好的 SHSH 會各放一份在 CYDIA 的 server 和本機(Mac) 上的
            /Users/(your username)/.shsh 目錄下.

    3. 備份 iPod Touch 資料:
        使用 iTunes 同步並備份 iPod touch 的資料.

--------------------------------------------------------------------

C. 進行 JB:

     1. 下載 JB 軟體
          網址: Greenpois0n.com
          連結: Absinthe v2.0.4 MacOSX (10.5, 10.6, 10.7)
          檔名: absinthe-mac-2.0.4.dmg
          備註: 由於目前已升級為 OS X 10.8, 經測試後無法 JB,
                    因此改下載 Linux 版本: Absinthe v2.0.4 Linux (x86/x86_64)
                    檔名: absinthe-linux-2.0.4.tar.bz2
                     (亦可用 Windows 的版本)

     2. 重置內容與設定:
         JB 官網建議如此作, 可讓 JB 過程更加快速.
        => 設定 > 一般 > 重置: 清除所有內容和設定

     3. 將 iPod touch 的 "自動鎖定" 功能, 設成 "永不".
        => 設定 > 一般 > 自動鎖定: 永不


     4. iPod touch 連接到 Linux 上, 並解壓縮 JB 軟體後, 執行 absinthe.x86_64

     5. 點選 "Jailbreak" 開始 JB.

     6. 在 JB 的過程中, iPod touch 會重新啓動, 完成後直接關閉視窗即可.

     7. JB 成功的話, 可以在 iPod touch 的第二頁桌面上看到 "Cydia" app

     8. 將  iPod touch 連接回 Mac 上, 並作資料回復. 

     9. 將 iPod touch 的 "自動鎖定" 功能, 設定回 "5分鐘".
         => 設定 > 一般 > 自動鎖定: 5分鐘 // 依個人需求而定

--------------------------------------------------------------------

D. Cydia 設定
     1. Cydia 開啟後, 選擇 開發者 > 完成.

     2. 切換到 "變更" 項目, 並按下左上方的 "更新":

     3. Cydia 安裝軟體: 先切換到 "搜尋" 項目
         a. OpenSSH:
             可在 Mac 上使用 sftp client 的軟體連入 iPod touch 系統中.

         b. AppSync for iOS 5.0+:
             讓應用程式 (.ipa / .app) 可直接透過 iTunes 安裝.
             (1). 開啟 Cydia > 管理 > 軟體源 > 編輯 > 添加
             (2). 輸入 http://cydia.hackulo.us/ > 按下 添加源 按鈕 > 若彈出提示框,
                    選擇 仍然添加 即可.
             (3). 完成 Source Update 後, 按下 Return To Cydia, 返回 Source, 再按下
                    剛加入的 Sources, 選擇 AppSync for iOS 5.0+ 安裝.

         c. CyDelete:
             可直接在桌面刪除從 Cydia 下載的軟體.

         d. USB Drive:
             可當成 USB 硬碟來使用.
             (1). 新增安裝源: http://apt.dmytro.me/
             (2). 安裝 USB Drive 軟體.

         e. afc2add:
             可讓應用軟體( iPhone Explorer / DiskAid )瀏覽到 iPod touch
             的根目錄.

             說明: 再執行一次 "變更" 項目, 並按下左上方的 "更新".

--------------------------------------------------------------------

E. 更改 iPod touch 的 root 密碼:
     1. 確定已用 Cydia 安裝了 OpenSSH.

     2. 共享 Mac Book Pro 的網路給 iPod touch:
         => Mac OS X > 系統偏好設定 > 共享 > Internet 共享
              (待都設定好時再勾選 "Internet 共享")
              > 共享來源: 乙太網路; 對使用以下傳輸埠的電腦: Wi-Fi

    3. iPod touch > 設定 > Wi-Fi > 停用 > 啟用
        (說明: Mac 所分享的仍然是原本所選擇的網路名稱)
        查看 IP, ex: 192.168.1.11

    4. Mac OS X > 終端機 > ssh root@192.168.1.11 (default password: alpine)
        => 如果出現以下訊息:
        WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
        (代表, 之前有 jailbreak 過不同的版本並曾登入過 iPod touch,)
        解決辦法: 先移除(這裡用搬移檔案) Mac 上 .ssh 目錄下的檔案, 再登入一次:
        $ cd /Users/lanli/.ssh
        $ mv known_hosts known_hosts_back_20120902

     5. 承上, 鍵入 passwd 來輸入新密碼.

     6. 亦可在 Mac 上使用 sftp client 的軟體連入 iPod touch 系統中.

--------------------------------------------------------------------

F. 備註:
    1. 如果想幫 iBook 增加 "英漢字典" 功能的話, 請參考:
        I touchs: 幫 iBooks 增加 英漢字典

    2. iTunes 備份檔案的位置:
        (your home) > 資源庫 > Application Support > MobileSync > Backup

2012年8月18日 星期六

Running OpenGL on Linux Mint - 3

since: 2012/08/18
update: 2012/09/06

reference:
1. OpenGL Video Tutorial - Getting OpenGL Set Up on Linux
2. Howto Install OpenGL Development Environment
3. Computing Reference Wikispace - geany_settings
4. GLEW: The OpenGL Extension Wrangler Library

開發環境設定與繪圖測試

A. 檢查 OpenGL 與 GLUT 開發函式庫
     1. 說明:
          要讓 OpenGL 在 Linux 上正常運作, 至少要在檔案中找到 gl.hglut.h 檔案,
          它們通常位於 /usr/include/GL/ 目錄下.

     2. 檢查:
         $ cd /usr/include/GL/
         $ ls

------------------------------------------------------------------------------------

B. 安裝 IDE(整合開發環境)
     1. Menu > Software Manager

     2. > Programming

     3. > geany

     4. > Install

     5. 備註:
         或直接執行
         $ sudo apt-get install geany

------------------------------------------------------------------------------------

C. 開發環境設定與繪圖測試
     1. 開啟 Geany
         Menu > All applications (選單右上方)
         > Programming > Geany

     2. 查看/設定 專案的檔案目錄
          Edit > Preferences
         General > Startup > Project files:
         /home/lanli/projects

     3. 建立專案目錄:
         $ cd ~
         $ mkdir projects

     4. 新增 OpenGL 測試檔案
         開啓新檔案, 寫入以下程式碼, 存檔至 /home/lanli/projects/teapot.c
#include <GL/glut.h>

void init();
void display();

int main(int argc, char* argv[])
{
 glutInit(&argc, argv);
 glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
 glutInitWindowPosition(0, 0);
 glutInitWindowSize(300, 300);
 
 glutCreateWindow("OpenGL 3D View");
 
 init();
 glutDisplayFunc(display);
 
 glutMainLoop();

 return 0;
}

void init()
{
 glClearColor(0.0, 0.0, 0.0, 0.0);
 glMatrixMode(GL_PROJECTION);
 glOrtho(-5, 5, -5, 5, 5, 15);
 glMatrixMode(GL_MODELVIEW);
 gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
}

void display()
{
 glClear(GL_COLOR_BUFFER_BIT);
  
 glColor3f(1.0, 0, 0);
 glutWireTeapot(3);
 
 glFlush();
}

     5. 查看編譯設定
         Build > Set Build Commands

         (update: 2012/08/22)
     6. 調整編譯設定
         a. Build 的 Command 改成:
             gcc -Wall -o "%e.o" "%f" -lglut -lGL -lGLU -lSDL // -lSDL 非必要

         b.Execute 的 Command 改成: "./%e.o"        // 添加 .o

     7. 編譯並執行
         a. Build > Build
         b. Build > Execute

------------------------------------------------------------------------------------

D. 使用 GLEW 的方式: (update: 2012/08/30)
     1. 說明:
         a. 調整編譯設定:
             將 Build 的 Command 改成: 
             gcc -Wall -o "%e.o" "%f" -lglut -lGLEW -lGL -lGLU

         b. 如果 GLEW 要跟 GLUT 一起使用的話, 必須要先 include glew.h, 然後才
     
include glut.h, 並且 glew.h 已經有 include glu.h 了.

         c. GLEW 的初始化必須要在全部的 glutInitxxx 及  glutCreateWindow 之後進行.
             (可以在註冊 callback functions 動作之前)

*******************************************************

     2. 將 teapot.c 修改如下:
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glut.h>

void init();
void display();
void initGlew();

int main(int argc, char* argv[])
{
 glutInit(&argc, argv);
 glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
 glutInitWindowPosition(0, 0);
 glutInitWindowSize(300, 300);
 
 glutCreateWindow("OpenGL 3D View"); 
 initGlew();
 init();
 glutDisplayFunc(display);
 
 glutMainLoop();

 return 0;
}

void init()
{
 glClearColor(0.0, 0.0, 0.0, 0.0);
 glMatrixMode(GL_PROJECTION);
 glOrtho(-5, 5, -5, 5, 5, 15);
 glMatrixMode(GL_MODELVIEW);
 gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
}

void display()
{
 glClear(GL_COLOR_BUFFER_BIT);
  
 glColor3f(1.0, 0, 0);
 glutWireTeapot(3);
 
 glFlush();
}

void initGlew()
{
    GLenum err = glewInit();
   
    if(err !=  GLEW_OK)
    {
        fprintf(stderr, "glewInitError\n");
        exit(1);
    }
   
    fprintf(stderr, "GLEW initialized OK\n");
    fprintf(stderr, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
}


*******************************************************

     3. 編譯並執行
         a. Build > Build
         b. Build > Execute

------------------------------------------------------------------------------------

E. 備註: (update: 2012/09/06)
     1. 後來在 geany 下使用 extern 變數時, 會造成編譯失敗的情況.
         ....
         extern void checkGLErrors(const char* caller);
         ....
         checkGLErrors("main here");
         ....

         *****************************************************

         main.c:(.text+0x70): undefined reference to `checkGLErrors'

         編譯失敗


     2. 試過安裝 codeblocks 來建立 OpenGL 專案, 編譯時也會出問題
         (可能是我不太熟  codeblocks). 

     3. 所以, 之後會改用 eclipse 來開發 OpenGL. 

2012年8月16日 星期四

Running OpenGL on Linux Mint - 2

since: 2012/08/15
update: 2012/08/29

reference:
1. Install Linux Mint 12 (Lisa) on 13inch MacBook Air
2. Things To Do after installing Linux Mint 13 (Maya)
3. How to quickly Install NVIDIA R302.11 Drivers Under Linux Mint 13
4. SDL, OpenGL, GLSL on the Mac and Linux
5. Linux 的3D加速--DRI
6. GLEW: The OpenGL Extension Wrangler Library
7. How to: Build GLEW on Debian

Update NVIDIA Graphics Drivers

A. 查詢系統目前資訊
      Menu > Terminal

     1. kernel 版本:
         $ uname -r
         3.2.0-23-generic

     2. 檔案系統的磁碟使用情況:
         $ df -h

     3. 記憶體使用情況:
          $ free -m

     4. 支援的 OpenGL 版本:
          $ glxinfo | grep "OpenGL version"

-----------------------------------------------------------------------

B. 更新軟體套件
      1. 更新系統軟體:
          $ sudo apt-get update
          $ sudo apt-get upgrade
          (備註: 亦可執行桌面右下方的 "Update Manager" 來更新套件)

      2. 安裝一般常用的工具:
          $ sudo apt-get install ubuntu-restricted-extras

          (update: 2012/08/24)
      3. 安裝其它軟體: (依個人需求而異)
          $ sudo apt-get install virtualbox // VirtualBox         
          $ sudo apt-get install gcin // 中文輸入法
          $ sudo apt-get install k3b // 燒錄軟體
          $ sudo apt-get install mercurial // 版本控制

-----------------------------------------------------------------------

C. 安裝 OpenGL 與相關開發套件
      1. 基本編譯環境
          $ sudo apt-get install build-essential

      2. OpenGL Library, Utility, Toolkit
          $ sudo apt-get install freeglut3
          $ sudo apt-get install freeglut3-dev

         
(update: 2012/08/29)
          $ sudo apt-get install libglew-dev // GLEW
             說明: 目前最新的 GLEW 版本為 1.9.0 已支援 OpenGL 4.3,
                       由於在此使用 apt 安裝, 因此版本為 1.6 支援 OpenGL 4.1.

          // GLEW build pre-req’s
          $ sudo apt-get install libxmu-headers libxmu-dev libxi-dev
          $ sudo apt-get install glew-utils // glewinfo

          $ glewinfo | grep "GLEW version"
         備註: 移除方式 (試過用編譯的方式, 版本仍未更新, 所以將其移除再安裝)
                   $ sudo apt-get --purge remove libglew1.6
                   $ sudo apt-get --purge remove glew-utils

      3. 其它 (update: 2012/08/18)
          $ sudo apt-get install libsdl-dev  // Simple Directmedia Layer

-----------------------------------------------------------------------

D. 更新 NVIDIA 顯卡驅動程式
      1. 下載:
           這邊直接下載對 OpenGL 4.3 提供 beta support 的版本來試試:
           OpenGL Driver Support ,
           檔名為: NVIDIA-Linux-x86_64-304.15.00.02.run

      2. 確認下載位置:
          $ cd ~/Downloads
          $ ls -al

      3. 進入第一個虛擬終端機:
           Ctrl + Alt + F1

      4. 檢查 Mint Display Manager(mdm) 的 process:
          $ ps aux | grep mdm

      5. 終止 Mint Display Manager 的行程:
           $ sudo killall mdm
           $ ps aux | grep mdm
           說明: 已經沒有 owner 為 rootmdm 相關行程.

      6. 開始安裝 Driver:
           $ cd ~/Downloads
           $ sudo sh NVIDIA-Linux-x86_64-304.15.00.02.run

          說明: a. 利用 Tab 鍵來切換選項. (切到 "Accept" 或 "YES")
                    b. 第一次安裝可能會失敗, 重新開機, 再從步驟 3 開始.
                    c. Install NVIDIA's 32-bit compatibility OpenGL libraries? YES

           $ sudo reboot

      7. 檢查目前所支援的 OpenGL 版本:
           $ glxinfo | grep "OpenGL version"

      8. 查看 NVIDIA Driver 狀況:
           $ nvidia-settings


2012年8月15日 星期三

Running OpenGL on Linux Mint - 1

since: 2012/08/15
update: 2012/08/21

reference:
Install Linux Mint 12 (Lisa) on 13inch MacBook Air


Install Linux Mint

A. 說明:
     1. 最新的 OpenGL 4.3 規格已在8月6日釋出, 詳見: Khronos Releases OpenGL 4.3.
         硬體方面, 許多顯卡的規格都是超前在軟體的支援前已準備好的; 軟體方面,
         部分顯卡晶片製造商也提供了對 4.3 版的 beta 支援供使用者下載, 如:
         NVIDIA OpenGL 4.3 Driver, 但是只有 WindowsLinux 的版本.

     2. Apple 對於 OpenGL 軟體的支援, 即使硬體方面(顯卡)都已支援到 4.2, 軟體方面
         仍然只支援到 3.2. 因此如果想使用 OpenGL 3.3 以上的版本, 就必須在 Windows
         或 Linux 平台上. (我選擇了 Linux)
         參考: 1. Mac OpenGL capabilities | RenderingPipeline
                   2. Mac OS X 10.8 Core Profile OpenGL Info

     3. 關於 Linux 版本, 將會使用 Linux Mint (Linux Mint - 维基百科), 主要是基於方便
         與友善的考量. 目前的版本為 Linux Mint 13 Maya, 在此下載了桌面環境為 MATE
         的 64 位元版本, 並燒錄成開機安裝光碟片.
        
     4. 硬體環境: (不是在我的 MBP 上, 是另一台 PC)
          Mother Board: P35-DS3
          CPU: Intel Core 2 Duo E6750 2.66GHZ
          RAM: 8GB
          HD: WDC SATA 250GB
          Display Card: Geforce GTX 560 Ti (Memory: 1GB)

     5. 安裝方式:
         由於安裝好 Linux 後, 需要再更新顯卡的驅動程式, 來提升對 OpenGL 的版本支援,
         因此在此採用完全的乾淨安裝方式, 來讓安裝的過程更加順利.
         備註: 其它裝方式, 還有: "安裝在 VM" 與 "製作多重開機系統".

---------------------------------------------------------------------------------

B. 安裝 Linux Mint
     1. 從 BIOS 將 CD-ROM 調整為開機的第一順位, 將 "Linux Mint 13" 開機片放入
         光碟機, 重新開機.

     2. 載入桌面完成後, 用滑鼠雙擊 "Install Linux Mint" 開始進行安裝設定.
         (備註: Alt + PrintScreen 可截取螢幕圖片)

     3. 選擇在安裝過程中, 所使用的語言:
          English > Continue
          (update: 2012/08/21)
          為了讓之後的 "中文輸入" 順利執行, 改成:
          中文(繁體) > 繼續


     4. 硬體需求確認:
          a. 至少還有 5.9 GB 可用的磁碟空間
          b. 已經連接到網路
           > Continue

     5. 安裝類型:
          點選: Something else (可自行建立分割區, 或選擇多重分割區)
           > Continue

     6. 先利用 "Delete" 將所有分割區刪除.

     7. 磁碟分割區規劃:
         a. 說明:
             好幾年前, 我在安裝 Linux (RedHat, Fedora ....), 於分割磁區時, 都是先
             切出一塊 swap, 然後再切 / 分割區. 在此則先切 / 分割區, 再切 swap 區,
             比較不會不小心將 / 區切成 "邏輯磁碟", 而造成無法開機的情況.

         b. 磁碟空間規劃:
             磁碟總容量: 250 GB
             / 分割區: 240000 MB (約 234 GB)
             swap 區: 10999 MB (約 10.7 GB)

         c. 點選 "free space" 並按下 "Add".
             Mount point: /
             Type: Primary
             partition size: 240000 (MB)
             Use as: Ext4 journaling file system
              > OK

         d. 再次點選 "free space" 並按下 "Add".
             Use as: swap area
             Type: Primary
             partition size: 10998 (MB)
              > OK

         e. 在 Mount point 為 / 的分割區, 將 Format? 勾選起來,
             並於最下方的 "Device for boot loader installation" 選擇 Mount point
             為 / 的分割區, 在此為: /dev/sda1
              > Install Now

     8. 開始安裝:
         a. 選擇地區:
             Taipei > Continue

         b. 選擇鍵盤配置:
             English(US) > Continue           
             (update: 2012/08/21)
            為了讓之後的 "中文輸入" 順利執行, 改成:
            Chinese > Chinese > 繼續


         c. 基本資料設定:
             name: Lanli
             computer's name: P35-DS3
             username: lanli
             password: xxxxxxxx
             confirm: xxxxxxxx
              > Continue

         d. 開始安裝系統

     9. 安裝完成, 重新啓動

         從光碟機拿出安裝片, 並按下 "Enter"

     10. 登入系統:
            輸入帳號

            輸入密碼

            登入成功 (換張桌圖)