Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualBornToCode

Posted 03 September 2013 - 11:28 PM

Forget it. I solved the problem. One of the difference between DX11 and GL that i notice is that if you set an Scissor in DX it does not get affected by clearing the buffer. But in GL when you clear any buffer if the scissor is on. It will not clear anything outside the box.


#6BornToCode

Posted 03 September 2013 - 11:25 PM

Forget it. I solved the problem.


#5BornToCode

Posted 03 September 2013 - 11:23 PM

Forget it. I just did an test in DirectX11 and i am getting the same results. It would be interesting to see some example code or how setting multiple viewport at once should be set up.


#4BornToCode

Posted 03 September 2013 - 11:22 PM

Forget it. I just did an test in DirectX11 and i am getting the same results.


#3BornToCode

Posted 03 September 2013 - 10:49 PM

Please post the traditional complete code example; the order of OpenGL calls and their parameters are important, as are the missing calls.

HRESULT OpenGLDeviceContext::RSSetScissorRects(__in UINT NumRects,__in const BEAST_RECT* pRects)
{
  GLint maxViewports = 0;
  glGetIntegerv(GL_MAX_VIEWPORTS,&maxViewports);

  OpenGLDevice* glDevice = device_->StaticCast<OpenGLDevice*>();
  if((int)NumRects >= maxViewports)
  {
    if(glDevice->flag_ & BEAST_FLAG_DEBUG)
    {
      DEBUG_PRINT(__FUNCTION__,"Exceed the number of scissor rects.\n");
    }
    return E_INVALIDARG;    
  }
  const UINT viewports = NumRects*4;
  GLint rectValues[4] = {0,0,0,0};
  int index = 0;  
  for(UINT viewportIndex=0;viewportIndex<NumRects;viewportIndex++)
  {
    const BEAST_RECT* currentRect = &pRects[viewportIndex];
    rectValues[index] = currentRect->left;
    rectValues[index+1] = currentRect->bottom;
    rectValues[index+2] = currentRect->right-currentRect->left;
    rectValues[index+3] = currentRect->top-currentRect->bottom;
    glScissorIndexedv(viewportIndex,rectValues);
  }
  return S_OK;
}

 

HRESULT OpenGLDeviceContext::RSSetViewports(__in UINT NumViewports,__in const BEAST_VIEWPORT* pViewports)
{
  GLint maxViewports = 0;
  glGetIntegerv(GL_MAX_VIEWPORTS,&maxViewports);
  OpenGLDevice* glDevice = device_->StaticCast<OpenGLDevice*>();
  if((int)NumViewports >= maxViewports)
  {
    if(glDevice->flag_ & BEAST_FLAG_DEBUG)
    {
      DEBUG_PRINT(__FUNCTION__,"Exceed the number of viewports.\n");
    }
    return E_INVALIDARG;    
  }
  const UINT viewports = NumViewports*4;
  GLfloat viewportValues[4] = {0,0,0,0};
  int index = 0;
  for(UINT viewportIndex=0;viewportIndex<NumViewports;viewportIndex++)
  {
    const BEAST_VIEWPORT* currentViewport = &pViewports[viewportIndex];
    viewportValues[index] = currentViewport->BottomLeftX;
    viewportValues[index+1] = currentViewport->BottomLeftY;
    viewportValues[index+2] = currentViewport->Width;
    viewportValues[index+3] = currentViewport->Height;
    glViewportIndexedfv(viewportIndex,viewportValues);
  }
 
  return S_OK;
}

i also have scissor test enable. You mention missing calls. This is not rocket scientist, i mean. All i need to set is the viewportindex/scissor index is there any other state i need to set in order for this to work.


#2BornToCode

Posted 03 September 2013 - 10:47 PM

Please post the traditional complete code example; the order of OpenGL calls and their parameters are important, as are the missing calls.

HRESULT OpenGLDeviceContext::RSSetScissorRects(__in UINT NumRects,__in const BEAST_RECT* pRects)
{
  GLint maxViewports = 0;
  glGetIntegerv(GL_MAX_VIEWPORTS,&maxViewports);

  OpenGLDevice* glDevice = device_->StaticCast<OpenGLDevice*>();
  if((int)NumRects >= maxViewports)
  {
    if(glDevice->flag_ & BEAST_FLAG_DEBUG)
    {
      DEBUG_PRINT(__FUNCTION__,"Exceed the number of scissor rects.\n");
    }
    return E_INVALIDARG;    
  }
  const UINT viewports = NumRects*4;
  GLint rectValues[4] = {0,0,0,0};
  int index = 0;  
  for(UINT viewportIndex=0;viewportIndex<NumRects;viewportIndex++)
  {
    const BEAST_RECT* currentRect = &pRects[viewportIndex];
    rectValues[index] = currentRect->left;
    rectValues[index+1] = currentRect->bottom;
    rectValues[index+2] = currentRect->right-currentRect->left;
    rectValues[index+3] = currentRect->top-currentRect->bottom;
    glScissorIndexedv(viewportIndex,rectValues);
  }
  return S_OK;
}

 

HRESULT OpenGLDeviceContext::RSSetViewports(__in UINT NumViewports,__in const BEAST_VIEWPORT* pViewports)
{
  GLint maxViewports = 0;
  glGetIntegerv(GL_MAX_VIEWPORTS,&maxViewports);
  OpenGLDevice* glDevice = device_->StaticCast<OpenGLDevice*>();
  if((int)NumViewports >= maxViewports)
  {
    if(glDevice->flag_ & BEAST_FLAG_DEBUG)
    {
      DEBUG_PRINT(__FUNCTION__,"Exceed the number of viewports.\n");
    }
    return E_INVALIDARG;    
  }
  const UINT viewports = NumViewports*4;
  GLfloat viewportValues[4] = {0,0,0,0};
  int index = 0;
  for(UINT viewportIndex=0;viewportIndex<NumViewports;viewportIndex++)
  {
    const BEAST_VIEWPORT* currentViewport = &pViewports[viewportIndex];
    viewportValues[index] = currentViewport->BottomLeftX;
    viewportValues[index+1] = currentViewport->BottomLeftY;
    viewportValues[index+2] = currentViewport->Width;
    viewportValues[index+3] = currentViewport->Height;
    glViewportIndexedfv(viewportIndex,viewportValues);
  }
 
  return S_OK;
}

i also have scissor test enable.


PARTNERS