Linux之X11+OpenGL,零基础学Linux运维

swa.event_mask = ExposureMask | PointerMotionMask | KeyPressMask;

win = XCreateWindow ( // create a window with the provided parameters

x_display, root,

0, 0, 800, 480, 0,

CopyFromParent, InputOutput,

CopyFromParent, CWEventMask,

&swa );

XSetWindowAttributes xattr;

Atom atom;

int one = 1;

xattr.override_redirect = False;

XChangeWindowAttributes ( x_display, win, CWOverrideRedirect, &xattr );

atom = XInternAtom ( x_display, “_NET_WM_STATE_FULLSCREEN”, True );

XChangeProperty (

x_display, win,

XInternAtom ( x_display, “_NET_WM_STATE”, True ),

XA_ATOM, 32, PropModeReplace,

(unsigned char*) &atom, 1 );

XChangeProperty (

x_display, win,

XInternAtom ( x_display, “_HILDON_NON_COMPOSITED_WINDOW”, False ),

XA_INTEGER, 32, PropModeReplace,

(unsigned char*) &one, 1);

XWMHints hints;

hints.input = True;

hints.flags = InputHint;

XSetWMHints(x_display, win, &hints);

XMapWindow ( x_display , win ); // make the window visible on the screen

XStoreName ( x_display , win , “GL test” ); // give the window a name

get identifiers for the provided atom name strings

Atom wm_state = XInternAtom ( x_display, “_NET_WM_STATE”, False );

Atom fullscreen = XInternAtom ( x_display, “_NET_WM_STATE_FULLSCREEN”, False );

XEvent xev;

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] = fullscreen;

XSendEvent ( // send an event mask to the X-server

x_display,

DefaultRootWindow ( x_display ),

False,

SubstructureNotifyMask,

&xev );

/// the egl part //

// egl provides an interface to connect the graphics related functionality of openGL ES

// with the windowing interface and functionality of the native operation system (X11

// in our case.

egl_display = eglGetDisplay( (EGLNativeDisplayType) x_display );

if ( egl_display == EGL_NO_DISPLAY ) {

cerr << “Got no EGL display.” << endl;

return 1;

}

if ( !eglInitialize( egl_display, NULL, NULL ) ) {

cerr << “Unable to initialize EGL” << endl;

return 1;

}

EGLint attr[] = { // some attributes to set up our egl-interface

EGL_BUFFER_SIZE, 16,

EGL_RENDERABLE_TYPE,

EGL_OPENGL_ES2_BIT,

EGL_NONE

};

EGLConfig ecfg;

EGLint num_config;

if ( !eglChooseConfig( egl_display, attr, &ecfg, 1, &num_config ) ) {

cerr << "Failed to choose config (eglError: " << eglGetError() << “)” << endl;

return 1;

}

if ( num_config != 1 ) {

cerr << "Didn’t get exactly one config, but " << num_config << endl;

return 1;

}

egl_surface = eglCreateWindowSurface ( egl_display, ecfg, win, NULL );

if ( egl_surface == EGL_NO_SURFACE ) {

cerr << "Unable to create EGL surface (eglError: " << eglGetError() << “)” << endl;

return 1;

}

egl-contexts collect all state descriptions needed required for operation

EGLint ctxattr[] = {

EGL_CONTEXT_CLIENT_VERSION, 2,

EGL_NONE

};

egl_context = eglCreateContext ( egl_display, ecfg, EGL_NO_CONTEXT, ctxattr );

if ( egl_context == EGL_NO_CONTEXT ) {

cerr << "Unable to create EGL context (eglError: " << eglGetError() << “)” << endl;

return 1;

}

associate the egl-context with the egl-surface

eglMakeCurrent( egl_display, egl_surface, egl_surface, egl_context );

/// the openGL part ///

GLuint vertexShader = load_shader ( vertex_src , GL_VERTEX_SHADER ); // load vertex shader

GLuint fragmentShader = load_shader ( fragment_src , GL_FRAGMENT_SHADER ); // load fragment shader

GLuint shaderProgram = glCreateProgram (); // create program object

glAttachShader ( shaderProgram, vertexShader ); // and attach both…

glAttachShader ( shaderProgram, fragmentShader ); // … shaders to it

glLinkProgram ( shaderProgram ); // link the program

glUseProgram ( shaderProgram ); // and select it for usage

now get the locations (kind of handle) of the shaders variables

position_loc = glGetAttribLocation ( shaderProgram , “position” );

phase_loc = glGetUniformLocation ( shaderProgram , “phase” );

offset_loc = glGetUniformLocation ( shaderProgram , “offset” );

if ( position_loc < 0 || phase_loc < 0 || offset_loc < 0 ) {

cerr << “Unable to get uniform location” << endl;

return 1;

}

const float

window_width = 800.0,

window_height = 480.0;

this is needed for time measuring --> frames per second

struct timezone tz;

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Linux运维工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Linux运维全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Linux运维知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加VX:vip1024b (备注Linux运维获取)
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Linux运维知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加VX:vip1024b (备注Linux运维获取)
[外链图片转存中…(img-ghdhs0q6-1712515794141)]

  • 13
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值