Welcome, Guest |
You have to register before you can post on our site.
|
Forum Statistics |
» Members: 103
» Latest member: yelruh
» Forum threads: 233
» Forum posts: 989
Full Statistics
|
Online Users |
There is currently 1 user online » 0 Member(s) | 1 Guest(s)
|
Latest Threads |
Is Vulkan the future?
Forum: General Chat
Last Post: web2gamedevconvert
07-07-2024, 12:29 PM
» Replies: 8
» Views: 18,667
|
hello
Forum: Scratchpad Games
Last Post: web2gamedevconvert
05-20-2024, 04:20 PM
» Replies: 10
» Views: 31,241
|
So, you're bypassing Unit...
Forum: General Chat
Last Post: web2gamedevconvert
05-18-2024, 10:34 AM
» Replies: 3
» Views: 15,213
|
Arise dead book?
Forum: Scratchpad Games
Last Post: Brian Beuken
02-29-2024, 08:07 AM
» Replies: 0
» Views: 1,136
|
Im working on a Game..
Forum: Scratchpad Games
Last Post: Brian Beuken
08-04-2023, 10:58 AM
» Replies: 8
» Views: 18,697
|
OpenGL Error handling
Forum: Assets, Tools, Libraries and other useful things
Last Post: Brian Beuken
12-07-2022, 11:48 AM
» Replies: 0
» Views: 5,789
|
Rock Pi5B
Forum: Other SBC's
Last Post: Brian Beuken
11-12-2022, 10:14 PM
» Replies: 5
» Views: 11,908
|
Setting Up Bullet
Forum: Assets, Tools, Libraries and other useful things
Last Post: Brian Beuken
10-12-2022, 11:36 AM
» Replies: 3
» Views: 14,641
|
Building with a toolchain
Forum: General Chat
Last Post: junglie85
09-11-2022, 07:45 AM
» Replies: 3
» Views: 11,697
|
Window doesn't open on Pi
Forum: Help my code won't work??
Last Post: junglie85
09-05-2022, 01:28 PM
» Replies: 5
» Views: 10,196
|
|
|
Some new tutorials on the way |
Posted by: Brian Beuken - 09-08-2019, 02:38 PM - Forum: Code Questions
- Replies (7)
|
|
A long time ago in a galaxy far away, about 10 years ago, some of my University collegues and I put together a basic introduction to C++ for games, and it was hosted on a few game dev sites.
Over time though they started to show their age and slipped down the search rankings. Despite saying every year we would update them, and make sure students were pointed to them, we just never got round to it.
But they have finally been updated, and will soon be hosted on my collegue Jeremiah van Oostens website at 3Dgep.com, where hopefully we can maintain and expand them, just as soon as my OCD co-writers can stop tinkering with it.
If you want to learn C++ on your PC, and make some basic but functional content that can build into games (not unlike the methods I use for the 2D content in my book) feel free to check it out.
If you are a slightly more advanced coder, Jeremiah site is an amazing resource for you to enhance your 3D graphic knowledge and get into some very (I do mean very) complex content.. But theres some beginner/intermediate stuff there too.
|
|
|
Khadas Vim3L |
Posted by: Brian Beuken - 09-08-2019, 02:08 PM - Forum: Other SBC's
- Replies (5)
|
|
I was hoping to get my hands on a Vim3 with the impressive A311D but though they were kind to respond to my mail, they didn't send me a free example and as its over my $100 limit I couldn't buy it. It currently tips the scale at $99 but when you factor in a heatsink it tips it over...
But they have announced a half price Vim3L version with the S905 chip which they had originally intended to use, its missing a few other bits, but I probably wouldn't have used them anyway.
So I've preordered and will wait and see.
I've always liked the Vim2 I have, its quite a processing beast and actually emulates ES2 better than any other system I have, but like a lot of higher end boards it lacks access to the GPU, I suspect the same here but we will see when it arrives. It'll be a few months.
oops edit... no, the original Vim3 chip was a S922 which is/was a hexacore chip but they switched to the A311D and that also pushed the price up a bit. The S905 is the same quad core you find in the Odroid C2, a powerful chip for sure, better than the Pi3B but not as impressive as the S922... So this should be compared with the C2 and Pi3B in terms of performance, I suspect it will match the C2 but fall behind the 3B, we'll see when it arrives. But one thing, the C2 has a strong community behind it and I "think" it has GPU drivers, I need to dig mine out and update it to see. So it may actually be a more useful dev target than the full Vim3 is... time, as always will tell.
|
|
|
Fundamentals of C/C++ Game Programming in Class form |
Posted by: jomoengineer - 08-14-2019, 04:18 AM - Forum: General Chat
- Replies (1)
|
|
Hey Brian,
I was wondering if you have thought about offering the teachings from "Fundamentals of C/C++ Game Programming" in some sort of online class form or MOOC? I think something like Udemy would be a good place for this and could broaden the audience for the book. Maybe even combine the MagPi articles with the material from the book?
Any thoughts on this?
Cheers,
Jon
|
|
|
Which Pi am I? |
Posted by: Brian Beuken - 07-13-2019, 12:41 PM - Forum: Raspberry Pi questions
- Replies (1)
|
|
Now that we have the Pi4 on the market, we have to finally accept that some differences exist between the different versions of Raspberry, (and libs they use)
For the most part we can build projects on the Zero, 1, 2, 3, A or B/B+ with no real care about the hardware as long as we are running the same OS we build on. That updates every 2 years or so but even so it tends to be compatible, so a project built on a new Stretch or Buster OS will work fine on a Jesse or older system.
The only real issue is that some machines are much slower than others and have less memory. Those kind of things can be dealt with by just checking that your project runs on a minimum specification, and using good optimisation.
But the Pi 4 introduces a wrinkle in that nice level of family compatibility, becuase it has a totally different approach to graphics and graphic code written for the older Pi's won't work on them, nor will Pi 4 code work on the older systems
There's 2 ways to tackle this.
1 Use Multiple configurations... where you create a specific build for a specific target system, or group of systems.. ie one build for the 1,2,3 and 1 for the 4.
Thats an easy option, and you can just build in pre-process values to set up the correct build.
2 Runtime detection of the target.
Where you actually try to work out what Pi you are running on, and then branch your code to do one set up for the older systems and another for the later ones.
There's pros and cons to both methods but for the most part, the only real difference between the units is graphics, oh and memory, but graphics is the killer. So lets try and do a simple detect and based on the results of that detect set up graphics accordingly.
There's no system call that automatically tells you what machine you are working on, but there are files on the system that you can read
/sys/firmware/devicetree/base/model
or
/proc/device-tree/model
These can be read in and parsed by your init systems to give you the info you need and set up the correct system. Once we know we're on a Pi2 we can use ES2.0 and BCM EGL, instead of X11 (trying to work out a DRM system though) and Mesa EGL for Pi4.
If you plan to incldue OpenGLES3.0+ features you can also set up conditional tests to do one draw system or another...probably routed through a simple render class that is instansiated depending on the type.
We can also get a good idea of how much memory our system has by reading
/proc/meminfo
Since there's bound to be a tendancy to assume you have 3 or 4GB of memory free, this will allow you to know roughly how much you can use, though be careful again as the Pi4 dynamically allocates GPU memory when needed so you can only use such info as a rough guide.
I'll use these info systems as a means to put together a general new graphics system that readers can replace the current systems with and upload the code as soon as I can.
|
|
|
Raspberry Pi 4 is different, book code won't work! |
Posted by: Brian Beuken - 07-03-2019, 11:10 AM - Forum: Help my code won't work??
- Replies (11)
|
|
Well it had to happen, the new Raspi4 is a lovely machine with some impressive graphic potential, but it does not work the same way as all the other Raspberries so the book examples won't work, there has to be a new version of the graphics startup code.
The previous Raspberries used Broadcom IV graphic drivers with binaries and libs located in opt/vc/lib and opt/vc/include
The Pi4 still has these libraries and locations but they don't work on the 4, though you can use the Buster OS with any other Raspberry.
1st things 1st you need mesa libs which can be installed by opening a terminal and typing
sudo apt-get install libgles2-mesa-dev
Now you need to change some of your project library needs and directory access. The increased number of libs needed to run on the older RPis has been reduced to just 3, EGL, GLES2 AND X11 (other display systems are possible though but not right now)
And include libs are now usr/lib for the libraries and usr/include for the h files
Also, and this is very important, do not disable the OpenGL drivers as we had to do in older Raspberry's
If you are using one of the multi build configs on the site, basically Raspberry has reverted to the normal way to build a Linux project, so remove the RASPBERRY pre processor instruction and let it build like a normal Linux build and it should be fine.
Here's the init code to set up an X11 window, EGL and get ready to work with OpenGLES2.0
Code: ///
// CreateEGLContext()
//
// Creates an EGL rendering context and all associated elements
static Display* x_display = NULL;
void Graphics::init_ogl(Target_State *state, int width, int height, int FBResX, int FBResY)
{
#define ES_WINDOW_RGB 0
state->width = width;
state->height = height;
EGLint numConfigs;
EGLint majorVersion;
EGLint minorVersion;
EGLDisplay display;
EGLContext context;
EGLSurface surface;
EGLConfig config;
EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
/* create a native window */
Window root;
XSetWindowAttributes swa;
XSetWindowAttributes xattr;
Atom wm_state;
XWMHints hints;
XEvent xev;
EGLConfig ecfg;
EGLint num_config;
Window win;
Screen *screen;
/*
* X11 native display initialization
*/
x_display = XOpenDisplay(NULL);
if (x_display == NULL)
{
printf("Sorry to say we can't create an Xwindow and this will fail");
exit(0); //return ; // we need to trap this;
}
eglBindAPI(EGL_OPENGL_ES_API);
root = DefaultRootWindow(x_display);
screen = ScreenOfDisplay(x_display, 0);
state->width = width;
state->height = height;
swa.event_mask = ExposureMask | PointerMotionMask | KeyPressMask | KeyReleaseMask;
swa.background_pixmap = None;
swa.background_pixel = 0;
swa.border_pixel = 0;
swa.override_redirect = true;
win = XCreateWindow(
x_display,
root,
0,
0,
width,
height,
0,
CopyFromParent,
InputOutput,
CopyFromParent,
CWEventMask,
&swa);
XSelectInput(x_display, win, KeyPressMask | KeyReleaseMask);
xattr.override_redirect = TRUE;
XChangeWindowAttributes(x_display, win, CWOverrideRedirect, &xattr);
hints.input = TRUE;
hints.flags = InputHint;
XSetWMHints(x_display, win, &hints);
char* title = (char*)"x11 window Maze3dHunt";
// make the window visible on the screen
XMapWindow(x_display, win);
XStoreName(x_display, win, title);
// get identifiers for the provided atom name strings
wm_state = XInternAtom(x_display, "_NET_WM_STATE", FALSE);
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
xev.xclient.window = win;
xev.xclient.message_type = wm_state;
xev.xclient.format = 32;
xev.xclient.data.l[0] = 1;
xev.xclient.data.l[1] = FALSE;
XSendEvent(
x_display,
DefaultRootWindow(x_display),
FALSE,
SubstructureNotifyMask,
&xev);
state->nativewindow = (EGLNativeWindowType) win;
// Get Display
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (display == EGL_NO_DISPLAY)
{
printf("Sorry to say we have an EGLinit error and this will fail");
EGLint err = eglGetError();
return; // EGL_FALSE;
}
// Initialize EGL
if (!eglInitialize(display, &majorVersion,&minorVersion))
{
printf("Sorry to say we have an EGLinit error and this will fail");
EGLint err = eglGetError();
return;// EGL_FALSE;
}
// Get configs
if (!eglGetConfigs(display, NULL, 0, &numConfigs))
{
printf("Sorry to say we have EGL config errors and this will fail");
EGLint err = eglGetError();
return;// EGL_FALSE;
}
// Choose config
if (!eglChooseConfig(display, attribute_list, &config, 1, &numConfigs))
{
printf("Sorry to say we have config choice issues, and this will fail");
EGLint err = eglGetError();
return;// EGL_FALSE;
}
// Create a surface
surface = eglCreateWindowSurface(display, config, state->nativewindow, NULL);
if (surface == EGL_NO_SURFACE)
{
EGLint err = eglGetError();
return;// EGL_FALSE;
}
// Create a GL context
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);
if (context == EGL_NO_CONTEXT)
{
EGLint err = eglGetError();
return;// EGL_FALSE;
}
// Make the context current
if (!eglMakeCurrent(display, surface, surface, context))
{
EGLint err = eglGetError();
return;// EGL_FALSE;
}
state->display = display;
state->surface = surface;
state->context = context;
// just for fun lets see what we can do with this GPU
printf("This SBC supports version %i.%i of EGL\n", majorVersion, minorVersion);
printf("This GPU supplied by :%s\n", glGetString(GL_VENDOR));
printf("This GPU supports :%s\n", glGetString(GL_VERSION));
printf("This GPU Renders with :%s\n", glGetString(GL_RENDERER));
printf("This GPU supports :%s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
printf("This GPU supports these extensions :%s\n", glGetString(GL_EXTENSIONS));
EGLBoolean GLtest = eglGetConfigAttrib( display,
config,
EGL_MAX_SWAP_INTERVAL,
&minorVersion);
EGLBoolean test = eglSwapInterval(display, 1); // 1 to lock speed to 60fps (assuming we are able to maintain it), 0 for immediate swap (may cause tearing) which will indicate actual frame rate
// on xu4 this seems to have no effect
// Some OpenGLES2.0 states that we might need
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glDepthMask(TRUE);
glDepthRangef(0.0f, 1.0f);
glClearDepthf(1.0f);
//these are the options you can have for the depth, play with them?
//#define GL_NEVER 0x0200
//#define GL_LESS 0x0201
//#define GL_EQUAL 0x0202
//#define GL_LEQUAL 0x0203
//#define GL_GREATER 0x0204
//#define GL_NOTEQUAL 0x0205
//#define GL_GEQUAL 0x0206
//
glViewport(0, 0, state->width, state->height);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glCullFace(GL_BACK);
if (glGetError() == GL_NO_ERROR) return ;
else
printf("Oh bugger, Some part of the EGL/OGL graphic init failed\n");
}
I will put new builds forPi4 up on the site as soon as I can, if you need help, just ping me on here or drop me a mail
|
|
|
|