00001 00007 #include "Demo.h" 00008 00009 /******************************************************************** 00010 * Constructor 00011 */ 00012 Demo::Demo() { 00013 } 00014 00015 /******************************************************************** 00016 * Constructor 00017 */ 00018 Demo::~Demo() { 00019 unload(); 00020 } 00021 00022 /******************************************************************** 00023 * Load 00024 */ 00025 bool Demo::load(Application *parent) { 00026 if (parent != NULL) 00027 m_parent = parent; 00028 00029 //if (g_fullscreen) { 00030 g_selectedScene = SCENE_MENU; 00031 return false; 00032 //} 00033 00034 //glEnable(GL_TEXTURE_2D); 00035 00036 avi.sethDC(((OpenGLApp *)m_parent)->hDC); 00037 00038 if (!avi.load("data\\intro\\intro.avi")) { 00039 g_selectedScene = SCENE_MENU; 00040 return false; 00041 } 00042 00043 music.load("data\\music\\exp.xm"); 00044 00045 g_drawConsole = true; 00046 g_showFPS = false; 00047 00048 LOG_SUCCESS(("Demo loaded")); 00049 00050 timeStart = g_time; 00051 00052 m_loaded = true; 00053 return true; 00054 } 00055 00056 /******************************************************************** 00057 * Unload 00058 */ 00059 bool Demo::unload() { 00060 if (!m_loaded) 00061 return false; 00067 music.stop(); 00068 music.unload(); 00069 00070 avi.unload(); 00071 00072 LOG_SUCCESS(("Demo unloaded")); 00073 m_loaded = false; 00074 return true; 00075 } 00076 00077 /******************************************************************** 00078 * Update 00079 */ 00080 bool Demo::update() { 00081 static bool musicPlaying = false; 00082 if (!m_loaded) 00083 return false; 00084 00085 if (m_parent->keys[VK_SPACE] || m_parent->keys[VK_ESCAPE] || m_parent->mouse.right || m_parent->mouse.left) { 00086 g_selectedScene = SCENE_MENU; 00087 00088 m_parent->keys[VK_SPACE] = false; 00089 m_parent->keys[VK_ESCAPE] = false; 00090 return true; 00091 } 00092 00093 if (!musicPlaying && (g_time - timeStart > 1900.0f)) { 00094 musicPlaying = true; 00095 music.play(); 00096 } 00097 00098 if (g_time - timeStart > 2000.0f) { 00099 avi.update((DWORD)g_frameTime); 00100 } 00101 00102 if (avi.isDone()) { 00103 g_selectedScene = SCENE_MENU; 00104 } 00105 00106 return true; 00107 } 00108 00109 /******************************************************************** 00110 * Draw frame 00111 */ 00112 bool Demo::drawFrame() { 00113 if (!m_loaded) 00114 return false; 00115 00116 //glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00117 00118 if (g_time - timeStart > 2000.0f) { 00119 avi.genTex(g_width, g_height); 00130 } 00131 00132 return true; 00133 }