Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    63
  • comments
    56
  • views
    44550

Going steady

Sign in to follow this  
rick_appleton

329 views

My thesis work is coming along nicely, although I have been held up by some very unsightly bugs.

Daedalus is shaping up very nicely. A code snippet for the interested:

#include "System/Window/window.h"
#include

class MyWindow : public System::PlatformWindow
{
public:
MyWindow() : right(100)
{
MyWindow() : right(100)
{
mKeymap.RegisterMapping(
DKEY_ESC,
Functor0(this, &PlatformWindow::Close),
Input::Keyboard::KEY_DOWN);
mKeymap.RegisterMapping(
DKEY_BACKSPACE,
Functor0(this, &MyWindow::Left),
Input::Keyboard::KEY_PRESSED);
mKeymap.RegisterMapping(
DKEY_ENTER,
Functor0(this, &MyWindow::Right),
Input::Keyboard::KEY_PRESSED);
mKeymap.RegisterMapping(
'G',
Functor0(this, &MyWindow::Color),
Input::Keyboard::KEY_PRESSED);
}

float r,g,b;
float right;

void Color( void )
{
g += 0.001;
Redraw();
}
void Left( void )
{
right -= 0.1;
Redraw();
}
void Right( void )
{
right += 0.1;
Redraw();
}
void Draw( void )
{
glViewport(0,0,mWidth,mHeight);
glClearColor(0.f, 0.f, 0.f, 0.f);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(0, mWidth, 0, mHeight, -10, 10);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

glColor3f(r,g,b);
glRectf(0,0, right, 100);
}
};

int Init()
{
MyWindow *p = new MyWindow;
p->Create();
p->r = 1.f;
p->g = 0.f;
p->b = 0.f;

p->MoveToFront();

return 0;
}



This basically does exactly what you'd expect of it. The Init function is called from within Daedalus. It creates a window of default size and colour depth, sets the color and moves it to the front (thereby giving it focus).
The window registers couple of input functions, and implements a drawing function.

This code works on Windows and on Linux without changing a single line. Only a recompile is necessary.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!