18
MMmm..sounds nice, but how to really use this code? all I get is errors...I added all the .h files needed and thingsl like linker option, but it doesn't work :/ the problem in my case might, that I don't know where to put it (proper place).
I have this kind of code for my WIN32 window. It works fine and makes a window, but how I can use this directx code together with that.
//-----------------------------------------------------------------------------
// Filename: Win32Creation.cpp
// Description: Creates a simple Win32 window on screen
//-----------------------------------------------------------------------------
#define WIN32_LEAN_AND_MEAN
#include "Windows.h"
// Function declarations
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
// Globals
static char strAppname[]="ANAN JUTTUU";
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// Register the window class
WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize=sizeof(WNDCLASSEX); // size of the window struct in bytes
wc.style=CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // window styles to use
wc.lpfnWndProc=MsgProc; // function name of event handler
wc.hInstance=hInstance; // handle to this apps instance
wc.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);// background colour of window
wc.hIcon= LoadIcon(NULL, IDI_APPLICATION); // icon for the app window
wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION); // icon when minimized to taskbar
wc.hCursor=LoadCursor(NULL, IDC_ARROW); // cursor to use for this window
wc.lpszClassName=strAppname; // name for this class
RegisterClassEx( &wc );
// Create the application's window
HWND hWnd = CreateWindow(strAppname, strAppname,
WS_OVERLAPPEDWINDOW |WS_BORDER | WS_MAXIMIZE, 0, 0, 1280, 960,
NULL, NULL, wc.hInstance, NULL );
// Show the window
ShowWindow( hWnd, nCmdShow );
UpdateWindow( hWnd );
// Enter the message loop
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
// no winmessages, idle code here
}
}
UnregisterClass( strAppname, wc.hInstance );
return 0;
}
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
HDC hDC;
PAINTSTRUCT PaintStruct;
switch( msg )
{
case WM_PAINT:
{
hDC=BeginPaint(hWnd, &PaintStruct); // Tell windows we want to update the window
// Do GDI drawing here
EndPaint(hWnd, &PaintStruct);
return 0;
}
case WM_DESTROY:
{
PostQuitMessage( 0 );
return 0;
}
default:
return DefWindowProc( hWnd, msg, wParam, lParam );
}
}
------ Build started: Project: Win32creation, Configuration: Debug Win32 ------
Compiling...
png.cpp
d:\demo\win32creation\png.cpp(11) : error C2143: syntax error : missing ';' before '.'
d:\demo\win32creation\png.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(11) : error C2371: 'd3dpp' : redefinition; different basic types
d:\demo\win32creation\png.cpp(10) : see declaration of 'd3dpp'
d:\demo\win32creation\png.cpp(12) : error C2143: syntax error : missing ';' before '.'
d:\demo\win32creation\png.cpp(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(12) : error C2371: 'd3dpp' : redefinition; different basic types
d:\demo\win32creation\png.cpp(10) : see declaration of 'd3dpp'
d:\demo\win32creation\png.cpp(13) : error C2143: syntax error : missing ';' before '.'
d:\demo\win32creation\png.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(13) : error C2371: 'd3dpp' : redefinition; different basic types
d:\demo\win32creation\png.cpp(10) : see declaration of 'd3dpp'
d:\demo\win32creation\png.cpp(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(14) : error C2040: 'd3d9' : 'int' differs in levels of indirection from 'IDirect3D9 *'
d:\demo\win32creation\png.cpp(14) : error C2440: 'initializing' : cannot convert from 'IDirect3D9 *' to 'int'
There is no context in which this conversion is possible
d:\demo\win32creation\png.cpp(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(15) : error C2371: 'err' : redefinition; different basic types
d:\demo\win32creation\png.cpp(5) : see declaration of 'err'
d:\demo\win32creation\png.cpp(15) : error C2065: 'hWnd' : undeclared identifier
d:\demo\win32creation\png.cpp(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(17) : error C2065: 'img' : undeclared identifier
d:\demo\win32creation\png.cpp(17) : error C2065: 'size' : undeclared identifier
d:\demo\win32creation\png.cpp(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(17) : error C2365: 'D3DXCreateTextureFromFileInMemory' : redefinition; previous definition was 'function'
d:\demo\win32creation\d3dx9tex.h(1450) : see declaration of 'D3DXCreateTextureFromFileInMemory'
d:\demo\win32creation\png.cpp(17) : error C2078: too many initializers
d:\demo\win32creation\png.cpp(17) : error C2440: 'initializing' : cannot convert from 'IDirect3DTexture9 **__w64 ' to 'int'
There is no context in which this conversion is possible
d:\demo\win32creation\png.cpp(20) : error C2143: syntax error : missing ';' before '->'
d:\demo\win32creation\png.cpp(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(20) : error C2040: 'd3dtex' : 'int' differs in levels of indirection from 'IDirect3DTexture9 *'
d:\demo\win32creation\png.cpp(21) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(21) : error C2040: 'pix' : 'int' differs in levels of indirection from 'unsigned int *'
d:\demo\win32creation\png.cpp(21) : error C2440: 'initializing' : cannot convert from 'unsigned int *' to 'int'
There is no context in which this conversion is possible
d:\demo\win32creation\png.cpp(22) : error C2143: syntax error : missing ';' before '->'
d:\demo\win32creation\png.cpp(22) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(22) : error C2040: 'd3dtex' : 'int' differs in levels of indirection from 'IDirect3DTexture9 *'
d:\demo\win32creation\png.cpp(24) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(24) : error C2040: 'src' : 'int' differs in levels of indirection from 'unsigned int *'
d:\demo\win32creation\png.cpp(24) : error C2440: 'initializing' : cannot convert from 'unsigned int *' to 'int'
There is no context in which this conversion is possible
d:\demo\win32creation\png.cpp(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(25) : error C2040: 'dst' : 'int' differs in levels of indirection from 'unsigned int *'
d:\demo\win32creation\png.cpp(25) : error C2440: 'initializing' : cannot convert from 'unsigned int *' to 'int'
There is no context in which this conversion is possible
d:\demo\win32creation\png.cpp(26) : error C2059: syntax error : 'for'
d:\demo\win32creation\png.cpp(26) : error C2143: syntax error : missing ')' before ';'
d:\demo\win32creation\png.cpp(26) : error C2143: syntax error : missing ';' before '<'
d:\demo\win32creation\png.cpp(26) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(26) : error C2143: syntax error : missing ';' before '++'
d:\demo\win32creation\png.cpp(26) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(26) : error C2086: 'int y' : redefinition
d:\demo\win32creation\png.cpp(26) : see declaration of 'y'
d:\demo\win32creation\png.cpp(26) : error C2059: syntax error : ')'
d:\demo\win32creation\png.cpp(27) : error C2143: syntax error : missing ';' before '{'
d:\demo\win32creation\png.cpp(27) : error C2447: '{' : missing function header (old-style formal list?)
d:\demo\win32creation\png.cpp(32) : error C2143: syntax error : missing ';' before '->'
d:\demo\win32creation\png.cpp(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(32) : error C2040: 'd3dtex' : 'int' differs in levels of indirection from 'IDirect3DTexture9 *'
d:\demo\win32creation\png.cpp(33) : error C2143: syntax error : missing ';' before '->'
d:\demo\win32creation\png.cpp(33) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(33) : error C2040: 'd3dtex' : 'int' differs in levels of indirection from 'IDirect3DTexture9 *'
d:\demo\win32creation\png.cpp(34) : error C2143: syntax error : missing ';' before '->'
d:\demo\win32creation\png.cpp(34) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(34) : error C2040: 'd3ddev' : 'int' differs in levels of indirection from 'IDirect3DDevice9 *'
d:\demo\win32creation\png.cpp(35) : error C2143: syntax error : missing ';' before '->'
d:\demo\win32creation\png.cpp(35) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\demo\win32creation\png.cpp(35) : error C2040: 'd3d9' : 'int' differs in levels of indirection from 'IDirect3D9 *'
Build log was saved at "file://d:\demo\Win32creation\Debug\BuildLog.htm"
Win32creation - 59 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
-Kypho (forever beginner:))