当前位置: 首页>>代码示例>>C++>>正文


C++ Platform::createWindow方法代码示例

本文整理汇总了C++中Platform::createWindow方法的典型用法代码示例。如果您正苦于以下问题:C++ Platform::createWindow方法的具体用法?C++ Platform::createWindow怎么用?C++ Platform::createWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Platform的用法示例。


在下文中一共展示了Platform::createWindow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(void)
{
	//Initialize platform subsystem and EGL
	Platform* platform = Platform::getInstance();
	platform->createWindow(WINDOW_WIDTH, WINDOW_HEIGHT);
	EGLRuntime::initializeEGL(EGLRuntime::OPENGLES2);
	eglMakeCurrent(EGLRuntime::display, EGLRuntime::surface, EGLRuntime::surface, EGLRuntime::context);

	Scene *scene = new Scene(WINDOW_WIDTH, WINDOW_HEIGHT);
	scene->Initialize();

	//Timer variable to calculate FPS
	Timer fpsTimer;
	fpsTimer.reset();
	DWORD wait = 0;

	bool end = false;
	while (!end)
	{		
		//End when something happens to the window
		if (platform->checkWindow() != Platform::WINDOW_IDLE)
			end = true;

		//This prints FPS every second
		float fFPS = fpsTimer.getFPS();		
		if (fpsTimer.isTimePassed(1.0f)){
			LOGI("FPS:\t%.1f\n", fFPS);			
		}

		scene->Draw();
		eglSwapBuffers(EGLRuntime::display, EGLRuntime::surface);
		
		//Calculate how much we have to wait to achieve 30FPS, 
		//getInterval() tells us how much time have passed 
		//since the last call (seems to be in centi-seconds)
		float interval = fpsTimer.getInterval() * 100;
		wait = (DWORD)(1000 / (interval * 30));
		Sleep(wait);
	}

	//Shutdown everything
	EGLRuntime::terminateEGL();
	platform->destroyWindow();
	delete platform;
	delete scene;

	return 0;
}
开发者ID:hectormoralespiloni,项目名称:OpenGL-ES2-Demo,代码行数:48,代码来源:main.cpp

示例2: main

int main(int argc, char** argv)
{
    if(argc < 2) {
        printf("usage : %s \"tty device\"\n\t ex) %s /dev/ttyACM0\n\n", argv[0], argv[0]);
        return 1;
    }

    /*
     * Initialize myAHRS+
     */
    const char* serial_device = argv[1];
	const char* demo_dir = argv[2];

    MyAhrsPlusForMaliSdk sensor(serial_device, 115200);
    if(sensor.initialize() == false) {
        fprintf(stderr, "ERROR: myAHRS+ initialization failure.\n");
        exit(1);
    }

    /* Result of linking a program. */
    GLint link_status = GL_FALSE;

    /* Location of a 'viewMat' uniform variable. */
    GLint location_viewMat = 0;

    /* ID of a program object. */
    GLuint program_id = 0;

    /* ID of a fragment shader. */
    GLuint frag_shader_id = 0;

    /* ID of a vertex shader. */
    GLuint vert_shader_id = 0;

    /* Quaternions representing rotations around X, Y and Z axes. */
    Quaternion Q_X = { 0.0f, 0.0f, 0.0f, 0.0f };
    Quaternion Q_Y = { 0.0f, 0.0f, 0.0f, 0.0f };
    Quaternion Q_Z = { 0.0f, 0.0f, 0.0f, 0.0f };

    /* Quaternions to store resultant products. */
    Quaternion Q_XZ  = { 0.0f, 0.0f, 0.0f, 0.0f };
    Quaternion Q_YXZ = { 0.0f, 0.0f, 0.0f, 0.0f };

    /* Path to cubemap texture. */
//	char file_name[] = { "assets/greenhouse_skybox-0.ppm" };
	char file_name[32];

	if (demo_dir == NULL)
	{
		demo_dir = "sky";
	}

	sprintf(file_name, "%s/0.ppm", demo_dir);

    /* Used to hold cube-map texture face data when initializing skybox cube-map texture. */
    ImageFile cubemap_image = { 0, 0, NULL };

    /* Texture cubemap targets. */
    GLenum cubemap_faces[] =
    {
        GL_TEXTURE_CUBE_MAP_POSITIVE_X,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
        GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
    };

    /* Texture cubemap name. */
    GLuint cubemap_texture = 0;

    /* Number of degrees to rotate counterclockwise around X, Y and Z axes respectively. */
    float angle_X = 0.0f, angle_Y = 0.0f, angle_Z = 0.0f;

    /* 4x4 matrix that transforms the skybox's vertices from model space to world space. */
    float model_view_matrix[16] = {0.0f};

    /* Intialise the Platform object for platform specific functions. */
    Platform* platform = Platform::getInstance();

    if(platform == NULL)
    {
        fprintf(stderr, "Could not create platform\n");
        exit(-1);
    }

    /* Initialize windowing system. */
    platform->createWindow(window_width, window_height);

    /* Initialize EGL. */
    EGLRuntime::initializeEGL(EGLRuntime::OPENGLES3);
    EGL_CHECK(eglMakeCurrent(EGLRuntime::display, EGLRuntime::surface, EGLRuntime::surface, EGLRuntime::context));

    /* Generate texture name and bind it to the texture cubemap target. */
    GL_CHECK(glGenTextures(1, &cubemap_texture));
    GL_CHECK(glBindTexture(GL_TEXTURE_CUBE_MAP, cubemap_texture));

    /* Set up texture parameters. */
    GL_CHECK(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
    GL_CHECK(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
//.........这里部分代码省略.........
开发者ID:pepmint,项目名称:myAHRS_plus,代码行数:101,代码来源:Skybox_with_myahrs.cpp


注:本文中的Platform::createWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。