Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actuallucky6969b

Posted 15 January 2013 - 04:52 AM

Thanks, I gave up the texture values, cos I don't make one yet.
However, when I am doing this
return IN.shade * materialColor;

The rendered output is extremely jagged.
How can I improve that?

Update:

 

void Application::Update(float deltaTime)
{
    try
    {
        //Check for lost device
        HRESULT coop = g_pDevice->TestCooperativeLevel();
        if(coop != D3D_OK)
        {
            if(coop == D3DERR_DEVICELOST)
            {
                if(m_deviceLost == false)
                    DeviceLost();        
            }
            else if(coop == D3DERR_DEVICENOTRESET)
            {
                if(m_deviceLost == true)
                    DeviceGained();
            }
            Sleep(100);
            return;
        }
        m_deltaTime = deltaTime * 0.4f;
        //Keyboard input
        if(KeyDown(VK_ESCAPE))
        {
            Quit();
        }
        if(KeyDown(VK_RETURN) && KeyDown(18))        //ALT + RETURN
        {
            //Switch between windowed mode and fullscreen mode
            m_present.Windowed = !m_present.Windowed;
            DeviceLost();
            DeviceGained();
            if(m_present.Windowed)
            {
                RECT rc = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
                AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, false);
                SetWindowPos(m_mainWindow, HWND_NOTOPMOST, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW);
                UpdateWindow(m_mainWindow);
            }
        }
        //Toggle Animation
        if(KeyDown(VK_RETURN))
        {
            Sleep(300);
            RandomizeAnimations();
        }
    }
    catch(...)
    {
        g_debug << "Error in Application::Update() \n";
    }
}  

 

 

void Application::DeviceLost()
{
	try
	{
		g_pFont->OnLostDevice();
		g_pEffect->OnLostDevice();
		m_deviceLost = true;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceLost() \n";
	}
}

void Application::DeviceGained()
{
	try
	{
		g_pDevice->Reset(&m_present);
		g_pFont->OnResetDevice();
		g_pEffect->OnResetDevice();
		m_deviceLost = false;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceGained() \n";
	}
}

I copied the code from a book. So this presentation parameters are the same when the device is regained.
 

void Application::DeviceGained()
{
	try
	{ 
		g_pDevice->Reset(&m_present);
		g_pFont->OnResetDevice();
		g_pEffect->OnResetDevice();
		m_deviceLost = false;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceGained() \n";
	}
}


 
Thanks
Jack
 


#4lucky6969b

Posted 15 January 2013 - 04:49 AM

Thanks, I gave up the texture values, cos I don't make one yet.
However, when I am doing this
return IN.shade * materialColor;

The rendered output is extremely jagged.
How can I improve that?

Update:

 

void Application::Update(float deltaTime)
{
    try
    {
        //Check for lost device
        HRESULT coop = g_pDevice->TestCooperativeLevel();
        if(coop != D3D_OK)
        {
            if(coop == D3DERR_DEVICELOST)
            {
                if(m_deviceLost == false)
                    DeviceLost();        
            }
            else if(coop == D3DERR_DEVICENOTRESET)
            {
                if(m_deviceLost == true)
                    DeviceGained();
            }
            Sleep(100);
            return;
        }
        m_deltaTime = deltaTime * 0.4f;
        //Keyboard input
        if(KeyDown(VK_ESCAPE))
        {
            Quit();
        }
        if(KeyDown(VK_RETURN) && KeyDown(18))        //ALT + RETURN
        {
            //Switch between windowed mode and fullscreen mode
            m_present.Windowed = !m_present.Windowed;
            DeviceLost();
            DeviceGained();
            if(m_present.Windowed)
            {
                RECT rc = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
                AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, false);
                SetWindowPos(m_mainWindow, HWND_NOTOPMOST, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW);
                UpdateWindow(m_mainWindow);
            }
        }
        //Toggle Animation
        if(KeyDown(VK_RETURN))
        {
            Sleep(300);
            RandomizeAnimations();
        }
    }
    catch(...)
    {
        g_debug << "Error in Application::Update() \n";
    }
}  

 

 

void Application::DeviceLost()
{
	try
	{
		g_pFont->OnLostDevice();
		g_pEffect->OnLostDevice();
		m_deviceLost = true;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceLost() \n";
	}
}

void Application::DeviceGained()
{
	try
	{
		g_pDevice->Reset(&m_present);
		g_pFont->OnResetDevice();
		g_pEffect->OnResetDevice();
		m_deviceLost = false;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceGained() \n";
	}
}

I copied the code from a book. So this presentation parameters are the same when the device is regained.
 

void Application::DeviceGained()
{
	try
	{
		RECT rcClient, rcWind;
	    
		GetClientRect(m_mainWindow, &rcClient);
		GetWindowRect(m_mainWindow, &rcWind);
		m_present.BackBufferWidth = (rcWind.right - rcWind.left) - rcClient.right;
		m_present.BackBufferHeight = (rcWind.bottom - rcWind.top) - rcClient.bottom;
				 
		g_pDevice->Reset(&m_present);
		g_pFont->OnResetDevice();
		g_pEffect->OnResetDevice();
		m_deviceLost = false;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceGained() \n";
	}
}


But this code snippet is never called even though the window is minimized, maximized, moved or resized.
Thanks
Jack
Thanks
Jack


#3lucky6969b

Posted 15 January 2013 - 04:48 AM

Thanks, I gave up the texture values, cos I don't make one yet.
However, when I am doing this
return IN.shade * materialColor;

The rendered output is extremely jagged.
How can I improve that?

Update:

void Application::Update(float deltaTime)
{
    try
    {
        //Check for lost device
        HRESULT coop = g_pDevice->TestCooperativeLevel();
        if(coop != D3D_OK)
        {
            if(coop == D3DERR_DEVICELOST)
            {
                if(m_deviceLost == false)
                    DeviceLost();        
            }
            else if(coop == D3DERR_DEVICENOTRESET)
            {
                if(m_deviceLost == true)
                    DeviceGained();
            }
            Sleep(100);
            return;
        }
        m_deltaTime = deltaTime * 0.4f;
        //Keyboard input
        if(KeyDown(VK_ESCAPE))
        {
            Quit();
        }
        if(KeyDown(VK_RETURN) && KeyDown(18))        //ALT + RETURN
        {
            //Switch between windowed mode and fullscreen mode
            m_present.Windowed = !m_present.Windowed;
            DeviceLost();
            DeviceGained();
            if(m_present.Windowed)
            {
                RECT rc = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
                AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, false);
                SetWindowPos(m_mainWindow, HWND_NOTOPMOST, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW);
                UpdateWindow(m_mainWindow);
            }
        }
        //Toggle Animation
        if(KeyDown(VK_RETURN))
        {
            Sleep(300);
            RandomizeAnimations();
        }
    }
    catch(...)
    {
        g_debug << "Error in Application::Update() \n";
    }
}  

 

void Application::DeviceLost()
{
	try
	{
		g_pFont->OnLostDevice();
		g_pEffect->OnLostDevice();
		m_deviceLost = true;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceLost() \n";
	}
}

void Application::DeviceGained()
{
	try
	{
		g_pDevice->Reset(&m_present);
		g_pFont->OnResetDevice();
		g_pEffect->OnResetDevice();
		m_deviceLost = false;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceGained() \n";
	}
}

I copied the code from a book. So this presentation parameters are the same when the device is regained.
 

void Application::DeviceGained()
{
	try
	{
		RECT rcClient, rcWind;
	    POINT ptDiff;
		GetClientRect(m_mainWindow, &rcClient);
		GetWindowRect(m_mainWindow, &rcWind);
		m_present.BackBufferWidth = (rcWind.right - rcWind.left) - rcClient.right;
		m_present.BackBufferHeight = (rcWind.bottom - rcWind.top) - rcClient.bottom;
				 
		g_pDevice->Reset(&m_present);
		g_pFont->OnResetDevice();
		g_pEffect->OnResetDevice();
		m_deviceLost = false;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceGained() \n";
	}
}


But this code snippet is never called even though the window is minimized, maximized, moved or resized.
Thanks
Jack
Thanks
Jack


#2lucky6969b

Posted 15 January 2013 - 04:47 AM

Thanks, I gave up the texture values, cos I don't make one yet.
However, when I am doing this
return IN.shade * materialColor;

The rendered output is extremely jagged.
How can I improve that?

Update:
void Application::DeviceLost()
{
	try
	{
		g_pFont->OnLostDevice();
		g_pEffect->OnLostDevice();
		m_deviceLost = true;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceLost() \n";
	}
}

void Application::DeviceGained()
{
	try
	{
		g_pDevice->Reset(&m_present);
		g_pFont->OnResetDevice();
		g_pEffect->OnResetDevice();
		m_deviceLost = false;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceGained() \n";
	}
}
I copied the code from a book. So this presentation parameters are the same when the device is regained.

void Application::DeviceGained()
{
	try
	{
		RECT rcClient, rcWind;
	    POINT ptDiff;
		GetClientRect(m_mainWindow, &rcClient);
		GetWindowRect(m_mainWindow, &rcWind);
		m_present.BackBufferWidth = (rcWind.right - rcWind.left) - rcClient.right;
		m_present.BackBufferHeight = (rcWind.bottom - rcWind.top) - rcClient.bottom;
				 
		g_pDevice->Reset(&m_present);
		g_pFont->OnResetDevice();
		g_pEffect->OnResetDevice();
		m_deviceLost = false;
	}
	catch(...)
	{
		g_debug << "Error occured in Application::DeviceGained() \n";
	}
}

But this code snippet is never called even though the window is minimized, maximized, moved or resized.
Thanks
Jack
Thanks
Jack

#1lucky6969b

Posted 15 January 2013 - 04:27 AM

Thanks, I gave up the texture values, cos I don't make one yet. However, when I am doing this return IN.shade * materialColor; The rendered output is extremely jagged. How can I improve that? Thanks Jack

PARTNERS