Tag Info

Hot answers tagged

28

My name is Kevin, and I'm a programmer/designer at Klei. I wrote a bunch of the animation stuff that we used in the Shank series, Mark of the Ninja, and Don't Starve. Our animators work in Flash. We have a concept of a character 'build' which is a set of body-part symbols with multiple views. Depending upon the fidelity of the given game, there are more or ...


12

Is GLUT 3.7 out of date? Absolutely. You should never use it for anything. However, FreeGLUT is perfectly fine to use. It is 100% backwards compatible with GLUT 3.7. FreeGLUT is a good utility to have when you need to slap together a quick and dirty program.


11

The "delta time" used to be the time elapsed between two frame updates (but it can also be used in other contexts; this is usually the result of a time subtraction). You can get the delta time in glut using the glutGet method and the GLUT_ELAPSED_TIME parameter, plus some operations. The following line returns the number of milliseconds since glutInit was ...


7

First off, you shouldn't be using GLUT for anything but testing. As far as I know, GLUT was never meant for application development. I recommend picking up SDL or SFML instead. That said, implementing framerate-independent rendering is relatively simple. // global gLastTick contains the last processed tick (ms) // game loop int tick = ...


6

To the best of my knowledge this is Windows-API specific - this functionality doesn't even exist on all platforms. If you want to dig through my code you can find a working Windows implementation (LockMouseCursor is the entry point into the OS module, ClipCursor is the actual Windows function that does the trapping, but there's some niceties surrounding that ...


6

GLTools and GLUT are not the same thing. GLUT is responsible for dealing with things outside of OpenGL. GLUT creates and manages a window and an OpenGL context; the actual stuff that goes on within that context (aka: OpenGL) is not GLUT's responsibility. Maik already covered the reasons why you don't see GLUT in serious applications. GLTools is another ...


6

Klei typically uses a really nice combination of Skeletal animations and sprite-changes. They rig a skeleton, apply sprites to the bones and then they'll swap sprites as an animation frame calls for it. The exact "how" (workflow/tools/etc) can really only come from them, however, they said so themselves when advertising "Shank", pre-release. And if you ...


5

gluLookAt will rotate and translate the world in a way, that the camera will be located at {0, 0, 0} and looks towards the negative z-axis. This is the camera setup used in OpenGL. The camera actually never moves, the world does. Sound confusing? Hell yeah, let me try to explain :) Lets take this example: eye : {300, 0, 0} lookat : { 0, 0, 0} up ...


4

Even though the original GLUT is not in active development anymore, its still a good tool for its targeted domain, which is quick OpenGL testing and demos. It was never intended to be a framework for developing complex OpenGL programs. from http://en.wikipedia.org/wiki/OpenGL_Utility_Toolkit The two aims of GLUT are to allow the creation of rather ...


4

You can convert between 3D and 2D coordinates in a variety of ways, some of which have more meaning than others. For example you could just drop the Z coordinate, yielding an (x,y) pair, but that probably doesn't do what you want semantically. But you're specifically asking how to convert between model, world or view space 3D and screen space 2D as used by ...


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

First some little tips: 1) Instead of: if (i > 360) i=0; Try i %= 360; 2) glPushMatrix and glPopMatrix are useless in your code, as you apply them on the identity matrix. 3) User GL_TRIANGLES or GL_QUADS instead of GL_POLYGON 4) Avoid global variables, they cause a lot of problems. Solution: Probably a typo: Change glTranslatef(distance_x, ...


3

glGenerateMipmap is an extension, unless you are using OpenGL 3 or above (I think). You probably want to use a library like GLEW to load it. See OpenGL Extensions for more information about extensions in OpenGL. Many things that were extensions in 2.x were promoted to the core API in versions 3 and 4, but unless you upgrade to those versions, you'll have to ...


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

If you want to use a perspective matrix for rendering, but an orthographic projection for retrieving mouse input, why not set up both? // this example uses the free and open source OpenGL Mathematics library // you can get it here: http://glm.g-truc.net/ glm::mat4x4 perspective = glm::perspective(90.f, 640.f / 480.f, 0.1f, 1000.f); ...


3

The argument against glut in big projects is that you don't have access to the application loop, so you can't change it to fit your needs. All it has are some callbacks which are triggered from glut, but you don't have much control about it. However, the purpose of glut is to create demos and test apps easily and cross platform, without the need to deal ...


3

You can do it by inserting another "push, transform, draw, pop" sequence before your pop. Something like this: // your current code glPushMatrix(); glRotatef(...); glTranslatef(...); glRotatef(...); DrawTriangle(); // new code glPushMatrix(); glRotatef(...); glTranslatef(...); glRotatef(...); DrawCircle(); glPopMatrix(); ...


3

glIsEnabled if (glIsEnabled (GL_CULL_FACE)) { // culling is enabled } Alternatively you can track state yourself in your own variable, using something like this: glEnable (GL_CULL_FACE); glState.CullEnabled = TRUE;


2

Does the problem occur whenever you change the direction or only when changing from positive values to negative values? If it is always, it is most likely the last acceleration stored from last movement which is still slightly bigger than zero. How do you determine that the movement is over in IsCameraMoving() ? Can you show the entire calculation of ...


2

With a quick search through the GLUT spec, GLUT does not seem to have mouse capture capabilities. The best you can do (like you seem to be doing) is to warp the cursor to the center and hope the user isn't fast enough (or isn't using a tablet) =) Or, you could switch to SDL or SFML, as GLUT is only designed for testing, not "real" software.


2

Yes GLUT is obsolete and not under developement since 1998 with the release of the 3.7 version. From French Wikipedia: La bibliothèque GLUT n'est désormais plus en développement et s'est arrêtée à la version 3.7 en mai 1998. http://fr.wikipedia.org/wiki/OpenGL_utility_toolkit Edit: Sorry for the french reference but i haven't find any date on the ...


2

You have to register the function that handles the callback function to be executed when a button is mouse pressed during your display() loop. This has to be done before running the main loop, when you are initialising everything that GLUT requires. glutMouseFunc (MouseButton); Then you need to define the callback function itself, for example, something ...


2

glutInitContextFlags(GLUT_FORWARD_COMPATIBLE | GLUT_DEBUG); Never, ever, ever, EVER use FORWARD_COMPATIBLE for ANYTHING. If you want a core OpenGL context in FreeGLUT, ask for it with the right function: glutInitContextProfile(GLUT_CORE_PROFILE); You never need the FORWARD_COMPATIBLE bit set. I know that a lot of code does it, and if I could, I would ...


2

Just at a quick glance I would check in your code where you are drawing the particle system in comparison to when you actually do the world rotations and translations. Drawing the particle system before you do the any changes could cause it to remain in the same position. Just trying to help in any way. Good Luck!


2

I'm unclear as to when exactly you think "immediately" is in this context, or what you're actually trying to do by "watching the keyboard during rendering." But given that you must have known what function is actually being assigned to the keyboard callback (since you had to pass to the glutKeyboardWhatever function), couldn't you just directly invoke the ...


2

The problem is that the framerate is too low given the simplicity of the rendering job. Simplicity? You're doing deferred rendering. That's not simple. You're obviously fillrate-limited (as part of the point of deferred rendering is to be fillrate-limited). And your GeForce GT 120M only has 32 shaders. Which is good for a mobile chip, but pretty poor ...


2

They are properties of both lights and materials. Typically, materials have a diffuse color and a specular color. Lights just have a light color. When shading a surface, you would multiply the light color componentwise with the material's diffuse and specular colors to arrive at the Kd and Ks values for that equation. Thus you could have various colors ...


2

Try Freetype OpenGL, a library for displaying a unicode text using a (single) vertex buffer and freetype fonts. Have a look at their web, repository and documentation. An example, from their website: /* Text to be printed */ wchar_t *text = L"A Quick Brown Fox Jumps Over The Lazy Dog 0123456789"; /* Texture atlas to store individual glyphs */ ...


1

Every rotation in gl is according to a given vector. Dependending from where you are looking at the triangle, you will have to rotate according to that vector. For instance, if you are looking from z>0, you have to rotate your triangle with inZ = 1 such that the triangle rotates according to the vector (0,0,1). UPDATE: Generally speaking, this code ...


1

Try disabling the glewExperimental support, as that may be attempting to call something in OpenGL that isn't supported by your particular driver. That actual error is GL_INVALID_ENUM​ which, unfortunately, can be raised from pretty much anywhere. Also, what OpenGL driver are you using and in what environment? Some drivers may allow you to enable a debug ...



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