Exemple #1
0
/*!
    \internal
*/
void QGLView::initializeGL()
{
    d->logEnter("QGLView::initializeGL");
    QGLPainter painter;
    painter.begin();

    // Set the default depth buffer options.
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    glDepthMask(GL_TRUE);
#if defined(QT_OPENGL_ES)
    glDepthRangef(0.0f, 1.0f);
#else
    glDepthRange(0.0f, 1.0f);
#endif

    // Set the default blend options.
    qt_gl_BlendColor(0, 0, 0, 0);
    qt_gl_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    qt_gl_BlendEquation(GL_FUNC_ADD);

    painter.setCullFaces(QGL::CullDisabled);
    initializeGL(&painter);
    d->logLeave("QGLView::initializeGL");
}
int main(int argc, char** argv)
{
	gflags::ParseCommandLineFlags(&argc, &argv, true);
	google::InitGoogleLogging(argv[0]);

	// GLUT Window Initialization:
	glutInit(&argc, argv);
	glutInitWindowSize(640, 480);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutCreateWindow("GlutViewer");

	// Initialize OpenGL graphics state
	initializeGL();

	// Register callbacks
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	glutMouseFunc(mouseButton);
	glutMotionFunc(mouseMotion);
	glutKeyboardFunc(Keyboard);

	// Create our popup menu
	buildPopupMenu();
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	// To do
	//const char *mesh_filename = "mesh.off";
	//g_MeshViewer.open_mesh(mesh_filename);
	g_MeshViewer.parse_arguments();

	// Turn the flow of control over to GLUT
	glutMainLoop();
	return 0;
}
Exemple #3
0
int main(int argc, char* argv[])
{
    SDLOpenGL window("Test",0,0,1024,720);
    window.makeCurrent();

    initializeGL();

    bool _while=true;

    while(_while)
    {
        renderGL();
        window.swapWindow();
        SDL_Delay(10);
        if(SDL_QUIT==1)
        {
            _while=false;
        };

   }


    SDL_Quit();
    return 0;
}
Exemple #4
0
CGlutWindow::CGlutWindow(void) {
    
	m_pCameraArcball = new CArcBall();
	m_pLightArcball = new CArcBall();
    
	glutInitWindowSize (1026,770); 
	glutInitWindowPosition (198, 0);
	main_window = glutCreateWindow ("Astronomy Multi-Volume Renderer");
    
	m_dFieldOfView = 30.0;
	m_nWidth = 1;
	m_nHeight = 1;
    
	m_dRadius = 0.5*sqrt(12.0);
	m_vecCameraPosition.set(0.0, 0.0, 0.0,1.0);
    
	m_dCenter = m_dRadius/ sin(DEG2RAD(m_dFieldOfView)/2.0);
    
	m_dZoom = 1.0;
	dZoom = 0.0;
	m_dTranslateX = 0.0;
	m_dTranslateY = 0.0;
	m_nMouseState = 0;
    
	m_bDragging = false;
	m_bZooming = false;
	m_bRotating = false;
	m_bExternalMouseHandling = false;
	initializeGL();
}
void GLWidget::OpenNewDataset(QString datasetname, Vec3i volumedim)
{
    datasetName = datasetname;
    volumeDim = volumedim;
    initializeGL();
    updateGL();
}
Exemple #6
0
int main(int argc, char** argv)
{
	// initialize openGL window
	glutInit(&argc, argv);
	glutInitWindowPosition(300, 200);
	glutInitWindowSize(600, 400);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutCreateWindow("TU Darmstadt, MBorner"); 
	// link functions to certain openGL events
	glutDisplayFunc(renderScene);
	glutReshapeFunc(reshape);  
	glutMouseFunc(mousePressed);
	glutMotionFunc(mouseMoved);
	glutKeyboardFunc(keyPressed);
	// further initializations
	setDefaults();
	initializeGL();
	// data structure stuff
	std::cout << heDS << std::endl << std::endl;
	if (heDS.getHalfEdges().size() > 0) activeHE = heDS.getHalfEdges().front();
	else activeHE = nullptr;
	// activate main loop
	glutMainLoop();
	return 0;
}
Exemple #7
0
void drawerWidget::paintEvent(QPaintEvent*)
{
	/*Если буфферы поддерживаются*/
	QPainter painter;
	if(hasbuffers)
	{
		painter.begin(pbuffer);
		pbuffer->makeCurrent();
		initializeGL();
		resizeGL(width(),height());
		paintGL();	
		painter.end();
	
		buffer = pbuffer->toImage().copy(0,512 - height(),width(), height()).convertToFormat(QImage::Format_RGB32);
	
		painter.begin(this);
		painter.drawImage(0,0,buffer);
		painter.end();
	}
	else
	{
		/*Ничего нет!*/
	}
	
}
Exemple #8
0
void MantidGLWidget::setSurface(boost::shared_ptr<ProjectionSurface> surface)
{
  m_surface = surface;
  connect(m_surface.get(),SIGNAL(redrawRequired()),this,SLOT(repaint()),Qt::QueuedConnection);
  m_firstFrame = true;
  initializeGL();
}
/* xextrusion initialization routine */
ENTRYPOINT void
init_extrusion (ModeInfo * mi)
{
  int screen = MI_SCREEN(mi);
  extrusionstruct *gp;

  if (MI_IS_WIREFRAME(mi)) do_light = 0;

  if (Extrusion == NULL) {
	if ((Extrusion = (extrusionstruct *)
         calloc(MI_NUM_SCREENS(mi), sizeof (extrusionstruct))) == NULL)
	  return;
  }
  gp = &Extrusion[screen];

  gp->window = MI_WINDOW(mi);
  if ((gp->glx_context = init_GL(mi)) != NULL) {
	reshape_extrusion(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
	initializeGL(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
	chooseExtrusionExample(mi);
  } else {
	MI_CLEARWINDOW(mi);
  }

}
Exemple #10
0
void TrackerArenaForm::paintEvent(QPaintEvent* e)
{
	//qDebug() << "paintEvent1";

	makeCurrent();

//	glMatrixMode(GL_MODELVIEW);
//	glPushMatrix();
//	glMatrixMode(GL_PROJECTION);
//	glPushMatrix();

	initializeGL();

	float ww = width();
	float hh = height();
	setupViewport(ww, hh);
	paintGLInternal();

//	glMatrixMode(GL_MODELVIEW);
//	glPopMatrix();
//	glMatrixMode(GL_PROJECTION);
//	glPopMatrix();

	//
	QPainter painter(this);
	overlapOpenGL(painter);
	//painter.end();

	//qDebug() << "paintEvent2";
}
void VasGLWidget::createPixelBuffer(QSize size)
{
    QImage imgDummy;

    // If we haven't got a pixel buffer yet or if it's the wrong size...
    if(m_pBuffer==NULL || m_size!=size)
    {
        // Create a new VasGLPixelBuffer and remember its size
        delete m_pBuffer;
        m_pBuffer=new VasGLPixelBuffer(size);
        m_size=size;

        // Make sure the dummy image has the right size
        imgDummy=QImage(m_size.width(), m_size.height(),
            QImage::Format_ARGB32);
        imgDummy.bits();

        // Make the GL context current
        m_pBuffer->makeCurrent(&imgDummy);

        // Initialize the pixel buffer
        initializeGL();
        resizeGL(size.width(), size.height());

        m_pBuffer->doneCurrent();
    }
}
Exemple #12
0
GLWindow::GLWindow(QScreen *screen) : QWindow(screen) {

    QSurfaceFormat cformat;
    cformat.setDepthBufferSize(24);
    cformat.setMajorVersion(4);
    cformat.setMinorVersion(2);
    cformat.setProfile(QSurfaceFormat::CoreProfile);
    
    resize(800,600);
    setSurfaceType(OpenGLSurface);
    create();

    _context = new QOpenGLContext;
    _context->setFormat(cformat);
    _context->create();

    connect(this,SIGNAL(widthChanged(int)), this, SLOT(resizeGL()));
    connect(this,SIGNAL(heightChanged(int)), this, SLOT(resizeGL()));

    initializeGL();
    resizeGL();

    /*QTimer* timer = new QTimer(this);
    connect( timer, SIGNAL(timeout()), this, SLOT(update()));
    timer->start();*/
}
Exemple #13
0
void System::initializeInstance()
{
	initializeGL();

	Engine* engine = Engine::getInstance();

	engine->getMeshCache()->resize(10 * 1000000); // 10MB
	engine->getTextureCache()->resize(25 * 1000000); // 25MB
	engine->getAnimationCache()->resize(10 * 1000000); // 10MB

	ProfileManager::getInstance()->loadProfiles();

	MainWindow* win = new MainWindow;
	win->show();

	win->initialize();

	connect(qApp, SIGNAL(lastWindowClosed()), this, SLOT(destroyInstance()));

	EntityManager::getInstance();

	initializing = false;

	emit initializationDone();
}
Exemple #14
0
/*!
    \internal
*/
void QGLView::initializeGL()
{
    d->logEnter("QGLView::initializeGL");
    QGLPainter painter;
    painter.begin();

    // Set the default depth buffer options.
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    glDepthMask(GL_TRUE);
#if defined(QT_OPENGL_ES)
    glDepthRangef(0.0f, 1.0f);
#else
    glDepthRange(0.0f, 1.0f);
#endif

    // Set the default blend options.
    if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendColor))
        painter.glBlendColor(0, 0, 0, 0);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendEquation))
        painter.glBlendEquation(GL_FUNC_ADD);
    else if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendEquationSeparate))
        painter.glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);

    glDisable(GL_CULL_FACE);
    initializeGL(&painter);
    d->logLeave("QGLView::initializeGL");
}
tui::LayoutCanvas::LayoutCanvas(wxWindow *parent, const wxPoint& pos, 
     const wxSize& size, int* attribList): 
 wxGLCanvas(parent, ID_TPD_CANVAS, pos, size, 0,wxT("LayoutCanvas"), attribList)
{
//   if (!wxGLCanvas::IsDisplaySupported(attribList)) return;
#ifdef __WXGTK__
   //  Here we'll have to check that we've got what we've asked for. It is
   // quite possible that we can't get the requested GL visual. If that is the case
   // we'll have to aboandon the init sequence right here, otherwise Toped will
   // crash.
   x_visual = (XVisualInfo*) m_vi;
   if (NULL == x_visual) return;
#endif
   crossCur = MakeCursor(crosscursor,16, 16);
   //crossCur = DEBUG_NEW wxCursor((const char*)crosscursor,16, 16);
   SetCursor(*crossCur);
   tmp_wnd = false;
   mouse_input = false;
   rubber_band = false;
   restricted_move = false;
   invalid_window = false;
   reperX = reperY = long_cursor = false;
   initializeGL();
   ap_trigger = 10;
   glfInit();
}
Exemple #16
0
Viewer::Viewer(float width, float height) :
    m_window{
        sf::VideoMode(width, height),
        "Computer Graphics Practicals",
        sf::Style::Default,
        sf::ContextSettings{ 24 /* depth*/, 8 /*stencil*/, 4 /*anti aliasing level*/, 4 /*GL major version*/, 0 /*GL minor version*/}
        },
    m_modeInformationTextDisappearanceTime{ clock::now() + g_modeInformationTextTimeout },
    m_modeInformationText{ "Arcball Camera Activated" },
    m_applicationRunning{ true }, m_animationLoop{ false }, m_animationIsStarted{ false },
    m_loopDuration{0}, m_simulationTime{0},
    m_screenshotCounter{0}, m_helpDisplayed{false},
    m_lastEventHandleTime{ clock::now() }
{
    sf::ContextSettings settings = m_window.getSettings();
    LOG( info, "Settings of OPENGL Context created by SFML");
    LOG( info, "\tdepth bits:         " << settings.depthBits );
    LOG( info, "\tstencil bits:       " << settings.stencilBits );
    LOG( info, "\tantialiasing level: " << settings.antialiasingLevel);
    LOG( info, "\tGL version:         " << glGetString( GL_VERSION ) );
    LOG( info, "\tGL renderer:        " << glGetString( GL_RENDERER ) );

    //Initialize the camera
    float ratio = width/height;
    m_camera.setRatio(ratio);

    //Set up GLEW
    initializeGL();

    //Initialize the text engine (this SHOULD be done after initializeGL, as the text
    //engine store some data on the graphic card)
    m_tengine.init();
    m_tengine.setWindowDimensions( m_window.getSize().x, m_window.getSize().y );
}
Exemple #17
0
MyGLWindow::MyGLWindow(EGLconfig *_config, std::string fragmentShader, std::string textureName) 
: EGLWindow(_config)
, _fragmentShader(fragmentShader)
, _textureName(textureName)
, _texture0(0)
{
  initializeGL();
  srand(time(NULL));
}
Exemple #18
0
//---------------------------------------------------------------------------
void __fastcall TOpenGL_Form::FormCreate(TObject *Sender)
{
    ghDC = GetDC(Handle);
    if (!bSetupPixelFormat(ghDC))
        Close();
    ghRC = wglCreateContext(ghDC);
    wglMakeCurrent(ghDC, ghRC);
    initializeGL(ClientRect.Right, ClientRect.Bottom);
}
    ThisPrivate(SimpleMultiSampleFBO * s):super(s){
        glClearDepth(1);
        glClearColor(0,0,0,0);
    #ifdef _DEBUG_OPENGL_QT_
            QGLDebugTool::setSimpleCallbackFunction();
            QGLDebugTool::test();
    #endif
        initializeGL();
}
Exemple #20
0
void WindowQt::initialize()
{
    makeCurrent();

    initializeGL();

    doneCurrent();

    m_initialized = true;
}
Exemple #21
0
GLWidget::GLWidget(QWidget *parent) :
    QWidget(parent), lbut(false), rbut(false),
    zoom(4), tx(0), ty(0), rx(0), ry(0),
    waitForToothSelection(false), toothSelected(0), pickingMode(false),
    context(0), fbo(0)
{
    this->setMouseTracking(true);

    initializeGL();
}
Exemple #22
0
DepthImageItem::DepthImageItem(QVector3D pos, QVector3D size,
                               QImage depth, QImage shaded, QColor color,
                               Viewport* viewport)
    : QObject(viewport), pos(pos), size(size), depth(depth), shaded(shaded),
      color(color), viewport(viewport)
{
    initializeGL();

    // Force a redraw of the viewport when this object is created.
    viewport->scene->invalidate(QRect(), QGraphicsScene::BackgroundLayer);
}
void GLRasterTexture::updateGL(bool coreProfile) {
    if(m_program == 0) {
        // has not been initialised yet, do that instead
        initializeGL(coreProfile);
    } else {
        m_vbo.bind();
        m_vbo.allocate(constData(), m_count * sizeof(GLfloat));
        m_vbo.release();
        m_built = true;
    }
}
MeshViewerWidget::MeshViewerWidget(QWidget* parent /*= 0*/)
	: QGLViewerWidget(parent)
	, mesh_viewer_core_(*this)
{
	initializeGL();

    add_draw_mode("Points");
    add_draw_mode("Hidden-Line");
#if defined(OM_USE_OSG) && OM_USE_OSG
    add_draw_mode("OpenSG Indices");
#endif
}
Exemple #25
0
GlutWindow::GlutWindow(void)
{

	nWidth = 1024;
	nHeight = 800;
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
	glutInitWindowSize (nWidth,nHeight); 
	glutInitWindowPosition (0, 0);
	glutCreateWindow ("AI Project");
	
	initializeGL();

}
Exemple #26
0
int main(int argc, char *argv[])
{
  SDLOpenGL window("test",0,0,1024,720);
  window.makeCurrent();
  initializeGL();
  while(true)
  {
    renderGL();
    window.swapWindow();
    SDL_Delay(10);
  }
  std::cout<<"Working\n";
}
Exemple #27
0
GameState::GameState(difficulty d) {
  m_difficulty = d;
  m_level = 0;
  m_balls = 3;
  m_blocks_destroyed = 0;

  m_paddle = 0;

  resetBall();
  buildLevel();
  initializeGL();

  g_sound_engine.playSound(NEW_GAME);
}
Exemple #28
0
int main(int argc, char *argv[])
{
	string recipe = parseCLArgs(argc, argv);

	// Initialize GLFW
	if( !glfwInit() ) exit( EXIT_FAILURE );

#ifdef __APPLE__
  // Select OpenGL 4.1
  glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
  glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 1 );
#else
	// Select OpenGL 4.3
	glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
	glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3 );
#endif
	glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
	glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);

	// Open the window
	string title = "Chapter 02 -- " + recipe;
	window = glfwCreateWindow( WIN_WIDTH, WIN_HEIGHT, title.c_str(), NULL, NULL );
	if( ! window ) {
		glfwTerminate();
		exit( EXIT_FAILURE );
	}
	glfwMakeContextCurrent(window);

	// Load the OpenGL functions.
	if( ogl_LoadFunctions() == ogl_LOAD_FAILED ) {
		glfwTerminate();
		exit(EXIT_FAILURE);
	}

	GLUtils::dumpGLInfo();

	// Initialization
	initializeGL();
	resizeGL(WIN_WIDTH,WIN_HEIGHT);

	// Enter the main loop
	mainLoop();

	// Close window and terminate GLFW
	glfwTerminate();
	// Exit program
	exit( EXIT_SUCCESS );
}
/**
 * @brief Constructeur paramétré
 *
 * Permet d'initialiser la fenêtre et les propriétés de la zone de rendu OpenGL
 *
 * @param screen Propriétés de l'écran
 */
Window::Window(QScreen *screen)
    : QWindow(screen),
      m_scene(new MovingColoredTriangle(this))
{
    // On définit le type de la zone de rendu, dans notre cas il
    // s'agit d'une zone OpenGL
    setSurfaceType(QSurface::OpenGLSurface);

    // Puis on définit les propriétés de la zone de rendu
    QSurfaceFormat format;

    format.setDepthBufferSize(24);
    format.setMajorVersion(4);
    format.setMinorVersion(3);
    format.setSamples(4); // Multisampling x4
    format.setProfile(QSurfaceFormat::CoreProfile); // Fonctions obsolètes d'OpenGL non disponibles
    format.setOption(QSurfaceFormat::DebugContext);

    // On applique le format et on créer la fenêtre
    setFormat(format);
    create();
    resize(800, 600);
    setTitle("OpenGLSBExamplesQt - MovingColoredTriangle");

    // On créer le contexte OpenGL et on définit son format
    m_context = new QOpenGLContext;
    m_context->setFormat(format);
    m_context->create();
    m_context->makeCurrent(this);

    // On définit le contexte OpenGL de la scène
    m_scene->setContext(m_context);

    m_timer.start();

    initializeGL();

    connect(this, SIGNAL(widthChanged(int)), this, SLOT(resizeGL()));
    connect(this, SIGNAL(heightChanged(int)), this, SLOT(resizeGL()));

    resizeGL();

    // Création d'un timer permettant la mise à jour de la zone de rendu 60 fois par seconde
    QTimer* timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateScene()));
    timer->start(16); // f = 1 / 16.10e-3 = 60Hz
}
HGLRC CDrawableWidget::InitOglStuff()
{
	/*if(!m_bOglInitialized)
	{*/
	// TRACE("Initialized OGL stuff\n");
	// m_ghDC = GetDC(); 
    if (!SetupPixelFormat()) 
	{
		// return;
        // PostQuitMessage (0); 
	}
	
	
    HGLRC ghRC = wglCreateContext(SafeGrabDC()->GetSafeHdc()); 
	if(ghRC != NULL)
	{
		m_bOglInitialized = true;
	}
	else
	{
		DWORD nCurrError = GetLastError();

		LPVOID lpMsgBuf;

		FormatMessage(
			FORMAT_MESSAGE_ALLOCATE_BUFFER | 
			FORMAT_MESSAGE_FROM_SYSTEM,
			NULL,
			nCurrError,
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
			(LPTSTR) &lpMsgBuf,
			0, NULL );

		TRACE("CreateContext failed %d (\"%s\")\n", nCurrError, lpMsgBuf);
	}
    wglMakeCurrent(SafeGrabDC()->GetSafeHdc(), ghRC); 
    GetClientRect(&m_rect); 
	// TRACE("%d %d -- %d %d\n", m_rect.right, m_rect.top, m_rect.left, m_rect.bottom);
    initializeGL(m_rect.right, m_rect.bottom, TRUE, m_lfNear, m_lfFar);
	m_lfAspect = m_rect.right/(double)m_rect.bottom;

	if(m_bRayPickerValid)
	{
		SetRayPickerVals(m_rayPicker);
	}
	return ghRC;
}