예제 #1
0
파일: mac.cpp 프로젝트: bavery22/aminolang
Handle<Value> createWindow(const Arguments& args) {
    HandleScope scope;
    int w  = args[0]->ToNumber()->NumberValue();
    int h  = args[1]->ToNumber()->NumberValue();
    width = w;
    height = h;
    if(!glfwOpenWindow(width,height, 8, 8, 8, 0, 24, 8, GLFW_WINDOW)) {
        printf("error. quitting\n");
        glfwTerminate();
        exit(EXIT_FAILURE);        
    }
    
    glfwSetWindowSizeCallback(GLFW_WINDOW_SIZE_CALLBACK_FUNCTION);
    glfwSetWindowCloseCallback(GLFW_WINDOW_CLOSE_CALLBACK_FUNCTION);
    glfwSetMousePosCallback(GLFW_MOUSE_POS_CALLBACK_FUNCTION);
    glfwSetMouseButtonCallback(GLFW_MOUSE_BUTTON_CALLBACK_FUNCTION);
    glfwSetKeyCallback(GLFW_KEY_CALLBACK_FUNCTION);
    
    colorShader = new ColorShader();
    textureShader = new TextureShader();
    fontShader = new FontShader();
    modelView = new GLfloat[16];

    globaltx = new GLfloat[16];
    make_identity_matrix(globaltx);
    

    
    
    glViewport(0,0,width, height);
    return scope.Close(Undefined());
}
예제 #2
0
void Application::createDisplay(uint width, uint height,
                            uint redBits, uint greenBits, uint blueBits,
                            uint alphaBits, uint depthBits, uint stencilBits,
                            DisplayMode mode, const std::string &title)
{
    GLboolean status;
    status = glfwOpenWindow(width, height, redBits, greenBits, blueBits, 
                    alphaBits, depthBits, stencilBits,
                    mode == DISP_FULLSCREEN ? GLFW_FULLSCREEN : GLFW_WINDOW);
    if(status == GL_FALSE)
    {
        throw APIError("Failed to create display.");
    }
    
    // fetch window size (fixes X11 fullscreen bug)
    glfwGetWindowSize(reinterpret_cast<int*>(&displayWidth_), 
                        reinterpret_cast<int*>(&displayHeight_));
    
    glfwSetWindowTitle(title.c_str());  // title is set separately
    
    initOpenGL();
    setOrthoView();
    
    // register the callbacks (after a window is open)
    glfwSetKeyCallback(Application::keyCallback);
    //glfwSetCharCallback(Application::charCallback);
    glfwSetMouseButtonCallback(Application::mouseButtonCallback);
    glfwSetMousePosCallback(Application::mouseMoveCallback);
    glfwSetMouseWheelCallback(Application::mouseWheelCallback);
    
    quit_ = false;
}
예제 #3
0
파일: glfw.c 프로젝트: Axure/emscripten
void Init()
{
  const int window_width = 800,
           window_height = 600;
 
  if (glfwInit() != GL_TRUE)
    Shut_Down(1);
  // 800 x 600, 16 bit color, no depth, alpha or stencil buffers, windowed
  if (glfwOpenWindow(window_width, window_height, 5, 6, 5,
                  0, 0, 0, GLFW_WINDOW) != GL_TRUE)
    Shut_Down(1);
  glfwSetWindowTitle("The GLFW Window");
 
  glfwSetKeyCallback( OnKeyPressed );
  glfwSetCharCallback( OnCharPressed );
  glfwSetWindowCloseCallback(OnClose);
  glfwSetWindowSizeCallback(OnResize);
  glfwSetWindowRefreshCallback(OnRefresh);
  glfwSetMouseWheelCallback(OnMouseWheel);
  glfwSetMousePosCallback(OnMouseMove);
  glfwSetMouseButtonCallback(OnMouseClick);
  
  // set the projection matrix to a normal frustum with a max depth of 50
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  float aspect_ratio = ((float)window_height) / window_width;
  glFrustum(.5, -.5, -.5 * aspect_ratio, .5 * aspect_ratio, 1, 50);
  glMatrixMode(GL_MODELVIEW);
  
  PullInfo();
}
예제 #4
0
파일: main.cpp 프로젝트: s0501007/ogldemo
void setCallbacks()
{
	mouse.firstMove = true;
	glfwSetWindowSizeCallback(resizeCallback);
	glfwSetMousePosCallback(mouseMoveCallback);
	glfwSetKeyCallback(keyCallback);
}
예제 #5
0
	Mouse* Mouse::GetInstance(int screenWidth, int screenHeight)
	{
		if(!instance)
		{
			instance = new Mouse();
			//SET THE BUTTONCALLBACK OF THE OPENGL TO A BUILTIN FUNCTION
			glfwSetMouseButtonCallback(cgl::Mouse::ButtonCallback);
		
			//PROGRAM BUGS IF THIS IS UNCOMMENTED; STRANGE AS HELL
			glfwSetMousePosCallback(cgl::Mouse::PositionCallback);
			if(screenWidth < 1)
			{
				screenWidth = 800;
			}
			if(screenHeight < 1)
			{
				screenHeight = 600;
			}
			instance->screenHeight = screenHeight;
			instance->screenWidth = screenWidth;
			instance->enableCustomMouseCursor = false;
			instance->enableMouseFrame = false;
			instance->SetCursorPosition(screenWidth/2, screenHeight/2);
		}
		return instance;
	}
bool initGlfw(int argc, char **argv)
{
    glfwInit();

    if (!glfwOpenWindow(
        g_app.w(), g_app.h(),
        8,8,8,8,
        0,8,
        GLFW_WINDOW //GLFW_FULLSCREEN
        ))
    {
        glfwTerminate();
        return 0;
    }

    glfwSetWindowTitle        ("GL Skeleton - GLFW 2");
    glfwSetMouseButtonCallback(mouseDown);
    glfwSetMousePosCallback   (mouseMove);
    glfwSetKeyCallback        (keyboard);
    glfwSetWindowSizeCallback (resize);


    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
        // Problem: glewInit failed, something is seriously wrong.
        LOG_INFO("Error: %s\n", glewGetErrorString(err));
    }
    LOG_INFO("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));

    return true;
}
예제 #7
0
GLPresenter::GLPresenter(DeckLinkCapture &capture, int w, int h, int hz) : 
	data_size(w*h*2),
	capture(capture), running(true), fullscreen(false), useVsync(false), rgbFull(false),
	texId(0), displayList(0), 
	convertUYVY(NULL),
	buffer(NULL), buffer2(NULL),
	reqW(w), reqH(h), reqHz(hz), 
	frameIndex(0), drawnFrameIndex(0), aspect(16.0/9.0), oneToNScaleFactor(-1.0)
{
	self = this;

	sprintf(prepend, "#define FRAME_WIDTH %d\n#define FRAME_HEIGHT %d\n", reqW, reqH);

	RT_ASSERT(glfwInit() == GL_TRUE, "Failed to initalize GLFW.");
	RT_ASSERT(glfwOpenWindow(w, h, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) == GL_TRUE, "Failed to open GLFW window.");

	string title("PtBi ");
	title += VER_STRING;
	glfwSetWindowTitle(title.c_str());
	glfwSetWindowPos(10, 10);

	dataPointers[0] = malloc(data_size);
	dataPointers[1] = malloc(data_size);

	glewInit();
	checkExtensions();

	ilInit();

	glfwDisable(GLFW_AUTO_POLL_EVENTS);
	glfwSwapInterval(0);
	glfwSetWindowCloseCallback(closeCallback);
	glfwSetWindowSizeCallback(resizeCallback);
	glfwSetMousePosCallback(mousePosCallback);
	glfwSetKeyCallback(keyCallback);

	hdc = wglGetCurrentDC();
	hrc = wglGetCurrentContext();

	initGL();

	convertUYVY = new GLFragmentProgram("shaders/uyvy_to_rgb_smooth.glsl", getShaderPrependString());

	buffer = new GLRenderTexture(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
	buffer->setFilterMode(GL_LINEAR);
	buffer2 = new GLRenderTexture(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
	buffer2->setFilterMode(GL_LINEAR);

	scalingManager = new ScalingManager(*this);
	aaManager = new AAManager(*this);
	ipManager = new IPManager(*this);
	keyBinding = new KeyBinding(this);
	capture.registerDisplayListener(this);

	hwnd = GetForegroundWindow();

	RT_GL_ASSERT("Error during GL initialization.");

	reshape(reqW, reqH);
}
예제 #8
0
void InputSystem::Initialize() {
	lock = glfwCreateMutex();
	wantsQuit = false;
	seconds = glfwGetTime();
	mousePosition = Vec2(0,0);
    glfwSetMousePosCallback(OnMouseMoved);
}
예제 #9
0
int main(void)
{
    if (!glfwInit())
	{
        fprintf(stderr, "Failed to initialize GLFW\n");
        exit(EXIT_FAILURE);
    }

    if (!glfwOpenWindow(window_width, window_height, 0, 0, 0, 0, 0, 0, GLFW_WINDOW))
    {
        glfwTerminate();

        fprintf(stderr, "Failed to open GLFW window\n");
        exit(EXIT_FAILURE);
    }

	CreateUI(window_width, window_height);

    glfwSetWindowTitle("GLFW + SimpleUI");
    glfwSetMousePosCallback(mouse_pos_callback);
	glfwSetMouseButtonCallback(mouse_button_callback);
    glfwSetWindowSizeCallback(window_size_callback);
    glfwSwapInterval(1);

    while (glfwGetWindowParam(GLFW_OPENED))
    {
		Render();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
예제 #10
0
void Controller::dragAnchorPoint(double x, double y){
	if(getPolygon(x,y) != NULL){
		deselectAllPoints();
		getSelectedPoint(x,y)->setSelection(true);
		glfwSetMousePosCallback(MousePosCallback);
	}
}
예제 #11
0
void Controller::dragSlider(double x, double y){
	try{
		getSlider(x,y)->setSelection(true);
		glfwSetMousePosCallback(MousePosCallback);
	} catch(...){
		throw eFileNotFoundException();
	}
}
예제 #12
0
int main(int argc, char** argv) {
    int running = GL_TRUE;
    // Initialize GLFW
    if (!glfwInit()) {
        exit(EXIT_FAILURE);
    }

    glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
    //    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    //    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1);
    //        glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL

    // Open an OpenGL window
    if (!glfwOpenWindow(1280, 720, 0, 0, 0, 0, 32, 0, GLFW_WINDOW)) {
        glfwTerminate();
        return EXIT_FAILURE;
    }

    glfwSetWindowTitle("Capivara-GL Test");

    //    glEnable(GL_LINE_SMOOTH);
    //    glEnable(GL_BLEND);
    //    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    //    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    //    glLineWidth(1.5f);

    glfwEnable(GLFW_KEY_REPEAT);
    glfwEnable(GLFW_STICKY_KEYS);

    glEnable(GL_MULTISAMPLE);
    glDisable(GL_DEPTH_TEST);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

    initComponents();
    glfwSetKeyCallback(keyCallback);
    glfwSetCharCallback(charCallback);
    glfwSetWindowRefreshCallback(display);
    glfwSetWindowSizeCallback(reshape);
    glfwSetMousePosCallback(mousePosition);
    glfwSetMouseButtonCallback(mouseButton);
    //-------------------------------------------------------------------------
    // Main loop
    while (running) {
        display();
        glfwSwapBuffers();

        running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);
    }
    deleteComponents();

    // Close window and terminate GLFW
    glfwTerminate();
    return EXIT_SUCCESS;
}
예제 #13
0
void ShellSystemInterface::UnRegisterInputDevices(){
	glfwSetCharCallback(NULL);
	glfwSetKeyCallback(NULL);
	
	glfwSetMousePosCallback(NULL);
	glfwSetMouseButtonCallback(NULL);
	glfwSetMouseWheelCallback(NULL);
	inputRegistered = false;
}
예제 #14
0
void ShellSystemInterface::RegisterInputDevices(){
	registerKeyboardInput();
	
	glfwSetMousePosCallback(&HandleMousePosition);
	glfwSetMouseButtonCallback(&HandleMouseToggle);
	glfwSetMouseWheelCallback(&HandleScrollWheel);
	inputRegistered = true;
	
}
예제 #15
0
CMouseController& CMouseController::Instance(){

	if (!m_mouseController){
		m_mouseController = new CMouseController();
		glfwSetMouseButtonCallback(&MouseCallback); //asocia la funcion de callback al glfw
		glfwSetMousePosCallback(&MouseCallback2);
	}

	return *m_mouseController;
}
예제 #16
0
파일: event_init.c 프로젝트: rolfrm/epiclib
void init_events()
{
  last_wheel_pos = glfwGetMouseWheel();
  glfwSetKeyCallback(keycallback);
  glfwSetMouseButtonCallback(mousebuttoncallback);
  glfwSetMousePosCallback(mouse_move_callback);
  glfwSetCharCallback(charcallback);
  glfwSetMouseWheelCallback(mouse_wheel_callback);
  glfwSetWindowSizeCallback(window_size_callback);
}
예제 #17
0
void setupCallbacks(){
    glfwSetWindowSizeCallback( GLFWWindowSizeCb );
    glfwSetWindowCloseCallback( GLFWWindowCloseCb );
    glfwSetWindowRefreshCallback( GLFWWindowRefreshCb );
    glfwSetKeyCallback( GLFWKeyCb );
    glfwSetCharCallback( GLFWMousePosCb );
    glfwSetMouseButtonCallback( GLFWMouseButtonCb );
    glfwSetMousePosCallback( GLFWMousePosCb );
    glfwSetMouseWheelCallback( GLFWMouseWheelCb );
};
예제 #18
0
//--------------------------------------------
void ofAppGLFWWindow::initializeWindow(){
	 //----------------------
	 // setup the callbacks

	 glfwSetMouseButtonCallback(mouse_cb);
	 glfwSetMousePosCallback(motion_cb);
	 glfwSetKeyCallback(keyboard_cb);
	 glfwSetWindowSizeCallback(resize_cb);
	 glfwSetWindowCloseCallback(exit_cb);

}
예제 #19
0
void GLFWMouseListener::MouseInit()
{
	if (!initialised)
	{
		glfwSetMouseButtonCallback(MouseButtonCallback);
		glfwSetMousePosCallback(MouseMoveCallback);
		glfwSetMouseWheelCallback(MouseWheelCallback);
		listeners.push_back(this);
	}
	initialised = true;
}
예제 #20
0
void outPut::init_Tw()
{
    ///Initialisation AntTweakBar
    TwInit(TW_OPENGL, NULL);
    TwWindowSize(_reg.WIDTH, _reg.HEIGHT);
    // redirection des callbacks GFLW sur AntTweakBar
    glfwSetMouseButtonCallback((GLFWmousebuttonfun)TwEventMouseButtonGLFW);
    glfwSetMousePosCallback((GLFWmouseposfun)TwEventMousePosGLFW);
    glfwSetMouseWheelCallback((GLFWmousewheelfun)TwEventMouseWheelGLFW);
    glfwSetKeyCallback((GLFWkeyfun)TwEventKeyGLFW);
    glfwSetCharCallback((GLFWcharfun)TwEventCharGLFW);
}
예제 #21
0
파일: fsinput.c 프로젝트: FeiZhan/smf_view
int main(void)
{
    GLFWvidmode mode;

    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW\n");
        exit(1);
    }

    glfwGetDesktopMode(&mode);

    if (!glfwOpenWindow(mode.Width, mode.Height, 0, 0, 0, 0, 0, 0, GLFW_FULLSCREEN))
    {
        glfwTerminate();

        fprintf(stderr, "Failed to open GLFW window\n");
        exit(1);
    }

    glfwSetWindowTitle("Fullscreen Input Detector");
    glfwSetKeyCallback(key_callback);
    glfwSetCharCallback(char_callback);
    glfwSetMousePosCallback(mouse_position_callback);
    glfwSetMouseButtonCallback(mouse_button_callback);
    glfwSetMouseWheelCallback(mouse_wheel_callback);
    glfwSetWindowSizeCallback(window_size_callback);
    glfwSwapInterval(1);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glfwSetTime(0.0);

    running = GL_TRUE;

    while (running)
    {
        glClearColor((GLclampf) fabs(cos(glfwGetTime() * 4.f)), 0, 0, 0);
        glClear(GL_COLOR_BUFFER_BIT);

        glfwSwapBuffers();

        if (!glfwGetWindowParam(GLFW_OPENED))
            running = GL_FALSE;

        if (glfwGetTime() > 10.0)
            running = GL_FALSE;
    }

    glfwTerminate();
    exit(0);
}
예제 #22
0
/////////////////////////////////////////////////////////
// createMess
//
/////////////////////////////////////////////////////////
bool gemglfw2window :: create(void)
{
  int mode = GLFW_WINDOW;
  if(0!=s_window) {
    error("window already made!");
    return false;
  }

  if(m_fullscreen)
    mode=GLFW_FULLSCREEN;

  glfwOpenWindowHint(GLFW_FSAA_SAMPLES, m_fsaa);


  if(m_profile_major) {
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, m_profile_major); // We want OpenGL 3.3
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, m_profile_minor);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL
  }

  if (!glfwOpenWindow(m_width, m_height,
                      8, 8, 8, 8,  /* RGBA bits */
                      24, 8,       /* depth/stencil bits */
                      mode)) {
    error("glfw couldn't create window");
    return false;
  }



  // FIXXME: single/double buffering

  if(!createGemWindow()) {
    destroyMess();
    return false;
  }
  s_window=this;

  titleMess(m_title);
  offsetMess(m_xoffset, m_yoffset);
  cursorMess(m_cursor);

  glfwSetWindowSizeCallback   (windowsizeCb);
  glfwSetWindowCloseCallback  (windowcloseCb);
  glfwSetWindowRefreshCallback(windowrefreshCb);
  glfwSetKeyCallback          (keyCb);
  glfwSetCharCallback         (charCb);
  glfwSetMouseButtonCallback  (mousebuttonCb);
  glfwSetMousePosCallback     (mouseposCb);
  glfwSetMouseWheelCallback   (mousewheelCb);
  dispatch();
  return (0!=s_window);
}
예제 #23
0
bool InputGLFW::Initialise()
{
	InitialiseKeymap();

	//init callbacks for glfw
	glfwSetCharCallback( CharCallback );
	glfwSetKeyCallback( KeyCallback );
	glfwSetMouseButtonCallback( MouseButtonCallback );
	glfwSetMousePosCallback( MousePosCallback );
	glfwSetMouseWheelCallback( MouseWheelCallback );

	return true;
}
예제 #24
0
void RenderWindow::setCallbacks() {

	glfwEnable(GLFW_STICKY_KEYS);
	//glfwDisable( GLFW_SYSTEM_KEYS );

	// glfw callbacks ///////////////////////////////////////////////////	
	glfwSetKeyCallback(keyCB);
	glfwSetCharCallback(charCB);
	glfwSetMousePosCallback(mousePosCB);
	glfwSetMouseButtonCallback(mouseButtonCB);
	glfwSetMouseWheelCallback(mouseWheelCB);

	glfwSetWindowSizeCallback(windowSizeCB);
}
예제 #25
0
int main(void)
{
    setlocale(LC_ALL, "");

    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW\n");
        exit(1);
    }

    printf("Library initialized\n");

    if (!glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW))
    {
        glfwTerminate();

        fprintf(stderr, "Failed to create GLFW window");
        exit(1);
    }

    printf("Window opened\n");

    glfwSetWindowTitle("Event Linter");
    glfwSwapInterval(1);

    glfwSetWindowSizeCallback(window_size_callback);
    glfwSetWindowCloseCallback(window_close_callback);
    glfwSetWindowRefreshCallback(window_refresh_callback);
    glfwSetMouseButtonCallback(mouse_button_callback);
    glfwSetMousePosCallback(mouse_position_callback);
    glfwSetMouseWheelCallback(mouse_wheel_callback);
    glfwSetKeyCallback(key_callback);
    glfwSetCharCallback(char_callback);

    printf("Key repeat should be %s\n", keyrepeat ? "enabled" : "disabled");
    printf("System keys should be %s\n", systemkeys ? "enabled" : "disabled");

    printf("Main loop starting\n");

    while (glfwGetWindowParam(GLFW_OPENED) == GL_TRUE)
    {
        glfwWaitEvents();
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers();
    }

    glfwTerminate();
    exit(0);
}
예제 #26
0
InputManager::InputManager()
{
	// Initialize all our buttons
	for (unsigned i = 0; i < RS_INPUT_MAX; i++)
		g_pButtons[i] = new ButtonState(i);
	
	// Reserve 16 slots in the queue initially
	g_vQueue.reserve(16);
	
	// Set the callbacks up
	glfwSetKeyCallback(KeyboardCallback);
	glfwSetMouseButtonCallback(MouseButtonCallback);
	glfwSetMousePosCallback(MousePosCallback);
	glfwSetScrollCallback(MouseScrollCallback);
}
예제 #27
0
파일: glfw.cpp 프로젝트: hglm/sre
void sreBackendGLFW::Initialize(int *argc, char ***argv, int requested_width, int requested_height,
int& actual_width, int& actual_height, unsigned int backend_flags) {
    glfwInit();
    // Require OpenGL >= 3.0.
//    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
//    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 0);
    // Because we use glBindAttribute for compability with OpenGL ES 2.0, we do not have forward compability.
//    glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    if (backend_flags & SRE_BACKEND_INIT_FLAG_MULTI_SAMPLE)
        // Enable multi-sample anti-aliasing
        glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
    int r;
    if (backend_flags & SRE_BACKEND_INIT_FLAG_STENCIL_BUFFER)
        r = glfwOpenWindow(requested_width, requested_height, 8, 8, 8, 8, 24, 8, GLFW_WINDOW);
    else
        r = glfwOpenWindow(requested_width, requested_height, 8, 8, 8, 8, 24, 0, GLFW_WINDOW);
    if (!r) {
        printf("Failed to open GLFW window.\n");
        glfwTerminate();
        exit(1);
    }
    glfwGetWindowSize(&actual_width, &actual_height);
    glfwSetWindowTitle("SRE demo -- OpenGL rendering demo using GLFW");
    int stencil_bits = glfwGetWindowParam(GLFW_STENCIL_BITS);
    int depth_bits = glfwGetWindowParam(GLFW_DEPTH_BITS);
    printf("Opened GLFW context of size %d x %d with 32-bit pixels, %d-bit depthbuffer and %d-bit stencil.\n",
        actual_width, actual_height, depth_bits, stencil_bits);
    glfwSetWindowSizeCallback(WindowResizeCallback);
    glfwSetKeyCallback(KeyCallback);
    glfwSetMousePosCallback(MousePosCallback);
    glfwSetMouseButtonCallback(MouseButtonCallback);
    // Don't poll events during glfwSwapBuffers but require explicit calls to glfwPollEvents().
    glfwDisable(GLFW_AUTO_POLL_EVENTS);
    // Generate multiple keypress events when a key is held down.
//    glfwEnable(GLFW_KEY_REPEAT);
//    if (fullscreen_mode)
//        glfwSetMousePos(window_width / 2, window_height / 2);

    GLenum err = glewInit();
    if (GLEW_OK != err) {
        /* Problem: glewInit failed, something is seriously wrong. */
        fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
        exit(1);
    }
    fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));

    initialized = true;
}
예제 #28
0
void InputManager::RemoveGlfwCallbacks()
{
	glfwSetWindowSizeCallback(nullptr);

	glfwSetKeyCallback(nullptr);
	glfwSetCharCallback(nullptr);
	glfwSetMouseButtonCallback(nullptr);
	glfwSetMousePosCallback(nullptr);
	glfwSetMouseWheelCallback(nullptr);
#ifdef _GLFW_DMITRI_WINDOWS_TOUCH_ENABLED
	glfwSetTouchCallback(nullptr);
#endif // _GLFW_DMITRI_WINDOWS_TOUCH_ENABLED

	m_TypingPointer.reset();
	m_MousePointer.reset();
}
예제 #29
0
void InputManager::SetGlfwCallbacks()
{
	m_TypingPointer = std::unique_ptr<TypingPointer>(new TypingPointer(*m_InputHandler));
	m_MousePointer = std::unique_ptr<MousePointer>(new MousePointer(*m_InputHandler));

	glfwSetWindowSizeCallback(&InputManager::ProcessWindowSize);

	glfwSetKeyCallback(&InputManager::ProcessKey);
	glfwSetCharCallback(&InputManager::ProcessChar);
	glfwSetMouseButtonCallback(&InputManager::ProcessMouseButton);
	glfwSetMousePosCallback(&InputManager::ProcessMousePos);
	glfwSetMouseWheelCallback(&InputManager::ProcessMouseWheel);
#ifdef _GLFW_DMITRI_WINDOWS_TOUCH_ENABLED
	glfwSetTouchCallback(&InputManager::ProcessTouch);
#endif // _GLFW_DMITRI_WINDOWS_TOUCH_ENABLED
}
예제 #30
0
int main( int argc, char* argv[] )
{
	width = 800;
	height = 600;
	int BPP=32;
	glfwInit(); // Initialize openGL.
#if GLFW_VERSION_MAJOR==3
	GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL Tutorialal", NULL, NULL);
	g_window=window;
	if(!window) {glfwTerminate(); return 1;}
	glfwMakeContextCurrent(window);

	initialize();									// Initialize the other thing.

	glfwSetKeyCallback(window, onKeyPress);
	glfwSetMouseButtonCallback(window, onMouseButton);
	glfwSetCursorPosCallback(window, onMouseDrag);

	while (!glfwWindowShouldClose(window))
	{
		display();
        glfwSwapBuffers(window);
		glfwPollEvents();
	}
#else
	// Create a window (8-bit depth-buffer, no alpha and stencil buffers, windowed)
   	glfwOpenWindow(width, height, BPP/4, BPP/4, BPP/4, 1, 8, 1, GLFW_WINDOW) ;
	glfwSetWindowTitle("Simple Scene");				// Make window whose name is "Simple Scene".
	int rv,gv,bv;
	glGetIntegerv(GL_RED_BITS,&rv);					// Get the depth of red bits from GL.
	glGetIntegerv(GL_GREEN_BITS,&gv);				// Get the depth of green bits from GL.
	glGetIntegerv(GL_BLUE_BITS,&bv);				// Get the depth of blue bits from GL.
	printf( "Pixel depth = %d : %d : %d\n", rv, gv, bv );
	initialize();									// Initialize the other thing.

	glfwSetKeyCallback(onKeyPress);					// Register onKeyPress function to call that when user presses the keyboard.
	glfwSetMouseButtonCallback(onMouseButton);		// Register onMouseButton function to call that when user moves mouse.
	glfwSetMousePosCallback(onMouseDrag);			// Register onMouseDrag function to call that when user drags mouse.

	while(glfwGetWindowParam(GLFW_OPENED) )
	{
		display();
		glfwSwapBuffers();
	}
#endif
	return 0;
}