Jump to content
  • Advertisement

amp47

Member
  • Content Count

    10
  • Joined

  • Last visited

Community Reputation

117 Neutral

About amp47

  • Rank
    Member
  1. thanks man i miss that thanks for replay iam stragling with glfw3 and glew now i will use it only
  2. hello every one it's been a while i need strangh a way to use opengl combinned with wxWidgets i have codeblocks 13.12 and i have only wxwidgets installed on my pc platform windows 7 sp1 what i had tried befor : its just oppening wxWidgets wproject drag the glcanvas to the frame and this errore showup buildlogo: cppProjects/opengl/openglMain.cpp:77: undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&, int const*, wxPalette const&)' and message logo D:\project\cppProjects\opengl\openglMain.cpp|77|undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&, int const*, wxPalette const&)'| and like i just said i have wxwidgets only library  i also tried to include  <wx/glcanvas.h>. i hope you get it i don't know how to combine opengl with wxwidget .
  3. the compile share checking its true and the aPositionVertex its 0 i have try using the vao it's working but i didn't get very well so i decide to follow that tutorial step by step i don understand where i can transform the vertices to shader i am use this to compile and load shader #include "ShaderLoader.h" #include <stdio.h> ShaderLoader::ShaderLoader(const char *vs,const char *fs) { glfwGetCurrentContext(); GLenum err = glewInit(); if (GLEW_OK != err) { std::cout<<glewGetErrorString(err); } _programeHandl=glCreateProgram(); GLuint vertexShader=CompileSharder(GL_VERTEX_SHADER,vs); GLuint fragmentShader=CompileSharder(GL_FRAGMENT_SHADER,fs); glAttachShader(_programeHandl,vertexShader); glAttachShader(_programeHandl,fragmentShader); glLinkProgram(_programeHandl); glDeleteShader(vertexShader); glDeleteShader(fragmentShader); } GLuint ShaderLoader::getProgramehandl(){ return _programeHandl; } GLuint ShaderLoader::CompileSharder(GLenum shader,const char *source){ GLuint shaderHandle=glCreateShader(shader); glShaderSource(shaderHandle,1,&source,NULL); glCompileShader(shaderHandle); std::cout<<shaderHandle<<"\n"; // check for compile errors int params = -1; glGetShaderiv (shaderHandle, GL_COMPILE_STATUS, &params); if (GL_TRUE != params) { fprintf (stderr, "ERROR: GL shader index %i did not compile\n", shaderHandle); return false; // or exit or something } return shaderHandle; } ShaderLoader::~ShaderLoader() { glDeleteProgram(_programeHandl); } and please i want the basics on ho to draw something  i meant what i have to pass and bind just steps
  4. hi everyone i want to follow a tutorial series and i just do everything but the seen still blank first this what I've done till now i use the classes   gameWindow ,renderSystem VertexBuffer,ShaderInterface,shaderLoader and ResourceManger. i create the gameWindow inside it take a refrence to rendersystem and setup the context inside the gamewindow and take it bake on renderSytem i use this lines on render method void RenderSystem::render(VertexBuffer *vertexBuffer){     glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);     glUseProgram((vertexBuffer->getShader())->get_programHandle());     glLoadIdentity();     gluLookAt(0.0f,0.0f,-5.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f);     vertexBuffer->configureVertexAttributes();     vertexBuffer->renderVertexBuffer();     glfwSwapBuffers(_window);     glfwPollEvents(); } and callback this method on game loop the resoureceManager has a vector of vertex buffer and i pass the first element from this vector to the render method the vertexbuffer file is #include "VertexBuffer.h" VertexBuffer::VertexBuffer(GLvoid *data,GLsizeiptr dataSize,GLenum mode,GLsizei Count,GLsizei stride,ShaderInterface *shader): _mode(mode),_stride(stride),_count(Count),_shader(shader) { glGenBuffers(1,&_vertexBufferId); glBindBuffer(GL_ARRAY_BUFFER,_vertexBufferId); glBufferData(GL_ARRAY_BUFFER,dataSize,data,GL_STATIC_DRAW); } GLuint VertexBuffer::getVertexBufferId(){ return _vertexBufferId; } void VertexBuffer::configureVertexAttributes(){ if(_shader->get_aPositionVertex()!=-1){ glEnableVertexAttribArray(_shader->get_aPositionVertex()); glVertexAttribPointer(_shader->get_aPositionVertex(),3,GL_FLOAT,GL_FALSE,_stride,NULL); } } ShaderInterface *VertexBuffer::getShader(){ return _shader; } void VertexBuffer::renderVertexBuffer(){ glDrawArrays(_mode,1,_count); } VertexBuffer::~VertexBuffer() { glDeleteBuffers(1,&_vertexBufferId); _vertexBufferId=0; } i have create the buffer on the resourceManager on the constructor #include "ResourceManager.h" #include "Vertecies.h" ResourceManager::ResourceManager() { _shaderArray= new std::vector <ShaderInterface *>(); ShaderInterface *shader=new ShaderInterface("ColorSharder.vs","ColorSharder.fs"); _shaderArray->push_back(shader); _vertexbufferArray= new std::vector <VertexBuffer *>(); VertexBuffer *vertexBuffer=new VertexBuffer(vertices,sizeof(vertices),GL_TRIANGLES,3,3*sizeof(GLfloat),_shaderArray->at(0)); _vertexbufferArray->push_back(vertexBuffer); } std::vector <ShaderInterface *>*ResourceManager::getShaderArray(){ return _shaderArray; } std::vector <VertexBuffer *>*ResourceManager::getVertexBuffer(){ return _vertexbufferArray; } ResourceManager& ResourceManager::getResourceManager() { ResourceManager *resourceManager=NULL; if(resourceManager==NULL){ resourceManager=new ResourceManager(); } return *resourceManager; } void ResourceManager::destroyResourceManager() { ResourceManager *resourceManager=&getResourceManager(); delete resourceManager; } ResourceManager::~ResourceManager() { for(std::vector<ShaderInterface *>::iterator step=_shaderArray->begin();step!=_shaderArray->end();step++){ delete *step; } delete _shaderArray; for(std::vector<VertexBuffer *>::iterator step=_vertexbufferArray->begin();step!=_vertexbufferArray->end();step++){ delete *step; } delete _vertexbufferArray; } the bufferLoudaer is present below and i think is work just find because it print the index on buffer #include "ShaderLoader.h" #include <stdio.h> ShaderLoader::ShaderLoader(const char *vs,const char *fs) { glfwGetCurrentContext(); GLenum err = glewInit(); if (GLEW_OK != err) { std::cout<<glewGetErrorString(err); } _programeHandl=glCreateProgram(); GLuint vertexShader=CompileSharder(GL_VERTEX_SHADER,vs); GLuint fragmentShader=CompileSharder(GL_FRAGMENT_SHADER,fs); glAttachShader(_programeHandl,vertexShader); glAttachShader(_programeHandl,fragmentShader); glLinkProgram(_programeHandl); glDeleteShader(vertexShader); glDeleteShader(fragmentShader); } GLuint ShaderLoader::getProgramehandl(){ return _programeHandl; } GLuint ShaderLoader::CompileSharder(GLenum shader,const char *source){ GLuint shaderHandle=glCreateShader(shader); glShaderSource(shaderHandle,1,&source,NULL); glCompileShader(shaderHandle); std::cout<<shaderHandle<<"\n"; // check for compile errors int params = -1; glGetShaderiv (shaderHandle, GL_COMPILE_STATUS, &params); if (GL_TRUE != params) { fprintf (stderr, "ERROR: GL shader index %i did not compile\n", shaderHandle); return false; // or exit or something } return shaderHandle; } ShaderLoader::~ShaderLoader() { glDeleteProgram(_programeHandl); } the shaders i am use #version 400 attribute vec3 aPositionVertex; void main () { gl_Position =vec4 (aPositionVertex, 1.0); } //fragment shader #version 400 uniform vec4 uColor; void main () {   //frag_colour = uColor;   gl_FragColor= uColor; } i get the attributes from the shaderinterface with get_uColor() and get_aPositionVertex() but i don't know how to pass the vertexbuffer to this pointer _vertexShaderString=readShaderFile(fileVs); _fragmentShaderString=readShaderFile(fileFs); _shader=new ShaderLoader(_vertexShaderString,_fragmentShaderString); _aPositionVertex=glGetAttribLocation(_shader->getProgramehandl(),"aPositionVertex"); _uColor=glGetUniformLocation(_shader->getProgramehandl(),"uColor");
  5. hello everyone i am new on opengl so i have a lot of questions :   - i have a glfw3 library and the tutorial that i follow use the glfw ,and i need to know what is a difference between this tow versions. - when i try to make my source code a part i mean render engine and game classes its crash . please help me i try a single file cpp it's work but on the class version its crash
  6. hello every one i finally did it draw a triangle on the screen ,i want now to draw multi-shapes but i don't know where i must add a second  vertex buffer ,   this is the code source : #include <GL/glew.h> // include GLEW and new version of GL on Windows #define GLFW_DLL #include <GL/glfw3.h> // GLFW helper library #include <stdio.h> int main () { // start GL context and O/S window using the GLFW helper library if (!glfwInit ()) { fprintf (stderr, "ERROR: could not start GLFW3\n"); return 1; } // uncomment these lines if on Apple OS X /*glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);*/ GLFWwindow* window = glfwCreateWindow (640, 480, "Hello Triangle", NULL, NULL); if (!window) { fprintf (stderr, "ERROR: could not open window with GLFW3\n"); glfwTerminate(); return 1; } glfwMakeContextCurrent (window); // start GLEW extension handler glewExperimental = GL_TRUE; glewInit (); // get version info const GLubyte* renderer = glGetString (GL_RENDERER); // get renderer string const GLubyte* version = glGetString (GL_VERSION); // version as a string printf ("Renderer: %s\n", renderer); printf ("OpenGL version supported %s\n", version); // tell GL to only draw onto a pixel if the shape is closer to the viewer glEnable (GL_DEPTH_TEST); // enable depth-testing glDepthFunc (GL_LESS); // depth-testing interprets a smaller value as "closer" /* OTHER STUFF GOES HERE NEXT */ float points[] = { -0.5f, 0.5f, 0.0f, -0.25f, -0.0f, 0.0f, -0.75f, -0.0f, 0.0f, }; float points01[] = { //the rictangele 0.25f, 0.25f, 0.0f, 0.75f, 0.25f, 0.0f, 0.75f, -0.25f, 0.0f, 0.25f, -0.25f, 0.0f }; //create a vertex buffer and bind it for triangle GLuint vbo = 0; glGenBuffers (1, &vbo); glBindBuffer (GL_ARRAY_BUFFER, vbo); glBufferData (GL_ARRAY_BUFFER, 9 * sizeof (float), points, GL_STATIC_DRAW); //create a vertex buffer and bind it for rectangle GLuint vbo01=0; glGenBuffers (1, &vbo01); glBindBuffer (GL_ARRAY_BUFFER, vbo01); glBufferData (GL_ARRAY_BUFFER, 12 * sizeof (float), points01, GL_STATIC_DRAW); // Here we create a vertex attribute Object GLuint vao = 0; glGenVertexArrays (1, &vao); glEnableVertexAttribArray (0); glBindBuffer (GL_ARRAY_BUFFER, vbo); glVertexAttribPointer (0, 3, GL_FLOAT, GL_FALSE, 0, NULL); //second vattribute GLuint vao01 = 0; glGenVertexArrays (1, &vao01); glEnableVertexAttribArray (1); glBindBuffer (GL_ARRAY_BUFFER, vbo01); glVertexAttribPointer (1, 3, GL_FLOAT, GL_FALSE, 0, NULL); //shader parts //vertex shader const char* vertex_shader = "#version 400\n" "in vec3 vp;" "void main () {" " gl_Position = vec4 (vp, 1.0);" "}"; //fragment shader const char* fragment_shader = "#version 400\n" "out vec4 frag_colour;" "void main () {" " frag_colour = vec4 (0.8, 0.5, 0.5, 1.0);" "}"; //load shader GLuint vs = glCreateShader (GL_VERTEX_SHADER); glShaderSource (vs, 1, &vertex_shader, NULL); glCompileShader (vs); //load fragment shader GLuint fs = glCreateShader (GL_FRAGMENT_SHADER); glShaderSource (fs, 1, &fragment_shader, NULL); glCompileShader (fs); //create the program GLuint shader_programme = glCreateProgram (); //attach the vertex shader and fragment shader to the program glAttachShader (shader_programme, fs); glAttachShader (shader_programme, vs); //link the program glLinkProgram (shader_programme); //drawing while (!glfwWindowShouldClose (window)) { // wipe the drawing surface clear glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram (shader_programme); glBindVertexArray (vao); // draw points 0-3 from the currently bound VAO with current in-use shader glBindVertexArray (vao01); glDrawArrays (GL_TRIANGLES, 1,3); // draw points 0-3 from the currently bound VAO with current in-use shader glDrawArrays (GL_QUADS,0,4); // update other events like input handling glfwPollEvents (); // put the stuff we've been drawing onto the display glfwSwapBuffers (window); } // close GL context and any other GLFW resources glfwTerminate(); return 0; }
  7. i have tried that but its still show the error ||=== Clean: Debug in cgame (compiler: GNU GCC Compiler) ===| ||=== Build: Debug in cgame (compiler: GNU GCC Compiler) ===| E:\CppProjects\cgame\GameWindow.h||In constructor 'GameWindow::GameWindow(bool)':| E:\CppProjects\cgame\GameWindow.h|17|warning: 'GameWindow::_window' will be initialized after [-Wreorder]| E:\CppProjects\cgame\GameWindow.h|14|warning:   'RenderEngine* GameWindow::_render' [-Wreorder]| E:\CppProjects\cgame\GameWindow.cpp|14|warning:   when initialized here [-Wreorder]| E:\CppProjects\cgame\RenderEngine.cpp|39|warning: 'renderEngine' is used uninitialized in this function [-Wuninitialized]| ||Warning: .drectve `/DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized| E:\CppProjects\glew-1.11.0-win32_3\glew-1.11.0\lib\Release\Win32\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x7)||undefined reference to `_imp__wglGetProcAddress@4'| E:\CppProjects\glew-1.11.0-win32_3\glew-1.11.0\lib\Release\Win32\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x4)||undefined reference to `_imp__wglGetProcAddress@4'| ||=== Build failed: 2 error(s), 5 warning(s) (0 minute(s), 4 second(s)) ===|   i am using this includes : #define GLFW_INCLUDE_GLU #define GLEW_STATIC #include <GL/glew.h> #include <GL/glfw3.h> #include "VertexBuffer.h" #include "ShaderInterface.h" #include <vector> #include <iostream>
  8. thanks for reply  iam using this on linker>>other options -lglew32 -lopengl32 -glfw32 -lglu32
  9. i am a new on opengl and following a tutorials but at this poient get stuck and this error show i don't know what can i do to solve it this   E:\**********CppProjects\glew-1.11.0-win32_3\glew-1.11.0\lib\Release\Win32\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x7)||undefined reference to `_imp__wglGetProcAddress@4'| please i need to know that cause this problem 
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!