New answers tagged

0

I am pretty sure the attribute should bind to the current buffer so there is no reason to be redoing this business with the attributes every frame unless you rebuild the buffer every time.... So you should probably do it one way or the other - either leave it be or rebuild the whole thing every frame.


0

You are offsetting the model as well as scaling its x and z coordinates, which I assume is why this is failing for you. You really aren't providing enough information to help you more than that, since we don't know how your interface between the terrain and the rest of the game looks like. I'd assume that if you account for the offset and the scaling along ...


2

Even though you are binding the textures correctly with glActiveTexture and glBindTexture you are not telling GLSL which sampler uniform goes to which texture. What you should do is this: glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, colorBuffers[0]); glUniformi(glGetUniformLocation(bloomShader.program, "colorTexture"), colorBuffers[0]); ...


-1

Make sure: Number of vertexes=3*Number of Triangles when using gldrawelement(GL_TRANGLES,...


0

I think you miss the point of what an engine is a little bit. Game engines are developed in order to make game creation easier, without having the users of the engine to take care of complex low-level APIs. Therefore I would manage OpenGL resources internally, inside the engine. So, let's go through your points. It depends on how you build your system. ...


0

This is a massive project, and if you haven't done any graphics progamming before it will most likely take many months or even years. That being said, the ArcSynthesis tutorial is often recommended for beginners. The site has been down for some time, but you can find a Bitbucket repository here.


2

You can render a quad onto the framebuffer with a shader that will just set the color value to 1000.0. Since you don't even need to set a texture really let alone compute lighting, this should not really take any noteworthy time to accomplish. It's pretty easy to do but here is a tutorial that talks about rendering to a texture. Though really you don't ...


3

SurvivalMachine nailed one of your problems (you can see that the texture is repeated twice). Your other problem (the texture is a big blob instead of a crosshair) is because you don't use transparency : some of the completely transparent pixels of your texture have a green color value (that's a common sight with optimized PNGs). Just enable blending with ...


2

Maybe there's more problems, but at least this looks incorrect: gl.glTexCoord2f(2f, 1.0f); Your texture is repeated horizontally 2 times because its wrap mode is repeat and the coordinates you set are over 1 (in this case 2f). To fix this, replace 2f with 1f: gl.glTexCoord2f(1f, 1.0f);


0

I hope I can make this clear, but basically you need to make a stencil of both objects as if they are both selected, then only keep the areas in the bounding box of the item you actually want to highlight. So basically you make one stencil buffer of both objects selected (or all objects that occlude the object, really...but I would not worry about those ...


1

Your question needs re-phrasing. SDL and OPENGL are two different technologies so to speak. Also, this question will lead to opinions instead of facts Wikipedia says: Simple DirectMedia Layer (SDL) is a cross-platform software development library designed to provide a low level hardware abstraction layer to computer multimedia hardware components. Open ...


0

As others have said, there is no real protection for your assets. That doesn't mean you have to push them out there totally unprotected, though. Having your own internal format for your assets is pretty useful or even necessary in the long run anyway. If you have your own file format that is not easy to open in content creation tools then it serves just as ...


1

Sometimes resources seem inaccessible because the devs used customized or proprietary formats, I.E. appending sound effects to the end of sprite image file. Keep in mind while it's possible to obfuscate the resources, but you can't fully protect them. Even if encrypted, your game will need to decrypt them before use & will need the key. If the key is in ...


0

I'm not particularly knowledgeable in the field of encryption and data storage, >so I may be overlooking something obvious but I would like to know how exactly I >could achieve something similar. I don't know a ton of stuff about encryption or advanced data storage either. :) However, one relatively simple way to protect the program assets would be to ...


2

glMatrixMode(GL_MODELVIEW); glDisable(GL_LIGHTING); gluPerspective(50, 1.33, 1, 1000); gluLookAt(3, m_xAxisLocation, 4, 0, 0, 0, 0, 1, 0); This kind of thing is generally wrong. What've you've done here is set the active matrix stack to the model-view stack; this is responsible for generating the matrix transform that will bring your rendered geometry into ...


0

You can send all the data in you want as a texture.


1

If you zoom the second image - you can see that green square rendered twice and on it to, so probably you have two draw calls for your green square...


1

Your code should be placing the object in one fixed spot with no rotation. It sounds like you want it to be moving so that it's always viewed from the same angle by the camera whenever the camera moves. I guess these are basically like powerups then? If so I guess this makes sense to do. The good news is that it is simple to rotate the object in the same ...


1

A guess (too long to put in a comment): If spotFactor becomes 0.6 at a specific pixel, from this float spotFactor = dot(lightDirection, spotLight.direction); then color goes negative here (as you said spotLight.cutoff is 0.71): color = calcPointLight(spotLight.pointLight, normal) * (1.0 - (1.0 - spotFactor)/(1.0-spotLight.cutoff)); will ...


0

I haven't thought about this for too long. But it seems fairly simple. I assume you know what the modelViewMatrix is. This 4x4 matrix transforms coordinates (points) from world space to camera space. There is a similar matrix called the normalMatrix that transforms vectors (usually normalvectors). It does the same as the modelViewMatrix, but skips all ...


1

There is at least one serious problem in the code. In calcLight(), the test below is invalid. Calling pow with a negative first argument is undefined behaviour, so you need to test specularFactor sooner. float specularFactor = dot(directionToEye, reflectDirection); specularFactor = pow(specularFactor, specularPower); if(specularFactor > 0) ...


0

Yes, you can. The issue is performance. The main benefit of tiling is that it enables the use of compute shaders so that you can short circuit your rendering logic and avoid unnecessary calculations. There's no reason you can't do the same thing without compute shaders but the problem is that you will have much less pleasing performance. Which makes it kind ...


0

OK so I have a partial answer (more of a kludge) that might eventually lead to the real, proper solution for this. I've added some code to check for a SDL_WINDOWEVENT_RESTORED event; when this occurs, openGL is reinitialised, and all of the textures that were loaded on program start are cleared and re-loaded. This feels very hacky, and carries about a 40MB ...


4

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 the above shader is the reflectDirection variable, but I could be wrong. GLSL has isinf() and isnan() functions that you can use to detect those cases. If that ...


2

I just want to know how to properly handle rendering a large amount of different TYPES of object. Whatever you consider a "type of object," you can usually avoid actually having too many types of things that the renderer needs to know how to process and draw. Fundamentally, for every given draw call, the renderer needs to know: what geometry (vertex ...


3

No, you can first render your perspective scene normally, and then switch to an orthographic mode and render your text on top of that, supplying the text vertices in screen space and using a shader that doesn't do much notable transformation to the vertices. (Strictly speaking you don't even need to do this second pass with an orthographic projection, but ...


2

I needed to use glDepthFunc(GL_LEQUAL) for queries because bounding boxes have the same size as objects size (z-fighting). //query everything glDepthMask(GL_FALSE); glDepthFunc(GL_LEQUAL); //this is critical glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); for(i = 0; i < scene->numInstances; i++) { inst = scene->...


4

Physics done on the GPU are usually cosmetic effects. Particles are a good example, but hair and tall grass are similar. The GPU is very good at doing a massive number of calculations and since it also handles the drawing if these things it is a good match. A GPU isn't very fast at communicating the results back to the CPU. This is why physics used in ...


2

Think of your question in terms of tessellation with your sphere formed by rings. If you have a tessellation factor of 5, you will have a top cap, 2 middle sections, and a bottom cap. The bottom two tessellation ring being the 25% bottom cap and the top tessellation two rings the 25% top cap. The center is therefore one ring at the equator with a set of ...


0

If you can draw triangles, then you can technically create a 3d engine with it. However, this involves the same amount of math as you need to do OpenGL if not more. First, you need to define positions in 3 dimensional space. This is done by using 3d vectors. To render a triangle, you need 3 vectors, one for each vertex of the triangle. Now, to project a ...


2

At first glance, this looks far too complicated. Lwjgl should have something to the effect of 'getmouseposition()'. Call this function every iteration of your game loop, cast or set it as a Vec2d, then use that position to blit or draw the mouse you want. All of your blits should be called every game iteration in some kind of draw loop. Mind you, I was ...


0

Okay I have found the answer and for those who might be looking through suffering the problem as well I will by trying to write fairly generic code that should be easy to read. Any issues post as a comment and I will answer as best as I can. Anyway it turns out that the problem was I was trying to use glBufferData before using glBindBufferwhich lead to the ...


2

Not really. In older, non-modern versions of OpenGL you can use glMatrixMode to activate the GL_TEXTURE matrix stack, and then push a scale and/or translation matrix that offsets accordingly. UV coordinates will be multiplied by the texture matrix prior to resolution. But those functions are deprecated in modern OpenGL, because it's trivial to do them in a ...


1

The problem you are experiencing is called Gimbal Lock. There are some ways to circumvent this problem. One possibility is to use Quaternions. There are plenty of resources on the web about them so I won't go to deep into the details here. Quaternions are fast but not very intuitive for a 3D editor. But it is possible to convert Euler angles to Quaternions. ...


2

There's no good way to detect different data formats from each other in shader code. In general you should always give the same kind of data to your shaders. You need to pre-process your data before drawing with it. Pick one format and convert all data to that, and then write your shaders to use that format. One other way is to detect the format before ...


-1

It's not an appropriate answer, but you can do this... You may go deep inside UE4 source code, rewrite the things you need; since it has free access it's possible. But it will hurt, promise you.


0

Your code should work as it is. In general, all you need to do is set the debug flag before creating the context and then query the extension. The code I'm currently using (SDL+GLEW; error checking omitted for brevity): // Get the current context flags and add the debug flag // (so we don't accidentally reset any default flags) int contextFlags = 0; ...


2

Code written for core 3.3 should be fully compatible with a 4.5 core profile. This can be seen from the OpenGL 4.1 and 4.5 specifications, which note features deprecated in each version (see appendices J and K in the first, and appendices E through H in the second). The only features which have been deprecated since the 3.3 specification are "the pixel pack ...


0

vec3 viewDir = normalize(viewPos - FragPos); float spec = pow(max(dot(viewDir, reflectDir), 0.0), shininess); vec3 specular = specularStrength * spec * lightColor; You need viewDir and reflectionDir. Your reflectionDirection looks ok. Your viewDirection looks messed up though. You also have them backwards from the norm but it shouldn't matter. If ...


1

In the case of a masked texture, only fully opaque pixels should update the depth buffer. Any pixel that is partially or completely transparent should not update the depth buffer. Updating the depth buffer will prevent pixels of greater depth from being drawn/calculated, and pixels with alpha need to blend with pixels in the background. If no blending occurs,...


2

It looks like you're trying to draw a 40x40 pixel aqua colored square at (0.0, 0.0, 0.5), is that right? OpenGL producing no output is probably the most common symptom you'll run into. I immediately see several things that look a little off: Your shaders are requiring OpenGL 4.5. Are you sure your current OS/drivers/etc. implement OpenGL 4.5? You set the ...


1

I am also looking for some code to make this conversion but..Only God knows why the code above is using that array indexes lol... Maybe he meant something like this? (in case other people wants to use the code too) PVector [] tUV = new PVector[3]; // 2d uv coordinates of the triangle vertices PVector [] t3D = new PVector[3]; // 3d space ...


0

Go to edit mode Select all vertices (a) Press Ctrl + n (this recalculates all normals for all faces) export again and see if it behaves the way you want it If that did not work, do Go to edit mode Select all vertices (b, blender keeps a tab of the hotkeys you use and increment them by 1 for every use) Press w, select "remove doubles" (or duplicates, ...


0

For future people running into my problem i found the solution. I was able to compile my project with this. -w is for removing warning its optional. I also found you need to link with -lXxf86vm g++ main.cpp -w -I../../../LIB/irrlicht-1.8.3/include/ -L ../../../LIB/irrlicht-1.8.3/lib/Linux/ -lIrrlicht -lGLU -lGL -lX11 -lXxf86vm


0

You'll need to install development libraries for OpenGL and X11. You didn't state what distro you're using, but in Ubuntu OpenGL development library is in package libgl1-mesa-dev.


0

You can have one shader for refractive/reflective objects and one for objects that have different materials (different textures and surface properties) or you can have one big shader (uber-shader) that will determine in runtime (via uniforms) how the object should be rendered. There is a bunch of tutorials. The best one, in my humble opinion is this one: ...


1

As far as I know that's the best solution to check if there is an active context.


2

According to GL spec: void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); *location* Specifies the location of the uniform value to be modified. *count* Specifies the number of matrices that are to be modified. This should be 1 if the ...



Top 50 recent answers are included