• Content count

  • Joined

  • Last visited

Community Reputation

489 Neutral

About lilljohan

  • Rank

Personal Information

  1. This has been solved now: I had to call glDepthMask(GL_TRUE) before clearing. Hello, I am having trouble with the depth buffer and my fbo. Everything renders correctly if I disable depth test or if I render directly to the frame buffer instead of the fbo. It looks like the depth buffer that is attached to the fbo is not cleared correctly, I can also see some flickering of the rendered object when I move the camera. My box is rendered correctly in the first frame when I do frame by frame stepping in CodeXL but it is not visible in the following frames. I get no errors from CheckFrameBufferStatus or GetError and the fbo looks ok when I check it in CodeXL (1 texture and 1 render buffer, fromat = GL_DEPTH_COMPONENT24, type = GL_FLOAT). Creation of the fbo: GL.GenFramebuffers(1, out Handles[index].FrameBufferObject); GL.BindFramebuffer(FramebufferTarget.Framebuffer, Handles[index].FrameBufferObject); Handles[index].DrawBuffers = new DrawBuffersEnum[textureHandles.Length]; for (var i = 0; i < textureHandles.Length; i++) {     Handles[index].DrawBuffers[i] = DrawBuffersEnum.ColorAttachment0 + i;     GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0 + i, OGL.TextureTarget.Texture2D, textureHandles[i], 0); } GL.GenRenderbuffers(1, out Handles[index].DepthBufferObject); GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, Handles[index].DepthBufferObject); GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, RenderbufferStorage.DepthComponent24, width, height); GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, RenderbufferTarget.Renderbuffer, Handles[index].DepthBufferObject); GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, 0); var status = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); if (status != FramebufferErrorCode.FramebufferComplete) {     // Log error and clean up if neccecary } GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); Below are all the draw calls for a complete frame, extracted while debugging with CodeXL. // Render the crate to the texture glBindFramebuffer(GL_FRAMEBUFFER, 1) glDrawBuffers(1, {GL_COLOR_ATTACHMENT0}) glViewport(0, 0, 512, 512) glClearColor(0, 0, 0, 1) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) glUseProgram(33) [Context 3 - program 33: shader 31, shader 32] glDisable(GL_BLEND) glEnable(GL_DEPTH_TEST) glDepthMask(TRUE) glEnable(GL_CULL_FACE) glBlendFunc(0, 1) glCullFace(GL_BACK) glDepthFunc(GL_LESS) glUniformMatrix4fv(0, 1, FALSE, {0.47494337, -1.4067751, 0.32057661, 0.32045144} {5.5997848e-008, 0.6356858, 0.93057901, 0.9302156} {0.85067475, 0.78542173, -0.17898236, -0.17891248} {1.7013494, 0.80802053, -1.6746986, -1.4740837}) glBindVertexArray(4) glDrawElements(GL_TRIANGLES, 612, GL_UNSIGNED_INT, 0x000000) // Render texture to fullscreen quad glBindFramebuffer(GL_FRAMEBUFFER, 0) glDrawBuffer(GL_BACK) glViewport(0, 0, 1280, 720) glClearColor(0, 0, 0, 1) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) glUseProgram(6) [Context 3 - program 6: shader 4, shader 5] glActiveTexture(GL_TEXTURE0) glBindTexture(GL_TEXTURE_2D, 2) [Context 3 - Texture 2: Context 3 - Texture 2] glDisable(GL_BLEND) glDisable(GL_DEPTH_TEST) glDepthMask(FALSE) glEnable(GL_CULL_FACE) glBlendFunc(0, 1) glCullFace(GL_BACK) glDepthFunc(GL_LESS) glUniform1i(0, 0) glBindVertexArray(5) glDrawElements(GL_TRIANGLES, 18, GL_UNSIGNED_INT, 0x000000) wglGetCurrentDC() wglSwapBuffers(0xE40123A5) Anyone got any ideas? I have searched on google but have not found anything that helps so far. It feels like I'm missing something obvious in my opengl calls.   Update: Actual fbo setup as reported by CodeXL, everything looks ok to me. // Texture setup glGenTextures(1, {0}) glBindTexture(GL_TEXTURE_2D, 2) [Context 4 - Texture 2: No preview available] glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 512, 512, 0, GL_RGBA, GL_FLOAT, 0x000000) [Context 4 - Texture 2: No preview available] glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) [Context 4 - Texture 2: Context 4 - Texture 2] glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) [Context 4 - Texture 2: Context 4 - Texture 2] glFinish() glGetError() // Frame buffer setup glGenFramebuffers(1, 0x29A83C4) glBindFramebuffer(GL_FRAMEBUFFER, 1) // Attach texture glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 2, 0) // Create and attach depth render buffer glGenRenderbuffers(1, 0x29A83C8) glBindRenderbuffer(GL_RENDERBUFFER, 1) glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, 512, 512) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 1) glBindRenderbuffer(GL_RENDERBUFFER, 0) glCheckFramebufferStatus(GL_FRAMEBUFFER) glBindFramebuffer(GL_FRAMEBUFFER, 0)
  2. The SpaceGame in 3d!

    Yeah OpenTK looks to be quite dead, but it's working fine for me at the moment. Might have to switch to something else or maybe patch it myself if I encounter any issues in the future.   Weird that Chrome marks the installers as malicious, I just did a couple of virus scans and have been unable to find anything suspicious. I will have to investigate this further.
  3. The SpaceGame in 3d!

    I have decided to convert my game RymdspeletHD (translation: The Space Game HD) to 3d. I suppose that the new title will be something like RymdspeletHD 3d Deluxe Edition. My idea with this conversion is that it might be a project that I may actually finish, instead of trying to make yet another full blown rpg or an epic freespace clone. I am using my home brew 3d engine to complete this (that I wrote for my freespace clone, which I never finished ). It's all being written in glorious C# with the help of OpenTK. I just implemented the cook torrance lighting model in the game and I am on the way to do some of the initial game play. Already got movement and shooting covered but collision detection is missing. It would be nice if you were actually able to hit one of those nasty asteroids. I have not decided exactly on how I will handle the collision detection yet but I will either do simple sphere colliders as I have done in the past or some kind of mesh based detection for more accurate collisions. I have attached screenshots of both the 3d and 2d versions to this post. As you can see I have quite a lot of work to do before I can match the visual quality of the old version. But at least the lighting will be dynamic and nice. If you're interested in playing the regular RymdspeletHD then it is still available at
  4. Unnamed Space Shooter

  5. An enemy and a friend

    From the album Unnamed Space Shooter

  6. Blowing stuff up

    From the album Unnamed Space Shooter

  7. Getting shot at

    From the album Unnamed Space Shooter

  8. Main Menu

    From the album Unnamed Space Shooter

  9. Unnamed Space Shooter, with screen-shots!

    Here are a couple of screen-shots from a Freespace like space shooter that I have been developing for the last six months. I am using Unity3d and C# to create the game. There is only one mission in the game at the movement but most of the features that I want are already there like complex objectives, including but not limited to destroy a specific group, protected a specific group, reach a point etc. All objectives can be time limited, start after a specific amount of time, depend on other objectives and more. There are also multiple weapons both primary (lasers) and secondary (missiles), the player can active or deactivate individual lasers, multiple lasers can be active at the same time, and switch between available missile launchers. The missiles have target locking or they can be just simple fire and forget missiles. I have also implemented some auto-piloting functionality such as automatic speed keeping either at full or half speed. Or the ability to match the speed of your current target, useful for pursuing someone while blasting them to pieces. There is also an afterburner that allows you to go slightly above the ships speed limit and accelerates faster than the ordinary engines. The ship control itself is not realistic and is more like driving a car, I found this to be more fun than the realistic alternative. That's it for today, the screen-shots are in the gallery just above all the text, just in case you didn't notice.
  10. A couple of hours with Unity

    The models are from [url=""]Arteria3d[/url] and [url=""]Dexsoft[/url], except fore the fire in the torches which is part of the standard unity package.
  11. A couple of hours with Unity

    I downloaded and I have now spent a couple of hours playing around with it, most of which was spent building the light maps. The result is a medieval city scene viewed from a top down perspective and a character that goes where you click. The camera can be moved be moving the cursor to the corners of the screen and there is also a monster that will try to hunt you down, although it does not deal any damage yet. Expect more updates soon. There is a web player available here: http://www.tinyrocke.../WebPlayer.html Update It is now possible to attack (and kill) the monster and he got a buddy waiting for you further down the road. There is also some wind blowing in the background. Update 2 The town is bigger now and there is new enemy "hiding" in it. I have also added basic path finding using Angry Ant's Path and some basic leveling, don't forget to spend your characters points or you will probably meet a gruesome death. Update 3 I have implemented the quest view and added one quest, "Kill all the monsters"...
  12. Hi, I have just released the final version of my latest game RymdspeletHD, (that's Swedish for "The Space Game HD"). It's your standard asteroids-like space shooter with a few nice features such as an online highscore and an upgrade system that let's you upgrade your ship between levels. The game is written in C++ with [url=""]HGE[/url]. I have been working on it for about 12 months but the total amount of time spent is probably closer to 60 hours, not including the previous incarnations of the game. It is made for Windows but it may work on Linux through wine. [url=""]It can be downloaded here.[/url] [url=""][/url] I have embedded a video showcasing some gameplay, or you can watch it in [url=""]hd here[/url]. [media][/media]
  13. RymdspeletHD