static void UNITY_INTERFACE_API OnRenderEvent(int eventID) { // Unknown graphics device type? Do nothing. if (s_DeviceType == kUnityGfxRendererNull) return; // A colored triangle. Note that colors will come out differently // in D3D9/11 and OpenGL, for example, since they expect color bytes // in different ordering. MyVertex verts[3] = { { -0.5f, -0.25f, 0, 0xFFff0000 }, { 0.5f, -0.25f, 0, 0xFF00ff00 }, { 0, 0.5f , 0, 0xFF0000ff }, }; // Some transformation matrices: rotate around Z axis for world // matrix, identity view matrix, and identity projection matrix. float phi = g_Time; float cosPhi = cosf(phi); float sinPhi = sinf(phi); float worldMatrix[16] = { cosPhi,-sinPhi,0,0, sinPhi,cosPhi,0,0, 0,0,1,0, 0,0,0.7f,1, }; float identityMatrix[16] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, }; float projectionMatrix[16] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, }; // Actual functions defined below SetDefaultGraphicsState (); DoRendering (worldMatrix, identityMatrix, projectionMatrix, verts); }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_LCDUISAMPLE, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LCDUISAMPLE)); /* Here we initialize our connection */ //Create a connection context and connect to LCDMon lgLcdConnectContextEx ConnectCtx; ConnectCtx.appFriendlyName = g_AppletTitle; //This part tells LCDMon what you want to display on. //Use LGLCD_APPLET_CAP_BW for monochrome, and //LGLCD_APPLET_CAP_QVGA for color. Or them together //to be dual mode. See the lgcd.h documentation //for more details on dual mode applets. ConnectCtx.dwAppletCapabilitiesSupported = LGLCD_APPLET_CAP_BW | LGLCD_APPLET_CAP_QVGA; //We don't want to autostart a sample ConnectCtx.isAutostartable = FALSE; //Persistence has been deprecated, so we will skip that field //ConnectCtx.isPersistent = doesn't matter //This example does not cover the configure callback, but it //is very similar to setting up notifications. ConnectCtx.onConfigure.configCallback = NULL; ConnectCtx.onConfigure.configContext = NULL; //In this sample, we are using the default notification ConnectCtx.onNotify.notificationCallback = NULL; ConnectCtx.onNotify.notifyContext = NULL; //Let's use our softbutton callback g_SBContext.softbuttonsChangedCallback = OnButtonCB; g_SBContext.softbuttonsChangedContext = g_hwnd; //Initialize your connection //We are using our own softbutton callback if( FALSE == g_Connection.Initialize(ConnectCtx, &g_SBContext) ) { return -1; } //Add your monochrome page CLCDOutput* pMonoOutput = g_Connection.MonoOutput(); CLCDPage m_MonoPage; pMonoOutput->ShowPage(&m_MonoPage); //For monochrome, let's just display some text g_MonoText.SetText( _T("Hello monochrome display.\n") ); g_MonoText.SetOrigin(0,0); g_MonoText.SetSize(160, 16); g_MonoText.SetFontPointSize(8); m_MonoPage.AddObject(&g_MonoText); //Add your color page CLCDOutput* pColorOutput = g_Connection.ColorOutput(); CLCDPage m_ColorPage; pColorOutput->ShowPage(&m_ColorPage); //Add our new OpenGL object //We're going to take up the entire screen with it g_OGLObj.Initialize(320,240); m_ColorPage.AddObject(&g_OGLObj); //Let's setup some OpenGL stuff in this function g_OGLObj.MakeCurrent(); SetupRendering(); // Main message loop: BOOL Done = FALSE; DWORD timestamp; while(!Done) { if( PeekMessage(&msg,NULL,0,0,PM_REMOVE) ) { if (msg.message==WM_QUIT) { Done = TRUE; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } else { timestamp = GetTickCount(); g_OGLObj.BeginDraw(); //Do OpenGL rendering here //One perk of OpenGL is that we do not have to put this rendering code //inside of COGLObject's OnDraw class. DoRendering(timestamp); g_OGLObj.EndDraw(); //The update will do the rendering of any LCDUI objects we added to pages g_Connection.Update(); //This loop goes very fast, so let's throttle it a bit Sleep(33); } } //Shutdown the connection //(also called in the destructor) g_Connection.Shutdown(); return (int) msg.wParam; }