void OpenGL::setupContext() { if (!contextInitialized) return; initMaxValues(); GLfloat glcolor[4] = {1.0f, 1.0f, 1.0f, 1.0f}; glVertexAttrib4fv(ATTRIB_COLOR, glcolor); glVertexAttrib4fv(ATTRIB_CONSTANTCOLOR, glcolor); GLint maxvertexattribs = 1; glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxvertexattribs); state.enabledAttribArrays = (uint32) ((1ull << uint32(maxvertexattribs)) - 1); useVertexAttribArrays(0); // Get the current viewport. glGetIntegerv(GL_VIEWPORT, (GLint *) &state.viewport.x); // And the current scissor - but we need to compensate for GL scissors // starting at the bottom left instead of top left. glGetIntegerv(GL_SCISSOR_BOX, (GLint *) &state.scissor.x); state.scissor.y = state.viewport.h - (state.scissor.y + state.scissor.h); if (GLAD_VERSION_1_0) glGetFloatv(GL_POINT_SIZE, &state.pointSize); else state.pointSize = 1.0f; if (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_sRGB || GLAD_EXT_framebuffer_sRGB || GLAD_EXT_sRGB_write_control) { state.framebufferSRGBEnabled = (glIsEnabled(GL_FRAMEBUFFER_SRGB) == GL_TRUE); } else state.framebufferSRGBEnabled = false; // Initialize multiple texture unit support for shaders. state.boundTextures.clear(); state.boundTextures.resize(maxTextureUnits, 0); for (int i = 0; i < (int) state.boundTextures.size(); i++) { glActiveTexture(GL_TEXTURE0 + i); glBindTexture(GL_TEXTURE_2D, 0); } glActiveTexture(GL_TEXTURE0); state.curTextureUnit = 0; createDefaultTexture(); // Invalidate the cached matrices by setting some elements to NaN. float nan = std::numeric_limits<float>::quiet_NaN(); state.lastProjectionMatrix.setTranslation(nan, nan); state.lastTransformMatrix.setTranslation(nan, nan); if (GLAD_VERSION_1_0) glMatrixMode(GL_MODELVIEW); contextInitialized = true; }
BaseSurface::BaseSurface(){ _moved = false; ofEnableNormalizedTexCoords(); createDefaultTexture(); }