• Advertisement

Search the Community

Showing results for tags '2D' in content posted in Graphics and GPU Programming.



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

  • News

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • GameDev Unboxed

Categories

  • Game Dev Loadout

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
    • Critique and Feedback
  • Topical
    • Virtual and Augmented Reality
    • News
  • Community
    • GameDev Challenges
    • For Beginners
    • 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
  • Workshops
    • C# Workshop
    • CPP Workshop
    • Freehand Drawing Workshop
    • Hands-On Interactive Game Development
    • SICP Workshop
    • XNA 4.0 Workshop
  • Archive
    • Topical
    • Affiliates
    • Contests
    • Technical

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams

Blogs

There are no results to display.

There are no results to display.

Marker Groups

  • Members

Developers

Developers


Group


About Me


Website


Industry Role


Twitter


Github


Twitch


Steam

Found 40 results

  1. A texture rectangle, texture type is RGBA. the alpha channel like this: (0=0,x=255) [0][0][0][0][0][0][0] [0][0][x][x][0][0][0] [0][x][x][x][0][0][0] [0][x][x][x][x][x][0] [0][0][0][x][x][x][0] [0][0][0][x][x][0][0] [0][0][0][0][0][0][0] I want a function to picking. now I have a very clumsy solutions: //system Init............. //.......... //pixel buffer to texture....... (texture is handle, a number.cannot get pixel matrix.) //.......... BYTE pixel_alpha[7][7];//save alpha channel matrix //.......... texture.draw(30,30);//draw the picture in the window x=30 , y=30 //.......... if(picking(GetMouseX,GetMouseY))MessageBox("click!"); // picking functio //.......... /*picking function*/ bool picking(int x,int y) { int mouse_to_image_x, mouse_to_image_y;//get mouse position in the image mouse_to_image_x = 30 - x; mouse_to_image_y = 30 - y; if((mouse_to_image_x < 0 && mouse_to_image_x > 7) && (mouse_to_image_y < 0 && mouse_to_image_y > 7))return false;//mouse is not in the image for(int i = 0; i < 7 * 7; i++) { if(pixel_alpha[mouse_to_image_x][mouse_to_image_y] == 255)return true;//in the image and alpha channel is 255 } return false; } //============================================================================================= but...... 1.an excessive amount of memory in alpha channel matrix. 2.i think efficiency is not high. so, how to do? not is ray picking, What is this technology called?
  2. Hey guys...I found a great channel on youtube. I was always a Unity guy and got pretty good in it. But finally I ended up with doing stuff on my own without a specific engine. I love the freedom of it I found monogame and I found this guy...he is a professional programmer in AAA games studio and shows really cool stuff for 2d MMORPG and server-client stuff!! Defenitly check it out...! https://www.youtube.com/channel/UCThwyD-sY4PwFm7EM89shhQ Have fun
  3. I'm currently learning opengl and started to make my own 2D engine. So far I've managed to render an rectangle made out of 2 triangles with `glDrawElements()` and apply it a custom shader. This is how my code looks like so far: #include <all> int main() { Window window("OpenGL", 800, 600); Shader shader1("./file.shader"); float vt[8] = { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f }; const GLuint indices[6] = { 0, 1, 2, 2, 3, 0 }; GLuint vao, vbo, ebo; glGenVertexArrays(1, &vao); glBindVertexArray(vao); glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vt), vertices, GL_STATIC_DRAW); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); glGenBuffers(1, &ebo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); while(window.isOpen()) { window.clear(0.0, 0.5, 1.0); shader1.use(); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, NULL); window.update(); } glDeleteBuffers(1, &vbo); glDeleteBuffers(1, &ebo); glDeleteVertexArrays(1, &vao); return 0; } There multiple way to do it, but I've heard that drawing and switching shaders one by one is pretty expensive. I'm looking to preload all the data, vertices, shaders in one buffer or what's more efficient and when it's all ready start drawing them in one call, similar to a batch. Thanks!
  4. I'm looking to render multiple objects (rectangles) with different shaders. So far I've managed to render one rectangle made out of 2 triangles and apply shader to it, but when it comes to render another I get stucked. Searched for documentations or stuffs that could help me, but everything shows how to render only 1 object. Any tips or help is highly appreciated, thanks! Here's my code for rendering one object with shader! #define GLEW_STATIC #include <stdio.h> #include <GL/glew.h> #include <GLFW/glfw3.h> #include "window.h" #define GLSL(src) "#version 330 core\n" #src // #define ASSERT(expression, msg) if(expression) {fprintf(stderr, "Error on line %d: %s\n", __LINE__, msg);return -1;} int main() { // Init GLFW if (glfwInit() != GL_TRUE) { std::cerr << "Failed to initialize GLFW\n" << std::endl; exit(EXIT_FAILURE); } // Create a rendering window with OpenGL 3.2 context glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); // assing window pointer GLFWwindow *window = glfwCreateWindow(800, 600, "OpenGL", NULL, NULL); glfwMakeContextCurrent(window); // Init GLEW glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { std::cerr << "Failed to initialize GLEW\n" << std::endl; exit(EXIT_FAILURE); } // ----------------------------- RESOURCES ----------------------------- // // create gl data const GLfloat positions[8] = { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, }; const GLuint elements[6] = { 0, 1, 2, 2, 3, 0 }; // Create Vertex Array Object GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); // Create a Vertex Buffer Object and copy the vertex data to it GLuint vbo; glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(positions), positions, GL_STATIC_DRAW); // Specify the layout of the vertex data glEnableVertexAttribArray(0); // layout(location = 0) glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); // Create a Elements Buffer Object and copy the elements data to it GLuint ebo; glGenBuffers(1, &ebo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elements), elements, GL_STATIC_DRAW); // Create and compile the vertex shader const GLchar *vertexSource = GLSL( layout(location = 0) in vec2 position; void main() { gl_Position = vec4(position, 0.0, 1.0); } ); GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, 1, &vertexSource, NULL); glCompileShader(vertexShader); // Create and compile the fragment shader const char* fragmentSource = GLSL( out vec4 gl_FragColor; uniform vec2 u_resolution; void main() { vec2 pos = gl_FragCoord.xy / u_resolution; gl_FragColor = vec4(1.0); } ); GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragmentShader, 1, &fragmentSource, NULL); glCompileShader(fragmentShader); // Link the vertex and fragment shader into a shader program GLuint shaderProgram = glCreateProgram(); glAttachShader(shaderProgram, vertexShader); glAttachShader(shaderProgram, fragmentShader); glLinkProgram(shaderProgram); glUseProgram(shaderProgram); // get uniform's id by name and set value GLint uRes = glGetUniformLocation(shaderProgram, "u_Resolution"); glUniform2f(uRes, 800.0f, 600.0f); // ---------------------------- RENDERING ------------------------------ // while(!glfwWindowShouldClose(window)) { // Clear the screen to black glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.0f, 0.5f, 1.0f, 1.0f); // Draw a rectangle made of 2 triangles -> 6 vertices glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, NULL); // Swap buffers and poll window events glfwSwapBuffers(window); glfwPollEvents(); } // ---------------------------- CLEARING ------------------------------ // // Delete allocated resources glDeleteProgram(shaderProgram); glDeleteShader(fragmentShader); glDeleteShader(vertexShader); glDeleteBuffers(1, &vbo); glDeleteVertexArrays(1, &vao); return 0; }
  5. Hey, I've a minor problem that prevents me from moving forward with development and looking to find a way that could solve it. Overall, I'm having a sf::VertexArray object and looking to reander a shader inside its area. The problem is that the shader takes the window as canvas and only becomes visible in the object range which is not what I'm looking for.. Here's a stackoverflow links that shows the expected behaviour image. Any tips or help is really appreciated. I would have accepted that answer, but currently it does not work with #version 330 ...
  6. I've started building a small library, that can render pie menu GUI in legacy opengl, planning to add some traditional elements of course. It's interface is similar to something you'd see in IMGUI. It's written in C. Early version of the library I'd really love to hear anyone's thoughts on this, any suggestions on what features you'd want to see in a library like this? Thanks in advance!
  7. I have a simple openGL engine using SDL working. I'm not using any SDL_Image stuff, its all just openGL. I've made 2d tilemap levels with a .txt file before by reading in the characters and using a switch statement to assign them to various textures and using their position in the file to render them. This method works fine and produces no graphical glitches. Then I made a .tmx map in Tiled and used TmxParser to read the file into my program, and I'm able to render the map properly to the screen, but when I move up and down these black lines start to appear between the tiles. The map loads in fine at first, its only once I start moving the camera around that it happens, and its only when the camera moves up or down. I made a video to show exactly what I'm seeing, I see a lot of these type of issues when searching google but nothing that matches whats happening to me. https://www.youtube.com/watch?v=bm6DcJgCUKA I'm not even sure if this is a problem with the code or what it could be so I don't know of any code to include. This problem also happened to me when I was using Unity and importing a Tiled map with Tiled2Unity. In unity there were long horizontal line glitches on the tilemap, and now its happening to me again in c++, is this something to do with Tiled? Has anyone encountered this before or know a solution? Any help would be greatly appreciated, I feel stuck on this issue.
  8. I have a character in a game, made of multiple sprites in a hierarchy for skeletal animation (also called cutout animation by some). I want to make that character semi-transparent for a while, like a ghost. The problem is, when I naïvely set the transparency on the top-most sprite and all of its children, it doesn't look as I expected, because the parts of the sprites that were supposed to be occluded by other sprites can now be seen through their occluders Like, for example, you can see the body through the clothes, or parts of the limbs inside the body, etc. (#3 in the picture below). I'd rather like it to be made transparent as a whole, as if it were a single image (#2 in the picture below). So my question is, how is this effect usually achieved in video games? (Preferably in OpenGL, but I'd like to know the general approach, so that I could apply it to whatever tool I'll use.) My first thought of how to fix it, was to render the sprite chierarchy to texture first, and then map that texture onto a simple rectangular mesh, and apply opacity to that. But this approach would have some drawbacks. One of them I guess being the additional overhead required for rendering to texture, especially if there will be more "ghosts" on the screen at the same time, all with different transparencies. Another one is of course the overhead in code – it would require a framework of managing these hierarchies and their associated render targets – in other words: a MESS! Is there any other, better way to do that than rendering the entire character to texture? If there isn't one, then maybe you could give me some advices about how to organize that mess in the code?
  9. Hi guys, anyone experienced with DX11 could look at my graphics.cpp class? I got fonts rendering correctly with painters algorithm - painting over the other 3d stuff each frame, however, whenever I turn the camera left or right, the fonts get smushed narrower and narrower, then disappear completely. It seems like the fix must be a very small change, untying their rendering from the cam direction, but I just can't figure out how to do it under all this rendering complexity. Any tips would be helpful, thanks. https://github.com/mister51213/DirectX11Engine/blob/master/DirectX11Engine/Graphics.cpp
  10. Hello there, I here have a quite technical question, and as my english isn't perfect, feel free to ask any questions if I wasn't clear enough on my explanations. I am building a homemade voxel model creator. My models are a set of blocks, from which I generate a mesh. I would like to texture them using an external 2D image file. So, I have to 'uv-map' the vertices of my model, meaning, having a projection of 3D vertices on a 2D plane (texture) I am looking for an algorithm to generate an optimal texture (optimal: having the lowest memory usage but still holding every vertices, without overlaps) Let me pose the problem more formally. Feel free to look at the example if there is any comprehension issues. • What I have: I have list of planes, where each planes is defined by 2 integers (width, height) • What the algorithm should do: 1) give the smallest (in term of area) rectangle which can hold every planes, without overlaps 2) give the position and orientation of each planes relatively this rectangle. The position is where the plane should be mapped. (x, y), the orientation is 0 or 1, weather the plane is flipped once mapped. Flipped: map on the rectangle from (x, y) to (x + height, y + width), (instead of (x, y) to (x + height, y + width)) There might be multiple optimal solutions (as the following example shows, I would like to find an algorithm that generate at least one of them) Example: (notice that "LEFT" plan is flipped once mapped here) sample.bmp Source code: https://github.com/rpereira-dev/VoxelEngine/blob/master/VoxelEngine/src/com/grillecube/client/renderer/model/editor/mesher/ModelMesherCull.java Screenshot: modelEditor.bmp NB: I've posted this topic on the "graphic and GPU programming" section; as this generated texture will be used in an OpenGL context.
  11. Now I am making 2d game in my home. I am so confused with the resolution. Please anyone help me to choose the resolution
  12. Hello, I’m writing research paper on software rasterization algorithms and at one point I gave example of triangle rasterization algorithm. The algorithm is really basic. If the triangle is flat top or flat bottom it’s possible to determine the minimum and the maximum x values for each scan line using the equation of line for the edges. Then for each scan line fill the pixels between minimum x and maximum x values. If the triangle is of other kind it’s possible to split it to flat top and flat bottom triangles (finding the fourth vertex) and draw it using the previous algorithm. I need to cite a reference for this algorithm. I saw it in some book in the ‘90s and I can’t just write it without a reference. The problem is that I can’t remember where I saw it. I already tried to look at “Computer Graphics: Principles and Practice” but the only similar algorithm there is the polygon rasterization algorithm, which is over engineered for this kind of problem, same with "Computer Graphics: C Version". I also tried to look at “Black Art of 3D Game Programming”, which have similar algorithm but the algorithm that I saw was in another book and slightly different. Anyone know a book with this kind of algorithm? Any help is appreciated. Thanks.
  13. I've been attempting to write a Navier Stokes fluid simulation using the Cg language in Unity for a few times now with no luck. Every attempt has only resulted in a blank result. I don't really know how to fix the problem but from what I see, I think the problem might lie in the rendering-to-texture aspect and not the shader themselves so this question might be more Unity-related the shader-related. But just in case, I've read Chapter 38 from GPU Gems and while I don't understand the maths, I do understand the implementation of it. If I'm correct, the order for each timestep of the simulation is: 1. Advection 2. Force application 3. Projection (computing divergence, solving Poisson equations using Jacobi iterations, gradient subtraction) So there's that. Multiple shaders would be required for each step and I need to have multiple textures to represent the state of fluid such as velocity, density and pressure. Those states each need to have two textures to read and write to, so I can swap them around after each step has been outputted to the correct texture. I also need a temporary divergence texture and a texture to display the final result. My first question is, what format should my textures be in? I've heard that you should use RGBA floating-point textures for each one but I don't know if that's really the case. Now about the implementation. Like I've said before, I think all my shaders have been written properly as I've compared them to numerous sources including GPU Gems codes and it looks similar. My shaders are based on this three.js implementation and this one. I want my simulation to be setup so that the user can click on the screen to add 'ink' and drag the mouse around to 'add force and velocity' to it. While the second implementation is a working example of a Unity implementation, it's not setup to how I want it to be and the three.js implementation does exactly that. So I combined the Splat shader from the three.js implementation to my own project to achieve the 'add force' that I want but I'm not sure if it's working properly. I've attached my shaders below along with a Unity package file for those who have Unity. If my shaders have all been written properly, then the problem lies in how to actually display it. Currently, I'm just inputting a density texture into my Render shader to display it but it's giving me a blank result. I don't know if there's anything I had to do first before displaying the fluid so if anyone knows, please let me know. Shaders.zip FluidSimulation.unitypackage
  14. Hi again, thanks to the good advise from the guys on this thread https://www.gamedev.net/forums/topic/692174-opengl-2d-gui-system-question/?tab=comments#comment-5356606 thanks guys! I have my basic 2D GUI working now, buttons, windows/dialogs and sliders are working, now i want to port my scrollbox, listview controls to OpenGL, unfortunately i dont have an idea on how 'clipping' a rendered object works, in 2D canvas such as in 2D SDL or javascript canvas, what i did is for example on listview/listbox control, i draw all items in an offscreen canvas, and just Blit copy the visible area to screen based on the amount it was scrolled. Since i dont think OpenGL has the BlitBlk style of partial rendering a texture/canvas, how should i approach implementing a control such as listview control? Background, i want a 2D GUI control where there will be items inside (like a listview) that hides/clip when scrolled based on scroll value, any tips on how to do this on OpenGL?
  15. Hola estoy interesado en practicar y crear un sistema de pre cargado de texturas, así el juego que estoy desarrollando en vb6 utilizando Direcxt8 tiene un mayor rendimiento a la hora de cargar los gráficos de un mapa. ¿Pueden orientarme con temas acerca el tema? ¿Qué es lo que necesito saber? Gracias! Hi, I'm interested in practicing and creating a pre-loaded system of textures, so the game I'm developing in vb6 using Direcxt8 has a higher performance when loading graphics on a map. Can you guide me with topics on the subject? What do I need to know? Thank you!
  16. Hi can anyone give me hint how to write a shader for making an animation of a transparent sweep means a line moving about 180 degree on the screen the line.
  17. I was thinking about how to render multiple objects. Things like sprites, truck models, plane models, boats models, etc. And I'm not too sure about this process Let's say I have a vector of Models objects class Model { Matrix4 modelMat; VertexData vertices; Texture texture; Shader shader; }; Since each model has is own model matrix, as all models should, does this mean I now need to have 1 draw call per model? Because each model that needs to be drawn could change the MVP matrix used by the bound vertex shader. Meaning I have to keep updating/mapping the constant buffer my MVP matrix is stored in, which is used by the vertex shader Am I thinking about all of this wrong? Isn't this horribly inefficient?
  18. How do i open an image to use it as Texture2D information without D3DX11CreateShaderResourceViewFromFile? And how it works for different formats like (JPG, PNG, BMP, DDS, etc.)? I have an (512 x 512) image with font letters, also i have the position and texcoord of every letter. The main idea is that i want to obtain the image pixel info, use the position and texcoords to create a new texture with one letter and render it. Or am I wrong in something?
  19. hi i am new to opengl can someone here tell me how to render this 2d shape i want to make curve or arc in 2d in between two lines its a rough sketch i made i tried the internet but could not find much help beacuse their were no specific tutorials of making arcs or curves
  20. Hello Community, I wanted to seperate drawings - different "IDirect3DDevice9Ex" Devices for different purposes. The problem I have is that Device A is drawing the background and if I add Device B for drawing simple geometricts or even a simple line.. the background turns black but the line is drawn. So I dont really know how to configure device B that it only overwrite the pixels at e.g. destination of the line and not all pixels of device A. So what are the correct settings to archive the mentioned goal ? (D3DPRESENT_PARAMETERS, Present/Clear) ,greetings
  21. youtube link at 1:38 - 1:42, purple things (I think this is particle system) that come off from the moon. Someone else had decompiled the game in the past, and the assets shows that the dark blue area around the moon (after purple things come off) is just background image. So my assumption is that there are many of those 'purple things', that use additive blending to give different density of 'purpleness'. The details that I'm looking at are: As those purple things come off completely from the moon, it forms jagged shapes At the edge of those jagged shapes, color blends smoothly instead of sharp turn between purple and dark blue(I know how to do it with simple shapes, but in here, the jagged shape itself constantly changes) further from edge between dark blue and purple, at the light purple direction, the density of purple is nice and smooth I'm pretty familiar on animating objects by manipulating transform, but this one seems like a lot of color works with programatically created shapes, any idea? Here's a picture to clarify
  22. 2D Best API for 2D animations

    Hi, I'm making a program which displays simple 2D animations (think text and images scrolling over the screen) and I'm wondering what API would be best to use. Two important factors here are 1) being pixel perfect 2) never miss a frame, always 60 FPS. My target is primarily Windows (7 and newer) but being cross-platform would be a plus. I started with GDI (i e, the normal Windows thing) which is good from a pixel perfect perspective, but has a hard time reaching 60 FPS. I have started to look into OpenGL but I'm not sure it's the right choice w r t being pixel perfect. As for never missing a frame, would DirectX be better due to its swapchain feature? (Input lag is not an issue here so a few frames in-flight would not hurt.) I guess Vulkan is a bit overkill and the amount of machines not supporting Vulcan is a big minus at this point. What about web technologies such as WebGL (or 2D Canvas) + CEF (Chromium Embedded Framework)? If that is smooth enough, that would also be a very interesting option. What do you think?
  23. Hello there, I am new to the forum and in game development in general! I am currently building a simulator for some game, and I am having a few problems already, and I am using the libgdx framework. I have an isometric map drawn, where each tile is a spot that only one entity can be at. An entity can either move left, right or just forward in a straight line. Now this is what it looks at the moment: As you can see, my ship entity is located at 1,1. I want to start with adding a function that moves the ship in a straight line, so I need to move this ship to 1,2. So I have a Vector2 that represents the ship's position, I made a dummy one in the local class where it paints entities, and the map and it's set to isometric coordinates of 1,1: r = new TextureRegion(texture, location.getX(), location.getY(), location.getWidth(), location.getHeight()); local = new Vector2(getIsometricX(1,1, r), getIsometricY(1,1, r)); "r" is my texture region, which is my sprite image off the spritesheet. Now I have set a target position to 1,2: target = new Vector2(getIsometricX(1,2, r), getIsometricY(1,2, r)); So now my question is, how can I make that ship move to the target position? If i add 1 to x and y every tick, it will just move too much to the right. This is how I paint everything: @Override public void render() { batch.setProjectionMatrix(camera.combined); batch.begin(); // Render the map renderSeaBattle(); // Render ships renderEntities(); batch.end(); } And the map painting: private void renderSeaBattle() { // The map tiles GameTile[][] tiles = map.getTiles(); for (int i = 0; i < tiles.length; i++) { for(int j = 0; j < tiles[i].length; j++) { GameTile tile = tiles[i][j]; Texture texture = tile.getTexture(); int x = (i * GameTile.TILE_WIDTH / 2) - (j * GameTile.TILE_WIDTH / 2) -texture.getWidth() / 2; int y = (i * GameTile.TILE_HEIGHT / 2) + (j * GameTile.TILE_HEIGHT / 2) -texture.getHeight() / 2; batch.draw(texture, x, y); } } } And the entities: private void renderEntities() { batch.draw(r, local.x + location.getOffsetx(), local.y + location.getOffsety()); } location is an instance that contains the offset position for that specific sprite, because not all sprites are the same size, so to center it on the tile, each one has set offsetX and Y. And this is my coordinate conversion methods: public int getIsometricX(int x, int y, TextureRegion region) { return (x * GameTile.TILE_WIDTH / 2) - (y * GameTile.TILE_WIDTH / 2) - (region.getRegionWidth() / 2); } public int getIsometricY(int x, int y, TextureRegion region) { return (x * GameTile.TILE_HEIGHT / 2) + (y * GameTile.TILE_HEIGHT / 2) - (region.getRegionHeight() / 2); } After I do the straight line, how can I create left/right movements in curves? Thanks!
  24. So the application itself is 2D and layered but I want to build the background bitmap from a Blender 3D model. When I make an appeal to Saint Google there seem to be an awful lot of ways of getting to the desired result. The process I have in mind is to do the following. Please comment on the practicality or otherwise of this approach. Use a background thread to: Load the model Create a 3D buffer for rendering into Render into the buffer Copy the 3D buffer to a 2D buffer somewhere The main loop will Blit? copy the 2D background to the backbuffer of the swap chain Overlay the background with various sprites Swap buffers Which leads to the following questions. What is the best option for exporting a Blender model for use by DirectX. Which API should I use to create a 3D buffer for rendering the model into? As it only gets rendered on scene changes, every 10-20 seconds, am I correct in assuming it shouldn't be part of the swap chain? In managing the background buffer is it best to, or must I, use a "dummy" device of some kind? How do I turn a 3D buffer into a 2D bitmap for load into the 2D swap chain? What is the best way to set up the 2D buffer so asto minimise the cost of the copy for every frame by the main loop?
  25. Hello GameDev vets, I use to program when I was younger (few college courses as well) and as I got older I got away from it. I've now been really taking learning programming very serious. I bought Sam's Teach Yourself C++ to learn the newer stuff added to C++ and refresh myself of all the basics. I am looking for the next book to help me actually start on a simple rogue RPG. I wish I could find a book (recent date) that covers heavily DirectX12 or 11 and RPGs. Especially procedural generation and tiles. I assume my book on Isometric programming still has relevant ways of doing tiles. Can anyone help me pick out 2-3 books that will help make me a comfortable windows programmer. 3D is probably my LAST stop. I just would really enjoy non outdated books regarding 2D RPG games (and eventually 3D). But I am trying to go through the stages in a more practical way. Price is not really an issue. Any other sources are great as well. Thanks everyone! I have the following books: Sam's teach yourself C++(8th Edition) |Beginning C++ Game Programming by John Horton Beginning C++ Through Game Programming (4th Edition) by Michael Dawson Game Programming Patterns The Art of Game Design Level Up (Also own a kindle version of 2D programming by I forget who, it was great during its time) OLD OUTDATED BOOKS: Programming Role Playing Games with DX9 Programing Isometric Games with DX7 (maybe 9) Programming Multiplayer Games
  • Advertisement