There must still be something wrong with my coordinates…Again here is my Init code:
void OGL_Renderer_3_2::initGL(){
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
glViewport(0, 0, width(), height());
// Spit out system graphics information.
cout << " - OpenGL System Info -" << endl;
driverName((char*)glGetString(GL_RENDERER));
cout << " Vendor: " << glGetString(GL_VENDOR) << endl;
cout << " Renderer: " << driverName() << endl;
cout << " Driver Version: " << glGetString(GL_VERSION) << endl;
cout << " GLSL Version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl;
// if(!checkExtensions())
// throw Exception(0, "Graphics Requirements Not Met", "Your graphics driver does not meet the minimum requirements.");
glGenVertexArrays(1, &mVertexArray);
getError();
glBindVertexArray(mVertexArray);
getError();
glGenBuffers(1, &mVertexBufferObject);
getError();
glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferObject);
getError();
glBufferData(GL_ARRAY_BUFFER, 4 * 6 * sizeof(GLfloat), DEFAULT_VERTEX_COORDS, GL_DYNAMIC_DRAW);
getError();
glGenBuffers(1, &mTextureBufferObject);
getError();
glBindBuffer(GL_ARRAY_BUFFER, mTextureBufferObject);
getError();
glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(DEFAULT_TEXTURE_COORDS), DEFAULT_TEXTURE_COORDS, GL_STATIC_DRAW);
getError();
glEnableVertexAttribArray(0);
getError();
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
getError();
}
void OGL_Renderer_3_2::initVideo(unsigned int resX, unsigned int resY, unsigned int bpp, bool fullscreen, bool vsync)
{
// Initialize SDL's Video Subsystems.
if(SDL_Init(SDL_INIT_VIDEO) < 0)
throw Exception(701, "Error starting SDL Video Library", SDL_GetError());
// Setup OpenGL parameters
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); /// odo Add checks to determine an appropriate depth buffer.
if(vsync)
SDL_GL_SetSwapInterval(1);
// Anti-aliasing... need to test this.
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
Uint32 sdlFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
if(fullscreen)
sdlFlags = sdlFlags | SDL_WINDOW_FULLSCREEN;
mWindow = SDL_CreateWindow(title().c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, resX, resY, sdlFlags);
if(!mWindow)
{
cout << "EXCEPTION: Could not create a Window: " << SDL_GetError() << endl;
throw Exception(0, "Window Creation Failed", "Unable to create a window.");
}
_window = mWindow;
mContext = SDL_GL_CreateContext(mWindow);
if(!mContext)
{
cout << "EXCEPTION: Could not create an OpenGL Context: " << SDL_GetError() << endl;
throw Exception(0, "Can't create OGL Context", "Unable to create an OpenGL Context.
" + string(SDL_GetError()));
}
void* ptr = SDL_GL_GetProcAddress("glDrawArrays");
SDL_ShowCursor(false);
buildDisplayModeList();
initGL();
mShaderManager = new ShaderManager();
int w, h;
SDL_GetWindowSize(mWindow, &w, &h);
projection = glm::ortho(0.0f, static_cast<float>(w), static_cast<float>(h), 0.0f);
view = glm::lookAt(
glm::vec3(0,0,-1), // Camera is at (0,0,5), in World Space
glm::vec3(0,0,0), // and looks at the origin
glm::vec3(0,-1,0) // Head is up (set to 0,-1,0 to look upside-down)
);
model = glm::mat4(1.0f);
ModelViewMatrix = projection * view * model;
}
This is the image I get when I don’t clear the screen and tell the VertShader not to use my MVP uniform:
[ATTACH=CONFIG]379[/ATTACH]
If I use the MVP uniform still without clearing the screen I get:
[ATTACH=CONFIG]380[/ATTACH]
if I don’t multiply the view and model from INIT and just send the projection, again without clearing the screen I get:
[ATTACH=CONFIG]381[/ATTACH]
*Note the above image has a background image command commented out so I can see the rest of the calls to draw other things.
And if I add in a clear screen command at the start of an update, the screen just doesn’t seem to have anything on it.