flat assembler
Message board for the users of flat assembler.
Index
> Windows > Direct3D Retained Mode Basic Example for Fasm needed... |
Author |
|
vid 16 Feb 2004, 19:44
you are right, macros are problem in all DX headers. I write pure assembly routines which use assembly in my library TG2D (section Main / thread TAJGA 2D GRAPHIC LIBRARY), if you are interested. There is a DX9 include posted on forum, but i think it uses too many unnescessary macros. Privalov's DDRAW example is okay but header is very limited.
about version independence - you have to either use version 1 interface or just check version. I dont see any workaround on this. |
|||
16 Feb 2004, 19:44 |
|
i-don 16 Feb 2004, 20:27
Since you mentioned about TG2D, I've test on my win95OCR2 test machine with DX7 and 4MB display card. It crash the display and messing up all my desktop icons. I've to reset my machine to exit the halt. since then, I'm not interesting to test the further version that really 'hot' to the hardware.
I impressed by the example of OpenGL in Fasm example. There is no macro used and still it run very nice. I even can feed-in a 3D cube with depth into the code. What I need is really basic D3DRM feature enable in DX screen like Frames, MeshBuilder, Vertex, Viewport and Mesh which is call from the DLL and the includes file for contants and structures probably list up like OpenGL include file. Pretty plain and nevermind if it's long. The rest may be just math dan value to show up a simple rotating cube in D3D example. Here is the source code in c which I was joined altogether from DX7 documentation into a single file: Code: ///////////////////////////////////////////////////////////////////// // // Copyright (C) 1996 Microsoft Corporation. All Rights Reserved. // // File: Helworld.c // // Simplified Direct3D Retained Mode example, based on // the "Globe" SDK sample. // ///////////////////////////////////////////////////////////////////// #define INITGUID // Must precede other defines and includes #include <windows.h> #include <malloc.h> // Required by memset call #include <d3drmwin.h> #define MAX_DRIVERS 5 // Maximum D3D drivers expected // Global variables LPDIRECT3DRM lpD3DRM; // Direct3DRM object LPDIRECTDRAWCLIPPER lpDDClipper;// DirectDrawClipper object struct _myglobs { LPDIRECT3DRMDEVICE dev; // Direct3DRM device LPDIRECT3DRMVIEWPORT view; // Direct3DRM viewport through which // the scene is viewed LPDIRECT3DRMFRAME scene; // Master frame in which others are // placed LPDIRECT3DRMFRAME camera; // Frame describing the user's POV GUID DriverGUID[MAX_DRIVERS]; // GUIDs of available D3D drivers char DriverName[MAX_DRIVERS][50]; // Names of available D3D drivers int NumDrivers; // Number of available D3D drivers int CurrDriver; // Number of D3D driver currently // being used BOOL bQuit; // Program is about to terminate BOOL bInitialized; // All D3DRM objects are initialized BOOL bMinimized; // Window is minimized int BPP; // Bit depth of the current display mode } myglobs; // Function prototypes. static BOOL InitApp(HINSTANCE, int); long FAR PASCAL WindowProc(HWND, UINT, WPARAM, LPARAM); static BOOL EnumDrivers(HWND win); static HRESULT WINAPI enumDeviceFunc(LPGUID lpGuid, LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC lpHWDesc, LPD3DDEVICEDESC lpHELDesc, LPVOID lpContext); static DWORD BPPToDDBD(int bpp); static BOOL CreateDevAndView(LPDIRECTDRAWCLIPPER lpDDClipper, int driver, int width, int height); static BOOL SetRenderState(void); static BOOL RenderLoop(void); static BOOL MyScene(LPDIRECT3DRMDEVICE dev, LPDIRECT3DRMVIEWPORT view, LPDIRECT3DRMFRAME scene, LPDIRECT3DRMFRAME camera); void MakeMyFrames(LPDIRECT3DRMFRAME lpScene, LPDIRECT3DRMFRAME lpCamera, LPDIRECT3DRMFRAME * lplpLightFrame1, LPDIRECT3DRMFRAME * lplpWorld_frame); void MakeMyLights(LPDIRECT3DRMFRAME lpScene, LPDIRECT3DRMFRAME lpCamera, LPDIRECT3DRMFRAME lpLightFrame1, LPDIRECT3DRMLIGHT * lplpLight1, LPDIRECT3DRMLIGHT * lplpLight2); void SetMyPositions(LPDIRECT3DRMFRAME lpScene, LPDIRECT3DRMFRAME lpCamera, LPDIRECT3DRMFRAME lpLightFrame1, LPDIRECT3DRMFRAME lpWorld_frame); void MakeMyMesh(LPDIRECT3DRMMESHBUILDER * lplpSphere3_builder); void MakeMyWrap(LPDIRECT3DRMMESHBUILDER sphere3_builder, LPDIRECT3DRMWRAP * lpWrap); void AddMyTexture(LPDIRECT3DRMMESHBUILDER lpSphere3_builder, LPDIRECT3DRMTEXTURE * lplpTex); static void CleanUp(void); ///////////////////////////////////////////////////////////////////// // // WinMain // Initializes the application and enters a message loop. // The message loop renders the scene until a quit message is received. // ///////////////////////////////////////////////////////////////////// int PASCAL WinMain (HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int cmdshow) { MSG msg; HACCEL accel = NULL; int failcount = 0; // Number of times RenderLoop has failed prev_inst; cmdline; // Create the window and initialize all objects needed to begin // rendering. if (!InitApp(this_inst, cmdshow)) return 1; while (!myglobs.bQuit) { // Monitor the message queue until there are no pressing // messages. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (!TranslateAccelerator(msg.hwnd, accel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } // If the app is not minimized, not about to quit, and D3DRM has // been initialized, begin rendering. if (!myglobs.bMinimized && !myglobs.bQuit && myglobs.bInitialized) { // Attempt to render a frame. If rendering fails more than // twice, abort execution. if (!RenderLoop()) ++failcount; if (failcount > 2) { CleanUp(); break; } } } return msg.wParam; } ///////////////////////////////////////////////////////////////////// // // InitApp // Creates window and initializes all objects necessary to begin // rendering. // ///////////////////////////////////////////////////////////////////// static BOOL InitApp(HINSTANCE this_inst, int cmdshow) { HWND win; HDC hdc; WNDCLASS wc; RECT rc; // Set up and register the window class. wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof(DWORD); wc.hInstance = this_inst; wc.hIcon = LoadIcon(this_inst, "AppIcon"); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "D3DRM Example"; if (!RegisterClass(&wc)) return FALSE; // Initialize the global variables. memset(&myglobs, 0, sizeof(myglobs)); // Create the window. win = CreateWindow ( "D3DRM Example", // Class "Hello World (Direct3DRM)", // Title bar WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, CW_USEDEFAULT, // Init. x pos CW_USEDEFAULT, // Init. y pos 400, // Init. x size 400, // Init. y size NULL, // Parent window NULL, // Menu handle this_inst, // Program handle NULL // Create parms ); if (!win) return FALSE; // Record the current display bits-per-pixel. hdc = GetDC(win); myglobs.BPP = GetDeviceCaps(hdc, BITSPIXEL); ReleaseDC(win, hdc); // Enumerate the D3D drivers and select one. if (!EnumDrivers(win)) return FALSE; // Create the D3DRM object and the D3DRM window object. lpD3DRM = NULL; Direct3DRMCreate(&lpD3DRM); // Create the master scene frame and camera frame. lpD3DRM->lpVtbl->CreateFrame(lpD3DRM, NULL, &myglobs.scene); lpD3DRM->lpVtbl->CreateFrame(lpD3DRM, myglobs.scene, &myglobs.camera); myglobs.camera->lpVtbl->SetPosition(myglobs.camera, myglobs.scene, D3DVAL(0.0), D3DVAL(0.0), D3DVAL(0.0)); // Create a DirectDrawClipper object and associate the // window with it. DirectDrawCreateClipper(0, &lpDDClipper, NULL); lpDDClipper->lpVtbl->SetHWnd(lpDDClipper, 0, win); // Create the D3DRM device by using the selected D3D driver. GetClientRect(win, &rc); if (!CreateDevAndView(lpDDClipper, myglobs.CurrDriver, rc.right, rc.bottom)) { return FALSE; } // Create the scene to be rendered. if (!MyScene(myglobs.dev, myglobs.view, myglobs.scene, myglobs.camera)) return FALSE; myglobs.bInitialized = TRUE; // Initialization completed // Display the window. ShowWindow(win, cmdshow); UpdateWindow(win); return TRUE; } ///////////////////////////////////////////////////////////////////// // // WindowProc // Main window message handler. // ///////////////////////////////////////////////////////////////////// LONG FAR PASCAL WindowProc(HWND win, UINT msg, WPARAM wparam, LPARAM lparam) { RECT r; PAINTSTRUCT ps; LPDIRECT3DRMWINDEVICE lpD3DRMWinDev; switch (msg) { case WM_DESTROY: CleanUp(); break; case WM_ACTIVATE: { // Create a Windows-specific Direct3D Retained Mode window device to handle this // message. if (!myglobs.dev) break; myglobs.dev->lpVtbl->QueryInterface(myglobs.dev, &IID_IDirect3DRMWinDevice, (void **) &lpD3DRMWinDev); lpD3DRMWinDev->lpVtbl->HandleActivate(lpD3DRMWinDev, (WORD) wparam); lpD3DRMWinDev->lpVtbl->Release(lpD3DRMWinDev); } break; case WM_PAINT: if (!myglobs.bInitialized || !myglobs.dev) return DefWindowProc(win, msg, wparam, lparam); // Create a Windows-specific Direct3D Retained Mode window device to handle this // message. if (GetUpdateRect(win, &r, FALSE)) { BeginPaint(win, &ps); myglobs.dev->lpVtbl->QueryInterface(myglobs.dev, &IID_IDirect3DRMWinDevice, (void **) &lpD3DRMWinDev); lpD3DRMWinDev->lpVtbl->HandlePaint(lpD3DRMWinDev, ps.hdc); lpD3DRMWinDev->lpVtbl->Release(lpD3DRMWinDev); EndPaint(win, &ps); } break; default: return DefWindowProc(win, msg, wparam, lparam); } return 0L; } ///////////////////////////////////////////////////////////////////// // // EnumDrivers // Enumerate the available D3D drivers and choose one. // ///////////////////////////////////////////////////////////////////// static BOOL EnumDrivers(HWND win) { LPDIRECTDRAW lpDD; LPDIRECT3D lpD3D; HRESULT rval; // Create a DirectDraw object and query for the Direct3D interface // to use to enumerate the drivers. DirectDrawCreate(NULL, &lpDD, NULL); rval = lpDD->lpVtbl->QueryInterface(lpDD, &IID_IDirect3D, (void**) &lpD3D); if (rval != DD_OK) { lpDD->lpVtbl->Release(lpDD); return FALSE; } // Enumerate the drivers, setting CurrDriver to -1 to initialize the // driver selection code in enumDeviceFunc. myglobs.CurrDriver = -1; lpD3D->lpVtbl->EnumDevices(lpD3D, enumDeviceFunc, &myglobs.CurrDriver); // Ensure at least one valid driver was found. if (myglobs.NumDrivers == 0) { return FALSE; } lpD3D->lpVtbl->Release(lpD3D); lpDD->lpVtbl->Release(lpDD); return TRUE; } ///////////////////////////////////////////////////////////////////// // // enumDeviceFunc // Callback function that records each usable D3D driver's name // and GUID. Chooses a driver and sets *lpContext to this driver. // ///////////////////////////////////////////////////////////////////// static HRESULT WINAPI enumDeviceFunc(LPGUID lpGuid, LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC lpHWDesc, LPD3DDEVICEDESC lpHELDesc, LPVOID lpContext) { static BOOL hardware = FALSE; // Current start driver is hardware static BOOL mono = FALSE; // Current start driver is mono light LPD3DDEVICEDESC lpDesc; int *lpStartDriver = (int *)lpContext; // Decide which device description should be consulted. lpDesc = lpHWDesc->dcmColorModel ? lpHWDesc : lpHELDesc; // If this driver cannot render in the current display bit-depth, // skip it and continue with the enumeration. if (!(lpDesc->dwDeviceRenderBitDepth & BPPToDDBD(myglobs.BPP))) return D3DENUMRET_OK; // Record this driver's name and GUID. memcpy(&myglobs.DriverGUID[myglobs.NumDrivers], lpGuid, sizeof(GUID)); lstrcpy(&myglobs.DriverName[myglobs.NumDrivers][0], lpDeviceName); // Choose hardware over software, RGB lights over mono lights. if (*lpStartDriver == -1) { // This is the first valid driver. *lpStartDriver = myglobs.NumDrivers; hardware = lpDesc == lpHWDesc ? TRUE : FALSE; mono = lpDesc->dcmColorModel & D3DCOLOR_MONO ? TRUE : FALSE; } else if (lpDesc == lpHWDesc && !hardware) { // This driver is hardware and the start driver is not. *lpStartDriver = myglobs.NumDrivers; hardware = lpDesc == lpHWDesc ? TRUE : FALSE; mono = lpDesc->dcmColorModel & D3DCOLOR_MONO ? TRUE : FALSE; } else if ((lpDesc == lpHWDesc && hardware ) || (lpDesc == lpHELDesc && !hardware)) { if (lpDesc->dcmColorModel == D3DCOLOR_MONO && !mono) { // This driver and the start driver are the same type, and // this driver is mono whereas the start driver is not. *lpStartDriver = myglobs.NumDrivers; hardware = lpDesc == lpHWDesc ? TRUE : FALSE; mono = lpDesc->dcmColorModel & D3DCOLOR_MONO ? TRUE : FALSE; } } myglobs.NumDrivers++; if (myglobs.NumDrivers == MAX_DRIVERS) return (D3DENUMRET_CANCEL); return (D3DENUMRET_OK); } ///////////////////////////////////////////////////////////////////// // // BPPToDDBD // Converts bits-per-pixel to a DirectDraw bit-depth flag. // ///////////////////////////////////////////////////////////////////// static DWORD BPPToDDBD(int bpp) { switch(bpp) { case 1: return DDBD_1; case 2: return DDBD_2; case 4: return DDBD_4; case 8: return DDBD_8; case 16: return DDBD_16; case 24: return DDBD_24; case 32: return DDBD_32; default: return 0; } } ///////////////////////////////////////////////////////////////////// // // CreateDevAndView // Create the D3DRM device and viewport with the given D3D driver and // with the specified size. // ///////////////////////////////////////////////////////////////////// static BOOL CreateDevAndView(LPDIRECTDRAWCLIPPER lpDDClipper, int driver, int width, int height) { HRESULT rval; // Create the D3DRM device from this window by using the specified // D3D driver. lpD3DRM->lpVtbl->CreateDeviceFromClipper(lpD3DRM, lpDDClipper, &myglobs.DriverGUID[driver], width, height, &myglobs.dev); // Create the D3DRM viewport by using the camera frame. Set the // background depth to a large number. The width and height // might have been slightly adjusted, so get them from the device. width = myglobs.dev->lpVtbl->GetWidth(myglobs.dev); height = myglobs.dev->lpVtbl->GetHeight(myglobs.dev); rval = lpD3DRM->lpVtbl->CreateViewport(lpD3DRM, myglobs.dev, myglobs.camera, 0, 0, width, height, &myglobs.view); if (rval != D3DRM_OK) { myglobs.dev->lpVtbl->Release(myglobs.dev); return FALSE; } rval = myglobs.view->lpVtbl->SetBack(myglobs.view, D3DVAL(5000.0)); if (rval != D3DRM_OK) { myglobs.dev->lpVtbl->Release(myglobs.dev); myglobs.view->lpVtbl->Release(myglobs.view); return FALSE; } // Set the render quality, fill mode, lighting state, // and color shade info. if (!SetRenderState()) return FALSE; return TRUE; } ///////////////////////////////////////////////////////////////////// // // SetRenderState // Set the render quality and shade information. // ///////////////////////////////////////////////////////////////////// BOOL SetRenderState(void) { HRESULT rval; // Set the render quality (light toggle, fill mode, shade mode). rval = myglobs.dev->lpVtbl->SetQuality(myglobs.dev, D3DRMLIGHT_ON | D3DRMFILL_SOLID | D3DRMSHADE_GOURAUD); if (rval != D3DRM_OK) { return FALSE; } // If you want to change the dithering mode, use SetDither here. // If you want a texture quality other than D3DRMTEXTURE_NEAREST // (the default value), use SetTextureQuality here. return TRUE; } ///////////////////////////////////////////////////////////////////// // // RenderLoop // Clear the viewport, render the next frame, and update the window. // ///////////////////////////////////////////////////////////////////// static BOOL RenderLoop() { HRESULT rval; // Tick the scene. rval = myglobs.scene->lpVtbl->Move(myglobs.scene, D3DVAL(1.0)); if (rval != D3DRM_OK) { return FALSE; } // Clear the viewport. rval = myglobs.view->lpVtbl->Clear(myglobs.view); if (rval != D3DRM_OK) { return FALSE; } // Render the scene to the viewport. rval = myglobs.view->lpVtbl->Render(myglobs.view, myglobs.scene); if (rval != D3DRM_OK) { return FALSE; } // Update the window. rval = myglobs.dev->lpVtbl->Update(myglobs.dev); if (rval != D3DRM_OK) { return FALSE; } return TRUE; } ///////////////////////////////////////////////////////////////////// // // MyScene // Uses the functions that create the frames, lights, mesh, and // texture. Releases all interfaces on completion. // ///////////////////////////////////////////////////////////////////// BOOL MyScene(LPDIRECT3DRMDEVICE dev, LPDIRECT3DRMVIEWPORT view, LPDIRECT3DRMFRAME lpScene, LPDIRECT3DRMFRAME lpCamera) { LPDIRECT3DRMFRAME lpLightframe1 = NULL; LPDIRECT3DRMFRAME lpWorld_frame = NULL; LPDIRECT3DRMLIGHT lpLight1 = NULL; LPDIRECT3DRMLIGHT lpLight2 = NULL; LPDIRECT3DRMTEXTURE lpTex = NULL; LPDIRECT3DRMWRAP lpWrap = NULL; LPDIRECT3DRMMESHBUILDER lpSphere3_builder = NULL; MakeMyFrames(lpScene, lpCamera, &lpLightframe1, &lpWorld_frame); MakeMyLights(lpScene, lpCamera, lpLightframe1, &lpLight1, &lpLight2); SetMyPositions(lpScene, lpCamera, lpLightframe1, lpWorld_frame); MakeMyMesh(&lpSphere3_builder); MakeMyWrap(lpSphere3_builder, &lpWrap); AddMyTexture(lpSphere3_builder, &lpTex); // If you need to create a material (for example, to create // a shiny surface), use CreateMaterial and SetMaterial here. // Now that the visual object has been created, add it // to the world frame. lpWorld_frame->lpVtbl->AddVisual(lpWorld_frame, (LPDIRECT3DRMVISUAL) lpSphere3_builder); lpLightframe1->lpVtbl->Release(lpLightframe1); lpWorld_frame->lpVtbl->Release(lpWorld_frame); lpSphere3_builder->lpVtbl->Release(lpSphere3_builder); lpLight1->lpVtbl->Release(lpLight1); lpLight2->lpVtbl->Release(lpLight2); lpTex->lpVtbl->Release(lpTex); lpWrap->lpVtbl->Release(lpWrap); return TRUE; } ///////////////////////////////////////////////////////////////////// // // MakeMyFrames // Create frames used in the scene. // ///////////////////////////////////////////////////////////////////// void MakeMyFrames(LPDIRECT3DRMFRAME lpScene, LPDIRECT3DRMFRAME lpCamera, LPDIRECT3DRMFRAME * lplpLightFrame1, LPDIRECT3DRMFRAME * lplpWorld_frame) { lpD3DRM->lpVtbl->CreateFrame(lpD3DRM, lpScene, lplpLightFrame1); lpD3DRM->lpVtbl->CreateFrame(lpD3DRM, lpScene, lplpWorld_frame); } ///////////////////////////////////////////////////////////////////// // // MakeMyLights // Create lights used in the scene. // ///////////////////////////////////////////////////////////////////// void MakeMyLights(LPDIRECT3DRMFRAME lpScene, LPDIRECT3DRMFRAME lpCamera, LPDIRECT3DRMFRAME lpLightFrame1, LPDIRECT3DRMLIGHT * lplpLight1, LPDIRECT3DRMLIGHT * lplpLight2) { lpD3DRM->lpVtbl->CreateLightRGB(lpD3DRM, D3DRMLIGHT_DIRECTIONAL, D3DVAL(0.9), D3DVAL(0.9), D3DVAL(0.9), lplpLight1); lpLightFrame1->lpVtbl->AddLight(lpLightFrame1, *lplpLight1); lpD3DRM->lpVtbl->CreateLightRGB(lpD3DRM, D3DRMLIGHT_AMBIENT, D3DVAL(0.1), D3DVAL(0.1), D3DVAL(0.1), lplpLight2); lpScene->lpVtbl->AddLight(lpScene, *lplpLight2); } ///////////////////////////////////////////////////////////////////// // // SetMyPositions // Set the positions and orientations of the light, camera, and // world frames. Establish a rotation for the globe. // ///////////////////////////////////////////////////////////////////// void SetMyPositions(LPDIRECT3DRMFRAME lpScene, LPDIRECT3DRMFRAME lpCamera, LPDIRECT3DRMFRAME lpLightFrame1, LPDIRECT3DRMFRAME lpWorld_frame) { lpLightFrame1->lpVtbl->SetPosition(lpLightFrame1, lpScene, D3DVAL(2), D3DVAL(0.0), D3DVAL(22)); lpCamera->lpVtbl->SetPosition(lpCamera, lpScene, D3DVAL(0.0), D3DVAL(0.0), D3DVAL(0.0)); lpCamera->lpVtbl->SetOrientation(lpCamera, lpScene, D3DVAL(0.0), D3DVAL(0.0), D3DVAL(1), D3DVAL(0.0), D3DVAL(1), D3DVAL(0.0)); lpWorld_frame->lpVtbl->SetPosition(lpWorld_frame, lpScene, D3DVAL(0.0), D3DVAL(0.0), D3DVAL(15)); lpWorld_frame->lpVtbl->SetOrientation(lpWorld_frame, lpScene, D3DVAL(0.0), D3DVAL(0.0), D3DVAL(1), D3DVAL(0.0), D3DVAL(1), D3DVAL(0.0)); lpWorld_frame->lpVtbl->SetRotation(lpWorld_frame, lpScene, D3DVAL(0.0), D3DVAL(0.1), D3DVAL(0.0), D3DVAL(0.05)); } ///////////////////////////////////////////////////////////////////// // // MakeMyMesh // Create MeshBuilder object, load, scale, and color the mesh. // ///////////////////////////////////////////////////////////////////// void MakeMyMesh(LPDIRECT3DRMMESHBUILDER * lplpSphere3_builder) { lpD3DRM->lpVtbl->CreateMeshBuilder(lpD3DRM, lplpSphere3_builder); (*lplpSphere3_builder)->lpVtbl->Load(*lplpSphere3_builder, "sphere3.x", NULL, D3DRMLOAD_FROMFILE, NULL, NULL); (*lplpSphere3_builder)->lpVtbl->Scale(*lplpSphere3_builder, D3DVAL(2), D3DVAL(2), D3DVAL(2)); // Set sphere to white to avoid unexpected texture-blending results. (*lplpSphere3_builder)->lpVtbl->SetColorRGB(*lplpSphere3_builder, D3DVAL(1), D3DVAL(1), D3DVAL(1)); } ///////////////////////////////////////////////////////////////////// // // MakeMyWrap // Creates and applies wrap for texture. // ///////////////////////////////////////////////////////////////////// void MakeMyWrap(LPDIRECT3DRMMESHBUILDER sphere3_builder, LPDIRECT3DRMWRAP * lpWrap) { D3DVALUE miny, maxy, height; D3DRMBOX box; sphere3_builder->lpVtbl->GetBox(sphere3_builder, &box); maxy = box.max.y; miny = box.min.y; height = maxy - miny; lpD3DRM->lpVtbl->CreateWrap (lpD3DRM, D3DRMWRAP_CYLINDER, NULL, D3DVAL(0.0), D3DVAL(0.0), D3DVAL(0.0), D3DVAL(0.0), D3DVAL(1.0), D3DVAL(0.0), D3DVAL(0.0), D3DVAL(0.0), D3DVAL(1.0), D3DVAL(0.0), D3DDivide(miny, height), D3DVAL(1.0), D3DDivide(D3DVAL(1.0), height), lpWrap); (*lpWrap)->lpVtbl->Apply(*lpWrap, (LPDIRECT3DRMOBJECT) sphere3_builder); } ///////////////////////////////////////////////////////////////////// // // AddMyTexture // Creates and applies wrap for texture. // ///////////////////////////////////////////////////////////////////// void AddMyTexture(LPDIRECT3DRMMESHBUILDER lpSphere3_builder, LPDIRECT3DRMTEXTURE * lplpTex) { lpD3DRM->lpVtbl->LoadTexture(lpD3DRM, "tutor.bmp", lplpTex); // If you need a color depth other than the default (16), // use IDirect3DRMTexture::SetShades here. lpSphere3_builder->lpVtbl->SetTexture(lpSphere3_builder, *lplpTex); } ///////////////////////////////////////////////////////////////////// // // CleanUp // Release all D3DRM objects and set the bQuit flag. // ///////////////////////////////////////////////////////////////////// void CleanUp(void) { myglobs.bInitialized = FALSE; myglobs.scene->lpVtbl->Release(myglobs.scene); myglobs.camera->lpVtbl->Release(myglobs.camera); myglobs.view->lpVtbl->Release(myglobs.view); myglobs.dev->lpVtbl->Release(myglobs.dev); lpD3DRM->lpVtbl->Release(lpD3DRM); lpDDClipper->lpVtbl->Release(lpDDClipper); myglobs.bQuit = TRUE; } To make things simple here I include the example from C source code. The model and texture file I use from other source. The executable was compile using LCC under DX7 environment. I guess it doesn't matter at all since the module has never declare or calling any DirectX header version such as DX7 or DX8. It probably will run under DX6 as long as you have DDraw.DLL and D3DRM.DLL. But not sure about DX9 since I heard they discard D3DRM from the distribution. Hope someone would able to translate this code into FASM and it's a good idea to use it as one of FASM distribution example file for D3DRM.
|
||||||||||||||||||||
16 Feb 2004, 20:27 |
|
i-don 14 Mar 2004, 19:48
I really want to learn and see a Direct3DRM example in FASM. Even better if it has example in Fullscreen and window mode. I've found from old download attics in my hard disk a D3DRM demo in TASM32. Forgot where I was download it from.
I'll appreciate it very much for anyone would able to convert or use the source code to make D3DRM examples for FASM. Thanks.
|
|||||||||||
14 Mar 2004, 19:48 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.