Results 1 to 2 of 2

Thread: CL_DisplayWindow set_size()

  1. #1

    Default CL_DisplayWindow set_size()

    ClanLib version 0.8.1

    When I resize the window using set_size() it seems like the coordinate system gets out of whack, or at least I am not understanding something. (0,0) ends up below the top left corner if you size it to be better than it originally was.

    I tried setting the cliprect in the graphics context but that didn't seem to be in. I'm a bit baffled currently and would appreciate any help.

    Below is the code I used, just copy some small png to sprite1.png, I compiled it in Linux using the following commands:

    g++ `pkg-config --cflags clanCore-0.8 clanDisplay-0.8 clanApp-0.8 clanGL-0.8` -c -o resizetest.o resizetest.cpp
    g++ -o resizetest resizetest.o `pkg-config --libs clanCore-0.8 clanDisplay-0.8 clanApp-0.8 clanGL-0.8

    Below is the file resizetest.cpp:
    #include <ClanLib/gl.h>
    #include <ClanLib/core.h>
    #include <ClanLib/application.h>
    #include <ClanLib/display.h>
    #include <iostream>
    class MyApp : public CL_ClanApplication
            virtual int main(int argc, char **argv)
                CL_ConsoleWindow console("Console");
                    CL_SetupCore setup_core;
                    CL_SetupDisplay setup_display;
                    CL_SetupGL setup_gl;
                    CL_DisplayWindow window("ClanLib application", 640, 480);
                    CL_SpriteDescription test_desc;
                    CL_Sprite *sprite1 = new CL_Sprite(test_desc);
                    unsigned long time_tick=0;
                    // Run until someone presses escape
                    int x = 0;
                    int y = 0;
                    while (!CL_Keyboard::get_keycode(CL_KEY_ESCAPE))
                        if(time_tick > 100)
                            if(time_tick > 200)
                                window.set_size(640, 480);
                                window.set_size(800, 600);
                        sprite1->draw(0, 0);
                catch (CL_Error err)
                    std::cout << err.message.c_str() << std::endl;
                return 0;
    } app;

  2. #2
    Master Sorcerer
    Join Date
    Sep 2006


    There are three likely causes for this:

    • ClanLib forgets to reset the projection and modelview matrces after a resize. Since OpenGL coordinates originate from the bottom-left corner with the y-axis going upwards, that would make it incorrectly place 0,0 above the window.
    • ClanLib does reset the matrices, but the code somehow uses the wrong height of the window
    • ClanLib, or the OpenGL driver, somehow manages to give the OpenGL viewport the wrong dimensions or position

    Unfortunately it requires quite an effort to debug this, and I personally prefer to spend most of my time working on 0.9, so someone else would have to hunt down this bug.

Similar Threads

  1. ClanLib crashes when creating CL_DisplayWindow with target SDL.
    By Otto (Strange) Halmén in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 01-19-2008, 08:38 AM
  2. cl_displaywindow refuses to display a window
    By dwune in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 10-01-2007, 04:01 PM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts