コード例 #1
0
ファイル: tutorial20.cpp プロジェクト: c14006078/opengl
int main(int argc, char** argv)
{
    Magick::InitializeMagick(*argv);
    GLUTBackendInit(argc, argv);

    if (!GLUTBackendCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, 32, false, "Tutorial 20")) {
        return 1;
    }

    Tutorial20* pApp = new Tutorial20();

    if (!pApp->Init()) {
        return 1;
    }

    pApp->Run();

    delete pApp;
 
    return 0;
}
コード例 #2
0
int main(int argc, char** argv)
{   
    SRANDOM;
       
    GLUTBackendInit(argc, argv, true, false);

    if (!GLUTBackendCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, false, "Tutorial 28")) {
        return 1;
    }

    Tutorial28* pApp = new Tutorial28();

    if (!pApp->Init()) {
        return 1;
    }

    pApp->Run();

    delete pApp;
 
    return 0;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: andriyut/ogldev
int main(int argc, char** argv)
{
    srandom(getpid());
       
    GLUTBackendInit(argc, argv);

    if (!GLUTBackendCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, 32, false, "Tutorial 28")) {
        return 1;
    }

    Tutorial28* pApp = new Tutorial28();

    if (!pApp->Init()) {
        return 1;
    }

    pApp->Run();

    delete pApp;
 
    return 0;
}
コード例 #4
0
ファイル: tutorial22.cpp プロジェクト: stanhome/OpenGL_Demo
int main(int argc, char * argv[])
{
	GLUTBackendInit(argc, argv, true, false);
	if (!GLUTBackendCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, false, "Tutorial 21"))
	{
		assert(0);
		//return 1;
	}

	printf("GL versions: %s\n", glGetString(GL_VERSION));

	Tutorial22 *pApp = new Tutorial22();
	if (!pApp->init())
	{
		assert(0);
		//return 1;
	}

	pApp->run();

	delete pApp;
	return 0;
}
コード例 #5
0
void Tutorial::Run()
{
#ifdef __TUT_VERSION

#if __TUT_VERSION >= 17
  if (_tutorialID >= 17) {
    char windowName[255];
    sprintf(&windowName[0], "Tutorial %d", _tutorialID);
    if (!GLUTBackendCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, false, windowName)) {
      return;
    }
#if __TUT_VERSION == 17
    _tutorial = new Tutorial17();
#elif __TUT_VERSION == 18
    _tutorial = new Tutorial18();
#elif __TUT_VERSION == 19
    _tutorial = new Tutorial19();
#elif __TUT_VERSION == 20
    _tutorial = new Tutorial20();
#elif __TUT_VERSION == 21
    _tutorial = new Tutorial21();
#elif __TUT_VERSION == 22
    _tutorial = new Tutorial22();
#elif __TUT_VERSION == 23
    _tutorial = new Tutorial23();
#endif

    if (!_tutorial->Init(pVSFileName, pFSFileName)) {
      return;
    }

    char* version = (char*)glGetString(GL_VERSION);
    fprintf(stdout, "Version: '%s'\n", version);
    _tutorial->Run();
    delete _tutorial;
    return;
  }
#endif

#endif



  initGlut();
  initGlew();

  glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

  if (_tutorialID == 16) {
    glFrontFace(GL_CW);
    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);
  }

  char* version = (char*)glGetString(GL_VERSION);
  fprintf(stdout, "Version: '%s'\n", version);

  ///
  /// Create vertex buffer: glGenBuffers, glBindBuffer, glBufferData.
  ///
  createVertexBuffer();

  ///
  /// Create the index buffer: glGenBuffers, glBindBuffer, glBufferData.
  ///
  createIndexBuffer();

  ///
  /// Read shaders from file, compile, verify and add to shader program.
  ///
  compileShaders();

  if (_tutorialID == 16) {
    glUniform1i(_gSampler, 0);

    _pTexture = new Texture(GL_TEXTURE_2D, "/home/lparkin/Projects/S3/OpenGlDirsProject/LearnOpenGL-nonQt/Project/Content/test.png");

    if (!_pTexture->Load()) {
      exit(1);
    }
  }

  ///
  /// Setup the perspective projection information.
  ///
  _gPersProjInfo.FOV = 60.0f;
  _gPersProjInfo.Height = WINDOW_HEIGHT_1_14;
  _gPersProjInfo.Width = WINDOW_WIDTH_1_14;
  _gPersProjInfo.zNear = 1.0f;
  _gPersProjInfo.zFar = 100.0f;

  ///
  /// Start the rendering loop.
  ///
  glutMainLoop();
}