bool PluginSearch::OnWndEvent(IWndParam& cmd,int phase) { if(cmd.evtptr && cmd.evtptr->m_sId=="search.text_new") { return true; } if(phase>0 && cmd.action==IDefs::ACTION_VALUE_CHANGED && cmd.evtptr && cmd.evtptr->m_sId=="search.regexp") { WndManager& wm(WndManager::current()); wm.evtmgr["search.case"].flags.set(EvtBase::FLAG_DISABLE,cmd.param1!=0); wm.evtmgr["search.word"].flags.set(EvtBase::FLAG_DISABLE,cmd.param1!=0); wm.evtmgr["search.case"].UpdateCtrl(); wm.evtmgr["search.word"].UpdateCtrl(); return true; } if(phase>0 && cmd.action==IDefs::ACTION_VALUE_CHANGED && cmd.evtptr && cmd.evtptr->m_sId=="search.replace") { WndManager& wm(WndManager::current()); wm.evtmgr["Btn.Replace"].flags.set(EvtBase::FLAG_HIDE_UI,cmd.param1==0); wm.evtmgr["Btn.ReplaceAll"].flags.set(EvtBase::FLAG_HIDE_UI,cmd.param1==0); wm.evtmgr["search.text_new"].flags.set(EvtBase::FLAG_HIDE_UI,cmd.param1==0); return true; } if(phase>0 && cmd.action==IDefs::ACTION_VALUE_CHANGED && cmd.evtptr && cmd.evtptr->m_sId=="search.text_old") { WndManager::current().evtmgr["Btn.Find"].CmdExecuteEx(1); } return true; }
/* TODO: maybe optimize this */ void WFrame::draw() { WDrawable &d = wm().buffer_pixmap.drawable(); WFrameStyle &style = wm().frame_style; WFrameStyleScheme &scheme = (marked() ? style.marked : style.normal); WFrameStyleSpecialized &substyle = (this == column()->selected_frame() ? (column() == column()->view()->selected_column() ? scheme.active_selected : scheme.inactive_selected) : scheme.inactive); if (decorated() || shaded()) { WRect rect(0, 0, bounds.width, bounds.height); fill_rect(d, substyle.background_color, rect); draw_border(d, substyle.highlight_color, style.highlight_pixels, substyle.shadow_color, style.shadow_pixels, rect); WRect rect2 = rect.inside_tl_br_border(style.highlight_pixels, style.shadow_pixels); draw_border(d, substyle.padding_color, style.padding_pixels, rect2); WRect rect3 = rect2.inside_border(style.padding_pixels + style.spacing); rect3.height = wm().bar_height(); // Draw the tag names utf8_string tags; { std::vector<utf8_string> tag_names; std::transform(client().view_frames().begin(), client().view_frames().end(), std::back_inserter(tag_names), boost::bind(&WView::name, boost::bind(&WClient::ViewFrameMap::value_type::first, _1))); std::sort(tag_names.begin(), tag_names.end()); BOOST_FOREACH(const utf8_string &str, tag_names) { tags += str; if (&str != &tag_names.back()) tags += ' '; } }
T produce_next_value() { guarantee(!memory_queue.empty()); write_message_t wm(std::move(memory_queue.front())); memory_queue.pop_front(); memory_queue_free_space += wm.size(); items_in_queue--; if (memory_queue.empty()) { available_control.set_available(false); } if (notify_when_room_in_memory_queue != nullptr) { notify_when_room_in_memory_queue->pulse_if_not_already_pulsed(); } // TODO: This does some unnecessary copying. vector_stream_t stream; stream.reserve(wm.size()); int res = send_write_message(&stream, &wm); guarantee(res == 0); std::vector<char> data; stream.swap(&data); vector_read_stream_t rstream(std::move(data)); T value; archive_result_t dres = deserialize<cluster_version_t::LATEST_OVERALL>(&rstream, &value); guarantee_deserialization(dres, "disk backed queue wrapper"); return value; }
int WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int) { try { dll_t("SciLexer.dll"); HACCEL haccel = LoadAccelerators(instance, "accel_main"); window_class_t wc("MAINFRAME", MainFrameProc); wc.install(); window_maker_t wm(wc); wm.create(); SetWindowText(wm.handle, "skeletype"); window_positioner_t wp(wm.handle); wp.setsize(782, 400); wp.center_to_screen(); UpdateWindow(wm.handle); ShowWindow(wm.handle, SW_SHOW); return win::run(wm.handle, haccel); } catch(error_t& e) { e.print(); } return -1; }
int main( int argc, char **argv ){ WarpedMain wm( new PingPongApplication( 5, 10000, 1, false ) ); // Defaults - 5 objects, 100 events apiece return wm.main( argc, argv ); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow gui; // main window, contains the canvas of QGLViewer // Creating a new WindowManager that will be added to the main window WindowManager wm(&gui); WINDOW_MANAGER_ID = gui.addManager(&wm, "Window"); // Creating a new DcelManager that will be added to the main window DcelManager d(&gui); DCEL_MANAGER_ID = gui.addManager(&d, "Dcel"); gui.setCurrentIndexToolBox(DCEL_MANAGER_ID); // DcelManager will be focused on start // Creating a new ConvexHullManager that will be added to the main window ConvexHullManager ch(&gui); CONVEX_HULL_MANAGER_ID = gui.addManager(&ch, "Convex Hull Solver"); gui.updateAndFit(); gui.show(); return app.exec(); }
/* * Checks to see if any existing window is currently in fullscreen mode. */ static PRBool CheckForFullscreenWindow() { nsCOMPtr<nsIWindowMediator> wm(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID)); if (!wm) return PR_FALSE; nsCOMPtr<nsISimpleEnumerator> windowList; wm->GetXULWindowEnumerator(nsnull, getter_AddRefs(windowList)); if (!windowList) return PR_FALSE; for (;;) { PRBool more = PR_FALSE; windowList->HasMoreElements(&more); if (!more) return PR_FALSE; nsCOMPtr<nsISupports> supportsWindow; windowList->GetNext(getter_AddRefs(supportsWindow)); nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(supportsWindow)); if (baseWin) { PRInt32 sizeMode; nsCOMPtr<nsIWidget> widget; baseWin->GetMainWidget(getter_AddRefs(widget)); if (widget && NS_SUCCEEDED(widget->GetSizeMode(&sizeMode)) && sizeMode == nsSizeMode_Fullscreen) { return PR_TRUE; } } } return PR_FALSE; }
int main(int argc, char* argv[]) { CWatermark wm(44100,20000); const int size = 64000*5; short* buff = new short[size]; memset(buff,0,size*2); FILE* pf = fopen("test.pcm","rb"); fread(buff,2,64000*5,pf); wm.GenerateWatermark(buff,size); fclose(pf); pf = fopen("water.pcm","rb"); fread(buff,2,64000*5,pf); bool r = wm.DetectWatermark(buff,size); if (r) { printf("检测到水印\n"); } else { printf("没有检测到水印\n"); } fclose(pf); return 0; }
int getSurfaceRotation() { int rotation = ANDROID_SURFACE_ROTATION_UNDEFINED; try { QAndroidQPAPluginGap::Context activity; QScopedPointer<QJniObject> wm(activity.callObject("getWindowManager", "android/view/WindowManager")); if (!wm) { qWarning() << "QAndroidScreenOrientation: could not get window manager"; throw std::exception(); } QScopedPointer<QJniObject> display(wm->callObject("getDefaultDisplay", "android/view/Display")); if (!display) { qWarning() << "QAndroidScreenOrientation: could not get display"; throw std::exception(); } rotation = display->callInt("getRotation"); } catch (const std::exception & e) { qWarning() << "QAndroidScreenOrientation exception (3):" << e.what(); } return rotation; }
void testSVD() { int m = 3; int n = 3; ublas::matrix<double> mat(m,n); ublas::matrix<double> u(m,n); ublas::matrix<double> v(n,n); ublas::vector<double> w(n); /* mat(0,0) = 1; mat(0,1) = 1; mat(0,2) = 2; mat(1,0) = 3; mat(1,1) = 4; mat(1,2) = 5; mat(2,0) = 6; mat(2,1) = 7; mat(2,2) = 8; */ mat(0,0) = .1875; mat(0,1) = -.0625; mat(0,2) = -.0625; mat(1,0) = -.0625; mat(1,1) = .1875; mat(1,2) = -.0625; mat(2,0) = -.0625; mat(2,1) = -.0625; mat(2,2) = .1875; svdcmp(mat, u, w, v); print("mat", mat); print("u", u); print("w", w); print("v",v); ublas::matrix<double> wm(n,n); wm*=0; wm(0,0) = w(0); wm(1,1) = w(1); wm(2,2) = w(2); ublas::matrix<double> orig(m,n); orig = prod(wm, trans(v)); orig = prod(u, orig); print("orig", orig); }
wxAuiNotebook* MvcBook::CreateBook(wxWindow* p) { WndManager& wm(WndManager::current()); MvcBookImpl* book=new MvcBookImpl(p,wm.evtmgr.id_new(),wm); book->SetName("centerpane"); m_pBook.reset(book); return book; }
void MvcBook::SaveAll() { WndManager& wm(WndManager::current()); size_t n=m_pBook->GetPageCount(); for(size_t i=0;i<n;i++) { wxWindow* w=m_pBook->GetPage(i); MvcView* v=MvcView::GetViewByCanvas(w); if(!v) continue; v->Target.ExecId(CmdProc::CP_DIRTY); } wm.wup.gp_add("Save"); wm.wup.gp_add("SaveAll"); }
void WindowWin32::Initialize() { HINSTANCE hInstance = Win32::GetAppInstance(); WinClassMaker wcm(hInstance, MY_WNDCLS_NAME, WndProc); wcm.Register(); WinMaker wm(hInstance, MY_WNDCLS_NAME); wm.SetSize(m_iWidth, m_iHeight); m_hWnd = wm.Create(m_sTitle.c_str(), this); // init renderer if (GetRenderer().get()) GetRenderer()->Initialize(this); }
WRect WFrame::client_bounds() const { WRect r; if (decorated() || shaded()) { WFrameStyle &style = wm().frame_style; int tl_off = top_left_offset(wm()); int br_off = bottom_right_offset(wm()); r.x = tl_off; r.width = bounds.width - r.x - br_off; r.y = tl_off + wm().bar_height() + style.spacing; r.height = bounds.height - r.y - br_off; } else { r.x = 0; r.y = 0; r.width = bounds.width; r.height = bounds.height; } return r; }
// The start of the Application int App::start(const std::vector<CL_String> &args) { CL_DisplayWindowDescription win_desc; win_desc.set_allow_resize(true); win_desc.set_title("ColorWheel Example"); win_desc.set_size(CL_Size( 800, 600 ), false); CL_DisplayWindow window(win_desc); CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close); CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up); CL_String theme; if (CL_FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css")) theme = "../../../Resources/GUIThemeAero"; else if (CL_FileHelp::file_exists("../../../Resources/GUIThemeBasic/theme.css")) theme = "../../../Resources/GUIThemeBasic"; else throw CL_Exception("No themes found"); CL_GUIWindowManagerTexture wm(window); CL_GUIManager gui(wm, theme); CL_GraphicContext gc = window.get_gc(); // Deleted automatically by the GUI new ColorWheel(gc, gui, CL_Rect(32, 32, CL_Size(512, 512))); unsigned int time_last = CL_System::get_time(); while (!quit) { unsigned int time_now = CL_System::get_time(); float time_diff = (float) (time_now - time_last); time_last = time_now; gc.clear(CL_Colorf(0.0f,0.0f,0.0f)); wm.process(); wm.draw_windows(gc); window.flip(1); CL_KeepAlive::process(); } return 0; }
void resize(int *w,int *h,int *bpp,Uint32 *video_flags,int *shrink, int *grow) { xy r = parsemodes(*w,*h,"modes",0,*shrink,*grow); if ((r.x!=-1)) { if (SDL_SetVideoMode( r.x,r.y, *bpp, *video_flags ) ) { *w=r.x; *h=r.y; glMatrixMode( GL_MODELVIEW ); glPopMatrix(); wm(*w,*h); } } *grow=*shrink=0; }
void CTestDistortion::Test(CAlgorithm* alg, QString& params, QString& alg_params, QByteArray& result, const QString& container_name, const QString& watermark_name, int size) { QImage in; //QImage in2; in.load(container_name); QImage orig(in); QFile wm(watermark_name); wm.open(QIODevice::ReadOnly); QByteArray bytes;// = wm.readAll(); QByteArray bytes_out; QBitArray bits, bits_out; wm.close(); if (!size) { size = (in.width() / 8) * (in.height() / 8) / 8; } bytes.resize(size); srand(QTime::currentTime().msec()); for (int i=0; i<size; i++) { bytes[i] = rand() % 256; } qDebug() << params; SetParams(params); alg->SetParams(alg_params); alg->GenKey(bytes); alg->Hide(in, bytes, alg_params); in.save("F:\\koh.bmp"); //alg->Restore(in, bytes_out, alg_params); CImgCompare::Result res = CImgCompare::PSNR_B(orig, in, ch); qDebug() << ch; /*qDebug() << "md: " << res.md; qDebug() << "ad: " << res.ad; qDebug() << "nad: " << res.nad; qDebug() << "mse: " << res.mse; qDebug() << "nmse: " << res.nmse; qDebug() << "l2: " << res.l2; qDebug() << "snr: " << res.snr; qDebug() << "psnr: " << res.psnr; qDebug() << "image fidelity: " << res.ifid; qDebug() << "hs: " << res.hs; qDebug() << "sc: " << res.sc; qDebug() << "cq: " << res.cq; qDebug() << "nc: " << res.nc;*/ result = SERIALIZE(res); }
void Button::createMe(HWND hParent) { Component::createMe(hParent); HINSTANCE hInst = Global::getHINSTANCE(); WinClassMaker wcm(hInst, "UxButton", ButtonWndProc); wcm.registerMe(); ChildWinMaker wm(hInst, "UxButton"); wm.setPos(x_, y_); wm.setSize(bitmaps_[ST_NORMAL].width(), bitmaps_[ST_NORMAL].height()); hWnd_ = wm.create(hParent, this); ::ShowWindow(hWnd_, SW_SHOWNORMAL); ::UpdateWindow(hWnd_); }
void WpaGui::processMsg(char *msg) { char *pos = msg, *pos2; int priority = 2; if (*pos == '<') { /* skip priority */ pos++; priority = atoi(pos); pos = strchr(pos, '>'); if (pos) pos++; else pos = msg; } WpaMsg wm(pos, priority); if (eh) eh->addEvent(wm); msgs.append(wm); while (msgs.count() > 100) msgs.pop_front(); /* Update last message with truncated version of the event */ if (strncmp(pos, "CTRL-", 5) == 0) { pos2 = strchr(pos, str_match(pos, WPA_CTRL_REQ) ? ':' : ' '); if (pos2) pos2++; else pos2 = pos; } else pos2 = pos; QString lastmsg = pos2; lastmsg.truncate(40); textLastMessage->setText(lastmsg); pingsToStatusUpdate = 0; networkMayHaveChanged = true; if (str_match(pos, WPA_CTRL_REQ)) processCtrlReq(pos + strlen(WPA_CTRL_REQ)); }
bool MvcBook::CloseAll() { WndManager& wm(WndManager::current()); ICmdParam cmd(-1); LockGuard<WndUpdator> lock(wm.wup); while(1) { wxWindow* w=m_pBook->GetCurrentCanvas(); if(!w) break; if(!m_pBook->CloseCanvas(cmd,w)) { return false; } } return true; }
Rnn::Rnn(Model& modelRef, std::unordered_map<wchar_t, int>& char2int, std::unordered_map<int, wchar_t>& int2char, int T, double learningRate) : model_(modelRef), char2int_(char2int), int2char_(int2char), generator_(modelRef, char2int, int2char), firstWordHidden_(modelRef.mw), firstCharHidden_(modelRef.mc), lastWordHidden_(modelRef.mw), lastCharHidden_(modelRef.mc), lastLambda_(modelRef.mw), lastMu_(modelRef.mc) { T_ = T; lr_ = learningRate; lr0_ = lr_; for (int t=0; t<T_; t++) { WordModule2 wm(modelRef, char2int, int2char); net_.push_back(wm); } reset(); }
void fft(Complex *a, int n, int rev) { // n是大于等于相乘的两个数组长度的2的幂次 // 从0开始表示长度,对a进行操作 // rev==1进行DFT,==-1进行IDFT for (int i = 1,j = 0; i < n; ++ i) { for (int k = n>>1; k > (j^=k); k >>= 1); if (i<j) std::swap(a[i],a[j]); } for (int m = 2; m <= n; m <<= 1) { Complex wm(cos(2*pi*rev/m),sin(2*pi*rev/m)); for (int i = 0; i < n; i += m) { Complex w(1.0,0.0); for (int j = i; j < i+m/2; ++ j) { Complex t = w*a[j+m/2]; a[j+m/2] = a[j] - t; a[j] = a[j] + t; w = w * wm; } } } if (rev==-1) { for (int i = 0; i < n; ++ i) a[i].x /= n,a[i].y /= n; } }
int load_index(t_process *process, int i) { t_parameters param; param.o = 10; decode_ocp(process, ¶m, i); param.jump = 1 + g_op_tab[i].has_ocp; if (g_op_tab[i].has_ocp == 0) return (1); params_value(process, ¶m, i); if (check_registers(¶m, process, i) == 1 || g_op_tab[i].param_nbr < 3 || check_param_error(param, i) == 1 || g_op_tab[i].param_nbr > 4) return (param.jump); if (param.type[0] == REG_CODE) param.value[0] = RBE(process->registers[param.value[0] - 1], REG_SIZE); if (param.type[1] == REG_CODE) param.value[1] = RBE(process->registers[param.value[1] - 1], REG_SIZE); PV[0] = rm(mem(process->pc + PV[0] + PV[1], 1, PA, process), REG_SIZE, PP); if (param.type[2] == REG_CODE) WBE(PV[0], PR[PV[2] - 1], REG_SIZE); else if (param.type[2] == IND_CODE) wm(PV[0], mem(process->pc + PV[0], 1, PA, process), REG_SIZE, PP); return (param.jump); }
// The start of the Application int App::start(const std::vector<CL_String> &args) { CL_DisplayWindowDescription win_desc; win_desc.set_allow_resize(true); win_desc.set_stencil_size(8); // For simplicity this example does not use the depth components //win_desc.set_depth_size(16); win_desc.set_title("Stencil Example"); win_desc.set_size(CL_Size( 900, 570 ), false); CL_DisplayWindow window(win_desc); CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close); CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up); CL_String theme; if (CL_FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css")) theme = "../../../Resources/GUIThemeAero"; else if (CL_FileHelp::file_exists("../../../Resources/GUIThemeBasic/theme.css")) theme = "../../../Resources/GUIThemeBasic"; else throw CL_Exception("No themes found"); CL_GUIWindowManagerTexture wm(window); CL_GUIManager gui(wm, theme); CL_GraphicContext gc = window.get_gc(); // Deleted automatically by the GUI Options *options = new Options(gui, CL_Rect(0, 0, gc.get_size())); CL_Image image_grid(gc, "../Blend/Resources/grid.png"); CL_Image image_ball(gc, "../Blend/Resources/ball.png"); grid_space = (float) (image_grid.get_width() - image_ball.get_width()); setup_balls(); CL_BufferControl buffer_control; CL_BufferControl default_buffer_control; options->request_repaint(); CL_Font font(gc, "Tahoma", 24); unsigned int time_last = CL_System::get_time(); while (!quit) { unsigned int time_now = CL_System::get_time(); float time_diff = (float) (time_now - time_last); time_last = time_now; wm.process(); wm.draw_windows(gc); int num_balls = options->num_balls; if (num_balls > max_balls) num_balls = max_balls; if (options->is_moveballs_set) move_balls(time_diff, num_balls); gc.clear_stencil(0); // Draw the grid const float grid_xpos = 10.0f; const float grid_ypos = 10.0f; image_grid.draw(gc, grid_xpos, grid_ypos); // Draw the circle onto the stencil if (options->is_circle_set) { buffer_control.enable_logic_op(false); buffer_control.enable_stencil_test(true); buffer_control.set_stencil_compare_func(cl_comparefunc_always, cl_comparefunc_always); buffer_control.set_stencil_fail(cl_stencil_incr_wrap, cl_stencil_incr_wrap); buffer_control.set_stencil_pass_depth_fail(cl_stencil_incr_wrap, cl_stencil_incr_wrap); buffer_control.set_stencil_pass_depth_pass(cl_stencil_incr_wrap, cl_stencil_incr_wrap); buffer_control.enable_color_write(false); buffer_control.enable_depth_write(false); buffer_control.enable_depth_test(false); gc.set_buffer_control(buffer_control); CL_Draw::circle(gc, grid_xpos + image_grid.get_width()/2, grid_ypos + image_grid.get_height()/2, 100, CL_Colorf::white); } buffer_control.enable_color_write(true); buffer_control.enable_logic_op(false); buffer_control.enable_stencil_test(true); buffer_control.set_stencil_compare_func(options->compare_function, options->compare_function); buffer_control.set_stencil_compare_reference(options->compare_reference, options->compare_reference); buffer_control.set_stencil_write_mask(255, 255); buffer_control.set_stencil_compare_mask(255, 255); buffer_control.set_stencil_fail(options->stencil_fail, options->stencil_fail);; // Note, depth testing disabled for this example buffer_control.set_stencil_pass_depth_fail(options->stencil_pass, options->stencil_pass); buffer_control.set_stencil_pass_depth_pass(options->stencil_pass, options->stencil_pass); buffer_control.enable_depth_write(false); buffer_control.enable_depth_test(false); gc.set_buffer_control(buffer_control); for (int cnt=0; cnt<num_balls; cnt++) { image_ball.draw(gc, grid_xpos + balls[cnt].xpos, grid_ypos + balls[cnt].ypos); } gc.set_buffer_control(default_buffer_control); CL_Image stencil_image = get_stencil(gc, CL_Rect(grid_xpos, grid_ypos, image_grid.get_width(), image_grid.get_height())); const float stencil_image_xpos = 400.0f; const float stencil_image_ypos = 30.0f; const float stencil_image_scale = 0.5f; stencil_image.set_scale(stencil_image_scale, stencil_image_scale); stencil_image.draw(gc, stencil_image_xpos, stencil_image_ypos); CL_Draw::box(gc, CL_Rectf(stencil_image_xpos, stencil_image_ypos, CL_Sizef(stencil_image.get_width() * stencil_image_scale, stencil_image.get_height() * stencil_image_scale)), CL_Colorf::white); font.draw_text(gc, stencil_image_xpos, stencil_image_ypos - 4.0f, "Stencil", CL_Colorf::black); // Add a note to avoid confusion font.draw_text(gc, 10.0f, 500.0, "(This example does not use the stencil depth buffer comparison or the stencil bitmask)", CL_Colorf::black); window.flip(1); CL_KeepAlive::process(); } return 0; }
int RunGLTest () { int bpp; int w = 500; int h = 500; int done = 0; int shrink=0; int grow=0; xy s = parsemodes(w,h,"mode",1,0,0); if (s.x!=-1){w=s.x;h=s.y;}; Uint32 video_flags=initsdl(w,h,&bpp); /* Set the window manager title bar */ SDL_WM_SetCaption( "SDL GL test", "testgl" ); SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); wm(w,h); glDepthFunc(GL_LESS); glEnable(GL_BLEND); glShadeModel(GL_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE); add_terminal(); glLineWidth(1); glClearColor( 0.0, 0.0, 0.0, 1.0 ); while( !done ) { GLenum gl_error; char* sdl_error; SDL_Event event; glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); rote_vt_update(t); glPushMatrix(); glRotatef(rot,1,0,0); glPushMatrix(); glTranslatef(-2.52,1.92,0); glPushMatrix(); activetext=(active==2); if (active==2) glScalef(0.003,-0.003,1); else glScalef(0.002,-0.002,1); draw_terminal(t); glPopMatrix(); glPushMatrix(); activetext=(active==1); if (active==1) glScalef(0.003,-0.003,1); else glScalef(0.002,-0.002,1); glTranslatef(0,plscroll*60,0); PyRun_SimpleString("dr_aw()"); glPopMatrix(); glPopMatrix(); glPopMatrix(); SDL_GL_SwapBuffers( ); gl_error = glGetError( ); if( gl_error != GL_NO_ERROR ) fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error ); sdl_error = SDL_GetError( ); if( sdl_error[0] != '\0' ) { fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error); SDL_ClearError(); } { } /* Check if there's a pending event. */ while( SDL_PollEvent( &event ) ) { switch( event.type ) { case SDL_KEYDOWN: printf("%i\n",event.key.keysym.unicode); int key=event.key.keysym.sym; if ( key==SDLK_UP ) { PyRun_SimpleString("pl_up()"); active=1; } if ( key==(SDLK_DOWN) ) { PyRun_SimpleString("pl_down()"); active=1; } if ( key==(SDLK_PAGEUP) ) { PyRun_SimpleString("pl_pgup()"); active=1; } if ( key==(SDLK_PAGEDOWN) ) { PyRun_SimpleString("pl_pgdown()"); active=1; } else if ( (key == SDLK_SPACE) ) keyp(32); else if ( (key == SDLK_q) ) rot++; else if ( (key == SDLK_w) ) rot--; else if ( (key == SDLK_e) ) glLineWidth(3); else if ( (key == SDLK_r) ) glLineWidth(4); else if ( (key == SDLK_t) ) glLineWidth(5); else if ( (key == SDLK_y) ) glLineWidth(6); else if ( (key == SDLK_F1) ) shrink=1; else if ( (key == SDLK_F2) ) grow=1; else if ( (key == SDLK_END) ) { PyRun_SimpleString("pl_end()"); active=1; } else if ( (key == SDLK_HOME) ) { PyRun_SimpleString("pl_home()"); active=1; } else if ( (key == SDLK_q) ) { PyRun_SimpleString("wanna_play()"); wannaplay=1; active=2; } else if ( (key == SDLK_RETURN) ) { keyp(10); PyRun_SimpleString("wanna_play()"); wannaplay=1; active=2; } else if ( (key == SDLK_c) ) done=1; break; case SDL_QUIT: done = 1; break; } } if (wannaplay) { FILE *f; if (f=fopen("/tmp/sftkoko","r")) fclose(f); else { wannaplay=0; PyRun_SimpleString("pl_ay()"); } } if (shrink||grow) resize(&w,&h,&bpp,&video_flags,&shrink,&grow); } SDL_Quit( ); return(0); }
/*! This is the main function and creates and links all the different classes. First it reads in all the parameters from the command prompt (<program name> -help)and uses these values to create the classes. After all the classes are linked, the mainLoop in the Player class is called. */ int main( int argc, char * argv[] ) { #ifdef WIN32 HANDLE listen, sense; #else pthread_t listen, sense; #endif ServerSettings ss; PlayerSettings cs; // define variables for command options and initialize with default values char strTeamName[MAX_TEAM_NAME_LENGTH] = "UvA_Trilearn"; int iPort = 6002; int iMinLogLevel = 0 ; int iMaxLogLevel = 0; char strHost[128] = "localhost"; double dVersion = 14; int iMode = 0; char strFormations[128] = "formations.conf"; int iNr = 0; int iReconnect = -1; bool bInfo = false; bool bSuppliedLogFile = false; ofstream os; // read in all the command options and change the associated variables // assume every two values supplied at prompt, form a duo char * str; for( int i = 1 ; i < argc ; i = i + 2 ) { // help is only option that does not have to have an argument if( i + 1 >= argc && strncmp( argv[i], "-help", 3 ) != 0 ) { cout << "Need argument for option: " << argv[i] << endl; exit( 0 ); } // read a command option if( argv[i][0] == '-' && strlen( argv[i] ) > 1) { switch( argv[i][1] ) { case 'h': // host server or help if( strlen( argv [i]) > 2 && argv[i][2] == 'e' ) { printOptions( ); exit(0); } else strcpy( strHost, argv[i+1] ); break; case 'f': // formations file strcpy( strFormations, argv[i+1] ); break; case 'c': // clientconf file if( cs.readValues( argv[i+1], ":" ) == false ) cerr << "Error in reading client file: " << argv[i+1] << endl; break; case 'i': // info 1 0 str = &argv[i+1][0]; bInfo = (Parse::parseFirstInt( &str ) == 1 ) ? true : false ; break; case 'l': // loglevel int[..int] str = &argv[i+1][0]; iMinLogLevel = Parse::parseFirstInt( &str ); while( iMinLogLevel != 0 ) { if( *str == '.' ) // '.' indicates range of levels { iMaxLogLevel = Parse::parseFirstInt( &str ); if( iMaxLogLevel == 0 ) iMaxLogLevel = iMinLogLevel; Log.addLogRange( iMinLogLevel, iMaxLogLevel ); } else Log.addLogLevel( iMinLogLevel ); iMinLogLevel = Parse::parseFirstInt( &str ); } break; case 'm': // mode int str = &argv[i+1][0]; iMode = Parse::parseFirstInt( &str ); break; case 'o': // output file log info os.open( argv[i+1] ); bSuppliedLogFile = true; break; case 'p': // port str = &argv[i+1][0]; iPort = Parse::parseFirstInt( &str ); break; case 's': // serverconf file if( ss.readValues( argv[i+1], ":" ) == false ) cerr << "Error in reading server file: " << argv[i+1] << endl; break; case 't': // teamname name strcpy( strTeamName, argv[i+1] ); break; case 'v': // version version str = &argv[i+1][0]; dVersion = Parse::parseFirstDouble( &str ); break; default: cerr << "(main) Unknown command option: " << argv[i] << endl; } } } if( bInfo == true ) cout << "team : " << strTeamName << endl << "port : " << iPort << endl << "host : " << strHost << endl << "version : " << dVersion << endl << "min loglevel : " << iMinLogLevel << endl << "max loglevel : " << iMaxLogLevel << endl << "mode : " << iMode << endl << "playernr : " << iNr << endl << "reconnect : " << iReconnect << endl ; if( bSuppliedLogFile == true ) Log.setOutputStream( os ); // initialize logger else Log.setOutputStream( cout ); Log.restartTimer( ); Formations fs( strFormations, (FormationT)cs.getInitialFormation(), iNr ); // read formations file WorldModel wm( &ss, &cs, &fs ); // create worldmodel Connection c( strHost, iPort, MAX_MSG ); // make connection with server ActHandler a( &c, &wm, &ss ); // link actHandler and WM SenseHandler s( &c, &wm, &ss, &cs ); // link senseHandler with wm bool isTrainer = (iPort == ss.getCoachPort()) ? true : false; BasicCoach bp( &a, &wm, &ss, strTeamName, dVersion, isTrainer ); // link acthandler and WM #ifdef WIN32 DWORD id1; sense = CreateThread(NULL, 0, &sense_callback, &s, 0, &id1); if (sense == NULL) { cerr << "create thread error" << endl; return false; } #else pthread_create( &sense, NULL, sense_callback , &s); // start listening #endif if( iMode > 0 && iMode < 9 ) // only listen to sdtdin when not playing #ifdef WIN32 { DWORD id2; listen = CreateThread(NULL, 0, &stdin_callback, &bp, 0, &id2); if ( listen == NULL) { cerr << "create thread error" << endl; return false; } } #else pthread_create( &listen, NULL, stdin_callback, &bp); #endif if( iMode == 0 ) bp.mainLoopNormal(); c.disconnect(); os.close(); }
// The start of the Application int App::start(const std::vector<CL_String> &args) { quit = false; CL_OpenGLWindowDescription desc; desc.set_title("ClanLib Light Surface Example"); desc.set_size(CL_Size(900, 700), true); desc.set_multisampling(4); desc.set_allow_resize(true); desc.set_depth_size(16); CL_DisplayWindow window(desc); // Connect the Window close event CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close); // Connect a keyboard handler to on_key_up() CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up); // Set up GUI CL_String theme; if (CL_FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css")) theme = "../../../Resources/GUIThemeAero"; else if (CL_FileHelp::file_exists("../../../Resources/GUIThemeBasic/theme.css")) theme = "../../../Resources/GUIThemeBasic"; else throw CL_Exception("No themes found"); CL_GUIWindowManagerTexture wm(window); CL_GUIManager gui(wm, theme); // Get the graphic context CL_GraphicContext gc = window.get_gc(); // Deleted automatically by the GUI Options *options = new Options(gui, CL_Rect(8, 8, CL_Size(340, 600))); options->request_repaint(); // Setup graphic store GraphicStore graphic_store(gc); scene.gs = &graphic_store; // Prepare the display gc.set_map_mode(cl_user_projection); CL_PolygonRasterizer polygon_rasterizer; polygon_rasterizer.set_culled(true); polygon_rasterizer.set_face_cull_mode(cl_cull_back); polygon_rasterizer.set_front_face(cl_face_side_clockwise); gc.set_polygon_rasterizer(polygon_rasterizer); create_scene(gc); CL_Font font(gc, "tahoma", 24); graphic_store.image_grid = CL_Image(gc, "../../Display_Render/Blend/Resources/grid.png"); FramerateCounter framerate_counter; unsigned int time_last = CL_System::get_time(); // Run until someone presses escape while (!quit) { framerate_counter.frame_shown(); unsigned int time_now = CL_System::get_time(); time_delta = time_now - time_last; time_last = time_now; // Copy direction options light_distant->rotation_y = options->light_direction_heading; light_distant->rotation_x = options->light_direction_pitch; // Set material options float shininess = options->material_shininess; // Convert shininess from a percentage, using Lightwave 3d's method shininess = shininess / 100.0f; shininess = pow(2, (10.0f * shininess) + 2); teapot->model.SetMaterial( shininess, // material_shininess CL_Vec4f(options->material_emission_color.r, options->material_emission_color.g, options->material_emission_color.b, options->material_emission_color.a), // material_emission CL_Vec4f(options->material_ambient_color.r, options->material_ambient_color.g, options->material_ambient_color.b, options->material_ambient_color.a), // material_ambient CL_Vec4f(options->material_specular_color.r, options->material_specular_color.g, options->material_specular_color.b, options->material_specular_color.a) //material_specular ); rotate_teapot(); calculate_matricies(gc); update_light(gc, options); polygon_rasterizer.set_culled(true); gc.set_polygon_rasterizer(polygon_rasterizer); render(gc); gc.set_modelview(CL_Mat4f::identity()); gc.set_map_mode(cl_map_2d_upper_left); polygon_rasterizer.set_culled(false); gc.set_polygon_rasterizer(polygon_rasterizer); CL_String fps(cl_format("%1 fps", framerate_counter.get_framerate())); font.draw_text(gc, 16-2, gc.get_height()-16-2, fps, CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f)); font.draw_text(gc, 16, gc.get_height()-16-2, fps, CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); wm.process(); wm.draw_windows(gc); // Use flip(1) to lock the fps window.flip(0); // This call processes user input and other events CL_KeepAlive::process(); } return 0; }
// The start of the Application int App::start(const std::vector<std::string> &args) { clan::DisplayWindowDescription win_desc; //win_desc.set_version(3, 2, false); win_desc.set_allow_resize(true); win_desc.set_title("Point Sprite Example"); win_desc.set_size(clan::Size( 800, 480 ), false); clan::DisplayWindow window(win_desc); clan::SlotContainer cc; cc.connect(window.sig_window_close(), clan::bind_member(this, &App::on_window_close)); cc.connect(window.get_ic().get_keyboard().sig_key_up(), clan::bind_member(this, &App::on_input_up)); std::string theme; if (clan::FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css")) theme = "../../../Resources/GUIThemeAero"; else if (clan::FileHelp::file_exists("../../../Resources/GUIThemeBasic/theme.css")) theme = "../../../Resources/GUIThemeBasic"; else throw clan::Exception("No themes found"); clan::GUIWindowManagerTexture wm(window); clan::GUIManager gui(wm, theme); clan::Canvas canvas(window); // Deleted automatically by the GUI Options *options = new Options(gui, clan::Rect(0, 0, canvas.get_size())); clan::Image image_grid(canvas, "../Blend/Resources/grid.png"); clan::Texture2D texture_particle(canvas, "Resources/particle.png"); float grid_width = (float) image_grid.get_width(); float grid_height = (float) image_grid.get_height(); grid_space = (float) (image_grid.get_width()); setup_particles(); clan::ShaderObject vertex_shader(canvas, clan::shadertype_vertex, text_shader_vertex); if(!vertex_shader.compile()) { throw clan::Exception(clan::string_format("Unable to compile vertex shader object: %1", vertex_shader.get_info_log())); } clan::ShaderObject fragment_shader(canvas, clan::shadertype_fragment, text_shader_fragment); if(!fragment_shader.compile()) { throw clan::Exception(clan::string_format("Unable to compile fragment shader object: %1", fragment_shader.get_info_log())); } clan::ProgramObject program_object(canvas); program_object.attach(vertex_shader); program_object.attach(fragment_shader); program_object.bind_attribute_location(0, "InPosition"); program_object.bind_attribute_location(1, "InColor"); if (!program_object.link()) { throw clan::Exception(clan::string_format("Unable to link program object: %1", program_object.get_info_log())); } program_object.set_uniform1i("Texture0", 0); options->request_repaint(); clan::BlendStateDescription blend_state_desc; blend_state_desc.enable_blending(true); blend_state_desc.set_blend_function(clan::blend_src_alpha, clan::blend_one, clan::blend_src_alpha, clan::blend_one); clan::BlendState blend_state(canvas, blend_state_desc); clan::GameTime game_time; while (!quit) { game_time.update(); wm.process(); wm.draw_windows(canvas); int num_particles = options->num_particles; if (num_particles > max_particles) num_particles = max_particles; move_particles(game_time.get_time_elapsed(), num_particles); const float grid_xpos = 10.0f; const float grid_ypos = 10.0f; // Draw the grid image_grid.draw(canvas, grid_xpos, grid_ypos); if (num_particles > 0) { std::vector<clan::Vec2f> positions; std::vector<clan::Colorf> colors; positions.resize(num_particles); colors.resize(num_particles); for (int cnt=0; cnt<num_particles; cnt++) { positions[cnt] = clan::Vec2f(grid_xpos + particles[cnt].xpos, grid_ypos + particles[cnt].ypos); switch (cnt % 3) { case 0: colors[cnt] = clan::Colorf(1.0f, 0.0f, 0.0f, 1.0f); break; case 1: colors[cnt] = clan::Colorf(0.0f, 1.0f, 0.0f, 1.0f); break; case 2: colors[cnt] = clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f); break; } }; canvas.flush(); clan::GraphicContext gc = canvas.get_gc(); canvas.set_blend_state(blend_state); clan::RasterizerStateDescription raster_state_desc; raster_state_desc.set_point_size(options->point_size); raster_state_desc.set_point_sprite_origin(clan::origin_upper_left); clan::RasterizerState raster_state(canvas, raster_state_desc); canvas.set_rasterizer_state(raster_state); clan::PrimitivesArray primarray(gc); clan::VertexArrayVector<clan::Vec2f> gpu_positions = clan::VertexArrayVector<clan::Vec2f>(gc, &positions[0], positions.size()); clan::VertexArrayVector<clan::Colorf> gpu_colors = clan::VertexArrayVector<clan::Colorf>(gc, &colors[0], colors.size()); primarray.set_attributes(0, gpu_positions); primarray.set_attributes(1, gpu_colors); ProgramUniforms buffer; buffer.cl_ModelViewProjectionMatrix = canvas.get_projection() * canvas.get_modelview(); clan::UniformVector<ProgramUniforms> uniform_vector(gc, &buffer, 1); gc.set_uniform_buffer(0, uniform_vector); gc.set_texture(0, texture_particle); gc.set_program_object(program_object); gc.draw_primitives(clan::type_points, num_particles, primarray); gc.reset_program_object(); gc.reset_texture(0); gc.reset_blend_state(); gc.reset_rasterizer_state(); } window.flip(1); clan::KeepAlive::process(); } return 0; }
int RunGLTest (void) { #ifdef GL int mm=1; #else int mm = 0; #endif int mode=0; cam.x=0; cam.y=0; int bpp; int w = 200; int h = 200; int done = 0; int shrink=0; int grow=0; int gofullscreen=0; int mustresize = 1; int justresized = 0; xy ss = parsemodes(w,h,"mode",1,0,0); printf("wtf\n"); if (ss.x!=-1){w=ss.x;h=ss.y;}; SDL_Surface* s; #ifdef GL s=initsdl(w,h,&bpp,SDL_OPENGL #else gltextsdlsurface=s=initsdl(w,h,&bpp, #endif +0);printf("inito\n"); SDL_InitSubSystem( SDL_INIT_TIMER); SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY/2, SDL_DEFAULT_REPEAT_INTERVAL*2); #ifdef GL newtermmsg=GetFileIntoCharPointer1("newtermmsg"); printf("pretty far\n"); wm(w,h); int down=0; glEnable(GL_BLEND); glShadeModel(GL_FLAT); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glClearColor( 0.0, 0.0, 0.04, 0.0 ); glLineWidth(lv); #else gltextsdlsurface=s; #endif roteface *face1; roteface *activeface; face1=add_face(); activeface =face1 ; face1->next=add_face(); printf("still?\n"); add_terminal(face1); printf("2threaad\n"); loadl2(); struct state *nerv=0; #ifdef nerve nerv=nerverot_init(w,h); #endif int dirty=1; printf("mainloop descent commencing\n"); while( !done ) { lockterms(face1); if(dirty||faces_dirty(face1)) { dirty=0; facesclean(face1); #ifdef GL glClear(GL_COLOR_BUFFER_BIT); #else SDL_FillRect ( s, NULL, 0 ); #endif #ifndef GL #else if(nerv) { shownerv(nerv); dirty=1; } glPushMatrix(); glScalef(sx,sy,0.004); glTranslatef(cam.x,cam.y,0); #endif Uint8 * k; int integer; k=SDL_GetKeyState(&integer); if(k[SDLK_RCTRL]) focusline(activeface); int nf; switch(mode) { case 0: showfaces(face1); break; #ifdef GL case 1: krychlus(face1); break; #endif } #ifdef GL glPopMatrix(); #endif #ifndef GL SDL_UpdateRect(s,0,0,0,0); #else SDL_GL_SwapBuffers( ); #endif facesclean(face1); } #ifdef GL GLenum gl_error; gl_error = glGetError( ); if( gl_error != GL_NO_ERROR ) { if(gl_error==GL_STACK_OVERFLOW) printf("QUACK QUACK QUACK, OVERFLOVING STACK\n"); else if(gl_error==GL_INVALID_OPERATION) printf("INVALID OPERATION, PATIENT EXPLODED\n"); else fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error ); } #endif char* sdl_error; sdl_error = SDL_GetError( ); if( sdl_error[0] != '\0' ) { fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error); SDL_ClearError(); } SDL_TimerID x=0; if(dirty) x= SDL_AddTimer(55, NewTimerCallback, 0); unlockterms(face1); // printf("---------unlocked wating\n"); SDL_Event event; if(SDL_WaitEvent( &event )) { lockterms(face1); // printf("---------locked goooin %i\n", event.type); if(x)SDL_RemoveTimer(x);x=0; do { int mod=event.key.keysym.mod; int key=event.key.keysym.sym; Uint8 *keystate = SDL_GetKeyState(NULL); switch( event.type ) { #ifdef GL case SDL_MOUSEMOTION: if((SDL_BUTTON(1)|SDL_BUTTON(2))&SDL_GetMouseState(0,0)) { activeface->x+=event.motion.xrel; activeface->y+=event.motion.yrel; } if((SDL_BUTTON(3)|SDL_BUTTON(2))&SDL_GetMouseState(0,0)) { cam.x-=event.motion.xrel; cam.y-=event.motion.yrel; } break; #endif case SDL_KEYUP: { if ( (key == SDLK_RCTRL) ) { dirty=1; } } break; case SDL_KEYDOWN: if(mod&KMOD_RSHIFT&&(key==SDLK_PAGEUP||key==SDLK_PAGEDOWN)) { if(key==SDLK_PAGEUP) tscroll+=9; if(key==SDLK_PAGEDOWN) tscroll-=9; if(tscroll<0)tscroll=0; // printf("scroll:%i,logl:%i, log&%i, t:%i ,b:%i\n", tscroll,activeface->t->logl, activeface->t->log,activeface->t->scrolltop,activeface->t->scrollbottom); } else if(key==SDLK_RCTRL||mod&KMOD_RCTRL) { dirty=1; switch (key) { case SDLK_TAB: cycle(face1, &activeface); break; case SDLK_F2: gofullscreen=1; break; case SDLK_F3: rastio+=0.05; mustresize=1; dirty=1; break; case SDLK_F4: rastio-=0.05; mustresize=1; dirty=1; break; case SDLK_F5: sx-=0.001; sy+=0.001; break; case SDLK_F6: sx+=0.001; sy-=0.001; break; case SDLK_F7: savemode(w,h); break; case SDLK_F8: loadl2(); break; case SDLK_p: saveScreenshot(); break; #ifdef GL case SDLK_F9: lv-=1; glLineWidth(lv); break; case SDLK_F10: lv+=1; glLineWidth(lv); break; #endif case SDLK_F11: shrink=1; break; case SDLK_F12: grow=1; break; case SDLK_PAGEUP: mode++; if(mode>mm)mode= mm; break; case SDLK_INSERT: mode--; if(mode<0)mode= 0; break; case SDLK_END: resizooo(activeface, 0,1,keystate); break; case SDLK_HOME: resizooo(activeface, 0,-1,keystate); break; case SDLK_DELETE: resizooo(activeface, -1,0,keystate); break; case SDLK_PAGEDOWN: resizooo(activeface, 1,0,keystate); break; #ifdef nerve case SDLK_F1: if(nerv) { nerverot_free(nerv); dirty=1; nerv=0; } else { nerv=nerverot_init(w,h); dirty=1; } break; #endif } } else { if(activeface->t==0) { printf("debug messages r fun\n"); add_terminal(activeface); activeface->next=add_face(); } if ( (key >= SDLK_F1) && (key <= SDLK_F15) ) { char *k; if(asprintf(&k ,"kf%i", key-SDLK_F1+1)!=-1) { rote_vt_terminfo(activeface->t, k); free(k); } } else if ( (key == SDLK_SPACE) ) keyp(activeface,32); else #define magic(x) rote_vt_terminfo(activeface->t, x ) if ( (key == SDLK_BACKSPACE) ) magic( "kbs"); else if ( (key == SDLK_ESCAPE) ) keyp(activeface,27); else if ( (key == SDLK_LEFT) ) magic("kcub1"); else if ( (key == SDLK_RIGHT) ) magic( "kcuf1"); else if ( (key == SDLK_UP) ) magic( "kcuu1"); else if ( (key == SDLK_DOWN) ) magic( "kcud1"); else if ( (key == SDLK_END) ) magic( "kend"); else if ( (key == SDLK_HOME) ) magic("khome"); else if ( (key == SDLK_DELETE) ) magic( "kdch1"); else if ( (key == SDLK_PAGEDOWN) ) magic( "knp"); else if ( (key == SDLK_INSERT) ) magic( "kich1"); else if ( (key == SDLK_PAGEUP) ) magic ( "kpp" ); else if ( (key == SDLK_RETURN) ) keyp(activeface,10); else if( event.key.keysym.unicode && ( (event.key.keysym.unicode & 0xFF80) == 0 ) ) keyp(activeface, event.key.keysym.unicode); } break; case SDL_QUIT: done = 1; break; #ifndef GL case SDL_MOUSEBUTTONDOWN: rote_vt_mousedown(activeface->t,event.button.x/13, event.button.y/26); break; case SDL_MOUSEBUTTONUP: rote_vt_mouseup (activeface->t,event.button.x/13, event.button.y/26); break; case SDL_MOUSEMOTION: rote_vt_mousemove(activeface->t,event.button.x/13, event.button.y/26); break; #endif case SDL_VIDEORESIZE: { w=event.resize.w;h=event.resize.h; // printf("videoresize %i %i\n", w,h); dirty=1; if (s=SDL_SetVideoMode( w,h, bpp, s->flags ) ) // printf("hmm\n"); wm(w,h); if(!justresized) mustresize=1; justresized=0; } break; case SDL_USEREVENT: if(event.user.code==1) RemoveTerm(&activeface,&face1, event.user.data1); break; } } while (SDL_PollEvent(&event)); if (shrink||grow) { resize(&w,&h,&bpp,&s->flags,&shrink,&grow); wm(w,h); } if (mustresize) { mustresize=0; justresized=1; // if(activeface->t->cols!=event.resize.w/13/rastio|| // activeface->t->rows!=event.resize.h/26/rastio) //rote_vt_resize(activeface->t,event.resize.h/26/rastio ,event.resize.w/13/rastio); } if(gofullscreen) if(s->flags & SDL_FULLSCREEN ) { s=SDL_SetVideoMode( w,h, bpp, (s->flags & ~SDL_FULLSCREEN )); } else s=SDL_SetVideoMode( w,h, bpp, (s->flags | SDL_FULLSCREEN )); gofullscreen=0; unlockterms(face1); } } SDL_Quit( ); return(0); }
MvcBook::MvcBook() { WndManager& wm(WndManager::current()); m_pViewListener.reset(new EvtListenerCurrentView(wm)); }