• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Dark Engineer

  • Content count

  • Joined

  • Last visited

Community Reputation

132 Neutral

About Dark Engineer

  • Rank
  1. It doesn't show errors but if i want to put this cameraInstance to the Camera class and my class is used by one another class then shows 1>main.obj : error LNK2005: "class Camera * cameraInstance" (?cameraInstance@@3PAVCamera@@A) already defined in Camera.obj 1>Pipeline.obj : error LNK2005: "class Camera * cameraInstance" (?cameraInstance@@3PAVCamera@@A) already defined in Camera.obj 1> fatal error LNK1169: one or more multiply defined symbols found
  2. This glfwSetKeyCallback(Camera::keyWrapper);   don't work error C2664: 'glfwSetKeyCallback' : cannot convert parameter 1 from 'bool (__cdecl *)(int)' to 'GLFWkeyfun' 1>          None of the functions with this name in scope match the target type
  3. I have this function bool Camera::onKeyboard( int Key ) { bool Ret = false; switch (Key) { case GLFW_KEY_UP: { m_pos += (m_target * STEP_SCALE ); Ret = true; } break; case GLFW_KEY_DOWN: { m_pos -= (m_target * STEP_SCALE ); Ret = true; } break; case GLFW_KEY_LEFT: { glm::vec3 left = glm::cross(m_target, m_up ); glm::normalize(left); left *= STEP_SCALE; m_pos += left; Ret = true; } break; case GLFW_KEY_RIGHT: { glm::vec3 right = glm::cross(m_up, m_target); glm::normalize(right); right *= STEP_SCALE; m_pos += right; Ret = true; } break; } return Ret; } Adn when i try to make function and run it void GLFWCALL Camera::keyWrapper(int Key) { onKeyboard(Key); } glfwSetKeyCallback(pGameCamera->keyWrapper); it doesn't work. Can someone help me how to do it correct?
  4. thanks for advice, i'm using this site but not from the beginning, i will try to study it again
  5. I have code where i initialize mesh: #ifndef Mesh_h #define Mesh_h #include "Texture.h" #include "Technique.h" #include <map> #include <vector> #include <GL/glew.h> #include <glm/glm.hpp> #include <list> #include <assimp/Importer.hpp> // C++ importer interface #include <assimp/scene.h> // Output data structure #include <assimp/postprocess.h> // Post processing flags struct Vertex { glm::vec3 m_pos; glm::vec2 m_tex; glm::vec3 m_normal; Vertex() {} Vertex(const glm::vec3& pos, const glm::vec2& tex, const glm::vec3& normal) { m_pos = pos; m_tex = tex; m_normal = normal; } }; class Mesh : public Technique { bool init(); bool initFromScene(const aiScene* pScene, const std::string &Filename); void initMesh(unsigned int index, const aiMesh* paiMesh); bool initMaterials(const aiScene* pScene, const std::string &Filename); void clear(); #define INVALID_MATERIAL 0xFFFFFFFF struct MeshEntry { MeshEntry(); ~MeshEntry(); void init(const std::vector<Vertex> & vertices, const std::vector<unsigned int> & indices); GLuint VB; GLuint IB; unsigned int numIndices; unsigned int materialIndex; }; GLint gSamplerLocation; GLint WVPLocation; std::vector <MeshEntry> m_Entries; std::vector <Texture*> m_Textures; public: Mesh(); ~Mesh(); bool loadMesh(const std::string &filename); void render(); }; #endif #include "Mesh.h" Mesh::Mesh() { } Mesh::~Mesh() { clear(); } void Mesh::clear() { for(unsigned int i = 0; i < m_Textures.size(); i++) delete m_Textures[i]; } Mesh::MeshEntry::MeshEntry() { VB = GL_INVALID_ENUM; IB = GL_INVALID_ENUM; numIndices = 0; materialIndex = INVALID_MATERIAL; } Mesh::MeshEntry::~MeshEntry() { if(VB != GL_INVALID_ENUM) glDeleteBuffers(1, &VB); if(IB != GL_INVALID_ENUM) glDeleteBuffers(1, &IB); } void Mesh::MeshEntry::init(const std::vector<Vertex> & vertices, const std::vector<unsigned int> & indices) { numIndices = indices.size(); glGenBuffers(1, &VB); glBindBuffer(GL_ARRAY_BUFFER, VB); glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * vertices.size(), &vertices[0], GL_STATIC_DRAW); glGenBuffers(1, &IB); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IB); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * numIndices, &indices[0], GL_STATIC_DRAW); } bool Mesh::loadMesh(const std::string & filename) { clear(); bool Ret = false; Assimp::Importer importer; const aiScene* pScene = importer.ReadFile(filename.c_str(), aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs); if(pScene) Ret = initFromScene(pScene, filename); else std::cout << "Error passing " << filename << " : " << importer.GetErrorString() << std::endl; return Ret; } bool Mesh::init() { if(!Technique::init()) return false; if(!addShader(Shader::VERTEX_SHADER, "vs.glsl")) return false; if(!addShader(Shader::FRAGMENT_SHADER, "fs.glsl")) return false; if(!finalize()) return false; gSamplerLocation = getUniformLocation("gSampler"); WVPLocation = getUniformLocation("gWVP"); if(gSamplerLocation == 0xFFFFFFFF || WVPLocation == 0xFFFFFFFF) return false; return true; } bool Mesh::initFromScene(const aiScene* pScene, const std::string &filename) { m_Entries.resize(pScene->mNumMeshes); m_Textures.resize(pScene->mNumMaterials); for(unsigned int i = 0; i < m_Entries.size(); i++) { const aiMesh* paiMesh = pScene->mMeshes[i]; initMesh(i, paiMesh); } return initMaterials(pScene, filename); } void Mesh::initMesh(unsigned int index, const aiMesh* paiMesh) { if(!init()) std::cout << "Failed to initialize shaders" << std::endl; m_Entries[index].materialIndex = paiMesh->mMaterialIndex; std::vector <Vertex> vertices; std::vector <unsigned int> indices; const aiVector3D zero3D(0.0f, 0.0f, 0.0f); for(unsigned int i = 0; i < paiMesh->mNumVertices; i++) { const aiVector3D * pPos = &(paiMesh->mVertices[i]); const aiVector3D *pNormal = &(paiMesh->mNormals[i]); const aiVector3D *pTextCoord = paiMesh->HasTextureCoords(0) ? &(paiMesh->mTextureCoords[0][i]) : &zero3D; Vertex v(glm::vec3(pPos->x, pPos->y, pPos->z), glm::vec2(pTextCoord->x, pTextCoord->y), glm::vec3(pNormal->x, pNormal->y, pNormal->z)); vertices.push_back(v); } for(unsigned int i = 0; i < paiMesh->mNumFaces; i++) { const aiFace &face = paiMesh->mFaces[i]; indices.push_back(face.mIndices[0]); indices.push_back(face.mIndices[1]); indices.push_back(face.mIndices[2]); } m_Entries[index].init(vertices, indices); } bool Mesh::initMaterials(const aiScene* pScene, const std::string &filename) { std::string::size_type SlashIndex = filename.find_last_of("/"); std::string Dir; if (SlashIndex == std::string::npos) { Dir = "."; } else if (SlashIndex == 0) { Dir = "/"; } else { Dir = filename.substr(0, SlashIndex); } bool Ret = true; for(unsigned int i = 0; i < pScene->mNumMaterials; i++) { const aiMaterial *pMaterial = pScene->mMaterials[i]; m_Textures[i] = NULL; if (pMaterial->GetTextureCount(aiTextureType_DIFFUSE) > 0) { aiString path; if(pMaterial->GetTexture(aiTextureType_DIFFUSE, 0, &path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) { std::string fullPath = Dir + "/" + path.data; m_Textures[i] = new Texture(GL_TEXTURE_2D, path.C_Str()); if(!m_Textures[i]->Load()) { std::cout << "Error Loading texture " << path.C_Str() << std::endl; delete m_Textures[i]; m_Textures[i] = NULL; Ret = false; } else std::cout << "Loaded texture " << path.C_Str() << std::endl; } } if(!m_Textures[i]) { std::cout << "No textures" << std::endl; m_Textures[i] = new Texture(GL_TEXTURE_2D, "/white.png"); Ret = m_Textures[i]->Load(); } } return Ret; } void Mesh::render() { glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); for(unsigned int i = 0; i < m_Entries.size(); i++) { glBindBuffer(GL_ARRAY_BUFFER, m_Entries[i].VB); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)12); glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)20); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_Entries[i].IB); const unsigned int materialIndex = m_Entries[i].materialIndex; if( materialIndex < m_Textures.size() && m_Textures[materialIndex]) { m_Textures[materialIndex]->Bind(GL_TEXTURE0); } glDrawElements(GL_TRIANGLES, m_Entries[i].numIndices, GL_UNSIGNED_INT, 0); } glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glDisableVertexAttribArray(2); } but when i try to render it with this methods in render() function it doesn't work, how can i change this code to get it working? Can i make shaders and use it? Edit// On the screen i see only white color? What to do?
  6. My mesh wasn't work properly so i was thinking that is because i don't have lights
  7. I wrote code for mesh and light but when i'm trying to see this things they don't show. On the screen i see only black color nothing else My code is here https://github.com/DarkEngineer/Crion-World
  8. OpenGL

    Solved it just needed to change in loop GLFW_WINDOW to GLFW_OPENED
  9. OpenGL

    I have in console and logs that both shaders loaded successfully and program loaded successfully but still have this same error. Maybe i made something wrong with creating window.
  10. OpenGL

    SimpleFragmentShader #version 150 out vec4 outColor; void main() {     outColor = vec4( 1.0, 1.0, 1.0, 1.0 ); } SimpleVertexShader #version 150 in vec2 position; void main() {     gl_Position = vec4( position, 0.0, 1.0 ); } and function for loading them string loadShaderFile(const string fileName) {          ifstream shaderFile( fileName.c_str());     //find the file size     shaderFile.seekg(0, ios::end);     std::streampos length = shaderFile.tellg();     shaderFile.seekg(0, ios::beg);     //read whole file into a vector     vector<char> buffer(length);     shaderFile.read(&buffer[0], length);     //return the shader string     return string( buffer.begin(), buffer.end()); } I think something is wrong under 53 line but i'm begginer in OpenGL
  11. OpenGL

    It doesn't change anything. When i turn application on then debug error appears with Invalid allocation size: 4294967295 bytes
  12. I have problem with this code because it doesn't show anything in a window, vertex and fragment shaders are loading successfully but glGetError shows something wrong is here. Please someone help me. #include "loadshader.h" int main() { glfwInit(); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE); glfwOpenWindow(800, 600, 0, 0, 0, 0, 0, 0, GLFW_WINDOW); glfwSetWindowTitle("Crion World Alpha"); glewExperimental = GL_TRUE; glewInit(); GLuint vertexBuffer; glGenBuffers( 1, &vertexBuffer ); GLuint vao; glGenVertexArrays(1, & vao); glBindVertexArray( vao ); GLuint vbo; glGenBuffers( 1, &vbo); //generate 1 buffer float vertices[] = { 0.0f, 0.5f, 0.5f, -0.5f, -0.5f, -0.5f }; glBindBuffer( GL_ARRAY_BUFFER, vbo ); glBufferData( GL_ARRAY_BUFFER, sizeof( vertices ), vertices, GL_STATIC_DRAW ); // vertex shader loading const string vShaderString = loadShaderFile("SimpleVertexShader.vertexshader").c_str(); const GLchar * tempVShader = vShaderString.c_str(); GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER ); glShaderSource(vertexShader, 1, & tempVShader, NULL); glCompileShader( vertexShader ); std::fstream logs; logs.open( "logs.txt", ios::in | ios::out | ios::trunc ); char vsbuffer[512]; glGetShaderInfoLog( vertexShader, 512, NULL, vsbuffer ); logs << vsbuffer; //fragment shader loading const string fShaderString = loadShaderFile("SimpleFragmentShader.fragmentshader").c_str(); const GLchar * tempFShader = fShaderString.c_str(); GLuint fragmentShader = glCreateShader( GL_FRAGMENT_SHADER ); glShaderSource(fragmentShader, 1, & tempFShader, NULL ); glCompileShader(fragmentShader); char fsbuffer[512]; glGetShaderInfoLog( fragmentShader, 512, NULL, fsbuffer ); logs << fsbuffer; if(glGetError() != 0) { logs << "sth errors"; cout << "sth wrong" << endl; } logs.close(); GLuint shaderProgram = glCreateProgram(); glAttachShader( shaderProgram, vertexShader ); glAttachShader( shaderProgram, fragmentShader); glBindFragDataLocation( shaderProgram, 0, "outColor" ); glLinkProgram( shaderProgram ); glUseProgram( shaderProgram ); GLint posAttrib = glGetAttribLocation( shaderProgram, "position" ); glEnableVertexAttribArray( posAttrib ); glVertexAttribPointer( posAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0 ); while( glfwGetWindowParam( GLFW_WINDOW ) ) { glDrawArrays( GL_TRIANGLES, 0, 3); glfwSwapBuffers(); } glDeleteProgram( shaderProgram ); glDeleteShader( vertexShader ); glDeleteShader( fragmentShader ); glDeleteBuffers(1, & vbo ); glDeleteVertexArrays(1, &vao ); glfwTerminate(); return 0; }
  13. OpenGL

  14. OpenGL

    I don't know how to create glsl object
  15. OpenGL

    I have problem with glsl on windows 8 in Microsoft Visual Studio Express 2012 with Radeon. Even #version 150 is not recognized in code.   #version 150 #include <glm\ext.hpp> #include <glm\glm.hpp> #include <GL\glew.h> #include <GL\glut.h> #include <GL\GL.h> #include <GL\GLU.h> #include <GL\glfw.h> in vec2 position; out vec4 outColor; int main() { vec3 commeo; glfwInit(); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE); glfwOpenWindow(800, 600, 0, 0, 0, 0, 0, 0, GLFW_WINDOW); glfwSetWindowTitle("Crion World Alpha"); while( glfwGetWindowParam( GLFW_WINDOW ) ) { glfwSwapBuffers(); } if( glfwGetKey( GLFW_KEY_ESC ) == GLFW_PRESS ) return 0; glewExperimental = GL_TRUE; glewInit(); GLuint vertexBuffer; glGenBuffers( 1, &vertexBuffer ); printf( "%u\n", vertexBuffer); float vertices[] = { 0.0f, 0.5f, 0.5f, -0.5f, -0.5f, -0.5f }; GLuint vbo; glGenBuffers( 1, &vbo); //generate 1 buffer glBindBuffer( GL_ARRAY_BUFFER, vbo ); glBufferData( GL_ARRAY_BUFFER, sizeof( vertices ), vertices, GL_STATIC_DRAW ); GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER ); glShaderSource( vertexShader, 1, &vertexSource, NULL ); glCompileShader( vertexShader ); glfwTerminate(); return 0; } I have errors:   1 IntelliSense: unrecognized preprocessing directive /// #version 150 2 IntelliSense: identifier "in" is undefined 4 IntelliSense: identifier "out" is undefined 6 IntelliSense: identifier "vec3" is undefined 7 IntelliSense: identifier "vertexSource" is undefined I have linked: opengl32.lib glu32.lib glut32.lib glfwdll.lib glew32d.lib