   directx in .net
  ok obviously I was misunderstood the last time I posted so let me try againI have looked extensivly online for directx tutorialsbut none of them  do me any good because they dont compile I am not typing this code I pasted it to make sure there were no errors so I would know if it was the program I am Using ok first off I want toI am using visual c++.net this is the one for $100 not visual c++ 6.0 I was told you could use this program with direct x is this true ??I was told yes if that is true do I need to add those libraries to my program???here is what I mean If you right click on the icon of any program you will pull up it's target folder I was told in other Ide's besides visual c++.net that you have to copy some libraries from the sdk folders to the library folders of the perticuler programming software you are using So Is this the case with visual c++.net do i need to add any files to .net's target folder or to it's library files?? Do I need to do anything to set it up outside of visual c++.netI was told also that this is not the case it is all sone for you during directx's instalation process  Is this true  or do i still need to add something??next inside visual c++.netthere are many option for creating a new project so which one should i use for directx code to work properly win32 or a console application ???what headers do i use for a d3d code ??I was told that you need some header files for directx to runhere all the headers i was told so far#pragma comment(lib, "d3d9.lib")#pragma comment(lib, "d3dx9.lib")#pragma comment(lib, "dxguid.lib")#include <d3d9x.h>I was told to add these headers If I add this to  the top of my code can I add Directx code without a problem and are these the only headers needed for a simple code to run??here is what i mean If I add these will the rest of the directx code workOk also is there an introductory program for directx like the one I include below ???I have looked up online tutorials and they're not any helpbecuase most of those are all writen for visual c++ 4,5, or 6 not for .net that is why i am asking questions on here can these tutorials be used in visual c++.net here is the problem I am going to show everyone what I meanhere is the code i am going to use for direct x it is written for 8.0 but I will look for 9.0 code, my question is if I input this code into my I.d.e will I get a window like the tutorial says I will??If this code works I can follow the rest of the online tutorials and Be able to use d3d and direct X I have add some code to the beginning for use with .net/* I added this #pragma comment(lib, "d3d8.lib")#pragma comment(lib, "d3dx8.lib")#pragma comment(lib, "dxguid.lib")#include <d3d8x.h>*/// here is the original directx code#include <d3d8.h>LPDIRECT3D8 g_pD3D = NULL;LPDIRECT3DDEVICE8 g_pD3DDevice = NULL;HRESULT InitialiseD3D(HWND hWnd){    //First of all, create the main D3D object. If it is created successfully we//should get a pointer to an IDirect3D8 interface.    g_pD3D = Direct3DCreate8(D3D_SDK_VERSION);    if(g_pD3D == NULL)    {   return E_FAIL;    }    //Get the current display mode    D3DDISPLAYMODE d3ddm;    if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))    {   return E_FAIL;    }    //Create a structure to hold the settings for our device    D3DPRESENT_PARAMETERS d3dpp;ZeroMemory(&d3dpp, sizeof(d3dpp));    //Fill the structure.//We want our program to be windowed, and set the back buffer to a format    //that matches our current display mode    d3dpp.Windowed = TRUE;    d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC;    d3dpp.BackBufferFormat = d3ddm.Format;    //Create a Direct3D device.    if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice)))    {   return E_FAIL;    }   return S_OK;}void Render(){    if(g_pD3DDevice == NULL)    {   return;    }    //Clear the backbuffer to a green color    g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 255, 0), 1.0f, 0);   //Begin the scene    g_pD3DDevice->BeginScene();   //Rendering of our game objects will go here   //End the scene    g_pD3DDevice->EndScene();   //Filp the back and front buffers so that whatever has been rendered on the back buffer    //will now be visible on screen (front buffer).    g_pD3DDevice->Present(NULL, NULL, NULL, NULL);}void CleanUp(){    if(g_pD3DDevice != NULL)    {   g_pD3DDevice->Release();   g_pD3DDevice = NULL;    }    if(g_pD3D != NULL)    {   g_pD3D->Release();   g_pD3D = NULL;    }}void GameLoop(){    //Enter the game loop    MSG msg;BOOL fMessage;    PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);   while(msg.message != WM_QUIT)    {   fMessage = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE);   if(fMessage)   {  //Process message  TranslateMessage(&msg);  DispatchMessage(&msg);   }   else   {  //No message to process, so render the current scene  Render();   }    }}//The windows message handlerLRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){    switch(msg)    {   case WM_DESTROY:  PostQuitMessage(0);  return 0;   break;   case WM_KEYUP:   switch (wParam)  {  case VK_ESCAPE://User has pressed the escape key, so quitDestroyWindow(hWnd);return 0; break;  }    break;    }    return DefWindowProc(hWnd, msg, wParam, lParam);}//Application entry pointINT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT){    //Register the window class    WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L,  GetModuleHandle(NULL), NULL, NULL, NULL, NULL, "DX Project 1", NULL};    RegisterClassEx(&wc);    //Create the application's window    HWND hWnd = CreateWindow("DX Project 1", "www.andypike.com: Tutorial 1", WS_OVERLAPPEDWINDOW, 50, 50, 500, 500,GetDesktopWindow(), NULL, wc.hInstance, NULL);    //Initialize Direct3D    if(SUCCEEDED(InitialiseD3D(hWnd)))    {    //Show our window   ShowWindow(hWnd, SW_SHOWDEFAULT);   UpdateWindow(hWnd);   //Start game running: Enter the game loop   GameLoop();    }   CleanUp();    UnregisterClass("DX Project 1", wc.hInstance);   return 0;}If this code doen't work can someone show me what is wrong with this code??Edited by Coder: source tags[Edited by - Coder on January 20, 2005 12:24:03 AM]
Quote:Original post by cellman... snip ...here is the problem I am going to show everyone what I meanhere is the code i am going to use for direct x it is written for 8.0 but I will look for 9.0 code, my question is if I input this code into my I.d.e will I get a window like the tutorial says I will??... snip ...If this code doen't work can someone show me what is wrong with this code??Have you tried it? If so, what were the results? Do you plan on posting all of your untested code for everyone to check before you type it into your IDE?;  The .net bit is optional.  You get 2 flavours, managed or unmanaged.  You have to have the DirectX SDK installed after visual c++, that should put all the libraries you need.  Really you want to be programming in DirectX 9.You then have a choice, managed via the .Net virtual machine (the same that c# and vb used), or traditional unmanaged.  The example u gave looks like the unmanaged stuff.Really stepping through the tutorials included with the sdk if you are unfamilar with the visual c++ ide is the best way to go.  Better yet get a decent book.C++ is C++ - there are a few compatibility issues between code in visual c++ 6 and 7 (.net) but not that many - for the unmanaged stuff anyways.   ;  Don't you think it's too much to create 7 threads for the same topic? SEVEN THREADS?!!! (2 3 4 5 6 7)Use the 'Post Reply' button instead of 'New Post' when replying. 'New Post' creates a new thread. if another thread is created for the same subject, it will be deleted. Please keep your replies here.   ;  Basically to get DirectX to compile and link you need two things.Your build environment VisualC++.net in this case need to be able to find the direct x header files and the library files.This means you have to add two paths to the environment, one is a new header file path found usually in:C:\Program Files\Microsoft DirectX 9.0 SDK (October 2004)\IncludeAnd a library path usually:C:\Program Files\Microsoft DirectX 9.0 SDK (October 2004)\LibThe "october 2004" part can be summer or december depending on which version of the sdk you have.These paths are added automatically if you install the sdk after "Visual Studio.NET 2003" But if they for some reason failed to be added you can add them manually. They are found in something similar to "options, environment settings" I think... But I cant check right now since Im at work where I only have a crappy Borland IDE :(If you need more help I surget you try to build your sample and then post the error messages, that ofthen helps more than posting the code in cases like this.Good luck   ;  Dude, buy a book,they only cost like £20 ($40). That will tell you how to setup the libraries and the includes etc. VS.net works fine with normal C++.Getting the includes right and putting the dlls in ur project is real tidious, so unless its done exactly right, it prob wont workYratelev