X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。
| Revision | 161 (tree) |
|---|---|
| Time | 2017-01-21 21:58:49 |
| Author | |
OpenGLにて、SS撮影に対応、DDSファイルのミップマップを回避するよう暫定対策、コンパイラの警告対策。
| @@ -588,7 +588,7 @@ | ||
| 588 | 588 | char filename2[MAX_PATH]; |
| 589 | 589 | |
| 590 | 590 | //ファイル名を小文字へ変換(拡張子判定用) |
| 591 | - for(int i=0; i<strlen(filename); i++){ | |
| 591 | + for(int i=0; i<(int)strlen(filename); i++){ | |
| 592 | 592 | filename2[i] = (char)tolower(filename[i]); |
| 593 | 593 | } |
| 594 | 594 | filename2[ strlen(filename) ] = '\0'; |
| @@ -828,7 +828,7 @@ | ||
| 828 | 828 | fread(pallet, 1, 16*4, fp); |
| 829 | 829 | |
| 830 | 830 | for(int h=height-1; h>=0; h--){ |
| 831 | - for(int w=0; w<(width/2); w++){ | |
| 831 | + for(int w=0; w<((int)width/2); w++){ | |
| 832 | 832 | fread(&pixel, 1, 1, fp); |
| 833 | 833 | pixelH = (pixel >> 4)&0x0F; |
| 834 | 834 | pixelL = pixel&0x0F; |
| @@ -865,7 +865,7 @@ | ||
| 865 | 865 | fread(pallet, 1, 256*4, fp); |
| 866 | 866 | |
| 867 | 867 | for(int h=height-1; h>=0; h--){ |
| 868 | - for(int w=0; w<width; w++){ | |
| 868 | + for(int w=0; w<(int)width; w++){ | |
| 869 | 869 | fread(&pixel, 1, 1, fp); |
| 870 | 870 | |
| 871 | 871 | data[(h*width+w)*4 + 0] = pallet[pixel*4 + 2]; |
| @@ -889,7 +889,7 @@ | ||
| 889 | 889 | if( index == 24 ){ |
| 890 | 890 | unsigned char pixel[3]; |
| 891 | 891 | for(int h=height-1; h>=0; h--){ |
| 892 | - for(int w=0; w<width; w++){ | |
| 892 | + for(int w=0; w<(int)width; w++){ | |
| 893 | 893 | fread(&pixel, 1, 3, fp); |
| 894 | 894 | |
| 895 | 895 | data[(h*width+w)*4 + 0] = pixel[2]; |
| @@ -911,7 +911,7 @@ | ||
| 911 | 911 | if( index == 32 ){ |
| 912 | 912 | unsigned char pixel[4]; |
| 913 | 913 | for(int h=height-1; h>=0; h--){ |
| 914 | - for(int w=0; w<width; w++){ | |
| 914 | + for(int w=0; w<(int)width; w++){ | |
| 915 | 915 | fread(&pixel, 1, 4, fp); |
| 916 | 916 | |
| 917 | 917 | data[(h*width+w)*4 + 0] = pixel[2]; |
| @@ -955,6 +955,7 @@ | ||
| 955 | 955 | unsigned int width, height; |
| 956 | 956 | unsigned int index; |
| 957 | 957 | unsigned int flag; |
| 958 | + unsigned int Caps; | |
| 958 | 959 | |
| 959 | 960 | //ファイルを読み込む |
| 960 | 961 | fp = fopen(filename, "rb"); |
| @@ -974,6 +975,8 @@ | ||
| 974 | 975 | width = *(int*)&(header[0x10]); |
| 975 | 976 | height = *(int*)&(header[0x0C]); |
| 976 | 977 | index = *(int*)&(header[0x58]); |
| 978 | + flag = *(int*)&(header[0x08]); | |
| 979 | + Caps = *(int*)&(header[0x70]); | |
| 977 | 980 | |
| 978 | 981 | if( (index != 16)&&(index != 32) ){ |
| 979 | 982 | fclose(fp); |
| @@ -980,10 +983,15 @@ | ||
| 980 | 983 | return false; //対応してないフォーマット |
| 981 | 984 | } |
| 982 | 985 | |
| 986 | + if( (flag & 0x00020000)&&(Caps & 0x00400000) ){ //DDSD_MIPMAPCOUNT・DDSCAPS_MIPMAP | |
| 987 | + //ミップマップ情報読み込み(ダミー) | |
| 988 | + fread(header, 1, 128, fp); | |
| 989 | + } | |
| 990 | + | |
| 983 | 991 | unsigned char *data = new unsigned char [width*height*4]; |
| 984 | 992 | |
| 985 | - for(int h=0; h<height; h++){ | |
| 986 | - for(int w=0; w<width; w++){ | |
| 993 | + for(int h=0; h<(int)height; h++){ | |
| 994 | + for(int w=0; w<(int)width; w++){ | |
| 987 | 995 | unsigned char pixel[4]; |
| 988 | 996 | fread(&pixel, 1, index/8, fp); |
| 989 | 997 |
| @@ -1049,7 +1057,7 @@ | ||
| 1049 | 1057 | |
| 1050 | 1058 | //領域確保 |
| 1051 | 1059 | img = (JSAMPARRAY)new JSAMPROW [cinfo.output_height]; |
| 1052 | - for(int i=0; i<cinfo.output_height; i++){ | |
| 1060 | + for(int i=0; i<(int)cinfo.output_height; i++){ | |
| 1053 | 1061 | img[i] = (JSAMPROW)new JSAMPLE [cinfo.output_width * cinfo.out_color_components]; |
| 1054 | 1062 | } |
| 1055 | 1063 |
| @@ -1072,11 +1080,11 @@ | ||
| 1072 | 1080 | |
| 1073 | 1081 | unsigned char *data = new unsigned char [width*height*4]; |
| 1074 | 1082 | |
| 1075 | - for(int h=0; h<height; h++){ | |
| 1083 | + for(int h=0; h<(int)height; h++){ | |
| 1076 | 1084 | //1ライン分取得 |
| 1077 | 1085 | JSAMPROW p = img[h]; |
| 1078 | 1086 | |
| 1079 | - for(int w=0; w<width; w++){ | |
| 1087 | + for(int w=0; w<(int)width; w++){ | |
| 1080 | 1088 | data[(h*width+w)*4 + 0] = p[w*3 + 0]; |
| 1081 | 1089 | data[(h*width+w)*4 + 1] = p[w*3 + 1]; |
| 1082 | 1090 | data[(h*width+w)*4 + 2] = p[w*3 + 2]; |
| @@ -1093,7 +1101,7 @@ | ||
| 1093 | 1101 | } |
| 1094 | 1102 | |
| 1095 | 1103 | //領域解放 |
| 1096 | - for(int i=0; i<cinfo.output_height; i++){ | |
| 1104 | + for(int i=0; i<(int)cinfo.output_height; i++){ | |
| 1097 | 1105 | delete [] img[i]; |
| 1098 | 1106 | } |
| 1099 | 1107 | delete [] img; |
| @@ -1192,11 +1200,11 @@ | ||
| 1192 | 1200 | //1ライン分の作業領域を確保 |
| 1193 | 1201 | png_bytep buf = new png_byte[width*4]; |
| 1194 | 1202 | |
| 1195 | - for(int h=0; h<height; h++){ | |
| 1203 | + for(int h=0; h<(int)height; h++){ | |
| 1196 | 1204 | //1ライン分取得 |
| 1197 | 1205 | png_read_row(pPng, buf, NULL); |
| 1198 | 1206 | |
| 1199 | - for(int w=0; w<width; w++){ | |
| 1207 | + for(int w=0; w<(int)width; w++){ | |
| 1200 | 1208 | data[(h*width+w)*4 + 0] = buf[w*4 + 0]; |
| 1201 | 1209 | data[(h*width+w)*4 + 1] = buf[w*4 + 1]; |
| 1202 | 1210 | data[(h*width+w)*4 + 2] = buf[w*4 + 2]; |
| @@ -1224,11 +1232,11 @@ | ||
| 1224 | 1232 | //1ライン分の作業領域を確保 |
| 1225 | 1233 | png_bytep buf = new png_byte[width]; |
| 1226 | 1234 | |
| 1227 | - for(int h=0; h<height; h++){ | |
| 1235 | + for(int h=0; h<(int)height; h++){ | |
| 1228 | 1236 | //1ライン分取得 |
| 1229 | 1237 | png_read_row(pPng, buf, NULL); |
| 1230 | 1238 | |
| 1231 | - for(int w=0; w<width; w++){ | |
| 1239 | + for(int w=0; w<(int)width; w++){ | |
| 1232 | 1240 | data[(h*width+w)*4 + 0] = palette[ buf[w] ].red; |
| 1233 | 1241 | data[(h*width+w)*4 + 1] = palette[ buf[w] ].green; |
| 1234 | 1242 | data[(h*width+w)*4 + 2] = palette[ buf[w] ].blue; |
| @@ -2061,7 +2069,7 @@ | ||
| 2061 | 2069 | int maxlen = 0; |
| 2062 | 2070 | int cnt = 0; |
| 2063 | 2071 | |
| 2064 | - for(int i=0; i<strlen(str); i++){ | |
| 2072 | + for(int i=0; i<(int)strlen(str); i++){ | |
| 2065 | 2073 | if( str[i] == '\n' ){ |
| 2066 | 2074 | if( maxlen < cnt ){ |
| 2067 | 2075 | maxlen = cnt; |
| @@ -2610,7 +2618,65 @@ | ||
| 2610 | 2618 | //! @return 成功:true 失敗:false |
| 2611 | 2619 | bool D3DGraphics::SaveScreenShot(char* filename) |
| 2612 | 2620 | { |
| 2613 | - return false; | |
| 2621 | + HDC hDC; | |
| 2622 | + FILE *fp; | |
| 2623 | + unsigned char header[54]; | |
| 2624 | + unsigned char pixel[3]; | |
| 2625 | + | |
| 2626 | + unsigned char *dataBuffer = new unsigned char [SCREEN_WIDTH * SCREEN_HEIGHT * 3]; | |
| 2627 | + | |
| 2628 | + //デバイスコンテキスト設定 | |
| 2629 | + hDC = GetDC(hWnd); | |
| 2630 | + wglMakeCurrent(hDC, hGLRC); | |
| 2631 | + | |
| 2632 | + //バッファに格納 | |
| 2633 | + glReadPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, dataBuffer); | |
| 2634 | + | |
| 2635 | + //ファイルを保存する | |
| 2636 | + fp = fopen(filename, "wb"); | |
| 2637 | + if( fp == NULL ){ | |
| 2638 | + delete [] dataBuffer; | |
| 2639 | + return false; //ファイルが保存できない | |
| 2640 | + } | |
| 2641 | + | |
| 2642 | + //ヘッダーを生成 | |
| 2643 | + for(int i=0; i<54; i++){ | |
| 2644 | + header[i] = 0x00; | |
| 2645 | + } | |
| 2646 | + header[0x00] = 'B'; | |
| 2647 | + header[0x01] = 'M'; | |
| 2648 | + header[0x0E] = 40; | |
| 2649 | + header[0x12] = (unsigned char)(SCREEN_WIDTH&0x000000FF); | |
| 2650 | + header[0x13] = (unsigned char)((SCREEN_WIDTH&0x0000FF00) >> 8); | |
| 2651 | + header[0x14] = (unsigned char)((SCREEN_WIDTH&0x00FF0000) >> 16); | |
| 2652 | + header[0x15] = (unsigned char)((SCREEN_WIDTH&0xFF000000) >> 24); | |
| 2653 | + header[0x16] = (unsigned char)(SCREEN_HEIGHT&0x000000FF); | |
| 2654 | + header[0x17] = (unsigned char)((SCREEN_HEIGHT&0x0000FF00) >> 8); | |
| 2655 | + header[0x18] = (unsigned char)((SCREEN_HEIGHT&0x00FF0000) >> 16); | |
| 2656 | + header[0x19] = (unsigned char)((SCREEN_HEIGHT&0xFF000000) >> 24); | |
| 2657 | + header[0x1C] = 24; | |
| 2658 | + | |
| 2659 | + //ヘッダーを書き込む | |
| 2660 | + fwrite(header, 1, 54, fp); | |
| 2661 | + | |
| 2662 | + for(int h=0; h<SCREEN_HEIGHT; h++){ | |
| 2663 | + for(int w=0; w<SCREEN_WIDTH; w++){ | |
| 2664 | + pixel[2] = dataBuffer[(h*SCREEN_WIDTH+w)*3 + 0]; | |
| 2665 | + pixel[1] = dataBuffer[(h*SCREEN_WIDTH+w)*3 + 1]; | |
| 2666 | + pixel[0] = dataBuffer[(h*SCREEN_WIDTH+w)*3 + 2]; | |
| 2667 | + | |
| 2668 | + fwrite(&pixel, 1, 3, fp); | |
| 2669 | + } | |
| 2670 | + } | |
| 2671 | + | |
| 2672 | + //ファイルハンドルを解放 | |
| 2673 | + fclose(fp); | |
| 2674 | + | |
| 2675 | + delete [] dataBuffer; | |
| 2676 | + | |
| 2677 | + ReleaseDC(hWnd, hDC); | |
| 2678 | + | |
| 2679 | + return true; | |
| 2614 | 2680 | } |
| 2615 | 2681 | |
| 2616 | 2682 | //! @brief カラーコードを取得 |