ページ 11

DXライブラリを使った画像の描画

Posted: 2012年10月03日(水) 03:54
by たばさ
DXライブラリを使ってゲームを作っているのですが、画像の表示がうまくいきません。
開発環境はVisual C++ 2010でWindows7 32bit上で作っています。
一応タイトル画面まで作ったのですがそこで問題ができました。
自分は32bitと64bitの両方を使用できる環境なのですが64bitのほうでプログラムを作動させると
下のコードのback_handleに格納された画像が表示できません。
32bitのほうだとうまくいきます。

コード:


#include "DxLib.h"
#include "Keyboard.h"
#include <math.h>
#include "Mode.h"

#define PI 3.1415926f

static int start_flag = 0, selecter = 1;
static int y = 284, counter = 0;
static int back_handle, logo_handle, music_handle;
static int font_handle1, font_handle2, font_handle3;

void end_title();
void draw_select_line();

void play_title() {
	if(start_flag == 0) {
		start_flag = 1;
		back_handle = LoadGraph( "画像/タイトル/chi.jpg" );
		music_handle = LoadSoundMem( "サウンド/BGM/記憶.wav" );
		logo_handle = LoadGraph( "画像/タイトル/p.jpg" );
		font_handle1 = CreateFontToHandle( "MS 明朝" , 28 , 11, DX_FONTTYPE_ANTIALIASING);
		font_handle2 = CreateFontToHandle( "MS 明朝" , 21 , 7, DX_FONTTYPE_ANTIALIASING);
		font_handle3 = CreateFontToHandle( "MS 明朝" , 16 , 3, DX_FONTTYPE_ANTIALIASING);
	}

	if(CheckSoundMem(music_handle) == 0)
		PlaySoundMem(music_handle, DX_PLAYTYPE_LOOP);

	SetBackgroundColor( 255, 255, 0 );
	DrawGraph(-7, 12, logo_handle, FALSE);
	DrawGraph(265, 0, back_handle, TRUE);

	DrawStringToHandle(20, 170, "Episode of Chie", RGB(0, 0, 0), font_handle1); 
	DrawStringToHandle(145, 250, "NEW GAME", RGB(0, 0, 0), font_handle2);
	DrawStringToHandle(85, 269, "Game is begun newly.", RGB(0, 0, 0), font_handle3);
	DrawStringToHandle(133, 320, "LOAD GAME", RGB(0, 0, 0), font_handle2);
	DrawStringToHandle(45, 339, "Former game data is read.", RGB(0, 0, 0), font_handle3);
	DrawStringToHandle(193, 390, "EXIT", RGB(0, 0, 0), font_handle2);
	DrawStringToHandle(29, 409, "Game is ended of the story.", RGB(0, 0, 0), font_handle3);

	draw_select_line();

	if(Keyboard_Get(KEY_INPUT_RETURN) == 1) {
		if(selecter == 1);
		else if(selecter == 2);
		else {
			end_title(); change_mode(0);
		}
	}
}

void end_title() {
	start_flag = 0;
	DeleteSoundMem(music_handle);
	DeleteGraph(back_handle);
	DeleteGraph(logo_handle);
	DeleteFontToHandle(font_handle1);
	DeleteFontToHandle(font_handle2);
	DeleteFontToHandle(font_handle3);
}

void draw_select_line() {
	DrawLine(0, y, (int)(sin(PI/120*counter/3*2)*245), y, RGB(0, 0, 0));
	if(counter <= 90) counter++;

	if(Keyboard_Get(KEY_INPUT_UP) == 1 && y > 284) {
		counter = 0; y -= 70; selecter++;
	}
	else if(Keyboard_Get(KEY_INPUT_DOWN) == 1 && y < 424) {
		counter = 0; y += 70; selecter--;
	}
}

back_handleに格納するchi.jpgはネットで拾ってきたものでGIMPで画像を縮小したり切り取って編集済みの画像です。
よくわからないのが編集していない画像だと問題なくきちんと表示されるということと、
logo_handleのp.jpgもGIMPで加工しているのにそっちはきちんと表示できているということです。

32bitで作ったものは64bit環境で動かすとエラーがでることもあるのでしょうか?
それとも単にコード自体にミスがあるのでしょうか?

何でもいいので指摘していただけるとありがたいです
お願します。

Re: DXライブラリを使った画像の描画

Posted: 2012年10月03日(水) 19:25
by softya(ソフト屋)
32bitで作ったプログラムを、どのような形で64bit環境で実行したのでしょうか?
それがわからないと答えようが無さそうです。