duempel1
Posts: 1
Joined: Sun Aug 10, 2014 11:44 am

general advice using openvg with C

Sun Aug 10, 2014 12:36 pm

Im new with linux programming and work on a project that uses openvg to display text a screen.
The main question with openvg I have is how to update the screen.
The program runs in a loop, gets data and should display the data on a screen.
I just use the following sequence to update the screen:

DoMainScreen()
{
Start(width, height);
InitPos(width, height);

Background(255,255, 0); /* yellow */
Fill(0,0,0,1); /* black */

strcpy(ScreenData.DateTime,sDateTime);
Text(ixPosDate,iyPosDate, ScreenData.DateTime, SerifTypeface, width *10/240);
End();

}

DoMainScreen() will be called in a loop.

Is there any other way to update data without open/close the screen?
I reached many projects without any success.
The problem is that I loose memory and possibly it has to do with it.

Please be gentle with me.... I`m a linux beginner.

User avatar
ajstarks
Posts: 129
Joined: Fri Jun 22, 2012 2:14 am

Re: general advice using openvg with C

Wed Aug 13, 2014 1:14 am

Here is a C program to show the date:

Code: Select all

// show the date
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "VG/openvg.h"
#include "VG/vgu.h"
#include "fontinfo.h"
#include "shapes.h"

int main() {
        int i, width, height;
        char datebuf[20];                               // data for the date
        time_t now;

        init(&width, &height);                          // Graphics initialization

        Start(width, height);                           // Start the picture
        Background(0, 0, 0);                            // Black background
        for (i=0; i < 10; i++) {                        // Loop 10 times
                Fill(44, 77, 232, 1);                   // Big blue marble
                Circle(width / 2, 0, width);            // The "world"
                Fill(255, 255, 255, 1);                 // White text
                time(&now);                             // get the time
                strftime(datebuf, 20, "%Y-%m-%d %H:%M:%S", localtime(&now));    // format the date string
                TextMid(width/2, height/2, datebuf, SerifTypeface, width/25);   // show the date
                sleep(1);                               // pause for second
                End();                                  // refresh
        }
        finish();                                       // Graphics shutdown
        exit(0);                                        // Program end
}


jwatte
Posts: 203
Joined: Sat Aug 13, 2011 7:28 pm

Re: general advice using openvg with C

Fri Aug 15, 2014 2:25 am

I pointed g++ at /opt/vc for include/ and lib/
However, I can't find the shapes.h and fontinfo.h include files -- where are they supposed to come from?

User avatar
AndyD
Posts: 2331
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: general advice using openvg with C

Fri Aug 15, 2014 3:06 am

jwatte wrote:I pointed g++ at /opt/vc for include/ and lib/
However, I can't find the shapes.h and fontinfo.h include files -- where are they supposed to come from?
From ajstarks shapes library available on github.

Return to “Graphics, sound and multimedia”