Пример #1
0
void OpenGLRenderer::init(){
	typedef std::pair<string,DynlibDescriptor> strDldPair; // necessary as FOREACH, being macro, cannot have the "," inside the argument (preprocessor does not parse templates)
	FOREACH(const strDldPair& item, Omega::instance().getDynlibsDescriptor()){
		// if (Omega::instance().isInheritingFrom_recursive(item.first,"GlStateFunctor")) stateFunctorNames.push_back(item.first);
		if (Omega::instance().isInheritingFrom_recursive(item.first,"GlBoundFunctor")) boundFunctorNames.push_back(item.first);
		if (Omega::instance().isInheritingFrom_recursive(item.first,"GlShapeFunctor")) shapeFunctorNames.push_back(item.first);
		if (Omega::instance().isInheritingFrom_recursive(item.first,"GlIGeomFunctor")) geomFunctorNames.push_back(item.first);
		if (Omega::instance().isInheritingFrom_recursive(item.first,"GlIPhysFunctor")) physFunctorNames.push_back(item.first);
	}
	initgl(); // creates functor objects in the proper sense

	clipPlaneNormals.resize(numClipPlanes);

	static bool glutInitDone=false;
	if(!glutInitDone){
		glutInit(&Omega::instance().origArgc,Omega::instance().origArgv);
		/* transparent spheres (still not working): glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_MULTISAMPLE | GLUT_ALPHA); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); */
		glutInitDone=true;
	}

	initDone=true;
	// glGetError crashes at some machines?! Was never really useful, anyway.
	// reported http://www.mail-archive.com/[email protected]/msg01482.html
	#if 0
		int e=glGetError();
		if(e!=GL_NO_ERROR) throw runtime_error((string("OpenGLRenderer::init returned GL error ")+boost::lexical_cast<string>(e)).c_str());
	#endif
}
Пример #2
0
Файл: 05.c Проект: manish05/TCR
int main (int argc, char* argv[]) {
  SDL_Event event;
  int active=1;
  fullscreen=0;
  sdlglinit(640,480,BPP,fullscreen);
  ourinit();
  while(1) {
    while(SDL_PollEvent(&event)) {
      switch(event.type) {
      case SDL_VIDEORESIZE:
        surface=SDL_SetVideoMode(event.resize.w,event.resize.h,BPP,videoflags);
        if(!surface) error("Couldn't get surface after resize: %s\n",SDL_GetError());
        initgl(); /* needed before resize to avoid every setting being reset, like
                    background colour, depth settings etc. the absence of this line causes
                    wrong depth stuff. */
        resizeglscene(event.resize.w,event.resize.h);
        break;
      case SDL_KEYDOWN:
        handlekeypress(&event.key.keysym);
        break;
      case SDL_QUIT:
        goto theend;
      }
    }
    if(active) drawglscene();
  }
theend:
  killglwindow();
  return 0;
}
Пример #3
0
/*
** Open a simple window using OpenWindowTagList()
*/
int main(int argc, char **argv)
{

    win = OpenWindowTags(0,
                WA_Title, (IPTR)"glAGetProcAddress",
                WA_CloseGadget, TRUE,
                WA_DragBar, TRUE,
                WA_DepthGadget, TRUE,
                WA_Left, 10,
                WA_Top, 10,
                WA_InnerWidth, 300,
                WA_InnerHeight, 300,
                WA_Activate, TRUE,
                WA_RMBTrap, TRUE,
                WA_SimpleRefresh, TRUE,
                WA_NoCareRefresh, TRUE,
                WA_IDCMP, IDCMP_CLOSEWINDOW,
                TAG_DONE);

    initgl();

    testextensions();

    deinitgl();

    CloseWindow(win);

    return 0;
}
Пример #4
0
Файл: 07.c Проект: manish05/TCR
int main (int argc, char* argv[]) {
  SDL_Event event;
  int active=1;
  fullscreen=0;
  sdlglinit(640,480,BPP,fullscreen);
  ourinit();
  while(1) {
    while(SDL_PollEvent(&event)) {
      switch(event.type) {
      case SDL_VIDEORESIZE:
        surface=SDL_SetVideoMode(event.resize.w,event.resize.h,BPP,videoflags);
        if(!surface) error("Couldn't get surface after resize: %s\n",SDL_GetError());
        initgl(); /* after setting video mode, we lost every gl setting. set again. */
        resizeglscene(event.resize.w,event.resize.h);
        break;
      case SDL_KEYDOWN:
        keys[event.key.keysym.sym]=1;
        handlekeypress(&event.key.keysym);
        break;
      case SDL_KEYUP:
        keys[event.key.keysym.sym]=0;
        break;
      case SDL_QUIT:
        goto theend;
      }
    }
    /* check for held keys */
    heldkeys();
    if(active) drawglscene();
  }
theend:
  killglwindow();
  return 0;
}
Пример #5
0
Background :: Background() {
	// Check constants.h for BACKGROUND
	ih = new ImageHandler(BACKGROUND, BSPOT_BKGD);

	ih->parseStrip(0, 0, ih->getSheetWidth(), ih->getSheetHeight(), 1, 1, 0, 0);
	initgl();
}
Пример #6
0
void DrawAbstract::deprectedAbstractInit(int first_frame, int videoduration,int sw,int sh, std::string storagedirectory){
		screen_width = sw;
		screen_height = sh;
		this->videoduration = first_frame + videoduration;
		this->storagedirectory = storagedirectory;
		processedframe = first_frame;

		mTextureIDs = new GLuint[videoduration];
		initgl();
}
Пример #7
0
int main (int argc, char** argv) {
        glutInit (&argc, argv);
        glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
        glutInitWindowSize (500, 500);
        glutInitWindowPosition (100, 100);
        glutCreateWindow ("Exercise 02561-01 Part 8");
        initgl ();
        glutDisplayFunc (display);
        glutReshapeFunc (reshape);
        glutMainLoop ();
        return 0;
}
Пример #8
0
static gboolean
draw(GtkWidget *widget,
     cairo_t   *cr,
     gpointer   data)
{
  GdkGLContext *glcontext = gtk_widget_get_gl_context(widget);
  GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);

  GLfloat m[4][4];
  mesh_info *info = (mesh_info*)g_object_get_data(G_OBJECT(widget), "mesh_info");

  /*** OpenGL BEGIN ***/
  if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
    goto NO_GL;

  /* basic initialization */
  if (info->do_init == TRUE) {
    initgl();
    info->do_init = FALSE;
  }

  /* view */
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(info->zoom, VIEW_ASPECT, 1,100);
  glMatrixMode(GL_MODELVIEW);

  /* draw object */
  glClearColor(.3,.4,.6,1);
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

  glLoadIdentity();
  glTranslatef(0,0,-30);
  add_quats(info->dquat, info->quat, info->quat);
  build_rotmatrix(m,info->quat);
  glMultMatrixf(&m[0][0]);

  lw_object_show(info->lwobject);

  /* swap backbuffer to front */
  if (gdk_gl_drawable_is_double_buffered(gldrawable))
    gdk_gl_drawable_swap_buffers(gldrawable);
  else
    glFlush();

  gdk_gl_drawable_gl_end(gldrawable);
  /*** OpenGL END ***/

 NO_GL:

  return TRUE;
}
Пример #9
0
void inits()
{
    // Init GLFW
    initgl();
#ifdef RAWMOUSE
    std::cout << "mouseinit = " << ManyMouse_Init() << std::endl;
#endif
    cfg.init("crashforce.cfg");
    cfg.SET(lag_coeff);
    if (cfg.getint("wireframe"))
    {
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    }
}
void plotMain(int argc, char ** argv, unsigned char * dataSet, int imageWidth, int imageHeight, int imageDepth)
{
    glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(1000, 1000);
	glutInitWindowPosition (0, 0);
	glutCreateWindow("Data Visualiser");
    
    initgl(dataSet, imageWidth, imageHeight, imageDepth);
    
    glutMouseFunc(&MouseClick);
    glutKeyboardFunc(input);
	glutDisplayFunc(DisplayGL);
	//glutIdleFunc(Update);
	glutMainLoop();
}
/* main program - setup window using GLUT */ 
int main(int argc, char **argv)
{
	
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);						// Hidden surface removal renders the scene such that the nearest surface rendered to the viewer is seen as the closest visible surface. By using a depth buffer, each rendered pixel in the depth buffer stores the distance to the previously rendered surface. Depending on the depth mode used, i.e. LESS for instance, if the new surface is closer to the view then the value of thedepth pixel is replaced otherwise is discarded and not rendered.
    glutInitWindowSize(1000, 500);
    glutCreateWindow("3D Maze Game");
    glutDisplayFunc(display);
    initgl();
	glutKeyboardFunc(keyboard_interaction);	
	glutKeyboardUpFunc(keyboard_up);
	glutMouseFunc(SpecialKeyStrokes);
	glutTimerFunc(17, timer, 0); //Add a timer
	glutMainLoop();
    return  0;
	
}
// setup the GLUT library which handles the windows for us
int setupGLUT(int *argc, char *argv[])
{
    glutInit(argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);

    int winid = glutCreateWindow("IOV UI Test");

    initgl();
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);
    glutSpecialFunc(keyboard_special);

    return winid;
}
Пример #13
0
static gboolean
draw(GtkWidget *widget,
     cairo_t   *cr,
     gpointer   data)
{
  GLfloat m[4][4];
  mesh_info *info = (mesh_info*)g_object_get_data(G_OBJECT(widget), "mesh_info");

  /*** OpenGL BEGIN ***/
  if (!gtk_widget_begin_gl (widget))
    goto NO_GL;

  /* basic initialization */
  if (info->do_init == TRUE) {
    initgl();
    info->do_init = FALSE;
  }

  /* view */
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(info->zoom, VIEW_ASPECT, 1,100);
  glMatrixMode(GL_MODELVIEW);

  /* draw object */
  glClearColor(.3,.4,.6,1);
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

  glLoadIdentity();
  glTranslatef(0,0,-30);
  add_quats(info->dquat, info->quat, info->quat);
  build_rotmatrix(m,info->quat);
  glMultMatrixf(&m[0][0]);

  lw_object_show(info->lwobject);

  gtk_widget_end_gl(widget, TRUE);
  /*** OpenGL END ***/

 NO_GL:

  return TRUE;
}
Пример #14
0
Файл: 07.c Проект: manish05/TCR
int sdlglinit(int w,int h,int bpp,int fullscreen) {
  const SDL_VideoInfo *info;
  if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER)<0) error("Video initialization failed: %s\n",SDL_GetError());
  info=SDL_GetVideoInfo();
  if(!info) error("Video query failed: %s\n",SDL_GetError());
  videoflags=SDL_OPENGL                               /* enable opengl in sdl */
    |SDL_GL_DOUBLEBUFFER                              /* enable double buffering */
    |SDL_HWPALETTE                                    /* store the palette in hardware */
    |SDL_RESIZABLE;                                   /* enable windows resizing */
  if(fullscreen) videoflags|=SDL_FULLSCREEN;
  if(info->hw_available) videoflags|=SDL_HWSURFACE;   /* check if we can store surfaces in memory */
  else videoflags|=SDL_SWSURFACE;
  if(info->blit_hw) videoflags|=SDL_HWACCEL;          /* check if hardware blits can be done */
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);         /* set up double buffering */
  surface=SDL_SetVideoMode(w,h,bpp,videoflags);
  if(!surface) error("Video mode set failed: %s\n",SDL_GetError());
  if(!initgl()) error("Couldn't initialize opengl.\n");
  resizeglscene(w,h);
  return 1;
}
Пример #15
0
void OpenGLRenderer::init(){
	typedef std::pair<string,DynlibDescriptor> strDldPair; // necessary as FOREACH, being macro, cannot have the "," inside the argument (preprocessor does not parse templates)
	FOREACH(const strDldPair& item, Omega::instance().getDynlibsDescriptor()){
		// if (Omega::instance().isInheritingFrom_recursive(item.first,"GlStateFunctor")) stateFunctorNames.push_back(item.first);
		if (Omega::instance().isInheritingFrom_recursive(item.first,"GlBoundFunctor")) boundFunctorNames.push_back(item.first);
		if (Omega::instance().isInheritingFrom_recursive(item.first,"GlShapeFunctor")) shapeFunctorNames.push_back(item.first);
		if (Omega::instance().isInheritingFrom_recursive(item.first,"GlIGeomFunctor")) geomFunctorNames.push_back(item.first);
		if (Omega::instance().isInheritingFrom_recursive(item.first,"GlIPhysFunctor")) physFunctorNames.push_back(item.first);
	}
	initgl(); // creates functor objects in the proper sense

	clipPlaneNormals.resize(numClipPlanes);

	static bool glutInitDone=false;
	if(!glutInitDone){
		glutInit(&Omega::instance().origArgc,Omega::instance().origArgv);
		/* transparent spheres (still not working): glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_MULTISAMPLE | GLUT_ALPHA); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); */
		glutInitDone=true;
	}

	initDone=true;
}
Пример #16
0
int main(int argc, char * argv[])
{
    srand(time(0));
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
    glutInitWindowSize(480, 272);
    glutInitWindowPosition(0, 0);
    wnd = glutCreateWindow("MasterPiece 3D");
    glutDisplayFunc(&render);
    //glutFullScreen();
    glutIdleFunc(&render);
    glutReshapeFunc(&resize);
    glutKeyboardFunc(&keydown);
    glutSpecialFunc(&specialkey);
    initgl(640, 480);
    releaseblock();
#ifdef FOR_PSP
   	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);	
#endif
    glutMainLoop();
    return (0);
}
Пример #17
0
int main(int argc, char *argv[])
{
    int mode = SDL_HWSURFACE | SDL_HWACCEL |
        SDL_DOUBLEBUF | SDL_OPENGL;

    if (argc >= 2 && (! strcmp(argv[1], "-h") ||
                      ! strcmp(argv[1], "--help"))) {
        printf("Uso: %s [-fs] resolucao-x resolucao-y\n\n"
               "Exemplo: ./walker 1024 768\n\n"
               "Para mais informacoes, leia o README.\n",
               argv[0]);
        exit(0);
    }

    int shift = 1;
    if (argc >= 2 && ! strcmp(argv[1], "-fs")) {
        mode |= SDL_FULLSCREEN;
        res_x = 1360;
        res_y = 768;
        shift++;
    }
    if (argc >= 3) {
        res_x = atoi(argv[shift]);
        res_y = atoi(argv[shift+1]);
    }

    init_event_keys();

    glutInit(&argc, argv);
    initsdl(mode);
    initgl();

    carregar_texturas();

    SDL_Event ev;

    while (1)
        if (! SDL_PollEvent(&ev)
            || ev.type == SDL_MOUSEMOTION)
            break;
        else
            event_handler(ev);

    uint64_t old_time, new_time;
    uint64_t old_border, new_border;
    old_time = time_get();
    old_border = time_in_secs(old_time);

    float dt = 0;
    int count = 0;

    while (1) {
        while (SDL_PollEvent(&ev))
            event_handler(ev);

        new_time = time_get();
        new_border = time_in_secs(new_time);

        dt = time_diff(new_time, old_time);

        if (new_border > old_border) {
            update_fps_str(count);
            old_border = new_border;
            count = 0;
        }

        old_time = new_time;
        count++;

        update_status_str();

        toggle();
        model(dt);
        physics(dt);
        update_map_pos();
        draw();
    }
}
Пример #18
0
int main(int argc, char *argv[])
{
  glfwSetErrorCallback(err);
  if (!glfwInit()) {
  exit(1);
  }

  /* create the window and its associated OpenGL context */
  wd = glfwCreateWindow(width, height, "Whoot 2",
            NULL, NULL);
  if (!wd) {
  glfwTerminate();
  exit(1);
  }
  /* make the window's context the current context */
  glfwMakeContextCurrent(wd);
  GLenum err = glewInit();
  if (GLEW_OK != err)
  {
  std::cout << "glewInit failed!" << std::endl;
  std::cout << glewGetErrorString(err) << std::endl;
  }
  glfwGetFramebufferSize(wd, &fbwidth, &fbheight);

  /* shape view port */
  fbreshape(wd, fbwidth, fbheight);
  
  /* --- register callbacks with GLFW --- */

  /* register function to handle window resizes */
  glfwSetFramebufferSizeCallback(wd, fbreshape);
  glfwSetWindowSizeCallback(wd, reshape);

  /* register function to handle window close */
  glfwSetWindowCloseCallback(wd, quit);

  /* register function to handle keyboard input */
  glfwSetKeyCallback(wd, kbd);      // general keyboard input
  glfwSetCharCallback(wd, charhd);  // simpler specific character handling

  initgl();
  
  FullScreenPass myFSP = FullScreenPass();
  ParticlePass myPP = ParticlePass(10000);

  typedef std::chrono::high_resolution_clock Clock;
  typedef std::chrono::milliseconds milliseconds;

  Clock::time_point currentTime, newTime;
  milliseconds frameTime;

  do {
    currentTime = Clock::now();
    
    /* color buffer must be cleared each time */
    glClear(GL_COLOR_BUFFER_BIT);
    myFSP.draw();
    myPP.draw();
    
    /* GLFW is ALWAYS double buffered; will call glFlush() */
    glfwSwapBuffers(wd);
    
    glfwPollEvents();

    newTime = Clock::now();
    frameTime = std::chrono::duration_cast<milliseconds>(newTime - currentTime);
    if(frameTime.count() < 16)
    {
      std::this_thread::sleep_for(milliseconds(16 - frameTime.count()));
    }
              
  } while (!glfwWindowShouldClose(wd));

  exit(0);
}