You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
364 lines
9.7 KiB
C++
364 lines
9.7 KiB
C++
// mfxtest2.cpp : Legt das Klassenverhalten für die Anwendung fest.
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "mfxtest2.h"
|
|
|
|
#include "MainFrm.h"
|
|
#include "ChildFrm.h"
|
|
#include "mfxtest2Doc.h"
|
|
#include "mfxtest2View.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
CRoot *gl_root;
|
|
/*
|
|
//RECT rect;
|
|
//GetClientRect(&rect);
|
|
//pDC->FillSolidRect(&rect,BLACK);
|
|
|
|
if( logo ){
|
|
// drv_gfx_UpdateDC(pDC->GetSafeHdc(), logo, 0 );
|
|
|
|
llgfx_BLITFast(blendbuffer,logo);
|
|
s_blitfx blitfx;
|
|
blitfx.fixalpha = 0.5;//effekt value
|
|
llgfx_BLIT(blendbuffer,logo,llirq_GetRand()%400,llirq_GetRand()%400,0,BLIT_FXBLEND,&blitfx);
|
|
|
|
|
|
drv_gfx_UpdateWND(m_hWnd,blendbuffer);
|
|
}
|
|
|
|
logo = llgfx_LoadGfx("test_bkgnd.png" );
|
|
blendbuffer = llgfx_CloneGfx(logo);
|
|
*/
|
|
HWND hWND = NULL;
|
|
extern HWND hWndMain;
|
|
DWORD WINAPI EngineThreadFunction(
|
|
LPVOID lpParameter // thread data
|
|
)
|
|
{
|
|
int xpos =0;
|
|
int ypos =0;
|
|
|
|
llgfx_SetDisplayMode(640,480,32,0,0);
|
|
|
|
llgfx_tab_chars[0] = '.';
|
|
llgfx_tab_pos[0] = 32;
|
|
|
|
llgfx_id background = llgfx_LoadGfx("background.png");
|
|
llsound_id musik = llsound_LoadSnd("theme3.ogg",LLSOUND_STREAM);
|
|
llsound_Play(musik,LLSOUND_LOOP);
|
|
llsound_id heli = llsound_LoadSnd("helicopter_1.wav");
|
|
llsound_id vol = llsound_LoadSnd("volume.wav");
|
|
llsound_id down = llsound_LoadSnd("down.wav");
|
|
llsound_id down_array[4];
|
|
down_array[0] = llsound_CloneSnd(down);
|
|
down_array[1] = llsound_CloneSnd(down);
|
|
down_array[2] = llsound_CloneSnd(down);
|
|
down_array[3] = llsound_CloneSnd(down);
|
|
int down_index=0;
|
|
|
|
llirq_ResetTime();
|
|
while(osmain_endgame==false){
|
|
|
|
float delta = llirq_GetDeltaTime();
|
|
|
|
if(background)
|
|
llgfx_TILE_BLIT(0,background,xpos++,ypos++);
|
|
else
|
|
llgfx_ClearScreen(BLUE);
|
|
|
|
llgfx_Printf("Sounddriver demo\n");
|
|
llgfx_Printf("Musik Pos:\t%f sec\n", llsound_GetSndPlaytime(musik) );
|
|
llgfx_Printf("Heli Pos:\t%f sec\n", llsound_GetSndPlaytime(heli) );
|
|
llgfx_Printf("Vol Pos:\t%f sec\n", llsound_GetSndPlaytime(vol) );
|
|
|
|
llgfx_Printf("\n");
|
|
|
|
|
|
int status = llsound_GetStatus(heli);
|
|
if( status == 0 )
|
|
llgfx_Printf("Heli=Stopped, press Key_A to play\n", llsound_GetSndPlaytime(heli));
|
|
else
|
|
llgfx_Printf("Heli=Resuming Playback, release Key_A to stop\n", llsound_GetSndPlaytime(heli));
|
|
|
|
|
|
|
|
if( Justdown(llinput_Keys[LLINPUT_KEY_A]) ){
|
|
llsound_Resume(heli,LLSOUND_LOOP,llsound_GetSndPlaytime(heli));
|
|
}
|
|
if( Justup(llinput_Keys[LLINPUT_KEY_A]) ){
|
|
llsound_Stop(heli);
|
|
}
|
|
|
|
|
|
|
|
// volume.wav
|
|
llgfx_Printf("\n");
|
|
if( Justdown(llinput_Keys[LLINPUT_KEY_B]) ){
|
|
llsound_Play(vol);
|
|
}
|
|
status = llsound_GetStatus(vol);
|
|
if( status == 0 )
|
|
llgfx_Printf("vol=Stopped, press Key_B to play\n", llsound_GetSndPlaytime(vol));
|
|
else
|
|
llgfx_Printf("vol=Playing\n", llsound_GetSndPlaytime(vol));
|
|
|
|
|
|
// down.wav
|
|
llgfx_Printf("\n");
|
|
if( Justdown(llinput_Keys[LLINPUT_KEY_X]) ){
|
|
llsound_Play( down_array[(down_index++)%4] );
|
|
}
|
|
int cnt = 4;
|
|
llgfx_Printf("Press Key_X to play one of down.wav\n");
|
|
while(cnt--)
|
|
{
|
|
llgfx_Printf("down[%d]\t%f\n",cnt,llsound_GetSndPlaytime(down_array[cnt]));
|
|
}
|
|
|
|
|
|
llgfx_Printf("\n");
|
|
llgfx_Printf("Musik sndlength\t%f secs\n",llsound_GetSndLength(musik));
|
|
llgfx_Printf("Heli sndlength\t%f secs\n",llsound_GetSndLength(heli));
|
|
llgfx_Printf("vol sndlength\t%f secs\n",llsound_GetSndLength(vol));
|
|
llgfx_Printf("Down sndlength\t%f secs\n",llsound_GetSndLength(down));
|
|
|
|
|
|
llgfx_sBLITFX blitfx;
|
|
blitfx.fixalpha = 0.5f;
|
|
llgfx_DrawText(" l3lib v1.0 - August 2006, GP2X Win32 Driver",BLIT_FXBLEND|BLIT_SRC_CKEY,&blitfx);
|
|
|
|
if( hWND != NULL ){
|
|
// drv_gfx_UpdateWND(hWND ,0);
|
|
hWndMain = hWND;
|
|
}
|
|
|
|
|
|
llgfx_FlipScreen(0);
|
|
|
|
|
|
llsound_Update(delta);
|
|
llinput_Update();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
HANDLE enginethreadhandle = 0;
|
|
DWORD engineThreadId = 0;
|
|
|
|
|
|
|
|
void StartEngine(HWND mainframewindow)
|
|
{
|
|
llgfx_Init(mainframewindow);
|
|
llsound_Init(mainframewindow);
|
|
llinput_Init(mainframewindow);
|
|
|
|
enginethreadhandle = (HANDLE) CreateThread(
|
|
0,
|
|
0,
|
|
&EngineThreadFunction,
|
|
0,
|
|
0,
|
|
&engineThreadId
|
|
);
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CMfxtest2App
|
|
|
|
BEGIN_MESSAGE_MAP(CMfxtest2App, CWinApp)
|
|
//{{AFX_MSG_MAP(CMfxtest2App)
|
|
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
|
|
// HINWEIS - Hier werden Mapping-Makros vom Klassen-Assistenten eingefügt und entfernt.
|
|
// Innerhalb dieser generierten Quelltextabschnitte NICHTS VERÄNDERN!
|
|
//}}AFX_MSG_MAP
|
|
// Dateibasierte Standard-Dokumentbefehle
|
|
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
|
|
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CMfxtest2App Konstruktion
|
|
|
|
CMfxtest2App::CMfxtest2App()
|
|
{
|
|
// ZU ERLEDIGEN: Hier Code zur Konstruktion einfügen
|
|
// Alle wichtigen Initialisierungen in InitInstance platzieren
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// Das einzige CMfxtest2App-Objekt
|
|
|
|
CMfxtest2App theApp;
|
|
|
|
// Dieser Bezeichner wurde als statistisch eindeutig für Ihre Anwendung generiert.
|
|
// Sie können ihn ändern, wenn Sie einen bestimmten Bezeichnernamen bevorzugen.
|
|
|
|
// {F3A31FC9-CD13-4C20-B13A-0CECFE53CE23}
|
|
static const CLSID clsid =
|
|
{ 0xf3a31fc9, 0xcd13, 0x4c20, { 0xb1, 0x3a, 0xc, 0xec, 0xfe, 0x53, 0xce, 0x23 } };
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CMfxtest2App Initialisierung
|
|
|
|
BOOL CMfxtest2App::InitInstance()
|
|
{
|
|
// OLE-Bibliotheken initialisieren
|
|
if (!AfxOleInit())
|
|
{
|
|
AfxMessageBox(IDP_OLE_INIT_FAILED);
|
|
return FALSE;
|
|
}
|
|
|
|
// Standardinitialisierung
|
|
// Wenn Sie diese Funktionen nicht nutzen und die Größe Ihrer fertigen
|
|
// ausführbaren Datei reduzieren wollen, sollten Sie die nachfolgenden
|
|
// spezifischen Initialisierungsroutinen, die Sie nicht benötigen, entfernen.
|
|
|
|
#ifdef _AFXDLL
|
|
Enable3dControls(); // Diese Funktion bei Verwendung von MFC in gemeinsam genutzten DLLs aufrufen
|
|
#else
|
|
Enable3dControlsStatic(); // Diese Funktion bei statischen MFC-Anbindungen aufrufen
|
|
#endif
|
|
|
|
// Ändern des Registrierungsschlüssels, unter dem unsere Einstellungen gespeichert sind.
|
|
// ZU ERLEDIGEN: Sie sollten dieser Zeichenfolge einen geeigneten Inhalt geben
|
|
// wie z.B. den Namen Ihrer Firma oder Organisation.
|
|
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
|
|
|
|
LoadStdProfileSettings(10); // Standard INI-Dateioptionen laden (einschließlich MRU)
|
|
|
|
// Dokumentvorlagen der Anwendung registrieren. Dokumentvorlagen
|
|
// dienen als Verbindung zwischen Dokumenten, Rahmenfenstern und Ansichten.
|
|
|
|
CMultiDocTemplate* pDocTemplate;
|
|
pDocTemplate = new CMultiDocTemplate(
|
|
IDR_L3LIBTYPE,
|
|
RUNTIME_CLASS(CMfxtest2Doc),
|
|
RUNTIME_CLASS(CChildFrame), // Benutzerspezifischer MDI-Child-Rahmen
|
|
RUNTIME_CLASS(CMfxtest2View));
|
|
AddDocTemplate(pDocTemplate);
|
|
|
|
// Verbinden des COleTemplateServer mit der Dokumentvorlage.
|
|
// Der COleTemplateServer legt auf Basis der Informationen in der
|
|
// Dokumentvorlage bei der Anforderung von OLE-Containern
|
|
// neue Dokumente an.
|
|
m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
|
|
|
|
// Alle OLE-Server (-fabriken) als aktiv registrieren. Dies aktiviert die
|
|
// OLE-Bibliotheken, um Objekte von anderen Anwendungen zu erstellen.
|
|
COleTemplateServer::RegisterAll();
|
|
// Hinweis: MDI-Anwendungen registrieren alle Server-Objekte, ohne Rücksicht
|
|
// auf die Parameter /Embedding oder /Automation in der Befehlszeile.
|
|
|
|
// Haupt-MDI-Rahmenfenster erzeugen
|
|
CMainFrame* pMainFrame = new CMainFrame;
|
|
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
|
|
return FALSE;
|
|
m_pMainWnd = pMainFrame;
|
|
|
|
// Öffnen per DragDrop aktivieren
|
|
m_pMainWnd->DragAcceptFiles();
|
|
|
|
// DDE-Execute-Open aktivieren
|
|
EnableShellOpen();
|
|
RegisterShellFileTypes(TRUE);
|
|
|
|
// Befehlszeile parsen, um zu prüfen auf Standard-Umgebungsbefehle DDE, Datei offen
|
|
CCommandLineInfo cmdInfo;
|
|
ParseCommandLine(cmdInfo);
|
|
|
|
// Testen, ob Ausführung als OLE-Server
|
|
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
|
|
{
|
|
// Anwendung mit /Embedding oder /Automation gestartet. In diesem Fall
|
|
// kein Hauptfenster anzeigen.
|
|
return TRUE;
|
|
}
|
|
|
|
// Wird eine Server-Anwendung im Standalone-Modus betrieben, ist es ratsam,
|
|
// die Systemregistrierung zu aktualisieren, falls diese beschädigt wurde.
|
|
m_server.UpdateRegistry(OAT_DISPATCH_OBJECT);
|
|
COleObjectFactory::UpdateRegistryAll();
|
|
|
|
// Verteilung der in der Befehlszeile angegebenen Befehle
|
|
if (!ProcessShellCommand(cmdInfo))
|
|
return FALSE;
|
|
|
|
StartEngine(pMainFrame->m_hWnd);
|
|
|
|
// Das Hauptfenster ist initialisiert und kann jetzt angezeigt und aktualisiert werden.
|
|
pMainFrame->ShowWindow(m_nCmdShow);
|
|
pMainFrame->UpdateWindow();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAboutDlg-Dialog für Info über Anwendung
|
|
|
|
class CAboutDlg : public CDialog
|
|
{
|
|
public:
|
|
CAboutDlg();
|
|
|
|
// Dialogdaten
|
|
//{{AFX_DATA(CAboutDlg)
|
|
enum { IDD = IDD_ABOUTBOX };
|
|
//}}AFX_DATA
|
|
|
|
// Überladungen für virtuelle Funktionen, die vom Anwendungs-Assistenten erzeugt wurden
|
|
//{{AFX_VIRTUAL(CAboutDlg)
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV-Unterstützung
|
|
//}}AFX_VIRTUAL
|
|
|
|
// Implementierung
|
|
protected:
|
|
//{{AFX_MSG(CAboutDlg)
|
|
// Keine Nachrichten-Handler
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
|
{
|
|
//{{AFX_DATA_INIT(CAboutDlg)
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CAboutDlg)
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CAboutDlg)
|
|
// Keine Nachrichten-Handler
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
// Anwendungsbefehl zum Ausführen des Dialogfelds
|
|
void CMfxtest2App::OnAppAbout()
|
|
{
|
|
CAboutDlg aboutDlg;
|
|
aboutDlg.DoModal();
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CMfxtest2App-Nachrichtenbehandlungsroutinen
|