navit  0.5.3-trunk
graphics_opengl.c File Reference
#include <glib.h>
#include <unistd.h>
#include <math.h>
#include <stdio.h>
#include <time.h>
#include "item.h"
#include "attr.h"
#include "config.h"
#include "point.h"
#include "graphics.h"
#include "color.h"
#include "plugin.h"
#include "event.h"
#include "debug.h"
#include "callback.h"
#include "keys.h"
#include "window.h"
#include "navit/font/freetype/font_freetype.h"
#include "graphics_opengl.h"
#include <GL/glut.h>

Data Structures

struct  graphics_gc_priv
 
struct  graphics_priv
 
struct  graphics_image_priv
 
struct  mouse_event_queue_element
 

Macros

#define USE_FLOAT   0
 
#define REQUIRES_POWER_OF_2   0
 
#define PIXEL_FORMAT   GL_BGRA
 
#define glOrthof   glOrtho
 
#define USE_FLOAT   1
 
#define glF(x)   x
 
#define glD(x)   x
 
#define GL_F   GL_FLOAT
 
#define SCREEN_WIDTH   700
 
#define SCREEN_HEIGHT   700
 

Typedefs

typedef GLfloat GLf
 

Functions

void APIENTRY tessBeginCB (GLenum which)
 
void APIENTRY tessEndCB (void)
 
void APIENTRY tessErrorCB (GLenum errorCode)
 
void APIENTRY tessVertexCB (const GLvoid *data)
 
void APIENTRY tessVertexCB2 (const GLvoid *data)
 
void APIENTRY tessCombineCB (GLdouble c[3], void *d[4], GLfloat w[4], void **out)
 
const char * getPrimitiveType (GLenum type)
 
static struct graphics_privgraphics_opengl_new_helper (struct graphics_methods *meth)
 
static void display (void)
 
static void resize_callback (int w, int h)
 
static void motion_notify_do (struct graphics_priv *priv, int x, int y)
 
static void resize_callback_do (struct graphics_priv *priv, int w, int h)
 
static void glut_close (void)
 
static void graphics_destroy (struct graphics_priv *gr)
 
static void gc_destroy (struct graphics_gc_priv *gc)
 
static void gc_set_linewidth (struct graphics_gc_priv *gc, int w)
 
static void gc_set_dashes (struct graphics_gc_priv *gc, int width, int offset, unsigned char *dash_list, int n)
 
static void gc_set_foreground (struct graphics_gc_priv *gc, struct color *c)
 
static void gc_set_background (struct graphics_gc_priv *gc, struct color *c)
 
static struct graphics_gc_privgc_new (struct graphics_priv *gr, struct graphics_gc_methods *meth)
 
static struct graphics_image_privimage_new (struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation)
 
static void set_color (struct graphics_priv *gr, struct graphics_gc_priv *gc)
 
static void draw_array (struct graphics_priv *gr, struct point *p, int count, GLenum mode)
 
static void draw_rectangle_do (struct graphics_priv *gr, struct point *p, int w, int h)
 
static void get_overlay_pos (struct graphics_priv *gr, struct point *point_out)
 
static void draw_lines (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
 
static void draw_polygon (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
 
static void draw_rectangle (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
 
static void display_text_draw (struct font_freetype_text *text, struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, int color, struct point *p)
 
static void draw_text (struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
 
static void draw_image (struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
 
static void draw_drag (struct graphics_priv *gr, struct point *p)
 
static void background_gc (struct graphics_priv *gr, struct graphics_gc_priv *gc)
 
static void handle_mouse_queue (void)
 
static int redraw_screen (struct graphics_priv *gr)
 
static gboolean redraw_filter (gpointer data)
 
static void draw_mode (struct graphics_priv *gr, enum draw_mode_num mode)
 
static struct graphics_privoverlay_new (struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
 
static int graphics_opengl_fullscreen (struct window *w, int on)
 
static void graphics_opengl_disable_suspend (struct window *w)
 
static void * get_data (struct graphics_priv *this, const char *type)
 
static void image_free (struct graphics_priv *gr, struct graphics_image_priv *priv)
 
static void overlay_disable (struct graphics_priv *gr, int disable)
 
static void overlay_resize (struct graphics_priv *gr, struct point *p, int w, int h, int wraparound)
 
static void click_notify (int button, int state, int x, int y)
 
static void motion_notify (int x, int y)
 
static gboolean graphics_opengl_idle (void *data)
 
static void ProcessNormalKeys (unsigned char key_in, int x, int y)
 
static void ProcessSpecialKeys (int key_in, int x, int y)
 
static struct graphics_privgraphics_opengl_new (struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
 
static void event_opengl_main_loop_run (void)
 
static void event_opengl_main_loop_quit (void)
 
static struct event_watchevent_opengl_add_watch (int fd, enum event_watch_cond cond, struct callback *cb)
 
static void event_opengl_remove_watch (struct event_watch *ev)
 
static struct event_timeoutevent_opengl_add_timeout (int timeout, int multi, struct callback *cb)
 
static void event_opengl_remove_timeout (struct event_timeout *to)
 
static struct event_idleevent_opengl_add_idle (int priority, struct callback *cb)
 
static void event_opengl_remove_idle (struct event_idle *ev)
 
static void event_opengl_call_callback (struct callback_list *cb)
 
static struct event_privevent_opengl_new (struct event_methods *meth)
 
void plugin_init (void)
 

Variables

struct graphics_gc_priv graphics_gc_priv
 
static struct graphics_privgraphics_priv_root
 
struct graphics_image_priv graphics_image_priv
 
static const int mouse_event_queue_size = 100
 
static int mouse_event_queue_begin_idx = 0
 
static int mouse_event_queue_end_idx = 0
 
static struct mouse_event_queue_element mouse_queue [100]
 
static GHashTable * hImageData
 
static struct graphics_gc_methods gc_methods
 
static int tess_count
 
static struct point tess_array [512]
 
static GLenum tess_type
 
static struct graphics_methods graphics_methods
 
static struct event_methods event_opengl_methods
 

Macro Definition Documentation

◆ GL_F

#define GL_F   GL_FLOAT

◆ glD

#define glD (   x)    x

◆ glF

#define glF (   x)    x

◆ glOrthof

#define glOrthof   glOrtho

◆ PIXEL_FORMAT

#define PIXEL_FORMAT   GL_BGRA

◆ REQUIRES_POWER_OF_2

#define REQUIRES_POWER_OF_2   0

◆ SCREEN_HEIGHT

#define SCREEN_HEIGHT   700

◆ SCREEN_WIDTH

#define SCREEN_WIDTH   700

◆ USE_FLOAT [1/2]

#define USE_FLOAT   0

Navit, a modular navigation system. Copyright (C) 2005-2010 Navit Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

◆ USE_FLOAT [2/2]

#define USE_FLOAT   1

Navit, a modular navigation system. Copyright (C) 2005-2010 Navit Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Typedef Documentation

◆ GLf

typedef GLfloat GLf

Function Documentation

◆ background_gc()

static void background_gc ( struct graphics_priv gr,
struct graphics_gc_priv gc 
)
static

◆ click_notify()

◆ display()

◆ display_text_draw()

◆ draw_array()

static void draw_array ( struct graphics_priv gr,
struct point p,
int  count,
GLenum  mode 
)
static

◆ draw_drag()

static void draw_drag ( struct graphics_priv gr,
struct point p 
)
static

References graphics_priv::p, p, point::x, and point::y.

◆ draw_image()

◆ draw_lines()

◆ draw_mode()

◆ draw_polygon()

◆ draw_rectangle()

static void draw_rectangle ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  w,
int  h 
)
static

◆ draw_rectangle_do()

static void draw_rectangle_do ( struct graphics_priv gr,
struct point p,
int  w,
int  h 
)
static

References draw_array(), p, point::x, and point::y.

Referenced by draw_rectangle().

◆ draw_text()

◆ event_opengl_add_idle()

static struct event_idle* event_opengl_add_idle ( int  priority,
struct callback cb 
)
static

References dbg, and lvl_debug.

◆ event_opengl_add_timeout()

static struct event_timeout* event_opengl_add_timeout ( int  timeout,
int  multi,
struct callback cb 
)
static

References dbg, and lvl_debug.

◆ event_opengl_add_watch()

static struct event_watch* event_opengl_add_watch ( int  fd,
enum event_watch_cond  cond,
struct callback cb 
)
static

References dbg, and lvl_debug.

◆ event_opengl_call_callback()

static void event_opengl_call_callback ( struct callback_list cb)
static

References dbg, and lvl_debug.

◆ event_opengl_main_loop_quit()

static void event_opengl_main_loop_quit ( void  )
static

References dbg, and lvl_debug.

◆ event_opengl_main_loop_run()

static void event_opengl_main_loop_run ( void  )
static

References dbg, and lvl_info.

◆ event_opengl_new()

static struct event_priv* event_opengl_new ( struct event_methods meth)
static

References event_opengl_methods.

Referenced by plugin_init().

◆ event_opengl_remove_idle()

static void event_opengl_remove_idle ( struct event_idle ev)
static

References dbg, and lvl_debug.

◆ event_opengl_remove_timeout()

static void event_opengl_remove_timeout ( struct event_timeout to)
static

References dbg, and lvl_debug.

◆ event_opengl_remove_watch()

static void event_opengl_remove_watch ( struct event_watch ev)
static

References dbg, and lvl_debug.

◆ gc_destroy()

static void gc_destroy ( struct graphics_gc_priv gc)
static

◆ gc_new()

static struct graphics_gc_priv* gc_new ( struct graphics_priv gr,
struct graphics_gc_methods meth 
)
static

◆ gc_set_background()

static void gc_set_background ( struct graphics_gc_priv gc,
struct color c 
)
static

◆ gc_set_dashes()

static void gc_set_dashes ( struct graphics_gc_priv gc,
int  width,
int  offset,
unsigned char *  dash_list,
int  n 
)
static

◆ gc_set_foreground()

static void gc_set_foreground ( struct graphics_gc_priv gc,
struct color c 
)
static

◆ gc_set_linewidth()

static void gc_set_linewidth ( struct graphics_gc_priv gc,
int  w 
)
static

◆ get_data()

◆ get_overlay_pos()

static void get_overlay_pos ( struct graphics_priv gr,
struct point point_out 
)
static

◆ getPrimitiveType()

const char * getPrimitiveType ( GLenum  type)

References type.

Referenced by tessBeginCB().

◆ glut_close()

static void glut_close ( void  )
static

◆ graphics_destroy()

static void graphics_destroy ( struct graphics_priv gr)
static

◆ graphics_opengl_disable_suspend()

static void graphics_opengl_disable_suspend ( struct window w)
static

Referenced by get_data().

◆ graphics_opengl_fullscreen()

static int graphics_opengl_fullscreen ( struct window w,
int  on 
)
static

Referenced by get_data().

◆ graphics_opengl_idle()

static gboolean graphics_opengl_idle ( void *  data)
static

◆ graphics_opengl_new()

◆ graphics_opengl_new_helper()

◆ handle_mouse_queue()

◆ image_free()

static void image_free ( struct graphics_priv gr,
struct graphics_image_priv priv 
)
static

◆ image_new()

◆ motion_notify()

static void motion_notify ( int  x,
int  y 
)
static

◆ motion_notify_do()

static void motion_notify_do ( struct graphics_priv priv,
int  x,
int  y 
)
static

◆ overlay_disable()

static void overlay_disable ( struct graphics_priv gr,
int  disable 
)
static

◆ overlay_new()

static struct graphics_priv * overlay_new ( struct graphics_priv gr,
struct graphics_methods meth,
struct point p,
int  w,
int  h,
int  wraparound 
)
static

◆ overlay_resize()

static void overlay_resize ( struct graphics_priv gr,
struct point p,
int  w,
int  h,
int  wraparound 
)
static

◆ plugin_init()

void plugin_init ( void  )

◆ ProcessNormalKeys()

static void ProcessNormalKeys ( unsigned char  key_in,
int  x,
int  y 
)
static

◆ ProcessSpecialKeys()

◆ redraw_filter()

static gboolean redraw_filter ( gpointer  data)
static

◆ redraw_screen()

◆ resize_callback()

static void resize_callback ( int  w,
int  h 
)
static

◆ resize_callback_do()

static void resize_callback_do ( struct graphics_priv priv,
int  w,
int  h 
)
static

◆ set_color()

◆ tessBeginCB()

void APIENTRY tessBeginCB ( GLenum  which)

References dbg, getPrimitiveType(), lvl_debug, tess_count, and tess_type.

Referenced by draw_polygon().

◆ tessCombineCB()

void APIENTRY tessCombineCB ( GLdouble  c[3],
void *  d[4],
GLfloat  w[4],
void **  out 
)

References c.

Referenced by draw_polygon().

◆ tessEndCB()

void APIENTRY tessEndCB ( void  )

◆ tessErrorCB()

void APIENTRY tessErrorCB ( GLenum  errorCode)

◆ tessVertexCB()

void APIENTRY tessVertexCB ( const GLvoid *  data)

◆ tessVertexCB2()

void APIENTRY tessVertexCB2 ( const GLvoid *  data)

Variable Documentation

◆ event_opengl_methods

struct event_methods event_opengl_methods
static
Initial value:
= {
}
static void event_opengl_main_loop_quit(void)
Definition: graphics_opengl.c:1579
static struct event_watch * event_opengl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb)
Definition: graphics_opengl.c:1583
static struct event_idle * event_opengl_add_idle(int priority, struct callback *cb)
Definition: graphics_opengl.c:1603
static void event_opengl_remove_watch(struct event_watch *ev)
Definition: graphics_opengl.c:1588
static void event_opengl_remove_timeout(struct event_timeout *to)
Definition: graphics_opengl.c:1598
static void event_opengl_main_loop_run(void)
Definition: graphics_opengl.c:1575
static struct event_timeout * event_opengl_add_timeout(int timeout, int multi, struct callback *cb)
Definition: graphics_opengl.c:1593
static void event_opengl_remove_idle(struct event_idle *ev)
Definition: graphics_opengl.c:1608
static void event_opengl_call_callback(struct callback_list *cb)
Definition: graphics_opengl.c:1612

Referenced by event_opengl_new().

◆ gc_methods

struct graphics_gc_methods gc_methods
static
Initial value:
= {
}
static void gc_destroy(struct graphics_gc_priv *gc)
Definition: graphics_opengl.c:258
static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
Definition: graphics_opengl.c:322
static void gc_set_background(struct graphics_gc_priv *gc, struct color *c)
Definition: graphics_opengl.c:329
static void gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset, unsigned char *dash_list, int n)
Definition: graphics_opengl.c:267
static void gc_set_linewidth(struct graphics_gc_priv *gc, int w)
Definition: graphics_opengl.c:263

Referenced by gc_new().

◆ graphics_gc_priv

◆ graphics_image_priv

◆ graphics_methods

Initial value:
= {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}
static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
Definition: graphics_opengl.c:1337
static void draw_drag(struct graphics_priv *gr, struct point *p)
Definition: graphics_opengl.c:993
static void overlay_disable(struct graphics_priv *gr, int disable)
Definition: graphics_opengl.c:1243
static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
Definition: graphics_opengl.c:792
static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
Definition: graphics_opengl.c:963
static void * get_data(struct graphics_priv *this, const char *type)
Definition: graphics_opengl.c:1149
static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
Definition: graphics_opengl.c:934
static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
Definition: graphics_opengl.c:1001
static struct graphics_image_priv * image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation)
Definition: graphics_opengl.c:357
static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
Definition: graphics_opengl.c:631
static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
Definition: graphics_opengl.c:1091
static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
Definition: graphics_opengl.c:739
static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv)
Definition: graphics_opengl.c:1232
static struct graphics_gc_priv * gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
Definition: graphics_opengl.c:344
static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound)
Definition: graphics_opengl.c:1249
static void graphics_destroy(struct graphics_priv *gr)
Definition: graphics_opengl.c:250

Referenced by graphics_opengl_new_helper().

◆ graphics_priv_root

◆ hImageData

GHashTable* hImageData
static

Referenced by graphics_opengl_new(), and image_new().

◆ mouse_event_queue_begin_idx

int mouse_event_queue_begin_idx = 0
static

Referenced by handle_mouse_queue().

◆ mouse_event_queue_end_idx

int mouse_event_queue_end_idx = 0
static

Referenced by click_notify(), and handle_mouse_queue().

◆ mouse_event_queue_size

const int mouse_event_queue_size = 100
static

Referenced by click_notify(), and handle_mouse_queue().

◆ mouse_queue

struct mouse_event_queue_element mouse_queue[100]
static

Referenced by click_notify(), and handle_mouse_queue().

◆ tess_array

struct point tess_array[512]
static

Referenced by tessEndCB(), and tessVertexCB().

◆ tess_count

int tess_count
static

◆ tess_type

GLenum tess_type
static

Referenced by tessBeginCB(), and tessEndCB().