pouët.net

windowless demos

category: code [glöplog]
I want to see more demos do this!
I want borderless windowed demos so I can IRC and browse teh WEB at the same time while also listening to music and ...
added on the 2016-11-04 21:39:00 by leGend leGend
hack the planet?
added on the 2016-11-04 21:54:15 by psenough psenough
Quote:
like this?

that's kinda awesome actually. If nothing else it could be used as a nice way to transition out of the desktop.
added on the 2016-11-06 01:10:16 by Claw Claw
fake dos prompts nostalgia? :D
added on the 2016-11-06 08:36:06 by psenough psenough
Similar fadeouts from the "desktop" are common in C64 and Amstrad CPC demos. Would be fun to see some on Windows as well :)
Oh u will ;-)
Here is the code below of my test application where it could use either DirectX or OpenGL.

In this code, you can also move the triangles which keep rotating...
You can compile without the transparency (which increase the FPS).

To close the application, ALT+F4 when the focus is on it.
Enjoy & do an amazing transition sequence within your demo! ;)

Code:#define _WIN32_WINNT 0x0500 #include <windows.h> #include "stdafx.h" #include <windowsx.h> #include <GL/gl.h> #include <GL/glu.h> #include <mmsystem.h> #include <stdio.h> #define USE_DIRECT_X #define COMPILE_WITH_TRANSPARENCY #pragma comment (lib, "opengl32.lib") #pragma comment (lib, "glu32.lib") #pragma comment (lib, "winmm.lib") #include <d3d9.h> #include <D3D9Types.h> // include the Direct3D Library file #pragma comment (lib, "d3d9.lib") // global declarations LPDIRECT3D9 d3d = NULL; // the pointer to our Direct3D interface LPDIRECT3DDEVICE9 d3ddev = NULL; // the pointer to the device class #include <assert.h> #include <tchar.h> #include <math.h> #define PI 3.14159265359 #define TIMER_DELAY 20 #ifdef assert #define verify(expr) if(!expr) assert(0) #else verify(expr) expr #endif const TCHAR szAppName[]=_T("TransparentGL"); const TCHAR wcWndName[]=_T("Transparent - DirectX"); HDC hDC; HGLRC m_hrc; HWND g_hWnd; int w(640); int h(480); bool g_bSwitchAlpha = false;//false; bool g_bTryFaster = false;//true; int g_dlgx = 0; int g_dlgy = 0; int g_nINTSTEP = 1; HDC pdcDIB; HBITMAP hbmpDIB; void *bmp_cnt(NULL); int cxDIB(0); int cyDIB(0); BITMAPINFOHEADER BIH; BITMAPV5HEADER BIHA; DWORD g_dwPrepareDrawPerf, g_dwDrawPerf, g_dwDrawCopyBuf, g_dwGetBuf, g_dwUpdatewin32, g_dwUnlockBuf; LARGE_INTEGER g_CPUTIME, g_CPUFREQ; void _beginProf( void ) { QueryPerformanceFrequency(&g_CPUFREQ); QueryPerformanceCounter(&g_CPUTIME); } DWORD _getProf( void ) { LARGE_INTEGER time; QueryPerformanceCounter(&time); time.QuadPart -= g_CPUTIME.QuadPart; time.QuadPart*= 1000000; time.QuadPart/= g_CPUFREQ.QuadPart; return time.LowPart; } #define glGenFramebuffersEXT_t void * BOOL initSC() { glEnable(GL_ALPHA_TEST); glEnable(GL_DEPTH_TEST); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_RGBA_MODE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glClearColor(0, 0, 0, 0); return 0; } #define CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE) LPDIRECT3DVERTEXBUFFER9 v_buffer; struct CUSTOMVERTEX { FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag DWORD color; // from the D3DFVF_DIFFUSE flag }; CUSTOMVERTEX OurVertices[] = { {320.0f, 50.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 0, 255),}, {520.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 255, 0),}, {120.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(255, 0, 0),}, {320.0f, 50.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 0, 255),}, {520.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 255, 0),}, {120.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(255, 0, 0),}, {320.0f, 50.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 0, 255),}, {520.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 255, 0),}, {120.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(255, 0, 0),}, {320.0f, 50.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 0, 255),}, {520.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 255, 0),}, {120.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(255, 0, 0),}, {320.0f, 50.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 0, 255),}, {520.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 255, 0),}, {120.0f, 400.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(255, 0, 0),}, }; BOOL initDX() { HRESULT hr; // This code fragment assumes that lpD3DDevice is a valid pointer to a device. // Enable alpha blending. d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); // Set the source blend state. d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR); // Set the destination blend state. d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR); hr = d3ddev->CreateVertexBuffer(5*3*sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL); VOID* pVoid; // the void* we were talking about hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0); // locks v_buffer, the buffer we made earlier memcpy(pVoid, OurVertices, sizeof(OurVertices)); // copy vertices to the vertex buffer hr = v_buffer->Unlock(); // unlock v_buffer return 0; } void resizeSC(int width,int height) { glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW ); glLoadIdentity(); } BOOL renderSC() { DWORD dwTime, dwTime2; DWORD dwPrepareDrawPerf, dwDrawPerf, dwDrawCopyBuf, dwGetBuf, dwUnlockBuf; HDC pdcDest; static double t = 0.0f; double a1, a2, a3, x,y, tf; int i, j; VOID* pVoid; // the void* we were talking about HRESULT hr; static DWORD s_lastTime = 0; static int s_nBufCpy = 0; char szDbg[MAX_PATH]; _beginProf(); dwTime = timeGetTime(); if (s_lastTime==0) s_lastTime = dwTime; dwTime-=s_lastTime; // reduce time big number to start to zero. dwTime = (DWORD) ((float) 0.7f * dwTime); /* { char szDbg[MAX_PATH]; sprintf(szDbg, "%d\n", dwTime-s_lastTime); OutputDebugString(szDbg); s_lastTime = dwTime; }*/ t=((double) dwTime/1.4f) + 350.0f * sin(2.0f * PI * (double) dwTime/1.4f* 1.0f /1000); #ifndef USE_DIRECT_X glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glPushMatrix(); glColor3f(0, 1, 1); glBegin(GL_TRIANGLES); // Drawing Using Triangles #else // clear the window to a deep blue d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0); d3ddev->BeginScene(); // begins the 3D scene d3ddev->SetFVF(CUSTOMFVF); // select which vertex format we are using #endif dwPrepareDrawPerf = _getProf(); g_dwPrepareDrawPerf+=dwPrepareDrawPerf; // g_dwPrepareDrawPerf = g_dwDrawPerf = g_dwDrawCopyBuf = g_dwGetBuf _beginProf(); // do 3D rendering on the back buffer here a3 = 0.0f; for(j=0;j<5;++j) { x = 0.3 * sin(2.0 * PI * t* 0.25 /1000); y = 0.3 * sin(2.0 * PI * t* 0.5 /1000); for(i=0;i<3;++i) { a1 = 0.75 * cos(2.0f * PI * t *0.3 / 1000 + 2.0 * PI * i /3); a2 = 0.75 * sin(2.0f * PI * t *0.3 / 1000 + 2.0 * PI * i /3); #ifndef USE_DIRECT_X if (i==0) glColor4f(0.8f,0.0f,0.0f,1.0f); // Set The Color To Red else if (i==1) glColor4f(1.0f,1.0f,0.0f,1.0f); // Set The Color To Green else glColor4f(0.0f,0.0f+j*0.1f,2.0f,0.0f); // Set The Color To Blue glVertex3f( a1+x, a2+y, a3); // Top #else if (i==0) OurVertices[i+j*3].color = D3DCOLOR_RGBA((int)(0.8f*255),(int)(0.0f*255),(int)(0.0f*255), int(1.0f*255)); else if (i==1) OurVertices[i+j*3].color = D3DCOLOR_RGBA((int)(1.0f*255),(int)(1.0f*255),(int)(0.0f*255), int(1.0f*255)); else OurVertices[i+j*3].color = D3DCOLOR_RGBA((int)(0.0f*255),(int)((0.0f+j*0.1f)*255),(int)(2.0f*255), int(0.25f*255)); tf = a1+x+1.0f; OurVertices[i+j*3].x = tf*(float) (w/2); //(w*(a1+x+1.0f))/2.0f; tf = a2+y+1.0f; OurVertices[i+j*3].y = tf*(float)(h/2); //(h*(a2+y+1.0f))/2.0f; OurVertices[i+j*3].z = 1.0f;//a3; #endif } t += (38.0+30.0*sin(2.0*PI*t*0.70/1000))*(j+1+j*0.1); a3-=0.01f; // a3+=1.5f; } #ifndef USE_DIRECT_X glEnd(); glPopMatrix(); glFlush(); #else // select the vertex buffer to display hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0); // locks v_buffer, the buffer we made earlier memcpy(pVoid, OurVertices, sizeof(OurVertices)); // copy vertices to the vertex buffer hr = v_buffer->Unlock(); // unlock v_buffer d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); // copy the vertex buffer to the back buffer d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, j); d3ddev->EndScene(); // ends the 3D scene #ifndef COMPILE_WITH_TRANSPARENCY d3ddev->Present(NULL, NULL, NULL, NULL); dwDrawPerf = _getProf(); g_dwDrawPerf+=dwDrawPerf; _beginProf(); return 0; #else dwDrawPerf = _getProf(); g_dwDrawPerf+=dwDrawPerf; _beginProf(); IDirect3DSurface9 *D3DBack; hr = d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &D3DBack ); RECT rect; D3DLOCKED_RECT lockedrect; rect.left = 0; rect.right = w; rect.top = 0; rect.bottom = h; hr = D3DBack->LockRect(&lockedrect, &rect, D3DLOCK_READONLY); dwGetBuf = _getProf(); g_dwGetBuf+=dwGetBuf; _beginProf(); if (hr==S_OK) { unsigned char *pS, *pD; pD = (unsigned char *) bmp_cnt; pS = (unsigned char *) lockedrect.pBits; for(i=s_nBufCpy;i<h;i+=g_nINTSTEP) { memcpy(&pD[i*w*4], &pS[i*w*4], w*4); } s_nBufCpy = s_nBufCpy+1; s_nBufCpy%=g_nINTSTEP; } dwDrawCopyBuf = _getProf(); g_dwDrawCopyBuf+=dwDrawCopyBuf; _beginProf(); hr = D3DBack->UnlockRect(); dwUnlockBuf = _getProf(); g_dwUnlockBuf+=dwUnlockBuf; #endif #endif return 0; } // DIB -> hDC void draw(HDC pdcDest) { POINT pptDst, pptSrc; SIZE pSize; int i,j; DWORD dwValue; DWORD dwTime = timeGetTime(); assert(pdcDIB); BLENDFUNCTION blendfunc; blendfunc.AlphaFormat = AC_SRC_ALPHA; blendfunc.BlendFlags = 0; blendfunc.SourceConstantAlpha = 255; blendfunc.BlendOp = AC_SRC_OVER; // AlphaBlend(pdcDest, 0, 0, w, h, pdcDIB, 0, 0, w, h, blendfunc); // TransparentBlt(pdcDest, 0, 0, w, h, pdcDIB, 0, 0, w, h, 0); // verify(BitBlt(pdcDest, 0, 0, w, h, pdcDIB, 0, 0, SRCCOPY)); pptDst.x = 0+g_dlgx; pptDst.y = 0+g_dlgy; pptSrc.x = 0; pptSrc.y = 0; pSize.cx = w; pSize.cy = h; BOOL bRet; unsigned char *pBuf; HBITMAP hbm; DWORD *pBmp = (DWORD *) bmp_cnt; // DWORD dwValue; int a, b; // if ((timeGetTime()%1000)<500) _beginProf(); #ifdef COMPILE_WITH_TRANSPARENCY bRet = UpdateLayeredWindow(g_hWnd, pdcDest, &pptDst, &pSize, pdcDIB, &pptSrc, RGB(0,0,0), &blendfunc, ULW_ALPHA); #endif g_dwUpdatewin32+= _getProf(); } void CreateDIB(int cx, int cy) { assert(cx > 0); assert(cy > 0); cxDIB = cx ; cyDIB = cy ; int iSize = sizeof(BITMAPV5HEADER); memset(&BIHA, 0, iSize); //The following mask specification specifies a supported 32 BPP //alpha format for Windows XP. BIHA.bV5Size = sizeof(BITMAPV5HEADER); BIHA.bV5Width = cx; BIHA.bV5Height = cy; BIHA.bV5Planes = 1; BIHA.bV5BitCount = 32; BIHA.bV5SizeImage = w*h*4; BIHA.bV5CSType = LCS_sRGB; BIHA.bV5Compression = BI_BITFIELDS; BIHA.bV5RedMask = 0x00FF0000; BIHA.bV5GreenMask = 0x0000FF00; BIHA.bV5BlueMask = 0x000000FF; BIHA.bV5AlphaMask = 0xFF000000; if(pdcDIB) verify(DeleteDC(pdcDIB)); pdcDIB = CreateCompatibleDC(NULL); assert(pdcDIB); if(hbmpDIB) verify(DeleteObject(hbmpDIB)); hbmpDIB = CreateDIBSection( pdcDIB, (BITMAPINFO*)&BIHA, DIB_RGB_COLORS, &bmp_cnt, NULL, 0); memset(bmp_cnt, 0x00, 4*w*h); assert(hbmpDIB); assert(bmp_cnt); if(hbmpDIB) SelectObject(pdcDIB, hbmpDIB); } BOOL CreateHGLRC() { DWORD dwFlags = PFD_DRAW_TO_BITMAP|PFD_SUPPORT_GDI|PFD_SUPPORT_DIRECTDRAW|PFD_GENERIC_ACCELERATED; PIXELFORMATDESCRIPTOR pfd ; memset(&pfd,0, sizeof(PIXELFORMATDESCRIPTOR)) ; pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = dwFlags ; pfd.iPixelType = PFD_TYPE_RGBA ; pfd.cColorBits = 32 ; pfd.cDepthBits = 24 ; pfd.cStencilBits = 8; pfd.cAlphaBits = 8; pfd.iLayerType = PFD_MAIN_PLANE; int PixelFormat = ChoosePixelFormat(pdcDIB, &pfd); if (PixelFormat == 0){ assert(0); return FALSE ; } BOOL bResult = SetPixelFormat(pdcDIB, PixelFormat, &pfd); if (bResult==FALSE){ assert(0); return FALSE ; } m_hrc = wglCreateContext(pdcDIB); if (!m_hrc){ assert(0); return FALSE; } return TRUE; } BOOL CreateHDXRC(HWND hWnd) { D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information HRESULT hr; ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use d3dpp.Windowed = TRUE; // program windowed, not fullscreen d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames d3dpp.hDeviceWindow = hWnd; // set the window to be used by Direct3D d3dpp.BackBufferWidth = w; d3dpp.BackBufferHeight = h; d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; // create a device class using this information and information from the d3dpp stuct hr = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); return TRUE; } LRESULT CALLBACK WindowFunc(HWND hWnd,UINT msg, WPARAM wParam, LPARAM lParam) { static int s_enter = 0; PAINTSTRUCT ps; int i; char szDbg[MAX_PATH]; char szLastDbg[MAX_PATH]; DWORD dwTime; static DWORD s_dwTime = 0; static int s_nTime = 0; static DWORD s_cumTime = 0; static int s_lMX = 0; static int s_lMY = 0; static bool s_bMCD = false; POINT pt; CURSORINFO pci; switch(msg) { case WM_ERASEBKGND: return 0; break; case WM_CREATE: break; case WM_LBUTTONDOWN: s_bMCD = true; GetCursorPos(&pt); s_lMX = pt.x; s_lMY = pt.y; break; case WM_LBUTTONUP: s_bMCD = false; break; case WM_MOUSEMOVE: if (s_bMCD && (wParam&MK_LBUTTON)==0) s_bMCD = false; break; case WM_DESTROY: #ifndef USE_DIRECT_X if(m_hrc) { wglMakeCurrent(NULL, NULL); wglDeleteContext(m_hrc) ; } #else if (d3ddev) d3ddev->Release(); // close and release the 3D device if (d3d) d3d->Release(); // close and release Direct3D #endif PostQuitMessage(0) ; break; case WM_PAINT: hDC = BeginPaint(hWnd, &ps); renderSC(); // OpenGL -> DIB draw(hDC); // DIB -> hDC EndPaint(hWnd, &ps); break; case WM_TIMER: // how to query mouse lbutton... to turn off moving our screen... ++s_nTime; if (s_bMCD) { GetCursorPos(&pt); g_dlgx += pt.x - s_lMX; g_dlgy += pt.y - s_lMY; s_lMX = pt.x; s_lMY = pt.y; } //#ifndef USE_DIRECT_X hDC = GetDC(hWnd); renderSC(); // OpenGL -> DIB draw(hDC); // DIB -> hDC ReleaseDC(hWnd, hDC); #ifndef COMPILE_WITH_TRANSPARENCY SetWindowPos(hWnd, NULL, g_dlgx, g_dlgy, 0, 0, SWP_NOOWNERZORDER|SWP_NOSIZE); #endif break; case WM_SIZE: w = LOWORD(lParam); h = HIWORD(lParam); #ifndef USE_DIRECT_X // --- initialize Open GL --- wglMakeCurrent(NULL, NULL); wglDeleteContext(m_hrc); CreateDIB(w, h); CreateHGLRC(); verify(wglMakeCurrent(pdcDIB, m_hrc)); initSC(); resizeSC(w, h); renderSC(); #else // --- initialize Direct X --- d3d = Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface CreateDIB(w, h); CreateHDXRC(hWnd); initDX(); renderSC(); #endif break; case WM_KEYDOWN: if (toupper(LOBYTE(wParam))=='A') { int nFPS, nRefXFer; nFPS = (g_dwPrepareDrawPerf+g_dwDrawPerf+g_dwGetBuf+g_dwDrawCopyBuf+g_dwUnlockBuf+g_dwUpdatewin32)/s_nTime; nFPS = 1000000/nFPS; unsigned char *pS, *pD; pS = new unsigned char[w*h*4]; pD = new unsigned char[w*h*4]; _beginProf(); memcpy(pD, pS, w*h*4); nRefXFer = _getProf(); delete pS; delete pD; sprintf(szLastDbg, "Average %d FPS using %d Steps (memcpy ref=%dus)\n(after %d times: %dx%d): prepare=%d us, draw=%d us\n---> getBuf=%d us, copyBuf=%d us, unlock=%d us, updateWin32=%d us\n", nFPS, g_nINTSTEP, nRefXFer, s_nTime, w, h, g_dwPrepareDrawPerf/s_nTime, g_dwDrawPerf/s_nTime, g_dwGetBuf/s_nTime, g_dwDrawCopyBuf/s_nTime, g_dwUnlockBuf/s_nTime, g_dwUpdatewin32/s_nTime); MessageBox(NULL, szLastDbg, "Info...", MB_OK); } else if (toupper(LOBYTE(wParam))=='1') { g_nINTSTEP = 1; s_nTime = 0; g_dwPrepareDrawPerf = g_dwDrawPerf = g_dwGetBuf = 0; g_dwDrawCopyBuf = g_dwUnlockBuf = g_dwUpdatewin32 = 0; } else if (toupper(LOBYTE(wParam))=='2') { g_nINTSTEP = 2; s_nTime = 0; g_dwPrepareDrawPerf = g_dwDrawPerf = g_dwGetBuf = 0; g_dwDrawCopyBuf = g_dwUnlockBuf = g_dwUpdatewin32 = 0; } else if (toupper(LOBYTE(wParam))=='3') { g_nINTSTEP = 4; s_nTime = 0; g_dwPrepareDrawPerf = g_dwDrawPerf = g_dwGetBuf = 0; g_dwDrawCopyBuf = g_dwUnlockBuf = g_dwUpdatewin32 = 0; } else if (toupper(LOBYTE(wParam))=='4') { g_nINTSTEP = 8; s_nTime = 0; g_dwPrepareDrawPerf = g_dwDrawPerf = g_dwGetBuf = 0; g_dwDrawCopyBuf = g_dwUnlockBuf = g_dwUpdatewin32 = 0; } else if (toupper(LOBYTE(wParam))=='5') { g_nINTSTEP = 16; s_nTime = 0; g_dwPrepareDrawPerf = g_dwDrawPerf = g_dwGetBuf = 0; g_dwDrawCopyBuf = g_dwUnlockBuf = g_dwUpdatewin32 = 0; } else if (toupper(LOBYTE(wParam))=='6') { g_nINTSTEP = 24; s_nTime = 0; g_dwPrepareDrawPerf = g_dwDrawPerf = g_dwGetBuf = 0; g_dwDrawCopyBuf = g_dwUnlockBuf = g_dwUpdatewin32 = 0; } else if (toupper(LOBYTE(wParam))=='7') { g_nINTSTEP = 32; s_nTime = 0; g_dwPrepareDrawPerf = g_dwDrawPerf = g_dwGetBuf = 0; g_dwDrawCopyBuf = g_dwUnlockBuf = g_dwUpdatewin32 = 0; } else if (toupper(LOBYTE(wParam))=='8') { g_nINTSTEP = 40; s_nTime = 0; g_dwPrepareDrawPerf = g_dwDrawPerf = g_dwGetBuf = 0; g_dwDrawCopyBuf = g_dwUnlockBuf = g_dwUpdatewin32 = 0; } else if (toupper(LOBYTE(wParam))=='Q') { g_bTryFaster = !g_bTryFaster; s_cumTime = 0; s_nTime = 0; } else { g_bSwitchAlpha = !g_bSwitchAlpha; s_cumTime = 0; s_nTime = 0; } break; default: return DefWindowProc(hWnd,msg,wParam,lParam); } return 0; } int WINAPI _tWinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR str,int nWinMode) { WNDCLASSEX wc; memset(&wc, 0, sizeof(wc)); wc.cbSize = sizeof(WNDCLASSEX); wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)WindowFunc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hThisInst; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) (COLOR_WINDOW); wc.lpszClassName = szAppName; char szDbg[MAX_PATH]; _beginProf(); timeBeginPeriod(1); sprintf(szDbg, "delay = %d us\n", _getProf()); g_dwPrepareDrawPerf = g_dwDrawPerf = g_dwDrawCopyBuf = g_dwGetBuf = 0; g_dwUpdatewin32 = g_dwUnlockBuf = 0; if(!RegisterClassEx(&wc)) { MessageBox(NULL, _T("RegisterClassEx - failed"), _T("Error"), MB_OK | MB_ICONERROR); return FALSE; } #ifdef COMPILE_WITH_TRANSPARENCY HWND hWnd = CreateWindowEx(WS_EX_LAYERED, szAppName, wcWndName, WS_VISIBLE | WS_POPUP, 0, 0, w, h, NULL, NULL, hThisInst, NULL); #else HWND hWnd = CreateWindowEx(WS_EX_TOOLWINDOW, szAppName, wcWndName, (WS_OVERLAPPED | WS_POPUP), 0, 0, w, h, NULL, NULL, hThisInst, NULL); #endif if(!hWnd){ MessageBox(NULL, _T("CreateWindowEx - failed"), _T("Error"), MB_OK | MB_ICONERROR); return FALSE; } #ifndef COMPILE_WITH_TRANSPARENCY ShowWindow(hWnd, SW_NORMAL); UpdateWindow(hWnd); #endif g_hWnd = hWnd; MSG msg; SetTimer(hWnd, 1, TIMER_DELAY, NULL); while(1) { while (PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)){ if (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } else return 0; } } timeEndPeriod(1); return (FALSE); }
added on the 2016-11-07 17:17:46 by F-Cycles F-Cycles

login