C++ :: OpenGL And 2D Games
Sep 12, 2013How I can make 2D games in OpenGL. I have sprites, but when I load them in game, they're all big and stuff, not pixel for pixel how I'd like them. How can I do this?
View 16 RepliesHow I can make 2D games in OpenGL. I have sprites, but when I load them in game, they're all big and stuff, not pixel for pixel how I'd like them. How can I do this?
View 16 RepliesI want to make a RTS game but how can I code an AI for RTS games. How to do that?
View 5 Replies View RelatedRight, I'm making a game and I'm not sure how I'm going to do this:
On Skyrim (for example; there are thousands of others), when you equip a helmet, it appears on your character's mesh.
How do they do that? Do they modify the mesh, or simply render the helmet at a location which makes it look like it is on their head, or what?
I am because I don't know what to use OpenGL or DirectX? I heard some people saying I can use both. How is this? What is better for online games? And when I choose I will need some tutorials too ....
View 1 Replies View RelatedThis is my first time using opengl and I am experimenting with adding/drawing polygons/points/etc. on top of a PPM image. The image is already loaded when the application runs. My attempt to draw a square is from lines 30 - 35. The program runs but the square is not present. Just the image.
#include<windows.h>
#include <stdio.h>
#include <stdlib.h>
#include<Gl/gl.h>
#include<GL/glut.h>
int n;
int m;
int *image;
[Code] ....
i want to draw a 3D snake in opengl.. i can't get nothing out of my search to make a start.. how it is made
View 4 Replies View RelatedI've read up on .bmp files on wikipedia and am currently attempting to make a function that can export a .bmp file of the screen of my programs. I've already begun work on it but it isn't working. The code I have so far is:
typedef char Byte;
typedef int Byte4;
typedef short Byte2;
struct BMP_Header {
[Code] ....
My problems are that when less then the required amount of bytes is needed to store a value in the file, the 00 bytes are skipped (Ex. The file will contain 42 instead of 42 00 00 00), and the Pixels are stored as nothing but 0D ( every value intended for storing pixel data is 0D ).
I don't know why, but textures in OpenGL are white. One day, I must've change something, and now my textures wont load properly. I tried rewriting my code that loads things multiple times, my textures still are white. Here is my code:
(I switched back to the FF pipeline temporarily, in my other projects I use shaders.)
Sprite.hpp
#include <SDL.h>
#include <SDL_opengl.h>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#ifndef _SPRITE_H_
#define _SPRITE_H_
[Code] ....
Where can I learn how to make fractals with opengl?
View 1 Replies View RelatedI'm printing characters on a texture map using OpenGL and GLUT with C++. The problem is that when they appear on the map the x-coordinates are correct but the y-coordinates are upside down. The coordinates are being read from an input file and are in the form x,y with a semicolon separating each xy pair. I tried putting a negative sign in front of the y-coordinates to see if that would force the characters to go in the right place but that just made minus signs appear on the screen. Is there a function in OpenGL/GLUT that can invert coordinates by a certain value?
View 12 Replies View RelatedIf I wanted to design an object in SolidWorks, and then output that object (I guess as a .stl file), is it possible to open that up and manipulate using openGL? How would I go about doing that?
View 1 Replies View RelatedHow can i convert pixel to [-1..1]coordinate in opengl? Which function? I want to write a program that is work with
glutmousefunc(),
When I click on the screen a ball is appear on it where clicked. but mouse work with pixel and circle work with coordinate between -1 and 1 ....
I am using the following code to print in SDL screen
SDL_GL_RenderText( timer, font, color, &position);
sprintf(timer," Time : %d",time);
to print in SDL screen(used with opengl) , i am doing project on C++, as "sprintf" is C style function , so i can't do like this , i am trying to use" ostringstream" , but i am not sure how to use it.
I am trying to compile an OpenGL program in Ubuntu.This program opens a blank window.
Code:
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <cstdio>
#include <iostream>
int main(int argc,char* argv[])
[code]....
What i'm trying to do is create a 3d game engine with opengl and i want to be multi platform. I'm trying to use code-blocks for this reason but i'm having trouble setting up opengl for code-blocks
View 1 Replies View RelatedI recently made a heightmap, it uses a triangle strip /row, and I try to figure out how can i color the triangles one by one. So, for example I have a color array of 9:
[0.0f,0.2f,0.6f //a triangles first vertex
0.0f,0.4f,0.3f //second vertex
0.0f,0.7f,0.2f] //third vertex
And I want to use it to color all triangles with it. My heightmap coords are in a vector:
vector<GLfloat> hmapcrds [x1,h1,z1; x2,h2,z2;...]
Like this:
c1 c2 c3 c4 c5 //row 1
c6 c7 c8 c9 c10 //row 2 coordinates
index array:c6->c1->c7->c2 ...cn->c(n-rwosize)->c(n+1)->cn->c(n-rwosize+1)
I draw my elements with a VAO and drawelements/row; (i tried drawrange but didnt work)
...
glGenVertexArrays(1,&VertArrObj);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,indexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(GLuint)*v_heightIndexes.sie(),&v_heightIndexes[0],GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER,vertexBuffer);
[Code] ....
I think it want to index my color array too, so how can i do that it only reads the 3 colors from my array, the repeat it /vertex/triangle till the end of drawing.
The shaders work fine, i changed the map to a triangle so it applied these colors, but with the map "I see only darkness before me".
with my working shader without color "in" - height coloring: [URL] ....
(I also want to do texturing per triangle.)
So I did read, however it said also that it was memory intensive and I had a question... I also came across this:
Window.pushGLStates();
Window.draw("Sfml Text");
Window.popGLStates();
The problem here is that none of these commands exist!
Window.draw should exist and even though I have all the proper includes I still get it telling me that 'Draw' is not a member of sf::Window
I have encountered that error many times everywhere across my sfml related code, it's not like they removed all those features in the update (Which they did not) but, why then would it not be a member?
I am supposed to create a class of rectangular prism in opengl. I am having touble in writing my "draw()" function.
I have searched the web, and lots of the sites have:
glBegin(GL_Quads);
glVertex3f(x,y,z);
glVertex3f(...);
glVertex3f(...);
glVertex3f(...);
3D coordinates for each face.
For my code, I am getting a value for lengths of x, y and z like "getXlength(x_length)" etc... I would like to know how I can use these values to draw the prism rather than giving values for each coordinates in each face.
I am using SFML CodeBlocks and OpenGL i am not very good in OGL ...
i want 2 know how to make a simple 3d Cube with OGL ...
I wrote a program in C + + and OpenGL using MinGW, which displays a map in 2D.
The following is a function that does the fault occur, ie when executes the statement gluTessEndPolygon (tobj) gives me segmentation fault:
// render each block as a polygon extruded into Z
void BlockGroup::BuildDisplayList() {
static GLUtesselator *tobj = NULL;
if( ! mod.world->IsGUI() )
[code]....
contours is a list of vectors of the following type:
std::vector<std::vector<GLdouble> > contours;
I report also:
#define VAR(V, init) __typeof(init) V=(init)
#define FOR_EACH(I,C) for(VAR(I, (C).begin()), ite = (C).end(); (I) != ite;
++(I))
I tried to use the debug and have come to the message of Segmentation Fault on education above. Now I do not know what to do.
how to get opengl working in code blocks? I have tried putting in the libraries and such in the correct folder. But I get an error saying that glut32.dll could not be found. I am running a 10.5 code blocks
View 1 Replies View RelatedI'm trying to load a Quad with a Monster Image on it that will always face the Camera, a la Doom 2.
Now I don't know how to load an image with an Alpha part on it.
In 2D using SDL I always used tga files.
Here is my LoadTexture functions.
AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image
{
FILE *File=NULL; // File Handle
[Code].....
I am trying to get OpenGL to render inside of a Win32 api static control. I've gone through Nehe's tutorial [URL] on how to render to an entire window. I understand how to do that and I can do it, but I'm not totally sure how to get it to render inside of a static control(or any control). The idea is to have a gui built around an OpenGL view. how I could render inside a static or custom win32 control?
View 4 Replies View RelatedI search for a really simple window library with a OpenGL context. I really only want to create window, I don't want a GUI library like wxWidgets. The best would be, if the library is cross platform compatible. In Google I only find very big libraries with widgets and other stuff.
View 4 Replies View RelatedI programming currently something with OpenGL. Now I have written some wrapper classes, like Shader, Program .... All works fine, but I don't like to call Shader.GetHandle() every time I want to call a OpenGL function manually where I need the object handle/id. (GetHandle() returns the OpenGL ID of the object)
So now I wonder, is it possible to program it in C++ so, that I can put my objects to gl methods and c++ automatically pass the handle/id member to that function ? Is there maybe a operator that I can use for that?
For example:
The way I do it now:
Shader vertexShader();
glCompileShader(vertexShader.GetHandle());
The way I want to:
Shader vertexShader;
glCompileShader(vertexShader);
I'm making a program to draw a trajectory, was using as a basis the tangent, but when I put 90 degrees, the tangent is very large, so I thought of putting an if (angle == 90) did not use the tangent.
the design is right, but after choosing it 90 degrees it stops to draw.
for example
1-30 degrees - draws
2-45 degrees ---- draws
3 draws -90 degrees ---
4-60 degrees --- not drawing
5 --- 80 degrees --- not drawing
*
*
making routine design is presented below:
void Draw() {
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINES);
convert(graus);
if (ant){
x=xx;
y=yy;
[code]....