void ExamplesMainInit() { #ifdef EXAMPLE_DEBUG_ONLY // Test for Debug only examples #ifndef IW_DEBUG DisplayMessage("This example is designed to run from a Debug build. Please build the example in Debug mode and run it again."); return 0; #endif #endif IwGxInit(); //IwResManagerInit(); //IwGxFontInit(); // Set screen clear colour IwGxSetColClear(0xff, 0xff, 0xff, 0xff); // white background IwGxPrintSetColour(0, 0, 0); // black font // Determine if the device has a keyboard if (s3eKeyboardGetInt(S3E_KEYBOARD_HAS_KEYPAD) || s3eKeyboardGetInt(S3E_KEYBOARD_HAS_ALPHA)) g_DeviceHasKeyboard = true; // User code init ExampleInit(); }
int main() { IwGxInit(); IwGxSetColClear(0, 0, 0xff, 0xff); IwResManagerInit(); Iw2DInit(); setupTextures(); registerInput(); const int textWidth = s3eDebugGetInt(S3E_DEBUG_FONT_SIZE_WIDTH); const int textHeight = s3eDebugGetInt(S3E_DEBUG_FONT_SIZE_HEIGHT); const int width = s3eSurfaceGetInt(S3E_SURFACE_WIDTH); const int height = s3eSurfaceGetInt(S3E_SURFACE_HEIGHT); sprintf(g_debugButtonEvent, "ButtonEvent:"); sprintf(g_debugKeyEvent, "KeyEvent:"); sprintf(g_debugMotionEvent, "MotionEvent:"); sprintf(g_debugTouchEvent, "TouchEvent:"); sprintf(g_debugTouchMotionEvent, "TouchMotionEvent:"); while (!s3eDeviceCheckQuitRequest()) { render(); // Yield until unyield is called or a quit request is recieved s3eDeviceYield(S3E_DEVICE_YIELD_FOREVER); } destroyTextures(); Iw2DTerminate(); IwResManagerTerminate(); IwGxTerminate(); return 0; }
//----------------------------------------------------------------------------- void HexMapTest::Init() { zoom = 1.0f; rotation = 0.0f; screenTranslationX = 0; screenTranslationY = 0; // Initialise the input system g_Input.Init(); // Initialise vectors s_left = CIwVec3::g_AxisX; s_up = -CIwVec3::g_AxisY; s_Angles = CIwSVec3::g_Zero; s_cameraPos = CIwVec3(0, 0, -0x80); // Initialise view matrix s_viewMatrix = CIwMat::g_Identity; s_viewMatrix.SetTrans(s_cameraPos); s_viewMatrix.LookAt( s_viewMatrix.GetTrans(), CIwVec3::g_Zero, -CIwVec3::g_AxisY); // Initialise IwGxInit(); IwResManagerInit(); // Set screen clear colour IwGxSetColClear(0x40, 0x40, 0x40, 0x00); // Turn all lighting off IwGxLightingOff(); // Set field of view IwGxSetPerspMul(0xa0); // Set near and far planes IwGxSetFarZNearZ(0x1000, 0x10); // Create empty texture object s_BitMapTexture = new CIwTexture; // Load image data from disk into texture s_BitMapTexture->LoadFromFile("./textures/testTexture_8bit.bmp"); // "Upload" texture to VRAM s_BitMapTexture->Upload(); // Set the view matrix along the -ve z axis CIwMat view = CIwMat::g_Identity; view.t.z = -0x100; IwGxSetViewMatrix(&view); IwGetResManager()->LoadGroup("TileRes.group"); pGroup = IwGetResManager()->GetGroupNamed("TileRes"); hexGrid = new HexGrid(hexGridMaxX, hexGridMaxY, textureMaxX, textureMaxY); hexGrid->setTexture(IW_TEXTURE(pGroup,"grid"),textureMaxX,textureMaxY); s_ModelMatrix.SetIdentity(); }
void ExampleInit() { IW_PROFILE_INIT(); // Initialise IwGxInit(); // Set screen clear colour IwGxSetColClear(0x40, 0x40, 0x40, 0x00); // Turn all lighting off IwGxLightingOff(); // Set field of view IwGxSetPerspMul(0xa0); // Set near and far planes IwGxSetFarZNearZ(0x1000, 0x10); // Set the view matrix along the -ve z axis CIwMat view = CIwMat::g_Identity; view.t.z = -0x200; IwGxSetViewMatrix(&view); //IwGxSetScreenOrient(IW_GX_ORIENT_NONE); s_Accelerometer = (S3E_RESULT_SUCCESS == s3eAccelerometerStart()); m_pAnimator = new CSplineAnimator(); m_pAnimator->Init(); m_pSplinePoly2Tri = new CSplinePoly2Tri(m_pAnimator->GetCurrentSpline()); // ball m_pBall = new CBall(); }
//----------------------------------------------------------------------------- // Main global function //----------------------------------------------------------------------------- int main() { #ifdef EXAMPLE_DEBUG_ONLY // Test for Debug only examples #ifndef IW_DEBUG DisplayMessage("This example is designed to run from a Debug build. Please build the example in Debug mode and run it again."); return 0; #endif #endif //IwGx can be initialised in a number of different configurations to help the linker eliminate unused code. //Normally, using IwGxInit() is sufficient. //To only include some configurations, see the documentation for IwGxInit_Base(), IwGxInit_GLRender() etc. IwGxInit(); // Example main loop ExampleInit(); // Set screen clear colour IwGxSetColClear(0xff, 0xff, 0xff, 0xff); IwGxPrintSetColour(128, 128, 128); while (1) { s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); int64 start = s3eTimerGetMs(); bool result = ExampleUpdate(); if ( (result == false) || (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) || (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN) || (s3eDeviceCheckQuitRequest()) ) break; // Clear the screen IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); RenderButtons(); RenderSoftkeys(); ExampleRender(); // Attempt frame rate while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } } ExampleShutDown(); DeleteButtons(); IwGxTerminate(); return 0; }
void N2F::Iw3D::Iw2DHelper::Init() { Iw2DInit(); IwGxInit(); IwGxFontInit(); IwGxLightingOn(); IwGxSetColClear(0, 0, 0, 0xff); return; }
int main() { Initialize(); // --HowTo: Load the tmx map from the json file tmxparser::Map_t *map = new tmxparser::Map_t; tmxparser::parseTmxFromJSON_file("testLevel.json", map); // --HowTo: Create a renderer tmxparser::TmxRenderer *renderer = new tmxparser::TmxRenderer(map); // an offset to use for scrolling the map CIwFVec2 offset(0,0); IwGxSetColClear(0x2f, 0x3f, 0x3f, 0xff); // Loop forever, until the user or the OS performs some action to quit the app while (!s3eDeviceCheckQuitRequest()) { //Update the input systems s3eKeyboardUpdate(); s3ePointerUpdate(); // Clear the surface IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); // --HowTo: render all layers, at original pixel size: //renderer->Render(offset); // --HowTo: render all layers at reduced/scaled tile size renderer->Render(offset, CIwFVec2(64.0f, 64.0f)); // --HowTo: render only one layer at original pixel size //renderer->RenderLayer(0, offset, CIwFVec2(0.0f, 0.0f)); // --HowTo: render only one layer at scaled pixel size //renderer->RenderLayer(0, offset, CIwFVec2(64.0f, 64.0f)); // advance offset offset.x += 3; if (offset.x>1900) offset.x =0; // Standard EGL-style flush of drawing to the surface IwGxFlush(); IwGxSwapBuffers(); s3eDeviceYield(0); } delete renderer; delete map; Terminate(); // Return return 0; }
void Desktop::init() { IwGxInit(); IwGxLightingOff(); width = IwGxGetScreenWidth(); height = IwGxGetScreenHeight(); IwGxSetColClear(0, 0, 0, 0); vSize = 0; duration = 1000 / 60; devices = new vector<Device>(); defPath = NULL; }
// Example showing how to use the s3eWwise extension int main() { IW_CALLSTACK("main"); s3eDebugOutputString("Booting s3eWwise example"); initWwise(); s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)buttonEvent, NULL); s3ePointerRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)motionEvent, NULL); IwGxInit(); IwGxSetColClear(0, 0, 0, 0xff); while(!s3eDeviceCheckQuitRequest()) { std::stringstream str; s3eWwiseSoundEngineRenderAudio(); IwGxClear(); IwGxPrintString(100, 100, "s3eWwise"); IwGxPrintString(100, 300, "Touch to fire event"); str << "RPM = " << rpm; IwGxPrintString(100, 400, str.str().c_str()); str.str(std::string()); str << "TH = " << touchHeight; IwGxPrintString(100, 500, str.str().c_str()); str.str(std::string()); str << "Height = " << height; IwGxPrintString(100, 600, str.str().c_str()); str.str(std::string()); IwGxFlush(); IwGxSwapBuffers(); s3eDeviceYield(0); } IwGxTerminate(); s3ePointerUnRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)buttonEvent); s3ePointerUnRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)motionEvent); shutdownWwise(); return 0; }
void Game::Init() { IwGxInit(); IwGraphicsInit(); IwResManagerInit(); #ifdef IW_BUILD_RESOURCES IwGetTextParserITX()->SetAssertOnUnrecognisedTokens( false ); IwGetResManager()->AddHandler( new CIwResHandlerWAV ); #endif IW_CLASS_REGISTER( Collision ); IW_CLASS_REGISTER( CStatic ); IW_CLASS_REGISTER( CDynamic ); IW_CLASS_REGISTER( CLocator ); IwGxSetColClear( 0x40, 0x40, 0x40, 0x00 ); LocaliseInit(); m_font = FontManager::GetInstance(); m_menuManager = MenuManager::GetInstance(); m_touchManager = TouchManager::GetInstance(); m_touchManager->Init(); m_accelerometerManager = AccelerometerManager::GetInstance(); m_accelerometerManager->Init(); m_webManager = WebManager::GetInstance(); m_webManager->Init(); m_config = Config::GetInstance(); m_config->Init(); m_soundManager = SoundManager::GetInstance(); m_soundManager->Init(); m_scriptManager = ScriptManager::GetInstance(); m_scriptManager->Init(); m_shaderManager = ShaderManager::GetInstance(); m_shaderManager->Init(); m_postProcessing = PostProcessing::GetInstance(); m_postProcessing->Init(); GameState::InitStatesStack(); GameState::SetState( new GS_Loading() ); }
void Render() { // Clear the screen to a pale blue IwGxSetColClear(128, 224, 255, 0); IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); // Render the UI for (uint32 i = 0; i < BUTTON_COUNT; i++) { gButton[i]->Render(); } // Finish rendering and display on screen IwGxFlush(); IwGxSwapBuffers(); }
void TransitionManager::Init() { IW_CALLSTACK("TransitionManager::Init"); if (m_HasStarted == true) { delete m_StartTexture; delete m_EndTexture; } m_StartTexture = NULL; m_EndTexture = NULL; m_HasStarted = false; m_alphaValue = 0; IwGxSetColClear(0, 0, 0, 0); IwGxScreenOrient orient = IwGxGetScreenOrient(); }
int main() { IwGxInit(); IwGxSetColClear(0, 0, 0xff, 0xff); while (!s3eDeviceCheckQuitRequest() && !(s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) && !(s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN)) { IwGxClear(); IwGxPrintString(120, 150, "Hello, World!"); IwGxFlush(); IwGxSwapBuffers(); s3eDeviceYield(0); } IwGxTerminate(); return 0; }
S3E_MAIN_DECL void IwMain() { Init(); // Set screen clear colour IwGxSetColClear(0, 0, 0, 0xff); IwGxPrintSetColour(128, 128, 128); while (1) { s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); int64 start = s3eTimerGetMs(); bool result = Update(); if ( ((result == false) || (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) || (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN) || (s3eDeviceCheckQuitRequest())) ) break; Render(); // Attempt frame rate while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } } ShutDown(); }
void Transitions2D::Slide(DIR d, uint8 transitionSpeed, bool skipFirstAndLastFrame) { IwGxSetColClear(0, 0, 0, 0); if (mStartTexture == NULL || mEndTexture == NULL) return; if (transitionSpeed == 0) transitionSpeed = 1; IwGxScreenOrient orient = IwGxGetScreenOrient(); if (isUsingPrivateTextures) IwGxSetScreenOrient(IW_GX_ORIENT_NONE); CIwMaterial* startMat; CIwMaterial* endMat; int w = mStartTexture->GetWidth(); int h = mStartTexture->GetHeight(); int pos = 0; int speed, size; if (d == LEFT || d == RIGHT) { speed = (int)((transitionSpeed * w) / 255.0); size = w; } else { speed = (int)((transitionSpeed * h) / 255.0); size = h; } if (skipFirstAndLastFrame) pos += speed; while (pos < size) { IwGxClear(); if (d == LEFT) { startMat = IW_GX_ALLOC_MATERIAL(); startMat->SetTexture(mStartTexture); IwGxSetMaterial(startMat); IwGxDrawRectScreenSpace(&CIwSVec2(-pos, 0), &CIwSVec2(mStartTexture->GetWidth(), mStartTexture->GetHeight())); endMat = IW_GX_ALLOC_MATERIAL(); endMat->SetTexture(mEndTexture); IwGxSetMaterial(endMat); IwGxDrawRectScreenSpace(&CIwSVec2(-pos + size, 0), &CIwSVec2(mEndTexture->GetWidth(), mEndTexture->GetHeight())); } else if (d == RIGHT) { endMat = IW_GX_ALLOC_MATERIAL(); endMat->SetTexture(mEndTexture); IwGxSetMaterial(endMat); IwGxDrawRectScreenSpace(&CIwSVec2(pos - size, 0), &CIwSVec2(mEndTexture->GetWidth(), mEndTexture->GetHeight())); startMat = IW_GX_ALLOC_MATERIAL(); startMat->SetTexture(mStartTexture); IwGxSetMaterial(startMat); IwGxDrawRectScreenSpace(&CIwSVec2(pos, 0), &CIwSVec2(mStartTexture->GetWidth(), mStartTexture->GetHeight())); } else if (d == UP) { startMat = IW_GX_ALLOC_MATERIAL(); startMat->SetTexture(mStartTexture); IwGxSetMaterial(startMat); IwGxDrawRectScreenSpace(&CIwSVec2(0, -pos), &CIwSVec2(mStartTexture->GetWidth(), mStartTexture->GetHeight())); endMat = IW_GX_ALLOC_MATERIAL(); endMat->SetTexture(mEndTexture); IwGxSetMaterial(endMat); IwGxDrawRectScreenSpace(&CIwSVec2(0, -pos + size), &CIwSVec2(mEndTexture->GetWidth(), mEndTexture->GetHeight())); } else if (d == DOWN) { endMat = IW_GX_ALLOC_MATERIAL(); endMat->SetTexture(mEndTexture); IwGxSetMaterial(endMat); IwGxDrawRectScreenSpace(&CIwSVec2(0, pos - size), &CIwSVec2(mEndTexture->GetWidth(), mEndTexture->GetHeight())); startMat = IW_GX_ALLOC_MATERIAL(); startMat->SetTexture(mStartTexture); IwGxSetMaterial(startMat); IwGxDrawRectScreenSpace(&CIwSVec2(0, pos), &CIwSVec2(mStartTexture->GetWidth(), mStartTexture->GetHeight())); } IwGxFlush(); IwGxSwapBuffers(); s3eDeviceYield(40); pos += speed; } if (!skipFirstAndLastFrame) { IwGxClear(); endMat = IW_GX_ALLOC_MATERIAL(); endMat->SetTexture(mEndTexture); IwGxSetMaterial(endMat); IwGxDrawRectScreenSpace(&CIwSVec2(0, 0), &CIwSVec2(mEndTexture->GetWidth(), mEndTexture->GetHeight())); IwGxFlush(); IwGxSwapBuffers(); } if (isUsingPrivateTextures) { delete mStartTexture; delete mEndTexture; mStartTexture = NULL; mEndTexture = NULL; } IwGxSetScreenOrient(orient); }
void MapBackground::RenderBackgroundOnSurface(CIw2DSurface* pSurface) { std::list<MapTile*>::iterator iter = gVectorImageUrls.begin(); // Set up a view matrix to rotate what we are viewing about the z-axis // This normalizes the center of the screen to (0,0), so we need to offset // our coordinates. // We also need to scale in our X and Y directions. CIwColour colClear; colClear = IwGxGetColClear(); if (g_dAlpha < 0xFF) { IwGxSetColClear(0, 0, 0, 0); } CIwColour* cols = IW_GX_ALLOC(CIwColour, 4); for (int i = 0; i < 4; ++i) { cols[i].r = cols[i].g = cols[i].b = 0xff; cols[i].a = (uint8)g_dAlpha; } //static CIwSVec2 uvs[4] = //{ // CIwSVec2(0 << 12, 0 << 12), // CIwSVec2(0 << 12, 1 << 12), // CIwSVec2(1 << 12, 1 << 12), // CIwSVec2(1 << 12, 0 << 12), //}; static CIwSVec2 uvs[4] = { CIwSVec2((0 << 12) + 1, (0 << 12) + 1), CIwSVec2((0 << 12) + 1, (1 << 12) - 1), CIwSVec2((1 << 12) - 1, (1 << 12) - 1), CIwSVec2((1 << 12) - 1, (0 << 12) + 1), }; static CIwSVec2 uvsRot[4] = { CIwSVec2((0 << 12) + 20, (0 << 12) + 20), CIwSVec2((0 << 12) + 20, (1 << 12) - 20), CIwSVec2((1 << 12) - 20, (1 << 12) - 20), CIwSVec2((1 << 12) - 20, (0 << 12) + 20), }; while (iter != gVectorImageUrls.end()) { MapTile* pTile = *iter; CIwTexture* pTexture = pTile->pTexture; if (pTexture) { //Calculate the top left of the map image CIwSVec2 topLeft = pTile->location; CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL(); pMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND); pMat->SetModulateMode(CIwMaterial::MODULATE_RGB); // Use Texture on Material pMat->SetTexture(pTexture); IwGxSetMaterial(pMat); int xOffset = IwGxGetScreenWidth() / 2; int yOffset = IwGxGetScreenHeight() / 2; CIwSVec3* pWSCoords= IW_GX_ALLOC(CIwSVec3, 4); pWSCoords[0].x = topLeft.x; pWSCoords[0].y = topLeft.y; pWSCoords[1].x = topLeft.x; pWSCoords[1].y = topLeft.y + 256; pWSCoords[2].x = topLeft.x + 256; pWSCoords[2].y = topLeft.y + 256; pWSCoords[3].x = topLeft.x + 256; pWSCoords[3].y = topLeft.y; pWSCoords[0].z = pWSCoords[1].z = pWSCoords[2].z = pWSCoords[3].z = 0; // Scale the coordinates by offsetting, scaling and rendering for (int i = 0; i < 4; ++i) { pWSCoords[i].x -= xOffset; pWSCoords[i].y -= yOffset; } IwGxSetVertStreamWorldSpace(pWSCoords, 4); if (g_bScaledMode) { IwGxSetUVStream(uvsRot); } else { IwGxSetUVStream(uvs); } IwGxSetColStream(cols); IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4); } iter++; } IwGxSetColStream(NULL); //IwGxSetColClear(colClear.r, colClear.g, colClear.b, colClear.a); }
int main(int, char**) { IwGxInit(); // Setup Dear ImGui binding IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls ImGui_Marmalade_Init(true); // Setup style ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); // Load Fonts // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. // - Read 'misc/fonts/README.txt' for more instructions and details. // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); //IM_ASSERT(font != NULL); bool show_demo_window = true; bool show_another_window = false; ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); // Main loop while (true) { if (s3eDeviceCheckQuitRequest()) break; // Poll and handle inputs // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. s3eKeyboardUpdate(); s3ePointerUpdate(); // Start the Dear ImGui frame ImGui_Marmalade_NewFrame(); ImGui::NewFrame(); // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). if (show_demo_window) ImGui::ShowDemoWindow(&show_demo_window); // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. { static float f = 0.0f; static int counter = 0; ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state ImGui::Checkbox("Another Window", &show_another_window); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) counter++; ImGui::SameLine(); ImGui::Text("counter = %d", counter); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); ImGui::End(); } // 3. Show another simple window. if (show_another_window) { ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) ImGui::Text("Hello from another window!"); if (ImGui::Button("Close Me")) show_another_window = false; ImGui::End(); } // Rendering ImGui::Render(); IwGxSetColClear(clear_color.x * 255, clear_color.y * 255, clear_color.z * 255, clear_color.w * 255); IwGxClear(); ImGui_Marmalade_RenderDrawData(ImGui::GetDrawData()); IwGxSwapBuffers(); s3eDeviceYield(0); } // Cleanup ImGui_Marmalade_Shutdown(); ImGui::DestroyContext(); IwGxTerminate(); return 0; }
int main() { IwGxInit(); IwGraphicsInit(); IwAnimInit(); Iw2DInit(); IwTrace(GHOST_HUNTER, ("Ghost Realm booting...")); IwTrace(GHOST_HUNTER, ("Audio channels: %d", s3eAudioGetInt(S3E_AUDIO_NUM_CHANNELS))); // Set screen clear colour IwGxSetColClear(0x0, 0x0, 0x0, 0xff); Splash* splash = new Splash(); s3eDeviceYield(20); { // Init game CameraViewPreInit(); MapControllerInit(); MapModelInit(); MapViewInit(); CameraControllerInit(); CameraModelInit(); CameraViewInit(); } delete splash; getGameState()->setGameMode(MAP_MODE); while (1) { s3eDeviceYield(0); int start = clock(); Audio::GetInstance().Update(); if (getGameState()->getGameMode() == CAMERA_MODE) { CameraControllerUpdate(); CameraModelUpdate(); CameraViewUpdate(); } else if (getGameState()->getGameMode() == MAP_MODE) { MapControllerUpdate(); MapModelUpdate(); MapViewUpdate(); } // Cap FPS int yield; do { yield = FRAME_DURATION - (clock() - start); if (yield > 0) { s3eDeviceYield(yield); } } while (yield > 0); } CameraControllerTerm(); CameraModelTerm(); CameraViewTerm(); MapControllerTerm(); MapModelTerm(); MapViewTerm(); delete getGameState(); Iw2DTerminate(); IwAnimTerminate(); IwGraphicsTerminate(); IwGxTerminate(); return 0; }
void Graphics::setBackgroundColor(uint8 r, uint8 g, uint8 b, uint8 a) { IwGxSetColClear(r, g, b, a); }
void doMain() { if(s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE)){ s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, (s3eCallback)MultiTouchButtonCB, NULL); s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, (s3eCallback)MultiTouchMotionCB, NULL); } else { s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)SingleTouchButtonCB, NULL); s3ePointerRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)SingleTouchMotionCB, NULL); } IwGetResManager()->LoadGroup("resource_groups/palate.group"); palateGroup = IwGetResManager()->GetGroupNamed("Palate"); std::vector<int> ui_texture_hashes; uint background_hash = IwHashString("background_clean"); CIwResList* resources = palateGroup->GetListHashed(IwHashString("CIwTexture")); for(CIwManaged** itr = resources->m_Resources.GetBegin(); itr != resources->m_Resources.GetEnd(); ++itr) { if(background_hash != (*itr)->m_Hash) { ui_texture_hashes.push_back((*itr)->m_Hash); } } CIwMaterial* background = new CIwMaterial(); background->SetTexture((CIwTexture*)palateGroup->GetResNamed("background_clean", IW_GX_RESTYPE_TEXTURE)); background->SetModulateMode(CIwMaterial::MODULATE_NONE); background->SetAlphaMode(CIwMaterial::ALPHA_DEFAULT); unit_ui = new CIwMaterial(); unit_ui->SetModulateMode(CIwMaterial::MODULATE_NONE); unit_ui->SetAlphaMode(CIwMaterial::ALPHA_DEFAULT); unit_ui->SetTexture((CIwTexture*)palateGroup->GetResNamed("TAKE2", IW_GX_RESTYPE_TEXTURE)); CIwSVec2 bg_wh(320, 480); CIwSVec2 ui_wh(80, 480); CIwSVec2 ui_offset(240, 0); CIwSVec2 uv(0, 0); CIwSVec2 duv(IW_GEOM_ONE, IW_GEOM_ONE); init(); IwGxLightingOff(); IwGxSetColClear(255, 255, 255, 255); float worldScrollMultiplier = 0.75; if(s3eDeviceGetInt(S3E_DEVICE_OS) == S3E_OS_ID_IPHONE) { worldScrollMultiplier = 0.925; } while (1) { int64 start = s3eTimerGetMs(); s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); if ((s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) || (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN) || (s3eDeviceCheckQuitRequest())) { break; } switch(currentState) { case MAIN_MENU: if(s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_PRESSED) { currentState = IN_GAME; } if(frameCount % FRAMES_PER_UPDATE == 0) { mainMenu->tick(); } mainMenu->render(); break; case IN_GAME: IwGxSetMaterial(background); IwGxSetScreenSpaceSlot(-1); IwGxDrawRectScreenSpace(&CIwSVec2::g_Zero, &bg_wh, &uv, &duv); IwGxSetMaterial(unit_ui); IwGxSetScreenSpaceSlot(1); IwGxDrawRectScreenSpace(&ui_offset, &ui_wh, &uv, &duv); if (worldScrollSpeed > .0005 || worldScrollSpeed < -.0005) { game->rotate(worldScrollSpeed); worldScrollSpeed *= worldScrollMultiplier; } if(frameCount % FRAMES_PER_UPDATE == 0) { game->tick(); } game->render(); if(!renderTouches()) { break; } break; } IwGxFlush(); IwGxSwapBuffers(); // Attempt frame rate while ((s3eTimerGetMs() - start) < MS_PER_FRAME){ int32 yield = (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield < 0) { break; } s3eDeviceYield(yield); } frameCount++; IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); } delete game; delete mainMenu; delete localPlayer; delete opponentPlayer; delete background; delete unit_ui; palateGroup->Finalise(); for(int i = 0; i < MAX_TOUCHES; ++i) if(touches[i].unit) delete touches[i].unit; }
void menu() { MenuInit(); //MusicInit("./textures/musicOn.jpg"); g_Input.gameOff(); MenuRender(); MusicRender(); while(!g_Input.getGame()) { int64 start = s3eTimerGetMs(); while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } if (g_Input.getTouchCount() != 0) { int x = g_Input.getTouch(0)->x; int y = g_Input.getTouch(0)->y; if (x <= 750 && x >= 500 && y <= 400 && y >= 200) { if (g_Input.getSound()) { MusicShutDown(); MusicInit("./textures/musicOf.jpg"); MusicRender(); g_Input.soundOff(); } else { MusicShutDown(); MusicInit("./textures/musicOn.jpg"); MusicRender(); g_Input.soundOn(); } } if (x <= 1270 && x >= 500 && y <= 190 && y >= 10) g_Input.gameOn(); } } //MusicShutDown(); //MenuShutDown(); IwGxSetColClear(0xff, 0xff, 0xff, 0xff); IwGxPrintSetColour(128, 128, 128); g_Input.initTimer(); g_Input.setTotalTime(); g_Input.setPosInitY(g_Input.getAccelerometerY()); SplashInit(); SplashUpdate("loading"); SplashRender(); MenuShutDown(); if (initMenu) { //Creating objects corazon = new corazones("corazones", 64, 64, -100, 1,2,false); for (int i=0; i<10; i++) { garras[i] = new claws("claws", 128, 128, -150,1,2,false); } maxiCoin = new Coin("./textures/monedas200pts.png", 128, 128, -150,1,2,false); for (int j=0; j<20; j++) { miniCoins[j] = new MiniCoin("coins", 64, 64, -100,1,2,true); } for (int i=0; i<10; i++) { tnts[i] = new Tnt("tnts", 128, 128, -150,1,2,false); } tank = new Tank(); tank->Init("./textures/tank.png", 256, 256, -300,1,2,false); chuletas = new Chuletas(); chuletas->Init("./textures/chuletas.png", 512, 512, -600,1,2,false); } SplashShutDown(); //SplashInit(); //SplashUpdate("go"); ciclo(); }
void Transitions2D::Fade(uint8 transitionSpeed, bool skipFirstAndLastFrame) { IwGxSetColClear(0, 0, 0, 0); if (mStartTexture == NULL || mEndTexture == NULL) return; if (transitionSpeed == 0) transitionSpeed = 1; IwGxScreenOrient orient = IwGxGetScreenOrient(); if (isUsingPrivateTextures) IwGxSetScreenOrient(IW_GX_ORIENT_NONE); int alpha = 0; if (skipFirstAndLastFrame) alpha += transitionSpeed; CIwMaterial* startMat; CIwMaterial* endMat; while (alpha <= 255) { IwGxClear(); startMat = IW_GX_ALLOC_MATERIAL(); startMat->SetTexture(mStartTexture); IwGxSetMaterial(startMat); IwGxDrawRectScreenSpace(&CIwSVec2(0, 0), &CIwSVec2(mStartTexture->GetWidth(), mStartTexture->GetHeight())); endMat = IW_GX_ALLOC_MATERIAL(); endMat->SetTexture(mEndTexture); endMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND); endMat->SetColAmbient(255, 255, 255, alpha); IwGxSetMaterial(endMat); IwGxDrawRectScreenSpace(&CIwSVec2(0, 0), &CIwSVec2(mEndTexture->GetWidth(), mEndTexture->GetHeight())); IwGxFlush(); IwGxSwapBuffers(); s3eDeviceYield(40); alpha += transitionSpeed; } if (!skipFirstAndLastFrame) { IwGxClear(); endMat = IW_GX_ALLOC_MATERIAL(); endMat->SetTexture(mEndTexture); IwGxSetMaterial(endMat); IwGxDrawRectScreenSpace(&CIwSVec2(0, 0), &CIwSVec2(mEndTexture->GetWidth(), mEndTexture->GetHeight())); IwGxFlush(); IwGxSwapBuffers(); } if (isUsingPrivateTextures) { delete mStartTexture; delete mEndTexture; mStartTexture = NULL; mEndTexture = NULL; } IwGxSetScreenOrient(orient); }