DWORD WINAPI glutThreadProc( LPVOID lpParameter)
{
	CVideoMixerOpenGL* pThis = (CVideoMixerOpenGL*)lpParameter;
	if(!pThis)	return -1;

	EnterCriticalSection(&(pThis->m_csDisplay));

	int argc = 0;
	glutInit(&argc, 0);
	glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);		

	glutInitWindowPosition(pThis->m_rViewPort.left,pThis->m_rViewPort.top);
	glutInitWindowSize(pThis->m_rViewPort.right - pThis->m_rViewPort.left,pThis->m_rViewPort.bottom - pThis->m_rViewPort.top);
	glutSetWindow((int)pThis ->m_hWndParent);
	
	glutCreateWindow( "OpenGL VideoMixer" );
	// GLee is used to setup all the extensions available
	GLeeInit();

#ifdef WGL_EXT_swap_control
	wglSwapIntervalEXT (1);
#endif

	glShadeModel(GL_SMOOTH);
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
	glClearDepth(1.0f);					
	glEnable(GL_DEPTH_TEST);			
	glDepthFunc(GL_LEQUAL);				

	// set up one-byte alignment for pixel storage (saves memory)
	glPixelStorei(GL_PACK_ALIGNMENT, 4);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
	//glEnable(GL_CULL_FACE);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	//glEnable(GL_TEXTURE_2D);

	// Setup the various call back functions GLUT requires
	glutDisplayFunc     ( glutDisplay );  
	glutReshapeFunc     (glutReshape );
	glutKeyboardFunc    (glutKeyboard );
	//glutIdleFunc		(glutIdle );
	glutTimerFunc(10,glutTimer,0);
	LeaveCriticalSection(&(pThis->m_csDisplay));

	glutMainLoop( );			// Run the main GLUT loop for rendering
	return 0;
}
Example #2
0
Shader::Shader(const char *vert, const char *frag, bool isFile)
{
#ifdef _WIN32
	GLeeInit();
#endif
	if(isFile)
	{
		char* vv = read(vert);
		char* vf = read(frag);

		setup(vv, vf);
		delete[] vv;
		delete[] vf;
	}
	else
		setup(vert, frag);
}
// display OpenGL graphics
void CompartmentMapWidget::initializeGL()
{
    qDebug()<<"CompartmentMapWidget initializeGL ... ...";

    _isSoftwareGL = false;
    GLeeInit();

    renderer = new Renderer_gl1(this);

    // settings
    renderer->bShowBoundingBox = false; //
    renderer->bShowAxes        = false;

    renderer->tryTexCompress = false; // texture
    renderer->tryTex3D       = false;
    renderer->tryTexNPT      = false;
    renderer->tryTexStream   = true;

    renderer->lineType   = false; // swc

    // prepare
    if (renderer)
    {
        loadAtlas();
        if(renderer->hasError())	POST_CLOSE(this);

        //qDebug()<<"label surf ..."<<((Renderer_gl1 *)renderer)->listLabelSurf.size();
        //qDebug()<<"triangle ..."<<((Renderer_gl1 *)renderer)->list_listTriangle.size();
        //qDebug()<<"glist label ..."<<((Renderer_gl1 *)renderer)->list_glistLabel.size();

        listLabelSurf = ((Renderer_gl1 *)renderer)->getListLabelSurf();

        pCompartmentComboBox->addItem("All On", true);
        pCompartmentComboBox->addItem("All Off", false);
        for(int i=0; i<listLabelSurf.size(); i++)
        {
            pCompartmentComboBox->addItem(listLabelSurf[i].name, true);
        }

        update();
    }

}
Example #4
0
void initializeScene()
{
  Logger::initialize();
  GLeeInit();
  MediaPathManager::registerPath("Data/Textures/");
  MediaPathManager::registerPath("Data/XML/");
  MediaPathManager::registerPath("Data/GUI/");
  guiFrame.GUIPanel::loadXMLSettings("GUILayout.xml");
  guiFrame.setGUIEventListener(&handler);

  fpsDisplay = (GUILabel*)guiFrame.getWidgetByCallbackString("fpsCounter");

  Logger::flush();

  glEnable(GL_DEPTH_TEST);
  glShadeModel(GL_SMOOTH);
  glEnable(GL_CULL_FACE);
  glCullFace(GL_BACK);
}
Example #5
0
void GLWnd::glInit() {
  if (m_rendercontext || m_dc) glShutdown();

  OSWINDOWHANDLE tmpwnd = NULL;
  HDC tmpdc = NULL;

  tmpwnd = StdWnd::createWnd(0, 0, 10, 10, TRUE, 0, NULL, WASABI_API_APP->main_gethInstance(), "WGLDUMMY", wglDummyWndProc, NULL);
  tmpdc = GetDC(tmpwnd);

  PIXELFORMATDESCRIPTOR pfd;
  MEMSET(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
  pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
  pfd.nVersion = 1;
  pfd.dwFlags = PFD_SUPPORT_OPENGL|(m_doublebuffered?PFD_DOUBLEBUFFER:0)|PFD_DRAW_TO_WINDOW|PFD_GENERIC_ACCELERATED;
  pfd.iPixelType = PFD_TYPE_RGBA;
  // todo: make this configurable
  pfd.cColorBits = 24;
  pfd.cDepthBits = 16;
  pfd.cAlphaBits = 8;
  pfd.cStencilBits = 16;
  pfd.iLayerType = PFD_MAIN_PLANE;

  HGLRC tmprc;
  int baseformat = ChoosePixelFormat(tmpdc, &pfd);
  if (baseformat == 0 || !SetPixelFormat(tmpdc, baseformat, &pfd) || ((tmprc = wglCreateContext(tmpdc)) == NULL)) {
	  ReleaseDC(tmpwnd, tmpdc);
	  StdWnd::destroyWnd(tmpwnd);
    // could not even create a simple opengl window
    return;
  }
  int reqformat = baseformat;
  if (m_wantmultisampling) {
    wglMakeCurrent(tmpdc, tmprc);
    m_multisampling = 0;
    if (GLeeInit()) {
      if (GLEE_ARB_multisample) {
        int pixelFormat;
        BOOL bStatus;
        UINT numFormats;
        float fAttributes[] = {0,0};
        int iAttributes[] = { WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
	                            WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
	                            WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
	                            WGL_COLOR_BITS_ARB,24,
	                            WGL_ALPHA_BITS_ARB,8,
	                            WGL_DEPTH_BITS_ARB,16,
	                            WGL_STENCIL_BITS_ARB,0,
	                            WGL_DOUBLE_BUFFER_ARB, m_doublebuffered?GL_TRUE:GL_FALSE,
	                            WGL_SAMPLE_BUFFERS_ARB,GL_TRUE,
	                            WGL_SAMPLES_ARB,4,
	                            0,0};
    
        bStatus = wglChoosePixelFormatARB(tmpdc,iAttributes,fAttributes,1,&pixelFormat,&numFormats);
        if ((bStatus == GL_TRUE) && (numFormats >= 1)) {
          m_multisampling = 1;
	        reqformat = pixelFormat;
        } else {
          // ok that failed, try using 2 samples now instead of 4
          iAttributes[19] = 2;
          bStatus = wglChoosePixelFormatARB(tmpdc,iAttributes,fAttributes,1,&pixelFormat,&numFormats);
          if ((bStatus == GL_TRUE) && (numFormats >= 1)) {
            m_multisampling = 1;
  	        reqformat = pixelFormat;	  
          }
        }
      }
    }
  }

  wglMakeCurrent(NULL, NULL);
  ReleaseDC(tmpwnd, tmpdc);
  wglDeleteContext(tmprc);
  StdWnd::destroyWnd(tmpwnd);

  m_dc = StdWnd::getDC(gethWnd());

  SetPixelFormat(m_dc, reqformat, &pfd);

  m_rendercontext = wglCreateContext(m_dc);
  wglMakeCurrent(m_dc, m_rendercontext);

  GLeeInit();
  resetWaitVertical();
}