summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/akiru/src/emu_window/emu_window_glfw.cpp96
-rw-r--r--src/akiru/src/emu_window/emu_window_glfw.h56
-rw-r--r--src/core/src/core.cpp2
3 files changed, 154 insertions, 0 deletions
diff --git a/src/akiru/src/emu_window/emu_window_glfw.cpp b/src/akiru/src/emu_window/emu_window_glfw.cpp
new file mode 100644
index 000000000..01e5992e5
--- /dev/null
+++ b/src/akiru/src/emu_window/emu_window_glfw.cpp
@@ -0,0 +1,96 @@
1/**
2 * Copyright (C) 2013 Akiru Emulator
3 *
4 * @file emu_window_glfw.cpp
5 * @author ShizZy <shizzy@6bit.net>
6 * @date 2013-09-04
7 * @brief Implementation implementation of EmuWindow class for GLFW
8 *
9 * @section LICENSE
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details at
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * Official project repository can be found at:
22 * http://code.google.com/p/gekko-gc-emu/
23 */
24
25#include "common.h"
26#include "emu_window_glfw.h"
27
28static void OnKeyEvent(GLFWwindow* win, int key, int action) {
29 // EmuWindow_GLFW* emuwin = (EmuWindow_GLFW*)glfwGetWindowUserPointer(win);
30 //input_common::GCController::GCButtonState state;
31
32 //if (action == GLFW_PRESS) {
33 // state = input_common::GCController::PRESSED;
34 //} else {
35 // state = input_common::GCController::RELEASED;
36 //}
37 // for (int channel = 0; channel < 4 && emuwin->controller_interface(); ++channel) {
38 // emuwin->controller_interface()->SetControllerStatus(channel, key, state);
39 // }
40}
41
42static void OnWindowSizeEvent(GLFWwindow* win, int width, int height) {
43 EmuWindow_GLFW* emuwin = (EmuWindow_GLFW*)glfwGetWindowUserPointer(win);
44 emuwin->set_client_area_width(width);
45 emuwin->set_client_area_height(height);
46}
47
48/// EmuWindow_GLFW constructor
49EmuWindow_GLFW::EmuWindow_GLFW() {
50 // Initialize the window
51 if(glfwInit() != GL_TRUE) {
52 printf("Failed to initialize GLFW! Exiting...");
53 exit(1);
54 }
55 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
56 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
57 render_window_ = glfwCreateWindow(640, 480, "akiru", NULL, NULL);
58
59 // Setup callbacks
60 glfwSetWindowUserPointer(render_window_, this);
61 //glfwSetKeyCallback(render_window_, OnKeyEvent);
62 //glfwSetWindowSizeCallback(render_window_, OnWindowSizeEvent);
63
64 DoneCurrent();
65}
66
67/// EmuWindow_GLFW destructor
68EmuWindow_GLFW::~EmuWindow_GLFW() {
69 glfwTerminate();
70}
71
72/// Swap buffers to display the next frame
73void EmuWindow_GLFW::SwapBuffers() {
74 glfwSwapBuffers(render_window_);
75}
76
77/// Polls window events
78void EmuWindow_GLFW::PollEvents() {
79 // TODO(ShizZy): Does this belong here? This is a reasonable place to update the window title
80 // from the main thread, but this should probably be in an event handler...
81 static char title[128];
82 sprintf(title, "%s (FPS: %02.02f)", window_title_.c_str(), 0.0f);
83 glfwSetWindowTitle(render_window_, title);
84
85 glfwPollEvents();
86}
87
88/// Makes the GLFW OpenGL context current for the caller thread
89void EmuWindow_GLFW::MakeCurrent() {
90 glfwMakeContextCurrent(render_window_);
91}
92
93/// Releases (dunno if this is the "right" word) the GLFW context from the caller thread
94void EmuWindow_GLFW::DoneCurrent() {
95 glfwMakeContextCurrent(NULL);
96}
diff --git a/src/akiru/src/emu_window/emu_window_glfw.h b/src/akiru/src/emu_window/emu_window_glfw.h
new file mode 100644
index 000000000..927d726b8
--- /dev/null
+++ b/src/akiru/src/emu_window/emu_window_glfw.h
@@ -0,0 +1,56 @@
1/**
2 * Copyright (C) 2013 Akiru Emulator
3 *
4 * @file emu_window_glfw.h
5 * @author ShizZy <shizzy@6bit.net>
6 * @date 2013-09-04
7 * @brief Implementation implementation of EmuWindow class for GLFW
8 *
9 * @section LICENSE
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details at
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * Official project repository can be found at:
22 * http://code.google.com/p/gekko-gc-emu/
23 */
24
25#ifndef AKIRU_EMUWINDOW_GLFW_
26#define AKIRU_EMUWINDOW_GLFW_
27
28#include <GL/glew.h>
29#include <GLFW/glfw3.h>
30
31#include "emu_window.h"
32
33class EmuWindow_GLFW : public EmuWindow {
34public:
35 EmuWindow_GLFW();
36 ~EmuWindow_GLFW();
37
38 /// Swap buffers to display the next frame
39 void SwapBuffers();
40
41 /// Polls window events
42 void PollEvents();
43
44 /// Makes the graphics context current for the caller thread
45 void MakeCurrent();
46
47 /// Releases (dunno if this is the "right" word) the GLFW context from the caller thread
48 void DoneCurrent();
49
50 GLFWwindow* render_window_; ///< Internal GLFW render window
51
52private:
53
54};
55
56#endif // AKIRU_EMUWINDOW_GLFW_
diff --git a/src/core/src/core.cpp b/src/core/src/core.cpp
new file mode 100644
index 000000000..b5ac85648
--- /dev/null
+++ b/src/core/src/core.cpp
@@ -0,0 +1,2 @@
1void null() {
2} \ No newline at end of file