Exemple #1
0
/*! 
  Draws the listbox
  \return  None
  \author  jfpatry
  \date    Created:  2000-09-18
  \date    Modified: 2000-09-18
*/
void listbox_draw( listbox_t *listbox )
{
    font_t *font;

    check_assertion( listbox != NULL, "listbox is NULL" );

    glDisable( GL_TEXTURE_2D );
    
    if(listbox->background_colour.a != 0.0) {
        glColor4dv( (scalar_t*)&listbox->border_colour );
        
        glRectf( listbox->pos.x, 
             listbox->pos.y,
             listbox->pos.x + listbox->w - listbox->arrow_width,
             listbox->pos.y + listbox->h );

        glColor4dv( (scalar_t*)&listbox->background_colour );

        glRectf( listbox->pos.x + listbox->border_width, 
             listbox->pos.y + listbox->border_width,
             listbox->pos.x + listbox->w - listbox->border_width -
             listbox->arrow_width,
             listbox->pos.y + listbox->h - listbox->border_width );
    }
    
    glEnable( GL_TEXTURE_2D );

    if ( !get_font_binding( listbox->font_binding, &font ) ) {
	print_warning( IMPORTANT_WARNING,
		       "Couldn't get font object for binding %s",
		       listbox->font_binding );
    } else {
	int w, asc, desc;
	char *string;

	string = listbox->label_gen_func( 
	    get_list_elem_data( listbox->cur_item ) );

	get_font_metrics( font, string, &w, &asc, &desc );

	bind_font_texture( font );

	glColor4f( 1.0, 1.0, 1.0, 1.0 );

	glPushMatrix();
	{
	    glTranslatef( 
		listbox->pos.x + listbox->border_width + listbox->text_pad,
		listbox->pos.y + listbox->h/2.0 - asc/2.0 + desc/2.0,
		0 );

	    draw_string( font, string );
	}
	glPopMatrix();
    }

    button_draw( listbox->up_button );
    button_draw( listbox->down_button );
}
void CCredits::DrawCreditsText (double time_step) {
    double w = (double)Winsys.resolution.width;
    double h = (double)Winsys.resolution.height;
	double offs = 0.0;
	if (moving) y_offset += time_step * 30;


	for (list<TCredits>::const_iterator i = CreditList.begin(); i != CreditList.end(); ++i) {
		offs = h - 100 - y_offset + i->offs;
		if (offs > h || offs < 0.0) // Draw only visible lines
			continue;

		if (i->col == 0)
			FT.SetColor (colWhite);
		else
			FT.SetColor (colDYell);
		FT.AutoSizeN (i->size);
		FT.DrawString (-1, (int)offs, i->text);
	}


    glDisable (GL_TEXTURE_2D);
	glColor4dv ((double*)&colBackgr);
    glRectf (0, 0, w, BOTT_Y);

    glBegin( GL_QUADS );
		glVertex2f (0, BOTT_Y);
		glVertex2f (w, BOTT_Y);
		glColor4f (colBackgr.r, colBackgr.g, colBackgr.b, 0);
		glVertex2f (w, BOTT_Y + 30);
		glVertex2f (0, BOTT_Y + 30);
    glEnd();

    glColor4dv ((double*)&colBackgr);
    glRectf (0, h - TOP_Y, w, h);

	glBegin( GL_QUADS );
		glVertex2f (w, h - TOP_Y);
		glVertex2f (0, h - TOP_Y);
		glColor4f (colBackgr.r, colBackgr.g, colBackgr.b, 0);
		glVertex2f (0, h - TOP_Y - 30);
		glVertex2f (w, h - TOP_Y - 30);
    glEnd();

	glColor4f (1, 1, 1, 1);
    glEnable (GL_TEXTURE_2D);
	if (offs < TOP_Y) y_offset = 0;
}
void SimpleDraw::DrawCircle( const Vec3d& center, double radius, const Vec4d& c, const Vec3d& n, float lineWidth )
{
	Vec3d startV(0,0,0);

	// Find orthogonal start vector
	if ((abs(n.y()) >= 0.9f * abs(n.x())) && 
		abs(n.z()) >= 0.9f * abs(n.x())) startV = Vec3d(0.0f, -n.z(), n.y());
	else if ( abs(n.x()) >= 0.9f * abs(n.y()) && 
		abs(n.z()) >= 0.9f * abs(n.y()) ) startV = Vec3d(-n.z(), 0.0f, n.x());
	else startV = Vec3d(-n.y(), n.x(), 0.0f);

	int segCount = 20;
	double theta = 2.0 * M_PI / segCount;

	glDisable(GL_LIGHTING);
	glLineWidth(lineWidth);
	glColor4dv(c);

	glBegin(GL_LINE_LOOP);
	for(int i = 0; i < segCount; i++){
		glVertex3dv(center + startV * radius );
		ROTATE_VEC(startV, theta, n);
	}
	glEnd();

	glEnable(GL_LIGHTING);
}
/*
    PsychSetGLColor()
    
    Accept a Psych color structure and a depth value and call the appropriate variant of glColor.       
*/
void PsychSetGLColor(PsychColorType *color, PsychWindowRecordType *windowRecord)
{
    int numVals;
    
    numVals=PsychConvertColorToDoubleVector(color, windowRecord, (GLdouble*) &(windowRecord->currentColor));
    if(numVals < 3 || numVals > 4) PsychErrorExitMsg(PsychError_internal, "Palette mode not yet implemented or illegal color specifier.");

	// Set the color in GL:
	if (windowRecord->defaultDrawShader) {
		// Drawshader color submission:
		HDRglColor4dv(windowRecord->currentColor);
	}
	else {
		// Fixed function pipe:
        if (PsychIsGLClassic(windowRecord)) {
            // OpenGL-1/2:
            glColor4dv(windowRecord->currentColor);
        }
        else {
            // OpenGL-ES 1.x: glColor4f() is only available function.
            glColor4f((float) windowRecord->currentColor[0], (float) windowRecord->currentColor[1], (float) windowRecord->currentColor[2], (float) windowRecord->currentColor[3]);
            PsychGLColor4f(windowRecord, (float) windowRecord->currentColor[0], (float) windowRecord->currentColor[1], (float) windowRecord->currentColor[2], (float) windowRecord->currentColor[3]);
        }
	}
}
/*void SimpleDraw::IdentifyLines(StdVector<Line> & lines, float lineWidth, float r, float g, float b)
{
	glDisable(GL_LIGHTING);
	glLineWidth(lineWidth);

	glColor3f(r, g, b);

	glBegin(GL_LINES);
	for(int i = 0; i < (int)lines.size(); i++)
	{
		glVertex3dv(lines[i].a);
		glVertex3dv(lines[i].b);
	}
	glEnd();

	glEnable(GL_LIGHTING);
}*/
void SimpleDraw::IdentifyLine( const Vec3d & p1, const Vec3d & p2, Vec4d c, bool showVec3ds /*= true*/, float lineWidth /*= 3.0f*/ )
{
	glDisable(GL_LIGHTING);

	// Set color
	glColor4dv(c);

	glLineWidth(lineWidth);
	glBegin(GL_LINES);
	glVertex3dv(p1);
	glVertex3dv(p2);
	glEnd();

	if(showVec3ds)
	{
		// Draw colored end points
		glPointSize(lineWidth * 5);
		glBegin(GL_POINTS);
		glVertex3dv(p1);
		glVertex3dv(p2);
		glEnd();

		// White border end points
		glPointSize((lineWidth * 5) + 2);
		glColor3f(1, 1, 1);

		glBegin(GL_POINTS);
		glVertex3dv(p1);
		glVertex3dv(p2);
		glEnd();
	}

	glEnable(GL_LIGHTING);
}
Exemple #6
0
void 
ShellContent::drawEntry()
{ 
    glPushMatrix();

    glLineWidth ( 1.2f );
    bufferFont->scale ( _fontScale, _fontAspect );

    glColor4dv( _fontColor.data() );
	glPushMatrix();
    bufferFont->draw_sub( _prompt ); // we lose kerning from one to the next, but otherwise this is pretty legal. 
    bufferFont->draw_sub( _entry.str() );
    glPopMatrix();


	double ll = bufferFont->length( _prompt + _entry.substr( 0 , _loc.chr ) );
	glColor4d( 0.0, 0.6, 0.1, 1.0 );
	glLineWidth( 2.0f );
	glBegin(GL_LINES);
	glVertex3d( ll , -0.25 * bufferFont->height() , 0 );
	glVertex3d( ll ,  1.25 * bufferFont->height() , 0 );
	glEnd();
	glPopMatrix();

}
void SimpleDraw::IdentifyPoints(const StdVector<Vec3d > & points, Vec4d c, float pointSize)
{
	glDisable(GL_LIGHTING);

	glEnable(GL_BLEND); 
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	// Colored dot
	glColor4dv(c);
	glPointSize(pointSize);
	glBegin(GL_POINTS);
	for(unsigned int i = 0; i < points.size(); i++)
		glVertex3dv(points[i]);
	glEnd();

	// White Border
	glPointSize(pointSize + 2);
	glColor4d(1, 1, 1, c[3]);

	glBegin(GL_POINTS);
	for(unsigned int i = 0; i < points.size(); i++)
		glVertex3dv(points[i]);
	glEnd();

	glEnable(GL_LIGHTING);
}
Exemple #8
0
void RenderShadowQuad (int bWhite)
{
	static GLdouble shadowHue [2][4] = {{0, 0, 0, 0.6},{0, 0, 0, 1}};

glMatrixMode (GL_MODELVIEW);
glPushMatrix ();
glLoadIdentity ();
glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
glOrtho (0, 1, 1, 0, 0, 1);
glDisable (GL_TEXTURE_2D);
glDisable (GL_DEPTH_TEST);
glEnable (GL_STENCIL_TEST);
glDepthMask (0);
if (gameStates.render.nShadowBlurPass)
	glDisable (GL_BLEND);
else
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable (GL_TEXTURE_2D);
glColor4dv (shadowHue [gameStates.render.nShadowBlurPass]);// / fDist);
glBegin (GL_QUADS);
glVertex2f (0,0);
glVertex2f (1,0);
glVertex2f (1,1);
glVertex2f (0,1);
glEnd ();
glEnable (GL_DEPTH_TEST);
glDisable (GL_STENCIL_TEST);
glDepthMask (1);
glPopMatrix ();
glMatrixMode (GL_MODELVIEW);
glPopMatrix ();
}
Exemple #9
0
void RateLimiter::Draw(wxPoint2DDouble translation, double scale) const
{
    glLineWidth(1.0);
    if(m_selected) {
        glColor4dv(m_selectionColour.GetRGBA());
        double borderSize = (m_borderSize * 2.0 + 1.0) / scale;
        DrawRectangle(m_position, m_width + borderSize, m_height + borderSize);
    }
    glColor4d(1.0, 1.0, 1.0, 1.0);
    DrawRectangle(m_position, m_width, m_height);
    glColor4d(0.0, 0.0, 0.0, 1.0);
    DrawRectangle(m_position, m_width, m_height, GL_LINE_LOOP);

    // Plot symbol.
    std::vector<wxPoint2DDouble> axis;
    axis.push_back(m_position + wxPoint2DDouble(-13, 0));
    axis.push_back(m_position + wxPoint2DDouble(13, 0));
    axis.push_back(m_position + wxPoint2DDouble(0, -13));
    axis.push_back(m_position + wxPoint2DDouble(0, 13));
    DrawLine(axis, GL_LINES);

    glLineWidth(2.0);
    std::vector<wxPoint2DDouble> limSymbol;
    limSymbol.push_back(m_position + wxPoint2DDouble(10, -10));
    limSymbol.push_back(m_position + wxPoint2DDouble(-10, 10));
    glColor4d(0.0, 0.3, 1.0, 1.0);
    DrawLine(limSymbol);

    glColor4d(0.0, 0.0, 0.0, 1.0);
    DrawNodes();
}
Exemple #10
0
void colour4::load()
{
#ifdef JFLOAT_IS_DOUBLE
    glColor4dv( cmp );
#else
    glColor4fv( cmp );
#endif
}
Exemple #11
0
void ruler_draw( const gui_context_s * const gui, const ruler_data_s * const ruler )
{
    // set vector line color
    glColor4dv( ruler->color_rgba );

    // line width
    glLineWidth( (GLfloat) GUI_DEFAULT_LINE_WIDTH );


    // check if p1 set
    if( ruler->p1_set != 0 )
    {
        // save state
        glPushMatrix();

        // translate to center, since it scales
        glTranslated( ruler->x1, ruler->y1, 0.0 );

        // draw x
        render_cross_2d( 0.0, 0.0, 2.0, 2.0 );

        // restore state
        glPopMatrix();
    }

    // check if p2 set
    if( ruler->p2_set != 0 )
    {
        // save state
        glPushMatrix();

        // translate to center, since it scales
        glTranslated( ruler->x2, ruler->y2, 0.0 );

        // draw x
        render_cross_2d( 0.0, 0.0, 2.0, 2.0 );

        // restore state
        glPopMatrix();
    }

    // check if both points are set
    if( (ruler->p1_set != 0) && (ruler->p2_set != 0) )
    {
        // start lines
        glBegin( GL_LINES );

        // line between points
        glVertex2d( ruler->x1, ruler->y1 );
        glVertex2d( ruler->x2, ruler->y2 );

        // end lines
        glEnd();
    }
}
DualVertexRenderer::DualVertexRenderer(const HMesh::Manifold& m, VertexAttributeVector<Vec4d>& field)
{
    // Create the program
    static GLuint prog = glCreateProgram();

    static bool was_here = false;
    if(!was_here)
    {
        was_here = true;
        // Create s	haders directly from file
        static GLuint vs = create_glsl_shader(GL_VERTEX_SHADER, vss);
        static GLuint gs = create_glsl_shader(GL_GEOMETRY_SHADER_EXT, gss);
        static GLuint fs = create_glsl_shader(GL_FRAGMENT_SHADER, fss);

        // Attach all shaders
        if(vs) glAttachShader(prog, vs);
        if(gs) glAttachShader(prog, gs);
        if(fs) glAttachShader(prog, fs);

        // Specify input and output for the geometry shader. Note that this must be
        // done before linking the program.
        glProgramParameteriEXT(prog,GL_GEOMETRY_INPUT_TYPE_EXT,GL_TRIANGLES);
        glProgramParameteriEXT(prog,GL_GEOMETRY_VERTICES_OUT_EXT,3);
        glProgramParameteriEXT(prog,GL_GEOMETRY_OUTPUT_TYPE_EXT,GL_TRIANGLE_STRIP);

        // Link the program object and print out the info log
        glLinkProgram(prog);
    }



    GLint old_prog;
    glGetIntegerv(GL_CURRENT_PROGRAM, &old_prog);

    glNewList(display_list,GL_COMPILE);
    glUseProgram(prog);
    for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f) {
        if(no_edges(m, *f) != 3)
            continue;
        else
            glBegin(GL_TRIANGLES);

        for(Walker w = m.walker(*f); !w.full_circle(); w = w.circulate_face_ccw()) {
            Vec3d n(normal(m, w.vertex()));
            glNormal3dv(n.get());
            glColor4dv(field[w.vertex()].get());
            glVertex3dv(m.pos(w.vertex()).get());
        }
        glEnd();
    }
    glUseProgram(old_prog);
    glEndList();

}
void RobotClawBase::draw() {
	glColor4dv(color);
	glPushMatrix();
        glTranslated(rd.clawBaseX, rd.clawBaseY, rd.clawBaseZ);
		glRotated(270, 1, 0, 0);
		glRotated(angle, 0, 0, 1);
        clawBase.draw();
	glPopMatrix();
    glTranslated(rd.clawBaseX, rd.clawBaseY + rd.clawBaseHeight + rd.ringRadius, rd.clawBaseZ);
	glRotated(angle, 0, 1, 0);
	glTranslated(0, 0, -rd.ringCenterZ);
    clawBaseJoint.draw();
}
Exemple #14
0
void __glXDisp_Color4dv(GLbyte *pc)
{

#ifdef __GLX_ALIGN64
	if ((unsigned long)(pc) & 7) {
	    __GLX_MEM_COPY(pc-4, pc, 32);
	    pc -= 4;
	}
#endif
	glColor4dv( 
		(GLdouble *)(pc + 0)
	);
}
Exemple #15
0
static void start_font_draw( font_t *font )
{
    scalar_t scale_fact = get_scale_factor( font );
    glPushMatrix();
    glScalef( scale_fact,
	      scale_fact,
	      scale_fact );

#ifdef __APPLE__DISABLED__
	glColor4f( (float)font->colour.r, (float)font->colour.g, (float)font->colour.b, (float)font->colour.a );
#else
    glColor4dv( (scalar_t*) &font->colour );
#endif
}
void GlSplatRenderer::drawpoints()
{
	glColor4dv(mColor);

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);

	glBindBuffer(GL_ARRAY_BUFFER, VertexVBOID);
	glMultiTexCoord1f(GL_TEXTURE2, mRadius);
	glNormalPointer(GL_FLOAT, sizeof(GLVertex), (void*)offsetof(GLVertex, nx));
	glVertexPointer(3, GL_FLOAT, sizeof(GLVertex), (void*)offsetof(GLVertex, x));
	glDrawArrays(GL_POINTS, 0, VertexCount);

	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
}
Exemple #17
0
void GeomRenderer::sendColor(GLuint colorIndex)
{
    assert(colorData.size == 3 || colorData.size == 4);

    switch(colorData.type)
    {
        case GL_BYTE:
            if (colorData.size == 3) glColor3bv((const GLbyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4bv((const GLbyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_UNSIGNED_BYTE:
            if (colorData.size == 3) glColor3ubv((const GLubyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4ubv((const GLubyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_SHORT:
            if (colorData.size == 3) glColor3sv((const GLshort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4sv((const GLshort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_UNSIGNED_SHORT:
            if (colorData.size == 3) glColor3usv((const GLushort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4usv((const GLushort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_INT:
            if (colorData.size == 3) glColor3iv((const GLint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4iv((const GLint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_UNSIGNED_INT:
            if (colorData.size == 3) glColor3uiv((const GLuint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4uiv((const GLuint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_FLOAT:
            if (colorData.size == 3) glColor3fv((const GLfloat*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4fv((const GLfloat*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_DOUBLE:
            if (colorData.size == 3) glColor3dv((const GLdouble*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4dv((const GLdouble*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;
    }
}
/*
    PsychSetGLColor()
    
    Accept a Psych color structure and a depth value and call the appropriate variant of glColor.       
*/
void PsychSetGLColor(PsychColorType *color, PsychWindowRecordType *windowRecord)
{
    int numVals;
    
    numVals=PsychConvertColorToDoubleVector(color, windowRecord, (GLdouble*) &(windowRecord->currentColor));
    if(numVals < 3 || numVals > 4) PsychErrorExitMsg(PsychError_internal, "Palette mode not yet implemented or illegal color specifier.");

	// Set the color in GL:
	if (windowRecord->defaultDrawShader) {
		// Drawshader color submission:
		HDRglColor4dv(windowRecord->currentColor);
	}
	else {
		// Fixed function pipe:
		glColor4dv(windowRecord->currentColor);
	}
}
Exemple #19
0
void Constant::Draw(wxPoint2DDouble translation, double scale) const
{
    glLineWidth(1.0);
    if(m_selected) {
        glColor4dv(m_selectionColour.GetRGBA());
        double borderSize = (m_borderSize * 2.0 + 1.0) / scale;
        DrawRectangle(m_position, m_width + borderSize, m_height + borderSize);
    }
    glColor4d(1.0, 1.0, 1.0, 1.0);
    DrawRectangle(m_position, m_width, m_height);
    glColor4d(0.0, 0.0, 0.0, 1.0);
    DrawRectangle(m_position, m_width, m_height, GL_LINE_LOOP);

    // Plot number.
    m_glText->Draw(m_position);

    glColor4d(0.0, 0.0, 0.0, 1.0);
    DrawNodes();
}
Exemple #20
0
void drawCircle(Vector *pos, double r, Colour *c) {
	Vector sc = coordToScreen(pos);
	r = fmax(r,2);

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

	glTranslated(sc.x, sc.y, 0.0);
	glScaled(r / width, r / height, 1.0);
	
	glBegin(GL_POLYGON);
	glColor4dv((double *)c);
	int i;
	for (i = 0; i < numUnitCircleVertices; ++i) {
		glVertex2d(unitCircle[i].x, unitCircle[i].y);
	}
	glEnd(); //  GL_POLYGON
	
	glPopMatrix();
}
void SimpleDraw::IdentifyLines( const StdVector<Vec3d> & p1, const StdVector<Vec3d> & p2, Vec4d c /*= Vec4d(1,0,0,1)*/, bool showVec3ds /*= true*/, float lineWidth /*= 3.0f */ )
{
	glDisable(GL_LIGHTING);

	// Set color
	glColor4dv(c);

	glLineWidth(lineWidth);
	glBegin(GL_LINES);
	for(int i = 0; i < (int)p1.size(); i++){
		glVertex3dv(p1[i]);
		glVertex3dv(p2[i]);
	}
	glEnd();

	if(showVec3ds)
	{
		// Draw colored end points
		glPointSize(lineWidth * 5);
		glBegin(GL_POINTS);
		for(int i = 0; i < (int)p1.size(); i++){
			glVertex3dv(p1[i]);
			glVertex3dv(p2[i]);
		}
		glEnd();

		// White border end points
		glPointSize((lineWidth * 5) + 2);
		glColor3f(1, 1, 1);

		glBegin(GL_POINTS);
		for(int i = 0; i < (int)p1.size(); i++){
			glVertex3dv(p1[i]);
			glVertex3dv(p2[i]);
		}
		glEnd();
	}

	glEnable(GL_LIGHTING);
}
Exemple #22
0
void
LineRenderer::draw_tokens( TextLine &line ) { 

	char lc = 0;
	int last = 0;
	std::vector<SyntaxToken>::size_type i;
	SyntaxToken tk;

	if ( line.dirty() ) refresh_tokens( line );
	SyntaxTokenList tklist = line.tokens();
	if ( tklist.howmany == 0 ) { draw(line); return; } 

	for ( i = 0 ; i < tklist.howmany ; i++ ) {
		tk = tklist.list[i];
		if ( last != tk.begin ) 
			lc = font->draw_sub( line.substr(last, tk.begin - last ), lc );
		glColor4dv( token_colors[ tk.type ].data() );
		lc = font->draw_sub( tk.token, lc );
		last = tk.end;
	}

}
Exemple #23
0
void iface::output_text(double x, double y, char const* text, GLdouble const* clr)
{
	window_.rt().trace("%s\n", text);
#if 0
	//y+= 10;
	static double const default_color[] = {1.0,1.0,1.0,1.0};
	if (!clr) clr = default_color;

	glColor4dv(clr);
	glDisable(GL_COLOR_MATERIAL);
	glDisable(GL_LIGHTING);

	//////////////////////////////////////////////////////////////////////////

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, window_.width(), window_.height(), 0, -1, 0);

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

	glRasterPos2d(x, y);

	glPushAttrib(GL_LIST_BIT);
	glListBase(font_base_ - 32);
	glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
	glPopAttrib();

	// ~~~
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
#endif // 0
}
Exemple #24
0
void Exponential::Draw(wxPoint2DDouble translation, double scale) const
{
    glLineWidth(1.0);
    if(m_selected) {
        glColor4dv(m_selectionColour.GetRGBA());
        double borderSize = (m_borderSize * 2.0 + 1.0) / scale;
        DrawRectangle(m_position, m_width + borderSize, m_height + borderSize);
    }
    glColor4d(1.0, 1.0, 1.0, 1.0);
    DrawRectangle(m_position, m_width, m_height);
    glColor4d(0.0, 0.0, 0.0, 1.0);
    DrawRectangle(m_position, m_width, m_height, GL_LINE_LOOP);

    // Plot symbol.
    std::vector<wxPoint2DDouble> axis;
    axis.push_back(m_position + wxPoint2DDouble(-13, 13));
    axis.push_back(m_position + wxPoint2DDouble(13, 13));
    axis.push_back(m_position + wxPoint2DDouble(-13, -13));
    axis.push_back(m_position + wxPoint2DDouble(-13, 13));
    DrawLine(axis, GL_LINES);

    glLineWidth(2.0);
    std::vector<wxPoint2DDouble> expSymbol;
    expSymbol.push_back(m_position + wxPoint2DDouble(-13, 13));
    expSymbol.push_back(m_position + wxPoint2DDouble(-6, 13));
    expSymbol.push_back(m_position + wxPoint2DDouble(2, 12));
    expSymbol.push_back(m_position + wxPoint2DDouble(4, 11));
    expSymbol.push_back(m_position + wxPoint2DDouble(6, 10));
    expSymbol.push_back(m_position + wxPoint2DDouble(8, 7));
    expSymbol.push_back(m_position + wxPoint2DDouble(11, -1));
    expSymbol.push_back(m_position + wxPoint2DDouble(12, -7));
    expSymbol.push_back(m_position + wxPoint2DDouble(13, -13));
    glColor4d(0.0, 0.3, 1.0, 1.0);
    DrawLine(expSymbol);

    glColor4d(0.0, 0.0, 0.0, 1.0);
    DrawNodes();
}
//------------------------------------------------------------------------------
// drawFunc() --
//------------------------------------------------------------------------------
void DspRwr::drawFunc()
{
    // Need a RWR to draw; if not, just draw a big X
    if (rwr == 0) {
        glBegin(GL_LINES);
        glVertex3d(-1.0, -1.0, 0.0);
        glVertex3d( 1.0,  1.0, 0.0);
        glVertex3d(-1.0,  1.0, 0.0);
        glVertex3d( 1.0, -1.0, 0.0);
        glEnd();
        return;
    }

    // ---
    // Draw the RWR signal rays
    // ---

    GLdouble  ocolor[4];
    glGetDoublev(GL_CURRENT_COLOR,ocolor);

    glColor3d(0.0, 1.0, 0.0);

    unsigned int n = rwr->getNumberOfRays();
    for (unsigned int i = 0; i < n; i++) {
        GLdouble azr = (Basic::Angle::D2RCC *  rwr->getRayAzimuth(i) );
        GLdouble pwr = rwr->getRay(i);
        GLdouble up = cos(azr) * pwr;
        GLdouble right = sin(azr) * pwr;
        glBegin(GL_LINES);
        glVertex3d( 0.0,  0.0, 0.0);
        glVertex3d( right, up, 0.0);
        glEnd();
    }

    glColor4dv(ocolor);
}
Exemple #26
0
void
TextContent::draw() {
    
    _fixCanvas();
    _fixView();
    
    glPushMatrix();
    
    glPushMatrix();
    _viewport.setCols( UI_BASE, Color4D( 1.0,1.0,1.0, 0.8 ), Color4D(0.2, 0.5, 0.2, 0.8 ) );
    _viewport.viewTranslate();
    _viewport.filledQuad();
    glPopMatrix();
    
    _viewport.scale();
    _viewport.viewTranslate();

//    glColor4dv ( _fontColor.data() );
    glColor4d( 0,0,0,0.9);
    glLineWidth (2.0);
        
    if (_parse_tree) { 

        glPushMatrix();
        glScaled( _leading * 1.2 , -_leading, 1.0 ); //scale to match line positions
        glTranslated ( 1.0 , 0.0 ,0.0 );
        glColor4d ( 1,0,0,0.2 );
        _parse_tree->draw_tree();
        glPopMatrix();

        //glPushMatrix();
        //glTranslated( _leading * 5.0, 0, 0 );
        //glPushMatrix();
        //glScaled( _leading * 0.7 , _leading, 0 ); //scale to match line positions
        //_parse_tree->draw_tree_buffer(_buf);
        //glPopMatrix();
        //glPopMatrix();

    }


    
    glLineWidth ( ( _selected ) ? _fontWeight : _fontWeight );
    glTranslated( 0, _windowLinePos * -_leading, 0 ); //for all the lines we are skipping

    int n = min ( _windowLinePos + _windowLineSpan , _buf->nlines() );
    bool render_pass = ( AudicleWindow::main()->m_render_mode == GL_RENDER );

    //this is the font's particular idea of a line-height
    // not including descenders..FIX LATER

    double font_text_height = bufferFont->height();

	//bufferFont will be phased out for bufferDraw, which will handle
	//more of the details of line rendering

/*
    double m_time = AudicleWindow::main()->get_current_time();    
    Color4D tdark =  Color4D ( 0.6, 0.8, 0.6, 0.5 );
    Color4D tlight =  Color4D ( 0.6, 0.9, 0.8, 0.4 );
    double blink_per_sec = 1.0;
    double glotime = m_time * blink_per_sec; 
    glotime -= floor ( glotime );
    double glomod =  fabs( -1.0 + 2.0 * ( glotime ) );
    Color4D tglow = tlight.interp( tdark , glomod );
*/

    Color4D tglow = Color4D ( 0.6, 0.8, 0.6, 0.4 );


    for  (int i = _windowLinePos ; i < n ; i++ ) { 
        glTranslated( 0, -_leading, 0 );
        
        if ( render_pass ) { 
            //we put a lot inside the render pass, so we may have broken picking. 
            //we shall see...
            glPushMatrix();

//			bufferDraw->setFontTransform(); // font scale 
			bufferFont->scale( _fontScale, _fontAspect );

            if ( _markSpan.begin.line <= i && i <= _markSpan.end.line ) {  
                //highlight span of selection;
                    
                double x1,x2;
                
                if ( i == _markSpan.begin.line ) 
                    x1 = bufferFont->length( _buf->line(i).substr( 0, _markSpan.begin.chr ) ); 
                else 
                    x1 = 0;

                if ( i == _markSpan.end.line ) { 
                    x2 = bufferFont->length( _buf->line(i).substr( 0, _markSpan.end.chr ) ); 
                }
                else 
                    x2 = bufferFont->length( _buf->line(i).str() ) + 0.5 * font_text_height; 

                if ( x1 != x2  ) { 
                    
                    glColor4dv ( tglow.data() );
//                    glColor4d( 0.3, 0.9, 0.9, 0.4 );
                    
                    glBegin(GL_QUADS);
                    glVertex2d( x1 , -0.4 * font_text_height );
                    glVertex2d( x2 , -0.4 * font_text_height );
                    glVertex2d( x2 ,  1.1 * font_text_height );
                    glVertex2d( x1 ,  1.1 * font_text_height );
                    glEnd();
                }
                
            }
            
            
            if (  i == _loc.line && WindowManager::getRenderMode() == WINDOW_RENDER_BLEND ) { 

                //highlight current line

                double xv = _viewport.vpW() * 100 * 40; 
                double xc = bufferFont->length( _buf->line(i).substr( 0, _loc.chr ) );

                glColor4d( 0.8, 0.8, 0.8, 0.2 );

                glBegin(GL_QUADS); 

                 glVertex2d(   -10 ,  -0.1 * font_text_height );
                 glVertex2d( xv + 10 , -0.1 * font_text_height );
                 glVertex2d( xv + 10 ,  1.1 * font_text_height );
                 glVertex2d(   -10 ,   1.1 * font_text_height );

                glEnd();
 
                glColor4d( 1.0 , 0.0, 0.0, 0.9 );
               
                glBegin(GL_LINES);
                                
                 glVertex2d ( xc, -0.1 * font_text_height );
                 glVertex2d ( xc,  1.1 * font_text_height );
                
                glEnd();
                
            }   

            //draw the line
            glColor4d( 0,0,0,1.0);
//			bufferDraw->draw( _buf->line(i) );
			bufferDraw->draw_tokens( _buf->line(i) );
//            bufferFont->draw( _buf->line(i).str() );
            glPopMatrix();
           
        }

    }
    glColor4d( 0,0,0,1.0);

    glPopMatrix();
}
Exemple #27
0
CAMLprim value c_restore_color(value color_state) {
    glColor4dv((GLdouble *)color_state);
    free((void *)color_state);
    return Val_unit;
}
Exemple #28
0
CAMLprim value c_restore_lineWidth(value lineWidth_state) {
    glColor4dv((GLdouble *)lineWidth_state);
    free((void *)lineWidth_state);
    return Val_unit;
}
Exemple #29
0
CAMLprim value c_restore_pointSize(value pointSize_state) {
    glColor4dv((GLdouble *)pointSize_state);
    free((void *)pointSize_state);
    return Val_unit;
}
/* PsychSetArrayColor()

   Helper routine, called from the different batch drawing functions of Screen():
*/
void PsychSetArrayColor(PsychWindowRecordType *windowRecord, int i, int mc, double* colors, unsigned char *bytecolors)
{
	GLdouble currentColor[4];
	
	if (windowRecord->defaultDrawShader) {
		// Draw shader assigned. Need to feed color values into high-precision
		// alternative channel for unclamped, high-precision color handling:
		if (mc==3) {
			i=i * 3;
			if (colors) {
				// RGB double:
				currentColor[0]=colors[i++];
				currentColor[1]=colors[i++];
				currentColor[2]=colors[i++];
				currentColor[3]=1.0;
			}
			else {
				// RGB uint8:
				currentColor[0]=((double) bytecolors[i++] / 255.0);
				currentColor[1]=((double) bytecolors[i++] / 255.0);
				currentColor[2]=((double) bytecolors[i++] / 255.0);
				currentColor[3]=1.0;
			}
		}
		else {
			i=i * 4;
			if (colors) {
				// RGBA double:
				currentColor[0]=colors[i++];
				currentColor[1]=colors[i++];
				currentColor[2]=colors[i++];
				currentColor[3]=colors[i++];
			}
			else {
				// RGBA uint8:
				currentColor[0]=((double) bytecolors[i++] / 255.0);
				currentColor[1]=((double) bytecolors[i++] / 255.0);
				currentColor[2]=((double) bytecolors[i++] / 255.0);
				currentColor[3]=((double) bytecolors[i++] / 255.0);
			}					
		}					

		HDRglColor4dv(currentColor);
	}
	else {
		// Standard fixed-function pipeline assigned: Feed into standard glColorXXX() calls:
		if (mc==3) {
			if (colors) {
				// RGB double:
				glColor3dv(&(colors[i*3]));
			}
			else {
				// RGB uint8:
				glColor3ubv(&(bytecolors[i*3]));
			}
		}
		else {
			if (colors) {
				// RGBA double:
				glColor4dv(&(colors[i*4]));
			}
			else {
				// RGBA uint8:
				glColor4ubv(&(bytecolors[i*4]));
			}					
		}
	}
	
	return;
}