navit  0.5.3-trunk
graphics_egl.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 "SDL_image.h"
#include <GLES2/gl2.h>
#include <EGL/egl.h>

Data Structures

struct  graphics_gc_priv
 
struct  graphics_priv
 
struct  graphics_image_priv
 
struct  graphics_opengl_platform
 
struct  contour
 

Macros

#define SCREEN_WIDTH   800
 
#define SCREEN_HEIGHT   600
 
#define glF(x)   x
 
#define glD(x)   x
 
#define GL_F   GL_FLOAT
 

Typedefs

typedef GLfloat GLf
 

Functions

static struct graphics_privgraphics_opengl_new_helper (struct graphics_methods *meth)
 
float area (const struct contour *contour)
 
int inside_triangle (float Ax, float Ay, float Bx, float By, float Cx, float Cy, float Px, float Py)
 
int snip (const struct point *pnt, int u, int v, int w, int n, int *V)
 
int process_triangles (const struct contour *contour, struct contour *result)
 
static void sdl_egl_destroy (struct graphics_opengl_platform *egl)
 
static void sdl_egl_swap_buffers (struct graphics_opengl_platform *egl)
 
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 *name, int *w, int *h, struct point *hot, int rotation)
 
static void image_free (struct graphics_priv *gr, struct graphics_image_priv *gi)
 
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 draw_image_es (struct graphics_priv *gr, struct point *p, int w, int h, unsigned char *data)
 
void get_overlay_pos (struct graphics_priv *gr, struct point *point_out)
 
void draw_overlay (struct graphics_priv *gr)
 
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 draw_background (struct graphics_priv *gr)
 
static void draw_mode (struct graphics_priv *gr, enum draw_mode_num mode)
 
static int graphics_opengl_fullscreen (struct window *w, int on)
 
static void graphics_opengl_disable_suspend (struct window *w)
 
static GLuint load_shader (const char *shader_source, GLenum type)
 
static void * get_data (struct graphics_priv *this, const char *type)
 
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 struct graphics_privoverlay_new (struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
 
static void create_framebuffer_texture (struct graphics_priv *gr)
 
static gboolean graphics_sdl_idle (void *data)
 
static struct graphics_privgraphics_opengl_new (struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
 
void plugin_init (void)
 

Variables

struct graphics_gc_priv graphics_gc_priv
 
struct graphics_image_priv graphics_image_priv
 
static GHashTable * hImageData
 
static int USERWANTSTOQUIT = 0
 
static struct graphics_privgraphics_priv_root
 
const char vertex_src []
 
const char fragment_src []
 
static struct graphics_gc_methods gc_methods
 
static struct graphics_image_priv image_error
 
static struct graphics_methods graphics_methods
 

Macro Definition Documentation

◆ GL_F

#define GL_F   GL_FLOAT

◆ glD

#define glD (   x)    x

◆ glF

#define glF (   x)    x

◆ SCREEN_HEIGHT

#define SCREEN_HEIGHT   600

◆ SCREEN_WIDTH

#define SCREEN_WIDTH   800

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

◆ area()

◆ background_gc()

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

◆ create_framebuffer_texture()

static void create_framebuffer_texture ( struct graphics_priv gr)
static

◆ display_text_draw()

◆ draw_array()

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

◆ draw_background()

◆ 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()

static void draw_image ( struct graphics_priv gr,
struct graphics_gc_priv fg,
struct point p,
struct graphics_image_priv img 
)
static

◆ draw_image_es()

static void draw_image_es ( struct graphics_priv gr,
struct point p,
int  w,
int  h,
unsigned char *  data 
)
static

◆ draw_lines()

static void draw_lines ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  count 
)
static

◆ draw_mode()

◆ draw_overlay()

◆ 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

◆ draw_text()

◆ 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()

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

◆ 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_new()

◆ graphics_opengl_new_helper()

◆ graphics_sdl_idle()

◆ image_free()

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

◆ image_new()

static struct graphics_image_priv* image_new ( struct graphics_priv gr,
struct graphics_image_methods meth,
char *  name,
int *  w,
int *  h,
struct point hot,
int  rotation 
)
static

◆ inside_triangle()

int inside_triangle ( float  Ax,
float  Ay,
float  Bx,
float  By,
float  Cx,
float  Cy,
float  Px,
float  Py 
)

Referenced by snip().

◆ load_shader()

static GLuint load_shader ( const char *  shader_source,
GLenum  type 
)
static

References type.

Referenced by get_data().

◆ overlay_disable()

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

◆ overlay_new()

◆ overlay_resize()

◆ plugin_init()

void plugin_init ( void  )

References graphics_opengl_new().

◆ process_triangles()

int process_triangles ( const struct contour contour,
struct contour result 
)

◆ sdl_egl_destroy()

static void sdl_egl_destroy ( struct graphics_opengl_platform egl)
static

◆ sdl_egl_swap_buffers()

static void sdl_egl_swap_buffers ( struct graphics_opengl_platform egl)
static

◆ set_color()

◆ snip()

int snip ( const struct point pnt,
int  u,
int  v,
int  w,
int  n,
int *  V 
)

Variable Documentation

◆ fragment_src

const char fragment_src[]
Initial value:
=
" \
uniform lowp vec4 avcolor; \
uniform sampler2D texture; \
uniform bool use_texture; \
varying vec2 v_texture_position; \
void main() \
{ \
if (use_texture) { \
gl_FragColor = texture2D(texture, v_texture_position); \
} else { \
gl_FragColor = avcolor; \
} \
} \
"

Referenced by get_data().

◆ gc_methods

struct graphics_gc_methods gc_methods
static
Initial value:
= {
}
static void gc_destroy(struct graphics_gc_priv *gc)
Definition: graphics_egl.c:337
static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
Definition: graphics_egl.c:401
static void gc_set_background(struct graphics_gc_priv *gc, struct color *c)
Definition: graphics_egl.c:408
static void gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset, unsigned char *dash_list, int n)
Definition: graphics_egl.c:346
static void gc_set_linewidth(struct graphics_gc_priv *gc, int w)
Definition: graphics_egl.c:342

Referenced by gc_new().

◆ graphics_gc_priv

◆ graphics_image_priv

◆ graphics_methods

Initial value:
= {
NULL,
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_egl.c:1082
static void draw_drag(struct graphics_priv *gr, struct point *p)
Definition: graphics_egl.c:784
static void overlay_disable(struct graphics_priv *gr, int disable)
Definition: graphics_egl.c:951
static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
Definition: graphics_egl.c:634
static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
Definition: graphics_egl.c:779
static void * get_data(struct graphics_priv *this, const char *type)
Definition: graphics_egl.c:899
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_egl.c:751
static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
Definition: graphics_egl.c:791
static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
Definition: graphics_egl.c:597
static void image_free(struct graphics_priv *gr, struct graphics_image_priv *gi)
Definition: graphics_egl.c:480
static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
Definition: graphics_egl.c:832
static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
Definition: graphics_egl.c:613
static struct graphics_gc_priv * gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
Definition: graphics_egl.c:423
static struct graphics_image_priv * image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot, int rotation)
Definition: graphics_egl.c:434
static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound)
Definition: graphics_egl.c:958
static void graphics_destroy(struct graphics_priv *gr)
Definition: graphics_egl.c:328

Referenced by graphics_opengl_new_helper().

◆ graphics_priv_root

◆ hImageData

GHashTable* hImageData
static

Referenced by graphics_opengl_new(), and image_new().

◆ image_error

struct graphics_image_priv image_error
static

Referenced by image_new().

◆ USERWANTSTOQUIT

int USERWANTSTOQUIT = 0
static

Referenced by graphics_sdl_idle().

◆ vertex_src

const char vertex_src[]
Initial value:
=
" \
attribute vec2 position; \
attribute vec2 texture_position; \
uniform mat4 mvp; \
varying vec2 v_texture_position; \
\
void main() \
{ \
v_texture_position=texture_position; \
gl_Position = mvp*vec4(position, 0.0, 1.0); \
} \
"

Referenced by get_data().