저는 SFML을 사용하여 최근에 작은 게임을 만들었습니다. 오늘 저녁까지 모든 것이 놀라 울 정도로 빠르고 간단했습니다. 나는 보통의 워크 스테이션에서 멀리 떨어져 있고 윈도우 8 태블릿/넷북에서 약간의 청소를하고 게임 창이 더 이상 나타나지 않는다. 나는 프로그램을 실행할 수 있고, 즉시 끝내고, 어떤 키를 눌러 콘솔에서 빠져 나오도록 요청한다. 몇 가지 연구를했는데 사용하고 있던 SFML 버전이 ATI 그래픽 카드를 지원하지 않는다는 것을 깨달았 기 때문에이 프로그램을 2.0으로 업그레이드했습니다 (이는 본질적으로 현재 프레임 워크이므로 업그레이드하는 데 몇 시간 만 걸렸습니다). 나는 그것이 모든 것을 고쳐주지 않는다고해도 상처를주지 않을 것이라고 생각했다.)SFML 창이 나타나지 않습니다.
불행히도, 아직 나타나지 않습니다. 프로그램을 실행하면 콘솔이 나타나지만 그래픽/렌더링 창은 표시되지 않습니다. 대신 "계속하려면 아무 키나 누르십시오."라는 텍스트가 표시됩니다. 프로그램이 이미 실행을 마친 것처럼 콘솔에 인쇄됩니다. 키를 누르면 반환 값이 0으로 종료됩니다.
이 프로그램은 Codelite를 사용하여 C++로 작성되고 g ++를 사용하여 컴파일됩니다. 나는 지금 Windows 8 Professional 태블릿/넷북에서 일하고 있으며, 다른 컴퓨터에 액세스 할 때까지는 테스트 할 수 없지만 이전에는 제대로 작동했지만 멈추지 않을 이유는 없습니다. 현재 환경 밖에서. 어떤 제안?
[업데이트] : 다른 PC, Windows 7에서 실행하려고 시도했지만 libstdC++ - 6.dll에서 프로 시저 엔트리 포인트 __gxx_personality_v0을 찾을 수 없다는 새로운 오류가 발생했습니다. 코드는 전체적으로 게시하기에는 너무 큽니다.하지만 문제가 아니라고 생각합니다. main()으로 들어가는 것조차 보이지 않기 때문입니다.
#include <iostream>
#include <string>
#include <cstdio>
#include <cassert>
#include "sfml.hpp"
#include "angelscript.hpp"
#include "MapGenerator.hpp"
#include "TestState.hpp"
#include "std.hpp"
sf::RenderWindow* initialize();
void TestAngelScript();
void MessageCallback(const asSMessageInfo *msg, void *param);
int main()
{
std::cout << "Made it into main!!!" << std::endl;
TestAngelScript();
std::cout << "Initializing" << std::endl;
sf::RenderWindow* App = initialize();
TextureHandler::Initialize();
FontHandler::Initialize();
SoundHandler::Initialize();
MusicHandler::Initialize();
InputHandler::Initialize(App);
StateEngine engine;
IState* state = new TestState(App);
engine.AddState(state);
sf::Clock clock;
while (App->isOpen())
{
sf::Event Event;
while (App->pollEvent(Event))
{
// Window closed
if (Event.type == sf::Event::Closed)
App->close();
// Escape key pressed
if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape))
App->close();
}
// Get elapsed time
float ElapsedTime = clock.restart().asSeconds();
engine.Update(ElapsedTime);
App->clear();
engine.Draw(App);
App->display();
}
return EXIT_SUCCESS;
}
sf::RenderWindow* initialize()
{
return new sf::RenderWindow(sf::VideoMode(800, 600, 32), "SFML Graphics");
}
// Print the script string to the standard output stream
void print(std::string &msg)
{
printf("%s", msg.c_str());
}
void TestAngelScript()
{
// Create the script engine
asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
// Set the message callback to receive information on errors in human readable form.
int r = engine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL); assert(r >= 0);
// AngelScript doesn't have a built-in string type, as there is no definite standard
// string type for C++ applications. Every developer is free to register it's own string type.
// The SDK do however provide a standard add-on for registering a string type, so it's not
// necessary to implement the registration yourself if you don't want to.
RegisterStdString(engine);
// Register the function that we want the scripts to call
r = engine->RegisterGlobalFunction("void print(const string &in)", asFUNCTION(print), asCALL_CDECL); assert(r >= 0);
// The CScriptBuilder helper is an add-on that loads the file,
// performs a pre-processing pass if necessary, and then tells
// the engine to build a script module.
CScriptBuilder builder;
r = builder.StartNewModule(engine, "MyModule");
if(r < 0)
{
// If the code fails here it is usually because there
// is no more memory to allocate the module
printf("Unrecoverable error while starting a new module.\n");
return;
}
r = builder.AddSectionFromFile("assets\\scripts\\test.as");
if(r < 0)
{
// The builder wasn't able to load the file. Maybe the file
// has been removed, or the wrong name was given, or some
// preprocessing commands are incorrectly written.
printf("Please correct the errors in the script and try again.\n");
return;
}
r = builder.BuildModule();
if(r < 0)
{
// An error occurred. Instruct the script writer to fix the
// compilation errors that were listed in the output stream.
printf("Please correct the errors in the script and try again.\n");
return;
}
// Find the function that is to be called.
asIScriptModule *mod = engine->GetModule("MyModule");
asIScriptFunction *func = mod->GetFunctionByDecl("void main()");
if(func == 0)
{
// The function couldn't be found. Instruct the script writer
// to include the expected function in the script.
printf("The script must have the function 'void main()'. Please add it and try again.\n");
return;
}
// Create our context, prepare it, and then execute
asIScriptContext *ctx = engine->CreateContext();
ctx->Prepare(func);
r = ctx->Execute();
if(r != asEXECUTION_FINISHED)
{
// The execution didn't complete as expected. Determine what happened.
if(r == asEXECUTION_EXCEPTION)
{
// An exception occurred, let the script writer know what happened so it can be corrected.
printf("An exception '%s' occurred. Please correct the code and try again.\n", ctx->GetExceptionString());
}
}
// Clean up
ctx->Release();
engine->Release();
}
// Implement a simple message callback function
void MessageCallback(const asSMessageInfo *msg, void *param)
{
const char *type = "ERR ";
if(msg->type == asMSGTYPE_WARNING)
type = "WARN";
else if(msg->type == asMSGTYPE_INFORMATION)
type = "INFO";
printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message);
}
콘솔에 아무 것도 출력되지 않으며 실행 후 입력에 대한 프롬프트를 저장하지 않습니다. 프로그램이 0을 반환합니다.
IDE 외부에서 프로그램을 실행하면 누락 된 DLL (libstdC++ - 6.dll 및 libgcc_s_sjlj_1.dll)에 대한 몇 가지 오류가 발생합니다. 이러한 프로그램이 제공되면 누락 된 프로 시저 입력 지점에 대한 오류가 표시됩니다. .. netbook에서 SFML 오디오 DLL에 누락 같은 점에 대해 불평하지만 ....
코드를 봅시다. – iKlsR