• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。


Commit MetaInfo

Revision161 (tree)
Time2017-01-21 21:58:49
Authorxops-mikan

Log Message

OpenGLにて、SS撮影に対応、DDSファイルのミップマップを回避するよう暫定対策、コンパイラの警告対策。

Change Summary

Incremental Difference

--- trunk/d3dgraphics-opengl.cpp (revision 160)
+++ trunk/d3dgraphics-opengl.cpp (revision 161)
@@ -588,7 +588,7 @@
588588 char filename2[MAX_PATH];
589589
590590 //ファイル名を小文字へ変換(拡張子判定用)
591- for(int i=0; i<strlen(filename); i++){
591+ for(int i=0; i<(int)strlen(filename); i++){
592592 filename2[i] = (char)tolower(filename[i]);
593593 }
594594 filename2[ strlen(filename) ] = '\0';
@@ -828,7 +828,7 @@
828828 fread(pallet, 1, 16*4, fp);
829829
830830 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++){
832832 fread(&pixel, 1, 1, fp);
833833 pixelH = (pixel >> 4)&0x0F;
834834 pixelL = pixel&0x0F;
@@ -865,7 +865,7 @@
865865 fread(pallet, 1, 256*4, fp);
866866
867867 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++){
869869 fread(&pixel, 1, 1, fp);
870870
871871 data[(h*width+w)*4 + 0] = pallet[pixel*4 + 2];
@@ -889,7 +889,7 @@
889889 if( index == 24 ){
890890 unsigned char pixel[3];
891891 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++){
893893 fread(&pixel, 1, 3, fp);
894894
895895 data[(h*width+w)*4 + 0] = pixel[2];
@@ -911,7 +911,7 @@
911911 if( index == 32 ){
912912 unsigned char pixel[4];
913913 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++){
915915 fread(&pixel, 1, 4, fp);
916916
917917 data[(h*width+w)*4 + 0] = pixel[2];
@@ -955,6 +955,7 @@
955955 unsigned int width, height;
956956 unsigned int index;
957957 unsigned int flag;
958+ unsigned int Caps;
958959
959960 //ファイルを読み込む
960961 fp = fopen(filename, "rb");
@@ -974,6 +975,8 @@
974975 width = *(int*)&(header[0x10]);
975976 height = *(int*)&(header[0x0C]);
976977 index = *(int*)&(header[0x58]);
978+ flag = *(int*)&(header[0x08]);
979+ Caps = *(int*)&(header[0x70]);
977980
978981 if( (index != 16)&&(index != 32) ){
979982 fclose(fp);
@@ -980,10 +983,15 @@
980983 return false; //対応してないフォーマット
981984 }
982985
986+ if( (flag & 0x00020000)&&(Caps & 0x00400000) ){ //DDSD_MIPMAPCOUNT・DDSCAPS_MIPMAP
987+ //ミップマップ情報読み込み(ダミー)
988+ fread(header, 1, 128, fp);
989+ }
990+
983991 unsigned char *data = new unsigned char [width*height*4];
984992
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++){
987995 unsigned char pixel[4];
988996 fread(&pixel, 1, index/8, fp);
989997
@@ -1049,7 +1057,7 @@
10491057
10501058 //領域確保
10511059 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++){
10531061 img[i] = (JSAMPROW)new JSAMPLE [cinfo.output_width * cinfo.out_color_components];
10541062 }
10551063
@@ -1072,11 +1080,11 @@
10721080
10731081 unsigned char *data = new unsigned char [width*height*4];
10741082
1075- for(int h=0; h<height; h++){
1083+ for(int h=0; h<(int)height; h++){
10761084 //1ライン分取得
10771085 JSAMPROW p = img[h];
10781086
1079- for(int w=0; w<width; w++){
1087+ for(int w=0; w<(int)width; w++){
10801088 data[(h*width+w)*4 + 0] = p[w*3 + 0];
10811089 data[(h*width+w)*4 + 1] = p[w*3 + 1];
10821090 data[(h*width+w)*4 + 2] = p[w*3 + 2];
@@ -1093,7 +1101,7 @@
10931101 }
10941102
10951103 //領域解放
1096- for(int i=0; i<cinfo.output_height; i++){
1104+ for(int i=0; i<(int)cinfo.output_height; i++){
10971105 delete [] img[i];
10981106 }
10991107 delete [] img;
@@ -1192,11 +1200,11 @@
11921200 //1ライン分の作業領域を確保
11931201 png_bytep buf = new png_byte[width*4];
11941202
1195- for(int h=0; h<height; h++){
1203+ for(int h=0; h<(int)height; h++){
11961204 //1ライン分取得
11971205 png_read_row(pPng, buf, NULL);
11981206
1199- for(int w=0; w<width; w++){
1207+ for(int w=0; w<(int)width; w++){
12001208 data[(h*width+w)*4 + 0] = buf[w*4 + 0];
12011209 data[(h*width+w)*4 + 1] = buf[w*4 + 1];
12021210 data[(h*width+w)*4 + 2] = buf[w*4 + 2];
@@ -1224,11 +1232,11 @@
12241232 //1ライン分の作業領域を確保
12251233 png_bytep buf = new png_byte[width];
12261234
1227- for(int h=0; h<height; h++){
1235+ for(int h=0; h<(int)height; h++){
12281236 //1ライン分取得
12291237 png_read_row(pPng, buf, NULL);
12301238
1231- for(int w=0; w<width; w++){
1239+ for(int w=0; w<(int)width; w++){
12321240 data[(h*width+w)*4 + 0] = palette[ buf[w] ].red;
12331241 data[(h*width+w)*4 + 1] = palette[ buf[w] ].green;
12341242 data[(h*width+w)*4 + 2] = palette[ buf[w] ].blue;
@@ -2061,7 +2069,7 @@
20612069 int maxlen = 0;
20622070 int cnt = 0;
20632071
2064- for(int i=0; i<strlen(str); i++){
2072+ for(int i=0; i<(int)strlen(str); i++){
20652073 if( str[i] == '\n' ){
20662074 if( maxlen < cnt ){
20672075 maxlen = cnt;
@@ -2610,7 +2618,65 @@
26102618 //! @return 成功:true 失敗:false
26112619 bool D3DGraphics::SaveScreenShot(char* filename)
26122620 {
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;
26142680 }
26152681
26162682 //! @brief カラーコードを取得