* Boston, MA 02110-1301, USA.
*/
-#define USE_OPENGLES 0
-#define USE_OPENGLES2 0
#define USE_FLOAT 0
#define REQUIRES_POWER_OF_2 0
#include <FreeImage.h>
#endif
-#if USE_OPENGLES
-#if USE_OPENGLES2
+#ifdef USE_OPENGLES
+#ifdef USE_OPENGLES2
#include <GLES2/gl2.h>
#include <EGL/egl.h>
#undef USE_FLOAT
void (*button_callback) (void *data, int press, int button,
struct point * p);
void *button_callback_data;
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
GLuint program;
GLint mvp_location, position_location, color_location, texture_position_location, use_texture_location, texture_location;
#else
//hastable for uncompressed image data
static GHashTable *hImageData;
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
#else
/* prototypes */
void APIENTRY tessBeginCB(GLenum which);
static void resize_callback(int w, int h);
static void glut_close();
-#if USE_OPENGLES2
+#ifdef USE_OPENGLES2
const char vertex_src [] =
" \
attribute vec2 position; \
#endif
}
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
static void
set_color(struct graphics_priv *gr, struct graphics_gc_priv *gc)
{
-#if USE_OPENGLES2
+#ifdef USE_OPENGLES2
GLfloat col[4];
col[0]=gc->fr;
col[1]=gc->fg;
x[i*2]=glF(p[i].x);
x[i*2+1]=glF(p[i].y);
}
-#if USE_OPENGLES2
+#ifdef USE_OPENGLES2
glVertexAttribPointer (gr->position_location, 2, GL_FLOAT, 0, 0, x );
#else
glVertexPointer(2, GL_F, 0, x);
x[2]+=glF(1);
x[3]+=glF(1);
x[7]+=glF(1);
-#if USE_OPENGLES2
+#ifdef USE_OPENGLES2
glUniform1i(gr->use_texture_location, 1);
glEnableVertexAttribArray(gr->texture_position_location);
glVertexAttribPointer (gr->texture_position_location, 2, GL_FLOAT, 0, 0, x );
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
draw_rectangle_es(gr, p, w, h);
-#if USE_OPENGLES2
+#ifdef USE_OPENGLES2
glUniform1i(gr->use_texture_location, 0);
glDisableVertexAttribArray(gr->texture_position_location);
#else
&& !gr->overlay_enabled)) {
return;
}
-#if !USE_OPENGLES || USE_OPENGLES2
+#if !defined(USE_OPENGLES) || defined(USE_OPENGLES2)
glLineWidth(gc->linewidth);
#endif
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
set_color(gr, gc);
draw_array(gr, p, count, GL_LINE_STRIP);
#else
#endif
}
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
#else
void APIENTRY
tessCombineCB(GLdouble c[3], void *d[4], GLfloat w[4], void **out)
draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc,
struct point *p, int count)
{
- int i;
-
if ((gr->parent && !gr->parent->overlay_enabled)
|| (gr->parent && gr->parent->overlay_enabled
&& !gr->overlay_enabled)) {
return;
}
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
set_color(gr, gc);
draw_array(gr, p, count, GL_LINE_STRIP);
#else
return; // failed to create tessellation object, return 0
GLdouble quad1[count][3];
+ int i;
for (i = 0; i < count; i++) {
quad1[i][0] = (GLdouble) (p[i].x);
quad1[i][1] = (GLdouble) (p[i].y);
&& !gr->overlay_enabled)) {
return;
}
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
set_color(gr, gc);
draw_rectangle_es(gr, p, w, h);
#else
draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc,
struct point *p, int r)
{
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
#else
if ((gr->parent && !gr->parent->overlay_enabled)
|| (gr->parent && gr->parent->overlay_enabled
32, stride,
&white,
&transparent);
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
struct point p;
p.x=((x + g->x) >> 6)-1;
p.y=((y + g->y) >> 6)-1;
&black,
&white,
&transparent);
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
struct point p;
p.x=(x + g->x) >> 6;
p.y=(y + g->y) >> 6;
&black,
&white,
&transparent);
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
struct point p;
p.x=(x + g->x) >> 6;
p.y=(y + g->y) >> 6;
draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg,
struct point *p, struct graphics_image_priv *img)
{
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
draw_image_es(gr, p, img->w, img->h, img->data);
#else
if ((gr->parent && !gr->parent->overlay_enabled)
static void
handle_mouse_queue()
{
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
#else
static locked = 0;
if (!locked) {
static int
redraw_screen(struct graphics_priv *gr)
{
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
#else
time_t curr_time = time(0);
graphics_priv_root->dirty = 0;
}
+#ifndef USE_OPENGLES
/*filters call to redraw in overlay enabled(map) mode*/
static void
redraw_filter(struct graphics_priv *gr)
redraw_screen(gr);
}
}
+#endif
draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
{
if (gr->parent) { //overlay
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
#else
if (mode == draw_mode_begin) {
glNewList(gr->DLid, GL_COMPILE);
#endif
} else { //root graphics
if (mode == draw_mode_begin) {
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
#else
glNewList(gr->DLid, GL_COMPILE);
#endif
}
if (mode == draw_mode_end) {
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
eglSwapBuffers(egldisplay, eglwindow);
#else
glEndList();
{
}
-#if USE_OPENGLES2
+#ifdef USE_OPENGLES2
static GLuint
load_shader(const char *shader_source, GLenum type)
{
if (!strcmp(type, "gtk_widget")) {
fprintf(stderr,
"Currently GTK gui is not yet supported with opengl graphics driver\n");
- exit(-1);
+ return NULL;
}
if (strcmp(type, "window") == 0) {
struct window *win;
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
GLuint vertexShader;
GLuint fragmentShader;
GLuint textures;
glClearColor ( 0.4 , 0.4 , 0.4 , 1);
#endif
glClear ( GL_COLOR_BUFFER_BIT );
-#if USE_OPENGLES2
+#ifdef USE_OPENGLES2
this->program=glCreateProgram();
vertexShader = load_shader(vertex_src, GL_VERTEX_SHADER);
fragmentShader = load_shader(fragment_src, GL_FRAGMENT_SHADER);
glGenTextures(1, &textures);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures);
+#ifndef USE_OPENGLES2
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-#if !USE_OPENGLES2
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
#endif
#endif
win->disable_suspend = graphics_opengl_disable_suspend;
return win;
} else {
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
return NULL;
#else
return &this->DLid;
this->next = gr->overlays;
gr->overlays = this;
-#if USE_OPENGLES
+#ifdef USE_OPENGLES
#else
this->DLid = glGenLists(1);
#endif
return;
}
+#ifndef USE_OPENGLES
static gboolean
graphics_opengl_idle(void *data)
{
-#if USE_OPENGLES
-#else
static int opengl_init_ok = 0;
if (!opengl_init_ok) {
callback_list_call_attr_2(graphics_priv_root->cbl,
handle_mouse_queue();
}
return TRUE;
-#endif
}
+#endif
static void
ProcessNormalKeys(unsigned char key_in, int x, int y)
resize_callback(int w, int h)
{
glViewport(0, 0, w, h);
+#ifndef USE_OPENGLES2
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
#ifdef MIRRORED_VIEW
#else
glOrthof(glF(0), glF(w), glF(h), glF(0), glF(1), glF(-1));
#endif
+#endif
graphics_priv_root->width = w;
graphics_priv_root->height = h;
char *cmdline = "";
int argc = 0;
-#if !USE_OPENGLES
+#ifndef USE_OPENGLES
glutInit(&argc, &cmdline);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
graphics_priv_root->width = this->width;
graphics_priv_root->height = this->height;
-#if !USE_OPENGLES
+#ifndef USE_OPENGLES
glutMotionFunc(motion_notify);
glutPassiveMotionFunc(motion_notify);
glutMouseFunc(click_notify);
glutCloseFunc(glut_close);
#endif
this->DLid = glGenLists(1);
-#endif
g_timeout_add(G_PRIORITY_DEFAULT + 10, graphics_opengl_idle, NULL);
/*this will only refresh screen in map(overlay enabled) mode */
g_timeout_add(G_PRIORITY_DEFAULT + 1000, redraw_filter, this);
+#endif
//create hash table for uncompressed image data
hImageData = g_hash_table_new(g_str_hash, g_str_equal);