겨울팥죽 여름빙수
article thumbnail
Android, NDK OpenGLES2.0 Texture

1. Load texture I used Android BitmapFactory to decode PNG texture. If you want one source multi flatform, Use libpng. This writing show example BitmapFactory decoding. First we have to load image. Theretofore we have to decide resource foloder. A. res/raw Many developer use assets foloder to manage resource, but I decide resource folder res/raw because res folder managed to R.java, there could ..

article thumbnail
OpenGLES2.0 GLSL, 2D Basic shader

1. Outline Recently, many developer use OpenGLES 2.0 to make a 2d graphics game. But it have little difficult because of OpenGLES1.0 & OpenglES 2.0 graphic-pipeline difference. Especially, when we meet GLSL shader first-time, it give little fear of programming. Follow writing show shader for someone who want to make 2d graphic game or app. 2. Vertex Shader vertex shader handle each vertex infos ..

article thumbnail
OpenGLES 2.0,GLSL lighting code

1. outline OpenGLES 2.0 don't support glLightf. So developer have to make light effect using glsl shader. Following content don't explane about OpenGL2.0 functions like glGetUniformLocation, glGetAttribLocation, ect. 2. Light formula Below formual show graphics expression of light in 3D graphics. I = Global Ambient + Emission + Ambient + Diffuse + Specular = Ga + Me + 1/a+bD+cD^2(Ka*Ia + Kd*Id(N..

article thumbnail
GLSL, OpenGLES2.0 glFog

OpenGLES2.0 not support glFog. So If you want fog effect, you have to a code using glsl. 1. Calculate GL_FOG_MODE have 3 modes. GL_LINEAR : f = (end - z)/(end - start) GL_EXP : f = exp(-density*z) GL_EXP2 : f = exp2(-(density*z)*(density*z)) Color = Color_source*f + (1-f)Color_fog start - fog start distionce(usually 0.0f) end - fog's end distance (usually 1.0f) Color_source is fragment color. Co..

article thumbnail
NDK AdMob, Can't see admob on Framelayout

I added admob view to Android framelayout. I couldn't see ad. I think that admob view is not disappered, because when I click admob location, actvity is changed to show advertisement. To resolve problem, I applied background color to admob view. Below show my code. Colored By Color Scripter™1234567891011121314//-------------------------------------------------------------------------------------..

c++ Builder 패턴
게임을 만들자/C++ 2014. 4. 16. 10:54

1. 다수의 멤버변수 보통 UI클래스나, 많은 정보를 가진 데이터 클래스(java의 bean객체 같은)의 경우, 많은 멤버 변수를 가진다. 이런 멤버 변수들을 생성자 파라미터로 초기화하면, 코드가 많이 복잡해 보일 수 있다. 예를 들어, 아래 클래스 처럼 new를 통해 파라미터로 값을 초기화하는 경우, 가독성이 많이 떨어진다(각각의 파라미터가 어떤 의미인지 알기 어렵다). 이런 문제를 해결하기 위해 get, set함수를 만들고 사용하기도 하는데 별로 만족 스럽지 못하다. class Node { protected: vec2m_position; vec2m_draw_position; floatm_width; floatm_height; AlignTypem_child_align_type; Marginm_margi..

GLSurfaceView & GLRenderer 설정

1. MainActivity 아래 코드를 보면 알 수 있듯이, MainActivity자체는 별로 하는 일이 없다. setContentView로 화면에 보여질 뷰를 MainGLSurfaceView로 설정한다. openGLVerstion는 MainGLSurfaceView 클래스 내에서, GL버전을 설정하는데 쓰인다. public class MainActivity extends Activity { public static MainGLSurfaceView view; public static Context context = null; public static final intopenGLVerstion = 2; @Override protected void onCreate(Bundle savedInstanceStat..

article thumbnail
Netty(java nio 통신 프레임워크) 대략적인 흐름
게임을 만들자/Java 2014. 4. 15. 13:48

Netty를 이용하면 간단하고 편리하게 client/server를 만들 수 있다.아래는 그림은 Channel, Pipleline, Context, Handler 의 관계를 나타내는 그림이다. Netty는 이벤트 Intercepting Filter pattern의 구조를 가진다. 무슨말이냐 하면, 사용자가 접속하거나, 읽어나, 쓰거나, 나가거나 하는 등의 이벤드를 발생시키고, Handler에서 이벤트를 받아 처리하면된다. 새로운 client가 서버에 접속하면, 채널과 이를 위한 파이프라인이 생성된다. 뭐 채널이 생성되는건 다른 소켓통신에서도 마찬가지니 설명안해도 알 것이다.client당 채널과 파이프라인이 있다고 생각하면된다. 그리고 채널을 통해 bind, read, write, close 등을 실행했을때..

c++ const
게임을 만들자/C++ 2014. 4. 15. 13:41

1. 변수 const : 변수 값을 변경하지 못하게 한다.const int n = 5;n = 10 // 에러 1-2 const int& n2 = n; : n2가 참조하는 곳의 값을 바꿀 수 없다.int n = 5;const int& n2 = n;n2 = 10; //에러n = 10 ; //가능. 2. 포인터 변수 const : 포인터가 가르키는 곳의 값을 변경하지 못하게 한다.int n = 5; const int* ap = &n; (int const* ap도 똑같다.)*ap = 10; //에러 int n2 = 10;ap = &n2; //가능함. 포인터 변경은 가능 int * ap2 = ap; //에러. 포인터가 가르키는 곳을 다른 포인터가 값을 변경할 수도 있기 때문에, 허용하지 않는다.const int ..

article thumbnail
이클립스 NDK설정

1. NDK 프로젝트 생성 일단 안드로이드 SDK, NDK, 이클립스를 모두 다운 받는다. - 이클립스 + SDK 다운로드 - NDK 다운로드 - cygwin설치(윈도우 경우) - Eclipse ADT 설치, CDT 등 설치 2. c++ 프로젝트 생성 - 빈 이클립스 프로젝트 생성 - 프로젝트 Right클릭 -> Android Tools -> Add Native Support클릭 - jni폴더 등이 생성되면, 프로젝트를 빌드한번 해주자. - 이렇게 하면 아래 그림과 같이, 기본적인 설정이 끝난다. 3. 추가적인 설정 - NDK 디버깅. 프로젝트 속성 -> c/c++ build -> Build command ndk-build NDK_DEBUG=1 로 변경(추후 추가 설명) - 프로젝트 속성 -> c/c++..