flat assembler
Message board for the users of flat assembler.
Index
> Tutorials and Examples > my GDI Win Graph tuto |
Author |
|
avcaballero 18 Aug 2013, 18:41
Hello there, if anyone interested I've just uploaded my updated tuto on GDI Win graphics.
There are here many new stuff from the last one though many to do yet, including translating it to English, but I'm getting more lazy to work on it, though surely I will keep on making things for it. In the other hand, there're many things that I've removed from the downloable version, that may be not in the interest of anybody. Now you can download the entire tuto from here. Also you can download the libs from here, but you need login first in my forum. The registering is 100% free, but you have to provide a valid email to complete it. I did it just for have an idea of how many times it was downloaded (at least one time for my checking ) and by who... I know, I know, you are rather shy and can't do it. Never mind, many codes really don't need libs... Besides, there're many new things from last one. Oops, I must say that the libs have failed while downloading, I will check it as soon as I can In the end... Good fun _________________ Siempre aprendiendo |
|||
18 Aug 2013, 18:41 |
|
avcaballero 19 Aug 2013, 06:12
Thank you, uart. Nice example!. Here it is another face sample in tinyc:
Code: /* ---------------------------------------------------------------------------- - TITULO : Doom Face Tiny C - ----- ----- - AUTOR : Alfonso Víctor Caballero Hurtado - ----- ----- - VERSION : 1.0 - ----- ----- - (c) 2013. http://www.abreojosensamblador.net - - Abre los Ojos a los Gráficos sobre Windows - ---------------------------------------------------------------------------- */ #define cdXPos 131 #define cdYPos 217 #define cdYSize 400 #define cdXSize 640 //cdYSize*1.6 #define cdColFondo COLOR_BTNFACE+1 // Color de fondo de la ventana #define cdVIcono IDI_APPLICATION #define cdVCursor IDC_ARROW #define cdVBarTipo NULL #define cdVBtnTipo WS_GROUP+WS_SYSMENU+WS_VISIBLE #define cdIdTimer 1 #define DIB_RGB_COLORS 0 #define cdSize 2 #include <windows.h> #include "../../../Lib/CCentW.h" LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; void CenterWindow(HWND) ; void PintaObjeto (void) ; void CreaBmpInfoHead (void) ; void Init (void) ; struct stPaleta { unsigned char Azul; unsigned char Verde; unsigned char Rojo; unsigned char Alfa; } miPaleta[256]; int *pMainDIB = NULL; BITMAPINFOHEADER bi; const unsigned char mDoomData[] = {0,0,0,0,0,76,74,74,74,73,72,72,72,72,72,73,74,74,76,0,0,0,0,0, 0,0,0,78,74,75,74,73,69,64,65,62,62,65,66,68,72,74,75,74,78,0,0,0, 0,0,78,74,72,69,68,64,63,62,67,65,68,68,68,69,69,72,72,75,76,78,0,0, 0,0,78,72,70,72,69,68,65,70,66,69,67,72,72,72,72,74,75,78,78,79,0,0, 0,79,77,74,72,74,69,68,69,69,69,69,76,69,74,76,74,76,78,79,79,79,79,0, 0,79,77,76,75,74,69,75,68,73,73,69,73,76,73,76,77,74,79,78,78,77,79,0, 0,79,76,76,72,72,75,69,75,73,72,73,73,69,69,69,70,70,73,76,77,76,79,0, 0,79,76,75,72,69,72,75,67,75,72,69,67,65,68,67,69,69,69,73,76,76,79,0, 0,79,76,74,69,66,65,67,67,65,65,65,65,65,65,67,67,65,66,69,75,76,79,0, 0,79,76,72,68,62,63,63,65,67,66,66,66,66,67,65,63,63,62,68,74,76,79,0, 0,79,76,72,68,62,58,59,62,64,67,69,69,67,64,62,59,58,62,68,72,76,79,0, 0,79,76,73,65,59,50,56,59,59,62,61,61,62,59,59,56,50,59,65,72,76,79,0, 65,73,76,72,73,73,75,67,60,65,72,65,65,72,65,60,67,75,73,73,72,76,73,65, 65,73,14,69,66,66,68,70,72,73,73,69,69,73,73,72,70,68,66,66,69,14,73,65, 69,73,148,65,72,163,225,224,162,163,165,61,61,165,163,162,224,225,163,72,65,14,8,73,69, 73,74,70,65,69,66,163,162,163,164,69,62,59,69,164,163,162,163,66,69,65,70,74,73, 70,74,70,22,61,64,66,69,66,63,61,213,212,61,63,66,69,66,64,61,22,70,74,70, 69,74,69,62,60,58,60,63,213,55,59,213,212,59,55,213,63,60,58,60,62,69,74,69, 0,74,70,67,66,64,61,213,53,60,61,212,210,61,60,53,213,61,64,66,67,70,74,0, 0,74,72,68,67,64,58,57,61,66,68,144,144,68,66,61,57,58,64,67,68,72,74,0, 0,0,72,65,68,61,55,59,64,75,72,70,70,72,75,64,59,55,61,68,65,72,0,0, 0,0,74,63,68,59,57,62,62,61,64,67,67,64,61,62,62,57,59,68,63,74,0,0, 0,0,75,66,67,61,59,62,61,57,54,60,60,54,57,61,62,59,61,67,66,75,0,0, 0,0,0,70,66,63,61,69,72,165,165,165,165,165,165,72,69,61,63,66,70,0,0,0, 0,0,0,75,69,65,63,63,63,61,59,213,213,59,61,63,63,63,65,69,75,0,0,0, 0,0,0,0,73,66,62,60,63,66,69,71,71,69,66,63,60,62,66,73,0,0,0,0, 0,0,0,0,0,73,66,62,60,63,63,59,59,63,63,60,62,66,73,0,0,0,0,0, 0,0,0,0,0,0,75,70,65,61,59,54,54,59,61,65,70,75,0,0,0,0,0,0, 0,0,0,0,0,0,0,79,73,69,67,67,67,67,69,73,79,0,0,0,0,0,0,0 }; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static TCHAR szAppName[] = TEXT ("DoomFace") ; HWND hWnd ; MSG msg ; WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hbrBackground = 0;//cdColFondo ; //no se debe poner (HBRUSH) wndclass.lpszMenuName = NULL ; wndclass.lpszClassName = szAppName ; wndclass.hInstance = GetModuleHandle (NULL) ; wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; if (!RegisterClass (&wndclass)) { MessageBox (NULL, TEXT ("This program requires Windows NT!"), TEXT ("Error"), MB_ICONERROR) ; return 0 ; } hWnd = CreateWindow (szAppName, TEXT ("Doom Face"), cdVBtnTipo,//WS_OVERLAPPEDWINDOW, cdXPos, cdYPos, cdXSize, cdYSize, NULL, NULL, hInstance, NULL) ; ShowWindow (hWnd, iCmdShow) ; UpdateWindow (hWnd) ; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } return msg.wParam ; } LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static HDC bufDIBDC, hBackDC; static HBITMAP hMainDIB, bufBMP ; HDC hdc ; PAINTSTRUCT ps ; static HGDIOBJ hOldBmp, hGDITmp, hOldDIB; int bResult; switch (message) { case WM_CHAR : if (wParam == VK_ESCAPE) { //MessageBox (NULL, TEXT ("WM_CHAR"), TEXT ("You were in..."), 0) ; // Destruimos KillTimer (hWnd, cdIdTimer) ; hGDITmp = SelectObject (hBackDC, hOldBmp); bResult = DeleteObject (bufBMP); bResult = DeleteDC (hBackDC); hGDITmp = SelectObject (bufDIBDC, hOldDIB); bResult = DeleteDC (bufDIBDC); bResult = DeleteObject (hMainDIB); PostQuitMessage(0); } return 0 ; case WM_CREATE: CreaBmpInfoHead () ; hdc = GetDC(hWnd); // Crea un búfer dib para PintaObjeto. pMainDIB es un puntero a él bufDIBDC = CreateCompatibleDC (hdc); hMainDIB = CreateDIBSection(hdc, (BITMAPINFO *) &bi, DIB_RGB_COLORS, (void **) &pMainDIB, NULL, 0); hOldDIB = SelectObject (bufDIBDC, hMainDIB); // Crea el búfer BMP hBackDC = CreateCompatibleDC (hdc); bufBMP = CreateCompatibleBitmap (hdc, cdXSize, cdYSize); hOldBmp = SelectObject (hBackDC, bufBMP); ReleaseDC (hWnd, hdc); // Libera device context Init () ; CenterWindow(hWnd); //SetTimer (hWnd, cdIdTimer, 20, NULL) ; return 0 ; case WM_TIMER : InvalidateRect (hWnd, NULL, FALSE) ; return 0 ; case WM_PAINT : { hdc = BeginPaint(hWnd, &ps); //PintaObjeto (); bResult = BitBlt(hBackDC, 0, 0, cdXSize, cdYSize, bufDIBDC, 0, 0, SRCCOPY); bResult = BitBlt(hdc, 0, 0, cdXSize, cdYSize, hBackDC, 0, 0, SRCCOPY); EndPaint(hWnd, &ps); return 0 ; } case WM_DESTROY : /*if (i++ == 0) MessageBox (NULL, TEXT ("WM_DESTROY"), TEXT ("You were in..."), 0) ;*/ // Destruimos KillTimer (hWnd, cdIdTimer) ; hGDITmp = SelectObject (hBackDC, hOldBmp); bResult = DeleteObject (bufBMP); bResult = DeleteDC (hBackDC); hGDITmp = SelectObject (bufDIBDC, hOldDIB); bResult = DeleteDC (bufDIBDC); bResult = DeleteObject (hMainDIB); bResult = DestroyWindow (hWnd); PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hWnd, message, wParam, lParam) ; } void CreaBmpInfoHead (void) { memset(&bi, 0, sizeof(BITMAPINFOHEADER)); bi.biSize = sizeof(BITMAPINFOHEADER); bi.biWidth = cdXSize; bi.biHeight = -1*cdYSize; bi.biPlanes = 1; bi.biBitCount = 32; bi.biCompression = 0;//BI_RGB; } void CreaPaleta (void) { miPaleta[ 14].Azul = 8; miPaleta[ 14].Verde = 12; miPaleta[ 14].Rojo = 17; miPaleta[ 22].Azul = 30; miPaleta[ 22].Verde = 30; miPaleta[ 22].Rojo = 54; miPaleta[ 48].Azul = 55; miPaleta[ 48].Verde = 58; miPaleta[ 48].Rojo = 63; miPaleta[ 49].Azul = 52; miPaleta[ 49].Verde = 56; miPaleta[ 49].Rojo = 63; miPaleta[ 50].Azul = 49; miPaleta[ 50].Verde = 54; miPaleta[ 50].Rojo = 63; miPaleta[ 51].Azul = 46; miPaleta[ 51].Verde = 52; miPaleta[ 51].Rojo = 63; miPaleta[ 52].Azul = 44; miPaleta[ 52].Verde = 51; miPaleta[ 52].Rojo = 63; miPaleta[ 53].Azul = 41; miPaleta[ 53].Verde = 49; miPaleta[ 53].Rojo = 63; miPaleta[ 54].Azul = 38; miPaleta[ 54].Verde = 47; miPaleta[ 54].Rojo = 63; miPaleta[ 55].Azul = 36; miPaleta[ 55].Verde = 46; miPaleta[ 55].Rojo = 63; miPaleta[ 56].Azul = 32; miPaleta[ 56].Verde = 44; miPaleta[ 56].Rojo = 63; miPaleta[ 57].Azul = 30; miPaleta[ 57].Verde = 42; miPaleta[ 57].Rojo = 63; miPaleta[ 58].Azul = 28; miPaleta[ 58].Verde = 40; miPaleta[ 58].Rojo = 59; miPaleta[ 59].Azul = 26; miPaleta[ 59].Verde = 38; miPaleta[ 59].Rojo = 57; miPaleta[ 60].Azul = 24; miPaleta[ 60].Verde = 36; miPaleta[ 60].Rojo = 55; miPaleta[ 61].Azul = 22; miPaleta[ 61].Verde = 34; miPaleta[ 61].Rojo = 53; miPaleta[ 62].Azul = 20; miPaleta[ 62].Verde = 32; miPaleta[ 62].Rojo = 51; miPaleta[ 63].Azul = 19; miPaleta[ 63].Verde = 31; miPaleta[ 63].Rojo = 50; miPaleta[ 64].Azul = 18; miPaleta[ 64].Verde = 30; miPaleta[ 64].Rojo = 47; miPaleta[ 65].Azul = 17; miPaleta[ 65].Verde = 28; miPaleta[ 65].Rojo = 44; miPaleta[ 66].Azul = 16; miPaleta[ 66].Verde = 27; miPaleta[ 66].Rojo = 42; miPaleta[ 67].Azul = 15; miPaleta[ 67].Verde = 26; miPaleta[ 67].Rojo = 40; miPaleta[ 68].Azul = 14; miPaleta[ 68].Verde = 24; miPaleta[ 68].Rojo = 38; miPaleta[ 69].Azul = 13; miPaleta[ 69].Verde = 23; miPaleta[ 69].Rojo = 35; miPaleta[ 70].Azul = 12; miPaleta[ 70].Verde = 21; miPaleta[ 70].Rojo = 33; miPaleta[ 71].Azul = 11; miPaleta[ 71].Verde = 20; miPaleta[ 71].Rojo = 31; miPaleta[ 72].Azul = 10; miPaleta[ 72].Verde = 19; miPaleta[ 72].Rojo = 29; miPaleta[ 73].Azul = 9; miPaleta[ 73].Verde = 17; miPaleta[ 73].Rojo = 26; miPaleta[ 74].Azul = 8; miPaleta[ 74].Verde = 16; miPaleta[ 74].Rojo = 23; miPaleta[ 75].Azul = 7; miPaleta[ 75].Verde = 15; miPaleta[ 75].Rojo = 20; miPaleta[ 76].Azul = 6; miPaleta[ 76].Verde = 13; miPaleta[ 76].Rojo = 18; miPaleta[ 77].Azul = 5; miPaleta[ 77].Verde = 11; miPaleta[ 77].Rojo = 15; miPaleta[ 78].Azul = 4; miPaleta[ 78].Verde = 10; miPaleta[ 78].Rojo = 12; miPaleta[ 79].Azul = 3; miPaleta[ 79].Verde = 8; miPaleta[ 79].Rojo = 10; miPaleta[144].Azul = 24; miPaleta[144].Verde = 32; miPaleta[144].Rojo = 39; miPaleta[148].Azul = 12; miPaleta[148].Verde = 20; miPaleta[148].Rojo = 25; miPaleta[162].Azul = 16; miPaleta[162].Verde = 46; miPaleta[162].Rojo = 53; miPaleta[163].Azul = 11; miPaleta[163].Verde = 38; miPaleta[163].Rojo = 48; miPaleta[164].Azul = 7; miPaleta[164].Verde = 30; miPaleta[164].Rojo = 43; miPaleta[165].Azul = 4; miPaleta[165].Verde = 22; miPaleta[165].Rojo = 38; miPaleta[210].Azul = 46; miPaleta[210].Verde = 53; miPaleta[210].Rojo = 63; miPaleta[212].Azul = 30; miPaleta[212].Verde = 44; miPaleta[212].Rojo = 63; miPaleta[213].Azul = 22; miPaleta[213].Verde = 40; miPaleta[213].Rojo = 63; miPaleta[224].Azul = 63; miPaleta[224].Verde = 63; miPaleta[224].Rojo = 63; miPaleta[225].Azul = 53; miPaleta[225].Verde = 63; miPaleta[225].Rojo = 63; } void DrawFace (void) { int x, y, z, z2, i, c; unsigned char d; i = 0; for (y = 1; y <= 29 * cdSize; y += cdSize) { for (x = 1; x <= 24 * cdSize; x += cdSize) { d = mDoomData[i++]; for (z = 1; z <= cdSize; z++) { for (z2 = 0; z2 < cdSize; z2++) { c = (miPaleta[d].Azul<<2) + (miPaleta[d].Verde<<10)+(miPaleta[d].Rojo<<18); *(pMainDIB + (y+z2)*cdXSize+x+z-1)= c; *(pMainDIB + (y+z-1)*cdXSize+x+z2)= c; *(pMainDIB + (y+z-1)*cdXSize+x+z-1)= c; } } } } } void Init (void) { CreaPaleta () ; DrawFace (); } |
|||
19 Aug 2013, 06:12 |
|
Walter 21 Aug 2013, 03:04
Flag Demo
Last edited by Walter on 21 Aug 2013, 17:52; edited 2 times in total |
|||
21 Aug 2013, 03:04 |
|
avcaballero 21 Aug 2013, 06:26
Hmmm, it sounds familiar to me You can get it from here
_________________ Siempre aprendiendo |
|||
21 Aug 2013, 06:26 |
|
avcaballero 06 Sep 2013, 06:43
Updated with a new chapter about optimizations. Only in TinyC and no exe, just c files uploaded. Any suggestion?
Regards _________________ Siempre aprendiendo |
|||
06 Sep 2013, 06:43 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.