Beispiel #1
0
void motion(int x, int y)
{
  static GLint savepoint[2];

  glEnable(GL_COLOR_LOGIC_OP);
  glLogicOp(GL_INVERT);

  glBegin(GL_LINES);
  if(rubberband){
    glVertex2iv(point[pointnum - 1]);
    glVertex2iv(savepoint);
  }
  glVertex2iv(point[pointnum - 1]);
  glVertex2i(x, y);
  glEnd();

  glFlush();

  glLogicOp(GL_COPY);
  glDisable(GL_COLOR_LOGIC_OP);

  savepoint[0] = x;
  savepoint[1] = y;

  rubberband = 1;
}
/*----------------------------------------------------------------------
  DrawRotationCenter
  Draw/Clear the cross that indicate the center of rotation.
  *----------------------------------------------------------------------*/
void AmayaTransformEvtHandler::DrawRotationCenter()
{
  InitDrawing (5, 1, 0);
  glEnable(GL_COLOR_LOGIC_OP);
#ifdef _WINDOWS
  glLogicOp(GL_COPY_INVERTED);
#else /* _WINDOWS */
  glLogicOp(GL_XOR);
#endif /* _WINDOWS */

  glColor4ub (127, 127, 127, 0);

  /* Horizontal line */
  glBegin(GL_LINE_STRIP);
  glVertex2i(cx2-CURSOR_SIZE, cy2);
  glVertex2i(cx2+CURSOR_SIZE, cy2);
  glEnd ();

  /* Vertical line */
  glBegin(GL_LINE_STRIP);
  glVertex2i(cx2, cy2-CURSOR_SIZE);
  glVertex2i(cx2, cy2+CURSOR_SIZE);
  glEnd ();

  glDisable(GL_COLOR_LOGIC_OP);

#ifdef _WINDOWS
  GL_Swap (FrameId);
#endif /* WINDOWS */
}
/*----------------------------------------------------------------------
  DrawSkewingArrows
  Draw/Clear the four arrows arround the objet that indicate the skewing
  direction.
  *----------------------------------------------------------------------*/
void AmayaTransformEvtHandler::DrawSkewingArrows()
{
  InitDrawing (5, 1, 0);

  glEnable(GL_COLOR_LOGIC_OP);
#ifdef _WINDOWS
  glLogicOp(GL_COPY_INVERTED);
#else /* _WINDOWS */
  glLogicOp(GL_XOR);
#endif /* _WINDOWS */

  glColor4ub (127, 127, 127, 0);

  /*
    ----3-----
    |        |
    1        2
    |        |
    ----4-----

  */

  /* 1 */
  DrawArrow (FrameId, 1, 5,
             left2 - CURSOR_SIZE/2,
             (top2+bottom2)/2 - CURSOR_SIZE,
             CURSOR_SIZE,
             2*CURSOR_SIZE,
             90, 3, 0);

  /* 2 */
  DrawArrow (FrameId, 1, 5,
             right2 - CURSOR_SIZE/2,
             (top2+bottom2)/2 - CURSOR_SIZE,
             CURSOR_SIZE,
             2*CURSOR_SIZE,
             90, 3, 0);

  /* 3 */
  DrawArrow (FrameId, 1, 5,
             (left2+right2)/2 - CURSOR_SIZE,
             top2 - CURSOR_SIZE/2,
             2*CURSOR_SIZE,
             CURSOR_SIZE,
             0, 3, 0);

  /* 4 */
  DrawArrow (FrameId, 1, 5,
             (left2+right2)/2 - CURSOR_SIZE,
             bottom2 - CURSOR_SIZE/2,
             2*CURSOR_SIZE,
             CURSOR_SIZE,
             0, 3, 0);

  glDisable(GL_COLOR_LOGIC_OP);

#ifdef _WINDOWS
  GL_Swap (FrameId);
#endif /* WINDOWS */
}
Beispiel #4
0
void motion(int x, int y) {
    static GLint savepoint[2]; /* 以前のラバーバンドの端点 */
    /* 論理演算機能 ON */
    glEnable(GL_COLOR_LOGIC_OP);
    glLogicOp(GL_INVERT);
    glBegin(GL_LINES);
    if (rubberband) {
        /* 以前のラバーバンドを消す */
        glVertex2iv(point[pointnum - 1]);
        glVertex2iv(savepoint);
    }
    /* 新しいラバーバンドを描く */
    glVertex2iv(point[pointnum - 1]);
    glVertex2i(x, y);
    glEnd();
    glFlush();
    /* 論理演算機能 OFF */
    glLogicOp(GL_COPY);
    glDisable(GL_COLOR_LOGIC_OP);
    /* 今描いたラバーバンドの端点を保存 */
    savepoint[0] = x;
    savepoint[1] = y;
    /* 今描いたラバーバンドは次のタイミングで消す */
    rubberband = 1;
}
Beispiel #5
0
void NLS::Graphics::Draw() {
	glClear(GL_COLOR_BUFFER_BIT);
	View::Step();
	Portal::Update();
	if (Mindfuck) {
		srand(floor(Time::tdelta*3));
		rand();
		float r = rand()*(1-fmod(Time::tdelta*3, 1));
		float g = rand()*(1-fmod(Time::tdelta*3, 1));
		float b = rand()*(1-fmod(Time::tdelta*3, 1));
		srand(floor(Time::tdelta*3)+1);
		rand();
		r += rand()*fmod(Time::tdelta*3, 1);
		g += rand()*fmod(Time::tdelta*3, 1);
		b += rand()*fmod(Time::tdelta*3, 1);
		r /= RAND_MAX;
		g /= RAND_MAX;
		b /= RAND_MAX;
		glColor4f(r, g, b, 1);
		srand(Time::tdelta*10000);
		if ((double)rand()/RAND_MAX < 0.2) {
			glLogicOp(GL_XOR);
		} else {
			glLogicOp(GL_OR);
		}
	}
	Map::Draw();
	View::Reset();
	UI::Draw();
	Mouse::Draw();
	Time::Step();
	if (Map::fade > 0 and !Profiling) {
		glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
		glBlendFunc(GL_ONE, GL_ONE);
		glBindTexture(GL_TEXTURE_2D, 0);
		glColor4f(Map::fade, Map::fade, Map::fade, 0);
		glBegin(GL_QUADS);
		glVertex2i(0, 0);
		glVertex2i(View::width, 0);
		glVertex2i(View::width, View::height);
		glVertex2i(0, View::height);
		glEnd();
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glBlendEquation(GL_FUNC_ADD);
		Map::fade -= 2*Time::delta;
	}
	window->SetTitle("NoLifeStory::FrameRate = "+tostring((int)Time::fps));
	window->Display();
#ifdef DEBUG
	switch (glGetError()) {
	case GL_NO_ERROR:
		break;
	default:
		cerr << "OH GOD OPENGL FAILED" << endl;
	}
#endif
}
void mouse(int btn, int state, int x, int y)
{

	if(btn==GLUT_LEFT_BUTTON && state == GLUT_DOWN) 
	{
		switch(first)
		{
		case 0: 
			xm = x/500.;
			ym = (500-y)/500.;
			first = 1;
			break;
		case 1:
			xmm = x/500.0;
			ymm = (500-y)/500.0;
			glBegin(GL_LINES);
			glVertex2f(xm, ym);
			glVertex2f(xmm, ymm);
			glEnd();
			glFlush();
			first = 2;
			break;
		case 2:
			glBegin(GL_LINES);
			glVertex2f(xm, ym);
			glVertex2f(xmm, ymm);
			glEnd();
			glFlush();
			xmm = x/500.0;
			ymm = (500-y)/500.0;
			glBegin(GL_LINES);
			glVertex2f(xm, ym);
			glVertex2f(xmm, ymm);
			glEnd();
			glFlush();
			break;
		}
	}
	if(btn==GLUT_RIGHT_BUTTON && state == GLUT_DOWN) 
	{
		glLogicOp(GL_COPY);
		glColor3f(0.0, 0.0, 1.0);
		glBegin(GL_LINES);
		glVertex2f(xm, ym);
		glVertex2f(xmm, ymm);
		glEnd();
		glFlush();
		first = 0;
		glLogicOp(GL_XOR);
		glColor3f(0.0, 1.0, 0.0);
	}
}
void move(int x,int y)
{
	if(f==1)
	{
		glLogicOp(GL_XOR);
		glRectf(xm,ym,xmm,ymm);
	}
	xmm=x;
	ymm=ymax-y;
	glLogicOp(GL_XOR);
		glRectf(xm,ym,xmm,ymm);
		glFlush();
	f=1;
}
Beispiel #8
0
void GUIQuad::render(RenderPass pass) {
	bool isTransparent = (_a < 1.0) || (!_texture.empty() && _texture.getTexture().hasAlpha());
	if (((pass == kRenderPassOpaque)      &&  isTransparent) ||
			((pass == kRenderPassTransparent) && !isTransparent))
		return;

	TextureMan.set(_texture);

	glColor4f(_r, _g, _b, _a);

	if (_xor) {
		glEnable(GL_COLOR_LOGIC_OP);
		glLogicOp(GL_XOR);
	}

	glBegin(GL_QUADS);
		glTexCoord2f(_tX1, _tY1);
		glVertex2f(_x1, _y1);
		glTexCoord2f(_tX2, _tY1);
		glVertex2f(_x2, _y1);
		glTexCoord2f(_tX2, _tY2);
		glVertex2f(_x2, _y2);
		glTexCoord2f(_tX1, _tY2);
		glVertex2f(_x1, _y2);
	glEnd();

	if (_xor)
		glDisable(GL_COLOR_LOGIC_OP);

	glColor4f(1.0, 1.0, 1.0, 1.0);
}
Beispiel #9
0
void draw(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    
    glColor3f(0.0, 0.4, 0.2);
    glEnable(GL_COLOR_LOGIC_OP);
    glLogicOp(GL_CLEAR);
    glBegin(GL_QUADS);
    
    //    glVertex2i(50, 50);
    //    glVertex2i(50, 100);
    //
    //    glVertex2i(100, 100);
    //    glVertex2i(100, 50);
    //    glVertex2i(150, 50);
    //    glVertex2i(150, 100);
    //    glVertex2i(200, 50);
    //    glVertex2i(200, 100);
    
    glRasterPos2i(100, 300);
    for (int k = 0; k < 36; k++)
    {
        glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'k');
    }
    
    glEnd();
    
    glFlush();
}
Beispiel #10
0
void OpenGLWrapper::SetInvert() {
	glEnable(GL_COLOR_LOGIC_OP);
	glLogicOp(GL_INVERT);

	// GL_LINE_SMOOTH combines badly with inverting
	smooth = false;
}
Beispiel #11
0
static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int height, float zoomx, float zoomy)
{
	int x, y;
	MovieClip *clip = ED_space_clip_get_clip(sc);

	/* find window pixel coordinates of origin */
	UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);

	/* draw boundary border for frame if stabilization is enabled */
	if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
		glColor3f(0.0f, 0.0f, 0.0f);
		glLineStipple(3, 0xaaaa);
		glEnable(GL_LINE_STIPPLE);
		glEnable(GL_COLOR_LOGIC_OP);
		glLogicOp(GL_NOR);

		glPushMatrix();
		glTranslatef(x, y, 0.0f);

		glScalef(zoomx, zoomy, 1.0f);
		glMultMatrixf(sc->stabmat);

		glBegin(GL_LINE_LOOP);
		glVertex2f(0.0f, 0.0f);
		glVertex2f(width, 0.0f);
		glVertex2f(width, height);
		glVertex2f(0.0f, height);
		glEnd();

		glPopMatrix();

		glDisable(GL_COLOR_LOGIC_OP);
		glDisable(GL_LINE_STIPPLE);
	}
}
Beispiel #12
0
/*
 * Draw rubberband box in front buffer
 */
static void
DrawRect(const struct rect *r)
{
   glDrawBuffer(GL_FRONT);

   if (LogicOp) {
      glLogicOp(GL_XOR);
      glEnable(GL_COLOR_LOGIC_OP);
   }
   else {
      glEnable(GL_BLEND);
      glBlendFunc(GL_ONE, GL_ONE);
      glBlendEquation(GL_FUNC_SUBTRACT);
   }

   glColor3f(1, 1, 1);

   glLineWidth(3.0);

   glBegin(GL_LINE_LOOP);
   glVertex2i(r->x0, r->y0);
   glVertex2i(r->x1, r->y0);
   glVertex2i(r->x1, r->y1);
   glVertex2i(r->x0, r->y1);
   glEnd();

   glDisable(GL_COLOR_LOGIC_OP);
   glDisable(GL_BLEND);

   glDrawBuffer(GL_BACK);
}
Beispiel #13
0
void rendering::UpdateColorLogicOperationParameters()
{
	if (glColorLogicOperationEnabled == glColorLogicOperationEnabledOld && glColorLogicOperationCode == glColorLogicOperationCodeOld)
	{
		return;
	}

	const GLenum glPropertyEnum = GL_COLOR_LOGIC_OP;
	if (glColorLogicOperationEnabled)
	{
		glEnable(glPropertyEnum);
		NOTICE_LOG_RENDERING("GL_COLOR_LOGIC_OP is now enabled");
	}
	else
	{
		glDisable(glPropertyEnum);
		NOTICE_LOG_RENDERING("GL_COLOR_LOGIC_OP is now disabled");
	}
	glColorLogicOperationEnabledOld = glColorLogicOperationEnabled;

	// Now we check if logic operation code has been changed
	if (glColorLogicOperationCode != glColorLogicOperationCodeOld)
	{
		glLogicOp(glColorLogicOperationCode);
		NOTICE_LOG_RENDERING("Color logic operation ", glColorLogicOperationCode, " is chosen");
		glColorLogicOperationCodeOld = glColorLogicOperationCode;
	}
}
Beispiel #14
0
void GUIQuad::renderImmediate(const glm::mat4 &parentTransform) {
	if (_xor) {
		glEnable(GL_COLOR_LOGIC_OP);
		glLogicOp(GL_XOR);
	}

	if (_scissor) {
		glEnable(GL_SCISSOR_TEST);
		GLint viewport[4];
		glGetIntegerv(GL_VIEWPORT, viewport);
		glScissor(viewport[2]/2 + _x1 + _scissorX,
		          viewport[3]/2 + _y1 + _scissorY,
		          _scissorWidth,
		          _scissorHeight);
	}

	glm::mat4 renderTransform = parentTransform;
	renderTransform = glm::translate(renderTransform, glm::vec3(_x1, _y1, 0.0f));
	renderTransform = glm::scale(renderTransform, glm::vec3(_x2 - _x1, _y2 - _y1, 1.0f));
	if (_angle != 0.0f) {
		renderTransform = glm::translate(renderTransform, glm::vec3(0.5f, 0.5f, 0.0f));
		renderTransform = glm::rotate(renderTransform, Common::deg2rad(_angle), glm::vec3(0.0f, 0.0f, 1.0f));
		renderTransform = glm::translate(renderTransform, glm::vec3(-0.5f, -0.5f, 0.0f));
	}
	_shaderRenderable.renderImmediate(renderTransform);

	if (_xor) {
		glDisable(GL_COLOR_LOGIC_OP);
	}

	if (_scissor)
		glDisable(GL_SCISSOR_TEST);
}
Beispiel #15
0
static int LogicOp(lua_State *L)
    {
    GLenum opcode = checklogicop(L, 1);
    glLogicOp(opcode);
    CheckError(L);
    return 0;
    }
void LogicOpChunk::deactivate(DrawEnv *drawEnv, UInt32 index)
{
    if(_sfLogicOp.getValue() != GL_COPY)
    {
        glDisable(GL_COLOR_LOGIC_OP);
        glLogicOp(GL_COPY          );
    }
}
Beispiel #17
0
void LogicOpChunk::deactivate ( DrawActionBase *, UInt32 )
{
    if(_sfLogicOp.getValue() != GL_COPY)
    {
        glDisable(GL_COLOR_LOGIC_OP);
        glLogicOp(GL_COPY          );
    }
}
void display()
{
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(1.0, 0.0, 0.0);
	glRectf(0.25, 0.25, 0.75, 0.75);
	glLogicOp(GL_XOR);
	glColor3f(1.0, 1.0, 0.0);
	glFlush();
}
Beispiel #19
0
	////////////////////////////////////////////////////////////////////////
	///
	/// @fn void initialiserRectangleElastique(const Vecteur2i& point, unsigned short patron, int facteur)
	///
	/// Cette fonction initialise le mode de rendu du rectangle élastique en
	/// mode XOR en sauvegardant l'état de la machine OpenGL et en la modifiant
	/// pour que le rendu soit correct.
	///
	/// @param[in] point   : Point initial de localisation du rectangle.
	/// @param[in] patron  : Patron de pointillé pour les lignes du rectangle.
	/// @param[in] facteur : Facteur du pointillé pour les lignes du rectangle.
	///
	/// @return Aucune.
	///
	////////////////////////////////////////////////////////////////////////
	void initialiserRectangleElastique(
		const Vecteur2i& point,
		unsigned short   patron, //= 0x3333
		int              facteur //= 1
		)
	{
		// On sauvegarde les attributs de traçage.
		glPushAttrib( GL_LINE_BIT |
			GL_CURRENT_BIT |
			GL_COLOR_BUFFER_BIT |
			GL_DEPTH_BUFFER_BIT |
			GL_LIGHTING_BIT | 
			GL_ENABLE_BIT);

		// On dessine uniquement dans ce qui est déjà à l'écran.
		glDrawBuffer( GL_FRONT );

		// On désactive l'éclairage, le test de profondeur et les textures.
		glDisable( GL_DEPTH_TEST );
		glDisable( GL_LIGHTING );
		glDisable( GL_TEXTURE_2D );

		glMatrixMode( GL_MODELVIEW );
		glLoadIdentity();
		glMatrixMode( GL_PROJECTION );

		// On initialise la matrice de projection: 1 pixel = 1 unité virtuelle.
		GLint Cloture[4];
		glGetIntegerv(GL_VIEWPORT, Cloture);
		glLoadIdentity();
		gluOrtho2D( 0.0, (GLdouble) Cloture[2], (GLdouble) Cloture[3], 0.0 );

		// On trace le rectangle en pointillés.
		glEnable( GL_LINE_STIPPLE );
		glLineStipple( 1, 0x3333 );

		// On choisit la couleur blanche pour que le XOR soit une inversion des
		// bits de la couleur déjà présente dans la mémoire de trame.
		glColor3f( 1.0, 1.0, 1.0 );

		// On active le mode XOR.
		glEnable( GL_COLOR_LOGIC_OP );
		glLogicOp( GL_XOR );

		// On trace le rectangle en un seul point.
		glBegin(GL_LINE_LOOP);
		{
			glVertex2i(point[0], point[1]);
			glVertex2i(point[0], point[1]);
			glVertex2i(point[0], point[1]);
			glVertex2i(point[0], point[1]);
		}
		glEnd();

		// On veut que le rectangle soit immédiatement visible.
		glFlush();
	}
void mousefunc(int button,int status,int x,int y)
{
	if(button==GLUT_LEFT_BUTTON && status==GLUT_DOWN)
	{
		xm=x;
		ym=ymax-y;
		f=0;
	}
	if(button==GLUT_LEFT_BUTTON && status==GLUT_UP)
	{
		glLogicOp(GL_XOR);
		glRectf(xm,ym,xmm,ymm);

		glLogicOp(GL_COPY);
		glRectf(xm,ym,x,ymax-y);
		
		glFlush();
		f=0;
	}
}
Beispiel #21
0
static int cdwritemode(cdCtxCanvas *ctxcanvas, int write_mode)
{
  switch (write_mode)
  {
  case CD_REPLACE:
    if(glIsEnabled(GL_COLOR_LOGIC_OP))
      glDisable(GL_COLOR_LOGIC_OP);
    break;
  case CD_XOR:
    glEnable(GL_COLOR_LOGIC_OP);
    glLogicOp(GL_XOR);
    break;
  case CD_NOT_XOR:
    glEnable(GL_COLOR_LOGIC_OP);
    glLogicOp(GL_EQUIV);
    break;
  }

  (void)ctxcanvas;
  return write_mode;
}
Beispiel #22
0
void
H19::display()
{
    pthread_mutex_lock(&h19_mutex);
    GLfloat color[3] = { 1.0, 1.0, 0.0 };  // amber
    //GLfloat color[3] = {0.0, 1.0, 0.0}; // green
    // GLfloat color[3] = { 1.0, 1.0, 1.0 };  // white
    // GLfloat color[3] = { 0.5, 0.0, 1.0 };  // purple
    // GLfloat color[3] = { 0.0, 0.8, 0.0 };
    // GLfloat color[3] = { 0.9, 0.9, 0.0 };  // amber

    glClear(GL_COLOR_BUFFER_BIT);
    glColor3fv(color);

    glRasterPos2i(20, 24 * 20 + 20);

    glPushAttrib(GL_LIST_BIT);
    glListBase(h19->fontOffset_m);
    glCallLists(26 * cols_c, GL_UNSIGNED_INT, (GLuint*) screen_m);
    glPopAttrib();
    glEnable(GL_COLOR_LOGIC_OP);

    if ((!cursorOff_m) && (curCursor_m))
    {

        glRasterPos2i(20 + min(posX_m, 79) * 8, (24 - posY_m) * 20 + 20);

        glPushAttrib(GL_LIST_BIT);
        //  glEnable(GL_COLOR_LOGIC_OP);
        glLogicOp(GL_COPY);
        glListBase(fontOffset_m);
        GLuint cursor = (cursorBlock_m) ? (128 + 32) : 27;
        glCallLists(1, GL_UNSIGNED_INT, &cursor);
        glPopAttrib();
    }

    glLogicOp(GL_COPY);
    glutSwapBuffers();
    pthread_mutex_unlock(&h19_mutex);
}
Beispiel #23
0
    void drawCacheStatistics()
    {
        glLogicOp( GL_XOR );
        glEnable( GL_COLOR_LOGIC_OP );
        glDisable( GL_LIGHTING );
        glDisable( GL_DEPTH_TEST );

        glColor3f( 1.f, 1.f, 1.f );

        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        _channel->applyScreenFrustum();
        glMatrixMode( GL_MODELVIEW );

        livre::Node* node = static_cast< livre::Node* >( _channel->getNode( ));
        std::ostringstream os;
        const size_t all = _frameInfo.allNodes.size();
        const size_t missing = _frameInfo.notAvailableRenderNodes.size();
        const float done = all > 0 ? float( all - missing ) / float( all ) : 0;
        os << node->getTextureDataCache().getStatistics() << "  "
           << int( 100.f * done + .5f ) << "% loaded" << std::endl;
        float y = 220;
        _drawText( os.str(), y );

        Window* window = static_cast< Window* >( _channel->getWindow( ));
        os.str("");
        os << window->getTextureCache().getStatistics();
        _drawText( os.str(), y );

        ConstVolumeDataSourcePtr dataSource = static_cast< livre::Node* >(
            _channel->getNode( ))->getDashTree()->getDataSource();
        const VolumeInformation& info = dataSource->getVolumeInformation();
        Vector3f voxelSize = info.boundingBox.getDimension() / info.voxels;
        std::string unit = "m";
        if( voxelSize.x() < 0.000001f )
        {
            unit = "um";
            voxelSize *= 1000000;
        }
        if( voxelSize.x() < 0.001f )
        {
            unit = "mm";
            voxelSize *= 1000;
        }

        os.str("");
        os << "Total resolution " << info.voxels << " depth "
           << info.rootNode.getDepth() << std::endl
           << "Block resolution " << info.maximumBlockSize << std::endl
           << unit << "/voxel " << voxelSize;
        _drawText( os.str( ), y );
    }
void CMyFillTriangle::Draw()
{

	glLogicOp(GL_COPY);
	glColor3f(this->color.r,this->color.g,this->color.b);
	glLineWidth(this->Width);
	glBegin(GL_POLYGON);
	  glVertex2f(m_x0,m_y0);
	  glVertex2f(m_x1,m_y1);
   	  glVertex2f(m_x2,m_y2);
	glEnd();



}
Beispiel #25
0
void Window::drawFPS()
{
    std::ostringstream fpsText;
    fpsText << std::setprecision(3) << getFPS() << " FPS";

    const util::BitmapFont* font = getSmallFont();
    const PixelViewport& pvp = getPixelViewport();

    glLogicOp( GL_XOR );
    glEnable( GL_COLOR_LOGIC_OP );
    glRasterPos3f( pvp.w - 60.f, pvp.h - 16.f , 0.99f );
    glColor3f( .8f, .8f, .8f );

    font->draw( fpsText.str( ));
}
Beispiel #26
0
static void rubberMotion(int x,int y) {
  pScene      sc;
  pPersp      p;

  sc = cv.scene[currentScene()];
  p  = sc->persp;

  glEnable(GL_COLOR_LOGIC_OP);
  glLogicOp(GL_XOR);

  /* draw frame */
  drawRubberBand(rxi,ryi,rx1,ry1);
  rx2 = x;
  ry2 = sc->par.ys-y;
  drawRubberBand(rxi,ryi,rx2,ry2);
  glFlush();

  glLogicOp(GL_COPY);
  glDisable(GL_COLOR_LOGIC_OP);

  /* keep old coords */
  rx1 = rx2;
  ry1 = ry2;
}
Beispiel #27
0
/**
 * If enabled, apply the currently selected logical operation to the computed fragment color and color buffer values.
 * See https://www.opengl.org/sdk/docs/man3/xhtml/glLogicOp.xml
 */
void rendering::ReadColorLogicOperationParameter()
{
	glColorLogicOperationEnabled = GET_CONFIG_VALUE_RENDERING("GL_COLOR_LOGIC_OP_ENABLED", false);
	glColorLogicOperationEnabledOld = glColorLogicOperationEnabled;
	if (!glColorLogicOperationEnabled)
	{
		glDisable(GL_COLOR_LOGIC_OP);
		DEBUG_LOG_RENDERING("GL_COLOR_LOGIC_OP disabled");
		return;
	}

	glEnable(GL_COLOR_LOGIC_OP);
	auto logicalOperationStr = GET_CONFIG_VALUE_STR_RENDERING("GL_COLOR_LOGIC_OPERATION", "GL_COPY");
	if (logicalOperationStr == "GL_CLEAR") { glColorLogicOperationCode = GL_CLEAR; }
	else if (logicalOperationStr == "GL_SET") { glColorLogicOperationCode = GL_SET; }
	else if (logicalOperationStr == "GL_COPY") { glColorLogicOperationCode = GL_COPY; }
	else if (logicalOperationStr == "GL_COPY_INVERTED") { glColorLogicOperationCode = GL_COPY_INVERTED; }
	else if (logicalOperationStr == "GL_NOOP") { glColorLogicOperationCode = GL_NOOP; }
	else if (logicalOperationStr == "GL_INVERT") { glColorLogicOperationCode = GL_INVERT; }
	else if (logicalOperationStr == "GL_AND") { glColorLogicOperationCode = GL_AND; }
	else if (logicalOperationStr == "GL_NAND") { glColorLogicOperationCode = GL_NAND; }
	else if (logicalOperationStr == "GL_OR") { glColorLogicOperationCode = GL_OR; }
	else if (logicalOperationStr == "GL_NOR") { glColorLogicOperationCode = GL_NOR; }
	else if (logicalOperationStr == "GL_XOR") { glColorLogicOperationCode = GL_XOR; }
	else if (logicalOperationStr == "GL_EQUIV") { glColorLogicOperationCode = GL_EQUIV; }
	else if (logicalOperationStr == "GL_AND_REVERSE") { glColorLogicOperationCode = GL_AND_REVERSE; }
	else if (logicalOperationStr == "GL_AND_INVERTED") { glColorLogicOperationCode = GL_AND_INVERTED; }
	else if (logicalOperationStr == "GL_OR_REVERSE") { glColorLogicOperationCode = GL_OR_REVERSE; }
	else if (logicalOperationStr == "GL_OR_INVERTED") { glColorLogicOperationCode = GL_OR_INVERTED; }
	else /* GL_COPY is default */
	{
		ERROR_LOG_RENDERING("Invalid enum \"", logicalOperationStr, "\" given for the color logic operation parameter. Using default GL_COPY");
		logicalOperationStr = "GL_COPY";
		glColorLogicOperationCode = GL_COPY;
	}

	glColorLogicOperationCodeOld = glColorLogicOperationCode;

	glLogicOp(glColorLogicOperationCode);

	INFO_LOG_RENDERING("GL_COLOR_LOGIC_OP enabled in \"", logicalOperationStr, "\" mode");
	CheckErrorCode(__FUNCTION__, "Initializing color logic parameters");
}
Beispiel #28
0
// draw an interact instance
static OfxStatus interactDraw(OfxImageEffectHandle  effect, OfxInteractHandle interactInstance, OfxPropertySetHandle drawArgs)
{
	// get my private interact data
	MyInteractData *data = getInteractData(interactInstance);
	Instance *instance = (Instance*)ofxuGetEffectInstanceData(effect);

	if (data->Down)
	{
		double penPos[2];
		gPropHost->propGetDoubleN(drawArgs, kOfxInteractPropPenPosition, 2, penPos);

		// Get the image size
		const std::pair<int, int> &size = instance->Mask.getSize ();
		const float x0 = (float)data->DownX;
		const float y0 = size.second-(float)data->DownY-1;
		const float x1 = (float)penPos[0];
		const float y1 = (float)penPos[1];

		glPushAttrib (GL_ENABLE_BIT|GL_CURRENT_BIT);
			// if the we have selected the Xhair, draw it highlit
			glColor3f(1, 1, 1);
		
			glEnable(GL_COLOR_LOGIC_OP);
			glLogicOp(GL_XOR);
			glLineStipple(1, 0xF0F0);
			glEnable(GL_LINE_STIPPLE);

			glBegin(GL_LINE_STRIP);

				glVertex2f(x0, y0);
				glVertex2f(x1, y0);
				glVertex2f(x1, y1);
				glVertex2f(x0, y1);
				glVertex2f(x0, y0);

			glEnd();
		glPopAttrib ();
	}

	return kOfxStatOK;
}
Beispiel #29
0
static void LineLoop(void)
{

    glBegin(GL_LINE_LOOP);
	SetColor(COLOR_RED);
	glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4));
	SetColor(COLOR_GREEN);
	glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4));
	SetColor(COLOR_BLUE);
	glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4));
	SetColor(COLOR_WHITE);
	glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4));
    glEnd();

    glEnable(GL_LOGIC_OP);
    glLogicOp(GL_XOR);

    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ONE);

    SetColor(COLOR_MAGENTA);
    glBegin(GL_LINE_LOOP);
	glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(-boxH/8));
	glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8));
    glEnd();
    glBegin(GL_LINE_LOOP);
	glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8+5));
	glVertex2f(PIXEL_CENTER(boxW/8), PIXEL_CENTER(boxH/8+5));
    glEnd();
    glDisable(GL_LOGIC_OP);
    glDisable(GL_BLEND);

    SetColor(COLOR_GREEN);
    glBegin(GL_POINTS);
	glVertex2i(0, 0);
    glEnd();

    glBegin(GL_LINE_LOOP);
	glVertex2i(0, 0);
    glEnd();
}
void DrawMenus(void)
{
   int x, y;

   if(GameMode)
      return;

   x = Menus[ActiveMenu].x;
   y = Menus[ActiveMenu].y;

   /* save old settings */
   glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT
		| GL_ENABLE_BIT | GL_VIEWPORT_BIT);

   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glLoadIdentity();

   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadMatrixd(MenuProjection);
   glViewport(0, 0, VarInfo.xres, VarInfo.yres);

   glDisable(GL_DEPTH_TEST);
   glDisable(GL_ALPHA_TEST);
   glDisable(GL_LIGHTING);
   glDisable(GL_FOG);
   glDisable(GL_TEXTURE_2D);
   glEnable(GL_COLOR_LOGIC_OP);
   glLogicOp(GL_AND_REVERSE);

   if(DrawMenu(ActiveMenu, x, &y))
      Menus[ActiveMenu].selected = -1;
    
   /* restore settings */
   glPopMatrix();
   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();

   glPopAttrib();
}