int Window::getMaximumSize(State & state, SDL_Window * window){ Stack * stack = state.stack; int w = 0, h = 0; SDL_GetWindowMaximumSize(window, &w, &h); stack->push<int>(w); stack->push<int>(h); return 2; }
bool inputSystem::processUnbufferedMouseInput() { renderEngine *render = renderEngine::Instance(); int x, y; int state = -1; SDL_MouseMotionEvent motion; SDL_PumpEvents(); SDL_GetMouseState(&x,&y); // logMsg("Processing mouse input"); //FIXME Need to get MyGUI working on android //#if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID //#else int w, h; //SDL_Window *sdlWindow = SDL_GetMouseFocus(); SDL_Window *sdlWindow = render->getSDLWindow(); SDL_GetWindowMaximumSize(sdlWindow,&w,&h); logMsg("sdlWindow width = " +Ogre::StringConverter::toString(w)); logMsg("sdlWindow height = " +Ogre::StringConverter::toString(h)); //SDL_GetGlobalMouseState(&x, &y); logMsg("mouse x = " +Ogre::StringConverter::toString(x)); logMsg("mouse y = " +Ogre::StringConverter::toString(y)); // state = SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(0); state = SDL_GetMouseState(NULL, NULL)&SDL_TOUCH_MOUSEID; logMsg("Mouse state = " +Ogre::StringConverter::toString(state)); // std::cout << "Mouse State = " << state << std::endl; if (state == 1) { // exit(0); } if (MyGUI::InputManager::getInstance().isFocusMouse()) { // exit(0); // std::cout << "focused" << std::endl; if(state == 1) { mouseLeftClick = 1; MyGUI::InputManager::getInstance().injectMousePress(x, y, MyGUI::MouseButton::Enum(0)); // exit(0); } else if (state == 0 && mouseLeftClick == 1) //if (SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1) == 0) { mouseLeftClick = 0; MyGUI::InputManager::getInstance().injectMouseRelease(x, y, MyGUI::MouseButton::Enum(0)); } } logMsg("Mouse x = " +Ogre::StringConverter::toString(x) + " y = " +Ogre::StringConverter::toString(y)); // Ogre::LogManager::getSingletonPtr()->logMessage("Mouse X = " +toString(x)); if (mouseX != x || mouseY != y) { MyGUI::InputManager::getInstance().injectMouseMove(x,y,0); } //#endif // logMsg("Mouse input processed"); return true; }
int main(int argc, char**argv) { SDL_Window* win = NULL; SDL_Renderer* ren = NULL; SDL_Texture* tex = NULL; SDL_Event eve; char*smoothing="nearest"; //nearest or linear unsigned width = 3000; unsigned height = 4000; unsigned i,r,g,b,x,y; int sizew,sizeh; //actual window size uint32_t*buff=NULL; srand(time(NULL)); assert(buff = calloc(width*height,sizeof(uint32_t))); for(x=0; x<width; x++) { for(y=0; y<height; y++) { r = x % 256; g = y % 256; //i / 256; b = 0; //rand() % 256; //buff[y*width+x] = (r<<16)+(g<<8)+b; setpixel(buff,x,y,width,r,g,b); } } if (SDL_Init(SDL_INIT_VIDEO) != 0) { printf("SDL_Init Error: %s\n",SDL_GetError()); return 1; } assert(win = SDL_CreateWindow("Hello World!", SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED, 100, 100,SDL_WINDOW_SHOWN|SDL_WINDOW_MAXIMIZED|SDL_WINDOW_RESIZABLE)); //SDL_WINDOW_FULLSCREEN_DESKTOP)); assert(ren = SDL_CreateRenderer(win, -1, 0)); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, smoothing); //"linear" or "nearest" //SDL_RenderSetLogicalSize(ren, width, height);- assert(tex = SDL_CreateTexture(ren,SDL_PIXELFORMAT_ARGB8888,SDL_TEXTUREACCESS_STREAMING, width, height)); SDL_UpdateTexture(tex, NULL, buff, width * sizeof (uint32_t)); SDL_RenderClear(ren); SDL_RenderCopy(ren, tex, NULL, NULL); SDL_RenderPresent(ren); SDL_PollEvent(&eve); SDL_RenderClear(ren); SDL_RenderCopy(ren, tex, NULL, NULL); SDL_RenderPresent(ren); SDL_Rect src; SDL_Rect dst; double vx = (double)width / 2.0; double vy = (double)height / 2.0; double scl = 0.5; src.x = 0; src.y = 0; src.w = width; src.h = height; SDL_GetWindowSize(win,&sizew,&sizeh); printf("window size: %d,%d\n",sizew,sizeh); SDL_GetWindowMaximumSize(win,&sizew,&sizeh); printf("max window size: %d,%d\n",sizew,sizeh); SDL_GetRendererOutputSize(ren,&sizew,&sizeh); printf("renderer size: %d,%d\n",sizew,sizeh); while(1) { SDL_WaitEvent(&eve); if(eve.type == SDL_QUIT) break; if(eve.type == SDL_KEYDOWN) { //quit if(eve.key.keysym.sym == SDLK_q) break; if(eve.key.keysym.sym == SDLK_ESCAPE) break; //scaling method if(eve.key.keysym.sym == SDLK_n) SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY,"nearest"); if(eve.key.keysym.sym == SDLK_l) SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY,"linear"); //reset view if(eve.key.keysym.sym == SDLK_RETURN || eve.key.keysym.sym == SDLK_RETURN2) { vx = (double)width / 2.0; vy = (double)height / 2.0; scl = 0.5; } //zoom in / out if(eve.key.keysym.sym == SDLK_PLUS || eve.key.keysym.sym == SDLK_KP_PLUS) { scl /= 1.01; } if(eve.key.keysym.sym == SDLK_MINUS || eve.key.keysym.sym == SDLK_KP_MINUS) { scl *= 1.01; } } if(eve.type == SDL_MOUSEBUTTONDOWN) { printf("(%d,%d)\n",eve.button.x,eve.button.y); } dst.x = vx - scl * (double)width; dst.y = vy - scl * (double)height; dst.w = 2.0 * scl * (double)width; dst.h = 2.0 * scl * (double)height; SDL_RenderClear(ren); SDL_RenderCopy(ren, tex, &src, &dst); SDL_RenderPresent(ren); } SDL_Quit(); return 0; }
vector maximum_size() const noexcept { vector result; SDL_GetWindowMaximumSize(ptr.get(), &result.x, &result.y); return result; }
SIZE ZWindow::GetMaximumSize() { SIZE sz={0}; SDL_GetWindowMaximumSize(m_win,&sz.cx,&sz.cy); return sz; }