コード例 #1
0
ファイル: Init.cpp プロジェクト: rjsikarwar/XCSoar
void
OpenGL::SetupContext()
{
#if defined(HAVE_EGL) && defined(ANDROID)
  egl = EGLInit();
#endif

  texture_non_power_of_two = SupportsNonPowerOfTwoTextures();

#ifdef ANDROID
  native_view->SetTexturePowerOfTwo(texture_non_power_of_two);

  vertex_buffer_object = EnableVBO();
#endif

  frame_buffer_object = CheckFBO() && FBO::Initialise();
  if (frame_buffer_object) {
    render_buffer_depth_stencil = CheckDepthStencil();

    render_buffer_stencil = CheckStencil();
    if (!render_buffer_stencil)
      /* fall back to a packed depth+stencil format */
      render_buffer_stencil = render_buffer_depth_stencil;
  }

  glDisable(GL_DEPTH_TEST);
  glDisable(GL_DITHER);
  glDisable(GL_LIGHTING);

  glEnableClientState(GL_VERTEX_ARRAY);

  InitShapes();
}
コード例 #2
0
ファイル: house.c プロジェクト: Aretnorp/cs-2010f
/*-----------------------------------------------------------------------------
 *  Main Function
 *  Initiates the graphics buffer, creates the window
 *-----------------------------------------------------------------------------*/
int main( int argc, char *argv[] )
{
    /* Seed the random number generator */
    srand(time(0));

    /* Initialize the drawing environment */
    glutInit( &argc, argv );

    /* Initialize the display mode */
    glutInitDisplayMode ( GLUT_DOUBLE | GLUT_MULTISAMPLE );

    /* Create an application window of a certain size */
    glutInitWindowSize( 850, 450 );

    /* Create an application window on the screen */
    glutCreateWindow( "Assignment #3: 2D Transformations" );

    /* Register the function that does drawing */
    glutDisplayFunc( Draw );

    /* Create the Keyboard callback */
    glutKeyboardFunc( Keyboard );

    /* Create the Mouse callbacks */
    glutMouseFunc( Mouse ); 
    glutMotionFunc( MouseMove );

    /* Create the Reshape callback */
    glutReshapeFunc( Reshape );

    /* Enable GL Properties */
    glEnable(GL_MULTISAMPLE);

    /* Register Exit Handler */
    atexit(ClearMemory);

    /* Initialize the House Shapes */
    InitShapes( );

    /* Add the transform */
    tlLevel.root = NULL;
    tlSelectedTransforms.root = NULL;
    tlAvailableTransforms.root = NULL;

    /* Open the file */
    file = fopen("level.dat", "r");
    ReadLevel(file, currentLevelString);

    /* Turn over control to OpenGL */
    glutMainLoop();

    return( 0 );  /* NOTE: this is here only for ANSI requirements */
}
コード例 #3
0
ファイル: Init.cpp プロジェクト: lshachar/LK8000
void
OpenGL::SetupContext()
{
#if defined(HAVE_DYNAMIC_EGL)
  egl = EGLInit();
#endif

  texture_non_power_of_two = SupportsNonPowerOfTwoTextures();

#ifdef HAVE_OES_DRAW_TEXTURE
  oes_draw_texture = CheckOESDrawTexture();
#endif

#ifdef ANDROID
  native_view->SetTexturePowerOfTwo(texture_non_power_of_two);

  vertex_buffer_object = EnableVBO();
#endif

#ifdef HAVE_OES_MAPBUFFER
  mapbuffer = IsExtensionSupported("GL_OES_mapbuffer");
#endif

#ifdef HAVE_DYNAMIC_MAPBUFFER
  if (mapbuffer) {
    GLExt::map_buffer = (PFNGLMAPBUFFEROESPROC)
      eglGetProcAddress("glMapBufferOES");
    GLExt::unmap_buffer = (PFNGLUNMAPBUFFEROESPROC)
      eglGetProcAddress("glUnmapBufferOES");
    if (GLExt::map_buffer == nullptr || GLExt::unmap_buffer == nullptr)
      mapbuffer = false;
  }
#endif

#ifdef HAVE_DYNAMIC_MULTI_DRAW_ARRAYS
  if (IsExtensionSupported("GL_EXT_multi_draw_arrays")) {
    GLExt::multi_draw_arrays = (PFNGLMULTIDRAWARRAYSEXTPROC)
      dlsym(RTLD_DEFAULT, "glMultiDrawArraysEXT");
    GLExt::multi_draw_elements = (PFNGLMULTIDRAWELEMENTSEXTPROC)
      dlsym(RTLD_DEFAULT, "glMultiDrawElementsEXT");
  } else {
    GLExt::multi_draw_arrays = nullptr;
    GLExt::multi_draw_elements = nullptr;
  }
#endif

  frame_buffer_object = CheckFBO() && FBO::Initialise();
  if (frame_buffer_object) {
    render_buffer_depth_stencil = CheckDepthStencil();

    render_buffer_stencil = CheckStencil();
    if (!render_buffer_stencil)
      /* fall back to a packed depth+stencil format */
      render_buffer_stencil = render_buffer_depth_stencil;
  }

  GLfloat lineWidthRange[2] = {0.0f, 0.0f};
  glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, lineWidthRange);
  max_line_width = lineWidthRange[1];

  glDisable(GL_DEPTH_TEST);
  glDisable(GL_DITHER);
#ifndef HAVE_GLES2
  glDisable(GL_LIGHTING);
#endif

#ifndef USE_GLSL
  glEnableClientState(GL_VERTEX_ARRAY);
#endif

  InitShapes();

#ifdef USE_GLSL
  InitShaders();
#endif

#ifndef HAVE_GLES
  ::glGetIntegerv(GL_MAX_ATTRIB_STACK_DEPTH, &max_attrib_stack_depth);
#endif
}