using othographic projection now
parent
419ebc8783
commit
0d78fc5ece
|
@ -89,6 +89,7 @@ class Model : public Engine::ModelBase {
|
|||
}
|
||||
|
||||
bool GetGameModified() { return mGameModified; }
|
||||
|
||||
protected:
|
||||
/** \brief Initializes the system */
|
||||
virtual int OnInit (int argc, char* argv[]);
|
||||
|
|
|
@ -183,6 +183,47 @@ bool View::OnReceiveEvent (const Engine::EventBasePtr &event) {
|
|||
/*
|
||||
* Module specific functions
|
||||
*/
|
||||
void View::Resize (int width, int height) {
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
|
||||
mWindowWidth = static_cast<unsigned int> (width);
|
||||
mWindowHeight = static_cast<unsigned int> (height);
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
float world_width, world_height;
|
||||
world_width = GetModel()->GetWorldWidth ();
|
||||
world_height = GetModel()->GetWorldHeight ();
|
||||
|
||||
Engine::LogMessage ("width %f height %f", world_width, world_height);
|
||||
|
||||
glOrtho (- world_width * 0.5, world_width * 0.5, -world_height * 0.5, world_height * 0.5, 0., 100.);
|
||||
// gluPerspective(mCamera->GetFOVY (), float (width) / float (height), 0., 100);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity ();
|
||||
|
||||
Engine::LogDebug ("Resize to: %d x %d", mWindowWidth,mWindowHeight);
|
||||
|
||||
/** \warning
|
||||
* This call has to be made for SDL 1.2 for 1.3 there seems to be a
|
||||
* workaround, however since I do not yet run SDL 1.3 I hold on to this.
|
||||
* See http://lists.libsdl.org/pipermail/sdl-libsdl.org/2008-November/067306.html
|
||||
*/
|
||||
Uint32 video_flags = SDL_OPENGL;
|
||||
|
||||
if (mDrawFullscreen)
|
||||
video_flags = video_flags | SDL_FULLSCREEN;
|
||||
|
||||
if( SDL_SetVideoMode( mWindowWidth, mWindowHeight, 16, video_flags) == 0 ) {
|
||||
Engine::LogError ("Video mode set failed: %s", SDL_GetError ());
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
|
||||
void View::UpdateCamera () {
|
||||
mCamera->SetEye (
|
||||
0.,
|
||||
|
@ -422,10 +463,10 @@ void View::DrawUi () {
|
|||
|
||||
ViewState current_view_state = GetViewState();
|
||||
|
||||
/*
|
||||
stringstream fps_stream;
|
||||
fps_stream << "fps: " << GetFrameRate();
|
||||
SelectFont ("console.ttf size=12");
|
||||
Engine::GUI::Label (99999, GetStringViewState(current_view_state), 8, 16);
|
||||
*/
|
||||
Engine::GUI::Label (99999, fps_stream.str().c_str(), 8, 48);
|
||||
|
||||
switch (current_view_state) {
|
||||
case ViewStateMainMenu:
|
||||
|
@ -1659,6 +1700,7 @@ void View::DrawAsteroid (AsteroidEntity *asteroid) {
|
|||
glEnable (GL_LIGHTING);
|
||||
glEnable (GL_LIGHT0);
|
||||
|
||||
glTranslatef (0., -1., 0.);
|
||||
// glRotatef (90, 1., 0., 0.);
|
||||
float scale = 1.8 * asteroid->mPhysicState->mRadius;
|
||||
glScalef (scale, scale, scale);
|
||||
|
|
|
@ -81,6 +81,7 @@ class View : public Engine::ViewBase {
|
|||
|
||||
/** \brief Updates the camera for further drawing */
|
||||
virtual void UpdateCamera ();
|
||||
virtual void Resize (int width, int height);
|
||||
|
||||
private:
|
||||
void DrawUi();
|
||||
|
|
|
@ -163,14 +163,15 @@ int main (int argc, char* argv[]) {
|
|||
version_string += FYSXASTEROIDS_VERSION;
|
||||
SDL_WM_SetCaption(version_string.c_str(), version_string.c_str());
|
||||
|
||||
engine.GetView()->SetGridSize (8,8);
|
||||
|
||||
/// \todo get rid of the world settings in asteroids
|
||||
dynamic_cast<asteroids::Physics*>(engine.GetPhysics())->SetWorldSize (26, 20);
|
||||
engine.GetPhysics()->SetWorldBounds (vector3d (-13, 0, -10), vector3d (13, 0, 10));
|
||||
engine.GetPhysics()->EnableWorldWarp(Engine::PhysicsBase::WorldWarpModeX);
|
||||
engine.GetPhysics()->EnableWorldWarp(Engine::PhysicsBase::WorldWarpModeZ);
|
||||
|
||||
engine.GetView()->SetGridSize (8,8);
|
||||
engine.GetView()->Resize (800, 600);
|
||||
|
||||
// run the default commands and load the configuration
|
||||
Engine::RunCommand ("exec asteroids.rc");
|
||||
Engine::RunCommand ("exec config.rc");
|
||||
|
|
|
@ -163,10 +163,10 @@ void draw_sprite_helper (float u_start, float u_end, float width, float height)
|
|||
*/
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f (u_start, 0.f); glColor3f (1.f, 0.f, 0.f); glVertex3f (0.f, 0.f, 0.f);
|
||||
glTexCoord2f (u_end, 0.f); glColor3f (0.f, 1.f, 0.f); glVertex3f (0.f, 0.f, height);
|
||||
glTexCoord2f (u_end, 1.f); glColor3f (0.f, 0.f, 1.f); glVertex3f (width, 0.f, height);
|
||||
glTexCoord2f (u_start, 1.f); glColor3f (1.f, 0.f, 1.f); glVertex3f (width, 0.f,0.f);
|
||||
glTexCoord2f (u_start, 0.f); glVertex3f (0.f, 0.f, 0.f);
|
||||
glTexCoord2f (u_end, 0.f); glVertex3f (0.f, 0.f, height);
|
||||
glTexCoord2f (u_end, 1.f); glVertex3f (width, 0.f, height);
|
||||
glTexCoord2f (u_start, 1.f); glVertex3f (width, 0.f,0.f);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
|
|
@ -681,7 +681,7 @@ void ViewBase::DrawOBJModelShaded (OBJModelPtr obj_model) {
|
|||
texture = iter->second;
|
||||
|
||||
} else {
|
||||
LogMessage ("Disabling textures");
|
||||
// LogMessage ("Disabling textures");
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
@ -1003,7 +1003,7 @@ void ViewBase::Resize (int width, int height) {
|
|||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(mCamera->GetFOVY (), float (width) / float (height), 0.1, 100);
|
||||
gluPerspective(mCamera->GetFOVY (), float (width) / float (height), 0., 100);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity ();
|
||||
|
|
|
@ -29,7 +29,7 @@ class ViewBase : public Module{
|
|||
virtual ~ViewBase() {};
|
||||
|
||||
/** \brief Resizes the View */
|
||||
void Resize (int width, int height);
|
||||
virtual void Resize (int width, int height);
|
||||
/** \brief Switches to fullscreen */
|
||||
void SetFullscreen (bool fullscreen);
|
||||
bool GetIsFullscreen () { return mDrawFullscreen; };
|
||||
|
|
Loading…
Reference in New Issue