Tag Info

New answers tagged

0

You could enable double buffering which would enable vsync (limit your framerate to whatever refresh rate your monitor supports (usually 60Hz, so 60fps)). SDL_SetVideoMode(yourWidth, yourHeight, yourBpp, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN);


3

Yes, this is a good idea in general, though it's usually called culling - not clipping. There are two basic kinds of culling: Frustum culling tries to eliminate objects that aren't in the view frustum, i.e. are behind the camera or too far to the side to be visible on screen. This is commonly done by doing a conservative intersection test of an object's ...


1

zNear is not really related to field of view. FOV specifies the angle of the frustrum, while zNear describes the distance to the nearest clipping plane. As an example, here are two frustrums with the same FOV, but different near clipping planes. And here is another frustrum with the same zNear as the first, but different FOV. A good approach to ...


1

zNear and zFar are measured in world space, not in anything to do with pixels. Their scale will depend on the scale of the scene you're rendering and how close/far the camera will be to the geometry. For instance, if your scene is modeled in meters, you might set zNear to 0.1 and zFar to 1000 or so. This would let you get the camera as close as 10 cm from ...


0

The problem is not you texture, this should be solved when you put something in background, like texture or geometry, I had similar problem.


1

Texture must be a square with measurements of an exponent of two (16, 32, 64, 128, etc...), so re-size the file to one of those. I tend to use 1024 X 1024 for item textures. Otherwise LWJGL gets all messed up and the texture 'bleeds.'


1

You need to change OpenGL's projection matrix so that it will change the area of the world that is drawn within your window. The projection matrix is what OpenGL uses to determine how the world will be projected onto the screen. Most likely, you're setting this in the beginning of your program to say "draw the area of the world from (0,0) to (800,600)." ...


2

There are some really good answers here, so just to supplement them. A major driving force behind software rendering is capability. This was touched on in one of the answers, but I'm going to make an opposing point: software rendering can actually be more capable than hardware rendering, not less. With hardware you're generally limited to the capabilities ...


0

I think this is a really good question. What I can imagine is: VRAM is more limited than general RAM memory. In case of GPU rendering - every texture is more of an issue. You can store in average about 4 to 8 times more data in RAM than VRAM. Of course this scenario assumes that there is no system that is responsible for freeing/pushing unused/required ...


2

As you clearly already know what GPU rendering is... let me answer what you seem to be asking. Traditionally, hardware rendering has carried a stigma of being very complex. This has in large part been due to the design of the application programming interfaces (APIs) which have not been well-geared to concealing complexity; that is, the learning curve has ...


4

Hardware or GPU rendering is, as you guessed using the graphical processing unit (aka Video Card) to render an image. The opposite is software rendering where the CPU is used. Software rendering is usually used as a fallback when there is no (suitable) GPU available. However since the GPU is orders of magnitude faster software renders are almost never ...


1

It should be either from the image file itself, or from a shader which rejects all perfectly white pixels, or something like that, but since the shader isn't the simplest thing to implement, I'll bet it's the image file. I'll also bet you made or found this image with a white background, then tried to delete that white to make the background transparent. ...


0

Try using gl_FragColor instead of color in simple.fs


0

Thank you all but I found an other way to do that. I created (or rather copied form this schema) a rotation matrix RotateMAT[16]: #define OGLToRadian(degre) ((degre) * (M_PI / 180.0f)) //... GLvoid ROT(float x, float y, float z) { const float cosA = cosf(OGLToRadian(GLrotate_y)); const float sinA = sinf(OGLToRadian(GLrotate_y)); float RotateMAT[16] = ...


2

I think Polyboards would be the thing for you. If you can get yourself a copy of Mathematics for 3D Game Programming and Computer Graphics, there is a section dedicated to this technique in the book.


2

Yes it seems you do want a post processing effect. First Render your scene normally. Then sample this texture in your next Render technique but use a set alpha. something along the lines of: in vec2 Texcoord; out vec4 outColour; uniform sampler2D tex; void main() { outColour = texture( tex, Texcoord ); outColour += vec4( outcolour.rgb, 0.5f ); } ...


0

The "flip queue" that feeds the back buffer is nowadays closely tied to double/triple buffering, as there are almost no implementations that copy the back buffer into the front buffer anymore. You may be setting the swap interval to 1; try setting it to 0, instead. This will disable vsync, but should improve your latency measurements. Ways of reducing ...


1

As Ben suggested, you could use a dummy call to glTexImage2D(). If setting a 0x0 texture doesn't work, you should be able to create a 1x1 texture. I've seen the WebKit source code do something similar to "allocate" texture IDs, and then call glTexImage2D/glTexSubImage2D to upload the actual texture data later. Of course, it's up to the driver whether it ...


2

OpenGL 1.x's built-in matrix operations are notoriously slow, and may even cause pipeline flushes in some cases. To gain performance, translate your gl matrix operations to client-side code (there are several solutions, http://glm.g-truc.net/0.9.5/index.html and http://cmldev.net/ being popular ones). If you already have a lot of code, you can easily write ...


2

When measuring performance, use frame times, rather than FPS. In your case: 1000 ms / 80 FPS => 12.5 msec/frame 1000 ms / 100 FPS => 10.0 msec/frame These are very even FPS numbers, which makes me suspect that they are tied to the display vsync. Have you tried disabling vsync (with a call like eglSwapInterval, or setting the Direct3D swap interval? ...


3

Nick already gave a more specific answer, but I get the sense from your question that you'd benefit from a more generic answer. Different platforms have various ways of getting pixels to the screen. Software is written in layers. You can implement OpenGL on top of D3D (like Microsoft has done), or even on top of GDI as software rendering (like Microsoft ...


4

Java defaults to using GDI (AWT, Swing). JavaFX supposedly will be able to make use of OpenGL in future. Java + LWJGL (an OpenGL wrapper that accesses native opengl32.dll via JNI) provides more direct hardware-accelerated support for Java. Flash Player 11 onward made use of OpenGL via Stage3D. Without using Stage3D, it is using a software renderer built to ...


1

Until OpenGL 3.0, each version of OpenGL was a direct superset of the previous one, so as long as a graphics card and its drivers support the functions you use, you don't have to worry about compatibility. Also, until 3.0 was released, there was no way to choose an OpenGL version because if you got a newer version than you wanted, you just got functionality ...


-1

I found myself that it is a bug of OpenGL version of Monogame. Just create DirectX version and it should work. Edit1: Issue has been send to the tracker. https://monogame.codeplex.com/workitem/7812


1

I can't read all of the source code (dang firewalls), but a display list is something that you compile once, then execute many times. What you're doing is telling OpenGL to regenerate an optimized execution list containing such and such triangle data every frame. That isn't what display lists were* used for -- they originally were more for things like old ...


1

This is possible using GL 1.x and here's how. So as you've found using vertex colors, a smooth transition is where it blends the two colors. This is a called a linear interpolation, or a "lerp" for short. It can be generalized to any dimension by operating on the elements of the vector individually and indeed colors are treated like a lerp in 3D -- blend R1 ...


1

One way of doing this is using min blending. With Unity this can be set up in ShaderLab using the BlendOp command. If your objects are all monochrome as seen here, you may simply be able to use min blending directly on the objects as they're rendered and avoid having an alpha channel at all. (White is transparent when using min blending.) Min blending ...


0

you can try drawing with a clipping mask, you could have a rectangle (or even irregular shapes) for the mask that represents that space. looks like LWJGL has that functionality (https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Masking). however if you want to make some kind of minimap i think @Mario sugestion is more appropriate.


1

Try setting the texture's minification filter to GL_NEAREST or GL_LINEAR after glTexImage2D(): glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); The OpenGL default is to use mipmaps and you didn't send any which makes the texture incomplete and will disable that texture ...


2

You should be able to use glViewport() to limit rendering to a specific portion of the screen. Just keep in mind that you might have to adjust your matrixes as well. In C++, the call would be as simple as this: glViewport(left, top, width, height); You should find a wrapper for this in LWJGL as well. glScissor() would be another alternative if you don't ...


4

For texture spaces, in Direct3D (0, 0) is top-left, in OpenGL (0, 0) is bottom-left. Therefore the v-coordinate will be upside down in one of these APIs. However, I wouldn't recommend negating the v-coordinate as this will only work if you're using a sampler with wrapping. You can fix the v-coordinate as follows: v = 1.0f - v;


0

OK! I got it... The problem was that my program was using old dll opengl32.dll that was located in the same folder. After removing the old dll the rendering context automatically switched to the local dll's: atioglxx.dll for AMD and nvoglv32.dll for NVidia. So basically now the glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT); ...


2

OpenGL provides occlusion queries, described here. They are not exactly simple to use, but I believe they will do what you need. Basically, you create an occlusion query object, then "activate" it with glBeginQuery during the rendering that you want to analyze. After you are done drawing the geometry of interest, call glEndQuery and glGetQueryObject, ...


0

As expected, it was a really simple solution. I suppose I stared so long at the problem that I was losing the ability to see anything at all. The solution was to send the correct buffer type (GL_ELEMENT_ARRAY_BUFFER instead of GL_ARRAY_BUFFER) to the glBindBuffer(...) call. ORIGINAL CODE glGenBuffers(1, &indexbuffer); glBindBuffer(GL_ARRAY_BUFFER, ...


2

OK, you seem to be pretty confused so here is some code I used with LWJGL which is very similar to JOGL. Probably you will have to swap the buffers with arrays, but the code will be almost identicall. Here is the method that takes screenshot by writing the screen data to a BufferedImage (the width and height are the dimensions of the screen, the buffer get ...


0

I'm not 100% sure what your exact problem is but I do know in my code, that.. glEnableVertexAttribArray(attrib_coord3d); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glVertexAttribPointer(attrib_coord3d, 3, GL_FLOAT, GL_FALSE, 0, 0); I don't do that every time I draw, I do it once when I load a 3D model, and then after that I just bind the vertex array to ...


0

The only way to go about this is to use Uniforms. You ALWAYS want to keep the Vertexs uv´s in the local space. for the reason that you don't want to have multiple vertex data containing almost the same information. Offseting and scaling will only happen on a per mesh basis so it wont be that bad for it either. Sometimes it will be on a special case basis ...


0

You also need to reflect the lighting environment (i.e. light positions and directions) for the lighting on the reflection to be correct. It's useful to think about the reflection as being applied to the camera, i.e. as part of the view transformation, rather than as part of the model transformation. That way, the logic you already have to ensure lights ...


2

The value 127 / 255 is an integer division and always has the value zero. You want vec3(127.0 / 255.0, 0.0, 0.0) instead.


1

There are several steps you need to follow that will allow you to pick in a 3D application. To transform screen coordinates to world space coordinates, you need to denormalize the scree-space coordinates. Then, you need to multiply the the point of the cursor (assumed object doing the picking) in normalized device space with this matrix. Then we would ...


2

By default the output variable (outputColor) is bound to location 0. For a fragment shader this specifies the color value to be used for that fragment for the framebuffer object in position 0. You can bind the output variable to different locations in the application code using glBindFragDataLocation() or in the shader like this layout(location = 0) out ...


1

OpenGL provides blending function. glEnable(GL_BLEND);// you enable blending function glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // then you will set flags to achieve desired blending effect. For further different usage, read http://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml However for your particular case, the desired effect, ...


1

I do not believe that this is directly possible using OpenGL 1.x. If you're using OpenGL 1.3, you can use Texture Combiners to merge two textures together in various ways, and you can even specify different sets of texture coordinates for the two textures, but I do not believe it's possible to set different opacities for the different textures per vertex ...


0

I got help in another part of this website on a similar question which answered this one. As such I'm going to answer my own question here and supply the answer I was given just to close this. So what I really needed was a working LookAt function, I'm still not sure what exactly was causing the problem I had before with the weird distortion other than ...


3

Yes, but keep in mind the default frame buffer will always be the same size of the window. What you can do is to render your scenes internally into an off-screen (400x300) frame buffer, and then up-scale it to (800x600), you can do this by rendering this into a texture and applying it on a full screen quad, the advantage you will get is your shaders will run ...


0

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.


0

The code you are using to switch between 2D and 3D seems OK. Your problem should be on the GL states. Usually, when rendering sprites and 2D GUI, I use the following states: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); Then when switching back to 3D, I normally set: ...


0

Interleaved VBOs Let's assume you have vertices V_1, V_2, ... V_i each having position p and normal n. Positions and normals are called vertex attributes. Vertex attributes can be stored in an array, e.g. positions = {p_1, p_2, ..., p_i} and normals = {n_1, n_2, ..., n_i}. If you feed these arrays to OpenGL, you are using non-interleaved VBOs. You can also ...


4

What you are looking for can be found in this very good explanation: http://www.songho.ca/opengl/gl_transform.html But since I found it sort of confusing without hand holding I will try to explain it here. At this point you need to consider 5 coordinate systems and how they relate to each other. These are the window coordinates, the normalized device ...


2

There are billion ways to do this. But here is my approach : To do this i would go with a more "particle" system approach. Rendering a line is quite easy with a quad, you just stretch the four vertex in the direction it´s traveling and then have a maximum length that it never can be longer than. the best way with this is that you can heayily optimize this ...



Top 50 recent answers are included