caca_set_display_time() and caca_get_display_time() for consistency.tags/v0.99.beta14
@@ -151,9 +151,9 @@ enum caca_key | |||||
* @{ */ | * @{ */ | ||||
caca_display_t * caca_create_display(cucul_canvas_t *); | caca_display_t * caca_create_display(cucul_canvas_t *); | ||||
void caca_free_display(caca_display_t *); | void caca_free_display(caca_display_t *); | ||||
void caca_set_delay(caca_display_t *, unsigned int); | |||||
void caca_refresh_display(caca_display_t *); | void caca_refresh_display(caca_display_t *); | ||||
unsigned int caca_get_rendertime(caca_display_t *); | |||||
void caca_set_display_time(caca_display_t *, unsigned int); | |||||
unsigned int caca_get_display_time(caca_display_t *); | |||||
unsigned int caca_get_display_width(caca_display_t *); | unsigned int caca_get_display_width(caca_display_t *); | ||||
unsigned int caca_get_display_height(caca_display_t *); | unsigned int caca_get_display_height(caca_display_t *); | ||||
int caca_set_display_title(caca_display_t *, char const *); | int caca_set_display_title(caca_display_t *, char const *); | ||||
@@ -28,7 +28,7 @@ | |||||
* If libcaca runs in a window, try to change its title. This works with | * If libcaca runs in a window, try to change its title. This works with | ||||
* the X11 and Win32 drivers. | * the X11 and Win32 drivers. | ||||
* | * | ||||
* \param dp The libcaca graphical context. | |||||
* \param dp The libcaca display context. | |||||
* \param title The desired display title. | * \param title The desired display title. | ||||
* \return 0 upon success, a non-zero value if an error occurs. | * \return 0 upon success, a non-zero value if an error occurs. | ||||
*/ | */ | ||||
@@ -44,7 +44,7 @@ int caca_set_display_title(caca_display_t *dp, char const *title) | |||||
* or if there is no way to know the font size, most drivers will assume a | * or if there is no way to know the font size, most drivers will assume a | ||||
* 6x10 font is being used. Note that the units are not necessarily pixels. | * 6x10 font is being used. Note that the units are not necessarily pixels. | ||||
* | * | ||||
* \param dp The libcaca graphical context. | |||||
* \param dp The libcaca display context. | |||||
* \return The display width. | * \return The display width. | ||||
*/ | */ | ||||
unsigned int caca_get_display_width(caca_display_t *dp) | unsigned int caca_get_display_width(caca_display_t *dp) | ||||
@@ -59,7 +59,7 @@ unsigned int caca_get_display_width(caca_display_t *dp) | |||||
* or if there is no way to know the font size, assume a 6x10 font is being | * or if there is no way to know the font size, assume a 6x10 font is being | ||||
* used. Note that the units are not necessarily pixels. | * used. Note that the units are not necessarily pixels. | ||||
* | * | ||||
* \param dp The libcaca graphical context. | |||||
* \param dp The libcaca display context. | |||||
* \return The display height. | * \return The display height. | ||||
*/ | */ | ||||
unsigned int caca_get_display_height(caca_display_t *dp) | unsigned int caca_get_display_height(caca_display_t *dp) | ||||
@@ -76,26 +76,26 @@ unsigned int caca_get_display_height(caca_display_t *dp) | |||||
* If the argument is zero, constant framerate is disabled. This is the | * If the argument is zero, constant framerate is disabled. This is the | ||||
* default behaviour. | * default behaviour. | ||||
* | * | ||||
* \param dp The libcaca graphical context. | |||||
* \param dp The libcaca display context. | |||||
* \param usec The refresh delay in microseconds. | * \param usec The refresh delay in microseconds. | ||||
*/ | */ | ||||
void caca_set_delay(caca_display_t *dp, unsigned int usec) | |||||
void caca_set_display_time(caca_display_t *dp, unsigned int usec) | |||||
{ | { | ||||
dp->delay = usec; | dp->delay = usec; | ||||
} | } | ||||
/** \brief Get the average rendering time. | |||||
/** \brief Get the display's average rendering time. | |||||
* | * | ||||
* This function returns the average rendering time, which is the average | * This function returns the average rendering time, which is the average | ||||
* measured time between two caca_refresh_display() calls, in microseconds. If | * measured time between two caca_refresh_display() calls, in microseconds. If | ||||
* constant framerate was activated by calling caca_set_delay(), the average | |||||
* rendering time will not be considerably shorter than the requested delay | |||||
* even if the real rendering time was shorter. | |||||
* constant framerate was activated by calling caca_set_display_time(), the | |||||
* average rendering time will not be considerably shorter than the requested | |||||
* delay even if the real rendering time was shorter. | |||||
* | * | ||||
* \param dp The libcaca graphical context. | |||||
* \param dp The libcaca display context. | |||||
* \return The render time in microseconds. | * \return The render time in microseconds. | ||||
*/ | */ | ||||
unsigned int caca_get_rendertime(caca_display_t *dp) | |||||
unsigned int caca_get_display_time(caca_display_t *dp) | |||||
{ | { | ||||
return dp->rendertime; | return dp->rendertime; | ||||
} | } | ||||
@@ -106,13 +106,13 @@ unsigned int caca_get_rendertime(caca_display_t *dp) | |||||
* screen. Nothing will show on the screen until caca_refresh_display() is | * screen. Nothing will show on the screen until caca_refresh_display() is | ||||
* called. | * called. | ||||
* | * | ||||
* If caca_set_delay() was called with a non-zero value, | |||||
* If caca_set_display_time() was called with a non-zero value, | |||||
* caca_refresh_display() will use that value to achieve constant | * caca_refresh_display() will use that value to achieve constant | ||||
* framerate: if two consecutive calls to caca_refresh_display() are | |||||
* within a time range shorter than the value set with caca_set_delay(), | |||||
* framerate: if two consecutive calls to caca_refresh_display() are within | |||||
* a time range shorter than the value set with caca_set_display_time(), | |||||
* the second call will be delayed before performing the screen refresh. | * the second call will be delayed before performing the screen refresh. | ||||
* | * | ||||
* \param dp The libcaca graphical context. | |||||
* \param dp The libcaca display context. | |||||
*/ | */ | ||||
void caca_refresh_display(caca_display_t *dp) | void caca_refresh_display(caca_display_t *dp) | ||||
{ | { | ||||
@@ -154,7 +154,7 @@ void caca_refresh_display(caca_display_t *dp) | |||||
* This function shows or hides the mouse pointer, for devices that | * This function shows or hides the mouse pointer, for devices that | ||||
* support it. | * support it. | ||||
* | * | ||||
* \param dp The libcaca graphical context. | |||||
* \param dp The libcaca display context. | |||||
* \param flag 0 hides the pointer, 1 shows the system's default pointer | * \param flag 0 hides the pointer, 1 shows the system's default pointer | ||||
* (usually an arrow). Other values are reserved for future use. | * (usually an arrow). Other values are reserved for future use. | ||||
*/ | */ | ||||
@@ -15,8 +15,8 @@ | |||||
static PyMethodDef CacaMethods[] = { | static PyMethodDef CacaMethods[] = { | ||||
{"init", pycaca_init, METH_VARARGS, "Init libcaca"}, | {"init", pycaca_init, METH_VARARGS, "Init libcaca"}, | ||||
{"set_delay", pycaca_set_delay, METH_VARARGS, "Set delay"}, | |||||
{"get_rendertime", pycaca_get_rendertime, METH_NOARGS, "Get render time"}, | |||||
{"set_display_time", pycaca_set_display_time, METH_VARARGS, "Set display time"}, | |||||
{"get_display_time", pycaca_get_display_time, METH_NOARGS, "Get render time"}, | |||||
{"get_width", pycaca_get_width, METH_NOARGS, "Get width"}, | {"get_width", pycaca_get_width, METH_NOARGS, "Get width"}, | ||||
{"get_height", pycaca_get_height, METH_NOARGS, "Get Height"}, | {"get_height", pycaca_get_height, METH_NOARGS, "Get Height"}, | ||||
{"set_size", pycaca_set_size, METH_VARARGS, "Set size"}, | {"set_size", pycaca_set_size, METH_VARARGS, "Set size"}, | ||||
@@ -196,18 +196,18 @@ pycaca_init(PyObject *self, PyObject *args) | |||||
} | } | ||||
static PyObject * | static PyObject * | ||||
pycaca_set_delay(PyObject *self, PyObject *args) | |||||
pycaca_set_display_time(PyObject *self, PyObject *args) | |||||
{ | { | ||||
int value=0; | int value=0; | ||||
if (!PyArg_ParseTuple(args, "i", &value)) | if (!PyArg_ParseTuple(args, "i", &value)) | ||||
caca_set_delay(value); | |||||
caca_set_display_time(value); | |||||
return Py_BuildValue("i", 1); /*FIXME*/ | return Py_BuildValue("i", 1); /*FIXME*/ | ||||
} | } | ||||
static PyObject * | static PyObject * | ||||
pycaca_get_rendertime(PyObject *self, PyObject *args) | |||||
pycaca_get_display_time(PyObject *self, PyObject *args) | |||||
{ | { | ||||
int ret = caca_get_rendertime(); | |||||
int ret = caca_get_display_time(); | |||||
return Py_BuildValue("i", ret); | return Py_BuildValue("i", ret); | ||||
} | } | ||||
@@ -24,9 +24,9 @@ PyMODINIT_FUNC initcaca(void); | |||||
static PyObject * | static PyObject * | ||||
pycaca_init(PyObject *self, PyObject *args); | pycaca_init(PyObject *self, PyObject *args); | ||||
static PyObject * | static PyObject * | ||||
pycaca_set_delay(PyObject *self, PyObject *args); | |||||
pycaca_set_display_time(PyObject *self, PyObject *args); | |||||
static PyObject * | static PyObject * | ||||
pycaca_get_rendertime(PyObject *self, PyObject *args); | |||||
pycaca_get_display_time(PyObject *self, PyObject *args); | |||||
static PyObject * | static PyObject * | ||||
pycaca_get_width(PyObject *self, PyObject *args); | pycaca_get_width(PyObject *self, PyObject *args); | ||||
static PyObject * | static PyObject * | ||||
@@ -113,7 +113,7 @@ initialize (void) | |||||
printf ("Failed to initialize libcaca\n"); | printf ("Failed to initialize libcaca\n"); | ||||
exit (1); | exit (1); | ||||
} | } | ||||
caca_set_delay(dp, 10000); | |||||
caca_set_display_time(dp, 10000); | |||||
XSIZ = cucul_get_canvas_width(cv) * 2; | XSIZ = cucul_get_canvas_width(cv) * 2; | ||||
YSIZ = cucul_get_canvas_height(cv) * 2 - 4; | YSIZ = cucul_get_canvas_height(cv) * 2 - 4; | ||||
#else | #else | ||||
@@ -61,7 +61,7 @@ int main(int argc, char **argv) | |||||
if(!dp) | if(!dp) | ||||
return 1; | return 1; | ||||
caca_set_delay(dp, 20000); | |||||
caca_set_display_time(dp, 20000); | |||||
/* Make the palette eatable by libcaca */ | /* Make the palette eatable by libcaca */ | ||||
for(p = 0; p < 256; p++) | for(p = 0; p < 256; p++) | ||||
@@ -50,7 +50,7 @@ int main (int argc, char **argv) | |||||
if(!dp) | if(!dp) | ||||
return 1; | return 1; | ||||
caca_set_delay(dp, 20000); | |||||
caca_set_display_time(dp, 20000); | |||||
/* Fill various tables */ | /* Fill various tables */ | ||||
for(i = 0 ; i < 256; i++) | for(i = 0 ; i < 256; i++) | ||||
@@ -54,7 +54,7 @@ int main (int argc, char **argv) | |||||
if(!dp) | if(!dp) | ||||
return 1; | return 1; | ||||
caca_set_delay(dp, 20000); | |||||
caca_set_display_time(dp, 20000); | |||||
c2 = cucul_create_canvas(cucul_get_canvas_width(cv), | c2 = cucul_create_canvas(cucul_get_canvas_width(cv), | ||||
cucul_get_canvas_height(cv)); | cucul_get_canvas_height(cv)); | ||||
@@ -55,7 +55,7 @@ int main(int argc, char **argv) | |||||
if(!dp) | if(!dp) | ||||
return 1; | return 1; | ||||
caca_set_delay(dp, 40000); | |||||
caca_set_display_time(dp, 40000); | |||||
/* Initialize data */ | /* Initialize data */ | ||||
#if 0 | #if 0 | ||||
@@ -187,8 +187,8 @@ int main(int argc, char **argv) | |||||
cucul_draw_thin_box(cv, 1, 1, cucul_get_canvas_width(cv) - 2, | cucul_draw_thin_box(cv, 1, 1, cucul_get_canvas_width(cv) - 2, | ||||
cucul_get_canvas_height(cv) - 2); | cucul_get_canvas_height(cv) - 2); | ||||
cucul_printf(cv, 4, 1, "[%i.%i fps]----", | cucul_printf(cv, 4, 1, "[%i.%i fps]----", | ||||
1000000 / caca_get_rendertime(dp), | |||||
(10000000 / caca_get_rendertime(dp)) % 10); | |||||
1000000 / caca_get_display_time(dp), | |||||
(10000000 / caca_get_display_time(dp)) % 10); | |||||
caca_refresh_display(dp); | caca_refresh_display(dp); | ||||
} | } | ||||
} | } | ||||
@@ -42,7 +42,7 @@ int main(void) | |||||
cucul_set_canvas_size(cv, 41, 16); | cucul_set_canvas_size(cv, 41, 16); | ||||
dp = caca_create_display(cv); | dp = caca_create_display(cv); | ||||
caca_set_delay(dp, 50000); | |||||
caca_set_display_time(dp, 50000); | |||||
/* Fill the first 16 frames with a different colour */ | /* Fill the first 16 frames with a different colour */ | ||||
for(frame = 0; frame < 16; frame++) | for(frame = 0; frame < 16; frame++) | ||||
@@ -55,7 +55,7 @@ int main(void) | |||||
0x00ff0000, 0x0000ff00, 0x000000ff, 0x0); | 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0); | ||||
right = cucul_create_dither(32, 256, 4, 4 * 256, | right = cucul_create_dither(32, 256, 4, 4 * 256, | ||||
0x00ff0000, 0x0000ff00, 0x000000ff, 0x0); | 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0); | ||||
caca_set_delay(dp, 20000); | |||||
caca_set_display_time(dp, 20000); | |||||
for(x = 0; ; x++) | for(x = 0; ; x++) | ||||
{ | { | ||||