Windows 1. Start VS. Open C:\CPP\a998engine\p_windows\p_windows.sln MyColor class The reason to have it as a separate class, is that we will need to keep colors in THREE different formats: as an array of 4 single byte integers (from 0 to 255, as it is stored in files) as an array of 4 floats (from 0.0 to […]
Chapter 12. Graphics Engine. Basic classes
At this point we successfully married desktop and mobile, Visual Studio and OpenGL ES. Now we are starting to implement our graphics engine. Sure, it can be done in many different ways. Warning: All following materials represent my personal vision of this topic. We'll start from basic classes. Our current TheGame code renders 1 simple […]
Chapter 11. Textures
1. To use textures, we first need to load them into the application. Using an image-loading library that supports several popular formats looks like a good solution. I like stb_image.h by Sean Barrett. Especially I love that it's a single h-file, not a lib or dll. You can download it here. Save it in C:\CPP\engine […]
Chapter 10. Simple shader
Finally, shaders! Let's start from the easiest one, just flat uniform color, which we will pass to the shader as an input, along with mesh data (in our sample - a triangle). Shaders use GLSL (OpenGL Shading Language with syntax similar to C). GLSL is executed directly by the graphics pipeline. The executable shader program […]
Chapter 9. Saving Android assets to files
Though we can access and use Android assets directly (as we just did in previous chapter). we still have to keep in mind, that assets are NOT files in the usual sense. The difference: Assets can't be accessed via common files tools. You have to use special Assets interface. They are read-only. You can't modify […]
Chapter 8. External data files, Android assets
The idea is the same as in previous chapter - to place the data files within the reach of the executable. However, in Android's case we are dealing NOT with the "executable", but with APK. Besides, we have to deliver data files not just to different folder, but to different device. The only "transport" (known […]
Chapter 7. External data files, Windows
Now we are ready to start writing real (practically usable) shaders. Right now we have 2 sample (1 vertex and 1 fragment) shaders, that are hard-coded in TheGame.cpp. Obviously, not the best solution, but for simplicity's sake was quite reasonable. In our turn, we want to keep our shaders outside of the executable. 1. In […]
Chapter 6. Cross-platform, Android
Now we will try to run TheGame spinning triangle sample on Android. 1. Start Visual Studio, open C:\CPP\a999hello\p_android\p_android.sln solution. 2. Under p_android.NativeActivity project add “xTheGame” filter: Right-click on p_android.NativeActivity project -> Add -> New Filter. Name - xTheGame Under xTheGame add Existing Item: Right-click on xTheGame -> Add -> Existing Item, Navigate to C:\CPP\a999hello Files […]
Chapter 5. Cross-platform, Windows
In this chapter we will dissect our GLFW spinning triangle sample. We will move “game” implementation into a separate class, which we will reuse later in Android version. It will be triangle rendering related code. In order to make it platform-independent we will separate it from platform-specific calls. All environment related code, such as window […]
Chapter 4. Printf in OpenGL ES
Now, having OpenGL ES projects for 2 different platforms, we can see what is common and what is different. Common is generic structure: Creating GL context, initializing data, main loop with frames rendering, exit. GL calls (Thank God!) look similar too. The difference is in program and GL initialization, in GL-related includes (gl/egl on Android […]