Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


BluePhase

Member Since 05 Aug 2012
Offline Last Active Jun 11 2013 05:22 PM

Topics I've Started

Fatal error LNK1561: entry point must be defined

18 May 2013 - 06:29 PM

For some reason I have been having a hard time figuring this out. I used the source code from the Microsoft DirectX 11 Tutorial series to generate a DirectX window but I am receiving a huge list of errors while compiling it.

 

The tutorial required me to include these libraries:

 

d3d11.lib
d3dcompiler.lib
dxguid.lib
winmm.lib
comctl32.lib
 

but the first error I got was huge but cant seem to recreate it anymore after I removed the above include libraries.

I then reincluded them and then got the following error:

 

"fatal error LNK1561: entry point must be defined"

 

I tried everything to fix the error but nothing is working so any help at all would be appreciated.

 

I modified the source code a little bit into this:

 

Game.cpp followed by Game.h:

#include "Game.h"

int WINAPI Game::wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{
    UNREFERENCED_PARAMETER( hPrevInstance );
    UNREFERENCED_PARAMETER( lpCmdLine );

    if( FAILED( InitGameWindow( hInstance, nCmdShow ) ) )
        return 0;

    if( FAILED( InitDirect3D() ) )
    {
        CleanupDevice();
        return 0;
    }

    // Main message loop
    MSG msg = {0};
    while( WM_QUIT != msg.message )
    {
        if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
        {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
        else
        {
            Render();
        }
    }

    CleanupDevice();

    return ( int )msg.wParam;
}

HRESULT Game::InitGameWindow(HINSTANCE hInstance, int cmdShow)
{
    // Register class
    WNDCLASSEX wcex;
    wcex.cbSize = sizeof( WNDCLASSEX );
    wcex.style = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc = WndProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInstance;
	wcex.hIcon = LoadIcon( hInstance, ( LPCTSTR )IDI_WINLOGO );
    wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
    wcex.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 );
    wcex.lpszMenuName = NULL;
    wcex.lpszClassName = L"Project Plexice";
    wcex.hIconSm = LoadIcon( wcex.hInstance, ( LPCTSTR )IDI_WINLOGO );
    if( !RegisterClassEx( &wcex ) )
        return E_FAIL;

    // Create window
    g_hInst = hInstance;
    RECT rc = { 0, 0, 640, 480 };
    AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );
    g_hWnd = CreateWindow( L"Project Plexice", L"Project Plexice - Development build 0.1", WS_OVERLAPPEDWINDOW,
                           CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance,
                           NULL );
    if( !g_hWnd )
        return E_FAIL;

    ShowWindow( g_hWnd, cmdShow );

     return S_OK;
}

HRESULT Game::InitDirect3D()
{
    HRESULT hr = S_OK;

    RECT rc;
    GetClientRect( g_hWnd, &rc );
    UINT width = rc.right - rc.left;
    UINT height = rc.bottom - rc.top;

    UINT createDeviceFlags = 0;
#ifdef _DEBUG
    createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

    D3D_DRIVER_TYPE driverTypes[] =
    {
        D3D_DRIVER_TYPE_HARDWARE,
        D3D_DRIVER_TYPE_WARP,
        D3D_DRIVER_TYPE_REFERENCE,
    };
    UINT numDriverTypes = ARRAYSIZE( driverTypes );

    D3D_FEATURE_LEVEL featureLevels[] =
    {
        D3D_FEATURE_LEVEL_11_0,
    };
	UINT numFeatureLevels = ARRAYSIZE( featureLevels );

    DXGI_SWAP_CHAIN_DESC sd;
    ZeroMemory( &sd, sizeof( sd ) );
    sd.BufferCount = 1;
    sd.BufferDesc.Width = width;
    sd.BufferDesc.Height = height;
    sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    sd.BufferDesc.RefreshRate.Numerator = 60;
    sd.BufferDesc.RefreshRate.Denominator = 1;
    sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    sd.OutputWindow = g_hWnd;
    sd.SampleDesc.Count = 1;
    sd.SampleDesc.Quality = 0;
    sd.Windowed = TRUE;

    for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ )
    {
        g_driverType = driverTypes[driverTypeIndex];
        hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels,
                                            D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext );
        if( SUCCEEDED( hr ) )
            break;
    }
    if( FAILED( hr ) )
        return hr;

    // Create a render target view
    ID3D11Texture2D* pBackBuffer = NULL;
    hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer );
    if( FAILED( hr ) )
        return hr;

    hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView );
    pBackBuffer->Release();
    if( FAILED( hr ) )
        return hr;

    g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, NULL );

    // Setup the viewport
    D3D11_VIEWPORT vp;
    vp.Width = (FLOAT)width;
    vp.Height = (FLOAT)height;
    vp.MinDepth = 0.0f;
    vp.MaxDepth = 1.0f;
    vp.TopLeftX = 0;
    vp.TopLeftY = 0;
    g_pImmediateContext->RSSetViewports( 1, &vp );

    return S_OK;
}


void Game::Render()
{
    // Just clear the backbuffer
    float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha
    g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, ClearColor );
    g_pSwapChain->Present( 0, 0 );
}

LRESULT CALLBACK Game::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    PAINTSTRUCT ps;
    HDC hdc;

    switch( message )
    {
        case WM_PAINT:
            hdc = BeginPaint( hWnd, &ps );
            EndPaint( hWnd, &ps );
            break;

        case WM_DESTROY:
            PostQuitMessage( 0 );
            break;

        default:
            return DefWindowProc( hWnd, message, wParam, lParam );
    }

    return 0;
}

void Game::CleanupDevice()
{
    if( g_pImmediateContext ) g_pImmediateContext->ClearState();

    if( g_pRenderTargetView ) g_pRenderTargetView->Release();
    if( g_pSwapChain ) g_pSwapChain->Release();
    if( g_pImmediateContext ) g_pImmediateContext->Release();
    if( g_pd3dDevice ) g_pd3dDevice->Release();
}
#ifndef GAME_H


#include <windows.h>
//#include <windowsx.h>
#include <d3d11.h>
#include <D3DX11.h>

class Game
{
public:
	Game(HINSTANCE hInstance);
	virtual ~Game();

	int Run();

	HWND GetGameWindow() const;
	HINSTANCE GetGameInstance() const;
	float GetAspectRatio() const;

	bool Init();
	void Update(float dt);
	void Render();
	LRESULT MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
	int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow );

public:
	HRESULT InitGameWindow(HINSTANCE hInstance, int cmdShow);
	HRESULT InitDirect3D();
	void CleanupDevice();

	UINT creationFlags;

	//DirectX attributes
HINSTANCE               g_hInst;
HWND                    g_hWnd;
D3D_DRIVER_TYPE         g_driverType;
D3D_FEATURE_LEVEL       g_featureLevel;
ID3D11Device*           g_pd3dDevice;
ID3D11DeviceContext*    g_pImmediateContext;
IDXGISwapChain*         g_pSwapChain;
ID3D11RenderTargetView* g_pRenderTargetView;
};

#endif // !GAME_H

 

 


Detecting a radius based on coordinates?

24 October 2012 - 01:47 PM

Is it possible to detect a radius from a circle based on the coordinates of the object (X, Y, Z) where it's located on the center? It has to be abstract where I can get the radius from any model from any location. I am using the radius to draw a circle around a model for collision detection. This is being implemented into XNA.

Any reason why my collision doesn't work?

21 October 2012 - 07:55 PM

I can't seem to get my collision detection to work at all. Hopefully someone can. Is there a better way to test if it's colliding? The object should free fall until it collides with the object then stops but it doesn't. It just free falls continuously. Thanks in advanced!


This is my Collision Detector:
[source lang="csharp"] public bool CheckForCollision(CustomModel c1, CustomModel c2) { for (int i = 0; i < c1.Model.Meshes.Count; i++) { // Check whether the bounding boxes of the two cubes intersect. BoundingSphere c1BoundingSphere = c1.Model.Meshes[i].BoundingSphere; c1BoundingSphere.Center += c1.Position; for (int j = 0; j < c2.Model.Meshes.Count; j++) { BoundingSphere c2BoundingSphere = c2.Model.Meshes[j].BoundingSphere; c2BoundingSphere.Center += c2.Position; if (c1BoundingSphere.Intersects(c2BoundingSphere)) { return true; } } } return false; }[/source]

This is my physics that I use to test it:

[source lang="csharp"] public void Update(GameTime gameTime, CustomModel model, float Mass, float Velocity) { if (collision.HasCollided == true) CollidedWithObject = true; ModelPositionHeight = model.Position.Y; if (CollidedWithObject == false) { ModelPositionHeight = (Velocity) - (0.5f * Mass * Time * (Time * Time)); model.Position = new Vector3(model.Position.X, ModelPositionHeight, model.Position.Z); Time += (float)gameTime.ElapsedGameTime.TotalSeconds; } if (CollidedWithObject == true) { model.Position = new Vector3(model.Position.X, ModelPositionHeight, model.Position.Z); } }[/source]

In my Main (game1) class:


[source lang="csharp"] customModel.Update(gameTime, models[0], 120, 250); collisionController.CheckForCollision(models[1], models[0]);[/source]

Method for largescale (chunk-based?), seamless terrain

11 October 2012 - 05:45 PM

Hi forums,


I have done a fair amount of CG in the past, but all characters and architecture/ objects- never any terrain larger than a single model.
My goal is to make a terrain which is several square kilometers large. I am using Mudbox, Maya, Blender, and World Machine.
Now I would like to model in a large amount of detail to make normal and displacement/heightmaps from to project onto lower poly models of the same terrain. In order to do this, I need a very large number of subdivisions. Since I can't afford (processing wise) to subdivide the entire world like this at once, I guess I need to divide the whole world into smaller chunks.

I started out in maya, and made a plane with a grid on it, divided into 64 spaces, each grid square I gave its own uv map space, so I ended up with 64 uvs. Then I imported this plane grid into mudbox, where I will model each unit, and then import each unit's UVs into world machine, then world machine's outputs back to mudbox. So the terrain is made up of 64 smaller objects with their own individual uvs.

I have two major issues:

1) [what seems to be the much harder question] since mudbox can only sclupt one object per stroke, when I sculpt over the edges between object squares, they never quite line up again. What is the secret for having sculpted terrain chunk objects that have edges which line up? Do I need to rethink my method entirely to achieve this? Am I perhaps doing it backward? Do I model a fair level of detail, then divide the master terrain model into my 64 chunks from there? Even so, once I cross a chunk edge between two models with a sculpting tool, the seam is broken I would think...


2) Since I am working with 64 sets of uvs from the start, the process is incredibly cumbersome. Is there a way to make a master height map to first take into world machine, and then export WM's outputs, and then take all this into say Maya, and subdividie the whole model into the smaller chunks at that point, with the heightmap UV's being divided as well into their corresponding grid parts?

If all of this doesn't make sense, my question is basically what process do I use to create a massive seamless world (that may have smaller model parts or chunks) if I want to model in high details for displacement maps to project, with Mudbox, Maya, Blender, and World Machine at my disposal?

Best Method to Create Terrain?

06 October 2012 - 05:43 PM

I'm about 4 months in to the development of a game and I have some concerns involving the terrain. I've read around many forums and people seem to always say that importing terrains like .fbx or .x is a horrible idea because it takes up too much hardware consumption. I was curious to know if this is true? What are some optimal methods to make beautiful designed terrain like the ones from Dear Esther? I and a friend (Professional Architect) have been discussing of how to handle things with the terrain and we can't seem to find the solution to our problem. I thought maybe I could program a map editor that uses the XNA Primitives and use Mudbox functions like Sculpting which would enable him to make efficient terrains but is that even considerable?

Thanks in advanced!

PARTNERS