示例#1
0
int init_glew()
{
    GLenum GlewInitResult = glewInit();
    if (GLEW_OK != GlewInitResult)
    {
        MessageBoxA(NULL, (char *)glewGetErrorString(GlewInitResult), "OpenGL error", MB_OK);
        return false;
    }

    if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
    {
        LOGP("Ready for GLSL");
    }
    else
    {
        LOGP("Not totally ready :(");
    }

    if (glewIsSupported("GL_VERSION_2_0"))
    {
        LOGP("Ready for OpenGL 2.0");
    }
    else
    {
        fprintf(stderr, "OpenGL 2.0 not supported\n");
    }

    if (glew_dynamic_binding() == false)
    {
        MessageBoxA(NULL, "No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error", MB_OK);
        return false;
    }

    return true;
}
示例#2
0
bool CCEGLView::initGL()
{
	if ( !m_bIsEditor )
		m_hDC = GetDC(m_hWnd);

    m_nPixelFormat = SetupPixelFormat(m_hDC);
    //SetupPalette();
    m_hRC = wglCreateContext(m_hDC);
    wglMakeCurrent(m_hDC, m_hRC);

    // check OpenGL version at first
    const GLubyte* glVersion = glGetString(GL_VERSION);
    CCLOG("OpenGL version = %s", glVersion);

    if ( atof((const char*)glVersion) < 1.5 )
    {
        char strComplain[256] = {0};
        sprintf(strComplain,
		"OpenGL 1.5 or higher is required (your version is %s). Please upgrade the driver of your video card.",
		glVersion);
		CCMessageBox(strComplain, "OpenGL version too old");
		return false;
    }

    GLenum GlewInitResult = glewInit();
    if (GLEW_OK != GlewInitResult)
    {
		CCMessageBox((char *)glewGetErrorString(GlewInitResult), "OpenGL error");
        return false;
    }

    if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
    {
        CCLog("Ready for GLSL");
    }
    else
    {
        CCLog("Not totally ready :(");
    }

    if (glewIsSupported("GL_VERSION_2_0"))
    {
        CCLog("Ready for OpenGL 2.0");
    }
    else
    {
        CCLog("OpenGL 2.0 not supported");
    }

    if(glew_dynamic_binding() == false)
	{
		CCMessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error");
		return false;
	}

    // Enable point size by default on windows.
    glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);

    return true;
}
// helper
bool GLViewImpl::initGlew()
{
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
    GLenum GlewInitResult = glewInit();
    if (GLEW_OK != GlewInitResult)
    {
        ccMessageBox((char *)glewGetErrorString(GlewInitResult), "OpenGL error");
        return false;
    }

    if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
    {
        log("Ready for GLSL");
    }
    else
    {
        log("Not totally ready :(");
    }

    if (glewIsSupported("GL_VERSION_2_0"))
    {
        log("Ready for OpenGL 2.0");
    }
    else
    {
        log("OpenGL 2.0 not supported");
    }

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    if(glew_dynamic_binding() == false)
    {
        ccMessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error");
        return false;
    }
    // x-studio365 close _vsync_ default, for nvidia display card
    ::glfwSwapInterval(0);
#endif

#endif // (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)

    return true;
}
示例#4
0
bool RenderSystem::initGlew()
{
#if (OC_TARGET_PLATFORM != OC_PLATFORM_MAC)
	GLenum GlewInitResult = glewInit();
	if (GLEW_OK != GlewInitResult)
	{
		char* glErrorString = (char*)glewGetErrorString(GlewInitResult);
		return false;
	}

	if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
	{
		//log("Ready for GLSL");
	}
	else
	{
		//log("Not totally ready :(");
	}

	if (glewIsSupported("GL_VERSION_2_0"))
	{
		//log("Ready for OpenGL 2.0");
	}
	else
	{
		//log("OpenGL 2.0 not supported");
	}

#if (OC_TARGET_PLATFORM == OC_PLATFORM_WIN32)
	if (glew_dynamic_binding() == false)
	{
		//MessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error");
		return false;
	}
#endif

#endif // (OC_TARGET_PLATFORM != OC_PLATFORM_MAC)

	return true;
}