Skip to content
Snippets Groups Projects
Commit fac69f15 authored by Stuart Layton's avatar Stuart Layton
Browse files

fixed mipmap generation bug for OSX. Previous versions of OpenGl wanted you to...

fixed mipmap generation bug for OSX. Previous versions of OpenGl wanted you to hint to generate mipmaps, OSX wants you to explicity call the function that generates them.
parent 5f68f7e9
No related branches found
No related tags found
No related merge requests found
......@@ -51,8 +51,8 @@ void SpikeDisplayCanvas::initializeSpikePlots(){
std::cout<<"Initializing Plots"<<std::endl;
int nPlots = 6;
int nCols = 2;
int nPlots = 4;
int nCols = 4;
int totalWidth = getWidth();
......
......@@ -103,6 +103,8 @@ void ProjectionAxes::plot(){
plot();
return;
}
// else
// std::cout<<"All is good no errors detected"<<std::endl;
}
void ProjectionAxes::plotOldSpikes(bool allSpikes){
......@@ -194,15 +196,17 @@ void ProjectionAxes::createTexture(){
texWidth = BaseUIElement::width;
texHeight = BaseUIElement::height;
std::cout<<"Creating a new texture of size:"<<texWidth<<"x"<<texHeight<<std::endl;
std::cout<<"Creating a new texture of size:"<<texWidth<<"x"<<texHeight;//<<std::endl;
// Delete the old texture
glDeleteTextures(1, &textureId);
// Generate a new texture
glGenTextures(1, &textureId);
std::cout<<" textureId:"<<textureId<<std::endl;
// Bind the texture, and set the appropriate parameters
glBindTexture(GL_TEXTURE_2D, textureId);
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glGenerateMipmap(GL_TEXTURE_2D);
// generate a new FrameBufferObject
createFBO();
......@@ -212,7 +216,7 @@ void ProjectionAxes::createTexture(){
}
void ProjectionAxes::createFBO(){
std::cout<<"Creating a new frame buffer object"<<std::endl;
std::cout<<"Creating a new frame buffer object";//<<std::endl;
// if (!isTextureValid)
// createTexture();
......@@ -227,20 +231,25 @@ void ProjectionAxes::createFBO(){
// Generate and bind the new Render Buffer
glGenRenderbuffersEXT(1, &rboId);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rboId);
std::cout<<" fboID:"<<fboId<<" rboID:"<<rboId<<std::endl;
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, texWidth, texHeight);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
// Attach the texture to the framebuffer
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, textureId, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboId);
// If the FrameBuffer wasn't created then we have a bigger problem. Abort the program.
if(!checkFramebufferStatus()){
std::cout<<"FrameBufferObject not created! Are you running the newest version of OpenGL?"<<std::endl;
std::cout<<"FrameBufferObjects are REQUIRED! Quitting!"<<std::endl;
exit(1);
}
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment