Hot answers tagged

8 votes

Random black pixels GLSL shader bug

Unexpectedly black pixels sometimes indicate that you've got an infinity or NaN in the shader somewhere. For example normalize(vec3(0,0,0)) will generate a NaN. To me, the most obvious candidate in ...
user avatar
  • 6,566
7 votes
Accepted

Difference Between LibGDX and LWGJL

LibGDX is based on LWGL and its advantage are that a lot of the base stuff is already written and you don't need to write it. Some people prefer to write it themselves though. LibGDX is generally used ...
user avatar
  • 330
7 votes
Accepted

Can I make color data not render as gradient?

You can try doing this with flat attribute qualifier in shaders, like so: flat vec3 surfColor; It tells GLSL to pass values ...
user avatar
  • 10k
6 votes
Accepted

Shadow map: depth texture always returns 0

You are using sampler2D with a texture that has GL_TEXTURE_COMPARE_MODE != GL_NONE. That is ...
user avatar
6 votes
Accepted

Using gluUnProject to transform mouse position to world coordinates (LWJGL)?

gluUnProject(float winx, float winy, float winz, FloatBuffer modelMatrix, FloatBuffer projMatrix, IntBuffer viewport, FloatBuffer obj_pos) ...
user avatar
6 votes
Accepted

render/draw or input first?

When writing your main loop and updating logic, you've got two basic strategies, which you're probably aware of: fixed time steps and dynamic time steps. Either way your updates will happen at some ...
user avatar
  • 8,272
5 votes

Menus for LWJGL - Swing or other?

This might be too late for you, but for the benefit of web searchers, I'll answer: Create an empty canvas (AWT). Set the size of the canvas to be equal to the LWJGL ...
user avatar
5 votes
Accepted

How do I ensure my skybox is always in the background, with OpenGL?

glDepthRange (1, 1); Job's a good 'un, done. How this works: glDepthRange() remaps depth values for the purpose of ...
user avatar
5 votes

Resizing a Framebuffer Object (ie: its attachments) on Screen Resize

To be safe I'd delete and recreate the entire FBO. Some drivers have strange stability issues when recycling/resizing FBOs. I've had entire screen flickers and occasional crashes. Switching attached ...
user avatar
5 votes

Algorithm for triangle picking?

What I do is a test known as Ray-Picking. It is a test to see if a "ray" intersects a triangle. In order to use it, you need to learn how to convert your mouse coordinate into world coordinates (where ...
user avatar
  • 993
5 votes

How can I optimize block rendering in an OpenGL game?

You can check every block if it is exposed to air (=no other block) on any side or completely enclosed. Those which are completely enclosed shouldn't be rendered as they are not visible anyways. This ...
user avatar
  • 467
4 votes

Are display lists faster than VBOs?

If you don't do any optimization you are rendering up to ~half a billion vertices, you can: Remove faces/vertices where blocks touch, and don't issue draw calls for chunks that lay outside of the FOV....
user avatar
  • 41
4 votes

Are VBOs only for OpenGL 3.x?

There is a lot of misinformation floating around here. Buffer Objects were introduced into core in OpenGL 1.5. They existed in extension form as far back as OpenGL 1.4. Vertex Buffer Objects are ...
user avatar
4 votes
Accepted

What is the difference between .obj files and Collada files?

Your basic OBJ, or Object Wavefront file only contains geometry data - vertices, normals, texture co-ords, and optionally material data in an second file. It does not contain any sort of skeletal ...
user avatar
  • 1,388
4 votes
Accepted

How can I blend up to 3 textures on a polygon without blend maps?

In very broad strokes, you can accomplish this by: Yes, using shaders Binding three textures to the shader program before drawing On your polygons, have the usual UV vec2 for each vertex. This is ...
user avatar
4 votes
Accepted

OpenGL How to render a voxel based world scene with many objects

The way you are rendering voxels is extremely ineffective. For each cube you have to do calculations, set uniforms, and worst of all bind textures(This is usually a very expensive operation) ...
user avatar
  • 1,651
4 votes

Difference Between LibGDX and LWGJL

LWJGL is Lightweight Java Game Library. It is not engine. LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL), audio (...
user avatar
4 votes
Accepted

Wind-blown fire particle effect from scratch

An effect like the one you show is actually pretty simple to code. Create a class Ember that sits at one (x,y) position and ...
user avatar
  • 29.1k
4 votes
Accepted

Only Square Textures loading correctly (Beginner question)

It looks like your pixel lookup is backwards: int pixel = rawPixels[x*width+y]; Should be int pixel = rawPixels[x+width*y];
user avatar
  • 4,226
3 votes

Are VBOs only for OpenGL 3.x?

VBOs have been available since OpenGL 1.4 as an extension and were added to the core in OpenGL 1.5. You can use either version depending on your needs, if you strictly want to use OpenGL 3.1 with the ...
user avatar
  • 12.5k
3 votes

(LWJGL) Pixel Unpack Buffer Object is Disabled? (glTextImage2D)

The last input in the function is the problem. If you look at the lwjgl source code you can see that it uses it as an offset (used with PBOs). To actually pass no data use a 'null' instead.
user avatar
  • 31
3 votes
Accepted

VBO -> How should it be done?

TLDR: VBOs makes a huge difference in performance. One simple reason to use them would be that OpenGL ES (mobile devices) don't support glBegin(...)/...
user avatar
3 votes
Accepted

How does rendering with Swing compare to rendering with openGL?

OpenGL performance will outperform Swing quite heavily once you start doing something a little more advanced. I dont have hard numbers to back my claim, but I have experience. I too started out with ...
user avatar
  • 231
3 votes

OpenGL/GLSL/LWJGL return value from shader

You can use a Transform Feedback Buffer to output from your vertex shader, your question is not very specific though so I can't be sure if this is truly what you want to do.
user avatar
3 votes
Accepted

FBO and VBO for performance

You should have only 1 VBO that contains all of your squares and render it in one single draw call. Use a texture atlas to combine all your snowflake textures. Also, look into using a geometry ...
user avatar
3 votes

render/draw or input first?

The typical implementation is Update first, then Render. I guess this is because it reduces input latency. In Update-First you see changes on the current frame (U - update, R - render, F - frame, [...
user avatar
  • 2,711

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