Given the following arrays of vertices and colors set up a vertex array object a
ID: 3603004 • Letter: G
Question
Given the following arrays of vertices and colors set up a vertex array object and a buffer with 2 sub buffers, one with the vertex data and one with color data, using OpenGL. Setup 2 attributes for the vertex shader "vPosition" and "vColor".
1. Given the following arrays of vertices and colors set up a vertex array object and a buffer with 2 sub-buffers, one with the vertex data and one with the color data, using OpenGL Setup 2 attributes for the vertex shader "vPosition" and "vColor 1 float vertices[] = { 0.0, 0.0, 0.0. 1.0. // x, y, z. W 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, float colors[] = { 1.0, 1.0, 1.0. 1.0, // r, g, b, aExplanation / Answer
int a[10];
int (*p_a)[10] = &a;
int with bounds 10, i.e. p_a = &a[0];
int *p_int = a;
int b[10][20];
int (*p_b)[20] = b;
int foo(int a[n]);
int f(float array[const restrict]);
f(float *const restrict array);
void foo(int a[static 10]);
float a[m*n*sizeof(float)];
for (i = 0; i < m; ++i)
for (j = 0; j < n; ++j)
a[i*n + j] = 1.0;
float a[m][n];
int i, j;
for (i = 0; i < m; ++i)
for (j = 0; j < n; ++j)
a[i][j] = 1.0;
char* pChar2D[] = {"A long long long string", "short", "something else"};
printf(pChar2D[0]);
int r0[] = malloc(sizeof(int) * 10);
int r1[] = malloc(sizeof(int) * 2);;
int *jagged[] = { r0, r1 };
printf("%d %d, jagged[0][9], jagged[1][1]);
8
9
10
11
12
13
14
15
int a[100] = {[0]=5, [99]=100};
struct S1 {
int i;
float f;
int a[2];
};
struct S1 x = {
.f=3.1,
.i=2,
.a[1]=9
};
(float){3.14};
(struct POINT){10, 10};
(char []){"Compound Literal Array"};
(const char[]){"A CONSTANT compound literal array"};
var vs_points = `
attribute vec3 vPosition;
attribute vec4 vRgbaColor;
attribute float vPointSize;
varying vec4 color;
void
main()
{
gl_Position = vec4(vPosition, 1.0);
gl_PointSize = vPointSize;
color = vRgbaColor;
}`;
var fs_point_default = `
precision mediump float;
varying vec4 color;
void
main()
{
float alpha = 1.0;
gl_FragColor = color * (alpha);
}`;
var point = [0.0, 0.0, 0.0];
var color = [1.0, 0.0, 0.0, 1.0];
var size = [400.0];
var canvas = document.getElementById("point-canvas");
initGL(canvas);
shaderPointDefault = initShaders(0);
initBuffers(point, color, size);
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.enable(gl.DEPTH_TEST);
drawScene(shaderPointDefault);
var fs_point_alias = `
precision mediump float;
varying vec4 color;
void
main()
{
float r = 0.0, delta = 0.0, alpha = 1.0;
vec2 cxy = 2.0 * gl_PointCoord - 1.0;
r = dot(cxy, cxy);
if (r > 1.0) {
discard;
}
gl_FragColor = color * (alpha);
}`;
var fs_point_anti_alias = `
#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif
precision mediump float;
varying vec4 color;
void main()
{
float r = 0.0, delta = 0.0, alpha = 1.0;
vec2 cxy = 2.0 * gl_PointCoord - 1.0;
r = dot(cxy, cxy);
#ifdef GL_OES_standard_derivatives
delta = fwidth(r);
alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);
#endif
gl_FragColor = color * alpha;
}`;
void i2c_read(byte seven_bit_address, byte reg, byte* pData, byte len ) {
byte i = 0;
Wire.beginTransmission(seven_bit_address);
Wire.write(reg);
Wire.endTransmission(false);
Wire.requestFrom(seven_bit_address, len, true);
while (Wire.available() && (i < len))
{
*pData++ = Wire.read();
i++;
}
}
void i2c_write(byte seven_bit_address, byte reg, byte* pData, byte len ) {
Wire.beginTransmission(seven_bit_address);
Wire.write(reg);
for (int i = 0; i < len; i++) {
Wire.write(*pData++);
}
Wire.endTransmission();
}
void i2c_write(byte seven_bit_address, byte reg, byte value ) {
Wire.beginTransmission(seven_bit_address);
Wire.write(reg);
Wire.write(value);
Wire.endTransmission();
}
Serial.begin(230400);
Wire.begin();
Wire.setClock(400000L);
byte id;
i2c_read(0x57, 0xFF, &id, 1);
Serial.println("Part ID:");
Serial.print(id, HEX);
byte data;
data = (byte)0xA << 4 | (byte)0xB;
i2c_write(0x57, 0x09, &data, 1);
i2c_read(0x57, 0x09, &data, 1);
Serial.println("LED Config = ");
Serial.print(data, HEX);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.