3
我正在用C++寫一個Direct3D和Python的小程序。 我創建了我的窗口,一切工作正常。但是如果我嘗試調用「Py_Initialize();」我的程序關閉。C++ Python關閉我的程序
(它以代碼1結尾) 問題是什麼?
編輯:這裏是我的代碼的一些部分。
MainIncludes.h
#include "Windows.h"
#include <d3d9.h>
#pragma comment (lib, "d3d9.lib")
#include <d3dx9.h>
#pragma comment (lib, "d3dx9.lib")
main_d3dwindow.cpp
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hWnd;
WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszClassName = L"WindowClass";
RegisterClassEx(&wc);
hWnd = CreateWindowEx(NULL,
L"WindowClass",
L"Program",
WS_OVERLAPPEDWINDOW,
300, 300,
800, 600,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hWnd, nCmdShow);
mainWindow = hWnd;
initD3D(hWnd);
init_python();
MSG msg;
while(TRUE)
{
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if(msg.message == WM_QUIT)
break;
render_frame();
}
cleanD3D();
return msg.wParam;
}
main_python.cpp
#include "Python.h"
void init_python() {
Py_Initialize();
}
歡迎的StackOverflow!請*顯示*代碼,否則任何人都無法幫助您。 (最好創建一個可重複使用的小例子,刪除與該問題無關的部分代碼) –
您能否提供一個代碼示例?只用函數調用很難說。 – Borgleader
我加了一些例子! – Freakyy