fix compilation of glew engine.

Unfortunately, the computer on which i compile does not
support OpenGL 2.0, so i can't test the engine.

SVN revision: 43610
This commit is contained in:
Vincent Torri 2009-11-11 11:17:11 +00:00
parent a704b35961
commit 43fb7ca168
3 changed files with 346 additions and 205 deletions

View File

@ -1,7 +1,7 @@
#include "evas_engine.h"
#include "Evas_Engine_GL_Glew.h"
int _evas_engine_GL_GLEW_log_dom = -1;
int _evas_engine_GL_glew_log_dom = -1;
/* function tables - filled in later (func and parent func) */
static Evas_Func func, pfunc;
@ -9,27 +9,26 @@ typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
{
HWND win;
HDC dc;
HGLRC context;
Evas_GL_Glew_Window *window;
int end;
};
static void *
eng_info(Evas *e)
eng_info(Evas *e __UNUSED__)
{
Evas_Engine_Info_GL_Glew *info;
info = calloc(1, sizeof(Evas_Engine_Info_GL_Glew));
if (!info) return NULL;
info->magic.magic = rand();
return info;
e = NULL;
}
static void
eng_info_free(Evas *e, void *info)
eng_info_free(Evas *e __UNUSED__, void *info)
{
Evas_Engine_Info_GL_Glew *in;
eina_log_domain_unregister(_evas_engine_GL_glew_log_dom);
in = (Evas_Engine_Info_GL_Glew *)info;
free(in);
}
@ -46,18 +45,8 @@ eng_setup(Evas *e, void *in)
re = calloc(1, sizeof(Render_Engine));
if (!re) return 0;
if (!evas_glew_init(info->info.window, &re->dc, &re->context))
{
free(re);
e->engine.data.output = NULL;
return 0;
}
re->win = info->info.window;
e->engine.data.output = re;
re->window = eng_window_new(info->info.window,
re->dc,
re->context,
info->info.depth,
e->output.w,
e->output.h);
@ -84,20 +73,9 @@ eng_setup(Evas *e, void *in)
}
else
{
if (!evas_glew_init(info->info.window, &re->dc, &re->context))
{
free(re);
e->engine.data.output = NULL;
return 0;
}
re->win = info->info.window;
re = e->engine.data.output;
eng_window_free(re->window);
re->window = eng_window_new(info->info.window,
re->dc,
re->context,
info->info.depth,
e->output.w,
e->output.h);
@ -107,6 +85,7 @@ eng_setup(Evas *e, void *in)
if (!e->engine.data.context)
e->engine.data.context =
e->engine.func->context_new(e->engine.data.output);
eng_window_use(re->window);
return 1;
}
@ -118,7 +97,6 @@ eng_output_free(void *data)
re = (Render_Engine *)data;
eng_window_free(re->window);
evas_glew_shutdown(re->win, re->dc, re->context);
free(re);
evas_common_font_shutdown();
@ -137,11 +115,8 @@ eng_output_resize(void *data, int w, int h)
}
static void
eng_output_tile_size_set(void *data, int w, int h)
eng_output_tile_size_set(void *data __UNUSED__, int w __UNUSED__, int h __UNUSED__)
{
Render_Engine *re;
re = (Render_Engine *)data;
}
static void
@ -177,11 +152,8 @@ eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
}
static void
eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
eng_output_redraws_rect_del(void *data __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
{
Render_Engine *re;
re = (Render_Engine *)data;
}
static void
@ -194,6 +166,8 @@ eng_output_redraws_clear(void *data)
}
#define SLOW_GL_COPY_RECT 1
/* vsync games - not for now though */
//#define VSYNC_TO_SCREEN 1
static void *
eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
@ -201,6 +175,7 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
Render_Engine *re;
re = (Render_Engine *)data;
evas_gl_common_context_flush(re->window->gl_context);
/* get the upate rect surface - return engine data as dummy */
if (!re->window->draw.redraw)
{
@ -235,11 +210,14 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
if (cw) *cw = re->window->draw.x2 - re->window->draw.x1 + 1;
if (ch) *ch = re->window->draw.y2 - re->window->draw.y1 + 1;
#endif
// clear buffer. only needed for dest alpha
// glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// glClear(GL_COLOR_BUFFER_BIT);
return re;
}
static void
eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
eng_output_redraws_next_update_push(void *data, void *surface __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
{
Render_Engine *re;
@ -247,6 +225,7 @@ eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int
/* put back update surface.. in this case just unflag redraw */
re->window->draw.redraw = 0;
re->window->draw.drew = 1;
evas_gl_common_context_flush(re->window->gl_context);
}
static void
@ -260,8 +239,11 @@ eng_output_flush(void *data)
re->window->draw.drew = 0;
eng_window_use(re->window);
#ifdef VSYNC_TO_SCREEN
eng_window_vsync_set(1);
#endif
#ifdef SLOW_GL_COPY_RECT
SwapBuffers(re->dc);
eng_window_swap_buffers(re->window);
#else
/* SLOW AS ALL HELL */
evas_gl_common_swap_rect(re->window->gl_context,
@ -272,35 +254,20 @@ eng_output_flush(void *data)
}
static void
eng_output_idle_flush(void *data)
eng_output_idle_flush(void *data __UNUSED__)
{
Render_Engine *re;
re = (Render_Engine *)data;
}
static void
eng_context_cutout_add(void *data, void *context, int x, int y, int w, int h)
eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
#ifndef EVAS_GL_COMMON_NOCUTOUTS
re->window->gl_context->dc = context;
evas_common_draw_context_add_cutout(context, x, y, w, h);
#endif
}
static void
eng_context_cutout_clear(void *data, void *context)
eng_context_cutout_clear(void *data __UNUSED__, void *context)
{
Render_Engine *re;
re = (Render_Engine *)data;
#ifndef EVAS_GL_COMMON_NOCUTOUTS
re->window->gl_context->dc = context;
evas_common_draw_context_clear_cutouts(context);
#endif
}
static void
@ -320,8 +287,9 @@ eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2,
Render_Engine *re;
re = (Render_Engine *)data;
eng_window_use(re->window);
re->window->gl_context->dc = context;
evas_gl_common_line_draw(re->window->gl_context, x1, y1, x2, y2);
//-// evas_gl_common_line_draw(re->win->gl_context, x1, y1, x2, y2);
}
static void *
@ -330,7 +298,8 @@ eng_polygon_point_add(void *data, void *context, void *polygon, int x, int y)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_gl_common_poly_point_add(polygon, x, y);
//--// return evas_gl_common_poly_point_add(polygon, x, y);
return NULL;
}
@ -340,7 +309,8 @@ eng_polygon_points_clear(void *data, void *context, void *polygon)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_gl_common_poly_points_clear(polygon);
//--// return evas_gl_common_poly_points_clear(polygon);
return NULL;
}
static void
@ -350,91 +320,199 @@ eng_polygon_draw(void *data, void *context, void *surface, void *polygon)
re = (Render_Engine *)data;
re->window->gl_context->dc = context;
evas_gl_common_poly_draw(re->window->gl_context, polygon);
//--// evas_gl_common_poly_draw(re->win->gl_context, polygon);
}
static void
eng_gradient2_color_np_stop_insert(void *data __UNUSED__, void *gradient __UNUSED__, int r __UNUSED__, int g __UNUSED__, int b __UNUSED__, int a __UNUSED__, float pos __UNUSED__)
{
}
static void
eng_gradient2_clear(void *data __UNUSED__, void *gradient __UNUSED__)
{
}
static void
eng_gradient2_fill_transform_set(void *data __UNUSED__, void *gradient __UNUSED__, void *transform __UNUSED__)
{
}
static void
eng_gradient2_fill_spread_set
(void *data __UNUSED__, void *gradient __UNUSED__, int spread __UNUSED__)
{
}
static void *
eng_gradient_new(void *data)
eng_gradient2_linear_new(void *data __UNUSED__)
{
return evas_gl_common_gradient_new();
return NULL;
}
static void
eng_gradient_color_stop_add(void *data, void *gradient, int r, int g, int b, int a, int delta)
eng_gradient2_linear_free(void *data __UNUSED__, void *linear_gradient __UNUSED__)
{
evas_gl_common_gradient_color_stop_add(gradient, r, g, b, a, delta);
}
static void
eng_gradient_alpha_stop_add(void *data, void *gradient, int a, int delta)
eng_gradient2_linear_fill_set(void *data __UNUSED__, void *linear_gradient __UNUSED__, int x0 __UNUSED__, int y0 __UNUSED__, int x1 __UNUSED__, int y1 __UNUSED__)
{
evas_gl_common_gradient_alpha_stop_add(gradient, a, delta);
}
static int
eng_gradient2_linear_is_opaque(void *data __UNUSED__, void *context __UNUSED__, void *linear_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
{
return 1;
}
static int
eng_gradient2_linear_is_visible(void *data __UNUSED__, void *context __UNUSED__, void *linear_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
{
return 1;
}
static void
eng_gradient_clear(void *data, void *gradient)
eng_gradient2_linear_render_pre(void *data __UNUSED__, void *context __UNUSED__, void *linear_gradient __UNUSED__)
{
evas_gl_common_gradient_clear(gradient);
}
static void
eng_gradient_color_data_set(void *data, void *gradient, void *map, int len, int has_alpha)
eng_gradient2_linear_render_post(void *data __UNUSED__, void *linear_gradient __UNUSED__)
{
evas_gl_common_gradient_color_data_set(gradient, map, len, has_alpha);
}
static void
eng_gradient_alpha_data_set(void *data, void *gradient, void *alpha_map, int len)
eng_gradient2_linear_draw(void *data __UNUSED__, void *context __UNUSED__, void *surface __UNUSED__, void *linear_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
{
evas_gl_common_gradient_alpha_data_set(gradient, alpha_map, len);
}
static void *
eng_gradient2_radial_new(void *data __UNUSED__)
{
return NULL;
}
static void
eng_gradient_free(void *data, void *gradient)
eng_gradient2_radial_free(void *data __UNUSED__, void *radial_gradient __UNUSED__)
{
evas_gl_common_gradient_free(gradient);
}
static void
eng_gradient_fill_set(void *data, void *gradient, int x, int y, int w, int h)
eng_gradient2_radial_fill_set(void *data __UNUSED__, void *radial_gradient __UNUSED__, float cx __UNUSED__, float cy __UNUSED__, float rx __UNUSED__, float ry __UNUSED__)
{
evas_gl_common_gradient_fill_set(gradient, x, y, w, h);
}
static int
eng_gradient2_radial_is_opaque(void *data __UNUSED__, void *context __UNUSED__, void *radial_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
{
return 1;
}
static int
eng_gradient2_radial_is_visible(void *data __UNUSED__, void *context __UNUSED__, void *radial_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
{
return 1;
}
static void
eng_gradient_fill_angle_set(void *data, void *gradient, double angle)
eng_gradient2_radial_render_pre(void *data __UNUSED__, void *context __UNUSED__, void *radial_gradient __UNUSED__)
{
evas_gl_common_gradient_fill_angle_set(gradient, angle);
}
static void
eng_gradient_fill_spread_set(void *data, void *gradient, int spread)
eng_gradient2_radial_render_post(void *data __UNUSED__, void *radial_gradient __UNUSED__)
{
evas_gl_common_gradient_fill_spread_set(gradient, spread);
}
static void
eng_gradient_angle_set(void *data, void *gradient, double angle)
eng_gradient2_radial_draw(void *data __UNUSED__, void *context __UNUSED__, void *surface __UNUSED__, void *radial_gradient __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
{
evas_gl_common_gradient_map_angle_set(gradient, angle);
}
static void *
eng_gradient_new(void *data __UNUSED__)
{
//--// return evas_gl_common_gradient_new();
return NULL;
}
static void
eng_gradient_offset_set(void *data, void *gradient, float offset)
eng_gradient_color_stop_add(void *data __UNUSED__, void *gradient, int r, int g, int b, int a, int delta)
{
evas_gl_common_gradient_map_offset_set(gradient, offset);
//--// evas_gl_common_gradient_color_stop_add(gradient, r, g, b, a, delta);
}
static void
eng_gradient_direction_set(void *data, void *gradient, int direction)
eng_gradient_alpha_stop_add(void *data __UNUSED__, void *gradient, int a, int delta)
{
evas_gl_common_gradient_map_direction_set(gradient, direction);
//--// evas_gl_common_gradient_alpha_stop_add(gradient, a, delta);
}
static void
eng_gradient_type_set(void *data, void *gradient, char *name, char *params)
eng_gradient_clear(void *data __UNUSED__, void *gradient)
{
evas_gl_common_gradient_type_set(gradient, name, params);
//--// evas_gl_common_gradient_clear(gradient);
}
static void
eng_gradient_color_data_set(void *data __UNUSED__, void *gradient, void *map, int len, int has_alpha)
{
//--// evas_gl_common_gradient_color_data_set(gradient, map, len, has_alpha);
}
static void
eng_gradient_alpha_data_set(void *data __UNUSED__, void *gradient, void *alpha_map, int len)
{
//--// evas_gl_common_gradient_alpha_data_set(gradient, alpha_map, len);
}
static void
eng_gradient_free(void *data __UNUSED__, void *gradient)
{
//--// evas_gl_common_gradient_free(gradient);
}
static void
eng_gradient_fill_set(void *data __UNUSED__, void *gradient, int x, int y, int w, int h)
{
//--// evas_gl_common_gradient_fill_set(gradient, x, y, w, h);
}
static void
eng_gradient_fill_angle_set(void *data __UNUSED__, void *gradient, double angle)
{
//--// evas_gl_common_gradient_fill_angle_set(gradient, angle);
}
static void
eng_gradient_fill_spread_set(void *data __UNUSED__, void *gradient, int spread)
{
//--// evas_gl_common_gradient_fill_spread_set(gradient, spread);
}
static void
eng_gradient_angle_set(void *data __UNUSED__, void *gradient, double angle)
{
//--// evas_gl_common_gradient_map_angle_set(gradient, angle);
}
static void
eng_gradient_offset_set(void *data __UNUSED__, void *gradient, float offset)
{
//--// evas_gl_common_gradient_map_offset_set(gradient, offset);
}
static void
eng_gradient_direction_set(void *data __UNUSED__, void *gradient, int direction)
{
//--// evas_gl_common_gradient_map_direction_set(gradient, direction);
}
static void
eng_gradient_type_set(void *data __UNUSED__, void *gradient, char *name, char *params)
{
//--// evas_gl_common_gradient_type_set(gradient, name, params);
}
static int
@ -443,7 +521,8 @@ eng_gradient_is_opaque(void *data, void *context, void *gradient, int x, int y,
Render_Engine *re = (Render_Engine *)data;
re->window->gl_context->dc = context;
return evas_gl_common_gradient_is_opaque(re->window->gl_context, gradient, x, y, w, h);
//--// return evas_gl_common_gradient_is_opaque(re->window->gl_context, gradient, x, y, w, h);
return 0;
}
static int
@ -452,7 +531,8 @@ eng_gradient_is_visible(void *data, void *context, void *gradient, int x, int y,
Render_Engine *re = (Render_Engine *)data;
re->window->gl_context->dc = context;
return evas_gl_common_gradient_is_visible(re->window->gl_context, gradient, x, y, w, h);
//--// return evas_gl_common_gradient_is_visible(re->window->gl_context, gradient, x, y, w, h);
return 0;
}
static void
@ -461,33 +541,31 @@ eng_gradient_render_pre(void *data, void *context, void *gradient)
Render_Engine *re = (Render_Engine *)data;
re->window->gl_context->dc = context;
evas_gl_common_gradient_render_pre(re->window->gl_context, gradient);
//--// evas_gl_common_gradient_render_pre(re->window->gl_context, gradient);
}
static void
eng_gradient_render_post(void *data, void *gradient)
eng_gradient_render_post(void *data __UNUSED__, void *gradient)
{
evas_gl_common_gradient_render_post(gradient);
//--// evas_gl_common_gradient_render_post(gradient);
}
static void
eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h)
eng_gradient_draw(void *data, void *context, void *surface __UNUSED__, void *gradient, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
eng_window_use(re->window);
re->window->gl_context->dc = context;
evas_gl_common_gradient_draw(re->window->gl_context, gradient, x, y, w, h);
//--// evas_gl_common_gradient_draw(re->window->gl_context, gradient, x, y, w, h);
}
static int
eng_image_alpha_get(void *data, void *image)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
if (!image) return 1;
im = image;
/* FIXME: can move to gl_common */
@ -504,10 +582,8 @@ eng_image_alpha_get(void *data, void *image)
static int
eng_image_colorspace_get(void *data, void *image)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
if (!image) return EVAS_COLORSPACE_ARGB8888;
im = image;
return im->cs.space;
@ -545,41 +621,31 @@ eng_image_alpha_set(void *data, void *image, int has_alpha)
}
static void *
eng_image_border_set(void *data, void *image, int l, int r, int t, int b)
eng_image_border_set(void *data __UNUSED__, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
{
Render_Engine *re;
re = (Render_Engine *)data;
return image;
}
static void
eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
eng_image_border_get(void *data __UNUSED__, void *image __UNUSED__, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
{
Render_Engine *re;
re = (Render_Engine *)data;
}
static char *
eng_image_comment_get(void *data, void *image, char *key)
eng_image_comment_get(void *data __UNUSED__, void *image, char *key __UNUSED__)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
if (!image) return NULL;
im = image;
im = (Evas_GL_Image *)image;
return im->im->info.comment;
}
static char *
eng_image_format_get(void *data, void *image)
eng_image_format_get(void *data __UNUSED__, void *image)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
im = image;
return NULL;
}
@ -595,6 +661,7 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
im = image;
/* FIXME: can move to gl_common */
if (im->cs.space == cspace) return;
eng_window_use(re->window);
evas_cache_image_colorspace(&im->im->cache_entry, cspace);
switch (cspace)
{
@ -625,12 +692,12 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
}
static void
eng_image_native_set(void *data, void *image, void *native)
eng_image_native_set(void *data __UNUSED__, void *image __UNUSED__, void *native __UNUSED__)
{
}
static void *
eng_image_native_get(void *data, void *image)
eng_image_native_get(void *data __UNUSED__, void *image __UNUSED__)
{
return NULL;
}
@ -678,11 +745,8 @@ eng_image_free(void *data, void *image)
}
static void
eng_image_size_get(void *data, void *image, int *w, int *h)
eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
{
Render_Engine *re;
re = (Render_Engine *)data;
if (!image)
{
*w = 0;
@ -731,12 +795,13 @@ eng_image_size_set(void *data, void *image, int w, int h)
}
static void *
eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
eng_image_dirty_region(void *data, void *image, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
{
Render_Engine *re;
re = (Render_Engine *)data;
if (!image) return NULL;
eng_window_use(re->window);
evas_gl_common_image_dirty(image);
return image;
}
@ -840,7 +905,7 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
}
static void
eng_image_data_preload_request(void *data, void *image, const void *target)
eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
{
Evas_GL_Image *gim = image;
RGBA_Image *im;
@ -852,7 +917,7 @@ eng_image_data_preload_request(void *data, void *image, const void *target)
}
static void
eng_image_data_preload_cancel(void *data, void *image, const void *target)
eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
{
Evas_GL_Image *gim = image;
RGBA_Image *im;
@ -864,7 +929,7 @@ eng_image_data_preload_cancel(void *data, void *image, const void *target)
}
static void
eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
eng_image_draw(void *data, void *context, void *surface __UNUSED__, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
{
Render_Engine *re;
@ -879,30 +944,51 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
}
static void
eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
eng_image_scale_hint_set(void *data __UNUSED__, void *image __UNUSED__, int hint __UNUSED__)
{
}
static int
eng_image_scale_hint_get(void *data __UNUSED__, void *image)
eng_image_scale_hint_get(void *data __UNUSED__, void *image __UNUSED__)
{
return EVAS_IMAGE_SCALE_HINT_NONE;
}
static void
eng_image_map4_draw(void *data __UNUSED__, void *context, void *surface, void *image, RGBA_Map_Point *p, int smooth, int level)
{
// XXX
}
static void *
eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
{
// XXX
return NULL;
}
static void
eng_image_map_surface_free(void *data __UNUSED__, void *surface)
{
// XXX
}
static void
eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, const char *text)
{
Render_Engine *re;
re = (Render_Engine *)data;
eng_window_use(re->window);
{
// FIXME: put im into context so we can free it
static RGBA_Image *im = NULL;
if (!im)
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
if (!im) return ;
evas_cache_image_surface_alloc(&im->cache_entry, re->window->width, re->window->height);
if (!im) return;
im->cache_entry.w = re->window->width;
im->cache_entry.h = re->window->height;
evas_common_draw_context_font_ext_set(context,
re->window->gl_context,
evas_gl_font_texture_new,
@ -917,14 +1003,21 @@ eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y
}
}
static Eina_Bool
eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
{
// FIXME: support ARGB gl targets!!!
return EINA_FALSE;
}
static int
module_open(Evas_Module *em)
{
if (!em) return 0;
/* get whatever engine module we inherit from */
if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
_evas_engine_GL_GLEW_log_dom = eina_log_domain_register("EvasGLGlew",EVAS_DEFAULT_LOG_COLOR);
if(_evas_engine_GL_GLEW_log_dom < 0)
_evas_engine_GL_glew_log_dom = eina_log_domain_register("EvasGLGlew", EVAS_DEFAULT_LOG_COLOR);
if(_evas_engine_GL_glew_log_dom < 0)
{
EINA_LOG_ERR("Impossible to create a log domain for GL (Glew) engine.\n");
return 0;
@ -936,6 +1029,7 @@ module_open(Evas_Module *em)
ORD(info);
ORD(info_free);
ORD(setup);
ORD(canvas_alpha_get);
ORD(output_free);
ORD(output_resize);
ORD(output_tile_size_set);
@ -953,6 +1047,28 @@ module_open(Evas_Module *em)
ORD(polygon_point_add);
ORD(polygon_points_clear);
ORD(polygon_draw);
ORD(gradient2_color_np_stop_insert);
ORD(gradient2_clear);
ORD(gradient2_fill_transform_set);
ORD(gradient2_fill_spread_set);
ORD(gradient2_linear_new);
ORD(gradient2_linear_free);
ORD(gradient2_linear_fill_set);
ORD(gradient2_linear_is_opaque);
ORD(gradient2_linear_is_visible);
ORD(gradient2_linear_render_pre);
ORD(gradient2_linear_render_post);
ORD(gradient2_linear_draw);
ORD(gradient2_radial_new);
ORD(gradient2_radial_free);
ORD(gradient2_radial_fill_set);
ORD(gradient2_radial_is_opaque);
ORD(gradient2_radial_is_visible);
ORD(gradient2_radial_render_pre);
ORD(gradient2_radial_render_post);
ORD(gradient2_radial_draw);
ORD(gradient_new);
ORD(gradient_free);
ORD(gradient_color_stop_add);
@ -972,6 +1088,7 @@ module_open(Evas_Module *em)
ORD(gradient_render_pre);
ORD(gradient_render_post);
ORD(gradient_draw);
ORD(image_load);
ORD(image_new_from_data);
ORD(image_new_from_copied_data);
@ -994,11 +1111,16 @@ module_open(Evas_Module *em)
ORD(image_colorspace_get);
ORD(image_native_set);
ORD(image_native_get);
ORD(font_draw);
ORD(image_scale_hint_set);
ORD(image_scale_hint_get);
ORD(image_map4_draw);
ORD(image_map_surface_new);
ORD(image_map_surface_free);
/* now advertise out own api */
em->functions = (void *)(&func);
return 1;
@ -1007,7 +1129,7 @@ module_open(Evas_Module *em)
static void
module_close(Evas_Module *em)
{
eina_log_domain_unregister(_evas_engine_GL_GLEW_log_dom);
eina_log_domain_unregister(_evas_engine_GL_glew_log_dom);
}
static Evas_Module_Api evas_modapi =

View File

@ -1,9 +1,15 @@
#ifndef __EVAS_ENGINE_H__
#define __EVAS_ENGINE_H__
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <windows.h>
#include "evas_gl_common.h"
#include "Evas_Engine_GL_Glew.h"
extern int _evas_engine_GL_glew_log_dom ;
#ifdef ERR
# undef ERR
@ -34,9 +40,11 @@ typedef struct _Evas_GL_Glew_Window Evas_GL_Glew_Window;
struct _Evas_GL_Glew_Window
{
#ifdef _WIN32
HWND window;
HDC dc;
HGLRC context;
#endif
int width;
int height;
int depth;
@ -51,21 +59,17 @@ struct _Evas_GL_Glew_Window
} draw;
};
int evas_glew_init(HWND window, HDC *dc, HGLRC *context);
void evas_glew_shutdown(HWND window,
HDC dc,
HGLRC context);
#ifdef _WIN32
Evas_GL_Glew_Window *eng_window_new(HWND window,
HDC dc,
HGLRC context,
int depth,
int width,
int height);
#endif
void eng_window_free(Evas_GL_Glew_Window *gw);
void eng_window_use(Evas_GL_Glew_Window *gw);
void eng_window_swap_buffers(Evas_GL_Glew_Window *gw);
void eng_window_vsync_set(int on);
#endif /* __EVAS_ENGINE_H__ */

View File

@ -1,19 +1,30 @@
#include "evas_common.h"
#include "evas_engine.h"
#include "Evas_Engine_GL_Glew.h"
#ifdef HAVE_GL_GLEW_H
# include <GL/wglew.h>
#endif
static Evas_GL_Glew_Window *_evas_gl_glew_window = NULL;
int
evas_glew_init(HWND window, HDC *dc, HGLRC *context)
Evas_GL_Glew_Window *
eng_window_new(HWND window,
int depth,
int width,
int height)
{
PIXELFORMATDESCRIPTOR pfd;
Evas_GL_Glew_Window *gw;
int format;
*dc = GetDC(window);
if (!*dc)
goto no_dc;
gw = calloc(1, sizeof(Evas_GL_Glew_Window));
if (!gw) return NULL;
gw->window = window;
gw->depth = depth;
gw->dc = GetDC(window);
if (!gw->dc)
goto free_window;
ZeroMemory(&pfd, sizeof (pfd));
pfd.nSize = sizeof (pfd);
@ -24,85 +35,60 @@ evas_glew_init(HWND window, HDC *dc, HGLRC *context)
pfd.cDepthBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE;
format = ChoosePixelFormat(*dc, &pfd);
format = ChoosePixelFormat(gw->dc, &pfd);
if (!format)
goto no_format;
goto release_dc;
SetPixelFormat(*dc, format, &pfd);
SetPixelFormat(gw->dc, format, &pfd);
if (pfd.iPixelType != PFD_TYPE_RGBA)
goto no_format;
goto release_dc;
*context = wglCreateContext(*dc);
if (!*context)
goto no_format;
gw->context = wglCreateContext(gw->dc);
if (!gw->context)
goto release_dc;
wglMakeCurrent(*dc, *context);
wglMakeCurrent(gw->dc, gw->context);
if (glewInit() != GLEW_OK)
goto glew_init_failed;
goto delete_context;
if (GLEW_VERSION_2_0)
if (!GLEW_VERSION_2_0)
{
INF("2.0");
fprintf(stderr, "\nERROR: OpenGL 2.0 not supported. Exiting...\n\n");
goto delete_context;
}
return 1;
glew_init_failed:
wglMakeCurrent(NULL, NULL);
wglDeleteContext(*context);
no_format:
ReleaseDC(window, *dc);
no_dc:
return 0;
}
void
evas_glew_shutdown(HWND window,
HDC dc,
HGLRC context)
{
wglMakeCurrent(NULL, NULL);
wglDeleteContext(context);
ReleaseDC(window, dc);
}
Evas_GL_Glew_Window *
eng_window_new(HWND window,
HDC dc,
HGLRC context,
int depth,
int width,
int height)
{
Evas_GL_Glew_Window *gw;
gw = calloc(1, sizeof(Evas_GL_Glew_Window));
if (!gw) return NULL;
gw->window = window;
gw->dc = dc;
gw->context = context;
gw->depth = depth;
_evas_gl_glew_window = gw;
gw->gl_context = evas_gl_common_context_new();
if (!gw->gl_context)
{
free(gw);
return NULL;
}
goto delete_context;
evas_gl_common_context_resize(gw->gl_context, width, height);
return gw;
delete_context:
wglMakeCurrent(NULL, NULL);
wglDeleteContext(gw->context);
release_dc:
ReleaseDC(window, gw->dc);
free_window:
free(gw);
return NULL;
}
void
eng_window_free(Evas_GL_Glew_Window *gw)
{
if (!gw)
return;
if (gw == _evas_gl_glew_window) _evas_gl_glew_window = NULL;
evas_gl_common_context_free(gw->gl_context);
wglMakeCurrent(NULL, NULL);
wglDeleteContext(gw->context);
ReleaseDC(gw->window, gw->dc);
free(gw);
}
@ -111,8 +97,37 @@ eng_window_use(Evas_GL_Glew_Window *gw)
{
if (_evas_gl_glew_window != gw)
{
_evas_gl_glew_window = gw;
wglMakeCurrent(gw->dc, gw->context);
if (_evas_gl_glew_window)
evas_gl_common_context_flush(_evas_gl_glew_window->gl_context);
_evas_gl_glew_window = gw;
wglMakeCurrent(gw->dc, gw->context);
}
evas_gl_common_context_use(gw->gl_context);
}
void
eng_window_swap_buffers(Evas_GL_Glew_Window *gw)
{
SwapBuffers(gw->dc);
}
void
eng_window_vsync_set(int on)
{
#if 1 /* Using Glew */
wglSwapIntervalEXT(on);
#else /* Using plain OpenGL */
const char *extensions = glGetString(GL_EXTENSIONS);
/* check if WGL_EXT_swap_control extension is supported */
if (strstr(extensions, "WGL_EXT_swap_control") == 0)
return;
else
{
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT");
if (wglSwapIntervalEXT)
wglSwapIntervalEXT(on);
}
#endif
}