Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Renderimage upside down?  (Read 3071 times)

0 Members and 1 Guest are viewing this topic.

kaikimi

  • Newbie
  • *
  • Posts: 5
    • View Profile
Renderimage upside down?
« on: September 28, 2010, 04:10:07 pm »
I made a main buffer to render to in my game as a test and it seems to be drawing the renderimage upside down. Maybe I'm doing something wrong? here's my code. I'm using SFML.NET 2.0



MainGame.cs
Code: [Select]
using System;
using System.Collections.Generic;
using System.Timers;
using SFML;
using SFML.Window;
using SFML.Graphics;

namespace FrostFire
{
    class MainGame : Program
    {
        public MainRenderBuffer MainBuffer;

        public MainGame()
        {  
            Text NewText = new Text();
            NewText.Position = new Vector2(200, 200);
            NewText.Color = new Color(250, 100, 30);

            Text NewText2 = new Text();
            NewText2.Position = new Vector2(120, 210);
            NewText2.Color = new Color(110, 222, 30);

            //sort all the sprites by depth and draw them to a buffer
            this.MainBuffer = new MainRenderBuffer(base.MainWindow.Height, base.MainWindow.Width);
       
            while (MainWindow.IsOpened())
            {
                base.MainWindow.DispatchEvents();

                //clear the window so we have a fresh screen to work with
                base.MainWindow.Clear();

                //Do all the game update logic
                MainGame.MainGameStateLoop();

                //replace this with the depth drawing array
                NewText.DisplayedString = Convert.ToString(base.MainWindow.GetFrameTime());
                NewText2.DisplayedString = Convert.ToString(base.MainWindow.GetFrameTime());
                this.MainBuffer.RenderBufferImage.Draw(NewText);
                this.MainBuffer.RenderBufferImage.Draw(NewText2);

                //draw the main buffer image to the screen
                base.MainWindow.Draw(new Sprite(this.MainBuffer.RenderBufferImage.Image));

                //display drawn buffer to the window
                base.MainWindow.Display();

                //clear the main buffer for the next frame.
                this.MainBuffer.RenderBufferImage.Clear();
            }
        }

        public static void MainGameStateLoop()
        {
            //switch statement for different room states (title, level, etc.)
        }

    }
}



renderbuffer.cs
Code: [Select]

using System;
using System.Collections.Generic;
using SFML;
using SFML.Window;
using SFML.Graphics;

namespace FrostFire
{
    class MainRenderBuffer
    {
        public uint Height, Width;
        public RenderImage RenderBufferImage;

        public MainRenderBuffer(uint Height, uint Width)
        {
            this.Height = Height;
            this.Width = Width;
            this.RenderBufferImage = new RenderImage(this.Width, this.Height);
            RenderBufferImage.Image.Smooth = false;

        }

    }
}

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
Renderimage upside down?
« Reply #1 on: September 28, 2010, 08:17:52 pm »
Call RenderImage.Display() before you read from the RenderImage, so right before this line:

Code: [Select]
base.MainWindow.Draw(new Sprite(this.MainBuffer.RenderBufferImage.Image));

kaikimi

  • Newbie
  • *
  • Posts: 5
    • View Profile
Renderimage upside down?
« Reply #2 on: September 28, 2010, 08:43:07 pm »
Ah, yeah that fixed it, thanks for the help.