Exemple #1
0
int init_resources(void) {

	InitProgram();
	InitCamera();
	InitWriter();

	InitWell();

	return 1;
}
Exemple #2
0
void CompProg( void )
{
    bool        tbreak;

    InitProgram();
    tbreak = CompFile();
    if( tbreak ) {
        Error( KO_INTERRUPT );
    }
    FiniProgram();
}
Exemple #3
0
void Graphics::renderGlowTexture() {
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(-1,1,-1,1,0.5,5);
    
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    gluLookAt(0.0,0.0,1.0,
              0.0,0.0,0.0,
              0.0,1.0,0.0);
    
    if(glowShader == NULL) {
        World &world = World::getInstance();
        glowShader = InitProgram(
            (world.assetsDir + "shaders/glow.vert").c_str(),
            (world.assetsDir + "shaders/glow.frag").c_str()
        );
    }
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, glowTexId);
    int glowLoc = UniformLocation(glowShader,"glowTexture");
    glUniform1i(glowLoc,0);

    glClear(GL_DEPTH_BUFFER_BIT);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);

    glDisable(GL_LIGHTING);
    glColor3f(1.0,1.0,1.0);
    UseProgram(glowShader);       

    glBegin(GL_QUADS);
      glTexCoord2f(0,0);
      glVertex3f(-1,-1,0);
      glTexCoord2f(1,0);
      glVertex3f(1,-1,0);
      glTexCoord2f(1,1);
      glVertex3f(1,1,0);
      glTexCoord2f(0,1);
      glVertex3f(-1,1,0);
    glEnd();

    UseProgram(0);
    glDisable(GL_BLEND);
    glEnable(GL_LIGHTING);

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
}
Exemple #4
0
int main(int argc, char **argv) {
   char randword[DEF_MAX_WORD_LENGTH + 1];
   int randlen;
   short i, stop = 0;

   /* Parse the command line arguments */
   parseArgs(argc, argv);

   /* Seed the random number generator */
   srand(time(NULL));

   /* If something goes wrong in init, it'll take care of itself */
   InitProgram();

   /* Register exit function */
   signal(SIGINT, SigHandler);
   atexit(ExitProgram);

   /* Start generate strings */
   while (!stop) {
      randlen = rand() % (maxWordLength - minWordLength + 1) + minWordLength;

      for (i = 0; i < randlen; i++)
         randword[i] = (unsigned char)(rand() % 26 + 97);

      randword[randlen] = '\0';

      totalcount++;
      
      if (CheckWord(randword, randlen)) {
         numfound++;

         printf("%s", randword);
         if (verbose)
            printf(" *");
         printf("%s", ENDL);

         if (stopAfterLength && randlen == xLength)
            stop = 1;
      }
      else if (verbose)
         printf("%s%s", randword, ENDL);

      if (stopAfterWord && strcmp(xWord, randword) == 0)
         stop = 1;

      if (stopAfterHits && numfound == xHits)
         stop = 1;
   }
   
   return 0;
}
Exemple #5
0
// The constructor does all heavy work, errors are returned as exceptions
Routine::Routine(Queue &queue, EventPointer event, const std::string &name,
                 const std::vector<std::string> &kernel_names, const Precision precision,
                 const std::vector<database::DatabaseEntry> &userDatabase,
                 std::initializer_list<const char *> source):
    precision_(precision),
    routine_name_(name),
    kernel_names_(kernel_names),
    queue_(queue),
    event_(event),
    context_(queue_.GetContext()),
    device_(queue_.GetDevice()),
    db_(kernel_names) {

  InitDatabase(device_, kernel_names, precision, userDatabase, db_);
  InitProgram(source);
}
Exemple #6
0
int RunProgram(po::variables_map& options)
{
    if(!InitProgram())
        return 1;
    if(!InitDirectories())
        return 1;

    // Zufallsgenerator initialisieren (Achtung: nur für Animations-Offsets interessant, für alles andere (spielentscheidende) wird unser Generator verwendet)
    srand(static_cast<unsigned int>(std::time(NULL)));

    // Exit-Handler initialisieren
    atexit(&ExitHandler);

    try{
        if(!InitGame())
            return 2;

        if(options.count("map"))
            QuickStartGame(options["map"].as<std::string>());

        // Hauptschleife
        while(GAMEMANAGER.Run())
        {
#ifndef _WIN32
            extern bool killme;
            killme = false;
#endif // !_WIN32
        }

        // Spiel beenden
        GAMEMANAGER.Stop();
        libsiedler2::setAllocator(NULL);
    } catch(RTTR_AssertError& error)
    {
        // Write to log file, but don't throw any errors if this fails too
        try{
            LOG.write(error.what());
        } catch(...){} //-V565
        return 42;
    }
    return 0;
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
        LPSTR lpCmdLine, int nCmdShow )
{
    MSG  msg ;

    InitCommonControls();
    InitProgram (hInstance);
    init_combo_list();
    init_info();

    edit_info_append (">>Ready.\n");

    if (auto_con) 
        on_button_connect_clicked();

    while(GetMessage(&msg, NULL, 0, 0)) {
        if(IsDialogMessage(hwndDlg, &msg))
            continue;
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return (int) msg.wParam;
}
Exemple #8
0
int radium_main(char *arg){
  struct Tracker_Windows *window;

#if 0
  // Seems to be some kind of problem when running givertcap? Try to uncomment and
  // see if you can start radium without segfaulting. I can't. -Kjetil.
  system("/usr/bin/givertcap");
#endif

  x11_display=XOpenDisplay(NULL);
  if(x11_display==NULL){
    fprintf(stderr, "Unable to open display \"%s\"\n",XDisplayName(NULL));
    return 1;
  }

  XSetIOErrorHandler (MySysErrorHandler);

  x11_screen=DefaultScreen(x11_display);

  printf("arg: -%s-\n",arg);
  printf("Width/Height: %d/%d\n",DisplayWidth(x11_display,x11_screen),DisplayHeight(x11_display,x11_screen));

  X11_init_keyboard();

  X11_StartBlockSelector();
  X11_StartMidiProperties();

  StartGuiThread();
  posix_InitPlayer();

  if(InitProgram()==true){

    /* Here: More inits, receive events, other things. */
    bool notend=true;

    printf("Inited\n");

    XFlush(x11_display);

    //    DrawUpTrackerWindow(root->song->tracker_windows);
    //XFlush(x11_display);

    window=root->song->tracker_windows;

    //GFX_StartFileRequester();
    X11_StartQtStuff();

    BS_UpdateBlockList();
    BS_UpdatePlayList();
    BS_SelectBlock(root->song->blocks);
    BS_SelectPlaylistPos(0);
      

    if(strlen(arg)>0)
      Load(arg);

    lockGUI();

    while(notend==true){
      int fd;
      fd_set fdset;


      XFlush(x11_display);

      fd=ConnectionNumber(x11_display);
      FD_ZERO(&fdset);
      FD_SET(fd,&fdset);

      unlockGUI();

      while((fd=select(fd+1,&fdset,NULL,NULL,NULL)==-1)){
	if(errno!=EINTR)
	  break;
      }

      lockGUI();

      while(XPending(x11_display)) {
	XEvent event;
	XNextEvent(x11_display, &event);

	//XNextEvent (x11_display, &event);

	window=root->song->tracker_windows;

	//P2MUpdateSongPosCallBack();
	
	switch(event.type){
	case KeyPress:
	  if(X11_KeyPress((XKeyEvent *)&event,window)==1){
	    notend=false;
	  }
	  break;
	case KeyRelease:
	  X11_KeyRelease((XKeyEvent *)&event,window);
	  break;
	case ButtonPress:
	  //printf("%d %d %d\n",((XButtonEvent *)&event)->x,((XButtonEvent *)&event)->y,((XButtonEvent *)&event)->button);
	  switch(((XButtonEvent *)&event)->button){
	  case 1:
	    tevent.ID=TR_LEFTMOUSEDOWN;
	    break;
	  case 2:
	    tevent.ID=TR_MIDDLEMOUSEDOWN;
	    break;
	  case 3:
	    tevent.ID=TR_RIGHTMOUSEDOWN;
	    break;
	  case 4:
	    tevent.ID=TR_KEYBOARD;
	    tevent.SubID=EVENT_UPARROW;
	    break;
	  case 5:
	    tevent.ID=TR_KEYBOARD;
	    tevent.SubID=EVENT_DOWNARROW;
	    break;
	  default:
	    tevent.ID=TR_LEFTMOUSEDOWN;
	  }
	  tevent.x=((XButtonEvent *)&event)->x;
	  tevent.y=((XButtonEvent *)&event)->y;
	  EventReciever(&tevent,window);
	  break;
	case ButtonRelease:
	  //printf("%d %d %d\n",((XButtonEvent *)&event)->x,((XButtonEvent *)&event)->y,((XButtonEvent *)&event)->button);
	  switch(((XButtonEvent *)&event)->button){
	  case 1:
	    tevent.ID=TR_LEFTMOUSEUP;
	    break;
	  case 2:
	    tevent.ID=TR_MIDDLEMOUSEUP;
	    break;
	  case 3:
	    tevent.ID=TR_RIGHTMOUSEUP;
	    break;
	  default:
	    tevent.ID=TR_LEFTMOUSEUP;
	  }
	  tevent.x=((XButtonEvent *)&event)->x;
	  tevent.y=((XButtonEvent *)&event)->y;
	  EventReciever(&tevent,window);
	  break;
	case EnterNotify:
	case LeaveNotify:
	  X11_ResetKeysUpDowns();
	  break;
	case MotionNotify:
	  //	printf("%d %d %d\n",((XMotionEvent *)&event)->x,((XMotionEvent *)&event)->y,((XMotionEvent *)&event)->state);
	  tevent.ID=TR_MOUSEMOVE;
	  tevent.x=((XButtonEvent *)&event)->x;
	  tevent.y=((XButtonEvent *)&event)->y;
	  EventReciever(&tevent,window);
	  break;
	  //case VisibilityNotify:
	  // case ConfigureNotify:
	case ConfigureNotify:
	  if(
	     window->width!=((XConfigureEvent *)&event)->width
	     ||	window->height!=((XConfigureEvent *)&event)->height
	     )
	    {
#if 0	   
	      fprintf(stderr,"Resized %d %d\n",
		      ((XConfigureEvent *)&event)->width,
		      ((XConfigureEvent *)&event)->height
		      );
#endif    
	      XFreePixmap(
			  x11_display,
			  window->os_visual->pixmap
			  );
	      XFreePixmap(
			  x11_display,
			  window->os_visual->cursorpixmap
			  );
	      window->os_visual->pixmap=XCreatePixmap(x11_display,
						      window->os_visual->window,
						      ((XConfigureEvent *)&event)->width,
						      ((XConfigureEvent *)&event)->height,
						      (unsigned int)(DefaultDepth(x11_display,x11_screen))
						      );
	      XFillRectangle(
			     x11_display,
			     window->os_visual->pixmap,
			     window->os_visual->gcs[0],
			     0, 0, ((XConfigureEvent *)&event)->width,((XConfigureEvent *)&event)->height
			     );
	      window->os_visual->cursorpixmap=XCreatePixmap(x11_display,
							    window->os_visual->window,
							    ((XConfigureEvent *)&event)->width,
							    ((XConfigureEvent *)&event)->height,
							    (unsigned int)(DefaultDepth(x11_display,x11_screen))
							    );
	      XFillRectangle(
			     x11_display,
			     window->os_visual->cursorpixmap,
			     window->os_visual->gcs[0],
			     0, 0, ((XConfigureEvent *)&event)->width, ((XConfigureEvent *)&event)->height
			     );
	      
	      Resize_resized(
			     window,
			     ((XConfigureEvent *)&event)->width-1,
			     ((XConfigureEvent *)&event)->height-1,
			     true
			     );
	    }
	  
	  break;
	case Expose:
	  printf("Expose\n");
	  //GFX_FilledBox(window,0,0,0,window->width,window->height);
	  //DrawUpTrackerWindow(root->song->tracker_windows);
	  Resize_resized(window,window->width,window->height,false);
	  //XFlush(x11_display);
	  
	  break;
	case NoExpose:
	  break;
	case GraphicsExpose:
	  printf("GRaphicsExpose event.\n");
	  break;
	case ClientMessage:
	  X11Event_ClientMessage((XClientMessageEvent *)&event,window);
	  //	printf("Received \"%s\"\n",((XClientMessageEvent *)&event)->data.b);	
	  break;
	default:
	  printf("Unknown xevent %d\n",event.type);
	  break;
	}
      }
    }

    EndProgram();
  }

  posix_EndPlayer();
  unlockGUI();
  EndGuiThread();

  XCloseDisplay(x11_display);

  return 0;
}
		void Load()
		{
			InitBuffers();
			InitProgram();
		}