Jump to content
  • Advertisement

Search the Community

Showing results for tags 'C++'.

The search index is currently processing. Current results may not be complete.


More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • Audio
    • Music and Sound FX
  • Business
    • Business and Law
    • Career Development
    • Production and Management
  • Game Design
    • Game Design and Theory
    • Writing for Games
    • UX for Games
  • Industry
    • Interviews
    • Event Coverage
  • Programming
    • Artificial Intelligence
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Engines and Middleware
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
  • Archive

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • Game Dev Loadout
  • Game Dev Unchained

Categories

  • Game Developers Conference
    • GDC 2017
    • GDC 2018
  • Power-Up Digital Games Conference
    • PDGC I: Words of Wisdom
    • PDGC II: The Devs Strike Back
    • PDGC III: Syntax Error

Forums

  • Audio
    • Music and Sound FX
  • Business
    • Games Career Development
    • Production and Management
    • Games Business and Law
  • Game Design
    • Game Design and Theory
    • Writing for Games
  • Programming
    • Artificial Intelligence
    • Engines and Middleware
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
    • 2D and 3D Art
    • Art Critique and Feedback
  • Community
    • GameDev Challenges
    • GDNet+ Member Forum
    • GDNet Lounge
    • GDNet Comments, Suggestions, and Ideas
    • Coding Horrors
    • Your Announcements
    • Hobby Project Classifieds
    • Indie Showcase
    • Article Writing
  • Affiliates
    • NeHe Productions
    • AngelCode
  • Topical
    • Virtual and Augmented Reality
    • News
  • Workshops
    • C# Workshop
    • CPP Workshop
    • Freehand Drawing Workshop
    • Hands-On Interactive Game Development
    • SICP Workshop
    • XNA 4.0 Workshop
  • Archive
    • Topical
    • Affiliates
    • Contests
    • Technical
  • GameDev Challenges's Topics
  • For Beginners's Forum
  • Unreal Engine Users's Unreal Engine Group Forum
  • Unity Developers's Forum
  • Unity Developers's Asset Share

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams
  • GameDev Challenges's Schedule

Blogs

There are no results to display.

There are no results to display.

Product Groups

  • Advertisements
  • GameDev Gear

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


Website


Role


Twitter


Github


Twitch


Steam

Found 28 results

  1. phil67rpg

    OpenGL tic tac toe

    well I am working on a simpler game called tic tac toe, my question is how do I get the mouse click to draw an X on the board. when I click the mouse nothing happens. #include <freeglut.h> #include <iostream> using namespace std; void drawBoard() { glPushMatrix(); glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_LINE_STRIP); glVertex3f(-18.75f, 6.25f, 0.0f); glVertex3f(18.75f, 6.25f, 0.0f); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f(-18.75f, -6.25f, 0.0f); glVertex3f(18.75f, -6.25f, 0.0f); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f(-6.25f, 18.75f, 0.0f); glVertex3f(-6.25f, -18.75f, 0.0f); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f(6.25f, 18.75f, 0.0f); glVertex3f(6.25f, -18.75f, 0.0f); glEnd(); glPopMatrix(); } void drawText() { glColor3f(0.0f, 1.0f, 1.0f); glRasterPos2f(10.0f, 10.0f); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'X'); } void renderScene() { glClear(GL_COLOR_BUFFER_BIT); drawBoard(); glutSwapBuffers(); } void ChangeSize(GLsizei w, GLsizei h) { GLfloat aspectRatio; if (h == 0) h = 1; glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); aspectRatio = (GLfloat)w / (GLfloat)h; if (w <= h) glOrtho(-100.0, 100.0, -100.0 / aspectRatio, 100.0 / aspectRatio, 1.0, -1.0); else glOrtho(-100.0*aspectRatio, 100.0*aspectRatio, -100.0, 100.0, 1.0, -1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void mouseClicks(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { drawText(); } } int main(int argc, char**argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE); glutInitWindowPosition(600, 400); glutInitWindowSize(800, 600); glutCreateWindow("Tic Tac Toe"); glutDisplayFunc(renderScene); glutReshapeFunc(ChangeSize); glutMouseFunc(mouseClicks); glutMainLoop(); }
  2. Hi guys, i am trying to implement a simple font renderer using bitmap font texture with a dynamic vertex buffer, i am able to successfully display text with correct glyph from bitmap texture. right now i am trying to draw a dynamic string that changes at user input, i.e user able change the displayded text by typing the new one. The issue is that length of string is exactly same as what it was initialized with even when updating string at every render frame. string gets updated every fram but is capped at length equal to what is was initialized with. i am suspecting that vertexBufferDesc.ByteWidth is not getting updated even when i update vertexbuffer by map and unmap it. initialize bool GlyphClass::Initialize(ID3D11Device* device, HWND hwnd, int screenWidth, int screenHeight, WCHAR* path) { bool result; m_GlyphWidthData.open("Font/AgencyFBFont_64x64_width.txt"); while (1) { if (m_GlyphWidthData.eof()) { break; } int tmp = 0; m_GlyphWidthData >> tmp; if (tmp != 0) { m_GlyphWidth.push_back(tmp); } } m_GlyphWidthData.close(); m_GlyphCharacter = 'A'; m_StringToDraw = "TEXTTEST@xyz";//userInputString != "" ? userInputString : "VIVEK599 xyz"; m_fontTextureShader = new TextureShaderClass; if (!m_fontTextureShader) { return false; } result = m_fontTextureShader->Initialize(device, hwnd); if (!result) { MessageBox(hwnd, L"Could not initialize font texture shader object!", L"Error", MB_OK); return false; } m_ScreenWidth = screenWidth; m_ScreenHeight = screenHeight; result = InitializeBuffers(device); if (!result) { return false; } result = LoadTexture(device, path); if (!result) { return false; } return true; } updatebuffer bool GlyphClass::UpdateBuffers(ID3D11DeviceContext* context, int posX, int posY) { m_StringToDraw = userInputString != "" ? userInputString : "STRING 555@xyz0123456789"; VertexType* vertices; D3D11_MAPPED_SUBRESOURCE mappedResource; VertexType* vertexPtr; HRESULT hr; vertices = new VertexType[m_VertexCount * m_StringToDraw.length()]; if (!vertices) { return false; } // Initialize vertex array to zeros at first. memset(vertices, 0, sizeof(VertexType) * m_VertexCount * m_StringToDraw.length() ); float posXOffset = (float)posX; float posYOffset = (float)posY; for ( int i = 0; i < m_StringToDraw.length(); i++ ) { int cx = m_StringToDraw[i] % 16; int cy = m_StringToDraw[i] / 16; float tex_left = (float)cx * (1.f / 16.f); float tex_top = (float)cy * (1.f / 16.f); float tex_right = tex_left + (1.f / 16.f) * ((float)m_GlyphWidth[m_StringToDraw[i]] / 64.f); float tex_bottom = tex_top + (1.f / 16.f); int totalCharWidth = 64; float left = (float)((float)(m_ScreenWidth / 2.f) * -1) + posXOffset; float right = left + (float)m_GlyphWidth[m_StringToDraw[i]]; float top = (float)(m_ScreenHeight / 2.f) - posYOffset; float bottom = top - (float)totalCharWidth; //triangle 1 - clockwise vertices[0 + m_VertexCount * i].position = Vector3(left, top, 0.f); vertices[0 + m_VertexCount * i].texture = Vector2(tex_left, tex_top); vertices[1 + m_VertexCount * i].position = Vector3(right, bottom, 0.f); vertices[1 + m_VertexCount * i].texture = Vector2(tex_right, tex_bottom); vertices[2 + m_VertexCount * i].position = Vector3(left, bottom, 0.f); vertices[2 + m_VertexCount * i].texture = Vector2(tex_left, tex_bottom); //triangle + i 2 vertices[3 + m_VertexCount * i].position = Vector3(left, top, 0.f); vertices[3 + m_VertexCount * i].texture = Vector2(tex_left, tex_top); vertices[4 + m_VertexCount * i].position = Vector3(right, top, 0.f); vertices[4 + m_VertexCount * i].texture = Vector2(tex_right, tex_top); vertices[5 + m_VertexCount * i].position = Vector3(right, bottom, 0.f); vertices[5 + m_VertexCount * i].texture = Vector2(tex_right, tex_bottom); posXOffset += m_GlyphWidth[m_StringToDraw[i]]; } hr = context->Map(m_VertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); if (FAILED(hr)) { return false; } vertexPtr = (VertexType*)mappedResource.pData; int bufferSize = sizeof(VertexType) * m_VertexCount * m_StringToDraw.length(); memcpy(vertexPtr, (void*)vertices, bufferSize); D3D11_BUFFER_DESC tmpDesc; m_VertexBuffer->GetDesc(&tmpDesc); context->Unmap(m_VertexBuffer, 0); delete[] vertices; vertices = 0; return true; }
  3. Hello everyone, I appreciate any help i can get. So i recently started getting this message listed bellow in visual studio when i would compile any game i have for UE4.23.0. 1>EXEC : [1/28] error : Unable to create child process I have no idea how to fix this, and also i really don't want to have to set all the classes again in a new project. Second thing is that i can not move my Character on the Sever when testing multiplayer after adding "Role = ROLE_Authority" to sections in an AI Tracker bot class that i created as a part of Tom Loomans Course on Udemy. I am not following Tom Loomans course 100%, Do i need to add sever implementation to my character because i am using different movement code then what Tom uses? I Am happy to share some screen shots if needed. Please help, thankyou for your time.
  4. I have two curves. One handdrawn and one is a smoothed version of the handdrawn. The data of each curve is stored in 2 seperate vector arrays. Time Delta is also stored in the handdrawn curve vector, so i can replay the drawing process and so that it looks natural. Now i need to transfer the Time Delta from Curve 1 (Raw input) to Curve 2 (the already smoothed curve). Sometimes the size of the first vector is larger and sometimes smaller than the second vector. (Depends on the input draw speed) So my question is: How do i fill the whole vector PenSmoot.time with the correct interpolated values? Case 1: Input vector is larger PenInput.time[0] = 0 PenSmoot.time[0] = 0 PenInput.time[1] = 5 PenSmoot.time[1] = ? PenInput.time[2] = 12 PenSmoot.time[2] = ? PenInput.time[3] = 2 PenSmoot.time[3] = ? PenInput.time[4] = 50 PenSmoot.time[4] = ? PenInput.time[5] = 100 PenInput.time[6] = 20 PenInput.time[7] = 3 PenInput.time[8] = 9 PenInput.time[9] = 33 Case 2: Input vector is smaller PenInput.time[0] = 0 PenSmoot.time[0] = 0 PenInput.time[1] = 5 PenSmoot.time[1] = ? PenInput.time[2] = 12 PenSmoot.time[2] = ? PenInput.time[3] = 2 PenSmoot.time[3] = ? PenInput.time[4] = 50 PenSmoot.time[4] = ? PenSmoot.time[5] = ? PenSmoot.time[6] = ? PenSmoot.time[7] = ? PenSmoot.time[8] = ? PenSmoot.time[9] = ?
  5. In my most complex gameplay source file (single .cpp) with a lot of necessary #include, ... whenever I edit it (e.g. add a single space character), it needs to recompile 40 seconds. Linking takes only 3-5 seconds. Is it what to be expected? Do you also face this issue? Should I just buy a new computer or more RAM? I am using Visual Studio 2017. I am not using Unity Build (single compilation unit technique). Just thinking that the cause is my code, I can't eat and sleep well. It also induces nightmare at my bedtime. Please help.
  6. phil67rpg

    OpenGL rotate ship

    I have a very simple question, I am trying to rotate some vertex's around an arbitrary axis. basically I want to use glRotatef and glTranslatef to rotate a space ship I have drawn on the screen. here is my code of my ship. what it does do is rotate around the origin when I use the arrow keys left and right. void drawShip() { glPushMatrix(); glColor3f(255.0f, 0.0f, 0.0f); glTranslatef(-50.0f, 0.0f, 0.0f); glRotatef(rotateship, 0.0f, 0.0f, 1.0f); glBegin(GL_LINE_LOOP); glVertex3f(50.0f, 0.0f, 0.0f); glVertex3f(45.0f, -5.0f, 0.0f); glVertex3f(50.0f, 10.0f, 0.0f); glVertex3f(55.0f, -5.0f, 0.0f); glEnd(); glTranslatef(50.0f, 0.0f, 0.0f); glPopMatrix(); }
  7. What could be a way of avoiding using inheritance and virtual methods when designing components for an entity-component-system? I'll be more specific about my design issue: I currently have different classes for different kinds of colliders (let's say, CircleCollider and LineCollider). My system that checks for collisions and updates the positions and/or velocities of my entities should be something like: for entity_i in alive_entities { collider_i = get_collider_of_entity(entity_i) // components of same kind are stored contiguously in separate arrays transform_i = get_transform_of_entity(entity_i) for entity_j in alive_entities { collider_j = get_collider_of_entity(entity_j) transform_j = get_transform_of_entity(entity_j) if check_collision(collider_i, collider_j) { update(transform_i) update(transform_j) } } } my problem is that I don't have a generic `get_collider_of_entity` function, but rather a function `get_circle_collider_of_entity` and a separate one `get_line_collider_of_entity`, and so on. (This happens because under the hood I am keeping a mapping (entity_id -> [transform_id, sprite_id, circle_collider_id, line_collider_id, ...]) that tells me whether an entity is using certain kinds of components and which are the indices of those components in the arrays containing the actual components instances. As you can see, each component class is corresponding to a unique index, namely the index position of the array of the mapping described above. For example, transforms are 0, sprites are 1, circle colliders are 2, line colliders are 3, and so on.) I am in need to write a system as the one in the snippet above. I can write several overloaded `check_collision` functions that implement the logic for collision detection between different kinds of geometric primitives, but my problem is that I am not sure how to obtain a generic `get_collider_of_entity` function. I would need something that would get me the collider of an entity, regardless of whether the entity has a circle collider, a line collider, a square collider, etc. One solution could be to write a function that checks whether in my internal entity_id -> [components_ids] mapping a certain entity has a collider at any of the indices that correspond to colliders. For example, say that the indices related to the collider classes are indices 10 to 20, then my function would do get_collider_of_entity (entity_id) { for comp_type_id in 10..20{ if mapping[entity_id][comp_type_id] not null { return components_arrays[comp_type_id][entity_id] } } return null } This could turn out to be pretty slow, since I have to do a small search for every collider of every entity. Also, it may not be straightforward to handle returned types here. (I'm working with C++, and the first solution - that is not involving inheritance in any way - would be returning a std::variant<CircleCollider, LineCollider, ... all kinds of components>, since I would need to return something that could be of different types). Another solution could be having some inheritance among components, e.g. all specific component classes inherit from a base Collider, and overrride some virtual `collide_with(const Collider& other)` method. Then I would redesign my mapping to probably reserve just one index for colliders, and then I would actual colliders in a polymorphic array of pointers to colliders, instead of having a separate array for CircleColliders, another for LineColliders, and so on. But this would destroy any attempt to be cache-friendly in my design, wouldn't it? That's why I am looking for alternatives. A third alternative would be to just have a single, only, Collider class. That would internally store the "actual type" ( aka what kind of collider it is ) with dynamic information (like an enum ColliderType). Then I would have all colliders have all members needed by any kind of colliders, and specific collision detection functions which I can dispatch dynamically that only use some of that data. (Practical example: a "Collider" would have a radius, and the coordinate for 2 points, and in case its type was "circle" it would only make use of the radius and of one of the 2 points - used as the center -, while if it was a "segment" it would only make use of the 2 points). My gut feeling is that this would bloat all colliders, and, even if the bloat could be reduced - using unions in some smart way for storing members? I wouldn't know how -, then still the design would be pretty brittle. I'm clueless and open for ideas and advice! How do you handle in general situations in which you have components that can be naturally modeled as subclasses of a more generic component class? Inheritance? Smart hacks with variants, templates, macros, custom indexing? Dynamic "internal" type?
  8. I have worked on this problem for several days. I have almost solved my problem. I have got my sprite to move up and down continuously using the mouse. this done by using the glutTimerFunc function. I want the mouse to get the sprite to move up and down once. I have googled and debugged my code. I have also taken some JavaScript code and ported it over into opengl. let me know if you need my question to be more specific. here is my code so far. bool onGround = false; void StartJump() { if (onGround) { velocityY = -12.0f; onGround = false; } } void EndJump() { if (velocityY < -6.0f) { velocityY = -6.0f; } } void Update() { velocityY += gravity; positionY += velocityY; positionX += velocityX; if (positionY > 25.0f) { positionY = 0.0f; velocityY = 0.0f; onGround = false; } } void Loop(int val) { Update(); drawSprite(); glutPostRedisplay(); glutTimerFunc(33, Loop, 0); } void mouseClicks(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { StartJump(); } if (button == GLUT_LEFT_BUTTON && state == GLUT_UP) { EndJump(); } } void handleKeypress(unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; case 32: Loop(0); break;
  9. Hi, I have interest developing Game Engine.But,you know it is very difficult and sometimes i feel unmotivated.So,I look for programmers who has passion about it.We will learn topics,then talk about them on Discord,so we will help one another and will learn faster.And we can build very good portfolio together.If you are interested pls send mail me => mr.vasifabdullayev@gmail.com
  10. It seemed best to start another thread for this instead of derailing the thread the conversation started in and maybe to get some other opinions. That's definitely clever, but it feels like you're just trading one compiler trick for a different compiler trick. Do you think this one is better because it's somehow "more C++" than the sizeof version? I have two issues with this code. Firstly I think it's too complicated and clever for it's own good. Even setting aside the new-ness of constexpr, this requires an understanding of templates and template parameter deduction that can take a while to understand. I have a hard enough time with other programmers doing templates right with trivial type deduction that this could make their head explode. Secondly, now that this is a function it's got to live somewhere which means either duplicating it in every header that uses it (bad) or putting it in it's own header (or a utilities header) and including it. This point is more personal preference than anything else since it feels like such a trivial operation to include a header for. I've definitely seen code that wraps the sizeof trick in a macro, but I think that's silly too since that has the same dependency problem as this function. I don't think many people would make a macro/function to wrap "+= 2" just because it happens to occur in multiple places in the code. I don't want to come off as argumentative here @a light breeze. I'm not claiming to be right or that you're wrong or that there's even a right or wrong to be decided here. I'm honestly just very interested in the why of how people decided the things they find acceptable or not. And when someone uses a phrase like "has no place" I immediately want to explore that!
  11. Hi, I'm trying to find a bug in my game that causes it to crash on Windows 7. It crashes (almost) reliably when I do a specific thing in the game, but only on Windows 7 and only in the release build (without debug heap). It's some access violation reading from address 0000 0xxxx xxxx xxxx (it's always those 5 0's and a "random" number, weird). I'm testing my game on Windows 10 and this never happened in months (or years). On Windows 7, it crashed randomly and when I looked at it I actually found 2 problems and fixed them and now it crashes more often. The problem with the error is: The game crashes at some point in time when I allocate or free memory in a different thread. I even tried to write code that causes such an error (to help me locate it) but everything I try makes it crash immediately. How do I find the source of such an error? I would use the debug build but it just doesn't crash in the debug build. And I can't go through 50K lines of code. I'm using several libraries but I doubt it's one of those. Their behavior shouldn't change on a different version of Windows. Thanks in advance for your help!
  12. Hi. I have no idea what's going on here. I understand that macros are used to paste code where the macro is located, and that they can take parameters in their use, but this exceeds me. What I understand is that using macros first sets the header or signature of a function (GetTransitionTable), and inside, defines a static variable TRANSITION_TABLE, which is an array. With the following macro, TRANSITION_ENTRY, fill in the array, I suppose doing an implicit construction of objects, and converting the parameters into the objects expected by the potential object of each element of the array. Finally add a null element at the end. Then, in the use of macros, pass the states they expect to fill in the array. Do you basically use the macro to save writing much more repeated text than you would have to write if you didn't use it? Is this use correct? In The C ++ Programming Language, Bjarne Stroustrup, apart from practically not addressing the issue, seems very contrary to the use of macros. Thanks. Used as:
  13. Hello, I need a tool which can generate c++ code, more precisely - for each string in some file to generate one header and one cpp file, and to add some functions in several files. What do you guys use in such scenarios? Of course I can write such generator myself in Python, but if you have better advice I would listen.
  14. As of last night, I managed to complete everything I wanted for the basic game. The menu system is in place, all the game options are working, there's a full screen option, and I worked through some minor issues that I wanted to address. Full source code, and the 1.1 release, are available on my GitHub account. That puts me on track to start "phase 2", where I'll be working on a story mode with level progression. I think I have some neat-o ideas: Different types of fruits / veggies that have different effects on the snake. Each level will have its own design (ie. not just a rectangular playing area) and new types of barriers. A fun / silly story line where Adam has trapped the snake (you!) in his maze, to get revenge for tricking Eve into eating from the tree of knowledge of good and evil. I don't want to call them "cutscenes" really, but there will be some voiced scenes between each level as Adam throws increasingly difficult dangers into the mix. Here are some notes that might be of interest: While I used Photoshop to create the images used for the icon, there's a rather nice free Icon editor out there called Greenfish Icon Editor Pro. This is what I used to combine the various icon sizes, and export as the *.ico file. I wanted to create a setup / installer program for the game. I used Inno Setup for this. I was hoping this would automatically solve the issue of Windows security blocking the program from running by default. It looks like I'll need to investigate a "signing tool" to achieve this. For now, Windows 10 users have to manually unblock the program if they want to run it. One of the issues I tackled was related to the rendering of the grass and shrubs that make up the playing field. Originally, this was done using individual draw calls for every single tile. When I pulled the grass and shrub textures out into their own separate *.png files, and turned on texture repeating, this allowed me to render the entire grass with one draw call; and the shrub barriers with four draw calls. This was a significant performance improvement, shaving off about 3 milliseconds per rendering frame. Given that you only have 16.67 milliseconds to get everything done in one frame, that's pretty huge!
  15. The most basic version of my SFML "Snake" clone is now playable, including background music and some rudimentary sound effects. (The "eating an apple" sound was literally just me making a mouth sound. I guess that makes me an "ASMRtist"?) I tagged this as "snake_1_0_0" over on my Github repository. Now I'll be moving along to adding game options. Everything in the image below is still part of my "phase 1". I'm happy with where things are at, but also slightly bummed because it'll be back to my regular job in a few days. 😥 Some things I feel I'll need to improve upon when I get to "phase 2" (the story mode with level progression)... Loading and managing assets. So far I've done this with member variables for music, sound, and textures. If I want to be able to improve the graphics, and perhaps include animations, I feel I'll need some kind of asset management structures. Spawning game objects. Spawning of the apples is also controlled by two member variables: "appleExistsFlag" and "applePosition". That approach definitely won't scale well if I want to have, say, multiple apples or a row of carrots pop onto the field. The "QuickGame::update" method is kind of getting out of control. Now that I'm typing this, I think I'll add an issue for that over on Github so I don't forget...