Posts

APUE第二章-Unix标准化

03 Jan 2015

Unix标准化

1. ISO C

2. POSIX

3. Signle Unix Specification

Unix实现

1.

2.

3.

4.

5.

...

阅读全文 ...


Install Jekyll on Windows

01 Jan 2015

#步骤

1. 安装ruby和ruby DevKit 下载地址, 本人使用2.0版本可行。

需要注意的两点:
  • 安装ruby时候,将ruby可执行文件路径加入到环境变量中
  • 解压Ruby DevKit之后,进入解压所在目录,分别执行:
ruby dk.rb init
ruby dk.rb install

2. 安装Jekyll: gem install jekyll

3. build and run jekyll

jekyll build
jekyll build --watch
jekyll build -w
jekyll serve
jekyll serve --watch
jekyll serve -w

#遇到的问题

gem install jekyll 报错:

Error
ERROR: Could not find a valid gem 'jekyll' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - 
Errno::ETIMEDOUT: Operation timed out - connect(2) (https://rubygems.org/latest_specs.4.8.gz)
Solution https://rubygems.org/ 可能被墙了,使用http://ruby.taobao.org这个源。
$ gem sources --remove https://rubygems.org/
$ gem sources -a http://ruby.taobao.org/
$ gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org  
$ gem install jekyll

#参考 ...

阅读全文 ...


songs

20 Dec 2014

#Song list

2015/1/27

一万次悲伤 ...

阅读全文 ...


[OpenGL ES 2.0学习]-1 基本概念

03 Dec 2014

OpenGL ES 2.0 Reference Card

Shader Program

两种shader脚本

  • glsl: short name for OpenGL Shader Language, is a high-level shading language based on the syntax of the C programming language. It was created by the OpenGL ARB (OpenGL Architecture Review Board) to give developers more direct control of the graphics pipeline without having to use ARB assembly language or hardware-specific languages.
  • hlsl: Hihg Level Shader Language, from Microfost against OpenGL

shader脚本文件的后缀名

  • vertex shader: .glsl, .vs(in OpenGL Shader Builder)
  • fragment shader: .glsl, .fs(in OpenGL Shader Builder)
  • geometry shader: .glsl, .gs(in OpenGL Shader Builder)

两种投影

  • 正交投影, 2D
  • 透视投影, 3D

下面的总结是《opengl es 2.0 实践指南》上代码总结,现在已经不参考那本书了,因为用java写opengl程序感觉太别扭.

第一个ES2.0程序


学到的东西

ByteOrder bOrder = vertexData.order();
if (bOrder == ByteOrder.BIG_ENDIAN) {
    // is big endian
} else {
    // ByteOrder.LITTLE_ENDIAN
}

// use native order
byteBuffer.order(ByteOrder.nativeOrder())

遇到的问题:

  • q1. java.lang.IllegalArgumentException: Must use a native order direct Buffer
use allocateDirect instead of allocate.
float[] tableVerticesWithTriangles = {
    // first triangle.
    -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f,

    // second triangle.
    -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f,

    // middle line
    -0.5f, 0f, 0.5f, 0f,

    // two points
    0f, -0.25f, 0f, 0.25f 
};
FloatBuffer vertexData = ByteBuffer.allocate(tableVerticesWithTriangles.length * BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
// ... when pass the vertexData to OpenGL memory:
vertexData.position(0);
// crash here: "java.lang.IllegalArgumentException: Must use a native order direct Buffer"
glVertexAttribPointer(aPostionLocation, POSITION_COMPONENT_COUNT, GL_FLOAT, false, 0, vertexData); 
// this is ok. use allocateDirect. 
// The vertBuff buffer needs to be direct so that it isn't moved around in memory. [from StackOverflow](http://stackoverflow.com/questions/11012669/opengl-es-rendereing-error)
// You need to use the allocateDirect(int) method from the ByteBuffer class.
vertexData = ByteBuffer.allocateDirect(tableVerticesWithTriangles.length * BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
...

阅读全文 ...


English Writing Skills

10 Nov 2014

Learn from web.

StackOverflow

  1. I am a total beginner to libclang and Python, sry if I’m asking something trivial.
...

阅读全文 ...