예제 #1
0
/**
 * @function GUI_ObjSetFocused
 * @brief set the flag <Focused> of a generic object
 * @param const g_obj_st *obj: generic object
 * @param bool p: new flag value
 * @return none
 */
void GUI_ObjSetFocused(g_obj_st /*@null@*/ *obj, bool p) {

  g_obj_st *ptr;

  if(obj == NULL) obj = lastAddedObj;
  if(obj != NULL) {

    /*if focus == true, we shall check that the given object can receive focus */
    if(p == true)  {
      if(GUI_ObjIsFocusable(obj) && GUI_ObjIsDisabled(obj) == false && GUI_ObjIsFocused(obj) == false) {

        /*find & clear previously focused object*/
        ptr = GetObjectList();

        while(ptr != NULL) {
          if(GUI_ObjIsFocused(ptr)) {
            StateSet(ptr, OBJ_S_FOCUSED, false);
            GUI_ObjSetNeedRefresh(ptr, true);
          }
          ptr = ptr->next;
        }

        /*give focus to object*/
        StateSet(obj, OBJ_S_FOCUSED, true);
        GUI_ObjSetNeedRefresh(obj, true);
      }
    }
    else {
      if(GUI_ObjIsFocused(obj)) {
        StateSet(obj, OBJ_S_FOCUSED, false);
        GUI_ObjSetNeedRefresh(obj, true);
      }
    }
  }
}
예제 #2
0
/**
 * @function GUI_ObjSetDisabled
 * @brief set the flag <Disabled> of a generic object
 * @param const g_obj_st *obj: generic object
 * @param bool p: new flag value
 * @return none
 */
void GUI_ObjSetDisabled(g_obj_st /*@null@*/ *obj, bool p) {
  if(obj == NULL) obj = lastAddedObj;
  if(GUI_ObjIsDisabled(obj) != p) {
    StateSet(obj, OBJ_S_DISABLED, p);
    GUI_ObjSetNeedRefresh(obj, true);
  }
}
예제 #3
0
/****************************************************************************
 * NameViewWndProc Message Cracker Callback Functions
 *
 * Purpose:
 *  Functions to process each message received by the Container WndProc.
 *  This is a Win16/Win32 portable method for message handling.
 *
 * Return Value:
 *  Varies according to the message being processed.
 ****************************************************************************/
BOOL Nam_OnNCCreate( HWND hWnd, LPCREATESTRUCT lpCreateStruct )
{
    LPCONTAINER  lpCntNew, lpCntOld;

    // Get the existing container struct being passed in the create params.
    lpCntOld = (LPCONTAINER) lpCreateStruct->lpCreateParams;

    // If we are creating a split child alloc a new struct and load it.
    if( StateTest( lpCntOld, CNTSTATE_CREATINGSB ) )
    {
      lpCntNew = (LPCONTAINER) calloc( 1, LEN_CONTAINER );
      if( lpCntNew == NULL )
        return 0L;

      // Save the container pointer in the window extra bytes.
      SetWindowLong( hWnd, GWL_CONTAINERHMEM, (LONG)lpCntNew );

      // Load up the new container struct with the already existing
      // info that is in the passed in container struct.
      *lpCntNew = *lpCntOld;

      // Flag that the container is now in a split state.
      lpCntNew->bIsSplit = TRUE;    

      // Clear out all initial states.
      StateClear( lpCntNew, CNTSTATE_ALL );

      // If the 1st child is deferring paints, set it for the split wnd.
      if( StateTest( lpCntOld, CNTSTATE_DEFERPAINT ) )
        StateSet( lpCntNew, CNTSTATE_DEFERPAINT );
    }
    else
    {
      // Do not alloc a new container struct since we are creating the
      // 1st child and it shares the same one as the frame window.
      // All other split children alloc their own container structs.

      // Save the old container pointer in the window extra bytes.
      SetWindowLong( hWnd, GWL_CONTAINERHMEM, (LONG)lpCntOld );
    }
 
    return FORWARD_WM_NCCREATE( hWnd, lpCreateStruct, CNT_DEFWNDPROC );
}
예제 #4
0
    void Camera::operator ()()
    {
        if (!pContext->getContext()->isValid())
            return;
        pContext->makeCurrent();

        CHECK_GL();

        if (ptex)
        {
            if (pContext->getTextureID(ptex) != fbo->getColorTexture())
                fbo->setColorTarget(GL_TEXTURE_2D, pContext->getTextureID(ptex), ptex->getTextureWidth(), ptex->getTextureHeight());
        }

        fbo->bind();
        CHECK_GL();
        glClearColor(0,0,0,0);
        CHECK_GL();
        glClear(GL_COLOR_BUFFER_BIT);
        CHECK_GL();

        if (background)     // background image
        {
            glClear(GL_DEPTH_BUFFER_BIT);
            CHECK_GL();
            glMatrixMode(GL_PROJECTION);
            CHECK_GL();
            glLoadIdentity();
            CHECK_GL();
            gluOrtho2D(0.0, 1.0, 1.0, 0.0);
            CHECK_GL();
            glMatrixMode(GL_MODELVIEW);
            CHECK_GL();
            glLoadIdentity();
            CHECK_GL();

            const GLuint pid = pContext->getProgramID(background_program);
            glUseProgram(pid);
            glUniform1i(glGetUniformLocation(pid, "tex"), 0);
            const osg::Matrixf mat(viewMatrix);
            glUniformMatrix4fv(glGetUniformLocation(pid, "viewMatrix"), 1, GL_FALSE, mat.ptr());
            glUniform1f(glGetUniformLocation(pid, "fov"), fov * M_PI / 180.0);
            glUniform1f(glGetUniformLocation(pid, "aspectRatio"), aspectRatio);

            glActiveTexture(GL_TEXTURE0);
            CHECK_GL();
            glDisable(GL_TEXTURE_CUBE_MAP);
            CHECK_GL();
            glEnable(GL_TEXTURE_2D);
            CHECK_GL();
            glBindTexture(GL_TEXTURE_2D, pContext->getTextureID(background));
            CHECK_GL();
            glDisable(GL_CULL_FACE);
            CHECK_GL();

            glBegin(GL_QUADS);
            glVertex2f(0.f,0.f);
            glVertex2f(1.f,0.f);
            glVertex2f(1.f,1.f);
            glVertex2f(0.f,1.f);
            glEnd();

            glUseProgram(0);
        }
        else if (starmap)   // background star map
        {
            glClear(GL_DEPTH_BUFFER_BIT);
            CHECK_GL();
            glMatrixMode(GL_PROJECTION);
            CHECK_GL();
            projectionMatrix = Matrixd::perspective(fov, aspectRatio, 0.5f, 2.f);
            glLoadMatrixd(projectionMatrix.ptr());
            CHECK_GL();
            glMatrixMode(GL_MODELVIEW);
            CHECK_GL();
            glLoadMatrixd(viewMatrix.ptr());
            CHECK_GL();

            const GLuint pid = pContext->getProgramID(background_program);
            glUseProgram(pid);
            CHECK_GL();

            glActiveTexture(GL_TEXTURE0);
            CHECK_GL();
            glDisable(GL_TEXTURE_CUBE_MAP);
            CHECK_GL();
            glDisable(GL_TEXTURE_2D);
            CHECK_GL();
            glDisable(GL_CULL_FACE);
            CHECK_GL();

            glEnableClientState(GL_VERTEX_ARRAY);
            CHECK_GL();
            glEnableClientState(GL_COLOR_ARRAY);
            CHECK_GL();
            glDisableClientState(GL_NORMAL_ARRAY);
            CHECK_GL();
            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
            CHECK_GL();
            if (pContext->hasVBOSupport())
            {
                glBindBuffer(GL_ARRAY_BUFFER, pContext->getDataVBOID(starmap->getDataPointer(), starmap->getTotalDataSize()));
                CHECK_GL();
                glVertexPointer(3,GL_FLOAT,12,0);
                CHECK_GL();
                glColorPointer(3,GL_FLOAT,12,(const GLvoid*)12);
                CHECK_GL();
            }
            else
            {
                glVertexPointer(3,GL_FLOAT,12,starmap->getDataPointer());
                CHECK_GL();
                glColorPointer(3,GL_FLOAT,12,(const char*)(starmap->getDataPointer()) + 12);
                CHECK_GL();
            }

            glEnable(GL_COLOR_MATERIAL);
            CHECK_GL();
            glEnable(GL_POINT_SPRITE);
            CHECK_GL();
            glPointSize(4.0f);
            CHECK_GL();

            glDrawArrays(GL_POINTS, 0, starmap->size() / 2);
            CHECK_GL();

            glDisableClientState(GL_COLOR_ARRAY);
            CHECK_GL();
            glPointSize(1.0f);
            CHECK_GL();
            glDisable(GL_POINT_SPRITE);
            CHECK_GL();
            glDisable(GL_COLOR_MATERIAL);
            CHECK_GL();

            if (pContext->hasVBOSupport())
            {
                glBindBuffer(GL_ARRAY_BUFFER, 0);
                CHECK_GL();
            }

            glUseProgram(0);
        }

        std::vector<std::pair<double, double> > depthRange;
        qMatrix.clear();
        qMatrix.push_back(viewMatrix);

        computeDepthRanges(scene, depthRange);
        computeMinimumRanges(depthRange);

        for(std::vector<std::pair<double, double> >::const_iterator range = depthRange.begin()
            ; range != depthRange.end()
            ; ++range)
        {
            glClear(GL_DEPTH_BUFFER_BIT);
            CHECK_GL();
            glMatrixMode(GL_PROJECTION);
            CHECK_GL();
            projectionMatrix = Matrixd::perspective(fov, aspectRatio, range->first, range->second);
            glLoadMatrixd(projectionMatrix.ptr());
            CHECK_GL();

            znear = range->first;
            zfar = range->second;

            glMatrixMode(GL_MODELVIEW);
            CHECK_GL();
            clearMatrixStack();
            CHECK_GL();

            glDisable(GL_TEXTURE_2D);
            CHECK_GL();
            glDisable(GL_TEXTURE_CUBE_MAP);
            CHECK_GL();
            glDisable(GL_COLOR_MATERIAL);
            CHECK_GL();
            glColor4ub(0xFF, 0xFF, 0xFF, 0xFF);
            CHECK_GL();
            glDisable(GL_BLEND);
            CHECK_GL();
            glDisable(GL_LIGHTING);
            CHECK_GL();
            glDisable(GL_CULL_FACE);
            CHECK_GL();
            glShadeModel(GL_SMOOTH);
            CHECK_GL();
            glEnable(GL_DEPTH_TEST);
            CHECK_GL();
            glDepthFunc(GL_LESS);
            CHECK_GL();

            qStateSet.clear();
            qStateSet.push_back(StateSet());
            /** Cubemaps cannot be used to override the background texture
              * which is a GL_TEXTURE_2D so we just render to a GL_TEXTURE_2D,
              * use it as background texture and copy it to the cubemap
              */
            if (ptexcube)
                qStateSet.back().setTexture(7, GL_TEXTURE_2D, fbo->getColorTexture(), osg::StateAttribute::OVERRIDE);

            renderGraph(scene);
        }
        glDisableClientState(GL_COLOR_ARRAY);
        CHECK_GL();

        if (ptexcube)
        {
            glBindTexture(GL_TEXTURE_CUBE_MAP, pContext->getTextureID(ptexcube));
            CHECK_GL();
            glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cube_face_id, 0, 0, 0, 0, 0, fbo->getWidth(), fbo->getHeight());
            CHECK_GL();
        }

        fbo->release();

        glUseProgram(0);
        CHECK_GL();
        for(int i = 15 ; i >= 0 ; --i)
        {
            glActiveTexture(GL_TEXTURE0 + i);
            CHECK_GL();
            glDisable(GL_TEXTURE_2D);
            CHECK_GL();
            glDisable(GL_TEXTURE_CUBE_MAP);
            CHECK_GL();
        }
    }
예제 #5
0
/**
 * @function GUI_ObjSetStatic
 * @brief set the flag <Static> of a generic object
 * @param const g_obj_st *obj: generic object
 * @param bool p: new flag value
 * @return none
 */
void GUI_ObjSetStatic(g_obj_st /*@null@*/ *obj, bool p) {
  StateSet(obj, OBJ_S_STATIC, p);
}
예제 #6
0
/**
 * @function GUI_ObjSetNeedRefresh
 * @brief set the flag <NeedRefresh> of a generic object
 * @param const g_obj_st *obj: generic object
 * @param bool p: new flag value
 * @return none
 */
void GUI_ObjSetNeedRefresh(g_obj_st /*@null@*/ *obj, bool p) {
  if(obj == NULL) obj = lastAddedObj;
  StateSet(obj, OBJ_S_NEED_REFRESH, p);
}
예제 #7
0
/**
 * @function GUI_ObjSetBlink
 * @brief set the flag <Blink> of a generic object
 * @param const g_obj_st *obj: generic object
 * @param bool p: new flag value
 * @return none
 */
void GUI_ObjSetBlink(g_obj_st /*@null@*/ *obj, bool p) {
  if(GUI_ObjIsDisabled(obj) == false && GUI_ObjIsNotified(obj) && GUI_ObjIsBlink(obj) != p) {
    StateSet(obj, OBJ_S_BLINK, p);
    GUI_ObjSetNeedRefresh(obj, true);
  }
}
예제 #8
0
/**
 * @function GUI_ObjSetFocusable
 * @brief set the flag <Focusable> of a generic object
 * @param const g_obj_st *obj: generic object
 * @param bool p: new flag value
 * @return none
 */
void GUI_ObjSetFocusable(g_obj_st /*@null@*/ *obj, bool p) {
  if(obj == NULL) obj = lastAddedObj;
  StateSet(obj, OBJ_S_FOCUSABLE, p);
}
예제 #9
0
/**
 * @function GUI_ObjSetPressed
 * @brief set the flag <Pressed> of a generic object
 * @param const g_obj_st *obj: generic object
 * @param bool p: new flag value
 * @return none
 */
void GUI_ObjSetPressed(g_obj_st /*@null@*/ *obj, bool p) {
  if(GUI_ObjIsPressed(obj) != p) {
    StateSet(obj, OBJ_S_PRESSED, p);
    if(GUI_ObjIsStatic(obj) == false) GUI_ObjSetNeedRefresh(obj, true);
  }
}
예제 #10
0
/**
 * @function GUI_ObjSetNotified
 * @brief set the flag <Notified> of a generic object
 * @param const g_obj_st *obj: generic object
 * @param bool p: new flag value
 * @return none
 */
void GUI_ObjSetNotified(g_obj_st /*@null@*/ *obj, bool p) {
  if(obj == NULL) obj = lastAddedObj;
  GUI_ObjSetBlink(obj, p);  /*execute first !*/
  StateSet(obj, OBJ_S_NOTIFIED, p);
}