update
This commit is contained in:
parent
ddcec9cb64
commit
2e69327371
2
.gitignore
vendored
2
.gitignore
vendored
@ -26,7 +26,7 @@ build
|
|||||||
# Compiled Static libraries
|
# Compiled Static libraries
|
||||||
*.lai
|
*.lai
|
||||||
*.la
|
*.la
|
||||||
*.a
|
# *.a
|
||||||
|
|
||||||
# Executables
|
# Executables
|
||||||
*.exe
|
*.exe
|
||||||
|
@ -16,7 +16,7 @@ pybind11_add_module(${PROJECT_NAME} ${SRC})
|
|||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
target_link_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/libs)
|
target_link_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/libs)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE glew32.lib)
|
target_link_libraries(${PROJECT_NAME} PRIVATE glew)
|
||||||
|
|
||||||
add_subdirectory( ${PROJECT_SOURCE_DIR}/glfw )
|
add_subdirectory( ${PROJECT_SOURCE_DIR}/glfw )
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE glfw)
|
target_link_libraries(${PROJECT_NAME} PRIVATE glfw)
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include<pybind11/pybind11.h>
|
||||||
|
#include<pybind11/stl.h>
|
||||||
|
namespace py = pybind11;
|
||||||
|
|
||||||
namespace tests{
|
namespace tests{
|
||||||
int glfw_window(unsigned width,unsigned height, std::string title);
|
int glfw_window(unsigned width,unsigned height, std::string title);
|
||||||
|
int glfw_black_window(unsigned width,unsigned height,std::string title);
|
||||||
}
|
}
|
BIN
libs/glew32.lib
BIN
libs/glew32.lib
Binary file not shown.
BIN
libs/glew32s.lib
BIN
libs/glew32s.lib
Binary file not shown.
BIN
libs/libglew-shared.dll.a
Normal file
BIN
libs/libglew-shared.dll.a
Normal file
Binary file not shown.
BIN
libs/libglew.a
Normal file
BIN
libs/libglew.a
Normal file
Binary file not shown.
67
src/glfw_black_window.cpp
Normal file
67
src/glfw_black_window.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#include <glpy.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
// #include <GL/glew.h>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int tests::glfw_black_window(unsigned width,unsigned height,std::string title)
|
||||||
|
{
|
||||||
|
GLFWwindow* window;
|
||||||
|
|
||||||
|
/* Initialize the library */
|
||||||
|
if (!glfwInit())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Create a windowed mode window and its OpenGL context */
|
||||||
|
window = glfwCreateWindow(width, height, title.c_str(), NULL, NULL);
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make the window's context current */
|
||||||
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
|
std::cout<<"-- OPEN_GL_VERSION: "<<glGetString(GL_VERSION)<<std::endl;
|
||||||
|
|
||||||
|
// float positions[6] = {
|
||||||
|
// -0.5f,-0.5f,
|
||||||
|
// 0.0f, 0.5f,
|
||||||
|
// 0.5f,-0.5f,
|
||||||
|
// };
|
||||||
|
|
||||||
|
// unsigned int buffer;
|
||||||
|
// glGenBuffers(1,&buffer);
|
||||||
|
// glBindBuffer(GL_ARRAY_BUFFER,buffer);
|
||||||
|
// glBufferData(GL_ARRAY_BUFFER,6 * sizeof(float),positions,GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
// glEnableVertexAttribArray(0);
|
||||||
|
// glVertexAttribPointer(0,2,GL_FLOAT,GL_FALSE,2*sizeof(float),0);
|
||||||
|
|
||||||
|
// glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||||
|
|
||||||
|
/* Loop until the user closes the window */
|
||||||
|
while (!glfwWindowShouldClose(window))
|
||||||
|
{
|
||||||
|
/* Render here */
|
||||||
|
// glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
//create a triangle
|
||||||
|
// glDrawArrays(GL_TRIANGLES,0, 3);
|
||||||
|
// glBegin(GL_TRIANGLES);
|
||||||
|
// glVertex2f(-0.5f,-0.5f);
|
||||||
|
// glVertex2f(0.0f,0.5f );
|
||||||
|
// glVertex2f(0.5f,-0.5f);
|
||||||
|
// glEnd();
|
||||||
|
|
||||||
|
/* Swap front and back buffers */
|
||||||
|
glfwSwapBuffers(window);
|
||||||
|
|
||||||
|
/* Poll for and process events */
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
|
return 0;
|
||||||
|
}
|
14
src/main.cpp
14
src/main.cpp
@ -1,18 +1,18 @@
|
|||||||
#include <pybind11/pybind11.h>
|
|
||||||
#include <pybind11/stl.h>
|
|
||||||
#include <glpy.h>
|
#include <glpy.h>
|
||||||
|
|
||||||
|
|
||||||
namespace py = pybind11;
|
|
||||||
|
|
||||||
|
|
||||||
PYBIND11_MODULE(glpy, m) {
|
PYBIND11_MODULE(glpy, m) {
|
||||||
m.doc() = "glpy a python opengl project"; // optional module docstring
|
m.doc() = "glpy a python opengl project"; // optional module docstring
|
||||||
auto tests = m.def_submodule("tests","the tests module");
|
auto tests = m.def_submodule("tests","the tests module");
|
||||||
|
|
||||||
tests.def("glfw_window",&tests::glfw_window,
|
tests.def("glfw_black_window",&tests::glfw_black_window,
|
||||||
py::arg("width"),
|
py::arg("width"),
|
||||||
py::arg("height"),
|
py::arg("height"),
|
||||||
py::arg("title")
|
py::arg("title")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// tests.def("glfw_window",&tests::glfw_window,
|
||||||
|
// py::arg("width"),
|
||||||
|
// py::arg("height"),
|
||||||
|
// py::arg("title")
|
||||||
|
// );
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
#include <pybind11/stl.h>
|
#include <glpy.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <glpy.h>
|
|
||||||
|
|
||||||
static int CreateShader(const std::string& vertexShader, const std::string& fragmentShader){
|
static int CreateShader(const std::string& vertexShader, const std::string& fragmentShader){
|
||||||
unsigned int program = glCreateProgram();
|
unsigned int program = glCreateProgram();
|
||||||
@ -17,8 +17,6 @@ int tests::glfw_window(unsigned width,unsigned height, std::string title)
|
|||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Create a windowed mode window and its OpenGL context */
|
/* Create a windowed mode window and its OpenGL context */
|
||||||
window = glfwCreateWindow(width, height, title.c_str(), NULL, NULL);
|
window = glfwCreateWindow(width, height, title.c_str(), NULL, NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
|
Loading…
Reference in New Issue
Block a user