• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By tj8146
      I am using immediate mode for OpenGL and I am creating a 2D top down car game. I am trying to configure my game loop in order to get my car-like physics working on a square shape. I have working code but it is not doing as I want it to. I am not sure as to whether it is my game loop that is incorrect or my code for the square is incorrect, or maybe both! Could someone help because I have been trying to work this out for over a day now
      I have attached my .cpp file if you wish to run it for yourself.. 
      WinMain code:
      /******************* WIN32 FUNCTIONS ***************************/ int WINAPI WinMain( HINSTANCE hInstance, // Instance HINSTANCE hPrevInstance, // Previous Instance LPSTR lpCmdLine, // Command Line Parameters int nCmdShow) // Window Show State { MSG msg; // Windows Message Structure bool done=false; // Bool Variable To Exit Loop Car car; car.x = 220; car.y = 140; car.dx = 0; car.dy = 0; car.ang = 0; AllocConsole(); FILE *stream; freopen_s(&stream, "CONOUT$", "w", stdout); // Create Our OpenGL Window if (!CreateGLWindow("OpenGL Win32 Example",screenWidth,screenHeight)) { return 0; // Quit If Window Was Not Created } while(!done) // Loop That Runs While done=FALSE { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting? { if (msg.message==WM_QUIT) // Have We Received A Quit Message? { done=true; // If So done=TRUE break; } else // If Not, Deal With Window Messages { TranslateMessage(&msg); // Translate The Message DispatchMessage(&msg); // Dispatch The Message } } else // If There Are No Messages { if(keys[VK_ESCAPE]) done = true; void processKeys(Car& car); //process keyboard while (game_is_running) { loops = 0; while (GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP) { update(car); // update variables next_game_tick += SKIP_TICKS; loops++; } display(car); // Draw The Scene SwapBuffers(hDC); // Swap Buffers (Double Buffering) } } } // Shutdown KillGLWindow(); // Kill The Window return (int)(msg.wParam); // Exit The Program } //WIN32 Processes function - useful for responding to user inputs or other events. LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window UINT uMsg, // Message For This Window WPARAM wParam, // Additional Message Information LPARAM lParam) // Additional Message Information { switch (uMsg) // Check For Windows Messages { case WM_CLOSE: // Did We Receive A Close Message? { PostQuitMessage(0); // Send A Quit Message return 0; // Jump Back } break; case WM_SIZE: // Resize The OpenGL Window { reshape(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height return 0; // Jump Back } break; case WM_LBUTTONDOWN: { mouse_x = LOWORD(lParam); mouse_y = screenHeight - HIWORD(lParam); LeftPressed = true; } break; case WM_LBUTTONUP: { LeftPressed = false; } break; case WM_MOUSEMOVE: { mouse_x = LOWORD(lParam); mouse_y = screenHeight - HIWORD(lParam); } break; case WM_KEYDOWN: // Is A Key Being Held Down? { keys[wParam] = true; // If So, Mark It As TRUE return 0; // Jump Back } break; case WM_KEYUP: // Has A Key Been Released? { keys[wParam] = false; // If So, Mark It As FALSE return 0; // Jump Back } break; } // Pass All Unhandled Messages To DefWindowProc return DefWindowProc(hWnd,uMsg,wParam,lParam); }  
      C++ and OpenGL code:
      int mouse_x=0, mouse_y=0; bool LeftPressed = false; int screenWidth=1080, screenHeight=960; bool keys[256]; float radiansFromDegrees(float deg) { return deg * (M_PI / 180.0f); } float degreesFromRadians(float rad) { return rad / (M_PI / 180.0f); } bool game_is_running = true; const int TICKS_PER_SECOND = 50; const int SKIP_TICKS = 1000 / TICKS_PER_SECOND; const int MAX_FRAMESKIP = 10; DWORD next_game_tick = GetTickCount(); int loops; typedef struct { float x, y; float dx, dy; float ang; }Car; //OPENGL FUNCTION PROTOTYPES void display(const Car& car); //called in winmain to draw everything to the screen void reshape(int width, int height); //called when the window is resized void init(); //called in winmain when the program starts. void processKeys(Car& car); //called in winmain to process keyboard input void update(Car& car); //called in winmain to update variables /************* START OF OPENGL FUNCTIONS ****************/ void display(const Car& car) { const float w = 50.0f; const float h = 50.0f; glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glTranslatef(100, 100, 0); glBegin(GL_POLYGON); glVertex2f(car.x, car.y); glVertex2f(car.x + w, car.y); glVertex2f(car.x + w, car.y + h); glVertex2f(car.x, car.y + h); glEnd(); glFlush(); } void reshape(int width, int height) // Resize the OpenGL window { screenWidth = width; screenHeight = height; // to ensure the mouse coordinates match // we will use these values to set the coordinate system glViewport(0, 0, width, height); // Reset the current viewport glMatrixMode(GL_PROJECTION); // select the projection matrix stack glLoadIdentity(); // reset the top of the projection matrix to an identity matrix gluOrtho2D(0, screenWidth, 0, screenHeight); // set the coordinate system for the window glMatrixMode(GL_MODELVIEW); // Select the modelview matrix stack glLoadIdentity(); // Reset the top of the modelview matrix to an identity matrix } void init() { glClearColor(1.0, 1.0, 0.0, 0.0); //sets the clear colour to yellow //glClear(GL_COLOR_BUFFER_BIT) in the display function //will clear the buffer to this colour. } void processKeys(Car& car) { if (keys[VK_UP]) { float cdx = sinf(radiansFromDegrees(car.ang)); float cdy = -cosf(radiansFromDegrees(car.ang)); car.dx += cdx; car.dy += cdy; } if (keys[VK_DOWN]) { float cdx = sinf(radiansFromDegrees(car.ang)); float cdy = -cosf(radiansFromDegrees(car.ang)); car.dx += -cdx; car.dy += -cdy; } if (keys[VK_LEFT]) { car.ang -= 2; } if (keys[VK_RIGHT]) { car.ang += 2; } } void update(Car& car) { car.x += car.dx*next_game_tick; }  
      game.cpp
    • By tj8146
      I am using immediate mode for OpenGL and I am creating a 2D top down car game. I am trying to configure my game loop in order to get my car-like physics working on a square shape. I have working code but it is not doing as I want it to. I am not sure as to whether it is my game loop that is incorrect or my code for the square is incorrect, or maybe both! Could someone help because I have been trying to work this out for over a day now
      I have attached my .cpp file if you wish to run it for yourself.. 
       
      This is my C++ and OpenGL code:
      int mouse_x=0, mouse_y=0; bool LeftPressed = false; int screenWidth=1080, screenHeight=960; bool keys[256]; float radiansFromDegrees(float deg) { return deg * (M_PI / 180.0f); } float degreesFromRadians(float rad) { return rad / (M_PI / 180.0f); } bool game_is_running = true; const int TICKS_PER_SECOND = 50; const int SKIP_TICKS = 1000 / TICKS_PER_SECOND; const int MAX_FRAMESKIP = 10; DWORD next_game_tick = GetTickCount(); int loops; typedef struct { float x, y; float dx, dy; float ang; }Car; //OPENGL FUNCTION PROTOTYPES void display(const Car& car); //called in winmain to draw everything to the screen void reshape(int width, int height); //called when the window is resized void init(); //called in winmain when the program starts. void processKeys(Car& car); //called in winmain to process keyboard input void update(Car& car); //called in winmain to update variables /************* START OF OPENGL FUNCTIONS ****************/ void display(const Car& car) { const float w = 50.0f; const float h = 50.0f; glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glTranslatef(100, 100, 0); glBegin(GL_POLYGON); glVertex2f(car.x, car.y); glVertex2f(car.x + w, car.y); glVertex2f(car.x + w, car.y + h); glVertex2f(car.x, car.y + h); glEnd(); glFlush(); } void reshape(int width, int height) // Resize the OpenGL window { screenWidth = width; screenHeight = height; // to ensure the mouse coordinates match // we will use these values to set the coordinate system glViewport(0, 0, width, height); // Reset the current viewport glMatrixMode(GL_PROJECTION); // select the projection matrix stack glLoadIdentity(); // reset the top of the projection matrix to an identity matrix gluOrtho2D(0, screenWidth, 0, screenHeight); // set the coordinate system for the window glMatrixMode(GL_MODELVIEW); // Select the modelview matrix stack glLoadIdentity(); // Reset the top of the modelview matrix to an identity matrix } void init() { glClearColor(1.0, 1.0, 0.0, 0.0); //sets the clear colour to yellow //glClear(GL_COLOR_BUFFER_BIT) in the display function //will clear the buffer to this colour. } void processKeys(Car& car) { if (keys[VK_UP]) { float cdx = sinf(radiansFromDegrees(car.ang)); float cdy = -cosf(radiansFromDegrees(car.ang)); car.dx += cdx; car.dy += cdy; } if (keys[VK_DOWN]) { float cdx = sinf(radiansFromDegrees(car.ang)); float cdy = -cosf(radiansFromDegrees(car.ang)); car.dx += -cdx; car.dy += -cdy; } if (keys[VK_LEFT]) { car.ang -= 2; } if (keys[VK_RIGHT]) { car.ang += 2; } } void update(Car& car) { car.x += car.dx*next_game_tick; } My WinMain code:
      /******************* WIN32 FUNCTIONS ***************************/ int WINAPI WinMain( HINSTANCE hInstance, // Instance HINSTANCE hPrevInstance, // Previous Instance LPSTR lpCmdLine, // Command Line Parameters int nCmdShow) // Window Show State { MSG msg; // Windows Message Structure bool done=false; // Bool Variable To Exit Loop Car car; car.x = 220; car.y = 140; car.dx = 0; car.dy = 0; car.ang = 0; AllocConsole(); FILE *stream; freopen_s(&stream, "CONOUT$", "w", stdout); // Create Our OpenGL Window if (!CreateGLWindow("OpenGL Win32 Example",screenWidth,screenHeight)) { return 0; // Quit If Window Was Not Created } while(!done) // Loop That Runs While done=FALSE { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting? { if (msg.message==WM_QUIT) // Have We Received A Quit Message? { done=true; // If So done=TRUE break; } else // If Not, Deal With Window Messages { TranslateMessage(&msg); // Translate The Message DispatchMessage(&msg); // Dispatch The Message } } else // If There Are No Messages { if(keys[VK_ESCAPE]) done = true; void processKeys(Car& car); //process keyboard while (game_is_running) { loops = 0; while (GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP) { update(car); // update variables next_game_tick += SKIP_TICKS; loops++; } display(car); // Draw The Scene SwapBuffers(hDC); // Swap Buffers (Double Buffering) } } } // Shutdown KillGLWindow(); // Kill The Window return (int)(msg.wParam); // Exit The Program } //WIN32 Processes function - useful for responding to user inputs or other events. LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window UINT uMsg, // Message For This Window WPARAM wParam, // Additional Message Information LPARAM lParam) // Additional Message Information { switch (uMsg) // Check For Windows Messages { case WM_CLOSE: // Did We Receive A Close Message? { PostQuitMessage(0); // Send A Quit Message return 0; // Jump Back } break; case WM_SIZE: // Resize The OpenGL Window { reshape(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height return 0; // Jump Back } break; case WM_LBUTTONDOWN: { mouse_x = LOWORD(lParam); mouse_y = screenHeight - HIWORD(lParam); LeftPressed = true; } break; case WM_LBUTTONUP: { LeftPressed = false; } break; case WM_MOUSEMOVE: { mouse_x = LOWORD(lParam); mouse_y = screenHeight - HIWORD(lParam); } break; case WM_KEYDOWN: // Is A Key Being Held Down? { keys[wParam] = true; // If So, Mark It As TRUE return 0; // Jump Back } break; case WM_KEYUP: // Has A Key Been Released? { keys[wParam] = false; // If So, Mark It As FALSE return 0; // Jump Back } break; } // Pass All Unhandled Messages To DefWindowProc return DefWindowProc(hWnd,uMsg,wParam,lParam); }  
      game.cpp
    • By lxjk
      Hi guys,
      There are many ways to do light culling in tile-based shading. I've been playing with this idea for a while, and just want to throw it out there.
      Because tile frustums are general small compared to light radius, I tried using cone test to reduce false positives introduced by commonly used sphere-frustum test.
      On top of that, I use distance to camera rather than depth for near/far test (aka. sliced by spheres).
      This method can be naturally extended to clustered light culling as well.
      The following image shows the general ideas

       
      Performance-wise I get around 15% improvement over sphere-frustum test. You can also see how a single light performs as the following: from left to right (1) standard rendering of a point light; then tiles passed the test of (2) sphere-frustum test; (3) cone test; (4) spherical-sliced cone test
       

       
      I put the details in my blog post (https://lxjk.github.io/2018/03/25/Improve-Tile-based-Light-Culling-with-Spherical-sliced-Cone.html), GLSL source code included!
       
      Eric
    • By Fadey Duh
      Good evening everyone!

      I was wondering if there is something equivalent of  GL_NV_blend_equation_advanced for AMD?
      Basically I'm trying to find more compatible version of it.

      Thank you!
    • By Jens Eckervogt
      Hello guys, 
       
      Please tell me! 
      How do I know? Why does wavefront not show for me?
      I already checked I have non errors yet.
      using OpenTK; using System.Collections.Generic; using System.IO; using System.Text; namespace Tutorial_08.net.sourceskyboxer { public class WaveFrontLoader { private static List<Vector3> inPositions; private static List<Vector2> inTexcoords; private static List<Vector3> inNormals; private static List<float> positions; private static List<float> texcoords; private static List<int> indices; public static RawModel LoadObjModel(string filename, Loader loader) { inPositions = new List<Vector3>(); inTexcoords = new List<Vector2>(); inNormals = new List<Vector3>(); positions = new List<float>(); texcoords = new List<float>(); indices = new List<int>(); int nextIdx = 0; using (var reader = new StreamReader(File.Open("Contents/" + filename + ".obj", FileMode.Open), Encoding.UTF8)) { string line = reader.ReadLine(); int i = reader.Read(); while (true) { string[] currentLine = line.Split(); if (currentLine[0] == "v") { Vector3 pos = new Vector3(float.Parse(currentLine[1]), float.Parse(currentLine[2]), float.Parse(currentLine[3])); inPositions.Add(pos); if (currentLine[1] == "t") { Vector2 tex = new Vector2(float.Parse(currentLine[1]), float.Parse(currentLine[2])); inTexcoords.Add(tex); } if (currentLine[1] == "n") { Vector3 nom = new Vector3(float.Parse(currentLine[1]), float.Parse(currentLine[2]), float.Parse(currentLine[3])); inNormals.Add(nom); } } if (currentLine[0] == "f") { Vector3 pos = inPositions[0]; positions.Add(pos.X); positions.Add(pos.Y); positions.Add(pos.Z); Vector2 tc = inTexcoords[0]; texcoords.Add(tc.X); texcoords.Add(tc.Y); indices.Add(nextIdx); ++nextIdx; } reader.Close(); return loader.loadToVAO(positions.ToArray(), texcoords.ToArray(), indices.ToArray()); } } } } } And It have tried other method but it can't show for me.  I am mad now. Because any OpenTK developers won't help me.
      Please help me how do I fix.

      And my download (mega.nz) should it is original but I tried no success...
      - Add blend source and png file here I have tried tried,.....  
       
      PS: Why is our community not active? I wait very longer. Stop to lie me!
      Thanks !
  • Advertisement
  • Advertisement
Sign in to follow this  

OpenGL Cross Platform FBO depth buffer issue

This topic is 4270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, As an experiment i'm trying to write a simple deferred shader in lwjgl. Everyhting was going quite well untill I decided to make an attempt at early z-culling. The results worked perfically well on windows, but not on osx (ignore the normal's channel as it's not finished yet): normals | colour ----------------- depth | blank Windows: windows split Apple: apple split I do 2 passes at present to split my scene. The first one renders the depth component, the second renders the color and the normal. To avoid having to use PBuffers and hackery associated with the NV render to depth texture functing I decided on FBO's as I can create a depth texture and just bind that to the screen for my lighting passes. As can be seen from the pictures something is not quite right in the apple rendering. If anyone can offer me any advice I would be very happy to listen. Now some code: Setting up the FBO:
    IntBuffer intBuffer = BufferUtils.createIntBuffer( 1 );
    EXTFramebufferObject.glGenFramebuffersEXT( intBuffer );
    myFBOId = intBuffer.get();

    EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId );

    EXTFramebufferObject.glFramebufferTexture2DEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, 
textureType, getTextureID( "fbo0" ), 0 );

    int textureID = TextureLoader.createTextureID();
    t = new Texture( textureID, width, height, textureType );

    GL11.glBindTexture( textureType, textureID );
    GL11.glTexParameteri( textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR );
    GL11.glTexParameteri( textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR );

    GL11.glTexImage2D( textureType, 0, GL14.GL_DEPTH_COMPONENT24, width, 
height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer)null );

    EXTFramebufferObject.glFramebufferTexture2DEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 
EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, textureType, textureID, 0 );

    fboErrorCheck();
    EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0 );




This is quite standard I do believe, with a 24 bit depth component. Rendering the depth pass:
    fbo1.activate();

    GL11.glViewport( 0, 0, width, height );
    GL11.glMatrixMode( GL11.GL_PROJECTION );
    GL11.glLoadIdentity();
    GLU.gluPerspective( 45.0f, aspectRatio, 1.0f, 7000.0f );
    GL11.glMatrixMode( GL11.GL_MODELVIEW );
    GL11.glLoadIdentity();

    // OpenGL render states configuration
    GL11.glCullFace( GL11.GL_BACK );
    GL11.glEnable( GL11.GL_CULL_FACE );
    GL11.glDisable( GL11.GL_BLEND );
    GL11.glDepthFunc( GL11.GL_LEQUAL );
    GL11.glEnable( GL11.GL_DEPTH_TEST );
    GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
    GL11.glClearDepth( 1.0 );
    GL11.glColorMask( true, true, true, true );
    GL11.glDepthMask( true );
    GL11.glClear( GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT );

    GL11.glColorMask( false, false, false, false );
    GL11.glDepthMask( true );
    GL11.glDisable( GL11.GL_LIGHTING );

    GameManager.getGameManager().getCameraManager().getCamera( "main").lookAt();

    scene.draw();

    GL11.glColorMask( true, true, true, true );
    GL11.glDepthMask( false );
    fbo1.deactivate();




Render the colour / normals.
    fbo1.activate();
    deferredSplitShader.activate()
    IntBuffer temp = BufferUtils.createIntBuffer( 3 );
    temp.put( 0, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT );
    temp.put( 1, EXTFramebufferObject.GL_COLOR_ATTACHMENT1_EXT );
    temp.rewind();
    GL20.glDrawBuffers( temp );

    GL11.glPushAttrib( GL11.GL_VIEWPORT_BIT );
    GL11.glViewport( 0, 0, width, height );

    GL11.glLoadIdentity();

    GL11.glPushMatrix();

    //configure camera
    GameManager.getGameManager().getCameraManager().getCamera( "main").lookAt();

    scene.draw();

    GL11.glPopMatrix();
    GL11.glPopAttrib();
    fbo1.deactivate();

    deferredSplitShader.deactivate();




This code executes on both machines, the problem is that it just doesn't look right on the apple. Any help would be much apreciated.

Share this post


Link to post
Share on other sites
Advertisement
Further research has shown to me that if I turn down the depth texture size:

GL11.glTexImage2D( textureType, 0, GL14.GL_DEPTH_COMPONENT16, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer)null );

GL14.GL_DEPTH_COMPONENT16 instead of 24 the problem is not as pronounced (although it is still present).

So i'm pretty sure that this is a depth buffer issue, i just have no idea how to solve it.

Share this post


Link to post
Share on other sites
Are you using one FBO with two attachments or two FBOS with one attachment each? I would use one FBO with two attachments, or one attachment and one renderbuffer for the depth. I personally use a RB with my FBO for depth...

Share this post


Link to post
Share on other sites
I use one fbo. The fbo has 3 colour attachments and 1 depth attachment. As I am trying to render depth to a texture it is infeasable to use a renderbuffer as they cant be bound as textures.

Share this post


Link to post
Share on other sites
Quote:
Original post by stramit
I use one fbo. The fbo has 3 colour attachments and 1 depth attachment. As I am trying to render depth to a texture it is infeasable to use a renderbuffer as they cant be bound as textures.


Hmm I am using it...


//depth buffer setup code here
glGenRenderbuffersEXT(1, &depth_rb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthBufferBitDepth, texWidth, texHeight);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);
glGenTextures(1, &depthtexture);
glBindTexture(texture_target, depthtexture);



Share this post


Link to post
Share on other sites

glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);
glGenTextures(1, &depthtexture);
glBindTexture(texture_target, depthtexture);



What are you specifying as the texture_target in this example? I don't know what possible values could bind a texture to an active render buffer? I thought the point was that a renderbuffer was a buffer for when you didn't need it as a texture, and that a texture image should be used when specifying a buffer which you want to bind as a texture.

Share this post


Link to post
Share on other sites
Looks like z-fighting to me which is why changing your depth precision affects it. Not sure why it's occuring if you are rendering *exactly* the same geometry. Are you rendering *exactly* the same geometry? In your depth pass you look like you're using fixed func T&L whereas for the deferred you are (obviously) using programmed T&L. This may be causing the problem. In your vertex shader you must use ftransform() to make sure the transformed vertices match the fixed func vertices.

If that's not the problem I suggest you cheat and edge your objects slightly towards the camera in the same way you'd stop z-fighting when shadow mapping.

Share this post


Link to post
Share on other sites
Vertex shader for the colour pass (it unfortunately needs to be 2 passes on osx as the 1600xt mobility in the macbook bro does not support GL drawbuffers, so I do a normal pass after this one):

void main()
{
//Mandatory outputs
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
}



Frag shader:

uniform sampler2D diffuseTex;

void main()
{
gl_FragColor = vec4(texture2D(diffuseTex, gl_TexCoord[0].st).rgb, 0);
}



Quite standard if I do say so myself.

(and just a note, even though the CPU code posted above uses gldrawbuffers, the screenshots are both from the fallback path)


Thank you very much for the input coordz, I will be trying this asap.

It is a very frustrating issue, if I use a rendertarget instead of the depth texture there are no issues... it's just that I can't bind a rendertarget as a texture :(


Share this post


Link to post
Share on other sites
Quote:
Original post by stramit
*** Source Snippet Removed ***

What are you specifying as the texture_target in this example? I don't know what possible values could bind a texture to an active render buffer? I thought the point was that a renderbuffer was a buffer for when you didn't need it as a texture, and that a texture image should be used when specifying a buffer which you want to bind as a texture.


GL_TEXTURE_2D

Share this post


Link to post
Share on other sites
That doesn't make any sense though. You generate a texture ID then bind the texture to the current context for use as a texture and that is all. You havn't attached the texture at a target for the depthchannel of the renderbuffer.

I have no idea how the code you posted actually renders the depth channel to the texture. If there is something I don't undersand here then please enlighten me as I'd be very interested to know. (You also havn't even created room in memory for the texture, or given the texture a type using glTexImage2D).

Unless there is some automagical way that if you bind an empty texture when a RenderBuffer is active it creates the texture and automatically binds it to the currently active renderbuffer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement