Hot answers tagged

11

You're taking the wrong approach with a static UI class. The usual way to "bounce" from a static callback to an instance function is to store something capable of making the jump in a place that is accessible from the static callback. Most APIs, like GLFW and native Win32, that require these sorts of static callbacks provide a way to make the association ...


8

I'm not sure about common practices, but lacking a glfwToggleFullscreen, this seems one way to toggle fullscreen mode: // On input handling, check if F11 is down. if ( glfwGetKey( GLFW_KEY_F11 ) ) { // Toggle fullscreen flag. fullscreen = !fullscreen; // Close the current window. glfwCloseWindow(); // Renew calls to glfwOpenWindowHint....


6

If I have understood your question right, I believe you are asking if the tools you mentioned let you commercialize the games that you create using them. In that case, the answer is yes. Their licenses and terms and conditions are very generous. Here's what they give you: When it comes to OpenGL (licenced under MIT License) From Wikipedia Copyright (c)...


5

There was a SIGGRAPH 2011 course on antialiasing in games, which will probably give you far more information about many more types of AA than you really want. :) When you run a typical PC game and in the options it gives you a choice of "2X, 4X, or 8X" antialiasing, it's referring to multisample antialiasing, MSAA. This stores super-resolution frame ...


5

You never call glEnable(GL_TEXTURE_2D); to switch on texturing. And since you seem to use the fixed function pipeline that means that only the currently set color (which is white by default is used) to draw. As for why the texture dimensions are not printed correctly: the format specifier %f expects a 64 bit double value on the stack (floats are ...


5

You can see from the source code that glfwCreateWindow returns a null pointer in only a few circumstances (as of this writing). GLFW is not initialized at all (_GLFW_REQUIRE_INIT_OR_RETURN(NULL); on line 137). The width or height you specify for the window is zero or negative. The context configuration (controlled by you via the window hints, checked via ...


5

I had a similar problem to this. It's annoying that there's so little documentation on using glfwSetWindowUserPointer and glfGetWindowUserPointer. Here's my solution to your problem: WindowManager::WindowManager() { // set the window pointer to the keyboard object glfwSetUserPointer(window_, keyboard_); glfwSetKeyCallback(window_, key_callback_);...


5

The callbacks must be free functions or static functions, as you've found out. The callbacks take a GLFWwindow* as their first argument in place of an automatic this pointer. With GLFW you can use glwSetWindowUserPointer and glfwGetWindowUserPointer to store and retrieve a reference to WindowManager or a per-window Window instance. Remember that GLFW ...


4

You define your vertex data as GLuints: static const GLuint g_vertex_buffer_data[] = However you bind this data as GL_FLOATs: glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); -1.0f when cast to GLuint and then interpreted as a float represents NaN (not a number) and lead to unspecified results, as the OpenGL 3.3 Core Profile specification ...


4

Well, the amount of time that passes between frames is highly dependent on the hardware rendering your scene. If the machine just isn't strong enough, there's no way to enforce a fixed frame-rate. However, GLFW DOES allow for very precise time MEASUREMENT (and glut does not), and therefore you can use it to make sure your frame rate is not too FAST. Too slow ...


4

glfwinit() isn't actually creating a valid context. glfwopenwindow should do that, but I suspect you're passing invalid parameters. You should check the return of glfwopenwindow (and glfwinit()) to ensure that it's successfully creating a context. This thread also mentions creating a context manually, supposedly without window creation.


4

In 3.x, you specify which monitor you want to use for fullscreen instead of the flag in 2.x. You can use glfwGetPrimaryMonitor() to get a monitor handle and pass it into glfwCreateWindow() as follows: glfwCreateWindow(width, height, m_windowName.c_str(), glfwGetPrimaryMonitor(), nullptr); As long as monitor param is not null, it will create full screen ...


3

This is the NVidia manual to their Optimus, the driver which is responsible of switching between integrated GPU and NVidia GPU. From a quick look, it seems they describe how to set the default GPU for a program. I haven't tried it yet though.


3

Unfortunately, desktop hardware is not designed for "real time" applications, where "real time" is defined as "thing X has to happen exactly at N". As computers get faster, we're edging closer to that goal, but at the same time the devices try to do more and more things at the same time. In other words - while your graphics hardware may be capable of ...


3

These flags allow you to specify the formatting of your color target, and depth stencil buffers that are a part of the final frame buffer. The color target is typically formatted in a R8G8B8A8 format, providing 8 bits of precision for each color, and the alpha channel. This gives a total of 32 bits. The final two flags specify formatting for the depth ...


3

Render to a small render target texture (FBO) first and then render an orthographic quad to the screen using the render target as a texture (with nearest neighbour sampling). There are plenty of tutorials for this such as this one.


2

Thanks to @DaleyPaley I was able to figure this out. The problem lay in my code to figure out the camera vectors Right, Up, and Back. I was just using some code that I found online, and once I started showing the actual camera placement and vectors from the perspective of a hardcoded camera, I could tell that the vectors being produced by Right, Up, and Back ...


2

Here is a link on how mix openGL code with the SFML, are you sure that the GLFW feature that you are looking for, aren't on the sfml already, because in my experience there is no reasone for mix up this two library.


2

After your glClear call you can render a full-screen quad with your texture (loaded like you would any other). You may want to disable writing to the depth buffer to avoid odd rendering issues.


2

This is usually solved by changing glfwSetInputMode with GLFW_CURSOR from GLFW_CURSOR_HIDDEN to GLFW_CURSOR_DISABLED. The behavior differences are due to the differences in OS APIs that GLFW uses and how they interact with the windowing system. In the documentation, it says that DISABLED should be used for 3D camera controls, and HIDDEN should be used when ...


2

CLARIFICATION glViewport will set the size of your viewport you are rendering to. This answer assumes that you were doing something along the lines of this: glViewport(0, 0, 1920, 1080); Which would give you a 16:9 aspect ratio. Setting it to something like: glViewport(0, 0, 800, 600); Would give you the correct aspect ratio (and hopefully answers ...


2

It seems that your mask texture is alpha 1.0 everywhere. In order for this to work, your mask should have alpha set 1.0 for "HOLA" and alpha set to zero everywhere else. Hope it helps!


2

This is at the top of my main.cpp file, so grid is global, purely so it can be used in the input handler. In general, the solution here is "don't make it global," and to pass instances needed to functions that need them. In this simple program you probably don't need to worry about it too much. Think of more as something you should think about for the ...


2

Thats because glBegin, glVertex2f and glColor3f are legacy functions which are deprecated. You may still use them if you request a backwards-compatible context, however I'd recommend you stick to your core-context (which is not backwards compatible) and learn the more powerful modern OpenGL. There is a pretty good modern OpenGL tutorial series on opengl-...


1

To the best of my knowledge, still there isn't a function to toggle between windowed and fullscreen modes. Here is the listing of all functions provided by the library at the current version. Such feature might be added in the future though, if enough requests for it pop up. However, the window and the OpenGL context are two tightly coupled things, so ...


1

To my knowledge of GLFW documentation and internals, events should only be dispatched in response to calls to PollEvents/WaitEvents. GLFW2 used to PollEvents in SwapBuffers, but that is gone in GLFW3. In any way, there's two possible solutions to your problem: Register your callbacks in the main loop, predicated on a boolean to ensure you do it once. ...


1

You need to set up the viewport again, by calling glViewport. Also, I believe a context is bound to the window and not to the thread, but I could be wrong. If this is the case, then you'll have to set up all your resources, buffers, etc..


1

Going into the NVidia control panel by whatever method (From the"Change Default Graphics Processor" link on the "Run With Graphics Processor" menu is how I got there). This will give you the option to change the graphics processor per application: Or globally: For your particular case, I'd try adding a program setting for cmake, and, failing that, change ...


1

I found the main problem. My Camera rotation didnt got an yAxis clamp, so when I build my project and click on it, the mouse position was different and sometimes made the yAxis be 180 or -180, which caused the issue. A simple clamp solved it: yAxis = glm::clamp(yAxis, -90.0f, 90.0f); Thanks for those who help me out!



Only top voted, non community-wiki answers of a minimum length are eligible