コード例 #1
0
ファイル: Controller.cpp プロジェクト: FieryGazette/2D-Game
void Controller::UpdateKeys()
{
	/** Set all keys to false **/
	for(unsigned i = 0; i < TOTAL_CONTROLS; ++i)
		myKeys[i] = false;

	/**** See which keys are pressed ****/
	/** Keyboard **/
	for(int i = 0; i <= OPEN; ++i)
	{
		if(IsKeyPressed(inputChar[i]))
			myKeys[i] = true;
	}

	/** non-keyboard(mouse) **/
	mouseLeftButton = glfwGetMouseButton(glfwGetCurrentContext(), GLFW_MOUSE_BUTTON_LEFT);
	mouseRightButton = glfwGetMouseButton(glfwGetCurrentContext(), GLFW_MOUSE_BUTTON_RIGHT);

	if(mouseLeftButton == GLFW_PRESS)
		myKeys[SHOOT] = true;
	if(mouseRightButton == GLFW_PRESS)
		myKeys[AIM] = true;

	/** Arrow key **/
	if( IsKeyPressed(VK_UP) )
		myKeys[ARROW_UP] = true;

	if( IsKeyPressed(VK_DOWN) )
		myKeys[ARROW_DOWN] = true;

	if( IsKeyPressed(VK_LEFT) )
		myKeys[ARROW_LEFT] = true;

	if( IsKeyPressed(VK_RIGHT) )
		myKeys[ARROW_RIGHT] = true;

	/** Scrolling **/
	GLFWwindow* glfwGetCurrentContext(void);
	glfwSetScrollCallback(glfwGetCurrentContext(), scroll);

	if(scrollyPos > 0.0)
	{
		myKeys[SCROLL_UP] = true;
	}
	else if(scrollyPos < 0.0)
	{
		myKeys[SCROLL_DOWN] = true;
	}
	
	if(scrollyPos != 0.0)
	{
		scrollyPos = 0.0;
	}
}
コード例 #2
0
ファイル: highscoremenu.cpp プロジェクト: Gooeybots/Hackman
std::string GetName(ResourceManager &resourceManager)
{
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    std::string name("");
    std::vector<std::string> strVec{"Name: ", name};
    TextRenderer textRenderer(resourceManager.GetTexture("text.png"));

    textRenderer.AddTextHorizontalAlign(strVec, TextRenderer::Alignment::Center,
                                        TextRenderer::Alignment::Center, 30,
                                        glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));

    bool playing(true);
    glfwSetKeyCallback(glfwGetCurrentContext(), GetInput);
    bool enterPressed(false);

    while(playing && !glfwWindowShouldClose(glfwGetCurrentContext()))
    {
        glClear(GL_COLOR_BUFFER_BIT);

        name = Input(strVec.back());

        if(name != strVec.back())
        {
            textRenderer.RemoveText(strVec.back());
            strVec.back() = name;

            textRenderer.AddTextHorizontalAlign(strVec, TextRenderer::Alignment::Center,
                                                TextRenderer::Alignment::Center, 30,
                                                glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
        }

        if(glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_ENTER) == GLFW_PRESS &&
                !enterPressed)
        {
            enterPressed = true;
        }
        else if(glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_ENTER) == GLFW_RELEASE &&
                enterPressed)
        {
            playing = false;
            if(strVec.back().empty())
            {
                strVec.back() = "Player";
            }
        }

        textRenderer.DrawAll();

        glfwSwapBuffers(glfwGetCurrentContext());
        glfwPollEvents();
    }
    return name;
}
コード例 #3
0
ファイル: CX_EntryPoint.cpp プロジェクト: hardmanko/ofxCX
void reopenWindow084(CX_WindowConfiguration config) {

	//Close previous window, if opened
	if (CX::Private::glfwContext == glfwGetCurrentContext()) {
		glfwDestroyWindow(CX::Private::glfwContext);
		CX::Private::glfwContext = nullptr;
	}

	CX::Private::setDesiredRenderer(config, true, nullptr);

	/*
	Note that this section of code is a nasty hack that is only done because of a bug in openFrameworks.
	They are working on the bug, but in the mean time, I want to work around the bug to use new features of
	openFrameworks. The bug is that the pointer passed to ofSetupOpenGL is treated as an ofAppGLFWWindow
	regardless of whether it is one or not. Because CX_AppWindow is not ofAppGLFWWindow (although it's very close)
	passing a pointer to a CX_AppWindow results in, AFAIK, undefined behavior (and we don't want that, do we?).
	
	The hack: Allocate on a pointer enough memory to store either an ofAppGLFWWindow or a CX_AppWindow.
	Use placement new to put an ofAppGLFWWindow at that location.
	Pass that pointer to ofSetupOpenGL. It's an ofAppGLFWWindow, so no problem.
	The location pointed to by the pointer is now stored in the variable "window" in ofAppRunner.cpp.
	Now that the pointer is stored by the "window" variable, destroy the just-opened window.
	Finally, use placement new to create a CX_AppWindow where the pointer points to.
	Success!!!
	*/
	unsigned int appWindowAllocationSize = std::max(sizeof(CX::Private::CX_AppWindow), sizeof(ofAppGLFWWindow));

	void* windowP = new char[appWindowAllocationSize];
	windowP = new(windowP) ofAppGLFWWindow;

	glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
	ofSetupOpenGL((ofAppGLFWWindow*)windowP, config.width, config.height, config.mode);
	if (glfwGetCurrentContext() != NULL) {
		glfwDestroyWindow(glfwGetCurrentContext()); //Close temporary window
	}
	glfwWindowHint(GLFW_VISIBLE, GL_TRUE);

	// shouldn't there be
	//delete windowP;
	// here?
	windowP = new(windowP) CX::Private::CX_AppWindow;
	////////////////////
	// End nasty hack //
	////////////////////

	CX::Private::appWindow = ofPtr<ofAppBaseWindow>((CX::Private::CX_AppWindow*)windowP);

	CX::Private::CX_AppWindow* awp = (CX::Private::CX_AppWindow*)CX::Private::appWindow.get();
	awp->setOpenGLVersion(config.desiredOpenGLVersion.major, config.desiredOpenGLVersion.minor);
	awp->setNumSamples(Util::getMsaaSampleCount());

	((CX::Private::CX_AppWindow*)CX::Private::appWindow.get())->setupOpenGL(config.width, config.height, config.mode, config.preOpeningUserFunction, config.resizeable);
}
コード例 #4
0
void Camera::Update()
{
	float speed = 0.25f;
	if (glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
		speed *= 10;

	if (glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_W) == GLFW_PRESS)
		m_position.z -= speed;
	if (glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_S) == GLFW_PRESS)
		m_position.z += speed;
	if (glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_A) == GLFW_PRESS)
		m_position.x -= speed;
	if (glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_D) == GLFW_PRESS)
		m_position.x += speed;
	if (glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_UP) == GLFW_PRESS)
		m_position.y += speed;
	if (glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_DOWN) == GLFW_PRESS)
		m_position.y -= speed;

	if (glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_F6) == GLFW_PRESS)
	{
		if (m_wireframe)
			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		else
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

		m_wireframe = !m_wireframe;
	}
}
コード例 #5
0
PlayerInputSystem& PlayerInputSystem::getPlayerInputSystem()
{
    static PlayerInputSystem *playerInputSystem = NULL;
    
    if (playerInputSystem == NULL) {
        
        glfwSetKeyCallback(glfwGetCurrentContext(),*keyCallbackFun);
        glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
        
        playerInputSystem = new PlayerInputSystem();
    }
    
    return *playerInputSystem;
}
コード例 #6
0
ファイル: App.cpp プロジェクト: Boopy321/Physics
bool App::GetKeyDown()
{

	if (glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_SPACE) == GLFW_PRESS && !keypress)
	{
		keypress = true;
		return true;
	}
	else if (!glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_SPACE) == GLFW_PRESS && keypress == true)
	{
		keypress = false;
		return false;
	}
	return false;
}
コード例 #7
0
void showDebugImage(std::string name, const char *data, size_t width, size_t height) {
    glfwInit();

    static GLFWwindow *debugWindow = nullptr;
    if (!debugWindow) {
        debugWindow = glfwCreateWindow(width, height, name.c_str(), nullptr, nullptr);
        if (!debugWindow) {
            glfwTerminate();
            fprintf(stderr, "Failed to initialize window\n");
            exit(1);
        }
    }

    GLFWwindow *currentWindow = glfwGetCurrentContext();

    glfwSetWindowSize(debugWindow, width, height);
    glfwMakeContextCurrent(debugWindow);

    int fbWidth, fbHeight;
    glfwGetFramebufferSize(debugWindow, &fbWidth, &fbHeight);
    float scale = static_cast<float>(fbWidth) / static_cast<float>(width);

    {
        gl::PreservePixelZoom pixelZoom;
        gl::PreserveRasterPos rasterPos;

        MBGL_CHECK_ERROR(glPixelZoom(scale, -scale));
        MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f));
        MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data));
    }

    glfwSwapBuffers(debugWindow);

    glfwMakeContextCurrent(currentWindow);
}
コード例 #8
0
void show_color_debug_image(std::string name, const char *data, size_t logical_width, size_t logical_height, size_t width, size_t height) {
    glfwInit();

    static GLFWwindow *debug_window = nullptr;
    if (!debug_window) {
        debug_window = glfwCreateWindow(logical_width, logical_height, name.c_str(), nullptr, nullptr);
        if (!debug_window) {
            glfwTerminate();
            fprintf(stderr, "Failed to initialize window\n");
            exit(1);
        }
    }

    GLFWwindow *current_window = glfwGetCurrentContext();

    glfwSetWindowSize(debug_window, logical_width, logical_height);
    glfwMakeContextCurrent(debug_window);

    int fb_width, fb_height;
    glfwGetFramebufferSize(debug_window, &fb_width, &fb_height);
    float x_scale = (float)fb_width / (float)width;
    float y_scale = (float)fb_height / (float)height;

    glClear(GL_COLOR_BUFFER_BIT);
    glEnable(GL_BLEND);
    glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glPixelZoom(x_scale, -y_scale);
    glRasterPos2f(-1.0f, 1.0f);
    glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
    glfwSwapBuffers(debug_window);

    glfwMakeContextCurrent(current_window);
}
コード例 #9
0
void show_debug_image(std::string name, const char *data, size_t width, size_t height) {
    glfwInit();

    static GLFWwindow *debug_window = nullptr;
    if (!debug_window) {
        debug_window = glfwCreateWindow(width, height, name.c_str(), nullptr, nullptr);
        if (!debug_window) {
            glfwTerminate();
            fprintf(stderr, "Failed to initialize window\n");
            exit(1);
        }
    }

    GLFWwindow *current_window = glfwGetCurrentContext();

    glfwSetWindowSize(debug_window, width, height);
    glfwMakeContextCurrent(debug_window);

    int fb_width, fb_height;
    glfwGetFramebufferSize(debug_window, &fb_width, &fb_height);
    float scale = (float)fb_width / (float)width;

    glPixelZoom(scale, -scale);
    glRasterPos2f(-1.0f, 1.0f);
    glDrawPixels(width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
    glfwSwapBuffers(debug_window);

    glfwMakeContextCurrent(current_window);
}
コード例 #10
0
ファイル: sharing.c プロジェクト: deltaluca/glfw
static void draw_quad(GLuint texture)
{
    int width, height;
    glfwGetFramebufferSize(glfwGetCurrentContext(), &width, &height);

    glViewport(0, 0, width, height);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.f, 1.f, 0.f, 1.f);

    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

    glBegin(GL_QUADS);

    glTexCoord2f(0.f, 0.f);
    glVertex2f(0.f, 0.f);

    glTexCoord2f(1.f, 0.f);
    glVertex2f(1.f, 0.f);

    glTexCoord2f(1.f, 1.f);
    glVertex2f(1.f, 1.f);

    glTexCoord2f(0.f, 1.f);
    glVertex2f(0.f, 1.f);

    glEnd();
}
コード例 #11
0
//----------
void ofxSplashScreen::begin(float minimumDuration) {
	if (!this->image.isAllocated()) {
		ofLogError("ofxSplashScreen") << "Cannot show splash screen since no image has been loaded";
		return;
	}
	this->endTime = ofGetElapsedTimef() + minimumDuration;
	this->appWindow = glfwGetCurrentContext();
	
	glfwHideWindow(this->appWindow);
	glfwWindowHint(GLFW_DECORATED, GL_FALSE);
	this->splashScreenWindow = glfwCreateWindow(this->image.getWidth(), this->image.getHeight(), "ofxSplashScreen", NULL, this->appWindow);
	glfwSetWindowPos(this->splashScreenWindow, (ofGetScreenWidth() - this->image.getWidth()) / 2.0f, (ofGetScreenHeight() - this->image.getHeight()) / 2.0f);
	glfwWindowHint(GLFW_DECORATED, GL_TRUE);
	glfwMakeContextCurrent(this->splashScreenWindow);
	
	//set the drawing matrices to normalised coordinates
	ofSetMatrixMode(OF_MATRIX_PROJECTION);
	ofLoadIdentityMatrix();
	ofSetMatrixMode(OF_MATRIX_MODELVIEW);
	ofLoadIdentityMatrix();
	
	//draw the images
	ofClear(0,0,0);
	this->image.update();
	this->image.draw(-1,-1,2,2);
	glfwSwapBuffers(this->splashScreenWindow);
	glFlush();
	
	//set the context back to main for rest of setup
	glfwMakeContextCurrent(this->appWindow);
	ofSetupScreen();
}
コード例 #12
0
ファイル: basic.hpp プロジェクト: daviddhas/CS-gO
	basic() {
		GLuint vertexArrayID;
		gl::GenVertexArrays(1, &vertexArrayID);
		gl::BindVertexArray(vertexArrayID);

		GLFWwindow *window = glfwGetCurrentContext();

		handle = gl::CreateProgram();
		frag = gl::CreateShader(gl::FRAGMENT_SHADER);
		csgo::glsl::compiler::compile(handle, frag, getFragShader());
		vert = gl::CreateShader(gl::VERTEX_SHADER);
		csgo::glsl::compiler::compile(handle, vert, getVertShader());

		gl::EnableVertexAttribArray(0);
		std::vector<GLfloat> quad = getQuad();
		gl::GenBuffers(1, &positions);
		gl::BindBuffer(gl::ARRAY_BUFFER, positions);
		gl::BufferData(gl::ARRAY_BUFFER, (GLint)quad.size() * sizeof(GLfloat), quad.data(), gl::STATIC_DRAW);
		gl::VertexAttribPointer(0, 3, gl::FLOAT, gl::FALSE_, 0, nullptr);

		gl::EnableVertexAttribArray(1);
		std::vector<GLfloat> quad_uvs = getUVs();
		gl::GenBuffers(1, &uvs);
		gl::BindBuffer(gl::ARRAY_BUFFER, uvs);
		gl::BufferData(gl::ARRAY_BUFFER, (GLint)quad_uvs.size() * sizeof(GLfloat), quad_uvs.data(), gl::STATIC_DRAW);
		gl::VertexAttribPointer(1, 2, gl::FLOAT, gl::FALSE_, 0, nullptr);
	}
コード例 #13
0
ファイル: Window.cpp プロジェクト: Golden-Eagle/pristine
	GlaerContext * getCurrentGlaerContext() {
		GLFWwindow *handle = glfwGetCurrentContext();
		if (!handle) {
			throw window_error("no current context");
		}
		return &(getWindowData(handle)->context);
	}
コード例 #14
0
const GrGLInterface* GrGLCreateNativeInterface() {
    if (nullptr == glfwGetCurrentContext()) {
        return nullptr;
    }

    return GrGLAssembleInterface(nullptr, glfw_get);
}
コード例 #15
0
void AIController::Update(float a_fdeltaTime)
{
	reassignTimer -= a_fdeltaTime;

	if (glfwGetKey(glfwGetCurrentContext(), GLFW_KEY_SPACE))
	{
		if (canSpawn)
		{
			AddNPC();
			canSpawn = false;
		}
	}
	else
	{
		canSpawn = true;
	}

	//Reassign Jobs
	if (reassignTimer <= 0)
	{
		CalculateNPCJobs();
		reassignTimer = 5;
	}

	for (std::vector<UtilityNPC*>::const_iterator iter = m_pWorld->NPCVector.begin(); iter != m_pWorld->NPCVector.end(); iter++)
	{
		(*iter)->update(a_fdeltaTime);
	}
}
コード例 #16
0
void showColorDebugImage(std::string name, const char *data, size_t logicalWidth, size_t logicalHeight, size_t width, size_t height) {
    glfwInit();

    static GLFWwindow *debugWindow = nullptr;
    if (!debugWindow) {
        debugWindow = glfwCreateWindow(logicalWidth, logicalHeight, name.c_str(), nullptr, nullptr);
        if (!debugWindow) {
            glfwTerminate();
            fprintf(stderr, "Failed to initialize window\n");
            exit(1);
        }
    }

    GLFWwindow *currentWindow = glfwGetCurrentContext();

    glfwSetWindowSize(debugWindow, logicalWidth, logicalHeight);
    glfwMakeContextCurrent(debugWindow);

    int fbWidth, fbHeight;
    glfwGetFramebufferSize(debugWindow, &fbWidth, &fbHeight);
    float xScale = static_cast<float>(fbWidth) / static_cast<float>(width);
    float yScale = static_cast<float>(fbHeight) / static_cast<float>(height);

    MBGL_CHECK_ERROR(glClearColor(0.8, 0.8, 0.8, 1));
    MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT));
    MBGL_CHECK_ERROR(glEnable(GL_BLEND));
    MBGL_CHECK_ERROR(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));

    MBGL_CHECK_ERROR(glPixelZoom(xScale, -yScale));
    MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f));
    MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, data));
    glfwSwapBuffers(debugWindow);

    glfwMakeContextCurrent(currentWindow);
}
コード例 #17
0
ファイル: Screen.cpp プロジェクト: Deathlymad/GraphicsTest
Screen::~Screen()
{
	if (!_winPtr.empty())
		_winPtr.erase(_winPtr.begin() + getPtr(_winHandle, 0, _winPtr.size() - 1));
	if (glfwGetCurrentContext() == _winHandle)
		glfwDestroyWindow(_winHandle);
}
コード例 #18
0
ファイル: GameManager.cpp プロジェクト: rowtn/LearningOpenGL
void GameManager::destroyGameManager() {
    GameManager *gameManager = &getGameManager();
    delete gameManager;
    GLFWwindow *window = glfwGetCurrentContext();
    glfwDestroyWindow(window);
    glfwTerminate();
}
コード例 #19
0
ファイル: threads.c プロジェクト: eledot/Plum
int main(void)
{
    int i, result;
    Thread threads[] =
    {
        { NULL, "Red", 1.f, 0.f, 0.f, 0 },
        { NULL, "Green", 0.f, 1.f, 0.f, 0 },
        { NULL, "Blue", 0.f, 0.f, 1.f, 0 }
    };
    const int count = sizeof(threads) / sizeof(Thread);

    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW: %s\n",
                glfwErrorString(glfwGetError()));
        exit(EXIT_FAILURE);
    }

    for (i = 0;  i < count;  i++)
    {
        glfwWindowHint(GLFW_POSITION_X, 200 + 250 * i);
        glfwWindowHint(GLFW_POSITION_Y, 200);
        threads[i].window = glfwCreateWindow(200, 200,
                                             GLFW_WINDOWED,
                                             threads[i].title,
                                             NULL);
        if (!threads[i].window)
        {
            fprintf(stderr, "Failed to open GLFW window: %s\n",
                    glfwErrorString(glfwGetError()));
            exit(EXIT_FAILURE);
        }

        if (thrd_create(&threads[i].id, thread_main, threads + i) !=
            thrd_success)
        {
            fprintf(stderr, "Failed to create secondary thread\n");
            exit(EXIT_FAILURE);
        }
    }

    while (running)
    {
        assert(glfwGetCurrentContext() == NULL);

        glfwWaitEvents();

        for (i = 0;  i < count;  i++)
        {
            if (glfwGetWindowParam(threads[i].window, GLFW_CLOSE_REQUESTED))
                running = GL_FALSE;
        }
    }

    for (i = 0;  i < count;  i++)
        thrd_join(threads[i].id, &result);

    exit(EXIT_SUCCESS);
}
コード例 #20
0
void PlayerInputSystem::keyCallback(GLFWwindow *window,
                                    int key,
                                    int scancode,
                                    int action,
                                    int mods)
{
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
        
        if (GLFW_CURSOR_DISABLED == glfwGetInputMode(glfwGetCurrentContext(), GLFW_CURSOR)) {
        glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
    } else {
        glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
    }
        
    }
    
}
コード例 #21
0
ファイル: main.cpp プロジェクト: L1tta/Physics
void draw2DGizmo()
{
	// get window dimensions for 2D orthographic projection
	int width = 0, height = 0;
	glfwGetWindowSize(glfwGetCurrentContext(), &width, &height);
	float AR = width / (float)height;
	Gizmos::draw2D(glm::ortho<float>(-100, 100, -100 / AR, 100 / AR, -1.0f, 1.0f));
}
コード例 #22
0
ファイル: CX_EntryPoint.cpp プロジェクト: hardmanko/ofxCX
/*! This function opens a GLFW window that can be rendered to. If another window was already
open by the application at the time this is called, that window will be closed. This is useful
if you want to control some of the parameters of the window that cannot be changed after the window
has been opened.
\param config Configuration options for the window to be opened.
\return `true` if reopening the window was successful, `false` otherwise.
*/
bool reopenWindow(CX_WindowConfiguration config) {

	Private::setMsaaSampleCount(config.msaaSampleCount);

	if (config.desiredOpenGLVersion.major <= 0) {
		config.desiredOpenGLVersion = Private::getOpenGLVersion();
	}

	try {
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR == 9 && OF_VERSION_PATCH >= 0
		CX::Private::reopenWindow090(config);
#elif OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR == 8 && OF_VERSION_PATCH == 4
		CX::Private::reopenWindow084(config);
#elif OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR == 8 && OF_VERSION_PATCH == 0
		CX::Private::reopenWindow080(config);
#else
		CX::Instances::Log.error("CX_EntryPoint") << "reopenWindow(): The current version of openFrameworks is not supported by CX. "
			"Version 0.9.8 of openFrameworks is recommended.";
		return false;
#endif

	} catch (std::exception& e) {
		CX::Instances::Log.error("CX_EntryPoint") << "reopenWindow(): Exception caught while setting up window: " << e.what();
	} catch (...) {
		CX::Instances::Log.error("CX_EntryPoint") << "reopenWindow(): Unknown exception caught while setting up window.";
	}

	if (glfwGetCurrentContext() == nullptr) {
		CX::Instances::Log.error("CX_EntryPoint") << "reopenWindow(): There was an error setting up the window.";
		return false;
	}

	Private::glfwContext = glfwGetCurrentContext();
	Private::glfwContextManager.setup(glfwGetCurrentContext(), std::this_thread::get_id());

	//Setup the display for the new window
	CX::Instances::Disp.setup();

#if !(OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR == 9 && OF_VERSION_PATCH >= 0)
	ofGetCurrentRenderer()->update(); //Only needed for ofGLRenderer, not for ofGLProgrammableRenderer, but there is no harm in calling it
	CX::Private::appWindow->initializeWindow();
#endif
	ofSetWindowTitle(config.windowTitle);

	return true;
}
コード例 #23
0
JNIEXPORT jlong JNICALL Java_com_badlogic_jglfw_Glfw_glfwGetCurrentContext(JNIEnv* env, jclass clazz) {


//@line:910

		return (jlong)glfwGetCurrentContext();
	

}
コード例 #24
0
bool TBClipboard::GetText(TBStr &text)
{
	if (GLFWwindow *window = glfwGetCurrentContext())
	{
		if (const char *str = glfwGetClipboardString(window))
			return text.Set(str);
	}
	return false;
}
コード例 #25
0
bool TBClipboard::SetText(const char *text)
{
	if (GLFWwindow *window = glfwGetCurrentContext())
	{
		glfwSetClipboardString(window, text);
		return true;
	}
	return false;
}
コード例 #26
0
ファイル: ofApp.cpp プロジェクト: Geistyp/experiments
//--------------------------------------------------------------
void ofApp::setup(){

	window = glfwGetCurrentContext();

	image.loadImage("Penguins.jpg");

	win.setup("Test Multi Window", 1024, 768, window, std::bind(&ofApp::renderNextWindow, this));

}
コード例 #27
0
bool GameRenderer::Initialize(MaterialHandler* mtlHandlerPtr, MeshHandler* meshHandlerPtr, TextureHandler* texHandlerPtr, TransformHandler* transformHandlerPtr)
{
	materialHandler = mtlHandlerPtr;
	meshHandler = meshHandlerPtr;
	textureHandler = texHandlerPtr;
	transformHandler = transformHandlerPtr;

	glfwWindow = glfwGetCurrentContext();

	glfwGetFramebufferSize(glfwWindow, &screenWidth, &screenHeight);

	float ratio = (float)screenWidth / (float) screenHeight;
	glViewport(0, 0, screenWidth, screenHeight);
	glClearColor(0.4f, 0.4f, 0.5f, 1.0f);

	glm::vec3 camPos(0.0f, 25.0f, -70.0f);
	glm::vec3 treePos(0.0f, 0.0f, 0.0f);
	glm::vec3 scalingVector(1.5f);
	glm::vec3 targetOffset = glm::vec3(0.0f, 6.0f, 0.0f) * scalingVector;

	scaleMatrix = glm::scale(glm::mat4(), scalingVector);

	wvpMatrixStruct.projMatrix = glm::perspective(45.0f, ratio, 0.25f, 300.0f);
	wvpMatrixStruct.viewMatrix = glm::lookAt(	
		camPos,
		treePos+targetOffset,
		glm::vec3(0.0f, 1.0f, 0.0f)
		);


	glGenBuffers(1, &matrixUBO);
	glBindBuffer(GL_UNIFORM_BUFFER, matrixUBO);
	glBufferData(GL_UNIFORM_BUFFER, sizeof(Matrices), (void *)(&wvpMatrixStruct), GL_DYNAMIC_DRAW);
	glBindBuffer(GL_UNIFORM_BUFFER, 0);

	SetupRenderPasses();

	//Loading and compiling all shaders etc
	if(!shaderManager.Initialize())
	{
		return false;
	}

	Shader* genericShader = nullptr;
	if(!shaderManager.GetShader("objshader", &genericShader))
	{
		LOG(ERROR) << "Couldn't fetch objshader from shadermanager. Aborting.";
		return false;
	}
	else
	{
		objShader = static_cast<OBJShader*>(genericShader);
		objShader->SetupBuffers(matrixUBO, 0);
	}

	return true;
}
コード例 #28
0
ファイル: Controller.cpp プロジェクト: barryHub20/SP3
bool Controller::getKeyboardUpdate()
{
	/** Set all keys to false **/
	for(unsigned i = 0; i < TOTAL_KEY; ++i)
		myKeys[i] = false;

	/**** See which keys are pressed ****/
	/** Keyboard **/
	for(int i = 0; i <= KEY_6; ++i) //all 256 chars
	{
		if(IsKeyPressed(inputChar[i]))
			myKeys[i] = true;
	}

	/** non-keyboard(mouse) **/
	mouseLeftButton = glfwGetMouseButton(glfwGetCurrentContext(), GLFW_MOUSE_BUTTON_LEFT);
	mouseRightButton = glfwGetMouseButton(glfwGetCurrentContext(), GLFW_MOUSE_BUTTON_RIGHT);

	if(mouseLeftButton == GLFW_PRESS)
		myKeys[KEY_LMOUSE] = true;
	if(mouseRightButton == GLFW_PRESS)
		myKeys[KEY_RMOUSE] = true;

	/** Scrolling **/
	GLFWwindow* glfwGetCurrentContext(void);
	glfwSetScrollCallback(glfwGetCurrentContext(), scroll);

	if(scrollyPos > 0.0)
	{
		myKeys[SCROLL_TOP] = true;
	}
	else if(scrollyPos < 0.0)
	{
		myKeys[SCROLL_BOTTOM] = true;
	}

	if(scrollyPos != 0.0)
	{
		scrollyPos = 0.0;
	}

	/* mouse */
	return true;
}
コード例 #29
0
bool AlloyContext::begin(bool onScreen) {
	windowHistory.push_back(glfwGetCurrentContext());
	if (onScreen) {
		glfwMakeContextCurrent(window);
	} else {
		glfwMakeContextCurrent(offscreenWindow);
	}
	return (windowHistory.size() == 1);

}
コード例 #30
0
bool TBClipboard::HasText()
{
	if (GLFWwindow *window = glfwGetCurrentContext())
	{
		const char *str = glfwGetClipboardString(window);
		if (str && *str)
			return true;
	}
	return false;
}