• Welcome to the Angry Joe Show Army!

    Join our community of gamers passionate about our community and our hobby! Whether it's playing, discussing, or watching games, regardless of platform, genre, or location, we have a place for you, always!

  • PS4 Forum

    The AJSA Playstation 4 Division: Game Nights and More!

    The AJSA is on Playstation 4! Join us for weekly Game Nights with a selection of the best games the PS4 has to offer!

  • XBO Forum

    The AJSA Xbox One Division: We Got You Covered!

    The AJSA Xbox One Division is ready to connect with you on XBox Live with a ton of events for the best Xbox games!

  • News Archive

    The Best News from the Best Sites, Every Week.

    The AJSA News Collection Team is hard at work condensing a week's worth of news into one giant-sze digest for you to chew on and discuss! Links to source articles are always provided!

  • More Info

    The AJSA Expeditionary Force: Deploying to Play the Best PC Games!

    The elite vanguard of the AJSA, the Expeditionary Force (EF) chooses a new PC game every week! Join us for weekly events and help decide if the game has a future in the AJSA.

  • The Team

    Streaming Now: The AJSA Stream Team

    Joe can't stream every game, but our talented AJSA Stream Team covers a wide variety of games and personalities! Check them out, and show them some AJSA Love!

  • The Tube

    The AJSA Community YouTube Channel

    Featuring news, gameplay clips, and more from the community! The Community is a chance to showcase the best moments in AJSA Gaming!

Sign in to follow this  
Followers 0
Seirex

SDL help?

4 posts in this topic

I'm making a menu using SDL and i'm having a weird issue, i have 2 textures on screen. Ive got a background on my mainWindow and i have a texture for a button. When i try to make a new texture it wont render. If i make 2 textures one will render. Is this a memory problem? why is it doing this?

Share this post


Link to post
Share on other sites

I am not sure what you are doing as without code I can not tell much, but here is a little SDL2 program I made in a few minutes. It opens a window and renders 3 images to it. The first is the background, the second a button, and the third another image.

154ca86cae66576182781984cba95b0d.png

That is what it should look like when you run it. Here is the code: http://pastebin.com/qh2Pi5T6

Edit: Unless by texture you mean on GPU.

Share this post


Link to post
Share on other sites

Works perfect! ok so I'm sure i was displaying them wrong, I'm still new at this.

i was using

Quote

Button::Button(const char* path, SDL_Renderer* windowRend, int xPos, int yPos, int width, int height)
{
  btnImageSurface = SDL_LoadBMP(path);
  btnTexture = SDL_CreateTextureFromSurface(windowRend, btnImageSurface);
  btn_Rect.x = xPos;
  btn_Rect.y = yPos;
  btn_Rect.w = width;
  btn_Rect.h = height;
  SDL_RenderCopy(windowRend, btnTexture, NULL, &btn_Rect);
  SDL_RenderPresent(windowRend);
}

I was working on this project a while ago, I got tired of learning Cpp making basic CLI stuff so I started SDL2. The Tutorial I was using is still over my head... it took me 20 mins before i found out GCC can compile more than one .cpp file at once. 

This is definitely a jump from c# and Visual Studio

Share this post


Link to post
Share on other sites

If you want to render with the GPU, then you need to use SDL_Texture instead of SDL_Surface, SDL_Texture is loaded into your video card's VRAM instead of RAM.

I have compiled this code with visual studio 2015 community edition: http://pastebin.com/A8Dc46Sr

edit: SDL will use OpenGL or DirectX internally to do this, or some other method in the future such as Vulkan.

Seirex likes this

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0