コード例 #1
0
ファイル: AntTweakBar.cpp プロジェクト: Kelloggs/experiments
void	setupGUI(int width, int height)
{
	pRenderer = new Gwen::Renderer::OpenGL_DebugFont();
	skin.SetRender( pRenderer );

	pCanvas = new Gwen::Controls::Canvas( &skin );
	pCanvas->SetSize( width,height);
	pCanvas->SetDrawBackground( false);
	pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );

	//MyWindow* window = new MyWindow(pCanvas);
	//profWindow = new MyProfileWindow(pCanvas);
	
	MyTestMenuBar* menubar = new MyTestMenuBar(pCanvas, profWindow);


	
}
コード例 #2
0
void	setupGUI(int width, int height, sth_stash* font, float retinaScale,GLPrimitiveRenderer* primRender)
{
	primRenderer = primRender;
	pRenderer = new GwenOpenGL3CoreRenderer(primRenderer,font,width,height, retinaScale);
//	pRenderer = new Gwen::Renderer::OpenGL_DebugFont();
	skin.SetRender( pRenderer );

	pCanvas = new Gwen::Controls::Canvas( &skin );
	pCanvas->SetSize( width,height);
	pCanvas->SetDrawBackground( false);
	pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );
//	pCanvas->SetScale(.5);
	//MyWindow* window = new MyWindow(pCanvas);
	profWindow = new MyProfileWindow(pCanvas);
	
	MyTestMenuBar* menubar = new MyTestMenuBar(pCanvas, profWindow);


	
}
コード例 #3
0
int main()
{

	b3gDefaultOpenGLWindow* window = new b3gDefaultOpenGLWindow();
	window->setKeyboardCallback(keyCallback);
	b3gWindowConstructionInfo wci;
    wci.m_openglVersion = 2;
	wci.m_width = sWidth;
	wci.m_height = sHeight;
	//	wci.m_resizeCallback = MyResizeCallback;

	window->createWindow(wci);
	window->setResizeCallback(MyResizeCallback);
	

    int majorGlVersion, minorGlVersion;

    if (!sscanf((const char*)glGetString(GL_VERSION), "%d.%d", &majorGlVersion, &minorGlVersion)==2)
    {
        printf("Exit: Error cannot extract OpenGL version from GL_VERSION string\n");
        exit(0);
    }
	char title[1024];
	if (wci.m_openglVersion>2)
	{
		sprintf(title,"Gwen with OpenGL %d.%d\n",majorGlVersion,minorGlVersion);
	} else
	{
		sprintf(title,"Gwen with OpenGL %d\n",wci.m_openglVersion);
	}
	window->setWindowTitle(title);

    if (majorGlVersion>=3 && wci.m_openglVersion>=3)
    {
        float retinaScale = 1.f;
		
#ifndef __APPLE__
#ifndef _WIN32
    //we need glewExperimental on Linux
    glewExperimental = GL_TRUE;
#endif // _WIN32
        glewInit();
#endif

    //we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue

    GLuint err = glGetError();
    err = glGetError();
    assert(err==GL_NO_ERROR);


        retinaScale = window->getRetinaScale();

        primRenderer = new GLPrimitiveRenderer(sWidth,sHeight);

        sth_stash* font = initFont(primRenderer );


        gwenRenderer = new GwenOpenGL3CoreRenderer(primRenderer,font,sWidth,sHeight,retinaScale);

    } else
    {
        //OpenGL 2.x
        gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();


        skin.SetRender( gwenRenderer );

       

        glClearColor(1,0,0,1);

    }



	//
	// Create a GWEN OpenGL Renderer
	//
//		Gwen::Renderer::OpenGL_DebugFont * pRenderer = new Gwen::Renderer::OpenGL_DebugFont();

	//
	// Create a GWEN skin
	//


#ifdef USE_TEXTURED_SKIN
	Gwen::Skin::TexturedBase skin;
	skin.SetRender( pRenderer );
	skin.Init("DefaultSkin.png");
#else
	skin.SetRender( gwenRenderer );
#endif


	//
	// Create a Canvas (it's root, on which all other GWEN panels are created)
	//
	pCanvas = new Gwen::Controls::Canvas( &skin );
	pCanvas->SetSize( sWidth, sHeight);
	pCanvas->SetDrawBackground( true );
	pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );

	window->setMouseButtonCallback(MyMouseButtonCallback);
	window->setMouseMoveCallback(MyMouseMoveCallback);


	//
	// Create our unittest control (which is a Window with controls in it)
	//
	UnitTest* pUnit = new UnitTest( pCanvas );
	pUnit->SetPos( 10, 10 );

	//
	// Create a Windows Control helper
	// (Processes Windows MSG's and fires input at GWEN)
	//
	//Gwen::Input::Windows GwenInput;
	//GwenInput.Initialize( pCanvas );

	//
	// Begin the main game loop
	//
//	MSG msg;
	while( !window->requestedExit() )
	{
        if (majorGlVersion<3 || wci.m_openglVersion<3)
        {
            saveOpenGLState(sWidth,sHeight);
        }

		// Skip out if the window is closed
		//if ( !IsWindowVisible( g_pHWND ) )
			//break;

		// If we have a message from windows..
	//	if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
		{

			// .. give it to the input handler to process
		//	GwenInput.ProcessMessage( msg );

			// if it's QUIT then quit..
		//	if ( msg.message == WM_QUIT )
			//	break;

			// Handle the regular window stuff..
		//	TranslateMessage(&msg);
		//	DispatchMessage(&msg);

		}

		window->startRendering();

		// Main OpenGL Render Loop
		{
			glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

				glEnable(GL_BLEND);
				GLint err = glGetError();
				assert(err==GL_NO_ERROR);

				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

				err = glGetError();
				assert(err==GL_NO_ERROR);

				err = glGetError();
				assert(err==GL_NO_ERROR);

				glDisable(GL_DEPTH_TEST);
				err = glGetError();
				assert(err==GL_NO_ERROR);

				//glColor4ub(255,0,0,255);

				err = glGetError();
				assert(err==GL_NO_ERROR);


				err = glGetError();
				assert(err==GL_NO_ERROR);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

			//	saveOpenGLState(width,height);//m_glutScreenWidth,m_glutScreenHeight);

				err = glGetError();
				assert(err==GL_NO_ERROR);


				err = glGetError();
				assert(err==GL_NO_ERROR);

				glDisable(GL_CULL_FACE);

				glDisable(GL_DEPTH_TEST);
				err = glGetError();
				assert(err==GL_NO_ERROR);

				err = glGetError();
				assert(err==GL_NO_ERROR);

				glEnable(GL_BLEND);


				err = glGetError();
				assert(err==GL_NO_ERROR);



			pCanvas->RenderCanvas();

			if (avoidUpdate<=0)
				avoidUpdate++;

	//		SwapBuffers( GetDC( g_pHWND ) );
		}
		window->endRendering();

        if (majorGlVersion<3 || wci.m_openglVersion<3)
        {
            restoreOpenGLState();
        }
	}

	window->closeWindow();
	delete window;


}