Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / cpp / Sample / Tizen C++ / GlesCube11 / GlesCube11 / project / inc / GlesCube11.h
1 //
2 // Tizen C++ SDK
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.tizenopensource.org/license
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #ifndef _GLES_CUBE11_H_
19 #define _GLES_CUBE11_H_
20
21
22 #include <new>
23 #include <FBase.h>
24 #include <FGraphics.h>
25 #include <FApp.h>
26 #include <FGraphicsOpengl.h>
27 #include <FSystem.h>
28 #include <FUi.h>
29
30
31 class GlesCube11
32         : public Osp::App::Application
33         , public Osp::System::IScreenEventListener
34         , public Osp::Base::Runtime::ITimerEventListener
35 {
36 public:
37         static Osp::App::Application* CreateInstance(void);
38
39         GlesCube11(void);
40         ~GlesCube11(void);
41
42         virtual bool OnAppInitializing(Osp::App::AppRegistry& appRegistry);
43         virtual bool OnAppTerminating(Osp::App::AppRegistry& appRegistry, bool forcedTermination = false);
44         virtual void OnForeground(void);
45         virtual void OnBackground(void);
46         virtual void OnLowMemory(void);
47         virtual void OnBatteryLevelChanged(Osp::System::BatteryLevel batteryLevel);
48         virtual void OnScreenOn (void);
49         virtual void OnScreenOff (void);
50
51         virtual void OnTimerExpired(Osp::Base::Runtime::Timer& timer);
52
53         bool Draw(void);
54
55 private:
56         bool InitEGL(void);
57         bool InitGL(void);
58         void Cleanup(void);
59         void DestroyGL(void);
60         void DrawCube1(void);
61         void DrawCube2(void);
62         void DrawTexture2D(int x, int y, int w, int h, Osp::Graphics::Opengl::GLuint texture, int texWidth, int texHeight);
63
64 private:
65         Osp::Graphics::Opengl::EGLDisplay __eglDisplay;
66         Osp::Graphics::Opengl::EGLSurface __eglSurface;
67         Osp::Graphics::Opengl::EGLConfig  __eglConfig;
68         Osp::Graphics::Opengl::EGLContext __eglContext;
69
70         Osp::Graphics::Opengl::GLuint     __texture[2];
71         unsigned int                      __textureIndex;
72         Osp::Graphics::Opengl::EGLSurface __pBufferSurface;
73         Osp::Graphics::Opengl::GLuint     __pBufferTexture;
74         int                               __pBufferWidth;
75         int                               __pBufferHeight;
76         Osp::Graphics::Opengl::EGLSurface __pixmapSurface;
77         Osp::Graphics::Bitmap*            __pBitmap;
78
79         Osp::Base::Runtime::Timer*        __pTimer;
80
81         Osp::Ui::Controls::Form*          __pForm;
82 };
83
84 #endif