?
Solved

C# + DirectX

Posted on 2004-03-22
4
Medium Priority
?
334 Views
Last Modified: 2008-02-01
Hey
Do u know anything in DirectX

this is my code and its generating error
localDevice.SetDisplayMode(1024, 768, 16, 0, false);
localDevice.SetCooperativeLevel(owner, CooperativeLevelFlags.Fullscreen);

and it gives me error

Values do not fall within expected range

what do u think is the prob

thanks
0
Comment
Question by:Pushkar_00
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 4

Expert Comment

by:Jarodtweiss
ID: 10652045
Hey !
I'm just a beginner with Managed DirectX but for info :

public void SetDisplayMode(
    int width,
    int height,
    int bitPerPixel,
    int refreshRate,
    bool standardVgaMode
);

So I bet your problem comes from your 0 --> try 60 for example, standard refresh rate !
0
 

Accepted Solution

by:
RafeWoo earned 80 total points
ID: 10656452
Hi,

I think passing in 0 as the refresh rate just uses the default refresh rate of your monitor. Anyway my program works just fine passing in zero.

It could be that your graphics card does not support 1024x768 at 16 bit.

As a quick test try 640X480 at 32 bits.

Failing that try enumerating the modes that your card does support:


DisplayModesCollection modes = new DisplayModesCollection(localDevice);
           
foreach(SurfaceDescription desc in modes)
{
  //harvest the information in some way
   //relevant fields are desc.Width , desc.Height , desc.PixelFormatStructure.RgbBitCount                
}
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question