GithubHelp home page GithubHelp logo

Comments (5)

raysan5 avatar raysan5 commented on June 5, 2024

Sure! Just use a RenderTexture2D target to do the render at 240x160 and then render that target.texture to window size. You can find an example here.

from raylib-go.

Pienkaito avatar Pienkaito commented on June 5, 2024

I think I nearly have it. My only problem right now would be "RenderTexture2d rendered upside down" issue, which was addressed in the forums.

Because of how DrawTextureRec works differently as I expected, I opted to use DrawTextureEx instead and it works perfectly for my intended use. But the problem is that I can't adjust the rendering height.

I could solve it by rendering it twice on two different textures, but perhaps there is another (and better) method.

from raylib-go.

raysan5 avatar raysan5 commented on June 5, 2024

But the problem is that I can't adjust the rendering height.

I don't understand exactly what you mean, could you post some example of what are you trying to accomplish?

from raylib-go.

Pienkaito avatar Pienkaito commented on June 5, 2024

In your example, you flipped the texture by its y-axis like so.

// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
raylib.DrawTextureRec(target.Texture, raylib.NewRectangle(0, 0, target.Texture.Width, -target.Texture.Height), raylib.NewVector2(0, 0), raylib.White)

I'm using this function to scale my output
raylib.DrawTextureEx(target.Texture, raylib.NewVector2(0, 0), 0, float32(scale), raylib.White)

My texture can be scaled accordingly by using this function, but the texture itself is upside down.
So in order to fix this I've done the following.

raylib.BeginTextureMode(target)
{
	//Draw stuff onto the texure
}
raylib.EndTextureMode()

raylib.BeginTextureMode(targetflipped)
{
	raylib.DrawTextureRec(target.Texture, raylib.NewRectangle(0, 0, target.Texture.Width, target.Texture.Height), raylib.NewVector2(0, 0), raylib.White)
}
raylib.EndTextureMode()

raylib.DrawTextureEx(targetflipped.Texture, raylib.NewVector2(0, 0), 0, float32(scale), raylib.White)

It feels sort of redundant and I was wondering if there's a better way for doing this.

from raylib-go.

nehpe avatar nehpe commented on June 5, 2024

@Pienkaito yeah, that is pretty inefficient. I recommend using DrawTexturePro --

raylib.DrawTexturePro(target.Texture, rl.NewRectangle(0, 0, target.Texture.Width, -target.Texture.Height), rl.NewRectangle(0, 0, target.Texture.Width, target.Texture.Height), rl.Vector2{0, 0}, 0, rl.White)

from raylib-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.