Jump to content
  • Advertisement

2470765

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

776 Good

About 2470765

  • Rank
    Newbie
  1. 2470765

    glMapBufferRange problem

    I'm not using beta drivers, I'm using the integrated gpu of my intel cpu (intel hd 4000), from what I've heard intel don't have good opengl drivers so maybe it could be the problem, I'll try to test it in another machine. Thanks for your help.
  2. 2470765

    glMapBufferRange problem

      yes, there is no error       well, technically it's a different block of memory since I'm orphaning using GL_MAP_INVALIDATE_BUFFER_BIT so I don't know why it doesn't work.   I tried your solution and it worked but what if I have 200 objects for example, Will it still be a good solution? GLint uniformBufferAlignSize = 0; glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uniformBufferAlignSize); mUbPerObjectSize = sizeof(UbPerObject); mUbPerObjectSize += uniformBufferAlignSize - (mUbPerObjectSize % uniformBufferAlignSize); glGenBuffers(1, &mPerObjectUbo); glBindBuffer(GL_UNIFORM_BUFFER, mPerObjectUbo); glBufferData(GL_UNIFORM_BUFFER, 2 * mUbPerObjectSize, nullptr, GL_STREAM_DRAW); glBindBuffer(GL_UNIFORM_BUFFER, 0); ---------------------------------------------------------------------------------------------------------------------------- // Draw the Land. glBindBuffer(GL_UNIFORM_BUFFER, mPerObjectUbo); glBindBufferRange(GL_UNIFORM_BUFFER, 1, mPerObjectUbo, 0 * mUbPerObjectSize, sizeof(UbPerObject)); pData = glMapBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(UbPerObject), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); //set data glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, 0); glBindVertexArray(mLandVao); glDrawElements(GL_TRIANGLES, mGridIndexCount, GL_UNSIGNED_INT, nullptr); // Draw the Waves. glBindBuffer(GL_UNIFORM_BUFFER, mPerObjectUbo); glBindBufferRange(GL_UNIFORM_BUFFER, 1, mPerObjectUbo, 1 * mUbPerObjectSize, sizeof(UbPerObject)); pData = glMapBufferRange(GL_UNIFORM_BUFFER, mUbPerObjectSize, sizeof(UbPerObject), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); // set data glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, 0); Furthermore, here I'm using GL_MAP_INVALIDATE_BUFFER_BIT too which discard the entire buffer so it's almost the same but this actually work
  3. hi, I'm having a problem mapping a uniform buffer (mPerObjectUbo) in my scene two times per frame. When I update it for the second time it doesn't take effect. I have found a partial fix using glFlush but it causes synchronization. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glm::mat4 projMatrix = mCam.GetProjMatrix(); glm::mat4 viewMatrix = mCam.GetViewMatrix(); // Update PerFrame UBO glBindBuffer(GL_UNIFORM_BUFFER, mPerFrameUbo); void * pData = glMapBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(UbPerFrame), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); reinterpret_cast<UbPerFrame*>(pData)->gProjection = projMatrix; reinterpret_cast<UbPerFrame*>(pData)->gDirLight = mDirLight; reinterpret_cast<UbPerFrame*>(pData)->gPointLight = mPointLight; reinterpret_cast<UbPerFrame*>(pData)->gSpotLight = mSpotLight; glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, 0); glUseProgram(mShader.GetProgram()); // Draw the Land. glBindBuffer(GL_UNIFORM_BUFFER, mPerObjectUbo); pData = glMapBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(UbPerObject), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); reinterpret_cast<UbPerObject*>(pData)->gModelView = viewMatrix; reinterpret_cast<UbPerObject*>(pData)->gModelViewInvTranspose = glm::inverseTranspose(viewMatrix); reinterpret_cast<UbPerObject*>(pData)->gMaterial = mLandMat; glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, 0); glBindVertexArray(mLandVao); glDrawElements(GL_TRIANGLES, mGridIndexCount, GL_UNSIGNED_INT, nullptr); //glFlush(); partial fix but it causes synchronization // Draw the Waves. glBindBuffer(GL_UNIFORM_BUFFER, mPerObjectUbo); pData = glMapBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(UbPerObject), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); // Does not take effect without glflush reinterpret_cast<UbPerObject*>(pData)->gModelView = viewMatrix*mWavesWorld; reinterpret_cast<UbPerObject*>(pData)->gModelViewInvTranspose = glm::inverseTranspose(viewMatrix*mWavesWorld); reinterpret_cast<UbPerObject*>(pData)->gMaterial = mWavesMat; glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, 0); glBindVertexArray(mWavesVao); glDrawElements(GL_TRIANGLES, 3 * mWaves.TriangleCount(), GL_UNSIGNED_INT, nullptr); glBindVertexArray(0); glUseProgram(0); without glflush:     with glflush:       Any suggestions will be appreciated, thanks.
  4. Hi all I'm learning OpenGL and I'm trying to write a shader for light attenuation and it's working ok except for a small problem as you can see in the image I'm getting circular strips       Here is my fragment shader: #version 400 smooth in vec4 diffuseColor; smooth in vec3 normal; smooth in vec4 cameraSpacePosition; out vec4 outputColor; uniform vec3 pointLightCamPos; uniform vec4 lightIntensity; uniform vec4 ambientIntensity; uniform float lightAttenuation; uniform bool bUseRSquare; vec4 ApplyLightIntensity(in vec3 cameraSpacePos, out vec3 lightDirection) { vec3 lightDifference = pointLightCamPos - cameraSpacePos; float lightDistanceSqr = dot(lightDifference, lightDifference); lightDirection = lightDifference * inversesqrt(lightDistanceSqr); float distFactor = bUseRSquare ? lightDistanceSqr : sqrt(lightDistanceSqr); return lightIntensity * (1 / ( 1.0 + lightAttenuation * distFactor)); } void main() { vec3 lightDir = vec3(0.0); vec4 attenIntensity = ApplyLightIntensity(vec3(cameraSpacePosition), lightDir); float cosAngIncidence = max(dot(normalize(normal), lightDir), 0); outputColor = (diffuseColor * ambientIntensity) + (diffuseColor * attenIntensity * cosAngIncidence); } Is this a normal behavior? or How I can fix it?
  5. Hi all I have a question about the constructor of the Bitmap class: Bitmap.Bitmap (HBITMAP, HPALETTE) The part of the code is as follows HBITMAP hBmp = LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BITMAP1)); ..... HDC hdc; PAINTSTRUCT ps; hdc = BeginPaint(hWnd, &ps); Graphics graphics(hdc); Bitmap bitmap(hBmp, ¿....?); graphics.DrawImage(&bitmap, 0, 400,bitmap.GetWidth(),bitmap.GetHeight()); EndPaint(hWnd, &ps); My question is What should I put as the second parameter of Bitmap constructor? I have tried with (HPALETTE)GetSockObject(DEFAULT_PALETTE); and (HPALETTE)GetCurrentObject(hdc,OBJ_PAL); but it doesn't work I know this is a beginner question but I would be grateful for your help
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!