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


ADVERTISEMENT

C++ :: How To Take A Screenshot Using WinAPI

Jul 2, 2012

I'm trying to learn how to take a screenshot using winAPI and c++.

this is what I have done so far.

Code:
#include <Windows.h>
#include <iostream>
using namespace std;
int main() {
HDC hScreenDC = GetDC(NULL);

[code]....

View 2 Replies View Related

C++ :: How To Take Screenshot And Save It In Image Format

Jul 31, 2014

I want to take screen shot and save it in any image format like jpg, bmp, ppm or any other .

View 3 Replies View Related

C# :: Button Taking To Another Page

Nov 12, 2014

I decided to code my own GUI menu. getting to another page from a button click. I have added the event handler I think (click="Button_click") then in the event handler I have added this:

private void Button_Click(object sender, System.EventArgs e);
}
Response.Redirect("Login.xaml");
}

After researching it says either to use
Response.Redirect("Login.xaml");
OR
Server.Transfer("Login.xaml");
Neither of these work, underlining "Response" and "Server" as an error saying "A namespace cannot directly contain members such as fields or methods."

NOTE: MY MAIN GUI PAGE IS CALLED "mainpage.xaml" THE CODE ABOVE IS STORED IN THE "mainpage.xaml.cs" THIS MIGHT BE RIGHT OR WRONG BUT I'M NOT SURE SO I AM LEAVING SOME EXTRA INFO!

View 1 Replies View Related

C++ :: Increment In Variable Not Taking Place

Oct 27, 2013

I have created this code; it is a taxi management system. I've made a class 'List' which handle a linked list structure of the waiting taxis and waiting passengers. The class has a public int variable: waiting, which keeps track of the number of waiting taxis/passengers.

#include<iostream>
using namespace std;
class Queue{ //Class for indivdual taxis and passengers, which will be members of linked list.
public:
string id;
Queue *next;
Queue (){

[Code] .....

But when I run the code and type in a new taxi number, the code does not increment the number of taxis by one the linked list by one. I can't seem to find the problem.

BTW, in the 'int main', I've added "<< taxi_list.waiting" at the end of the line after the user inputs the new taxi registration number, so that I can see how many taxis are now on the list. This is what is being shown as zero, no matter what.

View 2 Replies View Related

C++ :: Taking Input File And Doing Calculation

Dec 13, 2014

I am trying to work on a C++ program to calculate the quadratic formula using input files and classes. I have written my class, but I am trying to find a way to take an input file with unknown number of lines of coefficients. How do I take each integer from each line and set that value as "a" and "b" and so forth, then start over on the next line?

This is what i have so far.

fstream inputfile;//users input quadratic coefficients file
ofstream outputfile;// outputs a file with solutions
int main(int argc, char *argv[])// argc is argument count, char *argv[] is array of array of characters for arguments {
string dataline;
getline(inputfile, dataline);

[code].....

View 1 Replies View Related

C++ :: Class Taking Integers Or Doubles

Nov 18, 2014

Ok so I have a class that takes integer fractions and I want it to be able to take doubles also depending on what the user inputs. How would I go about this? I was thinking templates ...

View 7 Replies View Related

C/C++ :: Taking True Bool And Having It Display Statement Instead Of 1 Or 0

Dec 4, 2014

I am again a bit confused with bool since we have not used them much. I understand it is suppose to return a true or false value that is represented by 0 and 1. so I have these two bool's

bool Triangle::isRight() {
if (pow(largestSide(), 2) == (pow(smallestSide(), 2) + (pow(middleSide(), 2)))) {
return true;
} else {
return false;

[Code] ....

and then I cout to display them

cout << "Is this a right triangle: " << t2.isRight() << endl;
cout << "is this a Triangle: " << t2.isTriangle() << endl;

and i get this
"Is this a right triangle: " 0
"Is this a triangle: " 1

Which i know is correct but I want to replace the 1 and 0 with my own string but the things iv tried tweaking with has not worked.

Also in the file attached has some requirements from my teacher but i was confused at the second last one, --- bool isEqual(Triangle &other) and it says return true if triangles are equal and false if triangles are not.

I dont know if this is just simply if one triangle equals another (however you determine that) or if its for the two bool's, isTriangle() and isRight() or what.

Attached image(s)

View 2 Replies View Related

C/C++ :: Taking In File Path Names From User

Jul 22, 2014

How can I take in a path name like "C:myfolderfile.txt" where the user enters exactly that? I've tried putting the arg into a string, then looping through the string to find the '\', but by that time it is too late as c++ considers the '' as a escape character.

Is this even possible? I've googled it and everyone just says to make the user input the path with double \ or with a /.

View 1 Replies View Related

Visual C++ :: Taking Decimal Input From The User

Feb 21, 2015

I want the input for the price in decimal format(15.00). If the input is in integer format then I want to convert it to decimal format.

The maximum price for a sale is 999.99 and minimum is 0.00.

I have tried so far:

Code:
#include<iostream>
using std::cout;
using std::cin;
void main(){
float eventPrice;

[Code] .....

A valid input will be:

1.8,
0.8,
0.00,
0,
9,
99

View 2 Replies View Related

C++ :: Coin Program Not Taking In Amount Of Cents In Input

Mar 1, 2013

I'm currently working on a program to take the user's input as DDDD.CC and then converting it to the least amount of coins using quarters, dimes, nickels, and pennies. I was told to not use any doubles or floats as they would produce errors. And supposed to the use the library function atoi() after I take the input user's amount as a string to convert it into an integer.

So far the string input has worked and it produced the right number of quarters but it leaves off the cents. For example, I put in 352.23 and it gives the right amount of quarters but leaves off the 23 cents.here's my code:

#include <iostream> // Allows the program to perform input and output
#include <stdlib.h> // Atoi
#include <string>
using namespace std ; // Enables a program to use all the names in any Standard C++ header
int main() // Start of program execution {
string line ;

[code]....

View 6 Replies View Related

C++ :: Taking Data From Files And Output Information To Another File

Apr 2, 2014

Whenever I run my program, It should be taking this string of information:

Shampoo 10 8.75 87.50
Pen 3 2.50 7.50
Headphones 5 20.99 104.95
MacAir 1 879.23 879.23

Raspberries 6 4.99 29.94
Oranges 5 2.79 13.95
Apples 3 3.85 11.55

From one file and outputting it to another, the finished product should look like:

Shampoo 10 8.75 87.50
Pen 3 2.50 7.50
Headphones 5 20.99 104.95
MacAir 1 879.23 879.23

cheapest item = Pen
most expensive item = MacAir
total cost = 1079.18
shopper = Mary Kay

Raspberries 6 4.99 29.94
Oranges 5 2.79 13.95
Apples 3 3.85 11.55

cheapest item = Oranges
most expensive item = Raspberries
total cost = 55.44
shopper = Winnie B. The Pooh

When I run my code however, it doesn't get past shampoo and will continue to add shampoo to the total cost infinitely. How can I change the code to produce the proper information?

CODE:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <float.h>
#include <sstream>
#include <string>
using namespace std;
ifstream input_file;
ofstream output_file;

[Code] ....

View 1 Replies View Related

C++ :: Dispatch Message Taking Frames Away While Moving Window

Oct 29, 2014

lets start with the code:

while(run)
{
if (PeekMessage(&msg, win->win_handle,0,0,PM_REMOVE))
{

[Code]......

I have created a basic window and i discovered that while resizing or moving my windows, the myframe() don't get any calls at all.

Is there anyway possible that myframe gets at least someof the calls while those things are happening

View 1 Replies View Related

C/C++ :: Template Class Function Taking A Derived And Generic Object

Feb 23, 2014

I'm trying to write a function for receiving messages, so my classes can communicate with each other. The only issue I get is a compile error asking me to define the base parameter as one of the derived instances. I tried using a void* to fill the need, but then I lose the initial type, which I need to check for. How might I go about writing a generic object for this?

Here's my code:

template<class Object>
class State
{
public:

[Code].....

Should I just have all of the objects inherit in the order of Object >> GenericObject >> DerivedObject?

View 10 Replies View Related

C/C++ :: Error C2064 / Term Does Not Evaluate To A Function Taking 1 Arguments

Aug 7, 2014

i'm implementing a templated function callback.

I get this error:

"error C2064: term does not evaluate to a function taking 1 arguments"

I'm not sure why.

Here's the code for the template function in the timer class header:

template<class T>
void TimerEvent(DateAndTime DateTime, std::function<void(T)> Callback);

Now the class body:

template<class T>
void GameTimer::TimerEvent(DateAndTime DateTime, std::function<void(T)> Callback)
{
DateAndTime time;
time.Now(false);
if (time.Compare(DateTime) == 1)
Callback(T);
}

and calling the class in the Engine:

int test1(int a)
{
}
void Main()
{
gameTime.TimerEvent<int>(gh, test1(1));
}

View 6 Replies View Related

C/C++ :: Check Rational Or Irrational Numbers After Taking Square Root?

Aug 4, 2014

I tried to check the rational or irrational numbers after we take the square root. i dont get the formula. for eg. squareroot of 64 is 8 and it is rational. square root of 2 is irrational. how to check it in c++..

View 10 Replies View Related

C++ :: Quantlib / Error C2064 - Term Does Not Evaluate To A Function Taking 1 Arguments

Dec 8, 2014

The first call of my function works with empty vectors but fails when dimensions are introduced to the vectors.

When "uncommented, the commented out function call fails with the error above.

These links might be useful for those unfamiliar to QuantLib:

[URL]

QuantLib: GeneralLinearLeastSquares Class Reference

Code:
#include "stdafx.h"
#include "boost/multi_array.hpp"
#include <cassert>
#include <qlmathgenerallinearleastsquares.hpp>
#include <vector>
#include <list>
#include <iostream>
#include "boostlambdalambda.hpp"

[code]....

View 8 Replies View Related

C++ :: Debug Error When Taking A String And Casting It To Float With File Stream

May 9, 2014

Debug Error

ProjectsFinal ProjectGrItemDebugGrItem.exe

R6010 - abort() has been called

I was going over this with a friend and it seems as though getline() is not reading anything in and thus throwing the abort error. I'm not sure why this is because I've included the textfile, with the correct name of course, in both the regular file location and the debug folder. I ask for user input and the user then inputs the name of the file they want, I do some required things behind the scenes and display the results for them in a cmd window. I've included pastebin files for both my header and cpp files because it is far to large for one post I shall, however, post the full code in the comments.

Quick Code

The problem occurs on line 159. I'm assuming once this line is fixed, line 163 will have the same problem.

// Read regular price
getline(nameFile, input, '$');
vectorList[count].regPrice = stof(input.c_str());// Casts string to a float
// Read sale price
getline(nameFile, input, '#');
vectorList[count].salePrice = stof(input.c_str());

Pastebin Links : [URL] ....

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++ :: 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







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