New answers tagged opengl
0
There seems to be a whole lot of misunderstanding here, starting from the writers of OpenGL docs...
Let me quickly restore your sanity: the world doesn't move, it stays put. Whoever tries to implement the world as moving around the player will quickly run into trouble in the multiplayer mode. Not to mention that updating the positions of millions (or ...
-1
This question is really complex, since it depends from game to game, and what you are going to render. But you know you have chosen a bad design when you constantly needs to update it for your doings.
There are so many different designs out there that you simply have to do some test with what is the best or what you feel is most efficient.
1
A common thing people do is they make a drawing method for this. It's generally considered better the draw the object inside the class and directly use the API. It's also good if you can make a class to inherit which has the draw method inside, and allows polymorphism.
Generally the APIs have reasons why they are the way they are. It's best just use them as ...
1
Unless you are pre-transforming all of your vertex data, vertices should come into the vertex shader in object/model space. This is typically where the vertices are converted into screen space by transforming the vertex by the world, view, and projection matrices. If you want to perform operations on the vertices in world space, then either pass through the ...
2
This is solved in diffrent ways, some solve it by using #ifdefs, some solve it by branching And some solve it by having input values that updates per every object so you store an overall painting scheeme for the defualt shader.
and when it comes to scale of the game, it´s actualy no way around this. You will need more shaders for diffrent materials and ...
2
The problem is actually much simpler than you make it sound. Suppose wx, wy are your "world" coordinates -- that is, the native coordinates of your tiles. In order to transform that into the screen coordinates sx, sy, you apply some matrix transform. This can be written as: (sx, sy) = (dx, dy) + M * (wx, wy). You already have that equation somewhere in your ...
0
Although it doesn't seem like it, frustum culling is the answer here.
What you want to do is get a frustum from your view. This is determined by the screen width and height, the field of view angle and the near and far plane. Convert your view frustum to world space or your tiles to view space, depending on which is faster.
For every tile, determine if ...
0
When rendering with an ortographic projection, you need to set your model view matrix to identity.
To learn more about projection matrices, I'd suggest reading this article: http://www.songho.ca/opengl/gl_projectionmatrix.html
1
In my first attempt, I created a new projection matrix for the smaller window, and then tried to rotate the frustum using LookAt, this almost worked but had some distortion when tilting up or down.
However, using a different approach it turns out the problem was quite easy to solve in DirectX. The BoundingFrustum class that I used (while It can be ...
2
I figured out what I had to do. I had to get the Assimp SDK, replaced the include files with the ones supplied by the SDK, and things started to work perfectly. Thanks for your help!
2
How do I use the engine's vertex shader while still allowing the programmer to provide his/her own vertex shader for other calculations in their game? What is the normal approach here?
There is no normal approach because engines generally don't let you do that.
Generally speaking, engines take one of two approaches: either the user provides none of a ...
2
Higher-end engines typically use a higher-level abstraction than an individual shader.
Simpler games just allow each model/material to specify shaders and then to use HLSL includes or the like to allow all common code to be easily reused. You'll need a bit of discipline in applying the shader includes properly and it can be a bit repetitive sometimes, but ...
1
I'm not familiar with DirectX, but the BoundingFrustum docs you link to say that it can be constructed from a projection matrix.
All you need to do, then, is multiply your actual projection matrix by a matrix which (if you used it to draw with) would scale/translate the graphics so that the rectangle you want fills the viewport, then use that matrix product ...
3
For smooth shading, two adjacent triangles must share common vertex normals. The reason is interpolation. The normal from one vertex is smoothly interpolated to the normal on the second vertex. You need to ensure that the normal of triangle at a particular vertex matches the normal of all adjacent triangles at that same vertex. If you think of a smooth ...
0
The image of a point A under a rotation around another point B (an affine rotation if B is not the origin of the space) is A', with
A' = B + R*(A-B)
where R is the matrix of the associated linear rotation.
For example, in dimension 2, say you want to rotate A = (1,0) around B = (1,1) by 90 degrees counter-clockwise. That will yield (2,1). Make a picture ...
1
You can access the memory of any glm type by using glm::value_ptr.
Matrix types store their values in column-major order, and as floats.
1
The problem with the obj format is that it isn't standardised. So you'll see some that use clockwise winding (not good for a naive implementation in OpenGL) some that use counter-clockwise winding (not good for a naive implementation in DirectX) plus all other kinds of quirks that are vendor-dependent (eg. triangles vs quads as primitives).
The most usual ...
1
There is a good documentation on Wikipedia. The format is made by Wavefront, you'll find lot more information online with this name. This is the Wikipedia article.
Basically, v means vertex position, vt means texture coordinate and vn means vertex normal. f defines indices of a face.
It isn't that easy to draw *.obj models in a modern way, since their ...
-1
Set the glut32.lib and kernel32.lib paths at Project Properties->configuration Properties->Linker->General->Additional Library Directories.
If you don't have these lib files in local system/machine, you can download it from web.
0
For refraction, you need to render the background to an offscreen buffer. Then draw it on screen. Finally you draw the water on top and pass the background texture into the water shader.
In GLSL you can use gl_FragCoord to get the onscreen coordinate of the pixel. You will have to divide by the background texture size to get the uv for the texture lookup.
...
0
Any idea or help about this shader effect ? I found a couple of idea but I don'r know if they are great : GPUGems - Refraction
0
The event VIDEORESIZE is triggered from windowing system, not from pygame.
In response to event, program should update display with calling pygame.display.set_mode(newsize, sameoptions)
2
First of all, you probably meant to subdivide into rectangles, not squares. The problem is generally not solvable with squares.
Now, if you want to split your region into rectangles given an arbitrary number of rectangular holes, then I have a strong feeling it's an NP-hard problem. Which means you probably don't want to solve the problem in the best ...
1
Sometimes using a 0 or very low value for the zNear will result in a bad depth calculation.
Try using the following instead:
gluPerspective(30f, 1024f / 768f, 1.0f, 100);
6
You can easily use the Z-Buffer to render only the pixels that matter during skybox/light passes.
I render the skybox last (after all lights). When rendering the skybox, make sure your depth buffer is still intact and use GL_GEQUAL for the depth function. Then in the vertext shader of the skybox, set the z value of gl_Position to its w value. This makes ...
1
You might want to use double buffering for the FBO and a Pixel Buffer Object to read the depth from the previous frames depth map to get rid of any CPU stall, as in your case it shouldn´t be a problem if it is a frame behind.
I currently have the same problem and I can´t use double buffering as it would mess everything up a lot, but from profiling and ...
0
OpenGL can do more things that I care to shake a stick at in a comment. Among the thing it can do in relation to images is transform a given image (using shaders), clip an image and zoom an image(texture mapping).
So if what you want to do is create some kind of wavy mist, yes you can do this without drawing a million pictures of mist and loading them: You ...
1
In general, yes, there will often be a performance benefit to using "thinner" (fewer bytes per pixel) FBO formats. It depends on the details of your hardware and how you're using the buffers, but it's quite common for performance to be memory-bandwidth-limited for at least part of the graphics frame (postprocessing, for instance). In that case, a thinner ...
1
The answer you are referring to seems to be this one:
glbuffer.bind();
unsigned char *dest = (unsigned char*)glbuffer.map(QGLBuffer::ReadWrite);
// creates an openCV image but the pixel data is stored in an opengl buffer
cv::Mat opencvImage(rows,cols,CV_TYPE,dest);
.... do stuff ....
glbuffer.unmap(); // pointer is no longer valid - so neither is openCV ...
5
You can't do it with just that information. You need more.
For example, I assume you also actually have a the world, view, and projection transformation matrices available to you. In that case, you can compute the vertex's position in view space by multiplying it by the world matrix and then by the view matrix.
Since you're in view space, the eye is at (0, ...
0
You might want to take a look at the Lightweight Java Game Library, despite your asserted gripe with "the existing ones"
To quote the authors themselves:
LWJGL is primarily an enabling technology which allows developers to get
at resources that are simply otherwise unavailable or poorly
implemented on the existing Java platform
As for your ...
0
Have you tried like ANY opengl tutorial? Most of them are using WinAPI to create the window and pretty much describe everything you need. Probably the most famous one being that by NeHe: http://nehe.gamedev.net/tutorial/lessons_01__05/22004/ but there are many more on the net.
0
You are currently putting the position data into one VBO (vertexBuffer[0]) and the color data into another one (vertexBuffer[1]). But when drawing you bind both buffers one after the other, so the second binding will just override the previous one. Then you set the pointers as if both attributes were in the same buffer. This is slightly messed up. The ...
0
Turns out that it was none of the above. Typically, it was a typo somewhere so difficult to get wrong I never bothered to check it. When defining my attribute IDs, I had typed
GLuint vPosition = 0;
GLuint vColour = 0;
instead of
GLuint vPosition = 0;
GLuint vColour = 1;
Whoops.
0
I had some similar problems. Maybe the camera is in model space instead of worldspace? That was causing the problem in may project...
Does something like that helps?
// Calculate the position of the vertex in the world.
worldPosition = mul(input.position, worldMatrix);
// Determine the viewing direction based on the position of the camera and the ...
1
Model, View and Projection matrices are passed as uniforms to the vertex shader, which uses them to transform vertex coordinates and normals. Typically projection matrix is constant between frames, view matrix is calculated once per frame and model matrix is unique for each object. Model matrix is in world space. This is of course not the only way to do ...
3
Perhaps I´m over thinking it.
Yes, you are. Transformation being done in shaders is meant to be literal. "Transformation" in this case being the application of some transform to the various per-vertex attributes. Where that particular transformation comes from is generally irrelevant to the shader. It is given a transformation, and it applies it to the ...
4
Yes, you do need texture units when not using shaders; if you look at the evolution of graphics hardware this will be obvious as multitexturing predated the programmable pipeline.
The classic old-school use case is Quake-style lightmapping, and in fact if you look at the Quake source code you'll see that it used multitexturing (via the old ...
6
http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/ gives a nice overview over the basics. http://en.wikipedia.org/wiki/Shadow_mapping links to a multitude of research papers describing different improvements and optimisations.
Shadow volumes have been 'the thing' a few years ago. http://en.wikipedia.org/wiki/Shadow_volume ...
13
Sounds like the scaling algorithm you're using isn't interpolating pixels.
Pictures are best explained with pictures:
It's the Major, first in full, then scaled down with Lanczos (left) and nearest-pixel (a.k.a. no interpolation) (right) to two sizes.
The same comparison, in 3x magnified:
Make sure the scaling you're using is resampling sensibly. For ...
2
I'm adding this by way of expansion on a comment I made to a previous answer. This question in itself shows a fundamental misunderstanding of what OpenGL is so I believe it's necessary to say more.
OpenGL is not software
OpenGL is "a software interface to graphics hardware" (page 1 of the OpenGL specification until the ARB changed the terminology a little ...
0
glGetError is slow on Android and should be avoided. Something you can do is create a LoggerInterface, which is called for each method call. Put a dummy implementation that does nothing in you release code, and a real one in your lab (which calls glGetError). In release code, check glGetError once per frame, and activate the real LoggerInterface for the next ...
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 ...
0
The solution was to create a character or actor class representing a rigid body in the physics simulation. An instance of that class can be attached to the camera. Both actor and camera have distinctive transforms thus position and rotation.
The camera then updates its position and yaw from the attached actor's rigid body. Pitch and roll aren't ...
1
This answers the main question: "So my question really is how would I be able to stick OpenGL (I would like OpenAL and maybe OpenCL too) in a single jar and nothing else?"
You may choose to place all the JogAmp JOGL 2.0 JARs inside your main JAR when you export your application using Eclipse.
Use the "Package required libraries into generated JAR" in the ...
3
First of all that quote you give doesn't really apply to glBufferSubData itself, but to the actual buffer data at a whole when used (by whatever GL functions that actually work on the buffer object, like drawing from a VBO), since glBufferSubData doesn't have any notion of any multi-byte data types yet, it just copies a bunch of bytes around. Only when doing ...
1
In some ways, rasterisation is the opposite problem to raytracing. In raytracing, you know which pixel you are testing, and you have to find the triangles that are hit by the ray through it. In rasterisation, you have information about a triangle and you need to find which pixels it covers.
Basically, the vertices describing the triangle are projected into ...
0
Depth Buffer is not as fancy as ray tracing, it's just a simple sort of Z values from objects.
One of many types of information you send to the GPU are postions (x,y,z), after the data is in VRAM (Video Ram) each z value that a pixel intersects is taken in consideration. Something like this:
for every polygon in the polygon list in VRAM
if polygon ...
1
A lot of good answers here. I'll try to not repeat any of them. Sometimes it's easier to think of in terms of a camera, like how Direct3D does it (note: haven't played with a lot of post 9.0c)
"Moving the world" like in the Futurama sense that someone out there quoted is a very good way to look at it ("The engines don't move the ship at all. The ship stays ...
0
You can achieve what you wish, but not the way you're thinking of doing it.
If you want to output a common depth for all fragments belonging to a primitive, you can add an extra vertex attribute - say, the midpoint of the primitive - which can be a per-instance attribute (if using instancing) or an extra per-vertex attribute (or even set via a ...
Top 50 recent answers are included


