C++ :: GLSL Heightmap Coloring (OpenGL)

Aug 27, 2013

I 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.)

View 2 Replies


ADVERTISEMENT

C++ :: Creating Shaders - Scaling Matrix In GLSL

Jul 22, 2013

I'm working on creating shaders to be used for displaying text in my openGL programs but am having trouble. I want to be able to scale the text but I don't want to use a uniform ( I want different strings of text to be able to be scaled differently ) so I'm using an in variable. I'm not sure how to use a VBO with a mat4 so instead i've been using a vec2 and trying to convert it to a mat4 in glsl before multiplying it with the position. The problem is that when I run my program, my text isn't scaled; it's just partially missing (the part that is there is about the same size). My vertex shader for this is:

#version 140
in vec2 Position;
in vec4 VertexColor;
in vec2 TexCoord;
in vec2 Scale;

out vec4 Color;
out vec2 UV;

[Code] ....

Also, scaling matrix should look like this:

| x, 0, 0, 0 |
| 0, y, 0, 0 |
| 0, 0, z, 0 |
| 0, 0, 0, 1 |

with z = 1 for 2d scaling, right?

View 4 Replies View Related

C++ :: Coloring Cells In HTML Table

Apr 25, 2013

For this program i had to create an HTML with the cosine similarities. I got everything, i just need to color in the lowest and highest amount in the table, but I don't know how.

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstdio>
using namespace std;

const int ARRAY_OF_ASCII_CODES_SIZE=256;
const int NUMBER_OF_FILES=8;

[Code] .....

View 3 Replies View Related

C :: Write Message Passing Interface Program For Implementing Graph Coloring?

Mar 21, 2013

write mpi-c program for implementing graph coloring?(mpi-message passing interface used for parallel programming)

View 2 Replies View Related

C++ :: OpenGL And 2D Games

Sep 12, 2013

How 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 Replies View Related

C++ ::  Use DirectX Or OpenGL?

Feb 6, 2014

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 Related

C++ :: OpenGL - Draw On Top Of Image

Jun 22, 2014

This 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] ....

View 5 Replies View Related

C++ :: How To Draw A 3D Snake In OpenGL

Jan 3, 2014

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 Related

C++ :: Taking A Screenshot In OpenGL

Sep 14, 2013

I'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 ).

View 4 Replies View Related

C++ :: Textures White In OpenGL

Nov 17, 2013

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] ....

View 2 Replies View Related

C++ :: How To Make Fractals With OpenGL

Jan 20, 2013

Where can I learn how to make fractals with opengl?

View 1 Replies View Related

C/C++ :: Fix Upside-down Characters In OpenGL?

Jun 20, 2014

I'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 Related

C++ :: Designing Object In Solidworks -> OpenGL?

Jul 11, 2014

If 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 Related

C++ :: How To Convert Pixel To Coordinate In OpenGL

May 23, 2013

How 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 ....

View 4 Replies View Related

C++ :: Print Score In SDL With OpenGL Using Ostream?

Mar 5, 2013

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.

View 1 Replies View Related

C++ :: Compile OpenGL Program In Ubuntu

Aug 15, 2014

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]....

View 6 Replies View Related

C++ :: Create 3D Game Engine With OpenGL?

Jul 19, 2013

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 Related

C++ :: OpenGL Preserve States (SFML)

Feb 12, 2013

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?

View 8 Replies View Related

C++ ::  Drawing Rectangular Prism OpenGL

Oct 10, 2013

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.

View 1 Replies View Related

C++ :: How To Make A Simple 3D Cube With OpenGL

Nov 26, 2013

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 ...

View 1 Replies View Related

C++ :: Segmentation Fault With OpenGL Tessellation

May 4, 2013

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.

View 2 Replies View Related

C++ :: Get OpenGL Working In Code Blocks?

Dec 28, 2013

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 Related

C++ :: OPENGL How To Load A Texture With Alpha Channel

Jun 27, 2014

I'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].....

View 2 Replies View Related

C/C++ :: Rendering OpenGL Inside Of Win32 Control?

Feb 22, 2015

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 Related

C/C++ :: Search Simple Window Library For OpenGL

Sep 7, 2014

I 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 Related

C/C++ :: Automatic Cast Object To OpenGL Handle / ID

Oct 24, 2014

I 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);

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved