You are not logged in.
I have this code to create the window and parse it to the OpenGL layer to create the context. For some reason though, the window doesn't draw unless I move it then release the mouse button, it'll show a picture of what my screen was behind where it use to be.
//! Creates the window.
bool CEngineLayerUnix::createWindow(const char* title, int windowWidth, int windowHeight, int windowBits,
bool windowFullscreen, bool cursorVisibleWindowed, bool cursorVisibleFullscreen)
{
display = XOpenDisplay(0);
if(display == 0)
{
IOLayer->log("Failed to connect to the X server.");
return true;
}
setWindowAttributes.event_mask = ExposureMask | KeyPressMask;
window = XCreateWindow(display, DefaultRootWindow(display), 0, 0, windowWidth, windowHeight, 0, 24,
InputOutput, CopyFromParent, 0, &setWindowAttributes);
bool attemptedFullscreen = false;
setCursorState((windowFullscreen == true) ? cursorVisibleFullscreen : cursorVisibleWindowed);
width = windowWidth;
height = windowHeight;
bits = windowBits;
fullscreen = windowFullscreen;
IOLayer->log("Created window at %ix%i@%i %s %s", width, height, bits, fullscreen == true ? "fullscreen" : "windowed",
(attemptedFullscreen == false) ? "resolution." : "resolution after failing fullscreen mode.");
if(videoLayer->createContext(display, &window) == true) // If creating the video layer context failed..
{
removeWindow();
IOLayer->log("Failed to create the context.");
return true;
}
XMapWindow(display, window);
XStoreName(display, window, title);
return false;
}
//! Creates the context.
bool CVideoLayerOpenGL::createContext(Display* display, Window* window)
{
XDisplay = display;
XWindow = window;
GLXContext context;
GLint attributes[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
XVisualInfo* visualInfo = glXChooseVisual(XDisplay, 0, attributes);
context = glXCreateContext(XDisplay, visualInfo, 0, true);
glXMakeCurrent(XDisplay, *XWindow, context);
int width;
int height;
int bits;
bool fullscreen;
engineLayer->getResolution(width, height, bits, fullscreen);
initGL(width, height, bits);
//wglSwapIntervalEXT(true); // Enable VSync.
IIOLayer* IOLayer = engineLayer->getIOLayer();
IOLayer->log("Created the OpenGL context.");
return false;
}
//! Runs the video layer.
bool CVideoLayerOpenGL::run(void)
{
#if defined(_JE3D_OS_WINDOWS_) == true
SwapBuffers(deviceContext);
#elif defined(_JE3D_OS_UNIX_) == true
glXSwapBuffers(XDisplay, *XWindow);
#endif
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
for(unsigned int i = 0; i < artList.size(); i++)
{
SCursesArtOpenGL* artGL = artList[i];
float x = artGL->startPosX;
float y = artGL->startPosY;
float w = artGL->width;
float h = artGL->height;
glBindTexture(GL_TEXTURE_2D, artGL->texture);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(x, y);
glTexCoord2f(1.0f, 0.0f);
glVertex2f(x + w, y);
glTexCoord2f(1.0f, 1.0f);
glVertex2f(x + w, y + h);
glTexCoord2f(0.0f, 1.0f);
glVertex2f(x, y + h);
glEnd();
}
glFinish();
glFlush();
return false;
}
I can confirm the non-platform dependent code (the OpenGL stuff) works fine on Windows.
Offline