Glew OpenGL engine support added.

SVN revision: 31181
expedite-1.1
doursse 16 years ago committed by doursse
parent 5e28c4089c
commit 2d2badc29c
  1. 13
      configure.in
  2. 3
      src/bin/Makefile.am
  3. 325
      src/bin/engine_gl_glew.c
  4. 9
      src/bin/engine_gl_glew.h
  5. 2064
      src/bin/main.c
  6. 1
      src/bin/main.h

@ -25,7 +25,7 @@ else
PACKAGE_BIN_DIR="${bindir}"
fi
AC_SUBST(PACKAGE_BIN_DIR)
if test "x${libdir}" = 'xNONE'; then
if test "x${prefix}" = "xNONE"; then
PACKAGE_LIB_DIR="${ac_default_prefix}/lib"
@ -49,6 +49,15 @@ PKG_CHECK_MODULES([EVAS], evas)
PCFLAGS=$CFLAGS
CFLAGS="$EVAS_CFLAGS $CFLAGS"
have_glew_opengl="no"
AC_CHECK_HEADER(Evas_Engine_GL_Glew.h,
[ AC_DEFINE(HAVE_EVAS_GL_GLEW, 1, [Evas GL Glew Engine Support])
have_glew_opengl="yes"
glew_libs="-lglew32 -lgdi32" ],
[ dummy=no ],
[ #include <Evas.h> ]
)
have_xlib_opengl="no"
AC_CHECK_HEADER(Evas_Engine_GL_X11.h,
[ AC_DEFINE(HAVE_EVAS_GL, 1, [Evas GL Engine Support])
@ -100,6 +109,7 @@ fi
AC_SUBST(x_cflags)
AC_SUBST(x_libs)
AC_SUBST(ddraw_libs)
AC_SUBST(glew_libs)
#######################################
## SDL
@ -144,6 +154,7 @@ echo " Engines:"
echo " Software Xlib...........: ${have_xlib}"
echo " Software Xlib 16 bits...: ${have_xlib_16}"
echo " X Render Xlib...........: ${have_xlib_render}"
echo " Open GL Glew............: ${have_glew_opengl}"
echo " Open GL Xlib............: ${have_xlib_opengl}"
echo " Software DirectDraw.....: ${have_ddraw}"
echo " Software SDL............: ${have_sdl}"

@ -12,6 +12,7 @@ bin_PROGRAMS = expedite
expedite_SOURCES = \
main.c main.h \
engine_software_x11.c engine_software_x11.h \
engine_gl_glew.c engine_gl_glew.h \
engine_gl_x11.c engine_gl_x11.h \
engine_xrender_x11.c engine_xrender_x11.h \
engine_software_16_x11.c engine_software_16_x11.h \
@ -59,4 +60,4 @@ image_blend_occlude2_very_many.c \
image_blend_occlude3_very_many.c \
poly_blend.c
expedite_LDFLAGS = @EVAS_LIBS@ @sdl_libs@ @x_libs@ @ddraw_libs@ -lm
expedite_LDFLAGS = @EVAS_LIBS@ @sdl_libs@ @x_libs@ @ddraw_libs@ @glew_libs@ -lm

@ -0,0 +1,325 @@
#include "main.h"
#ifndef HAVE_EVAS_GL_GLEW
int
engine_gl_glew_args(int argc, char **argv)
{
fprintf(stderr, "ERROR: No GL Glew Engine built\n");
return 0;
}
void
engine_gl_glew_loop(void)
{
}
#else
#include <windows.h>
#include <windowsx.h>
#include <GL/glew.h>
#include <Evas_Engine_GL_Glew.h>
static HWND window;
static int
_opengl_init (HWND w,
int width,
int height,
HDC *dc,
int *depth)
{
PIXELFORMATDESCRIPTOR pfd;
int format;
*dc = GetDC (w);
if (!*dc)
goto no_dc;
ZeroMemory (&pfd, sizeof (pfd));
pfd.nSize = sizeof (pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE;
format = ChoosePixelFormat (*dc, &pfd);
if (!format)
goto no_format;
SetPixelFormat (*dc, format, &pfd);
*depth = 32;
return 1;
no_format:
ReleaseDC (w, *dc);
no_dc:
return 0;
}
static LRESULT CALLBACK
MainWndProc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_CLOSE:
PostQuitMessage(0);
return 0;
case WM_WINDOWPOSCHANGED: {
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint (window, &ps);
evas_damage_rectangle_add(evas,
ps.rcPaint.left, ps.rcPaint.top,
ps.rcPaint.right - ps.rcPaint.left,
ps.rcPaint.bottom - ps.rcPaint.top);
EndPaint(window, &ps);
return 0;
}
case WM_SIZING:
{
PRECT rect = (PRECT)lParam;
evas_output_size_set(evas,
rect->right - rect->left,
rect->bottom - rect->top);
return 0;
}
case WM_RBUTTONDOWN:
evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
evas_event_feed_mouse_down(evas, 3, EVAS_BUTTON_NONE, 0, NULL);
return 0;
case WM_LBUTTONDOWN:
evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
evas_event_feed_mouse_down(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
return 0;
case WM_LBUTTONUP:
evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
evas_event_feed_mouse_up(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
return 0;
case WM_RBUTTONUP:
evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
evas_event_feed_mouse_up(evas, 3, EVAS_BUTTON_NONE, 0, NULL);
return 0;
case WM_MOUSEMOVE:
if (!evas_pointer_inside_get(evas)) evas_event_feed_mouse_in(evas, 0, NULL);
evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
return 0;
case WM_MOUSELEAVE:
evas_event_feed_mouse_out(evas, 0, NULL);
return 0;
/* FIXME : can't find an event when the mouse is entering */
case WM_KEYDOWN:
case WM_SYSKEYDOWN: {
int key;
key = LOWORD(wParam);
if ((key == VK_SHIFT) ||
(key == VK_LSHIFT) ||
(key == VK_RSHIFT))
evas_key_modifier_on(evas, "Shift");
if ((key == VK_CONTROL) ||
(key == VK_LCONTROL) ||
(key == VK_RCONTROL))
evas_key_modifier_on(evas, "Control");
if ((key == VK_MENU) ||
(key == VK_LMENU) ||
(key == VK_RMENU))
evas_key_modifier_on(evas, "Alt");
if ((key == VK_LWIN) ||
(key == VK_RWIN))
evas_key_modifier_on(evas, "Super");
if (key == VK_CAPITAL)
{
if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock"))
evas_key_lock_off(evas, "Caps_Lock");
else
evas_key_lock_on(evas, "Caps_Lock");
}
if (key == VK_NUMLOCK)
{
if (evas_key_lock_is_set(evas_key_lock_get(evas), "Num_Lock"))
evas_key_lock_off(evas, "Num_Lock");
else
evas_key_lock_on(evas, "Num_Lock");
}
if (key == VK_SCROLL)
{
if (evas_key_lock_is_set(evas_key_lock_get(evas), "Scroll_Lock"))
evas_key_lock_off(evas, "Scroll_Lock");
else
evas_key_lock_on(evas, "Scroll_Lock");
}
if (key == VK_ESCAPE)
evas_event_feed_key_down(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
if (key == VK_RETURN)
evas_event_feed_key_down(evas, "Return", "Return", NULL, NULL, 0, NULL);
if (key == VK_LEFT)
evas_event_feed_key_down(evas, "Left", "Left", NULL, NULL, 0, NULL);
if (key == VK_RIGHT)
evas_event_feed_key_down(evas, "Right", "Right", NULL, NULL, 0, NULL);
if (key == 81)
evas_event_feed_key_down(evas, "Q", "Q", NULL, NULL, 0, NULL);
if (key == 113)
evas_event_feed_key_down(evas, "q", "q", NULL, NULL, 0, NULL);
return 0;
}
case WM_KEYUP:
case WM_SYSKEYUP: {
int key;
key = LOWORD(wParam);
if ((key == VK_SHIFT) ||
(key == VK_LSHIFT) ||
(key == VK_RSHIFT))
evas_key_modifier_off(evas, "Shift");
if ((key == VK_CONTROL) ||
(key == VK_LCONTROL) ||
(key == VK_RCONTROL))
evas_key_modifier_off(evas, "Control");
if ((key == VK_MENU) ||
(key == VK_LMENU) ||
(key == VK_RMENU))
evas_key_modifier_off(evas, "Alt");
if ((key == VK_LWIN) ||
(key == VK_RWIN))
evas_key_modifier_off(evas, "Super");
if (key == VK_ESCAPE)
evas_event_feed_key_up(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
if (key == VK_RETURN)
evas_event_feed_key_up(evas, "Return", "Return", NULL, NULL, 0, NULL);
if (key == VK_LEFT)
evas_event_feed_key_up(evas, "Left", "Left", NULL, NULL, 0, NULL);
if (key == VK_RIGHT)
evas_event_feed_key_up(evas, "Right", "Right", NULL, NULL, 0, NULL);
if (key == 81)
evas_event_feed_key_up(evas, "Q", "Q", NULL, NULL, 0, NULL);
if (key == 113)
evas_event_feed_key_up(evas, "q", "q", NULL, NULL, 0, NULL);
return 0;
}
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}
int
engine_gl_glew_args(int argc, char **argv)
{
WNDCLASS wc;
RECT rect;
HINSTANCE hinstance;
HDC dc;
Evas_Engine_Info_GL_Glew *einfo;
int depth;
int i;
int ok = 0;
for (i = 1; i < argc; i++)
{
if ((!strcmp(argv[i], "-e")) && (i < (argc - 1)))
{
i++;
if (!strcmp(argv[i], "gl-glew")) ok = 1;
}
}
if (!ok) return 0;
hinstance = GetModuleHandle(0);
wc.style = 0;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinstance;
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
wc.lpszMenuName = NULL;
wc.lpszClassName = "Evas_Gl_Glew_Test";
if(!RegisterClass(&wc)) return EXIT_FAILURE;
rect.left = 0;
rect.top = 0;
rect.right = win_w;
rect.bottom = win_h;
AdjustWindowRect (&rect, WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW | WS_SIZEBOX, FALSE);
window = CreateWindowEx(0,
"Evas_Gl_Glew_Test",
"Evas_Gl_Glew_Test",
WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW | WS_SIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT,
rect.right - rect.left, rect.bottom - rect.top,
NULL, NULL, hinstance, NULL);
if (!window) return 0;
if (!_opengl_init(window, win_w, win_h,
&dc,
&depth))
return 0;
if (GLEW_VERSION_2_0)
{
printf ("pas 2.0\n");
return 0;
}
else {
printf ("2.0 !!\n");
}
ShowWindow(window, SW_SHOWDEFAULT);
UpdateWindow(window);
evas_output_method_set(evas, evas_render_method_lookup("gl_glew"));
einfo = (Evas_Engine_Info_GL_Glew *)evas_engine_info_get(evas);
if (!einfo)
{
printf("Evas does not support the GL Glew Engine\n");
return 0;
}
einfo->info.window = window;
einfo->info.dc = dc;
einfo->info.depth = depth;
evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
return 1;
}
void
engine_gl_glew_loop(void)
{
MSG msg;
int res;
again:
if (!PeekMessage (&msg, window, 0, 0, PM_NOREMOVE))
return;
res = GetMessage (&msg, NULL, 0, 0);
TranslateMessage (&msg);
DispatchMessage (&msg);
goto again;
}
#endif /* HAVE_EVAS_GL_GLEW */

@ -0,0 +1,9 @@
#ifndef __ENGINE_GL_GLEW_H__
#define __ENGINE_GL_GLEW_H__
int engine_gl_glew_args(int argc, char **argv);
void engine_gl_glew_loop(void);
#endif /* __ENGINE_GL_GLEW_H__ */

File diff suppressed because it is too large Load Diff

@ -11,6 +11,7 @@
#include <Evas.h>
#include "config.h"
#include "engine_software_x11.h"
#include "engine_gl_glew.h"
#include "engine_gl_x11.h"
#include "engine_xrender_x11.h"
#include "engine_software_16_x11.h"

Loading…
Cancel
Save