void stop() { if (BASSMOD_MusicIsActive() != BASS_ACTIVE_STOPPED) { if(!BASSMOD_MusicStop()) { error("Can't stop the file", TRUE); } } BASSMOD_MusicFree(); status = STOPPED; }
//WinMain -- Main Window int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { MSG msg; msg.message = WM_CREATE; WNDCLASS wc; wc.style = CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(GetModuleHandle(NULL), IDI_APPLICATION); wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = "chockngt"; RegisterClass (&wc); // Create the window //mainWnd = CreateWindow (szAppName,szAppName,WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,CW_USEDEFAULT,CW_USEDEFAULT,1024,600,0,0,hInstance,0); //mainWnd = CreateWindow("epic","epic",WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,hInstance,0); hWnd = CreateWindow( "static",0,WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,0,0); HDC hDC = GetDC(hWnd); // initalize opengl if( !SetPixelFormat(hDC,ChoosePixelFormat(hDC,&pfd),&pfd) ) return -1; HGLRC hRC = wglCreateContext(hDC); wglMakeCurrent(hDC,hRC); glInit(); ShowWindow(hWnd,SW_SHOW); UpdateWindow(hWnd); long startTime = timeGetTime(); long lastTime = 0; // start music playback /* setup output - default device, 44100hz, stereo, 16 bits */ BASSMOD_Init(-1,44100,BASS_DEVICE_NOSYNC); BASSMOD_MusicLoad(FALSE,"dalezy - trollmannen_s krypt..mod",0,0,BASS_MUSIC_LOOP); BASSMOD_MusicPlay(); float fCurTime; GetAsyncKeyState(VK_ESCAPE); do { while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { if (!IsDialogMessage(hWnd, &msg)) { TranslateMessage (&msg); DispatchMessage (&msg); } } if (msg.message == WM_QUIT) break; // early exit on quit SetCursor(FALSE); // update timer long curTime = timeGetTime() - startTime; fCurTime = (float)curTime * 0.001f; long deltaTime = curTime - lastTime; float fDeltaTime = (float) deltaTime * 0.001f; lastTime = curTime; // render wglMakeCurrent(hDC,hRC); glClearColor(0.0f, 0.7f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // write your rendering code here! glMatrixMode(GL_MODELVIEW); parameterMatrix[0] = fCurTime; // time parameterMatrix[1] = 0.0f; // no font mode glLoadMatrixf(parameterMatrix); // draw offscreen glBindTexture(GL_TEXTURE_3D, noiseTexture); glGetIntegerv(GL_VIEWPORT, viewport); glViewport(0, 0, OFFSCREEN_WIDTH, OFFSCREEN_HEIGHT); glUseProgram(shaderPrograms[0]); glRectf(-1.0, -1.0, 1.0, 1.0); //// copy to front glViewport(0, 0, viewport[2], viewport[3]); glEnable(GL_TEXTURE_2D); // Enable Texture Mapping glBindTexture(GL_TEXTURE_2D, offscreenTexture); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, OFFSCREEN_WIDTH, OFFSCREEN_HEIGHT); //Copy back buffer to texture glUseProgram(shaderPrograms[1]); glRectf(-1.0, -1.0, 1.0, 1.0); glDisable(GL_TEXTURE_2D); // Enable Texture Mapping // draw font parameterMatrix[1] = 1.0f; // font mode glLoadMatrixf(parameterMatrix); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glBindTexture(GL_TEXTURE_2D, fontTexture); glBegin(GL_QUADS); for (int i = 0; i < sizeof(scroller)-1; i++) { float pos = 15.0f - fCurTime * 10.0f; int ch = scroller[i]; float xp = (fontX[ch] * 48.0f + 1.0f) / fontWidth; float yp = (fontY[ch] * 48.0f + 1.0f) / fontHeight; float w = 45.5f / fontWidth; float h = 45.5f / fontHeight; // repeat scroller while (pos < -1.0f * sizeof(scroller)) pos += 1.0f * sizeof(scroller); glTexCoord2f(xp, yp + h); glVertex3f((pos + i*1.0f)*0.2f/1920.0f*1080.0f, 0.7f, 0.5f); glTexCoord2f(xp, yp); glVertex3f((pos + i*1.0f)*0.2f/1920.0f*1080.0f, 0.9f, 0.5f); glTexCoord2f(xp+w, yp); glVertex3f((pos + i*1.0f+1.0f)*0.2f/1920.0f*1080.0f, 0.9f, 0.5f); glTexCoord2f(xp+w, yp + h); glVertex3f((pos + i*1.0f+1.0f)*0.2f/1920.0f*1080.0f, 0.7f, 0.5f); } glEnd(); glDisable(GL_BLEND); // swap buffers wglSwapLayerBuffers(hDC, WGL_SWAP_MAIN_PLANE); //Sleep(5); } while (msg.message != WM_QUIT && fCurTime < 230.0f && !GetAsyncKeyState(VK_ESCAPE)); // music uninit BASSMOD_MusicStop(); BASSMOD_MusicFree(); // free the current mod wglDeleteContext(hRC); ReleaseDC(hWnd, hDC); glUnInit(); return msg.wParam; }