Last active
August 23, 2017 05:30
-
-
Save bis83/0e30b6ef15092909ae890055ad57b6f1 to your computer and use it in GitHub Desktop.
GLES-TEST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use utils) | |
(system "gcc test.c -lEGL -lGLESv2 -lglfw3") | |
(exit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./a.exe | |
This application has requested the Runtime to terminate it in an unusual way. | |
Please contact the application's support team for more information. | |
Assertion failed! | |
Program: C:\msys64\home\bis\gltest\a.exe | |
File: ../src/libANGLE/ContextState.h, Line 153 | |
Expression: mSavedArgsType->hasDynamicType(T::TypeInfo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define GLFW_INCLUDE_ES2 | |
#include <GLFW/glfw3.h> | |
#include <stdio.h> | |
void error_callback(int error, const char* desc) { | |
fprintf(stdout, "%s\n", desc); | |
} | |
int main() { | |
glfwInit(); | |
glfwSetErrorCallback(error_callback); | |
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); | |
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); | |
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); | |
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); | |
GLFWwindow* wp = glfwCreateWindow(320, 240, "test", NULL, NULL); | |
glfwMakeContextCurrent(wp); | |
//fprintf(stdout, "GL_VENDOR: %s\n", glGetString(GL_VENDOR)); | |
//fprintf(stdout, "GL_RENDERER: %s\n", glGetString(GL_RENDERER)); | |
//fprintf(stdout, "GL_VERSION: %s\n", glGetString(GL_VERSION)); | |
//fprintf(stdout, "GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS)); | |
GLuint ib; | |
glGenBuffers(1, &ib); | |
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ib); | |
unsigned short idata[] = { 0, 0 }; | |
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 4, idata, GL_STATIC_DRAW); | |
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | |
// VertexShader | |
const char* vssource = | |
"#version 100\n" | |
"void main() { gl_PointSize = 10.0; gl_Position = vec4(0, 0, 0, 1); }"; | |
GLuint vs = glCreateShader(GL_VERTEX_SHADER); | |
glShaderSource(vs, 1, &vssource, NULL); | |
glCompileShader(vs); | |
// FragmentShader | |
const char* fssource = | |
"#version 100\n" | |
"void main() { gl_FragColor = vec4(1, 1, 1, 1); }"; | |
GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); | |
glShaderSource(fs, 1, &fssource, NULL); | |
glCompileShader(fs); | |
// Program | |
GLuint program = glCreateProgram(); | |
glAttachShader(program, vs); | |
glAttachShader(program, fs); | |
glLinkProgram(program); | |
while(!glfwWindowShouldClose(wp)) { | |
glfwPollEvents(); | |
glUseProgram(program); | |
glClearColor(1, 0, 0, 0); | |
glClear(GL_COLOR_BUFFER_BIT); | |
// ng | |
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ib); | |
glDrawElements(GL_POINTS, 1, GL_UNSIGNED_SHORT, NULL); | |
// ok | |
glDrawArrays(GL_POINTS, 0, 1); | |
glfwSwapBuffers(wp); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment