New answers tagged

1

I figured out the cause of the problem. I had to clear the depth buffer before rendering the screen filling quad, even though I switch the frame buffer. Apparently the quad, cull the objects behind it, causing the textures to go blank. I did glClear(GL_DEPTH_BUFFER_BIT) before I unbind the FBO. This fixed the issue for me.


-1

Try using glCullFace( GL_BACK );


0

In your code you seem to assume each face consists of 3 vertices aka. triangles which doesn't have to be the case. Blender tend to prefer exporting OBJ models using quads instead. The easiest way to fix this is to tell blender to convert all quads to triangles before exporting. Just tick off "Triangulate Faces" when you export. Though you do seem to also ...


0

yeah, thank you, But still the problem. ... here, my code: https://drive.google.com/open?id=0B_j9kxE7xxc2S0RaQkx1Ty1waVE the "Tableau X.txt", "Tableau Y.txt" and "Tableau Z.txt" contains the x, y,z datas for each profiles.


0

First you have to clear everything - because you are a newbie you can use glClear(GL_COLOR_BUFFER_BIT); After that it's time to "set" your "background" color like this: glClearColor(0.0f, 0.0f, 0.0f, 255.0f); You can put your own RGB color here. And finally draw simple quad. And after that you have to update your screen, the way to do that depends on ...


2

I know it's stupid to answer my own question but... With very, very big thanks to @Ben I fixed this problem by creating SDL_Surface and load image to it once for each TextureAsset and store it inside TextureAsset instead of creating new SDL_Surface for same texture and free it each draw call.


0

For people who come here from Google (like me), the shader version is: fract (tex_coord.st) this will loop coordinates in range 0.0 - 1.0


1

There are plenty of ways to do this, I mention here the 2 most popular one, so vertex array objects and immediate mode. To draw a rectange on the scree with immediate mode, you need to do the following: glBegin(GL_TRIANGLES); glVertex2f(-0.5, 0.5); glVertex2f(-0.5, -0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(-0.5, ...


0

Do you know the basic principles of java? If eclipse crosses out something, it means, that method is deprecated. Use glGetShaderi instead of glGetShader. Also, some other things you should consider to do: After you linked the shader, you don't need to have the vertex and fragment shader, delete them immedialitely after it. BindAttributes comes before ...


0

In your ShaderProgram.java try binding the attributes before you link and validate the program: public ShaderProgram(String vertexFile, String fragmentFile){ vertexShaderID = loadShader(vertexFile, GL20.GL_VERTEX_SHADER); fragmentShaderID = loadShader(fragmentFile, GL20.GL_FRAGMENT_SHADER); programID = GL20.glCreateProgram(); ...


3

There are two possibilities I can come up with that don't involve ordinary planar reflection. The first is to perform screen-space reflection, which is fairly cheap and works for any manner of surface. However, it will be prone to artifacts, and of course it will not be able to reflect objects that are not visible from the regular point of view. The other ...


0

I think you're missing a bind to your index buffer. It's been a while, but I believe binding the VertexArray only affects the vertex data, not the index data. If I remove the glBindBuffer(GL_ELEMEN_ARRAY_BUFFER...) from my code, i get a black screen. glBindVertexArray(VAO); **glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);** glDrawElements(GL_TRIANGLES, 6, ...


-4

Render it with layers of pixels for each layer of water


0

I had the exact same problem when I wanted to render a set of overlapping framebuffer objects like layers. The problem is Open GL blending functions is linear and it works when destination background is opaque. But actual blending equation for blending two transparent layers is not a linear equation and contains a division part. out_color = {src_color * ...


0

You would have to render your scene into a cube map, then render a quad. The texture coordinates would then translate directly to longitude/latitude you can use to calculate the vector to use for sampling the cube map. For equirectangular projection: lon = u*2*pi lat = (v*2-1)*2*pi x = cos(lon)*cos(lat) y = sin(lon)*cos(lat) z = sin(lat) Where u/v are ...


0

I would advise you to consider using glStencilOp function. In particular, you can use different operation if the stencil test passes but not the depth test. See that reference page for additional details. Hope it helps.


0

As Krom Stern pointed out in the comments, the issues with my shadow mapping stemmed from two issues in the pass 2 fragment shader. First, I needed to divide the v_shadowCoord by the w component in addition to performing the correct bias model-view-projection multiplication. This division would normalize my coordinates between 0 and 1 and provide valid ...


1

I don't know if this could help you, but this is everything I do for good MipMapping: public int loadTexture(String fileName){ Texture texture = null; try { texture = TextureLoader.getTexture("PNG", new FileInputStream("res/textures/"+fileName+".png")); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); //I preffer LINEAR_MIPMAP because ...


4

To me it looks very much like your issue here is that you are mixing world and viewspace or something similiar. Now your GBuffer normals look like they might be in viewspace in that picture, but the code in your geometry pass definitely doesn't transform them from world to view space. If they are in world space then your NBT matrix is basically oriented ...


1

If I understand you correctly you are having problems going left and right. First off currentFrontSpeed should never be negative since it's speed not velocity. Speed is a scalar and as such should not capture any direction and will always be positive. To move in different directions you should modify the angle instead where for example right is -90 from ...


0

The issue turned out to be a problem with the way Wayland works. My install of Gnome was defaulting to Wayland, instead of x, and Wayland doesn't do a good job of capturing the cursor within a window.


3

You load your images like this: texture = TextureLoader.getTexture("PNG", new FileInputStream("res/" + fileName + ".png")); However if you read through the source code of slick you'll see that internally it is represented as TextureImpl which was the following documentation. A texture to be bound within JOGL. This object is responsible for keeping ...


3

The problem was there gl_FragColor = (1.0, 0 , 0 ,1.0);//vec4(texVal.rgb, texVal.a)*(1.0, 0 , 0 ,1.0); it miss the vec4 name gl_FragColor = vec4(1.0, 0 , 0 ,1.0);//vec4(texVal.rgb, texVal.a)*vec4(1.0, 0 , 0 ,1.0);


0

Try this instead: Matrix4f modelMatrix = new Matrix4f(); modelMatrix.m00 = 2.0f / (float) Display.getWidth(); modelMatrix.m11 = -2.0f / (float) Display.getHeight(); modelMatrix.m30 = -1; modelMatrix.m31 = 1; I have no idea what gui.getSize().getX() / Display.getWidth() was suppose to do, so I left it out from above. But ...


0

Ok, I've finally figured it out. After some digging through the OpenGL 4.4 Core Specification, I found this paragraph regarding glGetProgramResourceiv : For the property MATRIX_STRIDE, a single integer identifying the stride between columns of a column-major matrix or rows of a row-major matrix is written to params. For active variables declared a single ...


-1

This is a very broad question. I'm assuming you have seen the answer from Kieran Chandler about platform abstraction. You've mentioned the SDL Library that you want to use. I've used it myself for such a OpenGL cross-platform project. The library provides most of the platform abstraction. Use its functions for all input and output, like accessing files, ...


-1

It doesn't sound like you are ready to take on a large task like this. You need to learn about the underlying concepts and make some smaller projects before you can really move on to making a cross-platform game. The main point to make about cross-platform games is that you need to have a "Platform Abstraction Layer" which will allow your game to perform ...


2

Ray-casting into the height map on the CPU will likely be much faster with proper optimizations and it wont unexpectedly fail (eg: due to some odd driver rounding issues on a rare-ish laptop chipset creating a few angry customers.) Either of those solution would work but reading a texture or frame (or any data) from GPU RAM is extremely slow (relatively ...


3

The texture regions inside don't need to be powers of two. But texture compression cells are often 4x4 so you have to be careful when using compressed textures that the edges of two texture regions don't share the same cell or they'll be compressed together which will degrade the quality if they have different colors. You should leave a N pixel border ...


2

You seem to just show the foliage at pre-determined distance. Why don't you lerp foliage opacity between transparent and opaque across some distance range? Could be the simplest most noticeable improvement.


3

You get the error because there is no operator*= for vec4 that takes a matrix as a parameter. It then tries to convert the matrix to a float, but just can't. To work around this, you should try to not use the operator*= and write it all in the long form: Off = Off * Util::createTransform(offset); Also, as pointed out in the comments to the OP, what you ...


4

No, but OpenGL might ;) The base Vulkan specification only supports SPIR-V. However, Vulkan does allow for vendor extensions. And NVIDIA is already on-record on this matter; they will be providing a Vulkan extension to be able to shove GLSL into their Vulkan implementation. That shouldn't be taken to mean everyone else will. However, let's not forget that ...


2

GL11.glColor3f(alpha, alpha, alpha); won't work for 2 reasons: It's opaque. You'd need GL11.glColor4f(alpha, alpha, alpha,alpha); It affects the next object to be rendered, not everything already rendered. It would be easier to render a semi-transparent quad over the whole screen (with a slightly higher z-depth) prior to drawing the menu. This will cut ...


1

Unfortunately, when it comes to lighting, some way or another, you'll need some normals. As you mentioned, for flat shading, you need per triangle normals, which implies vertices duplication, compared to smooth shading. The most often used techniques to compute normals in an OpenGL shader (using dfx/dfy or geometry shader) are not available in gles 2.0. ...


0

Ok so the problem was not winding. It seems that MickLH is right in that one cannot simply combine all the shared points in a mesh into one vertex. Only vertices used in triangles with similar normals can be combined otherwise one gets this strange effect.


4

Note that this is the 38th tutorial in a series. If you go back to part 22, you can see m_Entries is defined as follows: The m_Entries member of the Mesh class is a vector of the MeshEntry struct where each structure corresponds to one mesh structure in the aiScene object. That structure contains the vertex buffer, index buffer and the index of the ...


6

vec3 norm = vec3(uViewMatrix * uModelMatrix * aNormal); The normal cannot be transformed like a point, to transform a normal you use the inverse transpose matrix. If you want the fun details of why this is here is a qoute from the OpenGL Red Book that explains it better then I ever will: Mathematically, it's better to think of normal vectors not as ...


0

look at exported obj file, there you'll see directives about: 1. import mtl file mtllib "mtl file name" 2. and use materials usemtl "material nae" mtl, obj format are described here http://paulbourke.net/dataformats/mtl/ http://paulbourke.net/dataformats/obj/


0

Just call the render function and draw a filling black rectangle on your screen. public void render(GameContainer arg0, Graphics arg1) throws SlickException { arg1.setColor(Color.black); arg1.fillRect ( 0.0f, 0.0f, gameCon.getWidth(), gameCon.getHeight() ...


1

After spending whole day i finally found out whats the issue actually. Its really silly of me that its got overlooked at the very first place. So here is the problem : matrix[1][1] = (matrix[1][0] * matrixb[0][1]) + (matrix[1][1] * matrixb[1][1]) + (matrix[1][2] * matrixb[2][1]); Here i am setting matrix[1][1] to a new value. But in the next line i need ...


1

One downside to Z-buffering vs sorting not mentioned by the other answers can and most likely will happen when using Z-buffering with images whose pixels are not fully transparent or fully opaque. Alpha-blending said pixels correctly is dependent on the order they are drawn. Say you have a half-transparent green square and a half transparent red square in ...



Top 50 recent answers are included