Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic Embedding
#21
I haven't been posting recently, mainly because of other projects and time commitments. Life happens.

One thing that I've been doing recently though, is learning how to program in C++! Finally got over the learning hump that had been holding me back for so many years, and over the past few weeks I've been gobbling up basic C++ ravenously. Got everything from classes, extension, basic pointer and memory mapping, command-line build systems (cmake), arrays and their bizarre handling syntax, and some remedial OpenGL.

And as always, one of my favorite experiments when learning anything new is to embed Tilengine in it. It was actually even easier than usual, as Tilengine's C-nature makes it relatively painless to use it in conjunction with C++. (just include and link, and then you can call the C functions directly) For this one, I created a custom SDL window with an OpenGL context, and then mapped the output from Tilengine to a textured OpenGL quad. Here's the line of code that really makes the magic happen.

Code:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, targetWidth, targetHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixelsPointer);

This is the OpenGL function that draws a pixel array to the currently bound OpenGL texture. Basically, you create a texture, create a pixel array, target Tilengine to the Pixel array, update your frame in Tilengine, bind your texture, call that line of code, and then draw your texture to a 3D element. (in this case a simple quad) That simple.

It took a little bit of experimenting to get the right settings for the draw function, but I had a head start on that thanks to my previous attempts. Now that I've got Tilengine mapped into OpenGL, I can run things like fragment shaders on Tilengine's output. That will open a few possibilities that didn't exist before.
Reply


Messages In This Thread
Basic Embedding - by Richard Kain - 09-08-2018, 09:46 AM
RE: Basic Embedding - by Domarius - 09-08-2018, 11:31 PM
RE: Basic Embedding - by Richard Kain - 09-11-2018, 05:43 AM
RE: Basic Embedding - by megamarc - 09-11-2018, 07:19 AM
RE: Basic Embedding - by Richard Kain - 09-11-2018, 08:52 AM
RE: Basic Embedding - by megamarc - 09-13-2018, 06:22 AM
RE: Basic Embedding - by Richard Kain - 10-18-2018, 06:45 AM
RE: Basic Embedding - by megamarc - 10-18-2018, 11:34 PM
RE: Basic Embedding - by Richard Kain - 10-23-2018, 03:49 PM
RE: Basic Embedding - by megamarc - 10-24-2018, 05:17 PM
RE: Basic Embedding - by Richard Kain - 01-15-2019, 03:37 PM
RE: Basic Embedding - by megamarc - 01-22-2019, 02:58 AM
RE: Basic Embedding - by Richard Kain - 04-18-2019, 01:54 AM
RE: Basic Embedding - by megamarc - 04-18-2019, 07:26 PM
RE: Basic Embedding - by Richard Kain - 04-19-2019, 02:52 AM
RE: Basic Embedding - by megamarc - 04-19-2019, 05:39 PM
RE: Basic Embedding - by Richard Kain - 04-20-2019, 06:56 AM
RE: Basic Embedding - by megamarc - 04-23-2019, 07:20 PM
RE: Basic Embedding - by Richard Kain - 05-01-2019, 05:23 PM
RE: Basic Embedding - by megamarc - 05-01-2019, 09:26 PM
RE: Basic Embedding - by Richard Kain - 10-11-2019, 06:09 AM
RE: Basic Embedding - by megamarc - 10-14-2019, 08:31 PM
RE: Basic Embedding - by Richard Kain - 11-05-2019, 03:39 AM
RE: Basic Embedding - by Richard Kain - 11-05-2019, 04:46 AM
RE: Basic Embedding - by megamarc - 11-06-2019, 05:16 AM
RE: Basic Embedding - by Richard Kain - 11-06-2019, 06:08 AM
RE: Basic Embedding - by Richard Kain - 11-08-2019, 02:38 AM
RE: Basic Embedding - by megamarc - 11-09-2019, 02:27 AM
RE: Basic Embedding - by RootBeerKing - 11-10-2019, 10:54 PM
RE: Basic Embedding - by megamarc - 11-11-2019, 06:01 PM
RE: Basic Embedding - by RootBeerKing - 11-11-2019, 07:53 PM
RE: Basic Embedding - by megamarc - 11-12-2019, 02:18 AM
RE: Basic Embedding - by Richard Kain - 11-12-2019, 04:06 PM
RE: Basic Embedding - by RootBeerKing - 11-13-2019, 05:42 AM
RE: Basic Embedding - by Richard Kain - 11-13-2019, 05:36 AM
RE: Basic Embedding - by megamarc - 11-13-2019, 08:25 AM
RE: Basic Embedding - by RootBeerKing - 11-13-2019, 08:42 AM
RE: Basic Embedding - by megamarc - 11-13-2019, 06:08 PM
RE: Basic Embedding - by Richard Kain - 11-14-2019, 04:53 AM
RE: Basic Embedding - by Richard Kain - 11-14-2019, 08:30 AM
RE: Basic Embedding - by megamarc - 11-28-2019, 12:04 AM
RE: Basic Embedding - by megamarc - 12-05-2019, 08:22 PM
RE: Basic Embedding - by adreajessica - 11-25-2021, 02:42 PM
RE: Basic Embedding - by Richard Kain - 01-22-2022, 06:00 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)