Wo liegt der / die Fehler ?
-
Also ich habe mich mit Direct Input beschäftigt , nur als dann nichts lief wollte ich gucken ob Codes aus Tutorials funtkionieren um dann zu sehen was bei mir falsch ist . Nur ich bekomme hier :
#ifndef __CINPUT8_H__ #define __CINPUT8_H__ #include <windows.h> // standard Windows app include #include <dinput.h> #define WIN32_LEAN_AND_MEAN // trim the excess fat from Windows typedef unsigned char UCHAR; #define SafeRelease(x) if (x) {x->Release(); x=NULL;} bool Init_CInput8(HINSTANCE h); bool Shutdown_CInput8(void); bool Init_Keyboard(HWND hWnd); bool Acquire_Keyboard(); bool Unacquire_Keyboard(); bool Read_Keyboard(); bool Release_Keyboard(); bool KeyDown(DWORD key); bool KeyUp(DWORD key); bool KeyPress(DWORD key); bool Init_Mouse(HWND hWnd); bool Acquire_Mouse(void); bool Unacquire_Mouse(void); bool Read_Mouse(void); bool Release_Mouse(void); void Get_Mouse_X(float &m_x); void Get_Mouse_Y(float &m_y); void Get_Mouse_Coords(float &m_x, float &m_y); void Get_Movement(float &m_x, float &m_y); bool Button_Down(int mouse_button); bool Button_Up(int mouse_button); // defines for mouse #define LEFT_BUTTON 0 #define RIGHT_BUTTON 1 #define MIDDLE_BUTTON 2 #endif LPDIRECTINPUT lpdi; LPDIRECTINPUTDEVICE m_keyboard; UCHAR keystate[256]; UCHAR keypress_state[256]; LPDIRECTINPUTDEVICE m_mouse = NULL; float mX = 0.0f, mY = 0.0f; DIMOUSESTATE mouse_state; // Initiates input system bool Init_CInput8(HINSTANCE h) { if (FAILED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&lpdi, NULL))) return false; for (int i = 0; i < 256; i++) keypress_state[i] = 0; return true; } bool Init_Keyboard(HWND hWnd) { if (FAILED(lpdi->CreateDevice(GUID_SysKeyboard, &m_keyboard, NULL))) return false; if (FAILED(m_keyboard->SetDataFormat(&c_dfDIKeyboard))) return false; if (FAILED(m_keyboard->SetCooperativeLevel(hWnd, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE))) return false; if (FAILED(m_keyboard->Acquire())) return false; return true; } bool Acquire_Keyboard() { if (FAILED(m_keyboard->Acquire())) return false; return true; } bool Unacquire_Keyboard() { if (FAILED(m_keyboard->Unacquire())) return false; return true; } bool Read_Keyboard() { if (FAILED(m_keyboard->GetDeviceState(sizeof(UCHAR[256]), (LPVOID)keystate))) return false; return true; } bool Release_Keyboard() { SafeRelease(m_keyboard); return true; } bool KeyDown(DWORD key) { return ((keystate[key] & 0x80) ? true : false); } bool KeyUp(DWORD key) { return ((keystate[key] & 0x80) ? false : true); } bool KeyPress(DWORD key) { if (KeyDown(key)) keypress_state[key] = 1; if (keypress_state[key] == 1) if (KeyUp(key)) keypress_state[key] = 2; if (keypress_state[key] == 2) { keypress_state[key] = 0; return true; } return false; } bool Init_Mouse(HWND hWnd) { if (FAILED(lpdi->CreateDevice(GUID_SysMouse, &m_mouse, NULL))) return false; if (FAILED(m_mouse->SetCooperativeLevel(hWnd, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE))) return false; if (FAILED(m_mouse->SetDataFormat(&c_dfDIMouse))) return false; if (FAILED(m_mouse->Acquire())) return false; return true; } bool Acquire_Mouse(void) { if (FAILED(m_mouse->Acquire())) return false; return true; } bool Unacquire_Mouse(void) { if (FAILED(m_mouse->Unacquire())) return false; return true; } bool Read_Mouse(void) { if (FAILED(m_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mouse_state))) return false; return true; } void Get_Movement(float &m_x, float &m_y) { m_x = mouse_state.lX; m_y = mouse_state.lY; } void Get_Mouse_Coords(float &m_x, float &m_y) { Get_Mouse_X(m_x); Get_Mouse_Y(m_y); } void Get_Mouse_X(float &m_x) { mX += mouse_state.lX; if (mX < 0) mX = 0; m_x = mX; } void Get_Mouse_Y(float &m_y) { mY += mouse_state.lY; if (mY < 0) mY = 0; m_y = mY; } bool Button_Down(int mouse_button) { return ((mouse_state.rgbButtons[mouse_button] & 0x80) ? true : false); } bool Button_Up(int mouse_button) { return ((mouse_state.rgbButtons[mouse_button] & 0x80) ? false : true); } bool Release_Mouse() { if (Unacquire_Mouse()) return false; SafeRelease(m_mouse); return true; } // shutdown input system bool Shutdown_CInput8(void) { SafeRelease(lpdi); return true; }
diese Fehler :
--------------------Konfiguration: 123456789 - Win32 Debug--------------------
Kompilierung läuft...
CInput8.cpp
g:\dxsdk\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
g:\cinput8\cinput8.cpp(174) : warning C4244: '=' : Konvertierung von 'long' in 'float', moeglicher Datenverlust
g:\cinput8\cinput8.cpp(175) : warning C4244: '=' : Konvertierung von 'long' in 'float', moeglicher Datenverlust
Linker-Vorgang läuft...
LIBCD.lib(wincrt0.obj) : error LNK2001: Nichtaufgeloestes externes Symbol _WinMain@16
Debug/123456789.exe : fatal error LNK1120: 1 unaufgeloeste externe Verweise
Fehler beim Ausführen von link.exe.123456789.exe - 2 Fehler, 2 Warnung(en)
Die Warnungen mit de Datenverlust sind mir klar , das kann ich notfals noch eben ändern nur das mit dem LIBCD.lib(wincrt0.obj) : error LNK2001: Nichtaufgeloestes externes Symbol _WinMain@16 Fehler weiß ich nciht . so neben bei was heißt Nichtaufgeloestes externes Symbol überhaupt genau , weil ich diesen Fehler jetzt zum 3. mal habe und die dan ihrgendwann ihrgendwie wieder weg waren .
PS: Ich hoffe ich bin im richtigen Forum hat zwar was mit DX zu tuhen gehört aber nicht wirklich zur Spiele-Programmierung .
-
Hallo!
Hast du eigentlich eine WinMain-Funktion erstellt?
Oder ist die in einem anderen cpp-File.Ich glaube, dass dieser Fehler "Nicht aufgelöstes externes Symbol" immer dann auftritt, wenn du z.B eine Prototypen deklarierst und in der Implementierung der Funktion im Funktionsnamen oder der Parameterliste verschreibst, oder die Implementierung ganz weglässt.
z.B
int alterzu(void); // ......... // ......... int alterza(void) { //...... return 0; }
dabei würde glaube ich ein Linkererror entstehen.
-
ôk, danke dann gehe ich mal auf Fehlersuche ...
-
ich hatte mich beim verlinken der Seite verschrieben wo ich die WinMain hatte (konnte also nicht klappen
) danke für die Hilfe .
-
kleine anmerkung:
#include <windows.h> // standard Windows app include
#include <dinput.h>
#define WIN32_LEAN_AND_MEANdas ist sinnlos.
was bringt das lean and mean NACHDEM du bereits die gesamte windows.h parsen hast lassen?probiers mal so rum:
#define WIN32_LEAN_AND_MEAN
#include <windows.h> // standard Windows app include
#include <dinput.h>
-
oh danke , ja ... eh ... änder ich