예제 #1
0
void CEGControlBar::OnSize(UINT nType, int cx, int cy)
{
	CControlBar::OnSize(nType, cx, cy);

	DWORD dwStyle = GetBarStyle();
	if ( (dwStyle & CBRS_LEFT ) == CBRS_LEFT ) {
		m_dragRect.SetRect( cx - SPLITTER_SIZE, 0, cx, cy);
	} else if ( (dwStyle & CBRS_RIGHT ) == CBRS_RIGHT ) {
		m_dragRect.SetRect( 0, 0, SPLITTER_SIZE, cy);
	} else if ( (dwStyle & CBRS_TOP ) == CBRS_TOP ) {
		m_dragRect.SetRect( 0, cy - SPLITTER_SIZE, cx, cy);
	} else {
		m_dragRect.SetRect( 0, 0, cx, SPLITTER_SIZE);
	}
	
	CRect rc;
	GetInsideRect( rc );
	OnResize ( rc );
}
예제 #2
0
void D3D11App::SwitchResolution()
{
	SettingsData lSettings = *Settings->GetData();
	mcWidth = lSettings.mWidth;
	mcHeight = lSettings.mHeight;
	BOOL lpIsFullscreen = (BOOL)lSettings.mIsFullscreen;
	mDirect3D->GetSwapChain()->GetFullscreenState(&mIsFullscreen, nullptr);

	// Resize window and set window position at center of screen
	if (!mIsFullscreen)
	{
		SetWindowPos(mhMainWnd, HWND_TOP,
			static_cast<int>((GetSystemMetrics(SM_CXSCREEN)*0.5) - (mcWidth*0.5)),
			static_cast<int>((GetSystemMetrics(SM_CYSCREEN)*0.5) - (mcHeight*0.5)),
			mcWidth, mcHeight, SWP_FRAMECHANGED);
	}

	OnResize();
}
예제 #3
0
파일: MGFXFilters.cpp 프로젝트: EQ4/neonv2
//---------------------------------------------------------------------------//
// Constructor
//
//---------------------------------------------------------------------------//  
CMGFXFilters::CMGFXFilters(CMGControl *pParent, CMGEffect *pEffect) : CMGControl(pParent, 0,0,0,0)
{
  m_Align      = MGALIGN_CLIENT;
  m_FilterVars = NULL;

  m_PanelSup = NEW CMGPanel(this, 0,0,0,118, MGALIGN_TOP);
  m_PanelInf = NEW CMGPanel(this, 0,0,0,0, MGALIGN_CLIENT);

  m_LBFilters = NEW CMGListBox(m_PanelSup, 1,0,294,81, MGALIGN_NONE, true);
  m_LBFilters->m_OnSelectItem = boost::bind(&CMGFXFilters::OnSelectFilter,this,_1);
  for (size_t i = 0; i < g_pAppMain->FilterList().size(); i++)
      m_LBFilters->Add(g_pAppMain->FilterList()[i]);

  // Filter slots
  for (int i = 0; i < MAX_FILTERS; i++)
    m_FXFilter[i] = NEW CMGFXFilter(m_PanelSup, this, pEffect, 1+59*i, 82, i);

  OnResize();
}
예제 #4
0
파일: D2DWnd.cpp 프로젝트: yearling/YYUI
 LRESULT D3DWnd::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
     switch (uMsg)
     {
     case WM_PAINT:
         {
             OnRender();
         }
         break;
     case WM_SIZE:
         {
             OnResize(LOWORD(lParam),HIWORD(lParam));
         }
         break;
     default:
         break;
     }
     return WindowWnd::OnSysMessage(uMsg,wParam,lParam);
 }
예제 #5
0
파일: Window.hpp 프로젝트: Adrien81/XCSoar
  void Resize(UPixelScalar width, UPixelScalar height) {
    AssertNoneLocked();
    AssertThread();

#ifndef USE_GDI
    if (width == GetWidth() && height == GetHeight())
      return;

    size = { width, height };

    Invalidate();
    OnResize(size);
#else /* USE_GDI */
    ::SetWindowPos(hWnd, nullptr, 0, 0, width, height,
                   SWP_NOMOVE | SWP_NOZORDER |
                   SWP_NOACTIVATE | SWP_NOOWNERZORDER);
    // XXX store new size?
#endif
  }
예제 #6
0
파일: View3D.cpp 프로젝트: olegp/v3d
int View3D::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch(uMsg) {
    case WM_MOUSEMOVE:
      OnMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
      return 0;

    case WM_LBUTTONUP:
      OnLButtonUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
      return 0;

    case WM_LBUTTONDOWN:
      OnLButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
      return 0;

    case WM_RBUTTONUP:
      OnRButtonUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
      return 0;

    case WM_RBUTTONDOWN:
      OnRButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
      return 0;

//    case WM_MOUSEWHEEL:
//      OnMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam));
//      return 0;

    case WM_SIZE:
      OnResize(LOWORD(lParam), HIWORD(lParam));
      return 0;

//    case WM_PAINT:
//      RenderScene();
//      return 0;

    case WM_DESTROY:
      Destroy();
      return 0;
  }

  return (int)DefWindowProc(hWnd, uMsg, wParam, lParam);
}
예제 #7
0
void HexEditorCtrl::OnMouseRight( wxMouseEvent& event ){
	if(event.GetEventObject() == hex_ctrl)
		LastRightClickAt = hex_ctrl->PixelCoordToInternalPosition( event.GetPosition() )/2;
	else if(event.GetEventObject() == text_ctrl)
		LastRightClickAt = text_ctrl->PixelCoordToInternalPosition( event.GetPosition() );
	else if( event.GetEventObject() == offset_ctrl)
		{
		//m_static_offset->SetLabel( offset_ctrl->hex_offset==true ? _("Offset: DEC") : _("Offset: HEX"));
		//event.Skip(true);
		offset_ctrl->OnMouseRight( event );
		int x,y;
		DoGetSize(&x,&y);
		wxSizeEvent mevent(wxSize(x,y));
		OnResize(mevent);
		return;//to avoid ShowContextMenu
		}
	else
		std::cout << "Right click captured without ctrl!\n";
	ShowContextMenu( event );
	}
예제 #8
0
  void Resize(UPixelScalar width, UPixelScalar height) {
    AssertNoneLocked();
    AssertThread();

#ifndef USE_GDI
    if (width == this->width && height == this->height)
      return;

    this->width = width;
    this->height = height;

    Invalidate();
    OnResize(width, height);
#else /* USE_GDI */
    ::SetWindowPos(hWnd, NULL, 0, 0, width, height,
                   SWP_NOMOVE | SWP_NOZORDER |
                   SWP_NOACTIVATE | SWP_NOOWNERZORDER);
    // XXX store new size?
#endif
  }
void LoadingObjDemo::Initialize()
{
	glEnable(GL_DEPTH_TEST);
	glClearColor(0.4f, 0.7f, 0.2f, 1.0f);
	PrintUniformInfo();

	program.Initialize();
	program.AddShaderFile(ShaderType::Vertex, "Assets/Shaders/Vertex/uniforms.vert");
	program.AddShaderFile(ShaderType::Fragment, "Assets/Shaders/Fragment/uniforms.frag");
	program.Build();

	input->addBinding(GLFW_KEY_LEFT, [this](InputInfo info){
		camera->MoveLeft();
		program.UpdateUniformBlock("TransformBlock");
	});

	input->addBinding(GLFW_KEY_RIGHT, [this](InputInfo info) {
		camera->MoveRight();
		program.UpdateUniformBlock("TransformBlock");
	});


	input->addBinding(GLFW_KEY_UP, [this](InputInfo info) {
		camera->MoveForward();
		program.UpdateUniformBlock("TransformBlock");
	});

	input->addBinding(GLFW_KEY_DOWN, [this](InputInfo info) {
		camera->MoveBack();
		program.UpdateUniformBlock("TransformBlock");
	});
	
	UniformBufferBlock uniformBufferBlock("TransformBlock", {
		{ "TransformBlock.projection",&camera->GetProjection()[0][0],sizeof(mat4) },
		{ "TransformBlock.view",&camera->GetView()[0][0],sizeof(mat4) },
	});

	program.AddUniformBlock(uniformBufferBlock);
	InitializeObj("Assets/Models/Obj/monkey.obj");
	OnResize(width, height);
}
예제 #10
0
void LobbyState::SetServerData(ServerData data)
{
	mServerData = data;

	if(mDatabase->GetPublicIp() == data.publicIp)
		mClient->ConnectToServer(data.localIp);
	else
		mClient->ConnectToServer(data.publicIp);

	mClient->SetServerData(mServerData);
	
	float chatWidth = 600;
	float chatHeight = 250;
	mClient->GetChat()->SetDimensions(GLib::GetClientWidth()/2-chatWidth/2, GLib::GetClientHeight() - chatHeight - 100, chatWidth, chatHeight);

	mIsHost = mClient->GetName() == mServerData.host ? true : false;

	// [NOTE][HACK]
	BuildUi();
	OnResize(GLib::GetClientWidth(), GLib::GetClientHeight());
}
예제 #11
0
	void OutputWindow::OnLoad()
	{
		_hScintilla = (HWND)::SendMessageW(_hNpp, NPPM_CREATESCINTILLAHANDLE, 0, (LPARAM)_hWindow);
		if (!_hScintilla)
		{
			throw gcnew NppException("Failed to create scintilla window for output.");
		}

		::SendMessageA(_hScintilla, SCI_USEPOPUP, 0, 0);
		::SendMessageA(_hScintilla, SCI_SETREADONLY, 1, 0);
		::SendMessageA(_hScintilla, SCI_SETCODEPAGE, SC_CP_UTF8, 0);

		RECT clientRect;
		::GetClientRect(_hWindow, &clientRect);
		OnResize(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);

		::ShowWindow(_hScintilla, SW_SHOW);

		InitStyles();
		ProcessQueue();
	}
예제 #12
0
bool Window::FilterEvent(const Event& event)
{
    // Notify the input object
    myInput.OnEvent(event);

    // Notify resize events to the derived class
    if (event.Type == Event::Resized)
        OnResize();

    // Don't forward to the user MouseMove events generated by SetCursorPosition
    if ((event.Type        == Event::MouseMoved) &&
        (event.MouseMove.X == mySetCursorPosX)   &&
        (event.MouseMove.Y == mySetCursorPosY))
    {
        mySetCursorPosX = 0xFFFF;
        mySetCursorPosY = 0xFFFF;
        return false;
    }

    return true;
}
//---------------------------------------------------------------------------
__fastcall TFormTriplet::TFormTriplet(TComponent* Owner,
    TFormSimStagecraftMain * const formParent)
  : TFormMachine(Owner,formParent),
    mTriplet(boost::shared_ptr<Triplet>(new Triplet))
{

  //Control
  //Connect
  mSocket220_1 = boost::shared_ptr<Socket220Control>(
    new Socket220Control(this,mTriplet->mSocket220_1,ImageSocket220_1));
  mSocket220_2 = boost::shared_ptr<Socket220Control>(
    new Socket220Control(this,mTriplet->mSocket220_2,ImageSocket220_2));
  mSocket220_3 = boost::shared_ptr<Socket220Control>(
    new Socket220Control(this,mTriplet->mSocket220_3,ImageSocket220_3));
  mPlug220 = boost::shared_ptr<Plug220Control>(
    new Plug220Control(this,mTriplet->mPlug,ImagePlug220));

  CreateWatermark(ImageView,ImageWatermark);

  OnResize(0);
}
예제 #14
0
void Window::Update(void)
{
	XEvent event;

	// Obtenemos y procesamos los eventos de ventana
	long mascaraWindow = EnterWindowMask | LeaveWindowMask | FocusChangeMask | ResizeRedirectMask ; 
	while (XCheckMaskEvent(Small::Window::Instance().dpy,  mascaraWindow, &event))
	{
		switch(event.type)
		{
			case FocusIn:
				OnFocusIn();
				break;
			case FocusOut:
				OnFocusOut();
				break;
			case ConfigureNotify:
				OnResize(event.xconfigure.width, event.xconfigure.height);
				break;
		};
	};
};
예제 #15
0
  void cMainWindow::LoadWindowPosition()
  {
    int iShowCmd = 0;
    int iX = 0;
    int iY = 0;
    int iWidth = 0;
    int iHeight = 0;
    iShowCmd = SW_SHOWNORMAL;
    iWidth = 1080;
    iHeight = 720;
    /*if (settings.GetWindowStateAndPosition(TEXT("Window"), TEXT("Show"), iShowCmd, iX, iY, iWidth, iHeight))*/ {
      // Get a handle to the monitor
      const POINT position = { iX, iY };
      HMONITOR hMonitor = ::MonitorFromPoint(position, MONITOR_DEFAULTTONEAREST);

      // Get the monitor info
      MONITORINFO monInfo;
      monInfo.cbSize = sizeof(MONITORINFO);
      if (::GetMonitorInfo(hMonitor, &monInfo) == 0) {
        LOG<<TEXT("cMainWindow::LoadWindowPosition GetMonitorInfo FAILED, returning")<<std::endl;
        return;
      }

      // Adjust for work area
      iX += monInfo.rcWork.left - monInfo.rcMonitor.left;
      iY += monInfo.rcWork.top  - monInfo.rcMonitor.top;
      // Ensure top left point is on screen
      const POINT point = { iX, iY };
      if (::PtInRect(&monInfo.rcWork, point) == FALSE ) {
        iX = monInfo.rcWork.left;
        iY = monInfo.rcWork.top;
      }

      ::SetWindowPos(hwndWindow, NULL, iX, iY, iWidth, iHeight, iShowCmd);
    }

    OnResize(iWidth, iHeight);
  }
예제 #16
0
	LRESULT CALLBACK SystemWindow::LocalWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
		
		switch(msg)
		{
		case WM_SIZE:
			OnResize(static_cast<u32>(LOWORD(lparam)), static_cast<u32>(HIWORD(lparam)), static_cast<window::WINDOW_RESIZE_STATE>(wparam));
			break;
		case WM_MOVE:
			OnMove(static_cast<u32>(LOWORD(lparam)), static_cast<u32>(HIWORD(lparam)));
			break;
		case WM_CLOSE:
			OnClose();
			break;
		case WM_DESTROY:
			OnDestroy();
			break;

		default:
			//We don't handle the message so let the Default Window Proc handle it
			return DefWindowProcW(hwnd, msg, wparam, lparam);
		}
		return 0;
	}
예제 #17
0
void EmuWindow_SDL2::PollEvents() {
    SDL_Event event;

    // SDL_PollEvent returns 0 when there are no more events in the event queue
    while (SDL_PollEvent(&event)) {
        switch (event.type) {
        case SDL_WINDOWEVENT:
            switch (event.window.event) {
            case SDL_WINDOWEVENT_SIZE_CHANGED:
            case SDL_WINDOWEVENT_RESIZED:
            case SDL_WINDOWEVENT_MAXIMIZED:
            case SDL_WINDOWEVENT_RESTORED:
            case SDL_WINDOWEVENT_MINIMIZED:
                OnResize();
                break;
            case SDL_WINDOWEVENT_CLOSE:
                is_open = false;
                break;
            }
            break;
        case SDL_KEYDOWN:
        case SDL_KEYUP:
            OnKeyEvent(static_cast<int>(event.key.keysym.scancode), event.key.state);
            break;
        case SDL_MOUSEMOTION:
            OnMouseMotion(event.motion.x, event.motion.y);
            break;
        case SDL_MOUSEBUTTONDOWN:
        case SDL_MOUSEBUTTONUP:
            OnMouseButton(event.button.button, event.button.state, event.button.x, event.button.y);
            break;
        case SDL_QUIT:
            is_open = false;
            break;
        }
    }
}
예제 #18
0
void CEvent::OnEvent(SDL_Event* Event) {
	switch(Event->type) {

		case SDL_ACTIVEEVENT: {
			switch(Event->active.state) {
				case SDL_APPMOUSEFOCUS: {
					if ( Event->active.gain )	OnMouseFocus();
					else				OnMouseBlur();

					break;
				}
				case SDL_APPINPUTFOCUS: {
					if ( Event->active.gain )	OnInputFocus();
					else				OnInputBlur();

					break;
				}
				case SDL_APPACTIVE:	{
					if ( Event->active.gain )	OnRestore();
					else				OnMinimize();

					break;
				}
			}
			break;
		}

		case SDL_KEYDOWN: {
			OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode);
			break;
		}

		case SDL_KEYUP: {
			OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode);
			break;
		}

		case SDL_MOUSEMOTION: {
			OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
			break;
		}

		case SDL_MOUSEBUTTONDOWN: {
			switch(Event->button.button) {
				case SDL_BUTTON_LEFT: {
					OnLButtonDown(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_RIGHT: {
					OnRButtonDown(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_MIDDLE: {
					OnMButtonDown(Event->button.x,Event->button.y);
					break;
				}
			}
			break;
		}

		case SDL_MOUSEBUTTONUP:	{
			switch(Event->button.button) {
				case SDL_BUTTON_LEFT: {
					OnLButtonUp(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_RIGHT: {
					OnRButtonUp(Event->button.x,Event->button.y);
					break;
				}
				case SDL_BUTTON_MIDDLE: {
					OnMButtonUp(Event->button.x,Event->button.y);
					break;
				}
			}
			break;
		}

		case SDL_JOYAXISMOTION: {
			OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value);
			break;
		}

		case SDL_JOYBALLMOTION: {
			OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel);
			break;
		}

		case SDL_JOYHATMOTION: {
			OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value);
			break;
		}
		case SDL_JOYBUTTONDOWN: {
			OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button);
			break;
		}

		case SDL_JOYBUTTONUP: {
			OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button);
			break;
		}

		case SDL_QUIT: {
			OnExit();
			break;
		}

		case SDL_SYSWMEVENT: {
			//Ignore
			break;
		}

		case SDL_VIDEORESIZE: {
			OnResize(Event->resize.w,Event->resize.h);
			break;
		}

		case SDL_VIDEOEXPOSE: {
			OnExpose();
			break;
		}

		default: {
			OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2);
			break;
		}
	}
}
예제 #19
0
GUICutRenderWindow::GUICutRenderWindow(wxWindow * parent, const wxChar *title,
		int xpos, int ypos, int width, int height) :
		wxFrame(parent, -1, title, wxPoint(xpos, ypos), wxSize(width, height),
		wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT) {

	//erstellen der Komponenten und setzen der Standardwerte
	canvas = new GUIRenderCutCanvas(this);
	scroll_pane = new wxScrolledWindow(this, wxID_ANY);
	scroll_pane->SetScrollRate(10, 10);
	trilabel = new wxStaticText(scroll_pane, wxID_ANY,
			wxT("Dreiecksebene (Punkt1 ist Mittelpunkt):"));
	p1label = new wxStaticText(scroll_pane, wxID_ANY, wxT("Punkt 1:"));
	p1xedit = new wxTextCtrl(scroll_pane, ID_CUT_TRI_EDIT);
	p1yedit = new wxTextCtrl(scroll_pane, ID_CUT_TRI_EDIT);
	p1zedit = new wxTextCtrl(scroll_pane, ID_CUT_TRI_EDIT);

	p2label = new wxStaticText(scroll_pane, wxID_ANY, wxT("Punkt 2:"));
	p2xedit = new wxTextCtrl(scroll_pane, ID_CUT_TRI_EDIT);
	p2yedit = new wxTextCtrl(scroll_pane, ID_CUT_TRI_EDIT);
	p2zedit = new wxTextCtrl(scroll_pane, ID_CUT_TRI_EDIT);

	p3label = new wxStaticText(scroll_pane, wxID_ANY, wxT("Punkt 3:"));
	p3xedit = new wxTextCtrl(scroll_pane, ID_CUT_TRI_EDIT);
	p3yedit = new wxTextCtrl(scroll_pane, ID_CUT_TRI_EDIT);
	p3zedit = new wxTextCtrl(scroll_pane, ID_CUT_TRI_EDIT);

	optionslbl = new wxStaticText(scroll_pane, wxID_ANY, wxT("Optionen:"));
	widthHeightlbl = new wxStaticText(scroll_pane, wxID_ANY,
			wxT("Breite/Höhe:"));
	imgWidthEdit = new wxSpinCtrl(scroll_pane, ID_CUT_TRI_EDIT);
	imgHeightEdit = new wxSpinCtrl(scroll_pane, ID_CUT_TRI_EDIT);
	mmperpixellabel = new wxStaticText(scroll_pane, wxID_ANY,
			wxT("Maßstab (mm/px):"));
	mmperpixeledit = new wxTextCtrl(scroll_pane, ID_CUT_TRI_EDIT);
	threadcountlbl = new wxStaticText(scroll_pane, wxID_ANY,
			wxT("CPU-Threads:"));
	core_count = thread::hardware_concurrency();
	threadcountedit = new wxSpinCtrl(scroll_pane, wxID_ANY);

	calcbt = new wxButton(scroll_pane, ID_RENDER_CUT_BT, wxT("Analysieren"));
	export_img_bt = new wxButton(scroll_pane, ID_EXPORT_CUT_IMG_BT,
			wxT("Export (.png)..."));
	export_csv_bt = new wxButton(scroll_pane, ID_EXPORT_CUT_CSV_BT,
			wxT("Export (.csv)..."));

	scalelbl = new wxStaticText(scroll_pane, wxID_ANY, wxT("Temperaturskala:"));
	scalemodelbl = new wxStaticText(scroll_pane, wxID_ANY, wxT("Modus/ΔT:"));
	scalemodecb = new wxComboBox(scroll_pane, ID_COLORSCALE_PROP, wxT(""),
			wxDefaultPosition, wxDefaultSize, 0, NULL,
			wxCB_READONLY | wxCB_DROPDOWN);
	scalemodecb->Insert(wxT("Vertikal"), 0);
	scalemodecb->Insert(wxT("Horizontal"), 0);
	scalemodecb->Insert(wxT("Kein"), 0);

	scalefontpropslbl = new wxStaticText(scroll_pane, wxID_ANY,
			wxT("Schriftgröße/Farbe:"));
	scalefontsizeedit = new wxSpinCtrl(scroll_pane, ID_COLORSCALE_PROP);
	scalefontcolorbt = new wxButton(scroll_pane, ID_COLORSCALE_COLORBT,
			wxT("Text"));
	scalestepedit = new wxSpinCtrl(scroll_pane, ID_COLORSCALE_PROP);

	//Initialisieren der Temperaturverteilung
	value_img = new float[1];
	//Initialisieren Grafik zur Temperaturverteilung
	image = new wxImage(100, 100, true);

	canvas->setImage(image);
	canvas->setValueImg(value_img);

	//getrennte Initialisierung für wxMSW erforderlich
	p1xedit->SetValue(wxT("0.0"));
	p1yedit->SetValue(wxT("0.0"));
	p1zedit->SetValue(wxT("0.0"));

	p2xedit->SetValue(wxT("1.0"));
	p2yedit->SetValue(wxT("0.0"));
	p2zedit->SetValue(wxT("0.0"));

	p3xedit->SetValue(wxT("0.0"));
	p3yedit->SetValue(wxT("1.0"));
	p3zedit->SetValue(wxT("0.0"));

	imgWidthEdit->SetRange(1, 100000000);
	imgWidthEdit->SetValue(800);

	imgHeightEdit->SetRange(1, 100000000);
	imgHeightEdit->SetValue(600);

	threadcountedit->SetRange(1, 1000);
	threadcountedit->SetValue(core_count);

	mmperpixeledit->SetValue(wxT("15.0"));

	scalemodecb->Select(GUIColorScalePanel::SCM_HORIZONTAL);

	scalestepedit->SetRange(1, 1000);
	scalestepedit->SetValue(12);

	scalefontsizeedit->SetRange(1, 1000);
	scalefontsizeedit->SetValue(12);

	scalefontcolorbt->SetForegroundColour(
			canvas->getScalePanel()->getTextColor());

	//update der Oberfläche auslösen
	p1xedit->SetValue(p1xedit->GetValue());

	//Neupositionierung der Oberflächenkomponenten für wxMSW
	wxSizeEvent evt;
	OnResize(evt);
}
예제 #20
0
void GCamera::FarthestPlane(float farthest)
{
	mFarthest = farthest;
	OnResize(mClientWidth, mClientHeight);
}
예제 #21
0
void GCamera::NearestPlane(float nearest)
{
	mNearest = nearest;
	OnResize(mClientWidth, mClientHeight);
}
예제 #22
0
bool D3DApp::InitDirect3D()
{
	// Create the device and device context.

	UINT createDeviceFlags = 0;
#if defined(DEBUG) || defined(_DEBUG)  
    createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

	D3D_FEATURE_LEVEL featureLevel;
	HRESULT hr = D3D11CreateDevice(
			0,                 // default adapter
			md3dDriverType,
			0,                 // no software device
			createDeviceFlags, 
			0, 0,              // default feature level array
			D3D11_SDK_VERSION,
			&md3dDevice,
			&featureLevel,
			&md3dImmediateContext);

	if( FAILED(hr) )
	{
		MessageBox(0, L"D3D11CreateDevice Failed.", 0, 0);
		return false;
	}

	if( featureLevel != D3D_FEATURE_LEVEL_11_0 )
	{
		MessageBox(0, L"Direct3D Feature Level 11 unsupported.", 0, 0);
		return false;
	}

	// Check 4X MSAA quality support for our back buffer format.
	// All Direct3D 11 capable devices support 4X MSAA for all render 
	// target formats, so we only need to check quality support.

	HR(md3dDevice->CheckMultisampleQualityLevels(
		DXGI_FORMAT_R8G8B8A8_UNORM, 4, &m4xMsaaQuality));
	assert( m4xMsaaQuality > 0 );

	// Fill out a DXGI_SWAP_CHAIN_DESC to describe our swap chain.

	DXGI_SWAP_CHAIN_DESC sd;
	ZeroMemory(&sd, sizeof(DXGI_SWAP_CHAIN_DESC));
	sd.BufferDesc.Width = mClientWidth;
	sd.BufferDesc.Height = mClientHeight;
	sd.Windowed = true;


	sd.BufferDesc.RefreshRate.Numerator		= m_MonitorNumerator;
	sd.BufferDesc.RefreshRate.Denominator	= m_MonitorDenumerator;
	sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
	sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
	sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

	// Use 4X MSAA? 
	if( mEnable4xMsaa )
	{
		sd.SampleDesc.Count   = 4;
		sd.SampleDesc.Quality = m4xMsaaQuality-1;
	}
	// No MSAA
	else
	{
		sd.SampleDesc.Count   = 1;
		sd.SampleDesc.Quality = 0;
	}

	sd.BufferUsage  = DXGI_USAGE_RENDER_TARGET_OUTPUT;
	sd.BufferCount  = 1;
	sd.OutputWindow = mhMainWnd;
	sd.SwapEffect   = DXGI_SWAP_EFFECT_DISCARD;
	sd.Flags		= 0;

	// To correctly create the swap chain, we must use the IDXGIFactory that was
	// used to create the device.  If we tried to use a different IDXGIFactory instance
	// (by calling CreateDXGIFactory), we get an error: "IDXGIFactory::CreateSwapChain: 
	// This function is being called with a device from a different IDXGIFactory."

	IDXGIDevice* dxgiDevice = 0;
	HR(md3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice));
	      
	IDXGIAdapter* dxgiAdapter = 0;
	HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter));

	IDXGIFactory* dxgiFactory = 0;

	HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory));

	HR(dxgiFactory->CreateSwapChain(md3dDevice, &sd, &mSwapChain));
	

	//Disable Alt-Enter Sequence
	dxgiFactory->MakeWindowAssociation(mhMainWnd, DXGI_MWA_NO_ALT_ENTER);


	ReleaseCOM(dxgiDevice);
	ReleaseCOM(dxgiAdapter);
	ReleaseCOM(dxgiFactory);

	// The remaining steps that need to be carried out for d3d creation
	// also need to be executed every time the window is resized.  So
	// just call the OnResize method here to avoid code duplication.
	
	OnResize();

	if (mFullScreen){ mSwapChain->SetFullscreenState(true, NULL); }

	

	return true;
}
예제 #23
0
LRESULT D3DApp::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	if (msg == WM_SETCURSOR && LOWORD(lParam) == HTCLIENT && !mCursorOn)
	{
		SetCursor(NULL);

		return TRUE;
	}
	switch( msg )
	{
	// WM_ACTIVATE is sent when the window is activated or deactivated.  
	// We pause the game when the window is deactivated and unpause it 
	// when it becomes active.  

	case WM_ACTIVATE:
		if( LOWORD(wParam) == WA_INACTIVE )
		{
			mAppPaused = true;
			mTimer.Stop();
		}
		else
		{
			mAppPaused = false;
			mTimer.Start();
		}
		return 0;

	// WM_SIZE is sent when the user resizes the window.  
	case WM_SIZE:
		// Save the new client area dimensions.
		mClientWidth  = LOWORD(lParam);
		mClientHeight = HIWORD(lParam);
		if( md3dDevice )
		{
			if( wParam == SIZE_MINIMIZED )
			{
				if (mFullScreen)mSwapChain->SetFullscreenState(false, NULL);
				mAppPaused = true;
				mMinimized = true;
				mMaximized = false;
			}
			else if( wParam == SIZE_MAXIMIZED )
			{
				if (mFullScreen)mSwapChain->SetFullscreenState(true, NULL);
				mAppPaused = false;
				mMinimized = false;
				mMaximized = true;
				OnResize();
			}
			else if( wParam == SIZE_RESTORED )
			{
				
				// Restoring from minimized state?
				if( mMinimized )
				{
					if(mFullScreen)mSwapChain->SetFullscreenState(true, NULL);
					mAppPaused = false;
					mMinimized = false;
					OnResize();
				}

				// Restoring from maximized state?
				else if( mMaximized )
				{
					mAppPaused = false;
					mMaximized = false;
					OnResize();
				}
				else if( mResizing )
				{
					// If user is dragging the resize bars, we do not resize 
					// the buffers here because as the user continuously 
					// drags the resize bars, a stream of WM_SIZE messages are
					// sent to the window, and it would be pointless (and slow)
					// to resize for each WM_SIZE message received from dragging
					// the resize bars.  So instead, we reset after the user is 
					// done resizing the window and releases the resize bars, which 
					// sends a WM_EXITSIZEMOVE message.
				}
				else // API call such as SetWindowPos or mSwapChain->SetFullscreenState.
				{
					OnResize();
				}
			}
		}
		return 0;

	// WM_EXITSIZEMOVE is sent when the user grabs the resize bars.
	case WM_ENTERSIZEMOVE:
		mAppPaused = true;
		mResizing  = true;
		mTimer.Stop();
		return 0;

	// WM_EXITSIZEMOVE is sent when the user releases the resize bars.
	// Here we reset everything based on the new window dimensions.
	case WM_EXITSIZEMOVE:
		mAppPaused = false;
		mResizing  = false;
		mTimer.Start();
		OnResize();
		return 0;
 
	// WM_DESTROY is sent when the window is being destroyed.
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

	// The WM_MENUCHAR message is sent when a menu is active and the user presses 
	// a key that does not correspond to any mnemonic or accelerator key. 
	case WM_MENUCHAR:
        // Don't beep when we alt-enter.
        return MAKELRESULT(0, MNC_CLOSE);

	// Catch this message so to prevent the window from becoming too small.
	case WM_GETMINMAXINFO:
		((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200;
		((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200; 
		return 0;

	case WM_LBUTTONDOWN:
	case WM_MBUTTONDOWN:
	case WM_RBUTTONDOWN:
		OnMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		return 0;
	case WM_LBUTTONUP:
	case WM_MBUTTONUP:
	case WM_RBUTTONUP:
		OnMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		return 0;
	case WM_MOUSEMOVE:
		OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		return 0;
	case WM_KEYUP:
		OnKeyUP(wParam);
		if (wParam == VK_ESCAPE)
		{
			PostQuitMessage(0);
			return 0;
		}
		break;
	}

	return DefWindowProc(hwnd, msg, wParam, lParam);
}
예제 #24
0
/** 
	Process messages for the Window
**/
LRESULT Window::MessageHandler(UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_MOUSEMOVE:
		break;
	case WM_LBUTTONDOWN:
		break;
	case WM_RBUTTONDOWN:
		break;
	case WM_LBUTTONUP:
		break;
	case WM_RBUTTONUP:
		break;
	case WM_KEYDOWN:
		if(wParam == VK_ESCAPE) PostQuitMessage(0);
		break;
	case WM_KEYUP:
		break;
	case WM_SIZE: //User resizes window
		_clientWidth = LOWORD(lParam);
		_clientHeight = HIWORD(lParam);
		switch(wParam)
		{
		case SIZE_MINIMIZED:
			_minimized = true;
			_maximized = false;
			break;
		case SIZE_MAXIMIZED:
			_minimized = false;
			_maximized = true;
			break;
		case SIZE_RESTORED:
			if(_minimized) { //check previous state
				_minimized = false;
			}	
			else if(_maximized) {
				_maximized = false;
			}
			else if(_resizing) { /*do nothing while user is still resizing*/ }
			else {}
			break;
		}
		return 0;
	case WM_ENTERSIZEMOVE: //Users grabs resize bars
		_resizing = true;
		return 0;
	case WM_EXITSIZEMOVE: //User releases resize bars
		_resizing = false;
		OnResize();
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	case WM_GETMINMAXINFO: //Prevent window from becoming too small
		((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200;
		((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200;
		return 0;
	case WM_SYSCOMMAND:
		switch(wParam)
		{
		case SC_CLOSE:  //Application being closed
			break;
		case SC_SCREENSAVE: //ScreenSaver
			break;
		case SC_MONITORPOWER: //Power saving mode
			break;
		}
		break;
	}

	return DefWindowProc(_hWnd, msg, wParam, lParam);
}
예제 #25
0
// Called before render is available
bool ModuleRenderer3D::Init()
{
	LOG("Creating 3D Renderer context");
	bool ret = true;
	
	//Create context
	context = SDL_GL_CreateContext(App->window->window);
	if(context == NULL)
	{
		LOG("OpenGL context could not be created! SDL_Error: %s\n", SDL_GetError());
		ret = false;
	}
	
	if(ret == true)
	{
		//Use Vsync
		if(VSYNC && SDL_GL_SetSwapInterval(1) < 0)
			LOG("Warning: Unable to set VSync! SDL Error: %s\n", SDL_GetError());

		//Initialize Projection Matrix
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();

		//Check for error
		GLenum error = glGetError();
		if(error != GL_NO_ERROR)
		{
			LOG("Error initializing OpenGL! %s\n", gluErrorString(error));
			ret = false;
		}

		//Initialize Modelview Matrix
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();

		//Check for error
		error = glGetError();
		if(error != GL_NO_ERROR)
		{
			LOG("Error initializing OpenGL! %s\n", gluErrorString(error));
			ret = false;
		}
		
		glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
		glClearDepth(1.0f);
		
		//Initialize clear color
		glClearColor(0.f, 0.f, 0.f, 1.f);

		//Check for error
		error = glGetError();
		if(error != GL_NO_ERROR)
		{
			LOG("Error initializing OpenGL! %s\n", gluErrorString(error));
			ret = false;
		}
		
		GLfloat LightModelAmbient[] = {0.0f, 0.0f, 0.0f, 1.0f};
		glLightModelfv(GL_LIGHT_MODEL_AMBIENT, LightModelAmbient);
		
		lights[0].ref = GL_LIGHT0;
		lights[0].ambient.Set(0.25f, 0.25f, 0.25f, 1.0f);
		lights[0].diffuse.Set(0.75f, 0.75f, 0.75f, 1.0f);
		lights[0].SetPos(0.0f, 0.0f, 2.5f);
		lights[0].Init();
		
		GLfloat MaterialAmbient[] = {1.0f, 1.0f, 1.0f, 1.0f};
		glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, MaterialAmbient);

		GLfloat MaterialDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
		glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialDiffuse);
		
		glEnable(GL_DEPTH_TEST);
		glEnable(GL_CULL_FACE);
		lights[0].Active(true);
		glEnable(GL_LIGHTING);
		glEnable(GL_COLOR_MATERIAL);
	}

	// Projection matrix for
	OnResize(SCREEN_WIDTH, SCREEN_HEIGHT);

	return ret;
}
예제 #26
0
LRESULT D3DApp::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	// WM_ACTIVATE is sent when the window is activated or deactivated.  
	// We pause the game when the window is deactivated and unpause it 
	// when it becomes active.  
	case WM_ACTIVATE:
	{
		if (LOWORD(wParam) == WA_INACTIVE)
		{
			mAppPaused = true;
			mTimer.Stop();
		}
		else
		{
			mAppPaused = false;
			mTimer.Start();
		}
		return 0;
	}

	// WM_SIZE is sent when the user resizes the window.  
	case WM_SIZE:
	{
		// Save the new client area dimensions.
		mClientWidth = LOWORD(lParam);
		mClientHeight = HIWORD(lParam);
		if (mDevice)
		{
			if (wParam == SIZE_MINIMIZED)
			{
				mAppPaused = true;
				mMinimized = true;
				mMaximized = false;
			}
			else if (wParam == SIZE_MAXIMIZED)
			{
				mAppPaused = false;
				mMinimized = false;
				mMaximized = true;
				OnResize();
			}
			else if (wParam == SIZE_RESTORED)
			{
				// Restoring from minimized state?
				if (mMinimized)
				{
					mAppPaused = false;
					mMinimized = false;
					OnResize();
				}

				// Restoring from maximized state?
				else if (mMaximized)
				{
					mAppPaused = false;
					mMaximized = false;
					OnResize();
				}
				else // API call such as SetWindowPos or mSwapChain->SetFullscreenState.
				{
					OnResize();
				}
			}
		}
		return 0;
	}

	// WM_EXITSIZEMOVE is sent when the user grabs the resize bars.
	case WM_ENTERSIZEMOVE:
	{
		mAppPaused = true;
		mTimer.Stop();
		return 0;
	}

	// WM_EXITSIZEMOVE is sent when the user releases the resize bars.
	// Here we reset everything based on the new window dimensions.
	case WM_EXITSIZEMOVE:
	{
		mAppPaused = false;
		mTimer.Start();
		OnResize();
		return 0;
	}

	// WM_DESTROY is sent when the window is being destroyed.
	case WM_DESTROY:
	{
		PostQuitMessage(0);
		return 0;
	}

	// The WM_MENUCHAR message is sent when a menu is active and the user presses 
	// a key that does not correspond to any mnemonic or accelerator key. 
	case WM_MENUCHAR:
	{
		// Don't beep when we alt-enter.
		return MAKELRESULT(0, MNC_CLOSE);
	}

	// Catch this message so to prevent the window from becoming too small.
	case WM_GETMINMAXINFO:
	{
		((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200;
		((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200;
		return 0;
	}

	case WM_LBUTTONDOWN:
	case WM_MBUTTONDOWN:
	case WM_RBUTTONDOWN:
		OnMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		return 0;

	case WM_LBUTTONUP:
	case WM_MBUTTONUP:
	case WM_RBUTTONUP:
		OnMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		return 0;

	case WM_MOUSEMOVE:
		OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		return 0;

	case WM_CHAR:
		OnKeyDown(wParam, lParam);
		return 0;
	}


	return DefWindowProc(hwnd, msg, wParam, lParam);
}
예제 #27
0
// ´ÙÀÌ·ºÆ® °´Ã¼ ÃʱâÈ­
// - °¢Á¾±â´ÉÀ» Áö¿øÇϴ°¡ üũÇÏ°í(´ÙÁß »ùÇøµ µî), ½º¿ÒüÀÎ, ÄÄ °´Ã¼ µîÀ» »ý¼º, Á¦°ÅÇÑ´Ù.
bool cInitD3D::InitDirect3D()
{
	// µð¹ÙÀ̽º, µð¹ÙÀ̽º ÄÁÅؽºÆ® »ý¼º
	UINT createDeviceFlags = 0;
#if defined(DEBUG) || defined(_DEBUG)  
	createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

	D3D_FEATURE_LEVEL featureLevel;
	HRESULT hr = D3D11CreateDevice(
		0,                 // default adapter
		md3dDriverType,
		0,                 // no software device
		createDeviceFlags,
		0, 0,              // default feature level array
		D3D11_SDK_VERSION,
		&md3dDevice,
		&featureLevel,
		&md3dImmediateContext);

	if (FAILED(hr))
	{
		MessageBox(0, L"D3D11CreateDevice Failed.", 0, 0);
		return false;
	}

	if (featureLevel != D3D_FEATURE_LEVEL_11_0)
	{
		MessageBox(0, L"Direct3D Feature Level 11 unsupported.", 0, 0);
		return false;
	}

	// ¹é¹öÆÛ¿¡ 4X MSAA Ç°Áú Áö¿øÀ» È®ÀÎ
	HR(md3dDevice->CheckMultisampleQualityLevels(
		DXGI_FORMAT_R8G8B8A8_UNORM, 4, &m4xMsaaQuality));
	assert(m4xMsaaQuality > 0);

	// ½º¿ÒüÀÎ »ý¼º
	DXGI_SWAP_CHAIN_DESC sd;
	sd.BufferDesc.Width = mClientWidth;
	sd.BufferDesc.Height = mClientHeight;
	sd.BufferDesc.RefreshRate.Numerator = 60;
	sd.BufferDesc.RefreshRate.Denominator = 1;
	sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
	sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
	sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

	// ´ÙÁß »ùÇøµ À¯¹« (Use 4X MSAA?) 
	if (mEnable4xMsaa)
	{
		sd.SampleDesc.Count = 4;
		sd.SampleDesc.Quality = m4xMsaaQuality - 1;
	}
	// No MSAA
	else
	{
		sd.SampleDesc.Count = 1;
		sd.SampleDesc.Quality = 0;
	}

	// ¹öÆÛ »ý¼º
	sd.BufferUsage  = DXGI_USAGE_RENDER_TARGET_OUTPUT;
	sd.BufferCount  = 1;
	sd.OutputWindow = mhMainWnd;
	sd.Windowed     = true;
	sd.SwapEffect   = DXGI_SWAP_EFFECT_DISCARD;
	sd.Flags		= 0;

	// µð¹ÙÀ̽º »ý¼º
	IDXGIDevice* dxgiDevice = 0;
	HR(md3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice));

	IDXGIAdapter* dxgiAdapter = 0;
	HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter));

	IDXGIFactory* dxgiFactory = 0;
	HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory));

	// ½º¿ÒüÀÎ »ý¼º ¹× È®ÀÎ
	HR(dxgiFactory->CreateSwapChain(md3dDevice, &sd, &mSwapChain));

	// ÄÄ °´Ã¼ »èÁ¦
	ReleaseCOM(dxgiDevice);
	ReleaseCOM(dxgiAdapter);
	ReleaseCOM(dxgiFactory);

	// â Å©±â Á¶Àý (ÄÚµå Áߺ¹ ÇÇÇϱâ À§ÇØ »ç¿ë)
	OnResize();

	return true;
}
예제 #28
0
// ¸Þ¼¼Áö ÇÁ·Î½ÃÁ®
LRESULT cInitD3D::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	// µð¹ÙÀ̽º ·Î½ºÆ® °Ë»ç
	if (md3dDevice)
		CheckDeviceLost();

	switch (msg)
	{
	// Å°º¸µå¿Í ¸¶¿ì½º°ü·ÃµÈ °ÍµéÀ» ½ºÅ×ÀÌÆ® ¸Å´ÏÀú·Î ³Ñ±â¸ç,
	// ÀÌ°÷Àº ÃÖ»óÀ§ ¸í·É¾î ÄÚµå·Î »ç¿ëÇÑ´Ù.

	//---------------------------------------------------------------------------------------
	// Å°º¸µå
	//---------------------------------------------------------------------------------------
	// À̰Ŷ§¹®¿¡ 3ȸ°¡ ´­¸².
	//case WM_CHAR:
	//case WM_KEYUP:
	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_ESCAPE:
			PostQuitMessage(0);
			return 0;

		case '0':
			cGameStateSave::GetInstance()->m_StateChaneNumber = e_MapTool;
			cGameStateSave::GetInstance()->m_StateChangeCheck = true;
			return 0;

		case '1':
			cGameStateSave::GetInstance()->m_StateChaneNumber = e_MainState;
			cGameStateSave::GetInstance()->m_StateChangeCheck = true;
			return 0;

		case '2':
			cGameStateSave::GetInstance()->m_StateChaneNumber = e_PlayState;
			cGameStateSave::GetInstance()->m_StateChangeCheck = true;
			return 0;

		default:
			cGameStateManager::GetInstance()->KeyEvent(wParam);
			return 0;
		}
		return 0;

		//---------------------------------------------------------------------------------------
		// ¸¶¿ì½º
		//---------------------------------------------------------------------------------------
		// ¸¶¿ì½º Ŭ¸¯
	case WM_LBUTTONDOWN:
	case WM_MBUTTONDOWN:
	case WM_RBUTTONDOWN:
	case WM_LBUTTONUP:
	case WM_MBUTTONUP:
	case WM_RBUTTONUP:
		cGameStateManager::GetInstance()->MouseEvent(msg, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		return 0;

		// ¸¶¿ì½º À̵¿
	case WM_MOUSEMOVE:
		//cout << GET_X_LPARAM(lParam) << ", " << GET_Y_LPARAM(lParam) << endl;

		cGameStateManager::GetInstance()->MouseMoveEvent(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		return 0;
	
		//---------------------------------------------------------------------------------------
		// À©µµ¿ì º¸Á¶
		//---------------------------------------------------------------------------------------
	case WM_ACTIVATE:
		// À©µµ¿ì È°¼º, ºñÈ°¼º
		// À©µµ¿ì È°¼º, ºñÈ°¼ºÈ­¿¡ µû¶ó, ŸÀÌ¸Ó ¶ÇÇÑ È°¼º, ºñÈ°¼ºÈ­¸¦ ÇÑ´Ù.
		if (LOWORD(wParam) == WA_INACTIVE)
		{
			mAppPaused = true;
			mTimer.Stop();
		}
		else
		{
			mAppPaused = false;
			mTimer.Start();
		}
		return 0;

	case WM_SIZE:
		// À©µµ¿ì »çÀÌÁî°¡ º¯°æ‰ç´Â°¡?
		// »õ·Î¿î Ŭ¶óÀ̾ðÆ® ¿µ¿ªÀÇ Å©±â¸¦ ÀúÀå
		mClientWidth  = LOWORD(lParam);
		mClientHeight = HIWORD(lParam);
		if (md3dDevice)
		{
			if (wParam == SIZE_MINIMIZED)
			{
				mAppPaused = true;
				mMinimized = true;
				mMaximized = false;
			}
			else if (wParam == SIZE_MAXIMIZED)
			{
				mAppPaused = false;
				mMinimized = false;
				mMaximized = true;
				OnResize();
			}
			else if (wParam == SIZE_RESTORED)
			{
				// ÃÖ¼ÒÈ­ »óÅ¿¡¼­ º¹¿ø‰ç´Â°¡?
				if (mMinimized)
				{
					mAppPaused = false;
					mMinimized = false;
					OnResize();
				}
				// ÃÖ´ëÈ­ »óÅ¿¡¼­ º¹¿ø‰ç´Â°¡?
				else if (mMaximized)
				{
					mAppPaused = false;
					mMaximized = false;
					OnResize();
				}
				// »ç¿ëÀÚ°¡ Å©±â Á¶Á¤ ¸·´ë¸¦ µå·¡±×Çϴ°¡?
				// µå·¡±× Áß¿¡´Â ¾Æ¹«ÀÛ¾÷µµ ÇÏÁö ¾Ê´Â´Ù.
				else if (mResizing)
				{

				}
				// ³¡³µÀ¸¸é ¾÷µ¥ÀÌÆ® ¿äû
				else 
				{
					OnResize();
				}
			}
		}
		return 0;

		//WM_EXITSIZEMOVE´Â »ç¿ëÀÚ°¡ Å©±â Á¶Á¤ ¸·´ë¸¦ Àâ°íÀÖÀ» ¶§ Àü¼ÛµÈ´Ù.
	case WM_ENTERSIZEMOVE:
		mAppPaused = true;
		mResizing  = true;
		mTimer.Stop();
		return 0;

		// WM_EXITSIZEMOVE´Â »ç¿ëÀÚ°¡ Å©±â Á¶Á¤ ¸·´ë¸¦ ³õÀ» ¶§ Àü¼ÛµÈ´Ù.
		// ¿©±â¿¡¼­ »õ·Î¿î â Å©±â¿¡ µû¶ó ¸ðµç °ÍÀ» ´Ù½Ã ¼³Á¤.
	case WM_EXITSIZEMOVE:
		mAppPaused = false;
		mResizing  = false;
		mTimer.Start();
		OnResize();
		return 0;

		// À©µµ¿ì°¡ Æı« µÉ ¶§, WM_DESTROY°¡ Àü¼ÛµË´Ï´Ù.
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

		// ¸Þ´º´Â »ç¿ëÀÚ°¡ È°¼ºÇßÀ» ¶§ WM_MENUCHARÀÇ ¸Þ½ÃÁö°¡ Àü¼ÛµÈ´Ù.
		// ¾î¶² ´Ï¸ð´Ð ¶Ç´Â ¾×¼¿·¯·¹ÀÌÅÍ Å°¿¡ ÇØ´çÇÏÁö ¾Ê´Â Å°¸¦ ´©¸¨´Ï´Ù.
	case WM_MENUCHAR:
		//¿ì¸®°¡ ALTÅ°¸¦ ÀÔ·Â ÇÒ ¶§, »ß ¼Ò¸®ÇÏÁö ¸¶½Ê½Ã¿À.
		return MAKELRESULT(0, MNC_CLOSE);

		// ³Ê¹« âÀÌ ÀÛ¾ÆÁö´Â °ÍÀ» ¹æÁöÇϱâ À§ÇØ.
	case WM_GETMINMAXINFO:
		((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200;
		((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200;
		return 0;

	}

	return DefWindowProc(hwnd, msg, wParam, lParam);
}
예제 #29
0
bool CApp::OnInit()
{
    //设置工程目录
    putenv("PROJECT_PATH=/home/fuyajun/myplayground/qt/morrowland/morrowland/lesson09");

    if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
        return false;
    }

    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,            8);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,          8);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,           8);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,          8);

    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,          16);
    SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE,            32);

    SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE,        8);
    SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE,    8);
    SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE,        8);
    SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE,    8);

    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,  1);

    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,  2);

    if ((Surf_Display = SDL_SetVideoMode(600, 480, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) == NULL) {
        return false;
    }

    if(glewInit()  !=  GLEW_OK)
    {
        CLogger::err("Failed to init glew!");
        return false;
    }

    SDL_WM_SetCaption("Stencil Reflection", NULL);

    CLogger::info("Initializing GL...");

    glShadeModel(GL_SMOOTH);
    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
    glClearDepth(1.0f);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);


    glEnable(GL_TEXTURE_2D);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    // Enable light
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse);
    glLightfv(GL_LIGHT0, GL_SPECULAR,lightSpecular);
    glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
    // set the light posision
    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);


    objCamera.Position_Camera(0,30,90,  0,0,0,  0,1,0);

    if (tex[0].loadTexture2D("texture/image1.bmp")) {
        tex[0].setFiltering(TEXTURE_FILTER_MAG_NEAREST, TEXTURE_FILTER_MIN_NEAREST);
        CLogger::info("load texture 1 successfully!");
    } else {
        CLogger::warn("failed to load texture 1");
    }

    if (tex[1].loadTexture2D("texture/image2.bmp")) {
        tex[1].setFiltering(TEXTURE_FILTER_MAG_NEAREST, TEXTURE_FILTER_MIN_NEAREST);
        CLogger::info("load texture 2 successfully!");
    } else {
        CLogger::warn("failed to load texture 2");
    }


    OnResize(640, 480);

    return true;
}
예제 #30
0
// Create the device, device context, swap chain and necessary buffers
bool DirectXGame::InitDirect3D()
{
	UINT createDeviceFlags = 0;

	// Do we want a debug device?
#if defined(DEBUG) || defined(_DEBUG)
	createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

	// Set up a swap chain description
	DXGI_SWAP_CHAIN_DESC swapChainDesc;
	swapChainDesc.BufferDesc.Width = windowWidth;
	swapChainDesc.BufferDesc.Height = windowHeight;
	swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
	swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
	swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
	swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
	swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
	swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
	swapChainDesc.BufferCount = 1;
	swapChainDesc.OutputWindow = hMainWnd;
	swapChainDesc.Windowed = true;
	swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
	swapChainDesc.Flags = 0;
	if (enable4xMsaa)
	{
		// Set up 4x MSAA
		swapChainDesc.SampleDesc.Count = 4;
		swapChainDesc.SampleDesc.Quality = msaa4xQuality - 1;
	}
	else
	{
		// No MSAA
		swapChainDesc.SampleDesc.Count = 1;
		swapChainDesc.SampleDesc.Quality = 0;
	}

	// Create the device and swap chain and determine the supported feature level
	featureLevel = D3D_FEATURE_LEVEL_9_1; // Will be overwritten by next line
	HRESULT hr = D3D11CreateDeviceAndSwapChain(0, driverType, 0, createDeviceFlags, 0, 0, D3D11_SDK_VERSION, &swapChainDesc, &swapChain, &device, &featureLevel, &deviceContext);

	// Handle any device creation or DirectX version errors
	if (FAILED(hr))
	{
		MessageBox(0, L"D3D11CreateDevice Failed", 0, 0);
		return false;
	}

	// Check for 4X MSAA quality support
	HR(device->CheckMultisampleQualityLevels(
		DXGI_FORMAT_R8G8B8A8_UNORM,
		4,
		&msaa4xQuality));
	assert(msaa4xQuality > 0); // Potential problem if quality is 0

	// The remaining steps also need to happen each time the window
	// is resized, so just run the OnResize method
	OnResize();

	return true;
}