DotNetter
December 26th, 2005, 11:45 AM
Hi fellows. I've created a single app to test DirectX9. I'm using the Dev-CPP 4.9.9.2 to do the things in DirectX9:
#include <windows.h>
#include <windowsx.h>
#include <dmusici.h>
#include <iostream>
#define INITGUID
#define DXDELETE(p) if(p)p->Release()
IDirectMusicLoader8* g_pLoader = NULL;
IDirectMusicPerformance8* g_pPerformance = NULL;
IDirectMusicSegment8* g_pSegment = NULL;
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE h1, HINSTANCE h2, LPSTR lp, int iShow)
{
HWND hwnd;
HDC hdc;
MSG msg;
bool bQuit = false;
WNDCLASSEX wnd;
wnd.cbSize = sizeof(WNDCLASSEX);
wnd.style = CS_OWNDC;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hInstance = h1;
wnd.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wnd.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wnd.hCursor = LoadCursor(NULL, IDC_ARROW);
wnd.lpszMenuName = NULL;
wnd.lpszClassName = "hwnd";
wnd.lpfnWndProc = WindowProcedure;
wnd.hbrBackground = CreateSolidBrush(RGB(128,128,128));
if(!RegisterClassEx(&wnd))
{
MessageBox(0,"não registrou","",0);
}
hwnd = CreateWindowEx(0, "hwnd", "lalala", WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), HWND_DESKTOP, NULL, h1, NULL);
ShowWindow(hwnd, 1);
CoInitialize(NULL);
CoCreateInstance(CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, IID_IDirectMusicLoader8, (void**)&g_pLoader);
CoCreateInstance(CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC, IID_IDirectMusicPerformance8, (void**)&g_pPerformance);
g_pPerformance->InitAudio(NULL, NULL, hwnd, DMUS_APATH_SHARED_STEREOPLUESREVERB, 64, DMUS_AUDIOF_ALL, NULL);
g_pLoader->SetSearchDirectory(GUID_DirectMusicAllTypes, NULL, FALSE);
WCHAR wstrFileName[MAX_PATH] = "C:/Documents and Settings/Alex/My Documents/Music/Massacration/01-massacration-intro.mp3";
if(FAILED(g_pLoader->LoadObjectFromFile(CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, wstrFileName, (LPVOID*)&g_pSegment)))
{
MessageBox(NULL, "não deu", "", MB_OK);
return 0;
}
g_pSegment->Download(g_pPerformance);
g_pPerformance->PlaySegmentEx(g_pSegment, NULL, NULL, 0, 0, NULL, NULL, NULL);
g_pPerformance->Stop(NULL, NULL, 0, 0);
g_pPerformance->CloseDown();
if(MUSIC_ISDONE)g_pPerformance->Stop();
CoUninitialize();
DXDELETE(g_pLoader);
DXDELETE(g_pPerformance);
DXDELETE(g_pSegment);
while(!bQuit)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
{
bQuit = true;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_KEYDOWN:
{
switch(wParam)
{
case VK_ESCAPE:
{
PostQuitMessage(0);
break;
}
}
break;
}
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
I have these errors in my app:
19 C:\Dev-Cpp\include\dmusicc.h:21, from C:\Dev-Cpp\include\dmusici.h In file included from C:/Dev-Cpp/include/dmusicc.h:21, from C:/Dev-Cpp/include/dmusici.h
3 C:\Dev-Cpp\include\dmusici.h:19, from DirectMain.cpp from C:/Dev-Cpp/include/dmusici.h:19, from DirectMain.cpp
3 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp from DirectMain.cpp
23:1 C:\Dev-Cpp\include\dmdls.h [Warning] "MAKEFOURCC" redefined
1 C:\Dev-Cpp\include\windows.h:80, from DirectMain.cpp In file included from C:/Dev-Cpp/include/windows.h:80, from DirectMain.cpp
1 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp from DirectMain.cpp
24:1 C:\Dev-Cpp\include\mmsystem.h [Warning] this is the location of the previous definition
19 C:\Dev-Cpp\include\dmusicc.h:21, from C:\Dev-Cpp\include\dmusici.h In file included from C:/Dev-Cpp/include/dmusicc.h:21, from C:/Dev-Cpp/include/dmusici.h
3 C:\Dev-Cpp\include\dmusici.h:19, from DirectMain.cpp from C:/Dev-Cpp/include/dmusici.h:19, from DirectMain.cpp
3 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp from DirectMain.cpp
75 C:\Dev-Cpp\include\dmdls.h declaration of `WLOOP _DMUS_REGION::WLOOP[1]'
264 C:\Dev-Cpp\include\dls1.h changes meaning of `WLOOP' from `typedef struct _rloop WLOOP'
8 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected constructor, destructor, or type conversion before '*' token
8 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected `,' or `;' before '*' token
9 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected constructor, destructor, or type conversion before '*' token
9 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected `,' or `;' before '*' token
10 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected constructor, destructor, or type conversion before '*' token
10 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected `,' or `;' before '*' token
C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':
40 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `IID_IDirectMusicLoader8' undeclared (first use this function)
40 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `g_pLoader' undeclared (first use this function)
41 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `IID_IDirectMusicPerformance8' undeclared (first use this function)
41 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `g_pPerformance' undeclared (first use this function)
42 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `DMUS_APATH_SHARED_STEREOPLUESREVERB' undeclared (first use this function)
42 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `DMUS_AUDIOF_ALL' undeclared (first use this function)
44 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp int-array initialized from non-wide string
45 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `IID_IDirectMusicSegment8' undeclared (first use this function)
45 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `g_pSegment' undeclared (first use this function)
54 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `MUSIC_ISDONE' undeclared (first use this function)
In my Parameters option in the Project Menu of the Dev-CPP I added this like the Sherman Chin'n Tutorials:
-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
../../../../Dev-Cpp/lib/libgdi32.a
../../../../Dev-Cpp/lib/libdsound.a
../../../../Dev-Cpp/lib/libdxguid.a
../../../../Dev-Cpp/lib/libd3d8.a
../../../../Dev-Cpp/lib/libd3dx8d.a
../../../../Dev-Cpp/lib/libd3dxof.a
../../../../Dev-Cpp/lib/libdplayx.a
../../../../Dev-Cpp/lib/libwinmm.a
In my opinion the code is right, but it doesn't works. Fellows, what's going on?
#include <windows.h>
#include <windowsx.h>
#include <dmusici.h>
#include <iostream>
#define INITGUID
#define DXDELETE(p) if(p)p->Release()
IDirectMusicLoader8* g_pLoader = NULL;
IDirectMusicPerformance8* g_pPerformance = NULL;
IDirectMusicSegment8* g_pSegment = NULL;
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE h1, HINSTANCE h2, LPSTR lp, int iShow)
{
HWND hwnd;
HDC hdc;
MSG msg;
bool bQuit = false;
WNDCLASSEX wnd;
wnd.cbSize = sizeof(WNDCLASSEX);
wnd.style = CS_OWNDC;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hInstance = h1;
wnd.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wnd.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wnd.hCursor = LoadCursor(NULL, IDC_ARROW);
wnd.lpszMenuName = NULL;
wnd.lpszClassName = "hwnd";
wnd.lpfnWndProc = WindowProcedure;
wnd.hbrBackground = CreateSolidBrush(RGB(128,128,128));
if(!RegisterClassEx(&wnd))
{
MessageBox(0,"não registrou","",0);
}
hwnd = CreateWindowEx(0, "hwnd", "lalala", WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), HWND_DESKTOP, NULL, h1, NULL);
ShowWindow(hwnd, 1);
CoInitialize(NULL);
CoCreateInstance(CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, IID_IDirectMusicLoader8, (void**)&g_pLoader);
CoCreateInstance(CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC, IID_IDirectMusicPerformance8, (void**)&g_pPerformance);
g_pPerformance->InitAudio(NULL, NULL, hwnd, DMUS_APATH_SHARED_STEREOPLUESREVERB, 64, DMUS_AUDIOF_ALL, NULL);
g_pLoader->SetSearchDirectory(GUID_DirectMusicAllTypes, NULL, FALSE);
WCHAR wstrFileName[MAX_PATH] = "C:/Documents and Settings/Alex/My Documents/Music/Massacration/01-massacration-intro.mp3";
if(FAILED(g_pLoader->LoadObjectFromFile(CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, wstrFileName, (LPVOID*)&g_pSegment)))
{
MessageBox(NULL, "não deu", "", MB_OK);
return 0;
}
g_pSegment->Download(g_pPerformance);
g_pPerformance->PlaySegmentEx(g_pSegment, NULL, NULL, 0, 0, NULL, NULL, NULL);
g_pPerformance->Stop(NULL, NULL, 0, 0);
g_pPerformance->CloseDown();
if(MUSIC_ISDONE)g_pPerformance->Stop();
CoUninitialize();
DXDELETE(g_pLoader);
DXDELETE(g_pPerformance);
DXDELETE(g_pSegment);
while(!bQuit)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
{
bQuit = true;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_KEYDOWN:
{
switch(wParam)
{
case VK_ESCAPE:
{
PostQuitMessage(0);
break;
}
}
break;
}
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
I have these errors in my app:
19 C:\Dev-Cpp\include\dmusicc.h:21, from C:\Dev-Cpp\include\dmusici.h In file included from C:/Dev-Cpp/include/dmusicc.h:21, from C:/Dev-Cpp/include/dmusici.h
3 C:\Dev-Cpp\include\dmusici.h:19, from DirectMain.cpp from C:/Dev-Cpp/include/dmusici.h:19, from DirectMain.cpp
3 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp from DirectMain.cpp
23:1 C:\Dev-Cpp\include\dmdls.h [Warning] "MAKEFOURCC" redefined
1 C:\Dev-Cpp\include\windows.h:80, from DirectMain.cpp In file included from C:/Dev-Cpp/include/windows.h:80, from DirectMain.cpp
1 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp from DirectMain.cpp
24:1 C:\Dev-Cpp\include\mmsystem.h [Warning] this is the location of the previous definition
19 C:\Dev-Cpp\include\dmusicc.h:21, from C:\Dev-Cpp\include\dmusici.h In file included from C:/Dev-Cpp/include/dmusicc.h:21, from C:/Dev-Cpp/include/dmusici.h
3 C:\Dev-Cpp\include\dmusici.h:19, from DirectMain.cpp from C:/Dev-Cpp/include/dmusici.h:19, from DirectMain.cpp
3 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp from DirectMain.cpp
75 C:\Dev-Cpp\include\dmdls.h declaration of `WLOOP _DMUS_REGION::WLOOP[1]'
264 C:\Dev-Cpp\include\dls1.h changes meaning of `WLOOP' from `typedef struct _rloop WLOOP'
8 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected constructor, destructor, or type conversion before '*' token
8 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected `,' or `;' before '*' token
9 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected constructor, destructor, or type conversion before '*' token
9 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected `,' or `;' before '*' token
10 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected constructor, destructor, or type conversion before '*' token
10 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp expected `,' or `;' before '*' token
C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':
40 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `IID_IDirectMusicLoader8' undeclared (first use this function)
40 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `g_pLoader' undeclared (first use this function)
41 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `IID_IDirectMusicPerformance8' undeclared (first use this function)
41 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `g_pPerformance' undeclared (first use this function)
42 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `DMUS_APATH_SHARED_STEREOPLUESREVERB' undeclared (first use this function)
42 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `DMUS_AUDIOF_ALL' undeclared (first use this function)
44 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp int-array initialized from non-wide string
45 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `IID_IDirectMusicSegment8' undeclared (first use this function)
45 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `g_pSegment' undeclared (first use this function)
54 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `MUSIC_ISDONE' undeclared (first use this function)
In my Parameters option in the Project Menu of the Dev-CPP I added this like the Sherman Chin'n Tutorials:
-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
../../../../Dev-Cpp/lib/libgdi32.a
../../../../Dev-Cpp/lib/libdsound.a
../../../../Dev-Cpp/lib/libdxguid.a
../../../../Dev-Cpp/lib/libd3d8.a
../../../../Dev-Cpp/lib/libd3dx8d.a
../../../../Dev-Cpp/lib/libd3dxof.a
../../../../Dev-Cpp/lib/libdplayx.a
../../../../Dev-Cpp/lib/libwinmm.a
In my opinion the code is right, but it doesn't works. Fellows, what's going on?